Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/output pvtu parmmg #210

Merged
merged 4 commits into from
Apr 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 24 additions & 10 deletions src/common/vtkparser.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -334,25 +334,39 @@ int MMG5_saveVtkMesh_i(MMG5_pMesh mesh,MMG5_pSol *sol,
}

// Transfer point solutions into data set
MMG5_pSol psl = NULL;
int nsols;
MMG5_pSol psl = NULL;
int fieldData = 0;
int nsols = 0;

// For functions: MMG<Y>_saveVt<X>Mesh;
// PMMG_savePvtuMesh and PMMG_savePvtuMesh_and_allData
if ( metricData==1 ) {
if ( sol && *sol && sol[0]->np ) {
nsols = 1;
}
else {
/* In analysis mode (-noinsert -noswap -nomove), metric is not allocated */
nsols = 0;
}
}
else {
nsols = mesh->nsols;

// If we have other fields to output
// For functions: MMG<Y>_saveVt<X>Mesh_and_allData and PMMG_savePvtuMesh_and_allData
if (&sol[1][0]) {
nsols += mesh->nsols;
fieldData = 1;
}

static int mmgWarn = 0;
for ( int isol=0; isol<nsols; ++isol) {
psl = *sol + isol;
//- If metric, it is stored in sol[0]
if (metricData && isol==0) {
psl = sol[0];
}
//- If metric and other fields, fields are stored in sol[1]
else if (metricData){
psl = &sol[1][isol-1];
}
//- If other fields only, fields are stored in sol[1]
else {
psl = &sol[1][isol];
}

if ( !psl->m ) {
if ( !mmgWarn ) {
Expand Down Expand Up @@ -396,7 +410,7 @@ int MMG5_saveVtkMesh_i(MMG5_pMesh mesh,MMG5_pSol *sol,
strcat ( data2 , ":metric");
ar->SetName(data2);
}
else if (metricData && !strstr(data,":metric")) {
else if (metricData && !strstr(data,":metric") && isol==0) {
strcat ( data , ":metric");
ar->SetName(data);
}
Expand Down
21 changes: 18 additions & 3 deletions src/mmg2d/inoutcpp_2d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -348,15 +348,20 @@ int MMG2D_saveVtuMesh(MMG5_pMesh mesh,MMG5_pSol sol,const char *filename) {

int MMG2D_saveVtuMesh_and_allData(MMG5_pMesh mesh,MMG5_pSol *sol,const char *filename) {

MMG5_pSol allSol[2];

#ifndef USE_VTK

fprintf(stderr," ** VTK library not found. Unavailable file format.\n");
return -1;

#else

allSol[0] = NULL;
allSol[1] = *sol;

return MMG5_saveVtkMesh<vtkUnstructuredGrid,vtkXMLUnstructuredGridWriter,
vtkXMLPUnstructuredGridWriter>(mesh,sol,filename,0,1);
vtkXMLPUnstructuredGridWriter>(mesh,allSol,filename,0,1);

#endif
}
Expand All @@ -378,15 +383,20 @@ int MMG2D_saveVtkMesh(MMG5_pMesh mesh,MMG5_pSol sol,const char *filename) {

int MMG2D_saveVtkMesh_and_allData(MMG5_pMesh mesh,MMG5_pSol *sol,const char *filename) {

MMG5_pSol allSol[2];

#ifndef USE_VTK

fprintf(stderr," ** VTK library not found. Unavailable file format.\n");
return -1;

#else

allSol[0] = NULL;
allSol[1] = *sol;

return MMG5_saveVtkMesh<vtkUnstructuredGrid,vtkDataSetWriter,
vtkPDataSetWriter>(mesh,sol,filename,0,0);
vtkPDataSetWriter>(mesh,allSol,filename,0,0);

#endif
}
Expand All @@ -409,15 +419,20 @@ int MMG2D_saveVtpMesh(MMG5_pMesh mesh,MMG5_pSol sol,const char *filename) {

int MMG2D_saveVtpMesh_and_allData(MMG5_pMesh mesh,MMG5_pSol *sol,const char *filename) {

MMG5_pSol allSol[2];

#ifndef USE_VTK

fprintf(stderr," ** VTK library not found. Unavailable file format.\n");
return -1;

#else

allSol[0] = NULL;
allSol[1] = *sol;

return MMG5_saveVtkMesh<vtkPolyData,vtkXMLPolyDataWriter,
vtkXMLPPolyDataWriter>(mesh,sol,filename,0,1);
vtkXMLPPolyDataWriter>(mesh,allSol,filename,0,1);

#endif

Expand Down
14 changes: 12 additions & 2 deletions src/mmg3d/inoutcpp_3d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -245,15 +245,20 @@ int MMG3D_saveVtuMesh(MMG5_pMesh mesh,MMG5_pSol sol,const char *filename) {

int MMG3D_saveVtuMesh_and_allData(MMG5_pMesh mesh,MMG5_pSol *sol,const char *filename) {

MMG5_pSol allSol[2];

#ifndef USE_VTK

fprintf(stderr," ** VTK library not founded. Unavailable file format.\n");
return -1;

#else

allSol[0] = NULL;
allSol[1] = *sol;

return MMG5_saveVtkMesh<vtkUnstructuredGrid,vtkXMLUnstructuredGridWriter,
vtkXMLPUnstructuredGridWriter>(mesh,sol,filename,0,1);
vtkXMLPUnstructuredGridWriter>(mesh,allSol,filename,0,1);

#endif
}
Expand All @@ -275,15 +280,20 @@ int MMG3D_saveVtkMesh(MMG5_pMesh mesh,MMG5_pSol sol,const char *filename) {

int MMG3D_saveVtkMesh_and_allData(MMG5_pMesh mesh,MMG5_pSol *sol,const char *filename) {

MMG5_pSol allSol[2];

#ifndef USE_VTK

fprintf(stderr," ** VTK library not founded. Unavailable file format.\n");
return -1;

#else

allSol[0] = NULL;
allSol[1] = *sol;

return MMG5_saveVtkMesh<vtkUnstructuredGrid,vtkDataSetWriter,
vtkPDataSetWriter>(mesh,sol,filename,0,0);
vtkPDataSetWriter>(mesh,allSol,filename,0,0);

#endif
}
21 changes: 18 additions & 3 deletions src/mmgs/inoutcpp_s.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -329,15 +329,20 @@ int MMGS_saveVtuMesh(MMG5_pMesh mesh,MMG5_pSol sol,const char *filename) {

int MMGS_saveVtuMesh_and_allData(MMG5_pMesh mesh,MMG5_pSol *sol,const char *filename) {

MMG5_pSol allSol[2];

#ifndef USE_VTK

fprintf(stderr," ** VTK library not found. Unavailable file format.\n");
return -1;

#else

allSol[0] = NULL;
allSol[1] = *sol;

return MMG5_saveVtkMesh<vtkUnstructuredGrid,vtkXMLUnstructuredGridWriter,
vtkXMLPUnstructuredGridWriter>(mesh,sol,filename,0,1);
vtkXMLPUnstructuredGridWriter>(mesh,allSol,filename,0,1);

#endif
}
Expand All @@ -359,15 +364,20 @@ int MMGS_saveVtkMesh(MMG5_pMesh mesh,MMG5_pSol sol,const char *filename) {

int MMGS_saveVtkMesh_and_allData(MMG5_pMesh mesh,MMG5_pSol *sol,const char *filename) {

MMG5_pSol allSol[2];

#ifndef USE_VTK

fprintf(stderr," ** VTK library not found. Unavailable file format.\n");
return -1;

#else

allSol[0] = NULL;
allSol[1] = *sol;

return MMG5_saveVtkMesh<vtkUnstructuredGrid,vtkDataSetWriter,
vtkPDataSetWriter>(mesh,sol,filename,0,0);
vtkPDataSetWriter>(mesh,allSol,filename,0,0);

#endif
}
Expand All @@ -389,15 +399,20 @@ int MMGS_saveVtpMesh(MMG5_pMesh mesh,MMG5_pSol sol,const char *filename) {

int MMGS_saveVtpMesh_and_allData(MMG5_pMesh mesh,MMG5_pSol *sol,const char *filename) {

MMG5_pSol allSol[2];

#ifndef USE_VTK

fprintf(stderr," ** VTK library not found. Unavailable file format.\n");
return -1;

#else

allSol[0] = NULL;
allSol[1] = *sol;

return MMG5_saveVtkMesh<vtkPolyData,vtkXMLPolyDataWriter,
vtkXMLPPolyDataWriter>(mesh,sol,filename,0,1);
vtkXMLPPolyDataWriter>(mesh,allSol,filename,0,1);

#endif
}