-{
- //cout << "File: |" << multipr::getFilenameWithoutPath(pMEDfilename) << "|" << endl;
- //cout << "Path: |" << multipr::getPath(pMEDfilename) << "|" << endl;
-
- reset();
-
- //---------------------------------------------------------------------
- // Check arguments
- //---------------------------------------------------------------------
- MULTIPR_LOG("Check arguments: ");
- if (pMEDfilename == NULL) throw NullArgumentException("pMEDfilename should not be NULL", __FILE__, __LINE__);
- if (pMeshName == NULL) throw NullArgumentException("pMeshName should not be NULL", __FILE__, __LINE__);
- MULTIPR_LOG("OK\n");
-
- strncpy(mMEDfilename, pMEDfilename, 256);
- strncpy(mMeshName, pMeshName, MED_TAILLE_NOM);
-
- //---------------------------------------------------------------------
- // Open MED file (READ_ONLY)
- //---------------------------------------------------------------------
- MULTIPR_LOG("Open MED file: ");
- mMEDfile = MEDouvrir(mMEDfilename, MED_LECTURE); // open MED file for reading
- if (mMEDfile <= 0) throw FileNotFoundException("MED file not found", __FILE__, __LINE__);
- MULTIPR_LOG("OK\n");
-
- //---------------------------------------------------------------------
- // Check valid HDF format
- //---------------------------------------------------------------------
- MULTIPR_LOG("Format HDF: ");
- if (MEDformatConforme(mMEDfilename) != 0) throw IOException("invalid file", __FILE__, __LINE__);
- MULTIPR_LOG("OK\n");
-
- //---------------------------------------------------------------------
- // Get MED version
- //---------------------------------------------------------------------
- MULTIPR_LOG("MED version: ");
- med_int verMajor, verMinor, verRelease;
- med_err ret = MEDversionLire(mMEDfile, &verMajor, &verMinor, &verRelease);
- if (ret != 0) throw IOException("error while reading MED version", __FILE__, __LINE__);
- MULTIPR_LOG(verMajor << "." << verMinor << "." << verRelease << ": OK\n");
-
- //---------------------------------------------------------------------
- // Check that there is no profil
- //---------------------------------------------------------------------
- MULTIPR_LOG("#profils must be 0: ");
- med_int nbProfils = MEDnProfil(mMEDfile);
- if (nbProfils != 0) throw UnsupportedOperationException("not yet implemented", __FILE__, __LINE__);
- MULTIPR_LOG("OK\n");
-
- //---------------------------------------------------------------------
- // Read all Gauss localizations
- //---------------------------------------------------------------------
- readGaussLoc();
-
- //---------------------------------------------------------------------
- // Read scalars (should be 0)
- //---------------------------------------------------------------------
- MULTIPR_LOG("Scalars: ");
- med_int nbScalars = MEDnScalaire(mMEDfile);
- if (nbScalars != 0) throw UnsupportedOperationException("not yet implemented", __FILE__, __LINE__);
- MULTIPR_LOG(nbScalars << ": OK\n");
-
- //---------------------------------------------------------------------
- // Find the mesh
- //---------------------------------------------------------------------
- // read number of meshes
- MULTIPR_LOG("Num meshes: ");
- med_int nbMeshes = MEDnMaa(mMEDfile);
- if (nbMeshes <= 0) throw IOException("i/o error while reading number of meshes in MED file", __FILE__, __LINE__);
- MULTIPR_LOG(nbMeshes << ": OK\n");
-
- med_int meshIndex = -1;
- // iteration over mesh to find the mesh we want
- // for each mesh in the file (warning: first mesh is number 1)
- for (int itMesh = 1 ; itMesh <= nbMeshes ; itMesh++)
- {
- char meshName[MED_TAILLE_NOM + 1];
-
- ret = MEDmaaInfo(
- mMEDfile,
- itMesh,
- meshName,
- &mMeshDim,
- &mMeshType,
- mMeshDesc);
-
- if (ret != 0) throw IOException("i/o error while reading mesh information in MED file", __FILE__, __LINE__);
- MULTIPR_LOG("Mesh: |" << meshName << "|");
-
- // test if the current mesh is the mesh we want
- if (strcmp(pMeshName, meshName) == 0)
- {
- // *** mesh found ***
- MULTIPR_LOG(" OK (found)\n");
- meshIndex = itMesh;
- break;
- }
- else
- {
- // not the mesh we want: skip this mesh
- MULTIPR_LOG(" skipped\n");
- }
- }
-
- if (meshIndex == -1)
- {
- throw IllegalStateException("mesh not found in the given MED file", __FILE__, __LINE__);
- }
-
- //---------------------------------------------------------------------
- // Check mesh validity
- //---------------------------------------------------------------------
- // dimension of the mesh must be 3 (= 3D mesh)
- MULTIPR_LOG("Mesh is 3D: ");
- if (mMeshDim != 3) throw UnsupportedOperationException("dimension of the mesh should be 3; other dimension not yet implemented", __FILE__, __LINE__);
- MULTIPR_LOG("OK\n");
-
- // mesh must not be a grid
- MULTIPR_LOG("Mesh is not a grid: ");
- if (mMeshType != MED_NON_STRUCTURE)
- throw UnsupportedOperationException("grid not supported", __FILE__, __LINE__);
- MULTIPR_LOG("OK\n");
-
- // mesh must only contain TETRA10 elements
- MULTIPR_LOG("Only TETRA10: ");
- med_connectivite connectivite = MED_NOD; // NODAL CONNECTIVITY ONLY
- bool onlyTETRA10 = true;
- int numTetra10 = -1;
- for (int itCell = 0 ; itCell < MED_NBR_GEOMETRIE_MAILLE ; itCell++)
- {
- med_int meshNumCells = MEDnEntMaa(
- mMEDfile,
- mMeshName,
- MED_CONN,
- MED_MAILLE,
- CELL_TYPES[itCell],
- connectivite);
-
- if ((meshNumCells > 0) && (strcmp(CELL_NAMES[itCell], "MED_TETRA10") != 0))
- {
- onlyTETRA10 = false;
- break;
- }
- if (strcmp(CELL_NAMES[itCell], "MED_TETRA10") == 0)
- {
- numTetra10 = meshNumCells;
- }
- }
-
- if (!onlyTETRA10) throw UnsupportedOperationException("mesh should only contain TETRA10 elements", __FILE__, __LINE__);
- MULTIPR_LOG(numTetra10 << ": OK\n");
-
- // everything is OK...
-
- //---------------------------------------------------------------------
- // Check num joint = 0
- //---------------------------------------------------------------------
- MULTIPR_LOG("Num joints: ");
- med_int numJoints = MEDnJoint(mMEDfile, mMeshName);
- MULTIPR_LOG(numJoints << ": OK\n");
-
- //---------------------------------------------------------------------
- // Check num equivalence = 0
- //---------------------------------------------------------------------
- MULTIPR_LOG("Num equivalences: ");
- med_int numEquiv = MEDnEquiv(mMEDfile, mMeshName);
- MULTIPR_LOG(numEquiv << ": OK\n");
-
- //---------------------------------------------------------------------
- // Read nodes
- //---------------------------------------------------------------------
- mNodes = new Nodes();
- mNodes->readMED(mMEDfile, mMeshName, mMeshDim);
- mNodes->getBBox(mMeshBBoxMin, mMeshBBoxMax);
-
- //---------------------------------------------------------------------
- // Read elements
- //---------------------------------------------------------------------
- mElements = new Elements();
- mElements->readMED(mMEDfile, mMeshName, mMeshDim, MED_MAILLE, MED_TETRA10);
-
- //---------------------------------------------------------------------
- // Read families
- //---------------------------------------------------------------------
- readFamilies();
- finalizeFamiliesAndGroups();
-
- //---------------------------------------------------------------------
- // Read fields
- //---------------------------------------------------------------------
- readFields();
-
- //---------------------------------------------------------------------
- // Close the MED file
- //---------------------------------------------------------------------
- MULTIPR_LOG("Close MED file: ");
- ret = MEDfermer(mMEDfile);
- if (ret != 0) throw IOException("i/o error while closing MED file", __FILE__, __LINE__);
- MULTIPR_LOG("OK\n");
+{
+ reset();
+
+ //---------------------------------------------------------------------
+ // Check arguments
+ //---------------------------------------------------------------------
+ MULTIPR_LOG("Check arguments: ");
+ if (pMEDfilename == NULL) throw NullArgumentException("pMEDfilename should not be NULL", __FILE__, __LINE__);
+ if (pMeshName == NULL) throw NullArgumentException("pMeshName should not be NULL", __FILE__, __LINE__);
+ MULTIPR_LOG("OK\n");
+
+ strncpy(mMEDfilename, pMEDfilename, 256);
+ strncpy(mMeshName, pMeshName, MED_TAILLE_NOM);
+
+ //---------------------------------------------------------------------
+ // Open MED file (READ_ONLY)
+ //---------------------------------------------------------------------
+ MULTIPR_LOG("Open MED file: ");
+ mMEDfile = MEDouvrir(mMEDfilename, MED_LECTURE); // open MED file for reading
+ if (mMEDfile <= 0) throw FileNotFoundException("MED file not found", __FILE__, __LINE__);
+ MULTIPR_LOG("OK\n");
+
+ //---------------------------------------------------------------------
+ // Check valid HDF format
+ //---------------------------------------------------------------------
+ MULTIPR_LOG("Format HDF: ");
+ if (MEDformatConforme(mMEDfilename) != 0) throw IOException("invalid file", __FILE__, __LINE__);
+ MULTIPR_LOG("OK\n");
+
+ //---------------------------------------------------------------------
+ // Get MED version
+ //---------------------------------------------------------------------
+ MULTIPR_LOG("MED version: ");
+ med_int verMajor, verMinor, verRelease;
+ med_err ret = MEDversionLire(mMEDfile, &verMajor, &verMinor, &verRelease);
+ if (ret != 0) throw IOException("error while reading MED version", __FILE__, __LINE__);
+ MULTIPR_LOG(verMajor << "." << verMinor << "." << verRelease << ": OK\n");
+
+ //---------------------------------------------------------------------
+ // Check that there is no profil
+ //---------------------------------------------------------------------
+ MULTIPR_LOG("#profils must be 0: ");
+ med_int nbProfils = MEDnProfil(mMEDfile);
+ if (nbProfils != 0) throw UnsupportedOperationException("not yet implemented", __FILE__, __LINE__);
+ MULTIPR_LOG("OK\n");
+
+ //---------------------------------------------------------------------
+ // Read all Gauss localizations
+ //---------------------------------------------------------------------
+ readGaussLoc();
+
+ //---------------------------------------------------------------------
+ // Read scalars (should be 0)
+ //---------------------------------------------------------------------
+ MULTIPR_LOG("Scalars: ");
+ med_int nbScalars = MEDnScalaire(mMEDfile);
+ if (nbScalars != 0) throw UnsupportedOperationException("not yet implemented", __FILE__, __LINE__);
+ MULTIPR_LOG(nbScalars << ": OK\n");
+
+ //---------------------------------------------------------------------
+ // Find the mesh
+ //---------------------------------------------------------------------
+ // read number of meshes
+ MULTIPR_LOG("Num meshes: ");
+ med_int nbMeshes = MEDnMaa(mMEDfile);
+ if (nbMeshes <= 0) throw IOException("i/o error while reading number of meshes in MED file", __FILE__, __LINE__);
+ MULTIPR_LOG(nbMeshes << ": OK\n");
+
+ med_int meshIndex = -1;
+ // iteration over mesh to find the mesh we want
+ // for each mesh in the file (warning: first mesh is number 1)
+ for (int itMesh = 1 ; itMesh <= nbMeshes ; itMesh++)
+ {
+ char meshName[MED_TAILLE_NOM + 1];
+
+ ret = MEDmaaInfo(
+ mMEDfile,
+ itMesh,
+ meshName,
+ &mMeshDim,
+ &mMeshType,
+ mMeshDesc);
+
+ if (ret != 0) throw IOException("i/o error while reading mesh information in MED file", __FILE__, __LINE__);
+ MULTIPR_LOG("Mesh: |" << meshName << "|");
+
+ // test if the current mesh is the mesh we want
+ if (strcmp(pMeshName, meshName) == 0)
+ {
+ // *** mesh found ***
+ MULTIPR_LOG(" OK (found)\n");
+ meshIndex = itMesh;
+ break;
+ }
+ else
+ {
+ // not the mesh we want: skip this mesh
+ MULTIPR_LOG(" skipped\n");
+ }
+ }
+
+ if (meshIndex == -1)
+ {
+ throw IllegalStateException("mesh not found in the given MED file", __FILE__, __LINE__);
+ }
+
+ //---------------------------------------------------------------------
+ // Check mesh validity
+ //---------------------------------------------------------------------
+ // dimension of the mesh must be 3 (= 3D mesh)
+ MULTIPR_LOG("Mesh is 3D: ");
+ if (mMeshDim != 3) throw UnsupportedOperationException("dimension of the mesh should be 3; other dimension not yet implemented", __FILE__, __LINE__);
+ MULTIPR_LOG("OK\n");
+
+ // mesh must not be a grid
+ MULTIPR_LOG("Mesh is not a grid: ");
+ if (mMeshType != MED_NON_STRUCTURE)
+ throw UnsupportedOperationException("grid not supported", __FILE__, __LINE__);
+ MULTIPR_LOG("OK\n");
+
+ // mesh must only contain TETRA10 elements
+ MULTIPR_LOG("Only TETRA10: ");
+ med_connectivite connectivite = MED_NOD; // NODAL CONNECTIVITY ONLY
+ bool onlyTETRA10 = true;
+ int numTetra10 = -1;
+ for (int itCell = 0 ; itCell < MED_NBR_GEOMETRIE_MAILLE ; itCell++)
+ {
+ med_int meshNumCells = MEDnEntMaa(
+ mMEDfile,
+ mMeshName,
+ MED_CONN,
+ MED_MAILLE,
+ CELL_TYPES[itCell],
+ connectivite);
+
+ if ((meshNumCells > 0) && (strcmp(CELL_NAMES[itCell], "MED_TETRA10") != 0))
+ {
+ onlyTETRA10 = false;
+ break;
+ }
+ if (strcmp(CELL_NAMES[itCell], "MED_TETRA10") == 0)
+ {
+ numTetra10 = meshNumCells;
+ }
+ }
+
+ if (!onlyTETRA10) throw UnsupportedOperationException("mesh should only contain TETRA10 elements", __FILE__, __LINE__);
+ MULTIPR_LOG(numTetra10 << ": OK\n");
+
+ // everything is OK...
+
+ //---------------------------------------------------------------------
+ // Check num joint = 0
+ //---------------------------------------------------------------------
+ MULTIPR_LOG("Num joints: ");
+ med_int numJoints = MEDnJoint(mMEDfile, mMeshName);
+ MULTIPR_LOG(numJoints << ": OK\n");
+
+ //---------------------------------------------------------------------
+ // Check num equivalence = 0
+ //---------------------------------------------------------------------
+ MULTIPR_LOG("Num equivalences: ");
+ med_int numEquiv = MEDnEquiv(mMEDfile, mMeshName);
+ MULTIPR_LOG(numEquiv << ": OK\n");
+
+ //---------------------------------------------------------------------
+ // Read nodes
+ //---------------------------------------------------------------------
+ mNodes = new Nodes();
+ mNodes->readMED(mMEDfile, mMeshName, mMeshDim);
+ mNodes->getBBox(mMeshBBoxMin, mMeshBBoxMax);
+
+ //---------------------------------------------------------------------
+ // Read elements
+ //---------------------------------------------------------------------
+ mElements = new Elements();
+ mElements->readMED(mMEDfile, mMeshName, mMeshDim, MED_MAILLE, MED_TETRA10);
+
+ //---------------------------------------------------------------------
+ // Read families
+ //---------------------------------------------------------------------
+ readFamilies();
+ finalizeFamiliesAndGroups();
+
+ //---------------------------------------------------------------------
+ // Read fields
+ //---------------------------------------------------------------------
+ readFields();
+
+ //---------------------------------------------------------------------
+ // Close the MED file
+ //---------------------------------------------------------------------
+ MULTIPR_LOG("Close MED file: ");
+ ret = MEDfermer(mMEDfile);
+ if (ret != 0) throw IOException("i/o error while closing MED file", __FILE__, __LINE__);
+ MULTIPR_LOG("OK\n");