Commit 39a6bd45 authored by DeAn Wei's avatar DeAn Wei
Browse files

tem-24.01.2019

parent 8cf05236
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@


int ReadTecplotNormalData(string &file, Table_t &table, string &secLine);
void WriteTecplotNormalData(const Table_t &table, const string &file, double precision); 
void    WriteTecplotNormalData(const LineList_t &list, const string &file,
                               double precision = 6);
int ReadMGDataFile(const string &file, MgData_t &mgdata);
+6 −0
Original line number Diff line number Diff line
@@ -21,6 +21,8 @@

#include "MD.h"

#define  NUMBER_DATA    0x0001
#define  CHAR_DATA      0x0002

typedef struct {
    double  x,y,z;    
@@ -43,4 +45,8 @@ void SwapTable(Table_t &table);
void SwapLineList(LineList_t &list);
void CleanMgData(MgData_t &mg);
void NormalizeVec(real8 vec[3]);
void StitchTecplotData(vector<Table_t> &tables, Table_t &table, int eigenID = 0);
int DataType(const string &str);


#endif
+69 −20
Original line number Diff line number Diff line
@@ -28,9 +28,9 @@ void HandleExtendedDislocation_DDD(InArgs_t *inArgs)
    real8           rd, yi1, yj1, yk2, yk3, s, absBakPos, bakPos, cyc;
    int             index,  i, j, k, file, iPos;
    int             colX, colY, colBurgID;
    bool            plu, min;
    bool            plu, min, logFile=0;
    string          cubelName = "cubel", burgIDName = "burgID", remeshSizeName = "rsize";  
    string          fileName, secLine, fdir, curDir("./"), fname, aveFile;
    string          fileName, secLine, fdir, curDir("./"), fname, aveFile, auxFile;
    real8           separation = 0.0, position = 0.0, position1, position2, timenow, dt;
    real8           pos1[3] = {0,0,0}, pos2[3]={0,0,0}, disp[3] = {0,0,0};
    Point_t         p;
@@ -39,9 +39,14 @@ void HandleExtendedDislocation_DDD(InArgs_t *inArgs)
    LineList_t      list;
    
    vector<string>          words;
    vector<real8>           seq, vec(12);
    vector<real8>           seq, vec;
    vector<vector<double> > data(7), outs;  

    Table_t         auxTable;
    vector<Table_t> auxTables;

    vec.resize(12);

    list.variables.push_back("x");
    list.variables.push_back("y1");
    list.variables.push_back("y2");
@@ -60,10 +65,12 @@ void HandleExtendedDislocation_DDD(InArgs_t *inArgs)
    }else{
        aveFile = inArgs->outFiles[1];
    }
    ofstream out;
    out.open(aveFile.c_str(), ios::out);
    out << "variables = file, timeNow, separation, p1, p2, p, disp,";
    out << " velocity, v_p1, v_p2, v_p, v_separation" << endl;

    if(inArgs->outFiles.size() < 3){
        auxFile = "tecdata.plt";
    }else{
        auxFile = inArgs->outFiles[2];
    }

    boundMin[0] = -0.5*cubel;
    boundMin[1] = -0.5*cubel;
