Skip to content
Snippets Groups Projects
Commit 2c102dff authored by Jean-François Remacle's avatar Jean-François Remacle
Browse files

*** empty log message ***

parent 48554b32
No related branches found
No related tags found
No related merge requests found
...@@ -74,3 +74,8 @@ void gmshElasticityTerm::elementMatrix(MElement *e, Double_Matrix & m) const ...@@ -74,3 +74,8 @@ void gmshElasticityTerm::elementMatrix(MElement *e, Double_Matrix & m) const
m.blas_dgemm(BTH, B, weight * detJ, 1.); m.blas_dgemm(BTH, B, weight * detJ, 1.);
} }
} }
...@@ -112,10 +112,10 @@ bool PViewDataGModel::writeMSH(std::string fileName, bool binary) ...@@ -112,10 +112,10 @@ bool PViewDataGModel::writeMSH(std::string fileName, bool binary)
return false; return false;
} }
if(_type != NodeData){ // if(_type != NodeData){
Msg::Error("Can only export node-based datasets for now"); // Msg::Error("Can only export node-based datasets for now");
return false; // return false;
} // }
GModel *model = _steps[0]->getModel(); GModel *model = _steps[0]->getModel();
...@@ -135,32 +135,56 @@ bool PViewDataGModel::writeMSH(std::string fileName, bool binary) ...@@ -135,32 +135,56 @@ bool PViewDataGModel::writeMSH(std::string fileName, bool binary)
for(int i = 0; i < _steps[step]->getNumData(); i++) for(int i = 0; i < _steps[step]->getNumData(); i++)
if(_steps[step]->getData(i)) numNodes++; if(_steps[step]->getData(i)) numNodes++;
if(numNodes){ if(numNodes){
fprintf(fp, "$NodeData\n"); if (_type == NodeData){
fprintf(fp, "1\n\"%s\"\n", getName().c_str()); fprintf(fp, "$NodeData\n");
fprintf(fp, "1\n%.16g\n", _steps[step]->getTime()); fprintf(fp, "1\n\"%s\"\n", getName().c_str());
fprintf(fp, "3\n%d\n%d\n%d\n", step, numComp, numNodes); fprintf(fp, "1\n%.16g\n", _steps[step]->getTime());
for(int i = 0; i < _steps[step]->getNumData(); i++){ fprintf(fp, "3\n%d\n%d\n%d\n", step, numComp, numNodes);
if(_steps[step]->getData(i)){ for(int i = 0; i < _steps[step]->getNumData(); i++){
MVertex *v = _steps[step]->getModel()->getMeshVertexByTag(i); if(_steps[step]->getData(i)){
if(!v){ MVertex *v = _steps[step]->getModel()->getMeshVertexByTag(i);
Msg::Error("Unknown vertex %d in data", i); if(!v){
return false; Msg::Error("Unknown vertex %d in data", i);
} return false;
int num = v->getIndex(); }
if(binary){ int num = v->getIndex();
fwrite(&num, sizeof(int), 1, fp); if(binary){
fwrite(_steps[step]->getData(i), sizeof(double), numComp, fp); fwrite(&num, sizeof(int), 1, fp);
} fwrite(_steps[step]->getData(i), sizeof(double), numComp, fp);
else{ }
fprintf(fp, "%d", num); else{
for(int k = 0; k < numComp; k++) fprintf(fp, "%d", num);
fprintf(fp, " %.16g", _steps[step]->getData(i)[k]); for(int k = 0; k < numComp; k++)
fprintf(fp, "\n"); fprintf(fp, " %.16g", _steps[step]->getData(i)[k]);
} fprintf(fp, "\n");
} }
}
}
if(binary) fprintf(fp, "\n");
fprintf(fp, "$EndNodeData\n");
}
else{
fprintf(fp, "$ElementData\n");
fprintf(fp, "1\n\"%s\"\n", getName().c_str());
fprintf(fp, "1\n%.16g\n", _steps[step]->getTime());
fprintf(fp, "3\n%d\n%d\n%d\n", step, numComp, numNodes);
for(int i = 0; i < _steps[step]->getNumData(); i++){
if(_steps[step]->getData(i)){
if(binary){
fwrite(&i, sizeof(int), 1, fp);
fwrite(_steps[step]->getData(i), sizeof(double), numComp, fp);
}
else{
fprintf(fp, "%d", i);
for(int k = 0; k < numComp; k++)
fprintf(fp, " %.16g", _steps[step]->getData(i)[k]);
fprintf(fp, "\n");
}
}
}
if(binary) fprintf(fp, "\n");
fprintf(fp, "$EndElementData\n");
} }
if(binary) fprintf(fp, "\n");
fprintf(fp, "$EndNodeData\n");
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment