Skip to content

Commit

Permalink
Add vtu input - first try
Browse files Browse the repository at this point in the history
  • Loading branch information
laetitia-m committed Jun 9, 2023
1 parent 732a675 commit df44b15
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 12 deletions.
13 changes: 8 additions & 5 deletions src/inoutcpp_pmmg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@

#include "parmmg.h"

int PMMG_loadVtuMesh_centralized(PMMG_pParMesh parmesh,const char *filename) {
int PMMG_loadVtuMesh(PMMG_pParMesh parmesh,const char *filename) {
MMG5_pMesh mesh;
MMG5_pSol met, sol;
MMG5_pSol met, ls, field;
int ier;

if ( parmesh->myrank!=parmesh->info.root ) {
Expand All @@ -61,14 +61,17 @@ int PMMG_loadVtuMesh_centralized(PMMG_pParMesh parmesh,const char *filename) {
__func__);
return 0;
}
mesh = parmesh->listgrp[0].mesh;
met = parmesh->listgrp[0].met;
mesh = parmesh->listgrp[0].mesh;
met = parmesh->listgrp[0].met;
ls = parmesh->listgrp[0].ls;
field = parmesh->listgrp[0].field;

/* Set mmg verbosity to the max between the Parmmg verbosity and the mmg verbosity */
assert ( mesh->info.imprim == parmesh->info.mmg_imprim );
mesh->info.imprim = MG_MAX ( parmesh->info.imprim, mesh->info.imprim );

ier = MMG3D_loadVtuMesh(mesh,met,sol,filename);
// ier = MMG3D_loadVtuMesh(mesh,met,ls,filename);
ier = MMG3D_loadVtuMesh_and_allData(mesh,&field,filename);

/* Restore the mmg verbosity to its initial value */
mesh->info.imprim = parmesh->info.mmg_imprim;
Expand Down
19 changes: 19 additions & 0 deletions src/libparmmg.h
Original file line number Diff line number Diff line change
Expand Up @@ -2197,6 +2197,25 @@ int PMMG_usage( PMMG_pParMesh parmesh, char * const prog);
*/
int PMMG_loadMesh_hdf5(PMMG_pParMesh parmesh,const char *filename);

/**
* \param parmesh pointer toward the parmesh structure.
* \param filename name of the vtu file.
* \return 0 if failed, 1 otherwise.
*
* Load the mesh data, the metric, and the ls from a vtu file in
* a centralized parmesh.
*
* \remark Fortran interface:
* > SUBROUTINE PMMG_LOADVTUMESH(parmesh,filename,strlen,retval)\n
* > MMG5_DATA_PTR_T, INTENT(INOUT) :: parmesh\n
* > CHARACTER(LEN=*), INTENT(IN) :: filename\n
* > INTEGER, INTENT(IN) :: strlen\n
* > INTEGER, INTENT(OUT) :: retval\n
* > END SUBROUTINE\n
*
*/
int PMMG_loadVtuMesh(PMMG_pParMesh parmesh,const char *filename);

/**
* \param parmesh pointer toward the parmesh structure.
* \param filename name of file.
Expand Down
25 changes: 18 additions & 7 deletions src/parmmg.c
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,24 @@ int main( int argc, char *argv[] )
case ( MMG5_FMT_VtkVtk ):
if ( iermesh==0 ) fprintf(stdout," ## WARNING: Input %s under development .\n",MMG5_Get_formatName(fmtin));

break;

case ( MMG5_FMT_VtkVtu ):
if ( iermesh==0 ) fprintf(stdout," ## WARNING: Input %s under development .\n",MMG5_Get_formatName(fmtin));
iermesh = PMMG_loadVtuMesh(parmesh,parmesh->meshin);
MPI_Bcast( &iermesh, 1, MPI_INT, parmesh->info.root, parmesh->comm );

parmesh->info.fmtout = fmtout;

break;

case PMMG_FMT_HDF5:
ier = PMMG_loadMesh_hdf5( parmesh, parmesh->meshin );
parmesh->info.fmtout = fmtout;
distributedInput = 1;

break;

case ( MMG5_FMT_MeditASCII ): case ( MMG5_FMT_MeditBinary ):

// Algiane: Dirty (to be discussed, I don't have a clean solution)
Expand Down Expand Up @@ -328,13 +346,6 @@ int main( int argc, char *argv[] )
}
break;

case PMMG_FMT_HDF5:
ier = PMMG_loadMesh_hdf5( parmesh, parmesh->meshin );
parmesh->info.fmtout = fmtout;
distributedInput = 1;

break;

default:
if ( rank == parmesh->info.root ) {
fprintf(stderr," ** I/O AT FORMAT %s NOT IMPLEMENTED.\n",MMG5_Get_formatName(fmtin) );
Expand Down

0 comments on commit df44b15

Please sign in to comment.