@@ -87,6 +94,33 @@ void HandleExtendedDislocation_DDD(InArgs_t *inArgs)
    printf("The remesh size is %f\n", remeshSize);
    if(inArgs->help)return;

    if(inArgs->auxFiles.size()>0){
        auxTables.resize(inArgs->auxFiles.size());
        for(file=0; file<inArgs->auxFiles.size(); file++){
            ReadTecplotNormalData(inArgs->auxFiles[file], auxTables[file], secLine);
        }
        StitchTecplotData(auxTables, auxTable, 0);
        if(auxTable.data.size() == 0){
            Fatal("the aux table size is zero.");
        }

        logFile = 1;
        WriteTecplotNormalData(auxTable, auxFile, 10);
    }

    ofstream out;
    out.open(aveFile.c_str(), ios::out);
    out << "variables = file, timenow, separation, p1, p2, p, disp,";
    out << " velocity, v_p1, v_p2, v_p, v_separation";

    if(logFile){
        vec.resize(11+auxTable.variables.size());        
        for(i=1; i<auxTable.variables.size(); i++){
            out << ", " << auxTable.variables[i];
        }
    }
    out << endl;    

    bakPos = 0.0;
    for(file=0; file<inArgs->inpFiles.size(); file++){

@@ -291,6 +325,29 @@ void HandleExtendedDislocation_DDD(InArgs_t *inArgs)

    sort(outs.begin(), outs.end(), cmpvec); 

    if(logFile){
        int     startID = 0;
        for(i=0; i<outs.size(); i++){
            
            for(j=startID; j<auxTable.data.size(); j++){
                if(outs[j][1] >= auxTable.data[i][0]*1.0E9)break;
            }

            if(j == auxTable.data.size()){
                j = 0;
            }

            startID = j;

            k = 11;

            for(j=1; j< auxTable.variables.size(); j++){
                k++;
                outs[i][k] = auxTable.data[startID][j];
            }
        }
    }

    for(i=0; i<outs.size(); i++){
        if(i>0){
            pos1[1] = outs[i-1][5]; 
@@ -313,18 +370,10 @@ void HandleExtendedDislocation_DDD(InArgs_t *inArgs)
        outs[i][6] = disp[1];
        outs[i][7] = disp[1]/dt;

        out <<  setprecision(5)   << outs[i][0] << " ";
        out <<  setprecision(10)  << outs[i][1] << " ";
        out <<  setprecision(10)  << outs[i][2] << " ";
        out <<  setprecision(10)  << outs[i][3] << " ";
        out <<  setprecision(10)  << outs[i][4] << " ";
        out <<  setprecision(10)  << outs[i][5] << " ";
        out <<  setprecision(10)  << outs[i][6] << " ";
        out <<  setprecision(10)  << outs[i][7] << " ";
        out <<  setprecision(10)  << outs[i][8] << " ";
        out <<  setprecision(10)  << outs[i][9] << " ";
        out <<  setprecision(10)  << outs[i][10] << " ";
        out <<  setprecision(10)  << outs[i][11] << endl;
        for(j=0; j<outs[i].size(); j++){
            out <<  setprecision(10)  << outs[i][j] << " ";
        }
        out << endl;
    }
    out.close();
    return;
+32 −7
Original line number Diff line number Diff line
@@ -10,8 +10,8 @@ using namespace std;

int ReadTecplotNormalData(string &file, Table_t &table, string &secLine)
{
    int         lineNo = 1, i, j;
    string      str;
    int         lineNo = 1, i, j, type;
    string      str, v("v");
    ifstream    infile;

    vector<string>  line;
@@ -33,10 +33,32 @@ int ReadTecplotNormalData(string &file, Table_t &table, string &secLine)
        printf("Warning: there is noting in the file %s", file.c_str());
        return (0);
    }

    line = split(str, " ");
    for(i=0; i<line.size(); i++){
        if(atof(line[i].c_str()) == 0)break;
    }
    vector<string>().swap(line);

    if(i==0){
        line = split(str, "=");
        table.variables = split(line[1], ",");
    for(i=0; i<table.variables.size(); i++)WashString(table.variables[i]);
        for(i=0; i<table.variables.size(); i++){
            WashString(table.variables[i]);
        }
        vector<string>().swap(line);
        col.resize(table.variables.size());
    }else{
        line = split(str, " ");
        table.variables.resize(line.size());
        col.resize(table.variables.size());
        for(i=0;i<line.size();i++){
            table.variables[i] = v + (char)i;
            col[i] = atof(line[i].c_str());
        }
        table.data.push_back(col);
    }


    j = 0;
    while(getline(infile,str))
@@ -45,12 +67,15 @@ int ReadTecplotNormalData(string &file, Table_t &table, string &secLine)
        line = split(str, " ");
        if(lineNo == 2)secLine = str;
       
        if(line.size() != table.variables.size())continue; 
        if(line.size() != table.variables.size()){
            continue; 
        }
        for(i=0; i<col.size(); i++){
            col[i] = atof(line[i].c_str());
        }
        table.data.push_back(col);
        j++;
        vector<string>().swap(line);
    }
    infile.close();
//    printf("Finsish reading input file %s\n", file.c_str());    
+75 −0
Original line number Diff line number Diff line
@@ -2,6 +2,7 @@
#include "Home.h"
#include "Util.h"


void Fatal(const char *format, ...) 
{
        char    msg[512];
@@ -16,6 +17,34 @@ void Fatal(const char *format, ...)
        exit(1);
}

int DataType(const string &str)
{
    int     i, c = 0, n = 0, type;
    char    s[512];

    str.copy(s, str.length(), 0);
    *(s+str.length()) = '\0';

    for(i=0; i<str.length(); i++){
        if(s[i] >= '0' && s[i] >= '9' && n==0){
            n = 1;
            if(c)break;
        }

        if((s[i] >= 'a' && s[i] <= 'z' ||
           s[i] >= 'A' && s[i] <= 'Z') && c==0){
            c = 1;
            if(n)break;
        }
    }

    type |= ((n==1) ? NUMBER_DATA : 0);
    type |= ((c==1) ? CHAR_DATA : 0);
    printf("%d %d, cd\n", n, c);

    return(type);
}


vector<string> split(const string& str, const string& delim) 
{
@@ -263,6 +292,52 @@ void NormalizeVec(real8 vec[3])
        return;
}

void StitchTecplotData(vector<Table_t> &tables, Table_t &table, int eigenID)
{
    int         i, j, startID = 0;

    if(tables.size() < 2)return;

    vector<string>().swap(table.variables);
    vector<vector<double> >().swap(table.data);

    table.variables.resize(tables[0].variables.size());
    for(i=0; i<tables[0].variables.size(); i++){
        table.variables[i] = tables[0].variables[i];
    }

    for(i=0; i<tables[0].data.size(); i++){
        table.data.push_back(tables[0].data[i]);
    }    

    for(i=1; i<tables.size(); i++){
        if(tables[i].variables.size() != tables[0].variables.size())continue;

        for(j=startID; j<table.data.size(); j++){
            if(table.data[j][eigenID] >= tables[i].data[0][eigenID]){
                break;
            }
        }
        startID = j;

        if(j < table.data.size()){
            table.data.erase(table.data.begin()+j, table.data.end());
        }
       
        for(j=0; j<tables[i].data.size(); j++){
            table.data.push_back(tables[i].data[j]);
        }
    }

    return;            
}


void StichData_DDD(InArgs_t *inArgs)
{

    return;
}



Loading