Kaynağa Gözat

0620 文件流读取dat文件

caizm 2 yıl önce
ebeveyn
işleme
52b5ed1c7e

+ 2 - 2
CAE_Solution/conf/conf_recv.txt

@@ -4,6 +4,6 @@ userName:admin
 password:admin
 
 channel_id:1
-queue_name:BLOCKcaeint
+queue_name:BLOCKcaein
 exchange_name:BLOCKMQ-EXCHANGE
-keys_name:caeint
+keys_name:caein

+ 159 - 7
CAE_Solution/src/VTK/mesh/mesh_tecplot.cpp

@@ -77,6 +77,160 @@ bool Mesh_Tecplot::Load_Tecp_Ascii(ifstream &infile)
         cout<<"Source Tecplot File is not found!"<<endl;
         return false;
     }
+
+    string title;
+    int numOfPoint,numOfCell;
+    string celltype,datatype;
+    while (true) {
+        infile>>title;
+        if(title.find("\"")!=string::npos)break;
+    }
+    title = title.substr(title.find("\"")+1);
+    string str;
+    while (true) {
+        infile>>str;
+        title +=" ";
+        title +=str;
+        if(str.find("\"")!=string::npos)break;
+    }
+    title=title.substr(0,title.find_first_of("\""));
+    title_ = (char*)title.data();
+
+    string variables;
+    while(true){
+        infile>>variables;
+        if(variables.find("=")!=string::npos)break;
+    }
+    if((variables.find("="))!=(variables.size()-1)){
+        variables = variables.substr(variables.find("=")+1);
+        scalarName_.push_back(variables);
+    }
+    while (true) {
+        infile>>variables;
+        if(variables.find("zone")!=string::npos)break;
+        scalarName_.push_back(variables);
+    }
+    scalarNumber_ = scalarName_.size()+3;
+    //while(!infile.eof()){
+        //if(!infile.good())break;
+        infile>>variables;
+        if(variables.find("t=\"")!=string::npos){
+            string zoneName_temp;
+            if((variables.find("t=\""))!=(variables.size()-4)){
+                variables = variables.substr(variables.find("t=\"")+3);
+                zoneName_temp+=variables;
+            }
+            while(true){
+                infile>>variables;
+                zoneName_temp+=" ";
+                zoneName_temp+=variables;
+                if(variables.find("\"")!=string::npos)break;
+            }
+            zoneName_temp = zoneName_temp.substr(0,zoneName_temp.find_first_of("\""));
+            zoneName_.push_back(zoneName_temp);
+            zoneNumber_++;
+            while (true) {
+                infile>>variables;
+                if(variables=="solutiontime="){
+                    infile>>variables;
+                    variables = variables.substr(0,variables.find(","));
+                    solutionTime_ = stod(variables);
+                    continue;
+                }
+                if(variables.find("strandid=")!=string::npos){
+                    variables = variables.substr(9,variables.find_first_of(","));
+                    //to do
+                }
+                if((variables.find("n=")!=string::npos)||(variables.find("i=")!=string::npos)){
+                    variables = variables.substr(2,variables.find_first_of(","));
+                    numOfPoint = stoi(variables);
+                }
+                if((variables.find("e=")!=string::npos)||(variables.find("j=")!=string::npos)){
+                    variables = variables.substr(2,variables.find_first_of(","));
+                    numOfCell = stoi(variables);
+                }
+                if(variables.find("f=")!=string::npos){
+                    if(variables.find_first_of(",")==string::npos){
+                        variables = variables.substr(2,variables.size()-1);
+                        datatype = variables;
+                        break;
+                    }
+                    variables = variables.substr(2,variables.find(",")-2);
+                    datatype = variables;
+                }
+                if(variables.find("et=")!=string::npos){
+                    variables = variables.substr(3,variables.size()-1);
+                    celltype = variables;
+                    break;
+                }
+            }
+            if(celltype.empty()){//如果没有指定et
+                celltype = "tetrahedron";
+                celltype_empty = true;//标志位 0-有指定拓扑结构 1-未指定拓扑结构
+            }
+            if(datatype == "feblock"){
+                vector<double*> temp_vec_data;
+                temp_vec_data.resize(scalarNumber_+3);
+                for(int i =0;i<scalarNumber_+3;i++){
+                    double* temp_data = new double[numOfPoint];
+                    for(int j=0;j<numOfPoint;j++){
+                        infile>>temp_data[j];
+                    }
+                    temp_vec_data[i] = temp_data;
+                }
+                ScalarsData_.push_back(temp_vec_data);
+            }else if(datatype=="fepoint"){
+                vector<double*> temp_vec_data;
+                temp_vec_data.resize(scalarNumber_+3);
+                for(int i = 0;i<scalarNumber_+3;i++){
+                    double* temp_data = new double[numOfPoint];
+                    temp_vec_data[i] = temp_data;
+                }
+                for(int j =0;j<numOfPoint;j++){
+                    for(int k=0;k<scalarNumber_+3;k++){
+                        infile>>temp_vec_data[k][j];
+                    }
+                }
+                ScalarsData_.push_back(temp_vec_data);
+            }
+            vector<vector<int>> cell_vec;
+            if(celltype == "tetrahedron"){//tetrahedron四节点四面体
+                cell_vec.resize(numOfCell);
+                for(int i=0;i<numOfCell;i++){
+                    vector<int> cell_tmp;
+                    cell_tmp.resize(4);
+                    infile>>cell_tmp[0]>>cell_tmp[1]>>cell_tmp[2]>>cell_tmp[3];
+                    cell_vec[i] = cell_tmp;
+                }
+            }else if(celltype == "triangle"){//triangle 三节点三角形
+                cell_vec.resize(numOfCell);
+                for(int i=0;i<numOfCell;i++){
+                    vector<int> cell_tmp;
+                    cell_tmp.resize(3);
+                    infile>>cell_tmp[0]>>cell_tmp[1]>>cell_tmp[2];
+                    cell_vec[i] = cell_tmp;
+                }
+            }else if(celltype == "quadrilateral"){//quadrilateral 四节点四边形单元
+                cell_vec.resize(numOfCell);
+                for(int i=0;i<numOfCell;i++){
+                    vector<int> cell_tmp;
+                    cell_tmp.resize(4);
+                    infile>>cell_tmp[0]>>cell_tmp[1]>>cell_tmp[2]>>cell_tmp[3];
+                    cell_vec[i] = cell_tmp;
+                }
+            }else if(celltype == "brick"){//brick八节点六面体
+                cell_vec.resize(numOfCell);
+                for(int i=0;i<numOfCell;i++){
+                    vector<int> cell_tmp;
+                    cell_tmp.resize(8);
+                    infile>>cell_tmp[0]>>cell_tmp[1]>>cell_tmp[2]>>cell_tmp[3]>>cell_tmp[4]>>cell_tmp[5]>>cell_tmp[6]>>cell_tmp[7];
+                    cell_vec[i] = cell_tmp;
+                }
+            }
+            SaveData_Ascii(numOfPoint,numOfCell,celltype,cell_vec);
+        }
+    //}
+    /*
     char str[1024];
     infile.getline(str,1024);
     string title = str;
@@ -93,8 +247,7 @@ bool Mesh_Tecplot::Load_Tecp_Ascii(ifstream &infile)
     for(int i =3;i<var_l.size();i++){
         scalarName_[i-3]=var_l[i].toStdString();
     }
-    //while(!infile.eof()){//循环读zone
-    //while(true){
+    while(!infile.eof()&&infile.good()){//循环读zone
         int numOfPoint,numOfCell;
         string datatype,celltype;
         celltype.clear();
@@ -134,8 +287,8 @@ bool Mesh_Tecplot::Load_Tecp_Ascii(ifstream &infile)
             celltype = "tetrahedron";
             celltype_empty = true;//标志位 0-有指定拓扑结构 1-未指定拓扑结构
         }
-        zoneNumber_++;
-
+        zoneNumber_++;*/
+    /*
 
         if(datatype == "feblock"){
             vector<double*> temp_vec_data;
@@ -196,9 +349,8 @@ bool Mesh_Tecplot::Load_Tecp_Ascii(ifstream &infile)
                 cell_vec[i] = cell_tmp;
             }
         }
-        SaveData_Ascii(numOfPoint,numOfCell,celltype,cell_vec);
-        //if(infile.eof())break;
-    //}
+        SaveData_Ascii(numOfPoint,numOfCell,celltype,cell_vec);*/
+
     infile.close();
     return true;
 }

+ 1 - 1
CAE_Solution/src/threadPool_and_statemachine/dealWith/handlepool.cpp

@@ -291,7 +291,7 @@ void handlePool::judgeLoaddata(boostJsonObject *object, QVTKRenderer *render_)
 bool handlePool::resultImport(boostJsonObject *object_, QVTKRenderer *renderer_)
 {
     string type_;
-    //object_->fileName = "hcfd_part1_tec_volume_timestep100.dat,hcfd_part1_tec_volume_timestep100.dat";
+    //object_->fileName = "tfg_part1_tec_volume_timestep100.dat";
     //object_->fileName = "whole_part1.plt,whole_part2.plt";
     size_t found = object_->fileName.find_first_of(',');
     if(found==string::npos){//单个文件