::
import MEDLoader as ml
- from MEDLoader import MEDLoader
# Mesh creation
targetCoords = [-0.3,-0.3, 0.2,-0.3, 0.7,-0.3, -0.3,0.2, 0.2,0.2, 0.7,0.2, -0.3,0.7, 0.2,0.7, 0.7,0.7 ]
targetConn = [0,3,4,1, 1,4,2, 4,5,2, 6,7,4,3, 7,8,5,4]
::
import MEDLoader as ml
- from MEDLoader import MEDLoader
# Mesh creation
targetCoords = [-0.3,-0.3, 0.2,-0.3, 0.7,-0.3, -0.3,0.2, 0.2,0.2, 0.7,0.2, -0.3,0.7, 0.2,0.7, 0.7,0.7 ]
targetConn = [0,3,4,1, 1,4,2, 4,5,2, 6,7,4,3, 7,8,5,4]
myCoords.setInfoOnComponents(["X [km]","YY [mm]"])
targetMesh.setCoords(myCoords)
# Writing mesh only
- MEDLoader.WriteUMesh("TargetMesh.med",targetMesh,True) # True means 'from scratch'
+ ml.WriteUMesh("TargetMesh.med",targetMesh,True) # True means 'from scratch'
# Re-read it and test equality
- meshRead = MEDLoader.ReadUMeshFromFile("TargetMesh.med",targetMesh.getName(),0)
+ meshRead = ml.ReadUMeshFromFile("TargetMesh.med",targetMesh.getName(),0)
print "Is the read mesh equal to 'targetMesh' ?", meshRead.isEqual(targetMesh,1e-12)
# Writing a field and its support mesh in one go
f = ml.MEDCouplingFieldDouble.New(ml.ON_CELLS, ml.ONE_TIME)
f.setArray(targetMesh.computeCellCenterOfMass())
f.setMesh(targetMesh)
f.setName("AFieldName")
- MEDLoader.WriteField("MyFirstField.med",f,True)
+ ml.WriteField("MyFirstField.med",f,True)
# Re-read it ans test equality
- f2 = MEDLoader.ReadFieldCell("MyFirstField.med", f.getMesh().getName(), 0, f.getName(), 7, 8)
+ f2 = ml.ReadFieldCell("MyFirstField.med", f.getMesh().getName(), 0, f.getName(), 7, 8)
print "Is the read field identical to 'f' ?", f2.isEqual(f,1e-12,1e-12)
# Writing in several steps
- MEDLoader.WriteUMesh("MySecondField.med",f.getMesh(),True)
- MEDLoader.WriteFieldUsingAlreadyWrittenMesh("MySecondField.med",f)
+ ml.WriteUMesh("MySecondField.med",f.getMesh(),True)
+ ml.WriteFieldUsingAlreadyWrittenMesh("MySecondField.med",f)
# A second field to write
f2 = f.clone(True) # 'True' means that we need a deep copy
f2.getArray()[:] = 2.0
f2.setTime(7.8,9,10)
- MEDLoader.WriteFieldUsingAlreadyWrittenMesh("MySecondField.med",f2)
+ ml.WriteFieldUsingAlreadyWrittenMesh("MySecondField.med",f2)
# Re-read and test this two-timestep field
- f3 = MEDLoader.ReadFieldCell("MySecondField.med",f.getMesh().getName(),0,f.getName(),7,8)
+ f3 = ml.ReadFieldCell("MySecondField.med",f.getMesh().getName(),0,f.getName(),7,8)
print "Is the field read in file equals to 'f' ?", f.isEqual(f3,1e-12,1e-12)
- f4 = MEDLoader.ReadFieldCell("MySecondField.med",f.getMesh().getName(),0,f.getName(),9,10)
+ f4 = ml.ReadFieldCell("MySecondField.med",f.getMesh().getName(),0,f.getName(),9,10)
print "Is the field read in file equals to 'f2' ?", f2.isEqual(f4,1e-12,1e-12)
To implement this exercise we use the Python scripting language and import the MEDLoader Python module.
The whole MEDCoupling module is fully included in MEDLoader. No need to import MEDCoupling when MEDLoader has been loaded. ::
- from MEDLoader import *
+ import MEDLoader as ml
Writing and Reading meshes using MEDLoader's advanced API
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
targetCoords=[-0.3,-0.3, 0.2,-0.3, 0.7,-0.3, -0.3,0.2, 0.2,0.2, 0.7,0.2, -0.3,0.7, 0.2,0.7, 0.7,0.7 ]
targetConn=[0,3,4,1, 1,4,2, 4,5,2, 6,7,4,3, 7,8,5,4]
- targetMesh=MEDCouplingUMesh.New("MyMesh",2)
+ targetMesh=ml.MEDCouplingUMesh.New("MyMesh",2)
targetMesh.allocateCells(5)
targetMesh.insertNextCell(NORM_TRI3,3,targetConn[4:7])
targetMesh.insertNextCell(NORM_TRI3,3,targetConn[7:10])
targetMesh.insertNextCell(NORM_QUAD4,4,targetConn[0:4])
targetMesh.insertNextCell(NORM_QUAD4,4,targetConn[10:14])
targetMesh.insertNextCell(NORM_QUAD4,4,targetConn[14:18])
- myCoords=DataArrayDouble.New(targetCoords,9,2)
+ myCoords=ml.DataArrayDouble.New(targetCoords,9,2)
targetMesh.setCoords(myCoords)
Create 2 groups on level 0. The first called "grp0_Lev0" on cells [0,1,3] and the second called "grp1_Lev0" on cells [1,2,3,4] ::
- grp0_0=DataArrayInt.New([0,1,3]) ; grp0_0.setName("grp0_Lev0")
- grp1_0=DataArrayInt.New([1,2,3,4]) ; grp1_0.setName("grp1_Lev0")
+ grp0_0=ml.DataArrayInt.New([0,1,3]) ; grp0_0.setName("grp0_Lev0")
+ grp1_0=ml.DataArrayInt.New([1,2,3,4]) ; grp1_0.setName("grp1_Lev0")
meshMEDFile.setGroupsAtLevel(0,[grp0_0,grp1_0])
Create 3 groups on level -1. The 1st called "grp0_LevM1" on cells [0,1], the 2nd called "grp1_LevM1" on cells [0,1,2], and the 3rd called "grp2_LevM1" on cells [1,2,3] ::
- grp0_M1=DataArrayInt.New([0,1]) ; grp0_M1.setName("grp0_LevM1")
- grp1_M1=DataArrayInt.New([0,1,2]) ; grp1_M1.setName("grp1_LevM1")
- grp2_M1=DataArrayInt.New([1,2,3]) ; grp2_M1.setName("grp2_LevM1")
+ grp0_M1=ml.DataArrayInt.New([0,1]) ; grp0_M1.setName("grp0_LevM1")
+ grp1_M1=ml.DataArrayInt.New([0,1,2]) ; grp1_M1.setName("grp1_LevM1")
+ grp2_M1=ml.DataArrayInt.New([1,2,3]) ; grp2_M1.setName("grp2_LevM1")
meshMEDFile.setGroupsAtLevel(-1,[grp0_M1,grp1_M1,grp2_M1])
Creation of a simple vector field on cells called f. ::
- f=MEDCouplingFieldDouble.New(ON_CELLS,ONE_TIME)
+ f=ml.MEDCouplingFieldDouble.New(ON_CELLS,ONE_TIME)
f.setTime(5.6,7,8)
f.setArray(targetMesh.computeCellCenterOfMass())
f.setMesh(targetMesh)
Build a reduction on cells [1,2,3] of f and call it fPart. ::
- pfl=DataArrayInt.New([1,2,3]) ; pfl.setName("My1stPfl")
+ pfl=ml.DataArrayInt.New([1,2,3]) ; pfl.setName("My1stPfl")
fPart=f.buildSubPart(pfl)
fPart.setName("fPart")
si ``MEDLoader`` a été chargé. ::
import MEDLoader as ml
- from MEDLoader import MEDLoader
Lecture, écriture d'un maillage
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
To implement this exercise we use the Python scripting language and import the MEDLoader Python module.
The whole MEDCoupling module is fully included in MEDLoader. No need to import MEDCoupling when MEDLoader has been loaded. ::
- from MEDLoader import *
+ import MEDLoader as ml
Writing/Reading a mesh
~~~~~~~~~~~~~~~~~~~~~~
targetCoords=[-0.3,-0.3, 0.2,-0.3, 0.7,-0.3, -0.3,0.2, 0.2,0.2, 0.7,0.2, -0.3,0.7, 0.2,0.7, 0.7,0.7 ]
targetConn=[0,3,4,1, 1,4,2, 4,5,2, 6,7,4,3, 7,8,5,4]
- targetMesh=MEDCouplingUMesh.New("MyMesh",2)
+ targetMesh=ml.MEDCouplingUMesh.New("MyMesh",2)
targetMesh.allocateCells(5)
targetMesh.insertNextCell(NORM_TRI3,3,targetConn[4:7])
targetMesh.insertNextCell(NORM_TRI3,3,targetConn[7:10])
targetMesh.insertNextCell(NORM_QUAD4,4,targetConn[0:4])
targetMesh.insertNextCell(NORM_QUAD4,4,targetConn[10:14])
targetMesh.insertNextCell(NORM_QUAD4,4,targetConn[14:18])
- myCoords=DataArrayDouble.New(targetCoords,9,2)
+ myCoords=ml.DataArrayDouble.New(targetCoords,9,2)
myCoords.setInfoOnComponents(["X [km]","YY [mm]"])
targetMesh.setCoords(myCoords)
We are then ready to write it. ::
- MEDLoader.WriteUMesh("TargetMesh.med",targetMesh,True)
+ ml.WriteUMesh("TargetMesh.med",targetMesh,True)
Then trying to read it. ::
- meshRead=MEDLoader.ReadUMeshFromFile("TargetMesh.med",targetMesh.getName(),0)
+ meshRead=ml.ReadUMeshFromFile("TargetMesh.med",targetMesh.getName(),0)
print "Is the mesh read in file equals targetMesh? %s"%(meshRead.isEqual(targetMesh,1e-12))
Writing/Reading a field on one time step at once
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Creation of a vector field "f" on cell supported by "targetMesh". ::
- f=MEDCouplingFieldDouble.New(ON_CELLS,ONE_TIME)
+ f=ml.MEDCouplingFieldDouble.New(ON_CELLS,ONE_TIME)
f.setTime(5.6,7,8)
f.setArray(targetMesh.computeCellCenterOfMass())
f.setMesh(targetMesh)
f.setName("AFieldName")
- MEDLoader.WriteField("MyFirstField.med",f,True)
+ ml.WriteField("MyFirstField.med",f,True)
.. note:: Mesh AND Field is written at once into MyFirstField.
Reading into MyFirstField.med ::
- f2=MEDLoader.ReadFieldCell("MyFirstField.med",f.getMesh().getName(),0,f.getName(),7,8)
+ f2=ml.ReadFieldCell("MyFirstField.med",f.getMesh().getName(),0,f.getName(),7,8)
print "Is the field read in file equals f ? %s"%(f2.isEqual(f,1e-12,1e-12))
Writing/Reading a field on one or many times steps in "multi-session mode"
Here contrary to the previous steps, we are going to write in a multi-session mode on the same MED file.
First dealing with the mesh. ::
- MEDLoader.WriteUMesh("MySecondField.med",f.getMesh(),True)
+ ml.WriteUMesh("MySecondField.med",f.getMesh(),True)
Then writing only array part of field. ::
- MEDLoader.WriteFieldUsingAlreadyWrittenMesh("MySecondField.med",f)
+ ml.WriteFieldUsingAlreadyWrittenMesh("MySecondField.med",f)
Then put a another time step. ::
f2=f.clone(True)
f2.getArray()[:]=2.0
f2.setTime(7.8,9,10)
- MEDLoader.WriteFieldUsingAlreadyWrittenMesh("MySecondField.med",f2)
+ ml.WriteFieldUsingAlreadyWrittenMesh("MySecondField.med",f2)
Now "MySecondField.med" file contains 2 time steps.
si ``MEDLoader`` a été chargé. ::
import MEDLoader as ml
- from MEDLoader import MEDLoader
Lecture, écriture d'un maillage
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Le maillage peut alors directement être écrit ... ::
- MEDLoader.WriteUMesh("TargetMesh.med",targetMesh,True) # True means 'from scratch'
+ ml.WriteUMesh("TargetMesh.med",targetMesh,True) # True means 'from scratch'
... et relu. ::
- meshRead = MEDLoader.ReadUMeshFromFile("TargetMesh.med",targetMesh.getName(),0)
+ meshRead = ml.ReadUMeshFromFile("TargetMesh.med",targetMesh.getName(),0)
print "Is the read mesh equal to 'targetMesh' ?", meshRead.isEqual(targetMesh,1e-12)
Lire/Ecrire un champ sur un pas de temps
f.setArray(targetMesh.computeCellCenterOfMass())
f.setMesh(targetMesh)
f.setName("AFieldName")
- MEDLoader.WriteField("MyFirstField.med",f,True)
+ ml.WriteField("MyFirstField.med",f,True)
Question subsidiaire : à quoi correspond le champ ainsi créé ?
Nous relisons ensuite MyFirstField.med : ::
- f2 = MEDLoader.ReadFieldCell("MyFirstField.med", f.getMesh().getName(), 0, f.getName(), 7, 8)
+ f2 = ml.ReadFieldCell("MyFirstField.med", f.getMesh().getName(), 0, f.getName(), 7, 8)
print "Is the read field identical to 'f' ?", f2.isEqual(f,1e-12,1e-12)
.. note:: Lors de la lecture du champ, on doit donc connaître: son nom, le nom de sa mesh de support
Ici contrairement au cas précédent, nous écrivons en plusieurs fois dans le *même* fichier MED.
Ecrivons tout d'abord le maillage. ::
- MEDLoader.WriteUMesh("MySecondField.med",f.getMesh(),True)
+ ml.WriteUMesh("MySecondField.med",f.getMesh(),True)
Ensuite, nous écrivons seulement les informations relatives au champ (principalement son tableau de valeurs en fait
). ::
- MEDLoader.WriteFieldUsingAlreadyWrittenMesh("MySecondField.med",f) # mesh is not re-written
+ ml.WriteFieldUsingAlreadyWrittenMesh("MySecondField.med",f) # mesh is not re-written
Nous rajoutons ensuite un second pas de temps sur le *même* maillage. ::
f2 = f.clone(True) # 'True' means that we need a deep copy
f2.getArray()[:] = 2.0
f2.setTime(7.8,9,10)
- MEDLoader.WriteFieldUsingAlreadyWrittenMesh("MySecondField.med",f2)
+ ml.WriteFieldUsingAlreadyWrittenMesh("MySecondField.med",f2)
Maintenant le fichier "MySecondField.med" contient le maillage et un champ à deux pas de temps porté par ce maillage.
Nous pouvons relire tout cela avec des méthodes similaires à ce qui a été vu précédemment : ::
- f3 = MEDLoader.ReadFieldCell("MySecondField.med",f.getMesh().getName(),0,f.getName(),7,8)
+ f3 = ml.ReadFieldCell("MySecondField.med",f.getMesh().getName(),0,f.getName(),7,8)
print "Is the field read in file equals to 'f' ?", f.isEqual(f3,1e-12,1e-12)
- f4 = MEDLoader.ReadFieldCell("MySecondField.med",f.getMesh().getName(),0,f.getName(),9,10)
+ f4 = ml.ReadFieldCell("MySecondField.med",f.getMesh().getName(),0,f.getName(),9,10)
print "Is the field read in file equals to 'f2' ?", f2.isEqual(f4,1e-12,1e-12)
Solution
Some useful complementary resources:
+- \subpage porting
- \subpage glossary
- \subpage med-file
- \subpage install
--- /dev/null
+/*!
+
+\page porting Porting code/scripts from version 7 to 8
+
+\section port-migrate How to migrate
+
+Significant API changes have been made between version 7.x and 8.x of MEDCoupling.
+This page guides you through the changes you have to apply to migrate.
+
+First of all, the script
+\code
+ medcoup7to8.py
+\endcode
+
+installed in the binary directory can do most of the job. It takes as first argument the path of the directory
+containing the sources you want to port. Only some extensions are handled. A backup of the modified files is
+done. Run
+\code
+ medcoup7to8.py --help
+\endcode
+for a full usage description, including the handled file extensions.
+
+Beware however that the two substitutions below can not be done via this script, because they might conflict with
+standard STL C++ functions:
+- DataArray*::search -> DataArray*::findIdSequence
+- DataArray*::substr -> DataArray*::subArray
+Those will have to be treated manually.
+
+The script doesn't handle either the namespace change described below.
+
+\section port-medloader Namespace change and MEDLoader high level API
+
+The namespace ParaMEDMEM has been turned into MEDCoupling, and now contains MEDLoader high level API.
+The MEDLoader high level API is hence accessible:
+ - at the MEDCoupling namespace level in C++ (direct static functions, no more MEDLoader class)
+ - at the MEDLoader module level in Python. Scripts using the high level API of the MEDLoader
+typically need to get read of all the occurences of "MEDLoader." in their code.
+
+Note that on the Python side the module MEDLoader is still here, but doesn't containt the MEDLoader class anymore.
+As before it re-includes all of MEDCoupling classes, plus the low level MEDLoader classes (MEDFile* classes).
+
+\section port-full-ref Name changes - Reference list
+
+The following changes have been applied:
+- methods ending with a number (mergeNodes2, ...) have been made more explicit
+- search functions have been unified (they all begin with 'findId(s)')
+- plus some other various renames
+
+Full list of method name changes:
+
+- Interpolation
+ + RevIntegral / IntensiveConservation
+ + ConservativeVolumic / IntensiveMaximum
+ + IntegralGlobConstraint / ExtensiveConservation
+ + Integral / ExtensiveMaximum
+- All classes
+ + deepCpy / deepCopy
+ + performCpy / performCopyOrIncrRef
+- Auto-pointer
+ + MEDCouplingAutoRefCountObjectPtr / MCAuto
+- MEDCouplingExtrudedMesh
+ + MEDCouplingExtrudedMesh / MEDCouplingMappedExtrudedMesh
+- MEDCouplingMesh
+ + getBarycenterAndOwner / computeCellCenterOfMass
+ + checkCoherency / checkConsistencyLight
+ + checkCoherency1 / checkConsistency
+- MEDCouplingPointSet
+ + mergeNodes2 / mergeNodesCenter
+ + renumberNodes2 / renumberNodesCenter
+ + buildPartOfMySelf2 / buildPartOfMySelfSlice
+ + buildPartOfMySelfKeepCoords2 / buildPartOfMySelfKeepCoordsSlice
+ + deepCpyConnectivityOnly / deepCopyConnectivityOnly
+- MEDCoupling1DGTUMesh
+ + checkCoherencyOfConnectivity / checkConsistencyOfConnectivity
+- MEDCouplingUMesh
+ + getMeshLength / getNodalConnectivityArrayLen
+ + AreCellsEqual0 / AreCellsEqualPolicy0
+ + AreCellsEqual1 / AreCellsEqualPolicy1
+ + AreCellsEqual2 / AreCellsEqualPolicy2
+ + AreCellsEqual7 / AreCellsEqualPolicy7
+ + AreCellsEqual3 / AreCellsEqualPolicy2NoType
+ + areCellsIncludedIn2 / areCellsIncludedInPolicy7
+ + setPartOfMySelf2 / setPartOfMySelfSlice
+ + ExtractFromIndexedArrays2 / ExtractFromIndexedArraysSlice
+ + SetPartOfIndexedArrays2 / SetPartOfIndexedArraysSlice
+ + SetPartOfIndexedArraysSameIdx2 / SetPartOfIndexedArraysSameIdxSlice
+ + deepCpyConnectivityOnly / deepCopyConnectivityOnly
+- DataArray
+ + setContigPartOfSelectedValues2 / setContigPartOfSelectedValuesSlice
+ + selectByTupleId2 / selectByTupleIdSafe
+ + GetAxTypeRepr / GetAxisTypeRepr
+ + cpyFrom / deepCopyFrom
+- DataArrayInt
+ + isIdentity2 / isIota
+ + selectByTupleId2 / selectByTupleIdSlice
+ + BuildOld2NewArrayFromSurjectiveFormat2 / ConvertIndexArrayToO2N
+ + getIdsEqual / findIdsEqual
+ + getIdsNotEqual / findIdsNotEqual
+ + getIdsEqualList / findIdsEqualList
+ + getIdsNotEqualList / findIdsNotEqualList
+ + getIdsEqualTuple / findIdsEqualTuple
+ + locateValue / findIdFirstEqual
+ + locateTuple / findIdFirstEqualTuple
+ + search / findIdSequence (<b>WARNING not handled by the porting script!</b>)
+ + getIdsInRange / findIdsInRange
+ + getIdsNotInRange / findIdsNotInRange
+ + getIdsStrictlyNegative / findIdsStricltyNegative
+ + searchRangesInListOfIds / findIdsRangesInListOfIds
+ + computeOffsets2 / computeOffsetsFull
+- DataArrayDouble
+ + substr / subArray (<b>WARNING not handled by the porting script!</b>)
+ + applyFunc2 / applyFuncCompo
+ + applyFunc3 / applyFuncNamedCompo
+- MEDCouplingFieldDouble
+ + getIdsInRange / findIdsInRange
+ + fillFromAnalytic2 / fillFromAnalyticCompo
+ + fillFromAnalytic3 / fillFromAnalyticNamedCompo
+ + applyFunc2 / applyFuncCompo
+ + applyFunc3 / applyFuncNamedCompo
+ + mergeNodes2 / mergeNodesCenter
+
+*/
+
\endif
- \ref appendix
+ - \ref porting
- \ref glossary
- \ref med-file
- \ref install
-- \ref ParaMEDMEM "MEDCoupling (and other parallel classes) API documentation"
-- \ref MEDLoader "MEDLoader API documentation"
+- \ref MEDCoupling "MEDCoupling, MEDLoader (and other parallel classes) API documentation"
*/
--- /dev/null
+/* \page MEDLoader Static functions offering the "basic" API to read and write MED files
+
+ A set of static methods is available at the MEDCoupling namespace level and offers the
+ high level API to access MED files. Take a look at \ref medloader for more details.
+
+ */
The aim of this page is to present MEDLoader basic API. The goal of
this basic API is to perform a read or a write in one shot without any
-internal state. That's why the basic API of MEDLoader offers \b only \b static methods whose names have the first
-character in capital. You are intended to use these methods. The following
+internal state. That's why the basic API of MEDLoader offers \b only \b static functions whose names have the first
+character in capital. You are intended to use these functions. The following
chapters will try to describe in details some of important ones.
The basic idea of MEDLoader is to exploit as much as possible MED
\section BasicMEDLoaderBasicAPIGlobalInfo Retrieving tiny global information from MED files using basic API
-The MEDLoader::CheckFileForRead method will perform such a check before any attempt of read.
-A field is also discriminated by its name. The methods MEDLoader::GetCellFieldNamesOnMesh and MEDLoader::GetNodeFieldNamesOnMesh are available to know all fields
+The MEDCoupling::CheckFileForRead function will perform such a check before any attempt of read.
+A field is also discriminated by its name. The functions MEDCoupling::GetCellFieldNamesOnMesh and MEDCoupling::GetNodeFieldNamesOnMesh are available to know all fields
respectively on cells and on nodes lying on a specified mesh.
A field is defined by several time steps discriminated by a pair of ints
(iteration,order). It is \b not possible to store 2 time steps of a same
field having the same iteration and order
numbers. The floating point value attached to this couple of ids (iteration,order) is only present for information.
-Static methods MEDLoader::GetCellFieldIterations and
-MEDLoader::GetNodeFieldIterations return a vector of pairs (iteration, order).
+Static functions MEDCoupling::GetCellFieldIterations and
+MEDCoupling::GetNodeFieldIterations return a vector of pairs (iteration, order).
A field time step lies on one \b or \b more mesh(es) specified by its \b or \b their name(s). A field time step in
MED file could be defined on point \b and on cell \b and, \b or on Gauss points \b and, \b or on point per element.
\anchor MEDLoaderMeshNameConstraint MED file can contain several meshes. These meshes are
discriminated by their names (two meshes could not have the same
name). In the same way a MED file can contain several fields.
-So MEDLoader offers the MEDLoader::GetMeshNames method to
+So MEDLoader offers the MEDCoupling::GetMeshNames function to
discover all the mesh names contained in your file.
\section BasicMEDLoaderBasicAPIMesh Reading and writing meshes in MED files using basic API
MED_TETRA4, MED_TRIA6, MED_SEG2, MED_POINT1, MED_POLYGON,
MED_POLYHEDRA in a same mesh. In MEDCouplingUMesh such a mix is not
allowed as described \ref MEDCouplingMeshes "here". So to \b read such mesh it
-is important to know which mesh dimension you are interested in. The parameter \b meshDimRelToMax of method MEDLoader::ReadUMeshFromFile corresponds to the mesh dimension you are
+is important to know which mesh dimension you are interested in. The parameter \b meshDimRelToMax of function MEDCoupling::ReadUMeshFromFile corresponds to the mesh dimension you are
interested in, expressed relatively to the maximal dimension of cells contained
in the mesh in file.
\snippet MEDLoaderExamplesTest.py PySnippetMeshAdvAPI1_10
-The method MEDLoader::ReadUMeshDimFromFile could
+The function MEDCoupling::ReadUMeshDimFromFile could
help you to have this mesh dimension.
Here is a \ref MEDLoaderExample2 "Python example".<br>
is called the familyId. A family is discriminated by its id. MED file
attaches a name to its id to be more user friendly. So by construction, 2 different
families could not share anything. The user can retrieve all the
-families names available on a mesh with the static method MEDLoader::GetMeshFamiliesNames.
+families names available on a mesh with the static function MEDCoupling::GetMeshFamiliesNames.
A group is a set of families. So groups can overlap each other,
contrary to families. Groups are also discriminated by a name. As for
-families the static method to retrieve the groups of a specified mesh is MEDLoader::GetMeshGroupsNames.
+families the static function to retrieve the groups of a specified mesh is MEDCoupling::GetMeshGroupsNames.
MEDLoader allows you to retrieve the
-corresponding "part of meshes" thanks to static methods
-MEDLoader::ReadUMeshFromFamilies and MEDLoader::ReadUMeshFromGroups.
-These methods allow you to combine several families and groups in the
+corresponding "part of meshes" thanks to static functions
+MEDCoupling::ReadUMeshFromFamilies and MEDCoupling::ReadUMeshFromGroups.
+These functions allow you to combine several families and groups in the
same returned mesh.
\subsection BasicMEDLoaderAPIField Reading a field at one time step in MED files
to append data to an existing file, or if you want to create a new
file from scratch. This explains the presence of boolean parameter \b
writeFromScratch in API of MEDLoader starting with \b
-MEDLoader::Write* .
+MEDCoupling::Write* .
If \b writeFromScratch parameter is set to \b true and if the file
already exists the file will be crashed and replaced by the new
file does \b not \b exist the new file is created, but if the file
exists MEDLoader will enter in appended mode.
-Two classes of MEDLoader write methods exist when \b writeFromScratch
+Two classes of MEDLoader write functions exist when \b writeFromScratch
is set to \b false :
-- Methods \b MEDLoader::Write*Dep : The write operation is performed without any question in file. The
+- Functions \b MEDCoupling::Write*Dep : The write operation is performed without any question in file. The
responsibility is let to the user because the MED file could be
- corrupted. The advantage of this method is that it is faster
+ corrupted. The advantage of this function is that it is faster
because no check is done.
-- Methods \b MEDLoader::Write* : MEDLoader will not corrupt your file
+- Functions \b MEDCoupling::Write* : MEDLoader will not corrupt your file
by always trying to append data. The consequence is that a
read of part (and data processing) of MED file could be needed before any attempt of
- writing. So these methods could be in some cases much time and memory consuming.
+ writing. So these functions could be in some cases much time and memory consuming.
The behaviour of MEDLoader when \b writeFromScratch is set to false will be precised
-for each \b MEDLoader::Write* methods is the next subsections.
+for each \b MEDCoupling::Write* functions is the next subsections.
\subsection MEDLoaderWriteMesh Writing one mesh in a MED file with MEDLoader
possibilities:
- Write several instances of MEDCoupling::MEDCouplingUMesh
- lying \b on \b same \b coords \b with \b different \b mesh \b dimensions. In this case MEDLoader::WriteUMeshes is the method you should
- use. Typically this method should be used to write files such as
+ lying \b on \b same \b coords \b with \b different \b mesh \b dimensions. In this case MEDCoupling::WriteUMeshes is the function you should
+ use. Typically this function should be used to write files such as
defined \ref MEDLoaderExample2 "here".
- This method first checks that all instances share the same
+ This function first checks that all instances share the same
MEDCoupling::DataArrayDouble instance as coords. If not an
INTERP_KERNEL::Exception will be thrown and an invocation on
MEDCoupling::MEDCouplingPointSet::tryToShareSameCoords will be necessary.
- Write a partition of meshes having \b same \b mesh \b dimension, that is to say a set of
groups and families from given meshes. As in the previous case the
check of same coords will be done (if not an INTERP_KERNEL::Exception is
- thrown). After this step this method will
+ thrown). After this step this function will
merge input (preserving order) and will simplify the
merged mesh. After this operation, the groups will be constituted by
assigning the group names with the corresponding names of
- instance. That's why all meshes must have a not empty name which is different from one mesh to the other. The method to use in this case is
- MEDLoader::WriteUMeshesPartition.
+ instance. That's why all meshes must have a not empty name which is different from one mesh to the other. The function to use in this case is
+ MEDCoupling::WriteUMeshesPartition.
-For these 2 described methods the semantic of \b writeFromScratch when
+For these 2 described functions the semantic of \b writeFromScratch when
\b false is the same, that is to say : no writing
(INTERP_KERNEL::Exception thrown) will be done if the
file already exists and contains a mesh with name 'meshName'
-for MEDLoader::WriteUMeshesPartition method and the name of first element
+for MEDCoupling::WriteUMeshesPartition function and the name of first element
of unstructured mesh vector passed as first parameter of
-MEDLoader::WriteUMeshes.
+MEDCoupling::WriteUMeshes.
\subsection MEDLoaderWriteField Writing one time step of a field in a MED file with MEDLoader
To write \b one \b time \b step of a field from scratch with MEDLoader
-use MEDLoader::WriteField method. The behaviour of this method depends
+use MEDCoupling::WriteField function. The behaviour of this function depends
on the value of the \b writeFromScratch parameter :
-- When \b writeFromScratch equals to \b true, this method performs two things, it
+- When \b writeFromScratch equals to \b true, this function performs two things, it
writes the underlying mesh and writes the specified time step on it.
-- When \b writeFromScatch equals to \b false, this method checks that
+- When \b writeFromScatch equals to \b false, this function checks that
the underlying mesh exists (by looking to the contents of \c field->getMesh()->getName()) in file. If not, the behaviour is the
same that previous case with \b writeFromScratch parameter set to
\b true. If the mesh already exists, MEDLoader reads the field and
\ref medloader "MEDLoader" is a package in charge of loading from a file or write to a file
in MED format a \ref medcoupling "MEDCoupling data structure". The fact that these
-functionalities are not merged in the \ref library "MEDCoupling library" is explained by a
+functionalities are not merged in the \ref library "MEDCoupling library" (separated .so files) is explained by a
willingness of reducing as much as possible the dependencies of this library.
As a MED file can combine several \ref medcoupling "MEDCoupling" aspects in one (for example meshes in
This approach is less close to MED file concepts, but closer to \ref medcoupling "MEDCoupling concepts".
-So, basic API is simpler, as shown by method MEDLoader::WriteUMesh that needs no special knowledge about MED file concepts to interact with MED files.
+So, basic API is simpler, as shown by method MEDCoupling::WriteUMesh that needs no special knowledge about MED file concepts to interact with MED files.
-This API is in the form of a list of public static methods in a class MEDCoupling::MEDLoader.
+This API is in the form of a list of public static functions directly in the namespace MEDCoupling.
This simplicity has a cost, the I/O are not (cannot be) optimized.
# MEDLoader classes to include
#
SET(_classes_MEDLoader
- MEDLoader
MEDCoupling_1_1MEDFileMeshes
MEDCoupling_1_1MEDFileMesh
MEDCoupling_1_1MEDFileUMesh
#include <iterator>
#include <algorithm>
-/*! \class MEDLoader
- *
- * \brief Static class offering the "basic" API to read and write MED files/
- *
- * This class implements only static methods and offers the high level API to access MED files.
- * Take a look at \ref medloader for more details.
- *
- */
med_geometry_type typmai[MED_N_CELL_FIXED_GEO] = { MED_POINT1,
MED_SEG2,