Loading include/MD.h 0 → 100644 +41 −0 Original line number Diff line number Diff line #ifndef _MD_h #define _MD_h #include <stdio.h> #include <stdarg.h> #include <unistd.h> #include <errno.h> #include <time.h> #include <vector> #include <string> #include <cstring> #include <vector> #include <iostream> #include <fstream> #include <math.h> #include <sstream> #include <stdlib.h> #include <algorithm> #include <numeric> typedef struct{ int id, type; double x, y, z; vector<double> vars; }Atom_t; typedef struct { int timestep; int atoms; real8 box[6]; vector<string> bounds; vector<string> variables; vector<Atom_t> atom; }MgData_t; void HandleExtendedDislocation_MD(InArgs_t *inArgs); #endif include/ProDataIO.h +1 −1 Original line number Diff line number Diff line Loading @@ -23,7 +23,7 @@ #include "MD.h" int ReadTecplotNormalData(string &file, Table_t &table); int ReadTecplotNormalData(string &file, Table_t &table, string &secLine); void WriteTecplotNormalData(const LineList_t &list, const string &file, double precision = 6); int ReadMGDataFile(const string &file, MgData_t &mgdata); Loading src/HandleExtendedDislocation.cpp +120 −75 Original line number Diff line number Diff line Loading @@ -21,16 +21,17 @@ void HandleExtendedDislocation_DDD(InArgs_t *inArgs) real8 cubel = 20000, boundMin[3], boundMax[3]; real8 remeshSize = 20.0, burgID1 = 7, burgID2 = 12; real8 rd, yi1, yj1, yk2, yk3, s; int index, i, j, k; int index, i, j, k, file, iPos; int colX, colY, colBurgID; string cubelName = "cubel", burgIDName = "burgID", remeshSizeName = "rsize"; string fileName; real8 separation = 0.0; string fileName, secLine, fdir, curDir("./"), fname, aveFile; real8 separation = 0.0, position = 0.0; Point_t p; vector<Point_t> points1, points2; Curve_t curve1, curve2; LineList_t list; vector<string> words; vector<real8> seq; vector<vector<double> > data(7); Loading @@ -47,6 +48,15 @@ void HandleExtendedDislocation_DDD(InArgs_t *inArgs) } printf("The cubel size is %f\n", cubel); if(inArgs->outFiles.size() < 2){ aveFile = "Ave.plt"; }else{ aveFile = inArgs->outFiles[1]; } ofstream out; out.open(aveFile.c_str(), ios::out); out << "variables = timeNow, separation, position" << endl; boundMin[0] = -0.5*cubel; boundMin[1] = -0.5*cubel; boundMin[2] = -0.5*cubel; Loading @@ -68,7 +78,13 @@ void HandleExtendedDislocation_DDD(InArgs_t *inArgs) } printf("The remesh size is %f\n", remeshSize); ReadTecplotNormalData(inArgs->inpFiles[0], table); for(file=0; file<inArgs->inpFiles.size(); file++){ vector<string>().swap(table.variables); ReadTecplotNormalData(inArgs->inpFiles[file], table, secLine); vector<string>().swap(words); words = split(secLine, "\""); if(table.data.size() < 2)Fatal("the data size is %d", table.data.size()); Loading @@ -76,6 +92,8 @@ void HandleExtendedDislocation_DDD(InArgs_t *inArgs) colY = GetColIDFromTable(table, "Y"); colBurgID = GetColIDFromTable(table, "burgID"); vector<Point_t>().swap(points1); vector<Point_t>().swap(points2); p.x = 1.0E10; p.y = 1.0E10; for(i=0; i<table.data.size(); i++){ if(p.x == table.data[i][colX] && Loading Loading @@ -110,18 +128,26 @@ void HandleExtendedDislocation_DDD(InArgs_t *inArgs) curve2.ay[i] = points2[i].y; } vector<double>().swap(seq); seq = GenerateSequence(boundMin[0], boundMax[0], remeshSize); data[0].assign(seq.begin(), seq.end()); for(i=1; i<data.size(); i++) data[i].resize(data[0].size()); data.resize(7); for(i=0; i<data.size(); i++) data[i].resize(seq.size()); for(i=0; i<seq.size(); i++){ data[0][i] = seq[i]; } separation = 0.0; position = 0.0; for(i=0; i<seq.size(); i++){ data[1][i] = LinearInterpolation(curve1, seq[i], boundMin[0], boundMax[0]); data[2][i] = LinearInterpolation(curve2, seq[i], boundMin[0], boundMax[0]); data[3][i] = 0.5 * (data[1][i] + data[2][i]); separation += fabs(data[1][i] - data[2][i]); position += data[3][i]; } separation /= ((double)seq.size()); position /= ((double)seq.size()); for(i=0; i<seq.size(); i++){ data[4][i] = 0.0; Loading @@ -147,7 +173,26 @@ void HandleExtendedDislocation_DDD(InArgs_t *inArgs) swap(list.data, data); fileName = inArgs->outFiles[0]; iPos = inArgs->inpFiles[file].find_last_of('/'); if(iPos == string::npos){ fdir = curDir; fname = inArgs->inpFiles[file]; }else{ fdir = curDir + inArgs->inpFiles[file].substr(0,iPos); fname = inArgs->inpFiles[file].substr(iPos+1); } fileName += "-"; fileName += fname; WriteTecplotNormalData(list, fileName, 10); vector<vector<double> >().swap(list.data); out << words[1] << " "; out << setprecision(10) << separation << " "; out << setprecision(10) << position << endl; } return; } Loading src/Main.cpp +2 −0 Original line number Diff line number Diff line Loading @@ -282,6 +282,8 @@ static void GetInArgs(int argc, char *argv[], InArgs_t *inArgs) } } swap(bakInps, inArgs->inpFiles); sort(inArgs->inpFiles.begin(), inArgs->inpFiles.end()); if(inArgs->inpFiles.size()>1){ printf("Input files are:\n"); for(i=0; i<inArgs->inpFiles.size(); i++){ Loading src/Math.cpp +2 −2 Original line number Diff line number Diff line Loading @@ -14,7 +14,7 @@ void AverageLines(InArgs_t *inArgs) int record = 0; real8 rsize = 20, min, max; string rsizeName("rsize"), varsName("vars"), recordName("record"); string xName("X"), yName("Y"), str("Ave_"); string xName("X"), yName("Y"), str("Ave_"), secLine; LineList_t list; Curve_t curve; Loading Loading @@ -43,7 +43,7 @@ void AverageLines(InArgs_t *inArgs) printf("The Record (record) state is %d\n", record); for(i=0; i<inArgs->inpFiles.size(); i++){ ReadTecplotNormalData(inArgs->inpFiles[i], tables[i]); ReadTecplotNormalData(inArgs->inpFiles[i], tables[i], secLine); if(i == 0){ colX = GetColIDFromTable(tables[i], xName); colY = GetColIDFromTable(tables[i], yName); Loading Loading
include/MD.h 0 → 100644 +41 −0 Original line number Diff line number Diff line #ifndef _MD_h #define _MD_h #include <stdio.h> #include <stdarg.h> #include <unistd.h> #include <errno.h> #include <time.h> #include <vector> #include <string> #include <cstring> #include <vector> #include <iostream> #include <fstream> #include <math.h> #include <sstream> #include <stdlib.h> #include <algorithm> #include <numeric> typedef struct{ int id, type; double x, y, z; vector<double> vars; }Atom_t; typedef struct { int timestep; int atoms; real8 box[6]; vector<string> bounds; vector<string> variables; vector<Atom_t> atom; }MgData_t; void HandleExtendedDislocation_MD(InArgs_t *inArgs); #endif
include/ProDataIO.h +1 −1 Original line number Diff line number Diff line Loading @@ -23,7 +23,7 @@ #include "MD.h" int ReadTecplotNormalData(string &file, Table_t &table); int ReadTecplotNormalData(string &file, Table_t &table, string &secLine); void WriteTecplotNormalData(const LineList_t &list, const string &file, double precision = 6); int ReadMGDataFile(const string &file, MgData_t &mgdata); Loading
src/HandleExtendedDislocation.cpp +120 −75 Original line number Diff line number Diff line Loading @@ -21,16 +21,17 @@ void HandleExtendedDislocation_DDD(InArgs_t *inArgs) real8 cubel = 20000, boundMin[3], boundMax[3]; real8 remeshSize = 20.0, burgID1 = 7, burgID2 = 12; real8 rd, yi1, yj1, yk2, yk3, s; int index, i, j, k; int index, i, j, k, file, iPos; int colX, colY, colBurgID; string cubelName = "cubel", burgIDName = "burgID", remeshSizeName = "rsize"; string fileName; real8 separation = 0.0; string fileName, secLine, fdir, curDir("./"), fname, aveFile; real8 separation = 0.0, position = 0.0; Point_t p; vector<Point_t> points1, points2; Curve_t curve1, curve2; LineList_t list; vector<string> words; vector<real8> seq; vector<vector<double> > data(7); Loading @@ -47,6 +48,15 @@ void HandleExtendedDislocation_DDD(InArgs_t *inArgs) } printf("The cubel size is %f\n", cubel); if(inArgs->outFiles.size() < 2){ aveFile = "Ave.plt"; }else{ aveFile = inArgs->outFiles[1]; } ofstream out; out.open(aveFile.c_str(), ios::out); out << "variables = timeNow, separation, position" << endl; boundMin[0] = -0.5*cubel; boundMin[1] = -0.5*cubel; boundMin[2] = -0.5*cubel; Loading @@ -68,7 +78,13 @@ void HandleExtendedDislocation_DDD(InArgs_t *inArgs) } printf("The remesh size is %f\n", remeshSize); ReadTecplotNormalData(inArgs->inpFiles[0], table); for(file=0; file<inArgs->inpFiles.size(); file++){ vector<string>().swap(table.variables); ReadTecplotNormalData(inArgs->inpFiles[file], table, secLine); vector<string>().swap(words); words = split(secLine, "\""); if(table.data.size() < 2)Fatal("the data size is %d", table.data.size()); Loading @@ -76,6 +92,8 @@ void HandleExtendedDislocation_DDD(InArgs_t *inArgs) colY = GetColIDFromTable(table, "Y"); colBurgID = GetColIDFromTable(table, "burgID"); vector<Point_t>().swap(points1); vector<Point_t>().swap(points2); p.x = 1.0E10; p.y = 1.0E10; for(i=0; i<table.data.size(); i++){ if(p.x == table.data[i][colX] && Loading Loading @@ -110,18 +128,26 @@ void HandleExtendedDislocation_DDD(InArgs_t *inArgs) curve2.ay[i] = points2[i].y; } vector<double>().swap(seq); seq = GenerateSequence(boundMin[0], boundMax[0], remeshSize); data[0].assign(seq.begin(), seq.end()); for(i=1; i<data.size(); i++) data[i].resize(data[0].size()); data.resize(7); for(i=0; i<data.size(); i++) data[i].resize(seq.size()); for(i=0; i<seq.size(); i++){ data[0][i] = seq[i]; } separation = 0.0; position = 0.0; for(i=0; i<seq.size(); i++){ data[1][i] = LinearInterpolation(curve1, seq[i], boundMin[0], boundMax[0]); data[2][i] = LinearInterpolation(curve2, seq[i], boundMin[0], boundMax[0]); data[3][i] = 0.5 * (data[1][i] + data[2][i]); separation += fabs(data[1][i] - data[2][i]); position += data[3][i]; } separation /= ((double)seq.size()); position /= ((double)seq.size()); for(i=0; i<seq.size(); i++){ data[4][i] = 0.0; Loading @@ -147,7 +173,26 @@ void HandleExtendedDislocation_DDD(InArgs_t *inArgs) swap(list.data, data); fileName = inArgs->outFiles[0]; iPos = inArgs->inpFiles[file].find_last_of('/'); if(iPos == string::npos){ fdir = curDir; fname = inArgs->inpFiles[file]; }else{ fdir = curDir + inArgs->inpFiles[file].substr(0,iPos); fname = inArgs->inpFiles[file].substr(iPos+1); } fileName += "-"; fileName += fname; WriteTecplotNormalData(list, fileName, 10); vector<vector<double> >().swap(list.data); out << words[1] << " "; out << setprecision(10) << separation << " "; out << setprecision(10) << position << endl; } return; } Loading
src/Main.cpp +2 −0 Original line number Diff line number Diff line Loading @@ -282,6 +282,8 @@ static void GetInArgs(int argc, char *argv[], InArgs_t *inArgs) } } swap(bakInps, inArgs->inpFiles); sort(inArgs->inpFiles.begin(), inArgs->inpFiles.end()); if(inArgs->inpFiles.size()>1){ printf("Input files are:\n"); for(i=0; i<inArgs->inpFiles.size(); i++){ Loading
src/Math.cpp +2 −2 Original line number Diff line number Diff line Loading @@ -14,7 +14,7 @@ void AverageLines(InArgs_t *inArgs) int record = 0; real8 rsize = 20, min, max; string rsizeName("rsize"), varsName("vars"), recordName("record"); string xName("X"), yName("Y"), str("Ave_"); string xName("X"), yName("Y"), str("Ave_"), secLine; LineList_t list; Curve_t curve; Loading Loading @@ -43,7 +43,7 @@ void AverageLines(InArgs_t *inArgs) printf("The Record (record) state is %d\n", record); for(i=0; i<inArgs->inpFiles.size(); i++){ ReadTecplotNormalData(inArgs->inpFiles[i], tables[i]); ReadTecplotNormalData(inArgs->inpFiles[i], tables[i], secLine); if(i == 0){ colX = GetColIDFromTable(tables[i], xName); colY = GetColIDFromTable(tables[i], yName); Loading