Loading include/Home.h +1 −0 Original line number Diff line number Diff line Loading @@ -33,6 +33,7 @@ typedef struct { double burgMag; int seed; int type; bool help; vector<string> inpFiles, outFiles; vector<string> auxFiles; Loading src/HandleExtendedDislocation.cpp +11 −7 Original line number Diff line number Diff line Loading @@ -84,6 +84,7 @@ void HandleExtendedDislocation_DDD(InArgs_t *inArgs) remeshSize = atof(inArgs->priVars[index].vals[0].c_str()); } printf("The remesh size is %f\n", remeshSize); if(inArgs->help)return; for(file=0; file<inArgs->inpFiles.size(); file++){ Loading Loading @@ -296,7 +297,7 @@ void HandleExtendedDislocation_MD(InArgs_t *inArgs) int nums[2] = {18, 24}, logfile; int stepID; double cutofflen = 2.556, alpha = 0.005, beta = 1.0; double position[3], separation; double position[3], separation, dis, maxDis; MgData_t mg; LineList_t list; double dir[3] = {0, 1, 0}, p0[3], dval=5; Loading Loading @@ -347,7 +348,7 @@ void HandleExtendedDislocation_MD(InArgs_t *inArgs) dir[2] = atof(inArgs->priVars[index].vals[2].c_str()); NormalizeVec(dir); } printf("The moving direction of probe is along %f, %f, %f\n", dir[0], dir[1], dir[2]); printf("The moving direction of probe (dir) is along %f, %f, %f\n", dir[0], dir[1], dir[2]); if((index = GetValID(inArgs->priVars, numsName)) < inArgs->priVars.size()){ if(inArgs->priVars[index].vals.size() == 2){ Loading @@ -355,7 +356,9 @@ void HandleExtendedDislocation_MD(InArgs_t *inArgs) nums[1] = atoi(inArgs->priVars[index].vals[1].c_str()); } } printf("The parameters (para): cut-off length %f and resolution value %f\n", cutofflen, alpha); printf("The range of effective atoms of a paritial (nums) is [%d,%d]\n", nums[0], nums[1]); if(inArgs->help)return; logfile = ReadDataFromMDLogFile(inArgs->auxFiles, list); for(file=0; file<inArgs->inpFiles.size(); file++){ Loading @@ -378,7 +381,6 @@ void HandleExtendedDislocation_MD(InArgs_t *inArgs) (*it).z > mg.box[4] + (mg.box[5]-mg.box[4])*0.95){ if(mg.atom[i].vars[indexVar] == dval){ // vector<double>().swap(mg.atom[i].vars); mg.atom.erase(it); } } Loading Loading @@ -413,15 +415,17 @@ void HandleExtendedDislocation_MD(InArgs_t *inArgs) lastIndex = 0; while(1){ vector<Atom_t *>().swap(probe.nbr); probe.x += (dir[0]*d*cutofflen*alpha); probe.y += (dir[1]*d*cutofflen*alpha); probe.z += (dir[2]*d*cutofflen*alpha); firstNbr = 1; maxDis = -1E10; for(i=lastIndex; i<mg.atom.size(); i++){ if((pow((mg.atom[i].y-probe.y), 2) + pow((mg.atom[i].z-probe.z), 2) < cutofflen*cutofflen) && mg.atom[i].vars[indexVar] == dval){ dis = sqrt(pow((mg.atom[i].y-probe.y), 2) + pow((mg.atom[i].z-probe.z), 2) ); if(dis < cutofflen && mg.atom[i].vars[indexVar] == dval){ if(firstNbr){ lastIndex = i; firstNbr = 0; Loading src/Main.cpp +5 −10 Original line number Diff line number Diff line Loading @@ -65,11 +65,6 @@ Option_t optList[OPT_MAX] = { *-------------------------------------------------------------------------*/ static void Usage(char *program) { printf("\n"); printf("Usage:\n"); printf("\n"); printf("\n"); return; } Loading @@ -93,11 +88,8 @@ static void PrintHelp(char *program) printf(" Options may be abbreviated to the shortest non-ambiguous\n"); printf("\n"); exit(0); } /*--------------------------------------------------------------------------- * * Function: InitDefaultValues Loading @@ -110,6 +102,7 @@ static void InitDefaultValues(InArgs_t *inArgs) inArgs->outFiles.push_back((char*)"output"); inArgs->seed = time(0) + getpid(); inArgs->type = 0; inArgs->help = 0; return; } Loading Loading @@ -235,7 +228,8 @@ static void GetInArgs(int argc, char *argv[], InArgs_t *inArgs) switch (j) { case OPT_HELP: PrintHelp(argv[0]); exit(0); inArgs->help = 1; break; case OPT_INPFILE: swap(inArgs->inpFiles, argValues); break; Loading Loading @@ -263,6 +257,7 @@ static void GetInArgs(int argc, char *argv[], InArgs_t *inArgs) } #if 0 if(inArgs->priVars.size()>0){ printf("Private vars for type %d:\n", inArgs->type); for(i=0; i<inArgs->priVars.size(); i++){ Loading @@ -273,7 +268,7 @@ static void GetInArgs(int argc, char *argv[], InArgs_t *inArgs) printf("\n"); } } #endif strs.resize(inArgs->inpFiles.size()); for(i=0; i<inArgs->inpFiles.size(); i++){ Loading src/Math.cpp +76 −56 Original line number Diff line number Diff line Loading @@ -11,15 +11,17 @@ using namespace std; void AverageLines(InArgs_t *inArgs) { int index, i, j, k, colX, colY; int record = 0, readState; real8 rsize = 20, min, max; string rsizeName("rsize"), varsName("vars"), recordName("record"); string xName("X"), yName("Y"), str("Ave_"), secLine; int readState; bool firstFile = 1; real8 rsize = 20, min, max, effNums; string rsizeName("rsize"), varsName("vars"); string str("Ave_"), secLine; LineList_t list; Curve_t curve; vector<real8> seq, yVals, aveVals; vector<int> varID; vector<real8> seq; vector<Table_t> tables(inArgs->inpFiles.size()); vector<string> s1, s2; Loading @@ -29,18 +31,22 @@ void AverageLines(InArgs_t *inArgs) printf("The remesh size (rsize) is %f\n", rsize); if((index = GetValID(inArgs->priVars, varsName)) < inArgs->priVars.size()){ if(inArgs->priVars[index].vals.size() == 2){ xName = inArgs->priVars[index].vals[0]; yName = inArgs->priVars[index].vals[1]; if(inArgs->priVars[index].vals.size() < 2){ Fatal("variables is not enough for aveage line"); } } str += yName; printf("The variables (vars) are %s %s\n", xName.c_str(), yName.c_str()); if((index = GetValID(inArgs->priVars, recordName)) < inArgs->priVars.size()){ record = atoi(inArgs->priVars[index].vals[0].c_str()); list.variables.resize(inArgs->priVars[index].vals.size()); varID.resize(inArgs->priVars[index].vals.size()); printf("The variables (vars) are "); for(i=0; i<inArgs->priVars[index].vals.size(); i++){ list.variables[i] = inArgs->priVars[index].vals[i]; printf("%s ", list.variables[i].c_str()); } printf("The Record (record) state is %d\n", record); printf("\n"); } if(inArgs->help)return; if(inArgs->inpFiles.size() == 0){ Fatal("There is no input file."); Loading @@ -49,67 +55,81 @@ void AverageLines(InArgs_t *inArgs) for(i=0; i<inArgs->inpFiles.size(); i++){ readState = ReadTecplotNormalData(inArgs->inpFiles[i], tables[i], secLine); if(!readState)continue; if(i == 0){ colX = GetColIDFromTable(tables[i], xName); colY = GetColIDFromTable(tables[i], yName); effNums++; if(tables[i].data.size() < 2){ Fatal("The size of file %s is wrong", inArgs->inpFiles[i].c_str()); } if(firstFile){ if(list.variables.size()==0){ list.variables.resize(tables[i].variables.size()); varID.resize(list.variables.size()); printf("The average variables (vars) are: "); for(j=0; j<tables[i].variables.size(); j++){ list.variables[j] = tables[i].variables[j]; printf("%s ",list.variables[j].c_str()); } printf("\n"); } min = tables[i].data[0][colX]; max = tables[i].data[tables[i].data.size()-1][colX]; firstFile = 0; }else{ if(colX != GetColIDFromTable(tables[i], xName) || colY != GetColIDFromTable(tables[i], yName)){ Fatal("The format of file %s is not same as the first one", inArgs->inpFiles[i].c_str()); } if(min < tables[i].data[0][colX]) min = tables[i].data[0][colX]; if(max > tables[i].data[tables[i].data.size()-1][colX]){ max = tables[i].data[tables[i].data.size()-1][colX]; } } if(tables[i].data.size() < 2){ Fatal("The size of file %s is wrong", inArgs->inpFiles[i].c_str()); } } printf("The effective range of %s is [%f,%f]\n", list.variables[0].c_str(), min, max); seq = GenerateSequence(min, max, rsize); yVals.resize(seq.size()); aveVals.resize(seq.size()); list.data.resize(list.variables.size()); for(i=0; i<list.data.size(); i++){ list.data[i].resize(seq.size()); for(j=0; j<list.data[i].size(); j++)list.data[i][j] = 0.0; } for(i=0; i<seq.size(); i++){ aveVals[i] = 0.0; list.data[0][i] = seq[i]; } list.variables.push_back(xName); list.data.push_back(seq); for(i=0; i<tables.size(); i++){ if(tables[i].data.size()==0)continue; for(i=0; i<inArgs->inpFiles.size(); i++){ for(j=0; j<varID.size(); j++){ varID[j] = GetColIDFromTable(tables[i], list.variables[j]); if(varID[j] == tables[i].variables.size()){ Fatal("there is no %s in the file %s ", list.variables[j].c_str(), inArgs->inpFiles[i].c_str()); } if(j==0){ curve.ax.resize(tables[i].data.size()); curve.ay.resize(tables[i].data.size()); for(j=0; j<curve.ax.size(); j++){ curve.ax[j] = tables[i].data[j][colX]; curve.ay[j] = tables[i].data[j][colY]; for(k=0; k<curve.ax.size(); k++){ curve.ax[k] = tables[i].data[k][varID[j]]; } }else{ for(k=0; k<curve.ax.size(); k++){ curve.ay[k] = tables[i].data[k][varID[j]]; } for(j=0; j<seq.size(); j++){ yVals[j] = LinearInterpolation(curve, seq[j], min, max); aveVals[j] += yVals[j]; for(k=0; k<seq.size(); k++){ list.data[j][k] += LinearInterpolation(curve, seq[k], min, max); } } list.data.push_back(yVals); if(record){ s1 = split(inArgs->inpFiles[i], "/"); s2 = split(s1.back(), "."); list.variables.push_back(s2.front()); list.data.push_back(yVals); } } list.variables.push_back(str); for(j=0; j<seq.size(); j++){ aveVals[j] /= ((double)inArgs->inpFiles.size()); for(i=1; i<list.data.size(); i++){ for(j=0; j<list.data[i].size(); j++){ list.data[i][j] /= effNums; } } list.data.push_back(aveVals); WriteTecplotNormalData(list, inArgs->outFiles[0], 10); Loading src/ReadData.cpp +1 −1 Original line number Diff line number Diff line Loading @@ -53,7 +53,7 @@ int ReadTecplotNormalData(string &file, Table_t &table, string &secLine) j++; } infile.close(); printf("Finsish reading input file %s\n", file.c_str()); // printf("Finsish reading input file %s\n", file.c_str()); return 1; } Loading Loading
include/Home.h +1 −0 Original line number Diff line number Diff line Loading @@ -33,6 +33,7 @@ typedef struct { double burgMag; int seed; int type; bool help; vector<string> inpFiles, outFiles; vector<string> auxFiles; Loading
src/HandleExtendedDislocation.cpp +11 −7 Original line number Diff line number Diff line Loading @@ -84,6 +84,7 @@ void HandleExtendedDislocation_DDD(InArgs_t *inArgs) remeshSize = atof(inArgs->priVars[index].vals[0].c_str()); } printf("The remesh size is %f\n", remeshSize); if(inArgs->help)return; for(file=0; file<inArgs->inpFiles.size(); file++){ Loading Loading @@ -296,7 +297,7 @@ void HandleExtendedDislocation_MD(InArgs_t *inArgs) int nums[2] = {18, 24}, logfile; int stepID; double cutofflen = 2.556, alpha = 0.005, beta = 1.0; double position[3], separation; double position[3], separation, dis, maxDis; MgData_t mg; LineList_t list; double dir[3] = {0, 1, 0}, p0[3], dval=5; Loading Loading @@ -347,7 +348,7 @@ void HandleExtendedDislocation_MD(InArgs_t *inArgs) dir[2] = atof(inArgs->priVars[index].vals[2].c_str()); NormalizeVec(dir); } printf("The moving direction of probe is along %f, %f, %f\n", dir[0], dir[1], dir[2]); printf("The moving direction of probe (dir) is along %f, %f, %f\n", dir[0], dir[1], dir[2]); if((index = GetValID(inArgs->priVars, numsName)) < inArgs->priVars.size()){ if(inArgs->priVars[index].vals.size() == 2){ Loading @@ -355,7 +356,9 @@ void HandleExtendedDislocation_MD(InArgs_t *inArgs) nums[1] = atoi(inArgs->priVars[index].vals[1].c_str()); } } printf("The parameters (para): cut-off length %f and resolution value %f\n", cutofflen, alpha); printf("The range of effective atoms of a paritial (nums) is [%d,%d]\n", nums[0], nums[1]); if(inArgs->help)return; logfile = ReadDataFromMDLogFile(inArgs->auxFiles, list); for(file=0; file<inArgs->inpFiles.size(); file++){ Loading @@ -378,7 +381,6 @@ void HandleExtendedDislocation_MD(InArgs_t *inArgs) (*it).z > mg.box[4] + (mg.box[5]-mg.box[4])*0.95){ if(mg.atom[i].vars[indexVar] == dval){ // vector<double>().swap(mg.atom[i].vars); mg.atom.erase(it); } } Loading Loading @@ -413,15 +415,17 @@ void HandleExtendedDislocation_MD(InArgs_t *inArgs) lastIndex = 0; while(1){ vector<Atom_t *>().swap(probe.nbr); probe.x += (dir[0]*d*cutofflen*alpha); probe.y += (dir[1]*d*cutofflen*alpha); probe.z += (dir[2]*d*cutofflen*alpha); firstNbr = 1; maxDis = -1E10; for(i=lastIndex; i<mg.atom.size(); i++){ if((pow((mg.atom[i].y-probe.y), 2) + pow((mg.atom[i].z-probe.z), 2) < cutofflen*cutofflen) && mg.atom[i].vars[indexVar] == dval){ dis = sqrt(pow((mg.atom[i].y-probe.y), 2) + pow((mg.atom[i].z-probe.z), 2) ); if(dis < cutofflen && mg.atom[i].vars[indexVar] == dval){ if(firstNbr){ lastIndex = i; firstNbr = 0; Loading
src/Main.cpp +5 −10 Original line number Diff line number Diff line Loading @@ -65,11 +65,6 @@ Option_t optList[OPT_MAX] = { *-------------------------------------------------------------------------*/ static void Usage(char *program) { printf("\n"); printf("Usage:\n"); printf("\n"); printf("\n"); return; } Loading @@ -93,11 +88,8 @@ static void PrintHelp(char *program) printf(" Options may be abbreviated to the shortest non-ambiguous\n"); printf("\n"); exit(0); } /*--------------------------------------------------------------------------- * * Function: InitDefaultValues Loading @@ -110,6 +102,7 @@ static void InitDefaultValues(InArgs_t *inArgs) inArgs->outFiles.push_back((char*)"output"); inArgs->seed = time(0) + getpid(); inArgs->type = 0; inArgs->help = 0; return; } Loading Loading @@ -235,7 +228,8 @@ static void GetInArgs(int argc, char *argv[], InArgs_t *inArgs) switch (j) { case OPT_HELP: PrintHelp(argv[0]); exit(0); inArgs->help = 1; break; case OPT_INPFILE: swap(inArgs->inpFiles, argValues); break; Loading Loading @@ -263,6 +257,7 @@ static void GetInArgs(int argc, char *argv[], InArgs_t *inArgs) } #if 0 if(inArgs->priVars.size()>0){ printf("Private vars for type %d:\n", inArgs->type); for(i=0; i<inArgs->priVars.size(); i++){ Loading @@ -273,7 +268,7 @@ static void GetInArgs(int argc, char *argv[], InArgs_t *inArgs) printf("\n"); } } #endif strs.resize(inArgs->inpFiles.size()); for(i=0; i<inArgs->inpFiles.size(); i++){ Loading
src/Math.cpp +76 −56 Original line number Diff line number Diff line Loading @@ -11,15 +11,17 @@ using namespace std; void AverageLines(InArgs_t *inArgs) { int index, i, j, k, colX, colY; int record = 0, readState; real8 rsize = 20, min, max; string rsizeName("rsize"), varsName("vars"), recordName("record"); string xName("X"), yName("Y"), str("Ave_"), secLine; int readState; bool firstFile = 1; real8 rsize = 20, min, max, effNums; string rsizeName("rsize"), varsName("vars"); string str("Ave_"), secLine; LineList_t list; Curve_t curve; vector<real8> seq, yVals, aveVals; vector<int> varID; vector<real8> seq; vector<Table_t> tables(inArgs->inpFiles.size()); vector<string> s1, s2; Loading @@ -29,18 +31,22 @@ void AverageLines(InArgs_t *inArgs) printf("The remesh size (rsize) is %f\n", rsize); if((index = GetValID(inArgs->priVars, varsName)) < inArgs->priVars.size()){ if(inArgs->priVars[index].vals.size() == 2){ xName = inArgs->priVars[index].vals[0]; yName = inArgs->priVars[index].vals[1]; if(inArgs->priVars[index].vals.size() < 2){ Fatal("variables is not enough for aveage line"); } } str += yName; printf("The variables (vars) are %s %s\n", xName.c_str(), yName.c_str()); if((index = GetValID(inArgs->priVars, recordName)) < inArgs->priVars.size()){ record = atoi(inArgs->priVars[index].vals[0].c_str()); list.variables.resize(inArgs->priVars[index].vals.size()); varID.resize(inArgs->priVars[index].vals.size()); printf("The variables (vars) are "); for(i=0; i<inArgs->priVars[index].vals.size(); i++){ list.variables[i] = inArgs->priVars[index].vals[i]; printf("%s ", list.variables[i].c_str()); } printf("The Record (record) state is %d\n", record); printf("\n"); } if(inArgs->help)return; if(inArgs->inpFiles.size() == 0){ Fatal("There is no input file."); Loading @@ -49,67 +55,81 @@ void AverageLines(InArgs_t *inArgs) for(i=0; i<inArgs->inpFiles.size(); i++){ readState = ReadTecplotNormalData(inArgs->inpFiles[i], tables[i], secLine); if(!readState)continue; if(i == 0){ colX = GetColIDFromTable(tables[i], xName); colY = GetColIDFromTable(tables[i], yName); effNums++; if(tables[i].data.size() < 2){ Fatal("The size of file %s is wrong", inArgs->inpFiles[i].c_str()); } if(firstFile){ if(list.variables.size()==0){ list.variables.resize(tables[i].variables.size()); varID.resize(list.variables.size()); printf("The average variables (vars) are: "); for(j=0; j<tables[i].variables.size(); j++){ list.variables[j] = tables[i].variables[j]; printf("%s ",list.variables[j].c_str()); } printf("\n"); } min = tables[i].data[0][colX]; max = tables[i].data[tables[i].data.size()-1][colX]; firstFile = 0; }else{ if(colX != GetColIDFromTable(tables[i], xName) || colY != GetColIDFromTable(tables[i], yName)){ Fatal("The format of file %s is not same as the first one", inArgs->inpFiles[i].c_str()); } if(min < tables[i].data[0][colX]) min = tables[i].data[0][colX]; if(max > tables[i].data[tables[i].data.size()-1][colX]){ max = tables[i].data[tables[i].data.size()-1][colX]; } } if(tables[i].data.size() < 2){ Fatal("The size of file %s is wrong", inArgs->inpFiles[i].c_str()); } } printf("The effective range of %s is [%f,%f]\n", list.variables[0].c_str(), min, max); seq = GenerateSequence(min, max, rsize); yVals.resize(seq.size()); aveVals.resize(seq.size()); list.data.resize(list.variables.size()); for(i=0; i<list.data.size(); i++){ list.data[i].resize(seq.size()); for(j=0; j<list.data[i].size(); j++)list.data[i][j] = 0.0; } for(i=0; i<seq.size(); i++){ aveVals[i] = 0.0; list.data[0][i] = seq[i]; } list.variables.push_back(xName); list.data.push_back(seq); for(i=0; i<tables.size(); i++){ if(tables[i].data.size()==0)continue; for(i=0; i<inArgs->inpFiles.size(); i++){ for(j=0; j<varID.size(); j++){ varID[j] = GetColIDFromTable(tables[i], list.variables[j]); if(varID[j] == tables[i].variables.size()){ Fatal("there is no %s in the file %s ", list.variables[j].c_str(), inArgs->inpFiles[i].c_str()); } if(j==0){ curve.ax.resize(tables[i].data.size()); curve.ay.resize(tables[i].data.size()); for(j=0; j<curve.ax.size(); j++){ curve.ax[j] = tables[i].data[j][colX]; curve.ay[j] = tables[i].data[j][colY]; for(k=0; k<curve.ax.size(); k++){ curve.ax[k] = tables[i].data[k][varID[j]]; } }else{ for(k=0; k<curve.ax.size(); k++){ curve.ay[k] = tables[i].data[k][varID[j]]; } for(j=0; j<seq.size(); j++){ yVals[j] = LinearInterpolation(curve, seq[j], min, max); aveVals[j] += yVals[j]; for(k=0; k<seq.size(); k++){ list.data[j][k] += LinearInterpolation(curve, seq[k], min, max); } } list.data.push_back(yVals); if(record){ s1 = split(inArgs->inpFiles[i], "/"); s2 = split(s1.back(), "."); list.variables.push_back(s2.front()); list.data.push_back(yVals); } } list.variables.push_back(str); for(j=0; j<seq.size(); j++){ aveVals[j] /= ((double)inArgs->inpFiles.size()); for(i=1; i<list.data.size(); i++){ for(j=0; j<list.data[i].size(); j++){ list.data[i][j] /= effNums; } } list.data.push_back(aveVals); WriteTecplotNormalData(list, inArgs->outFiles[0], 10); Loading
src/ReadData.cpp +1 −1 Original line number Diff line number Diff line Loading @@ -53,7 +53,7 @@ int ReadTecplotNormalData(string &file, Table_t &table, string &secLine) j++; } infile.close(); printf("Finsish reading input file %s\n", file.c_str()); // printf("Finsish reading input file %s\n", file.c_str()); return 1; } Loading