MEDMEM_Field.* \
MEDMEM_Med.* \
InterpKernelDEC.* \
+ OverlapDEC.* \
DEC.* \
MPIProcessorGroup.* \
StructuredCoincidentDEC.* \
ExplicitCoincidentDEC.* \
NonCoincidentDEC.* \
CommInterface.* \
+ NormalizedUnstructuredMesh.* \
Interpolation2D.* \
Interpolation3D.* \
Interpolation3DSurf.* \
MEDCouplingMemArray.* \
MEDCouplingRemapper.* \
MEDLoader.* \
+ MEDFileMesh.* \
*.dox
RECURSIVE = NO
EXCLUDE = CVS
--- /dev/null
+#FIG 3.2 Produced by xfig version 3.2.5b
+Landscape
+Center
+Inches
+Letter
+100.00
+Single
+-2
+1200 2
+6 5775 5775 6750 6600
+2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2
+ 6450 5850 6750 5850
+2 1 0 1 2 7 50 -1 -1 0.000 0 0 -1 0 0 2
+ 6450 6450 6750 6450
+2 1 0 1 1 7 50 -1 -1 0.000 0 0 -1 0 0 2
+ 6450 6150 6750 6150
+4 0 0 50 -1 0 12 0.0000 4 180 525 5775 5925 proc 0\001
+4 0 2 50 -1 0 12 0.0000 4 180 525 5775 6525 proc 2\001
+4 0 1 50 -1 0 12 0.0000 4 180 525 5775 6225 proc 1\001
+-6
+6 2700 4050 3150 4500
+1 3 0 1 0 7 50 -1 -1 0.000 1 0.0000 2925 4275 212 212 2925 4275 3075 4425
+4 0 0 50 -1 0 14 0.0000 4 165 120 2925 4350 0\001
+-6
+6 9300 3825 9750 4275
+1 3 0 1 0 7 50 -1 -1 0.000 1 0.0000 9525 4050 212 212 9525 4050 9675 4200
+4 0 0 50 -1 0 14 0.0000 4 165 120 9525 4125 0\001
+-6
+6 4275 3525 4725 3975
+1 3 0 1 1 7 50 -1 -1 0.000 1 0.0000 4500 3750 212 212 4500 3750 4712 3750
+4 0 1 50 -1 0 12 0.0000 4 135 105 4425 3825 0\001
+-6
+6 7950 3225 8400 3675
+1 3 0 1 1 7 50 -1 -1 0.000 1 0.0000 8175 3450 212 212 8175 3450 8387 3450
+4 0 1 50 -1 0 12 0.0000 4 135 105 8100 3525 0\001
+-6
+6 2775 2550 3225 3000
+1 3 0 1 2 7 50 -1 -1 0.000 1 0.0000 3000 2775 212 212 3000 2775 3212 2775
+4 0 2 50 -1 0 12 0.0000 4 135 105 3000 2850 0\001
+-6
+6 8775 2475 9225 2925
+1 3 0 1 2 7 50 -1 -1 0.000 1 0.0000 9000 2700 212 212 9000 2700 9212 2700
+4 0 2 50 -1 0 12 0.0000 4 135 105 9000 2775 0\001
+-6
+1 3 0 1 0 7 50 -1 -1 0.000 1 0.0000 3975 4425 212 212 3975 4425 4125 4575
+1 3 0 1 1 7 50 -1 -1 0.000 1 0.0000 4248 2814 212 212 4248 2814 4460 2814
+2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 3
+ 3600 3600 4800 4800 3600 4800
+2 2 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 5
+ 3600 4800 2400 4800 2400 3600 3600 3600 3600 4800
+2 2 0 1 1 7 50 -1 -1 0.000 0 0 -1 0 0 5
+ 4875 3375 3675 3375 3675 2175 4875 2175 4875 3375
+2 1 0 1 1 7 50 -1 -1 0.000 0 0 -1 0 0 3
+ 4875 3375 4875 4650 3675 3375
+2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2
+ 6225 5250 6225 975
+2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2
+ 3075 1425 3975 1425
+2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2
+ 8700 1425 9525 1425
+2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 4
+ 7800 4800 10200 4800 10200 2400 7800 4800
+2 1 0 1 1 7 50 -1 -1 0.000 0 0 -1 0 0 4
+ 7800 4650 8925 3525 7800 2475 7800 4650
+2 1 0 1 2 7 50 -1 -1 0.000 0 0 -1 0 0 4
+ 9000 3450 10125 2325 7875 2325 9000 3450
+2 2 0 1 2 7 50 -1 -1 0.000 0 0 -1 0 0 5
+ 3600 3375 2400 3375 2400 2175 3600 2175 3600 3375
+4 0 0 50 -1 0 12 0.0000 4 135 105 2325 5100 0\001
+4 0 0 50 -1 0 12 0.0000 4 135 105 4725 5100 2\001
+4 0 0 50 -1 0 12 0.0000 4 135 105 3600 5100 1\001
+4 0 0 50 -1 0 12 0.0000 4 135 105 2175 3750 3\001
+4 0 0 50 -1 0 12 0.0000 4 135 105 3450 3825 4\001
+4 0 0 50 -1 0 20 0.0000 4 225 930 3075 1275 Source\001
+4 0 0 50 -1 0 14 0.0000 4 165 120 3900 4500 1\001
+4 0 2 50 -1 0 12 0.0000 4 135 105 2175 3450 0\001
+4 0 2 50 -1 0 12 0.0000 4 135 105 3450 3300 1\001
+4 0 1 50 -1 0 12 0.0000 4 135 105 3825 3300 1\001
+4 0 1 50 -1 0 12 0.0000 4 135 105 5025 3375 2\001
+4 0 1 50 -1 0 12 0.0000 4 135 105 3750 2025 3\001
+4 0 1 50 -1 0 12 0.0000 4 135 105 4950 2025 4\001
+4 0 1 50 -1 0 12 0.0000 4 135 105 4950 4875 0\001
+4 0 1 50 -1 0 12 0.0000 4 135 105 4200 2850 1\001
+4 0 0 50 -1 0 20 0.0000 4 300 885 8625 1275 Target\001
+4 0 1 50 -1 0 12 0.0000 4 135 105 7575 4725 0\001
+4 0 1 50 -1 0 12 0.0000 4 135 105 7500 2475 2\001
+4 0 0 50 -1 0 12 0.0000 4 135 105 7725 5100 0\001
+4 0 0 50 -1 0 12 0.0000 4 135 105 10125 5100 1\001
+4 0 0 50 -1 0 12 0.0000 4 135 105 10425 2400 2\001
+4 0 2 50 -1 0 12 0.0000 4 135 105 9000 3300 0\001
+4 0 2 50 -1 0 12 0.0000 4 135 105 7800 2175 1\001
+4 0 2 50 -1 0 12 0.0000 4 135 105 10050 2175 2\001
+4 0 1 50 -1 0 12 0.0000 4 135 105 8700 3600 1\001
+4 0 2 50 -1 0 12 0.0000 4 135 105 3525 2025 3\001
+4 0 2 50 -1 0 12 0.0000 4 135 105 2325 2025 2\001
namespace is visible ( by calling for example \c using \c
namespace \c ParaMEDMEM; ).
-Here a description of typical usages to use MEDCoupling arrays.
+Here a description of typical usages to use \ref ParaMEDMEM::DataArrayDouble "MEDCoupling arrays".
In this example we will create arrays with 12 tuples constituted each
of 3 components. These arrays will be created using different ways.
mesh have the same dimension)
- a space dimension (relative to coordinates)
- a number of nodes
-- a number of cells
+- a number of cells
+
+In MEDCoupling library there is no presence of faces nor edges.
+
+As a mesh has one dimension and only once, that is to say every cells in
+mesh have the same dimension called MeshDimension.
+
+That is to say the
+MEDMEM vocabulary of faces and edges \b do \b not \b exist \b anymore here in
+MEDCoupling.
+
+For exemple a mesh with a meshDimension equal to 1, have \b cells of type
+NORM_SEG2. An another exemple, a mesh with a meshDimension equal
+to 2, have \b cells of type
+NORM_TRI3 and NORM_POLYGON for example.
The class that incarnates the concept described above is :
\ref ParaMEDMEM::MEDCouplingMesh.
represent fields used by system code. This type of mesh will have
mesh dimension equal to -1.
-The norm used for cells connectivity of different types, is the same as specified in MED file execpt
+The norm used for cells connectivity of different types, is the same as specified in MED file except
that connectivities are in represented in \b C \b format and \b not \b in
\b FORTRAN \b format !
/*!
-\page medloader MEDLoader
+\page medloader %MEDLoader
\section MEDLoaderIntro Introduction
-MEDLoader is a package in charge of loading from a file or write to a file
+%MEDLoader is a package in charge of loading from a file or write to a file
in MED format a \ref medcoupling data structure. The fact that these
functionalities are not merged in \ref medcoupling is explained by a
willingness of reducing as much as possible the dependancies of \ref medcoupling libraries.
As a MED file can combine several \ref medcoupling aspects in one (for exemple meshes in
-MED file on different mesh dimension with families and groups) the API of MEDLoader is much more rich than simply read and write.
+MED file on different mesh dimension with families and groups) the API
+of %MEDLoader is much more rich than simply read and write.
-MEDLoader offers \b static methods whose method names have the first
+MEDCoupling mesh does \b not fit a MED file mesh, and a MEDCoupling
+field does \b not fit a MED file field. But it is possible to emulate
+with a very good fidelity a MED file mesh and a MED file field with
+a collection of MEDCoupling instances for each.
+
+That's why %MEDLoader module offers two different approaches to perform Read/Write from/to MED
+file.
+
+- Either the user is close too MEDCoupling concepts. This is the case
+if pieces of information to access or to write are \b directly
+mapped to a MEDCouplingMesh/MEDCouplingFieldDouble in MEDCoupling package. \nIn this case, the \ref MEDLoaderBasicAPI "basic API" is recommended in this case because simpler and faster.
+
+- Or the user knows the MED file concept well and if nature of
+information to deal with do not fit exactly the class offered by
+MEDCoupling, the \ref MEDLoaderAdvancedAPI "advanced API" is
+recommended. This is typically the case for a user that wants to precisely set/get
+mesh/group/family groups set on different level lying on a same field defined
+partially... This API is faster, all information contained in file is represented, but
+less check is performed.\n This API is recommended for users that want to operate directly on MED files (split of MED files for example)
+
+The two methods are \b not opposed, they are compatible each other so
+it is possible to mix them. But the user should keep in mind that
+behaviour of these two methods can vary.
+
+*/
+
+/*!
+\page MEDLoaderBasicAPI Basic %MEDLoader API.
+
+The aim of this page is to present basic API of MEDLoader. 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 method names have the first
character in capital. You are intended to use these methods. The following
chapters will try to describe in details some of important ones.
MED file. A field f with \ref ParaMEDMEM::MEDCouplingTimeDiscretization
"time discretization" set to ONE_TIME, the value of
\c f->getTime(time,iteration,order) are used by MEDLoader to store
-identifies the field into MED file. All strings used by MEDLoader to
+to identify the field into MED file. All strings used by MEDLoader to
use it into MED file should fulfill the rules of MED file where length
are limited.
That's why the user should be aware of these constaints when trying to read/write a MED file using MEDLoader.
Here we will describes some of basic concepts of MED files in order to
use the best methods proposed by MEDLoader API.
-\subsection MEDLoaderMEDFileGen Basics in MED files
+\subsection BasicMEDLoaderAPIGen Basics in MED files
First of all MEDLoader \b will \b not read MED files whose version is
\b lower \b than \b 2.2. The MEDLoader::CheckFileForRead will perform
each time, at field-read time, the type of field, the iteration and order
number the mesh you are interested in.
-\subsection MEDLoaderMEDFileMesh Meshes in MED files
+\subsection BasicMEDLoaderAPIMesh Meshes in MED files
In MED file meshes could combine in one unstructured mesh cells that
have different dimension. For example it is possible to mix
-MED_TETRA4, MED_TRIA6, MED_SEG2, MED_POINT0, MED_POLYGON,
+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 MEDCouplingUMeshes "here". So to \b read such mesh it
is important to know which meshdimension you are interested to. In API
\anchor MEDLoaderExample2
- Consider an another mesh called "Example2" in file "file2.med"
containing MED_POLYHEDRA, MED_TETRA4, MED_QUAD8, MED_TRI6, MED_SEG2
-and MED_POINT0. In this case you will have :
+and MED_POINT1. In this case you will have :
\code
assert(3==MEDLoader::ReadUMeshDimFromFile("file2.med","Example2"));
MEDCouplingUMesh *m1D=MEDLoader::ReadUMeshFromFile("file2.med","Example2",-2);
\endcode
-And finally for 0D cells (MED_POINT0) you will write :
+And finally for 0D cells (MED_POINT1) you will write :
\code
MEDCouplingUMesh *m0D=MEDLoader::ReadUMeshFromFile("file2.med","Example2",-3);
MEDCoupling cells into the file. So if the renumbering of cells in MED
file is not correct an exception will be thrown.
-\subsection MEDLoaderMEDFilePoMesh Part of meshes in MED files
+\subsection BasicMEDLoaderAPIPoMesh Part of meshes in MED files
A mesh contains one or more families on nodes and/or on cells. A family is a partition
(mathematical sense) of the mesh it lies to. A family can be described
This method allows you to combine several families and groups in the
same returned mesh.
-\subsection MEDLoaderMEDFileField Reading a field at one time step in MED files
+\subsection BasicMEDLoaderAPIField Reading a field at one time step in MED files
A field at one time step on one mesh, with one entity (cell, node)
lies on all mesh on on a part of it. In this last case a definition of
is not needed here.
*/
+
+/*!
+\page MEDLoaderAdvancedAPI Advanced %MEDLoader API.
+
+This method is much closer to MED file organization than \ref
+MEDLoaderBasicAPI "basic MEDLoader API". All MED file
+concepts are exposed to the user. As a consequence, this advanced
+API is lead to change with MED file data model enhancement.
+
+In reading mode, the user can scan entirely and directly the content of its MED file as it is organized in its MED file.
+Inversely, in writing mode, the user can describe its data in the same
+way that MED file does.
+
+\section AdvMEDLoaderBasics Some of basic parameters appearing in advanced API
+
+- Like basic %MEDLoader API there is a notion of \c meshDimRelToMax.
+Each time This parameter appears in API, it will have the semantic
+explain here.
+The value of the parameter \c meshDimRelToMax is at most in {0,-1,-2,-3}. This relative value specifies a level
+relative to value returned by \c myMedMesh->getMeshDimension().
+
+A mesh containing MED_TETRA4, MED_TRI3, MED_QUAD4 and MED_POINT1 has a meshDimension
+equal to 3. For \c meshDimRelToMax equal to 0 the user will
+deal with cells whose type has a dimension equal to 3+0, that is to
+say here MED_TETRA4. For \c meshDimRelToMax equal to -1 the user will
+deal with cells witch dimension equal to 3-1 that is to say MED_TRI3
+and MED_QUAD4.
+
+An important method is \c getNonEmptyLevels() method. It returns all
+non empty levels available. In the previous example, this method will
+return {0,-1,-3}. -2 does not appear because no cells with dimension
+equal to 1 (3-2) appear in MED file mesh (no MED_SEG2 not MED_SEG3).
+
+- Besides notion of \c meshDimRelToMax there is notion of \c meshDimRelToMaxExt.
+\c meshDimRelToMaxExt is simply an extension of \c meshDimRelToMax for
+nodes.
+
+The parameter of \c meshDimRelToMaxExt appears in
+\ref ParaMEDMEM::MEDFileUMesh "umesh advanced API" of %MEDLoader with the following semantics.
+
+Some of MED file concepts are available both for cells and
+nodes, (for example families, groups, numbering ) that's why for a simpler API this
+concept has been introduced. \c meshDimRelToMaxExt parameter can take a value in at
+most {1,0,-1,-2,-3}.
+1 stands for node and 0,-1,-2,-3 has exactly the
+same semantic than those described in \c meshDimRelToMax decribed
+before.
+
+- A parameter that also often appears in advanced %MEDLoader API is \c renum.
+This parameter by default in advanced %MEDLoader API is set to \c
+true.
+This parameter indicates if the user intend to take into account
+of the renumbering array of cells of the current MED file mesh.
+If no renumbering array is defined, this parameter is ignored by
+%MEDLoader.
+
+If such renumbering exists and the \c renum parameter is
+set to \c true, then the renumbering is taken into account. This is
+exactly the behaviour of \ref MEDLoader::ReadUMeshFromFile "basic MEDLoader API".
+If the user expects to ignore this renumbering even in case of
+presence of renumbering array, false should be passed to \c renum
+parameter. \b The \b parameter \b renum \b should \b be \b set \b with
+\b cauton \b for \b users \b concerned \b by \b cells \b orders.
+
+- A laster important parameter is the \c mode during writing. The
+ available values for the parameter \c mode are :
+ - 2 : for a write from scratch. If file already exists, file will be
+ erased and replace by the content of the instance on which \c write
+ method has been calles.
+ - 1 : If the file does not exists equivalent to 2. If file already
+ exists, the write is done on APPEND mode. That is to say that no
+ data loss will occur. But in case that an element with same ids than
+ current instance already exists, the content is not written and an
+ exception is thrown.
+ - 0 : If the file does not exists equivalent to 2. If file already
+ exists write without any question. If an element with same ids
+ existed previously the content is overwritten by the content of the
+ current instance, that can lead to a file corruption.
+
+\section AdvMEDLoaderAPIReading Reading from a file with advanced API.
+
+Contrary to the basic %MEDLoader API, here after reading process, the user
+has to deal with a new instance of class that fits the MED file model.
+To access to a MEDCoupling mesh the user should request this class
+instance.
+
+\subsection AdvMEDLoaderAPIMeshReading Reading a mesh.
+
+The class that incarnates Read/Write mesh in MED file is ParaMEDMEM::MEDFileUMesh.
+
+First of all, like basic %MEDLoader API, only MEDfile files whose version >= 2.2 are able
+to be read with advanced API.
+
+To read a mesh having the name \c meshName in file \c fileName the
+following simple code has to be written :
+
+\code
+
+MEDFileUMesh *myMedMesh=MEDFileUMesh::New(fileName,meshName);
+
+\endcode
+
+If the user do not know the name of the mesh inside MED file
+'fileName' the following code should be written :
+
+\code
+
+MEDFileUMesh *myMedMesh=MEDFileUMesh::New(fileName);
+
+\endcode
+
+In this case the first mesh (in MED file sense) found in \c fileName
+file will be loaded.
+
+Now the user can ask for mesh dimension of of \c myMedMesh instance by
+calling \c myMedMesh->getMeshDimension(). This method returns the
+highest level of present cell in MED file mesh \c myMedMesh.
+This returned integer is computed and \b not those contained in MED file
+that can be invalid.
+
+\n
+
+- Retrieving a mesh at a specified relative level \c meshDimRelToMax=mdrm : simply call
+ - \c myMedMesh->getMeshAtLevel(mdrm)
+ - or \c myMedMesh->getLevel0Mesh() or \c
+ myMedMesh->getLevelM1Mesh(), or \c myMedMesh->getLevelM2Mesh()
+ depending on the value of mdrm
+
+
+- Retrieving a family at a specified level :
+ - Either an array of node/cell id
+ - \c getFamilyArr method or \c getFamiliesArr
+ - Or on \ref ParaMEDMEM::MEDCouplingUMesh "MEDCouplingUMesh" form by calling
+ - \c getFamily method or \c getFamilies
+
+- Retrieving a group at a specified level :
+ - Either an array of node/cell id
+ - \c getGroupArr method or \c getGroupsArr
+ - Or on \ref ParaMEDMEM::MEDCouplingUMesh "MEDCouplingUMesh" form by calling
+ - \c getGroup method or \c getGroups
+
+- Retrieving family field array :
+Method \c getFamilyFieldAtLevel retrieves for a specified extended level the
+family id of each cell or node.
+
+- Retrieving renumbering array :
+Method \c getNumberFieldAtLevel returns, if it exists for a specified extended level, the
+family id of each cell or node. If it does not exist an exception will
+be thrown.
+
+An important point is that families and groups are \b not sorted in
+MED file. No sort is stored in MED file explicitely for Groups and
+Families. Advanced %MEDLoader API, uses the same order than underlying
+mesh at specified level.
+
+\subsection AdvMEDLoaderAPIMeshReadingSampl Sample of reading a mesh.
+
+Here a typical use of \ref ParaMEDMEM::MEDCouplingUMesh "MEDCouplingUMesh" instance.
+
+\code
+
+const char fileName[]=...;
+const char meshName[]=...;
+MEDFileUMesh *medmesh=MEDFileUMesh::New(fileName,meshName);
+std::vector<int> nel=medmesh->getNonEmptyLevels();
+if(nel.size()<1)
+ throw INTERP_KERNEL::Exception("The test is not good for my file ! Expecting a multi level mesh to play with !");
+MEDCouplingUMesh *m0=medmesh->getMeshAtLevel(nel[1],false);
+MEDCouplingUMesh *g1=medmesh->getGroup(nel[1],"mesh2",false);
+DataArrayInt *dag1=medmesh->getGroupArr(nel[1],"mesh2",false);
+MEDCouplingUMesh *g1bis=m0->buildPartOfMySelf(dag1->getConstPointer(),dag1->getConstPointer()+dag1->getNbOfElems());
+g1bis->setName(dag1->getName());
+if(!g1->isEqual(g1bis,1e-12))
+ throw INTERP_KERNEL::Exception("hmmmm :g1 and g1bis should be equal...");
+//
+dag1->decrRef();
+g1->decrRef();
+m0->decrRef();
+medmesh->decrRef();
+
+\endcode
+
+\subsection AdvMEDLoaderAPIMeshWriting Writing a mesh.
+
+The use is very symetric to reading part. It is possible to either
+build a \ref ParaMEDMEM::MEDFileUMesh "MEDFileUMesh" instance from
+scratch, or to work with an existing instance coming from a loading
+from a file.
+
+One important point is that coordinates of a mesh are shared by all
+cells whatever their level. That's why the
+\ref ParaMEDMEM::DataArrayDouble "DataArrayDouble" instance
+should be shared by all \ref ParaMEDMEM::MEDCouplingUMesh "MEDCouplingUMesh" used in input parameter of
+set* methods. If the user intend to build a \ref ParaMEDMEM::MEDFileUMesh "MEDFileUMesh" instance from
+scratch, a call to \c setCoords should be done first.
+
+
+Generally speaking traduce get* methods with set* methods have corresponding write semantic.
+
+Some differences still exist :
+
+- \c setMeshAtLevel, \c setMeshAtLevelOld simply call \c setMeshAtLevelGen with repectively \c newOrOld parameter
+set to true and false. These method specifies if a renumbering computation is needed or not. \c setMeshAtLevelOld is faster
+than \c setMeshAtLevel because no renumbering computation is done. If the user is not warranty about the order of its meshes to enter
+it is better to use \c setMeshAtLevel method.
+
+- Groups definition : Groups constitution is time consuming because of the stored mode chosen by MED file to store them. Groups definition
+lead to a partition computation which is time/mem consuming that's why groups should be defined at once and not with addGroup one by one that will lead to
+compute a partition for each appended group. One important point to note is that DataArrayInt instance given in input to define groups should have its name
+set to the desired group name. If not an exception will be thrown, because MED file does not support groups with no name.
+
+\subsection AdvMEDLoaderAPIMeshWritingSampl Sample of writing a mesh.
+
+\code
+
+MEDCouplingUMesh *m=...; //m is a mesh with meshDim=2 spaceDim=2
+MEDCouplingUMesh *m1=...; //m1 is a mesh with meshDim=1 spaceDim=2 same coords than m
+MEDCouplingUMesh *m2=...; //m2 is a mesh with meshDim=0 spaceDim=2 same coords than m
+MEDFileUMesh *mm=MEDFileUMesh::New();
+mm->setName("mm");//name needed to be non empty
+mm->setDescription("Description mm");
+mm->setCoords(m1->getCoords());
+mm->setMeshAtLevel(-1,m1,false);
+mm->setMeshAtLevel(0,m,false);
+mm->setMeshAtLevel(-2,m2,false);
+DataArrayInt *g1=DataArrayInt::New();
+g1->alloc(2,1);
+g1->setName("G1");
+const int val1[2]={1,3};
+std::copy(val1,val1+2,g1->getPointer());
+DataArrayInt *g2=DataArrayInt::New();
+g2->alloc(3,1);
+g2->setName("G2");
+const int val2[3]={1,2,3};
+std::copy(val2,val2+3,g2->getPointer());
+//
+std::vector<const DataArrayInt *> grps(2);
+grps[0]=g1; grps[1]=g2;
+mm->setGroupsAtLevel(0,grps,false);
+//
+g2->decrRef();
+g1->decrRef();
+//
+mm->write(2);
+
+
+\endcode
+
+*/
+
- \ref interpkerneldec for a \ref InterpKerRemapGlobal based on intersecting elems volume computation,
- \ref noncoincidentdec for a non-conservative interpolation based on element localization,
- \ref structuredcoincidentdec for remapping coincident meshes on a one-to-one basis. This class applies to structured topologies.
- - \ref explicitcoincidentdec for remapping coincident meshes on a one-to-one basis. This class applies to unstructured topologies,
+ - \ref explicitcoincidentdec for remapping coincident meshes on a
+ one-to-one basis. This class applies to unstructured topologies,
+ - \ref overlapdec based on intersecting elems volume
+ computation with source and target meshes are on same process id
*/
--- /dev/null
+// Copyright (C) 2007-2010 CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#ifndef __INTERPKERNELAUTOPTR_HXX__
+#define __INTERPKERNELAUTOPTR_HXX__
+
+namespace INTERP_KERNEL
+{
+ template<class T>
+ class AutoPtr
+ {
+ public:
+ AutoPtr(T *ptr=0):_ptr(ptr) { }
+ ~AutoPtr() { destroyPtr(); }
+ AutoPtr &operator=(T *ptr) { destroyPtr(); _ptr=ptr; return *this; }
+ T *operator->() { return _ptr ; }
+ const T *operator->() const { return _ptr; }
+ T& operator*() { return *_ptr; }
+ const T& operator*() const { return *_ptr; }
+ operator T *() { return _ptr; }
+ operator const T *() const { return _ptr; }
+ private:
+ void destroyPtr() { delete [] _ptr; }
+ private:
+ T *_ptr;
+ };
+}
+
+#endif
namespace INTERP_KERNEL
{
- class INTERPKERNELBASES_EXPORT Exception : std::exception
+ class INTERPKERNELBASES_EXPORT Exception : public std::exception
{
public:
Exception(const char *what);
class _HashFn = hash<_Key>,
class _EqualKey = std::equal_to<_Key>,
class _Alloc = std::allocator<_Tp> >
- class hash_multimap
+ class HashMultiMap
{
private:
typedef hashtable<std::pair<const _Key, _Tp>, _Key, _HashFn,
allocator_type get_allocator() const { return _M_ht.get_allocator(); }
- hash_multimap() : _M_ht(100, hasher(), key_equal(), allocator_type()) { }
+ HashMultiMap() : _M_ht(100, hasher(), key_equal(), allocator_type()) { }
- explicit hash_multimap(size_type __n) : _M_ht(__n, hasher(), key_equal(), allocator_type()) {}
+ explicit HashMultiMap(size_type __n) : _M_ht(__n, hasher(), key_equal(), allocator_type()) {}
- hash_multimap(size_type __n, const hasher& __hf) : _M_ht(__n, __hf, key_equal(), allocator_type()) {}
+ HashMultiMap(size_type __n, const hasher& __hf) : _M_ht(__n, __hf, key_equal(), allocator_type()) {}
- hash_multimap(size_type __n, const hasher& __hf, const key_equal& __eql,
- const allocator_type& __a = allocator_type()) : _M_ht(__n, __hf, __eql, __a) {}
+ HashMultiMap(size_type __n, const hasher& __hf, const key_equal& __eql,
+ const allocator_type& __a = allocator_type()) : _M_ht(__n, __hf, __eql, __a) {}
template<class _InputIterator>
- hash_multimap(_InputIterator __f, _InputIterator __l) : _M_ht(100, hasher(), key_equal(), allocator_type())
+ HashMultiMap(_InputIterator __f, _InputIterator __l) : _M_ht(100, hasher(), key_equal(), allocator_type())
{ _M_ht.insert_equal(__f, __l); }
template<class _InputIterator>
- hash_multimap(_InputIterator __f, _InputIterator __l, size_type __n) : _M_ht(__n, hasher(), key_equal(), allocator_type())
+ HashMultiMap(_InputIterator __f, _InputIterator __l, size_type __n) : _M_ht(__n, hasher(), key_equal(), allocator_type())
{ _M_ht.insert_equal(__f, __l); }
template<class _InputIterator>
- hash_multimap(_InputIterator __f, _InputIterator __l, size_type __n, const hasher& __hf)
+ HashMultiMap(_InputIterator __f, _InputIterator __l, size_type __n, const hasher& __hf)
: _M_ht(__n, __hf, key_equal(), allocator_type())
{ _M_ht.insert_equal(__f, __l); }
template<class _InputIterator>
- hash_multimap(_InputIterator __f, _InputIterator __l, size_type __n,
- const hasher& __hf, const key_equal& __eql,
- const allocator_type& __a = allocator_type())
+ HashMultiMap(_InputIterator __f, _InputIterator __l, size_type __n,
+ const hasher& __hf, const key_equal& __eql,
+ const allocator_type& __a = allocator_type())
: _M_ht(__n, __hf, __eql, __a)
{ _M_ht.insert_equal(__f, __l); }
bool empty() const { return _M_ht.empty(); }
- void swap(hash_multimap& __hs) { _M_ht.swap(__hs._M_ht); }
+ void swap(HashMultiMap& __hs) { _M_ht.swap(__hs._M_ht); }
template<class _K1, class _T1, class _HF, class _EqK, class _Al>
- friend bool operator==(const hash_multimap<_K1, _T1, _HF, _EqK, _Al>&,
- const hash_multimap<_K1, _T1, _HF, _EqK, _Al>&);
+ friend bool operator==(const HashMultiMap<_K1, _T1, _HF, _EqK, _Al>&,
+ const HashMultiMap<_K1, _T1, _HF, _EqK, _Al>&);
iterator begin() { return _M_ht.begin(); }
};
template<class _Key, class _Tp, class _HF, class _EqKey, class _Alloc>
- inline bool operator==(const hash_multimap<_Key, _Tp, _HF, _EqKey, _Alloc>& __hm1,
- const hash_multimap<_Key, _Tp, _HF, _EqKey, _Alloc>& __hm2)
+ inline bool operator==(const HashMultiMap<_Key, _Tp, _HF, _EqKey, _Alloc>& __hm1,
+ const HashMultiMap<_Key, _Tp, _HF, _EqKey, _Alloc>& __hm2)
{ return __hm1._M_ht == __hm2._M_ht; }
template<class _Key, class _Tp, class _HF, class _EqKey, class _Alloc>
- inline bool operator!=(const hash_multimap<_Key, _Tp, _HF, _EqKey, _Alloc>& __hm1,
- const hash_multimap<_Key, _Tp, _HF, _EqKey, _Alloc>& __hm2)
+ inline bool operator!=(const HashMultiMap<_Key, _Tp, _HF, _EqKey, _Alloc>& __hm1,
+ const HashMultiMap<_Key, _Tp, _HF, _EqKey, _Alloc>& __hm2)
{ return !(__hm1 == __hm2); }
template<class _Key, class _Tp, class _HashFn, class _EqlKey, class _Alloc>
- inline void swap(hash_multimap<_Key, _Tp, _HashFn, _EqlKey, _Alloc>& __hm1,
- hash_multimap<_Key, _Tp, _HashFn, _EqlKey, _Alloc>& __hm2)
+ inline void swap(HashMultiMap<_Key, _Tp, _HashFn, _EqlKey, _Alloc>& __hm1,
+ HashMultiMap<_Key, _Tp, _HashFn, _EqlKey, _Alloc>& __hm2)
{ __hm1.swap(__hm2); }
}
namespace std
{
// Specialization of insert_iterator so that it will work for HashMap
- // and hash_multimap.
+ // and HashMultiMap.
template<class _Key, class _Tp, class _HashFn, class _EqKey, class _Alloc>
class insert_iterator<INTERP_KERNEL::HashMap<_Key, _Tp, _HashFn,
_EqKey, _Alloc> >
};
template<class _Key, class _Tp, class _HashFn, class _EqKey, class _Alloc>
- class insert_iterator<INTERP_KERNEL::hash_multimap<_Key, _Tp, _HashFn,
- _EqKey, _Alloc> >
+ class insert_iterator<INTERP_KERNEL::HashMultiMap<_Key, _Tp, _HashFn,
+ _EqKey, _Alloc> >
{
protected:
- typedef INTERP_KERNEL::hash_multimap<_Key, _Tp, _HashFn, _EqKey, _Alloc>
+ typedef INTERP_KERNEL::HashMultiMap<_Key, _Tp, _HashFn, _EqKey, _Alloc>
_Container;
_Container* container;
typename _Container::iterator iter;
InterpKernelStlExt.hxx \
InterpKernelHashMap.hxx \
InterpKernelHashTable.hxx \
-InterpKernelHashFun.hxx
+InterpKernelHashFun.hxx \
+InterpKernelAutoPtr.hxx
# Libraries targets
typedef enum
{
- NORM_POINT0 = 0,
+ NORM_POINT1 = 0,
NORM_SEG2 = 1,
NORM_SEG3 = 2,
NORM_TRI3 = 3,
NORM_PENTA6 = 16,
NORM_HEXA8 = 18,
NORM_TETRA10 = 20,
+ NORM_HEXGP12 = 22,
NORM_PYRA13 = 23,
NORM_PENTA15 = 25,
NORM_HEXA20 = 30,
namespace INTERP_KERNEL
{
- const char *CellModel::CELL_TYPES_REPR[]={"NORM_POINT0", "NORM_SEG2", "NORM_SEG3", "NORM_TRI3", "NORM_QUAD4",// 0->4
+ const char *CellModel::CELL_TYPES_REPR[]={"NORM_POINT1", "NORM_SEG2", "NORM_SEG3", "NORM_TRI3", "NORM_QUAD4",// 0->4
"NORM_POLYGON", "NORM_TRI6", "" , "NORM_QUAD8", "",//5->9
"", "", "", "", "NORM_TETRA4",//10->14
"NORM_PYRA5", "NORM_PENTA6", "", "NORM_HEXA8", "",//15->19
- "NORM_TETRA10", "", "", "NORM_PYRA13", "",//20->24
+ "NORM_TETRA10", "", "NORM_HEXGP12", "NORM_PYRA13", "",//20->24
"NORM_PENTA15", "", "", "", "",//25->29
"NORM_HEXA20", "NORM_POLYHED", "", "", "",//30->34
"", "", "", "", "",//35->39
void CellModel::buildUniqueInstance()
{
- _map_of_unique_instance.insert(std::make_pair(NORM_POINT0,CellModel(NORM_POINT0)));
+ _map_of_unique_instance.insert(std::make_pair(NORM_POINT1,CellModel(NORM_POINT1)));
_map_of_unique_instance.insert(std::make_pair(NORM_SEG2,CellModel(NORM_SEG2)));
_map_of_unique_instance.insert(std::make_pair(NORM_SEG3,CellModel(NORM_SEG3)));
_map_of_unique_instance.insert(std::make_pair(NORM_TRI3,CellModel(NORM_TRI3)));
_map_of_unique_instance.insert(std::make_pair(NORM_PYRA5,CellModel(NORM_PYRA5)));
_map_of_unique_instance.insert(std::make_pair(NORM_PENTA6,CellModel(NORM_PENTA6)));
_map_of_unique_instance.insert(std::make_pair(NORM_TETRA10,CellModel(NORM_TETRA10)));
+ _map_of_unique_instance.insert(std::make_pair(NORM_HEXGP12,CellModel(NORM_HEXGP12)));
_map_of_unique_instance.insert(std::make_pair(NORM_PYRA13,CellModel(NORM_PYRA13)));
_map_of_unique_instance.insert(std::make_pair(NORM_PENTA15,CellModel(NORM_PENTA15)));
_map_of_unique_instance.insert(std::make_pair(NORM_HEXA20,CellModel(NORM_HEXA20)));
_quadratic_type=NORM_ERROR;
switch(type)
{
- case NORM_POINT0:
+ case NORM_POINT1:
{
- _nb_of_pts=0; _nb_of_sons=0; _dim=0; _extruded_type=NORM_SEG2; _is_simplex=true;
+ _nb_of_pts=1; _nb_of_sons=0; _dim=0; _extruded_type=NORM_SEG2; _is_simplex=true;
}
break;
case NORM_SEG2:
_sons_con[3][0]=2; _sons_con[3][1]=3; _sons_con[3][2]=0; _sons_con[3][3]=9; _sons_con[3][4]=7; _sons_con[3][5]=6; _nb_of_sons_con[3]=6; _quadratic=true;
}
break;
+ case NORM_HEXGP12:
+ {
+ _nb_of_pts=12; _nb_of_sons=8; _dim=3; _is_simplex=false;
+ _sons_type[0]=NORM_POLYGON; _sons_type[1]=NORM_POLYGON; _sons_type[2]=NORM_QUAD4; _sons_type[3]=NORM_QUAD4; _sons_type[4]=NORM_QUAD4; _sons_type[5]=NORM_QUAD4;
+ _sons_type[6]=NORM_QUAD4; _sons_type[7]=NORM_QUAD4;
+ _sons_con[0][0]=0; _sons_con[0][1]=1; _sons_con[0][2]=2; _sons_con[0][3]=3; _sons_con[0][4]=4; _sons_con[0][5]=5; _nb_of_sons_con[0]=6;
+ _sons_con[1][0]=6; _sons_con[1][1]=11; _sons_con[1][2]=10; _sons_con[1][3]=9; _sons_con[1][4]=8; _sons_con[1][5]=7; _nb_of_sons_con[1]=6;
+ _sons_con[2][0]=0; _sons_con[2][1]=6; _sons_con[2][2]=7; _sons_con[2][3]=1; _nb_of_sons_con[2]=4;
+ _sons_con[3][0]=1; _sons_con[3][1]=7; _sons_con[3][2]=8; _sons_con[3][3]=2; _nb_of_sons_con[3]=4;
+ _sons_con[4][0]=2; _sons_con[4][1]=8; _sons_con[4][2]=9; _sons_con[4][3]=3; _nb_of_sons_con[4]=4;
+ _sons_con[5][0]=3; _sons_con[5][1]=9; _sons_con[5][2]=10; _sons_con[5][3]=4; _nb_of_sons_con[5]=4;
+ _sons_con[6][0]=4; _sons_con[6][1]=10; _sons_con[6][2]=11; _sons_con[6][3]=5; _nb_of_sons_con[6]=4;
+ _sons_con[7][0]=5; _sons_con[7][1]=11; _sons_con[7][2]=6; _sons_con[7][3]=0; _nb_of_sons_con[7]=4;
+ }
+ break;
case NORM_PYRA13:
{
_nb_of_pts=13; _nb_of_sons=5; _dim=3; _linear_type=NORM_PYRA5; _is_simplex=false;
class CellModel
{
public:
- static const unsigned MAX_NB_OF_SONS=6;
+ static const unsigned MAX_NB_OF_SONS=8;
static const unsigned MAX_NB_OF_NODES_PER_ELEM=30;
private:
CellModel(NormalizedCellType type);
#include <sstream>
#include <algorithm>
+#ifdef _POSIX_MAPPED_FILES
+#include <sys/mman.h>
+#else
+#ifdef WNT
+#include <windows.h>
+#endif
+#endif
+
const char *INTERP_KERNEL::AsmX86::OPS[NB_OF_OPS]={"mov","push","pop","fld","faddp","fsubp","fmulp","fdivp","fcos","fsin","fabs","fchs","fsqrt","sub","add","ret","leave","movsd","fst"};
std::vector<char> INTERP_KERNEL::AsmX86::convertIntoMachineLangage(const std::vector<std::string>& asmb) const throw(INTERP_KERNEL::Exception)
return ret;
}
-char *INTERP_KERNEL::AsmX86::convertMachineLangageInBasic(const std::vector<char>& ml, int& lgth) const
+char *INTERP_KERNEL::AsmX86::copyToExecMemZone(const std::vector<char>& ml, unsigned& offset) const
{
- lgth=ml.size();
- char *ret=new char[lgth];
- std::copy(ml.begin(),ml.end(),ret);
+ char *ret=0;
+ int lgth=ml.size();
+#ifdef _POSIX_MAPPED_FILES
+ ret=(char *)mmap(0,lgth,PROT_EXEC | PROT_WRITE,MAP_ANONYMOUS | MAP_PRIVATE,-1,0);
+#else
+#ifdef WNT
+ HANDLE h=CreateFileMapping(INVALID_HANDLE_VALUE,NULL,PAGE_EXECUTE_READWRITE,0,lgth,NULL);
+ ret=(char *)MapViewOfFile(h,FILE_MAP_EXECUTE | FILE_MAP_READ | FILE_MAP_WRITE,0,0,lgth);
+#endif
+#endif
+ if(ret)
+ std::copy(ml.begin(),ml.end(),ret);
return ret;
}
{
public:
std::vector<char> convertIntoMachineLangage(const std::vector<std::string>& asmb) const throw(INTERP_KERNEL::Exception);
- char *convertMachineLangageInBasic(const std::vector<char>& ml, int& lgth) const;
+ char *copyToExecMemZone(const std::vector<char>& ml, unsigned& offset) const;
private:
void convertOneInstructionInML(const std::string& inst, std::vector<char>& ml) const throw(INTERP_KERNEL::Exception);
private:
#include <cctype>
#include <sstream>
+#include <limits>
#include <vector>
#include <iterator>
#include <iostream>
#include <algorithm>
-#ifdef _POSIX_MAPPED_FILES
-#include <sys/mman.h>
-#else
-#ifdef WNT
-#include <windows.h>
-#endif
-#endif
-
using namespace INTERP_KERNEL;
const char LeafExprVar::END_OF_RECOGNIZED_VAR[]="Vec";
val->setDouble(_value);
}
+void LeafExprVal::replaceValues(const std::vector<double>& valuesInExpr) throw(INTERP_KERNEL::Exception)
+{
+ int pos=(int)_value;
+ int lgth=valuesInExpr.size();
+ if(pos>=lgth || pos<0)
+ throw INTERP_KERNEL::Exception("LeafExprVal::replaceValues : Big Problem detected ! Send expression to Salome support with expression !");
+ _value=valuesInExpr[pos];
+}
+
LeafExprVar::LeafExprVar(const std::string& var):_fast_pos(-1),_var_name(var)
{
}
return true;
}
+/*!
+ * Nothing to do it is not a bug.
+ */
+void LeafExprVar::replaceValues(const std::vector<double>& valuesInExpr) throw(INTERP_KERNEL::Exception)
+{
+}
+
LeafExprVar::~LeafExprVar()
{
}
ExprParser::ExprParser(const char *expr, ExprParser *father):_father(father),_is_parsed(false),_leaf(0),_is_parsing_ok(false),_expr(expr)
{
+ _expr=deleteWhiteSpaces(_expr);
}
//! For \b NOT null terminated strings coming from FORTRAN.
ExprParser::ExprParser(const char *expr, int lgth, ExprParser *father):_father(father),_is_parsed(false),_leaf(0),_is_parsing_ok(false)
{
_expr=buildStringFromFortran(expr,lgth);
+ _expr=deleteWhiteSpaces(_expr);
}
ExprParser::~ExprParser()
releaseFunctions();
}
-std::size_t ExprParser::findCorrespondingOpenBracket(const std::string& expr, std::size_t posOfCloseBracket)
+std::size_t ExprParser::FindCorrespondingOpenBracket(const std::string& expr, std::size_t posOfCloseBracket)
{
int level=0;
- for(std::size_t iter=posOfCloseBracket-1;iter>=0;iter--)
- if(expr[iter]==')')
- level++;
- else if(expr[iter]=='(')
- {
- if(level==0)
- return iter;
- else
- level--;
- }
+ for(std::size_t iter=0;iter<posOfCloseBracket;iter++)
+ {
+ std::size_t iter2=posOfCloseBracket-1-iter;
+ if(expr[iter2]==')')
+ level++;
+ else if(expr[iter2]=='(')
+ {
+ if(level==0)
+ return iter2;
+ else
+ level--;
+ }
+ }
return std::string::npos;
}
releaseFunctions();
if(!_expr.empty())
{
+ std::string tmp(_expr);
+ std::vector<double> valuesInExpr;
+ fillValuesInExpr(valuesInExpr);
checkBracketsParity();
if(!simplify())
parseDeeper();
+ replaceValues(valuesInExpr);
+ _expr=tmp;
}
_is_parsing_ok=true;
}
return ;
//at this level of code _expr
std::size_t pos1=_expr.find_first_of('(');
- std::size_t pos4=findCorrespondingOpenBracket(_expr,_expr.length()-1);
+ std::size_t pos4=FindCorrespondingOpenBracket(_expr,_expr.length()-1);
if(pos4!=pos1)
return ;
std::string funcName=_expr.substr(0,pos1);
- std::size_t pos2=funcName.find_first_of("+-*/^",0,5);
- std::size_t pos3=funcName.find_first_not_of("+-*/^",0,5);
+ std::size_t pos2=funcName.find_first_of("+-*/^><",0,7);
+ std::size_t pos3=funcName.find_first_not_of("+-*/^><",0,7);
if(pos2!=std::string::npos && pos3!=std::string::npos)
return ;//Bracket group is not alone, can't conclude not recursively.
std::string newExp2=_expr.substr(pos1+1,_expr.length()-pos1-2);
std::size_t pos6=0;
for(int i=0;i<nbOfParamsInFunc;i++)
{
- std::size_t pos5=newExp2.find_first_of(',');
+ std::size_t pos5=newExp2.find_first_of(',',pos6);
std::size_t len=std::string::npos;
if(pos5!=std::string::npos)
len=pos5-pos6;
{
std::size_t pos=_expr.find_first_not_of("+-",0,2);
std::string minimizedExpr=_expr.substr(pos);
- std::size_t pos2=minimizedExpr.find_first_of("+-*/^()",0,7);
+ std::size_t pos2=minimizedExpr.find_first_of("+-*/^()<>",0,9);
if(pos2!=std::string::npos)
return false;
delete _leaf;
return true;
}
+void ExprParser::parseForCmp() throw(INTERP_KERNEL::Exception)
+{
+ std::string::const_iterator iter;
+ int curLevel=0;
+ std::string curPart;
+ bool isParsingSucceed=false;
+ for(iter=_expr.begin();iter!=_expr.end();iter++)
+ {
+ switch(*iter)
+ {
+ case '>':
+ case '<':
+ {
+ isParsingSucceed=true;
+ if(!curPart.empty())
+ {
+ _sub_expr.push_back(ExprParser(curPart.c_str(),this));
+ curPart.clear();
+ _func_btw_sub_expr.push_back(FunctionsFactory::buildBinaryFuncFromString(*iter));
+ }
+ else
+ {
+ std::ostringstream errMsg;
+ char MSGTYP1[]="Error non unary function for '";
+ errMsg << EXPR_PARSE_ERR_MSG << MSGTYP1 << *iter << "'";
+ std::string tmp=_expr.substr(iter-_expr.begin());
+ LocateError(errMsg,tmp,0);
+ throw INTERP_KERNEL::Exception(errMsg.str().c_str());
+ }
+ break;
+ }
+ case '(':
+ curLevel++;
+ curPart+=*iter;
+ break;
+ case ')':
+ curLevel--;
+ curPart+=*iter;
+ break;
+ default:
+ curPart+=*iter;
+ }
+ }
+ if(isParsingSucceed)
+ {
+ if(!curPart.empty())
+ {
+ _sub_expr.push_back(ExprParser(curPart.c_str(),this));
+ _is_parsing_ok=true;
+ }
+ else
+ {
+ std::ostringstream errMsg;
+ char MSGTYP4[]="Error following expression finished by > / < without right part.";
+ errMsg << EXPR_PARSE_ERR_MSG << MSGTYP4 << _expr;
+ throw INTERP_KERNEL::Exception(errMsg.str().c_str());
+ }
+ }
+}
+
void ExprParser::parseForAddMin() throw(INTERP_KERNEL::Exception)
{
std::string::const_iterator iter;
char MSGTYP1[]="Error non unary function for '";
errMsg << EXPR_PARSE_ERR_MSG << MSGTYP1 << *iter << "'";
std::string tmp=_expr.substr(iter-_expr.begin());
- locateError(errMsg,tmp,0);
+ LocateError(errMsg,tmp,0);
throw INTERP_KERNEL::Exception(errMsg.str().c_str());
}
}
char MSGTYP1[]="Error non unary function for '";
errMsg << EXPR_PARSE_ERR_MSG << MSGTYP1 << *iter << "'";
std::string tmp=_expr.substr(iter-_expr.begin());
- locateError(errMsg,tmp,0);curPart+=*iter;
+ LocateError(errMsg,tmp,0);curPart+=*iter;
throw INTERP_KERNEL::Exception(errMsg.str().c_str());
}
break;
parseUnaryFunc();
if(!_is_parsing_ok)
{
- parseForAddMin();
+ parseForCmp();
if(!_is_parsing_ok)
{
- parseForMulDiv();
+ parseForAddMin();
if(!_is_parsing_ok)
- parseForPow();
+ {
+ parseForMulDiv();
+ if(!_is_parsing_ok)
+ parseForPow();
+ }
}
}
if(!_is_parsing_ok)
std::ostringstream errMsg;
char MSGTYP3[]="Error in interpreting : ";
errMsg << EXPR_PARSE_ERR_MSG << MSGTYP3 << _expr;
- locateError(errMsg,_expr,0);
+ LocateError(errMsg,_expr,0);
throw INTERP_KERNEL::Exception(errMsg.str().c_str());
}
return false;
std::ostringstream errMsg;
char MSGTYP1[]="Error in brackets : closing brackets ')' before openning '('";
errMsg << EXPR_PARSE_ERR_MSG << MSGTYP1;
- locateError(errMsg,_expr,iter-_expr.begin());
+ LocateError(errMsg,_expr,iter-_expr.begin());
throw INTERP_KERNEL::Exception(errMsg.str().c_str());
}
curLevel--;
}
}
-void ExprParser::locateError(std::ostream& stringToDisp, const std::string& srcOfErr, int posOfErr)
+/*!
+ * This method substitutes part in [bg,end) in expr by the content of (str(id)) and returns the double value representation in expr[bg,end).
+ * If double representation is invalid an exception is thrown.
+ * This method returns a delta that is the delta to operate to pos in expr after substitution.
+ */
+double ExprParser::ReplaceAndTraduce(std::string& expr, int id, std::size_t bg, std::size_t end, int& delta) throw(INTERP_KERNEL::Exception)
+{
+ static const char MSG[]="Interal error : A string expected to be a float is not one ! Bug to signal !";
+ std::istringstream stream;
+ std::ostringstream oss;
+ std::size_t end2=end!=std::string::npos?end-bg:end;
+ std::string tmp=expr.substr(bg,end2);
+ stream.str(tmp);
+ double ret=std::numeric_limits<double>::max();
+ stream >> ret;
+ if(stream.fail())
+ throw INTERP_KERNEL::Exception(MSG);
+ if(!stream.eof())
+ throw INTERP_KERNEL::Exception(MSG);
+ oss << id;
+ std::string tmp2(oss.str());
+ std::size_t l1=tmp.length();
+ delta=(int)tmp2.length()-(int)l1;
+ expr.replace(bg,l1,tmp2);
+ return ret;
+}
+
+/*!
+ * This method makes the assumption that _expr has no white space.
+ * This method scans _expr finding in greedy mode the following pattern :
+ * {0..9}+{.}?{0..9}*{{eE}{-}?{0..9}+}?
+ */
+void ExprParser::fillValuesInExpr(std::vector<double>& valuesInExpr) throw(INTERP_KERNEL::Exception)
+{
+ const char FIGURES[]="0123456789";
+ const std::string other("+-*^/(<>,");
+ double val=std::numeric_limits<double>::max();
+ std::size_t lgth=_expr.length();
+ int id=0,delta;
+ for(std::size_t pos=0;pos!=std::string::npos;id++)
+ {
+ std::size_t pos2=_expr.find_first_of(FIGURES,pos,10);
+ if(pos2>0)
+ {//treat case of "x*log10(x)" -> "10" should NOT be intercepted by this
+ if(other.find_first_of(_expr[pos2-1])==std::string::npos)
+ {
+ pos=_expr.find_first_not_of(FIGURES,pos2,10);
+ id--;
+ continue;
+ }
+ if(_expr[pos2-1]==')')
+ {
+ pos=_expr.find_first_not_of(FIGURES,pos2,10);
+ std::ostringstream oss; oss << "Problem on parsing : Number \"" << _expr.substr(pos2,pos!=std::string::npos?pos2-pos:std::string::npos);
+ oss << "\" is right after close parenthesis... ')'";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ }
+ if(pos2==std::string::npos)
+ break;
+ std::size_t pos3=_expr.find_first_not_of(FIGURES,pos2,10);
+ if(pos3==std::string::npos)
+ {//"x+1223442320"
+ valuesInExpr.push_back(ReplaceAndTraduce(_expr,id,pos2,std::string::npos,delta));
+ break;
+ }
+ if(_expr[pos3]=='.')
+ pos3++;
+ if(pos3<lgth)
+ {
+ std::size_t pos4=_expr.find_first_not_of(FIGURES,pos3,10);
+ if(pos4==std::string::npos)
+ {//"x+1223334.223"
+ valuesInExpr.push_back(ReplaceAndTraduce(_expr,id,pos2,std::string::npos,delta));
+ break;
+ }
+ else
+ {
+ if(_expr[pos4]!='e' && _expr[pos4]!='E')
+ {//"x+1223334.223+x"
+ valuesInExpr.push_back(ReplaceAndTraduce(_expr,id,pos2,pos4,delta));
+ pos=pos4+delta;
+ continue;
+ }
+ else
+ {
+ if(++pos4<lgth)
+ {
+ if(_expr[pos4]=='+' || _expr[pos4]=='-')
+ pos4++;
+ if(pos4>=lgth)
+ {//"x+1223334.223e+" or "1223334.223E-"
+ std::ostringstream oss; oss << "Invalid expr : float number at the end of expr is invalid lacking number after exponential and sign ! -> \"" << _expr.substr(pos2) << "\"";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ std::size_t pos5=_expr.find_first_not_of(FIGURES,pos4,10);
+ if(pos4==pos5)
+ {//"x+1223334.223e+x" or "1223334.223E-y"
+ std::ostringstream oss; oss << "Invalid expr : float number in expr is invalid lacking number after exponential ! -> \"" << _expr.substr(pos2,pos4-pos2) << "\"";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ //OK, normal case
+ valuesInExpr.push_back(ReplaceAndTraduce(_expr,id,pos2,pos5,delta));
+ pos=pos5+delta;
+ continue;
+ }
+ else//"x+1223334.223e"
+ {
+ std::ostringstream oss; oss << "Invalid expr : float number at the end of expr is invalid lacking number after exponential ! " << _expr.substr(pos2);
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ }
+ }
+ }
+ else
+ {//"x+1223334."
+ valuesInExpr.push_back(ReplaceAndTraduce(_expr,id,pos2,std::string::npos,delta));
+ break;
+ }
+ }
+}
+
+void ExprParser::replaceValues(const std::vector<double>& valuesInExpr) throw(INTERP_KERNEL::Exception)
+{
+ if(_leaf)
+ _leaf->replaceValues(valuesInExpr);
+ else
+ {
+ for(std::list<ExprParser>::iterator iter=_sub_expr.begin();iter!=_sub_expr.end();iter++)
+ (*iter).replaceValues(valuesInExpr);
+ }
+}
+
+void ExprParser::LocateError(std::ostream& stringToDisp, const std::string& srcOfErr, int posOfErr)
{
stringToDisp << "Position is " << posOfErr << " of string : \"" << srcOfErr << "\"" << std::endl;
}
for(std::vector<char>::const_iterator iter=output.begin();iter!=output.end();iter++)
std::cout << std::hex << (int)((unsigned char)(*iter)) << " ";
std::cout << std::endl;
- int lgth;
- char *lm=asmb.convertMachineLangageInBasic(output,lgth);
- char *ret=0;
-#ifdef _POSIX_MAPPED_FILES
- ret=(char *)mmap(0,lgth,PROT_EXEC | PROT_WRITE,MAP_ANONYMOUS | MAP_PRIVATE,-1,0);
-#else
-#ifdef WNT
- HANDLE h=CreateFileMapping(INVALID_HANDLE_VALUE,NULL,PAGE_EXECUTE_READWRITE,0,lgth,NULL);
- ret=(char *)MapViewOfFile(h,FILE_MAP_EXECUTE | FILE_MAP_READ | FILE_MAP_WRITE,0,0,lgth);
-#endif
-#endif
- if(ret)
- std::copy(lm,lm+lgth,ret);
- delete [] lm;
- return ret;
+ unsigned offset;
+ return asmb.copyToExecMemZone(output,offset);
}
char *ExprParser::compileX86_64() const
for(std::vector<char>::const_iterator iter=output.begin();iter!=output.end();iter++)
std::cout << std::hex << (int)((unsigned char)(*iter)) << " ";
std::cout << std::endl;
- int lgth;
- char *lm=asmb.convertMachineLangageInBasic(output,lgth);
- char *ret=0;
-#ifdef _POSIX_MAPPED_FILES
- ret=(char *)mmap(0,lgth,PROT_EXEC | PROT_WRITE,MAP_ANONYMOUS | MAP_PRIVATE,-1,0);
-#else
-#ifdef WNT
- HANDLE h=CreateFileMapping(INVALID_HANDLE_VALUE,NULL,PAGE_EXECUTE_READWRITE,0,lgth,NULL);
- ret=(char *)MapViewOfFile(h,FILE_MAP_EXECUTE | FILE_MAP_READ | FILE_MAP_WRITE,0,0,lgth);
-#endif
-#endif
- if(ret)
- std::copy(lm,lm+lgth,ret);
- delete [] lm;
- return ret;
+ unsigned offset;
+ return asmb.copyToExecMemZone(output,offset);
}
void ExprParser::compileX86LowLev(std::vector<std::string>& ass) const
{
for(std::list<ExprParser>::const_iterator iter=_sub_expr.begin();iter!=_sub_expr.end();iter++)
(*iter).compileX86LowLev(ass);
- for(std::list<Function *>::const_iterator iter2=_func_btw_sub_expr.begin();iter2!=_func_btw_sub_expr.end();iter2++)
- (*iter2)->operateX86(ass);
}
+ for(std::list<Function *>::const_iterator iter2=_func_btw_sub_expr.begin();iter2!=_func_btw_sub_expr.end();iter2++)
+ (*iter2)->operateX86(ass);
}
void ExprParser::compileX86_64LowLev(std::vector<std::string>& ass) const
{
for(std::list<ExprParser>::const_iterator iter=_sub_expr.begin();iter!=_sub_expr.end();iter++)
(*iter).compileX86_64LowLev(ass);
- for(std::list<Function *>::const_iterator iter2=_func_btw_sub_expr.begin();iter2!=_func_btw_sub_expr.end();iter2++)
- (*iter2)->operateX86(ass);
}
+ for(std::list<Function *>::const_iterator iter2=_func_btw_sub_expr.begin();iter2!=_func_btw_sub_expr.end();iter2++)
+ (*iter2)->operateX86(ass);
}
void LeafExprVal::compileX86(std::vector<std::string>& ass) const
virtual void fillValue(Value *val) const throw(INTERP_KERNEL::Exception) = 0;
virtual void compileX86(std::vector<std::string>& ass) const = 0;
virtual void compileX86_64(std::vector<std::string>& ass) const = 0;
+ virtual void replaceValues(const std::vector<double>& valuesInExpr) throw(INTERP_KERNEL::Exception) = 0;
static LeafExpr *buildInstanceFrom(const std::string& expr) throw(INTERP_KERNEL::Exception);
};
void compileX86(std::vector<std::string>& ass) const;
void compileX86_64(std::vector<std::string>& ass) const;
void fillValue(Value *val) const throw(INTERP_KERNEL::Exception);
+ void replaceValues(const std::vector<double>& valuesInExpr) throw(INTERP_KERNEL::Exception);
private:
double _value;
};
std::string getVar() const { return _var_name; }
void prepareExprEvaluation(const std::vector<std::string>& vars) const throw(INTERP_KERNEL::Exception);
void prepareExprEvaluationVec() const throw(INTERP_KERNEL::Exception);
+ void replaceValues(const std::vector<double>& valuesInExpr) throw(INTERP_KERNEL::Exception);
static bool isRecognizedKeyVar(const std::string& var, int& pos);
public:
static const char END_OF_RECOGNIZED_VAR[];
void prepareExprEvaluationVecLowLev() const throw(INTERP_KERNEL::Exception);
bool tryToInterpALeaf() throw(INTERP_KERNEL::Exception);
void parseUnaryFunc() throw(INTERP_KERNEL::Exception);
+ void parseForCmp() throw(INTERP_KERNEL::Exception);
void parseForAddMin() throw(INTERP_KERNEL::Exception);
void parseForMulDiv() throw(INTERP_KERNEL::Exception);
void parseForPow() throw(INTERP_KERNEL::Exception);
bool simplify() throw(INTERP_KERNEL::Exception);
void releaseFunctions();
void checkBracketsParity() const throw(INTERP_KERNEL::Exception);
- static std::size_t findCorrespondingOpenBracket(const std::string& expr, std::size_t posOfCloseBracket);
- static void locateError(std::ostream& stringToDisp, const std::string& srcOfErr, int posOfErr);
+ void fillValuesInExpr(std::vector<double>& valuesInExpr) throw(INTERP_KERNEL::Exception);
+ void replaceValues(const std::vector<double>& valuesInExpr) throw(INTERP_KERNEL::Exception);
+ static double ReplaceAndTraduce(std::string& expr, int id, std::size_t bg, std::size_t end, int& delta) throw(INTERP_KERNEL::Exception);
+ static std::size_t FindCorrespondingOpenBracket(const std::string& expr, std::size_t posOfCloseBracket);
+ static void LocateError(std::ostream& stringToDisp, const std::string& srcOfErr, int posOfErr);
private:
ExprParser *_father;
bool _is_parsed;
const char LnFunction::REPR[]="ln";
+const char LogFunction::REPR[]="log";
+
+const char Log10Function::REPR[]="log10";
+
const char MaxFunction::REPR[]="max";
const char MinFunction::REPR[]="min";
+const char GreaterThanFunction::REPR[]=">";
+
+const char LowerThanFunction::REPR[]="<";
+
+const char IfFunction::REPR[]="if";
+
Function *FunctionsFactory::buildFuncFromString(const char *type, int nbOfParams) throw(INTERP_KERNEL::Exception)
{
switch(nbOfParams)
return buildUnaryFuncFromString(type);
case 2:
return buildBinaryFuncFromString(type);
+ case 3:
+ return buildTernaryFuncFromString(type);
default:
throw INTERP_KERNEL::Exception("Invalid number of params detected : limited to 2 !");
}
return new ExpFunction;
if(tmp==LnFunction::REPR)
return new LnFunction;
+ if(tmp==LogFunction::REPR)
+ return new LogFunction;
+ if(tmp==Log10Function::REPR)
+ return new Log10Function;
//
std::string msg("Invalid unary function detected : \"");
msg+=type; msg+="\"";
return new MaxFunction;
if(tmp==MinFunction::REPR)
return new MinFunction;
+ if(tmp==GreaterThanFunction::REPR)
+ return new GreaterThanFunction;
+ if(tmp==LowerThanFunction::REPR)
+ return new LowerThanFunction;
std::string msg("Invalid binary function detected : \"");
msg+=type; msg+="\"";
throw INTERP_KERNEL::Exception(msg.c_str());
}
+Function *FunctionsFactory::buildTernaryFuncFromString(const char *type) throw(INTERP_KERNEL::Exception)
+{
+ std::string tmp(type);
+ if(tmp==IfFunction::REPR)
+ return new IfFunction();
+ std::string msg("Invalid ternary function detected : \"");
+ msg+=type; msg+="\"";
+ throw INTERP_KERNEL::Exception(msg.c_str());
+}
+
Function *FunctionsFactory::buildBinaryFuncFromString(char type) throw(INTERP_KERNEL::Exception)
{
char tmp[2]; tmp[0]=type; tmp[1]='\0';
return true;
}
+LogFunction::~LogFunction()
+{
+}
+
+void LogFunction::operate(std::vector<Value *>& stack) const throw(INTERP_KERNEL::Exception)
+{
+ Value *val=stack.back();
+ val->ln();
+}
+
+void LogFunction::operateX86(std::vector<std::string>& asmb) const throw(INTERP_KERNEL::Exception)
+{
+ throw INTERP_KERNEL::Exception("Assembly for log Not implemented yet !");
+}
+
+const char *LogFunction::getRepr() const
+{
+ return REPR;
+}
+
+bool LogFunction::isACall() const
+{
+ return true;
+}
+
+Log10Function::~Log10Function()
+{
+}
+
+void Log10Function::operate(std::vector<Value *>& stack) const throw(INTERP_KERNEL::Exception)
+{
+ Value *val=stack.back();
+ val->log10();
+}
+
+void Log10Function::operateX86(std::vector<std::string>& asmb) const throw(INTERP_KERNEL::Exception)
+{
+ throw INTERP_KERNEL::Exception("Assembly for log Not implemented yet !");
+}
+
+const char *Log10Function::getRepr() const
+{
+ return REPR;
+}
+
+bool Log10Function::isACall() const
+{
+ return true;
+}
+
int BinaryFunction::getNbInputParams() const
{
return 2;
{
return false;
}
+
+GreaterThanFunction::~GreaterThanFunction()
+{
+}
+
+void GreaterThanFunction::operate(std::vector<Value *>& stack) const throw(INTERP_KERNEL::Exception)
+{
+ Value *val1=stack.back();
+ stack.pop_back();
+ Value *& val2=stack.back();
+ Value *val3;
+ try
+ {
+ val3=val1->greaterThan(val2);
+ }
+ catch(INTERP_KERNEL::Exception& e)
+ {
+ delete val1;
+ throw e;
+ }
+ delete val1;
+ delete val2;
+ val2=val3;
+}
+
+void GreaterThanFunction::operateX86(std::vector<std::string>& asmb) const throw(INTERP_KERNEL::Exception)
+{
+ throw INTERP_KERNEL::Exception("Assembly Not implemented yet !");
+}
+
+const char *GreaterThanFunction::getRepr() const
+{
+ return REPR;
+}
+
+bool GreaterThanFunction::isACall() const
+{
+ return false;
+}
+
+LowerThanFunction::~LowerThanFunction()
+{
+}
+
+void LowerThanFunction::operate(std::vector<Value *>& stack) const throw(INTERP_KERNEL::Exception)
+{
+ Value *val1=stack.back();
+ stack.pop_back();
+ Value *& val2=stack.back();
+ Value *val3;
+ try
+ {
+ val3=val1->lowerThan(val2);
+ }
+ catch(INTERP_KERNEL::Exception& e)
+ {
+ delete val1;
+ throw e;
+ }
+ delete val1;
+ delete val2;
+ val2=val3;
+}
+
+void LowerThanFunction::operateX86(std::vector<std::string>& asmb) const throw(INTERP_KERNEL::Exception)
+{
+ throw INTERP_KERNEL::Exception("Assembly Not implemented yet !");
+}
+
+const char *LowerThanFunction::getRepr() const
+{
+ return REPR;
+}
+
+bool LowerThanFunction::isACall() const
+{
+ return false;
+}
+
+int TernaryFunction::getNbInputParams() const
+{
+ return 3;
+}
+
+IfFunction::~IfFunction()
+{
+}
+
+void IfFunction::operate(std::vector<Value *>& stack) const throw(INTERP_KERNEL::Exception)
+{
+ Value *val1=stack.back();
+ stack.pop_back();
+ Value *val2=stack.back();
+ stack.pop_back();
+ Value *&val3=stack.back();
+ Value *val4;
+ try
+ {
+ val4=val1->ifFunc(val2,val3);
+ }
+ catch(INTERP_KERNEL::Exception& e)
+ {
+ delete val1;
+ delete val2;
+ throw e;
+ }
+ delete val1;
+ delete val2;
+ delete val3;
+ val3=val4;
+}
+
+void IfFunction::operateX86(std::vector<std::string>& asmb) const throw(INTERP_KERNEL::Exception)
+{
+ throw INTERP_KERNEL::Exception("Assembly Not implemented yet !");
+}
+
+const char *IfFunction::getRepr() const
+{
+ return REPR;
+}
+
+bool IfFunction::isACall() const
+{
+ return false;
+}
+
//static Function *buildUnaryFuncFromString(char type) throw(INTERP_KERNEL::Exception);
static Function *buildBinaryFuncFromString(const char *type) throw(INTERP_KERNEL::Exception);
static Function *buildBinaryFuncFromString(char type) throw(INTERP_KERNEL::Exception);
+ static Function *buildTernaryFuncFromString(const char *type) throw(INTERP_KERNEL::Exception);
};
class INTERPKERNELEXPREVAL_EXPORT Function
static const char REPR[];
};
+ class INTERPKERNELEXPREVAL_EXPORT LogFunction : public UnaryFunction
+ {
+ public:
+ ~LogFunction();
+ void operate(std::vector<Value *>& stack) const throw(INTERP_KERNEL::Exception);
+ void operateX86(std::vector<std::string>& asmb) const throw(INTERP_KERNEL::Exception);
+ const char *getRepr() const;
+ bool isACall() const;
+ public:
+ static const char REPR[];
+ };
+
+ class INTERPKERNELEXPREVAL_EXPORT Log10Function : public UnaryFunction
+ {
+ public:
+ ~Log10Function();
+ void operate(std::vector<Value *>& stack) const throw(INTERP_KERNEL::Exception);
+ void operateX86(std::vector<std::string>& asmb) const throw(INTERP_KERNEL::Exception);
+ const char *getRepr() const;
+ bool isACall() const;
+ public:
+ static const char REPR[];
+ };
+
class INTERPKERNELEXPREVAL_EXPORT BinaryFunction : public Function
{
public:
public:
static const char REPR[];
};
+
+ class INTERPKERNELEXPREVAL_EXPORT GreaterThanFunction : public BinaryFunction
+ {
+ public:
+ ~GreaterThanFunction();
+ void operate(std::vector<Value *>& stack) const throw(INTERP_KERNEL::Exception);
+ void operateX86(std::vector<std::string>& asmb) const throw(INTERP_KERNEL::Exception);
+ const char *getRepr() const;
+ bool isACall() const;
+ public:
+ static const char REPR[];
+ };
+
+ class INTERPKERNELEXPREVAL_EXPORT LowerThanFunction : public BinaryFunction
+ {
+ public:
+ ~LowerThanFunction();
+ void operate(std::vector<Value *>& stack) const throw(INTERP_KERNEL::Exception);
+ void operateX86(std::vector<std::string>& asmb) const throw(INTERP_KERNEL::Exception);
+ const char *getRepr() const;
+ bool isACall() const;
+ public:
+ static const char REPR[];
+ };
+
+ class INTERPKERNELEXPREVAL_EXPORT TernaryFunction : public Function
+ {
+ public:
+ int getNbInputParams() const;
+ };
+
+ class INTERPKERNELEXPREVAL_EXPORT IfFunction : public TernaryFunction
+ {
+ public:
+ ~IfFunction();
+ void operate(std::vector<Value *>& stack) const throw(INTERP_KERNEL::Exception);
+ void operateX86(std::vector<std::string>& asmb) const throw(INTERP_KERNEL::Exception);
+ const char *getRepr() const;
+ bool isACall() const;
+ public:
+ static const char REPR[];
+ };
}
#endif
_data=std::exp(_data);
}
-void ValueDouble:: ln() throw(INTERP_KERNEL::Exception)
+void ValueDouble::ln() throw(INTERP_KERNEL::Exception)
{
_data=std::log(_data);
}
+void ValueDouble::log10() throw(INTERP_KERNEL::Exception)
+{
+ _data=std::log10(_data);
+}
+
Value *ValueDouble::plus(const Value *other) const throw(INTERP_KERNEL::Exception)
{
const ValueDouble *valC=checkSameType(other);
return new ValueDouble(std::min(_data,valC->_data));
}
+Value *ValueDouble::greaterThan(const Value *other) const throw(INTERP_KERNEL::Exception)
+{
+ const ValueDouble *valC=checkSameType(other);
+ return new ValueDouble(_data>valC->_data?std::numeric_limits<double>::max():-std::numeric_limits<double>::max());
+}
+
+Value *ValueDouble::lowerThan(const Value *other) const throw(INTERP_KERNEL::Exception)
+{
+ const ValueDouble *valC=checkSameType(other);
+ return new ValueDouble(_data<valC->_data?std::numeric_limits<double>::max():-std::numeric_limits<double>::max());
+}
+
+Value *ValueDouble::ifFunc(const Value *the, const Value *els) const throw(INTERP_KERNEL::Exception)
+{
+ const ValueDouble *theC=checkSameType(the);
+ const ValueDouble *elsC=checkSameType(els);
+ if(_data==std::numeric_limits<double>::max())
+ return new ValueDouble(theC->_data);
+ if(_data==-std::numeric_limits<double>::max())
+ return new ValueDouble(elsC->_data);
+ throw INTERP_KERNEL::Exception("ValueDouble::ifFunc : The fist element of ternary function if is not a binary op !");
+}
+
const ValueDouble *ValueDouble::checkSameType(const Value *val) throw(INTERP_KERNEL::Exception)
{
const ValueDouble *valC=dynamic_cast<const ValueDouble *>(val);
unsupportedOp(LnFunction::REPR);
}
+void ValueUnit::log10() throw(INTERP_KERNEL::Exception)
+{
+ unsupportedOp(Log10Function::REPR);
+}
+
Value *ValueUnit::plus(const Value *other) const throw(INTERP_KERNEL::Exception)
{
unsupportedOp(PlusFunction::REPR);
return 0;
}
+Value *ValueUnit::greaterThan(const Value *other) const throw(INTERP_KERNEL::Exception)
+{
+ unsupportedOp(GreaterThanFunction::REPR);
+ return 0;
+}
+
+Value *ValueUnit::lowerThan(const Value *other) const throw(INTERP_KERNEL::Exception)
+{
+ unsupportedOp(LowerThanFunction::REPR);
+ return 0;
+}
+
+Value *ValueUnit::ifFunc(const Value *the, const Value *els) const throw(INTERP_KERNEL::Exception)
+{
+ unsupportedOp(IfFunction::REPR);
+ return 0;
+}
+
Value *ValueUnit::mult(const Value *other) const throw(INTERP_KERNEL::Exception)
{
const ValueUnit *valC=checkSameType(other);
{
double *it=std::find_if(_dest_data,_dest_data+_sz_dest_data,std::bind2nd(std::less_equal<double>(),0.));
if(it!=_dest_data+_sz_dest_data)
- throw INTERP_KERNEL::Exception("Trying to apply sqrt on < 0. value !");
+ throw INTERP_KERNEL::Exception("Trying to apply neperian/natural log on <= 0. value !");
std::transform(_dest_data,_dest_data+_sz_dest_data,_dest_data,std::ptr_fun<double,double>(std::log));
}
+void ValueDoubleExpr::log10() throw(INTERP_KERNEL::Exception)
+{
+ double *it=std::find_if(_dest_data,_dest_data+_sz_dest_data,std::bind2nd(std::less_equal<double>(),0.));
+ if(it!=_dest_data+_sz_dest_data)
+ throw INTERP_KERNEL::Exception("Trying to apply log10 on <= 0. value !");
+ std::transform(_dest_data,_dest_data+_sz_dest_data,_dest_data,std::ptr_fun<double,double>(std::log10));
+}
+
Value *ValueDoubleExpr::plus(const Value *other) const throw(INTERP_KERNEL::Exception)
{
const ValueDoubleExpr *otherC=static_cast<const ValueDoubleExpr *>(other);
std::transform(_dest_data,_dest_data+_sz_dest_data,otherC->getData(),ret->getData(),std::ptr_fun<const double&, const double&, const double& >(std::min));
return ret;
}
+
+Value *ValueDoubleExpr::greaterThan(const Value *other) const throw(INTERP_KERNEL::Exception)
+{
+ const ValueDoubleExpr *otherC=static_cast<const ValueDoubleExpr *>(other);
+ ValueDoubleExpr *ret=new ValueDoubleExpr(_sz_dest_data,_src_data);
+ for(int i=0;i<_sz_dest_data;i++)
+ if(_dest_data[i]<=otherC->getData()[i])
+ {
+ std::fill(ret->getData(),ret->getData()+_sz_dest_data,-std::numeric_limits<double>::max());
+ return ret;
+ }
+ std::fill(ret->getData(),ret->getData()+_sz_dest_data,std::numeric_limits<double>::max());
+ return ret;
+}
+
+Value *ValueDoubleExpr::lowerThan(const Value *other) const throw(INTERP_KERNEL::Exception)
+{
+ const ValueDoubleExpr *otherC=static_cast<const ValueDoubleExpr *>(other);
+ ValueDoubleExpr *ret=new ValueDoubleExpr(_sz_dest_data,_src_data);
+ for(int i=0;i<_sz_dest_data;i++)
+ if(_dest_data[i]>=otherC->getData()[i])
+ {
+ std::fill(ret->getData(),ret->getData()+_sz_dest_data,-std::numeric_limits<double>::max());
+ return ret;
+ }
+ std::fill(ret->getData(),ret->getData()+_sz_dest_data,std::numeric_limits<double>::max());
+ return ret;
+}
+
+Value *ValueDoubleExpr::ifFunc(const Value *the, const Value *els) const throw(INTERP_KERNEL::Exception)
+{
+ const ValueDoubleExpr *theC=static_cast<const ValueDoubleExpr *>(the);
+ const ValueDoubleExpr *elsC=static_cast<const ValueDoubleExpr *>(els);
+ ValueDoubleExpr *ret=new ValueDoubleExpr(_sz_dest_data,_src_data);
+ bool okmax=true;
+ bool okmin=true;
+ for(int i=0;i<_sz_dest_data && (okmax || okmin);i++)
+ {
+ okmax=_dest_data[i]==std::numeric_limits<double>::max();
+ okmin=_dest_data[i]==-std::numeric_limits<double>::max();
+ }
+ if(okmax || okmin)
+ {
+ if(okmax)
+ std::copy(theC->getData(),theC->getData()+_sz_dest_data,ret->getData());
+ else
+ std::copy(elsC->getData(),elsC->getData()+_sz_dest_data,ret->getData());
+ return ret;
+ }
+ else
+ {
+ throw INTERP_KERNEL::Exception("ValueDoubleExpr::ifFunc : first parameter of ternary func is NOT a consequence of a boolean op !");
+ }
+}
virtual void abs() throw(INTERP_KERNEL::Exception) = 0;
virtual void exp() throw(INTERP_KERNEL::Exception) = 0;
virtual void ln() throw(INTERP_KERNEL::Exception) = 0;
+ virtual void log10() throw(INTERP_KERNEL::Exception) = 0;
//binary
virtual Value *plus(const Value *other) const throw(INTERP_KERNEL::Exception) = 0;
virtual Value *minus(const Value *other) const throw(INTERP_KERNEL::Exception) = 0;
virtual Value *pow(const Value *other) const throw(INTERP_KERNEL::Exception) = 0;
virtual Value *max(const Value *other) const throw(INTERP_KERNEL::Exception) = 0;
virtual Value *min(const Value *other) const throw(INTERP_KERNEL::Exception) = 0;
+ virtual Value *greaterThan(const Value *other) const throw(INTERP_KERNEL::Exception) = 0;
+ virtual Value *lowerThan(const Value *other) const throw(INTERP_KERNEL::Exception) = 0;
+ //ternary
+ virtual Value *ifFunc(const Value *the, const Value *els) const throw(INTERP_KERNEL::Exception) = 0;
};
class INTERPKERNELEXPREVAL_EXPORT ValueDouble : public Value
void abs() throw(INTERP_KERNEL::Exception);
void exp() throw(INTERP_KERNEL::Exception);
void ln() throw(INTERP_KERNEL::Exception);
+ void log10() throw(INTERP_KERNEL::Exception);
//
Value *plus(const Value *other) const throw(INTERP_KERNEL::Exception);
Value *minus(const Value *other) const throw(INTERP_KERNEL::Exception);
Value *pow(const Value *other) const throw(INTERP_KERNEL::Exception);
Value *max(const Value *other) const throw(INTERP_KERNEL::Exception);
Value *min(const Value *other) const throw(INTERP_KERNEL::Exception);
+ Value *greaterThan(const Value *other) const throw(INTERP_KERNEL::Exception);
+ Value *lowerThan(const Value *other) const throw(INTERP_KERNEL::Exception);
+ //
+ Value *ifFunc(const Value *the, const Value *els) const throw(INTERP_KERNEL::Exception);
private:
ValueDouble(double val);
static const ValueDouble *checkSameType(const Value *val) throw(INTERP_KERNEL::Exception);
void abs() throw(INTERP_KERNEL::Exception);
void exp() throw(INTERP_KERNEL::Exception);
void ln() throw(INTERP_KERNEL::Exception);
+ void log10() throw(INTERP_KERNEL::Exception);
//
Value *plus(const Value *other) const throw(INTERP_KERNEL::Exception);
Value *minus(const Value *other) const throw(INTERP_KERNEL::Exception);
Value *pow(const Value *other) const throw(INTERP_KERNEL::Exception);
Value *max(const Value *other) const throw(INTERP_KERNEL::Exception);
Value *min(const Value *other) const throw(INTERP_KERNEL::Exception);
+ Value *greaterThan(const Value *other) const throw(INTERP_KERNEL::Exception);
+ Value *lowerThan(const Value *other) const throw(INTERP_KERNEL::Exception);
+ //
+ Value *ifFunc(const Value *the, const Value *els) const throw(INTERP_KERNEL::Exception);
private:
ValueUnit(const DecompositionInUnitBase& unit);
static void unsupportedOp(const char *type) throw(INTERP_KERNEL::Exception);
void abs() throw(INTERP_KERNEL::Exception);
void exp() throw(INTERP_KERNEL::Exception);
void ln() throw(INTERP_KERNEL::Exception);
+ void log10() throw(INTERP_KERNEL::Exception);
//
Value *plus(const Value *other) const throw(INTERP_KERNEL::Exception);
Value *minus(const Value *other) const throw(INTERP_KERNEL::Exception);
Value *pow(const Value *other) const throw(INTERP_KERNEL::Exception);
Value *max(const Value *other) const throw(INTERP_KERNEL::Exception);
Value *min(const Value *other) const throw(INTERP_KERNEL::Exception);
+ Value *greaterThan(const Value *other) const throw(INTERP_KERNEL::Exception);
+ Value *lowerThan(const Value *other) const throw(INTERP_KERNEL::Exception);
+ //
+ Value *ifFunc(const Value *the, const Value *els) const throw(INTERP_KERNEL::Exception);
private:
int _sz_dest_data;
double *_dest_data;
--- /dev/null
+// Copyright (C) 2007-2010 CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+//Local includes
+#include "InterpKernelGaussCoords.hxx"
+#include "CellModel.hxx"
+
+//STL includes
+#include <math.h>
+#include <algorithm>
+#include <sstream>
+
+using namespace INTERP_KERNEL;
+
+//Define common part of the code in the MACRO
+//---------------------------------------------------------------
+#define LOCAL_COORD_MACRO_BEGIN \
+ _my_local_reference_coord.resize( _my_local_ref_dim*_my_local_nb_ref ); \
+ for( int refId = 0; refId < _my_local_nb_ref; refId++ ) \
+ { \
+ double* coords = &_my_local_reference_coord[ refId*_my_local_ref_dim ]; \
+ switch(refId) \
+ {
+
+//---------------------------------------------------------------
+#define LOCAL_COORD_MACRO_END \
+ } \
+}
+
+//---------------------------------------------------------------
+#define SHAPE_FUN_MACRO_BEGIN \
+ for( int gaussId = 0 ; gaussId < _my_nb_gauss ; gaussId++ ) \
+ { \
+ double* funValue = &_my_function_value[ gaussId * _my_nb_ref ]; \
+ const double* gc = &_my_gauss_coord[ gaussId * getGaussCoordDim() ];
+
+//---------------------------------------------------------------
+#define SHAPE_FUN_MACRO_END \
+ }
+
+#define CHECK_MACRO \
+ if( ! aSatify ) \
+ { \
+ std::ostringstream stream; \
+ stream << "Error in the gauss localization for the cell with type "; \
+ stream << cellModel.getRepr(); \
+ stream << " !!!"; \
+ throw INTERP_KERNEL::Exception(stream.str().c_str()); \
+ }
+
+
+//---------------------------------------------------------------
+static bool IsEqual(double theLeft, double theRight)
+{
+ static double EPS = 1.0E-3;
+ if(fabs(theLeft) + fabs(theRight) > EPS)
+ return fabs(theLeft-theRight)/(fabs(theLeft)+fabs(theRight)) < EPS;
+ return true;
+}
+
+
+////////////////////////////////////////////////////////////////////////////////////////////////
+// GAUSS INFO CLASS //
+////////////////////////////////////////////////////////////////////////////////////////////////
+
+/*!
+ * Constructor of the GaussInfo
+ */
+GaussInfo::GaussInfo( NormalizedCellType theGeometry,
+ const DataVector& theGaussCoord,
+ int theNbGauss,
+ const DataVector& theReferenceCoord,
+ int theNbRef ) :
+ _my_geometry(theGeometry),
+ _my_nb_gauss(theNbGauss),
+ _my_gauss_coord(theGaussCoord),
+ _my_nb_ref(theNbRef),
+ _my_reference_coord(theReferenceCoord)
+{
+
+ //Allocate shape function values
+ _my_function_value.resize( _my_nb_gauss * _my_nb_ref );
+}
+
+/*!
+ * Destructor
+ */
+GaussInfo::~GaussInfo()
+{
+}
+
+/*!
+ * Return dimension of the gauss coordinates
+ */
+int GaussInfo::getGaussCoordDim() const
+{
+ if( _my_nb_gauss )
+ {
+ return _my_gauss_coord.size()/_my_nb_gauss;
+ }
+ else
+ {
+ return 0;
+ }
+}
+
+/*!
+ * Return dimension of the reference coordinates
+ */
+int GaussInfo::getReferenceCoordDim() const
+{
+ if( _my_nb_ref )
+ {
+ return _my_reference_coord.size()/_my_nb_ref;
+ }
+ else
+ {
+ return 0;
+ }
+}
+
+/*!
+ * Return type of the cell.
+ */
+NormalizedCellType GaussInfo::getCellType() const
+{
+ return _my_geometry;
+}
+
+/*!
+ * Return Nb of the gauss points.
+ */
+int GaussInfo::getNbGauss() const
+{
+ return _my_nb_gauss;
+}
+
+/*!
+ * Return Nb of the reference coordinates.
+ */
+int GaussInfo::getNbRef() const
+{
+ return _my_nb_ref;
+}
+
+/*!
+ * Check coordinates
+ */
+bool GaussInfo::isSatisfy()
+{
+
+ bool anIsSatisfy = ((_my_local_nb_ref == _my_nb_ref) && (_my_local_ref_dim == getReferenceCoordDim()));
+ //Check coordinates
+ if(anIsSatisfy)
+ {
+ for( int refId = 0; refId < _my_local_nb_ref; refId++ )
+ {
+ double* refCoord = &_my_reference_coord[ refId*_my_local_ref_dim ];
+ double* localRefCoord = &_my_local_reference_coord[ refId*_my_local_ref_dim ];
+ bool anIsEqual = false;
+ for( int dimId = 0; dimId < _my_local_ref_dim; dimId++ )
+ {
+ anIsEqual = IsEqual( localRefCoord[dimId], refCoord[dimId]);
+ if(!anIsEqual )
+ {
+ return false;
+ }
+ }
+ }
+ }
+ return anIsSatisfy;
+}
+
+/*!
+ * Initialize the internal vectors
+ */
+void GaussInfo::initLocalInfo() throw (INTERP_KERNEL::Exception)
+{
+ bool aSatify = false;
+ const CellModel& cellModel=CellModel::getCellModel(_my_geometry);
+ switch( _my_geometry )
+ {
+ case NORM_SEG2:
+ _my_local_ref_dim = 1;
+ _my_local_nb_ref = 2;
+ seg2Init();
+ aSatify = isSatisfy();
+ CHECK_MACRO;
+ break;
+
+ case NORM_SEG3:
+ _my_local_ref_dim = 1;
+ _my_local_nb_ref = 3;
+ seg3Init();
+ aSatify = isSatisfy();
+ CHECK_MACRO;
+ break;
+
+ case NORM_TRI3:
+ _my_local_ref_dim = 2;
+ _my_local_nb_ref = 3;
+ tria3aInit();
+ aSatify = isSatisfy();
+
+ if(!aSatify)
+ {
+ tria3bInit();
+ aSatify = isSatisfy();
+ CHECK_MACRO;
+ }
+ break;
+
+ case NORM_TRI6:
+ _my_local_ref_dim = 2;
+ _my_local_nb_ref = 6;
+ tria6aInit();
+ aSatify = isSatisfy();
+ if(!aSatify)
+ {
+ tria6bInit();
+ aSatify = isSatisfy();
+ CHECK_MACRO;
+ }
+ break;
+
+ case NORM_QUAD4:
+ _my_local_ref_dim = 2;
+ _my_local_nb_ref = 4;
+ quad4aInit();
+ aSatify = isSatisfy();
+
+ if(!aSatify)
+ {
+ quad4bInit();
+ aSatify = isSatisfy();
+ CHECK_MACRO;
+ }
+ break;
+
+ case NORM_QUAD8:
+ _my_local_ref_dim = 2;
+ _my_local_nb_ref = 8;
+ quad8aInit();
+ aSatify = isSatisfy();
+
+ if(!aSatify)
+ {
+ quad8bInit();
+ aSatify = isSatisfy();
+ CHECK_MACRO;
+ }
+ break;
+
+ case NORM_TETRA4:
+ _my_local_ref_dim = 3;
+ _my_local_nb_ref = 4;
+ tetra4aInit();
+ aSatify = isSatisfy();
+
+ if(!aSatify)
+ {
+ tetra4bInit();
+ aSatify = isSatisfy();
+ CHECK_MACRO;
+ }
+ break;
+
+ case NORM_TETRA10:
+ _my_local_ref_dim = 3;
+ _my_local_nb_ref = 10;
+ tetra10aInit();
+ aSatify = isSatisfy();
+
+ if(!aSatify)
+ {
+ tetra10bInit();
+ aSatify = isSatisfy();
+ CHECK_MACRO;
+ }
+ break;
+
+ case NORM_PYRA5:
+ _my_local_ref_dim = 3;
+ _my_local_nb_ref = 5;
+ pyra5aInit();
+ aSatify = isSatisfy();
+
+ if(!aSatify)
+ {
+ pyra5bInit();
+ aSatify = isSatisfy();
+ CHECK_MACRO;
+ }
+ break;
+
+ case NORM_PYRA13:
+ _my_local_ref_dim = 3;
+ _my_local_nb_ref = 13;
+ pyra13aInit();
+ aSatify = isSatisfy();
+
+ if(!aSatify)
+ {
+ pyra13bInit();
+ aSatify = isSatisfy();
+ CHECK_MACRO;
+ }
+ break;
+
+ case NORM_PENTA6:
+ _my_local_ref_dim = 3;
+ _my_local_nb_ref = 6;
+ penta6aInit();
+ aSatify = isSatisfy();
+
+ if(!aSatify)
+ {
+ penta6bInit();
+ aSatify = isSatisfy();
+ CHECK_MACRO;
+ }
+ break;
+
+ case NORM_PENTA15:
+ _my_local_ref_dim = 3;
+ _my_local_nb_ref = 15;
+ penta15aInit();
+ aSatify = isSatisfy();
+
+ if(!aSatify)
+ {
+ penta15bInit();
+ aSatify = isSatisfy();
+ CHECK_MACRO;
+ }
+ break;
+
+ case NORM_HEXA8:
+ _my_local_ref_dim = 3;
+ _my_local_nb_ref = 8;
+ hexa8aInit();
+ aSatify = isSatisfy();
+
+ if(!aSatify)
+ {
+ hexa8aInit();
+ aSatify = isSatisfy();
+ CHECK_MACRO;
+ }
+ break;
+
+ case NORM_HEXA20:
+ _my_local_ref_dim = 3;
+ _my_local_nb_ref = 20;
+ hexa20aInit();
+ aSatify = isSatisfy();
+
+ if(!aSatify)
+ {
+ hexa20aInit();
+ aSatify = isSatisfy();
+ CHECK_MACRO;
+ }
+ break;
+
+ default:
+ throw INTERP_KERNEL::Exception("Not manged cell type !");
+ break;
+ }
+}
+
+/**
+ * Return shape function value by node id
+ */
+const double* GaussInfo::getFunctionValues( const int theGaussId ) const
+{
+ return &_my_function_value[ _my_nb_ref*theGaussId ];
+}
+
+/*!
+ * Init Segment 2 Reference coordinates ans Shape function.
+ */
+void GaussInfo::seg2Init()
+{
+ LOCAL_COORD_MACRO_BEGIN;
+ case 0:
+ coords[0] = -1.0;
+ break;
+ case 1:
+ coords[0] = 1.0;
+ break;
+ LOCAL_COORD_MACRO_END;
+
+ SHAPE_FUN_MACRO_BEGIN;
+ funValue[0] = 0.5*(1.0 - gc[0]);
+ funValue[1] = 0.5*(1.0 + gc[0]);
+ SHAPE_FUN_MACRO_END;
+}
+
+/*!
+ * Init Segment 3 Reference coordinates ans Shape function.
+ */
+void GaussInfo::seg3Init()
+{
+ LOCAL_COORD_MACRO_BEGIN;
+ case 0:
+ coords[0] = -1.0;
+ break;
+ case 1:
+ coords[0] = 1.0;
+ break;
+ case 2:
+ coords[0] = 0.0;
+ break;
+ LOCAL_COORD_MACRO_END;
+
+ SHAPE_FUN_MACRO_BEGIN;
+ funValue[0] = 0.5*(1.0 - gc[0])*gc[0];
+ funValue[1] = 0.5*(1.0 + gc[0])*gc[0];
+ funValue[2] = (1.0 + gc[0])*(1.0 - gc[0]);
+ SHAPE_FUN_MACRO_END;
+}
+
+/*!
+ * Init Triangle Reference coordinates ans Shape function.
+ * Case A.
+ */
+void GaussInfo::tria3aInit()
+{
+ LOCAL_COORD_MACRO_BEGIN;
+ case 0:
+ coords[0] = -1.0;
+ coords[1] = 1.0;
+ break;
+ case 1:
+ coords[0] = -1.0;
+ coords[1] = -1.0;
+ break;
+ case 2:
+ coords[0] = 1.0;
+ coords[1] = -1.0;
+ break;
+ LOCAL_COORD_MACRO_END;
+
+ SHAPE_FUN_MACRO_BEGIN;
+ funValue[0] = 0.5*(1.0 + gc[1]);
+ funValue[1] = -0.5*(gc[0] + gc[1]);
+ funValue[2] = 0.5*(1.0 + gc[0]);
+ SHAPE_FUN_MACRO_END;
+}
+
+/*!
+ * Init Triangle Reference coordinates ans Shape function.
+ * Case B.
+ */
+void GaussInfo::tria3bInit()
+{
+ LOCAL_COORD_MACRO_BEGIN;
+ case 0:
+ coords[0] = 0.0;
+ coords[1] = 0.0;
+ break;
+ case 1:
+ coords[0] = 1.0;
+ coords[1] = 0.0;
+ break;
+ case 2:
+ coords[0] = 0.0;
+ coords[1] = 1.0;
+ break;
+ LOCAL_COORD_MACRO_END;
+
+ SHAPE_FUN_MACRO_BEGIN;
+ funValue[0] = 1.0 - gc[0] - gc[1];
+ funValue[1] = gc[0];
+ funValue[2] = gc[1];
+ SHAPE_FUN_MACRO_END;
+}
+
+/*!
+ * Init Quadratic Triangle Reference coordinates ans Shape function.
+ * Case A.
+ */
+void GaussInfo::tria6aInit()
+{
+ LOCAL_COORD_MACRO_BEGIN;
+ case 0:
+ coords[0] = -1.0;
+ coords[1] = 1.0;
+ break;
+ case 1:
+ coords[0] = -1.0;
+ coords[1] = -1.0;
+ break;
+ case 2:
+ coords[0] = 1.0;
+ coords[1] = -1.0;
+ break;
+ case 3:
+ coords[0] = -1.0;
+ coords[1] = 1.0;
+ break;
+ case 4:
+ coords[0] = 0.0;
+ coords[1] = -1.0;
+ break;
+ case 5:
+ coords[0] = 0.0;
+ coords[1] = 0.0;
+ break;
+ LOCAL_COORD_MACRO_END;
+
+ SHAPE_FUN_MACRO_BEGIN;
+ funValue[0] = 0.5*(1.0 + gc[1])*gc[1];
+ funValue[1] = 0.5*(gc[0] + gc[1])*(gc[0] + gc[1] + 1);
+ funValue[2] = 0.5*(1.0 + gc[0])*gc[0];
+ funValue[3] = -1.0*(1.0 + gc[1])*(gc[0] + gc[1]);
+ funValue[4] = -1.0*(1.0 + gc[0])*(gc[0] + gc[1]);
+ funValue[5] = (1.0 + gc[1])*(1.0 + gc[1]);
+ SHAPE_FUN_MACRO_END;
+}
+
+/*!
+ * Init Quadratic Triangle Reference coordinates ans Shape function.
+ * Case B.
+ */
+void GaussInfo::tria6bInit()
+{
+ LOCAL_COORD_MACRO_BEGIN;
+ case 0:
+ coords[0] = 0.0;
+ coords[1] = 0.0;
+ break;
+
+ case 1:
+ coords[0] = 1.0;
+ coords[1] = 0.0;
+ break;
+
+ case 2:
+ coords[0] = 0.0;
+ coords[1] = 1.0;
+ break;
+
+ case 3:
+ coords[0] = 0.5;
+ coords[1] = 0.0;
+ break;
+
+ case 4:
+ coords[0] = 0.5;
+ coords[1] = 0.5;
+ break;
+
+ case 5:
+ coords[0] = 0.0;
+ coords[1] = 0.5;
+ break;
+
+ LOCAL_COORD_MACRO_END;
+
+ SHAPE_FUN_MACRO_BEGIN;
+ funValue[0] = (1.0 - gc[0] - gc[1])*(1.0 - 2.0*gc[0] - 2.0*gc[1]);
+ funValue[1] = gc[0]*(2.0*gc[0] - 1.0);
+ funValue[2] = gc[1]*(2.0*gc[1] - 1.0);
+ funValue[3] = 4.0*gc[0]*(1.0 - gc[0] - gc[1]);
+ funValue[4] = 4.0*gc[0]*gc[1];
+ funValue[5] = 4.0*gc[1]*(1.0 - gc[0] - gc[1]);
+ SHAPE_FUN_MACRO_END;
+}
+
+/*!
+ * Init Quadrangle Reference coordinates ans Shape function.
+ * Case A.
+ */
+void GaussInfo::quad4aInit()
+{
+ LOCAL_COORD_MACRO_BEGIN;
+ case 0:
+ coords[0] = -1.0;
+ coords[1] = 1.0;
+ break;
+ case 1:
+ coords[0] = -1.0;
+ coords[1] = -1.0;
+ break;
+ case 2:
+ coords[0] = 1.0;
+ coords[1] = -1.0;
+ break;
+ case 3:
+ coords[0] = 1.0;
+ coords[1] = 1.0;
+ break;
+
+ LOCAL_COORD_MACRO_END;
+
+ SHAPE_FUN_MACRO_BEGIN;
+ funValue[0] = 0.25*(1.0 + gc[1])*(1.0 - gc[0]);
+ funValue[1] = 0.25*(1.0 - gc[1])*(1.0 - gc[0]);
+ funValue[2] = 0.25*(1.0 - gc[1])*(1.0 + gc[0]);
+ funValue[3] = 0.25*(1.0 + gc[0])*(1.0 + gc[1]);
+ SHAPE_FUN_MACRO_END;
+}
+
+/*!
+ * Init Quadrangle Reference coordinates ans Shape function.
+ * Case B.
+ */
+void GaussInfo::quad4bInit()
+{
+ LOCAL_COORD_MACRO_BEGIN;
+ case 0:
+ coords[0] = -1.0;
+ coords[1] = -1.0;
+ break;
+ case 1:
+ coords[0] = 1.0;
+ coords[1] = -1.0;
+ break;
+ case 2:
+ coords[0] = 1.0;
+ coords[1] = 1.0;
+ break;
+ case 3:
+ coords[0] = -1.0;
+ coords[1] = 1.0;
+ break;
+
+ LOCAL_COORD_MACRO_END;
+
+ SHAPE_FUN_MACRO_BEGIN;
+ funValue[0] = 0.25*(1.0 - gc[0])*(1.0 - gc[1]);
+ funValue[1] = 0.25*(1.0 + gc[0])*(1.0 - gc[1]);
+ funValue[2] = 0.25*(1.0 + gc[0])*(1.0 + gc[1]);
+ funValue[3] = 0.25*(1.0 - gc[0])*(1.0 + gc[1]);
+ SHAPE_FUN_MACRO_END;
+}
+
+
+/*!
+ * Init Quadratic Quadrangle Reference coordinates ans Shape function.
+ * Case A.
+ */
+void GaussInfo::quad8aInit()
+{
+ LOCAL_COORD_MACRO_BEGIN;
+ case 0:
+ coords[0] = -1.0;
+ coords[1] = 1.0;
+ break;
+ case 1:
+ coords[0] = -1.0;
+ coords[1] = -1.0;
+ break;
+ case 2:
+ coords[0] = 1.0;
+ coords[1] = -1.0;
+ break;
+ case 3:
+ coords[0] = 1.0;
+ coords[1] = 1.0;
+ break;
+ case 4:
+ coords[0] = -1.0;
+ coords[1] = 0.0;
+ break;
+ case 5:
+ coords[0] = 0.0;
+ coords[1] = -1.0;
+ break;
+ case 6:
+ coords[0] = 1.0;
+ coords[1] = 0.0;
+ break;
+ case 7:
+ coords[0] = 0.0;
+ coords[1] = 1.0;
+ break;
+ LOCAL_COORD_MACRO_END;
+
+ SHAPE_FUN_MACRO_BEGIN;
+ funValue[0] = 0.25*(1.0 + gc[1])*(1.0 - gc[0])*(gc[1] - gc[0] - 1.0);
+ funValue[1] = 0.25*(1.0 - gc[1])*(1.0 - gc[0])*(-gc[1] - gc[0] - 1.0);
+ funValue[2] = 0.25*(1.0 - gc[1])*(1.0 + gc[0])*(-gc[1] + gc[0] - 1.0);
+ funValue[3] = 0.25*(1.0 + gc[1])*(1.0 + gc[0])*(gc[1] + gc[0] - 1.0);
+ funValue[4] = 0.5*(1.0 - gc[0])*(1.0 - gc[1])*(1.0 + gc[1]);
+ funValue[5] = 0.5*(1.0 - gc[1])*(1.0 - gc[0])*(1.0 + gc[0]);
+ funValue[6] = 0.5*(1.0 + gc[0])*(1.0 - gc[1])*(1.0 + gc[1]);
+ funValue[7] = 0.5*(1.0 + gc[1])*(1.0 - gc[0])*(1.0 + gc[0]);
+ SHAPE_FUN_MACRO_END;
+}
+
+/*!
+ * Init Quadratic Quadrangle Reference coordinates ans Shape function.
+ * Case B.
+ */
+void GaussInfo::quad8bInit()
+{
+ LOCAL_COORD_MACRO_BEGIN;
+ case 0:
+ coords[0] = -1.0;
+ coords[1] = -1.0;
+ break;
+ case 1:
+ coords[0] = 1.0;
+ coords[1] = -1.0;
+ break;
+ case 2:
+ coords[0] = 1.0;
+ coords[1] = 1.0;
+ break;
+ case 3:
+ coords[0] = -1.0;
+ coords[1] = 1.0;
+ break;
+ case 4:
+ coords[0] = 0.0;
+ coords[1] = -1.0;
+ break;
+ case 5:
+ coords[0] = 1.0;
+ coords[1] = 0.0;
+ break;
+ case 6:
+ coords[0] = 0.0;
+ coords[1] = 1.0;
+ break;
+ case 7:
+ coords[0] = -1.0;
+ coords[1] = 0.0;
+ break;
+ LOCAL_COORD_MACRO_END;
+
+ SHAPE_FUN_MACRO_BEGIN;
+ funValue[0] = 0.25*(1.0 - gc[0])*(1.0 - gc[1])*(-1.0 - gc[0] - gc[1]);
+ funValue[1] = 0.25*(1.0 + gc[0])*(1.0 - gc[1])*(-1.0 + gc[0] - gc[1]);
+ funValue[2] = 0.25*(1.0 + gc[0])*(1.0 + gc[1])*(-1.0 + gc[0] + gc[1]);
+ funValue[3] = 0.25*(1.0 - gc[0])*(1.0 + gc[1])*(-1.0 - gc[0] + gc[1]);
+ funValue[4] = 0.5*(1.0 - gc[0]*gc[0])*(1.0 - gc[1]);
+ funValue[5] = 0.5*(1.0 - gc[1]*gc[1])*(1.0 + gc[0]);
+ funValue[6] = 0.5*(1.0 - gc[0]*gc[0])*(1.0 + gc[1]);
+ funValue[7] = 0.5*(1.0 - gc[1]*gc[1])*(1.0 - gc[0]);
+ SHAPE_FUN_MACRO_END;
+}
+
+/*!
+ * Init Tetrahedron Reference coordinates ans Shape function.
+ * Case A.
+ */
+void GaussInfo::tetra4aInit()
+{
+ LOCAL_COORD_MACRO_BEGIN;
+ case 0:
+ coords[0] = 0.0;
+ coords[1] = 1.0;
+ coords[2] = 0.0;
+ break;
+ case 1:
+ coords[0] = 0.0;
+ coords[1] = 0.0;
+ coords[2] = 1.0;
+ break;
+ case 2:
+ coords[0] = 0.0;
+ coords[1] = 0.0;
+ coords[2] = 0.0;
+ break;
+ case 3:
+ coords[0] = 1.0;
+ coords[1] = 0.0;
+ coords[2] = 0.0;
+ break;
+ LOCAL_COORD_MACRO_END;
+
+ SHAPE_FUN_MACRO_BEGIN;
+ funValue[0] = gc[1];
+ funValue[1] = gc[2];
+ funValue[2] = 1.0 - gc[0] - gc[1] - gc[2];
+ funValue[3] = gc[0];
+ SHAPE_FUN_MACRO_END;
+}
+
+/*!
+ * Init Tetrahedron Reference coordinates ans Shape function.
+ * Case B.
+ */
+void GaussInfo::tetra4bInit()
+{
+ LOCAL_COORD_MACRO_BEGIN;
+ case 0:
+ coords[0] = 0.0;
+ coords[1] = 1.0;
+ coords[2] = 0.0;
+ break;
+ case 2:
+ coords[0] = 0.0;
+ coords[1] = 0.0;
+ coords[2] = 1.0;
+ break;
+ case 1:
+ coords[0] = 0.0;
+ coords[1] = 0.0;
+ coords[2] = 0.0;
+ break;
+ case 3:
+ coords[0] = 1.0;
+ coords[1] = 0.0;
+ coords[2] = 0.0;
+ break;
+ LOCAL_COORD_MACRO_END;
+
+ SHAPE_FUN_MACRO_BEGIN;
+ funValue[0] = gc[1];
+ funValue[2] = gc[2];
+ funValue[1] = 1.0 - gc[0] - gc[1] - gc[2];
+ funValue[3] = gc[0];
+ SHAPE_FUN_MACRO_END;
+
+}
+
+/*!
+ * Init Quadratic Tetrahedron Reference coordinates ans Shape function.
+ * Case A.
+ */
+void GaussInfo::tetra10aInit()
+{
+ LOCAL_COORD_MACRO_BEGIN;
+ case 0:
+ coords[0] = 0.0;
+ coords[1] = 1.0;
+ coords[2] = 0.0;
+ break;
+ case 1:
+ coords[0] = 0.0;
+ coords[1] = 0.0;
+ coords[2] = 1.0;
+ break;
+ case 2:
+ coords[0] = 0.0;
+ coords[1] = 0.0;
+ coords[2] = 0.0;
+ break;
+ case 3:
+ coords[0] = 1.0;
+ coords[1] = 0.0;
+ coords[2] = 0.0;
+ break;
+ case 4:
+ coords[0] = 0.0;
+ coords[1] = 0.5;
+ coords[2] = 0.5;
+ break;
+ case 5:
+ coords[0] = 0.0;
+ coords[1] = 0.0;
+ coords[2] = 0.5;
+ break;
+ case 6:
+ coords[0] = 0.0;
+ coords[1] = 0.5;
+ coords[2] = 0.0;
+ break;
+ case 7:
+ coords[0] = 0.5;
+ coords[1] = 0.5;
+ coords[2] = 0.0;
+ break;
+ case 8:
+ coords[0] = 0.5;
+ coords[1] = 0.0;
+ coords[2] = 0.5;
+ break;
+ case 9:
+ coords[0] = 0.5;
+ coords[1] = 0.0;
+ coords[2] = 0.0;
+ break;
+ LOCAL_COORD_MACRO_END;
+
+ SHAPE_FUN_MACRO_BEGIN;
+ funValue[0] = gc[1]*(2.0*gc[1] - 1.0);
+ funValue[1] = gc[2]*(2.0*gc[2] - 1.0);
+ funValue[2] = (1.0 - gc[0] - gc[1] - gc[2])*(1.0 - 2.0*gc[0] - 2.0*gc[1] - 2.0*gc[2]);
+ funValue[3] = gc[0]*(2.0*gc[0] - 1.0);
+ funValue[4] = 4.0*gc[1]*gc[2];
+ funValue[5] = 4.0*gc[2]*(1.0 - gc[0] - gc[1] - gc[2]);
+ funValue[6] = 4.0*gc[1]*(1.0 - gc[0] - gc[1] - gc[2]);
+ funValue[7] = 4.0*gc[0]*gc[1];
+ funValue[8] = 4.0*gc[0]*gc[2];
+ funValue[9] = 4.0*gc[0]*(1.0 - gc[0] - gc[1] - gc[2]);
+ SHAPE_FUN_MACRO_END;
+}
+
+/*!
+ * Init Quadratic Tetrahedron Reference coordinates ans Shape function.
+ * Case B.
+ */
+void GaussInfo::tetra10bInit()
+{
+ LOCAL_COORD_MACRO_BEGIN;
+ case 0:
+ coords[0] = 0.0;
+ coords[1] = 1.0;
+ coords[2] = 0.0;
+ break;
+ case 2:
+ coords[0] = 0.0;
+ coords[1] = 0.0;
+ coords[2] = 1.0;
+ break;
+ case 1:
+ coords[0] = 0.0;
+ coords[1] = 0.0;
+ coords[2] = 0.0;
+ break;
+ case 3:
+ coords[0] = 1.0;
+ coords[1] = 0.0;
+ coords[2] = 0.0;
+ break;
+ case 6:
+ coords[0] = 0.0;
+ coords[1] = 0.5;
+ coords[2] = 0.5;
+ break;
+ case 5:
+ coords[0] = 0.0;
+ coords[1] = 0.0;
+ coords[2] = 0.5;
+ break;
+ case 4:
+ coords[0] = 0.0;
+ coords[1] = 0.5;
+ coords[2] = 0.0;
+ break;
+ case 7:
+ coords[0] = 0.5;
+ coords[1] = 0.5;
+ coords[2] = 0.0;
+ break;
+ case 9:
+ coords[0] = 0.5;
+ coords[1] = 0.0;
+ coords[2] = 0.5;
+ break;
+ case 8:
+ coords[0] = 0.5;
+ coords[1] = 0.0;
+ coords[2] = 0.0;
+ break;
+ LOCAL_COORD_MACRO_END;
+
+ SHAPE_FUN_MACRO_BEGIN;
+ funValue[0] = gc[1]*(2.0*gc[1] - 1.0);
+ funValue[2] = gc[2]*(2.0*gc[2] - 1.0);
+ funValue[1] = (1.0 - gc[0] - gc[1] - gc[2])*(1.0 - 2.0*gc[0] - 2.0*gc[1] - 2.0*gc[2]);
+ funValue[3] = gc[0]*(2.0*gc[0] - 1.0);
+ funValue[6] = 4.0*gc[1]*gc[2];
+ funValue[5] = 4.0*gc[2]*(1.0 - gc[0] - gc[1] - gc[2]);
+ funValue[4] = 4.0*gc[1]*(1.0 - gc[0] - gc[1] - gc[2]);
+ funValue[7] = 4.0*gc[0]*gc[1];
+ funValue[9] = 4.0*gc[0]*gc[2];
+ funValue[8] = 4.0*gc[0]*(1.0 - gc[0] - gc[1] - gc[2]);
+ SHAPE_FUN_MACRO_END;
+}
+
+/*!
+ * Init Pyramid Reference coordinates ans Shape function.
+ * Case A.
+ */
+void GaussInfo::pyra5aInit()
+{
+ LOCAL_COORD_MACRO_BEGIN;
+ case 0:
+ coords[0] = 1.0;
+ coords[1] = 0.0;
+ coords[2] = 0.0;
+ break;
+ case 1:
+ coords[0] = 0.0;
+ coords[1] = 1.0;
+ coords[2] = 0.0;
+ break;
+ case 2:
+ coords[0] = -1.0;
+ coords[1] = 0.0;
+ coords[2] = 0.0;
+ break;
+ case 3:
+ coords[0] = 0.0;
+ coords[1] = -1.0;
+ coords[2] = 0.0;
+ break;
+ case 4:
+ coords[0] = 0.0;
+ coords[1] = 0.0;
+ coords[2] = 1.0;
+ break;
+ LOCAL_COORD_MACRO_END;
+
+ SHAPE_FUN_MACRO_BEGIN;
+ funValue[0] = 0.25*(-gc[0] + gc[1] - 1.0)*(-gc[0] - gc[1] - 1.0)*(1.0 - gc[2]);
+ funValue[1] = 0.25*(-gc[0] - gc[1] - 1.0)*(+gc[0] - gc[1] - 1.0)*(1.0 - gc[2]);
+ funValue[2] = 0.25*(+gc[0] + gc[1] - 1.0)*(+gc[0] - gc[1] - 1.0)*(1.0 - gc[2]);
+ funValue[3] = 0.25*(+gc[0] + gc[1] - 1.0)*(-gc[0] + gc[1] - 1.0)*(1.0 - gc[2]);
+ funValue[4] = gc[2];
+ SHAPE_FUN_MACRO_END;
+}
+/*!
+ * Init Pyramid Reference coordinates ans Shape function.
+ * Case B.
+ */
+void GaussInfo::pyra5bInit()
+{
+ LOCAL_COORD_MACRO_BEGIN;
+ case 0:
+ coords[0] = 1.0;
+ coords[1] = 0.0;
+ coords[2] = 0.0;
+ break;
+ case 3:
+ coords[0] = 0.0;
+ coords[1] = 1.0;
+ coords[2] = 0.0;
+ break;
+ case 2:
+ coords[0] = -1.0;
+ coords[1] = 0.0;
+ coords[2] = 0.0;
+ break;
+ case 1:
+ coords[0] = 0.0;
+ coords[1] = -1.0;
+ coords[2] = 0.0;
+ break;
+ case 4:
+ coords[0] = 0.0;
+ coords[1] = 0.0;
+ coords[2] = 1.0;
+ break;
+ LOCAL_COORD_MACRO_END;
+
+ SHAPE_FUN_MACRO_BEGIN;
+ funValue[0] = 0.25*(-gc[0] + gc[1] - 1.0)*(-gc[0] - gc[1] - 1.0)*(1.0 - gc[2]);
+ funValue[3] = 0.25*(-gc[0] - gc[1] - 1.0)*(+gc[0] - gc[1] - 1.0)*(1.0 - gc[2]);
+ funValue[2] = 0.25*(+gc[0] + gc[1] - 1.0)*(+gc[0] - gc[1] - 1.0)*(1.0 - gc[2]);
+ funValue[1] = 0.25*(+gc[0] + gc[1] - 1.0)*(-gc[0] + gc[1] - 1.0)*(1.0 - gc[2]);
+ funValue[4] = gc[2];
+ SHAPE_FUN_MACRO_END;
+}
+
+/*!
+ * Init Quadratic Pyramid Reference coordinates ans Shape function.
+ * Case A.
+ */
+void GaussInfo::pyra13aInit()
+{
+ LOCAL_COORD_MACRO_BEGIN;
+ case 0:
+ coords[0] = 1.0;
+ coords[1] = 0.0;
+ coords[2] = 0.0;
+ break;
+ case 1:
+ coords[0] = 0.0;
+ coords[1] = 1.0;
+ coords[2] = 0.0;
+ break;
+ case 2:
+ coords[0] = -1.0;
+ coords[1] = 0.0;
+ coords[2] = 0.0;
+ break;
+ case 3:
+ coords[0] = 0.0;
+ coords[1] = -1.0;
+ coords[2] = 0.0;
+ break;
+ case 4:
+ coords[0] = 0.0;
+ coords[1] = 0.0;
+ coords[2] = 1.0;
+ break;
+
+ case 5:
+ coords[0] = 0.5;
+ coords[1] = 0.5;
+ coords[2] = 0.0;
+ break;
+ case 6:
+ coords[0] = -0.5;
+ coords[1] = 0.5;
+ coords[2] = 0.0;
+ break;
+ case 7:
+ coords[0] = -0.5;
+ coords[1] = -0.5;
+ coords[2] = 0.0;
+ break;
+ case 8:
+ coords[0] = 0.5;
+ coords[1] = -0.5;
+ coords[2] = 0.0;
+ break;
+ case 9:
+ coords[0] = 0.5;
+ coords[1] = 0.0;
+ coords[2] = 0.5;
+ break;
+ case 10:
+ coords[0] = 0.0;
+ coords[1] = 0.5;
+ coords[2] = 0.5;
+ break;
+ case 11:
+ coords[0] = -0.5;
+ coords[1] = 0.0;
+ coords[2] = 0.5;
+ break;
+ case 12:
+ coords[0] = 0.0;
+ coords[1] = -0.5;
+ coords[2] = 0.5;
+ break;
+ LOCAL_COORD_MACRO_END;
+
+ SHAPE_FUN_MACRO_BEGIN;
+ funValue[0] = 0.5*(-gc[0] + gc[1] + gc[2] - 1.0)*(-gc[0] - gc[1] + gc[2] - 1.0)*
+ (gc[0] - 0.5)/(1.0 - gc[2]);
+ funValue[1] = 0.5*(-gc[0] - gc[1] + gc[2] - 1.0)*(+gc[0] - gc[1] + gc[2] - 1.0)*
+ (gc[1] - 0.5)/(1.0 - gc[2]);
+ funValue[2] = 0.5*(+gc[0] - gc[1] + gc[2] - 1.0)*(+gc[0] + gc[1] + gc[2] - 1.0)*
+ (-gc[0] - 0.5)/(1.0 - gc[2]);
+ funValue[3] = 0.5*(+gc[0] + gc[1] + gc[2] - 1.0)*(-gc[0] + gc[1] + gc[2] - 1.0)*
+ (-gc[1] - 0.5)/(1.0 - gc[2]);
+
+ funValue[4] = 2.0*gc[2]*(gc[2] - 0.5);
+
+ funValue[5] = 0.5*(-gc[0] + gc[1] + gc[2] - 1.0)*(-gc[0] - gc[1] + gc[2] - 1.0)*
+ (gc[0] - gc[1] + gc[2] - 1.0)/(1.0 - gc[2]);
+ funValue[6] = 0.5*(-gc[0] - gc[1] + gc[2] - 1.0)*(gc[0] - gc[1] + gc[2] - 1.0)*
+ (gc[0] + gc[1] + gc[2] - 1.0)/(1.0 - gc[2]);
+ funValue[7] = 0.5*(gc[0] - gc[1] + gc[2] - 1.0)*(gc[0] + gc[1] + gc[2] - 1.0)*
+ (-gc[0] + gc[1] + gc[2] - 1.0)/(1.0 - gc[2]);
+ funValue[8] = 0.5*(gc[0] + gc[1] + gc[2] - 1.0)*(-gc[0] + gc[1] + gc[2] - 1.0)*
+ (-gc[0] - gc[1] + gc[2] - 1.0)/(1.0 - gc[2]);
+
+ funValue[9] = 0.5*gc[2]*(-gc[0] + gc[1] + gc[2] - 1.0)*(-gc[0] - gc[1] + gc[2] - 1.0)/
+ (1.0 - gc[2]);
+ funValue[10] = 0.5*gc[2]*(-gc[0] - gc[1] + gc[2] - 1.0)*(gc[0] - gc[1] + gc[2] - 1.0)/
+ (1.0 - gc[2]);
+ funValue[11] = 0.5*gc[2]*(gc[0] - gc[1] + gc[2] - 1.0)*(gc[0] + gc[1] + gc[2] - 1.0)/
+ (1.0 - gc[2]);
+ funValue[12] = 0.5*gc[2]*(gc[0] + gc[1] + gc[2] - 1.0)*(-gc[0] + gc[1] + gc[2] - 1.0)/
+ (1.0 - gc[2]);
+ SHAPE_FUN_MACRO_END;
+}
+
+/*!
+ * Init Quadratic Pyramid Reference coordinates ans Shape function.
+ * Case B.
+ */
+void GaussInfo::pyra13bInit()
+{
+ LOCAL_COORD_MACRO_BEGIN;
+ case 0:
+ coords[0] = 1.0;
+ coords[1] = 0.0;
+ coords[2] = 0.0;
+ break;
+ case 3:
+ coords[0] = 0.0;
+ coords[1] = 1.0;
+ coords[2] = 0.0;
+ break;
+ case 2:
+ coords[0] = -1.0;
+ coords[1] = 0.0;
+ coords[2] = 0.0;
+ break;
+ case 1:
+ coords[0] = 0.0;
+ coords[1] = -1.0;
+ coords[2] = 0.0;
+ break;
+ case 4:
+ coords[0] = 0.0;
+ coords[1] = 0.0;
+ coords[2] = 1.0;
+ break;
+ case 8:
+ coords[0] = 0.5;
+ coords[1] = 0.5;
+ coords[2] = 0.0;
+ break;
+ case 7:
+ coords[0] = -0.5;
+ coords[1] = 0.5;
+ coords[2] = 0.0;
+ break;
+ case 6:
+ coords[0] = -0.5;
+ coords[1] = -0.5;
+ coords[2] = 0.0;
+ break;
+ case 5:
+ coords[0] = 0.5;
+ coords[1] = -0.5;
+ coords[2] = 0.0;
+ break;
+ case 9:
+ coords[0] = 0.5;
+ coords[1] = 0.0;
+ coords[2] = 0.5;
+ break;
+ case 12:
+ coords[0] = 0.0;
+ coords[1] = 0.5;
+ coords[2] = 0.5;
+ break;
+ case 11:
+ coords[0] = -0.5;
+ coords[1] = 0.0;
+ coords[2] = 0.5;
+ break;
+ case 10:
+ coords[0] = 0.0;
+ coords[1] = -0.5;
+ coords[2] = 0.5;
+ break;
+ LOCAL_COORD_MACRO_END;
+
+ SHAPE_FUN_MACRO_BEGIN;
+ funValue[0] = 0.5*(-gc[0] + gc[1] + gc[2] - 1.0)*(-gc[0] - gc[1] + gc[2] - 1.0)*
+ (gc[0] - 0.5)/(1.0 - gc[2]);
+ funValue[3] = 0.5*(-gc[0] - gc[1] + gc[2] - 1.0)*(+gc[0] - gc[1] + gc[2] - 1.0)*
+ (gc[1] - 0.5)/(1.0 - gc[2]);
+ funValue[2] = 0.5*(+gc[0] - gc[1] + gc[2] - 1.0)*(+gc[0] + gc[1] + gc[2] - 1.0)*
+ (-gc[0] - 0.5)/(1.0 - gc[2]);
+ funValue[1] = 0.5*(+gc[0] + gc[1] + gc[2] - 1.0)*(-gc[0] + gc[1] + gc[2] - 1.0)*
+ (-gc[1] - 0.5)/(1.0 - gc[2]);
+
+ funValue[4] = 2.0*gc[2]*(gc[2] - 0.5);
+
+ funValue[8] = 0.5*(-gc[0] + gc[1] + gc[2] - 1.0)*(-gc[0] - gc[1] + gc[2] - 1.0)*
+ (gc[0] - gc[1] + gc[2] - 1.0)/(1.0 - gc[2]);
+ funValue[7] = 0.5*(-gc[0] - gc[1] + gc[2] - 1.0)*(gc[0] - gc[1] + gc[2] - 1.0)*
+ (gc[0] + gc[1] + gc[2] - 1.0)/(1.0 - gc[2]);
+ funValue[6] = 0.5*(gc[0] - gc[1] + gc[2] - 1.0)*(gc[0] + gc[1] + gc[2] - 1.0)*
+ (-gc[0] + gc[1] + gc[2] - 1.0)/(1.0 - gc[2]);
+ funValue[5] = 0.5*(gc[0] + gc[1] + gc[2] - 1.0)*(-gc[0] + gc[1] + gc[2] - 1.0)*
+ (-gc[0] - gc[1] + gc[2] - 1.0)/(1.0 - gc[2]);
+
+ funValue[9] = 0.5*gc[2]*(-gc[0] + gc[1] + gc[2] - 1.0)*(-gc[0] - gc[1] + gc[2] - 1.0)/
+ (1.0 - gc[2]);
+ funValue[12] = 0.5*gc[2]*(-gc[0] - gc[1] + gc[2] - 1.0)*(gc[0] - gc[1] + gc[2] - 1.0)/
+ (1.0 - gc[2]);
+ funValue[11] = 0.5*gc[2]*(gc[0] - gc[1] + gc[2] - 1.0)*(gc[0] + gc[1] + gc[2] - 1.0)/
+ (1.0 - gc[2]);
+ funValue[10] = 0.5*gc[2]*(gc[0] + gc[1] + gc[2] - 1.0)*(-gc[0] + gc[1] + gc[2] - 1.0)/
+ (1.0 - gc[2]);
+ SHAPE_FUN_MACRO_END;
+}
+
+
+/*!
+ * Init Pentahedron Reference coordinates and Shape function.
+ * Case A.
+ */
+void GaussInfo::penta6aInit()
+{
+ LOCAL_COORD_MACRO_BEGIN;
+ case 0:
+ coords[0] = -1.0;
+ coords[1] = 1.0;
+ coords[2] = 0.0;
+ break;
+ case 1:
+ coords[0] = -1.0;
+ coords[1] = -0.0;
+ coords[2] = 1.0;
+ break;
+ case 2:
+ coords[0] = -1.0;
+ coords[1] = 0.0;
+ coords[2] = 0.0;
+ break;
+ case 3:
+ coords[0] = 1.0;
+ coords[1] = 1.0;
+ coords[2] = 0.0;
+ break;
+ case 4:
+ coords[0] = 1.0;
+ coords[1] = 0.0;
+ coords[2] = 1.0;
+ break;
+ case 5:
+ coords[0] = 1.0;
+ coords[1] = 0.0;
+ coords[2] = 0.0;
+ break;
+ LOCAL_COORD_MACRO_END;
+
+ SHAPE_FUN_MACRO_BEGIN;
+ funValue[0] = 0.5*gc[1]*(1.0 - gc[0]);
+ funValue[1] = 0.5*gc[2]*(1.0 - gc[0]);
+ funValue[2] = 0.5*(1.0 - gc[1] - gc[2])*(1.0 - gc[0]);
+
+ funValue[3] = 0.5*gc[1]*(gc[0] + 1.0);
+ funValue[4] = 0.5*gc[2]*(gc[0] + 1.0);
+ funValue[5] = 0.5*(1.0 - gc[1] - gc[2])*(1.0 + gc[0]);
+ SHAPE_FUN_MACRO_END;
+}
+
+/*!
+ * Init Pentahedron Reference coordinates and Shape function.
+ * Case B.
+ */
+void GaussInfo::penta6bInit()
+{
+ LOCAL_COORD_MACRO_BEGIN;
+ case 0:
+ coords[0] = -1.0;
+ coords[1] = 1.0;
+ coords[2] = 0.0;
+ break;
+ case 2:
+ coords[0] = -1.0;
+ coords[1] = -0.0;
+ coords[2] = 1.0;
+ break;
+ case 1:
+ coords[0] = -1.0;
+ coords[1] = 0.0;
+ coords[2] = 0.0;
+ break;
+ case 3:
+ coords[0] = 1.0;
+ coords[1] = 1.0;
+ coords[2] = 0.0;
+ break;
+ case 5:
+ coords[0] = 1.0;
+ coords[1] = 0.0;
+ coords[2] = 1.0;
+ break;
+ case 4:
+ coords[0] = 1.0;
+ coords[1] = 0.0;
+ coords[2] = 0.0;
+ break;
+ LOCAL_COORD_MACRO_END;
+
+ SHAPE_FUN_MACRO_BEGIN;
+ funValue[0] = 0.5*gc[1]*(1.0 - gc[0]);
+ funValue[2] = 0.5*gc[2]*(1.0 - gc[0]);
+ funValue[1] = 0.5*(1.0 - gc[1] - gc[2])*(1.0 - gc[0]);
+ funValue[3] = 0.5*gc[1]*(gc[0] + 1.0);
+ funValue[5] = 0.5*gc[2]*(gc[0] + 1.0);
+ funValue[4] = 0.5*(1.0 - gc[1] - gc[2])*(1.0 + gc[0]);
+ SHAPE_FUN_MACRO_END;
+}
+/*!
+ * Init Pentahedron Reference coordinates and Shape function.
+ * Case A.
+ */
+void GaussInfo::penta15aInit()
+{
+ LOCAL_COORD_MACRO_BEGIN;
+ case 0:
+ coords[0] = -1.0;
+ coords[1] = 1.0;
+ coords[2] = 0.0;
+ break;
+ case 1:
+ coords[0] = -1.0;
+ coords[1] = -0.0;
+ coords[2] = 1.0;
+ break;
+ case 2:
+ coords[0] = -1.0;
+ coords[1] = 0.0;
+ coords[2] = 0.0;
+ break;
+ case 3:
+ coords[0] = 1.0;
+ coords[1] = 1.0;
+ coords[2] = 0.0;
+ break;
+ case 4:
+ coords[0] = 1.0;
+ coords[1] = 0.0;
+ coords[2] = 1.0;
+ break;
+ case 5:
+ coords[0] = 1.0;
+ coords[1] = 0.0;
+ coords[2] = 0.0;
+ break;
+
+ case 6:
+ coords[0] = -1.0;
+ coords[1] = 0.5;
+ coords[2] = 0.5;
+ break;
+ case 7:
+ coords[0] = -1.0;
+ coords[1] = 0.0;
+ coords[2] = 0.5;
+ break;
+ case 8:
+ coords[0] = -1.0;
+ coords[1] = 0.5;
+ coords[2] = 0.0;
+ break;
+ case 9:
+ coords[0] = 0.0;
+ coords[1] = 1.0;
+ coords[2] = 0.0;
+ break;
+ case 10:
+ coords[0] = 0.0;
+ coords[1] = 0.0;
+ coords[2] = 1.0;
+ break;
+ case 11:
+ coords[0] = 0.0;
+ coords[1] = 0.0;
+ coords[2] = 0.0;
+ break;
+ case 12:
+ coords[0] = 1.0;
+ coords[1] = 0.5;
+ coords[2] = 0.5;
+ break;
+ case 13:
+ coords[0] = 1.0;
+ coords[1] = 0.0;
+ coords[2] = 0.5;
+ break;
+ case 14:
+ coords[0] = 1.0;
+ coords[1] = 0.5;
+ coords[2] = 0.0;
+ break;
+ LOCAL_COORD_MACRO_END;
+
+ SHAPE_FUN_MACRO_BEGIN;
+ funValue[0] = 0.5*gc[1]*(1.0 - gc[0])*(2.0*gc[1] - 2.0 - gc[0]);
+ funValue[1] = 0.5*gc[2]*(1.0 - gc[0])*(2.0*gc[2] - 2.0 - gc[0]);
+ funValue[2] = 0.5*(gc[0] - 1.0)*(1.0 - gc[1] - gc[2])*(gc[0] + 2.0*gc[1] + 2.0*gc[2]);
+
+ funValue[3] = 0.5*gc[1]*(1.0 + gc[0])*(2.0*gc[1] - 2.0 + gc[0]);
+ funValue[4] = 0.5*gc[2]*(1.0 + gc[0])*(2.0*gc[2] - 2.0 + gc[0]);
+ funValue[5] = 0.5*(-gc[0] - 1.0)*(1.0 - gc[1] - gc[2])*(-gc[0] + 2.0*gc[1] + 2.0*gc[2]);
+
+ funValue[6] = 2.0*gc[1]*gc[2]*(1.0 - gc[0]);
+ funValue[7] = 2.0*gc[2]*(1.0 - gc[1] - gc[2])*(1.0 - gc[0]);
+ funValue[8] = 2.0*gc[1]*(1.0 - gc[1] - gc[2])*(1.0 - gc[0]);
+
+ funValue[9] = gc[1]*(1.0 - gc[0]*gc[0]);
+ funValue[10] = gc[2]*(1.0 - gc[0]*gc[0]);
+ funValue[11] = (1.0 - gc[1] - gc[2])*(1.0 - gc[0]*gc[0]);
+
+ funValue[12] = 2.0*gc[1]*gc[2]*(1.0 + gc[0]);
+ funValue[13] = 2.0*gc[2]*(1.0 - gc[1] - gc[2])*(1.0 + gc[0]);
+ funValue[14] = 2.0*gc[1]*(1.0 - gc[1] - gc[2])*(1.0 + gc[0]);
+ SHAPE_FUN_MACRO_END;
+}
+
+/*!
+ * Init Qaudratic Pentahedron Reference coordinates and Shape function.
+ * Case B.
+ */
+void GaussInfo::penta15bInit()
+{
+ LOCAL_COORD_MACRO_BEGIN;
+ case 0:
+ coords[0] = -1.0;
+ coords[1] = 1.0;
+ coords[2] = 0.0;
+ break;
+ case 2:
+ coords[0] = -1.0;
+ coords[1] = -0.0;
+ coords[2] = 1.0;
+ break;
+ case 1:
+ coords[0] = -1.0;
+ coords[1] = 0.0;
+ coords[2] = 0.0;
+ break;
+ case 3:
+ coords[0] = 1.0;
+ coords[1] = 1.0;
+ coords[2] = 0.0;
+ break;
+ case 5:
+ coords[0] = 1.0;
+ coords[1] = 0.0;
+ coords[2] = 1.0;
+ break;
+ case 4:
+ coords[0] = 1.0;
+ coords[1] = 0.0;
+ coords[2] = 0.0;
+ break;
+
+ case 8:
+ coords[0] = -1.0;
+ coords[1] = 0.5;
+ coords[2] = 0.5;
+ break;
+ case 7:
+ coords[0] = -1.0;
+ coords[1] = 0.0;
+ coords[2] = 0.5;
+ break;
+ case 6:
+ coords[0] = -1.0;
+ coords[1] = 0.5;
+ coords[2] = 0.0;
+ break;
+ case 12:
+ coords[0] = 0.0;
+ coords[1] = 1.0;
+ coords[2] = 0.0;
+ break;
+ case 14:
+ coords[0] = 0.0;
+ coords[1] = 0.0;
+ coords[2] = 1.0;
+ break;
+ case 13:
+ coords[0] = 0.0;
+ coords[1] = 0.0;
+ coords[2] = 0.0;
+ break;
+ case 11:
+ coords[0] = 1.0;
+ coords[1] = 0.5;
+ coords[2] = 0.5;
+ break;
+ case 10:
+ coords[0] = 1.0;
+ coords[1] = 0.0;
+ coords[2] = 0.5;
+ break;
+ case 9:
+ coords[0] = 1.0;
+ coords[1] = 0.5;
+ coords[2] = 0.0;
+ break;
+ LOCAL_COORD_MACRO_END;
+
+ SHAPE_FUN_MACRO_BEGIN;
+ funValue[0] = 0.5*gc[1]*(1.0 - gc[0])*(2.0*gc[1] - 2.0 - gc[0]);
+ funValue[2] = 0.5*gc[2]*(1.0 - gc[0])*(2.0*gc[2] - 2.0 - gc[0]);
+ funValue[1] = 0.5*(gc[0] - 1.0)*(1.0 - gc[1] - gc[2])*(gc[0] + 2.0*gc[1] + 2.0*gc[2]);
+
+ funValue[3] = 0.5*gc[1]*(1.0 + gc[0])*(2.0*gc[1] - 2.0 + gc[0]);
+ funValue[5] = 0.5*gc[2]*(1.0 + gc[0])*(2.0*gc[2] - 2.0 + gc[0]);
+ funValue[4] = 0.5*(-gc[0] - 1.0)*(1.0 - gc[1] - gc[2])*(-gc[0] + 2.0*gc[1] + 2.0*gc[2]);
+
+ funValue[8] = 2.0*gc[1]*gc[2]*(1.0 - gc[0]);
+ funValue[7] = 2.0*gc[2]*(1.0 - gc[1] - gc[2])*(1.0 - gc[0]);
+ funValue[6] = 2.0*gc[1]*(1.0 - gc[1] - gc[2])*(1.0 - gc[0]);
+
+ funValue[12] = gc[1]*(1.0 - gc[0]*gc[0]);
+ funValue[14] = gc[2]*(1.0 - gc[0]*gc[0]);
+ funValue[13] = (1.0 - gc[1] - gc[2])*(1.0 - gc[0]*gc[0]);
+
+ funValue[11] = 2.0*gc[1]*gc[2]*(1.0 + gc[0]);
+ funValue[10] = 2.0*gc[2]*(1.0 - gc[1] - gc[2])*(1.0 + gc[0]);
+ funValue[9] = 2.0*gc[1]*(1.0 - gc[1] - gc[2])*(1.0 + gc[0]);
+ SHAPE_FUN_MACRO_END;
+}
+
+/*!
+ * Init Hehahedron Reference coordinates and Shape function.
+ * Case A.
+ */
+void GaussInfo::hexa8aInit()
+{
+ LOCAL_COORD_MACRO_BEGIN;
+ case 0:
+ coords[0] = -1.0;
+ coords[1] = -1.0;
+ coords[2] = -1.0;
+ break;
+ case 1:
+ coords[0] = 1.0;
+ coords[1] = -1.0;
+ coords[2] = -1.0;
+ break;
+ case 2:
+ coords[0] = 1.0;
+ coords[1] = 1.0;
+ coords[2] = -1.0;
+ break;
+ case 3:
+ coords[0] = -1.0;
+ coords[1] = 1.0;
+ coords[2] = -1.0;
+ break;
+ case 4:
+ coords[0] = -1.0;
+ coords[1] = -1.0;
+ coords[2] = 1.0;
+ break;
+ case 5:
+ coords[0] = 1.0;
+ coords[1] = -1.0;
+ coords[2] = 1.0;
+ break;
+ case 6:
+ coords[0] = 1.0;
+ coords[1] = 1.0;
+ coords[2] = 1.0;
+ break;
+ case 7:
+ coords[0] = -1.0;
+ coords[1] = 1.0;
+ coords[2] = 1.0;
+ break;
+ LOCAL_COORD_MACRO_END;
+
+ SHAPE_FUN_MACRO_BEGIN;
+ funValue[0] = 0.125*(1.0 - gc[0])*(1.0 - gc[1])*(1.0 - gc[2]);
+ funValue[1] = 0.125*(1.0 + gc[0])*(1.0 - gc[1])*(1.0 - gc[2]);
+ funValue[2] = 0.125*(1.0 + gc[0])*(1.0 + gc[1])*(1.0 - gc[2]);
+ funValue[3] = 0.125*(1.0 - gc[0])*(1.0 + gc[1])*(1.0 - gc[2]);
+
+ funValue[4] = 0.125*(1.0 - gc[0])*(1.0 - gc[1])*(1.0 + gc[2]);
+ funValue[5] = 0.125*(1.0 + gc[0])*(1.0 - gc[1])*(1.0 + gc[2]);
+ funValue[6] = 0.125*(1.0 + gc[0])*(1.0 + gc[1])*(1.0 + gc[2]);
+ funValue[7] = 0.125*(1.0 - gc[0])*(1.0 + gc[1])*(1.0 + gc[2]);
+ SHAPE_FUN_MACRO_END;
+}
+
+/*!
+ * Init Hehahedron Reference coordinates and Shape function.
+ * Case B.
+ */
+void GaussInfo::hexa8bInit()
+{
+ LOCAL_COORD_MACRO_BEGIN;
+ case 0:
+ coords[0] = -1.0;
+ coords[1] = -1.0;
+ coords[2] = -1.0;
+ break;
+ case 3:
+ coords[0] = 1.0;
+ coords[1] = -1.0;
+ coords[2] = -1.0;
+ break;
+ case 2:
+ coords[0] = 1.0;
+ coords[1] = 1.0;
+ coords[2] = -1.0;
+ break;
+ case 1:
+ coords[0] = -1.0;
+ coords[1] = 1.0;
+ coords[2] = -1.0;
+ break;
+ case 4:
+ coords[0] = -1.0;
+ coords[1] = -1.0;
+ coords[2] = 1.0;
+ break;
+ case 7:
+ coords[0] = 1.0;
+ coords[1] = -1.0;
+ coords[2] = 1.0;
+ break;
+ case 6:
+ coords[0] = 1.0;
+ coords[1] = 1.0;
+ coords[2] = 1.0;
+ break;
+ case 5:
+ coords[0] = -1.0;
+ coords[1] = 1.0;
+ coords[2] = 1.0;
+ break;
+ LOCAL_COORD_MACRO_END;
+
+ SHAPE_FUN_MACRO_BEGIN;
+ funValue[0] = 0.125*(1.0 - gc[0])*(1.0 - gc[1])*(1.0 - gc[2]);
+ funValue[3] = 0.125*(1.0 + gc[0])*(1.0 - gc[1])*(1.0 - gc[2]);
+ funValue[2] = 0.125*(1.0 + gc[0])*(1.0 + gc[1])*(1.0 - gc[2]);
+ funValue[1] = 0.125*(1.0 - gc[0])*(1.0 + gc[1])*(1.0 - gc[2]);
+
+ funValue[4] = 0.125*(1.0 - gc[0])*(1.0 - gc[1])*(1.0 + gc[2]);
+ funValue[7] = 0.125*(1.0 + gc[0])*(1.0 - gc[1])*(1.0 + gc[2]);
+ funValue[6] = 0.125*(1.0 + gc[0])*(1.0 + gc[1])*(1.0 + gc[2]);
+ funValue[5] = 0.125*(1.0 - gc[0])*(1.0 + gc[1])*(1.0 + gc[2]);
+ SHAPE_FUN_MACRO_END;
+}
+
+/*!
+ * Init Qaudratic Hehahedron Reference coordinates and Shape function.
+ * Case A.
+ */
+void GaussInfo::hexa20aInit()
+{
+ LOCAL_COORD_MACRO_BEGIN;
+ case 0:
+ coords[0] = -1.0;
+ coords[1] = -1.0;
+ coords[2] = -1.0;
+ break;
+ case 1:
+ coords[0] = 1.0;
+ coords[1] = -1.0;
+ coords[2] = -1.0;
+ break;
+ case 2:
+ coords[0] = 1.0;
+ coords[1] = 1.0;
+ coords[2] = -1.0;
+ break;
+ case 3:
+ coords[0] = -1.0;
+ coords[1] = 1.0;
+ coords[2] = -1.0;
+ break;
+ case 4:
+ coords[0] = -1.0;
+ coords[1] = -1.0;
+ coords[2] = 1.0;
+ break;
+ case 5:
+ coords[0] = 1.0;
+ coords[1] = -1.0;
+ coords[2] = 1.0;
+ break;
+ case 6:
+ coords[0] = 1.0;
+ coords[1] = 1.0;
+ coords[2] = 1.0;
+ break;
+ case 7:
+ coords[0] = -1.0;
+ coords[1] = 1.0;
+ coords[2] = 1.0;
+ break;
+
+ case 8:
+ coords[0] = 0.0;
+ coords[1] = -1.0;
+ coords[2] = -1.0;
+ break;
+ case 9:
+ coords[0] = 1.0;
+ coords[1] = 0.0;
+ coords[2] = -1.0;
+ break;
+ case 10:
+ coords[0] = 0.0;
+ coords[1] = 1.0;
+ coords[2] = -1.0;
+ break;
+ case 11:
+ coords[0] = -1.0;
+ coords[1] = 0.0;
+ coords[2] = -1.0;
+ break;
+ case 12:
+ coords[0] = -1.0;
+ coords[1] = -1.0;
+ coords[2] = 0.0;
+ break;
+ case 13:
+ coords[0] = 1.0;
+ coords[1] = -1.0;
+ coords[2] = 0.0;
+ break;
+ case 14:
+ coords[0] = 1.0;
+ coords[1] = 1.0;
+ coords[2] = 0.0;
+ break;
+ case 15:
+ coords[0] = -1.0;
+ coords[1] = 1.0;
+ coords[2] = 0.0;
+ break;
+ case 16:
+ coords[0] = 0.0;
+ coords[1] = -1.0;
+ coords[2] = 1.0;
+ break;
+ case 17:
+ coords[0] = 1.0;
+ coords[1] = 0.0;
+ coords[2] = 1.0;
+ break;
+ case 18:
+ coords[0] = 0.0;
+ coords[1] = 1.0;
+ coords[2] = 1.0;
+ break;
+ case 19:
+ coords[0] = -1.0;
+ coords[1] = 0.0;
+ coords[2] = 1.0;
+ break;
+ LOCAL_COORD_MACRO_END;
+
+ SHAPE_FUN_MACRO_BEGIN;
+ funValue[0] = 0.125*(1.0 - gc[0])*(1.0 - gc[1])*(1.0 - gc[2])*
+ (-2.0 - gc[0] - gc[1] - gc[2]);
+ funValue[1] = 0.125*(1.0 + gc[0])*(1.0 - gc[1])*(1.0 - gc[2])*
+ (-2.0 + gc[0] - gc[1] - gc[2]);
+ funValue[2] = 0.125*(1.0 + gc[0])*(1.0 + gc[1])*(1.0 - gc[2])*
+ (-2.0 + gc[0] + gc[1] - gc[2]);
+ funValue[3] = 0.125*(1.0 - gc[0])*(1.0 + gc[1])*(1.0 - gc[2])*
+ (-2.0 - gc[0] + gc[1] - gc[2]);
+ funValue[4] = 0.125*(1.0 - gc[0])*(1.0 - gc[1])*(1.0 + gc[2])*
+ (-2.0 - gc[0] - gc[1] + gc[2]);
+ funValue[5] = 0.125*(1.0 + gc[0])*(1.0 - gc[1])*(1.0 + gc[2])*
+ (-2.0 + gc[0] - gc[1] + gc[2]);
+ funValue[6] = 0.125*(1.0 + gc[0])*(1.0 + gc[1])*(1.0 + gc[2])*
+ (-2.0 + gc[0] + gc[1] + gc[2]);
+ funValue[7] = 0.125*(1.0 - gc[0])*(1.0 + gc[1])*(1.0 + gc[2])*
+ (-2.0 - gc[0] + gc[1] + gc[2]);
+
+ funValue[8] = 0.25*(1.0 - gc[0]*gc[0])*(1.0 - gc[1])*(1.0 - gc[2]);
+ funValue[9] = 0.25*(1.0 - gc[1]*gc[1])*(1.0 + gc[0])*(1.0 - gc[2]);
+ funValue[10] = 0.25*(1.0 - gc[0]*gc[0])*(1.0 + gc[1])*(1.0 - gc[2]);
+ funValue[11] = 0.25*(1.0 - gc[1]*gc[1])*(1.0 - gc[0])*(1.0 - gc[2]);
+ funValue[12] = 0.25*(1.0 - gc[2]*gc[2])*(1.0 - gc[0])*(1.0 - gc[1]);
+ funValue[13] = 0.25*(1.0 - gc[2]*gc[2])*(1.0 + gc[0])*(1.0 - gc[1]);
+ funValue[14] = 0.25*(1.0 - gc[2]*gc[2])*(1.0 + gc[0])*(1.0 + gc[1]);
+ funValue[15] = 0.25*(1.0 - gc[2]*gc[2])*(1.0 - gc[0])*(1.0 + gc[1]);
+ funValue[16] = 0.25*(1.0 - gc[0]*gc[0])*(1.0 - gc[1])*(1.0 + gc[2]);
+ funValue[17] = 0.25*(1.0 - gc[1]*gc[1])*(1.0 + gc[0])*(1.0 + gc[2]);
+ funValue[18] = 0.25*(1.0 - gc[0]*gc[0])*(1.0 + gc[1])*(1.0 + gc[2]);
+ funValue[19] = 0.25*(1.0 - gc[1]*gc[1])*(1.0 - gc[0])*(1.0 + gc[2]);
+ SHAPE_FUN_MACRO_END;
+}
+
+/*!
+ * Init Qaudratic Hehahedron Reference coordinates and Shape function.
+ * Case B.
+ */
+void GaussInfo::hexa20bInit()
+{
+ LOCAL_COORD_MACRO_BEGIN;
+ case 0:
+ coords[0] = -1.0;
+ coords[1] = -1.0;
+ coords[2] = -1.0;
+ break;
+ case 3:
+ coords[0] = 1.0;
+ coords[1] = -1.0;
+ coords[2] = -1.0;
+ break;
+ case 2:
+ coords[0] = 1.0;
+ coords[1] = 1.0;
+ coords[2] = -1.0;
+ break;
+ case 1:
+ coords[0] = -1.0;
+ coords[1] = 1.0;
+ coords[2] = -1.0;
+ break;
+ case 4:
+ coords[0] = -1.0;
+ coords[1] = -1.0;
+ coords[2] = 1.0;
+ break;
+ case 7:
+ coords[0] = 1.0;
+ coords[1] = -1.0;
+ coords[2] = 1.0;
+ break;
+ case 6:
+ coords[0] = 1.0;
+ coords[1] = 1.0;
+ coords[2] = 1.0;
+ break;
+ case 5:
+ coords[0] = -1.0;
+ coords[1] = 1.0;
+ coords[2] = 1.0;
+ break;
+
+ case 11:
+ coords[0] = 0.0;
+ coords[1] = -1.0;
+ coords[2] = -1.0;
+ break;
+ case 10:
+ coords[0] = 1.0;
+ coords[1] = 0.0;
+ coords[2] = -1.0;
+ break;
+ case 9:
+ coords[0] = 0.0;
+ coords[1] = 1.0;
+ coords[2] = -1.0;
+ break;
+ case 8:
+ coords[0] = -1.0;
+ coords[1] = 0.0;
+ coords[2] = -1.0;
+ break;
+ case 16:
+ coords[0] = -1.0;
+ coords[1] = -1.0;
+ coords[2] = 0.0;
+ break;
+ case 19:
+ coords[0] = 1.0;
+ coords[1] = -1.0;
+ coords[2] = 0.0;
+ break;
+ case 18:
+ coords[0] = 1.0;
+ coords[1] = 1.0;
+ coords[2] = 0.0;
+ break;
+ case 17:
+ coords[0] = -1.0;
+ coords[1] = 1.0;
+ coords[2] = 0.0;
+ break;
+ case 15:
+ coords[0] = 0.0;
+ coords[1] = -1.0;
+ coords[2] = 1.0;
+ break;
+ case 14:
+ coords[0] = 1.0;
+ coords[1] = 0.0;
+ coords[2] = 1.0;
+ break;
+ case 13:
+ coords[0] = 0.0;
+ coords[1] = 1.0;
+ coords[2] = 1.0;
+ break;
+ case 12:
+ coords[0] = -1.0;
+ coords[1] = 0.0;
+ coords[2] = 1.0;
+ break;
+ LOCAL_COORD_MACRO_END;
+
+ SHAPE_FUN_MACRO_BEGIN;
+
+ funValue[0] = 0.125*(1.0 - gc[0])*(1.0 - gc[1])*(1.0 - gc[2])*
+ (-2.0 - gc[0] - gc[1] - gc[2]);
+ funValue[3] = 0.125*(1.0 + gc[0])*(1.0 - gc[1])*(1.0 - gc[2])*
+ (-2.0 + gc[0] - gc[1] - gc[2]);
+ funValue[2] = 0.125*(1.0 + gc[0])*(1.0 + gc[1])*(1.0 - gc[2])*
+ (-2.0 + gc[0] + gc[1] - gc[2]);
+ funValue[1] = 0.125*(1.0 - gc[0])*(1.0 + gc[1])*(1.0 - gc[2])*
+ (-2.0 - gc[0] + gc[1] - gc[2]);
+ funValue[4] = 0.125*(1.0 - gc[0])*(1.0 - gc[1])*(1.0 + gc[2])*
+ (-2.0 - gc[0] - gc[1] + gc[2]);
+ funValue[7] = 0.125*(1.0 + gc[0])*(1.0 - gc[1])*(1.0 + gc[2])*
+ (-2.0 + gc[0] - gc[1] + gc[2]);
+ funValue[6] = 0.125*(1.0 + gc[0])*(1.0 + gc[1])*(1.0 + gc[2])*
+ (-2.0 + gc[0] + gc[1] + gc[2]);
+ funValue[5] = 0.125*(1.0 - gc[0])*(1.0 + gc[1])*(1.0 + gc[2])*
+ (-2.0 - gc[0] + gc[1] + gc[2]);
+
+ funValue[11] = 0.25*(1.0 - gc[0]*gc[0])*(1.0 - gc[1])*(1.0 - gc[2]);
+ funValue[10] = 0.25*(1.0 - gc[1]*gc[1])*(1.0 + gc[0])*(1.0 - gc[2]);
+ funValue[9] = 0.25*(1.0 - gc[0]*gc[0])*(1.0 + gc[1])*(1.0 - gc[2]);
+ funValue[8] = 0.25*(1.0 - gc[1]*gc[1])*(1.0 - gc[0])*(1.0 - gc[2]);
+ funValue[16] = 0.25*(1.0 - gc[2]*gc[2])*(1.0 - gc[0])*(1.0 - gc[1]);
+ funValue[19] = 0.25*(1.0 - gc[2]*gc[2])*(1.0 + gc[0])*(1.0 - gc[1]);
+ funValue[18] = 0.25*(1.0 - gc[2]*gc[2])*(1.0 + gc[0])*(1.0 + gc[1]);
+ funValue[17] = 0.25*(1.0 - gc[2]*gc[2])*(1.0 - gc[0])*(1.0 + gc[1]);
+ funValue[15] = 0.25*(1.0 - gc[0]*gc[0])*(1.0 - gc[1])*(1.0 + gc[2]);
+ funValue[14] = 0.25*(1.0 - gc[1]*gc[1])*(1.0 + gc[0])*(1.0 + gc[2]);
+ funValue[13] = 0.25*(1.0 - gc[0]*gc[0])*(1.0 + gc[1])*(1.0 + gc[2]);
+ funValue[12] = 0.25*(1.0 - gc[1]*gc[1])*(1.0 - gc[0])*(1.0 + gc[2]);
+ SHAPE_FUN_MACRO_END;
+}
+
+
+
+////////////////////////////////////////////////////////////////////////////////////////////////
+// GAUSS COORD CLASS //
+////////////////////////////////////////////////////////////////////////////////////////////////
+/*!
+ * Constructor
+ */
+GaussCoords::GaussCoords()
+{
+}
+
+/*!
+ * Destructor
+ */
+GaussCoords::~GaussCoords()
+{
+ GaussInfoVector::iterator it = _my_gauss_info.begin();
+ for( ; it != _my_gauss_info.end(); it++ )
+ {
+ if((*it) != NULL)
+ delete (*it);
+ }
+}
+
+/*!
+ * Add Gauss localization info
+ */
+void GaussCoords::addGaussInfo( NormalizedCellType theGeometry,
+ int coordDim,
+ const double* theGaussCoord,
+ int theNbGauss,
+ const double* theReferenceCoord,
+ int theNbRef) throw (INTERP_KERNEL::Exception)
+{
+ GaussInfoVector::iterator it = _my_gauss_info.begin();
+ for( ; it != _my_gauss_info.end(); it++ )
+ {
+ if( (*it)->getCellType() == theGeometry )
+ {
+ break;
+ }
+ }
+
+ DataVector aGaussCoord;
+ for(int i = 0 ; i < theNbGauss*coordDim; i++ )
+ aGaussCoord.push_back(theGaussCoord[i]);
+
+ DataVector aReferenceCoord;
+ for(int i = 0 ; i < theNbRef*coordDim; i++ )
+ aReferenceCoord.push_back(theReferenceCoord[i]);
+
+
+ GaussInfo* info = new GaussInfo( theGeometry, aGaussCoord, theNbGauss, aReferenceCoord, theNbRef);
+ info->initLocalInfo();
+
+ //If info with cell type doesn't exist add it
+ if( it == _my_gauss_info.end() )
+ {
+ _my_gauss_info.push_back(info);
+
+ // If information exists, update it
+ }
+ else
+ {
+ int index = std::distance(_my_gauss_info.begin(),it);
+ delete (*it);
+ _my_gauss_info[index] = info;
+ }
+}
+
+
+/*!
+ * Calculate gauss points coordinates
+ */
+double* GaussCoords::calculateCoords( NormalizedCellType theGeometry,
+ const double *theNodeCoords,
+ const int theSpaceDim,
+ const int *theIndex) throw (INTERP_KERNEL::Exception)
+{
+ const GaussInfo *info = getInfoGivenCellType(theGeometry);
+ int nbCoords = theSpaceDim * info->getNbGauss();
+ double *aCoords = new double[nbCoords];
+ calculateCoordsAlg(info,theNodeCoords,theSpaceDim,theIndex,aCoords);
+ return aCoords;
+}
+
+
+void GaussCoords::calculateCoords( NormalizedCellType theGeometry, const double *theNodeCoords, const int theSpaceDim, const int *theIndex, double *result) throw(INTERP_KERNEL::Exception)
+{
+ const GaussInfo *info = getInfoGivenCellType(theGeometry);
+ calculateCoordsAlg(info,theNodeCoords,theSpaceDim,theIndex,result);
+}
+
+void GaussCoords::calculateCoordsAlg(const GaussInfo *info, const double* theNodeCoords, const int theSpaceDim, const int *theIndex, double *result)
+{
+ int aConn = info->getNbRef();
+
+ int nbCoords = theSpaceDim * info->getNbGauss();
+ std::fill(result,result+nbCoords,0.);
+
+ for( int gaussId = 0; gaussId < info->getNbGauss(); gaussId++ )
+ {
+ double *coord=result+gaussId*theSpaceDim;
+ const double *function=info->getFunctionValues(gaussId);
+ for ( int connId = 0; connId < aConn ; connId++ )
+ {
+ const double* nodeCoord = theNodeCoords + (theIndex[connId]*theSpaceDim);
+ for( int dimId = 0; dimId < theSpaceDim; dimId++ )
+ coord[dimId] += nodeCoord[dimId]*function[connId];
+ }
+ }
+}
+
+const GaussInfo *GaussCoords::getInfoGivenCellType(NormalizedCellType cellType)
+{
+ GaussInfoVector::const_iterator it = _my_gauss_info.begin();
+ //Try to find gauss localization info
+ for( ; it != _my_gauss_info.end() ; it++ )
+ if( (*it)->getCellType()==cellType)
+ return (*it);
+ throw INTERP_KERNEL::Exception("Can't find gauss localization information !");
+}
--- /dev/null
+// Copyright (C) 2007-2010 CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#ifndef __INTERPKERNELGAUSS_HXX__
+#define __INTERPKERNELGAUSS_HXX__
+
+#include "NormalizedUnstructuredMesh.hxx"
+#include "InterpKernelException.hxx"
+
+#include <vector>
+
+namespace INTERP_KERNEL
+{
+ typedef std::vector<double> DataVector;
+ typedef std::vector<int> IndexVector;
+
+ //Class to store Gauss Points information
+ class GaussInfo
+ {
+ public:
+ GaussInfo( NormalizedCellType theGeometry,
+ const DataVector& theGaussCoord,
+ int theNbGauss,
+ const DataVector& theReferenceCoord,
+ int theNbRef
+ );
+ ~GaussInfo();
+
+ NormalizedCellType getCellType() const;
+
+ int getGaussCoordDim() const;
+ int getReferenceCoordDim() const;
+
+ int getNbGauss() const;
+ int getNbRef() const;
+
+ const double* getFunctionValues( const int theGaussId ) const;
+
+ void initLocalInfo() throw (INTERP_KERNEL::Exception);
+
+ protected:
+
+ bool isSatisfy();
+
+ //1D
+ void seg2Init();
+ void seg3Init();
+
+ //2D
+ void tria3aInit();
+ void tria3bInit();
+ void tria6aInit();
+ void tria6bInit();
+
+ void quad4aInit();
+ void quad4bInit();
+ void quad8aInit();
+ void quad8bInit();
+
+ //3D
+ void tetra4aInit();
+ void tetra4bInit();
+ void tetra10aInit();
+ void tetra10bInit();
+
+ void pyra5aInit();
+ void pyra5bInit();
+ void pyra13aInit();
+ void pyra13bInit();
+
+ void penta6aInit();
+ void penta6bInit();
+ void penta15aInit();
+ void penta15bInit();
+
+ void hexa8aInit();
+ void hexa8bInit();
+ void hexa20aInit();
+ void hexa20bInit();
+
+
+ private:
+ //INFORMATION from MEDMEM
+ NormalizedCellType _my_geometry; //Cell type
+
+ int _my_nb_gauss; //Nb of the gauss points for element
+ DataVector _my_gauss_coord; //Gauss coordinates
+
+ int _my_nb_ref; //Nb of the nodes for element:
+ //NORM_SEG2 - 2
+ //NORM_SEG3 - 3
+ //NORM_TRI3 - 3
+ //.............
+
+ DataVector _my_reference_coord; //Reference coordinates
+
+ //LOCAL INFORMATION
+ DataVector _my_local_reference_coord; //Vector to store reference coordinates
+ int _my_local_ref_dim; //Dimension of the local reference coordinates:
+ // (x) - 1D case
+ // (x, y) - 2D case
+ // (x, y, z) - 3D case
+ int _my_local_nb_ref; //Nb of the local reference coordinates
+
+ DataVector _my_function_value; //Shape Function values
+ };
+
+
+ //Class for calculation of the coordinates of the gauss points
+ class GaussCoords
+ {
+ public:
+
+ GaussCoords();
+ ~GaussCoords();
+
+ void addGaussInfo( NormalizedCellType theGeometry,
+ int coordDim,
+ const double* theGaussCoord,
+ int theNbGauss,
+ const double* theReferenceCoord,
+ int theNbRef) throw (INTERP_KERNEL::Exception);
+
+ double* calculateCoords( NormalizedCellType theGeometry,
+ const double* theNodeCoords,
+ const int theSpaceDim,
+ const int* theIndex) throw(INTERP_KERNEL::Exception);
+
+ void calculateCoords( NormalizedCellType theGeometry,
+ const double* theNodeCoords,
+ const int theSpaceDim,
+ const int* theIndex,
+ double *result) throw(INTERP_KERNEL::Exception);
+ private:
+ const GaussInfo *getInfoGivenCellType(NormalizedCellType cellType);
+ void calculateCoordsAlg(const GaussInfo *info, const double* theNodeCoords, const int theSpaceDim, const int *theIndex,
+ double *result);
+ private:
+ typedef std::vector<GaussInfo*> GaussInfoVector;
+ GaussInfoVector _my_gauss_info;
+ };
+}
+#endif //INTERPKERNELGAUSS
--- /dev/null
+# Copyright (C) 2007-2010 CEA/DEN, EDF R&D
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+#
+
+# File : Makefile.am
+# Author : Vincent BERGEAUD (CEA/DEN/DANS/DM2S/SFME/LGLS)
+# Module : MED
+#
+include $(top_srcdir)/adm_local/unix/make_common_starter.am
+
+noinst_LTLIBRARIES = libinterpkernelgauss.la
+
+salomeinclude_HEADERS = \
+InterpKernelGaussCoords.hxx
+
+# Libraries targets
+dist_libinterpkernelgauss_la_SOURCES = \
+InterpKernelGaussCoords.cxx
+
+libinterpkernelgauss_la_CPPFLAGS=-I$(srcdir)/../Bases -I$(srcdir)/..
+
+AM_CPPFLAGS += $(libinterpkernelgauss_la_CPPFLAGS)
\ No newline at end of file
MergePoints commonNode;
for(int i=0;i<nbOfV1;i++)
{
- std::vector<double>::const_iterator iter=find_if(distrib2.begin()+1,distrib2.end(),bind2nd(std::greater_equal<double>(),distrib1[i]));
+ std::vector<double>::const_iterator iter=find_if(distrib2.begin()+1,distrib2.end(),bind2nd(std::greater_equal<double>(),distrib1[i]));
if(iter!=distrib2.end())
{
for(int j=(iter-1)-distrib2.begin();j<nbOfV2;j++)
bool isIn(double characterVal) const { return true; }
void dynCastFunction(const EdgeLin * &seg,
const EdgeArcCircle * &arcSeg) const { seg=this; }
- void dumpInXfigFile(std::ostream& stream) const { }
private:
~EdgeInfLin() { }
};
{
case 806:
return tryToUnPolyHex8(conn,nbOfFaces,lgth,retConn,retLgth);
+ case 1208:
+ return tryToUnPolyHexp12(conn,nbOfFaces,lgth,retConn,retLgth);
case 605:
return tryToUnPolyPenta6(conn,nbOfFaces,lgth,retConn,retLgth);
case 505:
return INTERP_KERNEL::NORM_POLYHED;
}
+INTERP_KERNEL::NormalizedCellType CellSimplify::tryToUnPolyHexp12(const int *conn, int nbOfFaces, int lgth, int *retConn, int& retLgth)
+{
+ int nbOfHexagon=std::count(conn+lgth,conn+lgth+nbOfFaces,(int)INTERP_KERNEL::NORM_POLYGON);
+ int nbOfQuad=std::count(conn+lgth,conn+lgth+nbOfFaces,(int)INTERP_KERNEL::NORM_QUAD4);
+ if(nbOfQuad==6 && nbOfHexagon==2)
+ {
+ const int *hexag0=std::find(conn+lgth,conn+lgth+nbOfFaces,(int)INTERP_KERNEL::NORM_POLYGON);
+ int hexg0Id=std::distance(conn+lgth,hexag0);
+ const int *hexag1=std::find(hexag0+1,conn+lgth+nbOfFaces,(int)INTERP_KERNEL::NORM_POLYGON);
+ int hexg1Id=std::distance(conn+lgth,hexag1);
+ const int *connHexag0=conn+5*hexg0Id;
+ int lgthH0=std::distance(connHexag0,std::find(connHexag0,conn+lgth,-1));
+ if(lgthH0==6)
+ {
+ const int *connHexag1=conn+5*hexg0Id+7+(hexg1Id-hexg0Id-1)*5;
+ int lgthH1=std::distance(connHexag1,std::find(connHexag1,conn+lgth,-1));
+ if(lgthH1==6)
+ {
+ std::vector<int> tmp;
+ std::set<int> conn1(connHexag0,connHexag0+6);
+ std::set<int> conn2(connHexag1,connHexag1+6);
+ std::set_intersection(conn1.begin(),conn1.end(),conn2.begin(),conn2.end(),std::back_insert_iterator< std::vector<int> >(tmp));
+ if(tmp.empty())
+ {
+ int tmp2[6];
+ if(tryToArrangeOppositeFace(conn,lgth,6,connHexag0,connHexag1,8,tmp2))
+ {
+ std::copy(connHexag0,connHexag0+6,retConn);
+ std::copy(tmp2,tmp2+6,retConn+6);
+ retLgth=12;
+ return INTERP_KERNEL::NORM_HEXGP12;
+ }
+ }
+ }
+ }
+ }
+ retLgth=lgth;
+ std::copy(conn,conn+lgth,retConn);
+ return INTERP_KERNEL::NORM_POLYHED;
+}
+
/*!
* Cell with 'conn' connectivity has been detected as a good candidate. Full check of this. If yes NORM_PENTA6 is returned.
* If fails a POLYHED is returned.
static INTERP_KERNEL::NormalizedCellType tryToUnPoly2D(const int *conn, int lgth, int *retConn, int& retLgth);
static INTERP_KERNEL::NormalizedCellType tryToUnPoly3D(const int *conn, int nbOfFaces, int lgth, int *retConn, int& retLgth);
static INTERP_KERNEL::NormalizedCellType tryToUnPolyHex8(const int *conn, int nbOfFaces, int lgth, int *retConn, int& retLgth);
+ static INTERP_KERNEL::NormalizedCellType tryToUnPolyHexp12(const int *conn, int nbOfFaces, int lgth, int *retConn, int& retLgth);
static INTERP_KERNEL::NormalizedCellType tryToUnPolyPenta6(const int *conn, int nbOfFaces, int lgth, int *retConn, int& retLgth);
static INTERP_KERNEL::NormalizedCellType tryToUnPolyPyra5(const int *conn, int nbOfFaces, int lgth, int *retConn, int& retLgth);
static INTERP_KERNEL::NormalizedCellType tryToUnPolyTetra4(const int *conn, int nbOfFaces, int lgth, int *retConn, int& retLgth);
int _val;
};
- class Row : public std::vector< typename std::pair<int,T> >
+ class Row : public std::vector< std::pair<int,T> >
{
public:
- Row():std::vector< typename std::pair<int,T> >(){};
+ Row():std::vector< std::pair<int,T> >(){};
Row (const Row& row)
{
this->resize(row.size());
}
typename std::vector< std::pair<int,T> >::const_iterator find(int elem) const
{
- return std::find_if(std::vector< typename std::pair<int,T> >::begin(),std::vector< typename std::pair<int,T> >::end(),KeyComparator(elem));
+ return std::find_if(std::vector< std::pair<int,T> >::begin(),std::vector< std::pair<int,T> >::end(),KeyComparator(elem));
}
- void erase(int elem) { std::vector< typename std::pair<int,T> >::erase(std::find_if(std::vector< typename std::pair<int,T> >::begin(),std::vector< typename std::pair<int,T> >::end(),KeyComparator(elem))); }
+ void erase(int elem) { std::vector< std::pair<int,T> >::erase(std::find_if(std::vector< std::pair<int,T> >::begin(),std::vector< std::pair<int,T> >::end(),KeyComparator(elem))); }
- void insert(const std::pair<int,T>& myPair) { push_back(myPair); }
+ void insert(const std::pair<int,T>& myPair) { vector<std::pair<int,T> >::push_back(myPair); }
};
private:
--- /dev/null
+// Copyright (C) 2007-2010 CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#include "Interpolation2DCurve.hxx"
+#include "InterpolationCurve.txx"
+
+namespace INTERP_KERNEL
+{
+ Interpolation2DCurve::Interpolation2DCurve()
+ {
+ // to have non-zero default thickness of target element
+ InterpolationOptions::setBoundingBoxAdjustmentAbs( InterpolationOptions::getPrecision() );
+ }
+
+ Interpolation2DCurve::Interpolation2DCurve
+ (const InterpolationOptions& io):InterpolationCurve<Interpolation2DCurve>(io)
+ {
+ // to have non-zero default thickness of target element
+ InterpolationOptions::setBoundingBoxAdjustmentAbs( InterpolationOptions::getPrecision() );
+ }
+
+ /**
+ * \brief Function used to set the options for the intersection calculation
+ * \details The following options can be modified:
+ * -# Precision: Level of precision of the computations.
+ * - Values: positive real number.
+ * - Default: 1.0E-12.
+ * -# Tolerance: Thickness of target element.
+ * - Values: positive real number.
+ * - Default: 1.0E-12.
+ * -# Median line: Position of the median line where both segments will be projected.
+ * - Values: real number between 0.0 and 1.0.
+ * - Default: 0.5
+ */
+ void Interpolation2DCurve::setOptions (double precision,
+ double tolerance,
+ double medianLine)
+ {
+ InterpolationOptions::setPrecision(precision);
+ InterpolationOptions::setBoundingBoxAdjustmentAbs(tolerance);
+ InterpolationOptions::setMedianPlane(medianLine);
+ }
+}
+++ /dev/null
-// Copyright (C) 2007-2010 CEA/DEN, EDF R&D
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-#ifndef __INTERPOLATION2DCURVE_TXX__
-#define __INTERPOLATION2DCURVE_TXX__
-
-#include "Interpolation2DCurve.hxx"
-#include "InterpolationCurve.txx"
-
-namespace INTERP_KERNEL
-{
- Interpolation2DCurve::Interpolation2DCurve()
- {
- // to have non-zero default thickness of target element
- InterpolationOptions::setBoundingBoxAdjustmentAbs( InterpolationOptions::getPrecision() );
- }
-
- Interpolation2DCurve::Interpolation2DCurve
- (const InterpolationOptions& io):InterpolationCurve<Interpolation2DCurve>(io)
- {
- // to have non-zero default thickness of target element
- InterpolationOptions::setBoundingBoxAdjustmentAbs( InterpolationOptions::getPrecision() );
- }
-
- /**
- * \brief Function used to set the options for the intersection calculation
- * \details The following options can be modified:
- * -# Precision: Level of precision of the computations.
- * - Values: positive real number.
- * - Default: 1.0E-12.
- * -# Tolerance: Thickness of target element.
- * - Values: positive real number.
- * - Default: 1.0E-12.
- * -# Median line: Position of the median line where both segments will be projected.
- * - Values: real number between 0.0 and 1.0.
- * - Default: 0.5
- */
- void Interpolation2DCurve::setOptions (double precision,
- double tolerance,
- double medianLine)
- {
- InterpolationOptions::setPrecision(precision);
- InterpolationOptions::setBoundingBoxAdjustmentAbs(tolerance);
- InterpolationOptions::setMedianPlane(medianLine);
- }
-}
-
-#endif
--- /dev/null
+// Copyright (C) 2007-2010 CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#include "Interpolation3D.hxx"
+
+namespace INTERP_KERNEL
+{
+ /**
+ * \defgroup interpolation3D Interpolation3D
+ * \class Interpolation3D
+ * \brief Class used to calculate the volumes of intersection between the elements of two 3D meshes.
+ *
+ */
+ /**
+ * Default constructor
+ *
+ */
+ Interpolation3D::Interpolation3D()
+ {
+ }
+ Interpolation3D::Interpolation3D(const InterpolationOptions& io):Interpolation<Interpolation3D>(io)
+ {
+ }
+}
namespace INTERP_KERNEL
{
- /**
- * \defgroup interpolation3D Interpolation3D
- * \class Interpolation3D
- * \brief Class used to calculate the volumes of intersection between the elements of two 3D meshes.
- *
- */
- /**
- * Default constructor
- *
- */
- Interpolation3D::Interpolation3D()
- {
- }
- Interpolation3D::Interpolation3D(const InterpolationOptions& io):Interpolation<Interpolation3D>(io)
- {
- }
-
/**
* Calculates the matrix of volumes of intersection between the elements of srcMesh and the elements of targetMesh.
* The calculation is done in two steps. First a filtering process reduces the number of pairs of elements for which the
--- /dev/null
+// Copyright (C) 2007-2010 CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#include "Interpolation3DSurf.hxx"
+#include "InterpolationPlanar.txx"
+
+namespace INTERP_KERNEL
+{
+ Interpolation3DSurf::Interpolation3DSurf()
+ {
+ }
+
+ Interpolation3DSurf::Interpolation3DSurf(const InterpolationOptions& io):InterpolationPlanar<Interpolation3DSurf>(io)
+ {
+ }
+
+
+ /**
+ \brief Function used to set the options for the intersection calculation
+ \details The following options can be modified:
+ -# Intersection_type: the type of algorithm to be used in the computation of the cell-cell intersections.
+ - Values: Triangle, Convex.
+ - Default: Triangle.
+ -# MedianPlane: Position of the median plane where both cells will be projected
+ - Values: between 0 and 1.
+ - Default: 0.5.
+ -# DoRotate: rotate the coordinate system such that the target cell is in the Oxy plane.
+ - Values: true (necessarilly if Intersection_type=Triangle), false.
+ - Default: true (as default Intersection_type=Triangle)
+ -# Precision: Level of precision of the computations is precision times the characteristic size of the mesh.
+ - Values: positive real number.
+ - Default: 1.0E-12.
+ -# PrintLevel: Level of verboseness during the computations.
+ - Values: interger between 0 and 3.
+ - Default: 0.
+ */
+ void Interpolation3DSurf::setOptions(double precision, int printLevel, double medianPlane,
+ IntersectionType intersectionType, bool doRotate, int orientation)
+ {
+ InterpolationPlanar<Interpolation3DSurf>::setOptions(precision,printLevel,intersectionType, orientation);
+ InterpolationPlanar<Interpolation3DSurf>::setDoRotate(doRotate);
+ InterpolationPlanar<Interpolation3DSurf>::setMedianPlane(medianPlane);
+ }
+}
+++ /dev/null
-// Copyright (C) 2007-2010 CEA/DEN, EDF R&D
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-#ifndef __INTERPOLATION3DSURF_TXX__
-#define __INTERPOLATION3DSURF_TXX__
-
-#include "Interpolation3DSurf.hxx"
-#include "InterpolationPlanar.txx"
-
-namespace INTERP_KERNEL
-{
- Interpolation3DSurf::Interpolation3DSurf()
- {
- }
-
- Interpolation3DSurf::Interpolation3DSurf(const InterpolationOptions& io):InterpolationPlanar<Interpolation3DSurf>(io)
- {
- }
-
-
- /**
- \brief Function used to set the options for the intersection calculation
- \details The following options can be modified:
- -# Intersection_type: the type of algorithm to be used in the computation of the cell-cell intersections.
- - Values: Triangle, Convex.
- - Default: Triangle.
- -# MedianPlane: Position of the median plane where both cells will be projected
- - Values: between 0 and 1.
- - Default: 0.5.
- -# DoRotate: rotate the coordinate system such that the target cell is in the Oxy plane.
- - Values: true (necessarilly if Intersection_type=Triangle), false.
- - Default: true (as default Intersection_type=Triangle)
- -# Precision: Level of precision of the computations is precision times the characteristic size of the mesh.
- - Values: positive real number.
- - Default: 1.0E-12.
- -# PrintLevel: Level of verboseness during the computations.
- - Values: interger between 0 and 3.
- - Default: 0.
- */
- void Interpolation3DSurf::setOptions(double precision, int printLevel, double medianPlane,
- IntersectionType intersectionType, bool doRotate, int orientation)
- {
- InterpolationPlanar<Interpolation3DSurf>::setOptions(precision,printLevel,intersectionType, orientation);
- InterpolationPlanar<Interpolation3DSurf>::setDoRotate(doRotate);
- InterpolationPlanar<Interpolation3DSurf>::setMedianPlane(medianPlane);
- }
-}
-
-#endif
}
/*_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ */
- /* fonction qui calcul le déterminant */
+ /* fonction qui calcul le determinant */
/* de deux vecteur(cf doc CGAL). */
/*_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _*/
- //fonction qui calcul le déterminant des vecteurs: P3P1 et P3P2
+ //fonction qui calcul le determinant des vecteurs: P3P1 et P3P2
//(cf doc CGAL).
inline double mon_determinant(const double* P_1,
}
/*_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ */
- /* calcul les coordonnées du barycentre d'un polygone */
- /* le vecteur en entrée est constitué des coordonnées */
+ /* calcul les coordonnees du barycentre d'un polygone */
+ /* le vecteur en entree est constitue des coordonnees */
/* des sommets du polygone */
/*_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ */
return Bary;
}
+
+ /*!
+ * Given 6 coeffs of a Tria6 returns the corresponding value of a given pos
+ */
+ inline double computeTria6RefBase(const double *coeffs, const double *pos)
+ {
+ return coeffs[0]+coeffs[1]*pos[0]+coeffs[2]*pos[1]+coeffs[3]*pos[0]*pos[0]+coeffs[4]*pos[0]*pos[1]+coeffs[5]*pos[1]*pos[1];
+ }
+
+ /*!
+ * Given xsi,eta in refCoo (length==2) return 6 coeffs in weightedPos.
+ */
+ inline void computeWeightedCoeffsInTria6FromRefBase(const double *refCoo, double *weightedPos)
+ {
+ weightedPos[0]=(1.-refCoo[0]-refCoo[1])*(1.-2*refCoo[0]-2.*refCoo[1]);
+ weightedPos[1]=refCoo[0]*(2.*refCoo[0]-1.);
+ weightedPos[2]=refCoo[1]*(2.*refCoo[1]-1.);
+ weightedPos[3]=4.*refCoo[0]*(1.-refCoo[0]-refCoo[1]);
+ weightedPos[4]=4.*refCoo[0]*refCoo[1];
+ weightedPos[5]=4.*refCoo[1]*(1.-refCoo[0]-refCoo[1]);
+ }
+
+ /*!
+ * Given 10 coeffs of a Tetra10 returns the corresponding value of a given pos
+ */
+ inline double computeTetra10RefBase(const double *coeffs, const double *pos)
+ {
+ return coeffs[0]+coeffs[1]*pos[0]+coeffs[2]*pos[1]+coeffs[3]*pos[2]+
+ coeffs[4]*pos[0]*pos[0]+coeffs[5]*pos[0]*pos[1]+coeffs[6]*pos[0]*pos[2]+
+ coeffs[7]*pos[1]*pos[1]+coeffs[8]*pos[1]*pos[2]+coeffs[9]*pos[2]*pos[2];
+ }
+
+ /*!
+ * Given xsi,eta,z in refCoo (length==3) return 10 coeffs in weightedPos.
+ */
+ inline void computeWeightedCoeffsInTetra10FromRefBase(const double *refCoo, double *weightedPos)
+ {
+ //http://www.cadfamily.com/download/CAE/ABAQUS/The%20Finite%20Element%20Method%20-%20A%20practical%20course%20abaqus.pdf page 217
+ //L1=1-refCoo[0]-refCoo[1]-refCoo[2]
+ //L2=refCoo[0] L3=refCoo[1] L4=refCoo[2]
+ weightedPos[0]=(-2.*(refCoo[0]+refCoo[1]+refCoo[2])+1)*(1-refCoo[0]-refCoo[1]-refCoo[2]);//(2*L1-1)*L1
+ weightedPos[1]=(2.*refCoo[0]-1.)*refCoo[0];//(2*L2-1)*L2
+ weightedPos[2]=(2.*refCoo[1]-1.)*refCoo[1];//(2*L3-1)*L3
+ weightedPos[3]=(2.*refCoo[2]-1.)*refCoo[2];//(2*L4-1)*L4
+ weightedPos[4]=4.*(1-refCoo[0]-refCoo[1]-refCoo[2])*refCoo[0];//4*L1*L2
+ weightedPos[5]=4.*refCoo[0]*refCoo[1];//4*L2*L3
+ weightedPos[6]=4.*(1-refCoo[0]-refCoo[1]-refCoo[2])*refCoo[1];//4*L1*L3
+ weightedPos[7]=4.*(1-refCoo[0]-refCoo[1]-refCoo[2])*refCoo[2];//4*L1*L4
+ weightedPos[8]=4.*refCoo[0]*refCoo[2];//4*L2*L4
+ weightedPos[9]=4.*refCoo[1]*refCoo[2];//4*L3*L4
+ }
/*!
* \brief Solve system equation in matrix form using Gaussian elimination algorithm
// make upper triangular matrix (forward elimination)
int iR[nbRow];// = { 0, 1, 2 };
- for ( int i = 0; i < (int) nbRow; ++i ) iR[i] = i;
-
+ for ( int i = 0; i < (int) nbRow; ++i )
+ iR[i] = i;
for ( int i = 0; i < (int)(nbRow-1); ++i ) // nullify nbRow-1 rows
{
// swap rows to have max value of i-th column in i-th row
double max = std::fabs( M[ iR[i] ][i] );
- for ( int r = i+1; r < (int)nbRow; ++r ) {
- double m = std::fabs( M[ iR[r] ][i] );
- if ( m > max ) {
- max = m;
- std::swap( iR[r], iR[i] );
+ for ( int r = i+1; r < (int)nbRow; ++r )
+ {
+ double m = std::fabs( M[ iR[r] ][i] );
+ if ( m > max )
+ {
+ max = m;
+ std::swap( iR[r], iR[i] );
+ }
+ }
+ if ( max < std::numeric_limits<double>::min() )
+ {
+ //sol[0]=1; sol[1]=sol[2]=sol[3]=0;
+ return false; // no solution
}
- }
- if ( max < std::numeric_limits<double>::min() ) {
- //sol[0]=1; sol[1]=sol[2]=sol[3]=0;
- return false; // no solution
- }
// make 0 below M[i][i] (actually we do not modify i-th column)
double* tUpRow = M[ iR[i] ];
- for ( int r = i+1; r < (int)nbRow; ++r ) {
- double* mRow = M[ iR[r] ];
- double coef = mRow[ i ] / tUpRow[ i ];
- for ( int c = i+1; c < nbCol; ++c )
- mRow[ c ] -= tUpRow[ c ] * coef;
- }
+ for ( int r = i+1; r < (int)nbRow; ++r )
+ {
+ double* mRow = M[ iR[r] ];
+ double coef = mRow[ i ] / tUpRow[ i ];
+ for ( int c = i+1; c < nbCol; ++c )
+ mRow[ c ] -= tUpRow[ c ] * coef;
+ }
}
double* mRow = M[ iR[nbRow-1] ];
- if ( std::fabs( mRow[ nbRow-1 ] ) < std::numeric_limits<double>::min() ) {
- //sol[0]=1; sol[1]=sol[2]=sol[3]=0;
- return false; // no solution
- }
+ if ( std::fabs( mRow[ nbRow-1 ] ) < std::numeric_limits<double>::min() )
+ {
+ //sol[0]=1; sol[1]=sol[2]=sol[3]=0;
+ return false; // no solution
+ }
mRow[ nbRow ] /= mRow[ nbRow-1 ];
// calculate solution (back substitution)
return true;
}
+
+ /*!
+ * \brief Solve system equation in matrix form using Gaussian elimination algorithm
+ * \param M - N x N+NB_OF_VARS matrix
+ * \param sol - vector of N solutions
+ * \retval bool - true if succeeded
+ */
+ template<unsigned SZ, unsigned NB_OF_RES>
+ bool solveSystemOfEquations2(const double *matrix, double *solutions, double eps)
+ {
+ unsigned k,j;
+ int nr,n,m,nx,np;
+ double s,g;
+ int mb;
+ //
+ double B[SZ*(SZ+NB_OF_RES)];
+ std::copy(matrix,matrix+SZ*(SZ+NB_OF_RES),B);
+ //
+ nr=SZ+NB_OF_RES;
+ nx=nr*SZ;
+ for(k=0;k<SZ;k++)
+ {
+ np=nr*k+k;
+ if(fabs(B[np])<eps)
+ {
+ n=k;
+ do
+ {
+ n++;
+ if(fabs(B[nr*k+n])>eps)
+ {/* Rows permutation */
+ for(m=0;m<nr;m++)
+ std::swap(B[nr*k+m],B[nr*n+m]);
+ }
+ }
+ while (n<(int)SZ);
+ }
+ s=B[np];//s is the Pivot
+ std::transform(B+k*nr,B+(k+1)*nr,B+k*nr,std::bind2nd(std::divides<double>(),s));
+ for(j=0;j<SZ;j++)
+ {
+ if(j!=k)
+ {
+ g=B[j*nr+k];
+ for(mb=k;mb<nr;mb++)
+ B[j*nr+mb]-=B[k*nr+mb]*g;
+ }
+ }
+ }
+ for(j=0;j<NB_OF_RES;j++)
+ for(k=0;k<SZ;k++)
+ solutions[j*SZ+k]=B[nr*k+SZ+j];
+ //
+ return true;
+ }
/*_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _*/
/* Calculate barycentric coordinates of a 2D point p */
bc[2] = 1. - bc[0] - bc[1];
}
- /*_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _*/
- /* Calculate barycentric coordinates of a point p */
- /* with respect to triangle or tetra verices. */
- /*_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _*/
-
- inline void barycentric_coords(const std::vector<const double*>& n, const double* p, double* bc)
+ /*!
+ * Calculate barycentric coordinates of a point p with respect to triangle or tetra verices.
+ * This method makes 2 assumptions :
+ * - this is a simplex
+ * - spacedim == meshdim. For TRI3 and TRI6 spaceDim is expected to be equal to 2 and for TETRA4 spaceDim is expected to be equal to 3.
+ * If not the case (3D surf for example) a previous projection should be done before.
+ */
+ inline void barycentric_coords(const std::vector<const double*>& n, const double *p, double *bc)
{
enum { _X, _Y, _Z };
- if ( n.size() == 3 ) // TRIA3
+ switch(n.size())
{
- // matrix 2x2
- double
- T11 = n[0][_X]-n[2][_X], T12 = n[1][_X]-n[2][_X],
- T21 = n[0][_Y]-n[2][_Y], T22 = n[1][_Y]-n[2][_Y];
- // matrix determinant
- double Tdet = T11*T22 - T12*T21;
- if ( std::fabs( Tdet ) < std::numeric_limits<double>::min() ) {
- bc[0]=1; bc[1]=bc[2]=0; // no solution
- return;
+ case 3:
+ { // TRIA3
+ // matrix 2x2
+ double
+ T11 = n[0][_X]-n[2][_X], T12 = n[1][_X]-n[2][_X],
+ T21 = n[0][_Y]-n[2][_Y], T22 = n[1][_Y]-n[2][_Y];
+ // matrix determinant
+ double Tdet = T11*T22 - T12*T21;
+ if ( std::fabs( Tdet ) < std::numeric_limits<double>::min() )
+ {
+ bc[0]=1; bc[1]=bc[2]=0; // no solution
+ return;
+ }
+ // matrix inverse
+ double t11 = T22, t12 = -T12, t21 = -T21, t22 = T11;
+ // vector
+ double r11 = p[_X]-n[2][_X], r12 = p[_Y]-n[2][_Y];
+ // barycentric coordinates: mutiply matrix by vector
+ bc[0] = (t11 * r11 + t12 * r12)/Tdet;
+ bc[1] = (t21 * r11 + t22 * r12)/Tdet;
+ bc[2] = 1. - bc[0] - bc[1];
+ break;
}
- // matrix inverse
- double t11 = T22, t12 = -T12, t21 = -T21, t22 = T11;
- // vector
- double r11 = p[_X]-n[2][_X], r12 = p[_Y]-n[2][_Y];
- // barycentric coordinates: mutiply matrix by vector
- bc[0] = (t11 * r11 + t12 * r12)/Tdet;
- bc[1] = (t21 * r11 + t22 * r12)/Tdet;
- bc[2] = 1. - bc[0] - bc[1];
- }
- else // TETRA4
- {
- // Find bc by solving system of 3 equations using Gaussian elimination algorithm
- // bc1*( x1 - x4 ) + bc2*( x2 - x4 ) + bc3*( x3 - x4 ) = px - x4
- // bc1*( y1 - y4 ) + bc2*( y2 - y4 ) + bc3*( y3 - y4 ) = px - y4
- // bc1*( z1 - z4 ) + bc2*( z2 - z4 ) + bc3*( z3 - z4 ) = px - z4
-
- double T[3][4]=
- {{ n[0][_X]-n[3][_X], n[1][_X]-n[3][_X], n[2][_X]-n[3][_X], p[_X]-n[3][_X] },
- { n[0][_Y]-n[3][_Y], n[1][_Y]-n[3][_Y], n[2][_Y]-n[3][_Y], p[_Y]-n[3][_Y] },
- { n[0][_Z]-n[3][_Z], n[1][_Z]-n[3][_Z], n[2][_Z]-n[3][_Z], p[_Z]-n[3][_Z] }};
-
- if ( !solveSystemOfEquations<3>( T, bc ))
- bc[0]=1., bc[1] = bc[2] = bc[3] = 0;
- else
- bc[ 3 ] = 1. - bc[0] - bc[1] - bc[2];
+ case 4:
+ { // TETRA4
+ // Find bc by solving system of 3 equations using Gaussian elimination algorithm
+ // bc1*( x1 - x4 ) + bc2*( x2 - x4 ) + bc3*( x3 - x4 ) = px - x4
+ // bc1*( y1 - y4 ) + bc2*( y2 - y4 ) + bc3*( y3 - y4 ) = px - y4
+ // bc1*( z1 - z4 ) + bc2*( z2 - z4 ) + bc3*( z3 - z4 ) = px - z4
+
+ double T[3][4]=
+ {{ n[0][_X]-n[3][_X], n[1][_X]-n[3][_X], n[2][_X]-n[3][_X], p[_X]-n[3][_X] },
+ { n[0][_Y]-n[3][_Y], n[1][_Y]-n[3][_Y], n[2][_Y]-n[3][_Y], p[_Y]-n[3][_Y] },
+ { n[0][_Z]-n[3][_Z], n[1][_Z]-n[3][_Z], n[2][_Z]-n[3][_Z], p[_Z]-n[3][_Z] }};
+
+ if ( !solveSystemOfEquations<3>( T, bc ) )
+ bc[0]=1., bc[1] = bc[2] = bc[3] = 0;
+ else
+ bc[ 3 ] = 1. - bc[0] - bc[1] - bc[2];
+ break;
+ }
+ case 6:
+ {
+ // TRIA6
+ double matrix2[48]={1., 0., 0., 0., 0., 0., 0., 0.,
+ 1., 0., 0., 0., 0., 0., 1., 0.,
+ 1., 0., 0., 0., 0., 0., 0., 1.,
+ 1., 0., 0., 0., 0., 0., 0.5, 0.,
+ 1., 0., 0., 0., 0., 0., 0.5, 0.5,
+ 1., 0., 0., 0., 0., 0., 0.,0.5};
+ for(int i=0;i<6;i++)
+ {
+ matrix2[8*i+1]=n[i][0];
+ matrix2[8*i+2]=n[i][1];
+ matrix2[8*i+3]=n[i][0]*n[i][0];
+ matrix2[8*i+4]=n[i][0]*n[i][1];
+ matrix2[8*i+5]=n[i][1]*n[i][1];
+ }
+ double res[12];
+ solveSystemOfEquations2<6,2>(matrix2,res,std::numeric_limits<double>::min());
+ double refCoo[2];
+ refCoo[0]=computeTria6RefBase(res,p);
+ refCoo[1]=computeTria6RefBase(res+6,p);
+ computeWeightedCoeffsInTria6FromRefBase(refCoo,bc);
+ break;
+ }
+ case 10:
+ {//TETRA10
+ double matrix2[130]={1., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
+ 1., 0., 0., 0., 0., 0., 0., 0., 0., 0., 1., 0., 0.,
+ 1., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 1., 0.,
+ 1., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 1.,
+ 1., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.5, 0., 0.,
+ 1., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.5, 0.5, 0.,
+ 1., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,0.5, 0.,
+ 1., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.5,
+ 1., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.5, 0., 0.5,
+ 1., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.5, 0.5};
+ for(int i=0;i<10;i++)
+ {
+ matrix2[13*i+1]=n[i][0];
+ matrix2[13*i+2]=n[i][1];
+ matrix2[13*i+3]=n[i][2];
+ matrix2[13*i+4]=n[i][0]*n[i][0];
+ matrix2[13*i+5]=n[i][0]*n[i][1];
+ matrix2[13*i+6]=n[i][0]*n[i][2];
+ matrix2[13*i+7]=n[i][1]*n[i][1];
+ matrix2[13*i+8]=n[i][1]*n[i][2];
+ matrix2[13*i+9]=n[i][2]*n[i][2];
+ }
+ double res[30];
+ solveSystemOfEquations2<10,3>(matrix2,res,std::numeric_limits<double>::min());
+ double refCoo[3];
+ refCoo[0]=computeTetra10RefBase(res,p);
+ refCoo[1]=computeTetra10RefBase(res+10,p);
+ refCoo[2]=computeTetra10RefBase(res+20,p);
+ computeWeightedCoeffsInTetra10FromRefBase(refCoo,bc);
+ break;
+ }
+ default:
+ throw INTERP_KERNEL::Exception("INTERP_KERNEL::barycentric_coords : unrecognized simplex !");
}
}
}
/*_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ */
- /*fonction pour vérifier qu'un point n'a pas déja été considérer dans */
+ /*fonction pour verifier qu'un point n'a pas deja ete considerer dans */
/* le vecteur et le rajouter au vecteur sinon. */
/*_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ */
/*_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ */
/* fonction qui rajoute les sommet du triangle P dans le vecteur V */
- /* si ceux-ci sont compris dans le triangle S et ne sont pas déjà dans */
+ /* si ceux-ci sont compris dans le triangle S et ne sont pas deja dans */
/* V. */
/*sommets de P: P_1, P_2, P_3 */
/*sommets de S: P_4, P_5, P_6 */
/*_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _*/
/* calcul de l'intersection de deux segments: segments P1P2 avec P3P4 */
/* . Si l'intersection est non nulle et si celle-ci n'est */
- /* n'est pas déjà contenue dans Vect on la rajoute à Vect */
+ /* n'est pas deja contenue dans Vect on la rajoute a Vect */
/*_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _*/
inline void inters_de_segment(const double * P_1,const double * P_2,
std::vector<double>& Vect,
double dim_caracteristic, double precision)
{
- // calcul du déterminant de P_1P_2 et P_3P_4.
+ // calcul du determinant de P_1P_2 et P_3P_4.
double det=(P_2[0]-P_1[0])*(P_4[1]-P_3[1])-(P_4[0]-P_3[0])*(P_2[1]-P_1[1]);
double absolute_precision = dim_caracteristic*precision;
/*_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _*/
/* calcul l'intersection de deux triangles */
/* P_1, P_2, P_3: sommets du premier triangle */
- /* P_4, P_5, P_6: sommets du deuxième triangle */
+ /* P_4, P_5, P_6: sommets du deuxi�me triangle */
/*_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _*/
inline void intersec_de_triangle(const double* P_1,const double* P_2, const double* P_3,
}
/*_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _*/
- /* fonction pour vérifier qu'un n°de maille n'a pas déja été considérer */
+ /* fonction pour verifier qu'un node maille n'a pas deja ete considerer */
/* dans le vecteur et le rajouter au vecteur sinon. */
/*_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _*/
/*_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ */
- /* fonction pour reconstituer un polygone convexe à partir */
+ /* fonction pour reconstituer un polygone convexe a partir */
/* d'un nuage de point. */
/*_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ */
/*_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _*/
/* calcul l'intersection de deux polygones COPLANAIRES */
- /* en dimension DIM (2 ou 3). Si DIM=3 l'algorithme ne considère*/
- /* que les deux premières coordonnées de chaque point */
+ /* en dimension DIM (2 ou 3). Si DIM=3 l'algorithme ne considere*/
+ /* que les deux premieres coordonnees de chaque point */
/*_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _*/
template<int DIM> inline void intersec_de_polygone(const double * Coords_A, const double * Coords_B,
int nb_NodesA, int nb_NodesB,
#
include $(top_srcdir)/adm_local/unix/make_common_starter.am
-SUBDIRS = Bases Geometric2D ExprEval .
+SUBDIRS = Bases Geometric2D ExprEval GaussPoints .
-DIST_SUBDIRS = Bases Geometric2D ExprEval
+DIST_SUBDIRS = Bases Geometric2D ExprEval GaussPoints
lib_LTLIBRARIES = libinterpkernel.la
Interpolation3D.hxx \
Interpolation3D.txx \
Interpolation3DSurf.hxx \
-Interpolation3DSurf.txx \
InterpolationOptions.hxx \
InterpolationPlanar.hxx \
InterpolationPlanar.txx \
Interpolation1D.hxx \
Interpolation1D.txx \
Interpolation2DCurve.hxx \
-Interpolation2DCurve.txx \
InterpolationCurve.hxx \
InterpolationCurve.txx \
DirectedBoundingBox.hxx
UnitTetraIntersectionBary.cxx \
InterpolationOptions.cxx \
DirectedBoundingBox.cxx \
+ Interpolation2DCurve.cxx \
+ Interpolation3DSurf.cxx \
+ Interpolation3D.cxx \
+ MeshElement.cxx \
InterpKernelMeshQuality.cxx \
InterpKernelCellSimplify.cxx
libinterpkernel_la_LDFLAGS=
# the geom2D library is included in the interpkernel one
-libinterpkernel_la_LIBADD= ./Geometric2D/libInterpGeometric2DAlg.la Bases/libinterpkernelbases.la ExprEval/libinterpkernelexpreval.la
+libinterpkernel_la_LIBADD= ./Geometric2D/libInterpGeometric2DAlg.la Bases/libinterpkernelbases.la ExprEval/libinterpkernelexpreval.la \
+ GaussPoints/libinterpkernelgauss.la
AM_CPPFLAGS += $(libinterpkernel_la_CPPFLAGS)
LDADD= $(libinterpkernel_la_LDFLAGS)
--- /dev/null
+// Copyright (C) 2007-2010 CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#include "MeshElement.hxx"
+
+namespace INTERP_KERNEL
+{
+ /////////////////////////////////////////////////////////////////////
+ /// ElementBBoxOrder /////////////
+ /////////////////////////////////////////////////////////////////////
+ /**
+ * Constructor
+ *
+ * @param coord BoundingBox coordinate (XMIN, XMAX, etc) on which to base the ordering
+ */
+ ElementBBoxOrder::ElementBBoxOrder(BoundingBox::BoxCoord coord)
+ : _coord(coord)
+ {
+ }
+}
+
/////////////////////////////////////////////////////////////////////
/// ElementBBoxOrder /////////////
/////////////////////////////////////////////////////////////////////
- /**
- * Constructor
- *
- * @param coord BoundingBox coordinate (XMIN, XMAX, etc) on which to base the ordering
- */
- ElementBBoxOrder::ElementBBoxOrder(BoundingBox::BoxCoord coord)
- : _coord(coord)
- {
- }
/**
* Comparison operator based on the bounding boxes of the elements
}
else
{
- std::cout << " Maille dégénérée " << "epsilon = " << epsilon << std::endl;
+ std::cout << " Degenerated cell " << "epsilon = " << epsilon << std::endl;
std::cout << " i_A1= " << i_A1 << " i_A2= " << i_A2 << std::endl;
std::cout << " distance2<SPACEDIM>(Coords_A,&Coords_A[i_A1])= " << distance2<SPACEDIM>(Coords_A,&Coords_A[i_A1]) << std::endl;
std::cout << "abs(normal_A) = " << fabs(normal_A[0]) << " ; " <<fabs( normal_A[1]) << " ; " << fabs(normal_A[2]) << std::endl;
else
{
double littleTargetCell[9];
- std::copy(baryT,baryT+3,littleTargetCell);
+ std::copy(baryT,baryT+SPACEDIM,littleTargetCell);
std::copy(CoordsT.begin(),CoordsT.begin()+3,littleTargetCell+3);
std::copy(CoordsT.begin()+3,CoordsT.begin()+6,littleTargetCell+6);
PlanarIntersector<MyMeshType,MyMatrix>::projectionThis(&CoordsS[0],littleTargetCell,3,3);
#include "BBTree.txx"
#include <list>
+#include <set>
#include <limits>
namespace INTERP_KERNEL
{
return isElementContainsPointAlg3D(ptToTest,conn_elem,conn_elem_sz,coords,cmType,eps);
}
+ throw INTERP_KERNEL::Exception("Invalid spacedim detected ! Managed spaceDim are 2 and 3 !");
}
bool elementContainsPoint(typename MyMeshType::MyConnType i, const double* x, double eps)
return (min_sign!=-1 || max_sign!=1);
}
};
+
+ template<class MyMeshType>
+ class PointLocatorInSimplex : public PointLocatorAlgos<MyMeshType>
+ {
+ const MyMeshType& _mesh;
+ public:
+ PointLocatorInSimplex(const MyMeshType& mesh)
+ :PointLocatorAlgos<MyMeshType>(mesh),_mesh(mesh)
+ {
+ }
+
+ //================================================================================
+ /*!
+ * \brief Returns nodes composing the simplex the point x is in
+ */
+ //================================================================================
+
+ virtual std::list<int> locates(const double* x, double eps)
+ {
+ typedef typename MyMeshType::MyConnType ConnType;
+ const NumberingPolicy numPol=MyMeshType::My_numPol;
+
+ std::list<int> simplexNodes;
+ std::list<int> candidates = PointLocatorAlgos<MyMeshType>::locates(x,eps);
+ std::list<int>::iterator eIt = candidates.begin();
+ for ( ; eIt != candidates.end(); ++eIt )
+ {
+ const int i = OTT<ConnType,numPol>::ind2C( *eIt );
+ const double* coords= _mesh.getCoordinatesPtr();
+ const ConnType* conn=_mesh.getConnectivityPtr();
+ const ConnType* conn_index= _mesh.getConnectivityIndexPtr();
+ const ConnType* conn_elem=conn+OTT<ConnType,numPol>::ind2C(conn_index[i]);
+ int conn_elem_sz=conn_index[i+1]-conn_index[i];
+ NormalizedCellType type=_mesh.getTypeOfElement(OTT<ConnType,numPol>::indFC(i));
+ CellModel cell = CellModel::getCellModel(type);
+
+ if ( cell.isQuadratic() )
+ throw Exception("P2 not implemented yet");
+
+ if ( cell.isSimplex())
+ {
+ for ( int n = 0; n < conn_elem_sz; ++n )
+ simplexNodes.push_back( conn_elem[ n ]);
+ }
+ else
+ {
+ NormalizedCellType simlexType = cell.getDimension()==3 ? NORM_TETRA4 : NORM_TRI3;
+ std::vector<int> sonNodes;
+ NormalizedCellType sonType;
+ const unsigned nbSons = cell.getNumberOfSons2( conn_elem, conn_elem_sz );
+ for ( unsigned s = 0; s < nbSons; ++s )
+ {
+ sonNodes.resize( cell.getNumberOfNodesConstituentTheSon2( s, conn_elem, conn_elem_sz ));
+ cell.fillSonCellNodalConnectivity2( s, conn_elem, conn_elem_sz, &sonNodes[0], sonType );
+ std::set<int> sonNodesSet( sonNodes.begin(), sonNodes.end() );
+
+ std::set< std::set< ConnType > > checkedSonSimplex;
+ for ( unsigned sn = 0; sn < sonNodes.size(); ++sn )
+ {
+ std::vector< ConnType > simplexConn( cell.getDimension() + 1 );
+ unsigned n;
+ for ( n = 0; n < cell.getDimension()-1; ++n )
+ simplexConn[n] = sonNodes[ (sn+n) % sonNodes.size() ];
+
+ for ( unsigned n2 = 0; n2 < sonNodes.size()-cell.getDimension()+1; ++n2 )
+ {
+ simplexConn[n] = sonNodes[ (sn+n+n2) % sonNodes.size() ];
+ std::set< ConnType > sonSimplex( simplexConn.begin(), --simplexConn.end());
+ if ( checkedSonSimplex.insert( sonSimplex ).second )
+ {
+ for ( unsigned cn = 0; cn < conn_elem_sz; ++cn )
+ if ( !sonNodesSet.count( conn_elem[cn] ))
+ {
+ simplexConn.back() = conn_elem[cn];
+ if ( isElementContainsPoint( x, simlexType, coords,
+ &simplexConn[0], simplexConn.size(), eps ))
+ {
+ simplexNodes.insert( simplexNodes.end(),
+ simplexConn.begin(), simplexConn.end());
+ return simplexNodes;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ return simplexNodes;
+ }
+
+ };
}
#endif
if(fabs(det) > _epsilon)
{
inv_det = 1/det;
- t1=(AC[1]*DC[2]-AC[2]*DC[1])*inv_det;
- t2=(AB[1]*AC[2]-AB[2]*AC[1])*inv_det;
+ t1=(AC[1]*DC[DIM-1]-AC[DIM-1]*DC[1])*inv_det;
+ t2=(AB[1]*AC[DIM-1]-AB[DIM-1]*AC[1])*inv_det;
}
else //beware AB and CD may belong to a plane y = constant
{
- det = AB[0]*DC[2]-AB[2]*DC[0];
+ det = AB[0]*DC[DIM-1]-AB[DIM-1]*DC[0];
if(fabs(det) > _epsilon)
{
inv_det = 1/det;
- t1=(AC[0]*DC[2]-AC[2]*DC[0])*inv_det;
- t2=(AB[0]*AC[2]-AB[2]*AC[0])*inv_det;
+ t1=(AC[0]*DC[DIM-1]-AC[DIM-1]*DC[0])*inv_det;
+ t2=(AB[0]*AC[DIM-1]-AB[DIM-1]*AC[0])*inv_det;
}
else
{
static const NumberingPolicy numPol=MyMeshType::My_numPol;
public:
- PolyhedronIntersectorP0P0(const MyMeshType& targetMesh, const MyMeshType& srcMesh, SplittingPolicy policy = GENERAL_24);
+ PolyhedronIntersectorP0P0(const MyMeshType& targetMesh, const MyMeshType& srcMesh, SplittingPolicy policy = PLANAR_FACE_5);
~PolyhedronIntersectorP0P0();
static const NumberingPolicy numPol=MyMeshType::My_numPol;
public:
- PolyhedronIntersectorP0P1(const MyMeshType& targetMesh, const MyMeshType& srcMesh, SplittingPolicy policy = GENERAL_24);
+ PolyhedronIntersectorP0P1(const MyMeshType& targetMesh, const MyMeshType& srcMesh, SplittingPolicy policy = PLANAR_FACE_5);
~PolyhedronIntersectorP0P1();
static const NumberingPolicy numPol=MyMeshType::My_numPol;
public:
- PolyhedronIntersectorP1P0(const MyMeshType& targetMesh, const MyMeshType& srcMesh, SplittingPolicy policy = GENERAL_24);
+ PolyhedronIntersectorP1P0(const MyMeshType& targetMesh, const MyMeshType& srcMesh, SplittingPolicy policy = PLANAR_FACE_5);
~PolyhedronIntersectorP1P0();
static const NumberingPolicy numPol=MyMeshType::My_numPol;
public:
- PolyhedronIntersectorP1P0Bary(const MyMeshType& targetMesh, const MyMeshType& srcMesh, SplittingPolicy policy = GENERAL_24);
+ PolyhedronIntersectorP1P0Bary(const MyMeshType& targetMesh, const MyMeshType& srcMesh, SplittingPolicy policy = PLANAR_FACE_5);
~PolyhedronIntersectorP1P0Bary();
static const NumberingPolicy numPol=MyMeshType::My_numPol;
public:
- PolyhedronIntersectorP1P1(const MyMeshType& targetMesh, const MyMeshType& srcMesh, SplittingPolicy policy = GENERAL_24);
+ PolyhedronIntersectorP1P1(const MyMeshType& targetMesh, const MyMeshType& srcMesh, SplittingPolicy policy = PLANAR_FACE_5);
~PolyhedronIntersectorP1P1();
nodes[1] = getCoordsOfSubNode2(faceCenterNode,conn[1]);
for(int j = 0; j < 4; ++j)
{
- const int row = 4*(faceCenterNode - 9) + j;
+ const int row = 4*(faceCenterNode - 8) + j;
nodes[2] = getCoordsOfSubNode2(TETRA_EDGES[2*row],conn[2]);
nodes[3] = getCoordsOfSubNode2(TETRA_EDGES[2*row + 1],conn[3]);
1,2,5,6,// sub-node 12 (face)
4,5,6,7,// sub-node 13 (face)
2,3,6,7,// sub-node 14 (face)
- 9,10,11,12// sub-node 15 (cell)
+ 8,9,10,11// sub-node 15 (cell)
};
for(int i = 0; i < 7; ++i)
coords+SPACEDIM*N8);
}
break;
-
+ case INTERP_KERNEL::NORM_HEXGP12:
+ {
+ const int connecHexa12[43]={
+ OTT<ConnType,numPol>::coo2C(connec[0]),OTT<ConnType,numPol>::coo2C(connec[1]),OTT<ConnType,numPol>::coo2C(connec[2]),OTT<ConnType,numPol>::coo2C(connec[3]),OTT<ConnType,numPol>::coo2C(connec[4]),OTT<ConnType,numPol>::coo2C(connec[5]),-1,
+ OTT<ConnType,numPol>::coo2C(connec[6]),OTT<ConnType,numPol>::coo2C(connec[11]),OTT<ConnType,numPol>::coo2C(connec[10]),OTT<ConnType,numPol>::coo2C(connec[9]),OTT<ConnType,numPol>::coo2C(connec[8]),OTT<ConnType,numPol>::coo2C(connec[7]),-1,
+ OTT<ConnType,numPol>::coo2C(connec[0]),OTT<ConnType,numPol>::coo2C(connec[6]),OTT<ConnType,numPol>::coo2C(connec[7]),OTT<ConnType,numPol>::coo2C(connec[1]),-1,
+ OTT<ConnType,numPol>::coo2C(connec[1]),OTT<ConnType,numPol>::coo2C(connec[7]),OTT<ConnType,numPol>::coo2C(connec[8]),OTT<ConnType,numPol>::coo2C(connec[2]),-1,
+ OTT<ConnType,numPol>::coo2C(connec[2]),OTT<ConnType,numPol>::coo2C(connec[8]),OTT<ConnType,numPol>::coo2C(connec[9]),OTT<ConnType,numPol>::coo2C(connec[3]),-1,
+ OTT<ConnType,numPol>::coo2C(connec[3]),OTT<ConnType,numPol>::coo2C(connec[9]),OTT<ConnType,numPol>::coo2C(connec[10]),OTT<ConnType,numPol>::coo2C(connec[4]),-1,
+ OTT<ConnType,numPol>::coo2C(connec[4]),OTT<ConnType,numPol>::coo2C(connec[10]),OTT<ConnType,numPol>::coo2C(connec[11]),OTT<ConnType,numPol>::coo2C(connec[5]),-1,
+ OTT<ConnType,numPol>::coo2C(connec[5]),OTT<ConnType,numPol>::coo2C(connec[11]),OTT<ConnType,numPol>::coo2C(connec[6]),OTT<ConnType,numPol>::coo2C(connec[0])};
+ return calculateVolumeForPolyh2<ConnType,numPol>(connecHexa12,43,coords);
+ }
case INTERP_KERNEL::NORM_POLYHED :
{
return calculateVolumeForPolyh2<ConnType,numPol>(connec,lgth,coords);
barycenterOfPolyhedron<ConnType,numPol>(conn,22,coords,res);
break;
}
+ case INTERP_KERNEL::NORM_HEXGP12:
+ {
+ const int connecHexa12[43]={
+ OTT<ConnType,numPol>::coo2C(connec[0]),OTT<ConnType,numPol>::coo2C(connec[1]),OTT<ConnType,numPol>::coo2C(connec[2]),OTT<ConnType,numPol>::coo2C(connec[3]),OTT<ConnType,numPol>::coo2C(connec[4]),OTT<ConnType,numPol>::coo2C(connec[5]),-1,
+ OTT<ConnType,numPol>::coo2C(connec[6]),OTT<ConnType,numPol>::coo2C(connec[11]),OTT<ConnType,numPol>::coo2C(connec[10]),OTT<ConnType,numPol>::coo2C(connec[9]),OTT<ConnType,numPol>::coo2C(connec[8]),OTT<ConnType,numPol>::coo2C(connec[7]),-1,
+ OTT<ConnType,numPol>::coo2C(connec[0]),OTT<ConnType,numPol>::coo2C(connec[6]),OTT<ConnType,numPol>::coo2C(connec[7]),OTT<ConnType,numPol>::coo2C(connec[1]),-1,
+ OTT<ConnType,numPol>::coo2C(connec[1]),OTT<ConnType,numPol>::coo2C(connec[7]),OTT<ConnType,numPol>::coo2C(connec[8]),OTT<ConnType,numPol>::coo2C(connec[2]),-1,
+ OTT<ConnType,numPol>::coo2C(connec[2]),OTT<ConnType,numPol>::coo2C(connec[8]),OTT<ConnType,numPol>::coo2C(connec[9]),OTT<ConnType,numPol>::coo2C(connec[3]),-1,
+ OTT<ConnType,numPol>::coo2C(connec[3]),OTT<ConnType,numPol>::coo2C(connec[9]),OTT<ConnType,numPol>::coo2C(connec[10]),OTT<ConnType,numPol>::coo2C(connec[4]),-1,
+ OTT<ConnType,numPol>::coo2C(connec[4]),OTT<ConnType,numPol>::coo2C(connec[10]),OTT<ConnType,numPol>::coo2C(connec[11]),OTT<ConnType,numPol>::coo2C(connec[5]),-1,
+ OTT<ConnType,numPol>::coo2C(connec[5]),OTT<ConnType,numPol>::coo2C(connec[11]),OTT<ConnType,numPol>::coo2C(connec[6]),OTT<ConnType,numPol>::coo2C(connec[0])};
+ barycenterOfPolyhedron<ConnType,numPol>(connecHexa12,43,coords,res);
+ break;
+ }
case NORM_POLYHED:
{
barycenterOfPolyhedron<ConnType,numPol>(connec,lgth,coords,res);
#include "ExprEvalInterpTest.hxx"
#include "InterpKernelExprParser.hxx"
+#include <limits>
+#include <iterator>
+
using namespace INTERP_TEST;
void ExprEvalInterpTest::testBuildStringFromFortran()
INTERP_KERNEL::Unit unit12("m-m");
CPPUNIT_ASSERT(!unit12.isInterpretationOK());
}
+
+void ExprEvalInterpTest::testInterpreter3()
+{
+ std::set<std::string> res;
+ double input[3];
+ double res2[3];
+ INTERP_KERNEL::ExprParser expr1("2.3+x>5.");
+ expr1.parse();
+ expr1.getSetOfVars(res);
+ CPPUNIT_ASSERT_EQUAL(1,(int)res.size());
+ CPPUNIT_ASSERT(*(res.begin())=="x");
+ expr1.prepareExprEvaluationVec();
+ input[0]=0.;
+ expr1.evaluateExpr(1,input,res2);
+ CPPUNIT_ASSERT(-std::numeric_limits<double>::max()==res2[0]);
+ input[0]=2.8;
+ expr1.evaluateExpr(1,input,res2);
+ CPPUNIT_ASSERT(std::numeric_limits<double>::max()==res2[0]);
+ input[0]=2.6;
+ expr1.evaluateExpr(1,input,res2);
+ CPPUNIT_ASSERT(-std::numeric_limits<double>::max()==res2[0]);
+ //
+ INTERP_KERNEL::ExprParser expr2("2.3+x<5.");
+ expr2.parse();
+ res.clear();
+ expr2.getSetOfVars(res);
+ CPPUNIT_ASSERT_EQUAL(1,(int)res.size());
+ CPPUNIT_ASSERT(*(res.begin())=="x");
+ expr2.prepareExprEvaluationVec();
+ input[0]=0.;
+ expr2.evaluateExpr(1,input,res2);
+ CPPUNIT_ASSERT(std::numeric_limits<double>::max()==res2[0]);
+ input[0]=2.8;
+ expr2.evaluateExpr(1,input,res2);
+ CPPUNIT_ASSERT(-std::numeric_limits<double>::max()==res2[0]);
+ input[0]=2.6;
+ expr2.evaluateExpr(1,input,res2);
+ CPPUNIT_ASSERT(std::numeric_limits<double>::max()==res2[0]);
+ //
+ INTERP_KERNEL::ExprParser expr3("if(2.3+x<5.,2+3*x,3+x/2)");
+ expr3.parse();
+ res.clear();
+ expr3.getSetOfVars(res);
+ CPPUNIT_ASSERT_EQUAL(1,(int)res.size());
+ CPPUNIT_ASSERT(*(res.begin())=="x");
+ expr3.prepareExprEvaluationVec();
+ input[0]=0.;
+ expr3.evaluateExpr(1,input,res2);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(2.,res2[0],1e-12);
+ input[0]=2.8;
+ expr3.evaluateExpr(1,input,res2);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(4.4,res2[0],1e-12);
+ input[0]=2.6;
+ expr3.evaluateExpr(1,input,res2);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(9.8,res2[0],1e-12);
+ //
+ INTERP_KERNEL::ExprParser expr4("if(x>1000,2*x,x/3)");
+ expr4.parse();
+ res.clear();
+ expr4.getSetOfVars(res);
+ CPPUNIT_ASSERT_EQUAL(1,(int)res.size());
+ CPPUNIT_ASSERT(*(res.begin())=="x");
+ expr4.prepareExprEvaluationVec();
+ input[0]=2.7;
+ expr4.evaluateExpr(1,input,res2);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(0.9,res2[0],1e-12);
+ input[0]=999.;
+ expr4.evaluateExpr(1,input,res2);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(333.,res2[0],1e-12);
+ input[0]=1002.;
+ expr4.evaluateExpr(1,input,res2);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(2004.,res2[0],1e-12);
+ //
+ INTERP_KERNEL::ExprParser expr5("4.4*x*log10(x)*10");
+ expr5.parse();
+ res.clear();
+ expr5.getSetOfVars(res);
+ CPPUNIT_ASSERT_EQUAL(1,(int)res.size());
+ CPPUNIT_ASSERT(*(res.begin())=="x");
+ expr5.prepareExprEvaluationVec();
+ input[0]=273.15;
+ expr5.evaluateExpr(1,input,res2);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(29282.131520617437,res2[0],1e-9);
+ input[0]=0.;
+ CPPUNIT_ASSERT_THROW(expr5.evaluateExpr(1,input,res2),INTERP_KERNEL::Exception);
+}
+
+/*!
+ * Bug detected by Marc concerning expressions with blanks.
+ */
+void ExprEvalInterpTest::testInterpreter4()
+{
+ INTERP_KERNEL::ExprParser expr("2*x + 1");
+ double vals[3]={0.1,0.2,0.3};
+ std::vector<std::string> varsV(3);
+ varsV[0] = "x";
+ varsV[1] = "y";
+ varsV[2] = "z";
+ expr.parse();
+ expr.prepareExprEvaluation(varsV);
+ double result;
+ expr.evaluateExpr(1,vals, &result);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(1.2,result,1e-12);
+}
+
+/*!
+ * Allowing scientific format for floats.
+ */
+void ExprEvalInterpTest::testInterpreter5()
+{
+ std::set<std::string> res;
+ double input[3];
+ double res2[3];
+ INTERP_KERNEL::ExprParser expr1("1.85e-3*x");
+ expr1.parse();
+ expr1.getSetOfVars(res);
+ CPPUNIT_ASSERT_EQUAL(1,(int)res.size());
+ CPPUNIT_ASSERT(*(res.begin())=="x");
+ input[0]=56.7;
+ expr1.prepareExprEvaluationVec();
+ expr1.evaluateExpr(1,input,res2);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(0.104895,res2[0],1e-12);
+ input[0]=-65.7;
+ expr1.evaluateExpr(1,input,res2);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(-0.121545,res2[0],1e-12);
+ //
+ INTERP_KERNEL::ExprParser expr2("x*1.85e-3");
+ expr2.parse();
+ expr2.getSetOfVars(res);
+ CPPUNIT_ASSERT_EQUAL(1,(int)res.size());
+ CPPUNIT_ASSERT(*(res.begin())=="x");
+ input[0]=56.7;
+ expr2.prepareExprEvaluationVec();
+ expr2.evaluateExpr(1,input,res2);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(0.104895,res2[0],1e-12);
+ input[0]=-65.7;
+ expr2.evaluateExpr(1,input,res2);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(-0.121545,res2[0],1e-12);
+ //
+ INTERP_KERNEL::ExprParser expr3("2.6E+1+x*1.85e-3");
+ expr3.parse();
+ expr3.getSetOfVars(res);
+ CPPUNIT_ASSERT_EQUAL(1,(int)res.size());
+ CPPUNIT_ASSERT(*(res.begin())=="x");
+ input[0]=56.7;
+ expr3.prepareExprEvaluationVec();
+ expr3.evaluateExpr(1,input,res2);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(26.104895,res2[0],1e-12);
+ input[0]=-65.7;
+ expr3.evaluateExpr(1,input,res2);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(25.878455,res2[0],1e-12);
+ //
+ INTERP_KERNEL::ExprParser expr4("3.*max(((3.2e+1*(ln((2*5.2E-02+6.)+(1.2E-001*1.2E+2+3e-4))))),((3.2E-2*(exp((6e-1+2*5.2e-2)+(1.2E001*1.2+3.))))))");
+ expr4.parse();
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(6994207.8359543988,expr4.evaluate(),1e-5);
+}
CPPUNIT_TEST( testInterpreter2 );
CPPUNIT_TEST( testInterpreterUnit0 );
CPPUNIT_TEST( testInterpreterUnit1 );
+ CPPUNIT_TEST( testInterpreter3 );
+ CPPUNIT_TEST( testInterpreter4 );
+ CPPUNIT_TEST( testInterpreter5 );
CPPUNIT_TEST_SUITE_END();
public:
void setUp() { }
void testInterpreter0();
void testInterpreter1();
void testInterpreter2();
+ void testInterpreter3();
+ void testInterpreter4();
+ void testInterpreter5();
void testInterpreterUnit0();
void testInterpreterUnit1();
};
#include "MeshTestToolkit.hxx"
#include "MEDMEM_Mesh.hxx"
-#include "Interpolation3DSurf.txx"
+#include "Interpolation3DSurf.hxx"
#include "Interpolation2D.txx"
#include "Interpolation3D.txx"
MEDCouplingAutoRefCountObjectPtr(const MEDCouplingAutoRefCountObjectPtr& other):_ptr(0) { referPtr(other._ptr); }
MEDCouplingAutoRefCountObjectPtr(T *ptr=0):_ptr(ptr) { }
~MEDCouplingAutoRefCountObjectPtr() { destroyPtr(); }
+ bool operator==(const MEDCouplingAutoRefCountObjectPtr& other) { return _ptr==other._ptr; }
MEDCouplingAutoRefCountObjectPtr &operator=(const MEDCouplingAutoRefCountObjectPtr& other) { if(_ptr!=other._ptr) { destroyPtr(); referPtr(other._ptr); } return *this; }
MEDCouplingAutoRefCountObjectPtr &operator=(T *ptr) { if(_ptr!=ptr) { destroyPtr(); _ptr=ptr; } return *this; }
T *operator->() { return _ptr ; }
if(deepCpy)
{
if(other._x_array)
- _x_array=_x_array->deepCopy();
+ _x_array=other._x_array->deepCpy();
+ else
+ _x_array=0;
if(other._y_array)
- _y_array=_y_array->deepCopy();
+ _y_array=other._y_array->deepCpy();
+ else
+ _y_array=0;
if(other._z_array)
- _z_array=_z_array->deepCopy();
+ _z_array=other._z_array->deepCpy();
+ else
+ _z_array=0;
}
else
{
return new MEDCouplingCMesh(*this,recDeepCpy);
}
-void MEDCouplingCMesh::updateTime()
+void MEDCouplingCMesh::updateTime() const
{
if(_x_array)
updateTimeWith(*_x_array);
}
}
+void MEDCouplingCMesh::checkCoherency1(double eps) const throw(INTERP_KERNEL::Exception)
+{
+ checkCoherency();
+ if(_x_array)
+ _x_array->checkMonotonic(eps);
+ if(_y_array)
+ _y_array->checkMonotonic(eps);
+ if(_z_array)
+ _z_array->checkMonotonic(eps);
+}
+
+void MEDCouplingCMesh::checkCoherency2(double eps) const throw(INTERP_KERNEL::Exception)
+{
+ checkCoherency1(eps);
+}
+
int MEDCouplingCMesh::getNumberOfCells() const
{
int ret=1;
return std::accumulate(tmp,tmp+spaceDim,0);
}
-void MEDCouplingCMesh::getPosFromId(int nodeId, int spaceDim, const int *split, int *res)
+void MEDCouplingCMesh::GetPosFromId(int nodeId, int spaceDim, const int *split, int *res)
{
int work=nodeId;
for(int i=spaceDim-1;i>=0;i--)
getSplitNodeValues(tmp);
const DataArrayDouble *tabs[3]={getCoordsAt(0),getCoordsAt(1),getCoordsAt(2)};
int tmp2[3];
- getPosFromId(nodeId,spaceDim,tmp,tmp2);
+ GetPosFromId(nodeId,spaceDim,tmp,tmp2);
for(int j=0;j<spaceDim;j++)
if(tabs[j])
coo.push_back(tabs[j]->getConstPointer()[tmp2[j]]);
{
std::ostringstream ret;
ret << "Cartesian mesh with name : \"" << getName() << "\"\n";
+ ret << "Description of mesh : \"" << getDescription() << "\"\n";
+ int tmpp1,tmpp2;
+ double tt=getTime(tmpp1,tmpp2);
+ ret << "Time attached to the mesh [unit] : " << tt << " [" << getTimeUnit() << "]\n";
+ ret << "Iteration : " << tmpp1 << " Order : " << tmpp2 << "\n";
ret << "Mesh and SpaceDimension dimension : " << getSpaceDimension() << "\n\nArrays :\n________\n\n";
if(_x_array)
{
return simpleRepr();
}
-DataArrayDouble *MEDCouplingCMesh::getCoordsAt(int i) const throw(INTERP_KERNEL::Exception)
+const DataArrayDouble *MEDCouplingCMesh::getCoordsAt(int i) const throw(INTERP_KERNEL::Exception)
{
switch(i)
{
}
}
-void MEDCouplingCMesh::setCoordsAt(int i, DataArrayDouble *arr) throw(INTERP_KERNEL::Exception)
+DataArrayDouble *MEDCouplingCMesh::getCoordsAt(int i) throw(INTERP_KERNEL::Exception)
+{
+ switch(i)
+ {
+ case 0:
+ return _x_array;
+ case 1:
+ return _y_array;
+ case 2:
+ return _z_array;
+ default:
+ throw INTERP_KERNEL::Exception("Invalid rank specified must be 0 or 1 or 2.");
+ }
+}
+
+void MEDCouplingCMesh::setCoordsAt(int i, const DataArrayDouble *arr) throw(INTERP_KERNEL::Exception)
{
DataArrayDouble **thisArr[3]={&_x_array,&_y_array,&_z_array};
if(i<0 || i>2)
{
if(*(thisArr[i]))
(*(thisArr[i]))->decrRef();
- (*(thisArr[i]))=arr;
+ (*(thisArr[i]))=const_cast<DataArrayDouble *>(arr);
if(*(thisArr[i]))
(*(thisArr[i]))->incrRef();
declareAsNew();
}
}
-void MEDCouplingCMesh::setCoords(DataArrayDouble *coordsX, DataArrayDouble *coordsY, DataArrayDouble *coordsZ)
+void MEDCouplingCMesh::setCoords(const DataArrayDouble *coordsX, const DataArrayDouble *coordsY, const DataArrayDouble *coordsZ)
{
if(_x_array)
_x_array->decrRef();
- _x_array=coordsX;
+ _x_array=const_cast<DataArrayDouble *>(coordsX);
if(_x_array)
_x_array->incrRef();
if(_y_array)
_y_array->decrRef();
- _y_array=coordsY;
+ _y_array=const_cast<DataArrayDouble *>(coordsY);
if(_y_array)
_y_array->incrRef();
if(_z_array)
_z_array->decrRef();
- _z_array=coordsZ;
+ _z_array=const_cast<DataArrayDouble *>(coordsZ);
if(_z_array)
_z_array->incrRef();
declareAsNew();
}
-MEDCouplingUMesh *MEDCouplingCMesh::buildUnstructured() const
+/*!
+ * See MEDCouplingUMesh::checkTypeConsistencyAndContig for more information
+ */
+DataArrayInt *MEDCouplingCMesh::checkTypeConsistencyAndContig(const std::vector<int>& code, const std::vector<const DataArrayInt *>& idsPerType) const throw(INTERP_KERNEL::Exception)
+{
+ int sz=code.size();
+ if(sz!=0 && sz!=3)
+ throw INTERP_KERNEL::Exception("MEDCouplingCMesh::checkTypeConsistencyAndContig : code should be of size 2 exactly !");
+ if(code[0]==INTERP_KERNEL::NORM_ERROR)
+ {
+ int nbNodes=getNumberOfNodes();
+ if(code[2]==-1)
+ {
+ if(code[1]==nbNodes)
+ return 0;
+ else
+ throw INTERP_KERNEL::Exception("MEDCouplingCMesh::checkTypeConsistencyAndContig : number of nodes mismatch !");
+ }
+ else
+ idsPerType[code[2]]->deepCpy();
+ }
+ else
+ {
+ int nbCells=getNumberOfCellsWithType((INTERP_KERNEL::NormalizedCellType)code[0]);
+ if(code[2]==-1)
+ {
+ if(code[1]==nbCells)
+ return 0;
+ else
+ throw INTERP_KERNEL::Exception("MEDCouplingCMesh::checkTypeConsistencyAndContig : number of cells mismatch !");
+ }
+ else
+ idsPerType[code[2]]->deepCpy();
+ }
+ return 0;
+}
+
+MEDCouplingUMesh *MEDCouplingCMesh::buildUnstructured() const throw(INTERP_KERNEL::Exception)
{
int spaceDim=getSpaceDimension();
MEDCouplingUMesh *ret=MEDCouplingUMesh::New(getName(),spaceDim);
int j=0;
for (int idim=0; idim<dim; idim++)
{
- DataArrayDouble *c=getCoordsAt(idim);
+ const DataArrayDouble *c=getCoordsAt(idim);
if(c)
{
const double *coords=c->getConstPointer();
for(int icell=0;icell<nbelem;icell++)
{
int tmp2[3];
- getPosFromId(icell,dim,tmp,tmp2);
+ GetPosFromId(icell,dim,tmp,tmp2);
area_vol[icell]=1.;
for(int i=0;i<dim;i++)
area_vol[icell]*=thisArr[i][tmp2[i]+1]-thisArr[i][tmp2[i]];
double *pt=ret->getPointer();
int tmp[3];
getSplitNodeValues(tmp);
- DataArrayDouble *tabs[3]={getCoordsAt(0),getCoordsAt(1),getCoordsAt(2)};
+ const DataArrayDouble *tabs[3]={getCoordsAt(0),getCoordsAt(1),getCoordsAt(2)};
const double *tabsPtr[3];
for(int j=0;j<spaceDim;j++)
- tabsPtr[j]=tabs[j]->getConstPointer();
+ {
+ tabsPtr[j]=tabs[j]->getConstPointer();
+ ret->setInfoOnComponent(j,tabs[j]->getInfoOnComponent(0).c_str());
+ }
int tmp2[3];
for(int i=0;i<nbNodes;i++)
{
- getPosFromId(i,spaceDim,tmp,tmp2);
+ GetPosFromId(i,spaceDim,tmp,tmp2);
for(int j=0;j<spaceDim;j++)
pt[i*spaceDim+j]=tabsPtr[j][tmp2[j]];
}
double *pt=ret->getPointer();
int tmp[3];
getSplitCellValues(tmp);
- DataArrayDouble *tabs[3]={getCoordsAt(0),getCoordsAt(1),getCoordsAt(2)};
+ const DataArrayDouble *tabs[3]={getCoordsAt(0),getCoordsAt(1),getCoordsAt(2)};
std::vector<double> tabsPtr[3];
for(int j=0;j<spaceDim;j++)
{
int sz=tabs[j]->getNbOfElems()-1;
+ ret->setInfoOnComponent(j,tabs[j]->getInfoOnComponent(0).c_str());
const double *srcPtr=tabs[j]->getConstPointer();
tabsPtr[j].insert(tabsPtr[j].end(),srcPtr,srcPtr+sz);
std::transform(tabsPtr[j].begin(),tabsPtr[j].end(),srcPtr+1,tabsPtr[j].begin(),std::plus<double>());
int tmp2[3];
for(int i=0;i<nbCells;i++)
{
- getPosFromId(i,spaceDim,tmp,tmp2);
+ GetPosFromId(i,spaceDim,tmp,tmp2);
for(int j=0;j<spaceDim;j++)
pt[i*spaceDim+j]=tabsPtr[j][tmp2[j]];
}
connI->decrRef();
}
-void MEDCouplingCMesh::getTinySerializationInformation(std::vector<int>& tinyInfo, std::vector<std::string>& littleStrings) const
+void MEDCouplingCMesh::getTinySerializationInformation(std::vector<double>& tinyInfoD, std::vector<int>& tinyInfo, std::vector<std::string>& littleStrings) const
{
+ int it,order;
+ double time=getTime(it,order);
tinyInfo.clear();
+ tinyInfoD.clear();
littleStrings.clear();
littleStrings.push_back(getName());
+ littleStrings.push_back(getDescription());
+ littleStrings.push_back(getTimeUnit());
const DataArrayDouble *thisArr[3]={_x_array,_y_array,_z_array};
for(int i=0;i<3;i++)
{
tinyInfo.push_back(val);
littleStrings.push_back(st);
}
+ tinyInfo.push_back(it);
+ tinyInfo.push_back(order);
+ tinyInfoD.push_back(time);
}
void MEDCouplingCMesh::resizeForUnserialization(const std::vector<int>& tinyInfo, DataArrayInt *a1, DataArrayDouble *a2, std::vector<std::string>& littleStrings) const
a2Ptr=std::copy(thisArr[i]->getConstPointer(),thisArr[i]->getConstPointer()+thisArr[i]->getNumberOfTuples(),a2Ptr);
}
-void MEDCouplingCMesh::unserialization(const std::vector<int>& tinyInfo, const DataArrayInt *a1, DataArrayDouble *a2,
+void MEDCouplingCMesh::unserialization(const std::vector<double>& tinyInfoD, const std::vector<int>& tinyInfo, const DataArrayInt *a1, DataArrayDouble *a2,
const std::vector<std::string>& littleStrings)
{
setName(littleStrings[0].c_str());
+ setDescription(littleStrings[1].c_str());
+ setTimeUnit(littleStrings[2].c_str());
DataArrayDouble **thisArr[3]={&_x_array,&_y_array,&_z_array};
const double *data=a2->getConstPointer();
for(int i=0;i<3;i++)
{
(*(thisArr[i]))=DataArrayDouble::New();
(*(thisArr[i]))->alloc(tinyInfo[i],1);
- (*(thisArr[i]))->setInfoOnComponent(0,littleStrings[i+1].c_str());
+ (*(thisArr[i]))->setInfoOnComponent(0,littleStrings[i+3].c_str());
std::copy(data,data+tinyInfo[i],(*(thisArr[i]))->getPointer());
data+=tinyInfo[i];
}
}
+ setTime(tinyInfoD[0],tinyInfo[3],tinyInfo[4]);
}
static MEDCouplingCMesh *New();
MEDCouplingMesh *deepCpy() const;
MEDCouplingCMesh *clone(bool recDeepCpy) const;
- void updateTime();
+ void updateTime() const;
MEDCouplingMeshType getType() const { return CARTESIAN; }
void copyTinyStringsFrom(const MEDCouplingMesh *other) throw(INTERP_KERNEL::Exception);
bool isEqual(const MEDCouplingMesh *other, double prec) const;
void checkDeepEquivalOnSameNodesWith(const MEDCouplingMesh *other, int cellCompPol, double prec,
DataArrayInt *&cellCor) const throw(INTERP_KERNEL::Exception);
void checkCoherency() const throw(INTERP_KERNEL::Exception);
+ void checkCoherency1(double eps=1e-12) const throw(INTERP_KERNEL::Exception);
+ void checkCoherency2(double eps=1e-12) const throw(INTERP_KERNEL::Exception);
int getNumberOfCells() const;
int getNumberOfNodes() const;
int getSpaceDimension() const;
int getMeshDimension() const;
int getCellIdFromPos(int i, int j, int k) const;
int getNodeIdFromPos(int i, int j, int k) const;
- static void getPosFromId(int nodeId, int spaceDim, const int *split, int *res);
+ static void GetPosFromId(int nodeId, int spaceDim, const int *split, int *res);
INTERP_KERNEL::NormalizedCellType getTypeOfCell(int cellId) const;
int getNumberOfCellsWithType(INTERP_KERNEL::NormalizedCellType type) const;
void getNodeIdsOfCell(int cellId, std::vector<int>& conn) const;
void getCoordinatesOfNode(int nodeId, std::vector<double>& coo) const;
std::string simpleRepr() const;
std::string advancedRepr() const;
- DataArrayDouble *getCoordsAt(int i) const throw(INTERP_KERNEL::Exception);
- void setCoordsAt(int i, DataArrayDouble *arr) throw(INTERP_KERNEL::Exception);
- void setCoords(DataArrayDouble *coordsX,
- DataArrayDouble *coordsY=0,
- DataArrayDouble *coordsZ=0);
+ const DataArrayDouble *getCoordsAt(int i) const throw(INTERP_KERNEL::Exception);
+ DataArrayDouble *getCoordsAt(int i) throw(INTERP_KERNEL::Exception);
+ void setCoordsAt(int i, const DataArrayDouble *arr) throw(INTERP_KERNEL::Exception);
+ void setCoords(const DataArrayDouble *coordsX,
+ const DataArrayDouble *coordsY=0,
+ const DataArrayDouble *coordsZ=0);
// tools
- MEDCouplingUMesh *buildUnstructured() const;
+ DataArrayInt *checkTypeConsistencyAndContig(const std::vector<int>& code, const std::vector<const DataArrayInt *>& idsPerType) const throw(INTERP_KERNEL::Exception);
+ MEDCouplingUMesh *buildUnstructured() const throw(INTERP_KERNEL::Exception);
MEDCouplingMesh *buildPart(const int *start, const int *end) const;
MEDCouplingMesh *buildPartAndReduceNodes(const int *start, const int *end, DataArrayInt*& arr) const;
DataArrayInt *simplexize(int policy) throw(INTERP_KERNEL::Exception);
void getSplitCellValues(int *res) const;
void getSplitNodeValues(int *res) const;
//serialisation-unserialization
- void getTinySerializationInformation(std::vector<int>& tinyInfo, std::vector<std::string>& littleStrings) const;
+ void getTinySerializationInformation(std::vector<double>& tinyInfoD, std::vector<int>& tinyInfo, std::vector<std::string>& littleStrings) const;
void resizeForUnserialization(const std::vector<int>& tinyInfo, DataArrayInt *a1, DataArrayDouble *a2, std::vector<std::string>& littleStrings) const;
void serialize(DataArrayInt *&a1, DataArrayDouble *&a2) const;
- void unserialization(const std::vector<int>& tinyInfo, const DataArrayInt *a1, DataArrayDouble *a2,
+ void unserialization(const std::vector<double>& tinyInfoD, const std::vector<int>& tinyInfo, const DataArrayInt *a1, DataArrayDouble *a2,
const std::vector<std::string>& littleStrings);
private:
MEDCouplingCMesh();
--- /dev/null
+// Copyright (C) 2007-2010 CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#include "MEDCouplingDefinitionTime.hxx"
+#include "MEDCouplingFieldDouble.hxx"
+
+#include <cmath>
+
+using namespace ParaMEDMEM;
+
+const double MEDCouplingDefinitionTime::EPS_DFT=1e-15;
+
+MEDCouplingDefinitionTimeSlice *MEDCouplingDefinitionTimeSlice::New(const MEDCouplingFieldDouble *f, int meshId, const std::vector<int>& arrId, int fieldId) throw(INTERP_KERNEL::Exception)
+{
+ static const char msg[]="TimeSlice::New : mismatch of arrays number of a fieldDouble and its policy !!! Internal error !!!";
+ if(!f)
+ throw INTERP_KERNEL::Exception("MEDCouplingDefinitionTimeSlice::New : empty field !");
+ switch(f->getTimeDiscretization())
+ {
+ case ONE_TIME:
+ {
+ if(arrId.size()!=1)
+ throw INTERP_KERNEL::Exception(msg);
+ return new MEDCouplingDefinitionTimeSliceInst(f,meshId,arrId[0],fieldId);
+ }
+ case CONST_ON_TIME_INTERVAL:
+ {
+ if(arrId.size()!=1)
+ throw INTERP_KERNEL::Exception(msg);
+ return new MEDCouplingDefinitionTimeSliceCstOnTI(f,meshId,arrId[0],fieldId);
+ }
+ case LINEAR_TIME:
+ {
+ if(arrId.size()!=2)
+ throw INTERP_KERNEL::Exception(msg);
+ return new MEDCouplingDefinitionTimeSliceLT(f,meshId,arrId[0],arrId[1],fieldId);
+ }
+ case NO_TIME:
+ throw INTERP_KERNEL::Exception("Invalide time discretization ! NO_TIME ! Impossible to build a definition time slice !");
+ default:
+ throw INTERP_KERNEL::Exception("Invalide time discretization : Not recognized !");
+ }
+}
+
+MEDCouplingDefinitionTimeSlice *MEDCouplingDefinitionTimeSlice::New(TypeOfTimeDiscretization type, const std::vector<int>& tiI, const std::vector<double>& tiD) throw(INTERP_KERNEL::Exception)
+{
+ switch(type)
+ {
+ case ONE_TIME:
+ return MEDCouplingDefinitionTimeSliceInst::New(tiI,tiD);
+ case CONST_ON_TIME_INTERVAL:
+ return MEDCouplingDefinitionTimeSliceCstOnTI::New(tiI,tiD);
+ case LINEAR_TIME:
+ return MEDCouplingDefinitionTimeSliceLT::New(tiI,tiD);
+ default:
+ throw INTERP_KERNEL::Exception("MEDCouplingDefinitionTimeSlice::New : unrecognized time discretization type !");
+ }
+}
+
+bool MEDCouplingDefinitionTimeSlice::isEqual(const MEDCouplingDefinitionTimeSlice& other, double eps) const
+{
+ if(_mesh_id!=other._mesh_id)
+ return false;
+ if(_array_id!=other._array_id)
+ return false;
+ if(_field_id!=other._field_id)
+ return false;
+ return true;
+}
+
+int MEDCouplingDefinitionTimeSlice::getStartId() const
+{
+ return _array_id;
+}
+
+int MEDCouplingDefinitionTimeSlice::getEndId() const
+{
+ return _array_id;
+}
+
+void MEDCouplingDefinitionTimeSlice::appendRepr(std::ostream& stream) const
+{
+ stream << " *** MeshId : " << _mesh_id << " ArrayId : " << _array_id;
+}
+
+MEDCouplingDefinitionTimeSlice::MEDCouplingDefinitionTimeSlice(const MEDCouplingFieldDouble *f, int meshId, int arrId, int fieldId) throw(INTERP_KERNEL::Exception):_mesh_id(meshId),_array_id(arrId),_field_id(fieldId)
+{
+ int tmp1,tmp2;
+ double t1=f->getStartTime(tmp1,tmp2);
+ double t2=f->getEndTime(tmp1,tmp2);
+ if(t2<t1)
+ throw INTERP_KERNEL::Exception("MEDCouplingDefinitionTimeSlice : End time strictly before Start time ...");
+}
+
+bool MEDCouplingDefinitionTimeSlice::isFullyIncludedInMe(const MEDCouplingDefinitionTimeSlice *other, double eps) const
+{
+ double t1=getStartTime();
+ double t2=getEndTime();
+ double o1=other->getStartTime();
+ double o2=other->getEndTime();
+ return o1>t1-eps && o2<t2+eps;
+}
+
+bool MEDCouplingDefinitionTimeSlice::isOverllapingWithMe(const MEDCouplingDefinitionTimeSlice *other, double eps) const
+{
+ double t1=getStartTime();
+ double t2=getEndTime();
+ double o1=other->getStartTime();
+ double o2=other->getEndTime();
+ return (o1<t1+eps && o2<t1+eps) || (o1>t2-eps && o2>t2-eps);
+}
+
+bool MEDCouplingDefinitionTimeSlice::isAfterMe(const MEDCouplingDefinitionTimeSlice *other, double eps) const
+{
+ double t2=getEndTime();
+ double o1=other->getStartTime();
+ double o2=other->getEndTime();
+ return (o1>t2-eps && o2>t2-eps);
+}
+
+bool MEDCouplingDefinitionTimeSlice::isBeforeMe(const MEDCouplingDefinitionTimeSlice *other, double eps) const
+{
+ double t1=getStartTime();
+ double o1=other->getStartTime();
+ double o2=other->getEndTime();
+ return (o1<t1+eps && o2<t1+eps);
+}
+
+MEDCouplingDefinitionTimeSliceInst *MEDCouplingDefinitionTimeSliceInst::New(const std::vector<int>& tiI, const std::vector<double>& tiD)
+{
+ MEDCouplingDefinitionTimeSliceInst *ret=new MEDCouplingDefinitionTimeSliceInst;
+ ret->unserialize(tiI,tiD);
+ return ret;
+}
+
+void MEDCouplingDefinitionTimeSliceInst::getTinySerializationInformation(std::vector<int>& tiI, std::vector<double>& tiD) const
+{
+ tiI.resize(3);
+ tiI[0]=_mesh_id; tiI[1]=_array_id; tiI[2]=_field_id;
+ tiD.resize(1);
+ tiD[0]=_instant;
+}
+
+void MEDCouplingDefinitionTimeSliceInst::unserialize(const std::vector<int>& tiI, const std::vector<double>& tiD)
+{
+ _mesh_id=tiI[0]; _array_id=tiI[1]; _field_id=tiI[2];
+ _instant=tiD[0];
+}
+
+TypeOfTimeDiscretization MEDCouplingDefinitionTimeSliceInst::getTimeType() const
+{
+ return ONE_TIME;
+}
+
+MEDCouplingDefinitionTimeSlice *MEDCouplingDefinitionTimeSliceInst::copy() const
+{
+ return new MEDCouplingDefinitionTimeSliceInst(*this);
+}
+
+bool MEDCouplingDefinitionTimeSliceInst::isEqual(const MEDCouplingDefinitionTimeSlice& other, double eps) const
+{
+ if(!MEDCouplingDefinitionTimeSlice::isEqual(other,eps))
+ return false;
+ const MEDCouplingDefinitionTimeSliceInst *otherC=dynamic_cast<const MEDCouplingDefinitionTimeSliceInst *>(&other);
+ if(!otherC)
+ return false;
+ return fabs(otherC->_instant-_instant)<eps;
+}
+
+void MEDCouplingDefinitionTimeSliceInst::getHotSpotsTime(std::vector<double>& ret) const
+{
+ ret.resize(1);
+ ret[0]=_instant;
+}
+
+void MEDCouplingDefinitionTimeSliceInst::getIdsOnTime(double tm, double eps, int& meshId, int& arrId, int& arrIdInField, int& fieldId) const throw(INTERP_KERNEL::Exception)
+{
+ meshId=_mesh_id;
+ arrId=_array_id;
+ arrIdInField=0;
+ fieldId=_field_id;
+}
+
+bool MEDCouplingDefinitionTimeSliceInst::isContaining(double tmp, double eps) const
+{
+ return fabs(tmp-_instant)<eps;
+}
+
+void MEDCouplingDefinitionTimeSliceInst::appendRepr(std::ostream& stream) const
+{
+ stream << "single point " << _instant;
+ MEDCouplingDefinitionTimeSlice::appendRepr(stream);
+}
+
+double MEDCouplingDefinitionTimeSliceInst::getStartTime() const
+{
+ return _instant;
+}
+
+double MEDCouplingDefinitionTimeSliceInst::getEndTime() const
+{
+ return _instant;
+}
+
+MEDCouplingDefinitionTimeSliceInst::MEDCouplingDefinitionTimeSliceInst(const MEDCouplingFieldDouble *f, int meshId, int arrId, int fieldId) throw(INTERP_KERNEL::Exception):MEDCouplingDefinitionTimeSlice(f,meshId,arrId,fieldId)
+{
+ int tmp1,tmp2;
+ double t1=f->getStartTime(tmp1,tmp2);
+ double t2=f->getEndTime(tmp1,tmp2);
+ double eps=f->getTimeTolerance();
+ if(fabs(t1-t2)>eps)
+ throw INTERP_KERNEL::Exception("MEDCouplingDefinitionTimeSliceInst : times differs in this");
+ _instant=t1;
+}
+
+MEDCouplingDefinitionTimeSliceCstOnTI *MEDCouplingDefinitionTimeSliceCstOnTI::New(const std::vector<int>& tiI, const std::vector<double>& tiD)
+{
+ MEDCouplingDefinitionTimeSliceCstOnTI *ret=new MEDCouplingDefinitionTimeSliceCstOnTI;
+ ret->unserialize(tiI,tiD);
+ return ret;
+}
+
+MEDCouplingDefinitionTimeSlice *MEDCouplingDefinitionTimeSliceCstOnTI::copy() const
+{
+ return new MEDCouplingDefinitionTimeSliceCstOnTI(*this);
+}
+
+bool MEDCouplingDefinitionTimeSliceCstOnTI::isEqual(const MEDCouplingDefinitionTimeSlice& other, double eps) const
+{
+ if(!MEDCouplingDefinitionTimeSlice::isEqual(other,eps))
+ return false;
+ const MEDCouplingDefinitionTimeSliceCstOnTI *otherC=dynamic_cast<const MEDCouplingDefinitionTimeSliceCstOnTI *>(&other);
+ if(!otherC)
+ return false;
+ if(fabs(otherC->_start-_start)>eps)
+ return false;
+ return fabs(otherC->_end-_end)<eps;
+}
+
+void MEDCouplingDefinitionTimeSliceCstOnTI::getHotSpotsTime(std::vector<double>& ret) const
+{
+ ret.resize(1);
+ ret[0]=(_start+_end)/2.;
+}
+
+void MEDCouplingDefinitionTimeSliceCstOnTI::getIdsOnTime(double tm, double eps, int& meshId, int& arrId, int& arrIdInField, int& fieldId) const throw(INTERP_KERNEL::Exception)
+{
+ meshId=_mesh_id;
+ arrId=_array_id;
+ arrIdInField=0;
+ fieldId=_field_id;
+}
+
+bool MEDCouplingDefinitionTimeSliceCstOnTI::isContaining(double tmp, double eps) const
+{
+ return _start-eps<tmp && _end+eps>tmp;
+}
+
+void MEDCouplingDefinitionTimeSliceCstOnTI::appendRepr(std::ostream& stream) const
+{
+ stream << "Constant on time interval [" << _start << "," << _end << "]";
+ MEDCouplingDefinitionTimeSlice::appendRepr(stream);
+}
+
+double MEDCouplingDefinitionTimeSliceCstOnTI::getStartTime() const
+{
+ return _start;
+}
+
+double MEDCouplingDefinitionTimeSliceCstOnTI::getEndTime() const
+{
+ return _end;
+}
+
+void MEDCouplingDefinitionTimeSliceCstOnTI::getTinySerializationInformation(std::vector<int>& tiI, std::vector<double>& tiD) const
+{
+ tiI.resize(3);
+ tiI[0]=_mesh_id; tiI[1]=_array_id; tiI[2]=_field_id;
+ tiD.resize(2);
+ tiD[0]=_start; tiD[1]=_end;
+}
+
+void MEDCouplingDefinitionTimeSliceCstOnTI::unserialize(const std::vector<int>& tiI, const std::vector<double>& tiD)
+{
+ _mesh_id=tiI[0]; _array_id=tiI[1]; _field_id=tiI[2];
+ _start=tiD[0]; _end=tiD[1];
+}
+
+TypeOfTimeDiscretization MEDCouplingDefinitionTimeSliceCstOnTI::getTimeType() const
+{
+ return CONST_ON_TIME_INTERVAL;
+}
+
+MEDCouplingDefinitionTimeSliceCstOnTI::MEDCouplingDefinitionTimeSliceCstOnTI(const MEDCouplingFieldDouble *f, int meshId, int arrId, int fieldId) throw(INTERP_KERNEL::Exception):MEDCouplingDefinitionTimeSlice(f,meshId,arrId,fieldId)
+{
+ int tmp1,tmp2;
+ double t1=f->getStartTime(tmp1,tmp2);
+ double t2=f->getEndTime(tmp1,tmp2);
+ _start=t1;
+ _end=t2;
+}
+
+MEDCouplingDefinitionTimeSliceLT *MEDCouplingDefinitionTimeSliceLT::New(const std::vector<int>& tiI, const std::vector<double>& tiD)
+{
+ MEDCouplingDefinitionTimeSliceLT *ret=new MEDCouplingDefinitionTimeSliceLT;
+ ret->unserialize(tiI,tiD);
+ return ret;
+}
+
+MEDCouplingDefinitionTimeSlice *MEDCouplingDefinitionTimeSliceLT::copy() const
+{
+ return new MEDCouplingDefinitionTimeSliceLT(*this);
+}
+
+bool MEDCouplingDefinitionTimeSliceLT::isEqual(const MEDCouplingDefinitionTimeSlice& other, double eps) const
+{
+ if(!MEDCouplingDefinitionTimeSlice::isEqual(other,eps))
+ return false;
+ const MEDCouplingDefinitionTimeSliceLT *otherC=dynamic_cast<const MEDCouplingDefinitionTimeSliceLT *>(&other);
+ if(!otherC)
+ return false;
+ if(_array_id_end!=otherC->_array_id_end)
+ return false;
+ if(fabs(otherC->_start-_start)>eps)
+ return false;
+ return fabs(otherC->_end-_end)<eps;
+}
+
+void MEDCouplingDefinitionTimeSliceLT::getHotSpotsTime(std::vector<double>& ret) const
+{
+ ret.resize(2);
+ ret[0]=_start;
+ ret[1]=_end;
+}
+
+void MEDCouplingDefinitionTimeSliceLT::getIdsOnTime(double tm, double eps, int& meshId, int& arrId, int& arrIdInField, int& fieldId) const throw(INTERP_KERNEL::Exception)
+{
+ if(fabs(tm-_start)<eps)
+ {
+ meshId=_mesh_id;
+ arrId=_array_id;
+ arrIdInField=0;
+ fieldId=_field_id;
+ return ;
+ }
+ if(fabs(tm-_end)<eps)
+ {
+ meshId=_mesh_id;
+ arrId=_array_id_end;
+ arrIdInField=1;
+ fieldId=_field_id;
+ return ;
+ }
+ throw INTERP_KERNEL::Exception("LinearTime request not in boundary of this ! use hot spots !");
+}
+
+bool MEDCouplingDefinitionTimeSliceLT::isContaining(double tmp, double eps) const
+{
+ return _start-eps<tmp && _end+eps>tmp;
+}
+
+void MEDCouplingDefinitionTimeSliceLT::appendRepr(std::ostream& stream) const
+{
+ stream << "Linear on time interval [" << _start << "," << _end << "]";
+ MEDCouplingDefinitionTimeSlice::appendRepr(stream);
+ stream << " EndArrayId : " << _array_id_end;
+}
+
+double MEDCouplingDefinitionTimeSliceLT::getStartTime() const
+{
+ return _start;
+}
+
+double MEDCouplingDefinitionTimeSliceLT::getEndTime() const
+{
+ return _end;
+}
+
+int MEDCouplingDefinitionTimeSliceLT::getEndId() const
+{
+ return _array_id_end;
+}
+
+void MEDCouplingDefinitionTimeSliceLT::getTinySerializationInformation(std::vector<int>& tiI, std::vector<double>& tiD) const
+{
+ tiI.resize(4);
+ tiI[0]=_mesh_id; tiI[1]=_array_id; tiI[2]=_field_id; tiI[3]=_array_id_end;
+ tiD.resize(2);
+ tiD[0]=_start; tiD[1]=_end;
+}
+
+void MEDCouplingDefinitionTimeSliceLT::unserialize(const std::vector<int>& tiI, const std::vector<double>& tiD)
+{
+ _mesh_id=tiI[0]; _array_id=tiI[1]; _field_id=tiI[2]; _array_id_end=tiI[3];
+ _start=tiD[0]; _end=tiD[1];
+}
+
+TypeOfTimeDiscretization MEDCouplingDefinitionTimeSliceLT::getTimeType() const
+{
+ return LINEAR_TIME;
+}
+
+MEDCouplingDefinitionTimeSliceLT::MEDCouplingDefinitionTimeSliceLT(const MEDCouplingFieldDouble *f, int meshId, int arrId, int arr2Id, int fieldId) throw(INTERP_KERNEL::Exception):MEDCouplingDefinitionTimeSlice(f,meshId,arrId,fieldId),_array_id_end(arr2Id)
+{
+ int tmp1,tmp2;
+ double t1=f->getStartTime(tmp1,tmp2);
+ double t2=f->getEndTime(tmp1,tmp2);
+ _start=t1;
+ _end=t2;
+}
+
+MEDCouplingDefinitionTime::MEDCouplingDefinitionTime():_eps(EPS_DFT)
+{
+}
+
+MEDCouplingDefinitionTime::MEDCouplingDefinitionTime(const std::vector<const MEDCouplingFieldDouble *>& fs, const std::vector<int>& meshRefs, const std::vector<std::vector<int> >& arrRefs) throw(INTERP_KERNEL::Exception)
+{
+ std::size_t sz=fs.size();
+ if(sz!=arrRefs.size())
+ throw INTERP_KERNEL::Exception("MEDCouplingDefinitionTime constructor : internal error ! should never happen !");
+ _slices.resize(sz);
+ for(std::size_t i=0;i<sz;i++)
+ {
+ if(arrRefs.empty())
+ throw INTERP_KERNEL::Exception("MEDCouplingDefinitionTime constructor : A field is null in list impossible to build a time definition !");
+ _slices[i]=MEDCouplingDefinitionTimeSlice::New(fs[i],meshRefs[i],arrRefs[i],i);
+ }
+ if(sz<=1)
+ return ;
+ const MEDCouplingDefinitionTimeSlice *ref=_slices[0];
+ _eps=fs[0]->getTimeTolerance();
+ for(std::size_t i=1;i<sz;i++)
+ {
+ if(!ref->isAfterMe(_slices[i],_eps))
+ throw INTERP_KERNEL::Exception("MEDCouplingDefinitionTime constructors : the sequences of fields does NOT defines a stricly ascendant monotonic time sequence !");
+ // double t1=ref->getEndTime();
+ // double t2=_slices[i]->getStartTime();
+ // if(fabs(t1-t2)<_eps)
+ // if(ref->getEndId() != _slices[i]->getStartId())
+ // throw INTERP_KERNEL::Exception("MEDCouplingDefinitionTime constructor : 2 slices refers to the same time and underlying arrays differs !");
+ ref=_slices[i];
+ }
+}
+
+void MEDCouplingDefinitionTime::assign(const MEDCouplingDefinitionTime& other)
+{
+ std::size_t sz=other._slices.size();
+ _slices.resize(sz);
+ for(std::size_t i=0;i<sz;i++)
+ _slices[i]=other._slices[i]->copy();
+}
+
+bool MEDCouplingDefinitionTime::isEqual(const MEDCouplingDefinitionTime& other) const
+{
+ std::size_t sz=_slices.size();
+ if(sz!=other._slices.size())
+ return false;
+ for(std::size_t i=0;i<sz;i++)
+ if(!_slices[i]->isEqual(*other._slices[i],_eps))
+ return false;
+ return true;
+}
+
+void MEDCouplingDefinitionTime::getIdsOnTimeRight(double tm, int& meshId, int& arrId, int& arrIdInField, int& fieldId) const throw(INTERP_KERNEL::Exception)
+{
+ std::vector<int> meshIds;
+ std::vector<int> arrIds;
+ std::vector<int> arrIdsInField;
+ std::vector<int> fieldIds;
+ getIdsOnTime(tm,meshIds,arrIds,arrIdsInField,fieldIds);
+ meshId=meshIds.back();
+ arrId=arrIds.back();
+ arrIdInField=arrIdsInField.back();
+ fieldId=fieldIds.back();
+}
+
+void MEDCouplingDefinitionTime::getIdsOnTimeLeft(double tm, int& meshId, int& arrId, int& arrIdInField, int& fieldId) const throw(INTERP_KERNEL::Exception)
+{
+ std::vector<int> meshIds;
+ std::vector<int> arrIds;
+ std::vector<int> arrIdsInField;
+ std::vector<int> fieldIds;
+ getIdsOnTime(tm,meshIds,arrIds,arrIdsInField,fieldIds);
+ meshId=meshIds.front();
+ arrId=arrIds.front();
+ arrIdInField=arrIdsInField.front();
+ fieldId=fieldIds.front();
+}
+
+void MEDCouplingDefinitionTime::getIdsOnTime(double tm, std::vector<int>& meshIds, std::vector<int>& arrIds, std::vector<int>& arrIdsInField, std::vector<int>& fieldIds) const throw(INTERP_KERNEL::Exception)
+{
+ std::vector<int> ids;
+ int id=0;
+ for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDCouplingDefinitionTimeSlice> >::const_iterator it=_slices.begin();it!=_slices.end();it++,id++)
+ if((*it)->isContaining(tm,_eps))
+ ids.push_back(id);
+ if(ids.empty())
+ throw INTERP_KERNEL::Exception("MEDCouplingDefinitionTime::getIdsOnTime : No matching slice for such time !");
+ int sz=ids.size();
+ if(sz>2)
+ throw INTERP_KERNEL::Exception("MEDCouplingDefinitionTime::getIdsOnTime : Too many slices match this time !");
+ //
+ meshIds.resize(sz);
+ arrIds.resize(sz);
+ arrIdsInField.resize(sz);
+ fieldIds.resize(sz);
+ for(int i=0;i<sz;i++)
+ _slices[ids[i]]->getIdsOnTime(tm,_eps,meshIds[i],arrIds[i],arrIdsInField[i],fieldIds[i]);
+}
+
+std::vector<double> MEDCouplingDefinitionTime::getHotSpotsTime() const
+{
+ std::vector<double> ret;
+ for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDCouplingDefinitionTimeSlice> >::const_iterator it=_slices.begin();it!=_slices.end();it++)
+ {
+ std::vector<double> tmp;
+ (*it)->getHotSpotsTime(tmp);
+ if(!ret.empty())
+ {
+ if(fabs(ret.back()-tmp.front())>_eps)
+ ret.insert(ret.end(),tmp.begin(),tmp.end());
+ else
+ ret.insert(ret.end(),tmp.begin()+1,tmp.end());
+ }
+ else
+ ret.insert(ret.end(),tmp.begin(),tmp.end());
+ }
+ return ret;
+}
+
+void MEDCouplingDefinitionTime::appendRepr(std::ostream& stream) const
+{
+ stream << "Time definition :\n";
+ for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDCouplingDefinitionTimeSlice> >::const_iterator it=_slices.begin();it!=_slices.end();it++)
+ {
+ stream << " - ";
+ (*it)->appendRepr(stream);
+ stream << std::endl;
+ }
+}
+
+void MEDCouplingDefinitionTime::getTinySerializationInformation(std::vector<int>& tinyInfoI, std::vector<double>& tinyInfoD) const
+{
+ int sz=_slices.size();
+ tinyInfoD.resize(1);
+ tinyInfoD[0]=_eps;
+ tinyInfoI.resize(3*sz+2);
+ tinyInfoI[0]=sz;
+ std::vector<int> coreData;
+ for(int i=0;i<sz;i++)
+ {
+ std::vector<int> tmp1;
+ std::vector<double> tmp2;
+ tinyInfoI[i+2]=(int)_slices[i]->getTimeType();
+ _slices[i]->getTinySerializationInformation(tmp1,tmp2);
+ tinyInfoI[i+sz+2]=tmp1.size();
+ tinyInfoI[i+2*sz+2]=tmp2.size();
+ coreData.insert(coreData.end(),tmp1.begin(),tmp1.end());
+ tinyInfoD.insert(tinyInfoD.end(),tmp2.begin(),tmp2.end());
+ }
+ tinyInfoI[1]=coreData.size();
+ tinyInfoI.insert(tinyInfoI.end(),coreData.begin(),coreData.end());
+}
+
+void MEDCouplingDefinitionTime::unserialize(const std::vector<int>& tinyInfoI, const std::vector<double>& tinyInfoD)
+{
+ int sz=tinyInfoI[0];
+ _slices.resize(sz);
+ _eps=tinyInfoD[0];
+ int offset1=0;
+ int offset2=1;
+ for(int i=0;i<sz;i++)
+ {
+ TypeOfTimeDiscretization ty=(TypeOfTimeDiscretization) tinyInfoI[i+2];
+ int sz1=tinyInfoI[i+sz+2];
+ int sz2=tinyInfoI[i+2*sz+2];
+ std::vector<int> tmp1(tinyInfoI.begin()+3*sz+2+offset1,tinyInfoI.begin()+3*sz+2+offset1+sz1);
+ std::vector<double> tmp2(tinyInfoD.begin()+offset2,tinyInfoD.begin()+offset2+sz2);
+ MEDCouplingDefinitionTimeSlice *pt=MEDCouplingDefinitionTimeSlice::New(ty,tmp1,tmp2);
+ _slices[i]=pt;
+ offset1+=sz1;
+ offset2+=sz2;
+ }
+}
+
--- /dev/null
+// Copyright (C) 2007-2010 CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#ifndef __PARAMEDMEM_MEDCOUPLINGDEFINITIONTIME_HXX__
+#define __PARAMEDMEM_MEDCOUPLINGDEFINITIONTIME_HXX__
+
+#include "MEDCouplingRefCountObject.hxx"
+#include "MEDCouplingAutoRefCountObjectPtr.hxx"
+
+#include "InterpKernelException.hxx"
+
+#include <vector>
+#include <sstream>
+
+namespace ParaMEDMEM
+{
+ class MEDCouplingFieldDouble;
+
+ class MEDCouplingDefinitionTimeSlice : public RefCountObject
+ {
+ public:
+ static MEDCouplingDefinitionTimeSlice *New(const MEDCouplingFieldDouble *f, int meshId, const std::vector<int>& arrId, int fieldId) throw(INTERP_KERNEL::Exception);
+ static MEDCouplingDefinitionTimeSlice *New(TypeOfTimeDiscretization type, const std::vector<int>& tiI, const std::vector<double>& tiD) throw(INTERP_KERNEL::Exception);
+ int getArrayId() const { return _array_id; }
+ virtual MEDCouplingDefinitionTimeSlice *copy() const = 0;
+ virtual bool isEqual(const MEDCouplingDefinitionTimeSlice& other, double eps) const;
+ virtual void getHotSpotsTime(std::vector<double>& ret) const = 0;
+ virtual void getIdsOnTime(double tm, double eps, int& meshId, int& arrId, int& arrIdInField, int& fieldId) const throw(INTERP_KERNEL::Exception) = 0;
+ virtual bool isContaining(double tmp, double eps) const = 0;
+ virtual int getStartId() const;
+ virtual int getEndId() const;
+ virtual void appendRepr(std::ostream& stream) const;
+ virtual double getStartTime() const = 0;
+ virtual double getEndTime() const = 0;
+ virtual void getTinySerializationInformation(std::vector<int>& tiI, std::vector<double>& tiD) const = 0;
+ virtual TypeOfTimeDiscretization getTimeType() const = 0;
+ bool isFullyIncludedInMe(const MEDCouplingDefinitionTimeSlice *other, double eps) const;
+ bool isOverllapingWithMe(const MEDCouplingDefinitionTimeSlice *other, double eps) const;
+ bool isAfterMe(const MEDCouplingDefinitionTimeSlice *other, double eps) const;
+ bool isBeforeMe(const MEDCouplingDefinitionTimeSlice *other, double eps) const;
+ protected:
+ MEDCouplingDefinitionTimeSlice() { }
+ MEDCouplingDefinitionTimeSlice(const MEDCouplingFieldDouble *f, int meshId, int arrId, int fieldId) throw(INTERP_KERNEL::Exception);
+ protected:
+ int _mesh_id;
+ int _array_id;
+ int _field_id;
+ };
+
+ class MEDCouplingDefinitionTimeSliceInst : public MEDCouplingDefinitionTimeSlice
+ {
+ public:
+ static MEDCouplingDefinitionTimeSliceInst *New(const std::vector<int>& tiI, const std::vector<double>& tiD);
+ MEDCouplingDefinitionTimeSlice *copy() const;
+ bool isEqual(const MEDCouplingDefinitionTimeSlice& other, double eps) const;
+ void getHotSpotsTime(std::vector<double>& ret) const;
+ void getIdsOnTime(double tm, double eps, int& meshId, int& arrId, int& arrIdInField, int& fieldId) const throw(INTERP_KERNEL::Exception);
+ bool isContaining(double tmp, double eps) const;
+ void appendRepr(std::ostream& stream) const;
+ double getStartTime() const;
+ double getEndTime() const;
+ void getTinySerializationInformation(std::vector<int>& tiI, std::vector<double>& tiD) const;
+ void unserialize(const std::vector<int>& tiI, const std::vector<double>& tiD);
+ TypeOfTimeDiscretization getTimeType() const;
+ public:
+ MEDCouplingDefinitionTimeSliceInst(const MEDCouplingFieldDouble *f, int meshId, int arrId, int fieldId) throw(INTERP_KERNEL::Exception);
+ protected:
+ MEDCouplingDefinitionTimeSliceInst() { }
+ protected:
+ double _instant;
+ };
+
+ class MEDCouplingDefinitionTimeSliceCstOnTI : public MEDCouplingDefinitionTimeSlice
+ {
+ public:
+ static MEDCouplingDefinitionTimeSliceCstOnTI *New(const std::vector<int>& tiI, const std::vector<double>& tiD);
+ MEDCouplingDefinitionTimeSlice *copy() const;
+ bool isEqual(const MEDCouplingDefinitionTimeSlice& other, double eps) const;
+ void getHotSpotsTime(std::vector<double>& ret) const;
+ void getIdsOnTime(double tm, double eps, int& meshId, int& arrId, int& arrIdInField, int& fieldId) const throw(INTERP_KERNEL::Exception);
+ bool isContaining(double tmp, double eps) const;
+ void appendRepr(std::ostream& stream) const;
+ double getStartTime() const;
+ double getEndTime() const;
+ void getTinySerializationInformation(std::vector<int>& tiI, std::vector<double>& tiD) const;
+ void unserialize(const std::vector<int>& tiI, const std::vector<double>& tiD);
+ TypeOfTimeDiscretization getTimeType() const;
+ public:
+ MEDCouplingDefinitionTimeSliceCstOnTI(const MEDCouplingFieldDouble *f, int meshId, int arrId, int fieldId) throw(INTERP_KERNEL::Exception);
+ protected:
+ MEDCouplingDefinitionTimeSliceCstOnTI() { }
+ protected:
+ double _start;
+ double _end;
+ };
+
+ class MEDCouplingDefinitionTimeSliceLT : public MEDCouplingDefinitionTimeSlice
+ {
+ public:
+ static MEDCouplingDefinitionTimeSliceLT *New(const std::vector<int>& tiI, const std::vector<double>& tiD);
+ MEDCouplingDefinitionTimeSlice *copy() const;
+ bool isEqual(const MEDCouplingDefinitionTimeSlice& other, double eps) const;
+ void getHotSpotsTime(std::vector<double>& ret) const;
+ void getIdsOnTime(double tm, double eps, int& meshId, int& arrId, int& arrIdInField, int& fieldId) const throw(INTERP_KERNEL::Exception);
+ bool isContaining(double tmp, double eps) const;
+ void appendRepr(std::ostream& stream) const;
+ double getStartTime() const;
+ double getEndTime() const;
+ int getEndId() const;
+ void getTinySerializationInformation(std::vector<int>& tiI, std::vector<double>& tiD) const;
+ void unserialize(const std::vector<int>& tiI, const std::vector<double>& tiD);
+ TypeOfTimeDiscretization getTimeType() const;
+ public:
+ MEDCouplingDefinitionTimeSliceLT(const MEDCouplingFieldDouble *f, int meshId, int arrId, int arr2Id, int fieldId) throw(INTERP_KERNEL::Exception);
+ protected:
+ MEDCouplingDefinitionTimeSliceLT() { }
+ protected:
+ int _array_id_end;
+ double _start;
+ double _end;
+ };
+
+ class MEDCouplingDefinitionTime
+ {
+ public:
+ MEDCouplingDefinitionTime();
+ MEDCouplingDefinitionTime(const std::vector<const MEDCouplingFieldDouble *>& fs, const std::vector<int>& meshRefs, const std::vector<std::vector<int> >& arrRefs) throw(INTERP_KERNEL::Exception);
+ void assign(const MEDCouplingDefinitionTime& other);
+ bool isEqual(const MEDCouplingDefinitionTime& other) const;
+ double getTimeResolution() const { return _eps; }
+ void getIdsOnTimeRight(double tm, int& meshId, int& arrId, int& arrIdInField, int& fieldId) const throw(INTERP_KERNEL::Exception);
+ void getIdsOnTimeLeft(double tm, int& meshId, int& arrId, int& arrIdInField, int& fieldId) const throw(INTERP_KERNEL::Exception);
+ void getIdsOnTime(double tm, std::vector<int>& meshIds, std::vector<int>& arrIds, std::vector<int>& arrIdsInField, std::vector<int>& fieldIds) const throw(INTERP_KERNEL::Exception);
+ std::vector<double> getHotSpotsTime() const;
+ void appendRepr(std::ostream& stream) const;
+ public:
+ void getTinySerializationInformation(std::vector<int>& tinyInfoI, std::vector<double>& tinyInfoD) const;
+ void unserialize(const std::vector<int>& tinyInfoI, const std::vector<double>& tinyInfoD);
+ private:
+ double _eps;
+ std::vector< MEDCouplingAutoRefCountObjectPtr<MEDCouplingDefinitionTimeSlice> > _slices;
+ static const double EPS_DFT;
+ };
+}
+
+#endif
{
_mesh2D=other._mesh2D->clone(true);
_mesh1D=other._mesh1D->clone(true);
- _mesh3D_ids=other._mesh3D_ids->deepCopy();
+ _mesh3D_ids=other._mesh3D_ids->deepCpy();
}
else
{
{
std::ostringstream ret;
ret << "3D Extruded mesh from a 2D Surf Mesh with name : \"" << getName() << "\"\n";
+ ret << "Description of mesh : \"" << getDescription() << "\"\n";
+ int tmpp1,tmpp2;
+ double tt=getTime(tmpp1,tmpp2);
+ ret << "Time attached to the mesh [unit] : " << tt << " [" << getTimeUnit() << "]\n";
+ ret << "Iteration : " << tmpp1 << " Order : " << tmpp2 << "\n";
ret << "Cell id where 1D mesh has been deduced : " << _cell_2D_id << "\n";
ret << "Number of cells : " << getNumberOfCells() << "(" << _mesh2D->getNumberOfCells() << "x" << _mesh1D->getNumberOfCells() << ")\n";
ret << "1D Mesh info : _____________________\n\n\n";
{
std::ostringstream ret;
ret << "3D Extruded mesh from a 2D Surf Mesh with name : \"" << getName() << "\"\n";
+ ret << "Description of mesh : \"" << getDescription() << "\"\n";
+ int tmpp1,tmpp2;
+ double tt=getTime(tmpp1,tmpp2);
+ ret << "Time attached to the mesh (unit) : " << tt << " (" << getTimeUnit() << ")\n";
+ ret << "Iteration : " << tmpp1 << " Order : " << tmpp2 << "\n";
ret << "Cell id where 1D mesh has been deduced : " << _cell_2D_id << "\n";
ret << "Number of cells : " << getNumberOfCells() << "(" << _mesh2D->getNumberOfCells() << "x" << _mesh1D->getNumberOfCells() << ")\n";
ret << "1D Mesh info : _____________________\n\n\n";
{
}
+void MEDCouplingExtrudedMesh::checkCoherency1(double eps) const throw(INTERP_KERNEL::Exception)
+{
+ checkCoherency();
+}
+
+void MEDCouplingExtrudedMesh::checkCoherency2(double eps) const throw(INTERP_KERNEL::Exception)
+{
+ checkCoherency1(eps);
+}
+
void MEDCouplingExtrudedMesh::getBoundingBox(double *bbox) const
{
double bbox2D[6];
bbox[2*id+1]+=tmp[id];
}
-void MEDCouplingExtrudedMesh::updateTime()
+void MEDCouplingExtrudedMesh::updateTime() const
{
if(_mesh2D)
{
MEDCouplingUMesh *MEDCouplingExtrudedMesh::build3DUnstructuredMesh() const
{
- MEDCouplingUMesh *ret=_mesh2D->buildExtrudedMeshFromThis(_mesh1D,0);
+ MEDCouplingUMesh *ret=_mesh2D->buildExtrudedMesh(_mesh1D,0);
const int *renum=_mesh3D_ids->getConstPointer();
ret->renumberCells(renum,false);
ret->setName(getName());
return ret;
}
+MEDCouplingUMesh *MEDCouplingExtrudedMesh::buildUnstructured() const throw(INTERP_KERNEL::Exception)
+{
+ return build3DUnstructuredMesh();
+}
+
MEDCouplingFieldDouble *MEDCouplingExtrudedMesh::getMeasureField(bool) const
{
std::string name="MeasureOfMesh_";
int MEDCouplingExtrudedMesh::getCellContainingPoint(const double *pos, double eps) const
{
- //not implemented yet
- return -1;
+ throw INTERP_KERNEL::Exception("MEDCouplingExtrudedMesh::getCellContainingPoint : not implemented yet !");
}
MEDCouplingExtrudedMesh::~MEDCouplingExtrudedMesh()
std::transform(zoneToUpdate,zoneToUpdate+3,zoneToUpdate,std::bind2nd(std::multiplies<double>(),(double)(1./nodalConnec.size())));
}
-int MEDCouplingExtrudedMesh::findCorrespCellByNodalConn(const std::vector<int>& nodalConnec, const int *revNodalPtr, const int *revNodalIndxPtr) throw(INTERP_KERNEL::Exception)
+int MEDCouplingExtrudedMesh::FindCorrespCellByNodalConn(const std::vector<int>& nodalConnec, const int *revNodalPtr, const int *revNodalIndxPtr) throw(INTERP_KERNEL::Exception)
{
std::vector<int>::const_iterator iter=nodalConnec.begin();
std::set<int> s1(revNodalPtr+revNodalIndxPtr[*iter],revNodalPtr+revNodalIndxPtr[*iter+1]);
* @param v is the output normalized vector of the common direction of 'm1' and 'm2'
* @throw in case that m1 and m2 are not compatible each other.
*/
-void MEDCouplingExtrudedMesh::project1DMeshes(const MEDCouplingUMesh *m1, const MEDCouplingUMesh *m2, double eps,
+void MEDCouplingExtrudedMesh::Project1DMeshes(const MEDCouplingUMesh *m1, const MEDCouplingUMesh *m2, double eps,
MEDCouplingUMesh *&m1r, MEDCouplingUMesh *&m2r, double *v) throw(INTERP_KERNEL::Exception)
{
if(m1->getSpaceDimension()!=3 || m1->getSpaceDimension()!=3)
- throw INTERP_KERNEL::Exception("Input meshes are expected to have a spaceDim==3 for projec1D !");
+ throw INTERP_KERNEL::Exception("Input meshes are expected to have a spaceDim==3 for Projec1D !");
m1r=m1->clone(true);
m2r=m2->clone(true);
m1r->changeSpaceDimension(1);
_mesh1D->scale(point,factor);
}
+DataArrayInt *MEDCouplingExtrudedMesh::checkTypeConsistencyAndContig(const std::vector<int>& code, const std::vector<const DataArrayInt *>& idsPerType) const throw(INTERP_KERNEL::Exception)
+{
+ throw INTERP_KERNEL::Exception("Not implemented yet !");
+}
+
MEDCouplingMesh *MEDCouplingExtrudedMesh::buildPart(const int *start, const int *end) const
{
// not implemented yet !
std::vector<int> nodalConnec(nodal2D+nodal2DIndx[i]+1,nodal2D+nodal2DIndx[i+1]);
try
{
- idInSubMesh=findCorrespCellByNodalConn(nodalConnec,revNodal2DPtr,revNodalIndx2DPtr);
+ idInSubMesh=FindCorrespCellByNodalConn(nodalConnec,revNodal2DPtr,revNodalIndx2DPtr);
}
catch(INTERP_KERNEL::Exception& e)
{
revDescIndx->decrRef();
}
-void MEDCouplingExtrudedMesh::getTinySerializationInformation(std::vector<int>& tinyInfo, std::vector<std::string>& littleStrings) const
+void MEDCouplingExtrudedMesh::getTinySerializationInformation(std::vector<double>& tinyInfoD, std::vector<int>& tinyInfo, std::vector<std::string>& littleStrings) const
{
std::vector<int> tinyInfo1;
std::vector<std::string> ls1;
- _mesh2D->getTinySerializationInformation(tinyInfo1,ls1);
+ std::vector<double> ls3;
+ _mesh2D->getTinySerializationInformation(ls3,tinyInfo1,ls1);
std::vector<int> tinyInfo2;
std::vector<std::string> ls2;
- _mesh1D->getTinySerializationInformation(tinyInfo2,ls2);
+ std::vector<double> ls4;
+ _mesh1D->getTinySerializationInformation(ls4,tinyInfo2,ls2);
tinyInfo.clear(); littleStrings.clear();
tinyInfo.insert(tinyInfo.end(),tinyInfo1.begin(),tinyInfo1.end());
littleStrings.insert(littleStrings.end(),ls1.begin(),ls1.end());
tinyInfo.push_back(tinyInfo1.size());
tinyInfo.push_back(_mesh3D_ids->getNbOfElems());
littleStrings.push_back(getName());
+ littleStrings.push_back(getDescription());
}
void MEDCouplingExtrudedMesh::resizeForUnserialization(const std::vector<int>& tinyInfo, DataArrayInt *a1, DataArrayDouble *a2, std::vector<std::string>& littleStrings) const
//
a1->alloc(la1+tinyInfo[sz-1],1);
a2->alloc(la2,1);
- littleStrings.resize(ls1.size()+ls2.size()+1);
+ littleStrings.resize(ls1.size()+ls2.size()+2);
}
void MEDCouplingExtrudedMesh::serialize(DataArrayInt *&a1, DataArrayDouble *&a2) const
a2_2->decrRef();
}
-void MEDCouplingExtrudedMesh::unserialization(const std::vector<int>& tinyInfo, const DataArrayInt *a1, DataArrayDouble *a2, const std::vector<std::string>& littleStrings)
+void MEDCouplingExtrudedMesh::unserialization(const std::vector<double>& tinyInfoD, const std::vector<int>& tinyInfo, const DataArrayInt *a1, DataArrayDouble *a2, const std::vector<std::string>& littleStrings)
{
- setName(littleStrings.back().c_str());
+ setName(littleStrings[littleStrings.size()-2].c_str());
+ setDescription(littleStrings.back().c_str());
int sz=tinyInfo.size();
int sz1=tinyInfo[sz-2];
_cell_2D_id=tinyInfo[sz-3];
a2Ptr+=a2tmp->getNbOfElems();
a1Ptr+=a1tmp->getNbOfElems();
ls2.insert(ls2.end(),littleStrings.begin(),littleStrings.begin()+ls1.size());
- _mesh2D->unserialization(ti1,a1tmp,a2tmp,ls2);
+ std::vector<double> d1(1);
+ _mesh2D->unserialization(d1,ti1,a1tmp,a2tmp,ls2);
a1tmp->decrRef(); a2tmp->decrRef();
//
ls2.clear();
- ls2.insert(ls2.end(),littleStrings.begin()+ls1.size(),littleStrings.end()-1);
+ ls2.insert(ls2.end(),littleStrings.begin()+ls1.size(),littleStrings.end()-2);
_mesh1D=MEDCouplingUMesh::New();
a1tmp=DataArrayInt::New(); a2tmp=DataArrayDouble::New();
_mesh1D->resizeForUnserialization(ti2,a1tmp,a2tmp,ls1);
std::copy(a2Ptr,a2Ptr+a2tmp->getNbOfElems(),a2tmp->getPointer());
std::copy(a1Ptr,a1Ptr+a1tmp->getNbOfElems(),a1tmp->getPointer());
a1Ptr+=a1tmp->getNbOfElems();
- _mesh1D->unserialization(ti2,a1tmp,a2tmp,ls2);
+ _mesh1D->unserialization(d1,ti2,a1tmp,a2tmp,ls2);
a1tmp->decrRef(); a2tmp->decrRef();
//
_mesh3D_ids=DataArrayInt::New();
std::string simpleRepr() const;
std::string advancedRepr() const;
void checkCoherency() const throw (INTERP_KERNEL::Exception);
+ void checkCoherency1(double eps=1e-12) const throw(INTERP_KERNEL::Exception);
+ void checkCoherency2(double eps=1e-12) const throw(INTERP_KERNEL::Exception);
void getBoundingBox(double *bbox) const;
- void updateTime();
+ void updateTime() const;
void renumberCells(const int *old2NewBg, bool check) throw(INTERP_KERNEL::Exception);
MEDCouplingUMesh *getMesh2D() const { return _mesh2D; }
MEDCouplingUMesh *getMesh1D() const { return _mesh1D; }
DataArrayInt *getMesh3DIds() const { return _mesh3D_ids; }
MEDCouplingUMesh *build3DUnstructuredMesh() const;
+ MEDCouplingUMesh *buildUnstructured() const throw(INTERP_KERNEL::Exception);
MEDCouplingFieldDouble *getMeasureField(bool) const;
MEDCouplingFieldDouble *getMeasureFieldOnNode(bool) const;
MEDCouplingFieldDouble *buildOrthogonalField() const;
int getCellContainingPoint(const double *pos, double eps) const;
- static int findCorrespCellByNodalConn(const std::vector<int>& nodalConnec,
+ static int FindCorrespCellByNodalConn(const std::vector<int>& nodalConnec,
const int *revNodalPtr, const int *revNodalIndxPtr) throw(INTERP_KERNEL::Exception);
- static void project1DMeshes(const MEDCouplingUMesh *m1, const MEDCouplingUMesh *m2, double eps,
+ static void Project1DMeshes(const MEDCouplingUMesh *m1, const MEDCouplingUMesh *m2, double eps,
MEDCouplingUMesh *&m1r, MEDCouplingUMesh *&m2r, double *v) throw(INTERP_KERNEL::Exception);
void rotate(const double *center, const double *vector, double angle);
void translate(const double *vector);
void scale(const double *point, double factor);
+ DataArrayInt *checkTypeConsistencyAndContig(const std::vector<int>& code, const std::vector<const DataArrayInt *>& idsPerType) const throw(INTERP_KERNEL::Exception);
MEDCouplingMesh *buildPart(const int *start, const int *end) const;
MEDCouplingMesh *buildPartAndReduceNodes(const int *start, const int *end, DataArrayInt*& arr) const;
DataArrayInt *simplexize(int policy) throw(INTERP_KERNEL::Exception);
DataArrayDouble *getCoordinatesAndOwner() const;
DataArrayDouble *getBarycenterAndOwner() const;
//Serialization unserialisation
- void getTinySerializationInformation(std::vector<int>& tinyInfo, std::vector<std::string>& littleStrings) const;
+ void getTinySerializationInformation(std::vector<double>& tinyInfoD, std::vector<int>& tinyInfo, std::vector<std::string>& littleStrings) const;
void resizeForUnserialization(const std::vector<int>& tinyInfo, DataArrayInt *a1, DataArrayDouble *a2, std::vector<std::string>& littleStrings) const;
void serialize(DataArrayInt *&a1, DataArrayDouble *&a2) const;
- void unserialization(const std::vector<int>& tinyInfo, const DataArrayInt *a1, DataArrayDouble *a2,
+ void unserialization(const std::vector<double>& tinyInfoD, const std::vector<int>& tinyInfo, const DataArrayInt *a1, DataArrayDouble *a2,
const std::vector<std::string>& littleStrings);
private:
MEDCouplingExtrudedMesh(const MEDCouplingUMesh *mesh3D, MEDCouplingUMesh *mesh2D, int cell2DId) throw(INTERP_KERNEL::Exception);
return false;
if(_desc!=other->_desc)
return false;
+ if(_nature!=other->_nature)
+ return false;
if(!_type->isEqual(other->_type,valsPrec))
return false;
if(_mesh==0 && other->_mesh==0)
{
if(!_type->isEqualWithoutConsideringStr(other->_type,valsPrec))
return false;
+ if(_nature!=other->_nature)
+ return false;
if(_mesh==0 && other->_mesh==0)
return true;
if(_mesh==0 || other->_mesh==0)
{
if(!_type->isEqual(other->_type,1.))
return false;
+ if(_nature!=other->_nature)
+ return false;
if(_mesh==other->_mesh)
return true;
return _mesh->areCompatibleForMerge(other->_mesh);
{
if(!_type->isEqual(other->_type,1.e-12))
return false;
+ if(_nature!=other->_nature)
+ return false;
return _mesh==other->_mesh;
}
-void MEDCouplingField::updateTime()
+void MEDCouplingField::updateTime() const
{
if(_mesh)
updateTimeWith(*_mesh);
return _type->getEnum();
}
+void MEDCouplingField::setNature(NatureOfField nat) throw(INTERP_KERNEL::Exception)
+{
+ _nature=nat;
+}
+
+/*!
+ * This method returns is case of success an instance of DataArrayDouble the user is in reponsability to deal with.
+ * If 'this->_mesh' is not set an exception will be thrown.
+ * For a field on node the array of coords will be returned. For a field on cell a ParaMEDMEM::DataArrayDouble instance
+ * containing the barycenter of cells will be returned. And for a field on gauss point the explicit position of gauss points.
+ */
+DataArrayDouble *MEDCouplingField::getLocalizationOfDiscr() const throw(INTERP_KERNEL::Exception)
+{
+ if(!_mesh)
+ throw INTERP_KERNEL::Exception("MEDCouplingField::getLocalizationOfDiscr : No mesh set !");
+ return _type->getLocalizationOfDiscValues(_mesh);
+}
+
/*!
* This method retrieves the measure field of 'this'. If no '_mesh' is defined an exception will be thrown.
* Warning the retrieved field life cycle is the responsability of caller.
delete _type;
}
-MEDCouplingField::MEDCouplingField(MEDCouplingFieldDiscretization *type):_mesh(0),_type(type)
+MEDCouplingField::MEDCouplingField(MEDCouplingFieldDiscretization *type, NatureOfField nature):_nature(nature),_mesh(0),_type(type)
{
}
-MEDCouplingField::MEDCouplingField(TypeOfField type):_mesh(0),_type(MEDCouplingFieldDiscretization::New(type))
+MEDCouplingField::MEDCouplingField(TypeOfField type):_nature(NoNature),_mesh(0),_type(MEDCouplingFieldDiscretization::New(type))
{
}
-MEDCouplingField::MEDCouplingField(const MEDCouplingField& other):_name(other._name),_desc(other._desc),
+MEDCouplingField::MEDCouplingField(const MEDCouplingField& other):_name(other._name),_desc(other._desc),_nature(other._nature),
_mesh(0),_type(other._type->clone())
{
if(other._mesh)
{
return _type->buildSubMeshData(_mesh,start,end,di);
}
+
+/*!
+ * This method returns number of tuples expected regarding its discretization and its _mesh attribute.
+ * This method expected a not null _mesh instance. If null, an exception will be thrown.
+ */
+int MEDCouplingField::getNumberOfTuplesExpected() const throw(INTERP_KERNEL::Exception)
+{
+ if(_mesh)
+ return _type->getNumberOfTuples(_mesh);
+ else
+ throw INTERP_KERNEL::Exception("MEDCouplingField::getNumberOfTuplesExpected : Empty mesh !");
+}
#include "MEDCoupling.hxx"
#include "MEDCouplingTimeLabel.hxx"
+#include "MEDCouplingNatureOfField.hxx"
#include "MEDCouplingRefCountObject.hxx"
#include "NormalizedUnstructuredMesh.hxx"
#include "InterpKernelException.hxx"
namespace ParaMEDMEM
{
class DataArrayInt;
+ class DataArrayDouble;
class MEDCouplingMesh;
class MEDCouplingFieldDouble;
class MEDCouplingFieldDiscretization;
void setDescription(const char *desc) { _desc=desc; }
const char *getName() const { return _name.c_str(); }
TypeOfField getTypeOfField() const;
+ NatureOfField getNature() const { return _nature; }
+ virtual void setNature(NatureOfField nat) throw(INTERP_KERNEL::Exception);
+ DataArrayDouble *getLocalizationOfDiscr() const throw(INTERP_KERNEL::Exception);
MEDCouplingFieldDouble *buildMeasureField(bool isAbs) const throw(INTERP_KERNEL::Exception);
MEDCouplingMesh *buildSubMeshData(const int *start, const int *end, DataArrayInt *&di) const;
MEDCouplingFieldDiscretization *getDiscretization() const { return _type; }
+ int getNumberOfTuplesExpected() const throw(INTERP_KERNEL::Exception);
// Gauss point specific methods
void setGaussLocalizationOnType(INTERP_KERNEL::NormalizedCellType type, const std::vector<double>& refCoo,
const std::vector<double>& gsCoo, const std::vector<double>& wg) throw(INTERP_KERNEL::Exception);
void getCellIdsHavingGaussLocalization(int locId, std::vector<int>& cellIds) const throw(INTERP_KERNEL::Exception);
const MEDCouplingGaussLocalization& getGaussLocalization(int locId) const throw(INTERP_KERNEL::Exception);
protected:
- void updateTime();
+ void updateTime() const;
protected:
MEDCouplingField(TypeOfField type);
MEDCouplingField(const MEDCouplingField& other);
- MEDCouplingField(MEDCouplingFieldDiscretization *type);
+ MEDCouplingField(MEDCouplingFieldDiscretization *type, NatureOfField nature=NoNature);
virtual ~MEDCouplingField();
protected:
std::string _name;
std::string _desc;
+ NatureOfField _nature;
const MEDCouplingMesh *_mesh;
MEDCouplingFieldDiscretization *_type;
};
#include "MEDCouplingFieldDiscretization.hxx"
#include "MEDCouplingCMesh.hxx"
+#include "MEDCouplingUMesh.hxx"
#include "MEDCouplingFieldDouble.hxx"
-#include "CellModel.hxx"
+#include "MEDCouplingAutoRefCountObjectPtr.hxx"
+#include "CellModel.hxx"
#include "InterpolationUtils.hxx"
+#include "InterpKernelAutoPtr.hxx"
+#include "InterpKernelGaussCoords.hxx"
#include <set>
+#include <list>
#include <limits>
#include <algorithm>
#include <functional>
const TypeOfField MEDCouplingFieldDiscretizationP1::TYPE=ON_NODES;
+const int MEDCouplingFieldDiscretizationPerCell::DFT_INVALID_LOCID_VALUE=-1;
+
const char MEDCouplingFieldDiscretizationGauss::REPR[]="GAUSS";
const TypeOfField MEDCouplingFieldDiscretizationGauss::TYPE=ON_GAUSS_PT;
/*!
* Excepted for MEDCouplingFieldDiscretizationPerCell no underlying TimeLabel object : nothing to do in generally.
*/
-void MEDCouplingFieldDiscretization::updateTime()
+void MEDCouplingFieldDiscretization::updateTime() const
{
}
throw INTERP_KERNEL::Exception("Invalid method for the corresponding field discretization : available only for GaussPoint discretization !");
}
-void MEDCouplingFieldDiscretization::renumberEntitiesFromO2NArr(const int *old2NewPtr, DataArrayDouble *arr, const char *msg)
+void MEDCouplingFieldDiscretization::renumberEntitiesFromO2NArr(double eps, const int *old2NewPtr, DataArrayDouble *arr, const char *msg)
{
int oldNbOfElems=arr->getNumberOfTuples();
int nbOfComp=arr->getNumberOfComponents();
int newNbOfTuples=(*std::max_element(old2NewPtr,old2NewPtr+oldNbOfElems))+1;
- DataArrayDouble *arrCpy=arr->deepCopy();
+ DataArrayDouble *arrCpy=arr->deepCpy();
const double *ptSrc=arrCpy->getConstPointer();
arr->reAlloc(newNbOfTuples);
double *ptToFill=arr->getPointer();
std::fill(ptToFill,ptToFill+nbOfComp*newNbOfTuples,std::numeric_limits<double>::max());
+ INTERP_KERNEL::AutoPtr<double> tmp=new double[nbOfComp];
for(int i=0;i<oldNbOfElems;i++)
{
int newNb=old2NewPtr[i];
std::copy(ptSrc+i*nbOfComp,ptSrc+(i+1)*nbOfComp,ptToFill+newNb*nbOfComp);
else
{
- if(!std::equal(ptSrc+i*nbOfComp,ptSrc+(i+1)*nbOfComp,ptToFill+newNb*nbOfComp))
+ std::transform(ptSrc+i*nbOfComp,ptSrc+(i+1)*nbOfComp,ptToFill+newNb*nbOfComp,(double *)tmp,std::minus<double>());
+ std::transform((double *)tmp,((double *)tmp)+nbOfComp,(double *)tmp,std::ptr_fun<double,double>(fabs));
+ //if(!std::equal(ptSrc+i*nbOfComp,ptSrc+(i+1)*nbOfComp,ptToFill+newNb*nbOfComp))
+ if(*std::max_element((double *)tmp,((double *)tmp)+nbOfComp)>eps)
{
arrCpy->decrRef();
std::ostringstream oss;
void MEDCouplingFieldDiscretization::renumberEntitiesFromN2OArr(const int *new2OldPtr, int new2OldSz, DataArrayDouble *arr, const char *msg)
{
int nbOfComp=arr->getNumberOfComponents();
- DataArrayDouble *arrCpy=arr->deepCopy();
+ DataArrayDouble *arrCpy=arr->deepCpy();
const double *ptSrc=arrCpy->getConstPointer();
arr->reAlloc(new2OldSz);
double *ptToFill=arr->getPointer();
{
const int *array=old2NewBg;
if(check)
- array=DataArrayInt::checkAndPreparePermutation(old2NewBg,old2NewBg+mesh->getNumberOfCells());
+ array=DataArrayInt::CheckAndPreparePermutation(old2NewBg,old2NewBg+mesh->getNumberOfCells());
for(std::vector<DataArrayDouble *>::const_iterator it=arrays.begin();it!=arrays.end();it++)
{
if(*it)
arr->getTuple(id,res);
}
+DataArrayDouble *MEDCouplingFieldDiscretizationP0::getValueOnMulti(const DataArrayDouble *arr, const MEDCouplingMesh *mesh, const double *loc, int nbOfPoints) const
+{
+ std::vector<int> elts,eltsIndex;
+ mesh->getCellsContainingPoints(loc,nbOfPoints,_precision,elts,eltsIndex);
+ int spaceDim=mesh->getSpaceDimension();
+ int nbOfComponents=arr->getNumberOfComponents();
+ MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> ret=DataArrayDouble::New();
+ ret->alloc(nbOfPoints,nbOfComponents);
+ double *ptToFill=ret->getPointer();
+ for(int i=0;i<nbOfPoints;i++,ptToFill+=nbOfComponents)
+ if(eltsIndex[i+1]-eltsIndex[i]>=1)
+ arr->getTuple(elts[eltsIndex[i]],ptToFill);
+ else
+ {
+ std::ostringstream oss; oss << "Point #" << i << " with coordinates : (";
+ std::copy(loc+i*spaceDim,loc+(i+1)*spaceDim,std::ostream_iterator<double>(oss,", "));
+ oss << ") detected outside mesh : unable to apply P0::getValueOnMulti ! ";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ ret->incrRef();
+ return ret;
+}
+
/*!
* Nothing to do. It's not a bug.
*/
-void MEDCouplingFieldDiscretizationP0::renumberValuesOnNodes(const int *, DataArrayDouble *) const
+void MEDCouplingFieldDiscretizationP0::renumberValuesOnNodes(double , const int *, DataArrayDouble *) const
{
}
-void MEDCouplingFieldDiscretizationP0::renumberValuesOnCells(const MEDCouplingMesh *mesh, const int *old2New, DataArrayDouble *arr) const
+void MEDCouplingFieldDiscretizationP0::renumberValuesOnCells(double epsOnVals, const MEDCouplingMesh *mesh, const int *old2New, DataArrayDouble *arr) const
{
- renumberEntitiesFromO2NArr(old2New,arr,"Cell");
+ renumberEntitiesFromO2NArr(epsOnVals,old2New,arr,"Cell");
}
void MEDCouplingFieldDiscretizationP0::renumberValuesOnCellsR(const MEDCouplingMesh *mesh, const int *new2old, int newSz, DataArrayDouble *arr) const
INTERP_KERNEL::NormalizedCellType type=mesh->getTypeOfCell(id);
if(type!=INTERP_KERNEL::NORM_SEG2 && type!=INTERP_KERNEL::NORM_TRI3 && type!=INTERP_KERNEL::NORM_TETRA4)
throw INTERP_KERNEL::Exception("P1 getValueOn is not specified for not simplex cells !");
+ getValueInCell(mesh,id,arr,loc,res);
+}
+
+/*!
+ * This method localizes a point defined by 'loc' in a cell with id 'cellId' into mesh 'mesh'.
+ * The result is put into res expected to be of size at least arr->getNumberOfComponents()
+ */
+void MEDCouplingFieldDiscretizationP1::getValueInCell(const MEDCouplingMesh *mesh, int cellId, const DataArrayDouble *arr, const double *loc, double *res) const
+{
std::vector<int> conn;
std::vector<double> coo;
- mesh->getNodeIdsOfCell(id,conn);
+ mesh->getNodeIdsOfCell(cellId,conn);
for(std::vector<int>::const_iterator iter=conn.begin();iter!=conn.end();iter++)
mesh->getCoordinatesOfNode(*iter,coo);
int spaceDim=mesh->getSpaceDimension();
std::vector<const double *> vec(nbOfNodes);
for(int i=0;i<nbOfNodes;i++)
vec[i]=&coo[i*spaceDim];
- double *tmp=new double[nbOfNodes];
+ INTERP_KERNEL::AutoPtr<double> tmp=new double[nbOfNodes];
INTERP_KERNEL::barycentric_coords(vec,loc,tmp);
int sz=arr->getNumberOfComponents();
- double *tmp2=new double[sz];
+ INTERP_KERNEL::AutoPtr<double> tmp2=new double[sz];
std::fill(res,res+sz,0.);
for(int i=0;i<nbOfNodes;i++)
{
- arr->getTuple(conn[i],tmp2);
- std::transform(tmp2,tmp2+sz,tmp2,std::bind2nd(std::multiplies<double>(),tmp[i]));
- std::transform(res,res+sz,tmp2,res,std::plus<double>());
+ arr->getTuple(conn[i],(double *)tmp2);
+ std::transform((double *)tmp2,((double *)tmp2)+sz,(double *)tmp2,std::bind2nd(std::multiplies<double>(),tmp[i]));
+ std::transform(res,res+sz,(double *)tmp2,res,std::plus<double>());
}
- delete [] tmp;
- delete [] tmp2;
}
void MEDCouplingFieldDiscretizationP1::getValueOnPos(const DataArrayDouble *arr, const MEDCouplingMesh *mesh, int i, int j, int k, double *res) const
arr->getTuple(id,res);
}
-void MEDCouplingFieldDiscretizationP1::renumberValuesOnNodes(const int *old2NewPtr, DataArrayDouble *arr) const
+DataArrayDouble *MEDCouplingFieldDiscretizationP1::getValueOnMulti(const DataArrayDouble *arr, const MEDCouplingMesh *mesh, const double *loc, int nbOfPoints) const
+{
+ std::vector<int> elts,eltsIndex;
+ mesh->getCellsContainingPoints(loc,nbOfPoints,_precision,elts,eltsIndex);
+ int spaceDim=mesh->getSpaceDimension();
+ int nbOfComponents=arr->getNumberOfComponents();
+ MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> ret=DataArrayDouble::New();
+ ret->alloc(nbOfPoints,nbOfComponents);
+ double *ptToFill=ret->getPointer();
+ for(int i=0;i<nbOfPoints;i++)
+ if(eltsIndex[i+1]-eltsIndex[i]>=1)
+ getValueInCell(mesh,elts[eltsIndex[i]],arr,loc+i*spaceDim,ptToFill+i*nbOfComponents);
+ else
+ {
+ std::ostringstream oss; oss << "Point #" << i << " with coordinates : (";
+ std::copy(loc+i*spaceDim,loc+(i+1)*spaceDim,std::ostream_iterator<double>(oss,", "));
+ oss << ") detected outside mesh : unable to apply P1::getValueOnMulti ! ";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ ret->incrRef();
+ return ret;
+}
+
+void MEDCouplingFieldDiscretizationP1::renumberValuesOnNodes(double epsOnVals, const int *old2NewPtr, DataArrayDouble *arr) const
{
- renumberEntitiesFromO2NArr(old2NewPtr,arr,"Node");
+ renumberEntitiesFromO2NArr(epsOnVals,old2NewPtr,arr,"Node");
}
/*!
* Nothing to do it's not a bug.
*/
-void MEDCouplingFieldDiscretizationP1::renumberValuesOnCells(const MEDCouplingMesh *mesh, const int *old2New, DataArrayDouble *arr) const
+void MEDCouplingFieldDiscretizationP1::renumberValuesOnCells(double epsOnVals, const MEDCouplingMesh *mesh, const int *old2New, DataArrayDouble *arr) const
{
}
{
DataArrayInt *arr=other._discr_per_cell;
if(arr)
- _discr_per_cell=arr->deepCopy();
+ _discr_per_cell=arr->deepCpy();
}
-void MEDCouplingFieldDiscretizationPerCell::updateTime()
+void MEDCouplingFieldDiscretizationPerCell::updateTime() const
{
if(_discr_per_cell)
updateTimeWith(*_discr_per_cell);
int nbCells=_discr_per_cell->getNumberOfTuples();
const int *array=old2NewBg;
if(check)
- array=DataArrayInt::checkAndPreparePermutation(old2NewBg,old2NewBg+nbCells);
+ array=DataArrayInt::CheckAndPreparePermutation(old2NewBg,old2NewBg+nbCells);
//
DataArrayInt *dpc=_discr_per_cell->renumber(array);
_discr_per_cell->decrRef();
int nbTuples=m->getNumberOfCells();
_discr_per_cell->alloc(nbTuples,1);
int *ptr=_discr_per_cell->getPointer();
- std::fill(ptr,ptr+nbTuples,-1);
+ std::fill(ptr,ptr+nbTuples,DFT_INVALID_LOCID_VALUE);
}
}
+void MEDCouplingFieldDiscretizationPerCell::checkNoOrphanCells() const throw(INTERP_KERNEL::Exception)
+{
+ if(!_discr_per_cell)
+ throw INTERP_KERNEL::Exception("MEDCouplingFieldDiscretizationPerCell::checkNoOrphanCells : no discretization defined !");
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> test=_discr_per_cell->getIdsEqual(DFT_INVALID_LOCID_VALUE);
+ if(test->getNumberOfTuples()!=0)
+ throw INTERP_KERNEL::Exception("MEDCouplingFieldDiscretizationPerCell::checkNoOrphanCells : presence of orphan cells !");
+}
+
MEDCouplingFieldDiscretizationGauss::MEDCouplingFieldDiscretizationGauss()
{
}
{
const int *array=old2NewBg;
if(check)
- array=DataArrayInt::checkAndPreparePermutation(old2NewBg,old2NewBg+mesh->getNumberOfCells());
+ array=DataArrayInt::CheckAndPreparePermutation(old2NewBg,old2NewBg+mesh->getNumberOfCells());
int nbOfCells=_discr_per_cell->getNumberOfTuples();
int nbOfTuples=getNumberOfTuples(0);
const int *dcPtr=_discr_per_cell->getConstPointer();
DataArrayDouble *MEDCouplingFieldDiscretizationGauss::getLocalizationOfDiscValues(const MEDCouplingMesh *mesh) const
{
- throw INTERP_KERNEL::Exception("Not implemented yet !");
+ checkNoOrphanCells();
+ MEDCouplingAutoRefCountObjectPtr<MEDCouplingUMesh> umesh=mesh->buildUnstructured();//in general do nothing
+ int nbOfTuples=getNumberOfTuples(mesh);
+ DataArrayDouble *ret=DataArrayDouble::New();
+ int spaceDim=mesh->getSpaceDimension();
+ ret->alloc(nbOfTuples,spaceDim);
+ std::vector< std::vector<int> > locIds;
+ std::vector<DataArrayInt *> parts=splitIntoSingleGaussDicrPerCellType(locIds);
+ std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > parts2(parts.size());
+ std::copy(parts.begin(),parts.end(),parts2.begin());
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> offsets=buildNbOfGaussPointPerCellField();
+ offsets->computeOffsets();
+ const int *ptrOffsets=offsets->getConstPointer();
+ const double *coords=umesh->getCoords()->getConstPointer();
+ const int *connI=umesh->getNodalConnectivityIndex()->getConstPointer();
+ const int *conn=umesh->getNodalConnectivity()->getConstPointer();
+ double *valsToFill=ret->getPointer();
+ for(std::size_t i=0;i<parts2.size();i++)
+ {
+ INTERP_KERNEL::GaussCoords calculator;
+ for(std::vector<int>::const_iterator it=locIds[i].begin();it!=locIds[i].end();it++)
+ {
+ const MEDCouplingGaussLocalization& cli=_loc[*it];//curLocInfo
+ INTERP_KERNEL::NormalizedCellType typ=cli.getType();
+ const std::vector<double>& wg=cli.getWeights();
+ calculator.addGaussInfo(typ,INTERP_KERNEL::CellModel::getCellModel(typ).getDimension(),
+ &cli.getGaussCoords()[0],wg.size(),&cli.getRefCoords()[0],
+ INTERP_KERNEL::CellModel::getCellModel(typ).getNumberOfNodes());
+ }
+ int nbt=parts2[i]->getNumberOfTuples();
+ for(const int *w=parts2[i]->getConstPointer();w!=parts2[i]->getConstPointer()+nbt;w++)
+ {
+ const MEDCouplingGaussLocalization& cli=_loc[*w];
+ calculator.calculateCoords(cli.getType(),coords,spaceDim,conn+connI[*w]+1,valsToFill+spaceDim*(ptrOffsets[*w]));
+ }
+ }
+ ret->copyStringInfoFrom(*umesh->getCoords());
+ return ret;
}
void MEDCouplingFieldDiscretizationGauss::computeMeshRestrictionFromTupleIds(const MEDCouplingMesh *mesh, const int *partBg, const int *partEnd,
throw INTERP_KERNEL::Exception("getValueOnPos(i,j,k) : Not applyable for Gauss points !");
}
+DataArrayDouble *MEDCouplingFieldDiscretizationGauss::getValueOnMulti(const DataArrayDouble *arr, const MEDCouplingMesh *mesh, const double *loc, int nbOfPoints) const
+{
+ throw INTERP_KERNEL::Exception("getValueOnMulti : Not implemented yet for gauss points !");
+}
+
MEDCouplingMesh *MEDCouplingFieldDiscretizationGauss::buildSubMeshData(const MEDCouplingMesh *mesh, const int *start, const int *end, DataArrayInt *&di) const
{
throw INTERP_KERNEL::Exception("Not implemented yet !");
/*!
* No implementation needed !
*/
-void MEDCouplingFieldDiscretizationGauss::renumberValuesOnNodes(const int *, DataArrayDouble *) const
+void MEDCouplingFieldDiscretizationGauss::renumberValuesOnNodes(double , const int *, DataArrayDouble *) const
{
}
-void MEDCouplingFieldDiscretizationGauss::renumberValuesOnCells(const MEDCouplingMesh *mesh, const int *old2New, DataArrayDouble *arr) const
+void MEDCouplingFieldDiscretizationGauss::renumberValuesOnCells(double epsOnVals, const MEDCouplingMesh *mesh, const int *old2New, DataArrayDouble *arr) const
{
throw INTERP_KERNEL::Exception("Not implemented yet !");
}
void MEDCouplingFieldDiscretizationGauss::setGaussLocalizationOnType(const MEDCouplingMesh *m, INTERP_KERNEL::NormalizedCellType type, const std::vector<double>& refCoo,
const std::vector<double>& gsCoo, const std::vector<double>& wg) throw(INTERP_KERNEL::Exception)
{
+ const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::getCellModel(type);
+ if((int)cm.getDimension()!=m->getMeshDimension())
+ {
+ std::ostringstream oss; oss << "MEDCouplingFieldDiscretizationGauss::setGaussLocalizationOnType : mismatch of dimensions ! MeshDim==" << m->getMeshDimension();
+ oss << " whereas Type '" << cm.getRepr() << "' has dimension " << cm.getDimension() << " !";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
buildDiscrPerCellIfNecessary(m);
int id=_loc.size();
MEDCouplingGaussLocalization elt(type,refCoo,gsCoo,wg);
return ret;
}
+/*!
+ * This method do the assumption that there is no orphan cell. If there is an exception is thrown.
+ * This method makes the assumption too that '_discr_per_cell' is defined. If not an exception is thrown.
+ * This method returns a newly created array with number of tuples equals to '_discr_per_cell->getNumberOfTuples' and number of components equal to 1.
+ * The i_th tuple in returned array is the number of gauss point if the corresponding cell.
+ */
+DataArrayInt *MEDCouplingFieldDiscretizationGauss::buildNbOfGaussPointPerCellField() const throw(INTERP_KERNEL::Exception)
+{
+ if(!_discr_per_cell)
+ throw INTERP_KERNEL::Exception("MEDCouplingFieldDiscretizationGauss::buildNbOfGaussPointPerCellField : no discretization array set !");
+ int nbOfTuples=_discr_per_cell->getNumberOfTuples();
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ret=DataArrayInt::New();
+ const int *w=_discr_per_cell->getConstPointer();
+ ret->alloc(nbOfTuples,1);
+ int *valsToFill=ret->getPointer();
+ for(int i=0;i<nbOfTuples;i++,w++)
+ if(*w!=DFT_INVALID_LOCID_VALUE)
+ valsToFill[i]=_loc[*w].getNumberOfGaussPt();
+ else
+ throw INTERP_KERNEL::Exception("MEDCouplingFieldDiscretizationGauss::buildNbOfGaussPointPerCellField : orphan cell detected !");
+ ret->incrRef();
+ return ret;
+}
+
/*!
* This method makes the assumption that _discr_per_cell is set.
* This method reduces as much as possible number size of _loc.
_loc=tmpLoc;
}
+/*!
+ * This method is usefull when 'this' describes a field discretization with several gauss discretization on a \b same cell type.
+ * For example same NORM_TRI3 cells having 6 gauss points and others with 12 gauss points.
+ * This method returns 2 arrays with same size : the return value and 'locIds' output parameter.
+ * For a given i into [0,locIds.size) ret[i] represents the set of cell ids of i_th set an locIds[i] represents the set of discretisation of the set.
+ * The return vector contains a set of newly created instance to deal with.
+ * The returned vector represents a \b partition of cells ids with a gauss discretization set.
+ *
+ * If no descretization is set in 'this' and exception will be thrown.
+ */
+std::vector<DataArrayInt *> MEDCouplingFieldDiscretizationGauss::splitIntoSingleGaussDicrPerCellType(std::vector< std::vector<int> >& locIds) const throw(INTERP_KERNEL::Exception)
+{
+ if(!_discr_per_cell)
+ throw INTERP_KERNEL::Exception("MEDCouplingFieldDiscretizationGauss::splitIntoSingleGaussDicrPerCellType : no descretization set !");
+ locIds.clear();
+ std::vector<DataArrayInt *> ret;
+ const int *discrPerCell=_discr_per_cell->getConstPointer();
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ret2=_discr_per_cell->getIdsNotEqual(-1);
+ int nbOfTuplesSet=ret2->getNumberOfTuples();
+ std::list<int> idsRemaining(ret2->getConstPointer(),ret2->getConstPointer()+nbOfTuplesSet);
+ std::list<int>::iterator it=idsRemaining.begin();
+ while(it!=idsRemaining.end())
+ {
+ std::vector<int> ids;
+ std::set<int> curLocIds;
+ std::set<INTERP_KERNEL::NormalizedCellType> curCellTypes;
+ while(it!=idsRemaining.end())
+ {
+ int curDiscrId=discrPerCell[*it];
+ INTERP_KERNEL::NormalizedCellType typ=_loc[curDiscrId].getType();
+ if(curCellTypes.find(typ)!=curCellTypes.end())
+ {
+ if(curLocIds.find(curDiscrId)!=curLocIds.end())
+ {
+ curLocIds.insert(curDiscrId);
+ curCellTypes.insert(typ);
+ ids.push_back(*it);
+ it=idsRemaining.erase(it);
+ }
+ else
+ it++;
+ }
+ else
+ {
+ curLocIds.insert(curDiscrId);
+ curCellTypes.insert(typ);
+ ids.push_back(*it);
+ it=idsRemaining.erase(it);
+ }
+ }
+ it=idsRemaining.begin();
+ ret.resize(ret.size()+1);
+ DataArrayInt *part=DataArrayInt::New();
+ part->alloc(ids.size(),1);
+ std::copy(ids.begin(),ids.end(),part->getPointer());
+ ret.back()=part;
+ locIds.resize(locIds.size()+1);
+ locIds.back().insert(locIds.back().end(),curLocIds.begin(),curLocIds.end());
+ }
+ return ret;
+}
+
MEDCouplingFieldDiscretizationGaussNE::MEDCouplingFieldDiscretizationGaussNE()
{
}
{
const int *array=old2NewBg;
if(check)
- array=DataArrayInt::checkAndPreparePermutation(old2NewBg,old2NewBg+mesh->getNumberOfCells());
+ array=DataArrayInt::CheckAndPreparePermutation(old2NewBg,old2NewBg+mesh->getNumberOfCells());
int nbOfCells=mesh->getNumberOfCells();
int nbOfTuples=getNumberOfTuples(mesh);
int *array2=new int[nbOfTuples];//stores the final conversion array old2New to give to arrays in renumberInPlace.
throw INTERP_KERNEL::Exception("getValueOnPos(i,j,k) : Not applyable for Gauss points !");
}
+DataArrayDouble *MEDCouplingFieldDiscretizationGaussNE::getValueOnMulti(const DataArrayDouble *arr, const MEDCouplingMesh *mesh, const double *loc, int nbOfPoints) const
+{
+ throw INTERP_KERNEL::Exception("getValueOnMulti : Not implemented for Gauss NE !");
+}
+
MEDCouplingMesh *MEDCouplingFieldDiscretizationGaussNE::buildSubMeshData(const MEDCouplingMesh *mesh, const int *start, const int *end, DataArrayInt *&di) const
{
throw INTERP_KERNEL::Exception("Not implemented yet !");
/*!
* No implementation needed !
*/
-void MEDCouplingFieldDiscretizationGaussNE::renumberValuesOnNodes(const int *, DataArrayDouble *) const
+void MEDCouplingFieldDiscretizationGaussNE::renumberValuesOnNodes(double , const int *, DataArrayDouble *) const
{
}
-void MEDCouplingFieldDiscretizationGaussNE::renumberValuesOnCells(const MEDCouplingMesh *mesh, const int *old2New, DataArrayDouble *arr) const
+void MEDCouplingFieldDiscretizationGaussNE::renumberValuesOnCells(double epsOnVals, const MEDCouplingMesh *mesh, const int *old2New, DataArrayDouble *arr) const
{
throw INTERP_KERNEL::Exception("Not implemented yet !");
}
static MEDCouplingFieldDiscretization *New(TypeOfField type);
double getPrecision() const { return _precision; }
void setPrecision(double val) { _precision=val; }
- void updateTime();
+ void updateTime() const;
static TypeOfField getTypeOfFieldFromStringRepr(const char *repr) throw(INTERP_KERNEL::Exception);
virtual TypeOfField getEnum() const = 0;
virtual bool isEqual(const MEDCouplingFieldDiscretization *other, double eps) const = 0;
virtual MEDCouplingFieldDouble *getMeasureField(const MEDCouplingMesh *mesh, bool isAbs) const = 0;
virtual void getValueOn(const DataArrayDouble *arr, const MEDCouplingMesh *mesh, const double *loc, double *res) const = 0;
virtual void getValueOnPos(const DataArrayDouble *arr, const MEDCouplingMesh *mesh, int i, int j, int k, double *res) const = 0;
+ virtual DataArrayDouble *getValueOnMulti(const DataArrayDouble *arr, const MEDCouplingMesh *mesh, const double *loc, int nbOfPoints) const = 0;
virtual MEDCouplingMesh *buildSubMeshData(const MEDCouplingMesh *mesh, const int *start, const int *end, DataArrayInt *&di) const = 0;
- virtual void renumberValuesOnNodes(const int *old2New, DataArrayDouble *arr) const = 0;
- virtual void renumberValuesOnCells(const MEDCouplingMesh *mesh, const int *old2New, DataArrayDouble *arr) const = 0;
+ virtual void renumberValuesOnNodes(double epsOnVals, const int *old2New, DataArrayDouble *arr) const = 0;
+ virtual void renumberValuesOnCells(double epsOnVals, const MEDCouplingMesh *mesh, const int *old2New, DataArrayDouble *arr) const = 0;
virtual void renumberValuesOnCellsR(const MEDCouplingMesh *mesh, const int *new2old, int newSz, DataArrayDouble *arr) const = 0;
virtual void getSerializationIntArray(DataArrayInt *& arr) const;
virtual void getTinySerializationIntInformation(std::vector<int>& tinyInfo) const;
virtual ~MEDCouplingFieldDiscretization();
protected:
MEDCouplingFieldDiscretization();
- static void renumberEntitiesFromO2NArr(const int *old2NewPtr, DataArrayDouble *arr, const char *msg);
+ static void renumberEntitiesFromO2NArr(double epsOnVals, const int *old2NewPtr, DataArrayDouble *arr, const char *msg);
static void renumberEntitiesFromN2OArr(const int *new2OldPtr, int new2OldSz, DataArrayDouble *arr, const char *msg);
protected:
double _precision;
MEDCouplingFieldDouble *getMeasureField(const MEDCouplingMesh *mesh, bool isAbs) const;
void getValueOn(const DataArrayDouble *arr, const MEDCouplingMesh *mesh, const double *loc, double *res) const;
void getValueOnPos(const DataArrayDouble *arr, const MEDCouplingMesh *mesh, int i, int j, int k, double *res) const;
- void renumberValuesOnNodes(const int *old2New, DataArrayDouble *arr) const;
- void renumberValuesOnCells(const MEDCouplingMesh *mesh, const int *old2New, DataArrayDouble *arr) const;
+ DataArrayDouble *getValueOnMulti(const DataArrayDouble *arr, const MEDCouplingMesh *mesh, const double *loc, int nbOfPoints) const;
+ void renumberValuesOnNodes(double epsOnVals, const int *old2New, DataArrayDouble *arr) const;
+ void renumberValuesOnCells(double epsOnVals, const MEDCouplingMesh *mesh, const int *old2New, DataArrayDouble *arr) const;
void renumberValuesOnCellsR(const MEDCouplingMesh *mesh, const int *new2old, int newSz, DataArrayDouble *arr) const;
MEDCouplingMesh *buildSubMeshData(const MEDCouplingMesh *mesh, const int *start, const int *end, DataArrayInt *&di) const;
public:
MEDCouplingFieldDouble *getMeasureField(const MEDCouplingMesh *mesh, bool isAbs) const;
void getValueOn(const DataArrayDouble *arr, const MEDCouplingMesh *mesh, const double *loc, double *res) const;
void getValueOnPos(const DataArrayDouble *arr, const MEDCouplingMesh *mesh, int i, int j, int k, double *res) const;
+ DataArrayDouble *getValueOnMulti(const DataArrayDouble *arr, const MEDCouplingMesh *mesh, const double *loc, int nbOfPoints) const;
MEDCouplingMesh *buildSubMeshData(const MEDCouplingMesh *mesh, const int *start, const int *end, DataArrayInt *&di) const;
- void renumberValuesOnNodes(const int *old2New, DataArrayDouble *arr) const;
- void renumberValuesOnCells(const MEDCouplingMesh *mesh, const int *old2New, DataArrayDouble *arr) const;
+ void renumberValuesOnNodes(double epsOnVals, const int *old2New, DataArrayDouble *arr) const;
+ void renumberValuesOnCells(double epsOnVals, const MEDCouplingMesh *mesh, const int *old2New, DataArrayDouble *arr) const;
void renumberValuesOnCellsR(const MEDCouplingMesh *mesh, const int *new2old, int newSz, DataArrayDouble *arr) const;
+ protected:
+ void getValueInCell(const MEDCouplingMesh *mesh, int cellId, const DataArrayDouble *arr, const double *loc, double *res) const;
public:
static const char REPR[];
static const TypeOfField TYPE;
MEDCouplingFieldDiscretizationPerCell();
MEDCouplingFieldDiscretizationPerCell(const MEDCouplingFieldDiscretizationPerCell& other);
~MEDCouplingFieldDiscretizationPerCell();
- void updateTime();
+ void updateTime() const;
void checkCoherencyBetween(const MEDCouplingMesh *mesh, const DataArrayDouble *da) const throw(INTERP_KERNEL::Exception);
bool isEqual(const MEDCouplingFieldDiscretization *other, double eps) const;
bool isEqualWithoutConsideringStr(const MEDCouplingFieldDiscretization *other, double eps) const;
void renumberCells(const int *old2NewBg, bool check) throw(INTERP_KERNEL::Exception);
+ void checkNoOrphanCells() const throw(INTERP_KERNEL::Exception);
protected:
void buildDiscrPerCellIfNecessary(const MEDCouplingMesh *m);
protected:
DataArrayInt *_discr_per_cell;
+ static const int DFT_INVALID_LOCID_VALUE;
};
class MEDCOUPLING_EXPORT MEDCouplingFieldDiscretizationGauss : public MEDCouplingFieldDiscretizationPerCell
MEDCouplingFieldDouble *getMeasureField(const MEDCouplingMesh *mesh, bool isAbs) const;
void getValueOn(const DataArrayDouble *arr, const MEDCouplingMesh *mesh, const double *loc, double *res) const;
void getValueOnPos(const DataArrayDouble *arr, const MEDCouplingMesh *mesh, int i, int j, int k, double *res) const;
+ DataArrayDouble *getValueOnMulti(const DataArrayDouble *arr, const MEDCouplingMesh *mesh, const double *loc, int nbOfPoints) const;
MEDCouplingMesh *buildSubMeshData(const MEDCouplingMesh *mesh, const int *start, const int *end, DataArrayInt *&di) const;
- void renumberValuesOnNodes(const int *old2New, DataArrayDouble *arr) const;
- void renumberValuesOnCells(const MEDCouplingMesh *mesh, const int *old2New, DataArrayDouble *arr) const;
+ void renumberValuesOnNodes(double epsOnVals, const int *old2New, DataArrayDouble *arr) const;
+ void renumberValuesOnCells(double epsOnVals, const MEDCouplingMesh *mesh, const int *old2New, DataArrayDouble *arr) const;
void renumberValuesOnCellsR(const MEDCouplingMesh *mesh, const int *new2old, int newSz, DataArrayDouble *arr) const;
void setGaussLocalizationOnType(const MEDCouplingMesh *m, INTERP_KERNEL::NormalizedCellType type, const std::vector<double>& refCoo,
const std::vector<double>& gsCoo, const std::vector<double>& wg) throw(INTERP_KERNEL::Exception);
int getGaussLocalizationIdOfOneType(INTERP_KERNEL::NormalizedCellType type) const throw(INTERP_KERNEL::Exception);
void getCellIdsHavingGaussLocalization(int locId, std::vector<int>& cellIds) const throw(INTERP_KERNEL::Exception);
const MEDCouplingGaussLocalization& getGaussLocalization(int locId) const throw(INTERP_KERNEL::Exception);
+ std::vector<DataArrayInt *> splitIntoSingleGaussDicrPerCellType(std::vector< std::vector<int> >& locIds) const throw(INTERP_KERNEL::Exception);
+ DataArrayInt *buildNbOfGaussPointPerCellField() const throw(INTERP_KERNEL::Exception);
protected:
MEDCouplingFieldDiscretizationGauss(const MEDCouplingFieldDiscretizationGauss& other);
void zipGaussLocalizations();
MEDCouplingFieldDouble *getMeasureField(const MEDCouplingMesh *mesh, bool isAbs) const;
void getValueOn(const DataArrayDouble *arr, const MEDCouplingMesh *mesh, const double *loc, double *res) const;
void getValueOnPos(const DataArrayDouble *arr, const MEDCouplingMesh *mesh, int i, int j, int k, double *res) const;
+ DataArrayDouble *getValueOnMulti(const DataArrayDouble *arr, const MEDCouplingMesh *mesh, const double *loc, int nbOfPoints) const;
MEDCouplingMesh *buildSubMeshData(const MEDCouplingMesh *mesh, const int *start, const int *end, DataArrayInt *&di) const;
- void renumberValuesOnNodes(const int *old2New, DataArrayDouble *arr) const;
- void renumberValuesOnCells(const MEDCouplingMesh *mesh, const int *old2New, DataArrayDouble *arr) const;
+ void renumberValuesOnNodes(double epsOnVals, const int *old2New, DataArrayDouble *arr) const;
+ void renumberValuesOnCells(double epsOnVals, const MEDCouplingMesh *mesh, const int *old2New, DataArrayDouble *arr) const;
void renumberValuesOnCellsR(const MEDCouplingMesh *mesh, const int *new2old, int newSz, DataArrayDouble *arr) const;
protected:
MEDCouplingFieldDiscretizationGaussNE(const MEDCouplingFieldDiscretizationGaussNE& other);
//
#include "MEDCouplingFieldDouble.hxx"
+#include "MEDCouplingFieldTemplate.hxx"
#include "MEDCouplingUMesh.hxx"
#include "MEDCouplingTimeDiscretization.hxx"
#include "MEDCouplingFieldDiscretization.hxx"
return new MEDCouplingFieldDouble(type,td);
}
+MEDCouplingFieldDouble *MEDCouplingFieldDouble::New(const MEDCouplingFieldTemplate *ft, TypeOfTimeDiscretization td)
+{
+ return new MEDCouplingFieldDouble(ft,td);
+}
+
+void MEDCouplingFieldDouble::setTimeUnit(const char *unit)
+{
+ _time_discr->setTimeUnit(unit);
+}
+
+const char *MEDCouplingFieldDouble::getTimeUnit() const
+{
+ return _time_discr->getTimeUnit();
+}
+
MEDCouplingFieldDouble *MEDCouplingFieldDouble::clone(bool recDeepCpy) const
{
return new MEDCouplingFieldDouble(*this,recDeepCpy);
return ret;
}
+MEDCouplingFieldDouble *MEDCouplingFieldDouble::deepCpy() const
+{
+ return cloneWithMesh(true);
+}
+
MEDCouplingFieldDouble *MEDCouplingFieldDouble::buildNewTimeReprFromThis(TypeOfTimeDiscretization td, bool deepCpy) const
{
- MEDCouplingTimeDiscretization *tdo=_time_discr->buildNewTimeReprFromThis(_time_discr,td,deepCpy);
+ MEDCouplingTimeDiscretization *tdo=_time_discr->buildNewTimeReprFromThis(td,deepCpy);
MEDCouplingFieldDouble *ret=new MEDCouplingFieldDouble(getNature(),tdo,_type->clone());
ret->setMesh(getMesh());
ret->setName(getName());
const MEDCouplingFieldDouble *otherC=dynamic_cast<const MEDCouplingFieldDouble *>(other);
if(!otherC)
return false;
- if(_nature!=otherC->_nature)
- return false;
if(!MEDCouplingField::isEqual(other,meshPrec,valsPrec))
return false;
if(!_time_discr->isEqual(otherC->_time_discr,valsPrec))
const MEDCouplingFieldDouble *otherC=dynamic_cast<const MEDCouplingFieldDouble *>(other);
if(!otherC)
return false;
- if(_nature!=otherC->_nature)
- return false;
if(!MEDCouplingField::isEqualWithoutConsideringStr(other,meshPrec,valsPrec))
return false;
if(!_time_discr->isEqualWithoutConsideringStr(otherC->_time_discr,valsPrec))
const MEDCouplingFieldDouble *otherC=dynamic_cast<const MEDCouplingFieldDouble *>(other);
if(!otherC)
return false;
- if(_nature!=otherC->_nature)
- return false;
if(!_time_discr->areCompatible(otherC->_time_discr))
return false;
return true;
const MEDCouplingFieldDouble *otherC=dynamic_cast<const MEDCouplingFieldDouble *>(other);
if(!otherC)
return false;
- if(_nature!=otherC->_nature)
- return false;
if(!_time_discr->areStrictlyCompatible(otherC->_time_discr))
return false;
return true;
const MEDCouplingFieldDouble *otherC=dynamic_cast<const MEDCouplingFieldDouble *>(other);
if(!otherC)
return false;
- if(_nature!=otherC->_nature)
- return false;
if(!_time_discr->areStrictlyCompatibleForMul(otherC->_time_discr))
return false;
return true;
}
+/*!
+ * Method with same principle than MEDCouplingFieldDouble::areStrictlyCompatible method except that
+ * number of components between 'this' and 'other' can be different here (for operator/).
+ */
+bool MEDCouplingFieldDouble::areCompatibleForDiv(const MEDCouplingField *other) const
+{
+ if(!MEDCouplingField::areStrictlyCompatible(other))
+ return false;
+ const MEDCouplingFieldDouble *otherC=dynamic_cast<const MEDCouplingFieldDouble *>(other);
+ if(!otherC)
+ return false;
+ if(!_time_discr->areStrictlyCompatibleForDiv(otherC->_time_discr))
+ return false;
+ return true;
+}
+
+/*!
+ * This method is invocated before any attempt of melding. This method is very close to areStrictlyCompatible,
+ * except that 'this' and other can have different number of components.
+ */
+bool MEDCouplingFieldDouble::areCompatibleForMeld(const MEDCouplingFieldDouble *other) const
+{
+ if(!MEDCouplingField::areStrictlyCompatible(other))
+ return false;
+ if(!_time_discr->areCompatibleForMeld(other->_time_discr))
+ return false;
+ return true;
+}
+
/*!
* This method performs a clone of mesh and a renumbering of underlying cells of it. The number of cells remains the same.
* The values of field are impacted in consequence to have the same geometrical field.
* This method performs half job of MEDCouplingFieldDouble::renumberNodes. That is to say no permutation of cells is done on underlying mesh.
* That is to say, the field content is changed by this method.
*/
-void MEDCouplingFieldDouble::renumberNodesWithoutMesh(const int *old2NewBg) throw(INTERP_KERNEL::Exception)
+void MEDCouplingFieldDouble::renumberNodesWithoutMesh(const int *old2NewBg, double eps) throw(INTERP_KERNEL::Exception)
{
std::vector<DataArrayDouble *> arrays;
_time_discr->getArrays(arrays);
for(std::vector<DataArrayDouble *>::const_iterator iter=arrays.begin();iter!=arrays.end();iter++)
if(*iter)
- _type->renumberValuesOnNodes(old2NewBg,*iter);
+ _type->renumberValuesOnNodes(eps,old2NewBg,*iter);
}
/*!
return _time_discr->getEnum();
}
-MEDCouplingFieldDouble::MEDCouplingFieldDouble(TypeOfField type, TypeOfTimeDiscretization td):MEDCouplingField(type),_nature(NoNature),
+MEDCouplingFieldDouble::MEDCouplingFieldDouble(TypeOfField type, TypeOfTimeDiscretization td):MEDCouplingField(type),
_time_discr(MEDCouplingTimeDiscretization::New(td))
{
}
-MEDCouplingFieldDouble::MEDCouplingFieldDouble(const MEDCouplingFieldDouble& other, bool deepCpy):MEDCouplingField(other),_nature(other._nature),
+MEDCouplingFieldDouble::MEDCouplingFieldDouble(const MEDCouplingFieldTemplate *ft, TypeOfTimeDiscretization td):MEDCouplingField(*ft),
+ _time_discr(MEDCouplingTimeDiscretization::New(td))
+{
+}
+
+MEDCouplingFieldDouble::MEDCouplingFieldDouble(const MEDCouplingFieldDouble& other, bool deepCpy):MEDCouplingField(other),
_time_discr(other._time_discr->performCpy(deepCpy))
{
}
-MEDCouplingFieldDouble::MEDCouplingFieldDouble(NatureOfField n, MEDCouplingTimeDiscretization *td, MEDCouplingFieldDiscretization *type):MEDCouplingField(type),
- _nature(n),_time_discr(td)
+MEDCouplingFieldDouble::MEDCouplingFieldDouble(NatureOfField n, MEDCouplingTimeDiscretization *td, MEDCouplingFieldDiscretization *type):MEDCouplingField(type,n),_time_discr(td)
{
}
void MEDCouplingFieldDouble::getValueOnPos(int i, int j, int k, double *res) const throw(INTERP_KERNEL::Exception)
{
const DataArrayDouble *arr=_time_discr->getArray();
+ if(!_mesh)
+ throw INTERP_KERNEL::Exception("No mesh underlying this field to perform getValueOnPos");
_type->getValueOnPos(arr,_mesh,i,j,k,res);
}
void MEDCouplingFieldDouble::getValueOn(const double *spaceLoc, double *res) const throw(INTERP_KERNEL::Exception)
{
const DataArrayDouble *arr=_time_discr->getArray();
+ if(!_mesh)
+ throw INTERP_KERNEL::Exception("No mesh underlying this field to perform getValueOn");
_type->getValueOn(arr,_mesh,spaceLoc,res);
}
+/*!
+ * Returns a newly allocated array with 'nbOfPoints' tuples and nb of components equal to 'this->getNumberOfComponents()'.
+ */
+DataArrayDouble *MEDCouplingFieldDouble::getValueOnMulti(const double *spaceLoc, int nbOfPoints) const throw(INTERP_KERNEL::Exception)
+{
+ const DataArrayDouble *arr=_time_discr->getArray();
+ if(!_mesh)
+ throw INTERP_KERNEL::Exception("No mesh underlying this field to perform getValueOnMulti");
+ return _type->getValueOnMulti(arr,_mesh,spaceLoc,nbOfPoints);
+}
+
/*!
* Returns value of 'this' on time 'time' of point 'spaceLoc' using spatial discretization.
* If 'time' is not covered by this->_time_discr an exception will be thrown.
void MEDCouplingFieldDouble::getValueOn(const double *spaceLoc, double time, double *res) const throw(INTERP_KERNEL::Exception)
{
std::vector< const DataArrayDouble *> arrs=_time_discr->getArraysForTime(time);
+ if(!_mesh)
+ throw INTERP_KERNEL::Exception("No mesh underlying this field to perform getValueOn");
std::vector<double> res2;
for(std::vector< const DataArrayDouble *>::const_iterator iter=arrs.begin();iter!=arrs.end();iter++)
{
_time_discr->fillFromAnalytic(loc,nbOfComp,func);
}
+/*!
+ * This method is very similar to this one MEDCouplingMesh::fillFromAnalytic2.
+ * The main difference is that the field as been started to be constructed here.
+ * An exception is throw if no underlying mesh is set before the call of this method.
+ */
+void MEDCouplingFieldDouble::fillFromAnalytic2(int nbOfComp, const char *func) throw(INTERP_KERNEL::Exception)
+{
+ if(!_mesh)
+ throw INTERP_KERNEL::Exception("MEDCouplingFieldDouble::fillFromAnalytic2 : no mesh defined !");
+ MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> loc=_type->getLocalizationOfDiscValues(_mesh);
+ _time_discr->fillFromAnalytic2(loc,nbOfComp,func);
+}
+
+/*!
+ * This method is very similar to this one MEDCouplingMesh::fillFromAnalytic3.
+ * The main difference is that the field as been started to be constructed here.
+ * An exception is throw if no underlying mesh is set before the call of this method.
+ */
+void MEDCouplingFieldDouble::fillFromAnalytic3(int nbOfComp, const std::vector<std::string>& varsOrder, const char *func) throw(INTERP_KERNEL::Exception)
+{
+ if(!_mesh)
+ throw INTERP_KERNEL::Exception("MEDCouplingFieldDouble::fillFromAnalytic2 : no mesh defined !");
+ MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> loc=_type->getLocalizationOfDiscValues(_mesh);
+ _time_discr->fillFromAnalytic3(loc,nbOfComp,varsOrder,func);
+}
+
/*!
* Applyies the function specified by pointer 'func' on each tuples on all arrays contained in _time_discr.
* If '*func' returns false during one evaluation an exception will be thrown.
* If '*func' fails in evaluation during one evaluation an exception will be thrown.
* The field will contain 'nbOfComp' components after the call.
*/
-void MEDCouplingFieldDouble::applyFunc(int nbOfComp, const char *func)
+void MEDCouplingFieldDouble::applyFunc(int nbOfComp, const char *func) throw(INTERP_KERNEL::Exception)
{
_time_discr->applyFunc(nbOfComp,func);
}
+/*!
+ * This method is equivalent to MEDCouplingFieldDouble::applyFunc, except that here components info are used to determine variables position in 'func'.
+ * If there is vars detected in 'func' that is not in an info on components an exception will be thrown.
+ */
+void MEDCouplingFieldDouble::applyFunc2(int nbOfComp, const char *func) throw(INTERP_KERNEL::Exception)
+{
+ _time_discr->applyFunc2(nbOfComp,func);
+}
+
+/*!
+ * This method is equivalent to MEDCouplingFieldDouble::applyFunc, except that here 'varsOrder' is used to determine variables position in 'func'.
+ * If there is vars detected in 'func' that is not in 'varsOrder' an exception will be thrown.
+ */
+void MEDCouplingFieldDouble::applyFunc3(int nbOfComp, const std::vector<std::string>& varsOrder, const char *func) throw(INTERP_KERNEL::Exception)
+{
+ _time_discr->applyFunc3(nbOfComp,varsOrder,func);
+}
+
/*!
* Applyies the function specified by the string repr 'func' on each tuples on all arrays contained in _time_discr.
* If '*func' fails in evaluation during one evaluation an exception will be thrown.
* The field will contain exactly the same number of components after the call.
*/
-void MEDCouplingFieldDouble::applyFunc(const char *func)
+void MEDCouplingFieldDouble::applyFunc(const char *func) throw(INTERP_KERNEL::Exception)
{
_time_discr->applyFunc(func);
}
return getArray()->getNbOfElems();
}
-void MEDCouplingFieldDouble::updateTime()
+void MEDCouplingFieldDouble::updateTime() const
{
MEDCouplingField::updateTime();
updateTimeWith(*_time_discr);
void MEDCouplingFieldDouble::setNature(NatureOfField nat) throw(INTERP_KERNEL::Exception)
{
+ MEDCouplingField::setNature(nat);
_type->checkCompatibilityWithNature(nat);
- _nature=nat;
}
double MEDCouplingFieldDouble::getIJK(int cellId, int nodeIdInCell, int compoId) const
_time_discr->setEndArray(array,this);
}
+void MEDCouplingFieldDouble::setArrays(const std::vector<DataArrayDouble *>& arrs) throw(INTERP_KERNEL::Exception)
+{
+ _time_discr->setArrays(arrs,this);
+}
+
void MEDCouplingFieldDouble::getTinySerializationStrInformation(std::vector<std::string>& tinyInfo) const
{
tinyInfo.clear();
_time_discr->getTinySerializationStrInformation(tinyInfo);
tinyInfo.push_back(_name);
tinyInfo.push_back(_desc);
+ tinyInfo.push_back(getTimeUnit());
}
/*!
_nature=(NatureOfField)tinyInfoI[2];
_type->finishUnserialization(tmp2);
int nbOfElemS=tinyInfoS.size();
- _name=tinyInfoS[nbOfElemS-2];
- _desc=tinyInfoS[nbOfElemS-1];
+ _name=tinyInfoS[nbOfElemS-3];
+ _desc=tinyInfoS[nbOfElemS-2];
+ setTimeUnit(tinyInfoS[nbOfElemS-1].c_str());
}
/*!
/*!
* Merge nodes of underlying mesh. In case of some node will be merged the underlying mesh instance will change.
+ * The first 'eps' stands for geometric approximation. The second 'epsOnVals' is for epsilon on values in case of node merging.
+ * If 2 nodes distant from less than 'eps' and with value different with more than 'epsOnVals' an exception will be thrown.
*/
-bool MEDCouplingFieldDouble::mergeNodes(double eps) throw(INTERP_KERNEL::Exception)
+bool MEDCouplingFieldDouble::mergeNodes(double eps, double epsOnVals) throw(INTERP_KERNEL::Exception)
{
const MEDCouplingPointSet *meshC=dynamic_cast<const MEDCouplingPointSet *>(_mesh);
if(!meshC)
_time_discr->getArrays(arrays);
for(std::vector<DataArrayDouble *>::const_iterator iter=arrays.begin();iter!=arrays.end();iter++)
if(*iter)
- _type->renumberValuesOnNodes(arr->getConstPointer(),*iter);
+ _type->renumberValuesOnNodes(epsOnVals,arr->getConstPointer(),*iter);
+ setMesh(meshC2);
+ return true;
+}
+
+/*!
+ * Merge nodes with (barycenter computation) of underlying mesh. In case of some node will be merged the underlying mesh instance will change.
+ * The first 'eps' stands for geometric approximation. The second 'epsOnVals' is for epsilon on values in case of node merging.
+ * If 2 nodes distant from less than 'eps' and with value different with more than 'epsOnVals' an exception will be thrown.
+ */
+bool MEDCouplingFieldDouble::mergeNodes2(double eps, double epsOnVals) throw(INTERP_KERNEL::Exception)
+{
+ const MEDCouplingPointSet *meshC=dynamic_cast<const MEDCouplingPointSet *>(_mesh);
+ if(!meshC)
+ throw INTERP_KERNEL::Exception("Invalid support mesh to apply mergeNodes on it : must be a MEDCouplingPointSet one !");
+ MEDCouplingAutoRefCountObjectPtr<MEDCouplingPointSet> meshC2((MEDCouplingPointSet *)meshC->deepCpy());
+ bool ret;
+ int ret2;
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr=meshC2->mergeNodes2(eps,ret,ret2);
+ if(!ret)//no nodes have been merged.
+ return ret;
+ std::vector<DataArrayDouble *> arrays;
+ _time_discr->getArrays(arrays);
+ for(std::vector<DataArrayDouble *>::const_iterator iter=arrays.begin();iter!=arrays.end();iter++)
+ if(*iter)
+ _type->renumberValuesOnNodes(epsOnVals,arr->getConstPointer(),*iter);
setMesh(meshC2);
return true;
}
/*!
* This method applyies ParaMEDMEM::MEDCouplingPointSet::zipCoords method on 'this->_mesh' that should be set and of type ParaMEDMEM::MEDCouplingPointSet.
* If some nodes have disappeared true is returned.
+ * 'epsOnVals' stands for epsilon in case of merge of cells. This value is used as tolerance in case the corresponding values differ.
*/
-bool MEDCouplingFieldDouble::zipCoords() throw(INTERP_KERNEL::Exception)
+bool MEDCouplingFieldDouble::zipCoords(double epsOnVals) throw(INTERP_KERNEL::Exception)
{
const MEDCouplingPointSet *meshC=dynamic_cast<const MEDCouplingPointSet *>(_mesh);
if(!meshC)
_time_discr->getArrays(arrays);
for(std::vector<DataArrayDouble *>::const_iterator iter=arrays.begin();iter!=arrays.end();iter++)
if(*iter)
- _type->renumberValuesOnNodes(arr->getConstPointer(),*iter);
+ _type->renumberValuesOnNodes(epsOnVals,arr->getConstPointer(),*iter);
setMesh(meshC2);
return true;
}
/*!
* This method applyies ParaMEDMEM::MEDCouplingUMesh::zipConnectivityTraducer on 'this->_mesh' that should be set and of type ParaMEDMEM::MEDCouplingUMesh.
* The semantic of 'compType' is given in ParaMEDMEM::MEDCouplingUMesh::zipConnectivityTraducer method.
+ * 'epsOnVals' stands for epsilon in case of merge of cells. This value is used as tolerance in case the corresponding values differ.
*/
-bool MEDCouplingFieldDouble::zipConnectivity(int compType) throw(INTERP_KERNEL::Exception)
+bool MEDCouplingFieldDouble::zipConnectivity(int compType, double epsOnVals) throw(INTERP_KERNEL::Exception)
{
const MEDCouplingUMesh *meshC=dynamic_cast<const MEDCouplingUMesh *>(_mesh);
if(!meshC)
_time_discr->getArrays(arrays);
for(std::vector<DataArrayDouble *>::const_iterator iter=arrays.begin();iter!=arrays.end();iter++)
if(*iter)
- _type->renumberValuesOnCells(meshC,arr->getConstPointer(),*iter);
+ _type->renumberValuesOnCells(epsOnVals,meshC,arr->getConstPointer(),*iter);
setMesh(meshC2);
return true;
}
_time_discr->sortPerTuple(asc);
}
-MEDCouplingFieldDouble *MEDCouplingFieldDouble::mergeFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2)
+MEDCouplingFieldDouble *MEDCouplingFieldDouble::MergeFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2) throw(INTERP_KERNEL::Exception)
{
if(!f1->areCompatibleForMerge(f2))
- throw INTERP_KERNEL::Exception("Fields are not compatible ; unable to apply mergeFields on them !");
+ throw INTERP_KERNEL::Exception("Fields are not compatible ; unable to apply MergeFields on them !");
const MEDCouplingMesh *m1=f1->getMesh();
const MEDCouplingMesh *m2=f2->getMesh();
MEDCouplingMesh *m=m1->mergeMyselfWith(m2);
MEDCouplingTimeDiscretization *td=f1->_time_discr->aggregate(f2->_time_discr);
+ td->copyTinyAttrFrom(*f1->_time_discr);
MEDCouplingFieldDouble *ret=new MEDCouplingFieldDouble(f1->getNature(),td,f1->_type->clone());
ret->setMesh(m);
m->decrRef();
return ret;
}
-MEDCouplingFieldDouble *MEDCouplingFieldDouble::dotFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2)
+MEDCouplingFieldDouble *MEDCouplingFieldDouble::MergeFields(const std::vector<const MEDCouplingFieldDouble *>& a) throw(INTERP_KERNEL::Exception)
+{
+ if(a.size()<=1)
+ throw INTERP_KERNEL::Exception("FieldDouble::MergeFields : size of array must be > 1 !");
+ std::vector< MEDCouplingAutoRefCountObjectPtr<MEDCouplingUMesh> > ms(a.size());
+ std::vector< const MEDCouplingUMesh *> ms2(a.size());
+ std::vector< const MEDCouplingTimeDiscretization *> tds(a.size());
+ std::vector<const MEDCouplingFieldDouble *>::const_iterator it=a.begin();
+ const MEDCouplingFieldDouble *ref=(*it++);
+ for(;it!=a.end();it++)
+ if(!ref->areCompatibleForMerge(*it))
+ throw INTERP_KERNEL::Exception("Fields are not compatible ; unable to apply MergeFields on them !");
+ for(int i=0;i<(int)a.size();i++)
+ {
+ if(!a[i]->getMesh())
+ throw INTERP_KERNEL::Exception("MergeFields : A field as no underlying mesh !");
+ ms[i]=a[i]->getMesh()->buildUnstructured();
+ ms2[i]=ms[i];
+ tds[i]=a[i]->_time_discr;
+ }
+ MEDCouplingAutoRefCountObjectPtr<MEDCouplingUMesh> m=MEDCouplingUMesh::MergeUMeshes(ms2);
+ MEDCouplingTimeDiscretization *td=tds[0]->aggregate(tds);
+ td->copyTinyAttrFrom(*(a[0]->_time_discr));
+ MEDCouplingFieldDouble *ret=new MEDCouplingFieldDouble(a[0]->getNature(),td,a[0]->_type->clone());
+ ret->setMesh(m);
+ ret->setName(a[0]->getName());
+ ret->setDescription(a[0]->getDescription());
+ return ret;
+}
+
+MEDCouplingFieldDouble *MEDCouplingFieldDouble::MeldFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2) throw(INTERP_KERNEL::Exception)
+{
+ if(!f1->areCompatibleForMeld(f2))
+ throw INTERP_KERNEL::Exception("Fields are not compatible ; unable to apply MeldFields on them !");
+ MEDCouplingTimeDiscretization *td=f1->_time_discr->meld(f2->_time_discr);
+ td->copyTinyAttrFrom(*f1->_time_discr);
+ MEDCouplingFieldDouble *ret=new MEDCouplingFieldDouble(f1->getNature(),td,f1->_type->clone());
+ ret->setMesh(f1->getMesh());
+ return ret;
+}
+
+MEDCouplingFieldDouble *MEDCouplingFieldDouble::DotFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2) throw(INTERP_KERNEL::Exception)
{
if(!f1->areStrictlyCompatible(f2))
- throw INTERP_KERNEL::Exception("Fields are not compatible ; unable to apply dotFields on them !");
+ throw INTERP_KERNEL::Exception("Fields are not compatible ; unable to apply DotFields on them !");
MEDCouplingTimeDiscretization *td=f1->_time_discr->dot(f2->_time_discr);
td->copyTinyAttrFrom(*f1->_time_discr);
MEDCouplingFieldDouble *ret=new MEDCouplingFieldDouble(f1->getNature(),td,f1->_type->clone());
return ret;
}
-MEDCouplingFieldDouble *MEDCouplingFieldDouble::crossProductFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2)
+MEDCouplingFieldDouble *MEDCouplingFieldDouble::CrossProductFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2) throw(INTERP_KERNEL::Exception)
{
if(!f1->areStrictlyCompatible(f2))
- throw INTERP_KERNEL::Exception("Fields are not compatible ; unable to apply crossProductFields on them !");
+ throw INTERP_KERNEL::Exception("Fields are not compatible ; unable to apply CrossProductFields on them !");
MEDCouplingTimeDiscretization *td=f1->_time_discr->crossProduct(f2->_time_discr);
td->copyTinyAttrFrom(*f1->_time_discr);
MEDCouplingFieldDouble *ret=new MEDCouplingFieldDouble(f1->getNature(),td,f1->_type->clone());
return ret;
}
-MEDCouplingFieldDouble *MEDCouplingFieldDouble::maxFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2)
+MEDCouplingFieldDouble *MEDCouplingFieldDouble::MaxFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2) throw(INTERP_KERNEL::Exception)
{
if(!f1->areStrictlyCompatible(f2))
- throw INTERP_KERNEL::Exception("Fields are not compatible ; unable to apply maxFields on them !");
+ throw INTERP_KERNEL::Exception("Fields are not compatible ; unable to apply MaxFields on them !");
MEDCouplingTimeDiscretization *td=f1->_time_discr->max(f2->_time_discr);
td->copyTinyAttrFrom(*f1->_time_discr);
MEDCouplingFieldDouble *ret=new MEDCouplingFieldDouble(f1->getNature(),td,f1->_type->clone());
return ret;
}
-MEDCouplingFieldDouble *MEDCouplingFieldDouble::minFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2)
+MEDCouplingFieldDouble *MEDCouplingFieldDouble::MinFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2) throw(INTERP_KERNEL::Exception)
{
if(!f1->areStrictlyCompatible(f2))
- throw INTERP_KERNEL::Exception("Fields are not compatible ; unable to apply minFields on them !");
+ throw INTERP_KERNEL::Exception("Fields are not compatible ; unable to apply MinFields on them !");
MEDCouplingTimeDiscretization *td=f1->_time_discr->min(f2->_time_discr);
td->copyTinyAttrFrom(*f1->_time_discr);
MEDCouplingFieldDouble *ret=new MEDCouplingFieldDouble(f1->getNature(),td,f1->_type->clone());
return ret;
}
-MEDCouplingFieldDouble *MEDCouplingFieldDouble::addFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2)
+MEDCouplingFieldDouble *MEDCouplingFieldDouble::AddFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2) throw(INTERP_KERNEL::Exception)
{
if(!f1->areStrictlyCompatible(f2))
- throw INTERP_KERNEL::Exception("Fields are not compatible ; unable to apply addFields on them !");
+ throw INTERP_KERNEL::Exception("Fields are not compatible ; unable to apply AddFields on them !");
MEDCouplingTimeDiscretization *td=f1->_time_discr->add(f2->_time_discr);
td->copyTinyAttrFrom(*f1->_time_discr);
MEDCouplingFieldDouble *ret=new MEDCouplingFieldDouble(f1->getNature(),td,f1->_type->clone());
return ret;
}
-const MEDCouplingFieldDouble &MEDCouplingFieldDouble::operator+=(const MEDCouplingFieldDouble& other)
+const MEDCouplingFieldDouble &MEDCouplingFieldDouble::operator+=(const MEDCouplingFieldDouble& other) throw(INTERP_KERNEL::Exception)
{
if(!areStrictlyCompatible(&other))
throw INTERP_KERNEL::Exception("Fields are not compatible ; unable to apply += on them !");
return *this;
}
-MEDCouplingFieldDouble *MEDCouplingFieldDouble::substractFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2)
+MEDCouplingFieldDouble *MEDCouplingFieldDouble::SubstractFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2) throw(INTERP_KERNEL::Exception)
{
if(!f1->areStrictlyCompatible(f2))
- throw INTERP_KERNEL::Exception("Fields are not compatible ; unable to apply substractFields on them !");
+ throw INTERP_KERNEL::Exception("Fields are not compatible ; unable to apply SubstractFields on them !");
MEDCouplingTimeDiscretization *td=f1->_time_discr->substract(f2->_time_discr);
td->copyTinyAttrFrom(*f1->_time_discr);
MEDCouplingFieldDouble *ret=new MEDCouplingFieldDouble(f1->getNature(),td,f1->_type->clone());
return ret;
}
-const MEDCouplingFieldDouble &MEDCouplingFieldDouble::operator-=(const MEDCouplingFieldDouble& other)
+const MEDCouplingFieldDouble &MEDCouplingFieldDouble::operator-=(const MEDCouplingFieldDouble& other) throw(INTERP_KERNEL::Exception)
{
if(!areStrictlyCompatible(&other))
throw INTERP_KERNEL::Exception("Fields are not compatible ; unable to apply -= on them !");
return *this;
}
-MEDCouplingFieldDouble *MEDCouplingFieldDouble::multiplyFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2)
+MEDCouplingFieldDouble *MEDCouplingFieldDouble::MultiplyFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2) throw(INTERP_KERNEL::Exception)
{
if(!f1->areCompatibleForMul(f2))
- throw INTERP_KERNEL::Exception("Fields are not compatible ; unable to apply multiplyFields on them !");
+ throw INTERP_KERNEL::Exception("Fields are not compatible ; unable to apply MultiplyFields on them !");
MEDCouplingTimeDiscretization *td=f1->_time_discr->multiply(f2->_time_discr);
td->copyTinyAttrFrom(*f1->_time_discr);
MEDCouplingFieldDouble *ret=new MEDCouplingFieldDouble(f1->getNature(),td,f1->_type->clone());
return ret;
}
-const MEDCouplingFieldDouble &MEDCouplingFieldDouble::operator*=(const MEDCouplingFieldDouble& other)
+const MEDCouplingFieldDouble &MEDCouplingFieldDouble::operator*=(const MEDCouplingFieldDouble& other) throw(INTERP_KERNEL::Exception)
{
if(!areCompatibleForMul(&other))
throw INTERP_KERNEL::Exception("Fields are not compatible ; unable to apply *= on them !");
return *this;
}
-MEDCouplingFieldDouble *MEDCouplingFieldDouble::divideFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2)
+MEDCouplingFieldDouble *MEDCouplingFieldDouble::DivideFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2) throw(INTERP_KERNEL::Exception)
{
- if(!f1->areStrictlyCompatible(f2))
- throw INTERP_KERNEL::Exception("Fields are not compatible ; unable to apply divideFields on them !");
+ if(!f1->areCompatibleForDiv(f2))
+ throw INTERP_KERNEL::Exception("Fields are not compatible ; unable to apply DivideFields on them !");
MEDCouplingTimeDiscretization *td=f1->_time_discr->divide(f2->_time_discr);
td->copyTinyAttrFrom(*f1->_time_discr);
MEDCouplingFieldDouble *ret=new MEDCouplingFieldDouble(f1->getNature(),td,f1->_type->clone());
return ret;
}
-const MEDCouplingFieldDouble &MEDCouplingFieldDouble::operator/=(const MEDCouplingFieldDouble& other)
+const MEDCouplingFieldDouble &MEDCouplingFieldDouble::operator/=(const MEDCouplingFieldDouble& other) throw(INTERP_KERNEL::Exception)
{
- if(!areStrictlyCompatible(&other))
+ if(!areCompatibleForDiv(&other))
throw INTERP_KERNEL::Exception("Fields are not compatible ; unable to apply /= on them !");
_time_discr->divideEqual(other._time_discr);
return *this;
#include "MEDCoupling.hxx"
#include "MEDCouplingField.hxx"
#include "MEDCouplingTimeDiscretization.hxx"
-#include "MEDCouplingNatureOfField.hxx"
#include "MEDCouplingMemArray.hxx"
namespace ParaMEDMEM
{
+ class MEDCouplingFieldTemplate;
+
class MEDCOUPLING_EXPORT MEDCouplingFieldDouble : public MEDCouplingField
{
public:
static MEDCouplingFieldDouble *New(TypeOfField type, TypeOfTimeDiscretization td=NO_TIME);
+ static MEDCouplingFieldDouble *New(const MEDCouplingFieldTemplate *ft, TypeOfTimeDiscretization td=NO_TIME);
+ void setTimeUnit(const char *unit);
+ const char *getTimeUnit() const;
void copyTinyStringsFrom(const MEDCouplingFieldDouble *other) throw(INTERP_KERNEL::Exception);
void copyTinyAttrFrom(const MEDCouplingFieldDouble *other) throw(INTERP_KERNEL::Exception);
std::string simpleRepr() const;
bool areCompatibleForMerge(const MEDCouplingField *other) const;
bool areStrictlyCompatible(const MEDCouplingField *other) const;
bool areCompatibleForMul(const MEDCouplingField *other) const;
+ bool areCompatibleForDiv(const MEDCouplingField *other) const;
+ bool areCompatibleForMeld(const MEDCouplingFieldDouble *other) const;
void renumberCells(const int *old2NewBg, bool check) throw(INTERP_KERNEL::Exception);
void renumberCellsWithoutMesh(const int *old2NewBg, bool check) throw(INTERP_KERNEL::Exception);
void renumberNodes(const int *old2NewBg) throw(INTERP_KERNEL::Exception);
- void renumberNodesWithoutMesh(const int *old2NewBg) throw(INTERP_KERNEL::Exception);
+ void renumberNodesWithoutMesh(const int *old2NewBg, double eps=1e-15) throw(INTERP_KERNEL::Exception);
DataArrayInt *getIdsInRange(double vmin, double vmax) const throw(INTERP_KERNEL::Exception);
MEDCouplingFieldDouble *buildSubPart(const DataArrayInt *part) const throw(INTERP_KERNEL::Exception);
MEDCouplingFieldDouble *buildSubPart(const int *partBg, const int *partEnd) const throw(INTERP_KERNEL::Exception);
+ MEDCouplingFieldDouble *deepCpy() const;
MEDCouplingFieldDouble *clone(bool recDeepCpy) const;
MEDCouplingFieldDouble *cloneWithMesh(bool recDeepCpy) const;
MEDCouplingFieldDouble *buildNewTimeReprFromThis(TypeOfTimeDiscretization td, bool deepCpy) const;
TypeOfTimeDiscretization getTimeDiscretization() const;
void checkCoherency() const throw(INTERP_KERNEL::Exception);
- NatureOfField getNature() const { return _nature; }
void setNature(NatureOfField nat) throw(INTERP_KERNEL::Exception);
void setTimeTolerance(double val) { _time_discr->setTimeTolerance(val); }
double getTimeTolerance() const { return _time_discr->getTimeTolerance(); }
+ void setIteration(int it) throw(INTERP_KERNEL::Exception) { _time_discr->setIteration(it); }
+ void setEndIteration(int it) throw(INTERP_KERNEL::Exception) { _time_discr->setEndIteration(it); }
+ void setOrder(int order) throw(INTERP_KERNEL::Exception) { _time_discr->setOrder(order); }
+ void setEndOrder(int order) throw(INTERP_KERNEL::Exception) { _time_discr->setEndOrder(order); }
+ void setTimeValue(double val) throw(INTERP_KERNEL::Exception) { _time_discr->setTimeValue(val); }
+ void setEndTimeValue(double val) throw(INTERP_KERNEL::Exception) { _time_discr->setEndTimeValue(val); }
void setTime(double val, int iteration, int order) { _time_discr->setTime(val,iteration,order); }
void setStartTime(double val, int iteration, int order) { _time_discr->setStartTime(val,iteration,order); }
void setEndTime(double val, int iteration, int order) { _time_discr->setEndTime(val,iteration,order); }
double getIJK(int cellId, int nodeIdInCell, int compoId) const;
void setArray(DataArrayDouble *array);
void setEndArray(DataArrayDouble *array);
- DataArrayDouble *getArray() const { return _time_discr->getArray(); }
- DataArrayDouble *getEndArray() const { return _time_discr->getEndArray(); }
+ void setArrays(const std::vector<DataArrayDouble *>& arrs) throw(INTERP_KERNEL::Exception);
+ const DataArrayDouble *getArray() const { return _time_discr->getArray(); }
+ DataArrayDouble *getArray() { return _time_discr->getArray(); }
+ const DataArrayDouble *getEndArray() const { return _time_discr->getEndArray(); }
+ DataArrayDouble *getEndArray() { return _time_discr->getEndArray(); }
+ std::vector<DataArrayDouble *> getArrays() const { std::vector<DataArrayDouble *> ret; _time_discr->getArrays(ret); return ret; }
double accumulate(int compId) const;
void accumulate(double *res) const;
double getMaxValue() const throw(INTERP_KERNEL::Exception);
void getValueOnPos(int i, int j, int k, double *res) const throw(INTERP_KERNEL::Exception);
void getValueOn(const double *spaceLoc, double *res) const throw(INTERP_KERNEL::Exception);
void getValueOn(const double *spaceLoc, double time, double *res) const throw(INTERP_KERNEL::Exception);
+ DataArrayDouble *getValueOnMulti(const double *spaceLoc, int nbOfPoints) const throw(INTERP_KERNEL::Exception);
//! \b temporary
void applyLin(double a, double b, int compoId);
MEDCouplingFieldDouble &operator=(double value) throw(INTERP_KERNEL::Exception);
void fillFromAnalytic(int nbOfComp, FunctionToEvaluate func) throw(INTERP_KERNEL::Exception);
void fillFromAnalytic(int nbOfComp, const char *func) throw(INTERP_KERNEL::Exception);
+ void fillFromAnalytic2(int nbOfComp, const char *func) throw(INTERP_KERNEL::Exception);
+ void fillFromAnalytic3(int nbOfComp, const std::vector<std::string>& varsOrder, const char *func) throw(INTERP_KERNEL::Exception);
void applyFunc(int nbOfComp, FunctionToEvaluate func);
void applyFunc(int nbOfComp, double val);
- void applyFunc(int nbOfComp, const char *func);
- void applyFunc(const char *func);
+ void applyFunc(int nbOfComp, const char *func) throw(INTERP_KERNEL::Exception);
+ void applyFunc2(int nbOfComp, const char *func) throw(INTERP_KERNEL::Exception);
+ void applyFunc3(int nbOfComp, const std::vector<std::string>& varsOrder, const char *func) throw(INTERP_KERNEL::Exception);
+ void applyFunc(const char *func) throw(INTERP_KERNEL::Exception);
void applyFuncFast32(const char *func) throw(INTERP_KERNEL::Exception);
void applyFuncFast64(const char *func) throw(INTERP_KERNEL::Exception);
int getNumberOfComponents() const throw(INTERP_KERNEL::Exception);
int getNumberOfTuples() const throw(INTERP_KERNEL::Exception);
int getNumberOfValues() const throw(INTERP_KERNEL::Exception);
- void updateTime();
+ void updateTime() const;
//
void getTinySerializationIntInformation(std::vector<int>& tinyInfo) const;
void getTinySerializationDbleInformation(std::vector<double>& tinyInfo) const;
//
void changeUnderlyingMesh(const MEDCouplingMesh *other, int levOfCheck, double prec) throw(INTERP_KERNEL::Exception);
void substractInPlaceDM(const MEDCouplingFieldDouble *f, int levOfCheck, double prec) throw(INTERP_KERNEL::Exception);
- bool mergeNodes(double eps) throw(INTERP_KERNEL::Exception);
- bool zipCoords() throw(INTERP_KERNEL::Exception);
- bool zipConnectivity(int compType) throw(INTERP_KERNEL::Exception);
+ bool mergeNodes(double eps, double epsOnVals=1e-15) throw(INTERP_KERNEL::Exception);
+ bool mergeNodes2(double eps, double epsOnVals=1e-15) throw(INTERP_KERNEL::Exception);
+ bool zipCoords(double epsOnVals=1e-15) throw(INTERP_KERNEL::Exception);
+ bool zipConnectivity(int compType, double epsOnVals=1e-15) throw(INTERP_KERNEL::Exception);
bool simplexize(int policy) throw(INTERP_KERNEL::Exception);
MEDCouplingFieldDouble *doublyContractedProduct() const throw(INTERP_KERNEL::Exception);
MEDCouplingFieldDouble *determinant() const throw(INTERP_KERNEL::Exception);
MEDCouplingFieldDouble *keepSelectedComponents(const std::vector<int>& compoIds) const throw(INTERP_KERNEL::Exception);
void setSelectedComponents(const MEDCouplingFieldDouble *f, const std::vector<int>& compoIds) throw(INTERP_KERNEL::Exception);
void sortPerTuple(bool asc) throw(INTERP_KERNEL::Exception);
- static MEDCouplingFieldDouble *mergeFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2);
- static MEDCouplingFieldDouble *dotFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2);
- MEDCouplingFieldDouble *dot(const MEDCouplingFieldDouble& other) const { return dotFields(this,&other); }
- static MEDCouplingFieldDouble *crossProductFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2);
- MEDCouplingFieldDouble *crossProduct(const MEDCouplingFieldDouble& other) const { return crossProductFields(this,&other); }
- static MEDCouplingFieldDouble *maxFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2);
- MEDCouplingFieldDouble *max(const MEDCouplingFieldDouble& other) const { return maxFields(this,&other); }
- static MEDCouplingFieldDouble *minFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2);
- MEDCouplingFieldDouble *min(const MEDCouplingFieldDouble& other) const { return minFields(this,&other); }
- MEDCouplingFieldDouble *operator+(const MEDCouplingFieldDouble& other) const { return addFields(this,&other); }
- const MEDCouplingFieldDouble &operator+=(const MEDCouplingFieldDouble& other);
- static MEDCouplingFieldDouble *addFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2);
- MEDCouplingFieldDouble *operator-(const MEDCouplingFieldDouble& other) const { return substractFields(this,&other); }
- const MEDCouplingFieldDouble &operator-=(const MEDCouplingFieldDouble& other);
- static MEDCouplingFieldDouble *substractFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2);
- MEDCouplingFieldDouble *operator*(const MEDCouplingFieldDouble& other) const { return multiplyFields(this,&other); }
- const MEDCouplingFieldDouble &operator*=(const MEDCouplingFieldDouble& other);
- static MEDCouplingFieldDouble *multiplyFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2);
- MEDCouplingFieldDouble *operator/(const MEDCouplingFieldDouble& other) const { return divideFields(this,&other); }
- const MEDCouplingFieldDouble &operator/=(const MEDCouplingFieldDouble& other);
- static MEDCouplingFieldDouble *divideFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2);
+ static MEDCouplingFieldDouble *MergeFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2) throw(INTERP_KERNEL::Exception);
+ static MEDCouplingFieldDouble *MergeFields(const std::vector<const MEDCouplingFieldDouble *>& a) throw(INTERP_KERNEL::Exception);
+ static MEDCouplingFieldDouble *MeldFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2) throw(INTERP_KERNEL::Exception);
+ static MEDCouplingFieldDouble *DotFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2) throw(INTERP_KERNEL::Exception);
+ MEDCouplingFieldDouble *dot(const MEDCouplingFieldDouble& other) const throw(INTERP_KERNEL::Exception) { return DotFields(this,&other); }
+ static MEDCouplingFieldDouble *CrossProductFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2) throw(INTERP_KERNEL::Exception);
+ MEDCouplingFieldDouble *crossProduct(const MEDCouplingFieldDouble& other) const throw(INTERP_KERNEL::Exception) { return CrossProductFields(this,&other); }
+ static MEDCouplingFieldDouble *MaxFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2) throw(INTERP_KERNEL::Exception);
+ MEDCouplingFieldDouble *max(const MEDCouplingFieldDouble& other) const throw(INTERP_KERNEL::Exception) { return MaxFields(this,&other); }
+ static MEDCouplingFieldDouble *MinFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2) throw(INTERP_KERNEL::Exception);
+ MEDCouplingFieldDouble *min(const MEDCouplingFieldDouble& other) const throw(INTERP_KERNEL::Exception) { return MinFields(this,&other); }
+ MEDCouplingFieldDouble *operator+(const MEDCouplingFieldDouble& other) const throw(INTERP_KERNEL::Exception) { return AddFields(this,&other); }
+ const MEDCouplingFieldDouble &operator+=(const MEDCouplingFieldDouble& other) throw(INTERP_KERNEL::Exception);
+ static MEDCouplingFieldDouble *AddFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2) throw(INTERP_KERNEL::Exception);
+ MEDCouplingFieldDouble *operator-(const MEDCouplingFieldDouble& other) const throw(INTERP_KERNEL::Exception) { return SubstractFields(this,&other); }
+ const MEDCouplingFieldDouble &operator-=(const MEDCouplingFieldDouble& other) throw(INTERP_KERNEL::Exception);
+ static MEDCouplingFieldDouble *SubstractFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2) throw(INTERP_KERNEL::Exception);
+ MEDCouplingFieldDouble *operator*(const MEDCouplingFieldDouble& other) const throw(INTERP_KERNEL::Exception) { return MultiplyFields(this,&other); }
+ const MEDCouplingFieldDouble &operator*=(const MEDCouplingFieldDouble& other) throw(INTERP_KERNEL::Exception);
+ static MEDCouplingFieldDouble *MultiplyFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2) throw(INTERP_KERNEL::Exception);
+ MEDCouplingFieldDouble *operator/(const MEDCouplingFieldDouble& other) const throw(INTERP_KERNEL::Exception) { return DivideFields(this,&other); }
+ const MEDCouplingFieldDouble &operator/=(const MEDCouplingFieldDouble& other) throw(INTERP_KERNEL::Exception);
+ static MEDCouplingFieldDouble *DivideFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2) throw(INTERP_KERNEL::Exception);
+ public:
+ const MEDCouplingTimeDiscretization *getTimeDiscretizationUnderGround() const { return _time_discr; }
+ MEDCouplingTimeDiscretization *getTimeDiscretizationUnderGround() { return _time_discr; }
private:
MEDCouplingFieldDouble(TypeOfField type, TypeOfTimeDiscretization td);
+ MEDCouplingFieldDouble(const MEDCouplingFieldTemplate *ft, TypeOfTimeDiscretization td);
MEDCouplingFieldDouble(const MEDCouplingFieldDouble& other, bool deepCpy);
MEDCouplingFieldDouble(NatureOfField n, MEDCouplingTimeDiscretization *td, MEDCouplingFieldDiscretization *type);
~MEDCouplingFieldDouble();
private:
- NatureOfField _nature;
MEDCouplingTimeDiscretization *_time_discr;
};
}
--- /dev/null
+// Copyright (C) 2007-2010 CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#include "MEDCouplingFieldOverTime.hxx"
+#include "MEDCouplingMesh.hxx"
+
+#include <cmath>
+
+using namespace ParaMEDMEM;
+
+MEDCouplingFieldOverTime *MEDCouplingFieldOverTime::New(const std::vector<MEDCouplingFieldDouble *>& fs) throw(INTERP_KERNEL::Exception)
+{
+ return new MEDCouplingFieldOverTime(fs);
+}
+
+double MEDCouplingFieldOverTime::getTimeTolerance() const throw(INTERP_KERNEL::Exception)
+{
+ std::vector< MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> >::const_iterator it=_fs.begin();
+ if(_fs.empty())
+ throw INTERP_KERNEL::Exception("MEDCouplingFieldOverTime::getTimeTolerance : empty set !");
+ for(;it!=_fs.end();it++)
+ if((const MEDCouplingFieldDouble *)(*it)!=0)
+ return (*it)->getTimeTolerance();
+ throw INTERP_KERNEL::Exception("MEDCouplingFieldOverTime::getTimeTolerance : only empty fields in this !");
+}
+
+void MEDCouplingFieldOverTime::checkCoherency() const throw(INTERP_KERNEL::Exception)
+{
+ MEDCouplingMultiFields::checkCoherency();
+ std::vector< MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> >::const_iterator it=_fs.begin();
+ for(;it!=_fs.end();it++)
+ if((*it)->getTimeDiscretization()==NO_TIME)
+ {
+ std::ostringstream oss; oss << "MEDCouplingFieldOverTime::checkCoherency : At rank #" << std::distance(_fs.begin(),it) << " the field has no time !";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ if(_fs.empty())
+ return ;
+ it=_fs.begin();
+ const MEDCouplingFieldDouble& ref=*(*(it++));
+ int tt1,tt2;
+ double reft=ref.getEndTime(tt1,tt2);
+ double eps=getTimeTolerance();
+ int id=1;
+ for(;it!=_fs.end();it++,id++)
+ {
+ if(!ref.getMesh()->areCompatibleForMerge((*it)->getMesh()))
+ {
+ std::ostringstream oss; oss << "Field slice at rank #" << id << " is not compatible with the first !";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ double curt=(*it)->getStartTime(tt1,tt2);
+ if(curt<reft-eps)
+ throw INTERP_KERNEL::Exception("MEDCouplingFieldOverTime::checkCoherency : fields are NOT sorted properly in ascending time !");
+ reft=(*it)->getEndTime(tt1,tt2);
+ }
+}
+
+std::string MEDCouplingFieldOverTime::simpleRepr() const
+{
+ std::ostringstream ret;
+ ret << "MEDCouplingFieldOverTime with name : \"" << getName() << "\"\n";
+ ret << "Description of MEDCouplingFieldOverTime is : \"" << getDescription() << "\"\n";
+ ret << "Number of discretization : " << _fs.size() << "\n";
+ ret << "Number of different meshes : ";
+ std::vector<MEDCouplingMesh *> ms;
+ std::vector<int> refms;
+ try
+ {
+ ms=getDifferentMeshes(refms);
+ ret << ms.size() << "\n";
+ }
+ catch(INTERP_KERNEL::Exception& e)
+ { ret << "Current instance is INVALID !\n"; }
+ try
+ {
+ MEDCouplingDefinitionTime dt=getDefinitionTimeZone();
+ dt.appendRepr(ret);
+ }
+ catch(INTERP_KERNEL::Exception& e)
+ { ret << "Definition zone is INVALID !\n"; }
+ return ret.str();
+}
+
+bool MEDCouplingFieldOverTime::isEqual(const MEDCouplingMultiFields *other, double meshPrec, double valsPrec) const
+{
+ if(!MEDCouplingMultiFields::isEqual(other,meshPrec,valsPrec))
+ return false;
+ const MEDCouplingFieldOverTime *otherC=dynamic_cast<const MEDCouplingFieldOverTime *>(other);
+ if(!otherC)
+ return false;
+ // to implement
+ return true;
+}
+
+bool MEDCouplingFieldOverTime::isEqualWithoutConsideringStr(const MEDCouplingMultiFields *other, double meshPrec, double valsPrec) const
+{
+ if(!MEDCouplingMultiFields::isEqualWithoutConsideringStr(other,meshPrec,valsPrec))
+ return false;
+ const MEDCouplingFieldOverTime *otherC=dynamic_cast<const MEDCouplingFieldOverTime *>(other);
+ if(!otherC)
+ return false;
+ // to implement
+ return true;
+}
+
+std::vector<MEDCouplingMesh *> MEDCouplingFieldOverTime::getMeshes() const throw(INTERP_KERNEL::Exception)
+{
+ checkCoherency();
+ return MEDCouplingMultiFields::getMeshes();
+}
+
+std::vector<MEDCouplingMesh *> MEDCouplingFieldOverTime::getDifferentMeshes(std::vector<int>& refs) const throw(INTERP_KERNEL::Exception)
+{
+ checkCoherency();
+ return MEDCouplingMultiFields::getDifferentMeshes(refs);
+}
+
+std::vector<DataArrayDouble *> MEDCouplingFieldOverTime::getArrays() const throw(INTERP_KERNEL::Exception)
+{
+ checkCoherency();
+ return MEDCouplingMultiFields::getArrays();
+}
+
+std::vector<DataArrayDouble *> MEDCouplingFieldOverTime::getDifferentArrays(std::vector< std::vector<int> >& refs) const throw(INTERP_KERNEL::Exception)
+{
+ checkCoherency();
+ return MEDCouplingMultiFields::getDifferentArrays(refs);
+}
+
+MEDCouplingDefinitionTime MEDCouplingFieldOverTime::getDefinitionTimeZone() const
+{
+ std::vector< std::vector<int> > tmp;
+ getDifferentArrays(tmp);
+ std::vector<const MEDCouplingFieldDouble *> tmp2(_fs.begin(),_fs.end());
+ std::vector<int> tmp3;
+ getDifferentMeshes(tmp3);
+ return MEDCouplingDefinitionTime(tmp2,tmp3,tmp);
+}
+
+MEDCouplingFieldOverTime::MEDCouplingFieldOverTime(const std::vector<MEDCouplingFieldDouble *>& fs) throw(INTERP_KERNEL::Exception):MEDCouplingMultiFields(fs)
+{
+ checkCoherency();
+}
+
+MEDCouplingFieldOverTime::MEDCouplingFieldOverTime()
+{
+}
--- /dev/null
+// Copyright (C) 2007-2010 CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#ifndef __PARAMEDMEM_MEDCOUPLINGFIELDOVERTIME_HXX__
+#define __PARAMEDMEM_MEDCOUPLINGFIELDOVERTIME_HXX__
+
+#include "MEDCouplingMultiFields.hxx"
+#include "MEDCouplingDefinitionTime.hxx"
+#include "MEDCouplingFieldDouble.hxx"
+
+#include <vector>
+
+namespace ParaMEDMEM
+{
+ class MEDCouplingFieldOverTime : public MEDCouplingMultiFields
+ {
+ public:
+ static MEDCouplingFieldOverTime *New(const std::vector<MEDCouplingFieldDouble *>& fs) throw(INTERP_KERNEL::Exception);
+ void checkCoherency() const throw(INTERP_KERNEL::Exception);
+ double getTimeTolerance() const throw(INTERP_KERNEL::Exception);
+ std::string simpleRepr() const;
+ bool isEqual(const MEDCouplingMultiFields *other, double meshPrec, double valsPrec) const;
+ bool isEqualWithoutConsideringStr(const MEDCouplingMultiFields *other, double meshPrec, double valsPrec) const;
+ //void getIdsToFetch(double time, int& fieldId, int& arrId, int& meshId) const;
+ //void setFieldOnId(int fieldId, MEDCouplingFieldDouble *f);
+ //void dispatchPointers();
+ std::vector<MEDCouplingMesh *> getMeshes() const throw(INTERP_KERNEL::Exception);
+ std::vector<MEDCouplingMesh *> getDifferentMeshes(std::vector<int>& refs) const throw(INTERP_KERNEL::Exception);
+ std::vector<DataArrayDouble *> getArrays() const throw(INTERP_KERNEL::Exception);
+ std::vector<DataArrayDouble *> getDifferentArrays(std::vector< std::vector<int> >& refs) const throw(INTERP_KERNEL::Exception);
+ MEDCouplingDefinitionTime getDefinitionTimeZone() const;
+ protected:
+ MEDCouplingFieldOverTime();
+ private:
+ MEDCouplingFieldOverTime(const std::vector<MEDCouplingFieldDouble *>& fs) throw(INTERP_KERNEL::Exception);
+ };
+}
+
+#endif
--- /dev/null
+// Copyright (C) 2007-2010 CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#include "MEDCouplingFieldTemplate.hxx"
+#include "MEDCouplingMesh.hxx"
+#include "MEDCouplingFieldDouble.hxx"
+#include "MEDCouplingFieldDiscretization.hxx"
+
+using namespace ParaMEDMEM;
+
+MEDCouplingFieldTemplate *MEDCouplingFieldTemplate::New(const MEDCouplingFieldDouble *f) throw(INTERP_KERNEL::Exception)
+{
+ return new MEDCouplingFieldTemplate(f);
+}
+
+/*!
+ * The user should \b not use this method. Only useful for CORBA serialization/unserialization.
+ */
+MEDCouplingFieldTemplate *MEDCouplingFieldTemplate::New(TypeOfField type)
+{
+ return new MEDCouplingFieldTemplate(type);
+}
+
+MEDCouplingFieldTemplate::MEDCouplingFieldTemplate(const MEDCouplingFieldDouble *f) throw(INTERP_KERNEL::Exception):MEDCouplingField(*f)
+{
+ checkCoherency();
+}
+
+MEDCouplingFieldTemplate::MEDCouplingFieldTemplate(TypeOfField type):MEDCouplingField(type)
+{
+}
+
+void MEDCouplingFieldTemplate::checkCoherency() const throw(INTERP_KERNEL::Exception)
+{
+ if(_mesh==0)
+ throw INTERP_KERNEL::Exception("MEDCouplingFieldTemplate::checkCoherency : Empty mesh !");
+}
+
+std::string MEDCouplingFieldTemplate::simpleRepr() const
+{
+ std::ostringstream ret;
+ ret << "FieldTemplate with name : \"" << getName() << "\"\n";
+ ret << "Description of field is : \"" << getDescription() << "\"\n";
+ ret << "FieldTemplate space discretization is : " << _type->getStringRepr() << "\n";
+ ret << "FieldTemplate nature of field is : " << MEDCouplingNatureOfField::getRepr(_nature) << "\n";
+ if(_mesh)
+ ret << "Mesh support information :\n__________________________\n" << _mesh->simpleRepr();
+ else
+ ret << "Mesh support information : No mesh set !\n";
+ return ret.str();
+}
+
+std::string MEDCouplingFieldTemplate::advancedRepr() const
+{
+ return simpleRepr();
+}
+
+void MEDCouplingFieldTemplate::getTinySerializationIntInformation(std::vector<int>& tinyInfo) const
+{
+ tinyInfo.clear();
+ tinyInfo.push_back((int)_type->getEnum());
+ tinyInfo.push_back((int)_nature);
+ std::vector<int> tinyInfo2;
+ _type->getTinySerializationIntInformation(tinyInfo2);
+ tinyInfo.insert(tinyInfo.end(),tinyInfo2.begin(),tinyInfo2.end());
+ tinyInfo.push_back(tinyInfo2.size());
+}
+
+void MEDCouplingFieldTemplate::getTinySerializationDbleInformation(std::vector<double>& tinyInfo) const
+{
+ tinyInfo.clear();
+ _type->getTinySerializationDbleInformation(tinyInfo);
+}
+
+void MEDCouplingFieldTemplate::getTinySerializationStrInformation(std::vector<std::string>& tinyInfo) const
+{
+ tinyInfo.clear();
+ tinyInfo.push_back(_name);
+ tinyInfo.push_back(_desc);
+}
+
+void MEDCouplingFieldTemplate::resizeForUnserialization(const std::vector<int>& tinyInfoI, DataArrayInt *&dataInt)
+{
+ dataInt=0;
+ std::vector<int> tinyInfoITmp(tinyInfoI.begin()+2,tinyInfoI.end());
+ _type->resizeForUnserialization(tinyInfoITmp,dataInt);
+}
+
+void MEDCouplingFieldTemplate::finishUnserialization(const std::vector<int>& tinyInfoI, const std::vector<double>& tinyInfoD, const std::vector<std::string>& tinyInfoS)
+{
+ _nature=(NatureOfField)tinyInfoI[1];
+ _type->finishUnserialization(tinyInfoD);
+ _name=tinyInfoS[0];
+ _desc=tinyInfoS[1];
+}
+
+void MEDCouplingFieldTemplate::serialize(DataArrayInt *&dataInt) const
+{
+ _type->getSerializationIntArray(dataInt);
+}
+
--- /dev/null
+// Copyright (C) 2007-2010 CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#ifndef __PARAMEDMEM_MEDCOUPLINGFIELDTEMPLATE_HXX__
+#define __PARAMEDMEM_MEDCOUPLINGFIELDTEMPLATE_HXX__
+
+#include "MEDCouplingField.hxx"
+
+namespace ParaMEDMEM
+{
+ class MEDCouplingFieldDouble;
+
+ class MEDCouplingFieldTemplate : public MEDCouplingField
+ {
+ public:
+ static MEDCouplingFieldTemplate *New(const MEDCouplingFieldDouble *f) throw(INTERP_KERNEL::Exception);
+ static MEDCouplingFieldTemplate *New(TypeOfField type);
+ std::string simpleRepr() const;
+ std::string advancedRepr() const;
+ void checkCoherency() const throw(INTERP_KERNEL::Exception);
+ //
+ void getTinySerializationIntInformation(std::vector<int>& tinyInfo) const;
+ void getTinySerializationDbleInformation(std::vector<double>& tinyInfo) const;
+ void getTinySerializationStrInformation(std::vector<std::string>& tinyInfo) const;
+ void resizeForUnserialization(const std::vector<int>& tinyInfoI, DataArrayInt *&dataInt);
+ void finishUnserialization(const std::vector<int>& tinyInfoI, const std::vector<double>& tinyInfoD, const std::vector<std::string>& tinyInfoS);
+ void serialize(DataArrayInt *&dataInt) const;
+ //
+ private:
+ MEDCouplingFieldTemplate(const MEDCouplingFieldDouble *f) throw(INTERP_KERNEL::Exception);
+ MEDCouplingFieldTemplate(TypeOfField type);
+ };
+}
+
+#endif
#include <set>
#include <cmath>
+#include <limits>
#include <numeric>
#include <functional>
stream << "\n";
}
+std::vector<std::string> DataArray::getVarsOnComponent() const
+{
+ int nbOfCompo=(int)_info_on_compo.size();
+ std::vector<std::string> ret(nbOfCompo);
+ for(int i=0;i<nbOfCompo;i++)
+ ret[i]=getVarOnComponent(i);
+ return ret;
+}
+
+std::vector<std::string> DataArray::getUnitsOnComponent() const
+{
+ int nbOfCompo=(int)_info_on_compo.size();
+ std::vector<std::string> ret(nbOfCompo);
+ for(int i=0;i<nbOfCompo;i++)
+ ret[i]=getUnitOnComponent(i);
+ return ret;
+}
+
std::string DataArray::getInfoOnComponent(int i) const throw(INTERP_KERNEL::Exception)
{
if(i<(int)_info_on_compo.size())
}
}
+/*!
+ * In the info part of i_th component this method returns the var part.
+ * For example, if getInfoOnComponent(0) return "SIGXY (N/m^2)", getVarOnComponent(0) will return "SIGXY"
+ */
+std::string DataArray::getVarOnComponent(int i) const throw(INTERP_KERNEL::Exception)
+{
+ if(i<(int)_info_on_compo.size())
+ {
+ std::string st0=_info_on_compo[i];
+ std::size_t p1=st0.find_last_of('[');
+ std::size_t p2=st0.find_last_of(']');
+ if(p1==std::string::npos || p2==std::string::npos)
+ return st0;
+ if(p1>p2)
+ return st0;
+ if(p1==0)
+ return std::string();
+ std::size_t p3=st0.find_last_not_of(' ',p1-1);
+ return st0.substr(0,p3+1);
+ }
+ else
+ {
+ std::ostringstream oss; oss << "getVarOnComponent : Invalid component id transmitted (" << i << ") >= " << (int) _info_on_compo.size();
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+}
+
+/*!
+ * In the info part of i_th component this method returns the var part.
+ * For example, if getInfoOnComponent(0) return "SIGXY (N/m^2)", getUnitOnComponent(0) will return "N/m^2"
+ */
+std::string DataArray::getUnitOnComponent(int i) const throw(INTERP_KERNEL::Exception)
+{
+ if(i<(int)_info_on_compo.size())
+ {
+ std::string st0=_info_on_compo[i];
+ std::size_t p1=st0.find_last_of('[');
+ std::size_t p2=st0.find_last_of(']');
+ if(p1==std::string::npos || p2==std::string::npos)
+ return std::string();
+ if(p1>p2)
+ return std::string();
+ return st0.substr(p1+1,p2-p1-1);
+ }
+ else
+ {
+ std::ostringstream oss; oss << "getUnitOnComponent : Invalid component id transmitted (" << i << ") >= " << (int) _info_on_compo.size();
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+}
+
void DataArray::setInfoOnComponent(int i, const char *info) throw(INTERP_KERNEL::Exception)
{
if(i<(int)_info_on_compo.size())
}
}
+void DataArray::checkNbOfTuplesAndComp(const DataArray& other, const char *msg) const throw(INTERP_KERNEL::Exception)
+{
+ if(getNumberOfTuples()!=other.getNumberOfTuples())
+ {
+ std::ostringstream oss; oss << msg << " : mismatch number of tuples : expected " << other.getNumberOfTuples() << " having " << getNumberOfTuples() << " !";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ if(getNumberOfComponents()!=other.getNumberOfComponents())
+ {
+ std::ostringstream oss; oss << msg << " : mismatch number of components : expected " << other.getNumberOfComponents() << " having " << getNumberOfComponents() << " !";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+}
+
+void DataArray::checkNbOfTuplesAndComp(int nbOfTuples, int nbOfCompo, const char *msg) const throw(INTERP_KERNEL::Exception)
+{
+ if(getNumberOfTuples()!=nbOfTuples)
+ {
+ std::ostringstream oss; oss << msg << " : mismatch number of tuples : expected " << nbOfTuples << " having " << getNumberOfTuples() << " !";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ if(getNumberOfComponents()!=nbOfCompo)
+ {
+ std::ostringstream oss; oss << msg << " : mismatch number of components : expected " << nbOfCompo << " having " << getNumberOfComponents() << " !";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+}
+
+void DataArray::checkNbOfElems(int nbOfElems, const char *msg) const throw(INTERP_KERNEL::Exception)
+{
+ if(getNbOfElems()!=nbOfElems)
+ {
+ std::ostringstream oss; oss << msg << " : mismatch number of elems : Expected " << nbOfElems << " having " << getNbOfElems() << " !";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+}
+
+void DataArray::CheckValueInRange(int ref, int value, const char *msg) throw(INTERP_KERNEL::Exception)
+{
+ if(value<0 || value>=ref)
+ {
+ std::ostringstream oss; oss << "DataArray::CheckValueInRange : " << msg << " ! Expected in range [0," << ref << ") having " << value << " !";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+}
+
+void DataArray::CheckClosingParInRange(int ref, int value, const char *msg) throw(INTERP_KERNEL::Exception)
+{
+ if(value<0 || value>ref)
+ {
+ std::ostringstream oss; oss << "DataArray::CheckClosingParInRange : " << msg << " ! Expected a range in [0," << ref << ") having closing open parenthesis " << value << " !";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+}
+
+int DataArray::GetNumberOfItemGivenBES(int begin, int end, int step, const char *msg) throw(INTERP_KERNEL::Exception)
+{
+ if(end<begin)
+ {
+ std::ostringstream oss; oss << msg << " : end before begin !";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ if(step<=0)
+ {
+ std::ostringstream oss; oss << msg << " : invalid step should be > 0 !";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ return (end-1-begin)/step+1;
+}
+
DataArrayDouble *DataArrayDouble::New()
{
return new DataArrayDouble;
throw INTERP_KERNEL::Exception("DataArrayDouble::checkAllocated : Array is defined but not allocated ! Call alloc or setValues method first !");
}
-DataArrayDouble *DataArrayDouble::deepCopy() const
+DataArrayDouble *DataArrayDouble::deepCpy() const
{
return new DataArrayDouble(*this);
}
-DataArrayDouble *DataArrayDouble::performCpy(bool deepCpy) const
+DataArrayDouble *DataArrayDouble::performCpy(bool dCpy) const
{
- if(deepCpy)
- return deepCopy();
+ if(dCpy)
+ return deepCpy();
else
{
incrRef();
}
}
+void DataArrayDouble::cpyFrom(const DataArrayDouble& other) throw(INTERP_KERNEL::Exception)
+{
+ other.checkAllocated();
+ int nbOfTuples=other.getNumberOfTuples();
+ int nbOfComp=other.getNumberOfComponents();
+ allocIfNecessary(nbOfTuples,nbOfComp);
+ int nbOfElems=nbOfTuples*nbOfComp;
+ double *pt=getPointer();
+ const double *ptI=other.getConstPointer();
+ for(int i=0;i<nbOfElems;i++)
+ pt[i]=ptI[i];
+ copyStringInfoFrom(other);
+}
+
+void DataArrayDouble::allocIfNecessary(int nbOfTuple, int nbOfCompo)
+{
+ if(isAllocated())
+ {
+ if(nbOfTuple!=getNumberOfTuples() || nbOfCompo!=getNumberOfComponents())
+ alloc(nbOfTuple,nbOfCompo);
+ }
+ else
+ alloc(nbOfTuple,nbOfCompo);
+}
+
void DataArrayDouble::alloc(int nbOfTuple, int nbOfCompo)
{
_nb_of_tuples=nbOfTuple;
if(!ptr)
throw INTERP_KERNEL::Exception("DataArrayDouble::iota : allocate first !");
if(getNumberOfComponents()!=1)
- throw INTERP_KERNEL::Exception("DataArrayDouble::iota : works only for arrays with only one component!");
+ throw INTERP_KERNEL::Exception("DataArrayDouble::iota : works only for arrays with only one component, you can call 'rearrange' method before !");
int ntuples=getNumberOfTuples();
for(int i=0;i<ntuples;i++)
ptr[i]=init+double(i);
bool DataArrayDouble::isUniform(double val, double eps) const
{
if(getNumberOfComponents()!=1)
- throw INTERP_KERNEL::Exception("DataArrayDouble::isUniform : must be applied on DataArrayDouble with only one component !");
+ throw INTERP_KERNEL::Exception("DataArrayDouble::isUniform : must be applied on DataArrayDouble with only one component, you can call 'rearrange' method before !");
int nbOfTuples=getNumberOfTuples();
const double *w=getConstPointer();
const double *end=w+nbOfTuples;
return true;
}
+void DataArrayDouble::sort() throw(INTERP_KERNEL::Exception)
+{
+ checkAllocated();
+ if(getNumberOfComponents()!=1)
+ throw INTERP_KERNEL::Exception("DataArrayDouble::sort : only supported with 'this' array with ONE component !");
+ _mem.sort();
+}
+
+void DataArrayDouble::checkMonotonic(double eps) const throw(INTERP_KERNEL::Exception)
+{
+ if(!isMonotonic(eps))
+ throw INTERP_KERNEL::Exception("DataArrayDouble::checkMonotonic : 'this' is not monotonic !");
+}
+
+bool DataArrayDouble::isMonotonic(double eps) const throw(INTERP_KERNEL::Exception)
+{
+ checkAllocated();
+ if(getNumberOfComponents()!=1)
+ throw INTERP_KERNEL::Exception("DataArrayDouble::isMonotonic : only supported with 'this' array with ONE component !");
+ int nbOfElements=getNumberOfTuples();
+ const double *ptr=getConstPointer();
+ if(nbOfElements==0)
+ return true;
+ double ref=ptr[0];
+ for(int i=1;i<nbOfElements;i++)
+ {
+ if(ptr[i]<ref+eps)
+ return false;
+ ref=ptr[i];
+ }
+ return true;
+}
+
std::string DataArrayDouble::repr() const
{
std::ostringstream ret;
return ret;
}
+/*!
+ * This method is equivalent to DataArrayDouble::selectByTupleId except that an analyze to the content of input range to check that it will not lead to memory corruption !
+ */
+DataArrayDouble *DataArrayDouble::selectByTupleIdSafe(const int *new2OldBg, const int *new2OldEnd) const throw(INTERP_KERNEL::Exception)
+{
+ MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> ret=DataArrayDouble::New();
+ int nbComp=getNumberOfComponents();
+ int oldNbOfTuples=getNumberOfTuples();
+ ret->alloc(std::distance(new2OldBg,new2OldEnd),nbComp);
+ ret->copyStringInfoFrom(*this);
+ double *pt=ret->getPointer();
+ const double *srcPt=getConstPointer();
+ int i=0;
+ for(const int *w=new2OldBg;w!=new2OldEnd;w++,i++)
+ if(*w>=0 && *w<oldNbOfTuples)
+ std::copy(srcPt+(*w)*nbComp,srcPt+((*w)+1)*nbComp,pt+i*nbComp);
+ else
+ throw INTERP_KERNEL::Exception("DataArrayInt::selectByTupleIdSafe : some ids has been detected to be out of [0,this->getNumberOfTuples) !");
+ ret->copyStringInfoFrom(*this);
+ ret->incrRef();
+ return ret;
+}
+
+/*!
+ * Idem than DataArrayInt::selectByTupleIdSafe except that the input array is not constructed explicitely.
+ * The convention is as python one. ['bg','end') with steps of 'step'.
+ * Returns a newly created array.
+ */
+DataArrayDouble *DataArrayDouble::selectByTupleId2(int bg, int end, int step) const throw(INTERP_KERNEL::Exception)
+{
+ if(end<bg)
+ throw INTERP_KERNEL::Exception("DataArrayDouble::selectByTupleId2 : end before begin !");
+ if(step<=0)
+ throw INTERP_KERNEL::Exception("DataArrayDouble::selectByTupleId2 : invalid step should > 0 !");
+ MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> ret=DataArrayDouble::New();
+ int nbComp=getNumberOfComponents();
+ int newNbOfTuples=(end-1-bg)/step+1;
+ ret->alloc(newNbOfTuples,nbComp);
+ double *pt=ret->getPointer();
+ const double *srcPt=getConstPointer()+bg*nbComp;
+ for(int i=0;i<newNbOfTuples;i++,srcPt+=step*nbComp)
+ std::copy(srcPt,srcPt+nbComp,pt+i*nbComp);
+ ret->copyStringInfoFrom(*this);
+ ret->incrRef();
+ return ret;
+}
+
/*!
* This methods has a similar behaviour than std::string::substr. This method returns a newly created DataArrayInt that is part of this with same number of components.
* The intervall is specified by [tupleIdBg,tupleIdEnd) except if tupleIdEnd ==-1 in this case the [tupleIdBg,this->end()) will be kept.
int nbt=getNumberOfTuples();
if(tupleIdBg<0)
throw INTERP_KERNEL::Exception("DataArrayInt::substr : The tupleIdBg parameter must be greater than 0 !");
- if(tupleIdBg>=nbt)
- throw INTERP_KERNEL::Exception("DataArrayInt::substr : The tupleIdBg parameter is greater or equal than number of tuples !");
+ if(tupleIdBg>nbt)
+ throw INTERP_KERNEL::Exception("DataArrayInt::substr : The tupleIdBg parameter is greater than number of tuples !");
int trueEnd=tupleIdEnd;
if(tupleIdEnd!=-1)
{
return ret;
}
+/*!
+ * Contrary to DataArrayDouble::changeNbOfComponents method this method is \b not const. The content
+ * This method \b do \b not change the content of data but changes the splitting of this data seen by the caller.
+ * This method makes the assumption that 'this' is already allocated. If not an exception will be thrown.
+ * This method checks that getNbOfElems()%newNbOfCompo==0. If not an exception will be throw !
+ * This method erases all components info set before call !
+ */
+void DataArrayDouble::rearrange(int newNbOfCompo) throw(INTERP_KERNEL::Exception)
+{
+ checkAllocated();
+ int nbOfElems=getNbOfElems();
+ if(nbOfElems%newNbOfCompo!=0)
+ throw INTERP_KERNEL::Exception("DataArrayDouble::rearrange : nbOfElems%newNbOfCompo!=0 !");
+ _nb_of_tuples=nbOfElems/newNbOfCompo;
+ _info_on_compo.clear();
+ _info_on_compo.resize(newNbOfCompo);
+ declareAsNew();
+}
+
DataArrayDouble *DataArrayDouble::keepSelectedComponents(const std::vector<int>& compoIds) const throw(INTERP_KERNEL::Exception)
{
checkAllocated();
MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> ret(DataArrayDouble::New());
int newNbOfCompo=compoIds.size();
int oldNbOfCompo=getNumberOfComponents();
+ for(std::vector<int>::const_iterator it=compoIds.begin();it!=compoIds.end();it++)
+ if((*it)<0 || (*it)>=oldNbOfCompo)
+ {
+ std::ostringstream oss; oss << "DataArrayDouble::keepSelectedComponents : invalid requested component : " << *it << " whereas it should be in [0," << oldNbOfCompo << ") !";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
int nbOfTuples=getNumberOfTuples();
ret->alloc(nbOfTuples,newNbOfCompo);
ret->copyPartOfStringInfoFrom(*this,compoIds);
return ret;
}
+/*!
+ * This method melds the components of 'this' with components of 'other'.
+ * After this call in case of success, 'this' will contain a number of components equal to the sum of 'this'
+ * before the call and the number of components of 'other'.
+ * This method expects that 'this' and 'other' have exactly the same number of tuples. If not an exception is thrown.
+ */
+void DataArrayDouble::meldWith(const DataArrayDouble *other) throw(INTERP_KERNEL::Exception)
+{
+ checkAllocated();
+ other->checkAllocated();
+ int nbOfTuples=getNumberOfTuples();
+ if(nbOfTuples!=other->getNumberOfTuples())
+ throw INTERP_KERNEL::Exception("DataArrayDouble::meldWith : mismatch of number of tuples !");
+ int nbOfComp1=getNumberOfComponents();
+ int nbOfComp2=other->getNumberOfComponents();
+ double *newArr=new double[nbOfTuples*(nbOfComp1+nbOfComp2)];
+ double *w=newArr;
+ const double *inp1=getConstPointer();
+ const double *inp2=other->getConstPointer();
+ for(int i=0;i<nbOfTuples;i++,inp1+=nbOfComp1,inp2+=nbOfComp2)
+ {
+ w=std::copy(inp1,inp1+nbOfComp1,w);
+ w=std::copy(inp2,inp2+nbOfComp2,w);
+ }
+ useArray(newArr,true,CPP_DEALLOC,nbOfTuples,nbOfComp1+nbOfComp2);
+ std::vector<int> compIds(nbOfComp2);
+ for(int i=0;i<nbOfComp2;i++)
+ compIds[i]=nbOfComp1+i;
+ copyPartOfStringInfoFrom2(compIds,*other);
+}
+
void DataArrayDouble::setSelectedComponents(const DataArrayDouble *a, const std::vector<int>& compoIds) throw(INTERP_KERNEL::Exception)
{
copyPartOfStringInfoFrom2(compoIds,*a);
nc[nbOfCompo*i+compoIds[j]]=*ac;
}
-void DataArrayDouble::setArrayIn(DataArrayDouble *newArray, DataArrayDouble* &arrayToSet)
+/*!
+ * This method performs a partial assignment of 'this' using 'a' as input. Other input parameters specifies the subpart being considered by the assignment.
+ * 'strictCompoCompare' specifies if DataArray 'a' should have exactly same number of components and tuples than 'this' (true) or not (false). By default set to true with maximal test.
+ */
+void DataArrayDouble::setPartOfValues1(const DataArrayDouble *a, int bgTuples, int endTuples, int stepTuples, int bgComp, int endComp, int stepComp, bool strictCompoCompare) throw(INTERP_KERNEL::Exception)
+{
+ const char msg[]="DataArrayDouble::setPartOfValues1";
+ checkAllocated();
+ a->checkAllocated();
+ int newNbOfTuples=DataArray::GetNumberOfItemGivenBES(bgTuples,endTuples,stepTuples,msg);
+ int newNbOfComp=DataArray::GetNumberOfItemGivenBES(bgComp,endComp,stepComp,msg);
+ int nbComp=getNumberOfComponents();
+ int nbOfTuples=getNumberOfTuples();
+ DataArray::CheckValueInRange(nbOfTuples,bgTuples,"invalid begin tuple value");
+ DataArray::CheckClosingParInRange(nbOfTuples,endTuples,"invalid end tuple value");
+ DataArray::CheckValueInRange(nbComp,bgComp,"invalid begin component value");
+ DataArray::CheckClosingParInRange(nbComp,endComp,"invalid end component value");
+ a->checkNbOfElems(newNbOfTuples*newNbOfComp,msg);
+ if(strictCompoCompare)
+ a->checkNbOfTuplesAndComp(newNbOfTuples,newNbOfComp,msg);
+ double *pt=getPointer()+bgTuples*nbComp+bgComp;
+ const double *srcPt=a->getConstPointer();
+ for(int i=0;i<newNbOfTuples;i++,pt+=stepTuples*nbComp)
+ for(int j=0;j<newNbOfComp;j++,srcPt++)
+ pt[j*stepComp]=*srcPt;
+}
+
+/*!
+ * This method performs a partial assignment of 'this' using 'a' as input. Other input parameters specifies the subpart being considered by the assignment.
+ */
+void DataArrayDouble::setPartOfValuesSimple1(double a, int bgTuples, int endTuples, int stepTuples, int bgComp, int endComp, int stepComp) throw(INTERP_KERNEL::Exception)
+{
+ const char msg[]="DataArrayDouble::setPartOfValuesSimple1";
+ checkAllocated();
+ int newNbOfTuples=DataArray::GetNumberOfItemGivenBES(bgTuples,endTuples,stepTuples,msg);
+ int newNbOfComp=DataArray::GetNumberOfItemGivenBES(bgComp,endComp,stepComp,msg);
+ int nbComp=getNumberOfComponents();
+ int nbOfTuples=getNumberOfTuples();
+ DataArray::CheckValueInRange(nbOfTuples,bgTuples,"invalid begin tuple value");
+ DataArray::CheckClosingParInRange(nbOfTuples,endTuples,"invalid end tuple value");
+ DataArray::CheckValueInRange(nbComp,bgComp,"invalid begin component value");
+ DataArray::CheckClosingParInRange(nbComp,endComp,"invalid end component value");
+ double *pt=getPointer()+bgTuples*nbComp+bgComp;
+ for(int i=0;i<newNbOfTuples;i++,pt+=stepTuples*nbComp)
+ for(int j=0;j<newNbOfComp;j++)
+ pt[j*stepComp]=a;
+}
+
+/*!
+ * This method performs a partial assignment of 'this' using 'a' as input. Other input parameters specifies the subpart being considered by the assignment.
+ * 'strictCompoCompare' specifies if DataArray 'a' should have exactly same number of components and tuples than 'this' (true) or not (false). By default set to true with maximal test.
+ */
+void DataArrayDouble::setPartOfValues2(const DataArrayDouble *a, const int *bgTuples, const int *endTuples, const int *bgComp, const int *endComp, bool strictCompoCompare) throw(INTERP_KERNEL::Exception)
+{
+ const char msg[]="DataArrayDouble::setPartOfValues2";
+ checkAllocated();
+ a->checkAllocated();
+ int nbComp=getNumberOfComponents();
+ int nbOfTuples=getNumberOfTuples();
+ for(const int *z=bgComp;z!=endComp;z++)
+ DataArray::CheckValueInRange(nbComp,*z,"invalid component id");
+ int newNbOfTuples=std::distance(bgTuples,endTuples);
+ int newNbOfComp=std::distance(bgComp,endComp);
+ a->checkNbOfElems(newNbOfTuples*newNbOfComp,msg);
+ if(strictCompoCompare)
+ a->checkNbOfTuplesAndComp(newNbOfTuples,newNbOfComp,msg);
+ double *pt=getPointer();
+ const double *srcPt=a->getConstPointer();
+ for(const int *w=bgTuples;w!=endTuples;w++)
+ for(const int *z=bgComp;z!=endComp;z++,srcPt++)
+ {
+ DataArray::CheckValueInRange(nbOfTuples,*w,"invalid tuple id");
+ pt[(*w)*nbComp+(*z)]=*srcPt;
+ }
+}
+
+/*!
+ * This method performs a partial assignment of 'this' using 'a' as input. Other input parameters specifies the subpart being considered by the assignment.
+ */
+void DataArrayDouble::setPartOfValuesSimple2(double a, const int *bgTuples, const int *endTuples, const int *bgComp, const int *endComp) throw(INTERP_KERNEL::Exception)
+{
+ checkAllocated();
+ int nbComp=getNumberOfComponents();
+ int nbOfTuples=getNumberOfTuples();
+ for(const int *z=bgComp;z!=endComp;z++)
+ DataArray::CheckValueInRange(nbComp,*z,"invalid component id");
+ double *pt=getPointer();
+ for(const int *w=bgTuples;w!=endTuples;w++)
+ for(const int *z=bgComp;z!=endComp;z++)
+ {
+ DataArray::CheckValueInRange(nbOfTuples,*w,"invalid tuple id");
+ pt[(*w)*nbComp+(*z)]=a;
+ }
+}
+
+/*!
+ * This method performs a partial assignment of 'this' using 'a' as input. Other input parameters specifies the subpart being considered by the assignment.
+ * 'strictCompoCompare' specifies if DataArray 'a' should have exactly same number of components and tuples than 'this' (true) or not (false). By default set to true with maximal test.
+ */
+void DataArrayDouble::setPartOfValues3(const DataArrayDouble *a, const int *bgTuples, const int *endTuples, int bgComp, int endComp, int stepComp, bool strictCompoCompare) throw(INTERP_KERNEL::Exception)
+{
+ const char msg[]="DataArrayDouble::setPartOfValues3";
+ checkAllocated();
+ a->checkAllocated();
+ int newNbOfComp=DataArray::GetNumberOfItemGivenBES(bgComp,endComp,stepComp,msg);
+ int nbComp=getNumberOfComponents();
+ int nbOfTuples=getNumberOfTuples();
+ DataArray::CheckValueInRange(nbComp,bgComp,"invalid begin component value");
+ DataArray::CheckClosingParInRange(nbComp,endComp,"invalid end component value");
+ int newNbOfTuples=std::distance(bgTuples,endTuples);
+ a->checkNbOfElems(newNbOfTuples*newNbOfComp,msg);
+ if(strictCompoCompare)
+ a->checkNbOfTuplesAndComp(newNbOfTuples,newNbOfComp,msg);
+ double *pt=getPointer()+bgComp;
+ const double *srcPt=a->getConstPointer();
+ for(const int *w=bgTuples;w!=endTuples;w++)
+ for(int j=0;j<newNbOfComp;j++,srcPt++)
+ {
+ DataArray::CheckValueInRange(nbOfTuples,*w,"invalid tuple id");
+ pt[(*w)*nbComp+j*stepComp]=*srcPt;
+ }
+}
+
+/*!
+ * This method performs a partial assignment of 'this' using 'a' as input. Other input parameters specifies the subpart being considered by the assignment.
+ */
+void DataArrayDouble::setPartOfValuesSimple3(double a, const int *bgTuples, const int *endTuples, int bgComp, int endComp, int stepComp) throw(INTERP_KERNEL::Exception)
+{
+ const char msg[]="DataArrayDouble::setPartOfValuesSimple3";
+ checkAllocated();
+ int newNbOfComp=DataArray::GetNumberOfItemGivenBES(bgComp,endComp,stepComp,msg);
+ int nbComp=getNumberOfComponents();
+ int nbOfTuples=getNumberOfTuples();
+ DataArray::CheckValueInRange(nbComp,bgComp,"invalid begin component value");
+ DataArray::CheckClosingParInRange(nbComp,endComp,"invalid end component value");
+ double *pt=getPointer()+bgComp;
+ for(const int *w=bgTuples;w!=endTuples;w++)
+ for(int j=0;j<newNbOfComp;j++)
+ {
+ DataArray::CheckValueInRange(nbOfTuples,*w,"invalid tuple id");
+ pt[(*w)*nbComp+j*stepComp]=a;
+ }
+}
+
+void DataArrayDouble::SetArrayIn(DataArrayDouble *newArray, DataArrayDouble* &arrayToSet)
{
if(newArray!=arrayToSet)
{
double DataArrayDouble::getMaxValue(int& tupleId) const throw(INTERP_KERNEL::Exception)
{
if(getNumberOfComponents()!=1)
- throw INTERP_KERNEL::Exception("DataArrayDouble::getMaxValue : must be applied on DataArrayDouble with only one component !");
+ throw INTERP_KERNEL::Exception("DataArrayDouble::getMaxValue : must be applied on DataArrayDouble with only one component, you can call 'rearrange' method before !");
int nbOfTuples=getNumberOfTuples();
if(nbOfTuples<=0)
throw INTERP_KERNEL::Exception("DataArrayDouble::getMaxValue : array exists but number of tuples must be > 0 !");
double DataArrayDouble::getMinValue(int& tupleId) const throw(INTERP_KERNEL::Exception)
{
if(getNumberOfComponents()!=1)
- throw INTERP_KERNEL::Exception("DataArrayDouble::getMinValue : must be applied on DataArrayDouble with only one component !");
+ throw INTERP_KERNEL::Exception("DataArrayDouble::getMinValue : must be applied on DataArrayDouble with only one component, you can call 'rearrange' method before !");
int nbOfTuples=getNumberOfTuples();
if(nbOfTuples<=0)
throw INTERP_KERNEL::Exception("DataArrayDouble::getMinValue : array exists but number of tuples must be > 0 !");
double DataArrayDouble::getAverageValue() const throw(INTERP_KERNEL::Exception)
{
if(getNumberOfComponents()!=1)
- throw INTERP_KERNEL::Exception("DataArrayDouble::getAverageValue : must be applied on DataArrayDouble with only one component !");
+ throw INTERP_KERNEL::Exception("DataArrayDouble::getAverageValue : must be applied on DataArrayDouble with only one component, you can call 'rearrange' method before !");
int nbOfTuples=getNumberOfTuples();
if(nbOfTuples<=0)
throw INTERP_KERNEL::Exception("DataArrayDouble::getAverageValue : array exists but number of tuples must be > 0 !");
declareAsNew();
}
+void DataArrayDouble::applyLin(double a, double b) throw(INTERP_KERNEL::Exception)
+{
+ checkAllocated();
+ double *ptr=getPointer();
+ int nbOfElems=getNbOfElems();
+ for(int i=0;i<nbOfElems;i++,ptr++)
+ *ptr=a*(*ptr)+b;
+ declareAsNew();
+}
+
+/*!
+ * This method applies the operation 'numerator/x' for each element 'x' in 'this'.
+ * If there is a value in 'this' exactly equal to 0. an exception is thrown.
+ * Warning if presence of null this is modified for each values previous than place where exception was thrown !
+ */
+void DataArrayDouble::applyInv(double numerator) throw(INTERP_KERNEL::Exception)
+{
+ checkAllocated();
+ double *ptr=getPointer();
+ int nbOfElems=getNbOfElems();
+ for(int i=0;i<nbOfElems;i++,ptr++)
+ {
+ if(*ptr!=0.)
+ {
+ *ptr=numerator/(*ptr);
+ }
+ else
+ {
+ std::ostringstream oss; oss << "DataArrayDouble::applyInv : presence of null value in tuple #" << i/getNumberOfComponents() << " component #" << i%getNumberOfComponents();
+ oss << " !";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ }
+ declareAsNew();
+}
+
DataArrayDouble *DataArrayDouble::applyFunc(int nbOfComp, FunctionToEvaluate func) const throw(INTERP_KERNEL::Exception)
{
checkAllocated();
int oldNbOfComp=getNumberOfComponents();
if((int)vars.size()>oldNbOfComp)
{
- std::ostringstream oss; oss << "The field has a " << oldNbOfComp << " components and there are ";
+ std::ostringstream oss; oss << "The field has " << oldNbOfComp << " components and there are ";
oss << vars.size() << " variables : ";
std::copy(vars.begin(),vars.end(),std::ostream_iterator<std::string>(oss," "));
throw INTERP_KERNEL::Exception(oss.str().c_str());
return newArr;
}
-void DataArrayDouble::applyFuncFast32(const char *func) throw(INTERP_KERNEL::Exception)
+/*!
+ * This method is equivalent than DataArrayDouble::applyFunc, except that here components names are used to determine vars orders.
+ * If 'func' contains vars that are not in \c this->getInfoOnComponent() an exception will be thrown.
+ */
+DataArrayDouble *DataArrayDouble::applyFunc2(int nbOfComp, const char *func) const throw(INTERP_KERNEL::Exception)
{
checkAllocated();
INTERP_KERNEL::ExprParser expr(func);
expr.parse();
- char *funcStr=expr.compileX86();
- MYFUNCPTR funcPtr=(MYFUNCPTR)funcStr;//he he...
+ std::set<std::string> vars;
+ expr.getTrueSetOfVars(vars);
+ int oldNbOfComp=getNumberOfComponents();
+ if((int)vars.size()>oldNbOfComp)
+ {
+ std::ostringstream oss; oss << "The field has " << oldNbOfComp << " components and there are ";
+ oss << vars.size() << " variables : ";
+ std::copy(vars.begin(),vars.end(),std::ostream_iterator<std::string>(oss," "));
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ expr.prepareExprEvaluation(getVarsOnComponent());
//
- double *ptr=getPointer();
- int nbOfComp=getNumberOfComponents();
+ DataArrayDouble *newArr=DataArrayDouble::New();
int nbOfTuples=getNumberOfTuples();
- int nbOfElems=nbOfTuples*nbOfComp;
- for(int i=0;i<nbOfElems;i++,ptr++)
+ newArr->alloc(nbOfTuples,nbOfComp);
+ const double *ptr=getConstPointer();
+ double *ptrToFill=newArr->getPointer();
+ for(int i=0;i<nbOfTuples;i++)
+ {
+ try
+ {
+ expr.evaluateExpr(nbOfComp,ptr+i*oldNbOfComp,ptrToFill+i*nbOfComp);
+ }
+ catch(INTERP_KERNEL::Exception& e)
+ {
+ std::ostringstream oss; oss << "For tuple # " << i << " with value (";
+ std::copy(ptr+oldNbOfComp*i,ptr+oldNbOfComp*(i+1),std::ostream_iterator<double>(oss,", "));
+ oss << ") : Evaluation of function failed !" << e.what();
+ newArr->decrRef();
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ }
+ return newArr;
+}
+
+/*!
+ * This method is equivalent than DataArrayDouble::applyFunc, except that here order of vars is passed explicitely in parameter.
+ * In 'func' contains vars not in 'varsOrder' an exception will be thrown.
+ */
+DataArrayDouble *DataArrayDouble::applyFunc3(int nbOfComp, const std::vector<std::string>& varsOrder, const char *func) const throw(INTERP_KERNEL::Exception)
+{
+ checkAllocated();
+ INTERP_KERNEL::ExprParser expr(func);
+ expr.parse();
+ std::set<std::string> vars;
+ expr.getTrueSetOfVars(vars);
+ int oldNbOfComp=getNumberOfComponents();
+ if((int)vars.size()>oldNbOfComp)
+ {
+ std::ostringstream oss; oss << "The field has " << oldNbOfComp << " components and there are ";
+ oss << vars.size() << " variables : ";
+ std::copy(vars.begin(),vars.end(),std::ostream_iterator<std::string>(oss," "));
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ expr.prepareExprEvaluation(varsOrder);
+ //
+ DataArrayDouble *newArr=DataArrayDouble::New();
+ int nbOfTuples=getNumberOfTuples();
+ newArr->alloc(nbOfTuples,nbOfComp);
+ const double *ptr=getConstPointer();
+ double *ptrToFill=newArr->getPointer();
+ for(int i=0;i<nbOfTuples;i++)
+ {
+ try
+ {
+ expr.evaluateExpr(nbOfComp,ptr+i*oldNbOfComp,ptrToFill+i*nbOfComp);
+ }
+ catch(INTERP_KERNEL::Exception& e)
+ {
+ std::ostringstream oss; oss << "For tuple # " << i << " with value (";
+ std::copy(ptr+oldNbOfComp*i,ptr+oldNbOfComp*(i+1),std::ostream_iterator<double>(oss,", "));
+ oss << ") : Evaluation of function failed !" << e.what();
+ newArr->decrRef();
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ }
+ return newArr;
+}
+
+void DataArrayDouble::applyFuncFast32(const char *func) throw(INTERP_KERNEL::Exception)
+{
+ checkAllocated();
+ INTERP_KERNEL::ExprParser expr(func);
+ expr.parse();
+ char *funcStr=expr.compileX86();
+ MYFUNCPTR funcPtr=(MYFUNCPTR)funcStr;//he he...
+ //
+ double *ptr=getPointer();
+ int nbOfComp=getNumberOfComponents();
+ int nbOfTuples=getNumberOfTuples();
+ int nbOfElems=nbOfTuples*nbOfComp;
+ for(int i=0;i<nbOfElems;i++,ptr++)
*ptr=funcPtr(*ptr);
declareAsNew();
}
return ret;
}
-DataArrayDouble *DataArrayDouble::aggregate(const DataArrayDouble *a1, const DataArrayDouble *a2) throw(INTERP_KERNEL::Exception)
+DataArrayDouble *DataArrayDouble::Aggregate(const DataArrayDouble *a1, const DataArrayDouble *a2) throw(INTERP_KERNEL::Exception)
{
- int nbOfComp=a1->getNumberOfComponents();
- if(nbOfComp!=a2->getNumberOfComponents())
- throw INTERP_KERNEL::Exception("Nb of components mismatch for array aggregation !");
- int nbOfTuple1=a1->getNumberOfTuples();
- int nbOfTuple2=a2->getNumberOfTuples();
+ std::vector<const DataArrayDouble *> tmp(2);
+ tmp[0]=a1; tmp[1]=a2;
+ return Aggregate(tmp);
+}
+
+DataArrayDouble *DataArrayDouble::Aggregate(const std::vector<const DataArrayDouble *>& a) throw(INTERP_KERNEL::Exception)
+{
+ if(a.empty())
+ throw INTERP_KERNEL::Exception("DataArrayDouble::Aggregate : input list must be NON EMPTY !");
+ std::vector<const DataArrayDouble *>::const_iterator it=a.begin();
+ int nbOfComp=(*it)->getNumberOfComponents();
+ int nbt=(*it++)->getNumberOfTuples();
+ for(int i=1;it!=a.end();it++,i++)
+ {
+ if((*it)->getNumberOfComponents()!=nbOfComp)
+ throw INTERP_KERNEL::Exception("DataArrayDouble::Aggregate : Nb of components mismatch for array aggregation !");
+ nbt+=(*it)->getNumberOfTuples();
+ }
DataArrayDouble *ret=DataArrayDouble::New();
- ret->alloc(nbOfTuple1+nbOfTuple2,nbOfComp);
- double *pt=std::copy(a1->getConstPointer(),a1->getConstPointer()+nbOfTuple1*nbOfComp,ret->getPointer());
- std::copy(a2->getConstPointer(),a2->getConstPointer()+nbOfTuple2*nbOfComp,pt);
- ret->copyStringInfoFrom(*a1);
+ ret->alloc(nbt,nbOfComp);
+ double *pt=ret->getPointer();
+ for(it=a.begin();it!=a.end();it++)
+ pt=std::copy((*it)->getConstPointer(),(*it)->getConstPointer()+(*it)->getNbOfElems(),pt);
+ ret->copyStringInfoFrom(*(a[0]));
+ return ret;
+}
+
+DataArrayDouble *DataArrayDouble::Meld(const DataArrayDouble *a1, const DataArrayDouble *a2) throw(INTERP_KERNEL::Exception)
+{
+ std::vector<const DataArrayDouble *> arr(2);
+ arr[0]=a1; arr[1]=a2;
+ return Meld(arr);
+}
+
+DataArrayDouble *DataArrayDouble::Meld(const std::vector<const DataArrayDouble *>& a) throw(INTERP_KERNEL::Exception)
+{
+ if(a.empty())
+ throw INTERP_KERNEL::Exception("DataArrayDouble::Meld : array must be NON empty !");
+ std::vector<const DataArrayDouble *>::const_iterator it;
+ for(it=a.begin();it!=a.end();it++)
+ (*it)->checkAllocated();
+ it=a.begin();
+ int nbOfTuples=(*it)->getNumberOfTuples();
+ std::vector<int> nbc(a.size());
+ std::vector<const double *> pts(a.size());
+ nbc[0]=(*it)->getNumberOfComponents();
+ pts[0]=(*it++)->getConstPointer();
+ for(int i=1;it!=a.end();it++,i++)
+ {
+ if(nbOfTuples!=(*it)->getNumberOfTuples())
+ throw INTERP_KERNEL::Exception("DataArrayDouble::Meld : mismatch of number of tuples !");
+ nbc[i]=(*it)->getNumberOfComponents();
+ pts[i]=(*it)->getConstPointer();
+ }
+ int totalNbOfComp=std::accumulate(nbc.begin(),nbc.end(),0);
+ DataArrayDouble *ret=DataArrayDouble::New();
+ ret->alloc(nbOfTuples,totalNbOfComp);
+ double *retPtr=ret->getPointer();
+ for(int i=0;i<nbOfTuples;i++)
+ for(int j=0;j<(int)a.size();j++)
+ {
+ retPtr=std::copy(pts[j],pts[j]+nbc[j],retPtr);
+ pts[j]+=nbc[j];
+ }
+ int k=0;
+ for(int i=0;i<(int)a.size();i++)
+ for(int j=0;j<nbc[i];j++,k++)
+ ret->setInfoOnComponent(k,a[i]->getInfoOnComponent(j).c_str());
return ret;
}
-DataArrayDouble *DataArrayDouble::dot(const DataArrayDouble *a1, const DataArrayDouble *a2) throw(INTERP_KERNEL::Exception)
+DataArrayDouble *DataArrayDouble::Dot(const DataArrayDouble *a1, const DataArrayDouble *a2) throw(INTERP_KERNEL::Exception)
{
a1->checkAllocated();
a2->checkAllocated();
int nbOfComp=a1->getNumberOfComponents();
if(nbOfComp!=a2->getNumberOfComponents())
- throw INTERP_KERNEL::Exception("Nb of components mismatch for array dot !");
+ throw INTERP_KERNEL::Exception("Nb of components mismatch for array Dot !");
int nbOfTuple=a1->getNumberOfTuples();
if(nbOfTuple!=a2->getNumberOfTuples())
- throw INTERP_KERNEL::Exception("Nb of tuples mismatch for array dot !");
+ throw INTERP_KERNEL::Exception("Nb of tuples mismatch for array Dot !");
DataArrayDouble *ret=DataArrayDouble::New();
ret->alloc(nbOfTuple,1);
double *retPtr=ret->getPointer();
return ret;
}
-DataArrayDouble *DataArrayDouble::crossProduct(const DataArrayDouble *a1, const DataArrayDouble *a2) throw(INTERP_KERNEL::Exception)
+DataArrayDouble *DataArrayDouble::CrossProduct(const DataArrayDouble *a1, const DataArrayDouble *a2) throw(INTERP_KERNEL::Exception)
{
int nbOfComp=a1->getNumberOfComponents();
if(nbOfComp!=a2->getNumberOfComponents())
return ret;
}
-DataArrayDouble *DataArrayDouble::max(const DataArrayDouble *a1, const DataArrayDouble *a2) throw(INTERP_KERNEL::Exception)
+DataArrayDouble *DataArrayDouble::Max(const DataArrayDouble *a1, const DataArrayDouble *a2) throw(INTERP_KERNEL::Exception)
{
int nbOfComp=a1->getNumberOfComponents();
if(nbOfComp!=a2->getNumberOfComponents())
- throw INTERP_KERNEL::Exception("Nb of components mismatch for array max !");
+ throw INTERP_KERNEL::Exception("Nb of components mismatch for array Max !");
int nbOfTuple=a1->getNumberOfTuples();
if(nbOfTuple!=a2->getNumberOfTuples())
- throw INTERP_KERNEL::Exception("Nb of tuples mismatch for array max !");
+ throw INTERP_KERNEL::Exception("Nb of tuples mismatch for array Max !");
DataArrayDouble *ret=DataArrayDouble::New();
ret->alloc(nbOfTuple,nbOfComp);
double *retPtr=ret->getPointer();
return ret;
}
-DataArrayDouble *DataArrayDouble::min(const DataArrayDouble *a1, const DataArrayDouble *a2) throw(INTERP_KERNEL::Exception)
+DataArrayDouble *DataArrayDouble::Min(const DataArrayDouble *a1, const DataArrayDouble *a2) throw(INTERP_KERNEL::Exception)
{
int nbOfComp=a1->getNumberOfComponents();
if(nbOfComp!=a2->getNumberOfComponents())
return ret;
}
-DataArrayDouble *DataArrayDouble::add(const DataArrayDouble *a1, const DataArrayDouble *a2) throw(INTERP_KERNEL::Exception)
+DataArrayDouble *DataArrayDouble::Add(const DataArrayDouble *a1, const DataArrayDouble *a2) throw(INTERP_KERNEL::Exception)
{
- int nbOfComp=a1->getNumberOfComponents();
- if(nbOfComp!=a2->getNumberOfComponents())
- throw INTERP_KERNEL::Exception("Nb of components mismatch for array add !");
- int nbOfTuple=a1->getNumberOfTuples();
- if(nbOfTuple!=a2->getNumberOfTuples())
- throw INTERP_KERNEL::Exception("Nb of tuples mismatch for array add !");
+ int nbOfTuple=a2->getNumberOfTuples();
+ int nbOfComp=a2->getNumberOfComponents();
+ a1->checkNbOfTuplesAndComp(nbOfTuple,nbOfComp,"Nb of components mismatch for array Add !");
DataArrayDouble *ret=DataArrayDouble::New();
ret->alloc(nbOfTuple,nbOfComp);
std::transform(a1->getConstPointer(),a1->getConstPointer()+nbOfTuple*nbOfComp,a2->getConstPointer(),ret->getPointer(),std::plus<double>());
void DataArrayDouble::addEqual(const DataArrayDouble *other) throw(INTERP_KERNEL::Exception)
{
- int nbOfComp=getNumberOfComponents();
- if(nbOfComp!=other->getNumberOfComponents())
- throw INTERP_KERNEL::Exception("Nb of components mismatch for array add !");
- int nbOfTuple=getNumberOfTuples();
- if(nbOfTuple!=other->getNumberOfTuples())
- throw INTERP_KERNEL::Exception("Nb of tuples mismatch for array add !");
+ int nbOfTuple=other->getNumberOfTuples();
+ int nbOfComp=other->getNumberOfComponents();
+ checkNbOfTuplesAndComp(nbOfTuple,nbOfComp,"Nb of components mismatch for array add equal !");
std::transform(getConstPointer(),getConstPointer()+nbOfTuple*nbOfComp,other->getConstPointer(),getPointer(),std::plus<double>());
declareAsNew();
}
-DataArrayDouble *DataArrayDouble::substract(const DataArrayDouble *a1, const DataArrayDouble *a2) throw(INTERP_KERNEL::Exception)
+DataArrayDouble *DataArrayDouble::Substract(const DataArrayDouble *a1, const DataArrayDouble *a2) throw(INTERP_KERNEL::Exception)
{
- int nbOfComp=a1->getNumberOfComponents();
- if(nbOfComp!=a2->getNumberOfComponents())
- throw INTERP_KERNEL::Exception("Nb of components mismatch for array substract !");
- int nbOfTuple=a1->getNumberOfTuples();
- if(nbOfTuple!=a2->getNumberOfTuples())
- throw INTERP_KERNEL::Exception("Nb of tuples mismatch for array substract !");
+ int nbOfTuple=a2->getNumberOfTuples();
+ int nbOfComp=a2->getNumberOfComponents();
+ a1->checkNbOfTuplesAndComp(nbOfTuple,nbOfComp,"Nb of components mismatch for array Substract !");
DataArrayDouble *ret=DataArrayDouble::New();
ret->alloc(nbOfTuple,nbOfComp);
std::transform(a1->getConstPointer(),a1->getConstPointer()+nbOfTuple*nbOfComp,a2->getConstPointer(),ret->getPointer(),std::minus<double>());
void DataArrayDouble::substractEqual(const DataArrayDouble *other) throw(INTERP_KERNEL::Exception)
{
- int nbOfComp=getNumberOfComponents();
- if(nbOfComp!=other->getNumberOfComponents())
- throw INTERP_KERNEL::Exception("Nb of components mismatch for array substract !");
- int nbOfTuple=getNumberOfTuples();
- if(nbOfTuple!=other->getNumberOfTuples())
- throw INTERP_KERNEL::Exception("Nb of tuples mismatch for array substract !");
+ int nbOfTuple=other->getNumberOfTuples();
+ int nbOfComp=other->getNumberOfComponents();
+ checkNbOfTuplesAndComp(nbOfTuple,nbOfComp,"Nb of components mismatch for array substract equal !");
std::transform(getConstPointer(),getConstPointer()+nbOfTuple*nbOfComp,other->getConstPointer(),getPointer(),std::minus<double>());
declareAsNew();
}
-DataArrayDouble *DataArrayDouble::multiply(const DataArrayDouble *a1, const DataArrayDouble *a2) throw(INTERP_KERNEL::Exception)
+DataArrayDouble *DataArrayDouble::Multiply(const DataArrayDouble *a1, const DataArrayDouble *a2) throw(INTERP_KERNEL::Exception)
{
int nbOfTuple=a1->getNumberOfTuples();
int nbOfTuple2=a2->getNumberOfTuples();
int nbOfComp=a1->getNumberOfComponents();
int nbOfComp2=a2->getNumberOfComponents();
if(nbOfTuple!=nbOfTuple2)
- throw INTERP_KERNEL::Exception("Nb of tuples mismatch for array multiply !");
+ throw INTERP_KERNEL::Exception("Nb of tuples mismatch for array Multiply !");
DataArrayDouble *ret=0;
if(nbOfComp==nbOfComp2)
{
ret->copyStringInfoFrom(*aMax);
}
else
- throw INTERP_KERNEL::Exception("Nb of components mismatch for array multiply !");
+ throw INTERP_KERNEL::Exception("Nb of components mismatch for array Multiply !");
}
return ret;
}
declareAsNew();
}
-DataArrayDouble *DataArrayDouble::divide(const DataArrayDouble *a1, const DataArrayDouble *a2) throw(INTERP_KERNEL::Exception)
+DataArrayDouble *DataArrayDouble::Divide(const DataArrayDouble *a1, const DataArrayDouble *a2) throw(INTERP_KERNEL::Exception)
{
- int nbOfComp=a1->getNumberOfComponents();
- if(nbOfComp!=a2->getNumberOfComponents())
- throw INTERP_KERNEL::Exception("Nb of components mismatch for array divide !");
int nbOfTuple=a1->getNumberOfTuples();
- if(nbOfTuple!=a2->getNumberOfTuples())
- throw INTERP_KERNEL::Exception("Nb of tuples mismatch for array divide !");
- DataArrayDouble *ret=DataArrayDouble::New();
- ret->alloc(nbOfTuple,nbOfComp);
- std::transform(a1->getConstPointer(),a1->getConstPointer()+nbOfTuple*nbOfComp,a2->getConstPointer(),ret->getPointer(),std::divides<double>());
- ret->copyStringInfoFrom(*a1);
+ int nbOfTuple2=a2->getNumberOfTuples();
+ int nbOfComp=a1->getNumberOfComponents();
+ int nbOfComp2=a2->getNumberOfComponents();
+ if(nbOfTuple!=nbOfTuple2)
+ throw INTERP_KERNEL::Exception("Nb of tuples mismatch for array Divide !");
+ DataArrayDouble *ret=0;
+ if(nbOfComp==nbOfComp2)
+ {
+ ret=DataArrayDouble::New();
+ ret->alloc(nbOfTuple,nbOfComp);
+ std::transform(a1->getConstPointer(),a1->getConstPointer()+nbOfTuple*nbOfComp,a2->getConstPointer(),ret->getPointer(),std::divides<double>());
+ ret->copyStringInfoFrom(*a1);
+ }
+ else
+ {
+ if(nbOfComp2==1)
+ {
+ ret=DataArrayDouble::New();
+ ret->alloc(nbOfTuple,nbOfComp);
+ const double *a2Ptr=a2->getConstPointer();
+ const double *a1Ptr=a1->getConstPointer();
+ double *res=ret->getPointer();
+ for(int i=0;i<nbOfTuple;i++)
+ res=std::transform(a1Ptr+i*nbOfComp,a1Ptr+(i+1)*nbOfComp,res,std::bind2nd(std::divides<double>(),a2Ptr[i]));
+ ret->copyStringInfoFrom(*a1);
+ }
+ else
+ throw INTERP_KERNEL::Exception("Nb of components mismatch for array Divide !");
+ }
return ret;
}
void DataArrayDouble::divideEqual(const DataArrayDouble *other) throw(INTERP_KERNEL::Exception)
{
- int nbOfComp=getNumberOfComponents();
- if(nbOfComp!=other->getNumberOfComponents())
- throw INTERP_KERNEL::Exception("Nb of components mismatch for array divideEqual !");
int nbOfTuple=getNumberOfTuples();
- if(nbOfTuple!=other->getNumberOfTuples())
+ int nbOfTuple2=other->getNumberOfTuples();
+ int nbOfComp=getNumberOfComponents();
+ int nbOfComp2=other->getNumberOfComponents();
+ if(nbOfTuple!=nbOfTuple2)
throw INTERP_KERNEL::Exception("Nb of tuples mismatch for array divideEqual !");
- std::transform(getConstPointer(),getConstPointer()+nbOfTuple*nbOfComp,other->getConstPointer(),getPointer(),std::divides<double>());
+ if(nbOfComp==nbOfComp2)
+ {
+ std::transform(getConstPointer(),getConstPointer()+nbOfTuple*nbOfComp,other->getConstPointer(),getPointer(),std::divides<double>());
+ }
+ else
+ {
+ if(nbOfComp2==1)
+ {
+ const double *ptr=other->getConstPointer();
+ double *myPtr=getPointer();
+ for(int i=0;i<nbOfTuple;i++)
+ myPtr=std::transform(myPtr,myPtr+nbOfComp,myPtr,std::bind2nd(std::divides<double>(),ptr[i]));
+ }
+ else
+ throw INTERP_KERNEL::Exception("Nb of components mismatch for array divideEqual !");
+ }
declareAsNew();
}
+/*!
+ * Useless method for end user. Only for MPI/Corba/File serialsation for multi arrays class.
+ * Server side.
+ */
+void DataArrayDouble::getTinySerializationIntInformation(std::vector<int>& tinyInfo) const
+{
+ tinyInfo.resize(2);
+ if(isAllocated())
+ {
+ tinyInfo[0]=getNumberOfTuples();
+ tinyInfo[1]=getNumberOfComponents();
+ }
+ else
+ {
+ tinyInfo[0]=-1;
+ tinyInfo[1]=-1;
+ }
+}
+
+/*!
+ * Useless method for end user. Only for MPI/Corba/File serialsation for multi arrays class.
+ * Server side.
+ */
+void DataArrayDouble::getTinySerializationStrInformation(std::vector<std::string>& tinyInfo) const
+{
+ if(isAllocated())
+ {
+ int nbOfCompo=getNumberOfComponents();
+ tinyInfo.resize(nbOfCompo+1);
+ tinyInfo[0]=getName();
+ for(int i=0;i<nbOfCompo;i++)
+ tinyInfo[i+1]=getInfoOnComponent(i);
+ }
+ else
+ {
+ tinyInfo.resize(1);
+ tinyInfo[0]=getName();
+ }
+}
+
+/*!
+ * Useless method for end user. Only for MPI/Corba/File serialsation for multi arrays class.
+ * This method returns if a feeding is needed.
+ */
+bool DataArrayDouble::resizeForUnserialization(const std::vector<int>& tinyInfoI)
+{
+ int nbOfTuple=tinyInfoI[0];
+ int nbOfComp=tinyInfoI[1];
+ if(nbOfTuple!=-1 || nbOfComp!=-1)
+ {
+ alloc(nbOfTuple,nbOfComp);
+ return true;
+ }
+ return false;
+}
+
+/*!
+ * Useless method for end user. Only for MPI/Corba/File serialsation for multi arrays class.
+ */
+void DataArrayDouble::finishUnserialization(const std::vector<int>& tinyInfoI, const std::vector<std::string>& tinyInfoS)
+{
+ setName(tinyInfoS[0].c_str());
+ if(isAllocated())
+ {
+ int nbOfCompo=getNumberOfComponents();
+ for(int i=0;i<nbOfCompo;i++)
+ setInfoOnComponent(i,tinyInfoS[i+1].c_str());
+ }
+}
+
DataArrayInt *DataArrayInt::New()
{
return new DataArrayInt;
throw INTERP_KERNEL::Exception("DataArrayInt::checkAllocated : Array is defined but not allocated ! Call alloc or setValues method first !");
}
-DataArrayInt *DataArrayInt::deepCopy() const
+DataArrayInt *DataArrayInt::deepCpy() const
{
return new DataArrayInt(*this);
}
-DataArrayInt *DataArrayInt::performCpy(bool deepCpy) const
+DataArrayInt *DataArrayInt::performCpy(bool dCpy) const
{
- if(deepCpy)
- return deepCopy();
+ if(dCpy)
+ return deepCpy();
else
{
incrRef();
}
}
+void DataArrayInt::cpyFrom(const DataArrayInt& other) throw(INTERP_KERNEL::Exception)
+{
+ other.checkAllocated();
+ int nbOfTuples=other.getNumberOfTuples();
+ int nbOfComp=other.getNumberOfComponents();
+ allocIfNecessary(nbOfTuples,nbOfComp);
+ int nbOfElems=nbOfTuples*nbOfComp;
+ int *pt=getPointer();
+ const int *ptI=other.getConstPointer();
+ for(int i=0;i<nbOfElems;i++)
+ pt[i]=ptI[i];
+ copyStringInfoFrom(other);
+}
+
+void DataArrayInt::allocIfNecessary(int nbOfTuple, int nbOfCompo)
+{
+ if(isAllocated())
+ {
+ if(nbOfTuple!=getNumberOfTuples() || nbOfCompo!=getNumberOfComponents())
+ alloc(nbOfTuple,nbOfCompo);
+ }
+ else
+ alloc(nbOfTuple,nbOfCompo);
+}
+
void DataArrayInt::alloc(int nbOfTuple, int nbOfCompo)
{
_nb_of_tuples=nbOfTuple;
if(!ptr)
throw INTERP_KERNEL::Exception("DataArrayInt::iota : allocate first !");
if(getNumberOfComponents()!=1)
- throw INTERP_KERNEL::Exception("DataArrayInt::iota : works only for arrays with only one component!");
+ throw INTERP_KERNEL::Exception("DataArrayInt::iota : works only for arrays with only one component, you can call 'rearrange' method before !");
int ntuples=getNumberOfTuples();
for(int i=0;i<ntuples;i++)
ptr[i]=init+i;
_mem.reprZip(getNumberOfComponents(),stream);
}
-void DataArrayInt::transformWithIndArr(const int *indArr)
+void DataArrayInt::transformWithIndArr(const int *indArrBg, const int *indArrEnd) throw(INTERP_KERNEL::Exception)
{
if(getNumberOfComponents()!=1)
- throw INTERP_KERNEL::Exception("Call transformWithIndArr method on DataArrayInt with only one component !");
+ throw INTERP_KERNEL::Exception("Call transformWithIndArr method on DataArrayInt with only one component, you can call 'rearrange' method before !");
+ int nbElemsIn=std::distance(indArrBg,indArrEnd);
int nbOfTuples=getNumberOfTuples();
int *pt=getPointer();
- for(int i=0;i<nbOfTuples;i++)
- pt[i]=indArr[pt[i]];
+ for(int i=0;i<nbOfTuples;i++,pt++)
+ {
+ if(*pt<nbElemsIn)
+ *pt=indArrBg[*pt];
+ else
+ {
+ std::ostringstream oss; oss << "DataArrayInt::transformWithIndArr : error on tuple #" << i << " value is " << *pt << " and indirectionnal array as a size equal to " << nbElemsIn;
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ }
}
/*!
return _mem.isEqual(other._mem,0);
}
+bool DataArrayInt::isEqualWithoutConsideringStrAndOrder(const DataArrayInt& other) const throw(INTERP_KERNEL::Exception)
+{
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> a=deepCpy();
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> b=other.deepCpy();
+ a->sort();
+ b->sort();
+ return a->isEqualWithoutConsideringStr(*b);
+}
+
+void DataArrayInt::sort() throw(INTERP_KERNEL::Exception)
+{
+ checkAllocated();
+ if(getNumberOfComponents()!=1)
+ throw INTERP_KERNEL::Exception("DataArrayInt::sort : only supported with 'this' array with ONE component !");
+ _mem.sort();
+}
+
+/*!
+ * This method expects that 'this' and 'other' have the same number of tuples and exactly one component both. If not an exception will be thrown.
+ * This method retrieves a newly created array with same number of tuples than 'this' and 'other' with one component.
+ * The returned array 'ret' contains the correspondance from 'this' to 'other' that is to say for every i so that 0<=i<getNumberOfTuples()
+ * other.getIJ(i,0)==this->getIJ(ret->getIJ(i),0)
+ * If such permutation is not possible because it exists some elements in 'other' not in 'this', an exception will be thrown.
+ */
+DataArrayInt *DataArrayInt::buildPermutationArr(const DataArrayInt& other) const throw(INTERP_KERNEL::Exception)
+{
+ if(getNumberOfComponents()!=1 || other.getNumberOfComponents()!=1)
+ throw INTERP_KERNEL::Exception("DataArrayInt::buildPermutationArr : 'this' and 'other' have to have exactly ONE component !");
+ int nbTuple=getNumberOfTuples();
+ if(nbTuple!=other.getNumberOfTuples())
+ throw INTERP_KERNEL::Exception("DataArrayInt::buildPermutationArr : 'this' and 'other' must have the same number of tuple !");
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ret=DataArrayInt::New();
+ ret->alloc(nbTuple,1);
+ ret->fillWithValue(-1);
+ const int *pt=getConstPointer();
+ std::map<int,int> mm;
+ for(int i=0;i<nbTuple;i++)
+ mm[pt[i]]=i;
+ pt=other.getConstPointer();
+ int *retToFill=ret->getPointer();
+ for(int i=0;i<nbTuple;i++)
+ {
+ std::map<int,int>::const_iterator it=mm.find(pt[i]);
+ if(it==mm.end())
+ {
+ std::ostringstream oss; oss << "DataArrayInt::buildPermutationArr : Arrays mismatch : element (" << pt[i] << ") in 'other' not findable in 'this' !";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ retToFill[i]=(*it).second;
+ }
+ ret->incrRef();
+ return ret;
+}
+
void DataArrayInt::useArray(const int *array, bool ownership, DeallocType type, int nbOfTuple, int nbOfCompo)
{
_nb_of_tuples=nbOfTuple;
}
/*!
- * This method checks that 'this' is with numberofcomponents == 1 and that it is equal to
- * stdext::iota() of size getNumberOfTuples. This method is particalary usefull for DataArrayInt instances
- * that represents a renumbering array to check the real need in renumbering.
+ * This method is equivalent to DataArrayInt::selectByTupleId except that an analyze to the content of input range to check that it will not lead to memory corruption !
*/
-bool DataArrayInt::isIdentity() const
+DataArrayInt *DataArrayInt::selectByTupleIdSafe(const int *new2OldBg, const int *new2OldEnd) const throw(INTERP_KERNEL::Exception)
{
- if(getNumberOfComponents()!=1)
- return false;
- int nbOfTuples=getNumberOfTuples();
- const int *pt=getConstPointer();
- for(int i=0;i<nbOfTuples;i++,pt++)
- if(*pt!=i)
- return false;
- return true;
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ret=DataArrayInt::New();
+ int nbComp=getNumberOfComponents();
+ int oldNbOfTuples=getNumberOfTuples();
+ ret->alloc(std::distance(new2OldBg,new2OldEnd),nbComp);
+ ret->copyStringInfoFrom(*this);
+ int *pt=ret->getPointer();
+ const int *srcPt=getConstPointer();
+ int i=0;
+ for(const int *w=new2OldBg;w!=new2OldEnd;w++,i++)
+ if(*w>=0 && *w<oldNbOfTuples)
+ std::copy(srcPt+(*w)*nbComp,srcPt+((*w)+1)*nbComp,pt+i*nbComp);
+ else
+ throw INTERP_KERNEL::Exception("DataArrayInt::selectByTupleIdSafe : some ids has been detected to be out of [0,this->getNumberOfTuples) !");
+ ret->copyStringInfoFrom(*this);
+ ret->incrRef();
+ return ret;
}
-bool DataArrayInt::isUniform(int val) const
-{
+/*!
+ * Idem than DataArrayInt::selectByTupleIdSafe except that the input array is not constructed explicitely.
+ * The convention is as python one. ['bg','end') with steps of 'step'.
+ * Returns a newly created array.
+ */
+DataArrayInt *DataArrayInt::selectByTupleId2(int bg, int end, int step) const throw(INTERP_KERNEL::Exception)
+{
+ if(end<bg)
+ throw INTERP_KERNEL::Exception("DataArrayInt::selectByTupleId2 : end before begin !");
+ if(step<=0)
+ throw INTERP_KERNEL::Exception("DataArrayInt::selectByTupleId2 : invalid step should > 0 !");
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ret=DataArrayInt::New();
+ int nbComp=getNumberOfComponents();
+ int newNbOfTuples=(end+1-bg)/step-1;
+ ret->alloc(newNbOfTuples,nbComp);
+ int *pt=ret->getPointer();
+ const int *srcPt=getConstPointer()+bg*nbComp;
+ for(int i=0;i<newNbOfTuples;i++,srcPt+=step*nbComp)
+ std::copy(srcPt,srcPt+nbComp,pt+i*nbComp);
+ ret->copyStringInfoFrom(*this);
+ ret->incrRef();
+ return ret;
+}
+
+/*!
+ * This method works only for arrays having single component.
+ * If this contains the array a1 containing [9,10,0,6,4,11,3,7] this method returns an array a2 [5,6,0,3,2,7,1,4].
+ * By doing a1.renumber(a2) the user will obtain array a3 equal to a1 sorted.
+ * This method is useful for renumbering (in MED file for example). This method is used by MEDCouplingFieldDouble::renumberCells when check is set to true.
+ * This method throws an exception if more 2 or more elements in 'this' are same.
+ */
+DataArrayInt *DataArrayInt::checkAndPreparePermutation() const throw(INTERP_KERNEL::Exception)
+{
+ checkAllocated();
+ if(getNumberOfComponents()!=1)
+ throw INTERP_KERNEL::Exception("DataArrayInt::checkAndPreparePermutation : number of components must == 1 !");
+ int nbTuples=getNumberOfTuples();
+ const int *pt=getConstPointer();
+ int *pt2=CheckAndPreparePermutation(pt,pt+nbTuples);
+ DataArrayInt *ret=DataArrayInt::New();
+ ret->useArray(pt2,true,CPP_DEALLOC,nbTuples,1);
+ return ret;
+}
+
+/*!
+ * This method makes the assumption that 'this' is correctly set, and has exactly one component. If not an exception will be thrown.
+ * Given a sujective application defined by 'this' from a set of size this->getNumberOfTuples() to a set of size targetNb.
+ * 'targetNb'<this->getNumberOfTuples(). 'this' should be surjective that is to say for each id in [0,'targetNb') it exists at least one tupleId tid
+ * so that this->getIJ(tid,0)==id.
+ * If not an exception will be thrown.
+ * This method returns 2 newly allocated arrays 'arr' and 'arrI', corresponding respectively to array and its corresponding index.
+ * This method is usefull for methods that returns old2New numbering concecutive to a reduction ( MEDCouplingUMesh::zipConnectivityTraducer, MEDCouplingUMesh::zipConnectivityTraducer for example)
+ * Example : if 'this' equals [0,3,2,3,2,2,1,2] this method will return arrI=[0,1,2,6,8] arr=[0, 6, 2,4,5,7, 1,3]
+ * That is to say elt id 2 has arrI[2+1]-arrI[2]=4 places in 'this'. The corresponding tuple ids are [2,4,5,7].
+ */
+void DataArrayInt::changeSurjectiveFormat(int targetNb, DataArrayInt *&arr, DataArrayInt *&arrI) const throw(INTERP_KERNEL::Exception)
+{
+ checkAllocated();
+ if(getNumberOfComponents()!=1)
+ throw INTERP_KERNEL::Exception("DataArrayInt::changeSurjectiveFormat : number of components must == 1 !");
+ int nbOfTuples=getNumberOfTuples();
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ret(DataArrayInt::New());
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> retI(DataArrayInt::New());
+ retI->alloc(targetNb+1,1);
+ const int *input=getConstPointer();
+ std::vector< std::vector<int> > tmp(targetNb);
+ for(int i=0;i<nbOfTuples;i++)
+ {
+ int tmp2=input[i];
+ if(tmp2<targetNb)
+ tmp[tmp2].push_back(i);
+ else
+ {
+ std::ostringstream oss; oss << "DataArrayInt::changeSurjectiveFormat : At pos " << i << " presence of element " << tmp2 << " higher than " << targetNb;
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ }
+ int *retIPtr=retI->getPointer();
+ *retIPtr=0;
+ for(std::vector< std::vector<int> >::const_iterator it1=tmp.begin();it1!=tmp.end();it1++,retIPtr++)
+ retIPtr[1]=retIPtr[0]+(*it1).size();
+ if(nbOfTuples!=retI->getIJ(targetNb,0))
+ throw INTERP_KERNEL::Exception("DataArrayInt::changeSurjectiveFormat : big problem should never happen !");
+ ret->alloc(nbOfTuples,1);
+ int *retPtr=ret->getPointer();
+ for(std::vector< std::vector<int> >::const_iterator it1=tmp.begin();it1!=tmp.end();it1++)
+ retPtr=std::copy((*it1).begin(),(*it1).end(),retPtr);
+ ret->incrRef();
+ retI->incrRef();
+ arr=ret;
+ arrI=retI;
+}
+
+/*!
+ * This method expects that 'this' is allocated and with only one component. If not an exception will be thrown.
+ * This method returns a newly created array with 'this->getNumberOfTuples()' tuples and 1 component.
+ * This methods returns an 'old2New' corresponding array that allows to follow the following rules :
+ * - Lower a value in tuple in 'this' is, higher is its priority.
+ * - If two tuples i and j have same value if i<j then ret[i]<ret[j]
+ * - The first tuple with the lowest value will have the value 0, inversely the last tuple with highest value will have value 'this->getNumberOfTuples()-1'
+ *
+ * Example if 'this' contains the following array : [2,0,1,1,0,1,2,0,1,1,0,0] this method returns [10,0,5,6,1,7,11,2,8,9,3,4]
+ */
+DataArrayInt *DataArrayInt::buildPermArrPerLevel() const throw(INTERP_KERNEL::Exception)
+{
+ checkAllocated();
+ if(getNumberOfComponents()!=1)
+ throw INTERP_KERNEL::Exception("DataArrayInt::buildPermArrPerLevel : number of components must == 1 !");
+ int nbOfTuples=getNumberOfTuples();
+ const int *pt=getConstPointer();
+ std::map<int,int> m;
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ret=DataArrayInt::New();
+ ret->alloc(nbOfTuples,1);
+ int *opt=ret->getPointer();
+ for(int i=0;i<nbOfTuples;i++,pt++,opt++)
+ {
+ int val=*pt;
+ std::map<int,int>::iterator it=m.find(val);
+ if(it!=m.end())
+ {
+ *opt=(*it).second;
+ (*it).second++;
+ }
+ else
+ {
+ *opt=0;
+ m.insert(std::pair<int,int>(val,1));
+ }
+ }
+ int sum=0;
+ for(std::map<int,int>::iterator it=m.begin();it!=m.end();it++)
+ {
+ int vt=(*it).second;
+ (*it).second=sum;
+ sum+=vt;
+ }
+ pt=getConstPointer();
+ opt=ret->getPointer();
+ for(int i=0;i<nbOfTuples;i++,pt++,opt++)
+ *opt+=m[*pt];
+ //
+ ret->incrRef();
+ return ret;
+}
+
+/*!
+ * This method checks that 'this' is with numberofcomponents == 1 and that it is equal to
+ * stdext::iota() of size getNumberOfTuples. This method is particalary usefull for DataArrayInt instances
+ * that represents a renumbering array to check the real need in renumbering.
+ */
+bool DataArrayInt::isIdentity() const
+{
+ if(getNumberOfComponents()!=1)
+ return false;
+ int nbOfTuples=getNumberOfTuples();
+ const int *pt=getConstPointer();
+ for(int i=0;i<nbOfTuples;i++,pt++)
+ if(*pt!=i)
+ return false;
+ return true;
+}
+
+bool DataArrayInt::isUniform(int val) const
+{
if(getNumberOfComponents()!=1)
- throw INTERP_KERNEL::Exception("DataArrayInt::isUniform : must be applied on DataArrayInt with only one component !");
+ throw INTERP_KERNEL::Exception("DataArrayInt::isUniform : must be applied on DataArrayInt with only one component, you can call 'rearrange' method before !");
int nbOfTuples=getNumberOfTuples();
const int *w=getConstPointer();
const int *end=w+nbOfTuples;
int nbt=getNumberOfTuples();
if(tupleIdBg<0)
throw INTERP_KERNEL::Exception("DataArrayInt::substr : The tupleIdBg parameter must be greater than 0 !");
- if(tupleIdBg>=nbt)
- throw INTERP_KERNEL::Exception("DataArrayInt::substr : The tupleIdBg parameter is greater or equal than number of tuples !");
+ if(tupleIdBg>nbt)
+ throw INTERP_KERNEL::Exception("DataArrayInt::substr : The tupleIdBg parameter is greater than number of tuples !");
int trueEnd=tupleIdEnd;
if(tupleIdEnd!=-1)
{
return ret;
}
+/*!
+ * Contrary to DataArrayInt::changeNbOfComponents method this method is \b not const. The content
+ * This method \b do \b not change the content of data but changes the splitting of this data seen by the caller.
+ * This method makes the assumption that 'this' is already allocated. If not an exception will be thrown.
+ * This method checks that getNbOfElems()%newNbOfCompo==0. If not an exception will be throw !
+ * This method erases all components info set before call !
+ */
+void DataArrayInt::rearrange(int newNbOfCompo) throw(INTERP_KERNEL::Exception)
+{
+ checkAllocated();
+ int nbOfElems=getNbOfElems();
+ if(nbOfElems%newNbOfCompo!=0)
+ throw INTERP_KERNEL::Exception("DataArrayInt::rearrange : nbOfElems%newNbOfCompo!=0 !");
+ _nb_of_tuples=nbOfElems/newNbOfCompo;
+ _info_on_compo.clear();
+ _info_on_compo.resize(newNbOfCompo);
+ declareAsNew();
+}
+
/*!
* This method builds a new instance of DataArrayInt (to deal with) that is reduction or an extension of 'this'.
* if 'newNbOfComp' < this->getNumberOfComponents() a reduction is done and for each tuple 'newNbOfComp' first components are kept.
MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ret(DataArrayInt::New());
int newNbOfCompo=compoIds.size();
int oldNbOfCompo=getNumberOfComponents();
+ for(std::vector<int>::const_iterator it=compoIds.begin();it!=compoIds.end();it++)
+ DataArray::CheckValueInRange(oldNbOfCompo,(*it),"keepSelectedComponents invalid requested component");
int nbOfTuples=getNumberOfTuples();
ret->alloc(nbOfTuples,newNbOfCompo);
ret->copyPartOfStringInfoFrom(*this,compoIds);
return ret;
}
+/*!
+ * This method melds the components of 'this' with components of 'other'.
+ * After this call in case of success, 'this' will contain a number of components equal to the sum of 'this'
+ * before the call and the number of components of 'other'.
+ * This method expects that 'this' and 'other' have exactly the same number of tuples. If not an exception is thrown.
+ */
+void DataArrayInt::meldWith(const DataArrayInt *other) throw(INTERP_KERNEL::Exception)
+{
+ checkAllocated();
+ other->checkAllocated();
+ int nbOfTuples=getNumberOfTuples();
+ if(nbOfTuples!=other->getNumberOfTuples())
+ throw INTERP_KERNEL::Exception("DataArrayInt::meldWith : mismatch of number of tuples !");
+ int nbOfComp1=getNumberOfComponents();
+ int nbOfComp2=other->getNumberOfComponents();
+ int *newArr=new int[nbOfTuples*(nbOfComp1+nbOfComp2)];
+ int *w=newArr;
+ const int *inp1=getConstPointer();
+ const int *inp2=other->getConstPointer();
+ for(int i=0;i<nbOfTuples;i++,inp1+=nbOfComp1,inp2+=nbOfComp2)
+ {
+ w=std::copy(inp1,inp1+nbOfComp1,w);
+ w=std::copy(inp2,inp2+nbOfComp2,w);
+ }
+ useArray(newArr,true,CPP_DEALLOC,nbOfTuples,nbOfComp1+nbOfComp2);
+ std::vector<int> compIds(nbOfComp2);
+ for(int i=0;i<nbOfComp2;i++)
+ compIds[i]=nbOfComp1+i;
+ copyPartOfStringInfoFrom2(compIds,*other);
+}
+
void DataArrayInt::setSelectedComponents(const DataArrayInt *a, const std::vector<int>& compoIds) throw(INTERP_KERNEL::Exception)
{
copyPartOfStringInfoFrom2(compoIds,*a);
nc[nbOfCompo*i+compoIds[j]]=*ac;
}
-void DataArrayInt::setArrayIn(DataArrayInt *newArray, DataArrayInt* &arrayToSet)
+/*!
+ * This method performs a partial assignment of 'this' using 'a' as input. Other input parameters specifies the subpart being considered by the assignment.
+ * 'strictCompoCompare' specifies if DataArray 'a' should have exactly same number of components and tuples than 'this' (true) or not (false). By default set to true with maximal test.
+ */
+void DataArrayInt::setPartOfValues1(const DataArrayInt *a, int bgTuples, int endTuples, int stepTuples, int bgComp, int endComp, int stepComp, bool strictCompoCompare) throw(INTERP_KERNEL::Exception)
+{
+ const char msg[]="DataArrayInt::setPartOfValues1";
+ checkAllocated();
+ a->checkAllocated();
+ int newNbOfTuples=DataArray::GetNumberOfItemGivenBES(bgTuples,endTuples,stepTuples,msg);
+ int newNbOfComp=DataArray::GetNumberOfItemGivenBES(bgComp,endComp,stepComp,msg);
+ int nbComp=getNumberOfComponents();
+ int nbOfTuples=getNumberOfTuples();
+ DataArray::CheckValueInRange(nbOfTuples,bgTuples,"invalid begin tuple value");
+ DataArray::CheckClosingParInRange(nbOfTuples,endTuples,"invalid end tuple value");
+ DataArray::CheckValueInRange(nbComp,bgComp,"invalid begin component value");
+ DataArray::CheckClosingParInRange(nbComp,endComp,"invalid end component value");
+ a->checkNbOfElems(newNbOfTuples*newNbOfComp,msg);
+ if(strictCompoCompare)
+ a->checkNbOfTuplesAndComp(newNbOfTuples,newNbOfComp,msg);
+ int *pt=getPointer()+bgTuples*nbComp+bgComp;
+ const int *srcPt=a->getConstPointer();
+ for(int i=0;i<newNbOfTuples;i++,pt+=stepTuples*nbComp)
+ for(int j=0;j<newNbOfComp;j++,srcPt++)
+ pt[j*stepComp]=*srcPt;
+}
+
+/*!
+ * This method performs a partial assignment of 'this' using 'a' as input. Other input parameters specifies the subpart being considered by the assignment.
+ */
+void DataArrayInt::setPartOfValuesSimple1(int a, int bgTuples, int endTuples, int stepTuples, int bgComp, int endComp, int stepComp) throw(INTERP_KERNEL::Exception)
+{
+ const char msg[]="DataArrayInt::setPartOfValuesSimple1";
+ checkAllocated();
+ int newNbOfTuples=DataArray::GetNumberOfItemGivenBES(bgTuples,endTuples,stepTuples,msg);
+ int newNbOfComp=DataArray::GetNumberOfItemGivenBES(bgComp,endComp,stepComp,msg);
+ int nbComp=getNumberOfComponents();
+ int nbOfTuples=getNumberOfTuples();
+ DataArray::CheckValueInRange(nbOfTuples,bgTuples,"invalid begin tuple value");
+ DataArray::CheckClosingParInRange(nbOfTuples,endTuples,"invalid end tuple value");
+ DataArray::CheckValueInRange(nbComp,bgComp,"invalid begin component value");
+ DataArray::CheckClosingParInRange(nbComp,endComp,"invalid end component value");
+ int *pt=getPointer()+bgTuples*nbComp+bgComp;
+ for(int i=0;i<newNbOfTuples;i++,pt+=stepTuples*nbComp)
+ for(int j=0;j<newNbOfComp;j++)
+ pt[j*stepComp]=a;
+}
+
+/*!
+ * This method performs a partial assignment of 'this' using 'a' as input. Other input parameters specifies the subpart being considered by the assignment.
+ * 'strictCompoCompare' specifies if DataArray 'a' should have exactly same number of components and tuples than 'this' (true) or not (false). By default set to true with maximal test.
+ */
+void DataArrayInt::setPartOfValues2(const DataArrayInt *a, const int *bgTuples, const int *endTuples, const int *bgComp, const int *endComp, bool strictCompoCompare) throw(INTERP_KERNEL::Exception)
+{
+ const char msg[]="DataArrayInt::setPartOfValues2";
+ checkAllocated();
+ a->checkAllocated();
+ int nbComp=getNumberOfComponents();
+ int nbOfTuples=getNumberOfTuples();
+ for(const int *z=bgComp;z!=endComp;z++)
+ DataArray::CheckValueInRange(nbComp,*z,"invalid component id");
+ int newNbOfTuples=std::distance(bgTuples,endTuples);
+ int newNbOfComp=std::distance(bgComp,endComp);
+ a->checkNbOfElems(newNbOfTuples*newNbOfComp,msg);
+ if(strictCompoCompare)
+ a->checkNbOfTuplesAndComp(newNbOfTuples,newNbOfComp,msg);
+ int *pt=getPointer();
+ const int *srcPt=a->getConstPointer();
+ for(const int *w=bgTuples;w!=endTuples;w++)
+ for(const int *z=bgComp;z!=endComp;z++,srcPt++)
+ {
+ DataArray::CheckValueInRange(nbOfTuples,*w,"invalid tuple id");
+ pt[(*w)*nbComp+(*z)]=*srcPt;
+ }
+}
+
+/*!
+ * This method performs a partial assignment of 'this' using 'a' as input. Other input parameters specifies the subpart being considered by the assignment.
+ */
+void DataArrayInt::setPartOfValuesSimple2(int a, const int *bgTuples, const int *endTuples, const int *bgComp, const int *endComp) throw(INTERP_KERNEL::Exception)
+{
+ checkAllocated();
+ int nbComp=getNumberOfComponents();
+ int nbOfTuples=getNumberOfTuples();
+ for(const int *z=bgComp;z!=endComp;z++)
+ DataArray::CheckValueInRange(nbComp,*z,"invalid component id");
+ int *pt=getPointer();
+ for(const int *w=bgTuples;w!=endTuples;w++)
+ for(const int *z=bgComp;z!=endComp;z++)
+ {
+ DataArray::CheckValueInRange(nbOfTuples,*w,"invalid tuple id");
+ pt[(*w)*nbComp+(*z)]=a;
+ }
+}
+
+/*!
+ * This method performs a partial assignment of 'this' using 'a' as input. Other input parameters specifies the subpart being considered by the assignment.
+ * 'strictCompoCompare' specifies if DataArray 'a' should have exactly same number of components and tuples than 'this' (true) or not (false). By default set to true with maximal test.
+ */
+void DataArrayInt::setPartOfValues3(const DataArrayInt *a, const int *bgTuples, const int *endTuples, int bgComp, int endComp, int stepComp, bool strictCompoCompare) throw(INTERP_KERNEL::Exception)
+{
+ const char msg[]="DataArrayInt::setPartOfValues3";
+ checkAllocated();
+ a->checkAllocated();
+ int newNbOfComp=DataArray::GetNumberOfItemGivenBES(bgComp,endComp,stepComp,msg);
+ int nbComp=getNumberOfComponents();
+ int nbOfTuples=getNumberOfTuples();
+ DataArray::CheckValueInRange(nbComp,bgComp,"invalid begin component value");
+ DataArray::CheckClosingParInRange(nbComp,endComp,"invalid end component value");
+ int newNbOfTuples=std::distance(bgTuples,endTuples);
+ a->checkNbOfElems(newNbOfTuples*newNbOfComp,msg);
+ if(strictCompoCompare)
+ a->checkNbOfTuplesAndComp(newNbOfTuples,newNbOfComp,msg);
+ int *pt=getPointer()+bgComp;
+ const int *srcPt=a->getConstPointer();
+ for(const int *w=bgTuples;w!=endTuples;w++)
+ for(int j=0;j<newNbOfComp;j++,srcPt++)
+ {
+ DataArray::CheckValueInRange(nbOfTuples,*w,"invalid tuple id");
+ pt[(*w)*nbComp+j*stepComp]=*srcPt;
+ }
+}
+
+/*!
+ * This method performs a partial assignment of 'this' using 'a' as input. Other input parameters specifies the subpart being considered by the assignment.
+ */
+void DataArrayInt::setPartOfValuesSimple3(int a, const int *bgTuples, const int *endTuples, int bgComp, int endComp, int stepComp) throw(INTERP_KERNEL::Exception)
+{
+ const char msg[]="DataArrayInt::setPartOfValuesSimple3";
+ checkAllocated();
+ int newNbOfComp=DataArray::GetNumberOfItemGivenBES(bgComp,endComp,stepComp,msg);
+ int nbComp=getNumberOfComponents();
+ int nbOfTuples=getNumberOfTuples();
+ DataArray::CheckValueInRange(nbComp,bgComp,"invalid begin component value");
+ DataArray::CheckClosingParInRange(nbComp,endComp,"invalid end component value");
+ int *pt=getPointer()+bgComp;
+ for(const int *w=bgTuples;w!=endTuples;w++)
+ for(int j=0;j<newNbOfComp;j++)
+ {
+ DataArray::CheckValueInRange(nbOfTuples,*w,"invalid tuple id");
+ pt[(*w)*nbComp+j*stepComp]=a;
+ }
+}
+
+void DataArrayInt::SetArrayIn(DataArrayInt *newArray, DataArrayInt* &arrayToSet)
{
if(newArray!=arrayToSet)
{
DataArrayInt *DataArrayInt::getIdsEqual(int val) const throw(INTERP_KERNEL::Exception)
{
if(getNumberOfComponents()!=1)
- throw INTERP_KERNEL::Exception("DataArrayInt::getIdsEqual : the array must have only one component !");
+ throw INTERP_KERNEL::Exception("DataArrayInt::getIdsEqual : the array must have only one component, you can call 'rearrange' method before !");
const int *cptr=getConstPointer();
std::vector<int> res;
int nbOfTuples=getNumberOfTuples();
return ret;
}
+DataArrayInt *DataArrayInt::getIdsNotEqual(int val) const throw(INTERP_KERNEL::Exception)
+{
+ if(getNumberOfComponents()!=1)
+ throw INTERP_KERNEL::Exception("DataArrayInt::getIdsNotEqual : the array must have only one component, you can call 'rearrange' method before !");
+ const int *cptr=getConstPointer();
+ std::vector<int> res;
+ int nbOfTuples=getNumberOfTuples();
+ for(int i=0;i<nbOfTuples;i++,cptr++)
+ if(*cptr!=val)
+ res.push_back(i);
+ DataArrayInt *ret=DataArrayInt::New();
+ ret->alloc(res.size(),1);
+ std::copy(res.begin(),res.end(),ret->getPointer());
+ return ret;
+}
+
DataArrayInt *DataArrayInt::getIdsEqualList(const std::vector<int>& vals) const throw(INTERP_KERNEL::Exception)
{
if(getNumberOfComponents()!=1)
- throw INTERP_KERNEL::Exception("DataArrayInt::getIdsEqualList : the array must have only one component !");
+ throw INTERP_KERNEL::Exception("DataArrayInt::getIdsEqualList : the array must have only one component, you can call 'rearrange' method before !");
std::set<int> vals2(vals.begin(),vals.end());
const int *cptr=getConstPointer();
std::vector<int> res;
return ret;
}
-DataArrayInt *DataArrayInt::aggregate(const DataArrayInt *a1, const DataArrayInt *a2, int offsetA2)
+DataArrayInt *DataArrayInt::getIdsNotEqualList(const std::vector<int>& vals) const throw(INTERP_KERNEL::Exception)
+{
+ if(getNumberOfComponents()!=1)
+ throw INTERP_KERNEL::Exception("DataArrayInt::getIdsNotEqualList : the array must have only one component, you can call 'rearrange' method before !");
+ std::set<int> vals2(vals.begin(),vals.end());
+ const int *cptr=getConstPointer();
+ std::vector<int> res;
+ int nbOfTuples=getNumberOfTuples();
+ for(int i=0;i<nbOfTuples;i++,cptr++)
+ if(vals2.find(*cptr)==vals2.end())
+ res.push_back(i);
+ DataArrayInt *ret=DataArrayInt::New();
+ ret->alloc(res.size(),1);
+ std::copy(res.begin(),res.end(),ret->getPointer());
+ return ret;
+}
+
+DataArrayInt *DataArrayInt::Aggregate(const DataArrayInt *a1, const DataArrayInt *a2, int offsetA2)
{
int nbOfComp=a1->getNumberOfComponents();
if(nbOfComp!=a2->getNumberOfComponents())
- throw INTERP_KERNEL::Exception("Nb of components mismatch for array aggregation !");
+ throw INTERP_KERNEL::Exception("Nb of components mismatch for array Aggregation !");
int nbOfTuple1=a1->getNumberOfTuples();
int nbOfTuple2=a2->getNumberOfTuples();
DataArrayInt *ret=DataArrayInt::New();
return ret;
}
-/*!
- * This method create a minimal partition of groups 'groups' the std::iota array of size 'newNb'.
- * This method returns an array of size 'newNb' that specifies for each item at which familyId it owns to, and this method returns
- * for each group the familyId it contains. If an id so that id<newNb and that appears in no groups will appears with 0 in return array.
- *
- * @param groups in arrays specifying ids of each groups.
- * @param newNb specifies size of whole set. Must be at least equal to max eltid in 'groups'.
- * @return an array of size newNb specifying fid of each item.
- */
-DataArrayInt *DataArrayInt::makePartition(const std::vector<DataArrayInt *>& groups, int newNb, std::vector< std::vector<int> >& fidsOfGroups)
+DataArrayInt *DataArrayInt::Aggregate(const std::vector<const DataArrayInt *>& a) throw(INTERP_KERNEL::Exception)
{
- DataArrayInt *ret=DataArrayInt::New();
- ret->alloc(newNb,1);
- int *retPtr=ret->getPointer();
- std::fill(retPtr,retPtr+newNb,0);
- int fid=1;
- for(std::vector<DataArrayInt *>::const_iterator iter=groups.begin();iter!=groups.end();iter++)
- {
- const int *ptr=(*iter)->getConstPointer();
- int nbOfElem=(*iter)->getNbOfElems();
- int sfid=fid;
- for(int j=0;j<sfid;j++)
- {
- bool found=false;
- for(int i=0;i<nbOfElem;i++)
- {
- if(retPtr[ptr[i]]==j)
- {
- retPtr[ptr[i]]=fid;
- found=true;
- }
- }
- if(found)
- fid++;
- }
- }
- fidsOfGroups.clear();
- fidsOfGroups.resize(groups.size());
- int grId=0;
- for(std::vector<DataArrayInt *>::const_iterator iter=groups.begin();iter!=groups.end();iter++,grId++)
+ if(a.empty())
+ throw INTERP_KERNEL::Exception("DataArrayInt::Aggregate : input list must be NON EMPTY !");
+ std::vector<const DataArrayInt *>::const_iterator it=a.begin();
+ int nbOfComp=(*it)->getNumberOfComponents();
+ int nbt=(*it++)->getNumberOfTuples();
+ for(int i=1;it!=a.end();it++,i++)
{
- std::set<int> tmp;
- const int *ptr=(*iter)->getConstPointer();
- int nbOfElem=(*iter)->getNbOfElems();
- for(const int *p=ptr;p!=ptr+nbOfElem;p++)
- tmp.insert(retPtr[*p]);
- fidsOfGroups[grId].insert(fidsOfGroups[grId].end(),tmp.begin(),tmp.end());
+ if((*it)->getNumberOfComponents()!=nbOfComp)
+ throw INTERP_KERNEL::Exception("DataArrayInt::Aggregate : Nb of components mismatch for array aggregation !");
+ nbt+=(*it)->getNumberOfTuples();
}
+ DataArrayInt *ret=DataArrayInt::New();
+ ret->alloc(nbt,nbOfComp);
+ int *pt=ret->getPointer();
+ for(it=a.begin();it!=a.end();it++)
+ pt=std::copy((*it)->getConstPointer(),(*it)->getConstPointer()+(*it)->getNbOfElems(),pt);
+ ret->copyStringInfoFrom(*(a[0]));
return ret;
}
-int *DataArrayInt::checkAndPreparePermutation(const int *start, const int *end)
+int DataArrayInt::getMaxValue(int& tupleId) const throw(INTERP_KERNEL::Exception)
{
- int sz=std::distance(start,end);
- int *ret=new int[sz];
- int *work=new int[sz];
- std::copy(start,end,work);
- std::sort(work,work+sz);
- if(std::unique(work,work+sz)!=work+sz)
- {
- delete [] work;
- delete [] ret;
- throw INTERP_KERNEL::Exception("Some elements are equals in the specified array !");
- }
- int *iter2=ret;
- for(const int *iter=start;iter!=end;iter++,iter2++)
- *iter2=std::distance(work,std::find(work,work+sz,*iter));
- delete [] work;
- return ret;
+ if(getNumberOfComponents()!=1)
+ throw INTERP_KERNEL::Exception("DataArrayDouble::getMaxValue : must be applied on DataArrayDouble with only one component !");
+ int nbOfTuples=getNumberOfTuples();
+ if(nbOfTuples<=0)
+ throw INTERP_KERNEL::Exception("DataArrayDouble::getMaxValue : array exists but number of tuples must be > 0 !");
+ const int *vals=getConstPointer();
+ const int *loc=std::max_element(vals,vals+nbOfTuples);
+ tupleId=std::distance(vals,loc);
+ return *loc;
+}
+
+int DataArrayInt::getMinValue(int& tupleId) const throw(INTERP_KERNEL::Exception)
+{
+ if(getNumberOfComponents()!=1)
+ throw INTERP_KERNEL::Exception("DataArrayDouble::getMaxValue : must be applied on DataArrayDouble with only one component !");
+ int nbOfTuples=getNumberOfTuples();
+ if(nbOfTuples<=0)
+ throw INTERP_KERNEL::Exception("DataArrayDouble::getMaxValue : array exists but number of tuples must be > 0 !");
+ const int *vals=getConstPointer();
+ const int *loc=std::min_element(vals,vals+nbOfTuples);
+ tupleId=std::distance(vals,loc);
+ return *loc;
+}
+
+void DataArrayInt::applyLin(int a, int b, int compoId) throw(INTERP_KERNEL::Exception)
+{
+ checkAllocated();
+ int *ptr=getPointer()+compoId;
+ int nbOfComp=getNumberOfComponents();
+ int nbOfTuple=getNumberOfTuples();
+ for(int i=0;i<nbOfTuple;i++,ptr+=nbOfComp)
+ *ptr=a*(*ptr)+b;
+ declareAsNew();
+}
+
+void DataArrayInt::applyLin(int a, int b) throw(INTERP_KERNEL::Exception)
+{
+ checkAllocated();
+ int *ptr=getPointer();
+ int nbOfElems=getNbOfElems();
+ for(int i=0;i<nbOfElems;i++,ptr++)
+ *ptr=a*(*ptr)+b;
+ declareAsNew();
+}
+
+/*!
+ * This method applies the operation 'numerator/x' for each element 'x' in 'this'.
+ * If there is a value in 'this' exactly equal to 0. an exception is thrown.
+ * Warning if presence of null this is modified for each values previous than place where exception was thrown !
+ */
+void DataArrayInt::applyInv(int numerator) throw(INTERP_KERNEL::Exception)
+{
+ checkAllocated();
+ int *ptr=getPointer();
+ int nbOfElems=getNbOfElems();
+ for(int i=0;i<nbOfElems;i++,ptr++)
+ {
+ if(*ptr!=0)
+ {
+ *ptr=numerator/(*ptr);
+ }
+ else
+ {
+ std::ostringstream oss; oss << "DataArrayInt::applyInv : presence of null value in tuple #" << i/getNumberOfComponents() << " component #" << i%getNumberOfComponents();
+ oss << " !";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ }
+ declareAsNew();
+}
+
+void DataArrayInt::applyDivideBy(int val) throw(INTERP_KERNEL::Exception)
+{
+ if(val==0)
+ throw INTERP_KERNEL::Exception("DataArrayInt::applyDivideBy : Trying to divide by 0 !");
+ checkAllocated();
+ int *ptr=getPointer();
+ int nbOfElems=getNbOfElems();
+ std::transform(ptr,ptr+nbOfElems,ptr,std::bind2nd(std::divides<int>(),val));
+ declareAsNew();
+}
+
+void DataArrayInt::applyModulus(int val) throw(INTERP_KERNEL::Exception)
+{
+ if(val<=0)
+ throw INTERP_KERNEL::Exception("DataArrayInt::applyDivideBy : Trying to operate modulus on value <= 0 !");
+ checkAllocated();
+ int *ptr=getPointer();
+ int nbOfElems=getNbOfElems();
+ std::transform(ptr,ptr+nbOfElems,ptr,std::bind2nd(std::modulus<int>(),val));
+ declareAsNew();
+}
+
+/*!
+ * This method applies the operation 'numerator%x' for each element 'x' in 'this'.
+ * If there is a value in 'this' exactly equals or lower than 0. an exception is thrown.
+ * Warning if presence of null this is modified for each values previous than place where exception was thrown !
+ */
+void DataArrayInt::applyRModulus(int val) throw(INTERP_KERNEL::Exception)
+{
+ checkAllocated();
+ int *ptr=getPointer();
+ int nbOfElems=getNbOfElems();
+ for(int i=0;i<nbOfElems;i++,ptr++)
+ {
+ if(*ptr>0)
+ {
+ *ptr=val%(*ptr);
+ }
+ else
+ {
+ std::ostringstream oss; oss << "DataArrayInt::applyRModulus : presence of value <=0 in tuple #" << i/getNumberOfComponents() << " component #" << i%getNumberOfComponents();
+ oss << " !";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ }
+ declareAsNew();
+}
+
+DataArrayInt *DataArrayInt::Meld(const DataArrayInt *a1, const DataArrayInt *a2) throw(INTERP_KERNEL::Exception)
+{
+ std::vector<const DataArrayInt *> arr(2);
+ arr[0]=a1; arr[1]=a2;
+ return Meld(arr);
+}
+
+DataArrayInt *DataArrayInt::Meld(const std::vector<const DataArrayInt *>& a) throw(INTERP_KERNEL::Exception)
+{
+ if(a.empty())
+ throw INTERP_KERNEL::Exception("DataArrayInt::Meld : array must be NON empty !");
+ std::vector<const DataArrayInt *>::const_iterator it;
+ for(it=a.begin();it!=a.end();it++)
+ (*it)->checkAllocated();
+ it=a.begin();
+ int nbOfTuples=(*it)->getNumberOfTuples();
+ std::vector<int> nbc(a.size());
+ std::vector<const int *> pts(a.size());
+ nbc[0]=(*it)->getNumberOfComponents();
+ pts[0]=(*it++)->getConstPointer();
+ for(int i=1;it!=a.end();it++,i++)
+ {
+ if(nbOfTuples!=(*it)->getNumberOfTuples())
+ throw INTERP_KERNEL::Exception("DataArrayInt::meld : mismatch of number of tuples !");
+ nbc[i]=(*it)->getNumberOfComponents();
+ pts[i]=(*it)->getConstPointer();
+ }
+ int totalNbOfComp=std::accumulate(nbc.begin(),nbc.end(),0);
+ DataArrayInt *ret=DataArrayInt::New();
+ ret->alloc(nbOfTuples,totalNbOfComp);
+ int *retPtr=ret->getPointer();
+ for(int i=0;i<nbOfTuples;i++)
+ for(int j=0;j<(int)a.size();j++)
+ {
+ retPtr=std::copy(pts[j],pts[j]+nbc[j],retPtr);
+ pts[j]+=nbc[j];
+ }
+ int k=0;
+ for(int i=0;i<(int)a.size();i++)
+ for(int j=0;j<nbc[i];j++,k++)
+ ret->setInfoOnComponent(k,a[i]->getInfoOnComponent(j).c_str());
+ return ret;
+}
+
+/*!
+ * This method create a minimal partition of groups 'groups' the std::iota array of size 'newNb'.
+ * This method returns an array of size 'newNb' that specifies for each item at which familyId it owns to, and this method returns
+ * for each group the familyId it contains. If an id so that id<newNb and that appears in no groups will appears with 0 in return array.
+ *
+ * @param groups in arrays specifying ids of each groups.
+ * @param newNb specifies size of whole set. Must be at least equal to max eltid in 'groups'.
+ * @return an array of size newNb specifying fid of each item.
+ */
+DataArrayInt *DataArrayInt::MakePartition(const std::vector<const DataArrayInt *>& groups, int newNb, std::vector< std::vector<int> >& fidsOfGroups)
+{
+ DataArrayInt *ret=DataArrayInt::New();
+ ret->alloc(newNb,1);
+ int *retPtr=ret->getPointer();
+ std::fill(retPtr,retPtr+newNb,0);
+ int fid=1;
+ for(std::vector<const DataArrayInt *>::const_iterator iter=groups.begin();iter!=groups.end();iter++)
+ {
+ const int *ptr=(*iter)->getConstPointer();
+ int nbOfElem=(*iter)->getNbOfElems();
+ int sfid=fid;
+ for(int j=0;j<sfid;j++)
+ {
+ bool found=false;
+ for(int i=0;i<nbOfElem;i++)
+ {
+ if(retPtr[ptr[i]]==j)
+ {
+ retPtr[ptr[i]]=fid;
+ found=true;
+ }
+ }
+ if(found)
+ fid++;
+ }
+ }
+ fidsOfGroups.clear();
+ fidsOfGroups.resize(groups.size());
+ int grId=0;
+ for(std::vector<const DataArrayInt *>::const_iterator iter=groups.begin();iter!=groups.end();iter++,grId++)
+ {
+ std::set<int> tmp;
+ const int *ptr=(*iter)->getConstPointer();
+ int nbOfElem=(*iter)->getNbOfElems();
+ for(const int *p=ptr;p!=ptr+nbOfElem;p++)
+ tmp.insert(retPtr[*p]);
+ fidsOfGroups[grId].insert(fidsOfGroups[grId].end(),tmp.begin(),tmp.end());
+ }
+ return ret;
+}
+
+DataArrayInt *DataArrayInt::BuildUnion(const std::vector<const DataArrayInt *>& a) throw(INTERP_KERNEL::Exception)
+{
+ int valm=std::numeric_limits<int>::max();
+ for(std::vector<const DataArrayInt *>::const_iterator it=a.begin();it!=a.end();it++)
+ {
+ (*it)->checkAllocated();
+ if((*it)->getNumberOfComponents()!=1)
+ throw INTERP_KERNEL::Exception("DataArrayInt::BuildUnion : only single component allowed !");
+ int tmp1;
+ valm=std::min((*it)->getMinValue(tmp1),valm);
+ }
+ if(valm<0)
+ throw INTERP_KERNEL::Exception("DataArrayInt::BuildUnion : a negative value has been detected !");
+ //
+ std::set<int> r;
+ for(std::vector<const DataArrayInt *>::const_iterator it=a.begin();it!=a.end();it++)
+ {
+ const int *pt=(*it)->getConstPointer();
+ int nbOfTuples=(*it)->getNumberOfTuples();
+ r.insert(pt,pt+nbOfTuples);
+ }
+ DataArrayInt *ret=DataArrayInt::New();
+ ret->alloc(r.size(),1);
+ std::copy(r.begin(),r.end(),ret->getPointer());
+ return ret;
+}
+
+DataArrayInt *DataArrayInt::BuildIntersection(const std::vector<const DataArrayInt *>& a) throw(INTERP_KERNEL::Exception)
+{
+ int valm=std::numeric_limits<int>::max();
+ for(std::vector<const DataArrayInt *>::const_iterator it=a.begin();it!=a.end();it++)
+ {
+ (*it)->checkAllocated();
+ if((*it)->getNumberOfComponents()!=1)
+ throw INTERP_KERNEL::Exception("DataArrayInt::BuildUnion : only single component allowed !");
+ int tmp1;
+ valm=std::min((*it)->getMinValue(tmp1),valm);
+ }
+ if(valm<0)
+ throw INTERP_KERNEL::Exception("DataArrayInt::BuildUnion : a negative value has been detected !");
+ //
+ std::set<int> r;
+ for(std::vector<const DataArrayInt *>::const_iterator it=a.begin();it!=a.end();it++)
+ {
+ const int *pt=(*it)->getConstPointer();
+ int nbOfTuples=(*it)->getNumberOfTuples();
+ std::set<int> s1(pt,pt+nbOfTuples);
+ if(it!=a.begin())
+ {
+ std::set<int> r2;
+ std::set_intersection(r.begin(),r.end(),s1.begin(),s1.end(),inserter(r2,r2.end()));
+ r=r2;
+ }
+ else
+ r=s1;
+ }
+ DataArrayInt *ret=DataArrayInt::New();
+ ret->alloc(r.size(),1);
+ std::copy(r.begin(),r.end(),ret->getPointer());
+ return ret;
+}
+
+DataArrayInt *DataArrayInt::buildComplement(int nbOfElement) const throw(INTERP_KERNEL::Exception)
+{
+ checkAllocated();
+ if(getNumberOfComponents()!=1)
+ throw INTERP_KERNEL::Exception("DataArrayInt::buildComplement : only single component allowed !");
+ std::vector<bool> tmp(nbOfElement);
+ const int *pt=getConstPointer();
+ int nbOfTuples=getNumberOfTuples();
+ for(const int *w=pt;w!=pt+nbOfTuples;w++)
+ if(*w>=0 && *w<nbOfElement)
+ tmp[*w]=true;
+ else
+ throw INTERP_KERNEL::Exception("DataArrayInt::buildComplement : an element is not in valid range : [0,nbOfElement) !");
+ int nbOfRetVal=std::count(tmp.begin(),tmp.end(),false);
+ DataArrayInt *ret=DataArrayInt::New();
+ ret->alloc(nbOfRetVal,1);
+ int j=0;
+ int *retPtr=ret->getPointer();
+ for(int i=0;i<nbOfElement;i++)
+ if(!tmp[i])
+ retPtr[j++]=i;
+ return ret;
+}
+
+DataArrayInt *DataArrayInt::buildSubstraction(const DataArrayInt *other) const throw(INTERP_KERNEL::Exception)
+{
+ checkAllocated();
+ other->checkAllocated();
+ if(getNumberOfComponents()!=1)
+ throw INTERP_KERNEL::Exception("DataArrayInt::buildSubstraction : only single component allowed !");
+ if(other->getNumberOfComponents()!=1)
+ throw INTERP_KERNEL::Exception("DataArrayInt::buildSubstraction : only single component allowed for other type !");
+ const int *pt=getConstPointer();
+ int nbOfTuples=getNumberOfTuples();
+ std::set<int> s1(pt,pt+nbOfTuples);
+ pt=other->getConstPointer();
+ nbOfTuples=other->getNumberOfTuples();
+ std::set<int> s2(pt,pt+nbOfTuples);
+ std::vector<int> r;
+ std::set_difference(s1.begin(),s1.end(),s2.begin(),s2.end(),std::back_insert_iterator< std::vector<int> >(r));
+ DataArrayInt *ret=DataArrayInt::New();
+ ret->alloc(r.size(),1);
+ std::copy(r.begin(),r.end(),ret->getPointer());
+ return ret;
+}
+
+DataArrayInt *DataArrayInt::buildUnion(const DataArrayInt *other) const throw(INTERP_KERNEL::Exception)
+{
+ std::vector<const DataArrayInt *>arrs(2);
+ arrs[0]=this; arrs[1]=other;
+ return BuildUnion(arrs);
+}
+
+DataArrayInt *DataArrayInt::buildIntersection(const DataArrayInt *other) const throw(INTERP_KERNEL::Exception)
+{
+ std::vector<const DataArrayInt *>arrs(2);
+ arrs[0]=this; arrs[1]=other;
+ return BuildIntersection(arrs);
+}
+
+/*!
+ * This method could be usefull for returned DataArrayInt marked as index. Some methods that generate such DataArrayInt instances:
+ * - ParaMEDMEM::MEDCouplingUMesh::buildDescendingConnectivity
+ * - ParaMEDMEM::MEDCouplingUMesh::getNodalConnectivityIndex
+ * This method makes the assumption that 'this' is allocated and has exactly one component and 2 or more tuples. If not an exception is thrown.
+ * This method retrives a newly created DataArrayInt instance with 1 component and this->getNumberOfTuples()-1 tuples.
+ * If this contains [1,3,6,7,7,9,15] -> returned array will contain [2,3,1,0,2,6].
+ */
+DataArrayInt *DataArrayInt::deltaShiftIndex() const throw(INTERP_KERNEL::Exception)
+{
+ checkAllocated();
+ if(getNumberOfComponents()!=1)
+ throw INTERP_KERNEL::Exception("DataArrayInt::deltaShiftIndex : only single component allowed !");
+ int nbOfTuples=getNumberOfTuples();
+ if(nbOfTuples<2)
+ throw INTERP_KERNEL::Exception("DataArrayInt::deltaShiftIndex : 1 tuple at least must be present in 'this' !");
+ const int *ptr=getPointer();
+ DataArrayInt *ret=DataArrayInt::New();
+ ret->alloc(nbOfTuples-1,1);
+ int *out=ret->getPointer();
+ std::transform(ptr+1,ptr+nbOfTuples,ptr,out,std::minus<int>());
+ return ret;
+}
+
+/*!
+ * This method performs the work on itself. This method works on array with number of component equal to one and allocated. If not an exception is thrown.
+ * This method conserves the number of tuples and number of components (1). No reallocation is done.
+ * For an array [3,5,1,2,0,8] it becomes [0,3,8,9,11,11]. For each i>0 new[i]=new[i-1]+old[i-1] for i==0 new[i]=0.
+ * This could be usefull for allToAllV in MPI with contiguous policy.
+ */
+void DataArrayInt::computeOffsets() throw(INTERP_KERNEL::Exception)
+{
+ checkAllocated();
+ if(getNumberOfComponents()!=1)
+ throw INTERP_KERNEL::Exception("DataArrayInt::computeOffsets : only single component allowed !");
+ int nbOfTuples=getNumberOfTuples();
+ if(nbOfTuples==0)
+ return ;
+ int *work=getPointer();
+ int tmp=work[0];
+ work[0]=0;
+ for(int i=1;i<nbOfTuples;i++)
+ {
+ int tmp2=work[i];
+ work[i]=work[i-1]+tmp;
+ tmp=tmp2;
+ }
+ declareAsNew();
+}
+
+/*!
+ * This method returns all different values found in 'this'.
+ */
+std::set<int> DataArrayInt::getDifferentValues() const throw(INTERP_KERNEL::Exception)
+{
+ checkAllocated();
+ std::set<int> ret;
+ ret.insert(getConstPointer(),getConstPointer()+getNbOfElems());
+ return ret;
+}
+
+DataArrayInt *DataArrayInt::Add(const DataArrayInt *a1, const DataArrayInt *a2) throw(INTERP_KERNEL::Exception)
+{
+ int nbOfTuple=a2->getNumberOfTuples();
+ int nbOfComp=a2->getNumberOfComponents();
+ a1->checkNbOfTuplesAndComp(nbOfTuple,nbOfComp,"Nb of components mismatch for array Add !");
+ DataArrayInt *ret=DataArrayInt::New();
+ ret->alloc(nbOfTuple,nbOfComp);
+ std::transform(a1->getConstPointer(),a1->getConstPointer()+nbOfTuple*nbOfComp,a2->getConstPointer(),ret->getPointer(),std::plus<int>());
+ ret->copyStringInfoFrom(*a1);
+ return ret;
+}
+
+void DataArrayInt::addEqual(const DataArrayInt *other) throw(INTERP_KERNEL::Exception)
+{
+ int nbOfTuple=other->getNumberOfTuples();
+ int nbOfComp=other->getNumberOfComponents();
+ checkNbOfTuplesAndComp(nbOfTuple,nbOfComp,"Nb of components mismatch for array add equal !");
+ std::transform(getConstPointer(),getConstPointer()+nbOfTuple*nbOfComp,other->getConstPointer(),getPointer(),std::plus<int>());
+ declareAsNew();
+}
+
+DataArrayInt *DataArrayInt::Substract(const DataArrayInt *a1, const DataArrayInt *a2) throw(INTERP_KERNEL::Exception)
+{
+ int nbOfTuple=a2->getNumberOfTuples();
+ int nbOfComp=a2->getNumberOfComponents();
+ a1->checkNbOfTuplesAndComp(nbOfTuple,nbOfComp,"Nb of components mismatch for array Substract !");
+ DataArrayInt *ret=DataArrayInt::New();
+ ret->alloc(nbOfTuple,nbOfComp);
+ std::transform(a1->getConstPointer(),a1->getConstPointer()+nbOfTuple*nbOfComp,a2->getConstPointer(),ret->getPointer(),std::minus<int>());
+ ret->copyStringInfoFrom(*a1);
+ return ret;
+}
+
+void DataArrayInt::substractEqual(const DataArrayInt *other) throw(INTERP_KERNEL::Exception)
+{
+ int nbOfTuple=other->getNumberOfTuples();
+ int nbOfComp=other->getNumberOfComponents();
+ checkNbOfTuplesAndComp(nbOfTuple,nbOfComp,"Nb of components mismatch for array substract equal !");
+ std::transform(getConstPointer(),getConstPointer()+nbOfTuple*nbOfComp,other->getConstPointer(),getPointer(),std::minus<int>());
+ declareAsNew();
+}
+
+DataArrayInt *DataArrayInt::Multiply(const DataArrayInt *a1, const DataArrayInt *a2) throw(INTERP_KERNEL::Exception)
+{
+ int nbOfTuple=a1->getNumberOfTuples();
+ int nbOfTuple2=a2->getNumberOfTuples();
+ int nbOfComp=a1->getNumberOfComponents();
+ int nbOfComp2=a2->getNumberOfComponents();
+ if(nbOfTuple!=nbOfTuple2)
+ throw INTERP_KERNEL::Exception("Nb of tuples mismatch for array Multiply !");
+ DataArrayInt *ret=0;
+ if(nbOfComp==nbOfComp2)
+ {
+ ret=DataArrayInt::New();
+ ret->alloc(nbOfTuple,nbOfComp);
+ std::transform(a1->getConstPointer(),a1->getConstPointer()+nbOfTuple*nbOfComp,a2->getConstPointer(),ret->getPointer(),std::multiplies<int>());
+ ret->copyStringInfoFrom(*a1);
+ }
+ else
+ {
+ int nbOfCompMin,nbOfCompMax;
+ const DataArrayInt *aMin, *aMax;
+ if(nbOfComp>nbOfComp2)
+ {
+ nbOfCompMin=nbOfComp2; nbOfCompMax=nbOfComp;
+ aMin=a2; aMax=a1;
+ }
+ else
+ {
+ nbOfCompMin=nbOfComp; nbOfCompMax=nbOfComp2;
+ aMin=a1; aMax=a2;
+ }
+ if(nbOfCompMin==1)
+ {
+ ret=DataArrayInt::New();
+ ret->alloc(nbOfTuple,nbOfCompMax);
+ const int *aMinPtr=aMin->getConstPointer();
+ const int *aMaxPtr=aMax->getConstPointer();
+ int *res=ret->getPointer();
+ for(int i=0;i<nbOfTuple;i++)
+ res=std::transform(aMaxPtr+i*nbOfCompMax,aMaxPtr+(i+1)*nbOfCompMax,res,std::bind2nd(std::multiplies<int>(),aMinPtr[i]));
+ ret->copyStringInfoFrom(*aMax);
+ }
+ else
+ throw INTERP_KERNEL::Exception("Nb of components mismatch for array Multiply !");
+ }
+ return ret;
+}
+
+void DataArrayInt::multiplyEqual(const DataArrayInt *other) throw(INTERP_KERNEL::Exception)
+{
+ int nbOfTuple=getNumberOfTuples();
+ int nbOfTuple2=other->getNumberOfTuples();
+ int nbOfComp=getNumberOfComponents();
+ int nbOfComp2=other->getNumberOfComponents();
+ if(nbOfTuple!=nbOfTuple2)
+ throw INTERP_KERNEL::Exception("Nb of tuples mismatch for array multiplyEqual !");
+ if(nbOfComp==nbOfComp2)
+ {
+ std::transform(getConstPointer(),getConstPointer()+nbOfTuple*nbOfComp,other->getConstPointer(),getPointer(),std::multiplies<int>());
+ }
+ else
+ {
+ if(nbOfComp2==1)
+ {
+ const int *ptr=other->getConstPointer();
+ int *myPtr=getPointer();
+ for(int i=0;i<nbOfTuple;i++)
+ myPtr=std::transform(myPtr,myPtr+nbOfComp,myPtr,std::bind2nd(std::multiplies<int>(),ptr[i]));
+ }
+ else
+ throw INTERP_KERNEL::Exception("Nb of components mismatch for array multiplyEqual !");
+ }
+ declareAsNew();
+}
+
+DataArrayInt *DataArrayInt::Divide(const DataArrayInt *a1, const DataArrayInt *a2) throw(INTERP_KERNEL::Exception)
+{
+ int nbOfTuple=a1->getNumberOfTuples();
+ int nbOfTuple2=a2->getNumberOfTuples();
+ int nbOfComp=a1->getNumberOfComponents();
+ int nbOfComp2=a2->getNumberOfComponents();
+ if(nbOfTuple!=nbOfTuple2)
+ throw INTERP_KERNEL::Exception("Nb of tuples mismatch for array Divide !");
+ DataArrayInt *ret=0;
+ if(nbOfComp==nbOfComp2)
+ {
+ ret=DataArrayInt::New();
+ ret->alloc(nbOfTuple,nbOfComp);
+ std::transform(a1->getConstPointer(),a1->getConstPointer()+nbOfTuple*nbOfComp,a2->getConstPointer(),ret->getPointer(),std::divides<int>());
+ ret->copyStringInfoFrom(*a1);
+ }
+ else
+ {
+ if(nbOfComp2==1)
+ {
+ ret=DataArrayInt::New();
+ ret->alloc(nbOfTuple,nbOfComp);
+ const int *a2Ptr=a2->getConstPointer();
+ const int *a1Ptr=a1->getConstPointer();
+ int *res=ret->getPointer();
+ for(int i=0;i<nbOfTuple;i++)
+ res=std::transform(a1Ptr+i*nbOfComp,a1Ptr+(i+1)*nbOfComp,res,std::bind2nd(std::divides<int>(),a2Ptr[i]));
+ ret->copyStringInfoFrom(*a1);
+ }
+ else
+ throw INTERP_KERNEL::Exception("Nb of components mismatch for array Divide !");
+ }
+ return ret;
+}
+
+void DataArrayInt::divideEqual(const DataArrayInt *other) throw(INTERP_KERNEL::Exception)
+{
+ int nbOfTuple=getNumberOfTuples();
+ int nbOfTuple2=other->getNumberOfTuples();
+ int nbOfComp=getNumberOfComponents();
+ int nbOfComp2=other->getNumberOfComponents();
+ if(nbOfTuple!=nbOfTuple2)
+ throw INTERP_KERNEL::Exception("Nb of tuples mismatch for array divideEqual !");
+ if(nbOfComp==nbOfComp2)
+ {
+ std::transform(getConstPointer(),getConstPointer()+nbOfTuple*nbOfComp,other->getConstPointer(),getPointer(),std::divides<int>());
+ }
+ else
+ {
+ if(nbOfComp2==1)
+ {
+ const int *ptr=other->getConstPointer();
+ int *myPtr=getPointer();
+ for(int i=0;i<nbOfTuple;i++)
+ myPtr=std::transform(myPtr,myPtr+nbOfComp,myPtr,std::bind2nd(std::divides<int>(),ptr[i]));
+ }
+ else
+ throw INTERP_KERNEL::Exception("Nb of components mismatch for array divideEqual !");
+ }
+ declareAsNew();
+}
+
+DataArrayInt *DataArrayInt::Modulus(const DataArrayInt *a1, const DataArrayInt *a2) throw(INTERP_KERNEL::Exception)
+{
+ int nbOfTuple=a2->getNumberOfTuples();
+ int nbOfComp=a2->getNumberOfComponents();
+ a1->checkNbOfTuplesAndComp(nbOfTuple,nbOfComp,"Nb of components mismatch for array Modulus");
+ DataArrayInt *ret=DataArrayInt::New();
+ ret->alloc(nbOfTuple,nbOfComp);
+ std::transform(a1->getConstPointer(),a1->getConstPointer()+nbOfTuple*nbOfComp,a2->getConstPointer(),ret->getPointer(),std::modulus<int>());
+ ret->copyStringInfoFrom(*a1);
+ return ret;
+}
+
+void DataArrayInt::modulusEqual(const DataArrayInt *other) throw(INTERP_KERNEL::Exception)
+{
+ int nbOfTuple=other->getNumberOfTuples();
+ int nbOfComp=other->getNumberOfComponents();
+ checkNbOfTuplesAndComp(nbOfTuple,nbOfComp,"Nb of components mismatch for array modulus equal");
+ std::transform(getConstPointer(),getConstPointer()+nbOfTuple*nbOfComp,other->getConstPointer(),getPointer(),std::modulus<int>());
+ declareAsNew();
+}
+
+int *DataArrayInt::CheckAndPreparePermutation(const int *start, const int *end)
+{
+ int sz=std::distance(start,end);
+ int *ret=new int[sz];
+ int *work=new int[sz];
+ std::copy(start,end,work);
+ std::sort(work,work+sz);
+ if(std::unique(work,work+sz)!=work+sz)
+ {
+ delete [] work;
+ delete [] ret;
+ throw INTERP_KERNEL::Exception("Some elements are equals in the specified array !");
+ }
+ int *iter2=ret;
+ for(const int *iter=start;iter!=end;iter++,iter2++)
+ *iter2=std::distance(work,std::find(work,work+sz,*iter));
+ delete [] work;
+ return ret;
+}
+
+/*!
+ * Useless method for end user. Only for MPI/Corba/File serialsation for multi arrays class.
+ * Server side.
+ */
+void DataArrayInt::getTinySerializationIntInformation(std::vector<int>& tinyInfo) const
+{
+ tinyInfo.resize(2);
+ if(isAllocated())
+ {
+ tinyInfo[0]=getNumberOfTuples();
+ tinyInfo[1]=getNumberOfComponents();
+ }
+ else
+ {
+ tinyInfo[0]=-1;
+ tinyInfo[1]=-1;
+ }
+}
+
+/*!
+ * Useless method for end user. Only for MPI/Corba/File serialsation for multi arrays class.
+ * Server side.
+ */
+void DataArrayInt::getTinySerializationStrInformation(std::vector<std::string>& tinyInfo) const
+{
+ if(isAllocated())
+ {
+ int nbOfCompo=getNumberOfComponents();
+ tinyInfo.resize(nbOfCompo+1);
+ tinyInfo[0]=getName();
+ for(int i=0;i<nbOfCompo;i++)
+ tinyInfo[i+1]=getInfoOnComponent(i);
+ }
+ else
+ {
+ tinyInfo.resize(1);
+ tinyInfo[0]=getName();
+ }
+}
+
+/*!
+ * Useless method for end user. Only for MPI/Corba/File serialsation for multi arrays class.
+ * This method returns if a feeding is needed.
+ */
+bool DataArrayInt::resizeForUnserialization(const std::vector<int>& tinyInfoI)
+{
+ int nbOfTuple=tinyInfoI[0];
+ int nbOfComp=tinyInfoI[1];
+ if(nbOfTuple!=-1 || nbOfComp!=-1)
+ {
+ alloc(nbOfTuple,nbOfComp);
+ return true;
+ }
+ return false;
+}
+
+/*!
+ * Useless method for end user. Only for MPI/Corba/File serialsation for multi arrays class.
+ * This method returns if a feeding is needed.
+ */
+void DataArrayInt::finishUnserialization(const std::vector<int>& tinyInfoI, const std::vector<std::string>& tinyInfoS)
+{
+ setName(tinyInfoS[0].c_str());
+ if(isAllocated())
+ {
+ int nbOfCompo=getNumberOfComponents();
+ for(int i=0;i<nbOfCompo;i++)
+ setInfoOnComponent(i,tinyInfoS[i+1].c_str());
+ }
}
#include "MEDCouplingRefCountObject.hxx"
#include "InterpKernelException.hxx"
+#include <set>
#include <string>
#include <vector>
#include <iterator>
void fillWithValue(const T& val);
T *fromNoInterlace(int nbOfComp) const;
T *toNoInterlace(int nbOfComp) const;
+ void sort();
void alloc(int nbOfElements);
void reAlloc(int newNbOfElements);
void useArray(const T *array, bool ownership, DeallocType type, int nbOfElem);
MEDCOUPLING_EXPORT void reprWithoutNameStream(std::ostream& stream) const;
MEDCOUPLING_EXPORT std::string getName() const { return _name; }
MEDCOUPLING_EXPORT const std::vector<std::string> &getInfoOnComponent() const { return _info_on_compo; }
+ MEDCOUPLING_EXPORT std::vector<std::string> getVarsOnComponent() const;
+ MEDCOUPLING_EXPORT std::vector<std::string> getUnitsOnComponent() const;
MEDCOUPLING_EXPORT std::string getInfoOnComponent(int i) const throw(INTERP_KERNEL::Exception);
+ MEDCOUPLING_EXPORT std::string getVarOnComponent(int i) const throw(INTERP_KERNEL::Exception);
+ MEDCOUPLING_EXPORT std::string getUnitOnComponent(int i) const throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT void setInfoOnComponent(int i, const char *info) throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT int getNumberOfComponents() const { return _info_on_compo.size(); }
MEDCOUPLING_EXPORT int getNumberOfTuples() const { return _nb_of_tuples; }
MEDCOUPLING_EXPORT int getNbOfElems() const { return _info_on_compo.size()*_nb_of_tuples; }
+ MEDCOUPLING_EXPORT void checkNbOfTuplesAndComp(const DataArray& other, const char *msg) const throw(INTERP_KERNEL::Exception);
+ MEDCOUPLING_EXPORT void checkNbOfTuplesAndComp(int nbOfTuples, int nbOfCompo, const char *msg) const throw(INTERP_KERNEL::Exception);
+ MEDCOUPLING_EXPORT void checkNbOfElems(int nbOfElems, const char *msg) const throw(INTERP_KERNEL::Exception);
protected:
DataArray():_nb_of_tuples(-1) { }
+ protected:
+ static void CheckValueInRange(int ref, int value, const char *msg) throw(INTERP_KERNEL::Exception);
+ static void CheckClosingParInRange(int ref, int value, const char *msg) throw(INTERP_KERNEL::Exception);
+ static int GetNumberOfItemGivenBES(int begin, int end, int step, const char *msg) throw(INTERP_KERNEL::Exception);
protected:
int _nb_of_tuples;
std::string _name;
MEDCOUPLING_EXPORT static DataArrayDouble *New();
MEDCOUPLING_EXPORT bool isAllocated() const;
MEDCOUPLING_EXPORT void checkAllocated() const throw(INTERP_KERNEL::Exception);
- MEDCOUPLING_EXPORT DataArrayDouble *deepCopy() const;
+ MEDCOUPLING_EXPORT DataArrayDouble *deepCpy() const;
MEDCOUPLING_EXPORT DataArrayDouble *performCpy(bool deepCpy) const;
+ MEDCOUPLING_EXPORT void cpyFrom(const DataArrayDouble& other) throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT void alloc(int nbOfTuple, int nbOfCompo);
+ MEDCOUPLING_EXPORT void allocIfNecessary(int nbOfTuple, int nbOfCompo);
MEDCOUPLING_EXPORT void fillWithZero() throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT void fillWithValue(double val) throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT void iota(double init=0.) throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT bool isUniform(double val, double eps) const;
+ MEDCOUPLING_EXPORT void sort() throw(INTERP_KERNEL::Exception);
+ MEDCOUPLING_EXPORT void checkMonotonic(double eps) const throw(INTERP_KERNEL::Exception);
+ MEDCOUPLING_EXPORT bool isMonotonic(double eps) const throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT std::string repr() const;
MEDCOUPLING_EXPORT std::string reprZip() const;
MEDCOUPLING_EXPORT void reprStream(std::ostream& stream) const;
MEDCOUPLING_EXPORT DataArrayDouble *renumberR(const int *new2Old) const;
MEDCOUPLING_EXPORT DataArrayDouble *renumberAndReduce(const int *old2New, int newNbOfTuple) const;
MEDCOUPLING_EXPORT DataArrayDouble *selectByTupleId(const int *new2OldBg, const int *new2OldEnd) const;
+ MEDCOUPLING_EXPORT DataArrayDouble *selectByTupleIdSafe(const int *new2OldBg, const int *new2OldEnd) const throw(INTERP_KERNEL::Exception);
+ MEDCOUPLING_EXPORT DataArrayDouble *selectByTupleId2(int bg, int end, int step) const throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT DataArrayDouble *substr(int tupleIdBg, int tupleIdEnd=-1) const throw(INTERP_KERNEL::Exception);
+ MEDCOUPLING_EXPORT void rearrange(int newNbOfCompo) throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT DataArrayDouble *changeNbOfComponents(int newNbOfComp, double dftValue) const throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT DataArrayDouble *keepSelectedComponents(const std::vector<int>& compoIds) const throw(INTERP_KERNEL::Exception);
+ MEDCOUPLING_EXPORT void meldWith(const DataArrayDouble *other) throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT void setSelectedComponents(const DataArrayDouble *a, const std::vector<int>& compoIds) throw(INTERP_KERNEL::Exception);
+ MEDCOUPLING_EXPORT void setPartOfValues1(const DataArrayDouble *a, int bgTuples, int endTuples, int stepTuples, int bgComp, int endComp, int stepComp, bool strictCompoCompare=true) throw(INTERP_KERNEL::Exception);
+ MEDCOUPLING_EXPORT void setPartOfValuesSimple1(double a, int bgTuples, int endTuples, int stepTuples, int bgComp, int endComp, int stepComp) throw(INTERP_KERNEL::Exception);
+ MEDCOUPLING_EXPORT void setPartOfValues2(const DataArrayDouble *a, const int *bgTuples, const int *endTuples, const int *bgComp, const int *endComp, bool strictCompoCompare=true) throw(INTERP_KERNEL::Exception);
+ MEDCOUPLING_EXPORT void setPartOfValuesSimple2(double a, const int *bgTuples, const int *endTuples, const int *bgComp, const int *endComp) throw(INTERP_KERNEL::Exception);
+ MEDCOUPLING_EXPORT void setPartOfValues3(const DataArrayDouble *a, const int *bgTuples, const int *endTuples, int bgComp, int endComp, int stepComp, bool strictCompoCompare=true) throw(INTERP_KERNEL::Exception);
+ MEDCOUPLING_EXPORT void setPartOfValuesSimple3(double a, const int *bgTuples, const int *endTuples, int bgComp, int endComp, int stepComp) throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT void getTuple(int tupleId, double *res) const { std::copy(_mem.getConstPointerLoc(tupleId*_info_on_compo.size()),_mem.getConstPointerLoc((tupleId+1)*_info_on_compo.size()),res); }
MEDCOUPLING_EXPORT double getIJ(int tupleId, int compoId) const { return _mem[tupleId*_info_on_compo.size()+compoId]; }
MEDCOUPLING_EXPORT void setIJ(int tupleId, int compoId, double newVal) { _mem[tupleId*_info_on_compo.size()+compoId]=newVal; declareAsNew(); }
+ MEDCOUPLING_EXPORT void setIJSilent(int tupleId, int compoId, double newVal) { _mem[tupleId*_info_on_compo.size()+compoId]=newVal; }
MEDCOUPLING_EXPORT double *getPointer() const { return _mem.getPointer(); }
- MEDCOUPLING_EXPORT static void setArrayIn(DataArrayDouble *newArray, DataArrayDouble* &arrayToSet);
+ MEDCOUPLING_EXPORT static void SetArrayIn(DataArrayDouble *newArray, DataArrayDouble* &arrayToSet);
MEDCOUPLING_EXPORT const double *getConstPointer() const { return _mem.getConstPointer(); }
MEDCOUPLING_EXPORT void useArray(const double *array, bool ownership, DeallocType type, int nbOfTuple, int nbOfCompo);
MEDCOUPLING_EXPORT void writeOnPlace(int id, double element0, const double *others, int sizeOfOthers) { _mem.writeOnPlace(id,element0,others,sizeOfOthers); }
MEDCOUPLING_EXPORT DataArrayDouble *maxPerTuple() const throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT void sortPerTuple(bool asc) throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT void applyLin(double a, double b, int compoId) throw(INTERP_KERNEL::Exception);
+ MEDCOUPLING_EXPORT void applyLin(double a, double b) throw(INTERP_KERNEL::Exception);
+ MEDCOUPLING_EXPORT void applyInv(double numerator) throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT DataArrayDouble *applyFunc(int nbOfComp, FunctionToEvaluate func) const throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT DataArrayDouble *applyFunc(int nbOfComp, const char *func) const throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT DataArrayDouble *applyFunc(const char *func) const throw(INTERP_KERNEL::Exception);
+ MEDCOUPLING_EXPORT DataArrayDouble *applyFunc2(int nbOfComp, const char *func) const throw(INTERP_KERNEL::Exception);
+ MEDCOUPLING_EXPORT DataArrayDouble *applyFunc3(int nbOfComp, const std::vector<std::string>& varsOrder, const char *func) const throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT void applyFuncFast32(const char *func) throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT void applyFuncFast64(const char *func) throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT DataArrayInt *getIdsInRange(double vmin, double vmax) const throw(INTERP_KERNEL::Exception);
- MEDCOUPLING_EXPORT static DataArrayDouble *aggregate(const DataArrayDouble *a1, const DataArrayDouble *a2) throw(INTERP_KERNEL::Exception);
- MEDCOUPLING_EXPORT static DataArrayDouble *dot(const DataArrayDouble *a1, const DataArrayDouble *a2) throw(INTERP_KERNEL::Exception);
- MEDCOUPLING_EXPORT static DataArrayDouble *crossProduct(const DataArrayDouble *a1, const DataArrayDouble *a2) throw(INTERP_KERNEL::Exception);
- MEDCOUPLING_EXPORT static DataArrayDouble *max(const DataArrayDouble *a1, const DataArrayDouble *a2) throw(INTERP_KERNEL::Exception);
- MEDCOUPLING_EXPORT static DataArrayDouble *min(const DataArrayDouble *a1, const DataArrayDouble *a2) throw(INTERP_KERNEL::Exception);
- MEDCOUPLING_EXPORT static DataArrayDouble *add(const DataArrayDouble *a1, const DataArrayDouble *a2) throw(INTERP_KERNEL::Exception);
+ MEDCOUPLING_EXPORT static DataArrayDouble *Aggregate(const DataArrayDouble *a1, const DataArrayDouble *a2) throw(INTERP_KERNEL::Exception);
+ MEDCOUPLING_EXPORT static DataArrayDouble *Aggregate(const std::vector<const DataArrayDouble *>& a) throw(INTERP_KERNEL::Exception);
+ MEDCOUPLING_EXPORT static DataArrayDouble *Meld(const DataArrayDouble *a1, const DataArrayDouble *a2) throw(INTERP_KERNEL::Exception);
+ MEDCOUPLING_EXPORT static DataArrayDouble *Meld(const std::vector<const DataArrayDouble *>& a) throw(INTERP_KERNEL::Exception);
+ MEDCOUPLING_EXPORT static DataArrayDouble *Dot(const DataArrayDouble *a1, const DataArrayDouble *a2) throw(INTERP_KERNEL::Exception);
+ MEDCOUPLING_EXPORT static DataArrayDouble *CrossProduct(const DataArrayDouble *a1, const DataArrayDouble *a2) throw(INTERP_KERNEL::Exception);
+ MEDCOUPLING_EXPORT static DataArrayDouble *Max(const DataArrayDouble *a1, const DataArrayDouble *a2) throw(INTERP_KERNEL::Exception);
+ MEDCOUPLING_EXPORT static DataArrayDouble *Min(const DataArrayDouble *a1, const DataArrayDouble *a2) throw(INTERP_KERNEL::Exception);
+ MEDCOUPLING_EXPORT static DataArrayDouble *Add(const DataArrayDouble *a1, const DataArrayDouble *a2) throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT void addEqual(const DataArrayDouble *other) throw(INTERP_KERNEL::Exception);
- MEDCOUPLING_EXPORT static DataArrayDouble *substract(const DataArrayDouble *a1, const DataArrayDouble *a2) throw(INTERP_KERNEL::Exception);
+ MEDCOUPLING_EXPORT static DataArrayDouble *Substract(const DataArrayDouble *a1, const DataArrayDouble *a2) throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT void substractEqual(const DataArrayDouble *other) throw(INTERP_KERNEL::Exception);
- MEDCOUPLING_EXPORT static DataArrayDouble *multiply(const DataArrayDouble *a1, const DataArrayDouble *a2) throw(INTERP_KERNEL::Exception);
+ MEDCOUPLING_EXPORT static DataArrayDouble *Multiply(const DataArrayDouble *a1, const DataArrayDouble *a2) throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT void multiplyEqual(const DataArrayDouble *other) throw(INTERP_KERNEL::Exception);
- MEDCOUPLING_EXPORT static DataArrayDouble *divide(const DataArrayDouble *a1, const DataArrayDouble *a2) throw(INTERP_KERNEL::Exception);
+ MEDCOUPLING_EXPORT static DataArrayDouble *Divide(const DataArrayDouble *a1, const DataArrayDouble *a2) throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT void divideEqual(const DataArrayDouble *other) throw(INTERP_KERNEL::Exception);
//! nothing to do here because this class does not aggregate any TimeLabel instance.
- MEDCOUPLING_EXPORT void updateTime() { }
+ MEDCOUPLING_EXPORT void updateTime() const { }
+ public:
+ void getTinySerializationIntInformation(std::vector<int>& tinyInfo) const;
+ void getTinySerializationStrInformation(std::vector<std::string>& tinyInfo) const;
+ bool resizeForUnserialization(const std::vector<int>& tinyInfoI);
+ void finishUnserialization(const std::vector<int>& tinyInfoI, const std::vector<std::string>& tinyInfoS);
private:
DataArrayDouble() { }
private:
MEDCOUPLING_EXPORT static DataArrayInt *New();
MEDCOUPLING_EXPORT bool isAllocated() const;
MEDCOUPLING_EXPORT void checkAllocated() const throw(INTERP_KERNEL::Exception);
- MEDCOUPLING_EXPORT DataArrayInt *deepCopy() const;
+ MEDCOUPLING_EXPORT DataArrayInt *deepCpy() const;
MEDCOUPLING_EXPORT DataArrayInt *performCpy(bool deepCpy) const;
+ MEDCOUPLING_EXPORT void cpyFrom(const DataArrayInt& other) throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT void alloc(int nbOfTuple, int nbOfCompo);
+ MEDCOUPLING_EXPORT void allocIfNecessary(int nbOfTuple, int nbOfCompo);
MEDCOUPLING_EXPORT bool isEqual(const DataArrayInt& other) const;
MEDCOUPLING_EXPORT bool isEqualWithoutConsideringStr(const DataArrayInt& other) const;
+ MEDCOUPLING_EXPORT bool isEqualWithoutConsideringStrAndOrder(const DataArrayInt& other) const throw(INTERP_KERNEL::Exception);
+ MEDCOUPLING_EXPORT DataArrayInt *buildPermutationArr(const DataArrayInt& other) const throw(INTERP_KERNEL::Exception);
+ MEDCOUPLING_EXPORT void sort() throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT void fillWithZero();
MEDCOUPLING_EXPORT void fillWithValue(int val);
MEDCOUPLING_EXPORT void iota(int init=0) throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT void reprZipStream(std::ostream& stream) const;
MEDCOUPLING_EXPORT void reprWithoutNameStream(std::ostream& stream) const;
MEDCOUPLING_EXPORT void reprZipWithoutNameStream(std::ostream& stream) const;
- MEDCOUPLING_EXPORT void transformWithIndArr(const int *indArr);
+ MEDCOUPLING_EXPORT void transformWithIndArr(const int *indArrBg, const int *indArrEnd) throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT DataArrayInt *invertArrayO2N2N2O(int newNbOfElem) const;
MEDCOUPLING_EXPORT DataArrayInt *invertArrayN2O2O2N(int oldNbOfElem) const;
//!alloc or useArray should have been called before.
MEDCOUPLING_EXPORT DataArrayInt *renumberR(const int *new2Old) const;
MEDCOUPLING_EXPORT DataArrayInt *renumberAndReduce(const int *old2NewBg, int newNbOfTuple) const;
MEDCOUPLING_EXPORT DataArrayInt *selectByTupleId(const int *new2OldBg, const int *new2OldEnd) const;
+ MEDCOUPLING_EXPORT DataArrayInt *selectByTupleIdSafe(const int *new2OldBg, const int *new2OldEnd) const throw(INTERP_KERNEL::Exception);
+ MEDCOUPLING_EXPORT DataArrayInt *selectByTupleId2(int bg, int end, int step) const throw(INTERP_KERNEL::Exception);
+ MEDCOUPLING_EXPORT DataArrayInt *checkAndPreparePermutation() const throw(INTERP_KERNEL::Exception);
+ MEDCOUPLING_EXPORT void changeSurjectiveFormat(int targetNb, DataArrayInt *&arr, DataArrayInt *&arrI) const throw(INTERP_KERNEL::Exception);
+ MEDCOUPLING_EXPORT DataArrayInt *buildPermArrPerLevel() const throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT bool isIdentity() const;
MEDCOUPLING_EXPORT bool isUniform(int val) const;
MEDCOUPLING_EXPORT DataArrayInt *substr(int tupleIdBg, int tupleIdEnd=-1) const throw(INTERP_KERNEL::Exception);
+ MEDCOUPLING_EXPORT void rearrange(int newNbOfCompo) throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT DataArrayInt *changeNbOfComponents(int newNbOfComp, int dftValue) const throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT DataArrayInt *keepSelectedComponents(const std::vector<int>& compoIds) const throw(INTERP_KERNEL::Exception);
+ MEDCOUPLING_EXPORT void meldWith(const DataArrayInt *other) throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT void setSelectedComponents(const DataArrayInt *a, const std::vector<int>& compoIds) throw(INTERP_KERNEL::Exception);
+ MEDCOUPLING_EXPORT void setPartOfValues1(const DataArrayInt *a, int bgTuples, int endTuples, int stepTuples, int bgComp, int endComp, int stepComp, bool strictCompoCompare=true) throw(INTERP_KERNEL::Exception);
+ MEDCOUPLING_EXPORT void setPartOfValuesSimple1(int a, int bgTuples, int endTuples, int stepTuples, int bgComp, int endComp, int stepComp) throw(INTERP_KERNEL::Exception);
+ MEDCOUPLING_EXPORT void setPartOfValues2(const DataArrayInt *a, const int *bgTuples, const int *endTuples, const int *bgComp, const int *endComp, bool strictCompoCompare=true) throw(INTERP_KERNEL::Exception);
+ MEDCOUPLING_EXPORT void setPartOfValuesSimple2(int a, const int *bgTuples, const int *endTuples, const int *bgComp, const int *endComp) throw(INTERP_KERNEL::Exception);
+ MEDCOUPLING_EXPORT void setPartOfValues3(const DataArrayInt *a, const int *bgTuples, const int *endTuples, int bgComp, int endComp, int stepComp, bool strictCompoCompare=true) throw(INTERP_KERNEL::Exception);
+ MEDCOUPLING_EXPORT void setPartOfValuesSimple3(int a, const int *bgTuples, const int *endTuples, int bgComp, int endComp, int stepComp) throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT void getTuple(int tupleId, int *res) const { std::copy(_mem.getConstPointerLoc(tupleId*_info_on_compo.size()),_mem.getConstPointerLoc((tupleId+1)*_info_on_compo.size()),res); }
MEDCOUPLING_EXPORT int getIJ(int tupleId, int compoId) const { return _mem[tupleId*_info_on_compo.size()+compoId]; }
- MEDCOUPLING_EXPORT void setIJ(int tupleId, int compoId, int newVal) { _mem[tupleId*_info_on_compo.size()+compoId]=newVal; }
+ MEDCOUPLING_EXPORT void setIJ(int tupleId, int compoId, int newVal) { _mem[tupleId*_info_on_compo.size()+compoId]=newVal; declareAsNew(); }
+ MEDCOUPLING_EXPORT void setIJSilent(int tupleId, int compoId, int newVal) { _mem[tupleId*_info_on_compo.size()+compoId]=newVal; }
MEDCOUPLING_EXPORT int *getPointer() const { return _mem.getPointer(); }
- MEDCOUPLING_EXPORT static void setArrayIn(DataArrayInt *newArray, DataArrayInt* &arrayToSet);
+ MEDCOUPLING_EXPORT static void SetArrayIn(DataArrayInt *newArray, DataArrayInt* &arrayToSet);
MEDCOUPLING_EXPORT const int *getConstPointer() const { return _mem.getConstPointer(); }
MEDCOUPLING_EXPORT DataArrayInt *getIdsEqual(int val) const throw(INTERP_KERNEL::Exception);
+ MEDCOUPLING_EXPORT DataArrayInt *getIdsNotEqual(int val) const throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT DataArrayInt *getIdsEqualList(const std::vector<int>& vals) const throw(INTERP_KERNEL::Exception);
- MEDCOUPLING_EXPORT static DataArrayInt *aggregate(const DataArrayInt *a1, const DataArrayInt *a2, int offsetA2);
- MEDCOUPLING_EXPORT static DataArrayInt *makePartition(const std::vector<DataArrayInt *>& groups, int newNb, std::vector< std::vector<int> >& fidsOfGroups);
+ MEDCOUPLING_EXPORT DataArrayInt *getIdsNotEqualList(const std::vector<int>& vals) const throw(INTERP_KERNEL::Exception);
+ MEDCOUPLING_EXPORT int getMaxValue(int& tupleId) const throw(INTERP_KERNEL::Exception);
+ MEDCOUPLING_EXPORT int getMinValue(int& tupleId) const throw(INTERP_KERNEL::Exception);
+ MEDCOUPLING_EXPORT void applyLin(int a, int b, int compoId) throw(INTERP_KERNEL::Exception);
+ MEDCOUPLING_EXPORT void applyLin(int a, int b) throw(INTERP_KERNEL::Exception);
+ MEDCOUPLING_EXPORT void applyInv(int numerator) throw(INTERP_KERNEL::Exception);
+ MEDCOUPLING_EXPORT void applyDivideBy(int val) throw(INTERP_KERNEL::Exception);
+ MEDCOUPLING_EXPORT void applyModulus(int val) throw(INTERP_KERNEL::Exception);
+ MEDCOUPLING_EXPORT void applyRModulus(int val) throw(INTERP_KERNEL::Exception);
+ MEDCOUPLING_EXPORT static DataArrayInt *Aggregate(const DataArrayInt *a1, const DataArrayInt *a2, int offsetA2);
+ MEDCOUPLING_EXPORT static DataArrayInt *Aggregate(const std::vector<const DataArrayInt *>& a) throw(INTERP_KERNEL::Exception);
+ MEDCOUPLING_EXPORT static DataArrayInt *Meld(const DataArrayInt *a1, const DataArrayInt *a2) throw(INTERP_KERNEL::Exception);
+ MEDCOUPLING_EXPORT static DataArrayInt *Meld(const std::vector<const DataArrayInt *>& a) throw(INTERP_KERNEL::Exception);
+ MEDCOUPLING_EXPORT static DataArrayInt *MakePartition(const std::vector<const DataArrayInt *>& groups, int newNb, std::vector< std::vector<int> >& fidsOfGroups);
+ MEDCOUPLING_EXPORT static DataArrayInt *BuildUnion(const std::vector<const DataArrayInt *>& a) throw(INTERP_KERNEL::Exception);
+ MEDCOUPLING_EXPORT static DataArrayInt *BuildIntersection(const std::vector<const DataArrayInt *>& a) throw(INTERP_KERNEL::Exception);
+ MEDCOUPLING_EXPORT DataArrayInt *buildComplement(int nbOfElement) const throw(INTERP_KERNEL::Exception);
+ MEDCOUPLING_EXPORT DataArrayInt *buildSubstraction(const DataArrayInt *other) const throw(INTERP_KERNEL::Exception);
+ MEDCOUPLING_EXPORT DataArrayInt *buildUnion(const DataArrayInt *other) const throw(INTERP_KERNEL::Exception);
+ MEDCOUPLING_EXPORT DataArrayInt *buildIntersection(const DataArrayInt *other) const throw(INTERP_KERNEL::Exception);
+ MEDCOUPLING_EXPORT DataArrayInt *deltaShiftIndex() const throw(INTERP_KERNEL::Exception);
+ MEDCOUPLING_EXPORT void computeOffsets() throw(INTERP_KERNEL::Exception);
+ MEDCOUPLING_EXPORT std::set<int> getDifferentValues() const throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT void useArray(const int *array, bool ownership, DeallocType type, int nbOfTuple, int nbOfCompo);
MEDCOUPLING_EXPORT void writeOnPlace(int id, int element0, const int *others, int sizeOfOthers) { _mem.writeOnPlace(id,element0,others,sizeOfOthers); }
+ MEDCOUPLING_EXPORT static DataArrayInt *Add(const DataArrayInt *a1, const DataArrayInt *a2) throw(INTERP_KERNEL::Exception);
+ MEDCOUPLING_EXPORT void addEqual(const DataArrayInt *other) throw(INTERP_KERNEL::Exception);
+ MEDCOUPLING_EXPORT static DataArrayInt *Substract(const DataArrayInt *a1, const DataArrayInt *a2) throw(INTERP_KERNEL::Exception);
+ MEDCOUPLING_EXPORT void substractEqual(const DataArrayInt *other) throw(INTERP_KERNEL::Exception);
+ MEDCOUPLING_EXPORT static DataArrayInt *Multiply(const DataArrayInt *a1, const DataArrayInt *a2) throw(INTERP_KERNEL::Exception);
+ MEDCOUPLING_EXPORT void multiplyEqual(const DataArrayInt *other) throw(INTERP_KERNEL::Exception);
+ MEDCOUPLING_EXPORT static DataArrayInt *Divide(const DataArrayInt *a1, const DataArrayInt *a2) throw(INTERP_KERNEL::Exception);
+ MEDCOUPLING_EXPORT void divideEqual(const DataArrayInt *other) throw(INTERP_KERNEL::Exception);
+ MEDCOUPLING_EXPORT static DataArrayInt *Modulus(const DataArrayInt *a1, const DataArrayInt *a2) throw(INTERP_KERNEL::Exception);
+ MEDCOUPLING_EXPORT void modulusEqual(const DataArrayInt *other) throw(INTERP_KERNEL::Exception);
//! nothing to do here because this class does not aggregate any TimeLabel instance.
- MEDCOUPLING_EXPORT void updateTime() { }
+ MEDCOUPLING_EXPORT void updateTime() const { }
+ public:
+ MEDCOUPLING_EXPORT static int *CheckAndPreparePermutation(const int *start, const int *end);
public:
- MEDCOUPLING_EXPORT static int *checkAndPreparePermutation(const int *start, const int *end);
+ void getTinySerializationIntInformation(std::vector<int>& tinyInfo) const;
+ void getTinySerializationStrInformation(std::vector<std::string>& tinyInfo) const;
+ bool resizeForUnserialization(const std::vector<int>& tinyInfoI);
+ void finishUnserialization(const std::vector<int>& tinyInfoI, const std::vector<std::string>& tinyInfoS);
private:
DataArrayInt() { }
private:
return ret;
}
+ template<class T>
+ void MemArray<T>::sort()
+ {
+ T *pt=_pointer.getPointer();
+ std::sort(pt,pt+_nb_of_elem);
+ }
+
template<class T>
void MemArray<T>::alloc(int nbOfElements)
{
#include "MEDCouplingAutoRefCountObjectPtr.hxx"
#include <set>
+#include <cmath>
#include <sstream>
#include <iterator>
using namespace ParaMEDMEM;
+MEDCouplingMesh::MEDCouplingMesh():_time(0.),_iteration(-1),_order(-1)
+{
+}
+
+MEDCouplingMesh::MEDCouplingMesh(const MEDCouplingMesh& other):_name(other._name),_description(other._description),
+ _time(other._time),_iteration(other._iteration),
+ _order(other._order),_time_unit(other._time_unit)
+{
+}
+
/*!
* This method is only for ParaMEDMEM in ParaFIELD constructor.
*/
bool MEDCouplingMesh::isEqual(const MEDCouplingMesh *other, double prec) const
{
- return _name==other->_name;
+ return _name==other->_name && _description==other->_description && _iteration==other->_iteration
+ && _order==other->_order && _time_unit==other->_time_unit && fabs(_time-other->_time)<1e-12;
}
/*!
void MEDCouplingMesh::copyTinyStringsFrom(const MEDCouplingMesh *other) throw(INTERP_KERNEL::Exception)
{
_name=other->_name;
+ _description=other->_description;
+ _time_unit=other->_time_unit;
+}
+
+/*!
+ * This method copies all attributes that are \b NOT arrays in this.
+ * All tiny attributes not usefully for state of 'this' are ignored.
+ */
+void MEDCouplingMesh::copyTinyInfoFrom(const MEDCouplingMesh *other) throw(INTERP_KERNEL::Exception)
+{
+ copyTinyStringsFrom(other);
+ _time=other->_time;
+ _iteration=other->_iteration;
+ _order=other->_order;
}
/*!
return ret;
}
+/*!
+ * This method builds a field lying on 'this' with 'nbOfComp' components.
+ * 'func' is a string that is the expression to evaluate.
+ * The return field will have type specified by 't'. 't' is also used to determine where values of field will be
+ * evaluate. This method is different than MEDCouplingMesh::fillFromAnalytic, because the info on components are used here to determine vars pos in 'func'.
+ *
+ * @param t type of field returned and specifies where the evaluation of func will be done.
+ * @param nbOfComp number of components of returned field.
+ * @param func expression.
+ * @return field with counter = 1.
+ */
+MEDCouplingFieldDouble *MEDCouplingMesh::fillFromAnalytic2(TypeOfField t, int nbOfComp, const char *func) const
+{
+ MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=MEDCouplingFieldDouble::New(t,NO_TIME);
+ ret->setMesh(this);
+ ret->fillFromAnalytic2(nbOfComp,func);
+ ret->incrRef();
+ return ret;
+}
+
+/*!
+ * This method builds a field lying on 'this' with 'nbOfComp' components.
+ * 'func' is a string that is the expression to evaluate.
+ * The return field will have type specified by 't'. 't' is also used to determine where values of field will be
+ * evaluate. This method is different than MEDCouplingMesh::fillFromAnalytic, because 'varsOrder' specifies the pos to assign of vars in 'func'.
+ *
+ * @param t type of field returned and specifies where the evaluation of func will be done.
+ * @param nbOfComp number of components of returned field.
+ * @param func expression.
+ * @return field with counter = 1.
+ */
+MEDCouplingFieldDouble *MEDCouplingMesh::fillFromAnalytic3(TypeOfField t, int nbOfComp, const std::vector<std::string>& varsOrder, const char *func) const
+{
+ MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=MEDCouplingFieldDouble::New(t,NO_TIME);
+ ret->setMesh(this);
+ ret->fillFromAnalytic3(nbOfComp,varsOrder,func);
+ ret->incrRef();
+ return ret;
+}
+
/*!
* retruns a newly created mesh with counter=1
* that is the union of mesh1 and mesh2 if possible. The cells of mesh2 will appear after cells of 'mesh1'. Idem for nodes.
*/
-MEDCouplingMesh *MEDCouplingMesh::mergeMeshes(const MEDCouplingMesh *mesh1, const MEDCouplingMesh *mesh2)
+MEDCouplingMesh *MEDCouplingMesh::MergeMeshes(const MEDCouplingMesh *mesh1, const MEDCouplingMesh *mesh2)
{
return mesh1->mergeMyselfWith(mesh2);
}
+
+void MEDCouplingMesh::getCellsContainingPoint(const double *pos, double eps, std::vector<int>& elts) const
+{
+ int ret=getCellContainingPoint(pos,eps);
+ elts.push_back(ret);
+}
+
+void MEDCouplingMesh::getCellsContainingPoints(const double *pos, int nbOfPoints, double eps, std::vector<int>& elts, std::vector<int>& eltsIndex) const
+{
+ eltsIndex.resize(nbOfPoints+1);
+ eltsIndex[0]=0;
+ elts.clear();
+ int spaceDim=getSpaceDimension();
+ const double *work=pos;
+ for(int i=0;i<nbOfPoints;i++,work+=spaceDim)
+ {
+ int ret=getCellContainingPoint(work,eps);
+ if(ret>=0)
+ {
+ elts.push_back(ret);
+ eltsIndex[i+1]=eltsIndex[i]+1;
+ }
+ else
+ eltsIndex[i+1]=eltsIndex[i];
+ }
+}
class DataArrayInt;
class DataArrayDouble;
+ class MEDCouplingUMesh;
class MEDCouplingFieldDouble;
class MEDCOUPLING_EXPORT MEDCouplingMesh : public RefCountObject, public TimeLabel
public:
void setName(const char *name) { _name=name; }
const char *getName() const { return _name.c_str(); }
+ void setDescription(const char *descr) { _description=descr; }
+ const char *getDescription() const { return _description.c_str(); }
+ double getTime(int& iteration, int& order) const { iteration=_iteration; order=_order; return _time; }
+ void setTime(double val, int iteration, int order) { _time=val; _iteration=iteration; _order=order; }
+ void setTimeUnit(const char *unit) { _time_unit=unit; }
+ const char *getTimeUnit() const { return _time_unit.c_str(); }
virtual MEDCouplingMesh *deepCpy() const = 0;
virtual MEDCouplingMeshType getType() const = 0;
bool isStructured() const;
virtual void copyTinyStringsFrom(const MEDCouplingMesh *other) throw(INTERP_KERNEL::Exception);
+ virtual void copyTinyInfoFrom(const MEDCouplingMesh *other) throw(INTERP_KERNEL::Exception);
// comparison methods
virtual bool isEqual(const MEDCouplingMesh *other, double prec) const;
virtual bool isEqualWithoutConsideringStr(const MEDCouplingMesh *other, double prec) const = 0;
DataArrayInt *&cellCor, DataArrayInt *&nodeCor) const throw(INTERP_KERNEL::Exception);
//
virtual void checkCoherency() const throw(INTERP_KERNEL::Exception) = 0;
+ virtual void checkCoherency1(double eps=1e-12) const throw(INTERP_KERNEL::Exception) = 0;
+ virtual void checkCoherency2(double eps=1e-12) const throw(INTERP_KERNEL::Exception) = 0;
virtual int getNumberOfCells() const = 0;
virtual int getNumberOfNodes() const = 0;
virtual int getSpaceDimension() const = 0;
virtual std::string simpleRepr() const = 0;
virtual std::string advancedRepr() const = 0;
// tools
+ virtual DataArrayInt *checkTypeConsistencyAndContig(const std::vector<int>& code, const std::vector<const DataArrayInt *>& idsPerType) const throw(INTERP_KERNEL::Exception) = 0;
virtual void getBoundingBox(double *bbox) const = 0;
virtual MEDCouplingFieldDouble *getMeasureField(bool isAbs) const = 0;
virtual MEDCouplingFieldDouble *getMeasureFieldOnNode(bool isAbs) const = 0;
virtual int getCellContainingPoint(const double *pos, double eps) const = 0;
+ virtual void getCellsContainingPoint(const double *pos, double eps, std::vector<int>& elts) const;
+ virtual void getCellsContainingPoints(const double *pos, int nbOfPoints, double eps, std::vector<int>& elts, std::vector<int>& eltsIndex) const;
virtual MEDCouplingFieldDouble *fillFromAnalytic(TypeOfField t, int nbOfComp, FunctionToEvaluate func) const;
virtual MEDCouplingFieldDouble *fillFromAnalytic(TypeOfField t, int nbOfComp, const char *func) const;
+ virtual MEDCouplingFieldDouble *fillFromAnalytic2(TypeOfField t, int nbOfComp, const char *func) const;
+ virtual MEDCouplingFieldDouble *fillFromAnalytic3(TypeOfField t, int nbOfComp, const std::vector<std::string>& varsOrder, const char *func) const;
virtual MEDCouplingFieldDouble *buildOrthogonalField() const = 0;
virtual void rotate(const double *center, const double *vector, double angle) = 0;
virtual void translate(const double *vector) = 0;
virtual MEDCouplingMesh *mergeMyselfWith(const MEDCouplingMesh *other) const = 0;
virtual MEDCouplingMesh *buildPart(const int *start, const int *end) const = 0;
virtual MEDCouplingMesh *buildPartAndReduceNodes(const int *start, const int *end, DataArrayInt*& arr) const = 0;
+ virtual MEDCouplingUMesh *buildUnstructured() const throw(INTERP_KERNEL::Exception) = 0;
virtual DataArrayInt *simplexize(int policy) throw(INTERP_KERNEL::Exception) = 0;
virtual bool areCompatibleForMerge(const MEDCouplingMesh *other) const;
- static MEDCouplingMesh *mergeMeshes(const MEDCouplingMesh *mesh1, const MEDCouplingMesh *mesh2);
+ static MEDCouplingMesh *MergeMeshes(const MEDCouplingMesh *mesh1, const MEDCouplingMesh *mesh2);
//serialisation-unserialization
- virtual void getTinySerializationInformation(std::vector<int>& tinyInfo, std::vector<std::string>& littleStrings) const = 0;
+ virtual void getTinySerializationInformation(std::vector<double>& tinyInfoD, std::vector<int>& tinyInfo, std::vector<std::string>& littleStrings) const = 0;
virtual void resizeForUnserialization(const std::vector<int>& tinyInfo, DataArrayInt *a1, DataArrayDouble *a2, std::vector<std::string>& littleStrings) const = 0;
virtual void serialize(DataArrayInt *&a1, DataArrayDouble *&a2) const = 0;
- virtual void unserialization(const std::vector<int>& tinyInfo, const DataArrayInt *a1, DataArrayDouble *a2,
+ virtual void unserialization(const std::vector<double>& tinyInfoD, const std::vector<int>& tinyInfo, const DataArrayInt *a1, DataArrayDouble *a2,
const std::vector<std::string>& littleStrings) = 0;
protected:
- MEDCouplingMesh() { }
- MEDCouplingMesh(const MEDCouplingMesh& other):_name(other._name) { }
+ MEDCouplingMesh();
+ MEDCouplingMesh(const MEDCouplingMesh& other);
virtual ~MEDCouplingMesh() { }
private:
std::string _name;
+ std::string _description;
+ double _time;
+ int _iteration;
+ int _order;
+ std::string _time_unit;
};
}
--- /dev/null
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#include "MEDCouplingMultiFields.hxx"
+#include "MEDCouplingFieldTemplate.hxx"
+#include "MEDCouplingFieldDouble.hxx"
+#include "MEDCouplingMesh.hxx"
+#include "MEDCouplingAutoRefCountObjectPtr.hxx"
+
+using namespace ParaMEDMEM;
+
+MEDCouplingMultiFields *MEDCouplingMultiFields::New(const std::vector<MEDCouplingFieldDouble *>& fs) throw(INTERP_KERNEL::Exception)
+{
+ return new MEDCouplingMultiFields(fs);
+}
+
+MEDCouplingMultiFields *MEDCouplingMultiFields::New()
+{
+ return new MEDCouplingMultiFields;
+}
+
+MEDCouplingMultiFields *MEDCouplingMultiFields::deepCpy() const
+{
+ return new MEDCouplingMultiFields(*this);
+}
+
+bool MEDCouplingMultiFields::isEqual(const MEDCouplingMultiFields *other, double meshPrec, double valsPrec) const
+{
+ std::size_t sz=_fs.size();
+ if(sz!=other->_fs.size())
+ return false;
+ for(std::size_t i=0;i<sz;i++)
+ {
+ const MEDCouplingFieldDouble *f1=_fs[i];
+ const MEDCouplingFieldDouble *f2=other->_fs[i];
+ if(f1!=f2)
+ {
+ if(f1==0 || f2==0)
+ return false;
+ if(!_fs[i]->isEqual(other->_fs[i],meshPrec,valsPrec))
+ return false;
+ }
+ }
+ std::vector<int> refs1,refs2;
+ std::vector<MEDCouplingMesh *> ms1=getDifferentMeshes(refs1);
+ std::vector<MEDCouplingMesh *> ms2=other->getDifferentMeshes(refs2);
+ if(ms1.size()!=ms2.size())
+ return false;
+ if(refs1!=refs2)
+ return false;
+ std::vector< std::vector<int> > refs3,refs4;
+ std::vector<DataArrayDouble *> das1=getDifferentArrays(refs3);
+ std::vector<DataArrayDouble *> das2=getDifferentArrays(refs4);
+ if(das1.size()!=das2.size())
+ return false;
+ if(refs3!=refs4)
+ return false;
+ return true;
+}
+
+std::string MEDCouplingMultiFields::getName() const
+{
+ std::vector< MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> >::const_iterator it=_fs.begin();
+ for(;it!=_fs.end();it++)
+ if((const MEDCouplingFieldDouble *)(*it))
+ return (*it)->getName();
+ return std::string();
+}
+
+std::string MEDCouplingMultiFields::getDescription() const
+{
+ std::vector< MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> >::const_iterator it=_fs.begin();
+ for(;it!=_fs.end();it++)
+ if((const MEDCouplingFieldDouble *)(*it))
+ return (*it)->getDescription();
+ return std::string();
+}
+
+std::string MEDCouplingMultiFields::getTimeUnit() const
+{
+ std::vector< MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> >::const_iterator it=_fs.begin();
+ for(;it!=_fs.end();it++)
+ if((const MEDCouplingFieldDouble *)(*it))
+ return (*it)->getTimeUnit();
+ return std::string();
+}
+
+double MEDCouplingMultiFields::getTimeResolution() const throw(INTERP_KERNEL::Exception)
+{
+ std::vector< MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> >::const_iterator it=_fs.begin();
+ for(;it!=_fs.end();it++)
+ if((const MEDCouplingFieldDouble *)(*it))
+ return (*it)->getTimeTolerance();
+ throw INTERP_KERNEL::Exception("MEDCouplingMultiFields::getTimeResolution : no not null field !");
+}
+
+std::string MEDCouplingMultiFields::simpleRepr() const
+{
+ std::ostringstream ret;
+ ret << "MEDCouplingMultiFields with name : \"" << getName() << "\"\n";
+ ret << "Description of MEDCouplingMultiFields is : \"" << getDescription() << "\"\n";
+ ret << "Number of discretization : " << _fs.size() << "\n";
+ ret << "Number of different meshes : ";
+ std::vector<MEDCouplingMesh *> ms;
+ std::vector<int> refms;
+ try
+ {
+ ms=getDifferentMeshes(refms);
+ ret << ms.size() << "\n";
+ }
+ catch(INTERP_KERNEL::Exception& e)
+ { ret << "Current instance is INVALID !\n"; }
+ return ret.str();
+}
+
+std::string MEDCouplingMultiFields::advancedRepr() const
+{
+ return simpleRepr();
+}
+
+bool MEDCouplingMultiFields::isEqualWithoutConsideringStr(const MEDCouplingMultiFields *other, double meshPrec, double valsPrec) const
+{
+ std::size_t sz=_fs.size();
+ if(sz!=other->_fs.size())
+ return false;
+ for(std::size_t i=0;i<sz;i++)
+ if(!_fs[i]->isEqualWithoutConsideringStr(other->_fs[i],meshPrec,valsPrec))
+ return false;
+ return true;
+}
+
+const MEDCouplingFieldDouble *MEDCouplingMultiFields::getFieldWithId(int id) const throw(INTERP_KERNEL::Exception)
+{
+ if(id>=(int)_fs.size() || id < 0)
+ throw INTERP_KERNEL::Exception("MEDCouplingMultiFields::getFieldWithId : invalid id outside boundaries !");
+ return _fs[id];
+}
+
+std::vector<const MEDCouplingFieldDouble *> MEDCouplingMultiFields::getFields() const
+{
+ std::vector<const MEDCouplingFieldDouble *> ret(_fs.size());
+ std::copy(_fs.begin(),_fs.end(),ret.begin());
+ return ret;
+}
+
+int MEDCouplingMultiFields::getNumberOfFields() const
+{
+ return _fs.size();
+}
+
+const MEDCouplingFieldDouble *MEDCouplingMultiFields::getFieldAtPos(int id) const throw(INTERP_KERNEL::Exception)
+{
+ if(id<0 || id>=(int)_fs.size())
+ {
+ std::ostringstream oss; oss << "MEDCouplingMultiFields::getFieldAtPos : Invalid given pos : should be >=0 and < " << _fs.size() << " !";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ return _fs[id];
+}
+
+void MEDCouplingMultiFields::updateTime() const
+{
+ std::vector< MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> >::const_iterator it=_fs.begin();
+ for(;it!=_fs.end();it++)
+ if((const MEDCouplingFieldDouble *)(*it))
+ (*it)->updateTime();
+ it=_fs.begin();
+ for(;it!=_fs.end();it++)
+ if((const MEDCouplingFieldDouble *)(*it))
+ updateTimeWith(*(*it));
+}
+
+std::vector<MEDCouplingMesh *> MEDCouplingMultiFields::getMeshes() const throw(INTERP_KERNEL::Exception)
+{
+ std::vector<MEDCouplingMesh *> ms;
+ for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> >::const_iterator it=_fs.begin();it!=_fs.end();it++)
+ {
+ const MEDCouplingMesh *m=0;
+ if((const MEDCouplingFieldDouble *)(*it))
+ m=(*it)->getMesh();
+ ms.push_back(const_cast<MEDCouplingMesh *>(m));
+ }
+ return ms;
+}
+
+std::vector<MEDCouplingMesh *> MEDCouplingMultiFields::getDifferentMeshes(std::vector<int>& refs) const throw(INTERP_KERNEL::Exception)
+{
+ refs.resize(_fs.size());
+ std::vector<MEDCouplingMesh *> ms;
+ int id=0;
+ for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> >::const_iterator it=_fs.begin();it!=_fs.end();it++,id++)
+ {
+ const MEDCouplingMesh *m=0;
+ if((const MEDCouplingFieldDouble *)(*it))
+ m=(*it)->getMesh();
+ if(m)
+ {
+ std::vector<MEDCouplingMesh *>::iterator it=std::find(ms.begin(),ms.end(),m);
+ if(it==ms.end())
+ {
+ ms.push_back(const_cast<MEDCouplingMesh *>(m));
+ refs[id]=ms.size()-1;
+ }
+ else
+ refs[id]=std::distance(ms.begin(),it);
+ }
+ else
+ refs[id]=-1;
+ }
+ return ms;
+}
+
+std::vector<DataArrayDouble *> MEDCouplingMultiFields::getArrays() const throw(INTERP_KERNEL::Exception)
+{
+ std::vector<DataArrayDouble *> tmp;
+ for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> >::const_iterator it=_fs.begin();it!=_fs.end();it++)
+ {
+ std::vector<DataArrayDouble *> tmp2=(*it)->getArrays();
+ tmp.insert(tmp.end(),tmp2.begin(),tmp2.end());
+ }
+ return tmp;
+}
+
+std::vector<DataArrayDouble *> MEDCouplingMultiFields::getDifferentArrays(std::vector< std::vector<int> >& refs) const throw(INTERP_KERNEL::Exception)
+{
+ refs.resize(_fs.size());
+ int id=0;
+ std::vector<DataArrayDouble *> ret;
+ for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> >::const_iterator it=_fs.begin();it!=_fs.end();it++,id++)
+ {
+ std::vector<DataArrayDouble *> tmp2;
+ if((const MEDCouplingFieldDouble *)(*it))
+ {
+ tmp2=(*it)->getArrays();
+ refs[id].resize(tmp2.size());
+ }
+ else
+ refs[id].clear();
+ int id2=0;
+ for(std::vector<DataArrayDouble *>::const_iterator it2=tmp2.begin();it2!=tmp2.end();it2++,id2++)
+ {
+ if(*it2)
+ {
+ std::vector<DataArrayDouble *>::iterator it3=std::find(ret.begin(),ret.end(),*it2);
+ if(it3==ret.end())
+ {
+ ret.push_back(*it2);
+ refs[id][id2]=ret.size()-1;
+ }
+ else
+ refs[id][id2]=std::distance(ret.begin(),it3);
+ }
+ else
+ refs[id][id2]=-1;
+ }
+ }
+ return ret;
+}
+
+void MEDCouplingMultiFields::checkCoherency() const throw(INTERP_KERNEL::Exception)
+{
+ std::vector< MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> >::const_iterator it=_fs.begin();
+ for(;it!=_fs.end();it++)
+ {
+ if((const MEDCouplingFieldDouble *)(*it)==0)
+ throw INTERP_KERNEL::Exception("MEDCouplingMultiFields::checkCoherency : There is an empty Field in array...");
+ (*it)->checkCoherency();
+ }
+}
+
+MEDCouplingMultiFields::MEDCouplingMultiFields(const std::vector<MEDCouplingFieldDouble *>& fs) throw(INTERP_KERNEL::Exception):_fs(fs.size())
+{
+ int id=0;
+ for(std::vector< MEDCouplingFieldDouble * >::const_iterator it=fs.begin();it!=fs.end();it++,id++)
+ {
+ if(*it)
+ (*it)->incrRef();
+ else
+ throw INTERP_KERNEL::Exception("MEDCouplingMultiFields constructor : empty field found in vector !");
+ (*it)->checkCoherency();
+ _fs[id]=*it;
+ }
+}
+
+
+/*!
+ * Performs deepCpy.
+ */
+MEDCouplingMultiFields::MEDCouplingMultiFields(const MEDCouplingMultiFields& other)
+{
+ int sz=other._fs.size();
+ _fs.resize(sz);
+ std::vector<int> refs;
+ std::vector< std::vector<int> > refs2;
+ std::vector<MEDCouplingMesh *> ms=other.getDifferentMeshes(refs);
+ int msLgh=ms.size();
+ std::vector< MEDCouplingAutoRefCountObjectPtr<MEDCouplingMesh> > ms2(msLgh);
+ for(int i=0;i<msLgh;i++)
+ ms2[i]=ms[i]->deepCpy();
+ std::vector<DataArrayDouble *> das=other.getDifferentArrays(refs2);
+ int dasLgth=das.size();
+ std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> > das2(dasLgth);
+ for(int i=0;i<dasLgth;i++)
+ das2[i]=das[i]->deepCpy();
+ for(int i=0;i<sz;i++)
+ {
+ if((const MEDCouplingFieldDouble *)other._fs[i])
+ {
+ MEDCouplingFieldTemplate *tmp=MEDCouplingFieldTemplate::New(other._fs[i]);
+ _fs[i]=MEDCouplingFieldDouble::New(tmp,other._fs[i]->getTimeDiscretization());
+ tmp->decrRef();
+ if(refs[i]!=-1)
+ _fs[i]->setMesh(ms2[refs[i]]);
+ int nbOfArr=refs2[i].size();
+ std::vector<DataArrayDouble *> tmp2(nbOfArr);
+ for(int j=0;j<nbOfArr;j++)
+ {
+ if(refs2[i][j]!=-1)
+ tmp2[j]=das2[refs2[i][j]];
+ else
+ tmp2[j]=0;
+ }
+ _fs[i]->setArrays(tmp2);
+ std::vector<int> tinyInfo;
+ std::vector<double> tinyInfo2;
+ other._fs[i]->getTimeDiscretizationUnderGround()->getTinySerializationIntInformation2(tinyInfo);
+ other._fs[i]->getTimeDiscretizationUnderGround()->getTinySerializationDbleInformation2(tinyInfo2);
+ _fs[i]->getTimeDiscretizationUnderGround()->finishUnserialization2(tinyInfo,tinyInfo2);
+ }
+ }
+}
+
+MEDCouplingMultiFields::MEDCouplingMultiFields()
+{
+}
+
+void MEDCouplingMultiFields::getTinySerializationInformation(std::vector<int>& tinyInfo, std::vector<double>& tinyInfo2, int& nbOfDiffMeshes, int& nbOfDiffArr) const
+{
+ std::vector<int> refs;
+ std::vector<MEDCouplingMesh *> ms=getDifferentMeshes(refs);
+ nbOfDiffMeshes=ms.size();
+ std::vector< std::vector<int> > refs2;
+ std::vector<DataArrayDouble *> fs=getDifferentArrays(refs2);
+ nbOfDiffArr=fs.size();
+ //
+ int sz=refs.size();//==_fs.size()
+ int sz2=0;
+ for(int i=0;i<sz;i++)
+ sz2+=refs2[i].size();
+ //
+ tinyInfo2.clear();
+ std::vector<int> doubleDaInd(sz);
+ std::vector<int> timeDiscrInt;
+ tinyInfo.resize(sz2+5*sz+3);
+ tinyInfo[0]=sz;
+ tinyInfo[1]=sz2;
+ for(int i=0;i<sz;i++)
+ {
+ std::vector<double> tmp;
+ std::vector<int> tmp2;
+ _fs[i]->getTimeDiscretizationUnderGround()->getTinySerializationDbleInformation2(tmp);
+ _fs[i]->getTimeDiscretizationUnderGround()->getTinySerializationIntInformation2(tmp2);
+ tinyInfo[3*sz+3+i]=tmp.size();
+ tinyInfo[4*sz+3+i]=tmp2.size();
+ tinyInfo2.insert(tinyInfo2.end(),tmp.begin(),tmp.end());
+ timeDiscrInt.insert(timeDiscrInt.end(),tmp2.begin(),tmp2.end());
+ }
+ int sz3=timeDiscrInt.size();
+ tinyInfo[2]=sz3;
+ //
+ for(int i=0;i<sz;i++)
+ tinyInfo[i+3]=refs[i];
+ for(int i=0;i<sz;i++)
+ tinyInfo[i+sz+3]=refs2[i].size();
+ for(int i=0;i<sz;i++)
+ tinyInfo[i+2*sz+3]=(int)_fs[i]->getTimeDiscretization();
+ int k=0;
+ for(int i=0;i<sz;i++)
+ for(std::vector<int>::const_iterator it=refs2[i].begin();it!=refs2[i].end();it++,k++)
+ tinyInfo[5*sz+k+3]=*it;
+ tinyInfo.insert(tinyInfo.end(),timeDiscrInt.begin(),timeDiscrInt.end());//tinyInfo has lgth==sz3+sz2+5*sz+3
+}
+
+void MEDCouplingMultiFields::finishUnserialization(const std::vector<int>& tinyInfoI, const std::vector<double>& tinyInfoD,
+ const std::vector<MEDCouplingFieldTemplate *>& ft, const std::vector<MEDCouplingMesh *>& ms,
+ const std::vector<DataArrayDouble *>& das)
+{
+ int sz=tinyInfoI[0];
+ _fs.resize(sz);
+ int sz2=tinyInfoI[1];
+ // dealing with ft with no mesh set.
+ for(int i=0;i<sz;i++)
+ {
+ int meshId=tinyInfoI[3+i];
+ if(meshId!=-1)
+ ft[i]->setMesh(ms[meshId]);
+ }
+ // dealing with fieldtemplate->fielddouble
+ int k=0;
+ int offI=0;
+ int offD=0;
+ for(int i=0;i<sz;i++)
+ {
+ _fs[i]=MEDCouplingFieldDouble::New(ft[i],(TypeOfTimeDiscretization)tinyInfoI[2*sz+3+i]);
+ int sz3=tinyInfoI[sz+i+3];
+ std::vector<DataArrayDouble *> tmp(sz3);
+ for(int j=0;j<sz3;j++,k++)
+ {
+ int daId=tinyInfoI[5*sz+k+3];
+ if(daId!=-1)
+ tmp[j]=das[daId];
+ else
+ tmp[j]=0;
+ }
+ _fs[i]->setArrays(tmp);
+ // time discr tiny info
+ int lgthI=tinyInfoI[4*sz+3+i];
+ int lgthD=tinyInfoI[3*sz+3+i];
+ //
+ std::vector<int> tdInfoI(tinyInfoI.begin()+sz2+5*sz+3+offI,tinyInfoI.begin()+sz2+5*sz+3+offI+lgthI);
+ std::vector<double> tdInfoD(tinyInfoD.begin()+offD,tinyInfoD.begin()+offD+lgthD);
+ _fs[i]->getTimeDiscretizationUnderGround()->finishUnserialization2(tdInfoI,tdInfoD);
+ //
+ offI+=lgthI;
+ offD+=lgthD;
+ }
+}
--- /dev/null
+// Copyright (C) 2007-2010 CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#ifndef __PARAMEDMEM_MEDCOUPLINGMULTIFIELDS_HXX__
+#define __PARAMEDMEM_MEDCOUPLINGMULTIFIELDS_HXX__
+
+#include "MEDCouplingRefCountObject.hxx"
+#include "MEDCouplingTimeLabel.hxx"
+#include "MEDCouplingAutoRefCountObjectPtr.hxx"
+
+#include "InterpKernelException.hxx"
+
+#include <vector>
+
+namespace ParaMEDMEM
+{
+ class MEDCouplingMesh;
+ class DataArrayDouble;
+ class MEDCouplingFieldDouble;
+ class MEDCouplingFieldTemplate;
+
+ class MEDCouplingMultiFields : public RefCountObject, public TimeLabel
+ {
+ public:
+ static MEDCouplingMultiFields *New(const std::vector<MEDCouplingFieldDouble *>& fs) throw(INTERP_KERNEL::Exception);
+ static MEDCouplingMultiFields *New();
+ MEDCouplingMultiFields *deepCpy() const;
+ std::string getName() const;
+ std::string getDescription() const;
+ std::string getTimeUnit() const;
+ double getTimeResolution() const throw(INTERP_KERNEL::Exception);
+ virtual std::string simpleRepr() const;
+ virtual std::string advancedRepr() const;
+ virtual bool isEqual(const MEDCouplingMultiFields *other, double meshPrec, double valsPrec) const;
+ virtual bool isEqualWithoutConsideringStr(const MEDCouplingMultiFields *other, double meshPrec, double valsPrec) const;
+ const MEDCouplingFieldDouble *getFieldWithId(int id) const throw(INTERP_KERNEL::Exception);
+ std::vector<const MEDCouplingFieldDouble *> getFields() const;
+ int getNumberOfFields() const;
+ const MEDCouplingFieldDouble *getFieldAtPos(int id) const throw(INTERP_KERNEL::Exception);
+ virtual std::vector<MEDCouplingMesh *> getMeshes() const throw(INTERP_KERNEL::Exception);
+ virtual std::vector<MEDCouplingMesh *> getDifferentMeshes(std::vector<int>& refs) const throw(INTERP_KERNEL::Exception);
+ virtual std::vector<DataArrayDouble *> getArrays() const throw(INTERP_KERNEL::Exception);
+ virtual std::vector<DataArrayDouble *> getDifferentArrays(std::vector< std::vector<int> >& refs) const throw(INTERP_KERNEL::Exception);
+ void updateTime() const;
+ void getTinySerializationInformation(std::vector<int>& tinyInfo, std::vector<double>& tinyInfo2, int& nbOfDiffMeshes, int& nbOfDiffArr) const;
+ void finishUnserialization(const std::vector<int>& tinyInfoI, const std::vector<double>& tinyInfoD,
+ const std::vector<MEDCouplingFieldTemplate *>& ft, const std::vector<MEDCouplingMesh *>& ms,
+ const std::vector<DataArrayDouble *>& das);
+ virtual void checkCoherency() const throw(INTERP_KERNEL::Exception);
+ protected:
+ MEDCouplingMultiFields(const std::vector<MEDCouplingFieldDouble *>& fs) throw(INTERP_KERNEL::Exception);
+ MEDCouplingMultiFields(const MEDCouplingMultiFields& other);
+ MEDCouplingMultiFields();
+ protected:
+ std::vector< MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> > _fs;
+ };
+}
+
+#endif
+
typedef int MyConnType;
static const INTERP_KERNEL::NumberingPolicy My_numPol=INTERP_KERNEL::ALL_C_MODE;
public:
- MEDCouplingNormalizedUnstructuredMesh(ParaMEDMEM::MEDCouplingUMesh *mesh);
+ MEDCouplingNormalizedUnstructuredMesh(const ParaMEDMEM::MEDCouplingUMesh *mesh);
void getBoundingBox(double *boundingBox) const;
INTERP_KERNEL::NormalizedCellType getTypeOfElement(int eltId) const;
unsigned char getNumberOfNodesOfElement(int eltId) const;
private:
void prepare();
private:
- ParaMEDMEM::MEDCouplingUMesh *_mesh;
+ const ParaMEDMEM::MEDCouplingUMesh *_mesh;
int *_conn_for_interp;
int *_conn_index_for_interp;
};
#include <limits>
template<int SPACEDIM,int MESHDIM>
-MEDCouplingNormalizedUnstructuredMesh<SPACEDIM,MESHDIM>::MEDCouplingNormalizedUnstructuredMesh(ParaMEDMEM::MEDCouplingUMesh *mesh):_mesh(mesh)
+MEDCouplingNormalizedUnstructuredMesh<SPACEDIM,MESHDIM>::MEDCouplingNormalizedUnstructuredMesh(const ParaMEDMEM::MEDCouplingUMesh *mesh):_mesh(mesh)
{
if(_mesh)
_mesh->incrRef();
boundingBox[i]=std::numeric_limits<double>::max();
boundingBox[SPACEDIM+i]=-std::numeric_limits<double>::max();
}
- ParaMEDMEM::DataArrayDouble *array=_mesh->getCoords();
+ const ParaMEDMEM::DataArrayDouble *array=_mesh->getCoords();
const double *ptr=array->getConstPointer();
int nbOfPts=array->getNbOfElems()/SPACEDIM;
for(int j=0;j<SPACEDIM;j++)
template<int SPACEDIM,int MESHDIM>
const double *MEDCouplingNormalizedUnstructuredMesh<SPACEDIM,MESHDIM>::getCoordinatesPtr() const
{
- ParaMEDMEM::DataArrayDouble *array=_mesh->getCoords();
+ const ParaMEDMEM::DataArrayDouble *array=_mesh->getCoords();
return array->getConstPointer();
}
MEDCouplingNormalizedUnstructuredMesh<SPACEDIM,MESHDIM>::~MEDCouplingNormalizedUnstructuredMesh()
{
if(_mesh)
- _mesh->decrRef();
+ ((ParaMEDMEM::MEDCouplingUMesh *)_mesh)->decrRef();
releaseTempArrays();
}
throw INTERP_KERNEL::Exception("Unable to get space dimension because no coordinates specified !");
}
-void MEDCouplingPointSet::updateTime()
+void MEDCouplingPointSet::updateTime() const
{
if(_coords)
{
}
}
-void MEDCouplingPointSet::setCoords(DataArrayDouble *coords)
+void MEDCouplingPointSet::setCoords(const DataArrayDouble *coords)
{
if( coords != _coords )
{
if (_coords)
_coords->decrRef();
- _coords=coords;
+ _coords=const_cast<DataArrayDouble *>(coords);
if(_coords)
_coords->incrRef();
declareAsNew();
/*!
* This methods searches for each node n1 nodes in _coords that are less far than 'prec' from n1. if any these nodes are stored in params
* comm and commIndex.
- * @param limitNodeId is the limit node id. All nodes which id is strictly lower than 'limitNodeId' will not be merged.
+ * @param limitNodeId is the limit node id. All nodes which id is strictly lower than 'limitNodeId' will not be merged each other.
* @param comm out parameter (not inout)
* @param commIndex out parameter (not inout)
*/
/*!
* Given a point given by its position 'pos' this method finds the set of node ids that are a a distance lower than eps.
- * Position 'pos' is expected to be of size getSpaceDimension(). If not the behabiour is not warranted.
+ * Position 'pos' is expected to be of size getSpaceDimension()*nbOfNodes. If not the behabiour is not warranted.
* This method throws an exception if no coordiantes are set.
*/
void MEDCouplingPointSet::getNodeIdsNearPoints(const double *pos, int nbOfNodes, double eps, std::vector<int>& c, std::vector<int>& cI) const throw(INTERP_KERNEL::Exception)
newCoords->decrRef();
}
+/*
+ * This method renumber 'this' using 'newNodeNumbers' array of size this->getNumberOfNodes.
+ * newNbOfNodes specifies the *std::max_element(newNodeNumbers,newNodeNumbers+this->getNumberOfNodes())
+ * This value is asked because often known by the caller of this method.
+ * Contrary to ParaMEDMEM::MEDCouplingPointSet::renumberNodes method for merged nodes the barycenter of them is computed here.
+ *
+ * @param newNodeNumbers array specifying the new numbering.
+ * @param newNbOfNodes the new number of nodes.
+ */
+void MEDCouplingPointSet::renumberNodes2(const int *newNodeNumbers, int newNbOfNodes)
+{
+ DataArrayDouble *newCoords=DataArrayDouble::New();
+ std::vector<int> div(newNbOfNodes);
+ int spaceDim=getSpaceDimension();
+ newCoords->alloc(newNbOfNodes,spaceDim);
+ newCoords->copyStringInfoFrom(*_coords);
+ newCoords->fillWithZero();
+ int oldNbOfNodes=getNumberOfNodes();
+ double *ptToFill=newCoords->getPointer();
+ const double *oldCoordsPtr=_coords->getConstPointer();
+ for(int i=0;i<oldNbOfNodes;i++)
+ {
+ std::transform(oldCoordsPtr+i*spaceDim,oldCoordsPtr+(i+1)*spaceDim,ptToFill+newNodeNumbers[i]*spaceDim,
+ ptToFill+newNodeNumbers[i]*spaceDim,std::plus<double>());
+ div[newNodeNumbers[i]]++;
+ }
+ for(int i=0;i<newNbOfNodes;i++)
+ ptToFill=std::transform(ptToFill,ptToFill+spaceDim,ptToFill,std::bind2nd(std::multiplies<double>(),1./(double)div[i]));
+ setCoords(newCoords);
+ newCoords->decrRef();
+}
+
/*!
* This method fills bbox params like that : bbox[0]=XMin, bbox[1]=XMax, bbox[2]=YMin...
* The returned bounding box is arranged along trihedron.
/*!
* merge _coords arrays of m1 and m2 and returns the union. The returned instance is newly created with ref count == 1.
*/
-DataArrayDouble *MEDCouplingPointSet::mergeNodesArray(const MEDCouplingPointSet *m1, const MEDCouplingPointSet *m2)
+DataArrayDouble *MEDCouplingPointSet::MergeNodesArray(const MEDCouplingPointSet *m1, const MEDCouplingPointSet *m2) throw(INTERP_KERNEL::Exception)
{
int spaceDim=m1->getSpaceDimension();
if(spaceDim!=m2->getSpaceDimension())
- throw INTERP_KERNEL::Exception("Mismatch in SpaceDim during call of mergeNodesArray !");
- return DataArrayDouble::aggregate(m1->getCoords(),m2->getCoords());
+ throw INTERP_KERNEL::Exception("Mismatch in SpaceDim during call of MergeNodesArray !");
+ return DataArrayDouble::Aggregate(m1->getCoords(),m2->getCoords());
+}
+
+DataArrayDouble *MEDCouplingPointSet::MergeNodesArray(const std::vector<const MEDCouplingPointSet *>& ms) throw(INTERP_KERNEL::Exception)
+{
+ if(ms.empty())
+ throw INTERP_KERNEL::Exception("MEDCouplingPointSet::MergeNodesArray : input array must be NON EMPTY !");
+ std::vector<const MEDCouplingPointSet *>::const_iterator it=ms.begin();
+ std::vector<const DataArrayDouble *> coo(ms.size());
+ int spaceDim=(*it)->getSpaceDimension();
+ coo[0]=(*it++)->getCoords();
+ for(int i=1;it!=ms.end();it++,i++)
+ {
+ const DataArrayDouble *tmp=(*it)->getCoords();
+ if(tmp)
+ {
+ if((*it)->getSpaceDimension()==spaceDim)
+ coo[i]=tmp;
+ else
+ throw INTERP_KERNEL::Exception("Mismatch in SpaceDim during call of MergeNodesArray !");
+ }
+ else
+ throw INTERP_KERNEL::Exception("Empty coords detected during call of MergeNodesArray !");
+ }
+ return DataArrayDouble::Aggregate(coo);
}
/*!
* Factory to build new instance of instanciable subclasses of MEDCouplingPointSet.
* This method is used during unserialization process.
*/
-MEDCouplingPointSet *MEDCouplingPointSet::buildInstanceFromMeshType(MEDCouplingMeshType type)
+MEDCouplingPointSet *MEDCouplingPointSet::BuildInstanceFromMeshType(MEDCouplingMeshType type)
{
switch(type)
{
/*!
* First step of serialization process. Used by ParaMEDMEM and MEDCouplingCorba to transfert data between process.
*/
-void MEDCouplingPointSet::getTinySerializationInformation(std::vector<int>& tinyInfo, std::vector<std::string>& littleStrings) const
+void MEDCouplingPointSet::getTinySerializationInformation(std::vector<double>& tinyInfoD, std::vector<int>& tinyInfo, std::vector<std::string>& littleStrings) const
{
+ int it,order;
+ double time=getTime(it,order);
if(_coords)
{
int spaceDim=getSpaceDimension();
- littleStrings.resize(spaceDim+1);
+ littleStrings.resize(spaceDim+4);
littleStrings[0]=getName();
+ littleStrings[1]=getDescription();
+ littleStrings[2]=_coords->getName();
+ littleStrings[3]=getTimeUnit();
for(int i=0;i<spaceDim;i++)
- littleStrings[i+1]=getCoords()->getInfoOnComponent(i);
+ littleStrings[i+4]=getCoords()->getInfoOnComponent(i);
tinyInfo.clear();
tinyInfo.push_back(getType());
tinyInfo.push_back(spaceDim);
tinyInfo.push_back(getNumberOfNodes());
+ tinyInfo.push_back(it);
+ tinyInfo.push_back(order);
+ tinyInfoD.push_back(time);
}
else
{
- littleStrings.resize(1);
+ littleStrings.resize(3);
littleStrings[0]=getName();
+ littleStrings[1]=getDescription();
+ littleStrings[2]=getTimeUnit();
tinyInfo.clear();
tinyInfo.push_back(getType());
tinyInfo.push_back(-1);
tinyInfo.push_back(-1);
+ tinyInfo.push_back(it);
+ tinyInfo.push_back(order);
+ tinyInfoD.push_back(time);
}
}
{
if(_coords)
{
- a2=getCoords();
+ a2=const_cast<DataArrayDouble *>(getCoords());
a2->incrRef();
}
else
if(tinyInfo[2]>=0 && tinyInfo[1]>=1)
{
a2->alloc(tinyInfo[2],tinyInfo[1]);
- littleStrings.resize(tinyInfo[1]+1);
+ littleStrings.resize(tinyInfo[1]+4);
}
else
{
- littleStrings.resize(1);
+ littleStrings.resize(3);
}
}
* Second and final unserialization process.
* @param tinyInfo must be equal to the result given by getTinySerializationInformation method.
*/
-void MEDCouplingPointSet::unserialization(const std::vector<int>& tinyInfo, const DataArrayInt *a1, DataArrayDouble *a2, const std::vector<std::string>& littleStrings)
+void MEDCouplingPointSet::unserialization(const std::vector<double>& tinyInfoD, const std::vector<int>& tinyInfo, const DataArrayInt *a1, DataArrayDouble *a2, const std::vector<std::string>& littleStrings)
{
if(tinyInfo[2]>=0 && tinyInfo[1]>=1)
{
setCoords(a2);
setName(littleStrings[0].c_str());
+ setDescription(littleStrings[1].c_str());
+ a2->setName(littleStrings[2].c_str());
+ setTimeUnit(littleStrings[3].c_str());
for(int i=0;i<tinyInfo[1];i++)
- getCoords()->setInfoOnComponent(i,littleStrings[i+1].c_str());
+ getCoords()->setInfoOnComponent(i,littleStrings[i+4].c_str());
+ setTime(tinyInfoD[0],tinyInfo[3],tinyInfo[4]);
}
else
- setName(littleStrings[0].c_str());
+ {
+ setName(littleStrings[0].c_str());
+ setDescription(littleStrings[1].c_str());
+ setTimeUnit(littleStrings[2].c_str());
+ setTime(tinyInfoD[0],tinyInfo[3],tinyInfo[4]);
+ }
}
/*!
{
double *coords=_coords->getPointer();
int nbNodes=getNumberOfNodes();
- rotate3DAlg(center,vect,angle,nbNodes,coords);
+ Rotate3DAlg(center,vect,angle,nbNodes,coords);
}
/*!
* Low static method that operates 3D rotation of 'nbNodes' 3D nodes whose coordinates are arranged in 'coords'
* around an axe ('center','vect') and with angle 'angle'.
*/
-void MEDCouplingPointSet::rotate3DAlg(const double *center, const double *vect, double angle, int nbNodes, double *coords)
+void MEDCouplingPointSet::Rotate3DAlg(const double *center, const double *vect, double angle, int nbNodes, double *coords)
{
double sina=sin(angle);
double cosa=cos(angle);
{
double *coords=_coords->getPointer();
int nbNodes=getNumberOfNodes();
- rotate2DAlg(center,angle,nbNodes,coords);
+ Rotate2DAlg(center,angle,nbNodes,coords);
}
/*!
* Low static method that operates 3D rotation of 'nbNodes' 3D nodes whose coordinates are arranged in 'coords'
* around the center point 'center' and with angle 'angle'.
*/
-void MEDCouplingPointSet::rotate2DAlg(const double *center, double angle, int nbNodes, double *coords)
+void MEDCouplingPointSet::Rotate2DAlg(const double *center, double angle, int nbNodes, double *coords)
{
double cosa=cos(angle);
double sina=sin(angle);
MEDCouplingPointSet(const MEDCouplingPointSet& other, bool deepCpy);
~MEDCouplingPointSet();
public:
- void updateTime();
+ void updateTime() const;
int getNumberOfNodes() const;
int getSpaceDimension() const;
- void setCoords(DataArrayDouble *coords);
- DataArrayDouble *getCoords() const { return _coords; }
+ void setCoords(const DataArrayDouble *coords);
+ const DataArrayDouble *getCoords() const { return _coords; }
+ DataArrayDouble *getCoords() { return _coords; }
DataArrayDouble *getCoordinatesAndOwner() const;
void copyTinyStringsFrom(const MEDCouplingMesh *other) throw(INTERP_KERNEL::Exception);
bool isEqual(const MEDCouplingMesh *other, double prec) const;
bool areCoordsEqual(const MEDCouplingPointSet& other, double prec) const;
bool areCoordsEqualWithoutConsideringStr(const MEDCouplingPointSet& other, double prec) const;
virtual DataArrayInt *mergeNodes(double precision, bool& areNodesMerged, int& newNbOfNodes) = 0;
+ virtual DataArrayInt *mergeNodes2(double precision, bool& areNodesMerged, int& newNbOfNodes) = 0;
DataArrayInt *buildPermArrayForMergeNode(int limitNodeId, double precision, bool& areNodesMerged, int& newNbOfNodes) const;
std::vector<int> getNodeIdsNearPoint(const double *pos, double eps) const throw(INTERP_KERNEL::Exception);
void getNodeIdsNearPoints(const double *pos, int nbOfNodes, double eps, std::vector<int>& c, std::vector<int>& cI) const throw(INTERP_KERNEL::Exception);
void tryToShareSameCoords(const MEDCouplingPointSet& other, double epsilon) throw(INTERP_KERNEL::Exception);
virtual void tryToShareSameCoordsPermute(const MEDCouplingPointSet& other, double epsilon) throw(INTERP_KERNEL::Exception) = 0;
void findNodesOnPlane(const double *pt, const double *vec, double eps, std::vector<int>& nodes) const throw(INTERP_KERNEL::Exception);
- static DataArrayDouble *mergeNodesArray(const MEDCouplingPointSet *m1, const MEDCouplingPointSet *m2);
- static MEDCouplingPointSet *buildInstanceFromMeshType(MEDCouplingMeshType type);
- static void rotate2DAlg(const double *center, double angle, int nbNodes, double *coords);
- static void rotate3DAlg(const double *center, const double *vect, double angle, int nbNodes, double *coords);
+ static DataArrayDouble *MergeNodesArray(const MEDCouplingPointSet *m1, const MEDCouplingPointSet *m2) throw(INTERP_KERNEL::Exception);
+ static DataArrayDouble *MergeNodesArray(const std::vector<const MEDCouplingPointSet *>& ms) throw(INTERP_KERNEL::Exception);
+ static MEDCouplingPointSet *BuildInstanceFromMeshType(MEDCouplingMeshType type);
+ static void Rotate2DAlg(const double *center, double angle, int nbNodes, double *coords);
+ static void Rotate3DAlg(const double *center, const double *vect, double angle, int nbNodes, double *coords);
MEDCouplingMesh *buildPart(const int *start, const int *end) const;
MEDCouplingMesh *buildPartAndReduceNodes(const int *start, const int *end, DataArrayInt*& arr) const;
virtual MEDCouplingPointSet *buildPartOfMySelf(const int *start, const int *end, bool keepCoords) const = 0;
virtual void findBoundaryNodes(std::vector<int>& nodes) const = 0;
virtual MEDCouplingPointSet *buildBoundaryMesh(bool keepCoords) const = 0;
virtual void renumberNodes(const int *newNodeNumbers, int newNbOfNodes);
+ virtual void renumberNodes2(const int *newNodeNumbers, int newNbOfNodes);
virtual bool isEmptyMesh(const std::vector<int>& tinyInfo) const = 0;
//! size of returned tinyInfo must be always the same.
- void getTinySerializationInformation(std::vector<int>& tinyInfo, std::vector<std::string>& littleStrings) const;
+ void getTinySerializationInformation(std::vector<double>& tinyInfoD, std::vector<int>& tinyInfo, std::vector<std::string>& littleStrings) const;
void resizeForUnserialization(const std::vector<int>& tinyInfo, DataArrayInt *a1, DataArrayDouble *a2, std::vector<std::string>& littleStrings) const;
void serialize(DataArrayInt *&a1, DataArrayDouble *&a2) const;
- void unserialization(const std::vector<int>& tinyInfo, const DataArrayInt *a1, DataArrayDouble *a2,
+ void unserialization(const std::vector<double>& tinyInfoD, const std::vector<int>& tinyInfo, const DataArrayInt *a1, DataArrayDouble *a2,
const std::vector<std::string>& littleStrings);
- virtual void giveElemsInBoundingBox(const double *bbox, double eps, std::vector<int>& elems) = 0;
- virtual void giveElemsInBoundingBox(const INTERP_KERNEL::DirectedBoundingBox& bbox, double eps, std::vector<int>& elems) = 0;
+ virtual void getCellsInBoundingBox(const double *bbox, double eps, std::vector<int>& elems) = 0;
+ virtual void getCellsInBoundingBox(const INTERP_KERNEL::DirectedBoundingBox& bbox, double eps, std::vector<int>& elems) = 0;
virtual DataArrayInt *zipCoordsTraducer() = 0;
protected:
virtual void checkFullyDefined() const throw(INTERP_KERNEL::Exception) = 0;
#include "MEDCouplingRemapper.hxx"
#include "MEDCouplingMemArray.hxx"
#include "MEDCouplingFieldDouble.hxx"
+#include "MEDCouplingFieldTemplate.hxx"
#include "MEDCouplingFieldDiscretization.hxx"
#include "MEDCouplingExtrudedMesh.hxx"
#include "MEDCouplingNormalizedUnstructuredMesh.txx"
#include "Interpolation1D.txx"
-#include "Interpolation2DCurve.txx"
+#include "Interpolation2DCurve.hxx"
#include "Interpolation2D.txx"
#include "Interpolation3D.txx"
-#include "Interpolation3DSurf.txx"
+#include "Interpolation3DSurf.hxx"
using namespace ParaMEDMEM;
int MEDCouplingRemapper::prepare(const MEDCouplingMesh *srcMesh, const MEDCouplingMesh *targetMesh, const char *method) throw(INTERP_KERNEL::Exception)
{
releaseData(true);
- _src_mesh=(MEDCouplingMesh *)srcMesh; _target_mesh=(MEDCouplingMesh *)targetMesh;
+ _src_mesh=const_cast<MEDCouplingMesh *>(srcMesh); _target_mesh=const_cast<MEDCouplingMesh *>(targetMesh);
_src_mesh->incrRef(); _target_mesh->incrRef();
int meshInterpType=((int)_src_mesh->getType()*16)+(int)_target_mesh->getType();
switch(meshInterpType)
}
}
+int MEDCouplingRemapper::prepareEx(const MEDCouplingFieldTemplate *src, const MEDCouplingFieldTemplate *target) throw(INTERP_KERNEL::Exception)
+{
+ std::string meth(src->getDiscretization()->getStringRepr());
+ meth+=target->getDiscretization()->getStringRepr();
+ return prepare(src->getMesh(),target->getMesh(),meth.c_str());
+}
+
void MEDCouplingRemapper::transfer(const MEDCouplingFieldDouble *srcField, MEDCouplingFieldDouble *targetField, double dftValue) throw(INTERP_KERNEL::Exception)
{
if(_src_method!=srcField->getDiscretization()->getStringRepr())
int nbCols2D=interpolation2D.interpolateMeshes(source_mesh_wrapper,target_mesh_wrapper,matrix2D,method);
MEDCouplingUMesh *s1D,*t1D;
double v[3];
- MEDCouplingExtrudedMesh::project1DMeshes(src_mesh->getMesh1D(),target_mesh->getMesh1D(),getPrecision(),s1D,t1D,v);
+ MEDCouplingExtrudedMesh::Project1DMeshes(src_mesh->getMesh1D(),target_mesh->getMesh1D(),getPrecision(),s1D,t1D,v);
MEDCouplingNormalizedUnstructuredMesh<1,1> s1DWrapper(s1D);
MEDCouplingNormalizedUnstructuredMesh<1,1> t1DWrapper(t1D);
std::vector<std::map<int,double> > matrix1D;
return 1;
}
-void MEDCouplingRemapper::updateTime()
+void MEDCouplingRemapper::updateTime() const
{
}
class MEDCouplingMesh;
class MEDCouplingUMesh;
class MEDCouplingFieldDouble;
+ class MEDCouplingFieldTemplate;
}
namespace ParaMEDMEM
MEDCOUPLINGREMAPPER_EXPORT MEDCouplingRemapper();
MEDCOUPLINGREMAPPER_EXPORT ~MEDCouplingRemapper();
MEDCOUPLINGREMAPPER_EXPORT int prepare(const MEDCouplingMesh *srcMesh, const MEDCouplingMesh *targetMesh, const char *method) throw(INTERP_KERNEL::Exception);
+ MEDCOUPLINGREMAPPER_EXPORT int prepareEx(const MEDCouplingFieldTemplate *src, const MEDCouplingFieldTemplate *target) throw(INTERP_KERNEL::Exception);
MEDCOUPLINGREMAPPER_EXPORT void transfer(const MEDCouplingFieldDouble *srcField, MEDCouplingFieldDouble *targetField, double dftValue) throw(INTERP_KERNEL::Exception);
MEDCOUPLINGREMAPPER_EXPORT void reverseTransfer(MEDCouplingFieldDouble *srcField, const MEDCouplingFieldDouble *targetField, double dftValue) throw(INTERP_KERNEL::Exception);
MEDCOUPLINGREMAPPER_EXPORT MEDCouplingFieldDouble *transferField(const MEDCouplingFieldDouble *srcField, double dftValue) throw(INTERP_KERNEL::Exception);
private:
int prepareUU(const char *method) throw(INTERP_KERNEL::Exception);
int prepareEE(const char *method) throw(INTERP_KERNEL::Exception);
- void updateTime();
+ void updateTime() const;
void releaseData(bool matrixSuppression);
void computeDeno(NatureOfField nat, const MEDCouplingFieldDouble *srcField, const MEDCouplingFieldDouble *trgField);
void computeDenoFromScratch(NatureOfField nat, const MEDCouplingFieldDouble *srcField, const MEDCouplingFieldDouble *trgField) throw(INTERP_KERNEL::Exception);
void MEDCouplingTimeDiscretization::copyTinyAttrFrom(const MEDCouplingTimeDiscretization& other)
{
_time_tolerance=other._time_tolerance;
+ _time_unit=other._time_unit;
}
void MEDCouplingTimeDiscretization::copyTinyStringsFrom(const MEDCouplingTimeDiscretization& other)
{
+ _time_unit=other._time_unit;
if(_array && other._array)
_array->copyStringInfoFrom(*other._array);
}
throw INTERP_KERNEL::Exception("time tolerance is expected to be greater than 0. !");
}
-void MEDCouplingTimeDiscretization::updateTime()
+void MEDCouplingTimeDiscretization::updateTime() const
{
if(_array)
updateTimeWith(*_array);
bool MEDCouplingTimeDiscretization::areStrictlyCompatible(const MEDCouplingTimeDiscretization *other) const
{
+ if(_time_unit!=other->_time_unit)
+ return false;
if(std::fabs(_time_tolerance-other->_time_tolerance)>1.e-16)
return false;
if(_array==0 && other->_array==0)
return true;
}
+bool MEDCouplingTimeDiscretization::areCompatibleForMeld(const MEDCouplingTimeDiscretization *other) const
+{
+ if(std::fabs(_time_tolerance-other->_time_tolerance)>1.e-16)
+ return false;
+ if(_array==0 && other->_array==0)
+ return true;
+ if(_array==0 || other->_array==0)
+ return false;
+ if(_array->getNumberOfTuples()!=other->_array->getNumberOfTuples())
+ return false;
+ return true;
+}
+
bool MEDCouplingTimeDiscretization::areStrictlyCompatibleForMul(const MEDCouplingTimeDiscretization *other) const
{
if(std::fabs(_time_tolerance-other->_time_tolerance)>1.e-16)
return true;
}
+bool MEDCouplingTimeDiscretization::areStrictlyCompatibleForDiv(const MEDCouplingTimeDiscretization *other) const
+{
+ if(std::fabs(_time_tolerance-other->_time_tolerance)>1.e-16)
+ return false;
+ if(_array==0 && other->_array==0)
+ return true;
+ if(_array==0 || other->_array==0)
+ return false;
+ int nbC1=_array->getNumberOfComponents();
+ int nbC2=other->_array->getNumberOfComponents();
+ if(nbC1!=nbC2 && nbC2!=1)
+ return false;
+ return true;
+}
+
bool MEDCouplingTimeDiscretization::isEqual(const MEDCouplingTimeDiscretization *other, double prec) const
{
if(!areStrictlyCompatible(other))
return _array->isEqualWithoutConsideringStr(*other->_array,prec);
}
-MEDCouplingTimeDiscretization *MEDCouplingTimeDiscretization::buildNewTimeReprFromThis(const MEDCouplingTimeDiscretization *other,
- TypeOfTimeDiscretization type, bool deepCpy) const
+MEDCouplingTimeDiscretization *MEDCouplingTimeDiscretization::buildNewTimeReprFromThis(TypeOfTimeDiscretization type, bool deepCpy) const
{
MEDCouplingTimeDiscretization *ret=MEDCouplingTimeDiscretization::New(type);
- DataArrayDouble *arrSrc=getArray();
+ ret->setTimeUnit(getTimeUnit());
+ const DataArrayDouble *arrSrc=getArray();
DataArrayDouble *arr=0;
if(arrSrc)
arr=arrSrc->performCpy(deepCpy);
{
}
-MEDCouplingTimeDiscretization::MEDCouplingTimeDiscretization(const MEDCouplingTimeDiscretization& other, bool deepCpy):_time_tolerance(other._time_tolerance)
+MEDCouplingTimeDiscretization::MEDCouplingTimeDiscretization(const MEDCouplingTimeDiscretization& other, bool deepCpy):_time_unit(other._time_unit),_time_tolerance(other._time_tolerance)
{
if(other._array)
_array=other._array->performCpy(deepCpy);
}
}
-DataArrayDouble *MEDCouplingTimeDiscretization::getEndArray() const
+const DataArrayDouble *MEDCouplingTimeDiscretization::getEndArray() const
+{
+ throw INTERP_KERNEL::Exception("getEndArray not available for this type of time discretization !");
+}
+
+DataArrayDouble *MEDCouplingTimeDiscretization::getEndArray()
{
throw INTERP_KERNEL::Exception("getEndArray not available for this type of time discretization !");
}
MEDCouplingTimeDiscretization *MEDCouplingTimeDiscretization::doublyContractedProduct() const throw(INTERP_KERNEL::Exception)
{
MEDCouplingTimeDiscretization *ret=MEDCouplingTimeDiscretization::New(getEnum());
+ ret->setTimeUnit(getTimeUnit());
std::vector<DataArrayDouble *> arrays;
getArrays(arrays);
std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> > arrays2(arrays.size());
for(int j=0;j<(int)arrays.size();j++)
arrays3[j]=arrays2[j];
MEDCouplingTimeDiscretization *ret=MEDCouplingTimeDiscretization::New(getEnum());
+ ret->setTimeUnit(getTimeUnit());
ret->setArrays(arrays3,0);
return ret;
}
for(int j=0;j<(int)arrays.size();j++)
arrays3[j]=arrays2[j];
MEDCouplingTimeDiscretization *ret=MEDCouplingTimeDiscretization::New(getEnum());
+ ret->setTimeUnit(getTimeUnit());
ret->setArrays(arrays3,0);
return ret;
}
for(int j=0;j<(int)arrays.size();j++)
arrays3[j]=arrays2[j];
MEDCouplingTimeDiscretization *ret=MEDCouplingTimeDiscretization::New(getEnum());
+ ret->setTimeUnit(getTimeUnit());
ret->setArrays(arrays3,0);
return ret;
}
for(int j=0;j<(int)arrays.size();j++)
arrays3[j]=arrays2[j];
MEDCouplingTimeDiscretization *ret=MEDCouplingTimeDiscretization::New(getEnum());
+ ret->setTimeUnit(getTimeUnit());
ret->setArrays(arrays3,0);
return ret;
}
for(int j=0;j<(int)arrays.size();j++)
arrays3[j]=arrays2[j];
MEDCouplingTimeDiscretization *ret=MEDCouplingTimeDiscretization::New(getEnum());
+ ret->setTimeUnit(getTimeUnit());
ret->setArrays(arrays3,0);
return ret;
}
for(int j=0;j<(int)arrays.size();j++)
arrays3[j]=arrays2[j];
MEDCouplingTimeDiscretization *ret=MEDCouplingTimeDiscretization::New(getEnum());
+ ret->setTimeUnit(getTimeUnit());
ret->setArrays(arrays3,0);
return ret;
}
for(int j=0;j<(int)arrays.size();j++)
arrays3[j]=arrays2[j];
MEDCouplingTimeDiscretization *ret=MEDCouplingTimeDiscretization::New(getEnum());
+ ret->setTimeUnit(getTimeUnit());
ret->setArrays(arrays3,0);
return ret;
}
for(int j=0;j<(int)arrays.size();j++)
arrays3[j]=arrays2[j];
MEDCouplingTimeDiscretization *ret=MEDCouplingTimeDiscretization::New(getEnum());
+ ret->setTimeUnit(getTimeUnit());
ret->setArrays(arrays3,0);
return ret;
}
for(int j=0;j<(int)arrays.size();j++)
arrays3[j]=arrays2[j];
MEDCouplingTimeDiscretization *ret=MEDCouplingTimeDiscretization::New(getEnum());
+ ret->setTimeUnit(getTimeUnit());
ret->setArrays(arrays3,0);
return ret;
}
{
std::vector<DataArrayDouble *> arrays;
getArrays(arrays);
- std::vector<DataArrayDouble *> arrays2(arrays.size());
+ std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> > arrays2(arrays.size());
for(int j=0;j<(int)arrays.size();j++)
{
if(arrays[j])
else
arrays2[j]=0;
}
- setArrays(arrays2,0);
+ std::vector<DataArrayDouble *> arrays3(arrays.size());
for(int j=0;j<(int)arrays.size();j++)
- if(arrays2[j])
- arrays2[j]->decrRef();
+ arrays3[j]=arrays2[j];
+ setArrays(arrays3,0);
}
void MEDCouplingTimeDiscretization::applyFunc(int nbOfComp, const char *func)
{
std::vector<DataArrayDouble *> arrays;
getArrays(arrays);
- std::vector<DataArrayDouble *> arrays2(arrays.size());
+ std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> > arrays2(arrays.size());
for(int j=0;j<(int)arrays.size();j++)
{
if(arrays[j])
else
arrays2[j]=0;
}
- setArrays(arrays2,0);
+ std::vector<DataArrayDouble *> arrays3(arrays.size());
for(int j=0;j<(int)arrays.size();j++)
- if(arrays2[j])
- arrays2[j]->decrRef();
+ arrays3[j]=arrays2[j];
+ setArrays(arrays3,0);
+}
+
+void MEDCouplingTimeDiscretization::applyFunc2(int nbOfComp, const char *func)
+{
+ std::vector<DataArrayDouble *> arrays;
+ getArrays(arrays);
+ std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> > arrays2(arrays.size());
+ for(int j=0;j<(int)arrays.size();j++)
+ {
+ if(arrays[j])
+ arrays2[j]=arrays[j]->applyFunc2(nbOfComp,func);
+ else
+ arrays2[j]=0;
+ }
+ std::vector<DataArrayDouble *> arrays3(arrays.size());
+ for(int j=0;j<(int)arrays.size();j++)
+ arrays3[j]=arrays2[j];
+ setArrays(arrays3,0);
+}
+
+void MEDCouplingTimeDiscretization::applyFunc3(int nbOfComp, const std::vector<std::string>& varsOrder, const char *func)
+{
+ std::vector<DataArrayDouble *> arrays;
+ getArrays(arrays);
+ std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> > arrays2(arrays.size());
+ for(int j=0;j<(int)arrays.size();j++)
+ {
+ if(arrays[j])
+ arrays2[j]=arrays[j]->applyFunc3(nbOfComp,varsOrder,func);
+ else
+ arrays2[j]=0;
+ }
+ std::vector<DataArrayDouble *> arrays3(arrays.size());
+ for(int j=0;j<(int)arrays.size();j++)
+ arrays3[j]=arrays2[j];
+ setArrays(arrays3,0);
}
void MEDCouplingTimeDiscretization::applyFunc(const char *func)
{
std::vector<DataArrayDouble *> arrays;
getArrays(arrays);
- std::vector<DataArrayDouble *> arrays2(arrays.size());
+ std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> > arrays2(arrays.size());
for(int j=0;j<(int)arrays.size();j++)
{
if(arrays[j])
else
arrays2[j]=0;
}
- setArrays(arrays2,0);
+ std::vector<DataArrayDouble *> arrays3(arrays.size());
for(int j=0;j<(int)arrays.size();j++)
- if(arrays2[j])
- arrays2[j]->decrRef();
+ arrays3[j]=arrays2[j];
+ setArrays(arrays3,0);
}
void MEDCouplingTimeDiscretization::applyFuncFast32(const char *func)
setArrays(arrays3,0);
}
+void MEDCouplingTimeDiscretization::fillFromAnalytic2(const DataArrayDouble *loc, int nbOfComp, const char *func) throw(INTERP_KERNEL::Exception)
+{
+ std::vector<DataArrayDouble *> arrays;
+ getArrays(arrays);
+ std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> > arrays2(arrays.size());
+ for(int j=0;j<(int)arrays.size();j++)
+ arrays2[j]=loc->applyFunc2(nbOfComp,func);
+ std::vector<DataArrayDouble *> arrays3(arrays.size());
+ for(int j=0;j<(int)arrays.size();j++)
+ arrays3[j]=arrays2[j];
+ setArrays(arrays3,0);
+}
+
+void MEDCouplingTimeDiscretization::fillFromAnalytic3(const DataArrayDouble *loc, int nbOfComp, const std::vector<std::string>& varsOrder, const char *func) throw(INTERP_KERNEL::Exception)
+{
+ std::vector<DataArrayDouble *> arrays;
+ getArrays(arrays);
+ std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> > arrays2(arrays.size());
+ for(int j=0;j<(int)arrays.size();j++)
+ arrays2[j]=loc->applyFunc3(nbOfComp,varsOrder,func);
+ std::vector<DataArrayDouble *> arrays3(arrays.size());
+ for(int j=0;j<(int)arrays.size();j++)
+ arrays3[j]=arrays2[j];
+ setArrays(arrays3,0);
+}
+
MEDCouplingNoTimeLabel::MEDCouplingNoTimeLabel()
{
}
{
std::ostringstream stream;
stream << REPR;
+ stream << "\nTime unit is : \"" << _time_unit << "\"";
return stream.str();
}
return otherC!=0;
}
+bool MEDCouplingNoTimeLabel::areStrictlyCompatibleForDiv(const MEDCouplingTimeDiscretization *other) const
+{
+ if(!MEDCouplingTimeDiscretization::areStrictlyCompatibleForDiv(other))
+ return false;
+ const MEDCouplingNoTimeLabel *otherC=dynamic_cast<const MEDCouplingNoTimeLabel *>(other);
+ return otherC!=0;
+}
+
+bool MEDCouplingNoTimeLabel::areCompatibleForMeld(const MEDCouplingTimeDiscretization *other) const
+{
+ if(!MEDCouplingTimeDiscretization::areCompatibleForMeld(other))
+ return false;
+ const MEDCouplingNoTimeLabel *otherC=dynamic_cast<const MEDCouplingNoTimeLabel *>(other);
+ return otherC!=0;
+}
+
bool MEDCouplingNoTimeLabel::isEqual(const MEDCouplingTimeDiscretization *other, double prec) const
{
const MEDCouplingNoTimeLabel *otherC=dynamic_cast<const MEDCouplingNoTimeLabel *>(other);
const MEDCouplingNoTimeLabel *otherC=dynamic_cast<const MEDCouplingNoTimeLabel *>(other);
if(!otherC)
throw INTERP_KERNEL::Exception("NoTimeLabel::aggregation on mismatched time discretization !");
- DataArrayDouble *arr=DataArrayDouble::aggregate(getArray(),other->getArray());
+ DataArrayDouble *arr=DataArrayDouble::Aggregate(getArray(),other->getArray());
+ MEDCouplingNoTimeLabel *ret=new MEDCouplingNoTimeLabel;
+ ret->setArray(arr,0);
+ arr->decrRef();
+ return ret;
+}
+
+MEDCouplingTimeDiscretization *MEDCouplingNoTimeLabel::aggregate(const std::vector<const MEDCouplingTimeDiscretization *>& other) const
+{
+ std::vector<const DataArrayDouble *> a(other.size());
+ int i=0;
+ for(std::vector<const MEDCouplingTimeDiscretization *>::const_iterator it=other.begin();it!=other.end();it++,i++)
+ {
+ const MEDCouplingNoTimeLabel *itC=dynamic_cast<const MEDCouplingNoTimeLabel *>(*it);
+ if(!itC)
+ throw INTERP_KERNEL::Exception("NoTimeLabel::aggregate on mismatched time discretization !");
+ a[i]=itC->getArray();
+ }
+ DataArrayDouble *arr=DataArrayDouble::Aggregate(a);
+ MEDCouplingNoTimeLabel *ret=new MEDCouplingNoTimeLabel;
+ ret->setArray(arr,0);
+ arr->decrRef();
+ return ret;
+}
+
+MEDCouplingTimeDiscretization *MEDCouplingNoTimeLabel::meld(const MEDCouplingTimeDiscretization *other) const
+{
+ const MEDCouplingNoTimeLabel *otherC=dynamic_cast<const MEDCouplingNoTimeLabel *>(other);
+ if(!otherC)
+ throw INTERP_KERNEL::Exception("NoTimeLabel::meld on mismatched time discretization !");
+ DataArrayDouble *arr=DataArrayDouble::Meld(getArray(),other->getArray());
MEDCouplingNoTimeLabel *ret=new MEDCouplingNoTimeLabel;
ret->setTimeTolerance(getTimeTolerance());
ret->setArray(arr,0);
const MEDCouplingNoTimeLabel *otherC=dynamic_cast<const MEDCouplingNoTimeLabel *>(other);
if(!otherC)
throw INTERP_KERNEL::Exception("NoTimeLabel::dot on mismatched time discretization !");
- DataArrayDouble *arr=DataArrayDouble::dot(getArray(),other->getArray());
+ DataArrayDouble *arr=DataArrayDouble::Dot(getArray(),other->getArray());
MEDCouplingNoTimeLabel *ret=new MEDCouplingNoTimeLabel;
ret->setArray(arr,0);
arr->decrRef();
const MEDCouplingNoTimeLabel *otherC=dynamic_cast<const MEDCouplingNoTimeLabel *>(other);
if(!otherC)
throw INTERP_KERNEL::Exception("NoTimeLabel::crossProduct on mismatched time discretization !");
- DataArrayDouble *arr=DataArrayDouble::crossProduct(getArray(),other->getArray());
+ DataArrayDouble *arr=DataArrayDouble::CrossProduct(getArray(),other->getArray());
MEDCouplingNoTimeLabel *ret=new MEDCouplingNoTimeLabel;
ret->setArray(arr,0);
arr->decrRef();
const MEDCouplingNoTimeLabel *otherC=dynamic_cast<const MEDCouplingNoTimeLabel *>(other);
if(!otherC)
throw INTERP_KERNEL::Exception("NoTimeLabel::max on mismatched time discretization !");
- DataArrayDouble *arr=DataArrayDouble::max(getArray(),other->getArray());
+ DataArrayDouble *arr=DataArrayDouble::Max(getArray(),other->getArray());
MEDCouplingNoTimeLabel *ret=new MEDCouplingNoTimeLabel;
ret->setArray(arr,0);
arr->decrRef();
const MEDCouplingNoTimeLabel *otherC=dynamic_cast<const MEDCouplingNoTimeLabel *>(other);
if(!otherC)
throw INTERP_KERNEL::Exception("NoTimeLabel::max on mismatched time discretization !");
- DataArrayDouble *arr=DataArrayDouble::min(getArray(),other->getArray());
+ DataArrayDouble *arr=DataArrayDouble::Min(getArray(),other->getArray());
MEDCouplingNoTimeLabel *ret=new MEDCouplingNoTimeLabel;
ret->setArray(arr,0);
arr->decrRef();
const MEDCouplingNoTimeLabel *otherC=dynamic_cast<const MEDCouplingNoTimeLabel *>(other);
if(!otherC)
throw INTERP_KERNEL::Exception("NoTimeLabel::add on mismatched time discretization !");
- DataArrayDouble *arr=DataArrayDouble::add(getArray(),other->getArray());
+ DataArrayDouble *arr=DataArrayDouble::Add(getArray(),other->getArray());
MEDCouplingNoTimeLabel *ret=new MEDCouplingNoTimeLabel;
ret->setArray(arr,0);
arr->decrRef();
const MEDCouplingNoTimeLabel *otherC=dynamic_cast<const MEDCouplingNoTimeLabel *>(other);
if(!otherC)
throw INTERP_KERNEL::Exception("NoTimeLabel::substract on mismatched time discretization !");
- DataArrayDouble *arr=DataArrayDouble::substract(getArray(),other->getArray());
+ DataArrayDouble *arr=DataArrayDouble::Substract(getArray(),other->getArray());
MEDCouplingNoTimeLabel *ret=new MEDCouplingNoTimeLabel;
ret->setArray(arr,0);
arr->decrRef();
const MEDCouplingNoTimeLabel *otherC=dynamic_cast<const MEDCouplingNoTimeLabel *>(other);
if(!otherC)
throw INTERP_KERNEL::Exception("NoTimeLabel::multiply on mismatched time discretization !");
- DataArrayDouble *arr=DataArrayDouble::multiply(getArray(),other->getArray());
+ DataArrayDouble *arr=DataArrayDouble::Multiply(getArray(),other->getArray());
MEDCouplingNoTimeLabel *ret=new MEDCouplingNoTimeLabel;
ret->setArray(arr,0);
arr->decrRef();
const MEDCouplingNoTimeLabel *otherC=dynamic_cast<const MEDCouplingNoTimeLabel *>(other);
if(!otherC)
throw INTERP_KERNEL::Exception("divide on mismatched time discretization !");
- DataArrayDouble *arr=DataArrayDouble::divide(getArray(),other->getArray());
+ DataArrayDouble *arr=DataArrayDouble::Divide(getArray(),other->getArray());
MEDCouplingNoTimeLabel *ret=new MEDCouplingNoTimeLabel;
ret->setArray(arr,0);
arr->decrRef();
throw INTERP_KERNEL::Exception(EXCEPTION_MSG);
}
+void MEDCouplingNoTimeLabel::setStartIteration(int it) throw(INTERP_KERNEL::Exception)
+{
+ throw INTERP_KERNEL::Exception(EXCEPTION_MSG);
+}
+
+void MEDCouplingNoTimeLabel::setEndIteration(int it) throw(INTERP_KERNEL::Exception)
+{
+ throw INTERP_KERNEL::Exception(EXCEPTION_MSG);
+}
+
+void MEDCouplingNoTimeLabel::setStartOrder(int order) throw(INTERP_KERNEL::Exception)
+{
+ throw INTERP_KERNEL::Exception(EXCEPTION_MSG);
+}
+
+void MEDCouplingNoTimeLabel::setEndOrder(int order) throw(INTERP_KERNEL::Exception)
+{
+ throw INTERP_KERNEL::Exception(EXCEPTION_MSG);
+}
+
+void MEDCouplingNoTimeLabel::setStartTimeValue(double time) throw(INTERP_KERNEL::Exception)
+{
+ throw INTERP_KERNEL::Exception(EXCEPTION_MSG);
+}
+
+void MEDCouplingNoTimeLabel::setEndTimeValue(double time) throw(INTERP_KERNEL::Exception)
+{
+ throw INTERP_KERNEL::Exception(EXCEPTION_MSG);
+}
+
void MEDCouplingNoTimeLabel::setStartTime(double time, int iteration, int order) throw(INTERP_KERNEL::Exception)
{
throw INTERP_KERNEL::Exception(EXCEPTION_MSG);
throw INTERP_KERNEL::Exception(EXCEPTION_MSG);
}
+/*!
+ * idem getTinySerializationIntInformation except that it is for multi field fetch
+ */
+void MEDCouplingNoTimeLabel::getTinySerializationIntInformation2(std::vector<int>& tinyInfo) const
+{
+ tinyInfo.clear();
+}
+
+/*!
+ * idem getTinySerializationDbleInformation except that it is for multi field fetch
+ */
+void MEDCouplingNoTimeLabel::getTinySerializationDbleInformation2(std::vector<double>& tinyInfo) const
+{
+ tinyInfo.resize(1);
+ tinyInfo[0]=_time_tolerance;
+}
+
+/*!
+ * idem finishUnserialization except that it is for multi field fetch
+ */
+void MEDCouplingNoTimeLabel::finishUnserialization2(const std::vector<int>& tinyInfoI, const std::vector<double>& tinyInfoD)
+{
+ _time_tolerance=tinyInfoD[0];
+}
+
MEDCouplingWithTimeStep::MEDCouplingWithTimeStep(const MEDCouplingWithTimeStep& other, bool deepCpy):MEDCouplingTimeDiscretization(other,deepCpy),
_time(other._time),_iteration(other._iteration),_order(other._order)
{
{
std::ostringstream stream;
stream << REPR << " Time is defined by iteration=" << _iteration << " order=" << _order << " and time=" << _time << ".";
+ stream << "\nTime unit is : \"" << _time_unit << "\"";
return stream.str();
}
_order=tinyInfoI[3];
}
+/*!
+ * idem getTinySerializationIntInformation except that it is for multi field fetch
+ */
+void MEDCouplingWithTimeStep::getTinySerializationIntInformation2(std::vector<int>& tinyInfo) const
+{
+ tinyInfo.resize(2);
+ tinyInfo[0]=_iteration;
+ tinyInfo[1]=_order;
+}
+
+/*!
+ * idem getTinySerializationDbleInformation except that it is for multi field fetch
+ */
+void MEDCouplingWithTimeStep::getTinySerializationDbleInformation2(std::vector<double>& tinyInfo) const
+{
+ tinyInfo.resize(2);
+ tinyInfo[0]=_time_tolerance;
+ tinyInfo[1]=_time;
+}
+
+/*!
+ * idem finishUnserialization except that it is for multi field fetch
+ */
+void MEDCouplingWithTimeStep::finishUnserialization2(const std::vector<int>& tinyInfoI, const std::vector<double>& tinyInfoD)
+{
+ _iteration=tinyInfoI[0];
+ _order=tinyInfoI[1];
+ _time_tolerance=tinyInfoD[0];
+ _time=tinyInfoD[1];
+}
+
bool MEDCouplingWithTimeStep::areCompatible(const MEDCouplingTimeDiscretization *other) const
{
if(!MEDCouplingTimeDiscretization::areCompatible(other))
return otherC!=0;
}
+bool MEDCouplingWithTimeStep::areStrictlyCompatibleForDiv(const MEDCouplingTimeDiscretization *other) const
+{
+ if(!MEDCouplingTimeDiscretization::areStrictlyCompatibleForDiv(other))
+ return false;
+ const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(other);
+ return otherC!=0;
+}
+
+bool MEDCouplingWithTimeStep::areCompatibleForMeld(const MEDCouplingTimeDiscretization *other) const
+{
+ if(!MEDCouplingTimeDiscretization::areCompatibleForMeld(other))
+ return false;
+ const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(other);
+ return otherC!=0;
+}
+
bool MEDCouplingWithTimeStep::isEqual(const MEDCouplingTimeDiscretization *other, double prec) const
{
const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(other);
const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(other);
if(!otherC)
throw INTERP_KERNEL::Exception("WithTimeStep::aggregation on mismatched time discretization !");
- DataArrayDouble *arr=DataArrayDouble::aggregate(getArray(),other->getArray());
+ DataArrayDouble *arr=DataArrayDouble::Aggregate(getArray(),other->getArray());
+ MEDCouplingWithTimeStep *ret=new MEDCouplingWithTimeStep;
+ ret->setArray(arr,0);
+ arr->decrRef();
+ return ret;
+}
+
+MEDCouplingTimeDiscretization *MEDCouplingWithTimeStep::aggregate(const std::vector<const MEDCouplingTimeDiscretization *>& other) const
+{
+ std::vector<const DataArrayDouble *> a(other.size());
+ int i=0;
+ for(std::vector<const MEDCouplingTimeDiscretization *>::const_iterator it=other.begin();it!=other.end();it++,i++)
+ {
+ const MEDCouplingWithTimeStep *itC=dynamic_cast<const MEDCouplingWithTimeStep *>(*it);
+ if(!itC)
+ throw INTERP_KERNEL::Exception("WithTimeStep::aggregate on mismatched time discretization !");
+ a[i]=itC->getArray();
+ }
+ DataArrayDouble *arr=DataArrayDouble::Aggregate(a);
+ MEDCouplingWithTimeStep *ret=new MEDCouplingWithTimeStep;
+ ret->setArray(arr,0);
+ arr->decrRef();
+ return ret;
+}
+
+MEDCouplingTimeDiscretization *MEDCouplingWithTimeStep::meld(const MEDCouplingTimeDiscretization *other) const
+{
+ const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(other);
+ if(!otherC)
+ throw INTERP_KERNEL::Exception("WithTimeStep::meld on mismatched time discretization !");
+ DataArrayDouble *arr=DataArrayDouble::Meld(getArray(),other->getArray());
MEDCouplingWithTimeStep *ret=new MEDCouplingWithTimeStep;
- ret->setTimeTolerance(getTimeTolerance());
ret->setArray(arr,0);
arr->decrRef();
- int tmp1,tmp2;
- double tmp3=getStartTime(tmp1,tmp2);
- ret->setStartTime(tmp3,tmp1,tmp2);
return ret;
}
if(!otherC)
throw INTERP_KERNEL::Exception("WithTimeStep::dot on mismatched time discretization !");
MEDCouplingWithTimeStep *ret=new MEDCouplingWithTimeStep;
- DataArrayDouble *arr=DataArrayDouble::dot(getArray(),other->getArray());
+ DataArrayDouble *arr=DataArrayDouble::Dot(getArray(),other->getArray());
ret->setArray(arr,0);
arr->decrRef();
return ret;
const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(other);
if(!otherC)
throw INTERP_KERNEL::Exception("WithTimeStep::crossProduct on mismatched time discretization !");
- DataArrayDouble *arr=DataArrayDouble::crossProduct(getArray(),other->getArray());
+ DataArrayDouble *arr=DataArrayDouble::CrossProduct(getArray(),other->getArray());
MEDCouplingWithTimeStep *ret=new MEDCouplingWithTimeStep;
ret->setArray(arr,0);
arr->decrRef();
const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(other);
if(!otherC)
throw INTERP_KERNEL::Exception("WithTimeStep::max on mismatched time discretization !");
- DataArrayDouble *arr=DataArrayDouble::max(getArray(),other->getArray());
+ DataArrayDouble *arr=DataArrayDouble::Max(getArray(),other->getArray());
MEDCouplingWithTimeStep *ret=new MEDCouplingWithTimeStep;
ret->setArray(arr,0);
arr->decrRef();
const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(other);
if(!otherC)
throw INTERP_KERNEL::Exception("WithTimeStep::min on mismatched time discretization !");
- DataArrayDouble *arr=DataArrayDouble::min(getArray(),other->getArray());
+ DataArrayDouble *arr=DataArrayDouble::Min(getArray(),other->getArray());
MEDCouplingWithTimeStep *ret=new MEDCouplingWithTimeStep;
ret->setArray(arr,0);
arr->decrRef();
const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(other);
if(!otherC)
throw INTERP_KERNEL::Exception("WithTimeStep::add on mismatched time discretization !");
- DataArrayDouble *arr=DataArrayDouble::add(getArray(),other->getArray());
+ DataArrayDouble *arr=DataArrayDouble::Add(getArray(),other->getArray());
MEDCouplingWithTimeStep *ret=new MEDCouplingWithTimeStep;
ret->setArray(arr,0);
arr->decrRef();
const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(other);
if(!otherC)
throw INTERP_KERNEL::Exception("WithTimeStep::substract on mismatched time discretization !");
- DataArrayDouble *arr=DataArrayDouble::substract(getArray(),other->getArray());
+ DataArrayDouble *arr=DataArrayDouble::Substract(getArray(),other->getArray());
MEDCouplingWithTimeStep *ret=new MEDCouplingWithTimeStep;
ret->setArray(arr,0);
arr->decrRef();
const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(other);
if(!otherC)
throw INTERP_KERNEL::Exception("WithTimeStep::multiply on mismatched time discretization !");
- DataArrayDouble *arr=DataArrayDouble::multiply(getArray(),other->getArray());
+ DataArrayDouble *arr=DataArrayDouble::Multiply(getArray(),other->getArray());
MEDCouplingWithTimeStep *ret=new MEDCouplingWithTimeStep;
ret->setArray(arr,0);
arr->decrRef();
const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(other);
if(!otherC)
throw INTERP_KERNEL::Exception("WithTimeStep::divide on mismatched time discretization !");
- DataArrayDouble *arr=DataArrayDouble::divide(getArray(),other->getArray());
+ DataArrayDouble *arr=DataArrayDouble::Divide(getArray(),other->getArray());
MEDCouplingWithTimeStep *ret=new MEDCouplingWithTimeStep;
ret->setArray(arr,0);
arr->decrRef();
_end_order=tinyInfoI[5];
}
+/*!
+ * idem getTinySerializationIntInformation except that it is for multi field fetch
+ */
+void MEDCouplingConstOnTimeInterval::getTinySerializationIntInformation2(std::vector<int>& tinyInfo) const
+{
+ tinyInfo.resize(4);
+ tinyInfo[0]=_start_iteration;
+ tinyInfo[1]=_start_order;
+ tinyInfo[2]=_end_iteration;
+ tinyInfo[3]=_end_order;
+}
+
+/*!
+ * idem getTinySerializationDbleInformation except that it is for multi field fetch
+ */
+void MEDCouplingConstOnTimeInterval::getTinySerializationDbleInformation2(std::vector<double>& tinyInfo) const
+{
+ tinyInfo.resize(3);
+ tinyInfo[0]=_time_tolerance;
+ tinyInfo[1]=_start_time;
+ tinyInfo[2]=_end_time;
+}
+
+/*!
+ * idem finishUnserialization except that it is for multi field fetch
+ */
+void MEDCouplingConstOnTimeInterval::finishUnserialization2(const std::vector<int>& tinyInfoI, const std::vector<double>& tinyInfoD)
+{
+ _start_iteration=tinyInfoI[0];
+ _start_order=tinyInfoI[1];
+ _end_iteration=tinyInfoI[2];
+ _end_order=tinyInfoI[3];
+ _time_tolerance=tinyInfoD[0];
+ _start_time=tinyInfoD[1];
+ _end_time=tinyInfoD[2];
+}
+
MEDCouplingConstOnTimeInterval::MEDCouplingConstOnTimeInterval(const MEDCouplingConstOnTimeInterval& other, bool deepCpy):
MEDCouplingTimeDiscretization(other,deepCpy),_start_time(other._start_time),_end_time(other._end_time),_start_iteration(other._start_iteration),
_end_iteration(other._end_iteration),_start_order(other._start_order),_end_order(other._end_order)
std::ostringstream stream;
stream << REPR << " Time interval is defined by :\niteration_start=" << _start_iteration << " order_start=" << _start_order << " and time_start=" << _start_time << "\n";
stream << "iteration_end=" << _end_iteration << " order_end=" << _end_order << " and end_time=" << _end_time << "\n";
+ stream << "\nTime unit is : \"" << _time_unit << "\"";
return stream.str();
}
bool MEDCouplingConstOnTimeInterval::areStrictlyCompatibleForMul(const MEDCouplingTimeDiscretization *other) const
{
- if(!MEDCouplingTimeDiscretization::areStrictlyCompatible(other))
+ if(!MEDCouplingTimeDiscretization::areStrictlyCompatibleForMul(other))
+ return false;
+ const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other);
+ return otherC!=0;
+}
+
+bool MEDCouplingConstOnTimeInterval::areStrictlyCompatibleForDiv(const MEDCouplingTimeDiscretization *other) const
+{
+ if(!MEDCouplingTimeDiscretization::areStrictlyCompatibleForDiv(other))
+ return false;
+ const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other);
+ return otherC!=0;
+}
+
+bool MEDCouplingConstOnTimeInterval::areCompatibleForMeld(const MEDCouplingTimeDiscretization *other) const
+{
+ if(!MEDCouplingTimeDiscretization::areCompatibleForMeld(other))
return false;
const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other);
return otherC!=0;
MEDCouplingTimeDiscretization *MEDCouplingConstOnTimeInterval::aggregate(const MEDCouplingTimeDiscretization *other) const
{
- const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other);
+ const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other);
if(!otherC)
throw INTERP_KERNEL::Exception("ConstOnTimeInterval::aggregation on mismatched time discretization !");
- DataArrayDouble *arr=DataArrayDouble::aggregate(getArray(),other->getArray());
+ DataArrayDouble *arr=DataArrayDouble::Aggregate(getArray(),other->getArray());
+ MEDCouplingConstOnTimeInterval *ret=new MEDCouplingConstOnTimeInterval;
+ ret->setArray(arr,0);
+ arr->decrRef();
+ return ret;
+}
+
+MEDCouplingTimeDiscretization *MEDCouplingConstOnTimeInterval::aggregate(const std::vector<const MEDCouplingTimeDiscretization *>& other) const
+{
+ std::vector<const DataArrayDouble *> a(other.size());
+ int i=0;
+ for(std::vector<const MEDCouplingTimeDiscretization *>::const_iterator it=other.begin();it!=other.end();it++,i++)
+ {
+ const MEDCouplingConstOnTimeInterval *itC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(*it);
+ if(!itC)
+ throw INTERP_KERNEL::Exception("ConstOnTimeInterval::aggregate on mismatched time discretization !");
+ a[i]=itC->getArray();
+ }
+ DataArrayDouble *arr=DataArrayDouble::Aggregate(a);
+ MEDCouplingConstOnTimeInterval *ret=new MEDCouplingConstOnTimeInterval;
+ ret->setArray(arr,0);
+ arr->decrRef();
+ return ret;
+}
+
+MEDCouplingTimeDiscretization *MEDCouplingConstOnTimeInterval::meld(const MEDCouplingTimeDiscretization *other) const
+{
+ const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other);
+ if(!otherC)
+ throw INTERP_KERNEL::Exception("ConstOnTimeInterval::meld on mismatched time discretization !");
+ DataArrayDouble *arr=DataArrayDouble::Meld(getArray(),other->getArray());
MEDCouplingConstOnTimeInterval *ret=new MEDCouplingConstOnTimeInterval;
ret->setTimeTolerance(getTimeTolerance());
ret->setArray(arr,0);
arr->decrRef();
- int tmp1,tmp2;
- double tmp3=getStartTime(tmp1,tmp2);
- ret->setStartTime(tmp3,tmp1,tmp2);
- tmp3=getEndTime(tmp1,tmp2);
- ret->setEndTime(tmp3,tmp1,tmp2);
return ret;
}
const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other);
if(!otherC)
throw INTERP_KERNEL::Exception("ConstOnTimeInterval::dot on mismatched time discretization !");
- DataArrayDouble *arr=DataArrayDouble::dot(getArray(),other->getArray());
+ DataArrayDouble *arr=DataArrayDouble::Dot(getArray(),other->getArray());
MEDCouplingConstOnTimeInterval *ret=new MEDCouplingConstOnTimeInterval;
ret->setArray(arr,0);
arr->decrRef();
const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other);
if(!otherC)
throw INTERP_KERNEL::Exception("ConstOnTimeInterval::crossProduct on mismatched time discretization !");
- DataArrayDouble *arr=DataArrayDouble::crossProduct(getArray(),other->getArray());
+ DataArrayDouble *arr=DataArrayDouble::CrossProduct(getArray(),other->getArray());
MEDCouplingConstOnTimeInterval *ret=new MEDCouplingConstOnTimeInterval;
ret->setArray(arr,0);
arr->decrRef();
const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other);
if(!otherC)
throw INTERP_KERNEL::Exception("ConstOnTimeInterval::max on mismatched time discretization !");
- DataArrayDouble *arr=DataArrayDouble::max(getArray(),other->getArray());
+ DataArrayDouble *arr=DataArrayDouble::Max(getArray(),other->getArray());
MEDCouplingConstOnTimeInterval *ret=new MEDCouplingConstOnTimeInterval;
ret->setArray(arr,0);
arr->decrRef();
const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other);
if(!otherC)
throw INTERP_KERNEL::Exception("ConstOnTimeInterval::min on mismatched time discretization !");
- DataArrayDouble *arr=DataArrayDouble::min(getArray(),other->getArray());
+ DataArrayDouble *arr=DataArrayDouble::Min(getArray(),other->getArray());
MEDCouplingConstOnTimeInterval *ret=new MEDCouplingConstOnTimeInterval;
ret->setArray(arr,0);
arr->decrRef();
const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other);
if(!otherC)
throw INTERP_KERNEL::Exception("ConstOnTimeInterval::add on mismatched time discretization !");
- DataArrayDouble *arr=DataArrayDouble::add(getArray(),other->getArray());
+ DataArrayDouble *arr=DataArrayDouble::Add(getArray(),other->getArray());
MEDCouplingConstOnTimeInterval *ret=new MEDCouplingConstOnTimeInterval;
ret->setArray(arr,0);
arr->decrRef();
const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other);
if(!otherC)
throw INTERP_KERNEL::Exception("ConstOnTimeInterval::substract on mismatched time discretization !");
- DataArrayDouble *arr=DataArrayDouble::substract(getArray(),other->getArray());
+ DataArrayDouble *arr=DataArrayDouble::Substract(getArray(),other->getArray());
MEDCouplingConstOnTimeInterval *ret=new MEDCouplingConstOnTimeInterval;
ret->setArray(arr,0);
arr->decrRef();
const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other);
if(!otherC)
throw INTERP_KERNEL::Exception("multiply on mismatched time discretization !");
- DataArrayDouble *arr=DataArrayDouble::multiply(getArray(),other->getArray());
+ DataArrayDouble *arr=DataArrayDouble::Multiply(getArray(),other->getArray());
MEDCouplingConstOnTimeInterval *ret=new MEDCouplingConstOnTimeInterval;
ret->setArray(arr,0);
arr->decrRef();
const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other);
if(!otherC)
throw INTERP_KERNEL::Exception("divide on mismatched time discretization !");
- DataArrayDouble *arr=DataArrayDouble::divide(getArray(),other->getArray());
+ DataArrayDouble *arr=DataArrayDouble::Divide(getArray(),other->getArray());
MEDCouplingConstOnTimeInterval *ret=new MEDCouplingConstOnTimeInterval;
ret->setArray(arr,0);
arr->decrRef();
_end_array=0;
}
-void MEDCouplingTwoTimeSteps::updateTime()
+void MEDCouplingTwoTimeSteps::updateTime() const
{
MEDCouplingTimeDiscretization::updateTime();
if(_end_array)
_end_array->copyStringInfoFrom(*otherC->_end_array);
}
-DataArrayDouble *MEDCouplingTwoTimeSteps::getEndArray() const
+const DataArrayDouble *MEDCouplingTwoTimeSteps::getEndArray() const
+{
+ return _end_array;
+}
+
+DataArrayDouble *MEDCouplingTwoTimeSteps::getEndArray()
{
return _end_array;
}
_end_order=tinyInfoI[5];
}
+/*!
+ * idem getTinySerializationIntInformation except that it is for multi field fetch
+ */
+void MEDCouplingTwoTimeSteps::getTinySerializationIntInformation2(std::vector<int>& tinyInfo) const
+{
+ tinyInfo.resize(4);
+ tinyInfo[0]=_start_iteration;
+ tinyInfo[1]=_start_order;
+ tinyInfo[2]=_end_iteration;
+ tinyInfo[3]=_end_order;
+}
+
+/*!
+ * idem getTinySerializationDbleInformation except that it is for multi field fetch
+ */
+void MEDCouplingTwoTimeSteps::getTinySerializationDbleInformation2(std::vector<double>& tinyInfo) const
+{
+ tinyInfo.resize(3);
+ tinyInfo[0]=_time_tolerance;
+ tinyInfo[1]=_start_time;
+ tinyInfo[2]=_end_time;
+}
+
+/*!
+ * idem finishUnserialization except that it is for multi field fetch
+ */
+void MEDCouplingTwoTimeSteps::finishUnserialization2(const std::vector<int>& tinyInfoI, const std::vector<double>& tinyInfoD)
+{
+ _start_iteration=tinyInfoI[0];
+ _start_order=tinyInfoI[1];
+ _end_iteration=tinyInfoI[2];
+ _end_order=tinyInfoI[3];
+ _time_tolerance=tinyInfoD[0];
+ _start_time=tinyInfoD[1];
+ _end_time=tinyInfoD[2];
+}
+
std::vector< const DataArrayDouble *> MEDCouplingTwoTimeSteps::getArraysForTime(double time) const throw(INTERP_KERNEL::Exception)
{
if(time>_start_time-_time_tolerance && time<_end_time+_time_tolerance)
std::ostringstream stream;
stream << REPR << " Time interval is defined by :\niteration_start=" << _start_iteration << " order_start=" << _start_order << " and time_start=" << _start_time << "\n";
stream << "iteration_end=" << _end_iteration << " order_end=" << _end_order << " and end_time=" << _end_time << "\n";
+ stream << "Time unit is : \"" << _time_unit << "\"";
return stream.str();
}
if(!MEDCouplingTimeDiscretization::areCompatible(other))
return false;
const MEDCouplingLinearTime *otherC=dynamic_cast<const MEDCouplingLinearTime *>(other);
- return otherC!=0;
+ if(otherC==0)
+ return false;
+ if(_end_array==0 && otherC->_end_array==0)
+ return true;
+ if(_end_array==0 || otherC->_end_array==0)
+ return false;
+ if(_end_array->getNumberOfComponents()!=otherC->_end_array->getNumberOfComponents())
+ return false;
+ return true;
}
bool MEDCouplingLinearTime::areStrictlyCompatible(const MEDCouplingTimeDiscretization *other) const
return otherC!=0;
}
+bool MEDCouplingLinearTime::areStrictlyCompatibleForDiv(const MEDCouplingTimeDiscretization *other) const
+{
+ if(!MEDCouplingTimeDiscretization::areStrictlyCompatibleForDiv(other))
+ return false;
+ const MEDCouplingLinearTime *otherC=dynamic_cast<const MEDCouplingLinearTime *>(other);
+ if(otherC==0)
+ return false;
+ if(_end_array==0 && otherC->_end_array==0)
+ return true;
+ if(_end_array==0 || otherC->_end_array==0)
+ return false;
+ int nbC1=_end_array->getNumberOfComponents();
+ int nbC2=otherC->_end_array->getNumberOfComponents();
+ if(nbC1!=nbC2 && nbC2!=1)
+ return false;
+ return true;
+}
+
+bool MEDCouplingLinearTime::areCompatibleForMeld(const MEDCouplingTimeDiscretization *other) const
+{
+ if(!MEDCouplingTimeDiscretization::areCompatibleForMeld(other))
+ return false;
+ const MEDCouplingLinearTime *otherC=dynamic_cast<const MEDCouplingLinearTime *>(other);
+ return otherC!=0;
+}
+
/*!
* vals is expected to be of size 2*_array->getNumberOfTuples()==_array->getNumberOfTuples()+_end_array->getNumberOfTuples()
*/
const MEDCouplingLinearTime *otherC=dynamic_cast<const MEDCouplingLinearTime *>(other);
if(!otherC)
throw INTERP_KERNEL::Exception("LinearTime::aggregation on mismatched time discretization !");
- DataArrayDouble *arr1=DataArrayDouble::aggregate(getArray(),other->getArray());
- DataArrayDouble *arr2=DataArrayDouble::aggregate(getEndArray(),other->getEndArray());
+ DataArrayDouble *arr1=DataArrayDouble::Aggregate(getArray(),other->getArray());
+ DataArrayDouble *arr2=DataArrayDouble::Aggregate(getEndArray(),other->getEndArray());
+ MEDCouplingLinearTime *ret=new MEDCouplingLinearTime;
+ ret->setArray(arr1,0);
+ arr1->decrRef();
+ ret->setEndArray(arr2,0);
+ arr2->decrRef();
+ return ret;
+}
+
+MEDCouplingTimeDiscretization *MEDCouplingLinearTime::aggregate(const std::vector<const MEDCouplingTimeDiscretization *>& other) const
+{
+ std::vector<const DataArrayDouble *> a(other.size());
+ std::vector<const DataArrayDouble *> b(other.size());
+ int i=0;
+ for(std::vector<const MEDCouplingTimeDiscretization *>::const_iterator it=other.begin();it!=other.end();it++,i++)
+ {
+ const MEDCouplingLinearTime *itC=dynamic_cast<const MEDCouplingLinearTime *>(*it);
+ if(!itC)
+ throw INTERP_KERNEL::Exception("MEDCouplingLinearTime::aggregate on mismatched time discretization !");
+ a[i]=itC->getArray();
+ b[i]=itC->getEndArray();
+ }
+ DataArrayDouble *arr=DataArrayDouble::Aggregate(a);
+ DataArrayDouble *arr2=DataArrayDouble::Aggregate(b);
+ MEDCouplingLinearTime *ret=new MEDCouplingLinearTime;
+ ret->setArray(arr,0);
+ arr->decrRef();
+ ret->setEndArray(arr2,0);
+ arr2->decrRef();
+ return ret;
+}
+
+MEDCouplingTimeDiscretization *MEDCouplingLinearTime::meld(const MEDCouplingTimeDiscretization *other) const
+{
+ const MEDCouplingLinearTime *otherC=dynamic_cast<const MEDCouplingLinearTime *>(other);
+ if(!otherC)
+ throw INTERP_KERNEL::Exception("LinearTime::meld on mismatched time discretization !");
+ DataArrayDouble *arr1=DataArrayDouble::Meld(getArray(),other->getArray());
+ DataArrayDouble *arr2=DataArrayDouble::Meld(getEndArray(),other->getEndArray());
MEDCouplingLinearTime *ret=new MEDCouplingLinearTime;
ret->setTimeTolerance(getTimeTolerance());
ret->setArray(arr1,0);
const MEDCouplingLinearTime *otherC=dynamic_cast<const MEDCouplingLinearTime *>(other);
if(!otherC)
throw INTERP_KERNEL::Exception("LinearTime::dot on mismatched time discretization !");
- DataArrayDouble *arr1=DataArrayDouble::dot(getArray(),other->getArray());
- DataArrayDouble *arr2=DataArrayDouble::dot(getEndArray(),other->getEndArray());
+ DataArrayDouble *arr1=DataArrayDouble::Dot(getArray(),other->getArray());
+ DataArrayDouble *arr2=DataArrayDouble::Dot(getEndArray(),other->getEndArray());
MEDCouplingLinearTime *ret=new MEDCouplingLinearTime;
ret->setArray(arr1,0);
arr1->decrRef();
const MEDCouplingLinearTime *otherC=dynamic_cast<const MEDCouplingLinearTime *>(other);
if(!otherC)
throw INTERP_KERNEL::Exception("LinearTime::crossProduct on mismatched time discretization !");
- DataArrayDouble *arr1=DataArrayDouble::crossProduct(getArray(),other->getArray());
- DataArrayDouble *arr2=DataArrayDouble::crossProduct(getEndArray(),other->getEndArray());
+ DataArrayDouble *arr1=DataArrayDouble::CrossProduct(getArray(),other->getArray());
+ DataArrayDouble *arr2=DataArrayDouble::CrossProduct(getEndArray(),other->getEndArray());
MEDCouplingLinearTime *ret=new MEDCouplingLinearTime;
ret->setArray(arr1,0);
arr1->decrRef();
if(!otherC)
throw INTERP_KERNEL::Exception("LinearTime::max on mismatched time discretization !");
MEDCouplingLinearTime *ret=new MEDCouplingLinearTime;
- DataArrayDouble *arr1=DataArrayDouble::max(getArray(),other->getArray());
+ DataArrayDouble *arr1=DataArrayDouble::Max(getArray(),other->getArray());
ret->setArray(arr1,0);
arr1->decrRef();
- DataArrayDouble *arr2=DataArrayDouble::max(getEndArray(),other->getEndArray());
+ DataArrayDouble *arr2=DataArrayDouble::Max(getEndArray(),other->getEndArray());
ret->setEndArray(arr2,0);
arr2->decrRef();
return ret;
const MEDCouplingLinearTime *otherC=dynamic_cast<const MEDCouplingLinearTime *>(other);
if(!otherC)
throw INTERP_KERNEL::Exception("LinearTime::min on mismatched time discretization !");
- DataArrayDouble *arr1=DataArrayDouble::min(getArray(),other->getArray());
- DataArrayDouble *arr2=DataArrayDouble::min(getEndArray(),other->getEndArray());
+ DataArrayDouble *arr1=DataArrayDouble::Min(getArray(),other->getArray());
+ DataArrayDouble *arr2=DataArrayDouble::Min(getEndArray(),other->getEndArray());
MEDCouplingLinearTime *ret=new MEDCouplingLinearTime;
ret->setArray(arr1,0);
arr1->decrRef();
const MEDCouplingLinearTime *otherC=dynamic_cast<const MEDCouplingLinearTime *>(other);
if(!otherC)
throw INTERP_KERNEL::Exception("LinearTime::add on mismatched time discretization !");
- DataArrayDouble *arr1=DataArrayDouble::add(getArray(),other->getArray());
- DataArrayDouble *arr2=DataArrayDouble::add(getEndArray(),other->getEndArray());
+ DataArrayDouble *arr1=DataArrayDouble::Add(getArray(),other->getArray());
+ DataArrayDouble *arr2=DataArrayDouble::Add(getEndArray(),other->getEndArray());
MEDCouplingLinearTime *ret=new MEDCouplingLinearTime;
ret->setArray(arr1,0);
arr1->decrRef();
const MEDCouplingLinearTime *otherC=dynamic_cast<const MEDCouplingLinearTime *>(other);
if(!otherC)
throw INTERP_KERNEL::Exception("LinearTime::substract on mismatched time discretization !");
- DataArrayDouble *arr1=DataArrayDouble::substract(getArray(),other->getArray());
- DataArrayDouble *arr2=DataArrayDouble::substract(getEndArray(),other->getEndArray());
+ DataArrayDouble *arr1=DataArrayDouble::Substract(getArray(),other->getArray());
+ DataArrayDouble *arr2=DataArrayDouble::Substract(getEndArray(),other->getEndArray());
MEDCouplingLinearTime *ret=new MEDCouplingLinearTime;
ret->setArray(arr1,0);
arr1->decrRef();
const MEDCouplingLinearTime *otherC=dynamic_cast<const MEDCouplingLinearTime *>(other);
if(!otherC)
throw INTERP_KERNEL::Exception("LinearTime::multiply on mismatched time discretization !");
- DataArrayDouble *arr1=DataArrayDouble::multiply(getArray(),other->getArray());
- DataArrayDouble *arr2=DataArrayDouble::multiply(getEndArray(),other->getEndArray());
+ DataArrayDouble *arr1=DataArrayDouble::Multiply(getArray(),other->getArray());
+ DataArrayDouble *arr2=DataArrayDouble::Multiply(getEndArray(),other->getEndArray());
MEDCouplingLinearTime *ret=new MEDCouplingLinearTime;
ret->setArray(arr1,0);
arr1->decrRef();
const MEDCouplingLinearTime *otherC=dynamic_cast<const MEDCouplingLinearTime *>(other);
if(!otherC)
throw INTERP_KERNEL::Exception("LinearTime::divide on mismatched time discretization !");
- DataArrayDouble *arr1=DataArrayDouble::divide(getArray(),other->getArray());
- DataArrayDouble *arr2=DataArrayDouble::divide(getEndArray(),other->getEndArray());
+ DataArrayDouble *arr1=DataArrayDouble::Divide(getArray(),other->getArray());
+ DataArrayDouble *arr2=DataArrayDouble::Divide(getEndArray(),other->getEndArray());
MEDCouplingLinearTime *ret=new MEDCouplingLinearTime;
ret->setArray(arr1,0);
arr1->decrRef();
MEDCouplingTimeDiscretization();
MEDCouplingTimeDiscretization(const MEDCouplingTimeDiscretization& other, bool deepCpy);
public:
- void updateTime();
+ void updateTime() const;
static MEDCouplingTimeDiscretization *New(TypeOfTimeDiscretization type);
+ void setTimeUnit(const char *unit) { _time_unit=unit; }
+ const char *getTimeUnit() const { return _time_unit.c_str(); }
virtual void copyTinyAttrFrom(const MEDCouplingTimeDiscretization& other);
virtual void copyTinyStringsFrom(const MEDCouplingTimeDiscretization& other);
virtual void checkCoherency() const throw(INTERP_KERNEL::Exception);
virtual bool areCompatible(const MEDCouplingTimeDiscretization *other) const;
virtual bool areStrictlyCompatible(const MEDCouplingTimeDiscretization *other) const;
virtual bool areStrictlyCompatibleForMul(const MEDCouplingTimeDiscretization *other) const;
+ virtual bool areStrictlyCompatibleForDiv(const MEDCouplingTimeDiscretization *other) const;
+ virtual bool areCompatibleForMeld(const MEDCouplingTimeDiscretization *other) const;
virtual bool isEqual(const MEDCouplingTimeDiscretization *other, double prec) const;
virtual bool isEqualWithoutConsideringStr(const MEDCouplingTimeDiscretization *other, double prec) const;
- virtual MEDCouplingTimeDiscretization *buildNewTimeReprFromThis(const MEDCouplingTimeDiscretization *other,
- TypeOfTimeDiscretization type, bool deepCpy) const;
+ virtual MEDCouplingTimeDiscretization *buildNewTimeReprFromThis(TypeOfTimeDiscretization type, bool deepCpy) const;
virtual std::string getStringRepr() const = 0;
virtual TypeOfTimeDiscretization getEnum() const = 0;
virtual MEDCouplingTimeDiscretization *aggregate(const MEDCouplingTimeDiscretization *other) const = 0;
+ virtual MEDCouplingTimeDiscretization *aggregate(const std::vector<const MEDCouplingTimeDiscretization *>& other) const = 0;
+ virtual MEDCouplingTimeDiscretization *meld(const MEDCouplingTimeDiscretization *other) const = 0;
virtual MEDCouplingTimeDiscretization *dot(const MEDCouplingTimeDiscretization *other) const = 0;
virtual MEDCouplingTimeDiscretization *crossProduct(const MEDCouplingTimeDiscretization *other) const = 0;
virtual MEDCouplingTimeDiscretization *max(const MEDCouplingTimeDiscretization *other) const = 0;
virtual void getTinySerializationStrInformation(std::vector<std::string>& tinyInfo) const;
virtual void resizeForUnserialization(const std::vector<int>& tinyInfoI, std::vector<DataArrayDouble *>& arrays);
virtual void finishUnserialization(const std::vector<int>& tinyInfoI, const std::vector<double>& tinyInfoD, const std::vector<std::string>& tinyInfoS);
+ virtual void getTinySerializationIntInformation2(std::vector<int>& tinyInfo) const = 0;
+ virtual void getTinySerializationDbleInformation2(std::vector<double>& tinyInfo) const = 0;
+ virtual void finishUnserialization2(const std::vector<int>& tinyInfoI, const std::vector<double>& tinyInfoD) = 0;
virtual MEDCouplingTimeDiscretization *performCpy(bool deepCpy) const = 0;
void setTimeTolerance(double val) { _time_tolerance=val; }
double getTimeTolerance() const { return _time_tolerance; }
virtual void setArray(DataArrayDouble *array, TimeLabel *owner);
virtual void setEndArray(DataArrayDouble *array, TimeLabel *owner);
virtual void setArrays(const std::vector<DataArrayDouble *>& arrays, TimeLabel *owner) throw(INTERP_KERNEL::Exception);
- DataArrayDouble *getArray() const { return _array; }
- virtual DataArrayDouble *getEndArray() const;
+ DataArrayDouble *getArray() { return _array; }
+ const DataArrayDouble *getArray() const { return _array; }
+ virtual const DataArrayDouble *getEndArray() const;
+ virtual DataArrayDouble *getEndArray();
virtual std::vector< const DataArrayDouble *> getArraysForTime(double time) const throw(INTERP_KERNEL::Exception) = 0;
virtual void getValueForTime(double time, const std::vector<double>& vals, double *res) const = 0;
virtual void getArrays(std::vector<DataArrayDouble *>& arrays) const;
virtual double getStartTime(int& iteration, int& order) const throw(INTERP_KERNEL::Exception) = 0;
virtual double getEndTime(int& iteration, int& order) const throw(INTERP_KERNEL::Exception) = 0;
void setTime(double time, int iteration, int order) throw(INTERP_KERNEL::Exception) { setStartTime(time,iteration,order); }
+ void setIteration(int it) throw(INTERP_KERNEL::Exception) { setStartIteration(it); }
+ void setOrder(int order) throw(INTERP_KERNEL::Exception) { setStartOrder(order); }
+ void setTimeValue(double val) throw(INTERP_KERNEL::Exception) { setStartTimeValue(val); }
+ virtual void setStartIteration(int it) throw(INTERP_KERNEL::Exception) = 0;
+ virtual void setEndIteration(int it) throw(INTERP_KERNEL::Exception) = 0;
+ virtual void setStartOrder(int order) throw(INTERP_KERNEL::Exception) = 0;
+ virtual void setEndOrder(int order) throw(INTERP_KERNEL::Exception) = 0;
+ virtual void setStartTimeValue(double time) throw(INTERP_KERNEL::Exception) = 0;
+ virtual void setEndTimeValue(double time) throw(INTERP_KERNEL::Exception) = 0;
virtual void setStartTime(double time, int iteration, int order) throw(INTERP_KERNEL::Exception) = 0;
virtual void setEndTime(double time, int iteration, int order) throw(INTERP_KERNEL::Exception) = 0;
virtual void getValueOnTime(int eltId, double time, double *value) const throw(INTERP_KERNEL::Exception) = 0;
virtual void applyLin(double a, double b, int compoId);
virtual void applyFunc(int nbOfComp, FunctionToEvaluate func);
virtual void applyFunc(int nbOfComp, const char *func);
+ virtual void applyFunc2(int nbOfComp, const char *func);
+ virtual void applyFunc3(int nbOfComp, const std::vector<std::string>& varsOrder, const char *func);
virtual void applyFunc(const char *func);
virtual void applyFuncFast32(const char *func);
virtual void applyFuncFast64(const char *func);
virtual void fillFromAnalytic(const DataArrayDouble *loc, int nbOfComp, FunctionToEvaluate func) throw(INTERP_KERNEL::Exception);
virtual void fillFromAnalytic(const DataArrayDouble *loc, int nbOfComp, const char *func) throw(INTERP_KERNEL::Exception);
+ virtual void fillFromAnalytic2(const DataArrayDouble *loc, int nbOfComp, const char *func) throw(INTERP_KERNEL::Exception);
+ virtual void fillFromAnalytic3(const DataArrayDouble *loc, int nbOfComp, const std::vector<std::string>& varsOrder, const char *func) throw(INTERP_KERNEL::Exception);
//
virtual ~MEDCouplingTimeDiscretization();
protected:
+ std::string _time_unit;
double _time_tolerance;
DataArrayDouble *_array;
protected:
std::string getStringRepr() const;
TypeOfTimeDiscretization getEnum() const { return DISCRETIZATION; }
MEDCouplingTimeDiscretization *aggregate(const MEDCouplingTimeDiscretization *other) const;
+ MEDCouplingTimeDiscretization *aggregate(const std::vector<const MEDCouplingTimeDiscretization *>& other) const;
+ MEDCouplingTimeDiscretization *meld(const MEDCouplingTimeDiscretization *other) const;
MEDCouplingTimeDiscretization *dot(const MEDCouplingTimeDiscretization *other) const;
MEDCouplingTimeDiscretization *crossProduct(const MEDCouplingTimeDiscretization *other) const;
MEDCouplingTimeDiscretization *max(const MEDCouplingTimeDiscretization *other) const;
bool areCompatible(const MEDCouplingTimeDiscretization *other) const;
bool areStrictlyCompatible(const MEDCouplingTimeDiscretization *other) const;
bool areStrictlyCompatibleForMul(const MEDCouplingTimeDiscretization *other) const;
+ bool areStrictlyCompatibleForDiv(const MEDCouplingTimeDiscretization *other) const;
+ bool areCompatibleForMeld(const MEDCouplingTimeDiscretization *other) const;
MEDCouplingTimeDiscretization *performCpy(bool deepCpy) const;
void checkNoTimePresence() const throw(INTERP_KERNEL::Exception) { }
void checkTimePresence(double time) const throw(INTERP_KERNEL::Exception);
bool isStrictlyBefore(const MEDCouplingTimeDiscretization *other) const throw(INTERP_KERNEL::Exception);
double getStartTime(int& iteration, int& order) const throw(INTERP_KERNEL::Exception);
double getEndTime(int& iteration, int& order) const throw(INTERP_KERNEL::Exception);
+ void setStartIteration(int it) throw(INTERP_KERNEL::Exception);
+ void setEndIteration(int it) throw(INTERP_KERNEL::Exception);
+ void setStartOrder(int order) throw(INTERP_KERNEL::Exception);
+ void setEndOrder(int order) throw(INTERP_KERNEL::Exception);
+ void setStartTimeValue(double time) throw(INTERP_KERNEL::Exception);
+ void setEndTimeValue(double time) throw(INTERP_KERNEL::Exception);
void setStartTime(double time, int iteration, int order) throw(INTERP_KERNEL::Exception);
void setEndTime(double time, int iteration, int order) throw(INTERP_KERNEL::Exception);
void getValueOnTime(int eltId, double time, double *value) const throw(INTERP_KERNEL::Exception);
void getValueOnDiscTime(int eltId, int iteration, int order, double *value) const throw(INTERP_KERNEL::Exception);
+ void getTinySerializationIntInformation2(std::vector<int>& tinyInfo) const;
+ void getTinySerializationDbleInformation2(std::vector<double>& tinyInfo) const;
+ void finishUnserialization2(const std::vector<int>& tinyInfoI, const std::vector<double>& tinyInfoD);
public:
static const TypeOfTimeDiscretization DISCRETIZATION=NO_TIME;
static const char REPR[];
void copyTinyAttrFrom(const MEDCouplingTimeDiscretization& other);
TypeOfTimeDiscretization getEnum() const { return DISCRETIZATION; }
MEDCouplingTimeDiscretization *aggregate(const MEDCouplingTimeDiscretization *other) const;
+ MEDCouplingTimeDiscretization *aggregate(const std::vector<const MEDCouplingTimeDiscretization *>& other) const;
+ MEDCouplingTimeDiscretization *meld(const MEDCouplingTimeDiscretization *other) const;
MEDCouplingTimeDiscretization *dot(const MEDCouplingTimeDiscretization *other) const;
MEDCouplingTimeDiscretization *crossProduct(const MEDCouplingTimeDiscretization *other) const;
MEDCouplingTimeDiscretization *max(const MEDCouplingTimeDiscretization *other) const;
bool areCompatible(const MEDCouplingTimeDiscretization *other) const;
bool areStrictlyCompatible(const MEDCouplingTimeDiscretization *other) const;
bool areStrictlyCompatibleForMul(const MEDCouplingTimeDiscretization *other) const;
+ bool areStrictlyCompatibleForDiv(const MEDCouplingTimeDiscretization *other) const;
+ bool areCompatibleForMeld(const MEDCouplingTimeDiscretization *other) const;
void getTinySerializationIntInformation(std::vector<int>& tinyInfo) const;
void getTinySerializationDbleInformation(std::vector<double>& tinyInfo) const;
void finishUnserialization(const std::vector<int>& tinyInfoI, const std::vector<double>& tinyInfoD, const std::vector<std::string>& tinyInfoS);
+ void getTinySerializationIntInformation2(std::vector<int>& tinyInfo) const;
+ void getTinySerializationDbleInformation2(std::vector<double>& tinyInfo) const;
+ void finishUnserialization2(const std::vector<int>& tinyInfoI, const std::vector<double>& tinyInfoD);
MEDCouplingTimeDiscretization *performCpy(bool deepCpy) const;
void checkNoTimePresence() const throw(INTERP_KERNEL::Exception);
void checkTimePresence(double time) const throw(INTERP_KERNEL::Exception);
void setEndTime(double time, int iteration, int order) throw(INTERP_KERNEL::Exception) { _time=time; _iteration=iteration; _order=order; }
double getStartTime(int& iteration, int& order) const throw(INTERP_KERNEL::Exception) { iteration=_iteration; order=_order; return _time; }
double getEndTime(int& iteration, int& order) const throw(INTERP_KERNEL::Exception) { iteration=_iteration; order=_order; return _time; }
+ void setStartIteration(int it) throw(INTERP_KERNEL::Exception) { _iteration=it; }
+ void setEndIteration(int it) throw(INTERP_KERNEL::Exception) { _iteration=it; }
+ void setStartOrder(int order) throw(INTERP_KERNEL::Exception) { _order=order; }
+ void setEndOrder(int order) throw(INTERP_KERNEL::Exception) { _order=order; }
+ void setStartTimeValue(double time) throw(INTERP_KERNEL::Exception) { _time=time; }
+ void setEndTimeValue(double time) throw(INTERP_KERNEL::Exception) { _time=time; }
std::vector< const DataArrayDouble *> getArraysForTime(double time) const throw(INTERP_KERNEL::Exception);
void getValueForTime(double time, const std::vector<double>& vals, double *res) const;
void getValueOnTime(int eltId, double time, double *value) const throw(INTERP_KERNEL::Exception);
void getTinySerializationIntInformation(std::vector<int>& tinyInfo) const;
void getTinySerializationDbleInformation(std::vector<double>& tinyInfo) const;
void finishUnserialization(const std::vector<int>& tinyInfoI, const std::vector<double>& tinyInfoD, const std::vector<std::string>& tinyInfoS);
+ void getTinySerializationIntInformation2(std::vector<int>& tinyInfo) const;
+ void getTinySerializationDbleInformation2(std::vector<double>& tinyInfo) const;
+ void finishUnserialization2(const std::vector<int>& tinyInfoI, const std::vector<double>& tinyInfoD);
MEDCouplingTimeDiscretization *performCpy(bool deepCpy) const;
bool areCompatible(const MEDCouplingTimeDiscretization *other) const;
bool areStrictlyCompatible(const MEDCouplingTimeDiscretization *other) const;
bool areStrictlyCompatibleForMul(const MEDCouplingTimeDiscretization *other) const;
+ bool areStrictlyCompatibleForDiv(const MEDCouplingTimeDiscretization *other) const;
+ bool areCompatibleForMeld(const MEDCouplingTimeDiscretization *other) const;
bool isEqual(const MEDCouplingTimeDiscretization *other, double prec) const;
bool isEqualWithoutConsideringStr(const MEDCouplingTimeDiscretization *other, double prec) const;
std::vector< const DataArrayDouble *> getArraysForTime(double time) const throw(INTERP_KERNEL::Exception);
TypeOfTimeDiscretization getEnum() const { return DISCRETIZATION; }
std::string getStringRepr() const;
MEDCouplingTimeDiscretization *aggregate(const MEDCouplingTimeDiscretization *other) const;
+ MEDCouplingTimeDiscretization *aggregate(const std::vector<const MEDCouplingTimeDiscretization *>& other) const;
+ MEDCouplingTimeDiscretization *meld(const MEDCouplingTimeDiscretization *other) const;
MEDCouplingTimeDiscretization *dot(const MEDCouplingTimeDiscretization *other) const;
MEDCouplingTimeDiscretization *crossProduct(const MEDCouplingTimeDiscretization *other) const;
MEDCouplingTimeDiscretization *max(const MEDCouplingTimeDiscretization *other) const;
void setEndTime(double time, int iteration, int order) throw(INTERP_KERNEL::Exception) { _end_time=time; _end_iteration=iteration; _end_order=order; }
double getStartTime(int& iteration, int& order) const throw(INTERP_KERNEL::Exception) { iteration=_start_iteration; order=_start_order; return _start_time; }
double getEndTime(int& iteration, int& order) const throw(INTERP_KERNEL::Exception) { iteration=_end_iteration; order=_end_order; return _end_time; }
+ void setStartIteration(int it) throw(INTERP_KERNEL::Exception) { _start_iteration=it; }
+ void setEndIteration(int it) throw(INTERP_KERNEL::Exception) { _end_iteration=it; }
+ void setStartOrder(int order) throw(INTERP_KERNEL::Exception) { _start_order=order; }
+ void setEndOrder(int order) throw(INTERP_KERNEL::Exception) { _end_order=order; }
+ void setStartTimeValue(double time) throw(INTERP_KERNEL::Exception) { _start_time=time; }
+ void setEndTimeValue(double time) throw(INTERP_KERNEL::Exception) { _end_time=time; }
void checkNoTimePresence() const throw(INTERP_KERNEL::Exception);
void checkTimePresence(double time) const throw(INTERP_KERNEL::Exception);
public:
MEDCouplingTwoTimeSteps();
~MEDCouplingTwoTimeSteps();
public:
- void updateTime();
+ void updateTime() const;
void copyTinyAttrFrom(const MEDCouplingTimeDiscretization& other);
void copyTinyStringsFrom(const MEDCouplingTimeDiscretization& other);
- DataArrayDouble *getEndArray() const;
+ const DataArrayDouble *getEndArray() const;
+ DataArrayDouble *getEndArray();
void checkCoherency() const throw(INTERP_KERNEL::Exception);
bool isEqual(const MEDCouplingTimeDiscretization *other, double prec) const;
bool isEqualWithoutConsideringStr(const MEDCouplingTimeDiscretization *other, double prec) const;
void setEndTime(double time, int iteration, int order) throw(INTERP_KERNEL::Exception) { _end_time=time; _end_iteration=iteration; _end_order=order; }
double getStartTime(int& iteration, int& order) const throw(INTERP_KERNEL::Exception) { iteration=_start_iteration; order=_start_order; return _start_time; }
double getEndTime(int& iteration, int& order) const throw(INTERP_KERNEL::Exception) { iteration=_end_iteration; order=_end_order; return _end_time; }
+ void setStartIteration(int it) throw(INTERP_KERNEL::Exception) { _start_iteration=it; }
+ void setEndIteration(int it) throw(INTERP_KERNEL::Exception) { _end_iteration=it; }
+ void setStartOrder(int order) throw(INTERP_KERNEL::Exception) { _start_order=order; }
+ void setEndOrder(int order) throw(INTERP_KERNEL::Exception) { _end_order=order; }
+ void setStartTimeValue(double time) throw(INTERP_KERNEL::Exception) { _start_time=time; }
+ void setEndTimeValue(double time) throw(INTERP_KERNEL::Exception) { _end_time=time; }
void getTinySerializationIntInformation(std::vector<int>& tinyInfo) const;
void getTinySerializationDbleInformation(std::vector<double>& tinyInfo) const;
void getTinySerializationStrInformation(std::vector<std::string>& tinyInfo) const;
void resizeForUnserialization(const std::vector<int>& tinyInfoI, std::vector<DataArrayDouble *>& arrays);
void finishUnserialization(const std::vector<int>& tinyInfoI, const std::vector<double>& tinyInfoD, const std::vector<std::string>& tinyInfoS);
+ void getTinySerializationIntInformation2(std::vector<int>& tinyInfo) const;
+ void getTinySerializationDbleInformation2(std::vector<double>& tinyInfo) const;
+ void finishUnserialization2(const std::vector<int>& tinyInfoI, const std::vector<double>& tinyInfoD);
std::vector< const DataArrayDouble *> getArraysForTime(double time) const throw(INTERP_KERNEL::Exception);
void setArrays(const std::vector<DataArrayDouble *>& arrays, TimeLabel *owner) throw(INTERP_KERNEL::Exception);
protected:
bool areCompatible(const MEDCouplingTimeDiscretization *other) const;
bool areStrictlyCompatible(const MEDCouplingTimeDiscretization *other) const;
bool areStrictlyCompatibleForMul(const MEDCouplingTimeDiscretization *other) const;
+ bool areStrictlyCompatibleForDiv(const MEDCouplingTimeDiscretization *other) const;
+ bool areCompatibleForMeld(const MEDCouplingTimeDiscretization *other) const;
void getValueForTime(double time, const std::vector<double>& vals, double *res) const;
void getValueOnTime(int eltId, double time, double *value) const throw(INTERP_KERNEL::Exception);
void getValueOnDiscTime(int eltId, int iteration, int order, double *value) const throw(INTERP_KERNEL::Exception);
MEDCouplingTimeDiscretization *aggregate(const MEDCouplingTimeDiscretization *other) const;
+ MEDCouplingTimeDiscretization *aggregate(const std::vector<const MEDCouplingTimeDiscretization *>& other) const;
+ MEDCouplingTimeDiscretization *meld(const MEDCouplingTimeDiscretization *other) const;
MEDCouplingTimeDiscretization *dot(const MEDCouplingTimeDiscretization *other) const;
MEDCouplingTimeDiscretization *crossProduct(const MEDCouplingTimeDiscretization *other) const;
MEDCouplingTimeDiscretization *max(const MEDCouplingTimeDiscretization *other) const;
{
}
- TimeLabel& TimeLabel::operator=(const TimeLabel& other)
+TimeLabel& TimeLabel::operator=(const TimeLabel& other)
{
_time=GLOBAL_TIME++;
return *this;
}
-void TimeLabel::declareAsNew()
+void TimeLabel::declareAsNew() const
{
_time=GLOBAL_TIME++;
}
-void TimeLabel::updateTimeWith(const TimeLabel& other)
+void TimeLabel::updateTimeWith(const TimeLabel& other) const
{
if(_time<other._time)
_time=other._time;
public:
TimeLabel& operator=(const TimeLabel& other);
//! This method should be called when write access has been done on this.
- void declareAsNew();
+ void declareAsNew() const;
//! This method should be called on high level classes as Field or Mesh to take into acount modifications done in aggragates objects.
- virtual void updateTime() = 0;
+ virtual void updateTime() const = 0;
unsigned int getTimeOfThis() const { return _time; }
protected:
TimeLabel();
virtual ~TimeLabel();
- void updateTimeWith(const TimeLabel& other);
+ void updateTimeWith(const TimeLabel& other) const;
private:
static unsigned int GLOBAL_TIME;
- unsigned int _time;
+ mutable unsigned int _time;
};
}
#include "InterpKernelCellSimplify.hxx"
#include "InterpKernelGeo2DEdgeArcCircle.hxx"
#include "MEDCouplingAutoRefCountObjectPtr.hxx"
+#include "InterpKernelAutoPtr.hxx"
#include <sstream>
#include <numeric>
return new MEDCouplingUMesh(*this,recDeepCpy);
}
-void MEDCouplingUMesh::updateTime()
+void MEDCouplingUMesh::updateTime() const
{
MEDCouplingPointSet::updateTime();
if(_nodal_connec)
}
}
+/*!
+ * This method performs deeper checking in 'this' than MEDCouplingUMesh::checkCoherency does.
+ * So this method is more time-consuming. This method checks that nodal connectivity points to valid node ids.
+ * No geometrical aspects are checked here. These aspects are done in MEDCouplingUMesh::checkCoherency2.
+ */
+void MEDCouplingUMesh::checkCoherency1(double eps) const throw(INTERP_KERNEL::Exception)
+{
+ checkCoherency();
+ if(_mesh_dim==-1)
+ return ;
+ int meshDim=getMeshDimension();
+ int nbOfNodes=getNumberOfNodes();
+ int nbOfCells=getNumberOfCells();
+ const int *ptr=_nodal_connec->getConstPointer();
+ const int *ptrI=_nodal_connec_index->getConstPointer();
+ for(int i=0;i<nbOfCells;i++)
+ {
+ const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::getCellModel((INTERP_KERNEL::NormalizedCellType)ptr[ptrI[i]]);
+ if((int)cm.getDimension()!=meshDim)
+ {
+ std::ostringstream oss;
+ oss << "MEDCouplingUMesh::checkCoherency1 : cell << #" << i<< " with type Type " << cm.getRepr() << " in 'this' whereas meshdim == " << meshDim << " !";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ int nbOfNodesInCell=ptrI[i+1]-ptrI[i]-1;
+ if(!cm.isDynamic())
+ if(nbOfNodesInCell!=(int)cm.getNumberOfNodes())
+ {
+ std::ostringstream oss;
+ oss << "MEDCouplingUMesh::checkCoherency1 : cell #" << i << " with static Type '" << cm.getRepr() << "' has " << cm.getNumberOfNodes();
+ oss << " nodes whereas in connectivity there is " << nbOfNodesInCell << " nodes ! Looks very bad !";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ for(const int *w=ptr+ptrI[i]+1;w!=ptr+ptrI[i+1];w++)
+ {
+ int nodeId=*w;
+ if(nodeId>=0)
+ {
+ if(nodeId>=nbOfNodes)
+ {
+ std::ostringstream oss; oss << "Cell #" << i << " is consituted of node #" << nodeId << " whereas there are only " << nbOfNodes << " nodes !";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ }
+ else if(nodeId<-1)
+ {
+ std::ostringstream oss; oss << "Cell #" << i << " is consituted of node #" << nodeId << " in connectivity ! sounds bad !";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ else
+ {
+ if((INTERP_KERNEL::NormalizedCellType)(ptr[ptrI[i]])!=INTERP_KERNEL::NORM_POLYHED)
+ {
+ std::ostringstream oss; oss << "Cell #" << i << " is consituted of node #-1 in connectivity ! sounds bad !";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ }
+ }
+ }
+}
+
+void MEDCouplingUMesh::checkCoherency2(double eps) const throw(INTERP_KERNEL::Exception)
+{
+ checkCoherency1(eps);
+}
+
void MEDCouplingUMesh::setMeshDimension(int meshDim)
{
if(meshDim<-1)
* @param size number of nodes constituting this cell.
* @param nodalConnOfCell the connectivity of the cell to add.
*/
-void MEDCouplingUMesh::insertNextCell(INTERP_KERNEL::NormalizedCellType type, int size, const int *nodalConnOfCell)
+void MEDCouplingUMesh::insertNextCell(INTERP_KERNEL::NormalizedCellType type, int size, const int *nodalConnOfCell) throw(INTERP_KERNEL::Exception)
{
- int *pt=_nodal_connec_index->getPointer();
- int idx=pt[_iterator];
-
- _nodal_connec->writeOnPlace(idx,type,nodalConnOfCell,size);
- _types.insert(type);
- pt[++_iterator]=idx+size+1;
+ const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::getCellModel(type);
+ if(_nodal_connec_index==0)
+ throw INTERP_KERNEL::Exception("MEDCouplingUMesh::insertNextCell : nodal connectivity not set ! invoke allocateCells before calling insertNextCell !");
+ if((int)cm.getDimension()==_mesh_dim)
+ {
+ int nbOfElems=_nodal_connec_index->getNbOfElems()-1;
+ if(_iterator>=nbOfElems)
+ throw INTERP_KERNEL::Exception("MEDCouplingUMesh::insertNextCell : allocation of cells was wide enough ! Call insertNextCell with higher value or call finishInsertingCells !");
+ int *pt=_nodal_connec_index->getPointer();
+ int idx=pt[_iterator];
+
+ _nodal_connec->writeOnPlace(idx,type,nodalConnOfCell,size);
+ _types.insert(type);
+ pt[++_iterator]=idx+size+1;
+ }
+ else
+ {
+ std::ostringstream oss; oss << "MEDCouplingUMesh::insertNextCell : cell type " << cm.getRepr() << " has a dimension " << cm.getDimension();
+ oss << " whereas Mesh Dimension of current UMesh instance is set to " << _mesh_dim << " ! Please invoke \"setMeshDimension\" method before or invoke ";
+ oss << "\"MEDCouplingUMesh::New\" static method with 2 parameters name and meshDimension !";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
}
/*!
MEDCouplingMesh::checkFastEquivalWith(other,prec);
if(_types!=otherC->_types)
throw INTERP_KERNEL::Exception("checkDeepEquivalWith : Types are not equal !");
- MEDCouplingAutoRefCountObjectPtr<MEDCouplingUMesh> m=mergeUMeshes(this,otherC);
+ MEDCouplingAutoRefCountObjectPtr<MEDCouplingUMesh> m=MergeUMeshes(this,otherC);
bool areNodesMerged;
int newNbOfNodes;
int oldNbOfNodes=getNumberOfNodes();
* This method looks if 'this' and 'other' are geometrically equivalent that is to say if each cell in 'other' correspond to one cell and only one
* in 'this' is found regarding 'prec' parameter and 'cellCompPol' parameter. The difference with MEDCouplingUMesh::checkDeepEquivalWith method is that
* coordinates of 'this' and 'other' are expected to be the same. If not an exception will be thrown.
+ * This method is close to MEDCouplingUMesh::areCellsIncludedIn except that this method throws exception !
*
* In case of success cellCor are informed both.
* @param cellCompPol values are described in MEDCouplingUMesh::zipConnectivityTraducer method.
throw INTERP_KERNEL::Exception("checkDeepEquivalOnSameNodesWith : Types are not equal !");
if(_coords!=otherC->_coords)
throw INTERP_KERNEL::Exception("checkDeepEquivalOnSameNodesWith : meshes do not share the same coordinates ! Use tryToShareSameCoordinates or call checkDeepEquivalWith !");
- std::vector<MEDCouplingUMesh *> ms(2);
- ms[0]=const_cast<MEDCouplingUMesh *>(this);
- ms[1]=const_cast<MEDCouplingUMesh *>(otherC);
- MEDCouplingAutoRefCountObjectPtr<MEDCouplingUMesh> m=mergeUMeshesOnSameCoords(ms);
+ std::vector<const MEDCouplingUMesh *> ms(2);
+ ms[0]=this;
+ ms[1]=otherC;
+ MEDCouplingAutoRefCountObjectPtr<MEDCouplingUMesh> m=MergeUMeshesOnSameCoords(ms);
MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da=m->zipConnectivityTraducer(cellCompPol);
int maxId=*std::max_element(da->getConstPointer(),da->getConstPointer()+getNumberOfCells());
const int *pt=std::find_if(da->getConstPointer()+getNumberOfCells(),da->getConstPointer()+da->getNbOfElems(),std::bind2nd(std::greater<int>(),maxId));
* \b WARNING this method do the assumption that connectivity lies on the coordinates set.
* For speed reasons no check of this will be done.
*/
-void MEDCouplingUMesh::getReverseNodalConnectivity(DataArrayInt *revNodal, DataArrayInt *revNodalIndx) const
+void MEDCouplingUMesh::getReverseNodalConnectivity(DataArrayInt *revNodal, DataArrayInt *revNodalIndx) const throw(INTERP_KERNEL::Exception)
{
checkFullyDefined();
int nbOfNodes=getNumberOfNodes();
* \b WARNING this method do the assumption that connectivity lies on the coordinates set.
* For speed reasons no check of this will be done.
*/
-MEDCouplingUMesh *MEDCouplingUMesh::buildDescendingConnectivity(DataArrayInt *desc, DataArrayInt *descIndx, DataArrayInt *revDesc, DataArrayInt *revDescIndx) const
+MEDCouplingUMesh *MEDCouplingUMesh::buildDescendingConnectivity(DataArrayInt *desc, DataArrayInt *descIndx, DataArrayInt *revDesc, DataArrayInt *revDescIndx) const throw(INTERP_KERNEL::Exception)
{
checkFullyDefined();
int nbOfCells=getNumberOfCells();
computeTypes();
}
+/*!
+ * This method converts all cells into poly type if possible.
+ * This method is purely for userfriendliness.
+ * As this method can be costly in Memory, no optimization is done to avoid construction of useless vector.
+ */
+void MEDCouplingUMesh::convertAllToPoly()
+{
+ int nbOfCells=getNumberOfCells();
+ std::vector<int> cellIds(nbOfCells);
+ for(int i=0;i<nbOfCells;i++)
+ cellIds[i]=i;
+ convertToPolyTypes(cellIds);
+}
+
/*!
* This method is the opposite of ParaMEDMEM::MEDCouplingUMesh::convertToPolyTypes method.
* The aim is to take all polygons or polyhedrons cell and to try to traduce them into classical cells.
{
if(cm.getDimension()==2)
{
- int *tmp=new int[lgthOfCurCell-1];
- std::copy(conn+posOfCurCell+1,conn+posOfCurCell+lgthOfCurCell,tmp);
+ INTERP_KERNEL::AutoPtr<int> tmp=new int[lgthOfCurCell-1];
+ std::copy(conn+posOfCurCell+1,conn+posOfCurCell+lgthOfCurCell,(int *)tmp);
newType=INTERP_KERNEL::CellSimplify::tryToUnPoly2D(tmp,lgthOfCurCell-1,conn+newPos+1,newLgth);
- delete [] tmp;
}
if(cm.getDimension()==3)
{
int nbOfFaces,lgthOfPolyhConn;
- int *zipFullReprOfPolyh=INTERP_KERNEL::CellSimplify::getFullPolyh3DCell(type,conn+posOfCurCell+1,lgthOfCurCell-1,nbOfFaces,lgthOfPolyhConn);
+ INTERP_KERNEL::AutoPtr<int> zipFullReprOfPolyh=INTERP_KERNEL::CellSimplify::getFullPolyh3DCell(type,conn+posOfCurCell+1,lgthOfCurCell-1,nbOfFaces,lgthOfPolyhConn);
newType=INTERP_KERNEL::CellSimplify::tryToUnPoly3D(zipFullReprOfPolyh,nbOfFaces,lgthOfPolyhConn,conn+newPos+1,newLgth);
- delete [] zipFullReprOfPolyh;
}
conn[newPos]=newType;
newPos+=newLgth+1;
posOfCurCell=index[i+1];
index[i+1]=newPos;
}
+ else
+ {
+ std::copy(conn+posOfCurCell,conn+posOfCurCell+lgthOfCurCell,conn+newPos);
+ newPos+=lgthOfCurCell;
+ posOfCurCell+=lgthOfCurCell;
+ index[i+1]=newPos;
+ }
}
if(newPos!=initMeshLgth)
_nodal_connec->reAlloc(newPos);
* The size of returned array is the number of nodes of the old (previous to the call of this method) number of nodes.
* -1 values in returned array means that the corresponding old node is no more used.
*/
-DataArrayInt *MEDCouplingUMesh::zipCoordsTraducer()
+DataArrayInt *MEDCouplingUMesh::zipCoordsTraducer() throw(INTERP_KERNEL::Exception)
{
int nbOfNodes=getNumberOfNodes();
DataArrayInt *ret=DataArrayInt::New();
* 2 : nodal. cell1 and cell2 are equal if and only if cell1 and cell2 have same type and have the same nodes constituting connectivity. This is the laziest policy.
* @return the correspondance array old to new.
*/
-DataArrayInt *MEDCouplingUMesh::zipConnectivityTraducer(int compType)
+DataArrayInt *MEDCouplingUMesh::zipConnectivityTraducer(int compType) throw(INTERP_KERNEL::Exception)
{
int spaceDim=getSpaceDimension();
int nbOfCells=getNumberOfCells();
return ret;
}
+/*!
+ * This method makes the assumption that 'this' and 'other' share the same coords. If not an exception will be thrown !
+ * This method tries to determine if 'other' is fully included in 'this'. To compute that, this method works with connectivity as MEDCouplingUMesh::zipConnectivityTraducer method does.
+ * This method is close to MEDCouplingUMesh::checkDeepEquivalOnSameNodesWith or MEDCouplingMesh::checkGeoEquivalWith with policy 20,21,or 22.
+ * The main difference is that this method is not expected to throw exception.
+ * This method has two outputs :
+ *
+ * @param compType is the comparison type. The possible values of this parameter are described in ParaMEDMEM::MEDCouplingUMesh::zipConnectivityTraducer method
+ * @param arr is an output parameter that returns a \b newly created instance. This array is of size 'other->getNumberOfCells()'.
+ * @return If 'other' is fully included in 'this 'true is returned. If not false is returned.
+ */
+bool MEDCouplingUMesh::areCellsIncludedIn(const MEDCouplingUMesh *other, int compType, DataArrayInt *& arr) const throw(INTERP_KERNEL::Exception)
+{
+ MEDCouplingAutoRefCountObjectPtr<MEDCouplingUMesh> mesh=MergeUMeshesOnSameCoords(this,other);
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> o2n=mesh->zipConnectivityTraducer(compType);
+ int nbOfCells=getNumberOfCells();
+ arr=o2n->substr(nbOfCells);
+ arr->setName(other->getName());
+ int tmp;
+ if(other->getNumberOfCells()==0)
+ return true;
+ return arr->getMaxValue(tmp)<nbOfCells;
+}
+
/*!
* @param areNodesMerged if at least two nodes have been merged.
* @return old to new node correspondance.
return ret;
}
+/*!
+ * Idem ParaMEDMEM::MEDCouplingUMesh::mergeNodes method except that the merged nodes are meld into the barycenter of them.
+ */
+DataArrayInt *MEDCouplingUMesh::mergeNodes2(double precision, bool& areNodesMerged, int& newNbOfNodes)
+{
+ DataArrayInt *ret=buildPermArrayForMergeNode(-1,precision,areNodesMerged,newNbOfNodes);
+ if(areNodesMerged)
+ renumberNodes2(ret->getConstPointer(),newNbOfNodes);
+ return ret;
+}
+
/*!
* This method tries to use 'other' coords and use it for 'this'. If no exception was thrown after the call of this method :
- * this->_coords==other->_coords. If not a exception is thrown this remains unchanged.
+ * this->_coords==other->_coords. If an exception is thrown 'this' remains unchanged.
+ * Contrary to MEDCouplingUMesh::tryToShareSameCoords method this method makes a deeper analyze of coordinates (and so more expensive) than simple equality.
+ * Two nodes one in 'this' and other in 'other' are considered equal if the distance between the two is lower than epsilon.
*/
void MEDCouplingUMesh::tryToShareSameCoordsPermute(const MEDCouplingPointSet& other, double epsilon) throw(INTERP_KERNEL::Exception)
{
- DataArrayDouble *coords=other.getCoords();
+ const DataArrayDouble *coords=other.getCoords();
if(!coords)
throw INTERP_KERNEL::Exception("tryToShareSameCoordsPermute : No coords specified in other !");
if(!_coords)
throw INTERP_KERNEL::Exception("tryToShareSameCoordsPermute : No coords specified in this whereas there is any in other !");
int otherNbOfNodes=other.getNumberOfNodes();
- MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> newCoords=mergeNodesArray(&other,this);
+ MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> newCoords=MergeNodesArray(&other,this);
_coords->incrRef();
MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> oldCoords=_coords;
setCoords(newCoords);
* build a sub part of 'this'. This sub part is defined by the cell ids contained in the array in [begin,end).
* @param begin begin of array containing the cell ids to keep.
* @param end end of array of cell ids to keep. \b WARNING end param is \b not included ! Idem STL standard definitions.
- * @param keepCoords that specifies if you want or not to keep coords as this or zip it (see zipCoords)
+ * @param keepCoords that specifies if you want or not to keep coords as this or zip it (see ParaMEDMEM::MEDCouplingUMesh::zipCoords). If true zipCoords is \b NOT called, if false, zipCoords is called.
*/
MEDCouplingPointSet *MEDCouplingUMesh::buildPartOfMySelf(const int *begin, const int *end, bool keepCoords) const
{
}
}
+/*!
+ * This method is very close too MEDCouplingUMesh::buildPartOfMySelfNode. The difference is that it returns directly ids.
+ */
+DataArrayInt *MEDCouplingUMesh::getCellIdsLyingOnNodes(const int *begin, const int *end, bool fullyIn) const
+{
+ std::vector<int> cellIdsKept;
+ fillCellIdsToKeepFromNodeIds(begin,end,fullyIn,cellIdsKept);
+ DataArrayInt *ret=DataArrayInt::New();
+ ret->alloc(cellIdsKept.size(),1);
+ std::copy(cellIdsKept.begin(),cellIdsKept.end(),ret->getPointer());
+ ret->setName(getName());
+ return ret;
+}
+
/*!
* Keeps from 'this' only cells which constituing point id are in the ids specified by ['begin','end').
* The return newly allocated mesh will share the same coordinates as 'this'.
/*!
* This method returns a mesh with meshDim=this->getMeshDimension()-1.
* This returned mesh contains cells that are linked with one and only one cell of this.
- * @param keepCoords specifies if zipCoords is called on returned mesh before being returned.
+ * @param keepCoords specifies if ParaMEDMEM::MEDCouplingUMesh::zipCoords is called on returned mesh before being returned. If true zipCoords is \b NOT called, if false, zipCoords is called.
* @return mesh with ref counter equal to 1.
*/
MEDCouplingPointSet *MEDCouplingUMesh::buildBoundaryMesh(bool keepCoords) const
return ret;
}
+/*!
+ * This method returns a newly created DataArrayInt instance containing ids of cells located in boundary.
+ * A cell is detected to be on boundary if it contains one or more than one face having only one father.
+ * This method makes the assumption that 'this' is fully defined (coords,connectivity). If not an exception will be thrown.
+ */
+DataArrayInt *MEDCouplingUMesh::findCellsIdsOnBoundary() const throw(INTERP_KERNEL::Exception)
+{
+ checkFullyDefined();
+ DataArrayInt *desc=DataArrayInt::New();
+ DataArrayInt *descIndx=DataArrayInt::New();
+ DataArrayInt *revDesc=DataArrayInt::New();
+ DataArrayInt *revDescIndx=DataArrayInt::New();
+ //
+ MEDCouplingUMesh *meshDM1=buildDescendingConnectivity(desc,descIndx,revDesc,revDescIndx);
+ meshDM1->decrRef();
+ desc->decrRef();
+ descIndx->decrRef();
+ //
+ DataArrayInt *tmp=revDescIndx->deltaShiftIndex();
+ DataArrayInt *faceIds=tmp->getIdsEqual(1);
+ tmp->decrRef();
+ int nbOfFaces=faceIds->getNumberOfTuples();
+ const int *faces=faceIds->getConstPointer();
+ std::set<int> ret;
+ for(const int *w=faces;w!=faces+nbOfFaces;w++)
+ ret.insert(revDesc->getIJ(revDescIndx->getIJ(*w,0),0));
+ faceIds->decrRef();
+ //
+ revDescIndx->decrRef();
+ revDesc->decrRef();
+ //
+ DataArrayInt *ret2=DataArrayInt::New();
+ ret2->alloc(ret.size(),1);
+ std::copy(ret.begin(),ret.end(),ret2->getPointer());
+ ret2->setName("BoundaryCells");
+ return ret2;
+}
+
/*!
* This methods returns set of nodes lying on the boundary of this.
*/
meshDM1->decrRef();
}
+MEDCouplingUMesh *MEDCouplingUMesh::buildUnstructured() const throw(INTERP_KERNEL::Exception)
+{
+ incrRef();
+ return const_cast<MEDCouplingUMesh *>(this);
+}
+
/*
* This method renumber 'this' using 'newNodeNumbers' array of size this->getNumberOfNodes.
* newNbOfNodes specifies the *std::max_element(newNodeNumbers,newNodeNumbers+this->getNumberOfNodes())
renumberNodesInConn(newNodeNumbers);
}
+/*
+ * This method renumber 'this' using 'newNodeNumbers' array of size this->getNumberOfNodes.
+ * newNbOfNodes specifies the *std::max_element(newNodeNumbers,newNodeNumbers+this->getNumberOfNodes())
+ * This value is asked because often known by the caller of this method.
+ * This method, contrary to MEDCouplingMesh::renumberCells does NOT conserve the number of nodes before and after.
+ * The difference with ParaMEDMEM::MEDCouplingUMesh::renumberNodes method is in the fact that the barycenter of merged nodes is computed here.
+ *
+ * @param newNodeNumbers array specifying the new numbering.
+ * @param newNbOfNodes the new number of nodes.
+ */
+void MEDCouplingUMesh::renumberNodes2(const int *newNodeNumbers, int newNbOfNodes)
+{
+ MEDCouplingPointSet::renumberNodes2(newNodeNumbers,newNbOfNodes);
+ renumberNodesInConn(newNodeNumbers);
+}
+
/*!
* This method renumbers nodes in connectivity only without any reference with coords.
* Use it with care !
int nbCells=getNumberOfCells();
const int *array=old2NewBg;
if(check)
- array=DataArrayInt::checkAndPreparePermutation(old2NewBg,old2NewBg+nbCells);
+ array=DataArrayInt::CheckAndPreparePermutation(old2NewBg,old2NewBg+nbCells);
//
const int *conn=_nodal_connec->getConstPointer();
const int *connI=_nodal_connec_index->getConstPointer();
* Warning 'elems' is incremented during the call so if elems is not empty before call returned elements will be
* added in 'elems' parameter.
*/
-void MEDCouplingUMesh::giveElemsInBoundingBox(const double *bbox, double eps, std::vector<int>& elems)
+void MEDCouplingUMesh::getCellsInBoundingBox(const double *bbox, double eps, std::vector<int>& elems)
{
if(getMeshDimension()==-1)
{
}
/*!
- * Given a boundary box 'bbox' returns elements 'elems' contained in this 'bbox'.
+ * Given a boundary box 'bbox' returns elements 'elems' contained in this 'bbox' or touching 'bbox' (within 'eps' distance).
* Warning 'elems' is incremented during the call so if elems is not empty before call returned elements will be
* added in 'elems' parameter.
*/
-void MEDCouplingUMesh::giveElemsInBoundingBox(const INTERP_KERNEL::DirectedBoundingBox& bbox, double eps, std::vector<int>& elems)
+void MEDCouplingUMesh::getCellsInBoundingBox(const INTERP_KERNEL::DirectedBoundingBox& bbox, double eps, std::vector<int>& elems)
{
if(getMeshDimension()==-1)
{
static const char msg0[]="No coordinates specified !";
std::ostringstream ret;
ret << "Unstructured mesh with name : \"" << getName() << "\"\n";
+ ret << "Description of mesh : \"" << getDescription() << "\"\n";
+ int tmpp1,tmpp2;
+ double tt=getTime(tmpp1,tmpp2);
+ ret << "Time attached to the mesh [unit] : " << tt << " [" << getTimeUnit() << "]\n";
+ ret << "Iteration : " << tmpp1 << " Order : " << tmpp2 << "\n";
ret << "Mesh dimension : " << _mesh_dim << "\nSpace dimension : ";
if(_coords!=0)
{
return std::count_if(pt+ptI[cellId]+1,pt+ptI[cellId+1],std::bind2nd(std::not_equal_to<int>(),-1));
}
+/*!
+ * This method is equivalent to MEDCouplingUMesh::getAllTypes excecpt that it returns only types of submesh which cell ids are in [begin,end).
+ * This method avoids to compute explicitely submesh to get its types.
+ */
+std::set<INTERP_KERNEL::NormalizedCellType> MEDCouplingUMesh::getTypesOfPart(const int *begin, const int *end) const throw(INTERP_KERNEL::Exception)
+{
+ checkFullyDefined();
+ std::set<INTERP_KERNEL::NormalizedCellType> ret;
+ const int *conn=_nodal_connec->getConstPointer();
+ const int *connIndex=_nodal_connec_index->getConstPointer();
+ for(const int *w=begin;w!=end;w++)
+ ret.insert((INTERP_KERNEL::NormalizedCellType)conn[connIndex[*w]]);
+ return ret;
+}
+
/*!
* Method reserved for advanced users having prepared their connectivity before.
* Arrays 'conn' and 'connIndex' will be aggregated without any copy and their counter will be incremented.
*/
void MEDCouplingUMesh::setConnectivity(DataArrayInt *conn, DataArrayInt *connIndex, bool isComputingTypes)
{
- DataArrayInt::setArrayIn(conn,_nodal_connec);
- DataArrayInt::setArrayIn(connIndex,_nodal_connec_index);
+ DataArrayInt::SetArrayIn(conn,_nodal_connec);
+ DataArrayInt::SetArrayIn(connIndex,_nodal_connec_index);
if(isComputingTypes)
computeTypes();
declareAsNew();
/*!
* First step of serialization process. Used by ParaMEDMEM and MEDCouplingCorba to transfert data between process.
*/
-void MEDCouplingUMesh::getTinySerializationInformation(std::vector<int>& tinyInfo, std::vector<std::string>& littleStrings) const
+void MEDCouplingUMesh::getTinySerializationInformation(std::vector<double>& tinyInfoD, std::vector<int>& tinyInfo, std::vector<std::string>& littleStrings) const
{
- MEDCouplingPointSet::getTinySerializationInformation(tinyInfo,littleStrings);
+ MEDCouplingPointSet::getTinySerializationInformation(tinyInfoD,tinyInfo,littleStrings);
tinyInfo.push_back(getMeshDimension());
tinyInfo.push_back(getNumberOfCells());
if(_nodal_connec)
*/
bool MEDCouplingUMesh::isEmptyMesh(const std::vector<int>& tinyInfo) const
{
- return tinyInfo[4]<=0;
+ return tinyInfo[6]<=0;
}
/*!
{
MEDCouplingPointSet::resizeForUnserialization(tinyInfo,a1,a2,littleStrings);
if(tinyInfo[5]!=-1)
- a1->alloc(tinyInfo[5]+tinyInfo[4]+1,1);
+ a1->alloc(tinyInfo[7]+tinyInfo[6]+1,1);
}
/*!
* Second and final unserialization process.
* @param tinyInfo must be equal to the result given by getTinySerializationInformation method.
*/
-void MEDCouplingUMesh::unserialization(const std::vector<int>& tinyInfo, const DataArrayInt *a1, DataArrayDouble *a2, const std::vector<std::string>& littleStrings)
+void MEDCouplingUMesh::unserialization(const std::vector<double>& tinyInfoD, const std::vector<int>& tinyInfo, const DataArrayInt *a1, DataArrayDouble *a2, const std::vector<std::string>& littleStrings)
{
- MEDCouplingPointSet::unserialization(tinyInfo,a1,a2,littleStrings);
- setMeshDimension(tinyInfo[3]);
- if(tinyInfo[5]!=-1)
+ MEDCouplingPointSet::unserialization(tinyInfoD,tinyInfo,a1,a2,littleStrings);
+ setMeshDimension(tinyInfo[5]);
+ if(tinyInfo[7]!=-1)
{
// Connectivity
const int *recvBuffer=a1->getConstPointer();
DataArrayInt* myConnecIndex=DataArrayInt::New();
- myConnecIndex->alloc(tinyInfo[4]+1,1);
- std::copy(recvBuffer,recvBuffer+tinyInfo[4]+1,myConnecIndex->getPointer());
+ myConnecIndex->alloc(tinyInfo[6]+1,1);
+ std::copy(recvBuffer,recvBuffer+tinyInfo[6]+1,myConnecIndex->getPointer());
DataArrayInt* myConnec=DataArrayInt::New();
- myConnec->alloc(tinyInfo[5],1);
- std::copy(recvBuffer+tinyInfo[4]+1,recvBuffer+tinyInfo[4]+1+tinyInfo[5],myConnec->getPointer());
+ myConnec->alloc(tinyInfo[7],1);
+ std::copy(recvBuffer+tinyInfo[6]+1,recvBuffer+tinyInfo[6]+1+tinyInfo[7],myConnec->getPointer());
setConnectivity(myConnec, myConnecIndex) ;
myConnec->decrRef();
myConnecIndex->decrRef();
{
checkFullyDefined();
MEDCouplingUMesh *ret=MEDCouplingUMesh::New();
- std::string name(getName());
- int sz=strlen(PART_OF_NAME);
- if((int)name.length()>=sz)
- name=name.substr(0,sz);
- if(name!=PART_OF_NAME)
- {
- std::ostringstream stream; stream << PART_OF_NAME << getName();
- ret->setName(stream.str().c_str());
- }
- else
- ret->setName(getName());
ret->_mesh_dim=_mesh_dim;
ret->setCoords(_coords);
int nbOfElemsRet=end-begin;
ret->_types=types;
connRetArr->decrRef();
connIndexRetArr->decrRef();
+ ret->copyTinyInfoFrom(this);
+ std::string name(getName());
+ int sz=strlen(PART_OF_NAME);
+ if((int)name.length()>=sz)
+ name=name.substr(0,sz);
+ if(name!=PART_OF_NAME)
+ {
+ std::ostringstream stream; stream << PART_OF_NAME << getName();
+ ret->setName(stream.str().c_str());
+ }
+ else
+ ret->setName(getName());
return ret;
}
return field;
}
+/*!
+ * This method is equivalent to MEDCouplingUMesh::getMeasureField except that only part defined by [begin,end) is returned !
+ * This method avoids to build explicitely part of this to perform the work.
+ */
+DataArrayDouble *MEDCouplingUMesh::getPartMeasureField(bool isAbs, const int *begin, const int *end) const
+{
+ std::string name="PartMeasureOfMesh_";
+ name+=getName();
+ int nbelem=std::distance(begin,end);
+ DataArrayDouble* array=DataArrayDouble::New();
+ array->setName(name.c_str());
+ array->alloc(nbelem,1);
+ double *area_vol=array->getPointer();
+ if(getMeshDimension()!=-1)
+ {
+ int ipt;
+ INTERP_KERNEL::NormalizedCellType type;
+ int dim_space=getSpaceDimension();
+ const double *coords=getCoords()->getConstPointer();
+ const int *connec=getNodalConnectivity()->getConstPointer();
+ const int *connec_index=getNodalConnectivityIndex()->getConstPointer();
+ for(const int *iel=begin;iel!=end;iel++)
+ {
+ ipt=connec_index[*iel];
+ type=(INTERP_KERNEL::NormalizedCellType)connec[ipt];
+ *area_vol++=INTERP_KERNEL::computeVolSurfOfCell2<int,INTERP_KERNEL::ALL_C_MODE>(type,connec+ipt+1,connec_index[*iel+1]-ipt-1,coords,dim_space);
+ }
+ if(isAbs)
+ std::transform(array->getPointer(),area_vol,array->getPointer(),std::ptr_fun<double,double>(fabs));
+ }
+ else
+ {
+ area_vol[0]=std::numeric_limits<double>::max();
+ }
+ return array;
+}
+
/*!
* This methods returns a field on nodes and no time. This method is usefull to check "P1*" conservative interpolators.
* This field returns the getMeasureField of the dualMesh in P1 sens of 'this'.
*/
MEDCouplingFieldDouble *MEDCouplingUMesh::buildOrthogonalField() const
{
- if(getMeshDimension()!=2)
- throw INTERP_KERNEL::Exception("Expected a umesh with meshDim == 2 !");
+ if((getMeshDimension()!=2) && (getMeshDimension()!=1 || getSpaceDimension()!=2))
+ throw INTERP_KERNEL::Exception("Expected a umesh with ( meshDim == 2 spaceDim == 2 or 3 ) or ( meshDim == 1 spaceDim == 2 ) !");
MEDCouplingFieldDouble *ret=MEDCouplingFieldDouble::New(ON_CELLS,NO_TIME);
DataArrayDouble *array=DataArrayDouble::New();
int nbOfCells=getNumberOfCells();
- array->alloc(nbOfCells,3);
+ int nbComp=getMeshDimension()+1;
+ array->alloc(nbOfCells,nbComp);
double *vals=array->getPointer();
const int *connI=_nodal_connec_index->getConstPointer();
const int *conn=_nodal_connec->getConstPointer();
const double *coords=_coords->getConstPointer();
- DataArrayDouble *loc=getBarycenterAndOwner();
- const double *locPtr=loc->getConstPointer();
- if(getSpaceDimension()==3)
+ if(getMeshDimension()==2)
{
- for(int i=0;i<nbOfCells;i++,vals+=3)
+ if(getSpaceDimension()==3)
{
- int offset=connI[i];
- INTERP_KERNEL::crossprod<3>(locPtr+3*i,coords+3*conn[offset+1],coords+3*conn[offset+2],vals);
- double n=INTERP_KERNEL::norm<3>(vals);
- std::transform(vals,vals+3,vals,std::bind2nd(std::multiplies<double>(),1./n));
+ DataArrayDouble *loc=getBarycenterAndOwner();
+ const double *locPtr=loc->getConstPointer();
+ for(int i=0;i<nbOfCells;i++,vals+=3)
+ {
+ int offset=connI[i];
+ INTERP_KERNEL::crossprod<3>(locPtr+3*i,coords+3*conn[offset+1],coords+3*conn[offset+2],vals);
+ double n=INTERP_KERNEL::norm<3>(vals);
+ std::transform(vals,vals+3,vals,std::bind2nd(std::multiplies<double>(),1./n));
+ }
+ loc->decrRef();
+ }
+ else
+ {
+ for(int i=0;i<nbOfCells;i++)
+ { vals[3*i]=0.; vals[3*i+1]=0.; vals[3*i+2]=1.; }
}
}
- else
+ else//meshdimension==1
{
+ double tmp[2];
for(int i=0;i<nbOfCells;i++)
- { vals[3*i]=0.; vals[3*i+1]=0.; vals[3*i+2]=1.; }
+ {
+ int offset=connI[i];
+ std::transform(coords+2*conn[offset+2],coords+2*conn[offset+2]+2,coords+2*conn[offset+1],tmp,std::minus<double>());
+ double n=INTERP_KERNEL::norm<2>(tmp);
+ std::transform(tmp,tmp+2,tmp,std::bind2nd(std::multiplies<double>(),1./n));
+ *vals++=-tmp[1];
+ *vals++=tmp[0];
+ }
+ }
+ ret->setArray(array);
+ array->decrRef();
+ ret->setMesh(this);
+ return ret;
+}
+
+/*!
+ * This method is equivalent to MEDCouplingUMesh::buildOrthogonalField except that only part defined by [begin,end) is returned !
+ * This method avoids to build explicitely part of this to perform the work.
+ */
+MEDCouplingFieldDouble *MEDCouplingUMesh::buildPartOrthogonalField(const int *begin, const int *end) const
+{
+ if((getMeshDimension()!=2) && (getMeshDimension()!=1 || getSpaceDimension()!=2))
+ throw INTERP_KERNEL::Exception("Expected a umesh with ( meshDim == 2 spaceDim == 2 or 3 ) or ( meshDim == 1 spaceDim == 2 ) !");
+ MEDCouplingFieldDouble *ret=MEDCouplingFieldDouble::New(ON_CELLS,NO_TIME);
+ DataArrayDouble *array=DataArrayDouble::New();
+ int nbelems=std::distance(begin,end);
+ int nbComp=getMeshDimension()+1;
+ array->alloc(nbelems,nbComp);
+ double *vals=array->getPointer();
+ const int *connI=_nodal_connec_index->getConstPointer();
+ const int *conn=_nodal_connec->getConstPointer();
+ const double *coords=_coords->getConstPointer();
+ if(getMeshDimension()==2)
+ {
+ if(getSpaceDimension()==3)
+ {
+ DataArrayDouble *loc=getPartBarycenterAndOwner(begin,end);
+ const double *locPtr=loc->getConstPointer();
+ for(const int *i=begin;i!=end;i++,vals+=3,locPtr+=3)
+ {
+ int offset=connI[*i];
+ INTERP_KERNEL::crossprod<3>(locPtr,coords+3*conn[offset+1],coords+3*conn[offset+2],vals);
+ double n=INTERP_KERNEL::norm<3>(vals);
+ std::transform(vals,vals+3,vals,std::bind2nd(std::multiplies<double>(),1./n));
+ }
+ loc->decrRef();
+ }
+ else
+ {
+ for(int i=0;i<nbelems;i++)
+ { vals[3*i]=0.; vals[3*i+1]=0.; vals[3*i+2]=1.; }
+ }
+ }
+ else//meshdimension==1
+ {
+ double tmp[2];
+ for(const int *i=begin;i!=end;i++)
+ {
+ int offset=connI[*i];
+ std::transform(coords+2*conn[offset+2],coords+2*conn[offset+2]+2,coords+2*conn[offset+1],tmp,std::minus<double>());
+ double n=INTERP_KERNEL::norm<2>(tmp);
+ std::transform(tmp,tmp+2,tmp,std::bind2nd(std::multiplies<double>(),1./n));
+ *vals++=-tmp[1];
+ *vals++=tmp[0];
+ }
}
ret->setArray(array);
- loc->decrRef();
array->decrRef();
ret->setMesh(this);
return ret;
/*!
* Returns a cell if any that contains the point located on 'pos' with precison eps.
* If 'pos' is outside 'this' -1 is returned. If several cells contain this point the cell with the smallest id is returned.
+ * \b Warning this method is good if the caller intends to evaluate only one point. But if more than one point is requested on 'this'
+ * it is better to use MEDCouplingUMesh::getCellsContainingPoints method because in this case, the acceleration structure will be computed only once.
*/
int MEDCouplingUMesh::getCellContainingPoint(const double *pos, double eps) const
{
/*!
* Returns all cellIds in 'elts' of point 'pos' with eps accuracy.
+ * \b Warning this method is good if the caller intends to evaluate only one point. But if more than one point is requested on 'this'
+ * it is better to use MEDCouplingUMesh::getCellsContainingPoints method because in this case, the acceleration structure will be computed only once.
*/
void MEDCouplingUMesh::getCellsContainingPoint(const double *pos, double eps, std::vector<int>& elts) const
{
const int *conn=_nodal_connec->getConstPointer();
const int *connI=_nodal_connec_index->getConstPointer();
double bb[2*SPACEDIM];
- for(int j=0;j<SPACEDIM;j++)
- { bb[2*j]=std::numeric_limits<double>::max(); bb[2*j+1]=-std::numeric_limits<double>::max(); }
BBTree<SPACEDIM,int> myTree(&bbox[0],0,0,nbOfCells,-eps);
for(int i=0;i<nbOfPoints;i++)
{
eltsIndex[i+1]=eltsIndex[i];
for(int j=0;j<SPACEDIM;j++)
{
- bb[2*j]=std::min(bb[2*j],pos[SPACEDIM*i+j]);
- bb[2*j+1]=std::max(bb[2*j+1],pos[SPACEDIM*i+j]);
+ bb[2*j]=pos[SPACEDIM*i+j];
+ bb[2*j+1]=pos[SPACEDIM*i+j];
}
std::vector<int> candidates;
myTree.getIntersectingElems(bb,candidates);
}
}
+/*!
+ * This method is an extension of MEDCouplingUMesh::getCellContainingPoint and MEDCouplingUMesh::getCellsContainingPoint.
+ * This method performs 'nbOfPoints' time the getCellsContainingPoint request. This method is recommended rather than the 2 others
+ * in case of multi points searching.
+ * This method returns 2 arrays 'elts' and 'eltsIndex'. 'eltsIndex' is of size 'nbOfPoints+1' and 'elts' is of size 'eltsIndex[nbOfPoints-1]'.
+ * For point j in [0,nbOfPoints), (eltsIndex[j+1]-eltsIndex[j]) cells contain this point. These cells are : [elts.begin()+eltsIndex[j],elts.begin():eltsIndex[j+1]).
+ *
+ * \param pos input parameter that points to an array of size 'getSpaceDim()*nbOfPoints' points stored in full interlace mode : X0,Y0,Z0,X1,Y1,Z1...
+ */
void MEDCouplingUMesh::getCellsContainingPoints(const double *pos, int nbOfPoints, double eps,
std::vector<int>& elts, std::vector<int>& eltsIndex) const
{
* \b 1 for translation and rotation around point of 'mesh1D'.
* @return an unstructured mesh with meshDim==3 and spaceDim==3. The returned mesh has the same coords than 'this'.
*/
-MEDCouplingUMesh *MEDCouplingUMesh::buildExtrudedMeshFromThis(const MEDCouplingUMesh *mesh1D, int policy)
+MEDCouplingUMesh *MEDCouplingUMesh::buildExtrudedMesh(const MEDCouplingUMesh *mesh1D, int policy)
{
checkFullyDefined();
mesh1D->checkFullyDefined();
if(!mesh1D->isContiguous1D())
- throw INTERP_KERNEL::Exception("buildExtrudedMeshFromThis : 1D mesh passed in parameter is not contiguous !");
+ throw INTERP_KERNEL::Exception("buildExtrudedMesh : 1D mesh passed in parameter is not contiguous !");
if(getSpaceDimension()!=mesh1D->getSpaceDimension())
- throw INTERP_KERNEL::Exception("Invalid call to buildExtrudedMeshFromThis this and mesh1D must have same dimension !");
+ throw INTERP_KERNEL::Exception("Invalid call to buildExtrudedMesh this and mesh1D must have same dimension !");
if((getMeshDimension()!=2 || getSpaceDimension()!=3) && (getMeshDimension()!=1 || getSpaceDimension()!=2))
- throw INTERP_KERNEL::Exception("Invalid 'this' for buildExtrudedMeshFromThis method : must be (meshDim==2 and spaceDim==3) or (meshDim==1 and spaceDim==2) !");
+ throw INTERP_KERNEL::Exception("Invalid 'this' for buildExtrudedMesh method : must be (meshDim==2 and spaceDim==3) or (meshDim==1 and spaceDim==2) !");
if(mesh1D->getMeshDimension()!=1)
- throw INTERP_KERNEL::Exception("Invalid 'mesh1D' for buildExtrudedMeshFromThis method : must be meshDim==1 !");
+ throw INTERP_KERNEL::Exception("Invalid 'mesh1D' for buildExtrudedMesh method : must be meshDim==1 !");
bool isQuad=false;
if(isPresenceOfQuadratic())
{
}
/*!
- * This method incarnates the policy 0 for MEDCouplingUMesh::buildExtrudedMeshFromThis method.
+ * This method incarnates the policy 0 for MEDCouplingUMesh::buildExtrudedMesh method.
* @param mesh1D is the input 1D mesh used for translation computation.
* @return newCoords new coords filled by this method.
*/
}
/*!
- * This method incarnates the policy 1 for MEDCouplingUMesh::buildExtrudedMeshFromThis method.
+ * This method incarnates the policy 1 for MEDCouplingUMesh::buildExtrudedMesh method.
* @param mesh1D is the input 1D mesh used for translation and automatic rotation computation.
* @return newCoords new coords filled by this method.
*/
}
/*!
- * This method incarnates the policy 1 for MEDCouplingUMesh::buildExtrudedMeshFromThis method.
+ * This method incarnates the policy 1 for MEDCouplingUMesh::buildExtrudedMesh method.
* @param mesh1D is the input 1D mesh used for translation and automatic rotation computation.
* @return newCoords new coords filled by this method.
*/
double *retPtr=ret->getPointer();
retPtr=std::copy(getCoords()->getConstPointer(),getCoords()->getConstPointer()+getCoords()->getNbOfElems(),retPtr);
MEDCouplingUMesh *tmp=MEDCouplingUMesh::New();
- DataArrayDouble *tmp2=getCoords()->deepCopy();
+ DataArrayDouble *tmp2=getCoords()->deepCpy();
tmp->setCoords(tmp2);
tmp2->decrRef();
const double *coo1D=mesh1D->getCoords()->getConstPointer();
}
/*!
- * This method incarnates the policy 1 for MEDCouplingUMesh::buildExtrudedMeshFromThis method.
+ * This method incarnates the policy 1 for MEDCouplingUMesh::buildExtrudedMesh method.
* @param mesh1D is the input 1D mesh used for translation and automatic rotation computation.
* @return newCoords new coords filled by this method.
*/
double *retPtr=ret->getPointer();
retPtr=std::copy(getCoords()->getConstPointer(),getCoords()->getConstPointer()+getCoords()->getNbOfElems(),retPtr);
MEDCouplingUMesh *tmp=MEDCouplingUMesh::New();
- DataArrayDouble *tmp2=getCoords()->deepCopy();
+ DataArrayDouble *tmp2=getCoords()->deepCpy();
tmp->setCoords(tmp2);
tmp2->decrRef();
const double *coo1D=mesh1D->getCoords()->getConstPointer();
/*!
* This method is private because not easy to use for end user. This method is const contrary to
- * MEDCouplingUMesh::buildExtrudedMeshFromThis method because this->_coords are expected to contain
+ * MEDCouplingUMesh::buildExtrudedMesh method because this->_coords are expected to contain
* the coords sorted slice by slice.
* @param isQuad specifies presence of quadratic cells.
*/
INTERP_KERNEL::NormalizedCellType type=(INTERP_KERNEL::NormalizedCellType)conn[connI[i]];
if(!polyOnly || type==INTERP_KERNEL::NORM_POLYGON)
{
- if(!isPolygonWellOriented(vec,conn+connI[i]+1,conn+connI[i+1],coordsPtr))
+ if(!IsPolygonWellOriented(vec,conn+connI[i]+1,conn+connI[i+1],coordsPtr))
cells.push_back(i);
}
}
{
INTERP_KERNEL::NormalizedCellType type=(INTERP_KERNEL::NormalizedCellType)conn[connI[i]];
if(!polyOnly || type==INTERP_KERNEL::NORM_POLYGON)
- if(!isPolygonWellOriented(vec,conn+connI[i]+1,conn+connI[i+1],coordsPtr))
+ if(!IsPolygonWellOriented(vec,conn+connI[i]+1,conn+connI[i+1],coordsPtr))
{
isModified=true;
std::vector<int> tmp(connI[i+1]-connI[i]-2);
INTERP_KERNEL::NormalizedCellType type=(INTERP_KERNEL::NormalizedCellType)conn[connI[i]];
if(type==INTERP_KERNEL::NORM_POLYHED)
{
- if(!isPolyhedronWellOriented(conn+connI[i]+1,conn+connI[i+1],coordsPtr))
+ if(!IsPolyhedronWellOriented(conn+connI[i]+1,conn+connI[i+1],coordsPtr))
cells.push_back(i);
}
}
{
INTERP_KERNEL::NormalizedCellType type=(INTERP_KERNEL::NormalizedCellType)conn[connI[i]];
if(type==INTERP_KERNEL::NORM_POLYHED)
- if(!isPolyhedronWellOriented(conn+connI[i]+1,conn+connI[i+1],coordsPtr))
+ if(!IsPolyhedronWellOriented(conn+connI[i]+1,conn+connI[i+1],coordsPtr))
{
- tryToCorrectPolyhedronOrientation(conn+connI[i]+1,conn+connI[i+1],coordsPtr);
+ TryToCorrectPolyhedronOrientation(conn+connI[i]+1,conn+connI[i+1],coordsPtr);
isModified=true;
}
}
const int *_conn;
int _val;
};
+
+ class ConnReader2
+ {
+ public:
+ ConnReader2(const int *c, int val):_conn(c),_val(val) { }
+ bool operator() (const int& pos) { return _conn[pos]==_val; }
+ private:
+ const int *_conn;
+ int _val;
+ };
+}
+
+/*!
+ * This method is used to check that this has contiguous cell type in same order than described in 'code'.
+ * Format of 'code' is the following. 'code' should be of size 3*n and non empty. If not an exception is thrown.
+ * foreach k in [0,n) on 3*k pos represent the geometric type and 3*k+1 number of elements of type 3*k.
+ * 3*k+2 refers if different from -1 the pos in 'idsPerType' to get the corresponding array.
+ * If 2 or more same geometric type is in 'code' and exception is thrown too.
+ *
+ * This method fistly checks
+ * If it exists k so that 3*k geometric type is not in geometric types of this an exception will be thrown.
+ * If it exists k so that 3*k geometric type exists but the number of consecutive cell types does not match,
+ * an exception is thrown too.
+ *
+ * If all geometric types in 'code' are exactly those in 'this' null pointer is returned.
+ * If it exists a geometric type in 'this' \b not in 'code' \b no exception is thrown and a DataArrayInt instance is returned that the user has the responsability
+ * to deallocate.
+ */
+DataArrayInt *MEDCouplingUMesh::checkTypeConsistencyAndContig(const std::vector<int>& code, const std::vector<const DataArrayInt *>& idsPerType) const throw(INTERP_KERNEL::Exception)
+{
+ if(code.empty())
+ throw INTERP_KERNEL::Exception("MEDCouplingUMesh::checkTypeConsistencyAndContig : code is empty, should not !");
+ int sz=code.size();
+ std::size_t n=sz/3;
+ if(sz%3!=0)
+ throw INTERP_KERNEL::Exception("MEDCouplingUMesh::checkTypeConsistencyAndContig : code size is NOT %3 !");
+ std::vector<INTERP_KERNEL::NormalizedCellType> types;
+ int nb=0;
+ for(std::size_t i=0;i<n;i++)
+ if(std::find(types.begin(),types.end(),(INTERP_KERNEL::NormalizedCellType)code[3*i])==types.end())
+ {
+ types.push_back((INTERP_KERNEL::NormalizedCellType)code[3*i]);
+ nb+=code[3*i+1];
+ if(_types.find((INTERP_KERNEL::NormalizedCellType)code[3*i])==_types.end())
+ throw INTERP_KERNEL::Exception("MEDCouplingUMesh::checkTypeConsistencyAndContig : expected geo types not in this !");
+ }
+ if(types.size()!=n)
+ throw INTERP_KERNEL::Exception("MEDCouplingUMesh::checkTypeConsistencyAndContig : code contains duplication of types in unstructured mesh !");
+ if(idsPerType.empty())
+ {
+ if(!checkConsecutiveCellTypesAndOrder(&types[0],&types[0]+types.size()))
+ throw INTERP_KERNEL::Exception("MEDCouplingUMesh::checkTypeConsistencyAndContig : non contiguous type !");
+ if(types.size()==_types.size())
+ return 0;
+ }
+ DataArrayInt *ret=DataArrayInt::New();
+ ret->alloc(nb,1);
+ int *retPtr=ret->getPointer();
+ const int *connI=_nodal_connec_index->getConstPointer();
+ const int *conn=_nodal_connec->getConstPointer();
+ int nbOfCells=getNumberOfCells();
+ const int *i=connI;
+ int kk=0;
+ for(std::vector<INTERP_KERNEL::NormalizedCellType>::const_iterator it=types.begin();it!=types.end();it++,kk++)
+ {
+ i=std::find_if(i,connI+nbOfCells,ParaMEDMEMImpl::ConnReader2(conn,(int)(*it)));
+ int offset=std::distance(connI,i);
+ if(code[3*kk+2]==-1)
+ {
+ const int *j=std::find_if(i+1,connI+nbOfCells,ParaMEDMEMImpl::ConnReader(conn,(int)(*it)));
+ int pos2=std::distance(i,j);
+ for(int k=0;k<pos2;k++)
+ *retPtr++=k+offset;
+ i=j;
+ }
+ else
+ {
+ retPtr=std::transform(idsPerType[code[3*kk+2]]->getConstPointer(),idsPerType[code[3*kk+2]]->getConstPointer()+idsPerType[code[3*kk+2]]->getNbOfElems(),
+ retPtr,std::bind2nd(std::plus<int>(),offset));
+ }
+ }
+ return ret;
+}
+
+/*!
+ * This method is here too emulate the MEDMEM behaviour on BDC (buildDescendingConnectivity). Hoping this method becomes deprecated very soon.
+ * This method make the assumption that 'this' and 'nM1LevMesh' mesh lyies on same coords (same pointer) as MED and MEDMEM does.
+ * The following equality should be verified 'nM1LevMesh->getMeshDimension()==this->getMeshDimension()-1'
+ * This method returns 5+2 elements. 'desc', 'descIndx', 'revDesc', 'revDescIndx' and 'meshnM1' behaves exactly as ParaMEDMEM::MEDCouplingUMesh::buildDescendingConnectivity except the content as described after. The returned array specifies the n-1 mesh reordered by type as MEDMEM does. 'nM1LevMeshIds' contains the ids in returned 'meshnM1'. Finally 'meshnM1Old2New' contains numbering old2new that is to say the cell #k in coarse 'nM1LevMesh' will have the number ret[k] in returned mesh 'nM1LevMesh' MEDMEM reordered.
+ */
+MEDCouplingUMesh *MEDCouplingUMesh::emulateMEDMEMBDC(const MEDCouplingUMesh *nM1LevMesh, DataArrayInt *desc, DataArrayInt *descIndx, DataArrayInt *&revDesc, DataArrayInt *&revDescIndx, DataArrayInt *& nM1LevMeshIds, DataArrayInt *&meshnM1Old2New) const throw(INTERP_KERNEL::Exception)
+{
+ static const int N=18;
+ static const INTERP_KERNEL::NormalizedCellType MEDMEM_ORDER[N] = { INTERP_KERNEL::NORM_POINT1, INTERP_KERNEL::NORM_SEG2, INTERP_KERNEL::NORM_SEG3, INTERP_KERNEL::NORM_TRI3, INTERP_KERNEL::NORM_QUAD4, INTERP_KERNEL::NORM_TRI6, INTERP_KERNEL::NORM_QUAD8, INTERP_KERNEL::NORM_TETRA4, INTERP_KERNEL::NORM_PYRA5, INTERP_KERNEL::NORM_PENTA6, INTERP_KERNEL::NORM_HEXA8, INTERP_KERNEL::NORM_HEXGP12, INTERP_KERNEL::NORM_TETRA10, INTERP_KERNEL::NORM_PYRA13, INTERP_KERNEL::NORM_PENTA15, INTERP_KERNEL::NORM_HEXA20, INTERP_KERNEL::NORM_POLYGON, INTERP_KERNEL::NORM_POLYHED };
+ checkFullyDefined();
+ nM1LevMesh->checkFullyDefined();
+ if(getMeshDimension()-1!=nM1LevMesh->getMeshDimension())
+ throw INTERP_KERNEL::Exception("MEDCouplingUMesh::emulateMEDMEMBDC : The mesh passed as first argument should have a meshDim equal to this->getMeshDimension()-1 !" );
+ if(_coords!=nM1LevMesh->getCoords())
+ throw INTERP_KERNEL::Exception("MEDCouplingUMesh::emulateMEDMEMBDC : 'this' and mesh in first argument should share the same coords : Use tryToShareSameCoords method !");
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> tmp0=DataArrayInt::New();
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> tmp1=DataArrayInt::New();
+ MEDCouplingAutoRefCountObjectPtr<MEDCouplingUMesh> ret1=buildDescendingConnectivity(desc,descIndx,tmp0,tmp1);
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ret0=ret1->getRenumArrForConsecutiveCellTypesSpec(MEDMEM_ORDER,MEDMEM_ORDER+N);
+ ret1->renumberCells(ret0->getConstPointer(),false);
+ desc->transformWithIndArr(ret0->getConstPointer(),ret0->getConstPointer()+ret0->getNbOfElems());
+ MEDCouplingAutoRefCountObjectPtr<MEDCouplingUMesh> tmp=MEDCouplingUMesh::New();
+ tmp->setConnectivity(tmp0,tmp1);
+ tmp->renumberCells(ret0->getConstPointer(),false);
+ revDesc=tmp->getNodalConnectivity();
+ revDescIndx=tmp->getNodalConnectivityIndex();
+ DataArrayInt *ret=0;
+ if(!ret1->areCellsIncludedIn(nM1LevMesh,2,ret))
+ {
+ int tmp;
+ ret->getMaxValue(tmp);
+ ret->decrRef();
+ std::ostringstream oss; oss << "MEDCouplingUMesh::emulateMEDMEMBDC : input N-1 mesh present a cell not in descending mesh ... Id of cell is " << tmp << " !";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ nM1LevMeshIds=ret;
+ //
+ revDesc->incrRef();
+ revDescIndx->incrRef();
+ ret1->incrRef();
+ ret0->incrRef();
+ meshnM1Old2New=ret0;
+ return ret1;
}
/*!
}
/*!
- * This method is similar to method MEDCouplingUMesh::rearrange2ConsecutiveCellTypes except that the type order is specfied by [orderBg,orderEnd) (as MEDCouplingUMesh::checkConsecutiveCellTypesAndOrder method) and that this method is \b const and performs \b NO permutation is 'this'.
- * This method returns an array of size getNumberOfCells() that gives a renumber array old2New that can be used as input of MEDCouplingMesh::renumberCells.
- * The mesh after this call will pass the test of MEDCouplingUMesh::checkConsecutiveCellTypesAndOrder with the same inputs.
- * The returned array minimizes the permutations that is to say the order of cells inside same geometric type remains the same.
+ * This method returns 2 newly allocated DataArrayInt instances. The first is an array of size 'this->getNumberOfCells()' with one component,
+ * that tells for each cell the pos of its type in the array on type given in input parameter. The 2nd output parameter is an array with the same
+ * number of tuples than input type array and with one component. This 2nd output array gives type by type the number of occurence of type in 'this'.
*/
-DataArrayInt *MEDCouplingUMesh::getRenumArrForConsecutiveCellTypesSpec(const INTERP_KERNEL::NormalizedCellType *orderBg, const INTERP_KERNEL::NormalizedCellType *orderEnd) const
+DataArrayInt *MEDCouplingUMesh::getLevArrPerCellTypes(const INTERP_KERNEL::NormalizedCellType *orderBg, const INTERP_KERNEL::NormalizedCellType *orderEnd, DataArrayInt *&nbPerType) const throw(INTERP_KERNEL::Exception)
{
checkFullyDefined();
int nbOfCells=getNumberOfCells();
const int *conn=_nodal_connec->getConstPointer();
const int *connI=_nodal_connec_index->getConstPointer();
- int *tmp=new int[nbOfCells];
- int minPos=std::numeric_limits<int>::max();
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> tmpa=DataArrayInt::New();
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> tmpb=DataArrayInt::New();
+ tmpa->alloc(nbOfCells,1);
+ tmpb->alloc(std::distance(orderBg,orderEnd),1);
+ tmpb->fillWithZero();
+ int *tmp=tmpa->getPointer();
+ int *tmp2=tmpb->getPointer();
for(const int *i=connI;i!=connI+nbOfCells;i++)
{
- int pos=std::distance(orderBg,std::find(orderBg,orderEnd,(INTERP_KERNEL::NormalizedCellType)conn[*i]));
- tmp[std::distance(connI,i)]=pos;
- minPos=std::min(minPos,pos);
- }
- DataArrayInt *ret=DataArrayInt::New();
- ret->alloc(nbOfCells,1);
- int *optr=ret->getPointer();
- int k=0;
- while(minPos!=std::numeric_limits<int>::max())
- {
- int nextMinPos=std::numeric_limits<int>::max();
- for(int j=0;j<nbOfCells;j++)
+ const INTERP_KERNEL::NormalizedCellType *where=std::find(orderBg,orderEnd,(INTERP_KERNEL::NormalizedCellType)conn[*i]);
+ if(where!=orderEnd)
{
- if(tmp[j]==minPos)
- {
- optr[j]=k++;
- tmp[j]=std::numeric_limits<int>::max();
- }
- else
- nextMinPos=std::min(nextMinPos,tmp[j]);
+ int pos=std::distance(orderBg,where);
+ tmp2[pos]++;
+ tmp[std::distance(connI,i)]=pos;
+ }
+ else
+ {
+ const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::getCellModel((INTERP_KERNEL::NormalizedCellType)conn[*i]);
+ std::ostringstream oss; oss << "MEDCouplingUMesh::getLevArrPerCellTypes : Cell #" << std::distance(connI,i);
+ oss << " has a type " << cm.getRepr() << " not in input array of type !";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
}
- minPos=nextMinPos;
}
- delete [] tmp;
- return ret;
+ nbPerType=tmpb;
+ tmpa->incrRef();
+ tmpb->incrRef();
+ return tmpa;
+}
+
+/*!
+ * This method is similar to method MEDCouplingUMesh::rearrange2ConsecutiveCellTypes except that the type order is specfied by [orderBg,orderEnd) (as MEDCouplingUMesh::checkConsecutiveCellTypesAndOrder method) and that this method is \b const and performs \b NO permutation in 'this'.
+ * This method returns an array of size getNumberOfCells() that gives a renumber array old2New that can be used as input of MEDCouplingMesh::renumberCells.
+ * The mesh after this call to MEDCouplingMesh::renumberCells will pass the test of MEDCouplingUMesh::checkConsecutiveCellTypesAndOrder with the same inputs.
+ * The returned array minimizes the permutations that is to say the order of cells inside same geometric type remains the same.
+ */
+DataArrayInt *MEDCouplingUMesh::getRenumArrForConsecutiveCellTypesSpec(const INTERP_KERNEL::NormalizedCellType *orderBg, const INTERP_KERNEL::NormalizedCellType *orderEnd) const throw(INTERP_KERNEL::Exception)
+{
+ DataArrayInt *nbPerType=0;
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> tmpa=getLevArrPerCellTypes(orderBg,orderEnd,nbPerType);
+ nbPerType->decrRef();
+ return tmpa->buildPermArrPerLevel();
}
/*!
}
/*!
- * This methods split this into as mush as untructured meshes that consecutive set of same type cells.
+ * This method splits 'this' into as mush as untructured meshes that consecutive set of same type cells.
* So this method has typically a sense if MEDCouplingUMesh::checkConsecutiveCellTypes has a sense.
* This method makes asumption that connectivity is correctly set before calling.
*/
return ret;
}
+/*!
+ * This method returns a newly created DataArrayInt instance.
+ * This method retrieves cell ids in [begin,end) that have the type 'type'.
+ */
+DataArrayInt *MEDCouplingUMesh::keepCellIdsByType(INTERP_KERNEL::NormalizedCellType type, const int *begin, const int *end) const throw(INTERP_KERNEL::Exception)
+{
+ checkFullyDefined();
+ std::vector<int> r;
+ const int *conn=_nodal_connec->getConstPointer();
+ const int *connIndex=_nodal_connec_index->getConstPointer();
+ for(const int *w=begin;w!=end;w++)
+ if((INTERP_KERNEL::NormalizedCellType)conn[connIndex[*w]]==type)
+ r.push_back(*w);
+ DataArrayInt *ret=DataArrayInt::New();
+ ret->alloc(r.size(),1);
+ std::copy(r.begin(),r.end(),ret->getPointer());
+ return ret;
+}
+
/*!
* This method makes the assumption that da->getNumberOfTuples()<this->getNumberOfCells(). This method makes the assumption that ids contained in 'da'
* are in [0:getNumberOfCells())
* cells whose ids is in 'idsPerGeoType' array.
* This method conserves coords and name of mesh.
*/
-MEDCouplingUMesh *MEDCouplingUMesh::keepSpecifiedCells(INTERP_KERNEL::NormalizedCellType type, const std::vector<int>& idsPerGeoType) const
+MEDCouplingUMesh *MEDCouplingUMesh::keepSpecifiedCells(INTERP_KERNEL::NormalizedCellType type, const int *idsPerGeoTypeBg, const int *idsPerGeoTypeEnd) const
{
std::vector<int> idsTokeep;
int nbOfCells=getNumberOfCells();
idsTokeep.push_back(i);
else
{
- if(std::find(idsPerGeoType.begin(),idsPerGeoType.end(),j)!=idsPerGeoType.end())
+ if(std::find(idsPerGeoTypeBg,idsPerGeoTypeEnd,j)!=idsPerGeoTypeEnd)
idsTokeep.push_back(i);
j++;
}
ret->decrRef();
return 0;
}
- ret2->setName(getName());
+ ret2->copyTinyInfoFrom(this);
return ret2;
}
if(other->getType()!=UNSTRUCTURED)
throw INTERP_KERNEL::Exception("Merge of umesh only available with umesh each other !");
const MEDCouplingUMesh *otherC=static_cast<const MEDCouplingUMesh *>(other);
- return mergeUMeshes(this,otherC);
+ return MergeUMeshes(this,otherC);
}
/*!
int spaceDim=getSpaceDimension();
int nbOfCells=getNumberOfCells();
ret->alloc(nbOfCells,spaceDim);
+ ret->copyStringInfoFrom(*getCoords());
double *ptToFill=ret->getPointer();
double *tmp=new double[spaceDim];
const int *nodal=_nodal_connec->getConstPointer();
return ret;
}
+/*!
+ * This method is similar to MEDCouplingUMesh::getBarycenterAndOwner except that it works on subPart of 'this' without
+ * building explicitely it. The input part is defined by an array [begin,end). All ids contained in this array should be less than this->getNumberOfCells().
+ * No check of that will be done !
+ */
+DataArrayDouble *MEDCouplingUMesh::getPartBarycenterAndOwner(const int *begin, const int *end) const
+{
+ DataArrayDouble *ret=DataArrayDouble::New();
+ int spaceDim=getSpaceDimension();
+ int nbOfTuple=std::distance(begin,end);
+ ret->alloc(nbOfTuple,spaceDim);
+ double *ptToFill=ret->getPointer();
+ double *tmp=new double[spaceDim];
+ const int *nodal=_nodal_connec->getConstPointer();
+ const int *nodalI=_nodal_connec_index->getConstPointer();
+ const double *coor=_coords->getConstPointer();
+ for(const int *w=begin;w!=end;w++)
+ {
+ INTERP_KERNEL::NormalizedCellType type=(INTERP_KERNEL::NormalizedCellType)nodal[nodalI[*w]];
+ INTERP_KERNEL::computeBarycenter2<int,INTERP_KERNEL::ALL_C_MODE>(type,nodal+nodalI[*w]+1,nodalI[*w+1]-nodalI[*w]-1,coor,spaceDim,ptToFill);
+ ptToFill+=spaceDim;
+ }
+ delete [] tmp;
+ return ret;
+}
+
+/*!
+ * This method expects as input a DataArrayDouble non nul instance 'da' that should be allocated. If not an exception is thrown.
+ *
+ */
+MEDCouplingUMesh *MEDCouplingUMesh::Build0DMeshFromCoords(DataArrayDouble *da) throw(INTERP_KERNEL::Exception)
+{
+ if(!da)
+ throw INTERP_KERNEL::Exception("MEDCouplingUMesh::Build0DMeshFromCoords : instance of DataArrayDouble must be not null !");
+ da->checkAllocated();
+ MEDCouplingAutoRefCountObjectPtr<MEDCouplingUMesh> ret=MEDCouplingUMesh::New(da->getName().c_str(),0);
+ ret->setCoords(da);
+ int nbOfTuples=da->getNumberOfTuples();
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> c=DataArrayInt::New();
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> cI=DataArrayInt::New();
+ c->alloc(2*nbOfTuples,1);
+ cI->alloc(nbOfTuples+1,1);
+ int *cp=c->getPointer();
+ int *cip=cI->getPointer();
+ *cip++=0;
+ for(int i=0;i<nbOfTuples;i++)
+ {
+ *cp++=INTERP_KERNEL::NORM_POINT1;
+ *cp++=i;
+ *cip++=2*(i+1);
+ }
+ ret->setConnectivity(c,cI,true);
+ ret->incrRef();
+ return ret;
+}
+
/*!
* Returns a newly created mesh (with ref count ==1) that contains merge of 'mesh1' and 'other'.
* The coords of 'mesh2' are added at the end of coords of 'mesh1'.
*/
-MEDCouplingUMesh *MEDCouplingUMesh::mergeUMeshes(const MEDCouplingUMesh *mesh1, const MEDCouplingUMesh *mesh2)
+MEDCouplingUMesh *MEDCouplingUMesh::MergeUMeshes(const MEDCouplingUMesh *mesh1, const MEDCouplingUMesh *mesh2) throw(INTERP_KERNEL::Exception)
{
- MEDCouplingUMesh *ret=MEDCouplingUMesh::New();
- ret->setName("merge");
- DataArrayDouble *pts=mergeNodesArray(mesh1,mesh2);
+ std::vector<const MEDCouplingUMesh *> tmp(2);
+ tmp[0]=const_cast<MEDCouplingUMesh *>(mesh1); tmp[1]=const_cast<MEDCouplingUMesh *>(mesh2);
+ return MergeUMeshes(tmp);
+}
+
+MEDCouplingUMesh *MEDCouplingUMesh::MergeUMeshes(std::vector<const MEDCouplingUMesh *>& a) throw(INTERP_KERNEL::Exception)
+{
+ if(a.empty())
+ throw INTERP_KERNEL::Exception("MEDCouplingUMesh::MergeUMeshes : input array must be NON EMPTY !");
+ std::vector<const MEDCouplingUMesh *>::const_iterator it=a.begin();
+ int meshDim=(*it)->getMeshDimension();
+ int nbOfCells=(*it)->getNumberOfCells();
+ int meshLgth=(*it++)->getMeshLength();
+ for(;it!=a.end();it++)
+ {
+ if(meshDim!=(*it)->getMeshDimension())
+ throw INTERP_KERNEL::Exception("Mesh dimensions mismatches, MergeUMeshes impossible !");
+ nbOfCells+=(*it)->getNumberOfCells();
+ meshLgth+=(*it)->getMeshLength();
+ }
+ std::vector<const MEDCouplingPointSet *> aps(a.size());
+ std::copy(a.begin(),a.end(),aps.begin());
+ DataArrayDouble *pts=MergeNodesArray(aps);
+ MEDCouplingAutoRefCountObjectPtr<MEDCouplingUMesh> ret=MEDCouplingUMesh::New("merge",meshDim);
ret->setCoords(pts);
pts->decrRef();
- int meshDim=mesh1->getMeshDimension();
- if(meshDim!=mesh2->getMeshDimension())
- throw INTERP_KERNEL::Exception("Mesh dimensions mismatches, mergeMeshes impossible !");
- ret->setMeshDimension(meshDim);
- int delta=mesh1->getMeshLength();
- int pos=mesh1->getNumberOfCells();
- int nbOfCells2=mesh2->getNumberOfCells();
- int end=mesh1->getNumberOfCells()+nbOfCells2+1;
- DataArrayInt *nodalIndex=DataArrayInt::aggregate(mesh1->getNodalConnectivityIndex(),
- mesh2->getNodalConnectivityIndex(),1);
- std::transform(nodalIndex->getConstPointer()+pos+1,nodalIndex->getConstPointer()+end,
- nodalIndex->getPointer()+pos+1,std::bind2nd(std::plus<int>(),delta));
- DataArrayInt *newNodal2=mesh2->getNodalConnectivity()->deepCopy();
- delta=mesh1->getNumberOfNodes();
- const int *nI2=mesh2->getNodalConnectivityIndex()->getConstPointer();
- int *pt=newNodal2->getPointer();
- for(int i=0;i<nbOfCells2;i++)
- {
- pt++;
- for(int j=0;j<nI2[i+1]-nI2[i]-1;j++,pt++)
- if(*pt!=-1)
- *pt+=delta;
- }
- DataArrayInt *nodal=DataArrayInt::aggregate(mesh1->getNodalConnectivity(),newNodal2,0);
- newNodal2->decrRef();
- ret->setConnectivity(nodal,nodalIndex,true);
- nodalIndex->decrRef();
- nodal->decrRef();
+ DataArrayInt *c=DataArrayInt::New();
+ c->alloc(meshLgth,1);
+ int *cPtr=c->getPointer();
+ DataArrayInt *cI=DataArrayInt::New();
+ cI->alloc(nbOfCells+1,1);
+ int *cIPtr=cI->getPointer();
+ *cIPtr++=0;
+ int offset=0;
+ int offset2=0;
+ for(it=a.begin();it!=a.end();it++)
+ {
+ int curNbOfCell=(*it)->getNumberOfCells();
+ const int *curCI=(*it)->_nodal_connec_index->getConstPointer();
+ const int *curC=(*it)->_nodal_connec->getConstPointer();
+ cIPtr=std::transform(curCI+1,curCI+curNbOfCell+1,cIPtr,std::bind2nd(std::plus<int>(),offset));
+ for(int j=0;j<curNbOfCell;j++)
+ {
+ const int *src=curC+curCI[j];
+ *cPtr++=*src++;
+ for(;src!=curC+curCI[j+1];src++,cPtr++)
+ {
+ if(*src!=-1)
+ *cPtr=*src+offset2;
+ else
+ *cPtr=-1;
+ }
+ }
+ offset+=curCI[curNbOfCell];
+ offset2+=(*it)->getNumberOfNodes();
+ }
+ //
+ ret->setConnectivity(c,cI,true);
+ c->decrRef();
+ cI->decrRef();
+ ret->incrRef();
return ret;
}
/*!
- * Idem mergeUMeshes except that 'meshes' are expected to lyie on the same coords and 'meshes' have the same meshdim.
+ * Idem MergeUMeshes except that 'meshes' are expected to lyie on the same coords and 'meshes' have the same meshdim.
+ * 'meshes' must be a non empty vector.
+ */
+MEDCouplingUMesh *MEDCouplingUMesh::MergeUMeshesOnSameCoords(const MEDCouplingUMesh *mesh1, const MEDCouplingUMesh *mesh2) throw(INTERP_KERNEL::Exception)
+{
+ std::vector<const MEDCouplingUMesh *> tmp(2);
+ tmp[0]=mesh1; tmp[1]=mesh2;
+ return MergeUMeshesOnSameCoords(tmp);
+}
+
+/*!
+ * Idem MergeUMeshes except that 'meshes' are expected to lyie on the same coords and 'meshes' have the same meshdim.
* 'meshes' must be a non empty vector.
*/
-MEDCouplingUMesh *MEDCouplingUMesh::mergeUMeshesOnSameCoords(const std::vector<MEDCouplingUMesh *>& meshes)
+MEDCouplingUMesh *MEDCouplingUMesh::MergeUMeshesOnSameCoords(const std::vector<const MEDCouplingUMesh *>& meshes)
{
if(meshes.empty())
throw INTERP_KERNEL::Exception("meshes input parameter is expected to be non empty.");
- DataArrayDouble *coords=meshes.front()->getCoords();
+ const DataArrayDouble *coords=meshes.front()->getCoords();
int meshDim=meshes.front()->getMeshDimension();
- std::vector<MEDCouplingUMesh *>::const_iterator iter=meshes.begin();
+ std::vector<const MEDCouplingUMesh *>::const_iterator iter=meshes.begin();
int meshLgth=0;
int meshIndexLgth=0;
for(;iter!=meshes.end();iter++)
if(coords!=(*iter)->getCoords())
throw INTERP_KERNEL::Exception("meshes does not share the same coords ! Try using tryToShareSameCoords method !");
if(meshDim!=(*iter)->getMeshDimension())
- throw INTERP_KERNEL::Exception("Mesh dimensions mismatches, fuseUMeshesOnSameCoords impossible !");
+ throw INTERP_KERNEL::Exception("Mesh dimensions mismatches, FuseUMeshesOnSameCoords impossible !");
meshLgth+=(*iter)->getMeshLength();
meshIndexLgth+=(*iter)->getNumberOfCells();
}
* @return The mesh lying on the same coordinates than those in meshes. All cells in 'meshes' are in returned mesh with
* @exception if meshes is a empty vector or meshes are not lying on same coordinates or meshes not have the same dimension.
*/
-MEDCouplingUMesh *MEDCouplingUMesh::fuseUMeshesOnSameCoords(const std::vector<MEDCouplingUMesh *>& meshes, int compType, std::vector<DataArrayInt *>& corr)
+MEDCouplingUMesh *MEDCouplingUMesh::FuseUMeshesOnSameCoords(const std::vector<const MEDCouplingUMesh *>& meshes, int compType, std::vector<DataArrayInt *>& corr)
{
- //All checks are delegated to mergeUMeshesOnSameCoords
- MEDCouplingUMesh *ret=mergeUMeshesOnSameCoords(meshes);
+ //All checks are delegated to MergeUMeshesOnSameCoords
+ MEDCouplingUMesh *ret=MergeUMeshesOnSameCoords(meshes);
DataArrayInt *o2n=ret->zipConnectivityTraducer(compType);
corr.resize(meshes.size());
int nbOfMeshes=meshes.size();
tmp->alloc(curNbOfCells,1);
std::copy(o2nPtr+offset,o2nPtr+offset+curNbOfCells,tmp->getPointer());
offset+=curNbOfCells;
+ tmp->setName(meshes[i]->getName());
corr[i]=tmp;
}
o2n->decrRef();
int deltaz=isQuad?2*nbOfNodesPerLev:nbOfNodesPerLev;
switch(flatType)
{
- case INTERP_KERNEL::NORM_POINT0:
+ case INTERP_KERNEL::NORM_POINT1:
{
ret.push_back(connBg[1]);
ret.push_back(connBg[1]+nbOfNodesPerLev);
/*!
* This static operates only for coords in 3D. The polygon is specfied by its connectivity nodes in [begin,end).
*/
-bool MEDCouplingUMesh::isPolygonWellOriented(const double *vec, const int *begin, const int *end, const double *coords)
+bool MEDCouplingUMesh::IsPolygonWellOriented(const double *vec, const int *begin, const int *end, const double *coords)
{
double v[3]={0.,0.,0.};
int sz=std::distance(begin,end);
/*!
* The polyhedron is specfied by its connectivity nodes in [begin,end).
*/
-bool MEDCouplingUMesh::isPolyhedronWellOriented(const int *begin, const int *end, const double *coords)
+bool MEDCouplingUMesh::IsPolyhedronWellOriented(const int *begin, const int *end, const double *coords)
{
std::vector<std::pair<int,int> > edges;
int nbOfFaces=std::count(begin,end,-1)+1;
* This method tries to obtain a well oriented polyhedron.
* If the algorithm fails, an exception will be thrown.
*/
-void MEDCouplingUMesh::tryToCorrectPolyhedronOrientation(int *begin, int *end, const double *coords) throw(INTERP_KERNEL::Exception)
+void MEDCouplingUMesh::TryToCorrectPolyhedronOrientation(int *begin, int *end, const double *coords) throw(INTERP_KERNEL::Exception)
{
std::vector<std::pair<int,int> > edges;
int nbOfFaces=std::count(begin,end,-1)+1;
MEDCOUPLING_EXPORT static MEDCouplingUMesh *New(const char *meshName, int meshDim);
MEDCOUPLING_EXPORT MEDCouplingMesh *deepCpy() const;
MEDCOUPLING_EXPORT MEDCouplingUMesh *clone(bool recDeepCpy) const;
- MEDCOUPLING_EXPORT void updateTime();
+ MEDCOUPLING_EXPORT void updateTime() const;
MEDCOUPLING_EXPORT MEDCouplingMeshType getType() const { return UNSTRUCTURED; }
MEDCOUPLING_EXPORT bool isEqual(const MEDCouplingMesh *other, double prec) const;
MEDCOUPLING_EXPORT bool isEqualWithoutConsideringStr(const MEDCouplingMesh *other, double prec) const;
DataArrayInt *&cellCor) const throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT void checkFastEquivalWith(const MEDCouplingMesh *other, double prec) const throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT void checkCoherency() const throw(INTERP_KERNEL::Exception);
+ MEDCOUPLING_EXPORT void checkCoherency1(double eps=1e-12) const throw(INTERP_KERNEL::Exception);
+ MEDCOUPLING_EXPORT void checkCoherency2(double eps=1e-12) const throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT void setMeshDimension(int meshDim);
MEDCOUPLING_EXPORT void allocateCells(int nbOfCells);
- MEDCOUPLING_EXPORT void insertNextCell(INTERP_KERNEL::NormalizedCellType type, int size, const int *nodalConnOfCell);
+ MEDCOUPLING_EXPORT void insertNextCell(INTERP_KERNEL::NormalizedCellType type, int size, const int *nodalConnOfCell) throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT void finishInsertingCells();
MEDCOUPLING_EXPORT const std::set<INTERP_KERNEL::NormalizedCellType>& getAllTypes() const { return _types; }
+ MEDCOUPLING_EXPORT std::set<INTERP_KERNEL::NormalizedCellType> getTypesOfPart(const int *begin, const int *end) const throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT void setConnectivity(DataArrayInt *conn, DataArrayInt *connIndex, bool isComputingTypes=true);
- MEDCOUPLING_EXPORT DataArrayInt *getNodalConnectivity() const { return _nodal_connec; }
- MEDCOUPLING_EXPORT DataArrayInt *getNodalConnectivityIndex() const { return _nodal_connec_index; }
+ MEDCOUPLING_EXPORT const DataArrayInt *getNodalConnectivity() const { return _nodal_connec; }
+ MEDCOUPLING_EXPORT const DataArrayInt *getNodalConnectivityIndex() const { return _nodal_connec_index; }
+ MEDCOUPLING_EXPORT DataArrayInt *getNodalConnectivity() { return _nodal_connec; }
+ MEDCOUPLING_EXPORT DataArrayInt *getNodalConnectivityIndex() { return _nodal_connec_index; }
MEDCOUPLING_EXPORT INTERP_KERNEL::NormalizedCellType getTypeOfCell(int cellId) const;
MEDCOUPLING_EXPORT int getNumberOfCellsWithType(INTERP_KERNEL::NormalizedCellType type) const;
MEDCOUPLING_EXPORT void getNodeIdsOfCell(int cellId, std::vector<int>& conn) const;
MEDCOUPLING_EXPORT int getMeshLength() const;
MEDCOUPLING_EXPORT void computeTypes();
//! size of returned tinyInfo must be always the same.
- MEDCOUPLING_EXPORT void getTinySerializationInformation(std::vector<int>& tinyInfo, std::vector<std::string>& littleStrings) const;
+ MEDCOUPLING_EXPORT void getTinySerializationInformation(std::vector<double>& tinyInfoD, std::vector<int>& tinyInfo, std::vector<std::string>& littleStrings) const;
MEDCOUPLING_EXPORT bool isEmptyMesh(const std::vector<int>& tinyInfo) const;
MEDCOUPLING_EXPORT void resizeForUnserialization(const std::vector<int>& tinyInfo, DataArrayInt *a1, DataArrayDouble *a2, std::vector<std::string>& littleStrings) const;
MEDCOUPLING_EXPORT void serialize(DataArrayInt *&a1, DataArrayDouble *&a2) const;
- MEDCOUPLING_EXPORT void unserialization(const std::vector<int>& tinyInfo, const DataArrayInt *a1, DataArrayDouble *a2, const std::vector<std::string>& littleStrings);
+ MEDCOUPLING_EXPORT void unserialization(const std::vector<double>& tinyInfoD, const std::vector<int>& tinyInfo, const DataArrayInt *a1, DataArrayDouble *a2, const std::vector<std::string>& littleStrings);
//tools
MEDCOUPLING_EXPORT bool areCellsEqual(int cell1, int cell2, int compType) const;
MEDCOUPLING_EXPORT bool areCellsEqual0(int cell1, int cell2) const;
MEDCOUPLING_EXPORT bool areCellsEqual2(int cell1, int cell2) const;
MEDCOUPLING_EXPORT bool areCellsFrom2MeshEqual(const MEDCouplingUMesh *other, int cellId, double prec) const;
MEDCOUPLING_EXPORT void convertToPolyTypes(const std::vector<int>& cellIdsToConvert);
+ MEDCOUPLING_EXPORT void convertAllToPoly();
MEDCOUPLING_EXPORT void unPolyze();
- MEDCOUPLING_EXPORT DataArrayInt *zipCoordsTraducer();
- MEDCOUPLING_EXPORT DataArrayInt *zipConnectivityTraducer(int compType);
- MEDCOUPLING_EXPORT void getReverseNodalConnectivity(DataArrayInt *revNodal, DataArrayInt *revNodalIndx) const;
- MEDCOUPLING_EXPORT MEDCouplingUMesh *buildDescendingConnectivity(DataArrayInt *desc, DataArrayInt *descIndx, DataArrayInt *revDesc, DataArrayInt *revDescIndx) const;
+ MEDCOUPLING_EXPORT DataArrayInt *zipCoordsTraducer() throw(INTERP_KERNEL::Exception);
+ MEDCOUPLING_EXPORT DataArrayInt *zipConnectivityTraducer(int compType) throw(INTERP_KERNEL::Exception);
+ MEDCOUPLING_EXPORT bool areCellsIncludedIn(const MEDCouplingUMesh *other, int compType, DataArrayInt *& arr) const throw(INTERP_KERNEL::Exception);
+ MEDCOUPLING_EXPORT void getReverseNodalConnectivity(DataArrayInt *revNodal, DataArrayInt *revNodalIndx) const throw(INTERP_KERNEL::Exception);
+ MEDCOUPLING_EXPORT MEDCouplingUMesh *buildDescendingConnectivity(DataArrayInt *desc, DataArrayInt *descIndx, DataArrayInt *revDesc, DataArrayInt *revDescIndx) const throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT DataArrayInt *mergeNodes(double precision, bool& areNodesMerged, int& newNbOfNodes);
+ MEDCOUPLING_EXPORT DataArrayInt *mergeNodes2(double precision, bool& areNodesMerged, int& newNbOfNodes);
MEDCOUPLING_EXPORT void tryToShareSameCoordsPermute(const MEDCouplingPointSet& other, double epsilon) throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT MEDCouplingPointSet *buildPartOfMySelf(const int *begin, const int *end, bool keepCoords) const;
MEDCOUPLING_EXPORT MEDCouplingPointSet *buildPartOfMySelfNode(const int *begin, const int *end, bool fullyIn) const;
+ MEDCOUPLING_EXPORT DataArrayInt *getCellIdsLyingOnNodes(const int *begin, const int *end, bool fullyIn) const;
MEDCOUPLING_EXPORT MEDCouplingPointSet *buildFacePartOfMySelfNode(const int *begin, const int *end, bool fullyIn) const;
+ MEDCOUPLING_EXPORT MEDCouplingUMesh *buildUnstructured() const throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT void findBoundaryNodes(std::vector<int>& nodes) const;
MEDCOUPLING_EXPORT MEDCouplingPointSet *buildBoundaryMesh(bool keepCoords) const;
+ MEDCOUPLING_EXPORT DataArrayInt *findCellsIdsOnBoundary() const throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT void renumberNodes(const int *newNodeNumbers, int newNbOfNodes);
+ MEDCOUPLING_EXPORT void renumberNodes2(const int *newNodeNumbers, int newNbOfNodes);
MEDCOUPLING_EXPORT void renumberCells(const int *old2NewBg, bool check) throw(INTERP_KERNEL::Exception);
- MEDCOUPLING_EXPORT void giveElemsInBoundingBox(const double *bbox, double eps, std::vector<int>& elems);
- MEDCOUPLING_EXPORT void giveElemsInBoundingBox(const INTERP_KERNEL::DirectedBoundingBox& bbox, double eps, std::vector<int>& elems);
+ MEDCOUPLING_EXPORT void getCellsInBoundingBox(const double *bbox, double eps, std::vector<int>& elems);
+ MEDCOUPLING_EXPORT void getCellsInBoundingBox(const INTERP_KERNEL::DirectedBoundingBox& bbox, double eps, std::vector<int>& elems);
MEDCOUPLING_EXPORT MEDCouplingFieldDouble *getMeasureField(bool isAbs) const;
+ MEDCOUPLING_EXPORT DataArrayDouble *getPartMeasureField(bool isAbs, const int *begin, const int *end) const;
MEDCOUPLING_EXPORT MEDCouplingFieldDouble *getMeasureFieldOnNode(bool isAbs) const;
MEDCOUPLING_EXPORT MEDCouplingFieldDouble *buildOrthogonalField() const;
+ MEDCOUPLING_EXPORT MEDCouplingFieldDouble *buildPartOrthogonalField(const int *begin, const int *end) const;
MEDCOUPLING_EXPORT MEDCouplingFieldDouble *buildDirectionVectorField() const;
MEDCOUPLING_EXPORT bool isContiguous1D() const throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT void project1D(const double *pt, const double *v, double eps, double *res) const;
MEDCOUPLING_EXPORT void getCellsContainingPoints(const double *pos, int nbOfPoints, double eps, std::vector<int>& elts, std::vector<int>& eltsIndex) const;
MEDCOUPLING_EXPORT void checkButterflyCells(std::vector<int>& cells) const;
MEDCOUPLING_EXPORT void getBoundingBoxForBBTree(std::vector<double>& bbox) const;
- MEDCOUPLING_EXPORT MEDCouplingUMesh *buildExtrudedMeshFromThis(const MEDCouplingUMesh *mesh1D, int policy);
+ MEDCOUPLING_EXPORT MEDCouplingUMesh *buildExtrudedMesh(const MEDCouplingUMesh *mesh1D, int policy);
MEDCOUPLING_EXPORT bool isFullyQuadratic() const;
MEDCOUPLING_EXPORT bool isPresenceOfQuadratic() const;
MEDCOUPLING_EXPORT void convertQuadraticCellsToLinear() throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT MEDCouplingFieldDouble *getWarpField() const throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT MEDCouplingFieldDouble *getSkewField() const throw(INTERP_KERNEL::Exception);
//utilities for MED File RW
+ MEDCOUPLING_EXPORT DataArrayInt *checkTypeConsistencyAndContig(const std::vector<int>& code, const std::vector<const DataArrayInt *>& idsPerType) const throw(INTERP_KERNEL::Exception);
+ MEDCOUPLING_EXPORT MEDCouplingUMesh *emulateMEDMEMBDC(const MEDCouplingUMesh *nM1LevMesh, DataArrayInt *desc, DataArrayInt *descIndx, DataArrayInt *&revDesc, DataArrayInt *&revDescIndx, DataArrayInt *& nM1LevMeshIds, DataArrayInt *&meshnM1Old2New) const throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT bool checkConsecutiveCellTypes() const;
MEDCOUPLING_EXPORT bool checkConsecutiveCellTypesAndOrder(const INTERP_KERNEL::NormalizedCellType *orderBg, const INTERP_KERNEL::NormalizedCellType *orderEnd) const;
- MEDCOUPLING_EXPORT DataArrayInt *getRenumArrForConsecutiveCellTypesSpec(const INTERP_KERNEL::NormalizedCellType *orderBg, const INTERP_KERNEL::NormalizedCellType *orderEnd) const;
+ MEDCOUPLING_EXPORT DataArrayInt *getLevArrPerCellTypes(const INTERP_KERNEL::NormalizedCellType *orderBg, const INTERP_KERNEL::NormalizedCellType *orderEnd, DataArrayInt *&nbPerType) const throw(INTERP_KERNEL::Exception);
+ MEDCOUPLING_EXPORT DataArrayInt *getRenumArrForConsecutiveCellTypesSpec(const INTERP_KERNEL::NormalizedCellType *orderBg, const INTERP_KERNEL::NormalizedCellType *orderEnd) const throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT DataArrayInt *rearrange2ConsecutiveCellTypes();
MEDCOUPLING_EXPORT std::vector<MEDCouplingUMesh *> splitByType() const;
+ MEDCOUPLING_EXPORT DataArrayInt *keepCellIdsByType(INTERP_KERNEL::NormalizedCellType type, const int *begin, const int *end) const throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT DataArrayInt *convertCellArrayPerGeoType(const DataArrayInt *da) const throw(INTERP_KERNEL::Exception);
- MEDCOUPLING_EXPORT MEDCouplingUMesh *keepSpecifiedCells(INTERP_KERNEL::NormalizedCellType type, const std::vector<int>& idsPerGeoType) const;
+ MEDCOUPLING_EXPORT MEDCouplingUMesh *keepSpecifiedCells(INTERP_KERNEL::NormalizedCellType type, const int *idsPerGeoTypeBg, const int *idsPerGeoTypeEnd) const;
//
MEDCOUPLING_EXPORT MEDCouplingMesh *mergeMyselfWith(const MEDCouplingMesh *other) const;
MEDCOUPLING_EXPORT DataArrayDouble *getBarycenterAndOwner() const;
- MEDCOUPLING_EXPORT static MEDCouplingUMesh *mergeUMeshes(const MEDCouplingUMesh *mesh1, const MEDCouplingUMesh *mesh2);
- MEDCOUPLING_EXPORT static MEDCouplingUMesh *mergeUMeshesOnSameCoords(const std::vector<MEDCouplingUMesh *>& meshes);
- MEDCOUPLING_EXPORT static MEDCouplingUMesh *fuseUMeshesOnSameCoords(const std::vector<MEDCouplingUMesh *>& meshes, int compType, std::vector<DataArrayInt *>& corr);
- MEDCOUPLING_EXPORT static bool isPolygonWellOriented(const double *vec, const int *begin, const int *end, const double *coords);
- MEDCOUPLING_EXPORT static bool isPolyhedronWellOriented(const int *begin, const int *end, const double *coords);
- MEDCOUPLING_EXPORT static void tryToCorrectPolyhedronOrientation(int *begin, int *end, const double *coords) throw(INTERP_KERNEL::Exception);
+ MEDCOUPLING_EXPORT DataArrayDouble *getPartBarycenterAndOwner(const int *begin, const int *end) const;
+ MEDCOUPLING_EXPORT static MEDCouplingUMesh *Build0DMeshFromCoords(DataArrayDouble *da) throw(INTERP_KERNEL::Exception);
+ MEDCOUPLING_EXPORT static MEDCouplingUMesh *MergeUMeshes(const MEDCouplingUMesh *mesh1, const MEDCouplingUMesh *mesh2) throw(INTERP_KERNEL::Exception);
+ MEDCOUPLING_EXPORT static MEDCouplingUMesh *MergeUMeshes(std::vector<const MEDCouplingUMesh *>& a) throw(INTERP_KERNEL::Exception);
+ MEDCOUPLING_EXPORT static MEDCouplingUMesh *MergeUMeshesOnSameCoords(const MEDCouplingUMesh *mesh1, const MEDCouplingUMesh *mesh2) throw(INTERP_KERNEL::Exception);
+ MEDCOUPLING_EXPORT static MEDCouplingUMesh *MergeUMeshesOnSameCoords(const std::vector<const MEDCouplingUMesh *>& meshes);
+ MEDCOUPLING_EXPORT static MEDCouplingUMesh *FuseUMeshesOnSameCoords(const std::vector<const MEDCouplingUMesh *>& meshes, int compType, std::vector<DataArrayInt *>& corr);
+ MEDCOUPLING_EXPORT static bool IsPolygonWellOriented(const double *vec, const int *begin, const int *end, const double *coords);
+ MEDCOUPLING_EXPORT static bool IsPolyhedronWellOriented(const int *begin, const int *end, const double *coords);
+ MEDCOUPLING_EXPORT static void TryToCorrectPolyhedronOrientation(int *begin, int *end, const double *coords) throw(INTERP_KERNEL::Exception);
private:
MEDCouplingUMesh();
MEDCouplingUMesh(const MEDCouplingUMesh& other, bool deepCpy);
using namespace ParaMEDMEM;
-MEDCouplingUMeshDesc::MEDCouplingUMeshDesc():_mesh_dim(-1),_desc_connec(0),_desc_connec_index(0),
+MEDCouplingUMeshDesc::MEDCouplingUMeshDesc():_mesh_dim(-2),_desc_connec(0),_desc_connec_index(0),
_nodal_connec_face(0),_nodal_connec_face_index(0)
{
}
{
for(std::set<INTERP_KERNEL::NormalizedCellType>::const_iterator iter=_types.begin();iter!=_types.end();iter++)
{
- if(INTERP_KERNEL::CellModel::getCellModel(*iter).getDimension()!=_mesh_dim)
+ if((int)INTERP_KERNEL::CellModel::getCellModel(*iter).getDimension()!=_mesh_dim)
{
std::ostringstream message;
message << "MeshDesc invalid because dimension is " << _mesh_dim << " and there is presence of cell(s) with type " << (*iter);
}
}
+void MEDCouplingUMeshDesc::checkCoherency1(double eps) const throw(INTERP_KERNEL::Exception)
+{
+ checkCoherency();
+}
+
+void MEDCouplingUMeshDesc::checkCoherency2(double eps) const throw(INTERP_KERNEL::Exception)
+{
+ checkCoherency1(eps);
+}
+
void MEDCouplingUMeshDesc::checkDeepEquivalWith(const MEDCouplingMesh *other, int cellCompPol, double prec,
DataArrayInt *&cellCor, DataArrayInt *&nodeCor) const throw(INTERP_KERNEL::Exception)
{
void MEDCouplingUMeshDesc::setConnectivity(DataArrayInt *descConn, DataArrayInt *descConnIndex, DataArrayInt *nodalFaceConn, DataArrayInt *nodalFaceConnIndx)
{
- DataArrayInt::setArrayIn(descConn,_desc_connec);
- DataArrayInt::setArrayIn(descConnIndex,_desc_connec_index);
- DataArrayInt::setArrayIn(nodalFaceConn,_nodal_connec_face);
- DataArrayInt::setArrayIn(nodalFaceConnIndx,_nodal_connec_face_index);
+ DataArrayInt::SetArrayIn(descConn,_desc_connec);
+ DataArrayInt::SetArrayIn(descConnIndex,_desc_connec_index);
+ DataArrayInt::SetArrayIn(nodalFaceConn,_nodal_connec_face);
+ DataArrayInt::SetArrayIn(nodalFaceConnIndx,_nodal_connec_face_index);
computeTypes();
}
-void MEDCouplingUMeshDesc::getTinySerializationInformation(std::vector<int>& tinyInfo, std::vector<std::string>& littleStrings) const
+DataArrayInt *MEDCouplingUMeshDesc::checkTypeConsistencyAndContig(const std::vector<int>& code, const std::vector<const DataArrayInt *>& idsPerType) const throw(INTERP_KERNEL::Exception)
+{
+ throw INTERP_KERNEL::Exception("Not implemented yet !");
+}
+
+void MEDCouplingUMeshDesc::getTinySerializationInformation(std::vector<double>& tinyInfoD, std::vector<int>& tinyInfo, std::vector<std::string>& littleStrings) const
{
- MEDCouplingPointSet::getTinySerializationInformation(tinyInfo,littleStrings);
+ MEDCouplingPointSet::getTinySerializationInformation(tinyInfoD,tinyInfo,littleStrings);
tinyInfo.push_back(getMeshDimension());
tinyInfo.push_back(getNumberOfNodes());
tinyInfo.push_back(getNumberOfCells());
return tinyInfo[5]<=0;
}
-void MEDCouplingUMeshDesc::resizeForUnserialization(const std::vector<int>& tinyInfo, DataArrayInt *a1, DataArrayDouble *a2, std::vector<std::string>& littleStrings)
+void MEDCouplingUMeshDesc::resizeForUnserialization(const std::vector<int>& tinyInfo, DataArrayInt *a1, DataArrayDouble *a2, std::vector<std::string>& littleStrings) const
{
std::vector<int> tinyInfoTmp(tinyInfo.begin()+1,tinyInfo.end());
MEDCouplingPointSet::resizeForUnserialization(tinyInfoTmp,a1,a2,littleStrings);
std::copy(faceConnIndex,faceConnIndex+getNumberOfFaces()+1,ptA1);
}
-void MEDCouplingUMeshDesc::unserialization(const std::vector<int>& tinyInfo, DataArrayInt *a1, DataArrayDouble *a2, const std::vector<std::string>& littleStrings)
+void MEDCouplingUMeshDesc::unserialization(const std::vector<double>& tinyInfoD, const std::vector<int>& tinyInfo, const DataArrayInt *a1, DataArrayDouble *a2, const std::vector<std::string>& littleStrings)
{
std::vector<int> tinyInfoTmp(tinyInfo.begin()+1,tinyInfo.end());
- MEDCouplingPointSet::unserialization(tinyInfoTmp,a1,a2,littleStrings);
+ MEDCouplingPointSet::unserialization(tinyInfoD,tinyInfoTmp,a1,a2,littleStrings);
//
const int *recvBuffer=a1->getConstPointer();
DataArrayInt *descConn=DataArrayInt::New();
setMeshDimension(tinyInfo[2]);
}
-void MEDCouplingUMeshDesc::giveElemsInBoundingBox(const double *bbox, double eps, std::vector<int>& elems)
+void MEDCouplingUMeshDesc::getCellsInBoundingBox(const double *bbox, double eps, std::vector<int>& elems)
{
int dim=getSpaceDimension();
double* elem_bb=new double[2*dim];
delete [] elem_bb;
}
-void MEDCouplingUMeshDesc::giveElemsInBoundingBox(const INTERP_KERNEL::DirectedBoundingBox &bbox, double eps, std::vector<int>& elems)
+void MEDCouplingUMeshDesc::getCellsInBoundingBox(const INTERP_KERNEL::DirectedBoundingBox &bbox, double eps, std::vector<int>& elems)
{
int dim=getSpaceDimension();
double* elem_bb=new double[2*dim];
return 0;
}
+DataArrayInt *MEDCouplingUMeshDesc::mergeNodes2(double precision, bool& areNodesMerged, int& newNbOfNodes)
+{
+ //not implemented yet.
+ areNodesMerged=false;
+ return 0;
+}
+
void MEDCouplingUMeshDesc::tryToShareSameCoordsPermute(const MEDCouplingPointSet& other, double epsilon) throw(INTERP_KERNEL::Exception)
{
throw INTERP_KERNEL::Exception("Not implemented yet !");
return 0;
}
+MEDCouplingUMesh *MEDCouplingUMeshDesc::buildUnstructured() const throw(INTERP_KERNEL::Exception)
+{
+ throw INTERP_KERNEL::Exception("MEDCouplingUMeshDesc::buildUnstructured : not implemented yet !");
+}
+
void MEDCouplingUMeshDesc::renumberCells(const int *old2NewBg, bool check) throw(INTERP_KERNEL::Exception)
{
throw INTERP_KERNEL::Exception("Available for UMesh desc but not implemented yet !");
int MEDCouplingUMeshDesc::getCellContainingPoint(const double *pos, double eps) const
{
- //not implemented yet.
- return -1;
+ throw INTERP_KERNEL::Exception("MEDCouplingUMeshDesc::getCellContainingPoint : not implemented yet !");
}
MEDCOUPLING_EXPORT static MEDCouplingUMeshDesc *New(const char *meshName, int meshDim);
MEDCOUPLING_EXPORT MEDCouplingMesh *deepCpy() const;
MEDCOUPLING_EXPORT void checkCoherency() const throw(INTERP_KERNEL::Exception);
+ MEDCOUPLING_EXPORT void checkCoherency1(double eps=1e-12) const throw(INTERP_KERNEL::Exception);
+ MEDCOUPLING_EXPORT void checkCoherency2(double eps=1e-12) const throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT void checkDeepEquivalWith(const MEDCouplingMesh *other, int cellCompPol, double prec,
DataArrayInt *&cellCor, DataArrayInt *&nodeCor) const throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT void checkDeepEquivalOnSameNodesWith(const MEDCouplingMesh *other, int cellCompPol, double prec,
MEDCOUPLING_EXPORT MEDCouplingMeshType getType() const { return UNSTRUCTURED_DESC; }
MEDCOUPLING_EXPORT void setConnectivity(DataArrayInt *descConn, DataArrayInt *descConnIndex, DataArrayInt *nodalFaceConn, DataArrayInt *nodalFaceConnIndx);
//tools to overload
- MEDCOUPLING_EXPORT void getTinySerializationInformation(std::vector<int>& tinyInfo, std::vector<std::string>& littleStrings) const;
+ MEDCOUPLING_EXPORT DataArrayInt *checkTypeConsistencyAndContig(const std::vector<int>& code, const std::vector<const DataArrayInt *>& idsPerType) const throw(INTERP_KERNEL::Exception);
+ MEDCOUPLING_EXPORT void getTinySerializationInformation(std::vector<double>& tinyInfoD, std::vector<int>& tinyInfo, std::vector<std::string>& littleStrings) const;
MEDCOUPLING_EXPORT bool isEmptyMesh(const std::vector<int>& tinyInfo) const;
- MEDCOUPLING_EXPORT void resizeForUnserialization(const std::vector<int>& tinyInfo, DataArrayInt *a1, DataArrayDouble *a2, std::vector<std::string>& littleStrings);
+ MEDCOUPLING_EXPORT void resizeForUnserialization(const std::vector<int>& tinyInfo, DataArrayInt *a1, DataArrayDouble *a2, std::vector<std::string>& littleStrings) const;
MEDCOUPLING_EXPORT void serialize(DataArrayInt *&a1, DataArrayDouble *&a2) const;
- MEDCOUPLING_EXPORT void unserialization(const std::vector<int>& tinyInfo, DataArrayInt *a1, DataArrayDouble *a2, const std::vector<std::string>& littleStrings);
- MEDCOUPLING_EXPORT void giveElemsInBoundingBox(const double *bbox, double eps, std::vector<int>& elems);
- MEDCOUPLING_EXPORT void giveElemsInBoundingBox(const INTERP_KERNEL::DirectedBoundingBox &bbox, double eps, std::vector<int>& elems);
+ MEDCOUPLING_EXPORT void unserialization(const std::vector<double>& tinyInfoD, const std::vector<int>& tinyInfo, const DataArrayInt *a1, DataArrayDouble *a2, const std::vector<std::string>& littleStrings);
+ MEDCOUPLING_EXPORT void getCellsInBoundingBox(const double *bbox, double eps, std::vector<int>& elems);
+ MEDCOUPLING_EXPORT void getCellsInBoundingBox(const INTERP_KERNEL::DirectedBoundingBox &bbox, double eps, std::vector<int>& elems);
MEDCOUPLING_EXPORT DataArrayInt *mergeNodes(double precision, bool& areNodesMerged, int& newNbOfNodes);
+ MEDCOUPLING_EXPORT DataArrayInt *mergeNodes2(double precision, bool& areNodesMerged, int& newNbOfNodes);
MEDCOUPLING_EXPORT void tryToShareSameCoordsPermute(const MEDCouplingPointSet& other, double epsilon) throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT MEDCouplingPointSet *buildPartOfMySelf(const int *start, const int *end, bool keepCoords) const;
MEDCOUPLING_EXPORT MEDCouplingPointSet *buildPartOfMySelfNode(const int *start, const int *end, bool fullyIn) const;
MEDCOUPLING_EXPORT DataArrayInt *simplexize(int policy) throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT void findBoundaryNodes(std::vector<int>& nodes) const;
MEDCOUPLING_EXPORT MEDCouplingPointSet *buildBoundaryMesh(bool keepCoords) const;
+ MEDCOUPLING_EXPORT MEDCouplingUMesh *buildUnstructured() const throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT void renumberCells(const int *old2NewBg, bool check) throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT void renumberNodes(const int *newNodeNumbers, int newNbOfNodes);
MEDCOUPLING_EXPORT MEDCouplingFieldDouble *getMeasureField(bool isAbs) const;
void computeTypes();
void checkFullyDefined() const throw(INTERP_KERNEL::Exception);
private:
- unsigned _mesh_dim;
+ int _mesh_dim;
DataArrayInt *_desc_connec;
DataArrayInt *_desc_connec_index;
DataArrayInt *_nodal_connec_face;
MEDCouplingNormalizedUnstructuredMesh.txx MEDCouplingMemArray.txx MEDCouplingRefCountObject.hxx \
MEDCouplingCMesh.hxx MEDCouplingTimeDiscretization.hxx \
MEDCouplingFieldDiscretization.hxx MEDCouplingPointSet.hxx MEDCouplingPointSet.txx \
-MEDCouplingUMeshDesc.hxx MEDCouplingNatureOfField.hxx \
+MEDCouplingUMeshDesc.hxx MEDCouplingNatureOfField.hxx MEDCouplingFieldTemplate.hxx \
MEDCouplingNormalizedCartesianMesh.hxx MEDCouplingNormalizedCartesianMesh.txx \
MEDCouplingRemapper.hxx MEDCouplingExtrudedMesh.hxx MEDCouplingGaussLocalization.hxx \
-MEDCouplingAutoRefCountObjectPtr.hxx
+MEDCouplingAutoRefCountObjectPtr.hxx MEDCouplingMultiFields.hxx MEDCouplingDefinitionTime.hxx \
+MEDCouplingFieldOverTime.hxx
# Libraries targets
MEDCouplingUMesh.cxx MEDCouplingMemArray.cxx MEDCouplingTimeLabel.cxx \
MEDCouplingCMesh.cxx MEDCouplingTimeDiscretization.cxx \
MEDCouplingFieldDiscretization.cxx MEDCouplingRefCountObject.cxx \
- MEDCouplingPointSet.cxx MEDCouplingUMeshDesc.cxx \
+ MEDCouplingPointSet.cxx MEDCouplingUMeshDesc.cxx MEDCouplingFieldTemplate.cxx \
MEDCouplingExtrudedMesh.cxx MEDCouplingMesh.cxx MEDCouplingGaussLocalization.cxx \
- MEDCouplingNatureOfField.cxx
+ MEDCouplingNatureOfField.cxx MEDCouplingMultiFields.cxx \
+ MEDCouplingDefinitionTime.cxx MEDCouplingFieldOverTime.cxx
libmedcoupling_la_LDFLAGS=
libmedcoupling_la_CPPFLAGS= @CXXTMPDPTHFLAGS@ \
-I$(srcdir) -I$(srcdir)/../INTERP_KERNEL/Bases \
-I$(srcdir)/../INTERP_KERNEL -I$(srcdir)/../INTERP_KERNEL/Geometric2D \
- -I$(srcdir)/../INTERP_KERNEL/ExprEval
+ -I$(srcdir)/../INTERP_KERNEL/ExprEval -I$(srcdir)/../INTERP_KERNEL/GaussPoints
# the geom2D library is included in the interpkernel one
libmedcoupling_la_LIBADD= ../INTERP_KERNEL/libinterpkernel.la
MEDCouplingNatureOfField.hxx \
MEDCouplingRemapper.hxx \
MEDCouplingExtrudedMesh.hxx \
- MEDCouplingGaussLocalization.hxx
+ MEDCouplingGaussLocalization.hxx \
+ MEDCouplingMultiFields.hxx \
+ MEDCouplingFieldTemplate.hxx \
+ MEDCouplingDefinitionTime.hxx \
+ MEDCouplingFieldOverTime.hxx
namespace ParaMEDMEM
{
+ class DataArrayDouble;
class MEDCouplingUMesh;
+ class MEDCouplingFieldDouble;
+ class MEDCouplingMultiFields;
class MEDCouplingBasicsTest : public CppUnit::TestFixture
{
CPPUNIT_TEST( testFillFromAnalytic3 );
CPPUNIT_TEST( testFieldDoubleOpEqual1 );
CPPUNIT_TEST( testAreaBary3D2 );
+ //MEDCouplingBasicsTest3.cxx
CPPUNIT_TEST( testGetMeasureFieldCMesh1 );
CPPUNIT_TEST( testFieldDoubleZipCoords1 );
CPPUNIT_TEST( testFieldDoubleZipConnectivity1 );
CPPUNIT_TEST( testExtrudedMesh7 );
CPPUNIT_TEST( testSimplexize1 );
CPPUNIT_TEST( testSimplexize2 );
+ CPPUNIT_TEST( testDAMeld1 );
+ CPPUNIT_TEST( testFieldMeld1 );
+ CPPUNIT_TEST( testMergeNodes2 );
+ CPPUNIT_TEST( testMergeField2 );
+ CPPUNIT_TEST( testDAIBuildComplement1 );
+ CPPUNIT_TEST( testDAIBuildUnion1 );
+ CPPUNIT_TEST( testDAIBuildIntersection1 );
+ CPPUNIT_TEST( testDAIDeltaShiftIndex1 );
+ CPPUNIT_TEST( testDaDoubleSelectByTupleIdSafe1 );
+ CPPUNIT_TEST( testAreCellsIncludedIn1 );
+ CPPUNIT_TEST( testDAIBuildSubstraction1 );
+ CPPUNIT_TEST( testBuildOrthogonalField2 );
+ CPPUNIT_TEST( testUMInsertNextCell1 );
+ CPPUNIT_TEST( testFieldOperatorDivDiffComp1 );
+ CPPUNIT_TEST( testDARearrange1 );
+ CPPUNIT_TEST( testGetDifferentValues1 );
+ CPPUNIT_TEST( testDAIBuildPermutationArr1 );
+ CPPUNIT_TEST( testAreCellsIncludedIn2 );
+ CPPUNIT_TEST( testUMeshGetPartBarycenterAndOwner1 );
+ CPPUNIT_TEST( testUMeshGetPartMeasureField1 );
+ CPPUNIT_TEST( testUMeshBuildPartOrthogonalField1 );
+ CPPUNIT_TEST( testUMeshGetTypesOfPart1 );
+ CPPUNIT_TEST( testUMeshKeepCellIdsByType1 );
+ CPPUNIT_TEST( testDAIAggregateMulti1 );
+ CPPUNIT_TEST( testMergeUMeshes2 );
+ CPPUNIT_TEST( testBuild0DMeshFromCoords1 );
+ //MEDCouplingBasicsTest4.cxx
+ CPPUNIT_TEST( testDescriptionInMeshTimeUnit1 );
+ CPPUNIT_TEST( testMultiFields1 );
+ CPPUNIT_TEST( testFieldOverTime1 );
+ CPPUNIT_TEST( testDAICheckAndPreparePermutation1 );
+ CPPUNIT_TEST( testDAIChangeSurjectiveFormat1 );
+ CPPUNIT_TEST( testUMeshGetCellIdsLyingOnNodes1 );
+ CPPUNIT_TEST( testUMeshFindCellsIdsOnBoundary1 );
+ CPPUNIT_TEST( testMeshSetTime1 );
+ CPPUNIT_TEST( testApplyFuncTwo1 );
+ CPPUNIT_TEST( testApplyFuncThree1 );
+ CPPUNIT_TEST( testFillFromAnalyticTwo1 );
+ CPPUNIT_TEST( testFillFromAnalyticThree1 );
+ CPPUNIT_TEST( testDAUnitVar1 );
+ CPPUNIT_TEST( testGaussCoordinates1 );
+ CPPUNIT_TEST( testP2Localization1 );
+ CPPUNIT_TEST( testP2Localization2 );
+ CPPUNIT_TEST( testGetValueOn2 );
+ CPPUNIT_TEST( testDAIGetIdsNotEqual1 );
+ CPPUNIT_TEST( testDAIComputeOffsets1 );
+ CPPUNIT_TEST( testUMeshHexagonPrism1 );
+ CPPUNIT_TEST( testDADCheckIsMonotonic );
+ CPPUNIT_TEST( testCheckCoherencyDeeper1 );
+ CPPUNIT_TEST( testUnPolyze2 );
+ CPPUNIT_TEST( testDACpyFrom1 );
+ CPPUNIT_TEST( testDAITransformWithIndArr1 );
+ CPPUNIT_TEST( testDAIBuildPermArrPerLevel1 );
+ CPPUNIT_TEST( testDAIOperations1 );
+ CPPUNIT_TEST( testEmulateMEDMEMBDC1 );
+ CPPUNIT_TEST( testGetLevArrPerCellTypes1 );
//MEDCouplingBasicsTestInterp.cxx
CPPUNIT_TEST( test2DInterpP0P0_1 );
CPPUNIT_TEST( test2DInterpP0P0PL_1 );
void testFillFromAnalytic3();
void testFieldDoubleOpEqual1();
void testAreaBary3D2();
+ //MEDCouplingBasicsTest3.cxx
void testGetMeasureFieldCMesh1();
void testFieldDoubleZipCoords1();
void testFieldDoubleZipConnectivity1();
void testExtrudedMesh7();
void testSimplexize1();
void testSimplexize2();
+ void testDAMeld1();
+ void testFieldMeld1();
+ void testMergeNodes2();
+ void testMergeField2();
+ void testDAIBuildComplement1();
+ void testDAIBuildUnion1();
+ void testDAIBuildIntersection1();
+ void testDAIDeltaShiftIndex1();
+ void testDaDoubleSelectByTupleIdSafe1();
+ void testAreCellsIncludedIn1();
+ void testDAIBuildSubstraction1();
+ void testBuildOrthogonalField2();
+ void testUMInsertNextCell1();
+ void testFieldOperatorDivDiffComp1();
+ void testDARearrange1();
+ void testGetDifferentValues1();
+ void testDAIBuildPermutationArr1();
+ void testAreCellsIncludedIn2();
+ void testUMeshGetPartBarycenterAndOwner1();
+ void testUMeshGetPartMeasureField1();
+ void testUMeshBuildPartOrthogonalField1();
+ void testUMeshGetTypesOfPart1();
+ void testUMeshKeepCellIdsByType1();
+ void testDAIAggregateMulti1();
+ void testMergeUMeshes2();
+ void testBuild0DMeshFromCoords1();
+ //MEDCouplingBasicsTest4.cxx
+ void testDescriptionInMeshTimeUnit1();
+ void testMultiFields1();
+ void testFieldOverTime1();
+ void testDAICheckAndPreparePermutation1();
+ void testDAIChangeSurjectiveFormat1();
+ void testUMeshGetCellIdsLyingOnNodes1();
+ void testUMeshFindCellsIdsOnBoundary1();
+ void testMeshSetTime1();
+ void testApplyFuncTwo1();
+ void testApplyFuncThree1();
+ void testFillFromAnalyticTwo1();
+ void testFillFromAnalyticThree1();
+ void testDAUnitVar1();
+ void testGaussCoordinates1();
+ void testQ1Localization1();
+ void testP2Localization1();
+ void testP2Localization2();
+ void testGetValueOn2();
+ void testDAIGetIdsNotEqual1();
+ void testDAIComputeOffsets1();
+ void testUMeshHexagonPrism1();
+ void testDADCheckIsMonotonic();
+ void testCheckCoherencyDeeper1();
+ void testUnPolyze2();
+ void testDACpyFrom1();
+ void testDAITransformWithIndArr1();
+ void testDAIBuildPermArrPerLevel1();
+ void testDAIOperations1();
+ void testEmulateMEDMEMBDC1();
+ void testGetLevArrPerCellTypes1();
//MEDCouplingBasicsTestInterp.cxx
void test2DInterpP0P0_1();
void test2DInterpP0P0PL_1();
static MEDCouplingUMesh *build2DTargetMesh_3();
static MEDCouplingUMesh *build3DTargetMesh_3();
static MEDCouplingUMesh *build2DTargetMesh_4();
+ static MEDCouplingUMesh *build1DMultiTypes_1();
+ static MEDCouplingUMesh *build2DMultiTypes_1();
+ static MEDCouplingUMesh *build3DMultiTypes_1();
+ static MEDCouplingUMesh *buildHexa8Mesh_1();
+ static MEDCouplingUMesh *buildPointe_1(MEDCouplingUMesh *&m1);
+ static DataArrayDouble *buildCoordsForMultiTypes_1();
+ static MEDCouplingMultiFields *buildMultiFields_1();
+ static std::vector<MEDCouplingFieldDouble *> buildMultiFields_2();
static double sumAll(const std::vector< std::map<int,double> >& matrix);
};
}
#include "MEDCouplingExtrudedMesh.hxx"
#include "MEDCouplingFieldDouble.hxx"
#include "MEDCouplingMemArray.hxx"
+#include "MEDCouplingMultiFields.hxx"
#include "MEDCouplingBasicsTestData1.hxx"
MEDCouplingUMesh *MEDCouplingBasicsTest::build3DExtrudedUMesh_1(MEDCouplingUMesh *&mesh2D)
{
double coords[180]={
- 0.,0.,0., 1.,1.,0., 1.,1.25,0., 0.,1.,0., 1.,1.5,0., 2.,0.,0., 2.,1.,0., 1.,2.,0., 0.,2.,0., 3.,1.,0.,
+ 0.,0.,0., 1.,1.,0., 1.,1.25,0., 1.,0.,0., 1.,1.5,0., 2.,0.,0., 2.,1.,0., 1.,2.,0., 0.,2.,0., 3.,1.,0.,
3.,2.,0., 0.,1.,0., 1.,3.,0., 2.,2.,0., 2.,3.,0.,
- 0.,0.,1., 1.,1.,1., 1.,1.25,1., 0.,1.,1., 1.,1.5,1., 2.,0.,1., 2.,1.,1., 1.,2.,1., 0.,2.,1., 3.,1.,1.,
+ 0.,0.,1., 1.,1.,1., 1.,1.25,1., 1.,0.,1., 1.,1.5,1., 2.,0.,1., 2.,1.,1., 1.,2.,1., 0.,2.,1., 3.,1.,1.,
3.,2.,1., 0.,1.,1., 1.,3.,1., 2.,2.,1., 2.,3.,1.,
- 0.,0.,2., 1.,1.,2., 1.,1.25,2., 0.,1.,2., 1.,1.5,2., 2.,0.,2., 2.,1.,2., 1.,2.,2., 0.,2.,2., 3.,1.,2.,
+ 0.,0.,2., 1.,1.,2., 1.,1.25,2., 1.,0.,2., 1.,1.5,2., 2.,0.,2., 2.,1.,2., 1.,2.,2., 0.,2.,2., 3.,1.,2.,
3.,2.,2., 0.,1.,2., 1.,3.,2., 2.,2.,2., 2.,3.,2.,
- 0.,0.,3., 1.,1.,3., 1.,1.25,3., 0.,1.,3., 1.,1.5,3., 2.,0.,3., 2.,1.,3., 1.,2.,3., 0.,2.,3., 3.,1.,3.,
+ 0.,0.,3., 1.,1.,3., 1.,1.25,3., 1.,0.,3., 1.,1.5,3., 2.,0.,3., 2.,1.,3., 1.,2.,3., 0.,2.,3., 3.,1.,3.,
3.,2.,3., 0.,1.,3., 1.,3.,3., 2.,2.,3., 2.,3.,3.};
int conn[354]={
return 0;
}
+MEDCouplingMultiFields *MEDCouplingBasicsTest::buildMultiFields_1()
+{
+ ParaMEDMEM::MEDCouplingUMesh *m1=build2DTargetMesh_1();
+ m1->setName("m1");
+ ParaMEDMEM::MEDCouplingUMesh *m2=build2DTargetMesh_1();
+ m2->setName("m2");
+ const double vals0[]={-0.7,-1.,-2.,-3.,-4.};
+ const double vals1[]={0.,1.,2.,3.,4.,0.1,0.2,0.3,0.4};
+ const double vals1_1[]={170.,171.,172.,173.,174.,170.1,170.2,170.3,170.4};
+ const double vals2[]={5.,6.,7.,8.,9.};
+ const double vals4[]={15.,16.,17.,18.,19.};
+ //
+ ParaMEDMEM::DataArrayDouble *d0=ParaMEDMEM::DataArrayDouble::New(); d0->alloc(5,1); std::copy(vals0,vals0+5,d0->getPointer());
+ ParaMEDMEM::DataArrayDouble *d1=ParaMEDMEM::DataArrayDouble::New(); d1->alloc(9,1); std::copy(vals1,vals1+9,d1->getPointer());
+ ParaMEDMEM::DataArrayDouble *d1_1=ParaMEDMEM::DataArrayDouble::New(); d1_1->alloc(9,1); std::copy(vals1_1,vals1_1+9,d1_1->getPointer());
+ ParaMEDMEM::DataArrayDouble *d2=ParaMEDMEM::DataArrayDouble::New(); d2->alloc(5,1); std::copy(vals2,vals2+5,d2->getPointer());
+ ParaMEDMEM::DataArrayDouble *d4=ParaMEDMEM::DataArrayDouble::New(); d4->alloc(5,1); std::copy(vals4,vals4+5,d4->getPointer());
+ //
+ d0->setName("d0"); d1->setName("d1"); d1_1->setName("d1_1"); d2->setName("d2"); d4->setName("d4");
+ d0->setInfoOnComponent(0,"c1");
+ d1->setInfoOnComponent(0,"c6");
+ d1_1->setInfoOnComponent(0,"c9");
+ d2->setInfoOnComponent(0,"c5");
+ d4->setInfoOnComponent(0,"c7");
+ //
+ ParaMEDMEM::MEDCouplingFieldDouble *f0=ParaMEDMEM::MEDCouplingFieldDouble::New(ParaMEDMEM::ON_CELLS,ParaMEDMEM::ONE_TIME);
+ f0->setMesh(m1);
+ f0->setArray(d0);
+ f0->setTime(0.2,5,6);
+ f0->setName("f0");
+ ParaMEDMEM::MEDCouplingFieldDouble *f1=ParaMEDMEM::MEDCouplingFieldDouble::New(ParaMEDMEM::ON_NODES,ParaMEDMEM::LINEAR_TIME);
+ f1->setMesh(m1);
+ std::vector<ParaMEDMEM::DataArrayDouble *> d1s(2); d1s[0]=d1; d1s[1]=d1_1;
+ f1->setArrays(d1s);
+ f1->setStartTime(0.7,7,8);
+ f1->setEndTime(1.2,9,10);
+ f1->setName("f1");
+ ParaMEDMEM::MEDCouplingFieldDouble *f2=ParaMEDMEM::MEDCouplingFieldDouble::New(ParaMEDMEM::ON_CELLS,ParaMEDMEM::CONST_ON_TIME_INTERVAL);
+ f2->setMesh(m2);
+ f2->setArray(d2);
+ f2->setTime(1.2,11,12);
+ f2->setEndTime(1.5,13,14);
+ f2->setName("f2");
+ ParaMEDMEM::MEDCouplingFieldDouble *f3=ParaMEDMEM::MEDCouplingFieldDouble::New(ParaMEDMEM::ON_CELLS,ParaMEDMEM::ONE_TIME);
+ f3->setMesh(m1);
+ f3->setArray(d2);
+ f3->setTime(1.7,15,16);
+ f3->setName("f3");
+ ParaMEDMEM::MEDCouplingFieldDouble *f4=ParaMEDMEM::MEDCouplingFieldDouble::New(ParaMEDMEM::ON_CELLS,ParaMEDMEM::NO_TIME);
+ f4->setMesh(m2);
+ f4->setArray(d4);
+ f4->setName("f4");
+ //
+ std::vector<ParaMEDMEM::MEDCouplingFieldDouble *> fs(5);
+ fs[0]=f0; fs[1]=f1; fs[2]=f2; fs[3]=f3; fs[4]=f4;
+ ParaMEDMEM::MEDCouplingMultiFields *ret=ParaMEDMEM::MEDCouplingMultiFields::New(fs);
+ //
+ m1->decrRef();
+ m2->decrRef();
+ d0->decrRef();
+ d1->decrRef();
+ d1_1->decrRef();
+ d2->decrRef();
+ d4->decrRef();
+ f0->decrRef();
+ f1->decrRef();
+ f2->decrRef();
+ f3->decrRef();
+ f4->decrRef();
+ //
+ return ret;
+}
+
+std::vector<MEDCouplingFieldDouble *> MEDCouplingBasicsTest::buildMultiFields_2()
+{
+ ParaMEDMEM::MEDCouplingUMesh *m1=build2DTargetMesh_1();
+ m1->setName("m1");
+ ParaMEDMEM::MEDCouplingUMesh *m2=build2DTargetMesh_1();
+ m2->setName("m2");
+ const double vals0[]={-0.7,-1.,-2.,-3.,-4.};
+ const double vals1[]={0.,1.,2.,3.,4.};
+ const double vals1_1[]={170.,171.,172.,173.,174.};
+ const double vals2[]={5.,6.,7.,8.,9.};
+ const double vals4[]={15.,16.,17.,18.,19.};
+ //
+ ParaMEDMEM::DataArrayDouble *d0=ParaMEDMEM::DataArrayDouble::New(); d0->alloc(5,1); std::copy(vals0,vals0+5,d0->getPointer());
+ ParaMEDMEM::DataArrayDouble *d1=ParaMEDMEM::DataArrayDouble::New(); d1->alloc(5,1); std::copy(vals1,vals1+5,d1->getPointer());
+ ParaMEDMEM::DataArrayDouble *d1_1=ParaMEDMEM::DataArrayDouble::New(); d1_1->alloc(5,1); std::copy(vals1_1,vals1_1+5,d1_1->getPointer());
+ ParaMEDMEM::DataArrayDouble *d2=ParaMEDMEM::DataArrayDouble::New(); d2->alloc(5,1); std::copy(vals2,vals2+5,d2->getPointer());
+ ParaMEDMEM::DataArrayDouble *d4=ParaMEDMEM::DataArrayDouble::New(); d4->alloc(5,1); std::copy(vals4,vals4+5,d4->getPointer());
+ //
+ d0->setName("d0"); d1->setName("d1"); d1_1->setName("d1_1"); d2->setName("d2"); d4->setName("d4");
+ d0->setInfoOnComponent(0,"c1");
+ d1->setInfoOnComponent(0,"c6");
+ d1_1->setInfoOnComponent(0,"c9");
+ d2->setInfoOnComponent(0,"c5");
+ d4->setInfoOnComponent(0,"c7");
+ //
+ ParaMEDMEM::MEDCouplingFieldDouble *f0=ParaMEDMEM::MEDCouplingFieldDouble::New(ParaMEDMEM::ON_CELLS,ParaMEDMEM::ONE_TIME);
+ f0->setMesh(m1);
+ f0->setArray(d0);
+ f0->setTime(0.2,5,6);
+ f0->setName("f0");
+ ParaMEDMEM::MEDCouplingFieldDouble *f1=ParaMEDMEM::MEDCouplingFieldDouble::New(ParaMEDMEM::ON_CELLS,ParaMEDMEM::LINEAR_TIME);
+ f1->setMesh(m1);
+ std::vector<ParaMEDMEM::DataArrayDouble *> d1s(2); d1s[0]=d1; d1s[1]=d1_1;
+ f1->setArrays(d1s);
+ f1->setStartTime(0.7,7,8);
+ f1->setEndTime(1.2,9,10);
+ f1->setName("f1");
+ ParaMEDMEM::MEDCouplingFieldDouble *f2=ParaMEDMEM::MEDCouplingFieldDouble::New(ParaMEDMEM::ON_CELLS,ParaMEDMEM::CONST_ON_TIME_INTERVAL);
+ f2->setMesh(m2);
+ f2->setArray(d2);
+ f2->setTime(1.2,11,12);
+ f2->setEndTime(1.5,13,14);
+ f2->setName("f2");
+ ParaMEDMEM::MEDCouplingFieldDouble *f3=ParaMEDMEM::MEDCouplingFieldDouble::New(ParaMEDMEM::ON_CELLS,ParaMEDMEM::ONE_TIME);
+ f3->setMesh(m1);
+ f3->setArray(d2);
+ f3->setTime(1.7,15,16);
+ f3->setName("f3");
+ ParaMEDMEM::MEDCouplingFieldDouble *f4=ParaMEDMEM::MEDCouplingFieldDouble::New(ParaMEDMEM::ON_CELLS,ParaMEDMEM::NO_TIME);
+ f4->setMesh(m2);
+ f4->setArray(d4);
+ f4->setName("f4");
+ //
+ std::vector<ParaMEDMEM::MEDCouplingFieldDouble *> fs(5);
+ fs[0]=f0; fs[1]=f1; fs[2]=f2; fs[3]=f3; fs[4]=f4;
+ m1->decrRef();
+ m2->decrRef();
+ d0->decrRef();
+ d1->decrRef();
+ d1_1->decrRef();
+ d2->decrRef();
+ d4->decrRef();
+ //
+ return fs;
+}
+
+MEDCouplingUMesh *MEDCouplingBasicsTest::build1DMultiTypes_1()
+{
+ MEDCouplingUMesh *mesh=MEDCouplingUMesh::New("Multi1DMesh",1);
+ DataArrayDouble *coo=buildCoordsForMultiTypes_1();
+ const int conn[5]={0,2, 0,2,1};
+ mesh->allocateCells(2);
+ mesh->insertNextCell(INTERP_KERNEL::NORM_SEG2,2,conn);
+ mesh->insertNextCell(INTERP_KERNEL::NORM_SEG3,3,conn+2);
+ mesh->finishInsertingCells();
+ mesh->setCoords(coo);
+ coo->decrRef();
+ return mesh;
+}
+
+MEDCouplingUMesh *MEDCouplingBasicsTest::build2DMultiTypes_1()
+{
+ MEDCouplingUMesh *mesh=MEDCouplingUMesh::New("Multi2DMesh",2);
+ DataArrayDouble *coo=buildCoordsForMultiTypes_1();
+ const int conn[21]={3,4,5, 3,4,5,6,7,8, 0,9,10,11, 0,9,10,11,12,13,14,15};
+ mesh->allocateCells(4);
+ mesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,conn);
+ mesh->insertNextCell(INTERP_KERNEL::NORM_TRI6,6,conn+3);
+ mesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,conn+9);
+ mesh->insertNextCell(INTERP_KERNEL::NORM_QUAD8,8,conn+13);
+ mesh->finishInsertingCells();
+ mesh->setCoords(coo);
+ coo->decrRef();
+ return mesh;
+}
+
+MEDCouplingUMesh *MEDCouplingBasicsTest::build3DMultiTypes_1()
+{
+ MEDCouplingUMesh *mesh=MEDCouplingUMesh::New("Multi3DMesh",3);
+ DataArrayDouble *coo=buildCoordsForMultiTypes_1();
+ const int conn[81]={0,16,17,18,
+ 0,16,17,18,19,20,21,22,23,24,
+ 0,11,10,9,25,
+ 0,11,10,9,25,15,14,13,12,26,27,28,29,
+ 0,30,31,32,33,34,
+ 0,30,31,32,33,34,35,36,37,38,39,40,41,42,43,
+ 0,9,10,11,44,45,46,47,
+ 0,9,10,11,44,45,46,47,12,13,14,15,48,49,50,51,52,53,54,55 };
+ mesh->allocateCells(8);
+ mesh->insertNextCell(INTERP_KERNEL::NORM_TETRA4,4,conn);
+ mesh->insertNextCell(INTERP_KERNEL::NORM_TETRA10,10,conn+4);
+ mesh->insertNextCell(INTERP_KERNEL::NORM_PYRA5,5,conn+14);
+ mesh->insertNextCell(INTERP_KERNEL::NORM_PYRA13,13,conn+19);
+ mesh->insertNextCell(INTERP_KERNEL::NORM_PENTA6,6,conn+32);
+ mesh->insertNextCell(INTERP_KERNEL::NORM_PENTA15,15,conn+38);
+ mesh->insertNextCell(INTERP_KERNEL::NORM_HEXA8,8,conn+53);
+ mesh->insertNextCell(INTERP_KERNEL::NORM_HEXA20,20,conn+61);
+ mesh->finishInsertingCells();
+ mesh->setCoords(coo);
+ coo->decrRef();
+ return mesh;
+}
+
+DataArrayDouble *MEDCouplingBasicsTest::buildCoordsForMultiTypes_1()
+{
+ DataArrayDouble *coords=DataArrayDouble::New();
+ coords->alloc(56,3);
+ coords->setInfoOnComponent(0,"X (cm)");
+ coords->setInfoOnComponent(1,"Y (cm)");
+ coords->setInfoOnComponent(2,"Z (cm)");
+ const double data[168]={
+ 0.0, 0.0, 0.0, //#0
+ 0.5, 0.5, 0.5, //#1
+ 1.0, 1.0, 1.0, //#2
+ 1.0, 1.0, 0.0, //#3
+ 2.0, 2.5, 0.0, //#4
+ 6.0, 1.5, 0.0, //#5
+ 1.0, 2.0, 0.0, //#6
+ 4.5, 2.5, 0.0, //#7
+ 4.0, 0.5, 0.0, //#8
+ 0.0, 4.0, 0.0, //#9
+ 4.0, 4.0, 0.0, //#10
+ 4.0, 0.0, 0.0, //#11
+ 0.0, 2.0, 0.0, //#12
+ 2.0, 4.0, 0.0, //#13
+ 4.0, 2.0, 0.0, //#14
+ 2.0, 0.0, 0.0, //#15
+ 0.0, 6.0, 0.0, //#16
+ 3.0, 3.0, 0.0, //#17
+ 1.3, 3.0, 3.0, //#18
+ 0.0, 3.0, 0.0, //#19
+ 1.5, 4.5, 0.0, //#20
+ 1.5, 1.5, 0.0, //#21
+ 0.65, 1.5, 1.5, //#22
+ 0.65, 4.5, 1.5, //#23
+ 2.15, 3.0, 1.5, //#24
+ 2.0, 2.0, 2.0, //#25
+ 3.0, 1.0, 1.0, //#26
+ 3.0, 3.0, 1.0, //#27
+ 1.0, 3.0, 1.0, //#28
+ 1.0, 1.0, 1.0, //#29
+ 0.0, 3.0, 0.0, //#30
+ 2.0, 0.0, 0.0, //#31
+ 0.0, 0.0, 6.0, //#32
+ 0.0, 3.0, 6.0, //#33
+ 3.0, 0.0, 6.0, //#34
+ 0.0, 1.5, 0.0, //#35
+ 1.5, 1.5, 0.0, //#36
+ 1.5, 0.0, 0.0, //#37
+ 0.0, 1.5, 6.0, //#38
+ 1.5, 1.5, 6.0, //#39
+ 1.5, 0.0, 6.0, //#40
+ 0.0, 0.0, 3.0, //#41
+ 0.0, 3.0, 3.0, //#42
+ 3.0, 0.0, 3.0, //#43
+ 0.0, 0.0, 4.0, //#44
+ 0.0, 4.0, 4.0, //#45
+ 4.0, 4.0, 4.0, //#46
+ 4.0, 0.0, 4.0, //#47
+ 0.0, 2.0, 4.0, //#48
+ 2.0, 4.0, 4.0, //#49
+ 4.0, 2.0, 4.0, //#50
+ 2.0, 0.0, 4.0, //#51
+ 0.0, 0.0, 2.0, //#52
+ 0.0, 4.0, 2.0, //#53
+ 4.0, 4.0, 2.0, //#54
+ 4.0, 0.0, 2.0 //#55
+ };
+ std::copy(data,data+168,coords->getPointer());
+ return coords;
+}
+
+MEDCouplingUMesh *MEDCouplingBasicsTest::buildHexa8Mesh_1()
+{
+ MEDCouplingUMesh *mesh=MEDCouplingUMesh::New("Hexa8Only",3);
+ DataArrayDouble *coo=DataArrayDouble::New();
+ const double coords[81]={0.0, 0.0, 0.0, 0.5, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.5, 0.0, 0.5, 0.5, 0.0, 1.0, 0.5, 0.0, 0.0, 1.0, 0.0, 0.5, 1.0, 0.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.5, 0.5, 0.0, 0.5, 1.0, 0.0, 0.5, 0.0, 0.5, 0.5, 0.5, 0.5, 0.5, 1.0, 0.5, 0.5, 0.0, 1.0, 0.5, 0.5, 1.0, 0.5, 1.0, 1.0, 0.5, 0.0, 0.0, 1.0, 0.5, 0.0, 1.0, 1.0, 0.0, 1.0, 0.0, 0.5, 1.0, 0.5, 0.5, 1.0, 1.0, 0.5, 1.0, 0.0, 1.0, 1.0, 0.5, 1.0, 1.0, 1.0, 1.0, 1.0};
+ coo->alloc(27,3);
+ std::copy(coords,coords+81,coo->getPointer());
+ const int conn[64]={3,12,13,4,0,9,10,1,
+ 4,13,14,5,1,10,11,2,
+ 6,15,16,7,3,12,13,4,
+ 7,16,17,8,4,13,14,5,
+ 12,21,22,13,9,18,19,10,
+ 13,22,23,14,10,19,20,11,
+ 15,24,25,16,12,21,22,13,
+ 16,25,26,17,13,22,23,14};
+ mesh->allocateCells(8);
+ for(int i=0;i<8;i++)
+ mesh->insertNextCell(INTERP_KERNEL::NORM_HEXA8,8,conn+8*i);
+ mesh->finishInsertingCells();
+ mesh->setCoords(coo);
+ coo->decrRef();
+ return mesh;
+}
+
+MEDCouplingUMesh *MEDCouplingBasicsTest::buildPointe_1(MEDCouplingUMesh *& m1)
+{
+ MEDCouplingUMesh *mesh=MEDCouplingUMesh::New("Pointe.med",3);
+ MEDCouplingUMesh *mesh2=MEDCouplingUMesh::New("Pointe.med",2);
+ const double coords[57]={0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 2.0, 0.0, 1.0, 0.0, 2.0, 1.0, -2.0, 0.0, 1.0, 0.0, -2.0, 1.0, 1.0, 1.0, 2.0, -1.0, 1.0, 2.0, -1.0, -1.0, 2.0, 1.0, -1.0, 2.0, 1.0, 1.0, 3.0, -1.0, 1.0, 3.0, -1.0, -1.0, 3.0, 1.0, -1.0, 3.0, 1.0, 1.0, 4.0, -1.0, 1.0, 4.0, -1.0, -1.0, 4.0, 1.0, -1.0, 4.0, 0.0, 0.0, 5.0};
+ const int conn[74]={0,1,2,5,0,1,3,2,0,1,4,3,0,1,5,4,1,6,3,2,1,7,4,3,1,8,5,4,1,9,2,5,1,6,2,9,1,7,3,6,1,8,4,7,1,9,5,8, 6,7,8,9,1,14,17,16,15,18, 10,11,12,13,6,7,8,9,14,15,16,17,10,11,12,13};
+ DataArrayDouble *coo=DataArrayDouble::New();
+ coo->alloc(19,3);
+ std::copy(coords,coords+57,coo->getPointer());
+ mesh->setCoords(coo);
+ mesh2->setCoords(coo);
+ coo->decrRef();
+ mesh->allocateCells(16);
+ for(int i=0;i<12;i++)
+ mesh->insertNextCell(INTERP_KERNEL::NORM_TETRA4,4,conn+4*i);
+ mesh->insertNextCell(INTERP_KERNEL::NORM_PYRA5,5,conn+48);
+ mesh->insertNextCell(INTERP_KERNEL::NORM_PYRA5,5,conn+53);
+ mesh->insertNextCell(INTERP_KERNEL::NORM_HEXA8,8,conn+58);
+ mesh->insertNextCell(INTERP_KERNEL::NORM_HEXA8,8,conn+66);
+ mesh->finishInsertingCells();
+ //[1,34,29,23,41,32]
+ const int conn2[20]={0,5,1,14,18,17,8,7,4,9,5,2, 12,8,9,13,6,7,8,9};
+ mesh2->allocateCells(6);
+ for(int i=0;i<4;i++)
+ mesh2->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,conn2+3*i);
+ mesh2->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,conn2+12);
+ mesh2->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,conn2+16);
+ mesh2->finishInsertingCells();
+ m1=mesh2;
+ //
+ return mesh;
+}
+
double MEDCouplingBasicsTest::sumAll(const std::vector< std::map<int,double> >& matrix)
{
double ret=0.;
void MEDCouplingBasicsTest::testMeshPointsCloud()
{
double targetCoords[27]={-0.3,-0.3,0.5, 0.2,-0.3,1., 0.7,-0.3,1.5, -0.3,0.2,0.5, 0.2,0.2,1., 0.7,0.2,1.5, -0.3,0.7,0.5, 0.2,0.7,1., 0.7,0.7,1.5};
- int *targetConn=0;
+ const int targetConn[]={0,1,2,3,4,5,7,6};
MEDCouplingUMesh *targetMesh=MEDCouplingUMesh::New();
targetMesh->setMeshDimension(0);
targetMesh->allocateCells(8);
- targetMesh->insertNextCell(INTERP_KERNEL::NORM_POINT0,0,targetConn);
- targetMesh->insertNextCell(INTERP_KERNEL::NORM_POINT0,0,targetConn);
- targetMesh->insertNextCell(INTERP_KERNEL::NORM_POINT0,0,targetConn);
- targetMesh->insertNextCell(INTERP_KERNEL::NORM_POINT0,0,targetConn);
- targetMesh->insertNextCell(INTERP_KERNEL::NORM_POINT0,0,targetConn);
- targetMesh->insertNextCell(INTERP_KERNEL::NORM_POINT0,0,targetConn);
- targetMesh->insertNextCell(INTERP_KERNEL::NORM_POINT0,0,targetConn);
- targetMesh->insertNextCell(INTERP_KERNEL::NORM_POINT0,0,targetConn);
+ targetMesh->insertNextCell(INTERP_KERNEL::NORM_POINT1,1,targetConn);
+ targetMesh->insertNextCell(INTERP_KERNEL::NORM_POINT1,1,targetConn+1);
+ targetMesh->insertNextCell(INTERP_KERNEL::NORM_POINT1,1,targetConn+2);
+ targetMesh->insertNextCell(INTERP_KERNEL::NORM_POINT1,1,targetConn+3);
+ targetMesh->insertNextCell(INTERP_KERNEL::NORM_POINT1,1,targetConn+4);
+ targetMesh->insertNextCell(INTERP_KERNEL::NORM_POINT1,1,targetConn+5);
+ targetMesh->insertNextCell(INTERP_KERNEL::NORM_POINT1,1,targetConn+6);
+ targetMesh->insertNextCell(INTERP_KERNEL::NORM_POINT1,1,targetConn+7);
targetMesh->finishInsertingCells();
DataArrayDouble *myCoords=DataArrayDouble::New();
myCoords->alloc(9,3);
std::fill(array->getPointer(),array->getPointer()+5*3,7.);
CPPUNIT_ASSERT_DOUBLES_EQUAL(7.,array->getIJ(3,2),1e-14);
double *tmp1=array->getPointer();
- DataArrayDouble *array2=array->deepCopy();
+ DataArrayDouble *array2=array->deepCpy();
double *tmp2=array2->getPointer();
CPPUNIT_ASSERT(tmp1!=tmp2);
array->decrRef();
std::fill(array3->getPointer(),array3->getPointer()+5*3,17);
CPPUNIT_ASSERT_EQUAL(17,array3->getIJ(3,2));
int *tmp3=array3->getPointer();
- DataArrayInt *array4=array3->deepCopy();
+ DataArrayInt *array4=array3->deepCpy();
int *tmp4=array4->getPointer();
CPPUNIT_ASSERT(tmp3!=tmp4);
array3->decrRef();
CPPUNIT_ASSERT(m3);
m2->decrRef();
MEDCouplingUMesh *m4=build2DSourceMesh_1();
- MEDCouplingUMesh *m5=MEDCouplingUMesh::mergeUMeshes(m1,m3);
+ MEDCouplingUMesh *m5=MEDCouplingUMesh::MergeUMeshes(m1,m3);
m1->decrRef();
m3->decrRef();
- MEDCouplingUMesh *m6=MEDCouplingUMesh::mergeUMeshes(m5,m4);
+ MEDCouplingUMesh *m6=MEDCouplingUMesh::MergeUMeshes(m5,m4);
m4->decrRef();
m5->decrRef();
//
CPPUNIT_ASSERT(fieldOnCells1->isEqual(fieldOnCells2,1e-12,1e-15));
CPPUNIT_ASSERT(fieldOnCells2->isEqual(fieldOnCells1,1e-12,1e-15));
//
- DataArrayDouble *arr2=arr->deepCopy();
+ DataArrayDouble *arr2=arr->deepCpy();
fieldOnCells2->setArray(arr2);
arr2->decrRef();
CPPUNIT_ASSERT(fieldOnCells1->isEqual(fieldOnCells2,1e-12,1e-15));
}
/*!
- * This test check MEDCouplingUMesh::buildExtrudedMeshFromThis method.
+ * This test check MEDCouplingUMesh::buildExtrudedMesh method.
*/
void MEDCouplingBasicsTest::testExtrudedMesh3()
{
double center[3]={0.,0.,0.};
double vector[3]={0,1,0};
m2->rotate(center,vector,-M_PI/2.);
- MEDCouplingUMesh *m3=m1->buildExtrudedMeshFromThis(m2,0);
+ MEDCouplingUMesh *m3=m1->buildExtrudedMesh(m2,0);
//
MEDCouplingExtrudedMesh *m4=MEDCouplingExtrudedMesh::New(m3,m1,0);
CPPUNIT_ASSERT_EQUAL(15,m4->getNumberOfCells());
//play with polygons and polyedrons
std::vector<int> cells(2); cells[0]=2; cells[1]=3;
m1->convertToPolyTypes(cells);
- m3=m1->buildExtrudedMeshFromThis(m2,0);
+ m3=m1->buildExtrudedMesh(m2,0);
CPPUNIT_ASSERT_EQUAL((int)INTERP_KERNEL::NORM_HEXA8,(int)m3->getTypeOfCell(0));
CPPUNIT_ASSERT_EQUAL((int)INTERP_KERNEL::NORM_PENTA6,(int)m3->getTypeOfCell(1));
CPPUNIT_ASSERT_EQUAL((int)INTERP_KERNEL::NORM_POLYHED,(int)m3->getTypeOfCell(2));
}
/*!
- * This test check MEDCouplingUMesh::buildExtrudedMeshFromThis method, but also, MEDCouplingExtrudedMesh following methods :
+ * This test check MEDCouplingUMesh::buildExtrudedMesh method, but also, MEDCouplingExtrudedMesh following methods :
* getCellContainingPoint getMeasureField getNodeIdsOfCell getCoordinateOfNode getTypeOfCell build3DUnstructuredMesh.
*/
void MEDCouplingBasicsTest::testExtrudedMesh4()
double center[3]={0.,0.,0.};
double vector[3]={0.,1.,0.};
m2->rotate(center,vector,-M_PI/2.);
- MEDCouplingUMesh *m3=m1->buildExtrudedMeshFromThis(m2,0);
+ MEDCouplingUMesh *m3=m1->buildExtrudedMesh(m2,0);
const int expected1[15]= {1,3,2,0,6,5,7,10,11,8,12,9,14,13,4};
const int rexpected1[15]={3, 0, 2, 1, 14, 5, 4, 6, 9, 11, 7, 8, 10, 13, 12};
m3->renumberCells(expected1,false);
m1->tryToShareSameCoords(*m2,1e-12);
MEDCouplingUMesh *m3=build2DTargetMesh_1();
m3->tryToShareSameCoords(*m2,1e-12);
- std::vector<MEDCouplingUMesh *> meshes;
+ std::vector<const MEDCouplingUMesh *> meshes;
meshes.push_back(m1); meshes.push_back(m2); meshes.push_back(m3);
- MEDCouplingUMesh *m4=MEDCouplingUMesh::mergeUMeshesOnSameCoords(meshes);
+ MEDCouplingUMesh *m4=MEDCouplingUMesh::MergeUMeshesOnSameCoords(meshes);
m4->checkCoherency();
CPPUNIT_ASSERT(m4->getCoords()==m1->getCoords());
CPPUNIT_ASSERT_EQUAL(15,m4->getNumberOfCells());
m2->translate(vec);
MEDCouplingFieldDouble *f1=m1->getMeasureField(true);
MEDCouplingFieldDouble *f2=m2->getMeasureField(true);
- MEDCouplingFieldDouble *f3=MEDCouplingFieldDouble::mergeFields(f1,f2);
+ MEDCouplingFieldDouble *f3=MEDCouplingFieldDouble::MergeFields(f1,f2);
f3->checkCoherency();
MEDCouplingUMesh *m4=build2DTargetMeshMerged_1();
CPPUNIT_ASSERT(f3->getMesh()->isEqual(m4,1.e-12));
MEDCouplingUMesh *m1=build3DSurfTargetMesh_1();
std::vector<MEDCouplingUMesh *> v=m1->splitByType();
CPPUNIT_ASSERT_EQUAL(3,(int)v.size());
- MEDCouplingUMesh *m2=MEDCouplingUMesh::mergeUMeshesOnSameCoords(v);
+ std::vector<const MEDCouplingUMesh *> v2(v.begin(),v.end());
+ MEDCouplingUMesh *m2=MEDCouplingUMesh::MergeUMeshesOnSameCoords(v2);
m2->setName(m1->getName());
CPPUNIT_ASSERT(m1->isEqual(m2,1.e-12));
for(std::vector<MEDCouplingUMesh *>::const_iterator iter=v.begin();iter!=v.end();iter++)
void MEDCouplingBasicsTest::testFuseUMeshesOnSameCoords()
{
- std::vector<MEDCouplingUMesh *> meshes;
+ std::vector<const MEDCouplingUMesh *> meshes;
MEDCouplingUMesh *m2=build2DTargetMesh_1();
int cells1[3]={2,3,4};
MEDCouplingPointSet *m3_1=m2->buildPartOfMySelf(cells1,cells1+3,true);
m2->decrRef();
//
std::vector<DataArrayInt *> corr;
- MEDCouplingUMesh *m7=MEDCouplingUMesh::fuseUMeshesOnSameCoords(meshes,0,corr);
+ MEDCouplingUMesh *m7=MEDCouplingUMesh::FuseUMeshesOnSameCoords(meshes,0,corr);
CPPUNIT_ASSERT_EQUAL(4,m7->getNumberOfCells());
CPPUNIT_ASSERT_EQUAL(3,(int)corr.size());
const int expectedVals1[3]={3,3,2};
CPPUNIT_ASSERT_EQUAL(expectedVals2[i][j],vals[j]);
}
std::vector< std::vector<int> > fidsOfGroups;
- DataArrayInt *arr2=DataArrayInt::makePartition(corr,m7->getNumberOfCells(),fidsOfGroups);
+ std::vector<const DataArrayInt *> corr2(corr.begin(),corr.end());
+ DataArrayInt *arr2=DataArrayInt::MakePartition(corr2,m7->getNumberOfCells(),fidsOfGroups);
const int fidExp[4]={5,1,3,4};
const int fidsGrp[3][3]={{1,3,5},{3,4,5},{4,5,23344}};
CPPUNIT_ASSERT_EQUAL(3,(int)fidsOfGroups.size());
MEDCouplingUMesh *m3=(MEDCouplingUMesh *)m1->buildPartOfMySelf(part1,part1+5,true);
const int part2[4]={5,6,4,7};
MEDCouplingUMesh *m4=(MEDCouplingUMesh *)m1->buildPartOfMySelf(part2,part2+4,true);
- std::vector<MEDCouplingUMesh *> meshes;
+ std::vector<const MEDCouplingUMesh *> meshes;
meshes.push_back(m1);
meshes.push_back(m3);
meshes.push_back(m3);
meshes.push_back(m4);
std::vector<DataArrayInt *> corr;
- MEDCouplingUMesh *m5=MEDCouplingUMesh::fuseUMeshesOnSameCoords(meshes,0,corr);
+ MEDCouplingUMesh *m5=MEDCouplingUMesh::FuseUMeshesOnSameCoords(meshes,0,corr);
CPPUNIT_ASSERT_EQUAL(18,m5->getNumberOfCells());
std::vector<DataArrayInt *>::iterator it=corr.begin();
const int exp1[4]={18,5,5,4};
CPPUNIT_ASSERT(std::equal(t2.begin(),t2.end(),expectedValues2));
//2D with no help of bounding box.
double center[2]={0.2,0.2};
- MEDCouplingPointSet::rotate2DAlg(center,0.78539816339744830962,6,pos);
+ MEDCouplingPointSet::Rotate2DAlg(center,0.78539816339744830962,6,pos);
targetMesh->rotate(center,0,0.78539816339744830962);
t1.clear(); t2.clear();
targetMesh->getCellsContainingPoints(pos,6,1e-12,t1,t2);
double center[3]={0.,0.,0.};
double vector[3]={0.,1.,0.};
m4->rotate(center,vector,-M_PI/2.);
- MEDCouplingUMesh *m5=m3->buildExtrudedMeshFromThis(m4,0);
+ MEDCouplingUMesh *m5=m3->buildExtrudedMesh(m4,0);
res1.clear();
m5->arePolyhedronsNotCorrectlyOriented(res1);
CPPUNIT_ASSERT_EQUAL(15,(int)res1.size());
a1->fillWithZero();
a1->setInfoOnComponent(0,"c");
a1->setInfoOnComponent(1,"d");
- DataArrayDouble *a2=a1->deepCopy();
+ DataArrayDouble *a2=a1->deepCpy();
a2->setInfoOnComponent(0,"e");
a2->setInfoOnComponent(1,"f");
f->setArray(a1);
//
mesh->decrRef();
}
-
-void MEDCouplingBasicsTest::testGetMeasureFieldCMesh1()
-{
- MEDCouplingCMesh *m=MEDCouplingCMesh::New();
- DataArrayDouble *da=DataArrayDouble::New();
- const double discX[4]={2.3,3.4,5.8,10.2};
- const double discY[3]={12.3,23.4,45.8};
- const double discZ[5]={-0.7,1.2,1.25,2.13,2.67};
- da->alloc(4,1);
- std::copy(discX,discX+4,da->getPointer());
- m->setCoordsAt(0,da);
- da->decrRef();
- m->checkCoherency();
- CPPUNIT_ASSERT_EQUAL(4,m->getNumberOfNodes());
- CPPUNIT_ASSERT_EQUAL(3,m->getNumberOfCells());
- CPPUNIT_ASSERT_EQUAL(1,m->getSpaceDimension());
- MEDCouplingFieldDouble *f=m->getMeasureField(true);
- CPPUNIT_ASSERT_EQUAL(3,f->getNumberOfTuples());
- CPPUNIT_ASSERT_EQUAL(1,f->getNumberOfComponents());
- const double expected1[3]={1.1,2.4,4.4};
- for(int i=0;i<3;i++)
- CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1[i],f->getIJ(i,0),1e-12);
- f->decrRef();
- DataArrayDouble *coords=m->getCoordinatesAndOwner();
- CPPUNIT_ASSERT_EQUAL(4,coords->getNumberOfTuples());
- CPPUNIT_ASSERT_EQUAL(1,coords->getNumberOfComponents());
- for(int i=0;i<4;i++)
- CPPUNIT_ASSERT_DOUBLES_EQUAL(discX[i],coords->getIJ(i,0),1e-12);
- coords->decrRef();
- coords=m->getBarycenterAndOwner();
- CPPUNIT_ASSERT_EQUAL(3,coords->getNumberOfTuples());
- CPPUNIT_ASSERT_EQUAL(1,coords->getNumberOfComponents());
- const double expected1_3[3]={2.85,4.6,8.};
- for(int i=0;i<3;i++)
- CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1_3[i],coords->getIJ(i,0),1e-12);
- coords->decrRef();
- //
- da=DataArrayDouble::New();
- da->alloc(3,1);
- std::copy(discY,discY+3,da->getPointer());
- m->setCoordsAt(1,da);
- da->decrRef();
- m->checkCoherency();
- CPPUNIT_ASSERT_EQUAL(12,m->getNumberOfNodes());
- CPPUNIT_ASSERT_EQUAL(6,m->getNumberOfCells());
- CPPUNIT_ASSERT_EQUAL(2,m->getSpaceDimension());
- f=m->getMeasureField(true);
- CPPUNIT_ASSERT_EQUAL(6,f->getNumberOfTuples());
- CPPUNIT_ASSERT_EQUAL(1,f->getNumberOfComponents());
- const double expected2[6]={12.21,26.64,48.84,24.64,53.76,98.56};
- for(int i=0;i<6;i++)
- CPPUNIT_ASSERT_DOUBLES_EQUAL(expected2[i],f->getIJ(i,0),1e-12);
- f->decrRef();
- coords=m->getCoordinatesAndOwner();
- CPPUNIT_ASSERT_EQUAL(12,coords->getNumberOfTuples());
- CPPUNIT_ASSERT_EQUAL(2,coords->getNumberOfComponents());
- const double expected2_2[24]={2.3,12.3,3.4,12.3,5.8,12.3,10.2,12.3, 2.3,23.4,3.4,23.4,5.8,23.4,10.2,23.4, 2.3,45.8,3.4,45.8,5.8,45.8,10.2,45.8};
- for(int i=0;i<24;i++)
- CPPUNIT_ASSERT_DOUBLES_EQUAL(expected2_2[i],coords->getIJ(0,i),1e-12);
- coords->decrRef();
- coords=m->getBarycenterAndOwner();
- CPPUNIT_ASSERT_EQUAL(6,coords->getNumberOfTuples());
- CPPUNIT_ASSERT_EQUAL(2,coords->getNumberOfComponents());
- const double expected2_3[12]={2.85,17.85,4.6,17.85,8.,17.85, 2.85,34.6,4.6,34.6,8.,34.6};
- for(int i=0;i<12;i++)
- CPPUNIT_ASSERT_DOUBLES_EQUAL(expected2_3[i],coords->getIJ(0,i),1e-12);
- coords->decrRef();
- //
- da=DataArrayDouble::New();
- da->alloc(5,1);
- std::copy(discZ,discZ+5,da->getPointer());
- m->setCoordsAt(2,da);
- da->decrRef();
- m->checkCoherency();
- CPPUNIT_ASSERT_EQUAL(60,m->getNumberOfNodes());
- CPPUNIT_ASSERT_EQUAL(24,m->getNumberOfCells());
- CPPUNIT_ASSERT_EQUAL(3,m->getSpaceDimension());
- f=m->getMeasureField(true);
- CPPUNIT_ASSERT_EQUAL(24,f->getNumberOfTuples());
- CPPUNIT_ASSERT_EQUAL(1,f->getNumberOfComponents());
- const double expected3[24]={23.199, 50.616, 92.796, 46.816, 102.144, 187.264, 0.6105, 1.332, 2.442, 1.232, 2.688, 4.928, 10.7448, 23.4432, 42.9792, 21.6832, 47.3088, 86.7328, 6.5934, 14.3856, 26.3736, 13.3056, 29.0304, 53.2224};
- for(int i=0;i<24;i++)
- CPPUNIT_ASSERT_DOUBLES_EQUAL(expected3[i],f->getIJ(i,0),1e-12);
- f->decrRef();
- coords=m->getCoordinatesAndOwner();
- CPPUNIT_ASSERT_EQUAL(60,coords->getNumberOfTuples());
- CPPUNIT_ASSERT_EQUAL(3,coords->getNumberOfComponents());
- const double expected3_2[180]={
- 2.3,12.3,-0.7, 3.4,12.3,-0.7, 5.8,12.3,-0.7, 10.2,12.3,-0.7, 2.3,23.4,-0.7, 3.4,23.4,-0.7, 5.8,23.4,-0.7, 10.2,23.4,-0.7, 2.3,45.8,-0.7, 3.4,45.8,-0.7, 5.8,45.8,-0.7, 10.2,45.8,-0.7,
- 2.3,12.3,1.2, 3.4,12.3,1.2, 5.8,12.3,1.2, 10.2,12.3,1.2, 2.3,23.4,1.2, 3.4,23.4,1.2, 5.8,23.4,1.2, 10.2,23.4,1.2, 2.3,45.8,1.2, 3.4,45.8,1.2, 5.8,45.8,1.2, 10.2,45.8,1.2,
- 2.3,12.3,1.25, 3.4,12.3,1.25, 5.8,12.3,1.25, 10.2,12.3,1.25, 2.3,23.4,1.25, 3.4,23.4,1.25, 5.8,23.4,1.25, 10.2,23.4,1.25, 2.3,45.8,1.25, 3.4,45.8,1.25, 5.8,45.8,1.25, 10.2,45.8,1.25,
- 2.3,12.3,2.13, 3.4,12.3,2.13, 5.8,12.3,2.13, 10.2,12.3,2.13, 2.3,23.4,2.13, 3.4,23.4,2.13, 5.8,23.4,2.13, 10.2,23.4,2.13, 2.3,45.8,2.13, 3.4,45.8,2.13, 5.8,45.8,2.13, 10.2,45.8,2.13,
- 2.3,12.3,2.67, 3.4,12.3,2.67, 5.8,12.3,2.67, 10.2,12.3,2.67, 2.3,23.4,2.67, 3.4,23.4,2.67, 5.8,23.4,2.67, 10.2,23.4,2.67, 2.3,45.8,2.67, 3.4,45.8,2.67, 5.8,45.8,2.67, 10.2,45.8,2.67
- };
- for(int i=0;i<180;i++)
- CPPUNIT_ASSERT_DOUBLES_EQUAL(expected3_2[i],coords->getIJ(0,i),1e-12);
- coords->decrRef();
- coords=m->getBarycenterAndOwner();
- CPPUNIT_ASSERT_EQUAL(24,coords->getNumberOfTuples());
- CPPUNIT_ASSERT_EQUAL(3,coords->getNumberOfComponents());
- const double expected3_3[72]={
- 2.85,17.85,0.25,4.6,17.85,0.25,8.,17.85,0.25, 2.85,34.6,0.25,4.6,34.6,0.25,8.,34.6,0.25,
- 2.85,17.85,1.225,4.6,17.85,1.225,8.,17.85,1.225, 2.85,34.6,1.225,4.6,34.6,1.225,8.,34.6,1.225,
- 2.85,17.85,1.69,4.6,17.85,1.69,8.,17.85,1.69, 2.85,34.6,1.69,4.6,34.6,1.69,8.,34.6,1.69,
- 2.85,17.85,2.4,4.6,17.85,2.4,8.,17.85,2.4, 2.85,34.6,2.4,4.6,34.6,2.4,8.,34.6,2.4
- };
- for(int i=0;i<72;i++)
- CPPUNIT_ASSERT_DOUBLES_EQUAL(expected3_3[i],coords->getIJ(0,i),1e-12);
- coords->decrRef();
- //
- m->decrRef();
-}
-
-void MEDCouplingBasicsTest::testFieldDoubleZipCoords1()
-{
- MEDCouplingUMesh *m=build2DTargetMeshMergeNode_1();
- MEDCouplingFieldDouble *f=m->fillFromAnalytic(ON_NODES,2,"x*2.");
- f->getArray()->setInfoOnComponent(0,"titi");
- f->getArray()->setInfoOnComponent(1,"tutu");
- f->checkCoherency();
- CPPUNIT_ASSERT_EQUAL(18,f->getNumberOfTuples());
- CPPUNIT_ASSERT_EQUAL(2,f->getNumberOfComponents());
- const double expected1[36]={-0.6, -0.6, 0.4, 0.4, 1.4, 1.4, -0.6, -0.6, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 1.4, 1.4, -0.6, -0.6, 0.4, 0.4, 1.4, 1.4, -0.6, -0.6, 1.4, 1.4, -0.6, -0.6, 0.4, 0.4, 1.4, 1.4, 0.4, 0.4};
- for(int i=0;i<36;i++)
- CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1[i],f->getIJ(0,i),1e-12);
- CPPUNIT_ASSERT(f->zipCoords());
- f->checkCoherency();
- const double expected2[30]={-0.6, -0.6, 1.4, 1.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 1.4, 1.4, -0.6, -0.6, 0.4, 0.4, 1.4, 1.4, 1.4, 1.4, -0.6, -0.6, 0.4, 0.4, 1.4, 1.4, 0.4, 0.4};
- for(int i=0;i<30;i++)
- CPPUNIT_ASSERT_DOUBLES_EQUAL(expected2[i],f->getIJ(0,i),1e-12);
- CPPUNIT_ASSERT(!f->zipCoords());
- f->checkCoherency();
- for(int i=0;i<30;i++)
- CPPUNIT_ASSERT_DOUBLES_EQUAL(expected2[i],f->getIJ(0,i),1e-12);
- CPPUNIT_ASSERT(std::string(f->getArray()->getInfoOnComponent(0))=="titi");
- CPPUNIT_ASSERT(std::string(f->getArray()->getInfoOnComponent(1))=="tutu");
- f->decrRef();
- m->decrRef();
-}
-
-void MEDCouplingBasicsTest::testFieldDoubleZipConnectivity1()
-{
- MEDCouplingUMesh *m1=build2DTargetMesh_1();
- MEDCouplingUMesh *m2=build2DTargetMesh_1();
- const int cells1[3]={2,3,4};
- MEDCouplingPointSet *m3_1=m2->buildPartOfMySelf(cells1,cells1+3,true);
- MEDCouplingUMesh *m3=dynamic_cast<MEDCouplingUMesh *>(m3_1);
- CPPUNIT_ASSERT(m3);
- m2->decrRef();
- MEDCouplingUMesh *m4=build2DSourceMesh_1();
- MEDCouplingUMesh *m5=MEDCouplingUMesh::mergeUMeshes(m1,m3);
- m1->decrRef();
- m3->decrRef();
- MEDCouplingUMesh *m6=MEDCouplingUMesh::mergeUMeshes(m5,m4);
- m4->decrRef();
- m5->decrRef();
- //
- CPPUNIT_ASSERT_EQUAL(10,m6->getNumberOfCells());
- CPPUNIT_ASSERT_EQUAL(22,m6->getNumberOfNodes());
- bool areNodesMerged;
- int newNbOfNodes;
- DataArrayInt *arr=m6->mergeNodes(1e-13,areNodesMerged,newNbOfNodes);
- CPPUNIT_ASSERT_EQUAL(9,m6->getNumberOfNodes());
- arr->decrRef();
- MEDCouplingFieldDouble *f=m6->fillFromAnalytic(ON_CELLS,2,"x");
- MEDCouplingFieldDouble *f2=m6->fillFromAnalytic(ON_NODES,2,"x");
- CPPUNIT_ASSERT_EQUAL(10,f->getNumberOfTuples());
- CPPUNIT_ASSERT_EQUAL(2,f->getNumberOfComponents());
- const double expected1[20]={-0.05, -0.05, 0.3666666666666667, 0.3666666666666667, 0.53333333333333321, 0.53333333333333321,
- -0.05, -0.05, 0.45, 0.45, 0.53333333333333321, 0.53333333333333321, -0.05, -0.05, 0.45, 0.45,
- 0.36666666666666659, 0.36666666666666659, 0.033333333333333326, 0.033333333333333326};
- for(int i=0;i<20;i++)
- CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1[i],f->getIJ(0,i),1e-12);
- f->getArray()->setInfoOnComponent(0,"titi");
- f->getArray()->setInfoOnComponent(1,"tutu");
- f->checkCoherency();
- CPPUNIT_ASSERT(f->zipConnectivity(0));
- const double expected2[14]={-0.05, -0.05, 0.3666666666666667, 0.3666666666666667, 0.53333333333333321, 0.53333333333333321,
- -0.05, -0.05, 0.45, 0.45, 0.36666666666666659, 0.36666666666666659, 0.033333333333333326, 0.033333333333333326};
- CPPUNIT_ASSERT_EQUAL(7,f->getNumberOfTuples());
- CPPUNIT_ASSERT_EQUAL(2,f->getNumberOfComponents());
- for(int i=0;i<14;i++)
- CPPUNIT_ASSERT_DOUBLES_EQUAL(expected2[i],f->getIJ(0,i),1e-12);
- CPPUNIT_ASSERT(std::string(f->getArray()->getInfoOnComponent(0))=="titi");
- CPPUNIT_ASSERT(std::string(f->getArray()->getInfoOnComponent(1))=="tutu");
- CPPUNIT_ASSERT(!f->zipConnectivity(0));
- f->decrRef();
- //
- const double expected3[18]={-0.3, -0.3, 0.2, 0.2, 0.7, 0.7, -0.3, -0.3, 0.2, 0.2, 0.7, 0.7,
- -0.3, -0.3, 0.2, 0.2, 0.7, 0.7};
- CPPUNIT_ASSERT_EQUAL(9,f2->getNumberOfTuples());
- CPPUNIT_ASSERT_EQUAL(2,f2->getNumberOfComponents());
- for(int i=0;i<18;i++)
- CPPUNIT_ASSERT_DOUBLES_EQUAL(expected3[i],f2->getIJ(0,i),1e-12);
- CPPUNIT_ASSERT(f2->zipConnectivity(0));
- CPPUNIT_ASSERT_EQUAL(9,f2->getNumberOfTuples());
- CPPUNIT_ASSERT_EQUAL(2,f2->getNumberOfComponents());
- for(int i=0;i<18;i++)
- CPPUNIT_ASSERT_DOUBLES_EQUAL(expected3[i],f2->getIJ(0,i),1e-12);
- f2->decrRef();
- //
- m6->decrRef();
-}
-
-void MEDCouplingBasicsTest::testDaDoubleRenumber1()
-{
- DataArrayDouble *a=DataArrayDouble::New();
- a->alloc(7,2);
- a->setInfoOnComponent(0,"toto");
- a->setInfoOnComponent(1,"tata");
- const double arr1[14]={1.1,11.1,2.1,12.1,3.1,13.1,4.1,14.1,5.1,15.1,6.1,16.1,7.1,17.1};
- std::copy(arr1,arr1+14,a->getPointer());
- //
- const int arr2[7]={3,1,0,6,5,4,2};
- DataArrayDouble *b=a->renumber(arr2);
- CPPUNIT_ASSERT_EQUAL(7,b->getNumberOfTuples());
- CPPUNIT_ASSERT_EQUAL(2,b->getNumberOfComponents());
- CPPUNIT_ASSERT(std::string(b->getInfoOnComponent(0))=="toto");
- CPPUNIT_ASSERT(std::string(b->getInfoOnComponent(1))=="tata");
- const double expected1[14]={3.1, 13.1, 2.1, 12.1, 7.1, 17.1, 1.1, 11.1, 6.1, 16.1, 5.1, 15.1, 4.1, 14.1};
- for(int i=0;i<14;i++)
- CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1[i],b->getIJ(0,i),1e-14);
- b->decrRef();
- a->decrRef();
- //
- DataArrayInt *c=DataArrayInt::New();
- c->alloc(7,2);
- c->setInfoOnComponent(0,"toto");
- c->setInfoOnComponent(1,"tata");
- const int arr3[14]={1,11,2,12,3,13,4,14,5,15,6,16,7,17};
- std::copy(arr3,arr3+14,c->getPointer());
- DataArrayInt *d=c->renumber(arr2);
- CPPUNIT_ASSERT_EQUAL(7,d->getNumberOfTuples());
- CPPUNIT_ASSERT_EQUAL(2,d->getNumberOfComponents());
- CPPUNIT_ASSERT(std::string(d->getInfoOnComponent(0))=="toto");
- CPPUNIT_ASSERT(std::string(d->getInfoOnComponent(1))=="tata");
- const int expected2[14]={3, 13, 2, 12, 7, 17, 1, 11, 6, 16, 5, 15, 4, 14};
- for(int i=0;i<14;i++)
- CPPUNIT_ASSERT_EQUAL(expected2[i],d->getIJ(0,i));
- c->decrRef();
- d->decrRef();
-}
-
-void MEDCouplingBasicsTest::testDaDoubleRenumberAndReduce1()
-{
- DataArrayDouble *a=DataArrayDouble::New();
- a->alloc(7,2);
- a->setInfoOnComponent(0,"toto");
- a->setInfoOnComponent(1,"tata");
- const double arr1[14]={1.1,11.1,2.1,12.1,3.1,13.1,4.1,14.1,5.1,15.1,6.1,16.1,7.1,17.1};
- std::copy(arr1,arr1+14,a->getPointer());
- //
- const int arr2[7]={2,-1,1,-1,0,4,3};
- DataArrayDouble *b=a->renumberAndReduce(arr2,5);
- CPPUNIT_ASSERT_EQUAL(5,b->getNumberOfTuples());
- CPPUNIT_ASSERT_EQUAL(2,b->getNumberOfComponents());
- CPPUNIT_ASSERT(std::string(b->getInfoOnComponent(0))=="toto");
- CPPUNIT_ASSERT(std::string(b->getInfoOnComponent(1))=="tata");
- const double expected1[10]={5.1,15.1,3.1,13.1,1.1,11.1,7.1,17.1,6.1,16.1};
- for(int i=0;i<10;i++)
- CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1[i],b->getIJ(0,i),1e-14);
- b->decrRef();
- a->decrRef();
- //
- DataArrayInt *c=DataArrayInt::New();
- c->alloc(7,2);
- c->setInfoOnComponent(0,"toto");
- c->setInfoOnComponent(1,"tata");
- const int arr3[14]={1,11,2,12,3,13,4,14,5,15,6,16,7,17};
- std::copy(arr3,arr3+14,c->getPointer());
- DataArrayInt *d=c->renumberAndReduce(arr2,5);
- CPPUNIT_ASSERT_EQUAL(5,d->getNumberOfTuples());
- CPPUNIT_ASSERT_EQUAL(2,d->getNumberOfComponents());
- CPPUNIT_ASSERT(std::string(d->getInfoOnComponent(0))=="toto");
- CPPUNIT_ASSERT(std::string(d->getInfoOnComponent(1))=="tata");
- const int expected2[10]={5,15,3,13,1,11,7,17,6,16};
- for(int i=0;i<10;i++)
- CPPUNIT_ASSERT_EQUAL(expected2[i],d->getIJ(0,i));
- c->decrRef();
- d->decrRef();
-}
-
-void MEDCouplingBasicsTest::testDaDoubleRenumberInPlace1()
-{
- DataArrayDouble *a=DataArrayDouble::New();
- a->alloc(7,2);
- const double arr1[14]={1.1,11.1,2.1,12.1,3.1,13.1,4.1,14.1,5.1,15.1,6.1,16.1,7.1,17.1};
- std::copy(arr1,arr1+14,a->getPointer());
- //
- const int arr2[7]={3,1,0,6,5,4,2};
- a->renumberInPlace(arr2);
- CPPUNIT_ASSERT_EQUAL(7,a->getNumberOfTuples());
- CPPUNIT_ASSERT_EQUAL(2,a->getNumberOfComponents());
- const double expected1[14]={3.1, 13.1, 2.1, 12.1, 7.1, 17.1, 1.1, 11.1, 6.1, 16.1, 5.1, 15.1, 4.1, 14.1};
- for(int i=0;i<14;i++)
- CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1[i],a->getIJ(0,i),1e-14);
- a->decrRef();
- //
- DataArrayInt *c=DataArrayInt::New();
- c->alloc(7,2);
- const int arr3[14]={1,11,2,12,3,13,4,14,5,15,6,16,7,17};
- std::copy(arr3,arr3+14,c->getPointer());
- c->renumberInPlace(arr2);
- CPPUNIT_ASSERT_EQUAL(7,c->getNumberOfTuples());
- CPPUNIT_ASSERT_EQUAL(2,c->getNumberOfComponents());
- const int expected2[14]={3, 13, 2, 12, 7, 17, 1, 11, 6, 16, 5, 15, 4, 14};
- for(int i=0;i<14;i++)
- CPPUNIT_ASSERT_EQUAL(expected2[i],c->getIJ(0,i));
- c->decrRef();
-}
-
-void MEDCouplingBasicsTest::testDaDoubleRenumberR1()
-{
- DataArrayDouble *a=DataArrayDouble::New();
- a->alloc(7,2);
- a->setInfoOnComponent(0,"toto");
- a->setInfoOnComponent(1,"tata");
- const double arr1[14]={1.1,11.1,2.1,12.1,3.1,13.1,4.1,14.1,5.1,15.1,6.1,16.1,7.1,17.1};
- std::copy(arr1,arr1+14,a->getPointer());
- //
- const int arr2[7]={3,1,0,6,5,4,2};
- DataArrayDouble *b=a->renumberR(arr2);
- CPPUNIT_ASSERT_EQUAL(7,b->getNumberOfTuples());
- CPPUNIT_ASSERT_EQUAL(2,b->getNumberOfComponents());
- CPPUNIT_ASSERT(std::string(b->getInfoOnComponent(0))=="toto");
- CPPUNIT_ASSERT(std::string(b->getInfoOnComponent(1))=="tata");
- const double expected1[14]={4.1, 14.1, 2.1, 12.1, 1.1, 11.1, 7.1, 17.1, 6.1, 16.1, 5.1, 15.1, 3.1, 13.1};
- for(int i=0;i<14;i++)
- CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1[i],b->getIJ(0,i),1e-14);
- b->decrRef();
- a->decrRef();
- //
- DataArrayInt *c=DataArrayInt::New();
- c->alloc(7,2);
- c->setInfoOnComponent(0,"toto");
- c->setInfoOnComponent(1,"tata");
- const int arr3[14]={1,11,2,12,3,13,4,14,5,15,6,16,7,17};
- std::copy(arr3,arr3+14,c->getPointer());
- DataArrayInt *d=c->renumberR(arr2);
- CPPUNIT_ASSERT_EQUAL(7,d->getNumberOfTuples());
- CPPUNIT_ASSERT_EQUAL(2,d->getNumberOfComponents());
- CPPUNIT_ASSERT(std::string(d->getInfoOnComponent(0))=="toto");
- CPPUNIT_ASSERT(std::string(d->getInfoOnComponent(1))=="tata");
- const int expected2[14]={4, 14, 2, 12, 1, 11, 7, 17, 6, 16, 5, 15, 3, 13};
- for(int i=0;i<14;i++)
- CPPUNIT_ASSERT_EQUAL(expected2[i],d->getIJ(0,i));
- c->decrRef();
- d->decrRef();
-}
-
-void MEDCouplingBasicsTest::testDaDoubleRenumberInPlaceR1()
-{
- DataArrayDouble *a=DataArrayDouble::New();
- a->alloc(7,2);
- const double arr1[14]={1.1,11.1,2.1,12.1,3.1,13.1,4.1,14.1,5.1,15.1,6.1,16.1,7.1,17.1};
- std::copy(arr1,arr1+14,a->getPointer());
- //
- const int arr2[7]={3,1,0,6,5,4,2};
- a->renumberInPlaceR(arr2);
- CPPUNIT_ASSERT_EQUAL(7,a->getNumberOfTuples());
- CPPUNIT_ASSERT_EQUAL(2,a->getNumberOfComponents());
- const double expected1[14]={4.1, 14.1, 2.1, 12.1, 1.1, 11.1, 7.1, 17.1, 6.1, 16.1, 5.1, 15.1, 3.1, 13.1};
- for(int i=0;i<14;i++)
- CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1[i],a->getIJ(0,i),1e-14);
- a->decrRef();
- //
- DataArrayInt *c=DataArrayInt::New();
- c->alloc(7,2);
- const int arr3[14]={1,11,2,12,3,13,4,14,5,15,6,16,7,17};
- std::copy(arr3,arr3+14,c->getPointer());
- c->renumberInPlaceR(arr2);
- CPPUNIT_ASSERT_EQUAL(7,c->getNumberOfTuples());
- CPPUNIT_ASSERT_EQUAL(2,c->getNumberOfComponents());
- const int expected2[14]={4, 14, 2, 12, 1, 11, 7, 17, 6, 16, 5, 15, 3, 13};
- for(int i=0;i<14;i++)
- CPPUNIT_ASSERT_EQUAL(expected2[i],c->getIJ(0,i));
- c->decrRef();
-}
-
-void MEDCouplingBasicsTest::testDaDoubleSelectByTupleId1()
-{
- DataArrayDouble *a=DataArrayDouble::New();
- a->alloc(7,2);
- a->setInfoOnComponent(0,"toto");
- a->setInfoOnComponent(1,"tata");
- const double arr1[14]={1.1,11.1,2.1,12.1,3.1,13.1,4.1,14.1,5.1,15.1,6.1,16.1,7.1,17.1};
- std::copy(arr1,arr1+14,a->getPointer());
- //
- const int arr2[7]={4,2,0,6,5};
- DataArrayDouble *b=a->selectByTupleId(arr2,arr2+5);
- CPPUNIT_ASSERT_EQUAL(5,b->getNumberOfTuples());
- CPPUNIT_ASSERT_EQUAL(2,b->getNumberOfComponents());
- CPPUNIT_ASSERT(std::string(b->getInfoOnComponent(0))=="toto");
- CPPUNIT_ASSERT(std::string(b->getInfoOnComponent(1))=="tata");
- const double expected1[10]={5.1,15.1,3.1,13.1,1.1,11.1,7.1,17.1,6.1,16.1};
- for(int i=0;i<10;i++)
- CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1[i],b->getIJ(0,i),1e-14);
- b->decrRef();
- a->decrRef();
- //
- DataArrayInt *c=DataArrayInt::New();
- c->alloc(7,2);
- c->setInfoOnComponent(0,"toto");
- c->setInfoOnComponent(1,"tata");
- const int arr3[14]={1,11,2,12,3,13,4,14,5,15,6,16,7,17};
- std::copy(arr3,arr3+14,c->getPointer());
- DataArrayInt *d=c->selectByTupleId(arr2,arr2+5);
- CPPUNIT_ASSERT_EQUAL(5,d->getNumberOfTuples());
- CPPUNIT_ASSERT_EQUAL(2,d->getNumberOfComponents());
- CPPUNIT_ASSERT(std::string(d->getInfoOnComponent(0))=="toto");
- CPPUNIT_ASSERT(std::string(d->getInfoOnComponent(1))=="tata");
- const int expected2[10]={5,15,3,13,1,11,7,17,6,16};
- for(int i=0;i<10;i++)
- CPPUNIT_ASSERT_EQUAL(expected2[i],d->getIJ(0,i));
- c->decrRef();
- d->decrRef();
-}
-
-void MEDCouplingBasicsTest::testDaDoubleGetMinMaxValues1()
-{
- DataArrayDouble *a=DataArrayDouble::New();
- a->alloc(9,1);
- const double arr1[9]={2.34,4.56,-6.77,4.55,4.56,2.24,2.34,1.02,4.56};
- std::copy(arr1,arr1+9,a->getPointer());
- int where;
- double m=a->getMaxValue(where);
- CPPUNIT_ASSERT_EQUAL(1,where);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(4.56,m,1e-12);
- DataArrayInt *ws;
- m=a->getMaxValue2(ws);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(4.56,m,1e-12);
- CPPUNIT_ASSERT_EQUAL(3,ws->getNumberOfTuples());
- CPPUNIT_ASSERT_EQUAL(1,ws->getNumberOfComponents());
- const int expected1[3]={1,4,8};
- for(int i=0;i<3;i++)
- CPPUNIT_ASSERT_EQUAL(expected1[i],ws->getIJ(i,0));
- ws->decrRef();
- a->decrRef();
- a=DataArrayDouble::New();
- const double arr2[9]={-2.34,-4.56,6.77,-4.55,-4.56,-2.24,-2.34,-1.02,-4.56};
- a->alloc(9,1);
- std::copy(arr2,arr2+9,a->getPointer());
- where=-2;
- m=a->getMinValue(where);
- CPPUNIT_ASSERT_EQUAL(1,where);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(-4.56,m,1e-12);
- m=a->getMinValue2(ws);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(-4.56,m,1e-12);
- CPPUNIT_ASSERT_EQUAL(3,ws->getNumberOfTuples());
- CPPUNIT_ASSERT_EQUAL(1,ws->getNumberOfComponents());
- for(int i=0;i<3;i++)
- CPPUNIT_ASSERT_EQUAL(expected1[i],ws->getIJ(i,0));
- ws->decrRef();
- a->decrRef();
-}
-
-void MEDCouplingBasicsTest::testFieldDoubleGetMinMaxValues2()
-{
- MEDCouplingUMesh *m1=0;
- MEDCouplingUMesh *m2=build3DExtrudedUMesh_1(m1);
- m1->decrRef();
- CPPUNIT_ASSERT_EQUAL(18,m2->getNumberOfCells());
- const double arr1[18]={8.71,4.53,-12.41,8.71,-8.71,8.7099,4.55,8.71,5.55,6.77,-1e-200,4.55,8.7099,0.,1.23,0.,2.22,8.71};
- MEDCouplingFieldDouble *f=MEDCouplingFieldDouble::New(ON_CELLS,NO_TIME);
- DataArrayDouble *a=DataArrayDouble::New();
- a->alloc(18,1);
- std::copy(arr1,arr1+18,a->getPointer());
- f->setArray(a);
- a->decrRef();
- f->setMesh(m2);
- //
- f->checkCoherency();
- double m=f->getMaxValue();
- CPPUNIT_ASSERT_DOUBLES_EQUAL(8.71,m,1e-12);
- DataArrayInt *ws;
- m=f->getMaxValue2(ws);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(8.71,m,1e-12);
- CPPUNIT_ASSERT_EQUAL(4,ws->getNumberOfTuples());
- CPPUNIT_ASSERT_EQUAL(1,ws->getNumberOfComponents());
- const int expected1[4]={0,3,7,17};
- for(int i=0;i<4;i++)
- CPPUNIT_ASSERT_EQUAL(expected1[i],ws->getIJ(i,0));
- ws->decrRef();
- //
- const double arr2[18]={-8.71,-4.53,12.41,-8.71,8.71,-8.7099,-4.55,-8.71,-5.55,-6.77,1e-200,-4.55,-8.7099,0.,-1.23,0.,-2.22,-8.71};
- std::copy(arr2,arr2+18,a->getPointer());
- f->checkCoherency();
- m=f->getMinValue();
- CPPUNIT_ASSERT_DOUBLES_EQUAL(-8.71,m,1e-12);
- m=f->getMinValue2(ws);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(-8.71,m,1e-12);
- CPPUNIT_ASSERT_EQUAL(4,ws->getNumberOfTuples());
- CPPUNIT_ASSERT_EQUAL(1,ws->getNumberOfComponents());
- for(int i=0;i<4;i++)
- CPPUNIT_ASSERT_EQUAL(expected1[i],ws->getIJ(i,0));
- ws->decrRef();
- //
- f->decrRef();
- m2->decrRef();
-}
-
-void MEDCouplingBasicsTest::testBuildUnstructuredCMesh1()
-{
- MEDCouplingCMesh *m=MEDCouplingCMesh::New();
- DataArrayDouble *da=DataArrayDouble::New();
- const double discX[4]={2.3,3.4,5.8,10.2};
- const double discY[3]={12.3,23.4,45.8};
- const double discZ[5]={-0.7,1.2,1.25,2.13,2.67};
- da->alloc(4,1);
- std::copy(discX,discX+4,da->getPointer());
- m->setCoordsAt(0,da);
- da->decrRef();
- m->checkCoherency();
- double pos=2.4;
- CPPUNIT_ASSERT_EQUAL(0,m->getCellContainingPoint(&pos,1e-12));
- pos=3.7;
- CPPUNIT_ASSERT_EQUAL(1,m->getCellContainingPoint(&pos,1e-12));
- pos=5.9;
- CPPUNIT_ASSERT_EQUAL(2,m->getCellContainingPoint(&pos,1e-12));
- pos=10.3;
- CPPUNIT_ASSERT_EQUAL(-1,m->getCellContainingPoint(&pos,1e-12));
- pos=1.3;
- CPPUNIT_ASSERT_EQUAL(-1,m->getCellContainingPoint(&pos,1e-12));
- //
- MEDCouplingUMesh *m2=m->buildUnstructured();
- m2->checkCoherency();
- MEDCouplingFieldDouble *f1=m->getMeasureField(false);
- MEDCouplingFieldDouble *f2=m2->getMeasureField(false);
- CPPUNIT_ASSERT_EQUAL(f1->getNumberOfTuples(),3);
- CPPUNIT_ASSERT_EQUAL(f2->getNumberOfTuples(),3);
- CPPUNIT_ASSERT_EQUAL(1,m2->getMeshDimension());
- CPPUNIT_ASSERT_EQUAL(1,m2->getSpaceDimension());
- for(int i=0;i<3;i++)
- CPPUNIT_ASSERT_DOUBLES_EQUAL(f1->getIJ(i,0),f2->getIJ(i,0),1e-10);
- da=DataArrayDouble::New();
- da->alloc(3,1);
- std::copy(discY,discY+3,da->getPointer());
- m->setCoordsAt(1,da);
- da->decrRef();
- m2->decrRef();
- f1->decrRef();
- f2->decrRef();
- //
- m2=m->buildUnstructured();
- m2->checkCoherency();
- f1=m->getMeasureField(false);
- f2=m2->getMeasureField(false);
- CPPUNIT_ASSERT_EQUAL(f1->getNumberOfTuples(),6);
- CPPUNIT_ASSERT_EQUAL(f2->getNumberOfTuples(),6);
- CPPUNIT_ASSERT_EQUAL(2,m2->getMeshDimension());
- CPPUNIT_ASSERT_EQUAL(2,m2->getSpaceDimension());
- for(int i=0;i<6;i++)
- CPPUNIT_ASSERT_DOUBLES_EQUAL(f1->getIJ(i,0),f2->getIJ(i,0),1e-10);
- f1->decrRef();
- f2->decrRef();
- m2->decrRef();
- //
- da=DataArrayDouble::New();
- da->alloc(5,1);
- std::copy(discZ,discZ+5,da->getPointer());
- m->setCoordsAt(2,da);
- da->decrRef();
- m2=m->buildUnstructured();
- m2->checkCoherency();
- f1=m->getMeasureField(false);
- f2=m2->getMeasureField(false);
- CPPUNIT_ASSERT_EQUAL(f1->getNumberOfTuples(),24);
- CPPUNIT_ASSERT_EQUAL(f2->getNumberOfTuples(),24);
- CPPUNIT_ASSERT_EQUAL(3,m2->getMeshDimension());
- CPPUNIT_ASSERT_EQUAL(3,m2->getSpaceDimension());
- for(int i=0;i<24;i++)
- CPPUNIT_ASSERT_DOUBLES_EQUAL(f1->getIJ(i,0),f2->getIJ(i,0),1e-10);
- f1->decrRef();
- f2->decrRef();
- //
- double pos1[3]={5.,30.,2.};
- CPPUNIT_ASSERT_EQUAL(16,m->getCellContainingPoint(pos1,1e-12));
- //
- const double pt[3]={2.4,12.7,-3.4};
- m->scale(pt,3.7);
- MEDCouplingUMesh *m3=m->buildUnstructured();
- m2->scale(pt,3.7);
- CPPUNIT_ASSERT(m3->isEqual(m2,1e-12));
- m2->decrRef();
- m3->decrRef();
- //
- m->decrRef();
-}
-
-void MEDCouplingBasicsTest::testDataArrayIntInvertO2NNO21()
-{
- const int arr1[6]={2,0,4,1,5,3};
- DataArrayInt *da=DataArrayInt::New();
- da->alloc(6,1);
- std::copy(arr1,arr1+6,da->getPointer());
- DataArrayInt *da2=da->invertArrayO2N2N2O(6);
- CPPUNIT_ASSERT_EQUAL(6,da2->getNumberOfTuples());
- CPPUNIT_ASSERT_EQUAL(1,da2->getNumberOfComponents());
- const int expected1[6]={1,3,0,5,2,4};
- for(int i=0;i<6;i++)
- CPPUNIT_ASSERT_EQUAL(expected1[i],da2->getIJ(i,0));
- DataArrayInt *da3=da2->invertArrayN2O2O2N(6);
- for(int i=0;i<6;i++)
- CPPUNIT_ASSERT_EQUAL(arr1[i],da3->getIJ(i,0));
- da3->decrRef();
- da2->decrRef();
- da->decrRef();
- //
- const int arr2[10]={3,-1,5,4,-1,0,-1,1,2,-1};
- da=DataArrayInt::New();
- da->alloc(10,1);
- std::copy(arr2,arr2+10,da->getPointer());
- da2=da->invertArrayO2N2N2O(6);
- CPPUNIT_ASSERT_EQUAL(6,da2->getNumberOfTuples());
- CPPUNIT_ASSERT_EQUAL(1,da2->getNumberOfComponents());
- const int expected2[10]={5,7,8,0,3,2};
- for(int i=0;i<6;i++)
- CPPUNIT_ASSERT_EQUAL(expected2[i],da2->getIJ(i,0));
- da3=da2->invertArrayN2O2O2N(10);
- for(int i=0;i<10;i++)
- CPPUNIT_ASSERT_EQUAL(arr2[i],da3->getIJ(i,0));
- da3->decrRef();
- da2->decrRef();
- da->decrRef();
-}
-
-void MEDCouplingBasicsTest::testKeepSetSelectedComponent1()
-{
- const double arr1[20]={1.,2.,3.,4., 11.,12.,13.,14., 21.,22.,23.,24., 31.,32.,33.,34., 41.,42.,43.,44.};
- DataArrayDouble *a1=DataArrayDouble::New();
- a1->alloc(5,4);
- std::copy(arr1,arr1+20,a1->getPointer());
- a1->setInfoOnComponent(0,"aaaa");
- a1->setInfoOnComponent(1,"bbbb");
- a1->setInfoOnComponent(2,"cccc");
- a1->setInfoOnComponent(3,"dddd");
- const int arr2[6]={1,2,1,2,0,0};
- std::vector<int> arr2V(arr2,arr2+6);
- DataArrayDouble *a2=a1->keepSelectedComponents(arr2V);
- CPPUNIT_ASSERT_EQUAL(6,a2->getNumberOfComponents());
- CPPUNIT_ASSERT_EQUAL(5,a2->getNumberOfTuples());
- CPPUNIT_ASSERT(std::string(a2->getInfoOnComponent(0))=="bbbb");
- CPPUNIT_ASSERT(std::string(a2->getInfoOnComponent(1))=="cccc");
- CPPUNIT_ASSERT(std::string(a2->getInfoOnComponent(2))=="bbbb");
- CPPUNIT_ASSERT(std::string(a2->getInfoOnComponent(3))=="cccc");
- CPPUNIT_ASSERT(std::string(a2->getInfoOnComponent(4))=="aaaa");
- CPPUNIT_ASSERT(std::string(a2->getInfoOnComponent(5))=="aaaa");
- const double expected1[30]={2.,3.,2.,3.,1.,1., 12.,13.,12.,13.,11.,11., 22.,23.,22.,23.,21.,21., 32.,33.,32.,33.,31.,31., 42.,43.,42.,43.,41.,41.};
- for(int i=0;i<30;i++)
- CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1[i],a2->getIJ(0,i),1e-14);
- DataArrayInt *a3=a1->convertToIntArr();
- DataArrayInt *a4=a3->keepSelectedComponents(arr2V);
- CPPUNIT_ASSERT_EQUAL(6,a4->getNumberOfComponents());
- CPPUNIT_ASSERT_EQUAL(5,a4->getNumberOfTuples());
- CPPUNIT_ASSERT(std::string(a4->getInfoOnComponent(0))=="bbbb");
- CPPUNIT_ASSERT(std::string(a4->getInfoOnComponent(1))=="cccc");
- CPPUNIT_ASSERT(std::string(a4->getInfoOnComponent(2))=="bbbb");
- CPPUNIT_ASSERT(std::string(a4->getInfoOnComponent(3))=="cccc");
- CPPUNIT_ASSERT(std::string(a4->getInfoOnComponent(4))=="aaaa");
- CPPUNIT_ASSERT(std::string(a4->getInfoOnComponent(5))=="aaaa");
- for(int i=0;i<30;i++)
- CPPUNIT_ASSERT_EQUAL(int(expected1[i]),a4->getIJ(0,i));
- // setSelectedComponents
- const int arr3[2]={3,2};
- std::vector<int> arr3V(arr3,arr3+2);
- DataArrayDouble *a5=a1->keepSelectedComponents(arr3V);
- a5->setInfoOnComponent(0,"eeee");
- a5->setInfoOnComponent(1,"ffff");
- const int arr4[2]={1,2};
- std::vector<int> arr4V(arr4,arr4+2);
- a2->setSelectedComponents(a5,arr4V);
- CPPUNIT_ASSERT_EQUAL(6,a2->getNumberOfComponents());
- CPPUNIT_ASSERT_EQUAL(5,a2->getNumberOfTuples());
- CPPUNIT_ASSERT(std::string(a2->getInfoOnComponent(0))=="bbbb");
- CPPUNIT_ASSERT(std::string(a2->getInfoOnComponent(1))=="eeee");
- CPPUNIT_ASSERT(std::string(a2->getInfoOnComponent(2))=="ffff");
- CPPUNIT_ASSERT(std::string(a2->getInfoOnComponent(3))=="cccc");
- CPPUNIT_ASSERT(std::string(a2->getInfoOnComponent(4))=="aaaa");
- CPPUNIT_ASSERT(std::string(a2->getInfoOnComponent(5))=="aaaa");
- const double expected2[30]={2.,4.,3.,3.,1.,1., 12.,14.,13.,13.,11.,11., 22.,24.,23.,23.,21.,21., 32.,34.,33.,33.,31.,31., 42.,44.,43.,43.,41.,41.};
- for(int i=0;i<30;i++)
- CPPUNIT_ASSERT_DOUBLES_EQUAL(expected2[i],a2->getIJ(0,i),1e-14);
- DataArrayInt *a6=a5->convertToIntArr();
- a6->setInfoOnComponent(0,"eeee");
- a6->setInfoOnComponent(1,"ffff");
- a4->setSelectedComponents(a6,arr4V);
- CPPUNIT_ASSERT_EQUAL(6,a4->getNumberOfComponents());
- CPPUNIT_ASSERT_EQUAL(5,a4->getNumberOfTuples());
- CPPUNIT_ASSERT(std::string(a4->getInfoOnComponent(0))=="bbbb");
- CPPUNIT_ASSERT(std::string(a4->getInfoOnComponent(1))=="eeee");
- CPPUNIT_ASSERT(std::string(a4->getInfoOnComponent(2))=="ffff");
- CPPUNIT_ASSERT(std::string(a4->getInfoOnComponent(3))=="cccc");
- CPPUNIT_ASSERT(std::string(a4->getInfoOnComponent(4))=="aaaa");
- CPPUNIT_ASSERT(std::string(a4->getInfoOnComponent(5))=="aaaa");
- for(int i=0;i<30;i++)
- CPPUNIT_ASSERT_EQUAL(int(expected2[i]),a4->getIJ(0,i));
- // test of throw
- const int arr5[3]={2,3,6};
- const int arr6[3]={2,7,5};
- const int arr7[4]={2,1,4,6};
- std::vector<int> arr5V(arr5,arr5+3);
- std::vector<int> arr6V(arr6,arr6+3);
- std::vector<int> arr7V(arr7,arr7+4);
- CPPUNIT_ASSERT_THROW(a2->keepSelectedComponents(arr5V),INTERP_KERNEL::Exception);
- CPPUNIT_ASSERT_THROW(a2->keepSelectedComponents(arr6V),INTERP_KERNEL::Exception);
- CPPUNIT_ASSERT_THROW(a2->setSelectedComponents(a1,arr7V),INTERP_KERNEL::Exception);
- arr7V.resize(3);
- CPPUNIT_ASSERT_THROW(a2->setSelectedComponents(a1,arr7V),INTERP_KERNEL::Exception);
- //
- a6->decrRef();
- a5->decrRef();
- a4->decrRef();
- a3->decrRef();
- a2->decrRef();
- a1->decrRef();
-}
-
-void MEDCouplingBasicsTest::testKeepSetSelectedComponent2()
-{
- MEDCouplingUMesh *m1=build2DTargetMesh_1();
- const double arr1[20]={1.,2.,3.,4., 11.,12.,13.,14., 21.,22.,23.,24., 31.,32.,33.,34., 41.,42.,43.,44.};
- DataArrayDouble *a1=DataArrayDouble::New();
- a1->alloc(5,4);
- std::copy(arr1,arr1+20,a1->getPointer());
- a1->setInfoOnComponent(0,"aaaa");
- a1->setInfoOnComponent(1,"bbbb");
- a1->setInfoOnComponent(2,"cccc");
- a1->setInfoOnComponent(3,"dddd");
- MEDCouplingFieldDouble *f1=MEDCouplingFieldDouble::New(ON_CELLS,ONE_TIME);
- f1->setTime(2.3,4,5);
- f1->setMesh(m1);
- f1->setName("f1");
- f1->setArray(a1);
- f1->checkCoherency();
- //
- const int arr2[6]={1,2,1,2,0,0};
- std::vector<int> arr2V(arr2,arr2+6);
- MEDCouplingFieldDouble *f2=f1->keepSelectedComponents(arr2V);
- CPPUNIT_ASSERT(f2->getMesh()==f1->getMesh());
- CPPUNIT_ASSERT(f2->getTimeDiscretization()==ONE_TIME);
- int dt,it;
- CPPUNIT_ASSERT_DOUBLES_EQUAL(2.3,f2->getTime(dt,it),1e-13);
- CPPUNIT_ASSERT_EQUAL(4,dt);
- CPPUNIT_ASSERT_EQUAL(5,it);
- f2->checkCoherency();
- CPPUNIT_ASSERT_EQUAL(6,f2->getNumberOfComponents());
- CPPUNIT_ASSERT_EQUAL(5,f2->getNumberOfTuples());
- CPPUNIT_ASSERT(std::string(f2->getArray()->getInfoOnComponent(0))=="bbbb");
- CPPUNIT_ASSERT(std::string(f2->getArray()->getInfoOnComponent(1))=="cccc");
- CPPUNIT_ASSERT(std::string(f2->getArray()->getInfoOnComponent(2))=="bbbb");
- CPPUNIT_ASSERT(std::string(f2->getArray()->getInfoOnComponent(3))=="cccc");
- CPPUNIT_ASSERT(std::string(f2->getArray()->getInfoOnComponent(4))=="aaaa");
- CPPUNIT_ASSERT(std::string(f2->getArray()->getInfoOnComponent(5))=="aaaa");
- const double expected1[30]={2.,3.,2.,3.,1.,1., 12.,13.,12.,13.,11.,11., 22.,23.,22.,23.,21.,21., 32.,33.,32.,33.,31.,31., 42.,43.,42.,43.,41.,41.};
- for(int i=0;i<30;i++)
- CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1[i],f2->getIJ(0,i),1e-14);
- //setSelectedComponents
- const int arr3[2]={3,2};
- std::vector<int> arr3V(arr3,arr3+2);
- MEDCouplingFieldDouble *f5=f1->keepSelectedComponents(arr3V);
- f5->setTime(6.7,8,9);
- f5->getArray()->setInfoOnComponent(0,"eeee");
- f5->getArray()->setInfoOnComponent(1,"ffff");
- f5->checkCoherency();
- const int arr4[2]={1,2};
- std::vector<int> arr4V(arr4,arr4+2);
- f2->setSelectedComponents(f5,arr4V);
- CPPUNIT_ASSERT_EQUAL(6,f2->getNumberOfComponents());
- CPPUNIT_ASSERT_EQUAL(5,f2->getNumberOfTuples());
- f2->checkCoherency();
- CPPUNIT_ASSERT_DOUBLES_EQUAL(2.3,f2->getTime(dt,it),1e-13);
- CPPUNIT_ASSERT_EQUAL(4,dt);
- CPPUNIT_ASSERT_EQUAL(5,it);
- CPPUNIT_ASSERT(std::string(f2->getArray()->getInfoOnComponent(0))=="bbbb");
- CPPUNIT_ASSERT(std::string(f2->getArray()->getInfoOnComponent(1))=="eeee");
- CPPUNIT_ASSERT(std::string(f2->getArray()->getInfoOnComponent(2))=="ffff");
- CPPUNIT_ASSERT(std::string(f2->getArray()->getInfoOnComponent(3))=="cccc");
- CPPUNIT_ASSERT(std::string(f2->getArray()->getInfoOnComponent(4))=="aaaa");
- CPPUNIT_ASSERT(std::string(f2->getArray()->getInfoOnComponent(5))=="aaaa");
- const double expected2[30]={2.,4.,3.,3.,1.,1., 12.,14.,13.,13.,11.,11., 22.,24.,23.,23.,21.,21., 32.,34.,33.,33.,31.,31., 42.,44.,43.,43.,41.,41.};
- for(int i=0;i<30;i++)
- CPPUNIT_ASSERT_DOUBLES_EQUAL(expected2[i],f2->getIJ(0,i),1e-14);
- f5->decrRef();
- f1->decrRef();
- f2->decrRef();
- a1->decrRef();
- m1->decrRef();
-}
-
-void MEDCouplingBasicsTest::testDAIGetIdsEqual1()
-{
- const int tab1[7]={5,-2,-4,-2,3,2,-2};
- DataArrayInt *da=DataArrayInt::New();
- da->alloc(7,1);
- std::copy(tab1,tab1+7,da->getPointer());
- DataArrayInt *da2=da->getIdsEqual(-2);
- CPPUNIT_ASSERT_EQUAL(3,da2->getNumberOfTuples());
- CPPUNIT_ASSERT_EQUAL(1,da2->getNumberOfComponents());
- const int expected1[3]={1,3,6};
- CPPUNIT_ASSERT(std::equal(expected1,expected1+3,da2->getConstPointer()));
- da2->decrRef();
- da->decrRef();
-}
-
-void MEDCouplingBasicsTest::testDAIGetIdsEqualList1()
-{
- const int tab1[7]={5,-2,-4,-2,3,2,-2};
- DataArrayInt *da=DataArrayInt::New();
- da->alloc(7,1);
- std::copy(tab1,tab1+7,da->getPointer());
- const int tab2[3]={3,-2,0};
- std::vector<int> tab2V(tab2,tab2+3);
- DataArrayInt *da2=da->getIdsEqualList(tab2V);
- CPPUNIT_ASSERT_EQUAL(4,da2->getNumberOfTuples());
- CPPUNIT_ASSERT_EQUAL(1,da2->getNumberOfComponents());
- const int expected1[4]={1,3,4,6};
- CPPUNIT_ASSERT(std::equal(expected1,expected1+4,da2->getConstPointer()));
- da2->decrRef();
- da->decrRef();
-}
-
-void MEDCouplingBasicsTest::testDAFromNoInterlace1()
-{
- const int tab1[15]={1,11,21,31,41,2,12,22,32,42,3,13,23,33,43};
- DataArrayInt *da=DataArrayInt::New();
- da->alloc(5,3);
- std::copy(tab1,tab1+15,da->getPointer());
- DataArrayInt *da2=da->fromNoInterlace();
- const int expected1[15]={1,2,3,11,12,13,21,22,23,31,32,33,41,42,43};
- CPPUNIT_ASSERT_EQUAL(5,da2->getNumberOfTuples());
- CPPUNIT_ASSERT_EQUAL(3,da2->getNumberOfComponents());// it's not a bug. Avoid to have 1 million components !
- CPPUNIT_ASSERT(std::equal(expected1,expected1+15,da2->getConstPointer()));
- DataArrayDouble *da3=da->convertToDblArr();
- DataArrayDouble *da4=da3->fromNoInterlace();
- CPPUNIT_ASSERT_EQUAL(5,da4->getNumberOfTuples());
- CPPUNIT_ASSERT_EQUAL(3,da4->getNumberOfComponents());// it's not a bug. Avoid to have 1 million components !
- for(int i=0;i<15;i++)
- CPPUNIT_ASSERT_DOUBLES_EQUAL((double)expected1[i],da4->getIJ(0,i),1e-14);
- da4->decrRef();
- da3->decrRef();
- da2->decrRef();
- da->decrRef();
-}
-
-void MEDCouplingBasicsTest::testDAToNoInterlace1()
-{
- const int tab1[15]={1,2,3,11,12,13,21,22,23,31,32,33,41,42,43};
- DataArrayInt *da=DataArrayInt::New();
- da->alloc(5,3);
- std::copy(tab1,tab1+15,da->getPointer());
- DataArrayInt *da2=da->toNoInterlace();
- const int expected1[15]={1,11,21,31,41,2,12,22,32,42,3,13,23,33,43};
- CPPUNIT_ASSERT_EQUAL(5,da2->getNumberOfTuples());
- CPPUNIT_ASSERT_EQUAL(3,da2->getNumberOfComponents());// it's not a bug. Avoid to have 1 million components !
- CPPUNIT_ASSERT(std::equal(expected1,expected1+15,da2->getConstPointer()));
- DataArrayDouble *da3=da->convertToDblArr();
- DataArrayDouble *da4=da3->toNoInterlace();
- CPPUNIT_ASSERT_EQUAL(5,da4->getNumberOfTuples());
- CPPUNIT_ASSERT_EQUAL(3,da4->getNumberOfComponents());// it's not a bug. Avoid to have 1 million components !
- for(int i=0;i<15;i++)
- CPPUNIT_ASSERT_DOUBLES_EQUAL((double)expected1[i],da4->getIJ(0,i),1e-14);
- da4->decrRef();
- da3->decrRef();
- da2->decrRef();
- da->decrRef();
-}
-
-void MEDCouplingBasicsTest::testDAIsUniform1()
-{
- const int tab1[5]={1,1,1,1,1};
- DataArrayInt *da=DataArrayInt::New();
- da->alloc(5,1);
- std::copy(tab1,tab1+5,da->getPointer());
- CPPUNIT_ASSERT(da->isUniform(1));
- da->setIJ(2,0,2);
- CPPUNIT_ASSERT(!da->isUniform(1));
- da->setIJ(2,0,1);
- CPPUNIT_ASSERT(da->isUniform(1));
- DataArrayDouble *da2=da->convertToDblArr();
- CPPUNIT_ASSERT(da2->isUniform(1.,1e-12));
- da2->setIJ(1,0,1.+1.e-13);
- CPPUNIT_ASSERT(da2->isUniform(1.,1e-12));
- da2->setIJ(1,0,1.+1.e-11);
- CPPUNIT_ASSERT(!da2->isUniform(1.,1e-12));
- da2->decrRef();
- da->decrRef();
-}
-
-void MEDCouplingBasicsTest::testDADFromPolarToCart1()
-{
- const double tab1[4]={2.,0.2,2.5,0.7};
- DataArrayDouble *da=DataArrayDouble::New();
- da->alloc(2,2);
- std::copy(tab1,tab1+4,da->getPointer());
- DataArrayDouble *da2=da->fromPolarToCart();
- const double expected1[4]={1.9601331556824833,0.39733866159012243, 1.9121054682112213,1.6105442180942275};
- for(int i=0;i<4;i++)
- CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1[i],da2->getIJ(0,i),1e-13);
- da2->decrRef();
- da->decrRef();
-}
-
-void MEDCouplingBasicsTest::testDADFromCylToCart1()
-{
- const double tab1[6]={2.,0.2,4.,2.5,0.7,9.};
- DataArrayDouble *da=DataArrayDouble::New();
- da->alloc(2,3);
- std::copy(tab1,tab1+6,da->getPointer());
- DataArrayDouble *da2=da->fromCylToCart();
- const double expected1[6]={1.9601331556824833,0.39733866159012243,4., 1.9121054682112213,1.6105442180942275,9.};
- for(int i=0;i<6;i++)
- CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1[i],da2->getIJ(0,i),1e-13);
- da2->decrRef();
- da->decrRef();
-}
-
-void MEDCouplingBasicsTest::testDADFromSpherToCart1()
-{
- const double tab1[6]={2.,0.2,0.3,2.5,0.7,0.8};
- DataArrayDouble *da=DataArrayDouble::New();
- da->alloc(2,3);
- std::copy(tab1,tab1+6,da->getPointer());
- DataArrayDouble *da2=da->fromSpherToCart();
- const double expected1[6]={0.37959212195737485,0.11742160338765303,1.9601331556824833, 1.1220769624465328,1.1553337045129035,1.9121054682112213};
- for(int i=0;i<6;i++)
- CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1[i],da2->getIJ(0,i),1e-13);
- da2->decrRef();
- da->decrRef();
-}
-
-void MEDCouplingBasicsTest::testUnPolyze1()
-{
- const int elts[8]={0,1,2,3,4,5,6,7};
- std::vector<int> eltsV(elts,elts+8);
- MEDCouplingUMesh *mesh=build3DTargetMesh_1();
- mesh->convertToPolyTypes(eltsV);
- mesh->unPolyze();
- MEDCouplingUMesh *mesh2=build3DTargetMesh_1();
- mesh->checkCoherency();
- CPPUNIT_ASSERT(mesh->isEqual(mesh2,1e-12));
- mesh->convertToPolyTypes(eltsV);
- CPPUNIT_ASSERT(!mesh->isEqual(mesh2,1e-12));
- mesh->getNodalConnectivity()->setIJ(0,6,10);
- mesh->getNodalConnectivity()->setIJ(0,7,9);
- mesh->getNodalConnectivity()->setIJ(0,8,12);
- mesh->getNodalConnectivity()->setIJ(0,9,13);
- mesh->unPolyze();
- CPPUNIT_ASSERT(mesh->isEqual(mesh2,1e-12));
- mesh->convertToPolyTypes(eltsV);
- mesh->getNodalConnectivity()->setIJ(0,6,12);
- mesh->getNodalConnectivity()->setIJ(0,7,13);
- mesh->getNodalConnectivity()->setIJ(0,8,10);
- mesh->getNodalConnectivity()->setIJ(0,9,9);
- mesh->unPolyze();
- CPPUNIT_ASSERT(mesh->isEqual(mesh2,1e-12));
- mesh->convertToPolyTypes(eltsV);
- mesh->getNodalConnectivity()->setIJ(0,6,12);
- mesh->getNodalConnectivity()->setIJ(0,7,10);
- mesh->getNodalConnectivity()->setIJ(0,8,13);
- mesh->getNodalConnectivity()->setIJ(0,9,9);
- mesh->unPolyze();
- CPPUNIT_ASSERT(!mesh->isEqual(mesh2,1e-12));
- mesh->decrRef();
- mesh2->decrRef();
- // Test for 2D mesh
- mesh=build2DTargetMesh_1();
- mesh2=build2DTargetMesh_1();
- eltsV.resize(5);
- mesh->convertToPolyTypes(eltsV);
- CPPUNIT_ASSERT(!mesh->isEqual(mesh2,1e-12));
- mesh->unPolyze();
- CPPUNIT_ASSERT(mesh->isEqual(mesh2,1e-12));
- mesh->decrRef();
- mesh2->decrRef();
-}
-
-void MEDCouplingBasicsTest::testConvertDegeneratedCells1()
-{
- MEDCouplingUMesh *mesh=build3DTargetMesh_1();
- int conn[32]={0,1,3,3,9,10,12,12, 0,1,3,4,9,9,9,9, 1,1,1,1,10,12,9,10, 10,11,12,9,1,1,1,1};
- mesh->allocateCells(4);
- mesh->insertNextCell(INTERP_KERNEL::NORM_HEXA8,8,conn);
- mesh->insertNextCell(INTERP_KERNEL::NORM_HEXA8,8,conn+8);
- mesh->insertNextCell(INTERP_KERNEL::NORM_HEXA8,8,conn+16);
- mesh->insertNextCell(INTERP_KERNEL::NORM_HEXA8,8,conn+24);
- mesh->finishInsertingCells();
- mesh->checkCoherency();
- CPPUNIT_ASSERT_EQUAL(4,mesh->getNumberOfCells());
- CPPUNIT_ASSERT_EQUAL(INTERP_KERNEL::NORM_HEXA8,mesh->getTypeOfCell(0));
- CPPUNIT_ASSERT_EQUAL(INTERP_KERNEL::NORM_HEXA8,mesh->getTypeOfCell(1));
- CPPUNIT_ASSERT_EQUAL(INTERP_KERNEL::NORM_HEXA8,mesh->getTypeOfCell(2));
- CPPUNIT_ASSERT_EQUAL(INTERP_KERNEL::NORM_HEXA8,mesh->getTypeOfCell(3));
- MEDCouplingFieldDouble *f1=mesh->getMeasureField(true);
- mesh->convertDegeneratedCells();
- mesh->checkCoherency();
- MEDCouplingFieldDouble *f2=mesh->getMeasureField(true);
- CPPUNIT_ASSERT_EQUAL(4,mesh->getNumberOfCells());
- CPPUNIT_ASSERT_EQUAL(INTERP_KERNEL::NORM_PENTA6,mesh->getTypeOfCell(0));
- CPPUNIT_ASSERT_EQUAL(INTERP_KERNEL::NORM_PYRA5,mesh->getTypeOfCell(1));
- CPPUNIT_ASSERT_EQUAL(INTERP_KERNEL::NORM_TETRA4,mesh->getTypeOfCell(2));
- CPPUNIT_ASSERT_EQUAL(INTERP_KERNEL::NORM_PYRA5,mesh->getTypeOfCell(3));
- for(int i=0;i<4;i++)
- CPPUNIT_ASSERT_DOUBLES_EQUAL(f1->getArray()->getIJ(0,i),f2->getArray()->getIJ(0,i),1e-5);
- f1->decrRef();
- f2->decrRef();
- mesh->decrRef();
-}
-
-void MEDCouplingBasicsTest::testGetNodeIdsNearPoints1()
-{
- MEDCouplingUMesh *mesh=build2DTargetMesh_1();
- DataArrayDouble *coords=mesh->getCoords();
- DataArrayDouble *tmp=DataArrayDouble::New();
- tmp->alloc(3,2);
- const double vals[6]={0.2,0.2,0.1,0.2,0.2,0.2};
- std::copy(vals,vals+6,tmp->getPointer());
- DataArrayDouble *tmp2=DataArrayDouble::aggregate(coords,tmp);
- tmp->decrRef();
- mesh->setCoords(tmp2);
- tmp2->decrRef();
- const double pts[6]={0.2,0.2,0.1,0.3,-0.3,0.7};
- std::vector<int> c=mesh->getNodeIdsNearPoint(pts,1e-7);
- CPPUNIT_ASSERT_EQUAL(3,(int)c.size());
- CPPUNIT_ASSERT_EQUAL(4,c[0]);
- CPPUNIT_ASSERT_EQUAL(9,c[1]);
- CPPUNIT_ASSERT_EQUAL(11,c[2]);
- c.clear();
- std::vector<int> cI;
- mesh->getNodeIdsNearPoints(pts,3,1e-7,c,cI);
- CPPUNIT_ASSERT_EQUAL(4,(int)cI.size());
- CPPUNIT_ASSERT_EQUAL(4,(int)c.size());
- CPPUNIT_ASSERT_EQUAL(4,c[0]);
- CPPUNIT_ASSERT_EQUAL(9,c[1]);
- CPPUNIT_ASSERT_EQUAL(11,c[2]);
- CPPUNIT_ASSERT_EQUAL(6,c[3]);
- CPPUNIT_ASSERT_EQUAL(0,cI[0]);
- CPPUNIT_ASSERT_EQUAL(3,cI[1]);
- CPPUNIT_ASSERT_EQUAL(3,cI[2]);
- CPPUNIT_ASSERT_EQUAL(4,cI[3]);
- mesh->decrRef();
-}
-
-void MEDCouplingBasicsTest::testFieldCopyTinyAttrFrom1()
-{
- MEDCouplingFieldDouble *f1=MEDCouplingFieldDouble::New(ON_CELLS,ONE_TIME);
- f1->setName("f1");
- f1->setTimeTolerance(1.e-5);
- f1->setDescription("f1Desc");
- f1->setTime(1.23,4,5);
- MEDCouplingFieldDouble *f2=MEDCouplingFieldDouble::New(ON_CELLS,ONE_TIME);
- f2->setName("f2");
- f2->setDescription("f2Desc");
- f2->setTime(6.78,9,10);
- f2->setTimeTolerance(4.556e-12);
- //
- int dt,it;
- f1->copyTinyAttrFrom(f2);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(4.556e-12,f1->getTimeTolerance(),1e-24);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(6.78,f1->getTime(dt,it),1e-12);
- CPPUNIT_ASSERT_EQUAL(9,dt);
- CPPUNIT_ASSERT_EQUAL(10,it);
- CPPUNIT_ASSERT(std::string(f1->getName())=="f1");//name unchanged
- CPPUNIT_ASSERT(std::string(f1->getDescription())=="f1Desc");//description unchanged
- f1->decrRef();
- f2->decrRef();
- //
- f1=MEDCouplingFieldDouble::New(ON_CELLS,NO_TIME);
- f1->setName("f1");
- f1->setTimeTolerance(1.e-5);
- f1->setDescription("f1Desc");
- f2=MEDCouplingFieldDouble::New(ON_CELLS,NO_TIME);
- f2->setName("f2");
- f2->setDescription("f2Desc");
- f2->setTimeTolerance(4.556e-12);
- //
- f1->copyTinyAttrFrom(f2);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(4.556e-12,f1->getTimeTolerance(),1e-24);
- CPPUNIT_ASSERT(std::string(f1->getName())=="f1");//name unchanged
- CPPUNIT_ASSERT(std::string(f1->getDescription())=="f1Desc");//description unchanged
- f1->decrRef();
- f2->decrRef();
- //
- f1=MEDCouplingFieldDouble::New(ON_CELLS,CONST_ON_TIME_INTERVAL);
- f1->setName("f1");
- f1->setTimeTolerance(1.e-5);
- f1->setDescription("f1Desc");
- f1->setTime(1.23,4,5);
- f1->setEndTime(5.43,2,1);
- f2=MEDCouplingFieldDouble::New(ON_CELLS,CONST_ON_TIME_INTERVAL);
- f2->setName("f2");
- f2->setDescription("f2Desc");
- f2->setTimeTolerance(4.556e-12);
- f2->setTime(6.78,9,10);
- f2->setEndTime(10.98,7,6);
- //
- f1->copyTinyAttrFrom(f2);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(4.556e-12,f1->getTimeTolerance(),1e-24);
- CPPUNIT_ASSERT(std::string(f1->getName())=="f1");//name unchanged
- CPPUNIT_ASSERT(std::string(f1->getDescription())=="f1Desc");//description unchanged
- CPPUNIT_ASSERT_DOUBLES_EQUAL(6.78,f1->getTime(dt,it),1e-12);
- CPPUNIT_ASSERT_EQUAL(9,dt);
- CPPUNIT_ASSERT_EQUAL(10,it);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(10.98,f1->getEndTime(dt,it),1e-12);
- CPPUNIT_ASSERT_EQUAL(7,dt);
- CPPUNIT_ASSERT_EQUAL(6,it);
- f1->decrRef();
- f2->decrRef();
- //
- f1=MEDCouplingFieldDouble::New(ON_CELLS,LINEAR_TIME);
- f1->setName("f1");
- f1->setTimeTolerance(1.e-5);
- f1->setDescription("f1Desc");
- f1->setTime(1.23,4,5);
- f1->setEndTime(5.43,2,1);
- f2=MEDCouplingFieldDouble::New(ON_CELLS,LINEAR_TIME);
- f2->setName("f2");
- f2->setDescription("f2Desc");
- f2->setTimeTolerance(4.556e-12);
- f2->setTime(6.78,9,10);
- f2->setEndTime(10.98,7,6);
- //
- f1->copyTinyAttrFrom(f2);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(4.556e-12,f1->getTimeTolerance(),1e-24);
- CPPUNIT_ASSERT(std::string(f1->getName())=="f1");//name unchanged
- CPPUNIT_ASSERT(std::string(f1->getDescription())=="f1Desc");//description unchanged
- CPPUNIT_ASSERT_DOUBLES_EQUAL(6.78,f1->getTime(dt,it),1e-12);
- CPPUNIT_ASSERT_EQUAL(9,dt);
- CPPUNIT_ASSERT_EQUAL(10,it);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(10.98,f1->getEndTime(dt,it),1e-12);
- CPPUNIT_ASSERT_EQUAL(7,dt);
- CPPUNIT_ASSERT_EQUAL(6,it);
- f1->decrRef();
- f2->decrRef();
-}
-
-/*!
- * 1D -> 2D extrusion with rotation
- */
-void MEDCouplingBasicsTest::testExtrudedMesh5()
-{
- const double coo1[4]={0.,1.,2.,3.5};
- DataArrayDouble *a=DataArrayDouble::New();
- a->alloc(4,1);
- std::copy(coo1,coo1+4,a->getPointer());
- MEDCouplingCMesh *b=MEDCouplingCMesh::New();
- b->setCoordsAt(0,a);
- MEDCouplingUMesh *c=b->buildUnstructured();
- CPPUNIT_ASSERT_EQUAL(1,c->getSpaceDimension());
- c->changeSpaceDimension(2);
- //
- DataArrayDouble *d=DataArrayDouble::New();
- d->alloc(13,1);
- d->iota();
- MEDCouplingCMesh *e=MEDCouplingCMesh::New();
- e->setCoordsAt(0,d);
- MEDCouplingUMesh *f=e->buildUnstructured();
- DataArrayDouble *g=f->getCoords()->applyFunc(2,"3.5*IVec+x/6*3.14159265359*JVec");
- DataArrayDouble *h=g->fromPolarToCart();
- f->setCoords(h);
- MEDCouplingUMesh *i=c->buildExtrudedMeshFromThis(f,1);
- CPPUNIT_ASSERT_EQUAL(52,i->getNumberOfNodes());
- bool tmp2;
- int tmp3;
- DataArrayInt *tmp=i->mergeNodes(1e-9,tmp2,tmp3);
- CPPUNIT_ASSERT(tmp2);
- CPPUNIT_ASSERT_EQUAL(37,tmp3);
- tmp->decrRef();
- i->convertDegeneratedCells();
- i->checkCoherency();
- CPPUNIT_ASSERT_EQUAL(36,i->getNumberOfCells());
- CPPUNIT_ASSERT_EQUAL(37,i->getNumberOfNodes());
- CPPUNIT_ASSERT_EQUAL(12,i->getNumberOfCellsWithType(INTERP_KERNEL::NORM_TRI3));
- CPPUNIT_ASSERT_EQUAL(24,i->getNumberOfCellsWithType(INTERP_KERNEL::NORM_QUAD4));
- const double expected1[3]={0.25,0.75,2.0625};
- MEDCouplingFieldDouble *j=i->getMeasureField(true);
- for(int i=0;i<12;i++)
- for(int k=0;k<3;k++)
- CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1[k],j->getIJ(0,i*3+k),1e-10);
- const double expected2[72]={0.62200846792814113, 0.16666666666681595, 1.4513530918323276, 0.38888888888923495, 2.6293994326053212, 0.7045454545460802, 0.45534180126145435, 0.45534180126150181, 1.0624642029433926, 1.0624642029435025, 1.9248539780597826, 1.9248539780599816, 0.16666666666661334, 0.62200846792815856, 0.38888888888876294, 1.4513530918323678, 0.70454545454522521, 2.629399432605394, -0.16666666666674007, 0.62200846792812436, -0.38888888888906142, 1.4513530918322881, -0.70454545454576778, 2.6293994326052488, -0.45534180126154766, 0.45534180126140844, -1.0624642029436118, 1.0624642029432834, -1.9248539780601803, 1.9248539780595841, -0.62200846792817499, 0.1666666666665495, -1.451353091832408, 0.388888888888613, -2.6293994326054668, 0.70454545454495332, -0.62200846792810593, -0.16666666666680507, -1.451353091832247, -0.38888888888921297, -2.6293994326051746, -0.70454545454604123, -0.45534180126135926, -0.45534180126159562, -1.0624642029431723, -1.0624642029437235, -1.9248539780593836, -1.9248539780603811, -0.1666666666664828, -0.62200846792819242, -0.38888888888846079, -1.4513530918324489, -0.70454545454467987, -2.6293994326055397, 0.16666666666687083, -0.62200846792808862, 0.38888888888936374, -1.4513530918322073, 0.70454545454631357, -2.6293994326051022, 0.45534180126164348, -0.45534180126131207, 1.0624642029438327, -1.0624642029430627, 1.9248539780605791, -1.9248539780591853, 0.62200846792821063, -0.16666666666641802, 1.4513530918324888, -0.38888888888831086, 2.6293994326056125, -0.70454545454440853};
- DataArrayDouble *m=i->getBarycenterAndOwner();
- for(int i=0;i<72;i++)
- CPPUNIT_ASSERT_DOUBLES_EQUAL(expected2[i],m->getIJ(0,i),1e-10);
- //
- m->decrRef();
- j->decrRef();
- i->decrRef();
- h->decrRef();
- g->decrRef();
- f->decrRef();
- e->decrRef();
- d->decrRef();
- c->decrRef();
- b->decrRef();
- a->decrRef();
-}
-
-/*!
- * 1D -> 2D extrusion without rotation
- */
-void MEDCouplingBasicsTest::testExtrudedMesh6()
-{
- const double coo1[4]={0.,1.,2.,3.5};
- DataArrayDouble *a=DataArrayDouble::New();
- a->alloc(4,1);
- std::copy(coo1,coo1+4,a->getPointer());
- MEDCouplingCMesh *b=MEDCouplingCMesh::New();
- b->setCoordsAt(0,a);
- MEDCouplingUMesh *c=b->buildUnstructured();
- CPPUNIT_ASSERT_EQUAL(1,c->getSpaceDimension());
- c->changeSpaceDimension(2);
- //
- DataArrayDouble *d=DataArrayDouble::New();
- d->alloc(5,1);
- d->iota();
- MEDCouplingCMesh *e=MEDCouplingCMesh::New();
- e->setCoordsAt(0,d);
- MEDCouplingUMesh *f=e->buildUnstructured();
- DataArrayDouble *d2=f->getCoords()->applyFunc("x*x/2");
- f->setCoords(d2);
- f->changeSpaceDimension(2);
- //
- const double center[2]={0.,0.};
- f->rotate(center,0,M_PI/3);
- MEDCouplingUMesh *g=c->buildExtrudedMeshFromThis(f,0);
- g->checkCoherency();
- const double expected1[]={ 0.4330127018922193, 0.4330127018922193, 0.649519052838329, 1.2990381056766578, 1.299038105676658, 1.948557158514987, 2.1650635094610955, 2.1650635094610964, 3.2475952641916446, 3.031088913245533, 3.0310889132455352, 4.546633369868303 };
- MEDCouplingFieldDouble *f1=g->getMeasureField(true);
- for(int i=0;i<12;i++)
- CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1[i],f1->getIJ(0,i),1e-12);
-
- const double expected2[]={0.625, 0.21650635094610962, 1.625, 0.21650635094610959, 2.8750000000000004, 0.21650635094610965, 1.1250000000000002, 1.0825317547305482, 2.125, 1.0825317547305482, 3.3750000000000004, 1.0825317547305484, 2.125, 2.8145825622994254, 3.125, 2.8145825622994254, 4.375, 2.8145825622994254, 3.6250000000000009, 5.4126587736527414, 4.625, 5.4126587736527414, 5.875, 5.4126587736527414};
- DataArrayDouble *f2=g->getBarycenterAndOwner();
- for(int i=0;i<24;i++)
- CPPUNIT_ASSERT_DOUBLES_EQUAL(expected2[i],f2->getIJ(0,i),1e-12);
- //
- f1->decrRef();
- f2->decrRef();
- g->decrRef();
- f->decrRef();
- e->decrRef();
- d->decrRef();
- d2->decrRef();
- c->decrRef();
- b->decrRef();
- a->decrRef();
-}
-
-/*!
- * 2D -> 3D extrusion with rotation
- */
-void MEDCouplingBasicsTest::testExtrudedMesh7()
-{
- const double coo1[4]={0.,1.,2.,3.5};
- DataArrayDouble *a=DataArrayDouble::New();
- a->alloc(4,1);
- std::copy(coo1,coo1+4,a->getPointer());
- MEDCouplingCMesh *b=MEDCouplingCMesh::New();
- b->setCoordsAt(0,a);
- MEDCouplingUMesh *c=b->buildUnstructured();
- CPPUNIT_ASSERT_EQUAL(1,c->getSpaceDimension());
- c->changeSpaceDimension(2);
- //
- DataArrayDouble *d=DataArrayDouble::New();
- d->alloc(13,1);
- d->iota();
- MEDCouplingCMesh *e=MEDCouplingCMesh::New();
- e->setCoordsAt(0,d);
- MEDCouplingUMesh *f=e->buildUnstructured();
- DataArrayDouble *g=f->getCoords()->applyFunc(2,"3.5*IVec+x/6*3.14159265359*JVec");
- DataArrayDouble *h=g->fromPolarToCart();
- f->setCoords(h);
- MEDCouplingUMesh *i=c->buildExtrudedMeshFromThis(f,1);
- CPPUNIT_ASSERT_EQUAL(52,i->getNumberOfNodes());
- bool tmp2;
- int tmp3;
- DataArrayInt *tmp=i->mergeNodes(1e-9,tmp2,tmp3);
- CPPUNIT_ASSERT(tmp2);
- CPPUNIT_ASSERT_EQUAL(37,tmp3);
- tmp->decrRef();
- i->convertDegeneratedCells();
- const double vec1[3]={10.,0.,0.};
- i->translate(vec1);
- DataArrayDouble *g2=h->applyFunc(3,"13.5/3.5*x*IVec+0*JVec+13.5/3.5*y*KVec");
- f->setCoords(g2);
- i->changeSpaceDimension(3);
- MEDCouplingUMesh *i3=i->buildExtrudedMeshFromThis(f,1);
- MEDCouplingFieldDouble *f2=i3->getMeasureField(true);
- tmp=i->mergeNodes(1e-9,tmp2,tmp3);
- CPPUNIT_ASSERT(tmp2);
- CPPUNIT_ASSERT_EQUAL(444,tmp3);
- tmp->decrRef();
- const double expected1[36]={1.327751058489274, 4.2942574094314701, 13.024068164857139, 1.3069177251569044, 4.1484240761012954, 12.297505664866796, 1.270833333332571, 3.8958333333309674, 11.039062499993179, 1.2291666666659207, 3.6041666666644425, 9.585937499993932, 1.1930822748415895, 3.3515759238941376, 8.3274943351204556, 1.1722489415082769, 3.2057425905609289, 7.6009318351210622, 1.1722489415082862, 3.2057425905609884, 7.6009318351213713, 1.1930822748416161, 3.3515759238943001, 8.3274943351212727, 1.2291666666659564, 3.6041666666646734, 9.5859374999950777, 1.2708333333326081, 3.8958333333311868, 11.039062499994293, 1.3069177251569224, 4.1484240761014384, 12.297505664867627, 1.3277510584902354, 4.2942574094346071, 13.024068164866796};
- int kk=0;
- for(int ii=0;ii<12;ii++)
- for(int jj=0;jj<36;jj++,kk++)
- CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1[jj],f2->getIJ(0,kk),1e-9);
- //
- f2->decrRef();
- i3->decrRef();
- g2->decrRef();
- i->decrRef();
- h->decrRef();
- g->decrRef();
- f->decrRef();
- e->decrRef();
- d->decrRef();
- c->decrRef();
- b->decrRef();
- a->decrRef();
-}
-
-void MEDCouplingBasicsTest::testSimplexize1()
-{
- MEDCouplingUMesh *m=build3DSurfTargetMesh_1();
- std::vector<int> v(1);
- v[0]=3;
- m->convertToPolyTypes(v);
- DataArrayInt *da=m->simplexize(0);
- CPPUNIT_ASSERT_EQUAL(7,da->getNumberOfTuples());
- CPPUNIT_ASSERT_EQUAL(1,da->getNumberOfComponents());
- const int expected2[7]={0,0,1,2,3,4,4};
- for(int i=0;i<7;i++)
- CPPUNIT_ASSERT_EQUAL(expected2[i],da->getIJ(i,0));
- m->checkCoherency();
- CPPUNIT_ASSERT_EQUAL(7,m->getNumberOfCells());
- CPPUNIT_ASSERT_EQUAL(INTERP_KERNEL::NORM_TRI3,m->getTypeOfCell(0));
- CPPUNIT_ASSERT_EQUAL(INTERP_KERNEL::NORM_TRI3,m->getTypeOfCell(1));
- CPPUNIT_ASSERT_EQUAL(INTERP_KERNEL::NORM_TRI3,m->getTypeOfCell(2));
- CPPUNIT_ASSERT_EQUAL(INTERP_KERNEL::NORM_TRI3,m->getTypeOfCell(3));
- CPPUNIT_ASSERT_EQUAL(INTERP_KERNEL::NORM_POLYGON,m->getTypeOfCell(4));
- CPPUNIT_ASSERT_EQUAL(INTERP_KERNEL::NORM_TRI3,m->getTypeOfCell(5));
- CPPUNIT_ASSERT_EQUAL(INTERP_KERNEL::NORM_TRI3,m->getTypeOfCell(6));
- const double expected1[7]={0.125,0.125,0.125,0.125,0.25,0.125,0.125};
- MEDCouplingFieldDouble *f=m->getMeasureField(false);
- for(int i=0;i<7;i++)
- CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1[i]*sqrt(2.),f->getIJ(i,0),1e-10);
- std::set<INTERP_KERNEL::NormalizedCellType> types=m->getAllTypes();
- CPPUNIT_ASSERT_EQUAL(2,(int)types.size());
- CPPUNIT_ASSERT_EQUAL(INTERP_KERNEL::NORM_TRI3,*(types.begin()));
- CPPUNIT_ASSERT_EQUAL(INTERP_KERNEL::NORM_POLYGON,*(++(types.begin())));
- f->decrRef();
- da->decrRef();
- m->decrRef();
- //
- m=build3DSurfTargetMesh_1();
- v[0]=3;
- m->convertToPolyTypes(v);
- da=m->simplexize(1);
- CPPUNIT_ASSERT_EQUAL(7,da->getNumberOfTuples());
- CPPUNIT_ASSERT_EQUAL(1,da->getNumberOfComponents());
- for(int i=0;i<7;i++)
- CPPUNIT_ASSERT_EQUAL(expected2[i],da->getIJ(i,0));
- m->checkCoherency();
- types=m->getAllTypes();
- CPPUNIT_ASSERT_EQUAL(2,(int)types.size());
- CPPUNIT_ASSERT_EQUAL(INTERP_KERNEL::NORM_TRI3,*(types.begin()));
- CPPUNIT_ASSERT_EQUAL(INTERP_KERNEL::NORM_POLYGON,*(++(types.begin())));
- CPPUNIT_ASSERT_EQUAL(7,m->getNumberOfCells());
- CPPUNIT_ASSERT_EQUAL(INTERP_KERNEL::NORM_TRI3,m->getTypeOfCell(0));
- CPPUNIT_ASSERT_EQUAL(INTERP_KERNEL::NORM_TRI3,m->getTypeOfCell(1));
- CPPUNIT_ASSERT_EQUAL(INTERP_KERNEL::NORM_TRI3,m->getTypeOfCell(2));
- CPPUNIT_ASSERT_EQUAL(INTERP_KERNEL::NORM_TRI3,m->getTypeOfCell(3));
- CPPUNIT_ASSERT_EQUAL(INTERP_KERNEL::NORM_POLYGON,m->getTypeOfCell(4));
- CPPUNIT_ASSERT_EQUAL(INTERP_KERNEL::NORM_TRI3,m->getTypeOfCell(5));
- CPPUNIT_ASSERT_EQUAL(INTERP_KERNEL::NORM_TRI3,m->getTypeOfCell(6));
- f=m->getMeasureField(false);
- for(int i=0;i<7;i++)
- CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1[i]*sqrt(2.),f->getIJ(i,0),1e-10);
- f->decrRef();
- da->decrRef();
- m->decrRef();
-}
-
-void MEDCouplingBasicsTest::testSimplexize2()
-{
- MEDCouplingUMesh *m=build3DSurfTargetMesh_1();
- std::vector<int> v(1);
- v[0]=3;
- m->convertToPolyTypes(v);
- MEDCouplingFieldDouble *f1=MEDCouplingFieldDouble::New(ON_CELLS,ONE_TIME);
- f1->setMesh(m);
- DataArrayDouble *arr=DataArrayDouble::New();
- const double arr1[10]={10.,110.,20.,120.,30.,130.,40.,140.,50.,150.};
- arr->alloc(5,2);
- std::copy(arr1,arr1+10,arr->getPointer());
- f1->setArray(arr);
- arr->decrRef();
- //
- f1->checkCoherency();
- CPPUNIT_ASSERT(f1->simplexize(0));
- f1->checkCoherency();
- const double expected1[14]={10.,110.,10.,110.,20.,120.,30.,130.,40.,140.,50.,150.,50.,150.};
- for(int i=0;i<14;i++)
- CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1[i],f1->getIJ(0,i),1e-10);
- CPPUNIT_ASSERT(!f1->simplexize(0));
- for(int i=0;i<14;i++)
- CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1[i],f1->getIJ(0,i),1e-10);
- //
- f1->decrRef();
- m->decrRef();
-}
--- /dev/null
+// Copyright (C) 2007-2010 CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#include "MEDCouplingBasicsTest.hxx"
+#include "MEDCouplingUMesh.hxx"
+#include "MEDCouplingCMesh.hxx"
+#include "MEDCouplingExtrudedMesh.hxx"
+#include "MEDCouplingFieldDouble.hxx"
+#include "MEDCouplingMemArray.hxx"
+#include "MEDCouplingGaussLocalization.hxx"
+
+#include <cmath>
+#include <functional>
+#include <iterator>
+
+using namespace ParaMEDMEM;
+
+void MEDCouplingBasicsTest::testGetMeasureFieldCMesh1()
+{
+ MEDCouplingCMesh *m=MEDCouplingCMesh::New();
+ DataArrayDouble *da=DataArrayDouble::New();
+ const double discX[4]={2.3,3.4,5.8,10.2};
+ const double discY[3]={12.3,23.4,45.8};
+ const double discZ[5]={-0.7,1.2,1.25,2.13,2.67};
+ da->alloc(4,1);
+ std::copy(discX,discX+4,da->getPointer());
+ m->setCoordsAt(0,da);
+ da->decrRef();
+ m->checkCoherency();
+ CPPUNIT_ASSERT_EQUAL(4,m->getNumberOfNodes());
+ CPPUNIT_ASSERT_EQUAL(3,m->getNumberOfCells());
+ CPPUNIT_ASSERT_EQUAL(1,m->getSpaceDimension());
+ MEDCouplingFieldDouble *f=m->getMeasureField(true);
+ CPPUNIT_ASSERT_EQUAL(3,f->getNumberOfTuples());
+ CPPUNIT_ASSERT_EQUAL(1,f->getNumberOfComponents());
+ const double expected1[3]={1.1,2.4,4.4};
+ for(int i=0;i<3;i++)
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1[i],f->getIJ(i,0),1e-12);
+ f->decrRef();
+ DataArrayDouble *coords=m->getCoordinatesAndOwner();
+ CPPUNIT_ASSERT_EQUAL(4,coords->getNumberOfTuples());
+ CPPUNIT_ASSERT_EQUAL(1,coords->getNumberOfComponents());
+ for(int i=0;i<4;i++)
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(discX[i],coords->getIJ(i,0),1e-12);
+ coords->decrRef();
+ coords=m->getBarycenterAndOwner();
+ CPPUNIT_ASSERT_EQUAL(3,coords->getNumberOfTuples());
+ CPPUNIT_ASSERT_EQUAL(1,coords->getNumberOfComponents());
+ const double expected1_3[3]={2.85,4.6,8.};
+ for(int i=0;i<3;i++)
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1_3[i],coords->getIJ(i,0),1e-12);
+ coords->decrRef();
+ //
+ da=DataArrayDouble::New();
+ da->alloc(3,1);
+ std::copy(discY,discY+3,da->getPointer());
+ m->setCoordsAt(1,da);
+ da->decrRef();
+ m->checkCoherency();
+ CPPUNIT_ASSERT_EQUAL(12,m->getNumberOfNodes());
+ CPPUNIT_ASSERT_EQUAL(6,m->getNumberOfCells());
+ CPPUNIT_ASSERT_EQUAL(2,m->getSpaceDimension());
+ f=m->getMeasureField(true);
+ CPPUNIT_ASSERT_EQUAL(6,f->getNumberOfTuples());
+ CPPUNIT_ASSERT_EQUAL(1,f->getNumberOfComponents());
+ const double expected2[6]={12.21,26.64,48.84,24.64,53.76,98.56};
+ for(int i=0;i<6;i++)
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(expected2[i],f->getIJ(i,0),1e-12);
+ f->decrRef();
+ coords=m->getCoordinatesAndOwner();
+ CPPUNIT_ASSERT_EQUAL(12,coords->getNumberOfTuples());
+ CPPUNIT_ASSERT_EQUAL(2,coords->getNumberOfComponents());
+ const double expected2_2[24]={2.3,12.3,3.4,12.3,5.8,12.3,10.2,12.3, 2.3,23.4,3.4,23.4,5.8,23.4,10.2,23.4, 2.3,45.8,3.4,45.8,5.8,45.8,10.2,45.8};
+ for(int i=0;i<24;i++)
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(expected2_2[i],coords->getIJ(0,i),1e-12);
+ coords->decrRef();
+ coords=m->getBarycenterAndOwner();
+ CPPUNIT_ASSERT_EQUAL(6,coords->getNumberOfTuples());
+ CPPUNIT_ASSERT_EQUAL(2,coords->getNumberOfComponents());
+ const double expected2_3[12]={2.85,17.85,4.6,17.85,8.,17.85, 2.85,34.6,4.6,34.6,8.,34.6};
+ for(int i=0;i<12;i++)
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(expected2_3[i],coords->getIJ(0,i),1e-12);
+ coords->decrRef();
+ //
+ da=DataArrayDouble::New();
+ da->alloc(5,1);
+ std::copy(discZ,discZ+5,da->getPointer());
+ m->setCoordsAt(2,da);
+ da->decrRef();
+ m->checkCoherency();
+ CPPUNIT_ASSERT_EQUAL(60,m->getNumberOfNodes());
+ CPPUNIT_ASSERT_EQUAL(24,m->getNumberOfCells());
+ CPPUNIT_ASSERT_EQUAL(3,m->getSpaceDimension());
+ f=m->getMeasureField(true);
+ CPPUNIT_ASSERT_EQUAL(24,f->getNumberOfTuples());
+ CPPUNIT_ASSERT_EQUAL(1,f->getNumberOfComponents());
+ const double expected3[24]={23.199, 50.616, 92.796, 46.816, 102.144, 187.264, 0.6105, 1.332, 2.442, 1.232, 2.688, 4.928, 10.7448, 23.4432, 42.9792, 21.6832, 47.3088, 86.7328, 6.5934, 14.3856, 26.3736, 13.3056, 29.0304, 53.2224};
+ for(int i=0;i<24;i++)
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(expected3[i],f->getIJ(i,0),1e-12);
+ f->decrRef();
+ coords=m->getCoordinatesAndOwner();
+ CPPUNIT_ASSERT_EQUAL(60,coords->getNumberOfTuples());
+ CPPUNIT_ASSERT_EQUAL(3,coords->getNumberOfComponents());
+ const double expected3_2[180]={
+ 2.3,12.3,-0.7, 3.4,12.3,-0.7, 5.8,12.3,-0.7, 10.2,12.3,-0.7, 2.3,23.4,-0.7, 3.4,23.4,-0.7, 5.8,23.4,-0.7, 10.2,23.4,-0.7, 2.3,45.8,-0.7, 3.4,45.8,-0.7, 5.8,45.8,-0.7, 10.2,45.8,-0.7,
+ 2.3,12.3,1.2, 3.4,12.3,1.2, 5.8,12.3,1.2, 10.2,12.3,1.2, 2.3,23.4,1.2, 3.4,23.4,1.2, 5.8,23.4,1.2, 10.2,23.4,1.2, 2.3,45.8,1.2, 3.4,45.8,1.2, 5.8,45.8,1.2, 10.2,45.8,1.2,
+ 2.3,12.3,1.25, 3.4,12.3,1.25, 5.8,12.3,1.25, 10.2,12.3,1.25, 2.3,23.4,1.25, 3.4,23.4,1.25, 5.8,23.4,1.25, 10.2,23.4,1.25, 2.3,45.8,1.25, 3.4,45.8,1.25, 5.8,45.8,1.25, 10.2,45.8,1.25,
+ 2.3,12.3,2.13, 3.4,12.3,2.13, 5.8,12.3,2.13, 10.2,12.3,2.13, 2.3,23.4,2.13, 3.4,23.4,2.13, 5.8,23.4,2.13, 10.2,23.4,2.13, 2.3,45.8,2.13, 3.4,45.8,2.13, 5.8,45.8,2.13, 10.2,45.8,2.13,
+ 2.3,12.3,2.67, 3.4,12.3,2.67, 5.8,12.3,2.67, 10.2,12.3,2.67, 2.3,23.4,2.67, 3.4,23.4,2.67, 5.8,23.4,2.67, 10.2,23.4,2.67, 2.3,45.8,2.67, 3.4,45.8,2.67, 5.8,45.8,2.67, 10.2,45.8,2.67
+ };
+ for(int i=0;i<180;i++)
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(expected3_2[i],coords->getIJ(0,i),1e-12);
+ coords->decrRef();
+ coords=m->getBarycenterAndOwner();
+ CPPUNIT_ASSERT_EQUAL(24,coords->getNumberOfTuples());
+ CPPUNIT_ASSERT_EQUAL(3,coords->getNumberOfComponents());
+ const double expected3_3[72]={
+ 2.85,17.85,0.25,4.6,17.85,0.25,8.,17.85,0.25, 2.85,34.6,0.25,4.6,34.6,0.25,8.,34.6,0.25,
+ 2.85,17.85,1.225,4.6,17.85,1.225,8.,17.85,1.225, 2.85,34.6,1.225,4.6,34.6,1.225,8.,34.6,1.225,
+ 2.85,17.85,1.69,4.6,17.85,1.69,8.,17.85,1.69, 2.85,34.6,1.69,4.6,34.6,1.69,8.,34.6,1.69,
+ 2.85,17.85,2.4,4.6,17.85,2.4,8.,17.85,2.4, 2.85,34.6,2.4,4.6,34.6,2.4,8.,34.6,2.4
+ };
+ for(int i=0;i<72;i++)
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(expected3_3[i],coords->getIJ(0,i),1e-12);
+ coords->decrRef();
+ //
+ m->decrRef();
+}
+
+void MEDCouplingBasicsTest::testFieldDoubleZipCoords1()
+{
+ MEDCouplingUMesh *m=build2DTargetMeshMergeNode_1();
+ MEDCouplingFieldDouble *f=m->fillFromAnalytic(ON_NODES,2,"x*2.");
+ f->getArray()->setInfoOnComponent(0,"titi");
+ f->getArray()->setInfoOnComponent(1,"tutu");
+ f->checkCoherency();
+ CPPUNIT_ASSERT_EQUAL(18,f->getNumberOfTuples());
+ CPPUNIT_ASSERT_EQUAL(2,f->getNumberOfComponents());
+ const double expected1[36]={-0.6, -0.6, 0.4, 0.4, 1.4, 1.4, -0.6, -0.6, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 1.4, 1.4, -0.6, -0.6, 0.4, 0.4, 1.4, 1.4, -0.6, -0.6, 1.4, 1.4, -0.6, -0.6, 0.4, 0.4, 1.4, 1.4, 0.4, 0.4};
+ for(int i=0;i<36;i++)
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1[i],f->getIJ(0,i),1e-12);
+ CPPUNIT_ASSERT(f->zipCoords());
+ f->checkCoherency();
+ const double expected2[30]={-0.6, -0.6, 1.4, 1.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 0.4, 1.4, 1.4, -0.6, -0.6, 0.4, 0.4, 1.4, 1.4, 1.4, 1.4, -0.6, -0.6, 0.4, 0.4, 1.4, 1.4, 0.4, 0.4};
+ for(int i=0;i<30;i++)
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(expected2[i],f->getIJ(0,i),1e-12);
+ CPPUNIT_ASSERT(!f->zipCoords());
+ f->checkCoherency();
+ for(int i=0;i<30;i++)
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(expected2[i],f->getIJ(0,i),1e-12);
+ CPPUNIT_ASSERT(std::string(f->getArray()->getInfoOnComponent(0))=="titi");
+ CPPUNIT_ASSERT(std::string(f->getArray()->getInfoOnComponent(1))=="tutu");
+ f->decrRef();
+ m->decrRef();
+}
+
+void MEDCouplingBasicsTest::testFieldDoubleZipConnectivity1()
+{
+ MEDCouplingUMesh *m1=build2DTargetMesh_1();
+ MEDCouplingUMesh *m2=build2DTargetMesh_1();
+ const int cells1[3]={2,3,4};
+ MEDCouplingPointSet *m3_1=m2->buildPartOfMySelf(cells1,cells1+3,true);
+ MEDCouplingUMesh *m3=dynamic_cast<MEDCouplingUMesh *>(m3_1);
+ CPPUNIT_ASSERT(m3);
+ m2->decrRef();
+ MEDCouplingUMesh *m4=build2DSourceMesh_1();
+ MEDCouplingUMesh *m5=MEDCouplingUMesh::MergeUMeshes(m1,m3);
+ m1->decrRef();
+ m3->decrRef();
+ MEDCouplingUMesh *m6=MEDCouplingUMesh::MergeUMeshes(m5,m4);
+ m4->decrRef();
+ m5->decrRef();
+ //
+ CPPUNIT_ASSERT_EQUAL(10,m6->getNumberOfCells());
+ CPPUNIT_ASSERT_EQUAL(22,m6->getNumberOfNodes());
+ bool areNodesMerged;
+ int newNbOfNodes;
+ DataArrayInt *arr=m6->mergeNodes(1e-13,areNodesMerged,newNbOfNodes);
+ CPPUNIT_ASSERT_EQUAL(9,m6->getNumberOfNodes());
+ arr->decrRef();
+ MEDCouplingFieldDouble *f=m6->fillFromAnalytic(ON_CELLS,2,"x");
+ MEDCouplingFieldDouble *f2=m6->fillFromAnalytic(ON_NODES,2,"x");
+ CPPUNIT_ASSERT_EQUAL(10,f->getNumberOfTuples());
+ CPPUNIT_ASSERT_EQUAL(2,f->getNumberOfComponents());
+ const double expected1[20]={-0.05, -0.05, 0.3666666666666667, 0.3666666666666667, 0.53333333333333321, 0.53333333333333321,
+ -0.05, -0.05, 0.45, 0.45, 0.53333333333333321, 0.53333333333333321, -0.05, -0.05, 0.45, 0.45,
+ 0.36666666666666659, 0.36666666666666659, 0.033333333333333326, 0.033333333333333326};
+ for(int i=0;i<20;i++)
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1[i],f->getIJ(0,i),1e-12);
+ f->getArray()->setInfoOnComponent(0,"titi");
+ f->getArray()->setInfoOnComponent(1,"tutu");
+ f->checkCoherency();
+ CPPUNIT_ASSERT(f->zipConnectivity(0));
+ const double expected2[14]={-0.05, -0.05, 0.3666666666666667, 0.3666666666666667, 0.53333333333333321, 0.53333333333333321,
+ -0.05, -0.05, 0.45, 0.45, 0.36666666666666659, 0.36666666666666659, 0.033333333333333326, 0.033333333333333326};
+ CPPUNIT_ASSERT_EQUAL(7,f->getNumberOfTuples());
+ CPPUNIT_ASSERT_EQUAL(2,f->getNumberOfComponents());
+ for(int i=0;i<14;i++)
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(expected2[i],f->getIJ(0,i),1e-12);
+ CPPUNIT_ASSERT(std::string(f->getArray()->getInfoOnComponent(0))=="titi");
+ CPPUNIT_ASSERT(std::string(f->getArray()->getInfoOnComponent(1))=="tutu");
+ CPPUNIT_ASSERT(!f->zipConnectivity(0));
+ f->decrRef();
+ //
+ const double expected3[18]={-0.3, -0.3, 0.2, 0.2, 0.7, 0.7, -0.3, -0.3, 0.2, 0.2, 0.7, 0.7,
+ -0.3, -0.3, 0.2, 0.2, 0.7, 0.7};
+ CPPUNIT_ASSERT_EQUAL(9,f2->getNumberOfTuples());
+ CPPUNIT_ASSERT_EQUAL(2,f2->getNumberOfComponents());
+ for(int i=0;i<18;i++)
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(expected3[i],f2->getIJ(0,i),1e-12);
+ CPPUNIT_ASSERT(f2->zipConnectivity(0));
+ CPPUNIT_ASSERT_EQUAL(9,f2->getNumberOfTuples());
+ CPPUNIT_ASSERT_EQUAL(2,f2->getNumberOfComponents());
+ for(int i=0;i<18;i++)
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(expected3[i],f2->getIJ(0,i),1e-12);
+ f2->decrRef();
+ //
+ m6->decrRef();
+}
+
+void MEDCouplingBasicsTest::testDaDoubleRenumber1()
+{
+ DataArrayDouble *a=DataArrayDouble::New();
+ a->alloc(7,2);
+ a->setInfoOnComponent(0,"toto");
+ a->setInfoOnComponent(1,"tata");
+ const double arr1[14]={1.1,11.1,2.1,12.1,3.1,13.1,4.1,14.1,5.1,15.1,6.1,16.1,7.1,17.1};
+ std::copy(arr1,arr1+14,a->getPointer());
+ //
+ const int arr2[7]={3,1,0,6,5,4,2};
+ DataArrayDouble *b=a->renumber(arr2);
+ CPPUNIT_ASSERT_EQUAL(7,b->getNumberOfTuples());
+ CPPUNIT_ASSERT_EQUAL(2,b->getNumberOfComponents());
+ CPPUNIT_ASSERT(std::string(b->getInfoOnComponent(0))=="toto");
+ CPPUNIT_ASSERT(std::string(b->getInfoOnComponent(1))=="tata");
+ const double expected1[14]={3.1, 13.1, 2.1, 12.1, 7.1, 17.1, 1.1, 11.1, 6.1, 16.1, 5.1, 15.1, 4.1, 14.1};
+ for(int i=0;i<14;i++)
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1[i],b->getIJ(0,i),1e-14);
+ b->decrRef();
+ a->decrRef();
+ //
+ DataArrayInt *c=DataArrayInt::New();
+ c->alloc(7,2);
+ c->setInfoOnComponent(0,"toto");
+ c->setInfoOnComponent(1,"tata");
+ const int arr3[14]={1,11,2,12,3,13,4,14,5,15,6,16,7,17};
+ std::copy(arr3,arr3+14,c->getPointer());
+ DataArrayInt *d=c->renumber(arr2);
+ CPPUNIT_ASSERT_EQUAL(7,d->getNumberOfTuples());
+ CPPUNIT_ASSERT_EQUAL(2,d->getNumberOfComponents());
+ CPPUNIT_ASSERT(std::string(d->getInfoOnComponent(0))=="toto");
+ CPPUNIT_ASSERT(std::string(d->getInfoOnComponent(1))=="tata");
+ const int expected2[14]={3, 13, 2, 12, 7, 17, 1, 11, 6, 16, 5, 15, 4, 14};
+ for(int i=0;i<14;i++)
+ CPPUNIT_ASSERT_EQUAL(expected2[i],d->getIJ(0,i));
+ c->decrRef();
+ d->decrRef();
+}
+
+void MEDCouplingBasicsTest::testDaDoubleRenumberAndReduce1()
+{
+ DataArrayDouble *a=DataArrayDouble::New();
+ a->alloc(7,2);
+ a->setInfoOnComponent(0,"toto");
+ a->setInfoOnComponent(1,"tata");
+ const double arr1[14]={1.1,11.1,2.1,12.1,3.1,13.1,4.1,14.1,5.1,15.1,6.1,16.1,7.1,17.1};
+ std::copy(arr1,arr1+14,a->getPointer());
+ //
+ const int arr2[7]={2,-1,1,-1,0,4,3};
+ DataArrayDouble *b=a->renumberAndReduce(arr2,5);
+ CPPUNIT_ASSERT_EQUAL(5,b->getNumberOfTuples());
+ CPPUNIT_ASSERT_EQUAL(2,b->getNumberOfComponents());
+ CPPUNIT_ASSERT(std::string(b->getInfoOnComponent(0))=="toto");
+ CPPUNIT_ASSERT(std::string(b->getInfoOnComponent(1))=="tata");
+ const double expected1[10]={5.1,15.1,3.1,13.1,1.1,11.1,7.1,17.1,6.1,16.1};
+ for(int i=0;i<10;i++)
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1[i],b->getIJ(0,i),1e-14);
+ b->decrRef();
+ a->decrRef();
+ //
+ DataArrayInt *c=DataArrayInt::New();
+ c->alloc(7,2);
+ c->setInfoOnComponent(0,"toto");
+ c->setInfoOnComponent(1,"tata");
+ const int arr3[14]={1,11,2,12,3,13,4,14,5,15,6,16,7,17};
+ std::copy(arr3,arr3+14,c->getPointer());
+ DataArrayInt *d=c->renumberAndReduce(arr2,5);
+ CPPUNIT_ASSERT_EQUAL(5,d->getNumberOfTuples());
+ CPPUNIT_ASSERT_EQUAL(2,d->getNumberOfComponents());
+ CPPUNIT_ASSERT(std::string(d->getInfoOnComponent(0))=="toto");
+ CPPUNIT_ASSERT(std::string(d->getInfoOnComponent(1))=="tata");
+ const int expected2[10]={5,15,3,13,1,11,7,17,6,16};
+ for(int i=0;i<10;i++)
+ CPPUNIT_ASSERT_EQUAL(expected2[i],d->getIJ(0,i));
+ c->decrRef();
+ d->decrRef();
+}
+
+void MEDCouplingBasicsTest::testDaDoubleRenumberInPlace1()
+{
+ DataArrayDouble *a=DataArrayDouble::New();
+ a->alloc(7,2);
+ const double arr1[14]={1.1,11.1,2.1,12.1,3.1,13.1,4.1,14.1,5.1,15.1,6.1,16.1,7.1,17.1};
+ std::copy(arr1,arr1+14,a->getPointer());
+ //
+ const int arr2[7]={3,1,0,6,5,4,2};
+ a->renumberInPlace(arr2);
+ CPPUNIT_ASSERT_EQUAL(7,a->getNumberOfTuples());
+ CPPUNIT_ASSERT_EQUAL(2,a->getNumberOfComponents());
+ const double expected1[14]={3.1, 13.1, 2.1, 12.1, 7.1, 17.1, 1.1, 11.1, 6.1, 16.1, 5.1, 15.1, 4.1, 14.1};
+ for(int i=0;i<14;i++)
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1[i],a->getIJ(0,i),1e-14);
+ a->decrRef();
+ //
+ DataArrayInt *c=DataArrayInt::New();
+ c->alloc(7,2);
+ const int arr3[14]={1,11,2,12,3,13,4,14,5,15,6,16,7,17};
+ std::copy(arr3,arr3+14,c->getPointer());
+ c->renumberInPlace(arr2);
+ CPPUNIT_ASSERT_EQUAL(7,c->getNumberOfTuples());
+ CPPUNIT_ASSERT_EQUAL(2,c->getNumberOfComponents());
+ const int expected2[14]={3, 13, 2, 12, 7, 17, 1, 11, 6, 16, 5, 15, 4, 14};
+ for(int i=0;i<14;i++)
+ CPPUNIT_ASSERT_EQUAL(expected2[i],c->getIJ(0,i));
+ c->decrRef();
+}
+
+void MEDCouplingBasicsTest::testDaDoubleRenumberR1()
+{
+ DataArrayDouble *a=DataArrayDouble::New();
+ a->alloc(7,2);
+ a->setInfoOnComponent(0,"toto");
+ a->setInfoOnComponent(1,"tata");
+ const double arr1[14]={1.1,11.1,2.1,12.1,3.1,13.1,4.1,14.1,5.1,15.1,6.1,16.1,7.1,17.1};
+ std::copy(arr1,arr1+14,a->getPointer());
+ //
+ const int arr2[7]={3,1,0,6,5,4,2};
+ DataArrayDouble *b=a->renumberR(arr2);
+ CPPUNIT_ASSERT_EQUAL(7,b->getNumberOfTuples());
+ CPPUNIT_ASSERT_EQUAL(2,b->getNumberOfComponents());
+ CPPUNIT_ASSERT(std::string(b->getInfoOnComponent(0))=="toto");
+ CPPUNIT_ASSERT(std::string(b->getInfoOnComponent(1))=="tata");
+ const double expected1[14]={4.1, 14.1, 2.1, 12.1, 1.1, 11.1, 7.1, 17.1, 6.1, 16.1, 5.1, 15.1, 3.1, 13.1};
+ for(int i=0;i<14;i++)
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1[i],b->getIJ(0,i),1e-14);
+ b->decrRef();
+ a->decrRef();
+ //
+ DataArrayInt *c=DataArrayInt::New();
+ c->alloc(7,2);
+ c->setInfoOnComponent(0,"toto");
+ c->setInfoOnComponent(1,"tata");
+ const int arr3[14]={1,11,2,12,3,13,4,14,5,15,6,16,7,17};
+ std::copy(arr3,arr3+14,c->getPointer());
+ DataArrayInt *d=c->renumberR(arr2);
+ CPPUNIT_ASSERT_EQUAL(7,d->getNumberOfTuples());
+ CPPUNIT_ASSERT_EQUAL(2,d->getNumberOfComponents());
+ CPPUNIT_ASSERT(std::string(d->getInfoOnComponent(0))=="toto");
+ CPPUNIT_ASSERT(std::string(d->getInfoOnComponent(1))=="tata");
+ const int expected2[14]={4, 14, 2, 12, 1, 11, 7, 17, 6, 16, 5, 15, 3, 13};
+ for(int i=0;i<14;i++)
+ CPPUNIT_ASSERT_EQUAL(expected2[i],d->getIJ(0,i));
+ c->decrRef();
+ d->decrRef();
+}
+
+void MEDCouplingBasicsTest::testDaDoubleRenumberInPlaceR1()
+{
+ DataArrayDouble *a=DataArrayDouble::New();
+ a->alloc(7,2);
+ const double arr1[14]={1.1,11.1,2.1,12.1,3.1,13.1,4.1,14.1,5.1,15.1,6.1,16.1,7.1,17.1};
+ std::copy(arr1,arr1+14,a->getPointer());
+ //
+ const int arr2[7]={3,1,0,6,5,4,2};
+ a->renumberInPlaceR(arr2);
+ CPPUNIT_ASSERT_EQUAL(7,a->getNumberOfTuples());
+ CPPUNIT_ASSERT_EQUAL(2,a->getNumberOfComponents());
+ const double expected1[14]={4.1, 14.1, 2.1, 12.1, 1.1, 11.1, 7.1, 17.1, 6.1, 16.1, 5.1, 15.1, 3.1, 13.1};
+ for(int i=0;i<14;i++)
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1[i],a->getIJ(0,i),1e-14);
+ a->decrRef();
+ //
+ DataArrayInt *c=DataArrayInt::New();
+ c->alloc(7,2);
+ const int arr3[14]={1,11,2,12,3,13,4,14,5,15,6,16,7,17};
+ std::copy(arr3,arr3+14,c->getPointer());
+ c->renumberInPlaceR(arr2);
+ CPPUNIT_ASSERT_EQUAL(7,c->getNumberOfTuples());
+ CPPUNIT_ASSERT_EQUAL(2,c->getNumberOfComponents());
+ const int expected2[14]={4, 14, 2, 12, 1, 11, 7, 17, 6, 16, 5, 15, 3, 13};
+ for(int i=0;i<14;i++)
+ CPPUNIT_ASSERT_EQUAL(expected2[i],c->getIJ(0,i));
+ c->decrRef();
+}
+
+void MEDCouplingBasicsTest::testDaDoubleSelectByTupleId1()
+{
+ DataArrayDouble *a=DataArrayDouble::New();
+ a->alloc(7,2);
+ a->setInfoOnComponent(0,"toto");
+ a->setInfoOnComponent(1,"tata");
+ const double arr1[14]={1.1,11.1,2.1,12.1,3.1,13.1,4.1,14.1,5.1,15.1,6.1,16.1,7.1,17.1};
+ std::copy(arr1,arr1+14,a->getPointer());
+ //
+ const int arr2[7]={4,2,0,6,5};
+ DataArrayDouble *b=a->selectByTupleId(arr2,arr2+5);
+ CPPUNIT_ASSERT_EQUAL(5,b->getNumberOfTuples());
+ CPPUNIT_ASSERT_EQUAL(2,b->getNumberOfComponents());
+ CPPUNIT_ASSERT(std::string(b->getInfoOnComponent(0))=="toto");
+ CPPUNIT_ASSERT(std::string(b->getInfoOnComponent(1))=="tata");
+ const double expected1[10]={5.1,15.1,3.1,13.1,1.1,11.1,7.1,17.1,6.1,16.1};
+ for(int i=0;i<10;i++)
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1[i],b->getIJ(0,i),1e-14);
+ b->decrRef();
+ a->decrRef();
+ //
+ DataArrayInt *c=DataArrayInt::New();
+ c->alloc(7,2);
+ c->setInfoOnComponent(0,"toto");
+ c->setInfoOnComponent(1,"tata");
+ const int arr3[14]={1,11,2,12,3,13,4,14,5,15,6,16,7,17};
+ std::copy(arr3,arr3+14,c->getPointer());
+ DataArrayInt *d=c->selectByTupleId(arr2,arr2+5);
+ CPPUNIT_ASSERT_EQUAL(5,d->getNumberOfTuples());
+ CPPUNIT_ASSERT_EQUAL(2,d->getNumberOfComponents());
+ CPPUNIT_ASSERT(std::string(d->getInfoOnComponent(0))=="toto");
+ CPPUNIT_ASSERT(std::string(d->getInfoOnComponent(1))=="tata");
+ const int expected2[10]={5,15,3,13,1,11,7,17,6,16};
+ for(int i=0;i<10;i++)
+ CPPUNIT_ASSERT_EQUAL(expected2[i],d->getIJ(0,i));
+ c->decrRef();
+ d->decrRef();
+}
+
+void MEDCouplingBasicsTest::testDaDoubleGetMinMaxValues1()
+{
+ DataArrayDouble *a=DataArrayDouble::New();
+ a->alloc(9,1);
+ const double arr1[9]={2.34,4.56,-6.77,4.55,4.56,2.24,2.34,1.02,4.56};
+ std::copy(arr1,arr1+9,a->getPointer());
+ int where;
+ double m=a->getMaxValue(where);
+ CPPUNIT_ASSERT_EQUAL(1,where);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(4.56,m,1e-12);
+ DataArrayInt *ws;
+ m=a->getMaxValue2(ws);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(4.56,m,1e-12);
+ CPPUNIT_ASSERT_EQUAL(3,ws->getNumberOfTuples());
+ CPPUNIT_ASSERT_EQUAL(1,ws->getNumberOfComponents());
+ const int expected1[3]={1,4,8};
+ for(int i=0;i<3;i++)
+ CPPUNIT_ASSERT_EQUAL(expected1[i],ws->getIJ(i,0));
+ ws->decrRef();
+ a->decrRef();
+ a=DataArrayDouble::New();
+ const double arr2[9]={-2.34,-4.56,6.77,-4.55,-4.56,-2.24,-2.34,-1.02,-4.56};
+ a->alloc(9,1);
+ std::copy(arr2,arr2+9,a->getPointer());
+ where=-2;
+ m=a->getMinValue(where);
+ CPPUNIT_ASSERT_EQUAL(1,where);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(-4.56,m,1e-12);
+ m=a->getMinValue2(ws);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(-4.56,m,1e-12);
+ CPPUNIT_ASSERT_EQUAL(3,ws->getNumberOfTuples());
+ CPPUNIT_ASSERT_EQUAL(1,ws->getNumberOfComponents());
+ for(int i=0;i<3;i++)
+ CPPUNIT_ASSERT_EQUAL(expected1[i],ws->getIJ(i,0));
+ ws->decrRef();
+ a->decrRef();
+}
+
+void MEDCouplingBasicsTest::testFieldDoubleGetMinMaxValues2()
+{
+ MEDCouplingUMesh *m1=0;
+ MEDCouplingUMesh *m2=build3DExtrudedUMesh_1(m1);
+ m1->decrRef();
+ CPPUNIT_ASSERT_EQUAL(18,m2->getNumberOfCells());
+ const double arr1[18]={8.71,4.53,-12.41,8.71,-8.71,8.7099,4.55,8.71,5.55,6.77,-1e-200,4.55,8.7099,0.,1.23,0.,2.22,8.71};
+ MEDCouplingFieldDouble *f=MEDCouplingFieldDouble::New(ON_CELLS,NO_TIME);
+ DataArrayDouble *a=DataArrayDouble::New();
+ a->alloc(18,1);
+ std::copy(arr1,arr1+18,a->getPointer());
+ f->setArray(a);
+ a->decrRef();
+ f->setMesh(m2);
+ //
+ f->checkCoherency();
+ double m=f->getMaxValue();
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(8.71,m,1e-12);
+ DataArrayInt *ws;
+ m=f->getMaxValue2(ws);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(8.71,m,1e-12);
+ CPPUNIT_ASSERT_EQUAL(4,ws->getNumberOfTuples());
+ CPPUNIT_ASSERT_EQUAL(1,ws->getNumberOfComponents());
+ const int expected1[4]={0,3,7,17};
+ for(int i=0;i<4;i++)
+ CPPUNIT_ASSERT_EQUAL(expected1[i],ws->getIJ(i,0));
+ ws->decrRef();
+ //
+ const double arr2[18]={-8.71,-4.53,12.41,-8.71,8.71,-8.7099,-4.55,-8.71,-5.55,-6.77,1e-200,-4.55,-8.7099,0.,-1.23,0.,-2.22,-8.71};
+ std::copy(arr2,arr2+18,a->getPointer());
+ f->checkCoherency();
+ m=f->getMinValue();
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(-8.71,m,1e-12);
+ m=f->getMinValue2(ws);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(-8.71,m,1e-12);
+ CPPUNIT_ASSERT_EQUAL(4,ws->getNumberOfTuples());
+ CPPUNIT_ASSERT_EQUAL(1,ws->getNumberOfComponents());
+ for(int i=0;i<4;i++)
+ CPPUNIT_ASSERT_EQUAL(expected1[i],ws->getIJ(i,0));
+ ws->decrRef();
+ //
+ f->decrRef();
+ m2->decrRef();
+}
+
+void MEDCouplingBasicsTest::testBuildUnstructuredCMesh1()
+{
+ MEDCouplingCMesh *m=MEDCouplingCMesh::New();
+ DataArrayDouble *da=DataArrayDouble::New();
+ const double discX[4]={2.3,3.4,5.8,10.2};
+ const double discY[3]={12.3,23.4,45.8};
+ const double discZ[5]={-0.7,1.2,1.25,2.13,2.67};
+ da->alloc(4,1);
+ std::copy(discX,discX+4,da->getPointer());
+ m->setCoordsAt(0,da);
+ da->decrRef();
+ m->checkCoherency();
+ double pos=2.4;
+ CPPUNIT_ASSERT_EQUAL(0,m->getCellContainingPoint(&pos,1e-12));
+ pos=3.7;
+ CPPUNIT_ASSERT_EQUAL(1,m->getCellContainingPoint(&pos,1e-12));
+ pos=5.9;
+ CPPUNIT_ASSERT_EQUAL(2,m->getCellContainingPoint(&pos,1e-12));
+ pos=10.3;
+ CPPUNIT_ASSERT_EQUAL(-1,m->getCellContainingPoint(&pos,1e-12));
+ pos=1.3;
+ CPPUNIT_ASSERT_EQUAL(-1,m->getCellContainingPoint(&pos,1e-12));
+ //
+ MEDCouplingUMesh *m2=m->buildUnstructured();
+ m2->checkCoherency();
+ MEDCouplingFieldDouble *f1=m->getMeasureField(false);
+ MEDCouplingFieldDouble *f2=m2->getMeasureField(false);
+ CPPUNIT_ASSERT_EQUAL(f1->getNumberOfTuples(),3);
+ CPPUNIT_ASSERT_EQUAL(f2->getNumberOfTuples(),3);
+ CPPUNIT_ASSERT_EQUAL(1,m2->getMeshDimension());
+ CPPUNIT_ASSERT_EQUAL(1,m2->getSpaceDimension());
+ for(int i=0;i<3;i++)
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(f1->getIJ(i,0),f2->getIJ(i,0),1e-10);
+ da=DataArrayDouble::New();
+ da->alloc(3,1);
+ std::copy(discY,discY+3,da->getPointer());
+ m->setCoordsAt(1,da);
+ da->decrRef();
+ m2->decrRef();
+ f1->decrRef();
+ f2->decrRef();
+ //
+ m2=m->buildUnstructured();
+ m2->checkCoherency();
+ f1=m->getMeasureField(false);
+ f2=m2->getMeasureField(false);
+ CPPUNIT_ASSERT_EQUAL(f1->getNumberOfTuples(),6);
+ CPPUNIT_ASSERT_EQUAL(f2->getNumberOfTuples(),6);
+ CPPUNIT_ASSERT_EQUAL(2,m2->getMeshDimension());
+ CPPUNIT_ASSERT_EQUAL(2,m2->getSpaceDimension());
+ for(int i=0;i<6;i++)
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(f1->getIJ(i,0),f2->getIJ(i,0),1e-10);
+ f1->decrRef();
+ f2->decrRef();
+ m2->decrRef();
+ //
+ da=DataArrayDouble::New();
+ da->alloc(5,1);
+ std::copy(discZ,discZ+5,da->getPointer());
+ m->setCoordsAt(2,da);
+ da->decrRef();
+ m2=m->buildUnstructured();
+ m2->checkCoherency();
+ f1=m->getMeasureField(false);
+ f2=m2->getMeasureField(false);
+ CPPUNIT_ASSERT_EQUAL(f1->getNumberOfTuples(),24);
+ CPPUNIT_ASSERT_EQUAL(f2->getNumberOfTuples(),24);
+ CPPUNIT_ASSERT_EQUAL(3,m2->getMeshDimension());
+ CPPUNIT_ASSERT_EQUAL(3,m2->getSpaceDimension());
+ for(int i=0;i<24;i++)
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(f1->getIJ(i,0),f2->getIJ(i,0),1e-10);
+ f1->decrRef();
+ f2->decrRef();
+ //
+ double pos1[3]={5.,30.,2.};
+ CPPUNIT_ASSERT_EQUAL(16,m->getCellContainingPoint(pos1,1e-12));
+ //
+ const double pt[3]={2.4,12.7,-3.4};
+ m->scale(pt,3.7);
+ MEDCouplingUMesh *m3=m->buildUnstructured();
+ m2->scale(pt,3.7);
+ CPPUNIT_ASSERT(m3->isEqual(m2,1e-12));
+ m2->decrRef();
+ m3->decrRef();
+ //
+ m->decrRef();
+}
+
+void MEDCouplingBasicsTest::testDataArrayIntInvertO2NNO21()
+{
+ const int arr1[6]={2,0,4,1,5,3};
+ DataArrayInt *da=DataArrayInt::New();
+ da->alloc(6,1);
+ std::copy(arr1,arr1+6,da->getPointer());
+ DataArrayInt *da2=da->invertArrayO2N2N2O(6);
+ CPPUNIT_ASSERT_EQUAL(6,da2->getNumberOfTuples());
+ CPPUNIT_ASSERT_EQUAL(1,da2->getNumberOfComponents());
+ const int expected1[6]={1,3,0,5,2,4};
+ for(int i=0;i<6;i++)
+ CPPUNIT_ASSERT_EQUAL(expected1[i],da2->getIJ(i,0));
+ DataArrayInt *da3=da2->invertArrayN2O2O2N(6);
+ for(int i=0;i<6;i++)
+ CPPUNIT_ASSERT_EQUAL(arr1[i],da3->getIJ(i,0));
+ da3->decrRef();
+ da2->decrRef();
+ da->decrRef();
+ //
+ const int arr2[10]={3,-1,5,4,-1,0,-1,1,2,-1};
+ da=DataArrayInt::New();
+ da->alloc(10,1);
+ std::copy(arr2,arr2+10,da->getPointer());
+ da2=da->invertArrayO2N2N2O(6);
+ CPPUNIT_ASSERT_EQUAL(6,da2->getNumberOfTuples());
+ CPPUNIT_ASSERT_EQUAL(1,da2->getNumberOfComponents());
+ const int expected2[10]={5,7,8,0,3,2};
+ for(int i=0;i<6;i++)
+ CPPUNIT_ASSERT_EQUAL(expected2[i],da2->getIJ(i,0));
+ da3=da2->invertArrayN2O2O2N(10);
+ for(int i=0;i<10;i++)
+ CPPUNIT_ASSERT_EQUAL(arr2[i],da3->getIJ(i,0));
+ da3->decrRef();
+ da2->decrRef();
+ da->decrRef();
+}
+
+void MEDCouplingBasicsTest::testKeepSetSelectedComponent1()
+{
+ const double arr1[20]={1.,2.,3.,4., 11.,12.,13.,14., 21.,22.,23.,24., 31.,32.,33.,34., 41.,42.,43.,44.};
+ DataArrayDouble *a1=DataArrayDouble::New();
+ a1->alloc(5,4);
+ std::copy(arr1,arr1+20,a1->getPointer());
+ a1->setInfoOnComponent(0,"aaaa");
+ a1->setInfoOnComponent(1,"bbbb");
+ a1->setInfoOnComponent(2,"cccc");
+ a1->setInfoOnComponent(3,"dddd");
+ const int arr2[6]={1,2,1,2,0,0};
+ std::vector<int> arr2V(arr2,arr2+6);
+ DataArrayDouble *a2=a1->keepSelectedComponents(arr2V);
+ CPPUNIT_ASSERT_EQUAL(6,a2->getNumberOfComponents());
+ CPPUNIT_ASSERT_EQUAL(5,a2->getNumberOfTuples());
+ CPPUNIT_ASSERT(std::string(a2->getInfoOnComponent(0))=="bbbb");
+ CPPUNIT_ASSERT(std::string(a2->getInfoOnComponent(1))=="cccc");
+ CPPUNIT_ASSERT(std::string(a2->getInfoOnComponent(2))=="bbbb");
+ CPPUNIT_ASSERT(std::string(a2->getInfoOnComponent(3))=="cccc");
+ CPPUNIT_ASSERT(std::string(a2->getInfoOnComponent(4))=="aaaa");
+ CPPUNIT_ASSERT(std::string(a2->getInfoOnComponent(5))=="aaaa");
+ const double expected1[30]={2.,3.,2.,3.,1.,1., 12.,13.,12.,13.,11.,11., 22.,23.,22.,23.,21.,21., 32.,33.,32.,33.,31.,31., 42.,43.,42.,43.,41.,41.};
+ for(int i=0;i<30;i++)
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1[i],a2->getIJ(0,i),1e-14);
+ DataArrayInt *a3=a1->convertToIntArr();
+ DataArrayInt *a4=a3->keepSelectedComponents(arr2V);
+ CPPUNIT_ASSERT_EQUAL(6,a4->getNumberOfComponents());
+ CPPUNIT_ASSERT_EQUAL(5,a4->getNumberOfTuples());
+ CPPUNIT_ASSERT(std::string(a4->getInfoOnComponent(0))=="bbbb");
+ CPPUNIT_ASSERT(std::string(a4->getInfoOnComponent(1))=="cccc");
+ CPPUNIT_ASSERT(std::string(a4->getInfoOnComponent(2))=="bbbb");
+ CPPUNIT_ASSERT(std::string(a4->getInfoOnComponent(3))=="cccc");
+ CPPUNIT_ASSERT(std::string(a4->getInfoOnComponent(4))=="aaaa");
+ CPPUNIT_ASSERT(std::string(a4->getInfoOnComponent(5))=="aaaa");
+ for(int i=0;i<30;i++)
+ CPPUNIT_ASSERT_EQUAL(int(expected1[i]),a4->getIJ(0,i));
+ // setSelectedComponents
+ const int arr3[2]={3,2};
+ std::vector<int> arr3V(arr3,arr3+2);
+ DataArrayDouble *a5=a1->keepSelectedComponents(arr3V);
+ a5->setInfoOnComponent(0,"eeee");
+ a5->setInfoOnComponent(1,"ffff");
+ const int arr4[2]={1,2};
+ std::vector<int> arr4V(arr4,arr4+2);
+ a2->setSelectedComponents(a5,arr4V);
+ CPPUNIT_ASSERT_EQUAL(6,a2->getNumberOfComponents());
+ CPPUNIT_ASSERT_EQUAL(5,a2->getNumberOfTuples());
+ CPPUNIT_ASSERT(std::string(a2->getInfoOnComponent(0))=="bbbb");
+ CPPUNIT_ASSERT(std::string(a2->getInfoOnComponent(1))=="eeee");
+ CPPUNIT_ASSERT(std::string(a2->getInfoOnComponent(2))=="ffff");
+ CPPUNIT_ASSERT(std::string(a2->getInfoOnComponent(3))=="cccc");
+ CPPUNIT_ASSERT(std::string(a2->getInfoOnComponent(4))=="aaaa");
+ CPPUNIT_ASSERT(std::string(a2->getInfoOnComponent(5))=="aaaa");
+ const double expected2[30]={2.,4.,3.,3.,1.,1., 12.,14.,13.,13.,11.,11., 22.,24.,23.,23.,21.,21., 32.,34.,33.,33.,31.,31., 42.,44.,43.,43.,41.,41.};
+ for(int i=0;i<30;i++)
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(expected2[i],a2->getIJ(0,i),1e-14);
+ DataArrayInt *a6=a5->convertToIntArr();
+ a6->setInfoOnComponent(0,"eeee");
+ a6->setInfoOnComponent(1,"ffff");
+ a4->setSelectedComponents(a6,arr4V);
+ CPPUNIT_ASSERT_EQUAL(6,a4->getNumberOfComponents());
+ CPPUNIT_ASSERT_EQUAL(5,a4->getNumberOfTuples());
+ CPPUNIT_ASSERT(std::string(a4->getInfoOnComponent(0))=="bbbb");
+ CPPUNIT_ASSERT(std::string(a4->getInfoOnComponent(1))=="eeee");
+ CPPUNIT_ASSERT(std::string(a4->getInfoOnComponent(2))=="ffff");
+ CPPUNIT_ASSERT(std::string(a4->getInfoOnComponent(3))=="cccc");
+ CPPUNIT_ASSERT(std::string(a4->getInfoOnComponent(4))=="aaaa");
+ CPPUNIT_ASSERT(std::string(a4->getInfoOnComponent(5))=="aaaa");
+ for(int i=0;i<30;i++)
+ CPPUNIT_ASSERT_EQUAL(int(expected2[i]),a4->getIJ(0,i));
+ // test of throw
+ const int arr5[3]={2,3,6};
+ const int arr6[3]={2,7,5};
+ const int arr7[4]={2,1,4,6};
+ std::vector<int> arr5V(arr5,arr5+3);
+ std::vector<int> arr6V(arr6,arr6+3);
+ std::vector<int> arr7V(arr7,arr7+4);
+ CPPUNIT_ASSERT_THROW(a2->keepSelectedComponents(arr5V),INTERP_KERNEL::Exception);
+ CPPUNIT_ASSERT_THROW(a2->keepSelectedComponents(arr6V),INTERP_KERNEL::Exception);
+ CPPUNIT_ASSERT_THROW(a2->setSelectedComponents(a1,arr7V),INTERP_KERNEL::Exception);
+ arr7V.resize(3);
+ CPPUNIT_ASSERT_THROW(a2->setSelectedComponents(a1,arr7V),INTERP_KERNEL::Exception);
+ //
+ a6->decrRef();
+ a5->decrRef();
+ a4->decrRef();
+ a3->decrRef();
+ a2->decrRef();
+ a1->decrRef();
+}
+
+void MEDCouplingBasicsTest::testKeepSetSelectedComponent2()
+{
+ MEDCouplingUMesh *m1=build2DTargetMesh_1();
+ const double arr1[20]={1.,2.,3.,4., 11.,12.,13.,14., 21.,22.,23.,24., 31.,32.,33.,34., 41.,42.,43.,44.};
+ DataArrayDouble *a1=DataArrayDouble::New();
+ a1->alloc(5,4);
+ std::copy(arr1,arr1+20,a1->getPointer());
+ a1->setInfoOnComponent(0,"aaaa");
+ a1->setInfoOnComponent(1,"bbbb");
+ a1->setInfoOnComponent(2,"cccc");
+ a1->setInfoOnComponent(3,"dddd");
+ MEDCouplingFieldDouble *f1=MEDCouplingFieldDouble::New(ON_CELLS,ONE_TIME);
+ f1->setTime(2.3,4,5);
+ f1->setMesh(m1);
+ f1->setName("f1");
+ f1->setArray(a1);
+ f1->checkCoherency();
+ //
+ const int arr2[6]={1,2,1,2,0,0};
+ std::vector<int> arr2V(arr2,arr2+6);
+ MEDCouplingFieldDouble *f2=f1->keepSelectedComponents(arr2V);
+ CPPUNIT_ASSERT(f2->getMesh()==f1->getMesh());
+ CPPUNIT_ASSERT(f2->getTimeDiscretization()==ONE_TIME);
+ int dt,it;
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(2.3,f2->getTime(dt,it),1e-13);
+ CPPUNIT_ASSERT_EQUAL(4,dt);
+ CPPUNIT_ASSERT_EQUAL(5,it);
+ f2->checkCoherency();
+ CPPUNIT_ASSERT_EQUAL(6,f2->getNumberOfComponents());
+ CPPUNIT_ASSERT_EQUAL(5,f2->getNumberOfTuples());
+ CPPUNIT_ASSERT(std::string(f2->getArray()->getInfoOnComponent(0))=="bbbb");
+ CPPUNIT_ASSERT(std::string(f2->getArray()->getInfoOnComponent(1))=="cccc");
+ CPPUNIT_ASSERT(std::string(f2->getArray()->getInfoOnComponent(2))=="bbbb");
+ CPPUNIT_ASSERT(std::string(f2->getArray()->getInfoOnComponent(3))=="cccc");
+ CPPUNIT_ASSERT(std::string(f2->getArray()->getInfoOnComponent(4))=="aaaa");
+ CPPUNIT_ASSERT(std::string(f2->getArray()->getInfoOnComponent(5))=="aaaa");
+ const double expected1[30]={2.,3.,2.,3.,1.,1., 12.,13.,12.,13.,11.,11., 22.,23.,22.,23.,21.,21., 32.,33.,32.,33.,31.,31., 42.,43.,42.,43.,41.,41.};
+ for(int i=0;i<30;i++)
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1[i],f2->getIJ(0,i),1e-14);
+ //setSelectedComponents
+ const int arr3[2]={3,2};
+ std::vector<int> arr3V(arr3,arr3+2);
+ MEDCouplingFieldDouble *f5=f1->keepSelectedComponents(arr3V);
+ f5->setTime(6.7,8,9);
+ f5->getArray()->setInfoOnComponent(0,"eeee");
+ f5->getArray()->setInfoOnComponent(1,"ffff");
+ f5->checkCoherency();
+ const int arr4[2]={1,2};
+ std::vector<int> arr4V(arr4,arr4+2);
+ f2->setSelectedComponents(f5,arr4V);
+ CPPUNIT_ASSERT_EQUAL(6,f2->getNumberOfComponents());
+ CPPUNIT_ASSERT_EQUAL(5,f2->getNumberOfTuples());
+ f2->checkCoherency();
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(2.3,f2->getTime(dt,it),1e-13);
+ CPPUNIT_ASSERT_EQUAL(4,dt);
+ CPPUNIT_ASSERT_EQUAL(5,it);
+ CPPUNIT_ASSERT(std::string(f2->getArray()->getInfoOnComponent(0))=="bbbb");
+ CPPUNIT_ASSERT(std::string(f2->getArray()->getInfoOnComponent(1))=="eeee");
+ CPPUNIT_ASSERT(std::string(f2->getArray()->getInfoOnComponent(2))=="ffff");
+ CPPUNIT_ASSERT(std::string(f2->getArray()->getInfoOnComponent(3))=="cccc");
+ CPPUNIT_ASSERT(std::string(f2->getArray()->getInfoOnComponent(4))=="aaaa");
+ CPPUNIT_ASSERT(std::string(f2->getArray()->getInfoOnComponent(5))=="aaaa");
+ const double expected2[30]={2.,4.,3.,3.,1.,1., 12.,14.,13.,13.,11.,11., 22.,24.,23.,23.,21.,21., 32.,34.,33.,33.,31.,31., 42.,44.,43.,43.,41.,41.};
+ for(int i=0;i<30;i++)
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(expected2[i],f2->getIJ(0,i),1e-14);
+ f5->decrRef();
+ f1->decrRef();
+ f2->decrRef();
+ a1->decrRef();
+ m1->decrRef();
+}
+
+void MEDCouplingBasicsTest::testDAIGetIdsEqual1()
+{
+ const int tab1[7]={5,-2,-4,-2,3,2,-2};
+ DataArrayInt *da=DataArrayInt::New();
+ da->alloc(7,1);
+ std::copy(tab1,tab1+7,da->getPointer());
+ DataArrayInt *da2=da->getIdsEqual(-2);
+ CPPUNIT_ASSERT_EQUAL(3,da2->getNumberOfTuples());
+ CPPUNIT_ASSERT_EQUAL(1,da2->getNumberOfComponents());
+ const int expected1[3]={1,3,6};
+ CPPUNIT_ASSERT(std::equal(expected1,expected1+3,da2->getConstPointer()));
+ da2->decrRef();
+ da->decrRef();
+}
+
+void MEDCouplingBasicsTest::testDAIGetIdsEqualList1()
+{
+ const int tab1[7]={5,-2,-4,-2,3,2,-2};
+ DataArrayInt *da=DataArrayInt::New();
+ da->alloc(7,1);
+ std::copy(tab1,tab1+7,da->getPointer());
+ const int tab2[3]={3,-2,0};
+ std::vector<int> tab2V(tab2,tab2+3);
+ DataArrayInt *da2=da->getIdsEqualList(tab2V);
+ CPPUNIT_ASSERT_EQUAL(4,da2->getNumberOfTuples());
+ CPPUNIT_ASSERT_EQUAL(1,da2->getNumberOfComponents());
+ const int expected1[4]={1,3,4,6};
+ CPPUNIT_ASSERT(std::equal(expected1,expected1+4,da2->getConstPointer()));
+ da2->decrRef();
+ da->decrRef();
+}
+
+void MEDCouplingBasicsTest::testDAFromNoInterlace1()
+{
+ const int tab1[15]={1,11,21,31,41,2,12,22,32,42,3,13,23,33,43};
+ DataArrayInt *da=DataArrayInt::New();
+ da->alloc(5,3);
+ std::copy(tab1,tab1+15,da->getPointer());
+ DataArrayInt *da2=da->fromNoInterlace();
+ const int expected1[15]={1,2,3,11,12,13,21,22,23,31,32,33,41,42,43};
+ CPPUNIT_ASSERT_EQUAL(5,da2->getNumberOfTuples());
+ CPPUNIT_ASSERT_EQUAL(3,da2->getNumberOfComponents());// it's not a bug. Avoid to have 1 million components !
+ CPPUNIT_ASSERT(std::equal(expected1,expected1+15,da2->getConstPointer()));
+ DataArrayDouble *da3=da->convertToDblArr();
+ DataArrayDouble *da4=da3->fromNoInterlace();
+ CPPUNIT_ASSERT_EQUAL(5,da4->getNumberOfTuples());
+ CPPUNIT_ASSERT_EQUAL(3,da4->getNumberOfComponents());// it's not a bug. Avoid to have 1 million components !
+ for(int i=0;i<15;i++)
+ CPPUNIT_ASSERT_DOUBLES_EQUAL((double)expected1[i],da4->getIJ(0,i),1e-14);
+ da4->decrRef();
+ da3->decrRef();
+ da2->decrRef();
+ da->decrRef();
+}
+
+void MEDCouplingBasicsTest::testDAToNoInterlace1()
+{
+ const int tab1[15]={1,2,3,11,12,13,21,22,23,31,32,33,41,42,43};
+ DataArrayInt *da=DataArrayInt::New();
+ da->alloc(5,3);
+ std::copy(tab1,tab1+15,da->getPointer());
+ DataArrayInt *da2=da->toNoInterlace();
+ const int expected1[15]={1,11,21,31,41,2,12,22,32,42,3,13,23,33,43};
+ CPPUNIT_ASSERT_EQUAL(5,da2->getNumberOfTuples());
+ CPPUNIT_ASSERT_EQUAL(3,da2->getNumberOfComponents());// it's not a bug. Avoid to have 1 million components !
+ CPPUNIT_ASSERT(std::equal(expected1,expected1+15,da2->getConstPointer()));
+ DataArrayDouble *da3=da->convertToDblArr();
+ DataArrayDouble *da4=da3->toNoInterlace();
+ CPPUNIT_ASSERT_EQUAL(5,da4->getNumberOfTuples());
+ CPPUNIT_ASSERT_EQUAL(3,da4->getNumberOfComponents());// it's not a bug. Avoid to have 1 million components !
+ for(int i=0;i<15;i++)
+ CPPUNIT_ASSERT_DOUBLES_EQUAL((double)expected1[i],da4->getIJ(0,i),1e-14);
+ da4->decrRef();
+ da3->decrRef();
+ da2->decrRef();
+ da->decrRef();
+}
+
+void MEDCouplingBasicsTest::testDAIsUniform1()
+{
+ const int tab1[5]={1,1,1,1,1};
+ DataArrayInt *da=DataArrayInt::New();
+ da->alloc(5,1);
+ std::copy(tab1,tab1+5,da->getPointer());
+ CPPUNIT_ASSERT(da->isUniform(1));
+ da->setIJ(2,0,2);
+ CPPUNIT_ASSERT(!da->isUniform(1));
+ da->setIJ(2,0,1);
+ CPPUNIT_ASSERT(da->isUniform(1));
+ DataArrayDouble *da2=da->convertToDblArr();
+ CPPUNIT_ASSERT(da2->isUniform(1.,1e-12));
+ da2->setIJ(1,0,1.+1.e-13);
+ CPPUNIT_ASSERT(da2->isUniform(1.,1e-12));
+ da2->setIJ(1,0,1.+1.e-11);
+ CPPUNIT_ASSERT(!da2->isUniform(1.,1e-12));
+ da2->decrRef();
+ da->decrRef();
+}
+
+void MEDCouplingBasicsTest::testDADFromPolarToCart1()
+{
+ const double tab1[4]={2.,0.2,2.5,0.7};
+ DataArrayDouble *da=DataArrayDouble::New();
+ da->alloc(2,2);
+ std::copy(tab1,tab1+4,da->getPointer());
+ DataArrayDouble *da2=da->fromPolarToCart();
+ const double expected1[4]={1.9601331556824833,0.39733866159012243, 1.9121054682112213,1.6105442180942275};
+ for(int i=0;i<4;i++)
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1[i],da2->getIJ(0,i),1e-13);
+ da2->decrRef();
+ da->decrRef();
+}
+
+void MEDCouplingBasicsTest::testDADFromCylToCart1()
+{
+ const double tab1[6]={2.,0.2,4.,2.5,0.7,9.};
+ DataArrayDouble *da=DataArrayDouble::New();
+ da->alloc(2,3);
+ std::copy(tab1,tab1+6,da->getPointer());
+ DataArrayDouble *da2=da->fromCylToCart();
+ const double expected1[6]={1.9601331556824833,0.39733866159012243,4., 1.9121054682112213,1.6105442180942275,9.};
+ for(int i=0;i<6;i++)
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1[i],da2->getIJ(0,i),1e-13);
+ da2->decrRef();
+ da->decrRef();
+}
+
+void MEDCouplingBasicsTest::testDADFromSpherToCart1()
+{
+ const double tab1[6]={2.,0.2,0.3,2.5,0.7,0.8};
+ DataArrayDouble *da=DataArrayDouble::New();
+ da->alloc(2,3);
+ std::copy(tab1,tab1+6,da->getPointer());
+ DataArrayDouble *da2=da->fromSpherToCart();
+ const double expected1[6]={0.37959212195737485,0.11742160338765303,1.9601331556824833, 1.1220769624465328,1.1553337045129035,1.9121054682112213};
+ for(int i=0;i<6;i++)
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1[i],da2->getIJ(0,i),1e-13);
+ da2->decrRef();
+ da->decrRef();
+}
+
+void MEDCouplingBasicsTest::testUnPolyze1()
+{
+ const int elts[8]={0,1,2,3,4,5,6,7};
+ std::vector<int> eltsV(elts,elts+8);
+ MEDCouplingUMesh *mesh=build3DTargetMesh_1();
+ mesh->convertToPolyTypes(eltsV);
+ mesh->unPolyze();
+ MEDCouplingUMesh *mesh2=build3DTargetMesh_1();
+ mesh->checkCoherency();
+ CPPUNIT_ASSERT(mesh->isEqual(mesh2,1e-12));
+ mesh->convertToPolyTypes(eltsV);
+ CPPUNIT_ASSERT(!mesh->isEqual(mesh2,1e-12));
+ mesh->getNodalConnectivity()->setIJ(0,6,10);
+ mesh->getNodalConnectivity()->setIJ(0,7,9);
+ mesh->getNodalConnectivity()->setIJ(0,8,12);
+ mesh->getNodalConnectivity()->setIJ(0,9,13);
+ mesh->unPolyze();
+ CPPUNIT_ASSERT(mesh->isEqual(mesh2,1e-12));
+ mesh->convertToPolyTypes(eltsV);
+ mesh->getNodalConnectivity()->setIJ(0,6,12);
+ mesh->getNodalConnectivity()->setIJ(0,7,13);
+ mesh->getNodalConnectivity()->setIJ(0,8,10);
+ mesh->getNodalConnectivity()->setIJ(0,9,9);
+ mesh->unPolyze();
+ CPPUNIT_ASSERT(mesh->isEqual(mesh2,1e-12));
+ mesh->convertToPolyTypes(eltsV);
+ mesh->getNodalConnectivity()->setIJ(0,6,12);
+ mesh->getNodalConnectivity()->setIJ(0,7,10);
+ mesh->getNodalConnectivity()->setIJ(0,8,13);
+ mesh->getNodalConnectivity()->setIJ(0,9,9);
+ mesh->unPolyze();
+ CPPUNIT_ASSERT(!mesh->isEqual(mesh2,1e-12));
+ mesh->decrRef();
+ mesh2->decrRef();
+ // Test for 2D mesh
+ mesh=build2DTargetMesh_1();
+ mesh2=build2DTargetMesh_1();
+ eltsV.resize(5);
+ mesh->convertToPolyTypes(eltsV);
+ CPPUNIT_ASSERT(!mesh->isEqual(mesh2,1e-12));
+ mesh->unPolyze();
+ CPPUNIT_ASSERT(mesh->isEqual(mesh2,1e-12));
+ mesh->decrRef();
+ mesh2->decrRef();
+}
+
+void MEDCouplingBasicsTest::testConvertDegeneratedCells1()
+{
+ MEDCouplingUMesh *mesh=build3DTargetMesh_1();
+ int conn[32]={0,1,3,3,9,10,12,12, 0,1,3,4,9,9,9,9, 1,1,1,1,10,12,9,10, 10,11,12,9,1,1,1,1};
+ mesh->allocateCells(4);
+ mesh->insertNextCell(INTERP_KERNEL::NORM_HEXA8,8,conn);
+ mesh->insertNextCell(INTERP_KERNEL::NORM_HEXA8,8,conn+8);
+ mesh->insertNextCell(INTERP_KERNEL::NORM_HEXA8,8,conn+16);
+ mesh->insertNextCell(INTERP_KERNEL::NORM_HEXA8,8,conn+24);
+ mesh->finishInsertingCells();
+ mesh->checkCoherency();
+ CPPUNIT_ASSERT_EQUAL(4,mesh->getNumberOfCells());
+ CPPUNIT_ASSERT_EQUAL(INTERP_KERNEL::NORM_HEXA8,mesh->getTypeOfCell(0));
+ CPPUNIT_ASSERT_EQUAL(INTERP_KERNEL::NORM_HEXA8,mesh->getTypeOfCell(1));
+ CPPUNIT_ASSERT_EQUAL(INTERP_KERNEL::NORM_HEXA8,mesh->getTypeOfCell(2));
+ CPPUNIT_ASSERT_EQUAL(INTERP_KERNEL::NORM_HEXA8,mesh->getTypeOfCell(3));
+ MEDCouplingFieldDouble *f1=mesh->getMeasureField(true);
+ mesh->convertDegeneratedCells();
+ mesh->checkCoherency();
+ MEDCouplingFieldDouble *f2=mesh->getMeasureField(true);
+ CPPUNIT_ASSERT_EQUAL(4,mesh->getNumberOfCells());
+ CPPUNIT_ASSERT_EQUAL(INTERP_KERNEL::NORM_PENTA6,mesh->getTypeOfCell(0));
+ CPPUNIT_ASSERT_EQUAL(INTERP_KERNEL::NORM_PYRA5,mesh->getTypeOfCell(1));
+ CPPUNIT_ASSERT_EQUAL(INTERP_KERNEL::NORM_TETRA4,mesh->getTypeOfCell(2));
+ CPPUNIT_ASSERT_EQUAL(INTERP_KERNEL::NORM_PYRA5,mesh->getTypeOfCell(3));
+ for(int i=0;i<4;i++)
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(f1->getArray()->getIJ(0,i),f2->getArray()->getIJ(0,i),1e-5);
+ f1->decrRef();
+ f2->decrRef();
+ mesh->decrRef();
+}
+
+void MEDCouplingBasicsTest::testGetNodeIdsNearPoints1()
+{
+ MEDCouplingUMesh *mesh=build2DTargetMesh_1();
+ DataArrayDouble *coords=mesh->getCoords();
+ DataArrayDouble *tmp=DataArrayDouble::New();
+ tmp->alloc(3,2);
+ const double vals[6]={0.2,0.2,0.1,0.2,0.2,0.2};
+ std::copy(vals,vals+6,tmp->getPointer());
+ DataArrayDouble *tmp2=DataArrayDouble::Aggregate(coords,tmp);
+ tmp->decrRef();
+ mesh->setCoords(tmp2);
+ tmp2->decrRef();
+ const double pts[6]={0.2,0.2,0.1,0.3,-0.3,0.7};
+ std::vector<int> c=mesh->getNodeIdsNearPoint(pts,1e-7);
+ CPPUNIT_ASSERT_EQUAL(3,(int)c.size());
+ CPPUNIT_ASSERT_EQUAL(4,c[0]);
+ CPPUNIT_ASSERT_EQUAL(9,c[1]);
+ CPPUNIT_ASSERT_EQUAL(11,c[2]);
+ c.clear();
+ std::vector<int> cI;
+ mesh->getNodeIdsNearPoints(pts,3,1e-7,c,cI);
+ CPPUNIT_ASSERT_EQUAL(4,(int)cI.size());
+ CPPUNIT_ASSERT_EQUAL(4,(int)c.size());
+ CPPUNIT_ASSERT_EQUAL(4,c[0]);
+ CPPUNIT_ASSERT_EQUAL(9,c[1]);
+ CPPUNIT_ASSERT_EQUAL(11,c[2]);
+ CPPUNIT_ASSERT_EQUAL(6,c[3]);
+ CPPUNIT_ASSERT_EQUAL(0,cI[0]);
+ CPPUNIT_ASSERT_EQUAL(3,cI[1]);
+ CPPUNIT_ASSERT_EQUAL(3,cI[2]);
+ CPPUNIT_ASSERT_EQUAL(4,cI[3]);
+ mesh->decrRef();
+}
+
+void MEDCouplingBasicsTest::testFieldCopyTinyAttrFrom1()
+{
+ MEDCouplingFieldDouble *f1=MEDCouplingFieldDouble::New(ON_CELLS,ONE_TIME);
+ f1->setName("f1");
+ f1->setTimeTolerance(1.e-5);
+ f1->setDescription("f1Desc");
+ f1->setTime(1.23,4,5);
+ MEDCouplingFieldDouble *f2=MEDCouplingFieldDouble::New(ON_CELLS,ONE_TIME);
+ f2->setName("f2");
+ f2->setDescription("f2Desc");
+ f2->setTime(6.78,9,10);
+ f2->setTimeTolerance(4.556e-12);
+ //
+ int dt,it;
+ f1->copyTinyAttrFrom(f2);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(4.556e-12,f1->getTimeTolerance(),1e-24);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(6.78,f1->getTime(dt,it),1e-12);
+ CPPUNIT_ASSERT_EQUAL(9,dt);
+ CPPUNIT_ASSERT_EQUAL(10,it);
+ CPPUNIT_ASSERT(std::string(f1->getName())=="f1");//name unchanged
+ CPPUNIT_ASSERT(std::string(f1->getDescription())=="f1Desc");//description unchanged
+ f1->decrRef();
+ f2->decrRef();
+ //
+ f1=MEDCouplingFieldDouble::New(ON_CELLS,NO_TIME);
+ f1->setName("f1");
+ f1->setTimeTolerance(1.e-5);
+ f1->setDescription("f1Desc");
+ f2=MEDCouplingFieldDouble::New(ON_CELLS,NO_TIME);
+ f2->setName("f2");
+ f2->setDescription("f2Desc");
+ f2->setTimeTolerance(4.556e-12);
+ //
+ f1->copyTinyAttrFrom(f2);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(4.556e-12,f1->getTimeTolerance(),1e-24);
+ CPPUNIT_ASSERT(std::string(f1->getName())=="f1");//name unchanged
+ CPPUNIT_ASSERT(std::string(f1->getDescription())=="f1Desc");//description unchanged
+ f1->decrRef();
+ f2->decrRef();
+ //
+ f1=MEDCouplingFieldDouble::New(ON_CELLS,CONST_ON_TIME_INTERVAL);
+ f1->setName("f1");
+ f1->setTimeTolerance(1.e-5);
+ f1->setDescription("f1Desc");
+ f1->setTime(1.23,4,5);
+ f1->setEndTime(5.43,2,1);
+ f2=MEDCouplingFieldDouble::New(ON_CELLS,CONST_ON_TIME_INTERVAL);
+ f2->setName("f2");
+ f2->setDescription("f2Desc");
+ f2->setTimeTolerance(4.556e-12);
+ f2->setTime(6.78,9,10);
+ f2->setEndTime(10.98,7,6);
+ //
+ f1->copyTinyAttrFrom(f2);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(4.556e-12,f1->getTimeTolerance(),1e-24);
+ CPPUNIT_ASSERT(std::string(f1->getName())=="f1");//name unchanged
+ CPPUNIT_ASSERT(std::string(f1->getDescription())=="f1Desc");//description unchanged
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(6.78,f1->getTime(dt,it),1e-12);
+ CPPUNIT_ASSERT_EQUAL(9,dt);
+ CPPUNIT_ASSERT_EQUAL(10,it);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(10.98,f1->getEndTime(dt,it),1e-12);
+ CPPUNIT_ASSERT_EQUAL(7,dt);
+ CPPUNIT_ASSERT_EQUAL(6,it);
+ f1->decrRef();
+ f2->decrRef();
+ //
+ f1=MEDCouplingFieldDouble::New(ON_CELLS,LINEAR_TIME);
+ f1->setName("f1");
+ f1->setTimeTolerance(1.e-5);
+ f1->setDescription("f1Desc");
+ f1->setTime(1.23,4,5);
+ f1->setEndTime(5.43,2,1);
+ f2=MEDCouplingFieldDouble::New(ON_CELLS,LINEAR_TIME);
+ f2->setName("f2");
+ f2->setDescription("f2Desc");
+ f2->setTimeTolerance(4.556e-12);
+ f2->setTime(6.78,9,10);
+ f2->setEndTime(10.98,7,6);
+ //
+ f1->copyTinyAttrFrom(f2);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(4.556e-12,f1->getTimeTolerance(),1e-24);
+ CPPUNIT_ASSERT(std::string(f1->getName())=="f1");//name unchanged
+ CPPUNIT_ASSERT(std::string(f1->getDescription())=="f1Desc");//description unchanged
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(6.78,f1->getTime(dt,it),1e-12);
+ CPPUNIT_ASSERT_EQUAL(9,dt);
+ CPPUNIT_ASSERT_EQUAL(10,it);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(10.98,f1->getEndTime(dt,it),1e-12);
+ CPPUNIT_ASSERT_EQUAL(7,dt);
+ CPPUNIT_ASSERT_EQUAL(6,it);
+ f1->decrRef();
+ f2->decrRef();
+}
+
+/*!
+ * 1D -> 2D extrusion with rotation
+ */
+void MEDCouplingBasicsTest::testExtrudedMesh5()
+{
+ const double coo1[4]={0.,1.,2.,3.5};
+ DataArrayDouble *a=DataArrayDouble::New();
+ a->alloc(4,1);
+ std::copy(coo1,coo1+4,a->getPointer());
+ MEDCouplingCMesh *b=MEDCouplingCMesh::New();
+ b->setCoordsAt(0,a);
+ MEDCouplingUMesh *c=b->buildUnstructured();
+ CPPUNIT_ASSERT_EQUAL(1,c->getSpaceDimension());
+ c->changeSpaceDimension(2);
+ //
+ DataArrayDouble *d=DataArrayDouble::New();
+ d->alloc(13,1);
+ d->iota();
+ MEDCouplingCMesh *e=MEDCouplingCMesh::New();
+ e->setCoordsAt(0,d);
+ MEDCouplingUMesh *f=e->buildUnstructured();
+ DataArrayDouble *g=f->getCoords()->applyFunc(2,"3.5*IVec+x/6*3.14159265359*JVec");
+ DataArrayDouble *h=g->fromPolarToCart();
+ f->setCoords(h);
+ MEDCouplingUMesh *i=c->buildExtrudedMesh(f,1);
+ CPPUNIT_ASSERT_EQUAL(52,i->getNumberOfNodes());
+ bool tmp2;
+ int tmp3;
+ DataArrayInt *tmp=i->mergeNodes(1e-9,tmp2,tmp3);
+ CPPUNIT_ASSERT(tmp2);
+ CPPUNIT_ASSERT_EQUAL(37,tmp3);
+ tmp->decrRef();
+ i->convertDegeneratedCells();
+ i->checkCoherency();
+ CPPUNIT_ASSERT_EQUAL(36,i->getNumberOfCells());
+ CPPUNIT_ASSERT_EQUAL(37,i->getNumberOfNodes());
+ CPPUNIT_ASSERT_EQUAL(12,i->getNumberOfCellsWithType(INTERP_KERNEL::NORM_TRI3));
+ CPPUNIT_ASSERT_EQUAL(24,i->getNumberOfCellsWithType(INTERP_KERNEL::NORM_QUAD4));
+ const double expected1[3]={0.25,0.75,2.0625};
+ MEDCouplingFieldDouble *j=i->getMeasureField(true);
+ for(int i=0;i<12;i++)
+ for(int k=0;k<3;k++)
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1[k],j->getIJ(0,i*3+k),1e-10);
+ const double expected2[72]={0.62200846792814113, 0.16666666666681595, 1.4513530918323276, 0.38888888888923495, 2.6293994326053212, 0.7045454545460802, 0.45534180126145435, 0.45534180126150181, 1.0624642029433926, 1.0624642029435025, 1.9248539780597826, 1.9248539780599816, 0.16666666666661334, 0.62200846792815856, 0.38888888888876294, 1.4513530918323678, 0.70454545454522521, 2.629399432605394, -0.16666666666674007, 0.62200846792812436, -0.38888888888906142, 1.4513530918322881, -0.70454545454576778, 2.6293994326052488, -0.45534180126154766, 0.45534180126140844, -1.0624642029436118, 1.0624642029432834, -1.9248539780601803, 1.9248539780595841, -0.62200846792817499, 0.1666666666665495, -1.451353091832408, 0.388888888888613, -2.6293994326054668, 0.70454545454495332, -0.62200846792810593, -0.16666666666680507, -1.451353091832247, -0.38888888888921297, -2.6293994326051746, -0.70454545454604123, -0.45534180126135926, -0.45534180126159562, -1.0624642029431723, -1.0624642029437235, -1.9248539780593836, -1.9248539780603811, -0.1666666666664828, -0.62200846792819242, -0.38888888888846079, -1.4513530918324489, -0.70454545454467987, -2.6293994326055397, 0.16666666666687083, -0.62200846792808862, 0.38888888888936374, -1.4513530918322073, 0.70454545454631357, -2.6293994326051022, 0.45534180126164348, -0.45534180126131207, 1.0624642029438327, -1.0624642029430627, 1.9248539780605791, -1.9248539780591853, 0.62200846792821063, -0.16666666666641802, 1.4513530918324888, -0.38888888888831086, 2.6293994326056125, -0.70454545454440853};
+ DataArrayDouble *m=i->getBarycenterAndOwner();
+ for(int i=0;i<72;i++)
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(expected2[i],m->getIJ(0,i),1e-10);
+ //
+ m->decrRef();
+ j->decrRef();
+ i->decrRef();
+ h->decrRef();
+ g->decrRef();
+ f->decrRef();
+ e->decrRef();
+ d->decrRef();
+ c->decrRef();
+ b->decrRef();
+ a->decrRef();
+}
+
+/*!
+ * 1D -> 2D extrusion without rotation
+ */
+void MEDCouplingBasicsTest::testExtrudedMesh6()
+{
+ const double coo1[4]={0.,1.,2.,3.5};
+ DataArrayDouble *a=DataArrayDouble::New();
+ a->alloc(4,1);
+ std::copy(coo1,coo1+4,a->getPointer());
+ MEDCouplingCMesh *b=MEDCouplingCMesh::New();
+ b->setCoordsAt(0,a);
+ MEDCouplingUMesh *c=b->buildUnstructured();
+ CPPUNIT_ASSERT_EQUAL(1,c->getSpaceDimension());
+ c->changeSpaceDimension(2);
+ //
+ DataArrayDouble *d=DataArrayDouble::New();
+ d->alloc(5,1);
+ d->iota();
+ MEDCouplingCMesh *e=MEDCouplingCMesh::New();
+ e->setCoordsAt(0,d);
+ MEDCouplingUMesh *f=e->buildUnstructured();
+ DataArrayDouble *d2=f->getCoords()->applyFunc("x*x/2");
+ f->setCoords(d2);
+ f->changeSpaceDimension(2);
+ //
+ const double center[2]={0.,0.};
+ f->rotate(center,0,M_PI/3);
+ MEDCouplingUMesh *g=c->buildExtrudedMesh(f,0);
+ g->checkCoherency();
+ const double expected1[]={ 0.4330127018922193, 0.4330127018922193, 0.649519052838329, 1.2990381056766578, 1.299038105676658, 1.948557158514987, 2.1650635094610955, 2.1650635094610964, 3.2475952641916446, 3.031088913245533, 3.0310889132455352, 4.546633369868303 };
+ MEDCouplingFieldDouble *f1=g->getMeasureField(true);
+ for(int i=0;i<12;i++)
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1[i],f1->getIJ(0,i),1e-12);
+
+ const double expected2[]={0.625, 0.21650635094610962, 1.625, 0.21650635094610959, 2.8750000000000004, 0.21650635094610965, 1.1250000000000002, 1.0825317547305482, 2.125, 1.0825317547305482, 3.3750000000000004, 1.0825317547305484, 2.125, 2.8145825622994254, 3.125, 2.8145825622994254, 4.375, 2.8145825622994254, 3.6250000000000009, 5.4126587736527414, 4.625, 5.4126587736527414, 5.875, 5.4126587736527414};
+ DataArrayDouble *f2=g->getBarycenterAndOwner();
+ for(int i=0;i<24;i++)
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(expected2[i],f2->getIJ(0,i),1e-12);
+ //
+ f1->decrRef();
+ f2->decrRef();
+ g->decrRef();
+ f->decrRef();
+ e->decrRef();
+ d->decrRef();
+ d2->decrRef();
+ c->decrRef();
+ b->decrRef();
+ a->decrRef();
+}
+
+/*!
+ * 2D -> 3D extrusion with rotation
+ */
+void MEDCouplingBasicsTest::testExtrudedMesh7()
+{
+ const double coo1[4]={0.,1.,2.,3.5};
+ DataArrayDouble *a=DataArrayDouble::New();
+ a->alloc(4,1);
+ std::copy(coo1,coo1+4,a->getPointer());
+ MEDCouplingCMesh *b=MEDCouplingCMesh::New();
+ b->setCoordsAt(0,a);
+ MEDCouplingUMesh *c=b->buildUnstructured();
+ CPPUNIT_ASSERT_EQUAL(1,c->getSpaceDimension());
+ c->changeSpaceDimension(2);
+ //
+ DataArrayDouble *d=DataArrayDouble::New();
+ d->alloc(13,1);
+ d->iota();
+ MEDCouplingCMesh *e=MEDCouplingCMesh::New();
+ e->setCoordsAt(0,d);
+ MEDCouplingUMesh *f=e->buildUnstructured();
+ DataArrayDouble *g=f->getCoords()->applyFunc(2,"3.5*IVec+x/6*3.14159265359*JVec");
+ DataArrayDouble *h=g->fromPolarToCart();
+ f->setCoords(h);
+ MEDCouplingUMesh *i=c->buildExtrudedMesh(f,1);
+ CPPUNIT_ASSERT_EQUAL(52,i->getNumberOfNodes());
+ bool tmp2;
+ int tmp3;
+ DataArrayInt *tmp=i->mergeNodes(1e-9,tmp2,tmp3);
+ CPPUNIT_ASSERT(tmp2);
+ CPPUNIT_ASSERT_EQUAL(37,tmp3);
+ tmp->decrRef();
+ i->convertDegeneratedCells();
+ const double vec1[3]={10.,0.,0.};
+ i->translate(vec1);
+ DataArrayDouble *g2=h->applyFunc(3,"13.5/3.5*x*IVec+0*JVec+13.5/3.5*y*KVec");
+ f->setCoords(g2);
+ i->changeSpaceDimension(3);
+ MEDCouplingUMesh *i3=i->buildExtrudedMesh(f,1);
+ MEDCouplingFieldDouble *f2=i3->getMeasureField(true);
+ tmp=i->mergeNodes(1e-9,tmp2,tmp3);
+ CPPUNIT_ASSERT(tmp2);
+ CPPUNIT_ASSERT_EQUAL(444,tmp3);
+ tmp->decrRef();
+ const double expected1[36]={1.327751058489274, 4.2942574094314701, 13.024068164857139, 1.3069177251569044, 4.1484240761012954, 12.297505664866796, 1.270833333332571, 3.8958333333309674, 11.039062499993179, 1.2291666666659207, 3.6041666666644425, 9.585937499993932, 1.1930822748415895, 3.3515759238941376, 8.3274943351204556, 1.1722489415082769, 3.2057425905609289, 7.6009318351210622, 1.1722489415082862, 3.2057425905609884, 7.6009318351213713, 1.1930822748416161, 3.3515759238943001, 8.3274943351212727, 1.2291666666659564, 3.6041666666646734, 9.5859374999950777, 1.2708333333326081, 3.8958333333311868, 11.039062499994293, 1.3069177251569224, 4.1484240761014384, 12.297505664867627, 1.3277510584902354, 4.2942574094346071, 13.024068164866796};
+ int kk=0;
+ for(int ii=0;ii<12;ii++)
+ for(int jj=0;jj<36;jj++,kk++)
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1[jj],f2->getIJ(0,kk),1e-9);
+ //
+ f2->decrRef();
+ i3->decrRef();
+ g2->decrRef();
+ i->decrRef();
+ h->decrRef();
+ g->decrRef();
+ f->decrRef();
+ e->decrRef();
+ d->decrRef();
+ c->decrRef();
+ b->decrRef();
+ a->decrRef();
+}
+
+void MEDCouplingBasicsTest::testSimplexize1()
+{
+ MEDCouplingUMesh *m=build3DSurfTargetMesh_1();
+ std::vector<int> v(1);
+ v[0]=3;
+ m->convertToPolyTypes(v);
+ DataArrayInt *da=m->simplexize(0);
+ CPPUNIT_ASSERT_EQUAL(7,da->getNumberOfTuples());
+ CPPUNIT_ASSERT_EQUAL(1,da->getNumberOfComponents());
+ const int expected2[7]={0,0,1,2,3,4,4};
+ for(int i=0;i<7;i++)
+ CPPUNIT_ASSERT_EQUAL(expected2[i],da->getIJ(i,0));
+ m->checkCoherency();
+ CPPUNIT_ASSERT_EQUAL(7,m->getNumberOfCells());
+ CPPUNIT_ASSERT_EQUAL(INTERP_KERNEL::NORM_TRI3,m->getTypeOfCell(0));
+ CPPUNIT_ASSERT_EQUAL(INTERP_KERNEL::NORM_TRI3,m->getTypeOfCell(1));
+ CPPUNIT_ASSERT_EQUAL(INTERP_KERNEL::NORM_TRI3,m->getTypeOfCell(2));
+ CPPUNIT_ASSERT_EQUAL(INTERP_KERNEL::NORM_TRI3,m->getTypeOfCell(3));
+ CPPUNIT_ASSERT_EQUAL(INTERP_KERNEL::NORM_POLYGON,m->getTypeOfCell(4));
+ CPPUNIT_ASSERT_EQUAL(INTERP_KERNEL::NORM_TRI3,m->getTypeOfCell(5));
+ CPPUNIT_ASSERT_EQUAL(INTERP_KERNEL::NORM_TRI3,m->getTypeOfCell(6));
+ const double expected1[7]={0.125,0.125,0.125,0.125,0.25,0.125,0.125};
+ MEDCouplingFieldDouble *f=m->getMeasureField(false);
+ for(int i=0;i<7;i++)
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1[i]*sqrt(2.),f->getIJ(i,0),1e-10);
+ std::set<INTERP_KERNEL::NormalizedCellType> types=m->getAllTypes();
+ CPPUNIT_ASSERT_EQUAL(2,(int)types.size());
+ CPPUNIT_ASSERT_EQUAL(INTERP_KERNEL::NORM_TRI3,*(types.begin()));
+ CPPUNIT_ASSERT_EQUAL(INTERP_KERNEL::NORM_POLYGON,*(++(types.begin())));
+ f->decrRef();
+ da->decrRef();
+ m->decrRef();
+ //
+ m=build3DSurfTargetMesh_1();
+ v[0]=3;
+ m->convertToPolyTypes(v);
+ da=m->simplexize(1);
+ CPPUNIT_ASSERT_EQUAL(7,da->getNumberOfTuples());
+ CPPUNIT_ASSERT_EQUAL(1,da->getNumberOfComponents());
+ for(int i=0;i<7;i++)
+ CPPUNIT_ASSERT_EQUAL(expected2[i],da->getIJ(i,0));
+ m->checkCoherency();
+ types=m->getAllTypes();
+ CPPUNIT_ASSERT_EQUAL(2,(int)types.size());
+ CPPUNIT_ASSERT_EQUAL(INTERP_KERNEL::NORM_TRI3,*(types.begin()));
+ CPPUNIT_ASSERT_EQUAL(INTERP_KERNEL::NORM_POLYGON,*(++(types.begin())));
+ CPPUNIT_ASSERT_EQUAL(7,m->getNumberOfCells());
+ CPPUNIT_ASSERT_EQUAL(INTERP_KERNEL::NORM_TRI3,m->getTypeOfCell(0));
+ CPPUNIT_ASSERT_EQUAL(INTERP_KERNEL::NORM_TRI3,m->getTypeOfCell(1));
+ CPPUNIT_ASSERT_EQUAL(INTERP_KERNEL::NORM_TRI3,m->getTypeOfCell(2));
+ CPPUNIT_ASSERT_EQUAL(INTERP_KERNEL::NORM_TRI3,m->getTypeOfCell(3));
+ CPPUNIT_ASSERT_EQUAL(INTERP_KERNEL::NORM_POLYGON,m->getTypeOfCell(4));
+ CPPUNIT_ASSERT_EQUAL(INTERP_KERNEL::NORM_TRI3,m->getTypeOfCell(5));
+ CPPUNIT_ASSERT_EQUAL(INTERP_KERNEL::NORM_TRI3,m->getTypeOfCell(6));
+ f=m->getMeasureField(false);
+ for(int i=0;i<7;i++)
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1[i]*sqrt(2.),f->getIJ(i,0),1e-10);
+ f->decrRef();
+ da->decrRef();
+ m->decrRef();
+}
+
+void MEDCouplingBasicsTest::testSimplexize2()
+{
+ MEDCouplingUMesh *m=build3DSurfTargetMesh_1();
+ std::vector<int> v(1);
+ v[0]=3;
+ m->convertToPolyTypes(v);
+ MEDCouplingFieldDouble *f1=MEDCouplingFieldDouble::New(ON_CELLS,ONE_TIME);
+ f1->setMesh(m);
+ DataArrayDouble *arr=DataArrayDouble::New();
+ const double arr1[10]={10.,110.,20.,120.,30.,130.,40.,140.,50.,150.};
+ arr->alloc(5,2);
+ std::copy(arr1,arr1+10,arr->getPointer());
+ f1->setArray(arr);
+ arr->decrRef();
+ //
+ f1->checkCoherency();
+ CPPUNIT_ASSERT(f1->simplexize(0));
+ f1->checkCoherency();
+ const double expected1[14]={10.,110.,10.,110.,20.,120.,30.,130.,40.,140.,50.,150.,50.,150.};
+ for(int i=0;i<14;i++)
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1[i],f1->getIJ(0,i),1e-10);
+ CPPUNIT_ASSERT(!f1->simplexize(0));
+ for(int i=0;i<14;i++)
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1[i],f1->getIJ(0,i),1e-10);
+ //
+ f1->decrRef();
+ m->decrRef();
+}
+
+void MEDCouplingBasicsTest::testDAMeld1()
+{
+ DataArrayDouble *da1=DataArrayDouble::New();
+ da1->alloc(7,2);
+ DataArrayDouble *da2=DataArrayDouble::New();
+ da2->alloc(7,1);
+ //
+ da1->fillWithValue(7.);
+ da2->iota(0.);
+ DataArrayDouble *da3=da2->applyFunc(3,"10*x*IVec+100*x*JVec+1000*x*KVec");
+ //
+ da1->setInfoOnComponent(0,"c0da1");
+ da1->setInfoOnComponent(1,"c1da1");
+ da3->setInfoOnComponent(0,"c0da3");
+ da3->setInfoOnComponent(1,"c1da3");
+ da3->setInfoOnComponent(2,"c2da3");
+ //
+ DataArrayDouble *da1C=da1->deepCpy();
+ da1->meldWith(da3);
+ CPPUNIT_ASSERT_EQUAL(5,da1->getNumberOfComponents());
+ CPPUNIT_ASSERT_EQUAL(7,da1->getNumberOfTuples());
+ CPPUNIT_ASSERT(da1->getInfoOnComponent(0)=="c0da1");
+ CPPUNIT_ASSERT(da1->getInfoOnComponent(1)=="c1da1");
+ CPPUNIT_ASSERT(da1->getInfoOnComponent(2)=="c0da3");
+ CPPUNIT_ASSERT(da1->getInfoOnComponent(3)=="c1da3");
+ CPPUNIT_ASSERT(da1->getInfoOnComponent(4)=="c2da3");
+ //
+ const double expected1[35]={7.,7.,0.,0.,0., 7.,7.,10.,100.,1000., 7.,7.,20.,200.,2000., 7.,7.,30.,300.,3000., 7.,7.,40.,400.,4000.,7.,7.,50.,500.,5000.,7.,7.,60.,600.,6000.};
+ for(int i=0;i<35;i++)
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1[i],da1->getIJ(0,i),1e-10);
+ //
+ DataArrayInt *dai1=da1C->convertToIntArr();
+ DataArrayInt *dai3=da3->convertToIntArr();
+ dai1->meldWith(dai3);
+ CPPUNIT_ASSERT_EQUAL(5,dai1->getNumberOfComponents());
+ CPPUNIT_ASSERT_EQUAL(7,dai1->getNumberOfTuples());
+ CPPUNIT_ASSERT(dai1->getInfoOnComponent(0)=="c0da1");
+ CPPUNIT_ASSERT(dai1->getInfoOnComponent(1)=="c1da1");
+ CPPUNIT_ASSERT(dai1->getInfoOnComponent(2)=="c0da3");
+ CPPUNIT_ASSERT(dai1->getInfoOnComponent(3)=="c1da3");
+ CPPUNIT_ASSERT(dai1->getInfoOnComponent(4)=="c2da3");
+ for(int i=0;i<35;i++)
+ CPPUNIT_ASSERT_EQUAL((int)expected1[i],dai1->getIJ(0,i));
+ // test of static method DataArrayDouble::meld
+ DataArrayDouble *da4=DataArrayDouble::Meld(da1C,da3);
+ CPPUNIT_ASSERT_EQUAL(5,da4->getNumberOfComponents());
+ CPPUNIT_ASSERT_EQUAL(7,da4->getNumberOfTuples());
+ CPPUNIT_ASSERT(da4->getInfoOnComponent(0)=="c0da1");
+ CPPUNIT_ASSERT(da4->getInfoOnComponent(1)=="c1da1");
+ CPPUNIT_ASSERT(da4->getInfoOnComponent(2)=="c0da3");
+ CPPUNIT_ASSERT(da4->getInfoOnComponent(3)=="c1da3");
+ CPPUNIT_ASSERT(da4->getInfoOnComponent(4)=="c2da3");
+ for(int i=0;i<35;i++)
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1[i],da4->getIJ(0,i),1e-10);
+ // test of static method DataArrayInt::meld
+ dai1->decrRef();
+ dai1=da1C->convertToIntArr();
+ DataArrayInt *dai4=DataArrayInt::Meld(dai1,dai3);
+ CPPUNIT_ASSERT_EQUAL(5,dai4->getNumberOfComponents());
+ CPPUNIT_ASSERT_EQUAL(7,dai4->getNumberOfTuples());
+ CPPUNIT_ASSERT(dai4->getInfoOnComponent(0)=="c0da1");
+ CPPUNIT_ASSERT(dai4->getInfoOnComponent(1)=="c1da1");
+ CPPUNIT_ASSERT(dai4->getInfoOnComponent(2)=="c0da3");
+ CPPUNIT_ASSERT(dai4->getInfoOnComponent(3)=="c1da3");
+ CPPUNIT_ASSERT(dai4->getInfoOnComponent(4)=="c2da3");
+ for(int i=0;i<35;i++)
+ CPPUNIT_ASSERT_EQUAL((int)expected1[i],dai4->getIJ(0,i));
+ //
+ dai4->decrRef();
+ da4->decrRef();
+ dai3->decrRef();
+ dai1->decrRef();
+ da1C->decrRef();
+ da1->decrRef();
+ da2->decrRef();
+ da3->decrRef();
+}
+
+void MEDCouplingBasicsTest::testFieldMeld1()
+{
+ MEDCouplingUMesh *m=build3DSurfTargetMesh_1();
+ MEDCouplingFieldDouble *f1=MEDCouplingFieldDouble::New(ON_CELLS,ONE_TIME);
+ f1->setMesh(m);
+ DataArrayDouble *da1=DataArrayDouble::New();
+ const double arr1[5]={12.,23.,34.,45.,56.};
+ da1->alloc(5,1);
+ std::copy(arr1,arr1+5,da1->getPointer());
+ da1->setInfoOnComponent(0,"aaa");
+ f1->setArray(da1);
+ f1->setTime(3.4,2,1);
+ f1->checkCoherency();
+ //
+ MEDCouplingFieldDouble *f2=f1->deepCpy();
+ f2->setMesh(f1->getMesh());
+ f2->checkCoherency();
+ f2->changeNbOfComponents(2,5.);
+ (*f2)=5.;
+ f2->getArray()->setInfoOnComponent(0,"bbb");
+ f2->getArray()->setInfoOnComponent(1,"ccc");
+ f2->checkCoherency();
+ //
+ MEDCouplingFieldDouble *f3=MEDCouplingFieldDouble::MeldFields(f2,f1);
+ f3->checkCoherency();
+ CPPUNIT_ASSERT_EQUAL(5,f3->getNumberOfTuples());
+ CPPUNIT_ASSERT_EQUAL(3,f3->getNumberOfComponents());
+ CPPUNIT_ASSERT(f3->getArray()->getInfoOnComponent(0)=="bbb");
+ CPPUNIT_ASSERT(f3->getArray()->getInfoOnComponent(1)=="ccc");
+ CPPUNIT_ASSERT(f3->getArray()->getInfoOnComponent(2)=="aaa");
+ const double expected1[15]={5.,5.,12.,5.,5.,23.,5.,5.,34.,5.,5.,45.,5.,5.,56.};
+ for(int i=0;i<15;i++)
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1[i],f3->getIJ(0,i),1e-12);
+ int dt,it;
+ double time=f3->getTime(dt,it);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(3.4,time,1e-14);
+ CPPUNIT_ASSERT_EQUAL(2,dt);
+ CPPUNIT_ASSERT_EQUAL(1,it);
+ //
+ MEDCouplingFieldDouble *f4=f2->buildNewTimeReprFromThis(NO_TIME,false);
+ MEDCouplingFieldDouble *f5=f1->buildNewTimeReprFromThis(NO_TIME,false);
+ MEDCouplingFieldDouble *f6=MEDCouplingFieldDouble::MeldFields(f4,f5);
+ f6->checkCoherency();
+ CPPUNIT_ASSERT_EQUAL(5,f6->getNumberOfTuples());
+ CPPUNIT_ASSERT_EQUAL(3,f6->getNumberOfComponents());
+ CPPUNIT_ASSERT(f6->getArray()->getInfoOnComponent(0)=="bbb");
+ CPPUNIT_ASSERT(f6->getArray()->getInfoOnComponent(1)=="ccc");
+ CPPUNIT_ASSERT(f6->getArray()->getInfoOnComponent(2)=="aaa");
+ for(int i=0;i<15;i++)
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1[i],f6->getIJ(0,i),1e-12);
+ //
+ f6->decrRef();
+ f4->decrRef();
+ f5->decrRef();
+ f3->decrRef();
+ da1->decrRef();
+ f2->decrRef();
+ f1->decrRef();
+ m->decrRef();
+}
+
+void MEDCouplingBasicsTest::testMergeNodes2()
+{
+ MEDCouplingUMesh *m1=build2DTargetMesh_1();
+ MEDCouplingUMesh *m2=build2DTargetMesh_1();
+ const double vec[2]={0.002,0.};
+ m2->translate(vec);
+ //
+ std::vector<const MEDCouplingUMesh *> tmp(2);
+ tmp[0]=m1;
+ tmp[1]=m2;
+ MEDCouplingUMesh *m3=MEDCouplingUMesh::MergeUMeshes(tmp);
+ bool b;
+ int newNbOfNodes;
+ DataArrayInt *da=m3->mergeNodes2(0.01,b,newNbOfNodes);
+ CPPUNIT_ASSERT_EQUAL(9,m3->getNumberOfNodes());
+ const double expected1[18]={-0.299,-0.3, 0.201,-0.3, 0.701,-0.3, -0.299,0.2, 0.201,0.2, 0.701,0.2, -0.299,0.7, 0.201,0.7, 0.701,0.7};
+ for(int i=0;i<18;i++)
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1[i],m3->getCoords()->getIJ(0,i),1e-13);
+ //
+ da->decrRef();
+ m3->decrRef();
+ m1->decrRef();
+ m2->decrRef();
+}
+
+void MEDCouplingBasicsTest::testMergeField2()
+{
+ MEDCouplingUMesh *m=build2DTargetMesh_1();
+ MEDCouplingFieldDouble *f1=MEDCouplingFieldDouble::New(ON_CELLS,ONE_TIME);
+ f1->setMesh(m);
+ DataArrayDouble *arr=DataArrayDouble::New();
+ arr->alloc(5,2);
+ arr->fillWithValue(2.);
+ f1->setArray(arr);
+ arr->decrRef();
+ MEDCouplingFieldDouble *f2=MEDCouplingFieldDouble::New(ON_CELLS,ONE_TIME);
+ f2->setMesh(m);
+ arr=DataArrayDouble::New();
+ arr->alloc(5,2);
+ arr->fillWithValue(5.);
+ f2->setArray(arr);
+ arr->decrRef();
+ MEDCouplingFieldDouble *f3=MEDCouplingFieldDouble::New(ON_CELLS,ONE_TIME);
+ f3->setMesh(m);
+ arr=DataArrayDouble::New();
+ arr->alloc(5,2);
+ arr->fillWithValue(7.);
+ f3->setArray(arr);
+ arr->decrRef();
+ //
+ std::vector<const MEDCouplingFieldDouble *> tmp(3);
+ tmp[0]=f1; tmp[1]=f2; tmp[2]=f3;
+ MEDCouplingFieldDouble *f4=MEDCouplingFieldDouble::MergeFields(tmp);
+ CPPUNIT_ASSERT_EQUAL(15,f4->getMesh()->getNumberOfCells());
+ const double expected1[30]={2.,2.,2.,2.,2.,2.,2.,2.,2.,2., 5.,5.,5.,5.,5.,5.,5.,5.,5.,5., 7.,7.,7.,7.,7.,7.,7.,7.,7.,7.};
+ for(int i=0;i<30;i++)
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1[i],f4->getIJ(0,i),1.e-13);
+ //
+ f4->decrRef();
+ f1->decrRef();
+ f2->decrRef();
+ f3->decrRef();
+ m->decrRef();
+}
+
+void MEDCouplingBasicsTest::testDAIBuildComplement1()
+{
+ DataArrayInt *a=DataArrayInt::New();
+ const int tab[4]={3,1,7,8};
+ a->alloc(4,1);
+ std::copy(tab,tab+4,a->getPointer());
+ DataArrayInt *b=a->buildComplement(12);
+ CPPUNIT_ASSERT_EQUAL(8,b->getNumberOfTuples());
+ CPPUNIT_ASSERT_EQUAL(1,b->getNumberOfComponents());
+ const int expected1[8]={0,2,4,5,6,9,10,11};
+ for(int i=0;i<8;i++)
+ CPPUNIT_ASSERT_EQUAL(expected1[i],b->getIJ(0,i));
+ b->decrRef();
+ a->decrRef();
+}
+
+void MEDCouplingBasicsTest::testDAIBuildUnion1()
+{
+ DataArrayInt *a=DataArrayInt::New();
+ const int tab1[4]={3,1,7,8};
+ a->alloc(4,1);
+ std::copy(tab1,tab1+4,a->getPointer());
+ DataArrayInt *c=DataArrayInt::New();
+ const int tab2[5]={5,3,0,18,8};
+ c->alloc(5,1);
+ std::copy(tab2,tab2+5,c->getPointer());
+ DataArrayInt *b=a->buildUnion(c);
+ CPPUNIT_ASSERT_EQUAL(7,b->getNumberOfTuples());
+ CPPUNIT_ASSERT_EQUAL(1,b->getNumberOfComponents());
+ const int expected1[7]={0,1,3,5,7,8,18};
+ for(int i=0;i<7;i++)
+ CPPUNIT_ASSERT_EQUAL(expected1[i],b->getIJ(0,i));
+ c->decrRef();
+ b->decrRef();
+ a->decrRef();
+}
+
+void MEDCouplingBasicsTest::testDAIBuildIntersection1()
+{
+ DataArrayInt *a=DataArrayInt::New();
+ const int tab1[4]={3,1,7,8};
+ a->alloc(4,1);
+ std::copy(tab1,tab1+4,a->getPointer());
+ DataArrayInt *c=DataArrayInt::New();
+ const int tab2[5]={5,3,0,18,8};
+ c->alloc(5,1);
+ std::copy(tab2,tab2+5,c->getPointer());
+ DataArrayInt *b=a->buildIntersection(c);
+ CPPUNIT_ASSERT_EQUAL(2,b->getNumberOfTuples());
+ CPPUNIT_ASSERT_EQUAL(1,b->getNumberOfComponents());
+ const int expected1[2]={3,8};
+ for(int i=0;i<2;i++)
+ CPPUNIT_ASSERT_EQUAL(expected1[i],b->getIJ(0,i));
+ c->decrRef();
+ b->decrRef();
+ a->decrRef();
+}
+
+void MEDCouplingBasicsTest::testDAIDeltaShiftIndex1()
+{
+ DataArrayInt *a=DataArrayInt::New();
+ const int tab[7]={1,3,6,7,7,9,15};
+ a->alloc(7,1);
+ std::copy(tab,tab+7,a->getPointer());
+ DataArrayInt *b=a->deltaShiftIndex();
+ CPPUNIT_ASSERT_EQUAL(6,b->getNumberOfTuples());
+ CPPUNIT_ASSERT_EQUAL(1,b->getNumberOfComponents());
+ const int expected1[6]={2,3,1,0,2,6};
+ for(int i=0;i<6;i++)
+ CPPUNIT_ASSERT_EQUAL(expected1[i],b->getIJ(0,i));
+ b->decrRef();
+ a->decrRef();
+}
+
+void MEDCouplingBasicsTest::testDaDoubleSelectByTupleIdSafe1()
+{
+ DataArrayDouble *a=DataArrayDouble::New();
+ a->alloc(7,2);
+ a->setInfoOnComponent(0,"toto");
+ a->setInfoOnComponent(1,"tata");
+ const double arr1[14]={1.1,11.1,2.1,12.1,3.1,13.1,4.1,14.1,5.1,15.1,6.1,16.1,7.1,17.1};
+ std::copy(arr1,arr1+14,a->getPointer());
+ //
+ const int arr2[7]={4,2,0,6,5};
+ DataArrayDouble *b=a->selectByTupleIdSafe(arr2,arr2+5);
+ CPPUNIT_ASSERT_EQUAL(5,b->getNumberOfTuples());
+ CPPUNIT_ASSERT_EQUAL(2,b->getNumberOfComponents());
+ CPPUNIT_ASSERT(std::string(b->getInfoOnComponent(0))=="toto");
+ CPPUNIT_ASSERT(std::string(b->getInfoOnComponent(1))=="tata");
+ const double expected1[10]={5.1,15.1,3.1,13.1,1.1,11.1,7.1,17.1,6.1,16.1};
+ for(int i=0;i<10;i++)
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1[i],b->getIJ(0,i),1e-14);
+ const int arr4[5]={4,-1,0,6,5};
+ CPPUNIT_ASSERT_THROW(a->selectByTupleIdSafe(arr4,arr4+5),INTERP_KERNEL::Exception);
+ const int arr5[5]={4,2,0,6,7};
+ CPPUNIT_ASSERT_THROW(a->selectByTupleIdSafe(arr5,arr5+5),INTERP_KERNEL::Exception);
+ b->decrRef();
+ a->decrRef();
+ //
+ DataArrayInt *c=DataArrayInt::New();
+ c->alloc(7,2);
+ c->setInfoOnComponent(0,"toto");
+ c->setInfoOnComponent(1,"tata");
+ const int arr3[14]={1,11,2,12,3,13,4,14,5,15,6,16,7,17};
+ std::copy(arr3,arr3+14,c->getPointer());
+ DataArrayInt *d=c->selectByTupleIdSafe(arr2,arr2+5);
+ CPPUNIT_ASSERT_EQUAL(5,d->getNumberOfTuples());
+ CPPUNIT_ASSERT_EQUAL(2,d->getNumberOfComponents());
+ CPPUNIT_ASSERT(std::string(d->getInfoOnComponent(0))=="toto");
+ CPPUNIT_ASSERT(std::string(d->getInfoOnComponent(1))=="tata");
+ const int expected2[10]={5,15,3,13,1,11,7,17,6,16};
+ for(int i=0;i<10;i++)
+ CPPUNIT_ASSERT_EQUAL(expected2[i],d->getIJ(0,i));
+ CPPUNIT_ASSERT_THROW(c->selectByTupleIdSafe(arr4,arr4+5),INTERP_KERNEL::Exception);
+ CPPUNIT_ASSERT_THROW(c->selectByTupleIdSafe(arr5,arr5+5),INTERP_KERNEL::Exception);
+ c->decrRef();
+ d->decrRef();
+}
+
+void MEDCouplingBasicsTest::testAreCellsIncludedIn1()
+{
+ MEDCouplingUMesh *m=build3DSurfTargetMesh_1();
+ const int pt[2]={1,3};
+ MEDCouplingUMesh *m2=(MEDCouplingUMesh *)m->buildPartOfMySelf(pt,pt+2,true);
+ DataArrayInt *tmp;
+ CPPUNIT_ASSERT(m->areCellsIncludedIn(m2,0,tmp));
+ CPPUNIT_ASSERT_EQUAL(2,tmp->getNumberOfTuples());
+ CPPUNIT_ASSERT_EQUAL(1,tmp->getNumberOfComponents());
+ CPPUNIT_ASSERT_EQUAL(pt[0],tmp->getIJ(0,0));
+ CPPUNIT_ASSERT_EQUAL(pt[1],tmp->getIJ(0,1));
+ tmp->decrRef();
+ CPPUNIT_ASSERT(!m2->areCellsIncludedIn(m,0,tmp));
+ tmp->decrRef();
+ m2->decrRef();
+ m->decrRef();
+}
+
+void MEDCouplingBasicsTest::testDAIBuildSubstraction1()
+{
+ DataArrayInt *a=DataArrayInt::New();
+ const int aa[]={2,3,6,8,9};
+ a->alloc(5,1);
+ std::copy(aa,aa+5,a->getPointer());
+ DataArrayInt *b=DataArrayInt::New();
+ const int bb[]={1,3,5,9,11};
+ b->alloc(5,1);
+ std::copy(bb,bb+5,b->getPointer());
+ //
+ DataArrayInt *c=a->buildSubstraction(b);
+ CPPUNIT_ASSERT_EQUAL(3,c->getNumberOfTuples());
+ CPPUNIT_ASSERT_EQUAL(1,c->getNumberOfComponents());
+ const int expected1[3]={2,6,8};
+ CPPUNIT_ASSERT(std::equal(expected1,expected1+3,c->getConstPointer()));
+ //
+ c->decrRef();
+ b->decrRef();
+ a->decrRef();
+}
+
+void MEDCouplingBasicsTest::testBuildOrthogonalField2()
+{
+ MEDCouplingUMesh *m=build2DTargetMesh_1();
+ DataArrayInt *d1=DataArrayInt::New();
+ DataArrayInt *d2=DataArrayInt::New();
+ DataArrayInt *d3=DataArrayInt::New();
+ DataArrayInt *d4=DataArrayInt::New();
+ MEDCouplingUMesh *m1=m->buildDescendingConnectivity(d1,d2,d3,d4);
+ //
+ MEDCouplingFieldDouble *f1=m1->buildOrthogonalField();
+ DataArrayDouble *da1=f1->getArray();
+ CPPUNIT_ASSERT_EQUAL(2,da1->getNumberOfComponents());
+ CPPUNIT_ASSERT_EQUAL(13,da1->getNumberOfTuples());
+ //
+ const double expected1[26]={-1.,0.,0.,1.,1.,0.,0.,-1.,0.707106781186548,0.707106781186548,0.,-1.,0.,1.,1.,0.,0.,1.,1.,0.,-1.,0.,0.,1.,1.,0.};
+ for(int i=0;i<26;i++)
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1[i],da1->getIJ(0,i),1e-14);
+ //
+ f1->decrRef();
+ m1->decrRef();
+ d1->decrRef();
+ d2->decrRef();
+ d3->decrRef();
+ d4->decrRef();
+ m->decrRef();
+}
+
+void MEDCouplingBasicsTest::testUMInsertNextCell1()
+{
+ double targetCoords[18]={-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 };
+ int targetConn[18]={0,3,4,1, 1,4,2, 4,5,2, 6,7,4,3, 7,8,5,4};
+ MEDCouplingUMesh *targetMesh=MEDCouplingUMesh::New();
+ targetMesh->allocateCells(5);
+ CPPUNIT_ASSERT_THROW(targetMesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,targetConn),INTERP_KERNEL::Exception);
+ targetMesh->setMeshDimension(2);
+ targetMesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,targetConn);
+ CPPUNIT_ASSERT_THROW(targetMesh->insertNextCell(INTERP_KERNEL::NORM_TETRA4,4,targetConn),INTERP_KERNEL::Exception);
+ CPPUNIT_ASSERT_THROW(targetMesh->insertNextCell(INTERP_KERNEL::NORM_SEG2,2,targetConn),INTERP_KERNEL::Exception);
+ CPPUNIT_ASSERT_THROW(targetMesh->insertNextCell(INTERP_KERNEL::NORM_POINT1,1,targetConn),INTERP_KERNEL::Exception);
+ targetMesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,targetConn+4);
+ targetMesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,targetConn+7);
+ targetMesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,targetConn+10);
+ targetMesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,targetConn+14);
+ targetMesh->finishInsertingCells();
+ DataArrayDouble *myCoords=DataArrayDouble::New();
+ myCoords->alloc(9,2);
+ std::copy(targetCoords,targetCoords+18,myCoords->getPointer());
+ targetMesh->setCoords(myCoords);
+ myCoords->decrRef();
+ targetMesh->checkCoherency();
+ targetMesh->decrRef();
+}
+
+void MEDCouplingBasicsTest::testFieldOperatorDivDiffComp1()
+{
+ MEDCouplingUMesh *m=build2DTargetMesh_1();
+ DataArrayInt *d1=DataArrayInt::New();
+ DataArrayInt *d2=DataArrayInt::New();
+ DataArrayInt *d3=DataArrayInt::New();
+ DataArrayInt *d4=DataArrayInt::New();
+ MEDCouplingUMesh *m1=m->buildDescendingConnectivity(d1,d2,d3,d4);
+ //
+ MEDCouplingFieldDouble *f1=m1->buildOrthogonalField();
+ const double arr1[13]={2.,3.,4.,5.,6.,7.,8.,9.,10.,11.,12.,13.,14.};
+ DataArrayDouble *arr=DataArrayDouble::New();
+ arr->alloc(13,1);
+ std::copy(arr1,arr1+13,arr->getPointer());
+ MEDCouplingFieldDouble *f2=MEDCouplingFieldDouble::New(ON_CELLS);
+ f2->setArray(arr);
+ f2->setMesh(m1);
+ f2->checkCoherency();
+ //
+ MEDCouplingFieldDouble *f3=(*f1)/(*f2);
+ CPPUNIT_ASSERT_THROW((*f2)/(*f1),INTERP_KERNEL::Exception);
+ f3->checkCoherency();
+ (*f1)/=(*f2);
+ CPPUNIT_ASSERT(f1->isEqual(f3,1e-10,1e-10));
+ CPPUNIT_ASSERT_THROW((*f2)/=(*f1),INTERP_KERNEL::Exception);
+ const double expected1[26]={-0.5, 0.0, 0.0, 0.33333333333333331, 0.25, 0.0, 0.0, -0.20000000000000001, 0.117851130197758, 0.117851130197758, 0.0, -0.14285714285714285, 0.0, 0.125, 0.1111111111111111, 0.0, 0.0, 0.10000000000000001, 0.090909090909090912, 0.0, -0.083333333333333329, 0.0, 0.0, 0.076923076923076927, 0.071428571428571425, 0.0};
+ for(int i=0;i<26;i++)
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1[i],f3->getIJ(0,i),1e-10);
+ //
+ f3->decrRef();
+ f2->decrRef();
+ arr->decrRef();
+ f1->decrRef();
+ m1->decrRef();
+ d1->decrRef();
+ d2->decrRef();
+ d3->decrRef();
+ d4->decrRef();
+ m->decrRef();
+}
+
+void MEDCouplingBasicsTest::testDARearrange1()
+{
+ DataArrayInt *da1=DataArrayInt::New();
+ da1->alloc(12,1);
+ da1->iota(0);
+ const int *ptr=da1->getConstPointer();
+ //
+ CPPUNIT_ASSERT_EQUAL(12,da1->getNbOfElems());
+ CPPUNIT_ASSERT_EQUAL(1,da1->getNumberOfComponents());
+ CPPUNIT_ASSERT_EQUAL(12,da1->getNumberOfTuples());
+ da1->rearrange(4);
+ CPPUNIT_ASSERT(ptr==da1->getConstPointer());
+ CPPUNIT_ASSERT_EQUAL(12,da1->getNbOfElems());
+ CPPUNIT_ASSERT_EQUAL(4,da1->getNumberOfComponents());
+ CPPUNIT_ASSERT_EQUAL(3,da1->getNumberOfTuples());
+ for(int i=0;i<12;i++)
+ CPPUNIT_ASSERT_EQUAL(i,da1->getIJ(0,i));
+ //
+ da1->rearrange(6);
+ CPPUNIT_ASSERT(ptr==da1->getConstPointer());
+ CPPUNIT_ASSERT_EQUAL(12,da1->getNbOfElems());
+ CPPUNIT_ASSERT_EQUAL(6,da1->getNumberOfComponents());
+ CPPUNIT_ASSERT_EQUAL(2,da1->getNumberOfTuples());
+ for(int i=0;i<12;i++)
+ CPPUNIT_ASSERT_EQUAL(i,da1->getIJ(0,i));
+ //
+ CPPUNIT_ASSERT_THROW(da1->rearrange(7),INTERP_KERNEL::Exception);
+ //
+ da1->rearrange(12);
+ CPPUNIT_ASSERT(ptr==da1->getConstPointer());
+ CPPUNIT_ASSERT_EQUAL(12,da1->getNbOfElems());
+ CPPUNIT_ASSERT_EQUAL(12,da1->getNumberOfComponents());
+ CPPUNIT_ASSERT_EQUAL(1,da1->getNumberOfTuples());
+ for(int i=0;i<12;i++)
+ CPPUNIT_ASSERT_EQUAL(i,da1->getIJ(0,i));
+ //
+ da1->rearrange(3);
+ CPPUNIT_ASSERT(ptr==da1->getConstPointer());
+ CPPUNIT_ASSERT_EQUAL(12,da1->getNbOfElems());
+ CPPUNIT_ASSERT_EQUAL(3,da1->getNumberOfComponents());
+ CPPUNIT_ASSERT_EQUAL(4,da1->getNumberOfTuples());
+ for(int i=0;i<12;i++)
+ CPPUNIT_ASSERT_EQUAL(i,da1->getIJ(0,i));
+ //double
+ DataArrayDouble *da2=da1->convertToDblArr();
+ da1->decrRef();
+ const double *ptr2=da2->getConstPointer();
+ //
+ CPPUNIT_ASSERT_EQUAL(12,da2->getNbOfElems());
+ CPPUNIT_ASSERT_EQUAL(3,da2->getNumberOfComponents());
+ CPPUNIT_ASSERT_EQUAL(4,da2->getNumberOfTuples());
+ da2->rearrange(4);
+ CPPUNIT_ASSERT(ptr2==da2->getConstPointer());
+ CPPUNIT_ASSERT_EQUAL(12,da2->getNbOfElems());
+ CPPUNIT_ASSERT_EQUAL(4,da2->getNumberOfComponents());
+ CPPUNIT_ASSERT_EQUAL(3,da2->getNumberOfTuples());
+ for(int i=0;i<12;i++)
+ CPPUNIT_ASSERT_DOUBLES_EQUAL((double)i,da2->getIJ(0,i),1e-14);
+ //
+ da2->rearrange(6);
+ CPPUNIT_ASSERT(ptr2==da2->getConstPointer());
+ CPPUNIT_ASSERT_EQUAL(12,da2->getNbOfElems());
+ CPPUNIT_ASSERT_EQUAL(6,da2->getNumberOfComponents());
+ CPPUNIT_ASSERT_EQUAL(2,da2->getNumberOfTuples());
+ for(int i=0;i<12;i++)
+ CPPUNIT_ASSERT_DOUBLES_EQUAL((double)i,da2->getIJ(0,i),1e-14);
+ //
+ CPPUNIT_ASSERT_THROW(da2->rearrange(7),INTERP_KERNEL::Exception);
+ //
+ da2->rearrange(1);
+ CPPUNIT_ASSERT(ptr2==da2->getConstPointer());
+ CPPUNIT_ASSERT_EQUAL(12,da2->getNbOfElems());
+ CPPUNIT_ASSERT_EQUAL(1,da2->getNumberOfComponents());
+ CPPUNIT_ASSERT_EQUAL(12,da2->getNumberOfTuples());
+ for(int i=0;i<12;i++)
+ CPPUNIT_ASSERT_DOUBLES_EQUAL((double)i,da2->getIJ(0,i),1e-14);
+ //
+ da2->rearrange(3);
+ CPPUNIT_ASSERT(ptr2==da2->getConstPointer());
+ CPPUNIT_ASSERT_EQUAL(12,da2->getNbOfElems());
+ CPPUNIT_ASSERT_EQUAL(3,da2->getNumberOfComponents());
+ CPPUNIT_ASSERT_EQUAL(4,da2->getNumberOfTuples());
+ for(int i=0;i<12;i++)
+ CPPUNIT_ASSERT_DOUBLES_EQUAL((double)i,da2->getIJ(0,i),1e-14);
+ da2->decrRef();
+}
+
+void MEDCouplingBasicsTest::testGetDifferentValues1()
+{
+ DataArrayInt *da1=DataArrayInt::New();
+ const int arr[12]={1,2,3,2,2,3,5,1,5,5,2,2};
+ da1->alloc(4,3);
+ std::copy(arr,arr+12,da1->getPointer());
+ std::set<int> s=da1->getDifferentValues();
+ const int expected1[4]={1,2,3,5};
+ CPPUNIT_ASSERT_EQUAL(4,(int)s.size());
+ CPPUNIT_ASSERT(std::equal(expected1,expected1+4,s.begin()));
+ da1->decrRef();
+}
+
+void MEDCouplingBasicsTest::testDAIBuildPermutationArr1()
+{
+ DataArrayInt *a=DataArrayInt::New();
+ const int vala[5]={4,5,6,7,8};
+ a->alloc(5,1);
+ std::copy(vala,vala+5,a->getPointer());
+ DataArrayInt *b=DataArrayInt::New();
+ const int valb[5]={5,4,8,6,7};
+ b->alloc(5,1);
+ std::copy(valb,valb+5,b->getPointer());
+ DataArrayInt *c=a->buildPermutationArr(*b);
+ const int expect1[5]={1,0,4,2,3};
+ CPPUNIT_ASSERT_EQUAL(5,c->getNumberOfTuples());
+ CPPUNIT_ASSERT_EQUAL(1,c->getNumberOfComponents());
+ CPPUNIT_ASSERT(std::equal(expect1,expect1+5,c->getConstPointer()));
+ CPPUNIT_ASSERT(a->isEqualWithoutConsideringStrAndOrder(*b));
+ b->setIJ(0,0,9);
+ CPPUNIT_ASSERT(!a->isEqualWithoutConsideringStrAndOrder(*b));
+ CPPUNIT_ASSERT_THROW(a->buildPermutationArr(*b),INTERP_KERNEL::Exception);
+ a->setIJ(3,0,4);
+ b->setIJ(0,0,5);
+ b->setIJ(4,0,4);//;a==[4,5,6,4,8] and b==[5,4,8,6,4]
+ CPPUNIT_ASSERT(a->isEqualWithoutConsideringStrAndOrder(*b));
+ c->decrRef();
+ c=a->buildPermutationArr(*b);
+ const int expect2[5]={1,3,4,2,3};
+ CPPUNIT_ASSERT(std::equal(expect2,expect2+5,c->getConstPointer()));
+ DataArrayDouble *d=b->convertToDblArr();
+ b->sort();
+ const int expect3[5]={4,4,5,6,8};
+ CPPUNIT_ASSERT(std::equal(expect3,expect3+5,b->getConstPointer()));
+ d->sort();
+ CPPUNIT_ASSERT_EQUAL(5,d->getNumberOfTuples());
+ CPPUNIT_ASSERT_EQUAL(1,d->getNumberOfComponents());
+ for(int i=0;i<5;i++)
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(double(expect3[i]),d->getIJ(i,0),1e-14);
+ //
+ d->decrRef();
+ c->decrRef();
+ a->decrRef();
+ b->decrRef();
+}
+
+void MEDCouplingBasicsTest::testAreCellsIncludedIn2()
+{
+ const char myName[]="Vitoo";
+ MEDCouplingUMesh *m=build3DSurfTargetMesh_1();
+ MEDCouplingUMesh *m2=(MEDCouplingUMesh *)m->buildPartOfMySelf(0,0,true);
+ CPPUNIT_ASSERT_EQUAL(0,m2->getNumberOfCells());
+ CPPUNIT_ASSERT_EQUAL(3,m2->getSpaceDimension());
+ CPPUNIT_ASSERT_EQUAL(2,m2->getMeshDimension());
+ m2->setName(myName);
+ DataArrayInt *tmp;
+ CPPUNIT_ASSERT(m->areCellsIncludedIn(m2,0,tmp));
+ CPPUNIT_ASSERT(std::string(myName)==tmp->getName());
+ CPPUNIT_ASSERT_EQUAL(0,tmp->getNumberOfTuples());
+ CPPUNIT_ASSERT_EQUAL(1,tmp->getNumberOfComponents());
+ m->decrRef();
+ m2->decrRef();
+ tmp->decrRef();
+}
+
+void MEDCouplingBasicsTest::testUMeshGetPartBarycenterAndOwner1()
+{
+ MEDCouplingUMesh *m1=build2DTargetMesh_1();
+ const int part[3]={1,0,4};
+ DataArrayDouble *b=m1->getPartBarycenterAndOwner(part,part+3);
+ CPPUNIT_ASSERT_EQUAL(2,b->getNumberOfComponents());
+ CPPUNIT_ASSERT_EQUAL(3,b->getNumberOfTuples());
+ const double expected1[6]={0.36666666666666665,-0.13333333333333333,-0.05,-0.05,0.45,0.45};
+ for(int i=0;i<6;i++)
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1[i],b->getIJ(0,i),1e-14);
+ b->decrRef();
+ m1->decrRef();
+}
+
+void MEDCouplingBasicsTest::testUMeshGetPartMeasureField1()
+{
+ MEDCouplingUMesh *m1=build2DTargetMesh_1();
+ const int part[3]={1,0,4};
+ DataArrayDouble *b=m1->getPartMeasureField(true,part,part+3);
+ CPPUNIT_ASSERT_EQUAL(1,b->getNumberOfComponents());
+ CPPUNIT_ASSERT_EQUAL(3,b->getNumberOfTuples());
+ const double expected1[3]={0.125,0.25,0.25};
+ for(int i=0;i<3;i++)
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1[i],b->getIJ(0,i),1e-14);
+ b->decrRef();
+ m1->decrRef();
+}
+
+void MEDCouplingBasicsTest::testUMeshBuildPartOrthogonalField1()
+{
+ MEDCouplingUMesh *m1=build2DTargetMesh_1();
+ m1->changeSpaceDimension(3);
+ const int part[3]={1,0,4};
+ MEDCouplingFieldDouble *b=m1->buildPartOrthogonalField(part,part+3);
+ CPPUNIT_ASSERT_EQUAL(3,b->getArray()->getNumberOfComponents());
+ CPPUNIT_ASSERT_EQUAL(3,b->getArray()->getNumberOfTuples());
+ const double expected1[9]={0.,0.,-1.,0.,0.,-1.,0.,0.,-1.};
+ for(int i=0;i<9;i++)
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1[i],b->getArray()->getIJ(0,i),1e-14);
+ b->decrRef();
+ m1->decrRef();
+}
+
+void MEDCouplingBasicsTest::testUMeshGetTypesOfPart1()
+{
+ MEDCouplingUMesh *m1=build2DTargetMesh_1();
+ const int part1[]={0,3,4};
+ std::set<INTERP_KERNEL::NormalizedCellType> s;
+ s=m1->getTypesOfPart(part1,part1+3);
+ CPPUNIT_ASSERT(s.size()==1);
+ CPPUNIT_ASSERT(*s.begin()==INTERP_KERNEL::NORM_QUAD4);
+ const int part2[]={2,2,2,1};
+ s=m1->getTypesOfPart(part2,part2+4);
+ CPPUNIT_ASSERT(s.size()==1);
+ CPPUNIT_ASSERT(*s.begin()==INTERP_KERNEL::NORM_TRI3);
+ const int part3[]={3,2,1};
+ s=m1->getTypesOfPart(part3,part3+3);
+ CPPUNIT_ASSERT(s.size()==2);
+ CPPUNIT_ASSERT(*s.begin()==INTERP_KERNEL::NORM_TRI3);
+ CPPUNIT_ASSERT(*(++s.begin())==INTERP_KERNEL::NORM_QUAD4);
+ m1->decrRef();
+}
+
+void MEDCouplingBasicsTest::testUMeshKeepCellIdsByType1()
+{
+ MEDCouplingUMesh *m1=build2DTargetMesh_1();
+ const int part1[3]={0,3,4};
+ DataArrayInt *a=m1->keepCellIdsByType(INTERP_KERNEL::NORM_TRI3,part1,part1+3);
+ CPPUNIT_ASSERT_EQUAL(1,a->getNumberOfComponents());
+ CPPUNIT_ASSERT_EQUAL(0,a->getNumberOfTuples());
+ a->decrRef();
+ //
+ const int part2[5]={3,2,0,2,4};
+ a=m1->keepCellIdsByType(INTERP_KERNEL::NORM_TRI3,part2,part2+5);
+ CPPUNIT_ASSERT_EQUAL(1,a->getNumberOfComponents());
+ CPPUNIT_ASSERT_EQUAL(2,a->getNumberOfTuples());
+ CPPUNIT_ASSERT_EQUAL(2,a->getIJ(0,0));
+ CPPUNIT_ASSERT_EQUAL(2,a->getIJ(1,0));
+ a->decrRef();
+ //
+ a=m1->keepCellIdsByType(INTERP_KERNEL::NORM_QUAD4,part2,part2+5);
+ CPPUNIT_ASSERT_EQUAL(1,a->getNumberOfComponents());
+ CPPUNIT_ASSERT_EQUAL(3,a->getNumberOfTuples());
+ CPPUNIT_ASSERT_EQUAL(3,a->getIJ(0,0));
+ CPPUNIT_ASSERT_EQUAL(0,a->getIJ(1,0));
+ CPPUNIT_ASSERT_EQUAL(4,a->getIJ(2,0));
+ //
+ a->decrRef();
+ m1->decrRef();
+}
+
+void MEDCouplingBasicsTest::testDAIAggregateMulti1()
+{
+ DataArrayInt *a=DataArrayInt::New();
+ a->setName("aa");
+ a->alloc(4,1);
+ a->iota(0);
+ a->rearrange(2);
+ DataArrayInt *b=DataArrayInt::New();
+ b->setName("bb");
+ b->alloc(6,1);
+ b->iota(0);
+ b->rearrange(2);
+ //
+ std::vector<const DataArrayInt *> v(2);
+ v[0]=a; v[1]=b;
+ DataArrayInt *c=DataArrayInt::Aggregate(v);
+ CPPUNIT_ASSERT_EQUAL(5,c->getNumberOfTuples());
+ CPPUNIT_ASSERT_EQUAL(2,c->getNumberOfComponents());
+ CPPUNIT_ASSERT(c->getName()=="aa");
+ const int expect1[10]={0,1,2,3,0,1,2,3,4,5};
+ for(int i=0;i<10;i++)
+ CPPUNIT_ASSERT_EQUAL(expect1[i],c->getIJ(0,i));
+ //
+ c->decrRef();
+ a->decrRef();
+ b->decrRef();
+}
+
+void MEDCouplingBasicsTest::testMergeUMeshes2()
+{
+ MEDCouplingUMesh *m1=build3DSurfTargetMesh_1();
+ MEDCouplingUMesh *m2=build3DSurfTargetMesh_1();
+ MEDCouplingUMesh *m3=build3DSurfTargetMesh_1();
+ //
+ const int vec1[3]={0,2,3};
+ MEDCouplingUMesh *m2_2=(MEDCouplingUMesh *)m2->buildPartOfMySelf(vec1,vec1+3,false);
+ const int vec2[2]={1,1};
+ MEDCouplingUMesh *m3_2=(MEDCouplingUMesh *)m3->buildPartOfMySelf(vec2,vec2+2,false);
+ //
+ std::vector<const MEDCouplingUMesh *> ms(3);
+ ms[0]=m1; ms[1]=m2_2; ms[2]=m3_2;
+ //
+ MEDCouplingUMesh *m4=MEDCouplingUMesh::MergeUMeshes(ms);
+ m4->checkCoherency();
+ CPPUNIT_ASSERT_EQUAL(10,m4->getNumberOfCells());
+ CPPUNIT_ASSERT_EQUAL(20,m4->getNumberOfNodes());
+ CPPUNIT_ASSERT_EQUAL(45,m4->getMeshLength());
+ //
+ const int vec3[5]={0,1,2,3,4};
+ MEDCouplingUMesh *m4_1=(MEDCouplingUMesh *)m4->buildPartOfMySelf(vec3,vec3+5,false);
+ m4_1->setName(m1->getName());
+ CPPUNIT_ASSERT(m4_1->isEqual(m1,1e-12));
+ m4_1->decrRef();
+ //
+ const int vec4[3]={5,6,7};
+ MEDCouplingUMesh *m4_2=(MEDCouplingUMesh *)m4->buildPartOfMySelf(vec4,vec4+3,false);
+ DataArrayInt *cellCor=0;
+ DataArrayInt *nodeCor=0;
+ m4_2->checkGeoEquivalWith(m2_2,10,1e-12,cellCor,nodeCor);
+ CPPUNIT_ASSERT(cellCor==0);
+ CPPUNIT_ASSERT(nodeCor==0);
+ m4_2->decrRef();
+ //
+ const int vec5[2]={8,9};
+ MEDCouplingUMesh *m4_3=(MEDCouplingUMesh *)m4->buildPartOfMySelf(vec5,vec5+2,false);
+ CPPUNIT_ASSERT_EQUAL(2,m4_3->getNumberOfCells());
+ CPPUNIT_ASSERT_EQUAL(3,m4_3->getNumberOfNodes());
+ m3_2->zipCoords();
+ m4_3->setName(m3_2->getName());
+ CPPUNIT_ASSERT(m4_3->isEqual(m3_2,1e-12));
+ m4_3->decrRef();
+ //
+ m4->decrRef();
+ m1->decrRef();
+ m2->decrRef();
+ m2_2->decrRef();
+ m3->decrRef();
+ m3_2->decrRef();
+}
+
+void MEDCouplingBasicsTest::testBuild0DMeshFromCoords1()
+{
+ const double sourceCoords[12]={-0.3,-0.3,0., 0.7,-0.3,0., -0.3,0.7,0., 0.7,0.7,0.};
+ DataArrayDouble *coo=DataArrayDouble::New();
+ coo->alloc(4,3);
+ coo->setName("My0D");
+ std::copy(sourceCoords,sourceCoords+12,coo->getPointer());
+ MEDCouplingUMesh *m=MEDCouplingUMesh::Build0DMeshFromCoords(coo);
+ m->checkCoherency();
+ CPPUNIT_ASSERT_EQUAL(4,m->getNumberOfNodes());
+ CPPUNIT_ASSERT_EQUAL(4,m->getNumberOfCells());
+ CPPUNIT_ASSERT_EQUAL(3,m->getSpaceDimension());
+ CPPUNIT_ASSERT_EQUAL(0,m->getMeshDimension());
+ const std::set<INTERP_KERNEL::NormalizedCellType>& types=m->getAllTypes();
+ CPPUNIT_ASSERT_EQUAL(1,(int)types.size());
+ CPPUNIT_ASSERT_EQUAL(INTERP_KERNEL::NORM_POINT1,*types.begin());
+ for(int i=0;i<4;i++)
+ {
+ std::vector<int> conn;
+ m->getNodeIdsOfCell(i,conn);
+ CPPUNIT_ASSERT_EQUAL(1,(int)conn.size());
+ CPPUNIT_ASSERT_EQUAL(i,conn[0]);
+ CPPUNIT_ASSERT(INTERP_KERNEL::NORM_POINT1==m->getTypeOfCell(i));
+ }
+ CPPUNIT_ASSERT(std::string(m->getName())=="My0D");
+ m->decrRef();
+ coo->decrRef();
+}
+
--- /dev/null
+// Copyright (C) 2007-2010 CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#include "MEDCouplingBasicsTest.hxx"
+#include "MEDCouplingUMesh.hxx"
+#include "MEDCouplingCMesh.hxx"
+#include "MEDCouplingExtrudedMesh.hxx"
+#include "MEDCouplingFieldDouble.hxx"
+#include "MEDCouplingMemArray.hxx"
+#include "MEDCouplingGaussLocalization.hxx"
+#include "MEDCouplingMultiFields.hxx"
+#include "MEDCouplingFieldOverTime.hxx"
+
+#include <cmath>
+#include <functional>
+#include <iterator>
+
+using namespace ParaMEDMEM;
+
+void MEDCouplingBasicsTest::testDescriptionInMeshTimeUnit1()
+{
+ static const char text1[]="totoTTEDD";
+ MEDCouplingUMesh *m=build2DTargetMesh_1();
+ m->setDescription(text1);
+ CPPUNIT_ASSERT(std::string(m->getDescription())==text1);
+ MEDCouplingUMesh *m2=(MEDCouplingUMesh *)m->deepCpy();
+ CPPUNIT_ASSERT(m->isEqual(m2,1e-12));
+ CPPUNIT_ASSERT(std::string(m2->getDescription())==text1);
+ m2->setDescription("ggg");
+ CPPUNIT_ASSERT(!m->isEqual(m2,1e-12));
+ m2->decrRef();
+ //
+ MEDCouplingFieldDouble *f=MEDCouplingFieldDouble::New(ON_CELLS,ONE_TIME);
+ f->setTimeUnit(text1);
+ CPPUNIT_ASSERT(std::string(f->getTimeUnit())==text1);
+ MEDCouplingFieldDouble *f2=f->deepCpy();
+ CPPUNIT_ASSERT(std::string(f2->getTimeUnit())==text1);
+ f2->decrRef();
+ //
+ f->decrRef();
+ m->decrRef();
+}
+
+void MEDCouplingBasicsTest::testMultiFields1()
+{
+ MEDCouplingMultiFields *mfs=buildMultiFields_1();
+ std::vector<MEDCouplingMesh *> ms=mfs->getMeshes();
+ std::vector<int> refs;
+ std::vector<MEDCouplingMesh *> dms=mfs->getDifferentMeshes(refs);
+ std::vector<DataArrayDouble *> das=mfs->getArrays();
+ std::vector< std::vector<int> > refs2;
+ std::vector<DataArrayDouble *> das2=mfs->getDifferentArrays(refs2);
+ //
+ CPPUNIT_ASSERT_EQUAL(5,(int)ms.size());
+ CPPUNIT_ASSERT_EQUAL(2,(int)dms.size());
+ CPPUNIT_ASSERT_EQUAL(6,(int)das.size());
+ CPPUNIT_ASSERT_EQUAL(5,(int)das2.size());
+ //
+ MEDCouplingMultiFields *mfs2=mfs->deepCpy();
+ CPPUNIT_ASSERT(mfs->isEqual(mfs2,1e-12,1e-12));
+ mfs2->decrRef();
+ //
+ mfs->decrRef();
+}
+
+void MEDCouplingBasicsTest::testFieldOverTime1()
+{
+ std::vector<MEDCouplingFieldDouble *> fs=buildMultiFields_2();
+ CPPUNIT_ASSERT_THROW(MEDCouplingFieldOverTime::New(fs),INTERP_KERNEL::Exception);
+ MEDCouplingFieldDouble *f4bis=fs[4]->buildNewTimeReprFromThis(ONE_TIME,false);
+ fs[4]->decrRef();
+ fs[4]=f4bis;
+ CPPUNIT_ASSERT_THROW(MEDCouplingFieldOverTime::New(fs),INTERP_KERNEL::Exception);
+ f4bis->setTime(2.7,20,21);
+ MEDCouplingFieldOverTime *fot=MEDCouplingFieldOverTime::New(fs);
+ MEDCouplingDefinitionTime dt=fot->getDefinitionTimeZone();
+ std::vector<double> hs=dt.getHotSpotsTime();
+ CPPUNIT_ASSERT_EQUAL(6,(int)hs.size());
+ const double expected1[]={0.2,0.7,1.2,1.35,1.7,2.7};
+ for(int i=0;i<6;i++)
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1[i],hs[i],1e-12);
+ int meshId,arrId,arrIdInField,fieldId;
+ dt.getIdsOnTimeRight(0.2,meshId,arrId,arrIdInField,fieldId);
+ CPPUNIT_ASSERT_EQUAL(0,meshId);
+ CPPUNIT_ASSERT_EQUAL(0,arrId);
+ CPPUNIT_ASSERT_EQUAL(0,arrIdInField);
+ CPPUNIT_ASSERT_EQUAL(0,fieldId);
+ //
+ dt.getIdsOnTimeRight(0.7,meshId,arrId,arrIdInField,fieldId);
+ CPPUNIT_ASSERT_EQUAL(0,meshId);
+ CPPUNIT_ASSERT_EQUAL(1,arrId);
+ CPPUNIT_ASSERT_EQUAL(0,arrIdInField);
+ CPPUNIT_ASSERT_EQUAL(1,fieldId);
+ //
+ dt.getIdsOnTimeLeft(1.2,meshId,arrId,arrIdInField,fieldId);//**** WARNING left here
+ CPPUNIT_ASSERT_EQUAL(0,meshId);
+ CPPUNIT_ASSERT_EQUAL(2,arrId);
+ CPPUNIT_ASSERT_EQUAL(1,arrIdInField);
+ CPPUNIT_ASSERT_EQUAL(1,fieldId);
+ //
+ dt.getIdsOnTimeRight(1.2,meshId,arrId,arrIdInField,fieldId);//**** WARNING right again here
+ CPPUNIT_ASSERT_EQUAL(1,meshId);
+ CPPUNIT_ASSERT_EQUAL(3,arrId);
+ CPPUNIT_ASSERT_EQUAL(0,arrIdInField);
+ CPPUNIT_ASSERT_EQUAL(2,fieldId);
+ //
+ dt.getIdsOnTimeRight(1.35,meshId,arrId,arrIdInField,fieldId);
+ CPPUNIT_ASSERT_EQUAL(1,meshId);
+ CPPUNIT_ASSERT_EQUAL(3,arrId);
+ CPPUNIT_ASSERT_EQUAL(0,arrIdInField);
+ CPPUNIT_ASSERT_EQUAL(2,fieldId);
+ //
+ dt.getIdsOnTimeRight(1.7,meshId,arrId,arrIdInField,fieldId);
+ CPPUNIT_ASSERT_EQUAL(0,meshId);
+ CPPUNIT_ASSERT_EQUAL(3,arrId);
+ CPPUNIT_ASSERT_EQUAL(0,arrIdInField);
+ CPPUNIT_ASSERT_EQUAL(3,fieldId);
+ //
+ dt.getIdsOnTimeRight(2.7,meshId,arrId,arrIdInField,fieldId);
+ CPPUNIT_ASSERT_EQUAL(1,meshId);
+ CPPUNIT_ASSERT_EQUAL(4,arrId);
+ CPPUNIT_ASSERT_EQUAL(0,arrIdInField);
+ CPPUNIT_ASSERT_EQUAL(4,fieldId);
+ //
+ MEDCouplingDefinitionTime dt2;
+ CPPUNIT_ASSERT(!dt2.isEqual(dt));
+ dt2.assign(dt);
+ dt2.assign(dt);//to check memory management
+ CPPUNIT_ASSERT(dt2.isEqual(dt));
+ //
+ MEDCouplingDefinitionTime dt3;
+ std::vector<int> tmp1;
+ std::vector<double> tmp2;
+ CPPUNIT_ASSERT(!dt2.isEqual(dt3));
+ dt2.getTinySerializationInformation(tmp1,tmp2);
+ dt3.unserialize(tmp1,tmp2);
+ CPPUNIT_ASSERT(dt2.isEqual(dt3));
+ //
+ for(std::vector<MEDCouplingFieldDouble *>::iterator it=fs.begin();it!=fs.end();it++)
+ (*it)->decrRef();
+ fot->decrRef();
+}
+
+void MEDCouplingBasicsTest::testDAICheckAndPreparePermutation1()
+{
+ const int vals1[]={9,10,0,6,4,11,3,7};
+ const int expect1[]={5,6,0,3,2,7,1,4};
+ const int vals2[]={9,10,0,6,10,11,3,7};
+ DataArrayInt *da=DataArrayInt::New();
+ da->alloc(8,1);
+ std::copy(vals1,vals1+8,da->getPointer());
+ DataArrayInt *da2=da->checkAndPreparePermutation();
+ CPPUNIT_ASSERT_EQUAL(8,da2->getNumberOfTuples());
+ CPPUNIT_ASSERT_EQUAL(1,da2->getNumberOfComponents());
+ for(int i=0;i<8;i++)
+ CPPUNIT_ASSERT_EQUAL(expect1[i],da2->getIJ(i,0));
+ da2->decrRef();
+ da->decrRef();
+ //
+ da=DataArrayInt::New();
+ da->alloc(8,1);
+ da->iota(0);
+ da2=da->checkAndPreparePermutation();
+ CPPUNIT_ASSERT_EQUAL(8,da2->getNumberOfTuples());
+ CPPUNIT_ASSERT_EQUAL(1,da2->getNumberOfComponents());
+ CPPUNIT_ASSERT(da2->isIdentity());
+ da2->decrRef();
+ da->decrRef();
+ //
+ da=DataArrayInt::New();
+ da->alloc(8,1);
+ std::copy(vals2,vals2+8,da->getPointer());
+ CPPUNIT_ASSERT_THROW(da->checkAndPreparePermutation(),INTERP_KERNEL::Exception);
+ da->decrRef();
+}
+
+void MEDCouplingBasicsTest::testDAIChangeSurjectiveFormat1()
+{
+ const int vals1[8]={0,3,2,3,2,2,1,2};
+ const int expected1[5]={0,1,2,6,8};
+ const int expected2[8]={0, 6, 2,4,5,7, 1,3};
+ DataArrayInt *da=DataArrayInt::New();
+ da->alloc(8,1);
+ std::copy(vals1,vals1+8,da->getPointer());
+ //
+ DataArrayInt *da2,*da2I;
+ da->changeSurjectiveFormat(4,da2,da2I);
+ CPPUNIT_ASSERT_EQUAL(5,da2I->getNumberOfTuples());
+ CPPUNIT_ASSERT_EQUAL(8,da2->getNumberOfTuples());
+ CPPUNIT_ASSERT(std::equal(expected1,expected1+5,da2I->getConstPointer()));
+ CPPUNIT_ASSERT(std::equal(expected2,expected2+8,da2->getConstPointer()));
+ da2->decrRef();
+ da2I->decrRef();
+ //
+ CPPUNIT_ASSERT_THROW(da->changeSurjectiveFormat(3,da2,da2I),INTERP_KERNEL::Exception);
+ //
+ da->decrRef();
+}
+
+void MEDCouplingBasicsTest::testUMeshGetCellIdsLyingOnNodes1()
+{
+ MEDCouplingUMesh *m=build3DSurfTargetMesh_1();
+ const int nodeIds1[5]={1,2,3,4,6};
+ const int nodeIds2[2]={6,7};
+ DataArrayInt *da=m->getCellIdsLyingOnNodes(nodeIds1,nodeIds1+5,true);
+ CPPUNIT_ASSERT_EQUAL(1,da->getNumberOfTuples());
+ CPPUNIT_ASSERT_EQUAL(1,da->getNumberOfComponents());
+ CPPUNIT_ASSERT_EQUAL(1,da->getIJ(0,0));
+ da->decrRef();
+ da=m->getCellIdsLyingOnNodes(nodeIds2,nodeIds2+2,false);
+ CPPUNIT_ASSERT_EQUAL(2,da->getNumberOfTuples());
+ CPPUNIT_ASSERT_EQUAL(1,da->getNumberOfComponents());
+ CPPUNIT_ASSERT_EQUAL(3,da->getIJ(0,0));
+ CPPUNIT_ASSERT_EQUAL(4,da->getIJ(1,0));
+ da->decrRef();
+ //
+ m->decrRef();
+}
+
+void MEDCouplingBasicsTest::testUMeshFindCellsIdsOnBoundary1()
+{
+ MEDCouplingUMesh *m=build3DSurfTargetMesh_1();
+ DataArrayInt *da5=m->findCellsIdsOnBoundary();
+ CPPUNIT_ASSERT_EQUAL(5,da5->getNumberOfTuples());
+ CPPUNIT_ASSERT(da5->isIdentity());
+ //
+ da5->decrRef();
+ m->decrRef();
+}
+
+void MEDCouplingBasicsTest::testMeshSetTime1()
+{
+ MEDCouplingUMesh *m1=build3DSurfTargetMesh_1();
+ MEDCouplingUMesh *m2=build3DSurfTargetMesh_1();
+ //
+ CPPUNIT_ASSERT(m1->isEqual(m2,1e-12));
+ m1->setTime(3.14,6,7);
+ int tmp1,tmp2;
+ double tmp3=m1->getTime(tmp1,tmp2);
+ CPPUNIT_ASSERT_EQUAL(6,tmp1);
+ CPPUNIT_ASSERT_EQUAL(7,tmp2);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(3.14,tmp3,1e-12);
+ CPPUNIT_ASSERT(!m1->isEqual(m2,1e-12));
+ m2->setTime(3.14,6,7);
+ CPPUNIT_ASSERT(m1->isEqual(m2,1e-12));
+ m1->setTimeUnit("ms");
+ CPPUNIT_ASSERT(std::string(m1->getTimeUnit())=="ms");
+ m1->setTimeUnit("us");
+ CPPUNIT_ASSERT(std::string(m1->getTimeUnit())=="us");
+ CPPUNIT_ASSERT(!m1->isEqual(m2,1e-12));
+ m2->setTimeUnit("us");
+ CPPUNIT_ASSERT(m1->isEqual(m2,1e-12));
+ m2->setTime(3.14,6,8);
+ CPPUNIT_ASSERT(!m1->isEqual(m2,1e-12));
+ m2->setTime(3.14,7,7);
+ CPPUNIT_ASSERT(!m1->isEqual(m2,1e-12));
+ m2->setTime(3.15,6,7);
+ CPPUNIT_ASSERT(!m1->isEqual(m2,1e-12));
+ //
+ m1->setTime(10.34,55,12);
+ MEDCouplingUMesh *m3=(MEDCouplingUMesh *)m1->deepCpy();
+ CPPUNIT_ASSERT(m1->isEqual(m3,1e-12));
+ tmp3=m3->getTime(tmp1,tmp2);
+ CPPUNIT_ASSERT_EQUAL(55,tmp1);
+ CPPUNIT_ASSERT_EQUAL(12,tmp2);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(10.34,tmp3,1e-12);
+ //
+ m3->decrRef();
+ m1->decrRef();
+ m2->decrRef();
+ // testing CMesh
+ const double coo1[4]={0.,1.,2.,3.5};
+ DataArrayDouble *a=DataArrayDouble::New();
+ a->alloc(4,1);
+ std::copy(coo1,coo1+4,a->getPointer());
+ MEDCouplingCMesh *b=MEDCouplingCMesh::New();
+ b->setCoordsAt(0,a);
+ a->decrRef();
+ //
+ b->setTime(5.67,8,100);
+ tmp3=b->getTime(tmp1,tmp2);
+ CPPUNIT_ASSERT_EQUAL(8,tmp1);
+ CPPUNIT_ASSERT_EQUAL(100,tmp2);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(5.67,tmp3,1e-12);
+ MEDCouplingCMesh *c=(MEDCouplingCMesh *)b->deepCpy();
+ CPPUNIT_ASSERT(c->isEqual(b,1e-12));
+ tmp3=c->getTime(tmp1,tmp2);
+ CPPUNIT_ASSERT_EQUAL(8,tmp1);
+ CPPUNIT_ASSERT_EQUAL(100,tmp2);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(5.67,tmp3,1e-12);
+ c->decrRef();
+ b->decrRef();
+}
+
+void MEDCouplingBasicsTest::testApplyFuncTwo1()
+{
+ MEDCouplingUMesh *m1=build3DSurfTargetMesh_1();
+ MEDCouplingFieldDouble *f1=MEDCouplingFieldDouble::New(ON_CELLS,ONE_TIME);
+ f1->setMesh(m1);
+ //
+ const double vals[15]={1.,11.,21.,2.,12.,22.,3.,13.,23.,4.,14.,24.,5.,15.,25.};
+ DataArrayDouble *da=DataArrayDouble::New();
+ da->alloc(5,3);
+ std::copy(vals,vals+15,da->getPointer());
+ f1->setArray(da);
+ //
+ CPPUNIT_ASSERT_THROW(da->applyFunc2(1,"y+z"),INTERP_KERNEL::Exception);
+ da->setInfoOnComponent(0,"x [m]");
+ da->setInfoOnComponent(1,"y [mm]");
+ da->setInfoOnComponent(2,"z [km]");
+ DataArrayDouble *da2=da->applyFunc2(1,"y+z");
+ CPPUNIT_ASSERT_EQUAL(1,da2->getNumberOfComponents());
+ CPPUNIT_ASSERT_EQUAL(5,da2->getNumberOfTuples());
+ const double expected1[5]={32.,34.,36.,38.,40.};
+ for(int i=0;i<5;i++)
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1[i],da2->getIJ(0,i),1e-12);
+ da2->decrRef();
+ da2=da->applyFunc(1,"y+z");
+ const double expected2[5]={12.,14.,16.,18.,20.};
+ for(int i=0;i<5;i++)
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(expected2[i],da2->getIJ(0,i),1e-12);
+ da2->decrRef();
+ //
+ CPPUNIT_ASSERT_EQUAL(3,f1->getNumberOfComponents());
+ CPPUNIT_ASSERT_EQUAL(5,f1->getNumberOfTuples());
+ f1->applyFunc2(1,"y+z");
+ CPPUNIT_ASSERT_EQUAL(1,f1->getNumberOfComponents());
+ CPPUNIT_ASSERT_EQUAL(5,f1->getNumberOfTuples());
+ for(int i=0;i<5;i++)
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1[i],f1->getArray()->getIJ(0,i),1e-12);
+ //
+ da->decrRef();
+ f1->decrRef();
+ m1->decrRef();
+}
+
+void MEDCouplingBasicsTest::testApplyFuncThree1()
+{
+ MEDCouplingUMesh *m1=build3DSurfTargetMesh_1();
+ MEDCouplingFieldDouble *f1=MEDCouplingFieldDouble::New(ON_CELLS,ONE_TIME);
+ f1->setMesh(m1);
+ //
+ const double vals[15]={1.,11.,21.,2.,12.,22.,3.,13.,23.,4.,14.,24.,5.,15.,25.};
+ DataArrayDouble *da=DataArrayDouble::New();
+ da->alloc(5,3);
+ std::copy(vals,vals+15,da->getPointer());
+ f1->setArray(da);
+ //
+ std::vector<std::string> vs(3);
+ vs[0]="x"; vs[1]="Y"; vs[2]="z";
+ CPPUNIT_ASSERT_THROW(da->applyFunc3(1,vs,"y+z"),INTERP_KERNEL::Exception);
+ vs[1]="y";
+ DataArrayDouble *da2=da->applyFunc3(1,vs,"y+z");
+ const double expected1[5]={32.,34.,36.,38.,40.};
+ for(int i=0;i<5;i++)
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1[i],da2->getIJ(0,i),1e-12);
+ da2->decrRef();
+ f1->setArray(da);
+ CPPUNIT_ASSERT_EQUAL(3,f1->getNumberOfComponents());
+ CPPUNIT_ASSERT_EQUAL(5,f1->getNumberOfTuples());
+ f1->applyFunc3(1,vs,"y+z");
+ CPPUNIT_ASSERT_EQUAL(1,f1->getNumberOfComponents());
+ CPPUNIT_ASSERT_EQUAL(5,f1->getNumberOfTuples());
+ for(int i=0;i<5;i++)
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1[i],f1->getArray()->getIJ(0,i),1e-12);
+ //
+ da->decrRef();
+ f1->decrRef();
+ m1->decrRef();
+}
+
+void MEDCouplingBasicsTest::testFillFromAnalyticTwo1()
+{
+ MEDCouplingUMesh *m1=build3DSurfTargetMesh_1();
+ CPPUNIT_ASSERT_THROW(m1->fillFromAnalytic2(ON_NODES,1,"y+z"),INTERP_KERNEL::Exception);
+ m1->getCoords()->setInfoOnComponent(0,"x [m]");
+ m1->getCoords()->setInfoOnComponent(1,"y");
+ m1->getCoords()->setInfoOnComponent(2,"z");
+ MEDCouplingFieldDouble *f1=m1->fillFromAnalytic2(ON_NODES,1,"y+z");
+ CPPUNIT_ASSERT_EQUAL(1,f1->getNumberOfComponents());
+ CPPUNIT_ASSERT_EQUAL(9,f1->getNumberOfTuples());
+ const double expected1[9]={0.2, 0.7, 1.2, 0.7, 1.2, 1.7, 1.2, 1.7, 2.2};
+ for(int i=0;i<9;i++)
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1[i],f1->getArray()->getIJ(0,i),1e-12);
+ f1->decrRef();
+ m1->decrRef();
+}
+
+void MEDCouplingBasicsTest::testFillFromAnalyticThree1()
+{
+ MEDCouplingUMesh *m1=build3DSurfTargetMesh_1();
+ std::vector<std::string> vs(3);
+ vs[0]="x"; vs[1]="Y"; vs[2]="z";
+ CPPUNIT_ASSERT_THROW(m1->fillFromAnalytic3(ON_NODES,1,vs,"y+z"),INTERP_KERNEL::Exception);
+ vs[1]="y";
+ MEDCouplingFieldDouble *f1=m1->fillFromAnalytic3(ON_NODES,1,vs,"y+z");
+ CPPUNIT_ASSERT_EQUAL(1,f1->getNumberOfComponents());
+ CPPUNIT_ASSERT_EQUAL(9,f1->getNumberOfTuples());
+ const double expected1[9]={0.2, 0.7, 1.2, 0.7, 1.2, 1.7, 1.2, 1.7, 2.2};
+ for(int i=0;i<9;i++)
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1[i],f1->getArray()->getIJ(0,i),1e-12);
+ f1->decrRef();
+ m1->decrRef();
+}
+
+void MEDCouplingBasicsTest::testDAUnitVar1()
+{
+ DataArrayDouble *da=DataArrayDouble::New();
+ da->alloc(1,3);
+ da->setInfoOnComponent(0,"XPS [m]");
+ std::string st1,st2;
+ st1=da->getVarOnComponent(0);
+ CPPUNIT_ASSERT(st1=="XPS");
+ st2=da->getUnitOnComponent(0);
+ CPPUNIT_ASSERT(st2=="m");
+ //
+ da->setInfoOnComponent(0,"XPS [m]");
+ st1=da->getVarOnComponent(0);
+ CPPUNIT_ASSERT(st1=="XPS");
+ st2=da->getUnitOnComponent(0);
+ CPPUNIT_ASSERT(st2=="m");
+ //
+ da->setInfoOnComponent(0,"XPP [m]");
+ st1=da->getVarOnComponent(0);
+ CPPUNIT_ASSERT(st1=="XPP");
+ st2=da->getUnitOnComponent(0);
+ CPPUNIT_ASSERT(st2=="m");
+ //
+ da->setInfoOnComponent(0,"XPP kdep kefer [ m ]");
+ st1=da->getVarOnComponent(0);
+ CPPUNIT_ASSERT(st1=="XPP kdep kefer");
+ st2=da->getUnitOnComponent(0);
+ CPPUNIT_ASSERT(st2==" m ");
+ //
+ da->setInfoOnComponent(0," XPP k[ dep k]efer [ m^ 2/s^3*kJ ]");
+ st1=da->getVarOnComponent(0);
+ CPPUNIT_ASSERT(st1==" XPP k[ dep k]efer");
+ st2=da->getUnitOnComponent(0);
+ CPPUNIT_ASSERT(st2==" m^ 2/s^3*kJ ");
+ //
+ da->setInfoOnComponent(0," XPP kefer ");
+ st1=da->getVarOnComponent(0);
+ CPPUNIT_ASSERT(st1==" XPP kefer ");
+ st2=da->getUnitOnComponent(0);
+ CPPUNIT_ASSERT(st2=="");
+ //
+ da->setInfoOnComponent(0,"temperature( bof)");
+ st1=da->getVarOnComponent(0);
+ CPPUNIT_ASSERT(st1=="temperature( bof)");
+ st2=da->getUnitOnComponent(0);
+ CPPUNIT_ASSERT(st2=="");
+ //
+ da->setInfoOnComponent(0,"kkk [m]");
+ da->setInfoOnComponent(1,"ppp [m^2/kJ]");
+ da->setInfoOnComponent(2,"abcde [MW/s]");
+ //
+ std::vector<std::string> vs;
+ vs=da->getVarsOnComponent();
+ CPPUNIT_ASSERT_EQUAL(3,(int)vs.size());
+ CPPUNIT_ASSERT(vs[0]=="kkk");
+ CPPUNIT_ASSERT(vs[1]=="ppp");
+ CPPUNIT_ASSERT(vs[2]=="abcde");
+ vs=da->getUnitsOnComponent();
+ CPPUNIT_ASSERT_EQUAL(3,(int)vs.size());
+ CPPUNIT_ASSERT(vs[0]=="m");
+ CPPUNIT_ASSERT(vs[1]=="m^2/kJ");
+ CPPUNIT_ASSERT(vs[2]=="MW/s");
+ //
+ da->decrRef();
+}
+
+void MEDCouplingBasicsTest::testGaussCoordinates1()
+{
+ //Testing 1D cell types
+ MEDCouplingUMesh *m1=build1DMultiTypes_1();
+ MEDCouplingFieldDouble *f=MEDCouplingFieldDouble::New(ON_GAUSS_PT,ONE_TIME);
+ f->setMesh(m1);
+ std::vector<double> wg1(1); wg1[0]=0.3;
+ std::vector<double> gsCoo1(1); gsCoo1[0]=0.2;
+ std::vector<double> refCoo1(2); refCoo1[0]=-1.0; refCoo1[1]=1.0;
+ f->setGaussLocalizationOnType(INTERP_KERNEL::NORM_SEG2,refCoo1,gsCoo1,wg1);
+ std::vector<double> wg2(wg1);
+ std::vector<double> gsCoo2(1); gsCoo2[0]=0.2;
+ std::vector<double> refCoo2(3); refCoo2[0]=-1.0; refCoo2[1]=1.0; refCoo2[2]=0.0;
+ f->setGaussLocalizationOnType(INTERP_KERNEL::NORM_SEG3,refCoo2,gsCoo2,wg2);
+ //
+ DataArrayDouble *resToTest=f->getLocalizationOfDiscr();
+ CPPUNIT_ASSERT_EQUAL(3,resToTest->getNumberOfComponents());
+ CPPUNIT_ASSERT_EQUAL(2,resToTest->getNumberOfTuples());
+ const double expected1[6]={0.6,0.6,0.6, 0.6,0.6,0.6};
+ for(int i=0;i<6;i++)
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1[i],resToTest->getIJ(0,i),1e-14);
+ resToTest->decrRef();
+ //
+ m1->decrRef();
+ f->decrRef();
+ //Testing 2D cell types
+ MEDCouplingUMesh *m2=build2DMultiTypes_1();
+ f=MEDCouplingFieldDouble::New(ON_GAUSS_PT,ONE_TIME);
+ f->setMesh(m2);
+ std::vector<double> wg3(2); wg3[0]=0.3; wg3[1]=0.3;
+ const double tria3CooGauss[4]={ 0.1, 0.8, 0.2, 0.7 };
+ std::vector<double> gsCoo3(tria3CooGauss,tria3CooGauss+4);
+ const double tria3CooRef[6]={ 0.0, 0.0, 1.0 , 0.0, 0.0, 1.0 };
+ std::vector<double> refCoo3(tria3CooRef,tria3CooRef+6);
+ f->setGaussLocalizationOnType(INTERP_KERNEL::NORM_TRI3,refCoo3,gsCoo3,wg3);
+ std::vector<double> wg4(3); wg4[0]=0.3; wg4[1]=0.3; wg4[2]=0.3;
+ const double tria6CooGauss[6]={ 0.3, 0.2, 0.2, 0.1, 0.2, 0.4 };
+ std::vector<double> gsCoo4(tria6CooGauss,tria6CooGauss+6);
+ const double tria6CooRef[12]={0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.5, 0.0, 0.5, 0.5, 0.0, 0.5};
+ std::vector<double> refCoo4(tria6CooRef,tria6CooRef+12);
+ f->setGaussLocalizationOnType(INTERP_KERNEL::NORM_TRI6,refCoo4,gsCoo4,wg4);
+ std::vector<double> wg5(4); wg5[0]=0.3; wg5[1]=0.3; wg5[2]=0.3; wg5[3]=0.3;
+ const double quad4CooGauss[8]={ 0.3, 0.2, 0.2, 0.1, 0.2, 0.4, 0.15, 0.27 };
+ std::vector<double> gsCoo5(quad4CooGauss,quad4CooGauss+8);
+ const double quad4CooRef[8]={-1.0, 1.0, -1.0, -1.0, 1.0, -1.0, 1.0, 1.0};
+ std::vector<double> refCoo5(quad4CooRef,quad4CooRef+8);
+ f->setGaussLocalizationOnType(INTERP_KERNEL::NORM_QUAD4,refCoo5,gsCoo5,wg5);
+ std::vector<double> wg6(4); wg6[0]=0.3; wg6[1]=0.3; wg6[2]=0.3; wg6[3]=0.3;
+ const double quad8CooGauss[8]={ 0.34, 0.16, 0.21, 0.3, 0.23, 0.4, 0.14, 0.37 };
+ std::vector<double> gsCoo6(quad8CooGauss,quad8CooGauss+8);
+ const double quad8CooRef[16]={ -1.0, -1.0, 1.0, -1.0, 1.0, 1.0, -1.0, 1.0, 0.0, -1.0, 1.0, 0.0, 0.0, 1.0, -1.0, 0.0};
+ std::vector<double> refCoo6(quad8CooRef,quad8CooRef+16);
+ f->setGaussLocalizationOnType(INTERP_KERNEL::NORM_QUAD8,refCoo6,gsCoo6,wg6);
+ //
+ resToTest=f->getLocalizationOfDiscr();
+ CPPUNIT_ASSERT_EQUAL(3,resToTest->getNumberOfComponents());
+ CPPUNIT_ASSERT_EQUAL(13,resToTest->getNumberOfTuples());//2+3+4+4 gauss points for resp TRI3,TRI6,QUAD4,QUAD8
+ const double expected2[39]={5.1,1.55,0.0, 4.7,1.65,0.0, //TRI3
+ 2.32,1.52,0.0, 1.6,1.32,0.0, 3.52,1.26,0.0,//TRI6
+ 2.6,1.6,0.0, 2.4,1.8,0.0, 2.4,1.2,0.0, 2.3,1.46,0.0,//QUAD4
+ 2.32,2.68,0.0, 2.6,2.42,0.0, 2.8,2.46,0.0, 2.74,2.28,0.0 };//QUAD8
+ for(int i=0;i<39;i++)
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(expected2[i],resToTest->getIJ(0,i),1e-14);
+ resToTest->decrRef();
+ //
+ m2->decrRef();
+ f->decrRef();
+ //Testing 3D cell types
+ MEDCouplingUMesh *m3=build3DMultiTypes_1();
+ f=MEDCouplingFieldDouble::New(ON_GAUSS_PT,ONE_TIME);
+ f->setMesh(m3);
+ //
+ std::vector<double> wg7(1); wg7[0]=0.3;
+ const double tetra4CooGauss[3]={0.34, 0.16, 0.21};
+ std::vector<double> gsCoo7(tetra4CooGauss,tetra4CooGauss+3);
+ const double tetra4CooRef[12]={0.0,1.0,0.0, 0.0,0.0,1.0, 0.0,0.0,0.0, 1.0,0.0,0.0};
+ std::vector<double> refCoo7(tetra4CooRef,tetra4CooRef+12);
+ f->setGaussLocalizationOnType(INTERP_KERNEL::NORM_TETRA4,refCoo7,gsCoo7,wg7);
+ std::vector<double> wg8(1); wg8[0]=0.3;
+ const double tetra10CooGauss[3]={0.2, 0.3, 0.1};
+ std::vector<double> gsCoo8(tetra10CooGauss,tetra10CooGauss+3);
+ const double tetra10CooRef[30]={0.0,1.0,0.0, 0.0,0.0,0.0, 0.0,0.0,1.0, 1.0,0.0,0.0, 0.0,0.5,0.0, 0.0,0.0,0.5, 0.0,0.5,0.5, 0.5,0.5,0.0, 0.5,0.0,0.0, 0.5,0.0,0.5};
+ std::vector<double> refCoo8(tetra10CooRef,tetra10CooRef+30);
+ f->setGaussLocalizationOnType(INTERP_KERNEL::NORM_TETRA10,refCoo8,gsCoo8,wg8);
+ std::vector<double> wg9(1); wg9[0]=0.3;
+ const double pyra5CooGauss[3]={0.2, 0.3, 0.1};
+ std::vector<double> gsCoo9(pyra5CooGauss,pyra5CooGauss+3);
+ const double pyra5CooRef[15]={1.0,0.0,0.0, 0.0,1.0,0.0, -1.0,0.0,0.0, 0.0,-1.0,0.0, 0.0,0.0,1.0};
+ std::vector<double> refCoo9(pyra5CooRef,pyra5CooRef+15);
+ f->setGaussLocalizationOnType(INTERP_KERNEL::NORM_PYRA5,refCoo9,gsCoo9,wg9);
+ std::vector<double> wg10(1); wg10[0]=0.3;
+ const double pyra13CooGauss[3]={0.1, 0.2, 0.7};
+ std::vector<double> gsCoo10(pyra13CooGauss,pyra13CooGauss+3);
+ const double pyra13CooRef[39]={1.0,0.0,0.0, 0.0,1.0,0.0,-1.0,0.0,0.0,0.0,-1.0,0.0,0.0,0.0,1.0,0.5,0.5,0.0,-0.5,0.5,0.0,-0.5,-0.5,0.0,0.5,-0.5,0.0,0.5,0.0,0.5,0.0,0.5,0.5,-0.5,0.0,0.5,0.0,-0.5,0.5};
+ std::vector<double> refCoo10(pyra13CooRef,pyra13CooRef+39);
+ f->setGaussLocalizationOnType(INTERP_KERNEL::NORM_PYRA13,refCoo10,gsCoo10,wg10);
+ std::vector<double> wg11(1); wg11[0]=0.3;
+ const double penta6CooGauss[3]={0.2, 0.3, 0.1};
+ std::vector<double> gsCoo11(penta6CooGauss,penta6CooGauss+3);
+ const double penta6CooRef[18]={-1.0,1.0,0.0,-1.0,-0.0,1.0,-1.0,0.0,0.0,1.0,1.0,0.0,1.0,0.0,1.0,1.0,0.0,0.0};
+ std::vector<double> refCoo11(penta6CooRef,penta6CooRef+18);
+ f->setGaussLocalizationOnType(INTERP_KERNEL::NORM_PENTA6,refCoo11,gsCoo11,wg11);
+ std::vector<double> wg12(1); wg12[0]=0.3;
+ const double penta15CooGauss[3]={0.2, 0.3,0.15};
+ std::vector<double> gsCoo12(penta15CooGauss,penta15CooGauss+3);
+ const double penta15CooRef[45]={-1.0,1.0,0.0,-1.0,0.0,1.0,-1.0,0.0,0.0,1.0,1.0,0.0,1.0,0.0,1.0,1.0,0.0,0.0,-1.0,0.5,0.5,-1.0,0.0,0.5,-1.0,0.5,0.0,0.0,1.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,1.0,0.5,0.5,1.0,0.0, 0.5,1.0,0.5,0.0};
+ std::vector<double> refCoo12(penta15CooRef,penta15CooRef+45);
+ f->setGaussLocalizationOnType(INTERP_KERNEL::NORM_PENTA15,refCoo12,gsCoo12,wg12);
+ std::vector<double> wg13(1); wg13[0]=0.3;
+ const double hexa8CooGauss[3]={0.2,0.3,0.15};
+ std::vector<double> gsCoo13(hexa8CooGauss,hexa8CooGauss+3);
+ const double hexa8CooRef[24]={-1.0,-1.0,-1.0,1.0,-1.0,-1.0,1.0,1.0,-1.0,-1.0,1.0,-1.0,-1.0,-1.0,1.0,1.0,-1.0,1.0,1.0,1.0,1.0,-1.0,1.0,1.0};
+ std::vector<double> refCoo13(hexa8CooRef,hexa8CooRef+24);
+ f->setGaussLocalizationOnType(INTERP_KERNEL::NORM_HEXA8,refCoo13,gsCoo13,wg13);
+ std::vector<double> wg14(1); wg14[0]=0.3;
+ const double hexa20CooGauss[3]={0.11,0.3,0.55};
+ std::vector<double> gsCoo14(hexa20CooGauss,hexa20CooGauss+3);
+ const double hexa20CooRef[60]={-1.0,-1.0,-1.0,1.0,-1.0,-1.0,1.0,1.0,-1.0,-1.0,1.0,-1.0,-1.0,-1.0,1.0,1.0,-1.0,1.0,1.0,1.0,1.0,-1.0,1.0,1.0,0.0,-1.0,-1.0,1.0,0.0,-1.0,0.0,1.0,-1.0,-1.0,0.0,-1.0,-1.0,-1.0,0.0,1.0,-1.0,0.0,1.0,1.0,0.0,-1.0,1.0,0.0,0.0,-1.0,1.0,1.0,0.0,1.0,0.0,1.0,1.0,-1.0,0.0,1.0};
+ std::vector<double> refCoo14(hexa20CooRef,hexa20CooRef+60);
+ f->setGaussLocalizationOnType(INTERP_KERNEL::NORM_HEXA20,refCoo14,gsCoo14,wg14);
+ //
+ resToTest=f->getLocalizationOfDiscr();
+ CPPUNIT_ASSERT_EQUAL(3,resToTest->getNumberOfComponents());
+ CPPUNIT_ASSERT_EQUAL(8,resToTest->getNumberOfTuples());//2+3+4+4 gauss points for resp TRI3,TRI6,QUAD4,QUAD8
+ const double expected3[24]={1.312,3.15,1.02, 0.56,3.3,0.6, 2.18,1.1,0.2, 1.18,1.54,0.98, 1.56,0.3,3.6, 1.613,0.801,4.374, 2.6,2.4,2.3, 2.31232,2.3933985,1.553255};
+ for(int i=0;i<24;i++)
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(expected3[i],resToTest->getIJ(0,i),1e-14);
+ resToTest->decrRef();
+ //
+ m3->decrRef();
+ f->decrRef();
+}
+
+/*!
+ * Not activated test ! To be implemented !
+ */
+void MEDCouplingBasicsTest::testQ1Localization1()
+{
+ MEDCouplingUMesh *m=buildHexa8Mesh_1();
+ MEDCouplingFieldDouble *f=MEDCouplingFieldDouble::New(ON_NODES,ONE_TIME);
+ DataArrayDouble *da=DataArrayDouble::New();
+ const double vals1[27]={1.0,3.0,4.0,1.0,3.0,4.0,3.0,2.0,5.0,1.0,3.0,4.0,1.0,3.0,4.0,3.0,2.0,5.0,1.0,3.0,4.0,1.0,3.0,4.0,3.0,2.0,5.0};
+ da->alloc(27,1);
+ std::copy(vals1,vals1+27,da->getPointer());
+ f->setMesh(m);
+ f->setArray(da);
+ da->decrRef();
+ //
+ const double point1[3]={0.25,0.75,0.25};
+ //const double points1[6]={0.25,0.75,0.25,1.0,1.0,1.0};
+ double res1[3];
+ f->getValueOn(point1,res1);
+ //
+ f->decrRef();
+ m->decrRef();
+}
+
+void MEDCouplingBasicsTest::testP2Localization1()
+{
+ MEDCouplingUMesh *m=MEDCouplingUMesh::New("testP2",2);
+ const double coords[12]={0.,2.,3.5,0.,4.5,1.5,1.2,0.32,3.4,1.,2.1,2.4};
+ const int conn[6]={0,1,2,3,4,5};
+ DataArrayDouble *coo=DataArrayDouble::New();
+ coo->alloc(6,2);
+ std::copy(coords,coords+12,coo->getPointer());
+ m->setCoords(coo);
+ coo->decrRef();
+ m->allocateCells(1);
+ m->insertNextCell(INTERP_KERNEL::NORM_TRI6,6,conn);
+ m->finishInsertingCells();
+ //
+ MEDCouplingFieldDouble *f=MEDCouplingFieldDouble::New(ON_NODES,ONE_TIME);
+ f->setMesh(m);
+ DataArrayDouble *da=DataArrayDouble::New();
+ da->alloc(6,3);
+ const double vals1[18]={1.2,2.3,3.4, 2.2,3.3,4.4, 3.2,4.3,5.4, 4.2,5.3,6.4, 5.2,6.3,7.4, 6.2,7.3,8.4};
+ std::copy(vals1,vals1+18,da->getPointer());
+ f->setArray(da);
+ da->decrRef();
+ //
+ const double loc[2]={2.27,1.3};
+ DataArrayDouble *locs=f->getValueOnMulti(loc,1);
+ const double expected1[3]={6.0921164547752236, 7.1921164547752232, 8.2921164547752255};
+ for(int i=0;i<3;i++)
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1[i],locs->getIJ(0,i),1e-12);
+ locs->decrRef();
+ //
+ m->decrRef();
+ f->decrRef();
+}
+
+void MEDCouplingBasicsTest::testP2Localization2()
+{
+ MEDCouplingUMesh *m=MEDCouplingUMesh::New("testP2_2",3);
+ const double coords[30]={0.33312787792955395, -0.35155740179580952, -0.03567564825034563, 1.307146326477638, -0.57234557776250305, -0.08608044208272235, 0.5551834466499993, 0.62324964668794192, -0.014638951108536295, 0.37761817224442129, -0.38324019806913578, 0.96283164472856886, 0.79494856035658679, -0.40628057809270046, 0.0021004190225864614, 1.023740446371799, 0.07665912970471335, -0.072889657161871096, 0.54564584619517376, 0.11132872093429744, 0.039647326652013051, 0.27164784387819052, -0.42018012100866675, 0.46563376500745146, 0.89501965094896418, -0.56148455362735061, 0.43337469695473035, 0.49118025152924394, 0.093884938060727313, 0.47216346905220891};
+ const int conn[10]={0,1,2,3,4,5,6,7,8,9};
+ DataArrayDouble *coo=DataArrayDouble::New();
+ coo->alloc(10,3);
+ std::copy(coords,coords+30,coo->getPointer());
+ m->setCoords(coo);
+ coo->decrRef();
+ m->allocateCells(1);
+ m->insertNextCell(INTERP_KERNEL::NORM_TETRA10,10,conn);
+ m->finishInsertingCells();
+ //
+ MEDCouplingFieldDouble *f=MEDCouplingFieldDouble::New(ON_NODES,ONE_TIME);
+ f->setMesh(m);
+ DataArrayDouble *da=DataArrayDouble::New();
+ da->alloc(10,1);
+ const double vals1[10]={1.1,2.1,3.1,4.1,5.2,6.2,7.2,8.2,9.2,10.2};
+ std::copy(vals1,vals1+10,da->getPointer());
+ f->setArray(da);
+ da->decrRef();
+ //
+ const double loc[3]={0.64637931739890486, -0.16185896817550552, 0.22678966365273748};
+ DataArrayDouble *locs=f->getValueOnMulti(loc,1);
+ const double expected1[1]={10.0844021968047};
+ for(int i=0;i<1;i++)
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1[i],locs->getIJ(0,i),1e-12);
+ locs->decrRef();
+ //
+ m->decrRef();
+ f->decrRef();
+}
+
+void MEDCouplingBasicsTest::testGetValueOn2()
+{
+ MEDCouplingUMesh *m=build2DTargetMesh_1();
+ MEDCouplingFieldDouble *f=MEDCouplingFieldDouble::New(ON_CELLS,NO_TIME);
+ f->setMesh(m);
+ DataArrayDouble *arr=DataArrayDouble::New();
+ int nbOfCells=m->getNumberOfCells();
+ arr->alloc(nbOfCells,3);
+ f->setArray(arr);
+ arr->decrRef();
+ const double values1[15]={7.,107.,10007.,8.,108.,10008.,9.,109.,10009.,10.,110.,10010.,11.,111.,10011.};
+ std::copy(values1,values1+15,arr->getPointer());
+ const double loc[10]={-0.05,-0.05, 0.55,-0.25, 0.55,0.15, -0.05,0.45, 0.45,0.45};
+ f->checkCoherency();
+ DataArrayDouble *locs=f->getValueOnMulti(loc,5);
+ CPPUNIT_ASSERT_EQUAL(5,locs->getNumberOfTuples());
+ CPPUNIT_ASSERT_EQUAL(3,locs->getNumberOfComponents());
+ for(int j=0;j<15;j++)
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(values1[j],locs->getIJ(0,j),1e-12);
+ locs->decrRef();
+ f->decrRef();
+ // Testing ON_NODES
+ f=MEDCouplingFieldDouble::New(ON_NODES,NO_TIME);
+ f->setMesh(m);
+ arr=DataArrayDouble::New();
+ int nbOfNodes=m->getNumberOfNodes();
+ arr->alloc(nbOfNodes,3);
+ f->setArray(arr);
+ arr->decrRef();
+ const double values2[27]={7.,107.,10007.,8.,108.,10008.,9.,109.,10009.,10.,110.,10010.,11.,111.,10011.,12.,112.,10012.,13.,113.,10013.,14.,114.,10014.,15.,115.,10015.};
+ std::copy(values2,values2+27,arr->getPointer());
+ const double loc2[8]={0.5432,-0.2432, 0.5478,0.1528, 0.5432,-0.2432, 0.5432,-0.2432};
+ const double expected2[12]={9.0272, 109.0272, 10009.0272, 11.4124,111.4124,10011.4124, 9.0272, 109.0272, 10009.0272, 9.0272, 109.0272, 10009.0272};
+ f->checkCoherency();
+ locs=f->getValueOnMulti(loc2,4);
+ CPPUNIT_ASSERT_EQUAL(4,locs->getNumberOfTuples());
+ CPPUNIT_ASSERT_EQUAL(3,locs->getNumberOfComponents());
+ for(int i=0;i<12;i++)
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(expected2[i],locs->getIJ(0,i),1e-12);
+ f->decrRef();
+ locs->decrRef();
+ //
+ m->decrRef();
+}
+
+void MEDCouplingBasicsTest::testDAIGetIdsNotEqual1()
+{
+ DataArrayInt *d=DataArrayInt::New();
+ const int vals1[10]={2,3,5,6,8,5,5,6,1,-5};
+ d->alloc(10,1);
+ std::copy(vals1,vals1+10,d->getPointer());
+ DataArrayInt *d2=d->getIdsNotEqual(5);
+ CPPUNIT_ASSERT_EQUAL(7,d2->getNumberOfTuples());
+ CPPUNIT_ASSERT_EQUAL(1,d2->getNumberOfComponents());
+ const int expected1[7]={0,1,3,4,7,8,9};
+ for(int i=0;i<7;i++)
+ CPPUNIT_ASSERT_EQUAL(expected1[i],d2->getIJ(0,i));
+ d->rearrange(2);
+ CPPUNIT_ASSERT_THROW(d->getIdsNotEqual(5),INTERP_KERNEL::Exception);
+ const int vals2[3]={-4,5,6};
+ std::vector<int> vals3(vals2,vals2+3);
+ d->rearrange(1);
+ DataArrayInt *d3=d->getIdsNotEqualList(vals3);
+ CPPUNIT_ASSERT_EQUAL(5,d3->getNumberOfTuples());
+ CPPUNIT_ASSERT_EQUAL(1,d3->getNumberOfComponents());
+ const int expected2[5]={0,1,4,8,9};
+ for(int i=0;i<5;i++)
+ CPPUNIT_ASSERT_EQUAL(expected2[i],d3->getIJ(0,i));
+ d3->decrRef();
+ d->decrRef();
+ d2->decrRef();
+}
+
+void MEDCouplingBasicsTest::testDAIComputeOffsets1()
+{
+ DataArrayInt *d=DataArrayInt::New();
+ const int vals1[6]={3,5,1,2,0,8};
+ const int expected1[6]={0,3,8,9,11,11};
+ d->alloc(6,1);
+ std::copy(vals1,vals1+6,d->getPointer());
+ d->computeOffsets();
+ CPPUNIT_ASSERT_EQUAL(6,d->getNumberOfTuples());
+ CPPUNIT_ASSERT_EQUAL(1,d->getNumberOfComponents());
+ for(int i=0;i<6;i++)
+ CPPUNIT_ASSERT_EQUAL(expected1[i],d->getIJ(0,i));
+ d->decrRef();
+}
+
+void MEDCouplingBasicsTest::testUMeshHexagonPrism1()
+{
+ const double coords[36]={
+ 0.8660254037844386, 0.5, 0.0, 0.0, 1.0, 0.0, -0.8660254037844386, 0.5, 0.0, -0.8660254037844386, -0.5, 0.0, 0.0, -1.0, 0.0, 0.8660254037844386, -0.5, 0.0,
+ 0.8660254037844386, 0.5, 2.0, 0.0, 1.0, 2.0, -0.8660254037844386, 0.5, 2.0, -0.8660254037844386, -0.5, 2.0, 0.0, -1.0, 2.0, 0.8660254037844386, -0.5, 2.0
+ };
+ const int conn[12]={1,2,3,4,5,0,7,8,9,10,11,6};
+ MEDCouplingUMesh *mesh=MEDCouplingUMesh::New("MyFirstHexagonalPrism",3);
+ DataArrayDouble *coo=DataArrayDouble::New();
+ coo->alloc(12,3);
+ std::copy(coords,coords+36,coo->getPointer());
+ mesh->setCoords(coo);
+ mesh->allocateCells(1);
+ mesh->insertNextCell(INTERP_KERNEL::NORM_HEXGP12,12,conn);
+ mesh->finishInsertingCells();
+ coo->decrRef();
+ //
+ mesh->checkCoherency();
+ MEDCouplingFieldDouble *vols=mesh->getMeasureField(false);
+ CPPUNIT_ASSERT_EQUAL(1,vols->getNumberOfTuples());
+ CPPUNIT_ASSERT_EQUAL(1,vols->getNumberOfComponents());
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(-5.196152422706632,vols->getIJ(0,0),1e-12);
+ DataArrayDouble *bary=mesh->getBarycenterAndOwner();
+ CPPUNIT_ASSERT_EQUAL(1,bary->getNumberOfTuples());
+ CPPUNIT_ASSERT_EQUAL(3,bary->getNumberOfComponents());
+ const double expected1[3]={0.,0.,1.};
+ for(int i=0;i<3;i++)
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1[i],bary->getIJ(0,i),1e-12);
+ DataArrayInt *d1=DataArrayInt::New();
+ DataArrayInt *d2=DataArrayInt::New();
+ DataArrayInt *d3=DataArrayInt::New();
+ DataArrayInt *d4=DataArrayInt::New();
+ MEDCouplingUMesh *m2=mesh->buildDescendingConnectivity(d1,d2,d3,d4);
+ CPPUNIT_ASSERT_EQUAL(8,m2->getNumberOfCells());
+ const int expected4[8][6]={{1,2,3,4,5,0},{7,6,11,10,9,8},{1,7,8,2},{2,8,9,3},{3,9,10,4},{4,10,11,5},{5,11,6,0},{0,6,7,1}};
+ const INTERP_KERNEL::NormalizedCellType expected2[8]={INTERP_KERNEL::NORM_POLYGON, INTERP_KERNEL::NORM_POLYGON, INTERP_KERNEL::NORM_QUAD4, INTERP_KERNEL::NORM_QUAD4, INTERP_KERNEL::NORM_QUAD4, INTERP_KERNEL::NORM_QUAD4, INTERP_KERNEL::NORM_QUAD4, INTERP_KERNEL::NORM_QUAD4};
+ const int expected3[8]={6,6,4,4,4,4,4,4};
+ for(int i=0;i<8;i++)
+ {
+ CPPUNIT_ASSERT(m2->getTypeOfCell(i)==expected2[i]);
+ std::vector<int> v;
+ m2->getNodeIdsOfCell(i,v);
+ CPPUNIT_ASSERT((int)v.size()==expected3[i]);
+ CPPUNIT_ASSERT(std::equal(expected4[i],expected4[i]+expected3[i],v.begin()));
+ }
+ d1->decrRef();
+ d2->decrRef();
+ d3->decrRef();
+ d4->decrRef();
+ m2->decrRef();
+ //
+ mesh->convertAllToPoly();
+ CPPUNIT_ASSERT(INTERP_KERNEL::NORM_POLYHED==mesh->getTypeOfCell(0));
+ mesh->unPolyze();
+ CPPUNIT_ASSERT(INTERP_KERNEL::NORM_HEXGP12==mesh->getTypeOfCell(0));
+ CPPUNIT_ASSERT_EQUAL(13,mesh->getMeshLength());
+ //
+ vols->decrRef();
+ bary->decrRef();
+ mesh->decrRef();
+}
+
+void MEDCouplingBasicsTest::testDADCheckIsMonotonic()
+{
+ DataArrayDouble *da=DataArrayDouble::New();
+ const double vals[4]={-1.,1.01,2.03,6.};
+ da->alloc(2,2);
+ std::copy(vals,vals+4,da->getPointer());
+ CPPUNIT_ASSERT_THROW(da->isMonotonic(1e-12),INTERP_KERNEL::Exception);
+ da->rearrange(1);
+ CPPUNIT_ASSERT(da->isMonotonic(1e-12));
+ da->checkMonotonic(1e-12);
+ da->setIJ(2,0,6.1);
+ CPPUNIT_ASSERT(!da->isMonotonic(1e-12));
+ CPPUNIT_ASSERT_THROW(da->checkMonotonic(1e-12),INTERP_KERNEL::Exception);
+ da->setIJ(2,0,5.99);
+ CPPUNIT_ASSERT(da->isMonotonic(1e-12));
+ CPPUNIT_ASSERT(!da->isMonotonic(1e-1));
+ da->decrRef();
+}
+
+void MEDCouplingBasicsTest::testCheckCoherencyDeeper1()
+{
+ MEDCouplingUMesh *m=build3DSourceMesh_1();
+ m->checkCoherency();
+ m->checkCoherency1();
+ m->getNodalConnectivity()->setIJ(8,0,-1);
+ m->checkCoherency();
+ CPPUNIT_ASSERT_THROW(m->checkCoherency1(),INTERP_KERNEL::Exception);
+ m->getNodalConnectivity()->setIJ(8,0,-6);
+ m->checkCoherency();
+ CPPUNIT_ASSERT_THROW(m->checkCoherency1(),INTERP_KERNEL::Exception);
+ m->getNodalConnectivity()->setIJ(8,0,9);//9>=NbOfNodes
+ m->checkCoherency();
+ CPPUNIT_ASSERT_THROW(m->checkCoherency1(),INTERP_KERNEL::Exception);
+ m->getNodalConnectivity()->setIJ(8,0,8);//OK
+ m->checkCoherency();
+ m->checkCoherency1();
+ const int elts[2]={1,5};
+ std::vector<int> eltsV(elts,elts+2);
+ m->convertToPolyTypes(eltsV);
+ m->checkCoherency();
+ m->checkCoherency1();
+ m->getNodalConnectivity()->setIJ(2,0,9);//9>=NbOfNodes
+ m->checkCoherency();
+ CPPUNIT_ASSERT_THROW(m->checkCoherency1(),INTERP_KERNEL::Exception);
+ m->getNodalConnectivity()->setIJ(2,0,-3);
+ m->checkCoherency();
+ CPPUNIT_ASSERT_THROW(m->checkCoherency1(),INTERP_KERNEL::Exception);
+ m->getNodalConnectivity()->setIJ(2,0,-1);
+ m->checkCoherency();
+ CPPUNIT_ASSERT_THROW(m->checkCoherency1(),INTERP_KERNEL::Exception);//Throw because cell#0 is not a polyhedron
+ m->getNodalConnectivity()->setIJ(2,0,4);
+ m->checkCoherency();
+ m->checkCoherency1();
+ m->getNodalConnectivity()->setIJ(7,0,-1);
+ m->checkCoherency();
+ m->checkCoherency1();//OK because we are in polyhedron connec
+ m->getNodalConnectivity()->setIJ(36,0,14);
+ m->checkCoherency();
+ CPPUNIT_ASSERT_THROW(m->checkCoherency1(),INTERP_KERNEL::Exception);//Throw beacause now cell 5 is a TETRA4 (14) so mimatch of number index and static type.
+ m->decrRef();
+}
+
+void MEDCouplingBasicsTest::testUnPolyze2()
+{
+ MEDCouplingUMesh *m=MEDCouplingUMesh::New("jjj",3);
+ DataArrayDouble *coo=DataArrayDouble::New();
+ coo->alloc(4,3);
+ coo->rearrange(1);
+ coo->iota(0);
+ coo->rearrange(3);
+ m->setCoords(coo);
+ coo->decrRef();
+ m->allocateCells(2);
+ const int conn[4]={0,1,2,3};
+ m->insertNextCell(INTERP_KERNEL::NORM_TETRA4,4,conn);
+ m->insertNextCell(INTERP_KERNEL::NORM_TETRA4,4,conn);
+ m->finishInsertingCells();
+ std::vector<const MEDCouplingUMesh *> ms(4,m);
+ MEDCouplingUMesh *m2=MEDCouplingUMesh::MergeUMeshesOnSameCoords(ms);
+ std::vector<int> temp(1,2);
+ m2->convertToPolyTypes(temp);
+ m2->unPolyze();
+ CPPUNIT_ASSERT(INTERP_KERNEL::NORM_TETRA4==m2->getTypeOfCell(2));
+ CPPUNIT_ASSERT_EQUAL(40,m2->getMeshLength());
+ std::vector<int> temp2;
+ m2->getNodeIdsOfCell(2,temp2);
+ CPPUNIT_ASSERT(4==(int)temp2.size());
+ CPPUNIT_ASSERT(std::equal(conn,conn+4,temp2.begin()));
+ m2->checkCoherency1();
+ MEDCouplingMesh *m3=m2->deepCpy();
+ m2->unPolyze();
+ CPPUNIT_ASSERT(m3->isEqual(m2,1e-12));
+ m3->decrRef();
+ m->decrRef();
+ m2->decrRef();
+}
+
+void MEDCouplingBasicsTest::testDACpyFrom1()
+{
+ DataArrayDouble *d=DataArrayDouble::New();
+ d->alloc(12,1);
+ d->iota(14.);
+ d->rearrange(3);
+ d->setName("Toto");
+ d->setInfoOnComponent(0,"X [m]");
+ d->setInfoOnComponent(1,"Y [m]");
+ d->setInfoOnComponent(2,"Z [m]");
+ //
+ DataArrayDouble *d1=DataArrayDouble::New();
+ CPPUNIT_ASSERT(!d->isEqual(*d1,1e-12));
+ d1->cpyFrom(*d);
+ CPPUNIT_ASSERT(d->isEqual(*d1,1e-12));
+ d1->cpyFrom(*d);
+ CPPUNIT_ASSERT(d->isEqual(*d1,1e-12));
+ d1->rearrange(2);
+ CPPUNIT_ASSERT(!d->isEqual(*d1,1e-12));
+ d1->cpyFrom(*d);
+ CPPUNIT_ASSERT(d->isEqual(*d1,1e-12));
+ //
+ DataArrayInt *d2=d->convertToIntArr();
+ DataArrayInt *d4=DataArrayInt::New();
+ CPPUNIT_ASSERT(!d2->isEqual(*d4));
+ d4->cpyFrom(*d2);
+ CPPUNIT_ASSERT(d2->isEqual(*d4));
+ d4->cpyFrom(*d2);
+ CPPUNIT_ASSERT(d2->isEqual(*d4));
+ d4->rearrange(2);
+ CPPUNIT_ASSERT(!d2->isEqual(*d4));
+ d4->cpyFrom(*d2);
+ CPPUNIT_ASSERT(d2->isEqual(*d4));
+ //
+ d->decrRef();
+ d1->decrRef();
+ d2->decrRef();
+ d4->decrRef();
+}
+
+void MEDCouplingBasicsTest::testDAITransformWithIndArr1()
+{
+ const int tab1[4]={17,18,22,19};
+ const int tab2[12]={0,1,1,3,3,0,1,3,2,2,3,0};
+ const int expected[12]={17,18,18,19,19,17,18,19,22,22,19,17};
+ DataArrayInt *d=DataArrayInt::New();
+ d->alloc(4,1);
+ std::copy(tab1,tab1+4,d->getPointer());
+ DataArrayInt *d1=DataArrayInt::New();
+ d1->alloc(12,1);
+ std::copy(tab2,tab2+12,d1->getPointer());
+ //
+ d1->transformWithIndArr(d->getConstPointer(),d->getConstPointer()+d->getNbOfElems());
+ CPPUNIT_ASSERT_EQUAL(12,d1->getNumberOfTuples());
+ CPPUNIT_ASSERT_EQUAL(1,d1->getNumberOfComponents());
+ for(int i=0;i<12;i++)
+ CPPUNIT_ASSERT_EQUAL(expected[i],d1->getIJ(i,0));
+ //
+ d->decrRef();
+ d1->decrRef();
+}
+
+void MEDCouplingBasicsTest::testDAIBuildPermArrPerLevel1()
+{
+ const int arr[12]={2,0,1,1,0,1,2,0,1,1,0,0};
+ const int expected1[12]={10,0,5,6,1,7,11,2,8,9,3,4};
+ DataArrayInt *da=DataArrayInt::New();
+ da->alloc(12,1);
+ std::copy(arr,arr+12,da->getPointer());
+ DataArrayInt *da2=da->buildPermArrPerLevel();
+ CPPUNIT_ASSERT_EQUAL(12,da2->getNumberOfTuples());
+ CPPUNIT_ASSERT_EQUAL(1,da2->getNumberOfComponents());
+ for(int i=0;i<12;i++)
+ CPPUNIT_ASSERT_EQUAL(expected1[i],da2->getIJ(i,0));
+ da->decrRef();
+ da2->decrRef();
+}
+
+void MEDCouplingBasicsTest::testDAIOperations1()
+{
+ const int arr1[12]={-1,-2,4,7,3,2,6,6,4,3,0,1};
+ DataArrayInt *da=DataArrayInt::New();
+ da->alloc(4,3);
+ std::copy(arr1,arr1+12,da->getPointer());
+ DataArrayInt *da1=DataArrayInt::New();
+ da1->alloc(12,1);
+ da1->iota(2);
+ CPPUNIT_ASSERT_THROW(DataArrayInt::Add(da,da1),INTERP_KERNEL::Exception);//not same number of tuples/Components
+ da1->rearrange(3);
+ DataArrayInt *da2=DataArrayInt::Add(da,da1);
+ CPPUNIT_ASSERT_EQUAL(4,da2->getNumberOfTuples());
+ CPPUNIT_ASSERT_EQUAL(3,da2->getNumberOfComponents());
+ const int expected1[12]={1,1,8,12,9,9,14,15,14,14,12,14};
+ for(int i=0;i<12;i++)
+ CPPUNIT_ASSERT_EQUAL(expected1[i],da2->getIJ(0,i));
+ da2->decrRef();
+ da1->substractEqual(da);
+ const int expected2[12]={3,5,0,-2,3,5,2,3,6,8,12,12};
+ for(int i=0;i<12;i++)
+ CPPUNIT_ASSERT_EQUAL(expected2[i],da1->getIJ(0,i));
+ da1->rearrange(1); da1->iota(2); da1->rearrange(3);
+ da1->addEqual(da);
+ for(int i=0;i<12;i++)
+ CPPUNIT_ASSERT_EQUAL(expected1[i],da1->getIJ(0,i));
+ da1->rearrange(1); da1->iota(2); da1->rearrange(3);
+ da2=DataArrayInt::Multiply(da,da1);
+ CPPUNIT_ASSERT_EQUAL(4,da2->getNumberOfTuples());
+ CPPUNIT_ASSERT_EQUAL(3,da2->getNumberOfComponents());
+ const int expected3[12]={-2,-6,16,35,18,14,48,54,40,33,0,13};
+ for(int i=0;i<12;i++)
+ CPPUNIT_ASSERT_EQUAL(expected3[i],da2->getIJ(0,i));
+ da2->decrRef();
+ da->divideEqual(da1);
+ CPPUNIT_ASSERT_EQUAL(4,da->getNumberOfTuples());
+ CPPUNIT_ASSERT_EQUAL(3,da->getNumberOfComponents());
+ const int expected4[12]={0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0};
+ for(int i=0;i<12;i++)
+ CPPUNIT_ASSERT_EQUAL(expected4[i],da->getIJ(0,i));
+ std::copy(arr1,arr1+12,da->getPointer());
+ da1->multiplyEqual(da);
+ CPPUNIT_ASSERT_EQUAL(4,da1->getNumberOfTuples());
+ CPPUNIT_ASSERT_EQUAL(3,da1->getNumberOfComponents());
+ for(int i=0;i<12;i++)
+ CPPUNIT_ASSERT_EQUAL(expected3[i],da1->getIJ(0,i));
+ da1->rearrange(1); da1->iota(2); da1->rearrange(3);
+ da2=DataArrayInt::Divide(da,da1);
+ CPPUNIT_ASSERT_EQUAL(4,da2->getNumberOfTuples());
+ CPPUNIT_ASSERT_EQUAL(3,da2->getNumberOfComponents());
+ for(int i=0;i<12;i++)
+ CPPUNIT_ASSERT_EQUAL(expected4[i],da2->getIJ(0,i));
+ da2->decrRef();
+ da1->applyInv(321);
+ CPPUNIT_ASSERT_EQUAL(4,da1->getNumberOfTuples());
+ CPPUNIT_ASSERT_EQUAL(3,da1->getNumberOfComponents());
+ const int expected5[12]={160,107,80,64,53,45,40,35,32,29,26,24};
+ for(int i=0;i<12;i++)
+ CPPUNIT_ASSERT_EQUAL(expected5[i],da1->getIJ(0,i));
+ da1->applyDivideBy(2);
+ CPPUNIT_ASSERT_EQUAL(4,da1->getNumberOfTuples());
+ CPPUNIT_ASSERT_EQUAL(3,da1->getNumberOfComponents());
+ const int expected6[12]={80,53,40,32,26,22,20,17,16,14,13,12};
+ for(int i=0;i<12;i++)
+ CPPUNIT_ASSERT_EQUAL(expected6[i],da1->getIJ(0,i));
+ const int expected7[12]={3,4,5,4,5,1,6,3,2,0,6,5};
+ da1->applyModulus(7);
+ for(int i=0;i<12;i++)
+ CPPUNIT_ASSERT_EQUAL(expected7[i],da1->getIJ(0,i));
+ da1->applyLin(1,1);
+ const int expected8[12]={3,3,3,3,3,1,3,3,0,0,3,3};
+ da1->applyRModulus(3);
+ for(int i=0;i<12;i++)
+ CPPUNIT_ASSERT_EQUAL(expected8[i],da1->getIJ(0,i));
+ //
+ da1->decrRef();
+ da->decrRef();
+}
+
+void MEDCouplingBasicsTest::testEmulateMEDMEMBDC1()
+{
+ MEDCouplingUMesh *m1=0;
+ MEDCouplingUMesh *m=buildPointe_1(m1);
+ DataArrayInt *da1=DataArrayInt::New();
+ DataArrayInt *da2=DataArrayInt::New();
+ DataArrayInt *da3=0;
+ DataArrayInt *da4=0;
+ DataArrayInt *da5=0;
+ DataArrayInt *da0=0;
+ MEDCouplingUMesh *m2=m->emulateMEDMEMBDC(m1,da1,da2,da3,da4,da5,da0);
+ const int expected0[47]={0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,36,37,32,33,34,35,38,39,40,41,42,43,44,45,46};
+ const int expected1[6]={1,32,29,23,41,36};
+ CPPUNIT_ASSERT_EQUAL(47,da0->getNumberOfTuples());
+ CPPUNIT_ASSERT_EQUAL(1,da0->getNumberOfComponents());
+ for(int i=0;i<47;i++)
+ CPPUNIT_ASSERT_EQUAL(expected0[i],da0->getIJ(0,i));
+ CPPUNIT_ASSERT_EQUAL(6,da5->getNumberOfTuples());
+ CPPUNIT_ASSERT_EQUAL(1,da5->getNumberOfComponents());
+ for(int i=0;i<6;i++)
+ CPPUNIT_ASSERT_EQUAL(expected1[i],da5->getIJ(0,i));
+ const int expected2[70]={0,1,2,3,4,0,5,6,7,4,8,9,1,7,10,11,12,13,14,5,15,16,17,8,18,19,20,10,21,22,23,2,13,24,25,21,16,26,27,12,19,28,29,15,22,30,31,18,36,26,28,30,24,37,32,33,34,35,38,36,39,40,41,42,37,38,43,44,45,46};
+ CPPUNIT_ASSERT_EQUAL(70,da1->getNumberOfTuples());
+ CPPUNIT_ASSERT_EQUAL(1,da1->getNumberOfComponents());
+ for(int i=0;i<70;i++)
+ CPPUNIT_ASSERT_EQUAL(expected2[i],da1->getIJ(0,i));
+ const int expected3[17]={0,4,8,12,16,20,24,28,32,36,40,44,48,53,58,64,70};
+ CPPUNIT_ASSERT_EQUAL(17,da2->getNumberOfTuples());
+ CPPUNIT_ASSERT_EQUAL(1,da2->getNumberOfComponents());
+ for(int i=0;i<17;i++)
+ CPPUNIT_ASSERT_EQUAL(expected3[i],da2->getIJ(0,i));
+ const int expected4[48]={0,2,4,6,7,9,11,12,14,16,17,19,20,22,24,25,27,29,30,32,34,35,37,39,40,42,43,45,46,48,49,51,52,53,54,55,56,58,60,62,63,64,65,66,67,68,69,70};
+ //const int expected4[48]={0,2,4,6,7,9,11,12,14,16,17,19,20,22,24,25,27,29,30,32,34,35,37,39,40,42,43,45,46,48,49,51,52,54,56,57,58,59,60,62,63,64,65,66,67,68,69,70};
+ CPPUNIT_ASSERT_EQUAL(48,da4->getNumberOfTuples());
+ CPPUNIT_ASSERT_EQUAL(1,da4->getNumberOfComponents());
+ for(int i=0;i<48;i++)
+ CPPUNIT_ASSERT_EQUAL(expected4[i],da4->getIJ(0,i));
+ const int expected5[70]={0,1,0,3,0,7,0,1,2,1,4,1,2,3,2,5,2,3,6,3,4,9,4,8,4,5,10,5,9,5,6,11,6,10,6,7,8,7,11,7,8,12,8,9,12,9,10,12,10,11,12,11,13,13,13,13,12,14,13,15,14,15,14,14,14,14,15,15,15,15};
+ CPPUNIT_ASSERT_EQUAL(70,da3->getNumberOfTuples());
+ CPPUNIT_ASSERT_EQUAL(1,da3->getNumberOfComponents());
+ for(int i=0;i<70;i++)
+ CPPUNIT_ASSERT_EQUAL(expected5[i],da3->getIJ(0,i));
+ //
+ da0->decrRef();
+ da1->decrRef();
+ da2->decrRef();
+ da3->decrRef();
+ da4->decrRef();
+ da5->decrRef();
+ //
+ m2->decrRef();
+ m1->decrRef();
+ m->decrRef();
+}
+
+void MEDCouplingBasicsTest::testGetLevArrPerCellTypes1()
+{
+ MEDCouplingUMesh *m1=0;
+ MEDCouplingUMesh *m=buildPointe_1(m1);
+ m1->decrRef();
+ DataArrayInt *d0=DataArrayInt::New();
+ DataArrayInt *d1=DataArrayInt::New();
+ DataArrayInt *d2=DataArrayInt::New();
+ DataArrayInt *d3=DataArrayInt::New();
+ m1=m->buildDescendingConnectivity(d0,d1,d2,d3);
+ d0->decrRef(); d1->decrRef(); d2->decrRef(); d3->decrRef();
+ INTERP_KERNEL::NormalizedCellType order[2]={INTERP_KERNEL::NORM_TRI3,INTERP_KERNEL::NORM_QUAD4};
+ DataArrayInt *da1=0;
+ DataArrayInt *da0=m1->getLevArrPerCellTypes(order,order+2,da1);
+ const int expected0[47]={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,1,1,1,1,1,1,1,1,1};
+ const int expected1[47]={0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,36,37,32,33,34,35,38,39,40,41,42,43,44,45,46};
+ CPPUNIT_ASSERT_EQUAL(47,da0->getNumberOfTuples());
+ CPPUNIT_ASSERT_EQUAL(1,da0->getNumberOfComponents());
+ for(int i=0;i<47;i++)
+ CPPUNIT_ASSERT_EQUAL(expected0[i],da0->getIJ(0,i));
+ CPPUNIT_ASSERT_EQUAL(2,da1->getNumberOfTuples());
+ CPPUNIT_ASSERT_EQUAL(1,da1->getNumberOfComponents());
+ CPPUNIT_ASSERT_EQUAL(36,da1->getIJ(0,0));//36 TRI3
+ CPPUNIT_ASSERT_EQUAL(11,da1->getIJ(1,0));//11 QUAD4
+ //
+ DataArrayInt *da2=da0->buildPermArrPerLevel();
+ //
+ CPPUNIT_ASSERT_EQUAL(47,da2->getNumberOfTuples());
+ CPPUNIT_ASSERT_EQUAL(1,da2->getNumberOfComponents());
+ for(int i=0;i<47;i++)
+ CPPUNIT_ASSERT_EQUAL(expected1[i],da2->getIJ(0,i));
+ da2->decrRef();
+ da0->decrRef();
+ da1->decrRef();
+ //
+ m->decrRef();
+ m1->decrRef();
+}
#include "MEDCouplingFieldDouble.hxx"
#include "MEDCouplingMemArray.hxx"
#include "Interpolation2D.txx"
-#include "Interpolation3DSurf.txx"
+#include "Interpolation3DSurf.hxx"
#include "Interpolation3D.txx"
#include "InterpolationCC.txx"
#include "InterpolationCU.txx"
-#include "Interpolation2DCurve.txx"
+#include "Interpolation2DCurve.hxx"
#include "Interpolation1D.txx"
#include "MEDCouplingNormalizedUnstructuredMesh.txx"
INTERP_KERNEL::Interpolation3D myInterpolator;
std::vector<std::map<int,double> > res;
myInterpolator.setPrecision(1e-12);
- myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P0P0");
- CPPUNIT_ASSERT_EQUAL(8,(int)res.size());
- CPPUNIT_ASSERT_DOUBLES_EQUAL(8.e6,sumAll(res),1e-7);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(20833.33333333333,res[0][0],1e-7);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(41666.66666666667,res[0][6],1e-7);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(20833.33333333333,res[0][7],1e-7);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(20833.33333333333,res[0][8],1e-7);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(20833.33333333333,res[0][10],1e-7);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(41666.66666666667,res[1][2],1e-7);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(166666.6666666667,res[1][7],1e-7);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(166666.6666666667,res[1][8],1e-7);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(166666.6666666667,res[2][0],1e-7);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(20833.33333333333,res[2][5],1e-7);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(145833.3333333333,res[2][6],1e-7);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(20833.33333333333,res[2][9],1e-7);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(20833.33333333333,res[2][11],1e-7);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(395833.3333333333,res[3][0],1e-7);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(145833.3333333333,res[3][2],1e-7);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(20833.33333333331,res[3][3],1e-7);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(166666.6666666667,res[3][5],1e-7);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(395833.3333333333,res[3][8],1e-7);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(20833.33333333333,res[4][1],1e-7);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(20833.33333333333,res[4][4],1e-7);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(145833.3333333333,res[4][6],1e-7);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(20833.33333333333,res[4][9],1e-7);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(166666.6666666667,res[4][10],1e-7);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(145833.3333333333,res[5][2],1e-7);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(20833.33333333331,res[5][3],1e-7);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(166666.6666666667,res[5][4],1e-7);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(395833.3333333333,res[5][7],1e-7);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(395833.3333333333,res[5][10],1e-7);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(166666.6666666667,res[6][1],1e-7);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(250000,res[6][6],1e-7);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(541666.6666666667,res[6][9],1e-7);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(166666.6666666667,res[6][11],1e-7);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(83333.33333333331,res[7][0],1e-7);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(479166.6666666667,res[7][1],1e-7);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(333333.3333333333,res[7][2],1e-7);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(624999.9999999997,res[7][3],1e-7);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(479166.6666666667,res[7][4],1e-7);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(479166.6666666667,res[7][5],1e-7);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(83333.33333333333,res[7][6],1e-7);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(83333.33333333331,res[7][7],1e-7);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(83333.33333333333,res[7][8],1e-7);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(83333.33333333333,res[7][9],1e-7);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(83333.33333333331,res[7][10],1e-7);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(479166.6666666667,res[7][11],1e-7);
+ INTERP_KERNEL::SplittingPolicy sp[] = { INTERP_KERNEL::PLANAR_FACE_5, INTERP_KERNEL::PLANAR_FACE_6, INTERP_KERNEL::GENERAL_24, INTERP_KERNEL::GENERAL_48 };
+ for ( int i = 0; i < 4; ++i )
+ {
+ myInterpolator.setSplittingPolicy( sp[i] );
+ res.clear();
+ myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P0P0");
+ CPPUNIT_ASSERT_EQUAL(8,(int)res.size());
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(8.e6,sumAll(res),1e-7);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(20833.33333333333,res[0][0],1e-7);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(41666.66666666667,res[0][6],1e-7);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(20833.33333333333,res[0][7],1e-7);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(20833.33333333333,res[0][8],1e-7);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(20833.33333333333,res[0][10],1e-7);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(41666.66666666667,res[1][2],1e-7);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(166666.6666666667,res[1][7],1e-7);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(166666.6666666667,res[1][8],1e-7);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(166666.6666666667,res[2][0],1e-7);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(20833.33333333333,res[2][5],1e-7);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(145833.3333333333,res[2][6],1e-7);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(20833.33333333333,res[2][9],1e-7);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(20833.33333333333,res[2][11],1e-7);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(395833.3333333333,res[3][0],1e-7);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(145833.3333333333,res[3][2],1e-7);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(20833.33333333331,res[3][3],1e-7);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(166666.6666666667,res[3][5],1e-7);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(395833.3333333333,res[3][8],1e-7);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(20833.33333333333,res[4][1],1e-7);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(20833.33333333333,res[4][4],1e-7);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(145833.3333333333,res[4][6],1e-7);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(20833.33333333333,res[4][9],1e-7);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(166666.6666666667,res[4][10],1e-7);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(145833.3333333333,res[5][2],1e-7);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(20833.33333333331,res[5][3],1e-7);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(166666.6666666667,res[5][4],1e-7);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(395833.3333333333,res[5][7],1e-7);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(395833.3333333333,res[5][10],1e-7);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(166666.6666666667,res[6][1],1e-7);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(250000,res[6][6],1e-7);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(541666.6666666667,res[6][9],1e-7);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(166666.6666666667,res[6][11],1e-7);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(83333.33333333331,res[7][0],1e-7);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(479166.6666666667,res[7][1],1e-7);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(333333.3333333333,res[7][2],1e-7);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(624999.9999999997,res[7][3],1e-7);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(479166.6666666667,res[7][4],1e-7);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(479166.6666666667,res[7][5],1e-7);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(83333.33333333333,res[7][6],1e-7);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(83333.33333333331,res[7][7],1e-7);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(83333.33333333333,res[7][8],1e-7);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(83333.33333333333,res[7][9],1e-7);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(83333.33333333331,res[7][10],1e-7);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(479166.6666666667,res[7][11],1e-7);
+ }
//clean up
sourceMesh->decrRef();
targetMesh->decrRef();
std::vector<std::map<int,double> > res;
myInterpolator.setPrecision(1e-12);
myInterpolator.setIntersectionType(INTERP_KERNEL::PointLocator);
- myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P0P0");
- CPPUNIT_ASSERT_EQUAL(8,(int)res.size());
- CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][0],1e-12);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][6],1e-12);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][7],1e-12);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][8],1e-12);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][10],1e-12);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[1][7],1e-12);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[1][8],1e-12);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[2][0],1e-12);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[2][6],1e-12);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[3][0],1e-12);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[3][8],1e-12);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[4][6],1e-12);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[4][10],1e-12);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[5][7],1e-12);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[5][10],1e-12);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[6][9],1e-12);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[7][1],1e-12);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[7][3],1e-12);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[7][4],1e-12);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[7][5],1e-12);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[7][11],1e-12);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(21.,sumAll(res),1e-12);
+ INTERP_KERNEL::SplittingPolicy sp[] = { INTERP_KERNEL::PLANAR_FACE_5, INTERP_KERNEL::PLANAR_FACE_6, INTERP_KERNEL::GENERAL_24, INTERP_KERNEL::GENERAL_48 };
+ for ( int i = 0; i < 4; ++i )
+ {
+ myInterpolator.setSplittingPolicy( sp[i] );
+ res.clear();
+ myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P0P0");
+ CPPUNIT_ASSERT_EQUAL(8,(int)res.size());
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][0],1e-12);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][6],1e-12);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][7],1e-12);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][8],1e-12);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][10],1e-12);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[1][7],1e-12);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[1][8],1e-12);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[2][0],1e-12);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[2][6],1e-12);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[3][0],1e-12);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[3][8],1e-12);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[4][6],1e-12);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[4][10],1e-12);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[5][7],1e-12);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[5][10],1e-12);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[6][9],1e-12);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[7][1],1e-12);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[7][3],1e-12);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[7][4],1e-12);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[7][5],1e-12);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[7][11],1e-12);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(21.,sumAll(res),1e-12);
+ }
//clean up
sourceMesh->decrRef();
targetMesh->decrRef();
std::vector<std::map<int,double> > res;
myInterpolator.setPrecision(1e-12);
myInterpolator.setIntersectionType(INTERP_KERNEL::PointLocator);
- myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P0P0");
- CPPUNIT_ASSERT_EQUAL(8,(int)res.size());
- CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][0],1e-12);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][6],1e-12);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][7],1e-12);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][8],1e-12);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][10],1e-12);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[1][7],1e-12);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[1][8],1e-12);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[2][0],1e-12);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[2][6],1e-12);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[3][0],1e-12);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[3][8],1e-12);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[4][6],1e-12);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[4][10],1e-12);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[5][7],1e-12);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[5][10],1e-12);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[6][9],1e-12);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[7][1],1e-12);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[7][3],1e-12);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[7][4],1e-12);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[7][5],1e-12);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[7][11],1e-12);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(21.,sumAll(res),1e-12);
+ INTERP_KERNEL::SplittingPolicy sp[] = { INTERP_KERNEL::PLANAR_FACE_5, INTERP_KERNEL::PLANAR_FACE_6, INTERP_KERNEL::GENERAL_24, INTERP_KERNEL::GENERAL_48 };
+ for ( int i = 0; i < 4; ++i )
+ {
+ myInterpolator.setSplittingPolicy( sp[i] );
+ res.clear();
+ myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P0P0");
+ CPPUNIT_ASSERT_EQUAL(8,(int)res.size());
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][0],1e-12);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][6],1e-12);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][7],1e-12);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][8],1e-12);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][10],1e-12);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[1][7],1e-12);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[1][8],1e-12);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[2][0],1e-12);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[2][6],1e-12);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[3][0],1e-12);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[3][8],1e-12);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[4][6],1e-12);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[4][10],1e-12);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[5][7],1e-12);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[5][10],1e-12);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[6][9],1e-12);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[7][1],1e-12);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[7][3],1e-12);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[7][4],1e-12);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[7][5],1e-12);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[7][11],1e-12);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(21.,sumAll(res),1e-12);
+ }
//clean up
sourceMesh->decrRef();
targetMesh->decrRef();
std::vector<std::map<int,double> > res;
myInterpolator.setPrecision(1e-12);
myInterpolator.setIntersectionType(INTERP_KERNEL::PointLocator);
- myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P0P0");
- CPPUNIT_ASSERT_EQUAL(8,(int)res.size());
- CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][0],1e-12);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][6],1e-12);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][7],1e-12);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][8],1e-12);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][10],1e-12);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[1][7],1e-12);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[1][8],1e-12);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[2][0],1e-12);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[2][6],1e-12);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[3][0],1e-12);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[3][8],1e-12);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[4][6],1e-12);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[4][10],1e-12);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[5][7],1e-12);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[5][10],1e-12);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[6][9],1e-12);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[7][1],1e-12);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[7][3],1e-12);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[7][4],1e-12);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[7][5],1e-12);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[7][11],1e-12);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(21.,sumAll(res),1e-12);
+ INTERP_KERNEL::SplittingPolicy sp[] = { INTERP_KERNEL::PLANAR_FACE_5, INTERP_KERNEL::PLANAR_FACE_6, INTERP_KERNEL::GENERAL_24, INTERP_KERNEL::GENERAL_48 };
+ for ( int i = 0; i < 4; ++i )
+ {
+ myInterpolator.setSplittingPolicy( sp[i] );
+ res.clear();
+ myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P0P0");
+ CPPUNIT_ASSERT_EQUAL(8,(int)res.size());
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][0],1e-12);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][6],1e-12);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][7],1e-12);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][8],1e-12);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][10],1e-12);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[1][7],1e-12);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[1][8],1e-12);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[2][0],1e-12);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[2][6],1e-12);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[3][0],1e-12);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[3][8],1e-12);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[4][6],1e-12);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[4][10],1e-12);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[5][7],1e-12);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[5][10],1e-12);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[6][9],1e-12);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[7][1],1e-12);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[7][3],1e-12);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[7][4],1e-12);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[7][5],1e-12);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[7][11],1e-12);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(21.,sumAll(res),1e-12);
+ }
//clean up
sourceMesh->decrRef();
targetMesh->decrRef();
std::vector<std::map<int,double> > res;
myInterpolator.setPrecision(1e-12);
myInterpolator.setIntersectionType(INTERP_KERNEL::PointLocator);
- myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P0P0");
- CPPUNIT_ASSERT_EQUAL(8,(int)res.size());
- CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][0],1e-12);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][6],1e-12);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][7],1e-12);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][8],1e-12);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][10],1e-12);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[1][7],1e-12);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[1][8],1e-12);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[2][0],1e-12);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[2][6],1e-12);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[3][0],1e-12);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[3][8],1e-12);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[4][6],1e-12);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[4][10],1e-12);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[5][7],1e-12);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[5][10],1e-12);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[6][9],1e-12);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[7][1],1e-12);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[7][3],1e-12);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[7][4],1e-12);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[7][5],1e-12);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[7][11],1e-12);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(21.,sumAll(res),1e-12);
+ INTERP_KERNEL::SplittingPolicy sp[] = { INTERP_KERNEL::PLANAR_FACE_5, INTERP_KERNEL::PLANAR_FACE_6, INTERP_KERNEL::GENERAL_24, INTERP_KERNEL::GENERAL_48 };
+ for ( int i = 0; i < 4; ++i )
+ {
+ myInterpolator.setSplittingPolicy( sp[i] );
+ res.clear();
+ myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P0P0");
+ CPPUNIT_ASSERT_EQUAL(8,(int)res.size());
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][0],1e-12);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][6],1e-12);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][7],1e-12);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][8],1e-12);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][10],1e-12);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[1][7],1e-12);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[1][8],1e-12);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[2][0],1e-12);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[2][6],1e-12);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[3][0],1e-12);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[3][8],1e-12);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[4][6],1e-12);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[4][10],1e-12);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[5][7],1e-12);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[5][10],1e-12);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[6][9],1e-12);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[7][1],1e-12);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[7][3],1e-12);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[7][4],1e-12);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[7][5],1e-12);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[7][11],1e-12);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(21.,sumAll(res),1e-12);
+ }
//clean up
sourceMesh->decrRef();
targetMesh->decrRef();
INTERP_KERNEL::Interpolation3D myInterpolator;
std::vector<std::map<int,double> > res;
myInterpolator.setPrecision(1e-12);
- myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P0P1");
- CPPUNIT_ASSERT_EQUAL(9,(int)res.size());
- CPPUNIT_ASSERT_DOUBLES_EQUAL(244444.4444444445,res[0][4],1e-7);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(145833.3333333333,res[0][5],1e-7);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(291666.6666666666,res[0][6],1e-7);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(151388.8888888889,res[0][7],1e-7);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(125000,res[1][0],1e-7);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(140277.7777777778,res[1][1],1e-7);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(119444.4444444444,res[1][2],1e-7);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(151388.8888888889,res[1][3],1e-7);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(119444.4444444444,res[1][4],1e-7);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(151388.8888888889,res[1][5],1e-7);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(26388.88888888889,res[1][6],1e-7);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(348611.1111111111,res[2][6],1e-7);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(151388.8888888888,res[2][7],1e-7);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(244444.4444444444,res[3][2],1e-7);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(145833.3333333334,res[3][3],1e-7);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(291666.6666666666,res[3][6],1e-7);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(151388.8888888889,res[3][7],1e-7);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(536111.111111111,res[4][5],1e-7);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(297222.2222222221,res[4][7],1e-7);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(223611.1111111111,res[5][1],1e-7);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(125000,res[5][3],1e-7);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(125000,res[5][5],1e-7);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(26388.88888888892,res[5][7],1e-7);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(833333.333333333,res[6][7],1e-7);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(536111.1111111109,res[7][3],1e-7);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(297222.2222222221,res[7][7],1e-7);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(11111.1111111111,res[8][1],1e-7);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(11111.11111111111,res[8][2],1e-7);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(166666.6666666666,res[8][3],1e-7);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(11111.11111111111,res[8][4],1e-7);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(166666.6666666667,res[8][5],1e-7);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(166666.6666666667,res[8][6],1e-7);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(1466666.666666668,res[8][7],1e-7);
+ INTERP_KERNEL::SplittingPolicy sp[] = { INTERP_KERNEL::PLANAR_FACE_5, INTERP_KERNEL::PLANAR_FACE_6, INTERP_KERNEL::GENERAL_24, INTERP_KERNEL::GENERAL_48 };
+ for ( int i = 0; i < 4; ++i )
+ {
+ myInterpolator.setSplittingPolicy( sp[i] );
+ res.clear();
+ myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P0P1");
+ CPPUNIT_ASSERT_EQUAL(9,(int)res.size());
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(244444.4444444445,res[0][4],1e-7);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(145833.3333333333,res[0][5],1e-7);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(291666.6666666666,res[0][6],1e-7);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(151388.8888888889,res[0][7],1e-7);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(125000,res[1][0],1e-7);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(140277.7777777778,res[1][1],1e-7);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(119444.4444444444,res[1][2],1e-7);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(151388.8888888889,res[1][3],1e-7);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(119444.4444444444,res[1][4],1e-7);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(151388.8888888889,res[1][5],1e-7);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(26388.88888888889,res[1][6],1e-7);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(348611.1111111111,res[2][6],1e-7);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(151388.8888888888,res[2][7],1e-7);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(244444.4444444444,res[3][2],1e-7);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(145833.3333333334,res[3][3],1e-7);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(291666.6666666666,res[3][6],1e-7);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(151388.8888888889,res[3][7],1e-7);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(536111.111111111,res[4][5],1e-7);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(297222.2222222221,res[4][7],1e-7);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(223611.1111111111,res[5][1],1e-7);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(125000,res[5][3],1e-7);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(125000,res[5][5],1e-7);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(26388.88888888892,res[5][7],1e-7);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(833333.333333333,res[6][7],1e-7);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(536111.1111111109,res[7][3],1e-7);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(297222.2222222221,res[7][7],1e-7);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(11111.1111111111,res[8][1],1e-7);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(11111.11111111111,res[8][2],1e-7);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(166666.6666666666,res[8][3],1e-7);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(11111.11111111111,res[8][4],1e-7);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(166666.6666666667,res[8][5],1e-7);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(166666.6666666667,res[8][6],1e-7);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(1466666.666666668,res[8][7],1e-7);
+ }
//clean up
sourceMesh->decrRef();
targetMesh->decrRef();
std::vector<std::map<int,double> > res;
myInterpolator.setPrecision(1e-12);
myInterpolator.setIntersectionType(INTERP_KERNEL::PointLocator);
- myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P0P1");
- CPPUNIT_ASSERT_EQUAL(9,(int)res.size());
- CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][4],1e-12);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[1][0],1e-12);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[2][6],1e-12);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[3][2],1e-12);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[4][5],1e-12);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[5][1],1e-12);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[6][7],1e-12);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[7][3],1e-12);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[8][7],1e-12);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(9.,sumAll(res),1e-12);
+ INTERP_KERNEL::SplittingPolicy sp[] = { INTERP_KERNEL::PLANAR_FACE_5, INTERP_KERNEL::PLANAR_FACE_6, INTERP_KERNEL::GENERAL_24, INTERP_KERNEL::GENERAL_48 };
+ for ( int i = 0; i < 4; ++i )
+ {
+ myInterpolator.setSplittingPolicy( sp[i] );
+ res.clear();
+ myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P0P1");
+ CPPUNIT_ASSERT_EQUAL(9,(int)res.size());
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][4],1e-12);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[1][0],1e-12);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[2][6],1e-12);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[3][2],1e-12);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[4][5],1e-12);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[5][1],1e-12);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[6][7],1e-12);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[7][3],1e-12);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[8][7],1e-12);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(9.,sumAll(res),1e-12);
+ }
//clean up
sourceMesh->decrRef();
targetMesh->decrRef();
INTERP_KERNEL::Interpolation3D myInterpolator;
std::vector<std::map<int,double> > res;
myInterpolator.setPrecision(1e-12);
- myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P1P0");
- CPPUNIT_ASSERT_EQUAL(8,(int)res.size());
- CPPUNIT_ASSERT_DOUBLES_EQUAL(125000,res[0][1],1e-7);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(140277.7777777778,res[1][1],1e-7);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(223611.1111111111,res[1][5],1e-7);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(11111.1111111111,res[1][8],1e-7);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(119444.4444444444,res[2][1],1e-7);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(244444.4444444445,res[2][3],1e-7);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(11111.11111111111,res[2][8],1e-7);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(151388.8888888889,res[3][1],1e-7);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(145833.3333333333,res[3][3],1e-7);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(125000,res[3][5],1e-7);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(536111.1111111109,res[3][7],1e-7);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(166666.6666666667,res[3][8],1e-7);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(244444.4444444445,res[4][0],1e-7);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(119444.4444444445,res[4][1],1e-7);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(11111.11111111111,res[4][8],1e-7);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(145833.3333333333,res[5][0],1e-7);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(151388.8888888889,res[5][1],1e-7);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(536111.1111111109,res[5][4],1e-7);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(125000,res[5][5],1e-7);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(166666.6666666666,res[5][8],1e-7);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(291666.6666666666,res[6][0],1e-7);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(26388.88888888889,res[6][1],1e-7);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(348611.1111111112,res[6][2],1e-7);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(291666.6666666667,res[6][3],1e-7);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(166666.6666666666,res[6][8],1e-7);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(151388.8888888889,res[7][0],1e-7);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(151388.8888888889,res[7][2],1e-7);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(151388.8888888889,res[7][3],1e-7);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(297222.2222222221,res[7][4],1e-7);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(26388.88888888892,res[7][5],1e-7);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(833333.333333333,res[7][6],1e-7);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(297222.2222222222,res[7][7],1e-7);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(1466666.666666668,res[7][8],1e-7);
+ INTERP_KERNEL::SplittingPolicy sp[] = { INTERP_KERNEL::PLANAR_FACE_5, INTERP_KERNEL::PLANAR_FACE_6, INTERP_KERNEL::GENERAL_24, INTERP_KERNEL::GENERAL_48 };
+ for ( int i = 0; i < 4; ++i )
+ {
+ myInterpolator.setSplittingPolicy( sp[i] );
+ res.clear();
+ myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P1P0");
+ CPPUNIT_ASSERT_EQUAL(8,(int)res.size());
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(125000,res[0][1],1e-7);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(140277.7777777778,res[1][1],1e-7);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(223611.1111111111,res[1][5],1e-7);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(11111.1111111111,res[1][8],1e-7);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(119444.4444444444,res[2][1],1e-7);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(244444.4444444445,res[2][3],1e-7);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(11111.11111111111,res[2][8],1e-7);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(151388.8888888889,res[3][1],1e-7);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(145833.3333333333,res[3][3],1e-7);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(125000,res[3][5],1e-7);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(536111.1111111109,res[3][7],1e-7);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(166666.6666666667,res[3][8],1e-7);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(244444.4444444445,res[4][0],1e-7);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(119444.4444444445,res[4][1],1e-7);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(11111.11111111111,res[4][8],1e-7);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(145833.3333333333,res[5][0],1e-7);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(151388.8888888889,res[5][1],1e-7);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(536111.1111111109,res[5][4],1e-7);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(125000,res[5][5],1e-7);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(166666.6666666666,res[5][8],1e-7);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(291666.6666666666,res[6][0],1e-7);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(26388.88888888889,res[6][1],1e-7);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(348611.1111111112,res[6][2],1e-7);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(291666.6666666667,res[6][3],1e-7);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(166666.6666666666,res[6][8],1e-7);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(151388.8888888889,res[7][0],1e-7);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(151388.8888888889,res[7][2],1e-7);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(151388.8888888889,res[7][3],1e-7);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(297222.2222222221,res[7][4],1e-7);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(26388.88888888892,res[7][5],1e-7);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(833333.333333333,res[7][6],1e-7);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(297222.2222222222,res[7][7],1e-7);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(1466666.666666668,res[7][8],1e-7);
+ }
//clean up
sourceMesh->decrRef();
targetMesh->decrRef();
std::vector<std::map<int,double> > res;
myInterpolator.setPrecision(1e-12);
myInterpolator.setIntersectionType(INTERP_KERNEL::PointLocator);
- myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P1P0");
- CPPUNIT_ASSERT_EQUAL(8,(int)res.size());
- CPPUNIT_ASSERT_DOUBLES_EQUAL(3.75,res[0][1],1e-12);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(1.25,res[0][8],1e-12);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(0.5,res[1][1],1e-12);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[1][5],1e-12);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(0.5,res[1][8],1e-12);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(0.5,res[2][1],1e-12);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[2][3],1e-12);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(0.5,res[2][8],1e-12);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(0.5,res[3][1],1e-12);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[3][7],1e-12);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(0.5,res[3][8],1e-12);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[4][0],1e-12);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(0.5,res[4][1],1e-12);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(0.5,res[4][8],1e-12);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(0.5,res[5][1],1e-12);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[5][4],1e-12);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(0.5,res[5][8],1e-12);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(0.25,res[6][0],1e-12);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(0.25,res[6][2],1e-12);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(0.25,res[6][3],1e-12);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(0.25,res[6][8],1e-12);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(1.25,res[7][6],1e-12);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(3.75,res[7][8],1e-12);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(21.,sumAll(res),1e-12);
+ INTERP_KERNEL::SplittingPolicy sp[] = { INTERP_KERNEL::PLANAR_FACE_5, INTERP_KERNEL::PLANAR_FACE_6, INTERP_KERNEL::GENERAL_24, INTERP_KERNEL::GENERAL_48 };
+ for ( int i = 0; i < 4; ++i )
+ {
+ myInterpolator.setSplittingPolicy( sp[i] );
+ res.clear();
+ myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P1P0");
+ CPPUNIT_ASSERT_EQUAL(8,(int)res.size());
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(3.75,res[0][1],1e-12);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(1.25,res[0][8],1e-12);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(0.5,res[1][1],1e-12);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[1][5],1e-12);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(0.5,res[1][8],1e-12);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(0.5,res[2][1],1e-12);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[2][3],1e-12);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(0.5,res[2][8],1e-12);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(0.5,res[3][1],1e-12);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[3][7],1e-12);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(0.5,res[3][8],1e-12);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[4][0],1e-12);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(0.5,res[4][1],1e-12);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(0.5,res[4][8],1e-12);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(0.5,res[5][1],1e-12);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[5][4],1e-12);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(0.5,res[5][8],1e-12);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(0.25,res[6][0],1e-12);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(0.25,res[6][2],1e-12);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(0.25,res[6][3],1e-12);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(0.25,res[6][8],1e-12);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(1.25,res[7][6],1e-12);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(3.75,res[7][8],1e-12);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(21.,sumAll(res),1e-12);
+ }
//clean up
sourceMesh->decrRef();
targetMesh->decrRef();
#include "MEDCouplingUMesh.hxx"
#include "MEDCouplingExtrudedMesh.hxx"
#include "MEDCouplingFieldDouble.hxx"
+#include "MEDCouplingFieldTemplate.hxx"
#include "MEDCouplingMemArray.hxx"
#include "MEDCouplingRemapper.hxx"
meshTF->decrRef();
}
+void MEDCouplingRemapperTest::testPrepareEx1()
+{
+ MEDCouplingUMesh *sourceMesh=MEDCouplingBasicsTest::build2DSourceMesh_1();
+ MEDCouplingUMesh *targetMesh=build2DTargetMesh_3();
+ //
+ MEDCouplingRemapper remapper;
+ remapper.setPrecision(1e-12);
+ remapper.setIntersectionType(INTERP_KERNEL::Triangulation);
+ MEDCouplingFieldTemplate *srcFt=MEDCouplingFieldTemplate::New(ON_CELLS);
+ MEDCouplingFieldTemplate *trgFt=MEDCouplingFieldTemplate::New(ON_CELLS);
+ srcFt->setMesh(sourceMesh);
+ trgFt->setMesh(targetMesh);
+ CPPUNIT_ASSERT_EQUAL(1,remapper.prepareEx(srcFt,trgFt));
+ srcFt->decrRef();
+ trgFt->decrRef();
+ MEDCouplingFieldDouble *srcField=MEDCouplingFieldDouble::New(ON_CELLS);
+ srcField->setNature(ConservativeVolumic);
+ srcField->setMesh(sourceMesh);
+ DataArrayDouble *array=DataArrayDouble::New();
+ array->alloc(sourceMesh->getNumberOfCells(),1);
+ srcField->setArray(array);
+ double *ptr=array->getPointer();
+ for(int i=0;i<sourceMesh->getNumberOfCells();i++)
+ ptr[i]=(double)(i+7);
+ array->decrRef();
+ MEDCouplingFieldDouble *trgfield=remapper.transferField(srcField,4.220173);
+ const double *values=trgfield->getArray()->getConstPointer();
+ const double valuesExpected[4]={7.75, 7.0625, 4.220173,8.0};
+ CPPUNIT_ASSERT_EQUAL(4,trgfield->getArray()->getNumberOfTuples());
+ CPPUNIT_ASSERT_EQUAL(1,trgfield->getArray()->getNumberOfComponents());
+ for(int i0=0;i0<4;i0++)
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(valuesExpected[i0],values[i0],1e-12);
+ trgfield->decrRef();
+ srcField->decrRef();
+ sourceMesh->decrRef();
+ targetMesh->decrRef();
+}
+
MEDCouplingUMesh *MEDCouplingRemapperTest::build1DTargetMesh_2()
{
double targetCoords[20]={
CPPUNIT_TEST( testNatureOfField );
CPPUNIT_TEST( testExtruded );
CPPUNIT_TEST( testExtruded2 );
+ CPPUNIT_TEST( testPrepareEx1 );
CPPUNIT_TEST_SUITE_END();
public:
void test2DInterpP0P0_1();
void testNatureOfField();
void testExtruded();
void testExtruded2();
+ void testPrepareEx1();
private:
static MEDCouplingUMesh *build1DTargetMesh_2();
static MEDCouplingUMesh *build2DTargetMesh_3();
TestMEDCoupling_LDFLAGS = @CPPUNIT_LIBS@ ../libmedcoupling.la ../../INTERP_KERNEL/libinterpkernel.la
dist_TestMEDCoupling_SOURCES = TestMEDCoupling.cxx MEDCouplingBasicsTest.hxx MEDCouplingBasicsTest0.cxx MEDCouplingBasicsTest1.cxx \
- MEDCouplingBasicsTest2.cxx MEDCouplingBasicsTestInterp.cxx MEDCouplingBasicsTestData1.hxx
+ MEDCouplingBasicsTest2.cxx MEDCouplingBasicsTest3.cxx MEDCouplingBasicsTestInterp.cxx MEDCouplingBasicsTestData1.hxx \
+ MEDCouplingBasicsTest4.cxx
TestMEDCouplingRemapper_CPPFLAGS=@CPPUNIT_INCLUDES@ @PTHREAD_CFLAGS@ -I$(srcdir)/.. -I$(srcdir)/../../INTERP_KERNEL/Bases -I$(srcdir)/../../INTERP_KERNELTest -I$(srcdir)/../../INTERP_KERNEL -I$(srcdir)/../../INTERP_KERNEL/Geometric2D
-TestMEDCouplingRemapper_LDFLAGS = @CPPUNIT_LIBS@ ../libmedcouplingremapper.la ../../INTERP_KERNEL/libinterpkernel.la
+TestMEDCouplingRemapper_LDFLAGS = @CPPUNIT_LIBS@ ../libmedcouplingremapper.la ../../INTERP_KERNEL/libinterpkernel.la ../libmedcoupling.la
dist_TestMEDCouplingRemapper_SOURCES = TestMEDCouplingRemapper.cxx MEDCouplingRemapperTest.hxx MEDCouplingRemapperTest.cxx MEDCouplingBasicsTest0.cxx
CLEANFILES = \
UnitTestsResult
-
\ No newline at end of file
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
-#include "CppUnitTest.hxx"
#include "MEDCouplingBasicsTest.hxx"
CPPUNIT_TEST_SUITE_REGISTRATION( ParaMEDMEM::MEDCouplingBasicsTest );
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
-#include "CppUnitTest.hxx"
#include "MEDCouplingRemapperTest.hxx"
CPPUNIT_TEST_SUITE_REGISTRATION( ParaMEDMEM::MEDCouplingRemapperTest );
--- /dev/null
+// Copyright (C) 2007-2010 CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+%module MEDCoupling
+
+#define MEDCOUPLING_EXPORT
+
+%include std_vector.i
+%include std_string.i
+
+%{
+#include "MEDCouplingMemArray.hxx"
+#include "MEDCouplingUMesh.hxx"
+#include "MEDCouplingExtrudedMesh.hxx"
+#include "MEDCouplingCMesh.hxx"
+#include "MEDCouplingField.hxx"
+#include "MEDCouplingFieldDouble.hxx"
+#include "MEDCouplingFieldTemplate.hxx"
+#include "MEDCouplingGaussLocalization.hxx"
+#include "MEDCouplingAutoRefCountObjectPtr.hxx"
+#include "MEDCouplingMultiFields.hxx"
+#include "MEDCouplingFieldOverTime.hxx"
+#include "MEDCouplingDefinitionTime.hxx"
+#include "MEDCouplingTypemaps.i"
+
+#include "InterpKernelAutoPtr.hxx"
+
+using namespace ParaMEDMEM;
+using namespace INTERP_KERNEL;
+%}
+
+%template(ivec) std::vector<int>;
+%template(dvec) std::vector<double>;
+%template(svec) std::vector<std::string>;
+
+%typemap(out) ParaMEDMEM::MEDCouplingMesh*
+{
+ $result=convertMesh($1,$owner);
+}
+
+%typemap(out) ParaMEDMEM::MEDCouplingPointSet*
+{
+ $result=convertMesh($1,$owner);
+}
+
+%typemap(out) ParaMEDMEM::MEDCouplingMultiFields*
+{
+ $result=convertMultiFields($1,$owner);
+}
+
+#ifdef WITH_NUMPY2
+%init %{ import_array(); %}
+#endif
+
+%feature("autodoc", "1");
+%feature("docstring");
+
+%newobject ParaMEDMEM::MEDCouplingField::buildMeasureField;
+%newobject ParaMEDMEM::MEDCouplingField::getLocalizationOfDiscr;
+%newobject ParaMEDMEM::MEDCouplingFieldDouble::New;
+%newobject ParaMEDMEM::MEDCouplingFieldDouble::getArray;
+%newobject ParaMEDMEM::MEDCouplingFieldDouble::getEndArray;
+%newobject ParaMEDMEM::MEDCouplingFieldDouble::MergeFields;
+%newobject ParaMEDMEM::MEDCouplingFieldDouble::MeldFields;
+%newobject ParaMEDMEM::MEDCouplingFieldDouble::doublyContractedProduct;
+%newobject ParaMEDMEM::MEDCouplingFieldDouble::determinant;
+%newobject ParaMEDMEM::MEDCouplingFieldDouble::eigenValues;
+%newobject ParaMEDMEM::MEDCouplingFieldDouble::eigenVectors;
+%newobject ParaMEDMEM::MEDCouplingFieldDouble::inverse;
+%newobject ParaMEDMEM::MEDCouplingFieldDouble::trace;
+%newobject ParaMEDMEM::MEDCouplingFieldDouble::deviator;
+%newobject ParaMEDMEM::MEDCouplingFieldDouble::magnitude;
+%newobject ParaMEDMEM::MEDCouplingFieldDouble::maxPerTuple;
+%newobject ParaMEDMEM::MEDCouplingFieldDouble::keepSelectedComponents;
+%newobject ParaMEDMEM::MEDCouplingFieldDouble::DotFields;
+%newobject ParaMEDMEM::MEDCouplingFieldDouble::dot;
+%newobject ParaMEDMEM::MEDCouplingFieldDouble::CrossProductFields;
+%newobject ParaMEDMEM::MEDCouplingFieldDouble::crossProduct;
+%newobject ParaMEDMEM::MEDCouplingFieldDouble::MaxFields;
+%newobject ParaMEDMEM::MEDCouplingFieldDouble::max;
+%newobject ParaMEDMEM::MEDCouplingFieldDouble::MinFields;
+%newobject ParaMEDMEM::MEDCouplingFieldDouble::AddFields;
+%newobject ParaMEDMEM::MEDCouplingFieldDouble::SubstractFields;
+%newobject ParaMEDMEM::MEDCouplingFieldDouble::MultiplyFields;
+%newobject ParaMEDMEM::MEDCouplingFieldDouble::DivideFields;
+%newobject ParaMEDMEM::MEDCouplingFieldDouble::min;
+%newobject ParaMEDMEM::MEDCouplingFieldDouble::getIdsInRange;
+%newobject ParaMEDMEM::MEDCouplingFieldDouble::buildSubPart;
+%newobject ParaMEDMEM::MEDCouplingFieldDouble::operator+;
+%newobject ParaMEDMEM::MEDCouplingFieldDouble::operator-;
+%newobject ParaMEDMEM::MEDCouplingFieldDouble::operator*;
+%newobject ParaMEDMEM::MEDCouplingFieldDouble::operator/;
+%newobject ParaMEDMEM::MEDCouplingFieldDouble::clone;
+%newobject ParaMEDMEM::MEDCouplingFieldDouble::cloneWithMesh;
+%newobject ParaMEDMEM::MEDCouplingFieldDouble::deepCpy;
+%newobject ParaMEDMEM::MEDCouplingFieldDouble::buildNewTimeReprFromThis;
+%newobject ParaMEDMEM::MEDCouplingFieldDouble::getValueOnMulti;
+%newobject ParaMEDMEM::MEDCouplingFieldTemplate::New;
+%newobject ParaMEDMEM::DataArrayInt::New;
+%newobject ParaMEDMEM::DataArrayInt::convertToDblArr;
+%newobject ParaMEDMEM::DataArrayInt::deepCpy;
+%newobject ParaMEDMEM::DataArrayInt::performCpy;
+%newobject ParaMEDMEM::DataArrayInt::substr;
+%newobject ParaMEDMEM::DataArrayInt::changeNbOfComponents;
+%newobject ParaMEDMEM::DataArrayInt::keepSelectedComponents;
+%newobject ParaMEDMEM::DataArrayInt::selectByTupleId;
+%newobject ParaMEDMEM::DataArrayInt::selectByTupleIdSafe;
+%newobject ParaMEDMEM::DataArrayInt::selectByTupleId2;
+%newobject ParaMEDMEM::DataArrayInt::checkAndPreparePermutation;
+%newobject ParaMEDMEM::DataArrayInt::renumber;
+%newobject ParaMEDMEM::DataArrayInt::renumberR;
+%newobject ParaMEDMEM::DataArrayInt::renumberAndReduce;
+%newobject ParaMEDMEM::DataArrayInt::invertArrayO2N2N2O;
+%newobject ParaMEDMEM::DataArrayInt::invertArrayN2O2O2N;
+%newobject ParaMEDMEM::DataArrayInt::getIdsEqual;
+%newobject ParaMEDMEM::DataArrayInt::getIdsNotEqual;
+%newobject ParaMEDMEM::DataArrayInt::getIdsEqualList;
+%newobject ParaMEDMEM::DataArrayInt::getIdsNotEqualList;
+%newobject ParaMEDMEM::DataArrayInt::Aggregate;
+%newobject ParaMEDMEM::DataArrayInt::Meld;
+%newobject ParaMEDMEM::DataArrayInt::Add;
+%newobject ParaMEDMEM::DataArrayInt::Substract;
+%newobject ParaMEDMEM::DataArrayInt::Multiply;
+%newobject ParaMEDMEM::DataArrayInt::Divide;
+%newobject ParaMEDMEM::DataArrayInt::BuildUnion;
+%newobject ParaMEDMEM::DataArrayInt::BuildIntersection;
+%newobject ParaMEDMEM::DataArrayInt::fromNoInterlace;
+%newobject ParaMEDMEM::DataArrayInt::toNoInterlace;
+%newobject ParaMEDMEM::DataArrayInt::buildComplement;
+%newobject ParaMEDMEM::DataArrayInt::buildUnion;
+%newobject ParaMEDMEM::DataArrayInt::buildSubstraction;
+%newobject ParaMEDMEM::DataArrayInt::buildIntersection;
+%newobject ParaMEDMEM::DataArrayInt::deltaShiftIndex;
+%newobject ParaMEDMEM::DataArrayInt::buildPermutationArr;
+%newobject ParaMEDMEM::DataArrayInt::buildPermArrPerLevel;
+%newobject ParaMEDMEM::DataArrayInt::__getitem__;
+%newobject ParaMEDMEM::DataArrayInt::__add__;
+%newobject ParaMEDMEM::DataArrayInt::__radd__;
+%newobject ParaMEDMEM::DataArrayInt::__sub__;
+%newobject ParaMEDMEM::DataArrayInt::__rsub__;
+%newobject ParaMEDMEM::DataArrayInt::__mul__;
+%newobject ParaMEDMEM::DataArrayInt::__rmul__;
+%newobject ParaMEDMEM::DataArrayInt::__div__;
+%newobject ParaMEDMEM::DataArrayInt::__rdiv__;
+%newobject ParaMEDMEM::DataArrayInt::__mod__;
+%newobject ParaMEDMEM::DataArrayInt::__rmod__;
+%newobject ParaMEDMEM::DataArrayDouble::New;
+%newobject ParaMEDMEM::DataArrayDouble::convertToIntArr;
+%newobject ParaMEDMEM::DataArrayDouble::deepCpy;
+%newobject ParaMEDMEM::DataArrayDouble::performCpy;
+%newobject ParaMEDMEM::DataArrayDouble::Aggregate;
+%newobject ParaMEDMEM::DataArrayDouble::Meld;
+%newobject ParaMEDMEM::DataArrayDouble::Dot;
+%newobject ParaMEDMEM::DataArrayDouble::CrossProduct;
+%newobject ParaMEDMEM::DataArrayDouble::Add;
+%newobject ParaMEDMEM::DataArrayDouble::Substract;
+%newobject ParaMEDMEM::DataArrayDouble::Multiply;
+%newobject ParaMEDMEM::DataArrayDouble::Divide;
+%newobject ParaMEDMEM::DataArrayDouble::substr;
+%newobject ParaMEDMEM::DataArrayDouble::changeNbOfComponents;
+%newobject ParaMEDMEM::DataArrayDouble::keepSelectedComponents;
+%newobject ParaMEDMEM::DataArrayDouble::getIdsInRange;
+%newobject ParaMEDMEM::DataArrayDouble::selectByTupleId;
+%newobject ParaMEDMEM::DataArrayDouble::selectByTupleIdSafe;
+%newobject ParaMEDMEM::DataArrayDouble::selectByTupleId2;
+%newobject ParaMEDMEM::DataArrayDouble::applyFunc;
+%newobject ParaMEDMEM::DataArrayDouble::applyFunc2;
+%newobject ParaMEDMEM::DataArrayDouble::applyFunc3;
+%newobject ParaMEDMEM::DataArrayDouble::doublyContractedProduct;
+%newobject ParaMEDMEM::DataArrayDouble::determinant;
+%newobject ParaMEDMEM::DataArrayDouble::eigenValues;
+%newobject ParaMEDMEM::DataArrayDouble::eigenVectors;
+%newobject ParaMEDMEM::DataArrayDouble::inverse;
+%newobject ParaMEDMEM::DataArrayDouble::trace;
+%newobject ParaMEDMEM::DataArrayDouble::deviator;
+%newobject ParaMEDMEM::DataArrayDouble::magnitude;
+%newobject ParaMEDMEM::DataArrayDouble::maxPerTuple;
+%newobject ParaMEDMEM::DataArrayDouble::renumber;
+%newobject ParaMEDMEM::DataArrayDouble::renumberR;
+%newobject ParaMEDMEM::DataArrayDouble::renumberAndReduce;
+%newobject ParaMEDMEM::DataArrayDouble::fromNoInterlace;
+%newobject ParaMEDMEM::DataArrayDouble::toNoInterlace;
+%newobject ParaMEDMEM::DataArrayDouble::fromPolarToCart;
+%newobject ParaMEDMEM::DataArrayDouble::fromCylToCart;
+%newobject ParaMEDMEM::DataArrayDouble::fromSpherToCart;
+%newobject ParaMEDMEM::DataArrayDouble::__getitem__;
+%newobject ParaMEDMEM::DataArrayDouble::__add__;
+%newobject ParaMEDMEM::DataArrayDouble::__radd__;
+%newobject ParaMEDMEM::DataArrayDouble::__sub__;
+%newobject ParaMEDMEM::DataArrayDouble::__rsub__;
+%newobject ParaMEDMEM::DataArrayDouble::__mul__;
+%newobject ParaMEDMEM::DataArrayDouble::__rmul__;
+%newobject ParaMEDMEM::DataArrayDouble::__div__;
+%newobject ParaMEDMEM::DataArrayDouble::__rdiv__;
+%newobject ParaMEDMEM::MEDCouplingMesh::deepCpy;
+%newobject ParaMEDMEM::MEDCouplingMesh::checkTypeConsistencyAndContig;
+%newobject ParaMEDMEM::MEDCouplingMesh::getCoordinatesAndOwner;
+%newobject ParaMEDMEM::MEDCouplingMesh::getBarycenterAndOwner;
+%newobject ParaMEDMEM::MEDCouplingMesh::buildOrthogonalField;
+%newobject ParaMEDMEM::MEDCouplingMesh::getCellIdsFullyIncludedInNodeIds;
+%newobject ParaMEDMEM::MEDCouplingMesh::mergeMyselfWith;
+%newobject ParaMEDMEM::MEDCouplingMesh::fillFromAnalytic;
+%newobject ParaMEDMEM::MEDCouplingMesh::fillFromAnalytic2;
+%newobject ParaMEDMEM::MEDCouplingMesh::fillFromAnalytic3;
+%newobject ParaMEDMEM::MEDCouplingMesh::getMeasureField;
+%newobject ParaMEDMEM::MEDCouplingMesh::simplexize;
+%newobject ParaMEDMEM::MEDCouplingMesh::buildUnstructured;
+%newobject ParaMEDMEM::MEDCouplingMesh::MergeMeshes;
+%newobject ParaMEDMEM::MEDCouplingPointSet::zipCoordsTraducer;
+%newobject ParaMEDMEM::MEDCouplingPointSet::buildBoundaryMesh;
+%newobject ParaMEDMEM::MEDCouplingPointSet::MergeNodesArray;
+%newobject ParaMEDMEM::MEDCouplingPointSet::BuildInstanceFromMeshType;
+%newobject ParaMEDMEM::MEDCouplingUMesh::New;
+%newobject ParaMEDMEM::MEDCouplingUMesh::getNodalConnectivity;
+%newobject ParaMEDMEM::MEDCouplingUMesh::getNodalConnectivityIndex;
+%newobject ParaMEDMEM::MEDCouplingUMesh::clone;
+%newobject ParaMEDMEM::MEDCouplingUMesh::zipConnectivityTraducer;
+%newobject ParaMEDMEM::MEDCouplingUMesh::buildDescendingConnectivity;
+%newobject ParaMEDMEM::MEDCouplingUMesh::buildExtrudedMesh;
+%newobject ParaMEDMEM::MEDCouplingUMesh::MergeUMeshes;
+%newobject ParaMEDMEM::MEDCouplingUMesh::MergeUMeshesOnSameCoords;
+%newobject ParaMEDMEM::MEDCouplingUMesh::buildNewNumberingFromCommNodesFrmt;
+%newobject ParaMEDMEM::MEDCouplingUMesh::rearrange2ConsecutiveCellTypes;
+%newobject ParaMEDMEM::MEDCouplingUMesh::convertCellArrayPerGeoType;
+%newobject ParaMEDMEM::MEDCouplingUMesh::getRenumArrForConsecutiveCellTypesSpec;
+%newobject ParaMEDMEM::MEDCouplingUMesh::buildDirectionVectorField;
+%newobject ParaMEDMEM::MEDCouplingUMesh::getEdgeRatioField;
+%newobject ParaMEDMEM::MEDCouplingUMesh::getAspectRatioField;
+%newobject ParaMEDMEM::MEDCouplingUMesh::getWarpField;
+%newobject ParaMEDMEM::MEDCouplingUMesh::getSkewField;
+%newobject ParaMEDMEM::MEDCouplingUMesh::getPartBarycenterAndOwner;
+%newobject ParaMEDMEM::MEDCouplingUMesh::getPartMeasureField;
+%newobject ParaMEDMEM::MEDCouplingUMesh::buildPartOrthogonalField;
+%newobject ParaMEDMEM::MEDCouplingUMesh::keepCellIdsByType;
+%newobject ParaMEDMEM::MEDCouplingUMesh::Build0DMeshFromCoords;
+%newobject ParaMEDMEM::MEDCouplingUMesh::findCellsIdsOnBoundary;
+%newobject ParaMEDMEM::MEDCouplingUMesh::getCellIdsLyingOnNodes;
+%newobject ParaMEDMEM::MEDCouplingExtrudedMesh::New;
+%newobject ParaMEDMEM::MEDCouplingExtrudedMesh::build3DUnstructuredMesh;
+%newobject ParaMEDMEM::MEDCouplingCMesh::New;
+%newobject ParaMEDMEM::MEDCouplingCMesh::getCoordsAt;
+%newobject ParaMEDMEM::MEDCouplingMultiFields::New;
+%newobject ParaMEDMEM::MEDCouplingMultiFields::deepCpy;
+%newobject ParaMEDMEM::MEDCouplingFieldOverTime::New;
+
+%feature("unref") DataArrayDouble "$this->decrRef();"
+%feature("unref") MEDCouplingPointSet "$this->decrRef();"
+%feature("unref") MEDCouplingMesh "$this->decrRef();"
+%feature("unref") MEDCouplingUMesh "$this->decrRef();"
+%feature("unref") MEDCouplingExtrudedMesh "$this->decrRef();"
+%feature("unref") MEDCouplingCMesh "$this->decrRef();"
+%feature("unref") DataArrayInt "$this->decrRef();"
+%feature("unref") MEDCouplingField "$this->decrRef();"
+%feature("unref") MEDCouplingFieldDouble "$this->decrRef();"
+%feature("unref") MEDCouplingMultiFields "$this->decrRef();"
+
+%rename(assign) *::operator=;
+%ignore ParaMEDMEM::MemArray::operator=;
+%ignore ParaMEDMEM::MemArray::operator[];
+%ignore ParaMEDMEM::MEDCouplingGaussLocalization::pushTinySerializationIntInfo;
+%ignore ParaMEDMEM::MEDCouplingGaussLocalization::pushTinySerializationDblInfo;
+%ignore ParaMEDMEM::MEDCouplingGaussLocalization::fillWithValues;
+%ignore ParaMEDMEM::MEDCouplingGaussLocalization::buildNewInstanceFromTinyInfo;
+
+%nodefaultctor;
+
+%rename (InterpKernelException) INTERP_KERNEL::Exception;
+
+namespace INTERP_KERNEL
+{
+ class Exception
+ {
+ public:
+ Exception(const char* what);
+ ~Exception() throw ();
+ const char *what() const throw ();
+ };
+}
+
+%include "MEDCouplingTimeLabel.hxx"
+%include "MEDCouplingRefCountObject.hxx"
+
+namespace ParaMEDMEM
+{
+ typedef enum
+ {
+ UNSTRUCTURED = 5,
+ UNSTRUCTURED_DESC = 6,
+ CARTESIAN = 7,
+ EXTRUDED = 8
+ } MEDCouplingMeshType;
+
+ class DataArrayInt;
+ class DataArrayDouble;
+ class MEDCouplingUMesh;
+ class MEDCouplingFieldDouble;
+
+ %extend RefCountObject
+ {
+ std::string getHiddenCppPointer() const
+ {
+ std::ostringstream oss; oss << "C++ Pointer address is : " << self;
+ return oss.str();
+ }
+ }
+
+ class MEDCouplingMesh : public RefCountObject, public TimeLabel
+ {
+ public:
+ void setName(const char *name);
+ const char *getName() const;
+ void setDescription(const char *descr);
+ const char *getDescription() const;
+ void setTime(double val, int iteration, int order);
+ void setTimeUnit(const char *unit);
+ const char *getTimeUnit() const;
+ virtual MEDCouplingMeshType getType() const throw(INTERP_KERNEL::Exception) = 0;
+ bool isStructured() const throw(INTERP_KERNEL::Exception);
+ virtual MEDCouplingMesh *deepCpy() const = 0;
+ virtual bool isEqual(const MEDCouplingMesh *other, double prec) const throw(INTERP_KERNEL::Exception);
+ virtual bool isEqualWithoutConsideringStr(const MEDCouplingMesh *other, double prec) const throw(INTERP_KERNEL::Exception) = 0;
+ virtual void copyTinyStringsFrom(const MEDCouplingMesh *other) throw(INTERP_KERNEL::Exception);
+ virtual void copyTinyInfoFrom(const MEDCouplingMesh *other) throw(INTERP_KERNEL::Exception);
+ virtual void checkCoherency() const throw(INTERP_KERNEL::Exception) = 0;
+ virtual void checkCoherency1(double eps=1e-12) const throw(INTERP_KERNEL::Exception) = 0;
+ virtual void checkCoherency2(double eps=1e-12) const throw(INTERP_KERNEL::Exception) = 0;
+ virtual int getNumberOfCells() const throw(INTERP_KERNEL::Exception) = 0;
+ virtual int getNumberOfNodes() const throw(INTERP_KERNEL::Exception) = 0;
+ virtual int getSpaceDimension() const throw(INTERP_KERNEL::Exception) = 0;
+ virtual int getMeshDimension() const throw(INTERP_KERNEL::Exception) = 0;
+ virtual DataArrayDouble *getCoordinatesAndOwner() const throw(INTERP_KERNEL::Exception) = 0;
+ virtual DataArrayDouble *getBarycenterAndOwner() const throw(INTERP_KERNEL::Exception) = 0;
+ virtual int getNumberOfCellsWithType(INTERP_KERNEL::NormalizedCellType type) const throw(INTERP_KERNEL::Exception) = 0;
+ virtual INTERP_KERNEL::NormalizedCellType getTypeOfCell(int cellId) const throw(INTERP_KERNEL::Exception) = 0;
+ virtual std::string simpleRepr() const = 0;
+ virtual std::string advancedRepr() const = 0;
+ // tools
+ virtual MEDCouplingFieldDouble *getMeasureField(bool isAbs) const throw(INTERP_KERNEL::Exception) = 0;
+ virtual MEDCouplingFieldDouble *getMeasureFieldOnNode(bool isAbs) const throw(INTERP_KERNEL::Exception) = 0;
+ virtual MEDCouplingFieldDouble *fillFromAnalytic(TypeOfField t, int nbOfComp, const char *func) const throw(INTERP_KERNEL::Exception);
+ virtual MEDCouplingFieldDouble *fillFromAnalytic2(TypeOfField t, int nbOfComp, const char *func) const throw(INTERP_KERNEL::Exception);
+ virtual MEDCouplingFieldDouble *fillFromAnalytic3(TypeOfField t, int nbOfComp, const std::vector<std::string>& varsOrder, const char *func) const throw(INTERP_KERNEL::Exception);
+ virtual MEDCouplingFieldDouble *buildOrthogonalField() const throw(INTERP_KERNEL::Exception) = 0;
+ virtual MEDCouplingUMesh *buildUnstructured() const throw(INTERP_KERNEL::Exception);
+ virtual MEDCouplingMesh *mergeMyselfWith(const MEDCouplingMesh *other) const throw(INTERP_KERNEL::Exception) = 0;
+ virtual bool areCompatibleForMerge(const MEDCouplingMesh *other) const throw(INTERP_KERNEL::Exception);
+ virtual DataArrayInt *simplexize(int policy) throw(INTERP_KERNEL::Exception);
+ static MEDCouplingMesh *MergeMeshes(const MEDCouplingMesh *mesh1, const MEDCouplingMesh *mesh2) throw(INTERP_KERNEL::Exception);
+ %extend
+ {
+ std::string __str__() const
+ {
+ return self->simpleRepr();
+ }
+
+ PyObject *getTime() throw(INTERP_KERNEL::Exception)
+ {
+ int tmp1,tmp2;
+ double tmp0=self->getTime(tmp1,tmp2);
+ PyObject *res = PyList_New(3);
+ PyList_SetItem(res,0,SWIG_From_double(tmp0));
+ PyList_SetItem(res,1,SWIG_From_int(tmp1));
+ PyList_SetItem(res,2,SWIG_From_int(tmp2));
+ return res;
+ }
+
+ int getCellContainingPoint(PyObject *p, double eps) const throw(INTERP_KERNEL::Exception)
+ {
+ int sz;
+ double *pos=convertPyToNewDblArr2(p,&sz);
+ int ret=self->getCellContainingPoint(pos,eps);
+ delete [] pos;
+ return ret;
+ }
+
+ PyObject *getCellsContainingPoints(PyObject *p, int nbOfPoints, double eps) const throw(INTERP_KERNEL::Exception)
+ {
+ int sz;
+ INTERP_KERNEL::AutoPtr<double> pos=convertPyToNewDblArr2(p,&sz);
+ std::vector<int> elts,eltsIndex;
+ self->getCellsContainingPoints(pos,nbOfPoints,eps,elts,eltsIndex);
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> d0=DataArrayInt::New();
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> d1=DataArrayInt::New();
+ d0->alloc(elts.size(),1);
+ d1->alloc(eltsIndex.size(),1);
+ std::copy(elts.begin(),elts.end(),d0->getPointer());
+ std::copy(eltsIndex.begin(),eltsIndex.end(),d1->getPointer());
+ PyObject *ret=PyTuple_New(2);
+ PyTuple_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(d0),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 ));
+ PyTuple_SetItem(ret,1,SWIG_NewPointerObj(SWIG_as_voidptr(d1),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 ));
+ d0->incrRef();
+ d1->incrRef();
+ return ret;
+ }
+
+ PyObject *getCellsContainingPoint(PyObject *p, double eps) const throw(INTERP_KERNEL::Exception)
+ {
+ int sz;
+ INTERP_KERNEL::AutoPtr<double> pos=convertPyToNewDblArr2(p,&sz);
+ std::vector<int> elts;
+ self->getCellsContainingPoint(pos,eps,elts);
+ return convertIntArrToPyList2(elts);
+ }
+
+ void renumberCells(PyObject *li, bool check) throw(INTERP_KERNEL::Exception)
+ {
+ void *da=0;
+ int res1=SWIG_ConvertPtr(li,&da,SWIGTYPE_p_ParaMEDMEM__DataArrayInt, 0 | 0 );
+ if (!SWIG_IsOK(res1))
+ {
+ int size;
+ INTERP_KERNEL::AutoPtr<int> tmp=convertPyToNewIntArr2(li,&size);
+ self->renumberCells(tmp,check);
+ }
+ else
+ {
+ DataArrayInt *da2=reinterpret_cast< DataArrayInt * >(da);
+ if(!da2)
+ throw INTERP_KERNEL::Exception("Not null DataArrayInt instance expected !");
+ da2->checkAllocated();
+ self->renumberCells(da2->getConstPointer(),check);
+ }
+ }
+
+ PyObject *checkGeoEquivalWith(const MEDCouplingMesh *other, int levOfCheck, double prec) const throw(INTERP_KERNEL::Exception)
+ {
+ DataArrayInt *cellCor, *nodeCor;
+ self->checkGeoEquivalWith(other,levOfCheck,prec,cellCor,nodeCor);
+ PyObject *res = PyList_New(2);
+ PyList_SetItem(res,0,SWIG_NewPointerObj(SWIG_as_voidptr(cellCor),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, cellCor?SWIG_POINTER_OWN | 0:0 ));
+ PyList_SetItem(res,1,SWIG_NewPointerObj(SWIG_as_voidptr(nodeCor),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, nodeCor?SWIG_POINTER_OWN | 0:0 ));
+ return res;
+ }
+ DataArrayInt *getCellIdsFullyIncludedInNodeIds(PyObject *li) const throw(INTERP_KERNEL::Exception)
+ {
+ void *da=0;
+ int res1=SWIG_ConvertPtr(li,&da,SWIGTYPE_p_ParaMEDMEM__DataArrayInt, 0 | 0 );
+ if (!SWIG_IsOK(res1))
+ {
+ int size;
+ INTERP_KERNEL::AutoPtr<int> tmp=convertPyToNewIntArr2(li,&size);
+ return self->getCellIdsFullyIncludedInNodeIds(tmp,((const int *)tmp)+size);
+ }
+ else
+ {
+ DataArrayInt *da2=reinterpret_cast< DataArrayInt * >(da);
+ if(!da2)
+ throw INTERP_KERNEL::Exception("Not null DataArrayInt instance expected !");
+ da2->checkAllocated();
+ return self->getCellIdsFullyIncludedInNodeIds(da2->getConstPointer(),da2->getConstPointer()+da2->getNbOfElems());
+ }
+ }
+ PyObject *getNodeIdsOfCell(int cellId) const throw(INTERP_KERNEL::Exception)
+ {
+ std::vector<int> conn;
+ self->getNodeIdsOfCell(cellId,conn);
+ return convertIntArrToPyList2(conn);
+ }
+
+ PyObject *getCoordinatesOfNode(int nodeId) const throw(INTERP_KERNEL::Exception)
+ {
+ std::vector<double> coo;
+ self->getCoordinatesOfNode(nodeId,coo);
+ return convertDblArrToPyList2(coo);
+ }
+
+ void scale(PyObject *point, double factor) throw(INTERP_KERNEL::Exception)
+ {
+ int sz;
+ double *p=convertPyToNewDblArr2(point,&sz);
+ self->scale(p,factor);
+ delete [] p;
+ }
+
+ PyObject *getBoundingBox() const throw(INTERP_KERNEL::Exception)
+ {
+ int spaceDim=self->getSpaceDimension();
+ double *tmp=new double[2*spaceDim];
+ self->getBoundingBox(tmp);
+ PyObject *ret=convertDblArrToPyListOfTuple(tmp,2,spaceDim);
+ delete [] tmp;
+ return ret;
+ }
+
+ PyObject *buildPart(PyObject *li) const throw(INTERP_KERNEL::Exception)
+ {
+ void *da=0;
+ int res1=SWIG_ConvertPtr(li,&da,SWIGTYPE_p_ParaMEDMEM__DataArrayInt, 0 | 0 );
+ if (!SWIG_IsOK(res1))
+ {
+ int size;
+ INTERP_KERNEL::AutoPtr<int> tmp=convertPyToNewIntArr2(li,&size);
+ MEDCouplingMesh *ret=self->buildPart(tmp,((const int *)tmp)+size);
+ return convertMesh(ret, SWIG_POINTER_OWN | 0 );
+ }
+ else
+ {
+ DataArrayInt *da2=reinterpret_cast< DataArrayInt * >(da);
+ if(!da2)
+ throw INTERP_KERNEL::Exception("Not null DataArrayInt instance expected !");
+ da2->checkAllocated();
+ MEDCouplingMesh *ret=self->buildPart(da2->getConstPointer(),da2->getConstPointer()+da2->getNbOfElems());
+ ret->setName(da2->getName().c_str());
+ return convertMesh(ret, SWIG_POINTER_OWN | 0 );
+ }
+ }
+
+ PyObject *buildPartAndReduceNodes(PyObject *li) const throw(INTERP_KERNEL::Exception)
+ {
+ int size;
+ INTERP_KERNEL::AutoPtr<int> tmp=convertPyToNewIntArr2(li,&size);
+ DataArrayInt *arr=0;
+ MEDCouplingMesh *ret=self->buildPartAndReduceNodes(tmp,tmp+size,arr);
+ PyObject *res = PyList_New(2);
+ PyObject *obj0=convertMesh(ret, SWIG_POINTER_OWN | 0 );
+ PyObject *obj1=SWIG_NewPointerObj(SWIG_as_voidptr(arr),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 );
+ PyList_SetItem(res,0,obj0);
+ PyList_SetItem(res,1,obj1);
+ return res;
+ }
+
+ DataArrayInt *checkTypeConsistencyAndContig(PyObject *li, PyObject *li2) const throw(INTERP_KERNEL::Exception)
+ {
+ std::vector<int> code;
+ std::vector<const DataArrayInt *> idsPerType;
+ convertPyObjToVecDataArrayIntCst(li2,idsPerType);
+ convertPyToNewIntArr3(li,code);
+ return self->checkTypeConsistencyAndContig(code,idsPerType);
+ }
+
+ void translate(PyObject *vector) throw(INTERP_KERNEL::Exception)
+ {
+ int sz;
+ INTERP_KERNEL::AutoPtr<double> v=convertPyToNewDblArr2(vector,&sz);
+ self->translate(v);
+ }
+
+ void rotate(PyObject *center, PyObject *vector, double alpha) throw(INTERP_KERNEL::Exception)
+ {
+ int sz;
+ INTERP_KERNEL::AutoPtr<double> c=convertPyToNewDblArr2(center,&sz);
+ if(!c)
+ return ;
+ INTERP_KERNEL::AutoPtr<double> v=convertPyToNewDblArr2(vector,&sz);
+ if(!v)
+ { return ; }
+ self->rotate(c,v,alpha);
+ }
+ }
+ };
+}
+
+%include "MEDCouplingMemArray.hxx"
+%include "NormalizedUnstructuredMesh.hxx"
+%include "MEDCouplingNatureOfField.hxx"
+%include "MEDCouplingTimeDiscretization.hxx"
+%include "MEDCouplingGaussLocalization.hxx"
+
+namespace ParaMEDMEM
+{
+ class MEDCouplingPointSet : public ParaMEDMEM::MEDCouplingMesh
+ {
+ public:
+ void updateTime() const;
+ void setCoords(const DataArrayDouble *coords) throw(INTERP_KERNEL::Exception);
+ DataArrayDouble *getCoordinatesAndOwner() const throw(INTERP_KERNEL::Exception);
+ bool areCoordsEqual(const MEDCouplingPointSet& other, double prec) const throw(INTERP_KERNEL::Exception);
+ void zipCoords() throw(INTERP_KERNEL::Exception);
+ double getCaracteristicDimension() const throw(INTERP_KERNEL::Exception);
+ void changeSpaceDimension(int newSpaceDim, double dftVal=0.) throw(INTERP_KERNEL::Exception);
+ void tryToShareSameCoords(const MEDCouplingPointSet& other, double epsilon) throw(INTERP_KERNEL::Exception);
+ virtual void tryToShareSameCoordsPermute(const MEDCouplingPointSet& other, double epsilon) throw(INTERP_KERNEL::Exception) = 0;
+ static DataArrayDouble *MergeNodesArray(const MEDCouplingPointSet *m1, const MEDCouplingPointSet *m2) throw(INTERP_KERNEL::Exception);
+ static MEDCouplingPointSet *BuildInstanceFromMeshType(MEDCouplingMeshType type) throw(INTERP_KERNEL::Exception);
+ virtual MEDCouplingPointSet *buildBoundaryMesh(bool keepCoords) const throw(INTERP_KERNEL::Exception) = 0;
+ virtual bool isEmptyMesh(const std::vector<int>& tinyInfo) const throw(INTERP_KERNEL::Exception) = 0;
+ //! size of returned tinyInfo must be always the same.
+ void getTinySerializationInformation(std::vector<double>& tinyInfoD, std::vector<int>& tinyInfo, std::vector<std::string>& littleStrings) const throw(INTERP_KERNEL::Exception);
+ void resizeForUnserialization(const std::vector<int>& tinyInfo, DataArrayInt *a1, DataArrayDouble *a2, std::vector<std::string>& littleStrings) const throw(INTERP_KERNEL::Exception);
+ void serialize(DataArrayInt *&a1, DataArrayDouble *&a2) const throw(INTERP_KERNEL::Exception);
+ void unserialization(const std::vector<double>& tinyInfoD, const std::vector<int>& tinyInfo, const DataArrayInt *a1, DataArrayDouble *a2,
+ const std::vector<std::string>& littleStrings) throw(INTERP_KERNEL::Exception);
+ virtual void getCellsInBoundingBox(const INTERP_KERNEL::DirectedBoundingBox& bbox, double eps, std::vector<int>& elems) throw(INTERP_KERNEL::Exception) = 0;
+ virtual DataArrayInt *zipCoordsTraducer() throw(INTERP_KERNEL::Exception) = 0;
+ %extend
+ {
+ std::string __str__() const
+ {
+ return self->simpleRepr();
+ }
+
+ PyObject *buildNewNumberingFromCommonNodesFormat(const DataArrayInt *comm, const DataArrayInt *commIndex) const throw(INTERP_KERNEL::Exception)
+ {
+ int newNbOfNodes;
+ DataArrayInt *ret0=self->buildNewNumberingFromCommonNodesFormat(comm,commIndex,newNbOfNodes);
+ PyObject *res = PyList_New(2);
+ PyList_SetItem(res,0,SWIG_NewPointerObj(SWIG_as_voidptr(ret0),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 ));
+ PyList_SetItem(res,1,SWIG_From_int(newNbOfNodes));
+ return res;
+ }
+
+ PyObject *findCommonNodes(int limitNodeId, double prec) const throw(INTERP_KERNEL::Exception)
+ {
+ DataArrayInt *comm, *commIndex;
+ self->findCommonNodes(limitNodeId,prec,comm,commIndex);
+ PyObject *res = PyList_New(2);
+ PyList_SetItem(res,0,SWIG_NewPointerObj(SWIG_as_voidptr(comm),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 ));
+ PyList_SetItem(res,1,SWIG_NewPointerObj(SWIG_as_voidptr(commIndex),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 ));
+ return res;
+ }
+
+ PyObject *getCoords() throw(INTERP_KERNEL::Exception)
+ {
+ DataArrayDouble *ret1=self->getCoords();
+ ret1->incrRef();
+ return SWIG_NewPointerObj((void*)ret1,SWIGTYPE_p_ParaMEDMEM__DataArrayDouble,SWIG_POINTER_OWN | 0);
+ }
+ PyObject *buildPartOfMySelf(PyObject *li, bool keepCoords) const throw(INTERP_KERNEL::Exception)
+ {
+ void *da=0;
+ int res1=SWIG_ConvertPtr(li,&da,SWIGTYPE_p_ParaMEDMEM__DataArrayInt, 0 | 0 );
+ if (!SWIG_IsOK(res1))
+ {
+ int size;
+ INTERP_KERNEL::AutoPtr<int> tmp=convertPyToNewIntArr2(li,&size);
+ MEDCouplingPointSet *ret=self->buildPartOfMySelf(tmp,((const int *)tmp)+size,keepCoords);
+ return convertMesh(ret, SWIG_POINTER_OWN | 0 );
+ }
+ else
+ {
+ DataArrayInt *da2=reinterpret_cast< DataArrayInt * >(da);
+ if(!da2)
+ throw INTERP_KERNEL::Exception("Not null DataArrayInt instance expected !");
+ da2->checkAllocated();
+ MEDCouplingPointSet *ret=self->buildPartOfMySelf(da2->getConstPointer(),da2->getConstPointer()+da2->getNbOfElems(),keepCoords);
+ ret->setName(da2->getName().c_str());
+ return convertMesh(ret, SWIG_POINTER_OWN | 0 );
+ }
+ }
+ PyObject *buildPartOfMySelfNode(PyObject *li, bool fullyIn) const throw(INTERP_KERNEL::Exception)
+ {
+ void *da=0;
+ int res1=SWIG_ConvertPtr(li,&da,SWIGTYPE_p_ParaMEDMEM__DataArrayInt, 0 | 0 );
+ if (!SWIG_IsOK(res1))
+ {
+ int size;
+ INTERP_KERNEL::AutoPtr<int> tmp=convertPyToNewIntArr2(li,&size);
+ MEDCouplingPointSet *ret=self->buildPartOfMySelfNode(tmp,((const int *)tmp)+size,fullyIn);
+ return convertMesh(ret, SWIG_POINTER_OWN | 0 );
+ }
+ else
+ {
+ DataArrayInt *da2=reinterpret_cast< DataArrayInt * >(da);
+ if(!da2)
+ throw INTERP_KERNEL::Exception("Not null DataArrayInt instance expected !");
+ da2->checkAllocated();
+ MEDCouplingPointSet *ret=self->buildPartOfMySelfNode(da2->getConstPointer(),da2->getConstPointer()+da2->getNbOfElems(),fullyIn);
+ ret->setName(da2->getName().c_str());
+ return convertMesh(ret, SWIG_POINTER_OWN | 0 );
+ }
+ }
+ PyObject *buildFacePartOfMySelfNode(PyObject *li, bool fullyIn) const throw(INTERP_KERNEL::Exception)
+ {
+ void *da=0;
+ int res1=SWIG_ConvertPtr(li,&da,SWIGTYPE_p_ParaMEDMEM__DataArrayInt, 0 | 0 );
+ if (!SWIG_IsOK(res1))
+ {
+ int size;
+ INTERP_KERNEL::AutoPtr<int> tmp=convertPyToNewIntArr2(li,&size);
+ MEDCouplingPointSet *ret=self->buildFacePartOfMySelfNode(tmp,((const int *)tmp)+size,fullyIn);
+ return convertMesh(ret, SWIG_POINTER_OWN | 0 );
+ }
+ else
+ {
+ DataArrayInt *da2=reinterpret_cast< DataArrayInt * >(da);
+ if(!da2)
+ throw INTERP_KERNEL::Exception("Not null DataArrayInt instance expected !");
+ da2->checkAllocated();
+ MEDCouplingPointSet *ret=self->buildFacePartOfMySelfNode(da2->getConstPointer(),da2->getConstPointer()+da2->getNbOfElems(),fullyIn);
+ ret->setName(da2->getName().c_str());
+ return convertMesh(ret, SWIG_POINTER_OWN | 0 );
+ }
+ }
+ PyObject *findBoundaryNodes() const throw(INTERP_KERNEL::Exception)
+ {
+ std::vector<int> nodes;
+ self->findBoundaryNodes(nodes);
+ return convertIntArrToPyList2(nodes);
+ }
+ void renumberNodes(PyObject *li, int newNbOfNodes) throw(INTERP_KERNEL::Exception)
+ {
+ void *da=0;
+ int res1=SWIG_ConvertPtr(li,&da,SWIGTYPE_p_ParaMEDMEM__DataArrayInt, 0 | 0 );
+ if (!SWIG_IsOK(res1))
+ {
+ int size;
+ INTERP_KERNEL::AutoPtr<int> tmp=convertPyToNewIntArr2(li,&size);
+ self->renumberNodes(tmp,newNbOfNodes);
+ }
+ else
+ {
+ DataArrayInt *da2=reinterpret_cast< DataArrayInt * >(da);
+ if(!da2)
+ throw INTERP_KERNEL::Exception("Not null DataArrayInt instance expected !");
+ da2->checkAllocated();
+ self->renumberNodes(da2->getConstPointer(),newNbOfNodes);
+ }
+ }
+ void renumberNodes2(PyObject *li, int newNbOfNodes) throw(INTERP_KERNEL::Exception)
+ {
+ void *da=0;
+ int res1=SWIG_ConvertPtr(li,&da,SWIGTYPE_p_ParaMEDMEM__DataArrayInt, 0 | 0 );
+ if (!SWIG_IsOK(res1))
+ {
+ int size;
+ INTERP_KERNEL::AutoPtr<int> tmp=convertPyToNewIntArr2(li,&size);
+ self->renumberNodes2(tmp,newNbOfNodes);
+ }
+ else
+ {
+ DataArrayInt *da2=reinterpret_cast< DataArrayInt * >(da);
+ if(!da2)
+ throw INTERP_KERNEL::Exception("Not null DataArrayInt instance expected !");
+ da2->checkAllocated();
+ self->renumberNodes2(da2->getConstPointer(),newNbOfNodes);
+ }
+ }
+ PyObject *findNodesOnPlane(PyObject *pt, PyObject *vec, double eps) const throw(INTERP_KERNEL::Exception)
+ {
+ std::vector<int> nodes;
+ int sz;
+ double *p=convertPyToNewDblArr2(pt,&sz);
+ double *v=convertPyToNewDblArr2(vec,&sz);
+ self->findNodesOnPlane(p,v,eps,nodes);
+ delete [] v;
+ delete [] p;
+ return convertIntArrToPyList2(nodes);
+ }
+ PyObject *getNodeIdsNearPoint(PyObject *pt, double eps) const throw(INTERP_KERNEL::Exception)
+ {
+ int size;
+ INTERP_KERNEL::AutoPtr<double> pos=convertPyToNewDblArr2(pt,&size);
+ if(size<self->getSpaceDimension())
+ throw INTERP_KERNEL::Exception("getNodeIdsNearPoint : to tiny array ! must be at least of size SpaceDim !");
+ std::vector<int> tmp=self->getNodeIdsNearPoint(pos,eps);
+ return convertIntArrToPyList2(tmp);
+ }
+
+ PyObject *getNodeIdsNearPoints(PyObject *pt, int nbOfNodes, double eps) const throw(INTERP_KERNEL::Exception)
+ {
+ std::vector<int> c,cI;
+ int size;
+ INTERP_KERNEL::AutoPtr<double> pos=convertPyToNewDblArr2(pt,&size);
+ if(size<self->getSpaceDimension()*nbOfNodes)
+ throw INTERP_KERNEL::Exception("getNodeIdsNearPoints : to tiny array ! must be at least of size SpaceDim*nbOfNodes !");
+ self->getNodeIdsNearPoints(pos,nbOfNodes,eps,c,cI);
+ PyObject *ret=PyTuple_New(2);
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> d0=DataArrayInt::New();
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> d1=DataArrayInt::New();
+ d0->alloc(c.size(),1);
+ d1->alloc(cI.size(),1);
+ std::copy(c.begin(),c.end(),d0->getPointer());
+ std::copy(cI.begin(),cI.end(),d1->getPointer());
+ PyTuple_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(d0),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 ));
+ PyTuple_SetItem(ret,1,SWIG_NewPointerObj(SWIG_as_voidptr(d1),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 ));
+ d0->incrRef();
+ d1->incrRef();
+ return ret;
+ }
+
+ PyObject *getCellsInBoundingBox(PyObject *bbox, double eps) throw(INTERP_KERNEL::Exception)
+ {
+ std::vector<int> elems;
+ int size;
+ double *tmp=convertPyToNewDblArr2(bbox,&size);
+ self->getCellsInBoundingBox(tmp,eps,elems);
+ delete [] tmp;
+ return convertIntArrToPyList2(elems);
+ }
+
+ static void Rotate2DAlg(PyObject *center, double angle, int nbNodes, PyObject *coords) throw(INTERP_KERNEL::Exception)
+ {
+ int sz;
+ double *c=convertPyToNewDblArr2(center,&sz);
+ double *coo=convertPyToNewDblArr2(coords,&sz);
+ ParaMEDMEM::MEDCouplingPointSet::Rotate2DAlg(c,angle,nbNodes,coo);
+ for(int i=0;i<sz;i++)
+ PyList_SetItem(coords,i,PyFloat_FromDouble(coo[i]));
+ delete [] coo;
+ delete [] c;
+ }
+ static void Rotate3DAlg(PyObject *center, PyObject *vect, double angle, int nbNodes, PyObject *coords) throw(INTERP_KERNEL::Exception)
+ {
+ int sz,sz2;
+ double *c=convertPyToNewDblArr2(center,&sz);
+ double *coo=convertPyToNewDblArr2(coords,&sz);
+ double *v=convertPyToNewDblArr2(vect,&sz2);
+ ParaMEDMEM::MEDCouplingPointSet::Rotate3DAlg(c,v,angle,nbNodes,coo);
+ for(int i=0;i<sz;i++)
+ PyList_SetItem(coords,i,PyFloat_FromDouble(coo[i]));
+ delete [] coo;
+ delete [] c;
+ }
+ }
+ };
+
+ class MEDCouplingUMesh : public ParaMEDMEM::MEDCouplingPointSet
+ {
+ public:
+ static MEDCouplingUMesh *New();
+ static MEDCouplingUMesh *New(const char *meshName, int meshDim);
+ MEDCouplingUMesh *clone(bool recDeepCpy) const;
+ void updateTime() const;
+ void checkCoherency() const throw(INTERP_KERNEL::Exception);
+ void setMeshDimension(int meshDim) throw(INTERP_KERNEL::Exception);
+ void allocateCells(int nbOfCells) throw(INTERP_KERNEL::Exception);
+ void finishInsertingCells() throw(INTERP_KERNEL::Exception);
+ void setConnectivity(DataArrayInt *conn, DataArrayInt *connIndex, bool isComputingTypes=true) throw(INTERP_KERNEL::Exception);
+ INTERP_KERNEL::NormalizedCellType getTypeOfCell(int cellId) const throw(INTERP_KERNEL::Exception);
+ int getNumberOfNodesInCell(int cellId) const throw(INTERP_KERNEL::Exception);
+ int getMeshLength() const throw(INTERP_KERNEL::Exception);
+ void computeTypes() throw(INTERP_KERNEL::Exception);
+ std::string reprConnectivityOfThis() const throw(INTERP_KERNEL::Exception);
+ //tools
+ DataArrayInt *findCellsIdsOnBoundary() const throw(INTERP_KERNEL::Exception);
+ bool checkConsecutiveCellTypes() const throw(INTERP_KERNEL::Exception);
+ DataArrayInt *rearrange2ConsecutiveCellTypes() throw(INTERP_KERNEL::Exception);
+ DataArrayInt *convertCellArrayPerGeoType(const DataArrayInt *da) const throw(INTERP_KERNEL::Exception);
+ DataArrayInt *zipConnectivityTraducer(int compType) throw(INTERP_KERNEL::Exception);
+ MEDCouplingUMesh *buildDescendingConnectivity(DataArrayInt *desc, DataArrayInt *descIndx, DataArrayInt *revDesc, DataArrayInt *revDescIndx) const throw(INTERP_KERNEL::Exception);
+ void orientCorrectlyPolyhedrons() throw(INTERP_KERNEL::Exception);
+ bool isPresenceOfQuadratic() const throw(INTERP_KERNEL::Exception);
+ MEDCouplingFieldDouble *buildDirectionVectorField() const throw(INTERP_KERNEL::Exception);
+ bool isContiguous1D() const throw(INTERP_KERNEL::Exception);
+ void convertQuadraticCellsToLinear() throw(INTERP_KERNEL::Exception);
+ void convertDegeneratedCells() throw(INTERP_KERNEL::Exception);
+ bool areOnlySimplexCells() const throw(INTERP_KERNEL::Exception);
+ MEDCouplingFieldDouble *getEdgeRatioField() const throw(INTERP_KERNEL::Exception);
+ MEDCouplingFieldDouble *getAspectRatioField() const throw(INTERP_KERNEL::Exception);
+ MEDCouplingFieldDouble *getWarpField() const throw(INTERP_KERNEL::Exception);
+ MEDCouplingFieldDouble *getSkewField() const throw(INTERP_KERNEL::Exception);
+ static MEDCouplingUMesh *Build0DMeshFromCoords(DataArrayDouble *da) throw(INTERP_KERNEL::Exception);
+ static MEDCouplingUMesh *MergeUMeshes(const MEDCouplingUMesh *mesh1, const MEDCouplingUMesh *mesh2) throw(INTERP_KERNEL::Exception);
+ static MEDCouplingUMesh *MergeUMeshesOnSameCoords(const MEDCouplingUMesh *mesh1, const MEDCouplingUMesh *mesh2) throw(INTERP_KERNEL::Exception);
+ %extend {
+ std::string __str__() const
+ {
+ return self->simpleRepr();
+ }
+ void insertNextCell(INTERP_KERNEL::NormalizedCellType type, int size, PyObject *li) throw(INTERP_KERNEL::Exception)
+ {
+ int sz;
+ INTERP_KERNEL::AutoPtr<int> tmp=convertPyToNewIntArr2(li,&sz);
+ self->insertNextCell(type,size,tmp);
+ }
+ DataArrayInt *getNodalConnectivity() throw(INTERP_KERNEL::Exception)
+ {
+ DataArrayInt *ret=self->getNodalConnectivity();
+ if(ret)
+ ret->incrRef();
+ return ret;
+ }
+ DataArrayInt *getNodalConnectivityIndex() throw(INTERP_KERNEL::Exception)
+ {
+ DataArrayInt *ret=self->getNodalConnectivityIndex();
+ if(ret)
+ ret->incrRef();
+ return ret;
+ }
+ PyObject *getAllTypes() const throw(INTERP_KERNEL::Exception)
+ {
+ std::set<INTERP_KERNEL::NormalizedCellType> result=self->getAllTypes();
+ std::set<INTERP_KERNEL::NormalizedCellType>::const_iterator iL=result.begin();
+ PyObject *res = PyList_New(result.size());
+ for (int i=0;iL!=result.end(); i++, iL++)
+ PyList_SetItem(res,i,PyInt_FromLong(*iL));
+ return res;
+ }
+ PyObject *mergeNodes(double precision) throw(INTERP_KERNEL::Exception)
+ {
+ bool ret1;
+ int ret2;
+ DataArrayInt *ret0=self->mergeNodes(precision,ret1,ret2);
+ PyObject *res = PyList_New(3);
+ PyList_SetItem(res,0,SWIG_NewPointerObj(SWIG_as_voidptr(ret0),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 ));
+ PyList_SetItem(res,1,SWIG_From_bool(ret1));
+ PyList_SetItem(res,2,SWIG_From_int(ret2));
+ return res;
+ }
+ PyObject *mergeNodes2(double precision) throw(INTERP_KERNEL::Exception)
+ {
+ bool ret1;
+ int ret2;
+ DataArrayInt *ret0=self->mergeNodes2(precision,ret1,ret2);
+ PyObject *res = PyList_New(3);
+ PyList_SetItem(res,0,SWIG_NewPointerObj(SWIG_as_voidptr(ret0),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 ));
+ PyList_SetItem(res,1,SWIG_From_bool(ret1));
+ PyList_SetItem(res,2,SWIG_From_int(ret2));
+ return res;
+ }
+ PyObject *checkButterflyCells() throw(INTERP_KERNEL::Exception)
+ {
+ std::vector<int> cells;
+ self->checkButterflyCells(cells);
+ return convertIntArrToPyList2(cells);
+ }
+
+ PyObject *splitByType() const throw(INTERP_KERNEL::Exception)
+ {
+ std::vector<MEDCouplingUMesh *> ms=self->splitByType();
+ int sz=ms.size();
+ PyObject *ret = PyList_New(sz);
+ for(int i=0;i<sz;i++)
+ PyList_SetItem(ret,i,SWIG_NewPointerObj(SWIG_as_voidptr(ms[i]),SWIGTYPE_p_ParaMEDMEM__MEDCouplingUMesh, SWIG_POINTER_OWN | 0 ));
+ return ret;
+ }
+
+ PyObject *keepSpecifiedCells(INTERP_KERNEL::NormalizedCellType type, PyObject *ids) const throw(INTERP_KERNEL::Exception)
+ {
+ int size;
+ INTERP_KERNEL::AutoPtr<int> tmp=convertPyToNewIntArr2(ids,&size);
+ MEDCouplingUMesh *ret=self->keepSpecifiedCells(type,tmp,tmp+size);
+ return SWIG_NewPointerObj(SWIG_as_voidptr(ret),SWIGTYPE_p_ParaMEDMEM__MEDCouplingUMesh, SWIG_POINTER_OWN | 0 );
+ }
+
+ bool checkConsecutiveCellTypesAndOrder(PyObject *li) const throw(INTERP_KERNEL::Exception)
+ {
+ int sz;
+ INTERP_KERNEL::AutoPtr<INTERP_KERNEL::NormalizedCellType> order=(INTERP_KERNEL::NormalizedCellType *)convertPyToNewIntArr2(li,&sz);
+ bool ret=self->checkConsecutiveCellTypesAndOrder(order,order+sz);
+ return ret;
+ }
+
+ DataArrayInt *getRenumArrForConsecutiveCellTypesSpec(PyObject *li) const throw(INTERP_KERNEL::Exception)
+ {
+ int sz;
+ INTERP_KERNEL::AutoPtr<INTERP_KERNEL::NormalizedCellType> order=(INTERP_KERNEL::NormalizedCellType *)convertPyToNewIntArr2(li,&sz);
+ DataArrayInt *ret=self->getRenumArrForConsecutiveCellTypesSpec(order,(INTERP_KERNEL::NormalizedCellType *)order+sz);
+ return ret;
+ }
+
+ PyObject *getLevArrPerCellTypes(PyObject *li) const throw(INTERP_KERNEL::Exception)
+ {
+ int sz;
+ INTERP_KERNEL::AutoPtr<INTERP_KERNEL::NormalizedCellType> order=(INTERP_KERNEL::NormalizedCellType *)convertPyToNewIntArr2(li,&sz);
+ DataArrayInt *tmp0,*tmp1=0;
+ tmp0=self->getLevArrPerCellTypes(order,(INTERP_KERNEL::NormalizedCellType *)order+sz,tmp1);
+ PyObject *ret=PyTuple_New(2);
+ PyTuple_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(tmp0),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 ));
+ PyTuple_SetItem(ret,1,SWIG_NewPointerObj(SWIG_as_voidptr(tmp1),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 ));
+ return ret;
+ }
+
+ static PyObject *MergeUMeshesOnSameCoords(PyObject *ms) throw(INTERP_KERNEL::Exception)
+ {
+ std::vector<const ParaMEDMEM::MEDCouplingUMesh *> meshes;
+ convertPyObjToVecUMeshesCst(ms,meshes);
+ MEDCouplingUMesh *ret=MEDCouplingUMesh::MergeUMeshesOnSameCoords(meshes);
+ return convertMesh(ret, SWIG_POINTER_OWN | 0 );
+ }
+
+ static PyObject *FuseUMeshesOnSameCoords(PyObject *ms, int compType) throw(INTERP_KERNEL::Exception)
+ {
+ int sz;
+ std::vector<const MEDCouplingUMesh *> meshes;
+ convertPyObjToVecUMeshesCst(ms,meshes);
+ std::vector<DataArrayInt *> corr;
+ MEDCouplingUMesh *um=MEDCouplingUMesh::FuseUMeshesOnSameCoords(meshes,compType,corr);
+ sz=corr.size();
+ PyObject *ret1=PyList_New(sz);
+ for(int i=0;i<sz;i++)
+ PyList_SetItem(ret1,i,SWIG_NewPointerObj(SWIG_as_voidptr(corr[i]),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 ));
+ PyObject *ret=PyList_New(2);
+ PyList_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(um),SWIGTYPE_p_ParaMEDMEM__MEDCouplingUMesh, SWIG_POINTER_OWN | 0 ));
+ PyList_SetItem(ret,1,ret1);
+ return ret;
+ }
+
+ PyObject *are2DCellsNotCorrectlyOriented(PyObject *vec, bool polyOnly) const throw(INTERP_KERNEL::Exception)
+ {
+ std::vector<int> cells;
+ int sz;
+ double *v=convertPyToNewDblArr2(vec,&sz);
+ try
+ {
+ self->are2DCellsNotCorrectlyOriented(v,polyOnly,cells);
+ }
+ catch(INTERP_KERNEL::Exception& e)
+ {
+ delete [] v;
+ throw e;
+ }
+ delete [] v;
+ return convertIntArrToPyList2(cells);
+ }
+
+ void orientCorrectly2DCells(PyObject *vec, bool polyOnly) throw(INTERP_KERNEL::Exception)
+ {
+ int sz;
+ double *v=convertPyToNewDblArr2(vec,&sz);
+ try
+ {
+ self->orientCorrectly2DCells(v,polyOnly);
+ }
+ catch(INTERP_KERNEL::Exception& e)
+ {
+ delete [] v;
+ throw e;
+ }
+ delete [] v;
+ }
+
+ PyObject *arePolyhedronsNotCorrectlyOriented() const throw(INTERP_KERNEL::Exception)
+ {
+ std::vector<int> cells;
+ self->arePolyhedronsNotCorrectlyOriented(cells);
+ return convertIntArrToPyList2(cells);
+ }
+
+ PyObject *getFastAveragePlaneOfThis() const throw(INTERP_KERNEL::Exception)
+ {
+ double vec[3];
+ double pos[3];
+ self->getFastAveragePlaneOfThis(vec,pos);
+ double vals[6];
+ std::copy(vec,vec+3,vals);
+ std::copy(pos,pos+3,vals+3);
+ return convertDblArrToPyListOfTuple(vals,3,2);
+ }
+
+ static MEDCouplingUMesh *MergeUMeshes(PyObject *li) throw(INTERP_KERNEL::Exception)
+ {
+ std::vector<const ParaMEDMEM::MEDCouplingUMesh *> tmp;
+ convertPyObjToVecUMeshesCst(li,tmp);
+ return MEDCouplingUMesh::MergeUMeshes(tmp);
+ }
+
+ PyObject *areCellsIncludedIn(const MEDCouplingUMesh *other, int compType) const throw(INTERP_KERNEL::Exception)
+ {
+ DataArrayInt *ret1;
+ bool ret0=self->areCellsIncludedIn(other,compType,ret1);
+ PyObject *ret=PyTuple_New(2);
+ PyObject *ret0Py=ret0?Py_True:Py_False;
+ Py_XINCREF(ret0Py);
+ PyTuple_SetItem(ret,0,ret0Py);
+ PyTuple_SetItem(ret,1,SWIG_NewPointerObj(SWIG_as_voidptr(ret1),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 ));
+ return ret;
+ }
+
+ PyObject *buildDescendingConnectivity() const throw(INTERP_KERNEL::Exception)
+ {
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> d0=DataArrayInt::New();
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> d1=DataArrayInt::New();
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> d2=DataArrayInt::New();
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> d3=DataArrayInt::New();
+ MEDCouplingUMesh *m=self->buildDescendingConnectivity(d0,d1,d2,d3);
+ PyObject *ret=PyTuple_New(5);
+ PyTuple_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(m),SWIGTYPE_p_ParaMEDMEM__MEDCouplingUMesh, SWIG_POINTER_OWN | 0 ));
+ PyTuple_SetItem(ret,1,SWIG_NewPointerObj(SWIG_as_voidptr(d0),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 ));
+ PyTuple_SetItem(ret,2,SWIG_NewPointerObj(SWIG_as_voidptr(d1),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 ));
+ PyTuple_SetItem(ret,3,SWIG_NewPointerObj(SWIG_as_voidptr(d2),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 ));
+ PyTuple_SetItem(ret,4,SWIG_NewPointerObj(SWIG_as_voidptr(d3),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 ));
+ d0->incrRef();
+ d1->incrRef();
+ d2->incrRef();
+ d3->incrRef();
+ return ret;
+ }
+
+ PyObject *emulateMEDMEMBDC(const MEDCouplingUMesh *nM1LevMesh)
+ {
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> d0=DataArrayInt::New();
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> d1=DataArrayInt::New();
+ DataArrayInt *d2,*d3,*d4,*dd5;
+ MEDCouplingUMesh *mOut=self->emulateMEDMEMBDC(nM1LevMesh,d0,d1,d2,d3,d4,dd5);
+ PyObject *ret=PyTuple_New(7);
+ PyTuple_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(mOut),SWIGTYPE_p_ParaMEDMEM__MEDCouplingUMesh, SWIG_POINTER_OWN | 0 ));
+ PyTuple_SetItem(ret,1,SWIG_NewPointerObj(SWIG_as_voidptr((DataArrayInt *)d0),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 ));
+ PyTuple_SetItem(ret,2,SWIG_NewPointerObj(SWIG_as_voidptr((DataArrayInt *)d1),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 ));
+ PyTuple_SetItem(ret,3,SWIG_NewPointerObj(SWIG_as_voidptr(d2),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 ));
+ PyTuple_SetItem(ret,4,SWIG_NewPointerObj(SWIG_as_voidptr(d3),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 ));
+ PyTuple_SetItem(ret,5,SWIG_NewPointerObj(SWIG_as_voidptr(d4),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 ));
+ PyTuple_SetItem(ret,6,SWIG_NewPointerObj(SWIG_as_voidptr(dd5),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 ));
+ d0->incrRef();
+ d1->incrRef();
+ return ret;
+ }
+
+ PyObject *getReverseNodalConnectivity() const throw(INTERP_KERNEL::Exception)
+ {
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> d0=DataArrayInt::New();
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> d1=DataArrayInt::New();
+ self->getReverseNodalConnectivity(d0,d1);
+ PyObject *ret=PyTuple_New(2);
+ PyTuple_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(d0),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 ));
+ PyTuple_SetItem(ret,1,SWIG_NewPointerObj(SWIG_as_voidptr(d1),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 ));
+ d0->incrRef();
+ d1->incrRef();
+ return ret;
+ }
+
+ DataArrayDouble *getPartBarycenterAndOwner(DataArrayInt *da) const throw(INTERP_KERNEL::Exception)
+ {
+ if(!da)
+ throw INTERP_KERNEL::Exception("Not null DataArrayInt instance expected !");
+ da->checkAllocated();
+ return self->getPartBarycenterAndOwner(da->getConstPointer(),da->getConstPointer()+da->getNbOfElems());
+ }
+
+ DataArrayDouble *getPartMeasureField(bool isAbs, DataArrayInt *da) const throw(INTERP_KERNEL::Exception)
+ {
+ if(!da)
+ throw INTERP_KERNEL::Exception("Not null DataArrayInt instance expected !");
+ da->checkAllocated();
+ return self->getPartMeasureField(isAbs,da->getConstPointer(),da->getConstPointer()+da->getNbOfElems());
+ }
+
+ MEDCouplingFieldDouble *buildPartOrthogonalField(DataArrayInt *da) const throw(INTERP_KERNEL::Exception)
+ {
+ if(!da)
+ throw INTERP_KERNEL::Exception("Not null DataArrayInt instance expected !");
+ da->checkAllocated();
+ return self->buildPartOrthogonalField(da->getConstPointer(),da->getConstPointer()+da->getNbOfElems());
+ }
+
+ PyObject *getTypesOfPart(DataArrayInt *da) const throw(INTERP_KERNEL::Exception)
+ {
+ if(!da)
+ throw INTERP_KERNEL::Exception("Not null DataArrayInt instance expected !");
+ da->checkAllocated();
+ std::set<INTERP_KERNEL::NormalizedCellType> result=self->getTypesOfPart(da->getConstPointer(),da->getConstPointer()+da->getNbOfElems());
+ std::set<INTERP_KERNEL::NormalizedCellType>::const_iterator iL=result.begin();
+ PyObject *res = PyList_New(result.size());
+ for (int i=0;iL!=result.end(); i++, iL++)
+ PyList_SetItem(res,i,PyInt_FromLong(*iL));
+ return res;
+ }
+
+ DataArrayInt *keepCellIdsByType(INTERP_KERNEL::NormalizedCellType type, DataArrayInt *da) const throw(INTERP_KERNEL::Exception)
+ {
+ if(!da)
+ throw INTERP_KERNEL::Exception("Not null DataArrayInt instance expected !");
+ da->checkAllocated();
+ DataArrayInt *ret=self->keepCellIdsByType(type,da->getConstPointer(),da->getConstPointer()+da->getNbOfElems());
+ ret->setName(da->getName().c_str());
+ return ret;
+ }
+
+ DataArrayInt *getCellIdsLyingOnNodes(PyObject *li, bool fullyIn) const throw(INTERP_KERNEL::Exception)
+ {
+ void *da=0;
+ int res1=SWIG_ConvertPtr(li,&da,SWIGTYPE_p_ParaMEDMEM__DataArrayInt, 0 | 0 );
+ if (!SWIG_IsOK(res1))
+ {
+ int size;
+ INTERP_KERNEL::AutoPtr<int> tmp=convertPyToNewIntArr2(li,&size);
+ return self->getCellIdsLyingOnNodes(tmp,((const int *)tmp)+size,fullyIn);
+ }
+ else
+ {
+ DataArrayInt *da2=reinterpret_cast< DataArrayInt * >(da);
+ if(!da2)
+ throw INTERP_KERNEL::Exception("Not null DataArrayInt instance expected !");
+ da2->checkAllocated();
+ return self->getCellIdsLyingOnNodes(da2->getConstPointer(),da2->getConstPointer()+da2->getNbOfElems(),fullyIn);
+ }
+ }
+ }
+ void convertToPolyTypes(const std::vector<int>& cellIdsToConvert) throw(INTERP_KERNEL::Exception);
+ void convertAllToPoly();
+ void unPolyze() throw(INTERP_KERNEL::Exception);
+ MEDCouplingUMesh *buildExtrudedMesh(const MEDCouplingUMesh *mesh1D, int policy) throw(INTERP_KERNEL::Exception);
+ };
+
+ class MEDCouplingExtrudedMesh : public ParaMEDMEM::MEDCouplingMesh
+ {
+ public:
+ static MEDCouplingExtrudedMesh *New(const MEDCouplingUMesh *mesh3D, MEDCouplingUMesh *mesh2D, int cell2DId) throw(INTERP_KERNEL::Exception);
+ MEDCouplingUMesh *build3DUnstructuredMesh() const throw(INTERP_KERNEL::Exception);
+ %extend {
+ std::string __str__() const
+ {
+ return self->simpleRepr();
+ }
+ PyObject *getMesh2D() const throw(INTERP_KERNEL::Exception)
+ {
+ MEDCouplingUMesh *ret=self->getMesh2D();
+ ret->incrRef();
+ return convertMesh(ret, SWIG_POINTER_OWN | 0 );
+ }
+ PyObject *getMesh1D() const throw(INTERP_KERNEL::Exception)
+ {
+ MEDCouplingUMesh *ret=self->getMesh1D();
+ ret->incrRef();
+ return convertMesh(ret, SWIG_POINTER_OWN | 0 );
+ }
+ PyObject *getMesh3DIds() const throw(INTERP_KERNEL::Exception)
+ {
+ DataArrayInt *ret=self->getMesh3DIds();
+ ret->incrRef();
+ return SWIG_NewPointerObj(SWIG_as_voidptr(ret),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 );
+ }
+ }
+ };
+
+ class MEDCouplingCMesh : public ParaMEDMEM::MEDCouplingMesh
+ {
+ public:
+ static MEDCouplingCMesh *New();
+ void setCoords(const DataArrayDouble *coordsX,
+ const DataArrayDouble *coordsY=0,
+ const DataArrayDouble *coordsZ=0) throw(INTERP_KERNEL::Exception);
+ void setCoordsAt(int i, const DataArrayDouble *arr) throw(INTERP_KERNEL::Exception);
+ %extend {
+ std::string __str__() const
+ {
+ return self->simpleRepr();
+ }
+ DataArrayDouble *getCoordsAt(int i) throw(INTERP_KERNEL::Exception)
+ {
+ DataArrayDouble *ret=self->getCoordsAt(i);
+ if(ret)
+ ret->incrRef();
+ return ret;
+ }
+ }
+ };
+}
+
+%extend ParaMEDMEM::DataArray
+{
+ void copyPartOfStringInfoFrom(const DataArray& other, PyObject *li) throw(INTERP_KERNEL::Exception)
+ {
+ std::vector<int> tmp;
+ convertPyToNewIntArr3(li,tmp);
+ self->copyPartOfStringInfoFrom(other,tmp);
+ }
+
+ void copyPartOfStringInfoFrom2(PyObject *li, const DataArray& other) throw(INTERP_KERNEL::Exception)
+ {
+ std::vector<int> tmp;
+ convertPyToNewIntArr3(li,tmp);
+ self->copyPartOfStringInfoFrom2(tmp,other);
+ }
+}
+
+%extend ParaMEDMEM::DataArrayDouble
+ {
+ std::string __str__() const
+ {
+ return self->repr();
+ }
+
+ void setValues(PyObject *li, int nbOfTuples, int nbOfElsPerTuple) throw(INTERP_KERNEL::Exception)
+ {
+ double *tmp=new double[nbOfTuples*nbOfElsPerTuple];
+ try
+ {
+ fillArrayWithPyListDbl(li,tmp,nbOfTuples*nbOfElsPerTuple,0.);
+ }
+ catch(INTERP_KERNEL::Exception& e)
+ {
+ delete [] tmp;
+ throw e;
+ }
+ self->useArray(tmp,true,CPP_DEALLOC,nbOfTuples,nbOfElsPerTuple);
+ }
+
+ PyObject *getValues() throw(INTERP_KERNEL::Exception)
+ {
+ const double *vals=self->getPointer();
+ return convertDblArrToPyList(vals,self->getNbOfElems());
+ }
+
+ PyObject *getValuesAsTuple() throw(INTERP_KERNEL::Exception)
+ {
+ const double *vals=self->getPointer();
+ int nbOfComp=self->getNumberOfComponents();
+ int nbOfTuples=self->getNumberOfTuples();
+ return convertDblArrToPyListOfTuple(vals,nbOfComp,nbOfTuples);
+ }
+
+ DataArrayDouble *renumber(PyObject *li) throw(INTERP_KERNEL::Exception)
+ {
+ void *da=0;
+ int res1=SWIG_ConvertPtr(li,&da,SWIGTYPE_p_ParaMEDMEM__DataArrayInt, 0 | 0 );
+ if (!SWIG_IsOK(res1))
+ {
+ int size;
+ INTERP_KERNEL::AutoPtr<int> tmp=convertPyToNewIntArr2(li,&size);
+ if(size!=self->getNumberOfTuples())
+ {
+ throw INTERP_KERNEL::Exception("Invalid list length ! Must be equal to number of tuples !");
+ }
+ return self->renumber(tmp);
+ }
+ else
+ {
+ DataArrayInt *da2=reinterpret_cast< DataArrayInt * >(da);
+ if(!da2)
+ throw INTERP_KERNEL::Exception("Not null DataArrayInt instance expected !");
+ da2->checkAllocated();
+ int size=self->getNbOfElems();
+ if(size!=self->getNumberOfTuples())
+ {
+ throw INTERP_KERNEL::Exception("Invalid list length ! Must be equal to number of tuples !");
+ }
+ return self->renumber(da2->getConstPointer());
+ }
+ }
+
+ DataArrayDouble *renumberR(PyObject *li) throw(INTERP_KERNEL::Exception)
+ {
+ void *da=0;
+ int res1=SWIG_ConvertPtr(li,&da,SWIGTYPE_p_ParaMEDMEM__DataArrayInt, 0 | 0 );
+ if (!SWIG_IsOK(res1))
+ {
+ int size;
+ INTERP_KERNEL::AutoPtr<int> tmp=convertPyToNewIntArr2(li,&size);
+ if(size!=self->getNumberOfTuples())
+ {
+ throw INTERP_KERNEL::Exception("Invalid list length ! Must be equal to number of tuples !");
+ }
+ return self->renumberR(tmp);
+ }
+ else
+ {
+ DataArrayInt *da2=reinterpret_cast< DataArrayInt * >(da);
+ if(!da2)
+ throw INTERP_KERNEL::Exception("Not null DataArrayInt instance expected !");
+ da2->checkAllocated();
+ int size=self->getNbOfElems();
+ if(size!=self->getNumberOfTuples())
+ {
+ throw INTERP_KERNEL::Exception("Invalid list length ! Must be equal to number of tuples !");
+ }
+ return self->renumberR(da2->getConstPointer());
+ }
+ }
+
+ DataArrayDouble *renumberAndReduce(PyObject *li, int newNbOfTuple) throw(INTERP_KERNEL::Exception)
+ {
+ void *da=0;
+ int res1=SWIG_ConvertPtr(li,&da,SWIGTYPE_p_ParaMEDMEM__DataArrayInt, 0 | 0 );
+ if (!SWIG_IsOK(res1))
+ {
+ int size;
+ INTERP_KERNEL::AutoPtr<int> tmp=convertPyToNewIntArr2(li,&size);
+ if(size!=self->getNumberOfTuples())
+ {
+ throw INTERP_KERNEL::Exception("Invalid list length ! Must be equal to number of tuples !");
+ }
+ return self->renumberAndReduce(tmp,newNbOfTuple);
+ }
+ else
+ {
+ DataArrayInt *da2=reinterpret_cast< DataArrayInt * >(da);
+ if(!da2)
+ throw INTERP_KERNEL::Exception("Not null DataArrayInt instance expected !");
+ da2->checkAllocated();
+ int size=self->getNbOfElems();
+ if(size!=self->getNumberOfTuples())
+ {
+ throw INTERP_KERNEL::Exception("Invalid list length ! Must be equal to number of tuples !");
+ }
+ return self->renumberAndReduce(da2->getConstPointer(),newNbOfTuple);
+ }
+ }
+
+ void renumberInPlace(PyObject *li) throw(INTERP_KERNEL::Exception)
+ {
+ void *da=0;
+ int res1=SWIG_ConvertPtr(li,&da,SWIGTYPE_p_ParaMEDMEM__DataArrayInt, 0 | 0 );
+ if (!SWIG_IsOK(res1))
+ {
+ int size;
+ INTERP_KERNEL::AutoPtr<int> tmp=convertPyToNewIntArr2(li,&size);
+ if(size!=self->getNumberOfTuples())
+ {
+ throw INTERP_KERNEL::Exception("Invalid list length ! Must be equal to number of tuples !");
+ }
+ self->renumberInPlace(tmp);
+ }
+ else
+ {
+ DataArrayInt *da2=reinterpret_cast< DataArrayInt * >(da);
+ if(!da2)
+ throw INTERP_KERNEL::Exception("Not null DataArrayInt instance expected !");
+ da2->checkAllocated();
+ int size=self->getNbOfElems();
+ if(size!=self->getNumberOfTuples())
+ {
+ throw INTERP_KERNEL::Exception("Invalid list length ! Must be equal to number of tuples !");
+ }
+ self->renumberInPlace(da2->getConstPointer());
+ }
+ }
+
+ void renumberInPlaceR(PyObject *li) throw(INTERP_KERNEL::Exception)
+ {
+ void *da=0;
+ int res1=SWIG_ConvertPtr(li,&da,SWIGTYPE_p_ParaMEDMEM__DataArrayInt, 0 | 0 );
+ if (!SWIG_IsOK(res1))
+ {
+ int size;
+ INTERP_KERNEL::AutoPtr<int> tmp=convertPyToNewIntArr2(li,&size);
+ if(size!=self->getNumberOfTuples())
+ {
+ throw INTERP_KERNEL::Exception("Invalid list length ! Must be equal to number of tuples !");
+ }
+ self->renumberInPlaceR(tmp);
+ }
+ else
+ {
+ DataArrayInt *da2=reinterpret_cast< DataArrayInt * >(da);
+ if(!da2)
+ throw INTERP_KERNEL::Exception("Not null DataArrayInt instance expected !");
+ da2->checkAllocated();
+ int size=self->getNbOfElems();
+ if(size!=self->getNumberOfTuples())
+ {
+ throw INTERP_KERNEL::Exception("Invalid list length ! Must be equal to number of tuples !");
+ }
+ self->renumberInPlaceR(da2->getConstPointer());
+ }
+ }
+
+ DataArrayDouble *selectByTupleId(PyObject *li) const throw(INTERP_KERNEL::Exception)
+ {
+ void *da=0;
+ int res1=SWIG_ConvertPtr(li,&da,SWIGTYPE_p_ParaMEDMEM__DataArrayInt, 0 | 0 );
+ if (!SWIG_IsOK(res1))
+ {
+ int size;
+ INTERP_KERNEL::AutoPtr<int> tmp=convertPyToNewIntArr2(li,&size);
+ return self->selectByTupleId(tmp,tmp+size);
+ }
+ else
+ {
+ DataArrayInt *da2=reinterpret_cast< DataArrayInt * >(da);
+ if(!da2)
+ throw INTERP_KERNEL::Exception("Not null DataArrayInt instance expected !");
+ da2->checkAllocated();
+ return self->selectByTupleId(da2->getConstPointer(),da2->getConstPointer()+da2->getNbOfElems());
+ }
+ }
+
+ DataArrayDouble *selectByTupleIdSafe(PyObject *li) const throw(INTERP_KERNEL::Exception)
+ {
+ void *da=0;
+ int res1=SWIG_ConvertPtr(li,&da,SWIGTYPE_p_ParaMEDMEM__DataArrayInt, 0 | 0 );
+ if (!SWIG_IsOK(res1))
+ {
+ int size;
+ INTERP_KERNEL::AutoPtr<int> tmp=convertPyToNewIntArr2(li,&size);
+ return self->selectByTupleIdSafe(tmp,tmp+size);
+ }
+ else
+ {
+ DataArrayInt *da2=reinterpret_cast< DataArrayInt * >(da);
+ if(!da2)
+ throw INTERP_KERNEL::Exception("Not null DataArrayInt instance expected !");
+ da2->checkAllocated();
+ return self->selectByTupleIdSafe(da2->getConstPointer(),da2->getConstPointer()+da2->getNbOfElems());
+ }
+ }
+
+ PyObject *getMaxValue() const throw(INTERP_KERNEL::Exception)
+ {
+ int tmp;
+ double r1=self->getMaxValue(tmp);
+ PyObject *ret=PyTuple_New(2);
+ PyTuple_SetItem(ret,0,PyFloat_FromDouble(r1));
+ PyTuple_SetItem(ret,1,PyInt_FromLong(tmp));
+ return ret;
+ }
+
+ PyObject *getMaxValue2() const throw(INTERP_KERNEL::Exception)
+ {
+ DataArrayInt *tmp;
+ double r1=self->getMaxValue2(tmp);
+ PyObject *ret=PyTuple_New(2);
+ PyTuple_SetItem(ret,0,PyFloat_FromDouble(r1));
+ PyTuple_SetItem(ret,1,SWIG_NewPointerObj(SWIG_as_voidptr(tmp),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 ));
+ return ret;
+ }
+
+ PyObject *getMinValue() const throw(INTERP_KERNEL::Exception)
+ {
+ int tmp;
+ double r1=self->getMinValue(tmp);
+ PyObject *ret=PyTuple_New(2);
+ PyTuple_SetItem(ret,0,PyFloat_FromDouble(r1));
+ PyTuple_SetItem(ret,1,PyInt_FromLong(tmp));
+ return ret;
+ }
+
+ PyObject *getMinValue2() const throw(INTERP_KERNEL::Exception)
+ {
+ DataArrayInt *tmp;
+ double r1=self->getMinValue2(tmp);
+ PyObject *ret=PyTuple_New(2);
+ PyTuple_SetItem(ret,0,PyFloat_FromDouble(r1));
+ PyTuple_SetItem(ret,1,SWIG_NewPointerObj(SWIG_as_voidptr(tmp),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 ));
+ return ret;
+ }
+
+ PyObject *accumulate() const throw(INTERP_KERNEL::Exception)
+ {
+ int sz=self->getNumberOfComponents();
+ double *tmp=new double[sz];
+ try
+ {
+ self->accumulate(tmp);
+ }
+ catch(INTERP_KERNEL::Exception& e)
+ {
+ delete [] tmp;
+ throw e;
+ }
+ PyObject *ret=convertDblArrToPyList(tmp,sz);
+ delete [] tmp;
+ return ret;
+ }
+
+ DataArrayDouble *keepSelectedComponents(PyObject *li) const throw(INTERP_KERNEL::Exception)
+ {
+ std::vector<int> tmp;
+ convertPyToNewIntArr3(li,tmp);
+ return self->keepSelectedComponents(tmp);
+ }
+
+ void setSelectedComponents(const DataArrayDouble *a, PyObject *li) throw(INTERP_KERNEL::Exception)
+ {
+ std::vector<int> tmp;
+ convertPyToNewIntArr3(li,tmp);
+ self->setSelectedComponents(a,tmp);
+ }
+
+ PyObject *getTuple(int tupleId) throw(INTERP_KERNEL::Exception)
+ {
+ int sz=self->getNumberOfComponents();
+ INTERP_KERNEL::AutoPtr<double> tmp=new double[sz];
+ self->getTuple(tupleId,tmp);
+ return convertDblArrToPyList(tmp,sz);
+ }
+
+ static DataArrayDouble *Aggregate(PyObject *li) throw(INTERP_KERNEL::Exception)
+ {
+ std::vector<const DataArrayDouble *> tmp;
+ convertPyObjToVecDataArrayDblCst(li,tmp);
+ return DataArrayDouble::Aggregate(tmp);
+ }
+
+ static DataArrayDouble *Meld(PyObject *li) throw(INTERP_KERNEL::Exception)
+ {
+ std::vector<const DataArrayDouble *> tmp;
+ convertPyObjToVecDataArrayDblCst(li,tmp);
+ return DataArrayDouble::Meld(tmp);
+ }
+
+ DataArrayDouble *__getitem__(PyObject *obj) throw(INTERP_KERNEL::Exception)
+ {
+ const char msg[]="Unexpected situation in __getitem__ !";
+ self->checkAllocated();
+ int nbOfTuples=self->getNumberOfTuples();
+ int nbOfComponents=self->getNumberOfComponents();
+ int it1,ic1;
+ std::vector<int> vt1,vc1;
+ std::pair<int, std::pair<int,int> > pt1,pc1;
+ DataArrayInt *dt1=0,*dc1=0;
+ int sw;
+ convertObjToPossibleCpp3(obj,nbOfTuples,nbOfComponents,sw,it1,ic1,vt1,vc1,pt1,pc1,dt1,dc1);
+ MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> ret;
+ switch(sw)
+ {
+ case 1:
+ return self->selectByTupleIdSafe(&it1,&it1+1);
+ case 2:
+ return self->selectByTupleIdSafe(&vt1[0],&vt1[0]+vt1.size());
+ case 3:
+ return self->selectByTupleId2(pt1.first,pt1.second.first,pt1.second.second);
+ case 4:
+ return self->selectByTupleIdSafe(dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems());
+ case 5:
+ {
+ ret=self->selectByTupleIdSafe(&it1,&it1+1);
+ std::vector<int> v2(1,ic1);
+ return ret->keepSelectedComponents(v2);
+ }
+ case 6:
+ {
+ ret=self->selectByTupleIdSafe(&vt1[0],&vt1[0]+vt1.size());
+ std::vector<int> v2(1,ic1);
+ return ret->keepSelectedComponents(v2);
+ }
+ case 7:
+ {
+ ret=self->selectByTupleId2(pt1.first,pt1.second.first,pt1.second.second);
+ std::vector<int> v2(1,ic1);
+ return ret->keepSelectedComponents(v2);
+ }
+ case 8:
+ {
+ ret=self->selectByTupleIdSafe(dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems());
+ std::vector<int> v2(1,ic1);
+ return ret->keepSelectedComponents(v2);
+ }
+ case 9:
+ {
+ ret=self->selectByTupleIdSafe(&it1,&it1+1);
+ return ret->keepSelectedComponents(vc1);
+ }
+ case 10:
+ {
+ ret=self->selectByTupleIdSafe(&vt1[0],&vt1[0]+vt1.size());
+ return ret->keepSelectedComponents(vc1);
+ }
+ case 11:
+ {
+ ret=self->selectByTupleId2(pt1.first,pt1.second.first,pt1.second.second);
+ return ret->keepSelectedComponents(vc1);
+ }
+ case 12:
+ {
+ ret=self->selectByTupleIdSafe(dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems());
+ return ret->keepSelectedComponents(vc1);
+ }
+ case 13:
+ {
+ ret=self->selectByTupleIdSafe(&it1,&it1+1);
+ int nbOfComp=(pc1.second.first-1-pc1.first)/pc1.second.second+1;
+ std::vector<int> v2(nbOfComp);
+ for(int i=0;i<nbOfComp;i++)
+ v2[i]=pc1.first+i*pc1.second.second;
+ return ret->keepSelectedComponents(v2);
+ }
+ case 14:
+ {
+ ret=self->selectByTupleIdSafe(&vt1[0],&vt1[0]+vt1.size());
+ int nbOfComp=(pc1.second.first-1-pc1.first)/pc1.second.second+1;
+ std::vector<int> v2(nbOfComp);
+ for(int i=0;i<nbOfComp;i++)
+ v2[i]=pc1.first+i*pc1.second.second;
+ return ret->keepSelectedComponents(v2);
+ }
+ case 15:
+ {
+ ret=self->selectByTupleId2(pt1.first,pt1.second.first,pt1.second.second);
+ int nbOfComp=(pc1.second.first-1-pc1.first)/pc1.second.second+1;
+ std::vector<int> v2(nbOfComp);
+ for(int i=0;i<nbOfComp;i++)
+ v2[i]=pc1.first+i*pc1.second.second;
+ return ret->keepSelectedComponents(v2);
+ }
+ case 16:
+ {
+ ret=self->selectByTupleIdSafe(dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems());
+ int nbOfComp=(pc1.second.first-1-pc1.first)/pc1.second.second+1;
+ std::vector<int> v2(nbOfComp);
+ for(int i=0;i<nbOfComp;i++)
+ v2[i]=pc1.first+i*pc1.second.second;
+ return ret->keepSelectedComponents(v2);
+ }
+ default:
+ throw INTERP_KERNEL::Exception(msg);
+ }
+ }
+
+ DataArrayDouble *__setitem__(PyObject *obj, PyObject *value) throw(INTERP_KERNEL::Exception)
+ {
+ self->checkAllocated();
+ const char msg[]="Unexpected situation in __setitem__ !";
+ int nbOfTuples=self->getNumberOfTuples();
+ int nbOfComponents=self->getNumberOfComponents();
+ int sw1,sw2;
+ double i1;
+ std::vector<double> v1;
+ DataArrayDouble *d1=0;
+ convertObjToPossibleCpp4(value,sw1,i1,v1,d1);
+ int it1,ic1;
+ std::vector<int> vt1,vc1;
+ std::pair<int, std::pair<int,int> > pt1,pc1;
+ DataArrayInt *dt1=0,*dc1=0;
+ convertObjToPossibleCpp3(obj,nbOfTuples,nbOfComponents,sw2,it1,ic1,vt1,vc1,pt1,pc1,dt1,dc1);
+ MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> tmp;
+ switch(sw2)
+ {
+ case 1:
+ {
+ switch(sw1)
+ {
+ case 1:
+ self->setPartOfValuesSimple1(i1,it1,it1+1,1,0,nbOfComponents,1);
+ return self;
+ case 2:
+ tmp=DataArrayDouble::New();
+ tmp->useArray(&v1[0],false,CPP_DEALLOC,v1.size(),1);
+ self->setPartOfValues1(tmp,it1,it1+1,1,0,nbOfComponents,1,false);
+ return self;
+ case 3:
+ self->setPartOfValues1(d1,it1,it1+1,1,0,nbOfComponents,1);
+ return self;
+ default:
+ throw INTERP_KERNEL::Exception(msg);
+ }
+ break;
+ }
+ case 2:
+ {
+ switch(sw1)
+ {
+ case 1:
+ self->setPartOfValuesSimple3(i1,&vt1[0],&vt1[0]+vt1.size(),0,nbOfComponents,1);
+ return self;
+ case 2:
+ tmp=DataArrayDouble::New();
+ tmp->useArray(&v1[0],false,CPP_DEALLOC,v1.size(),1);
+ self->setPartOfValues3(tmp,&vt1[0],&vt1[0]+vt1.size(),0,nbOfComponents,1,false);
+ return self;
+ case 3:
+ self->setPartOfValues3(d1,&vt1[0],&vt1[0]+vt1.size(),0,nbOfComponents,1);
+ return self;
+ default:
+ throw INTERP_KERNEL::Exception(msg);
+ }
+ break;
+ }
+ case 3:
+ {
+ switch(sw1)
+ {
+ case 1:
+ self->setPartOfValuesSimple1(i1,pt1.first,pt1.second.first,pt1.second.second,0,nbOfComponents,1);
+ return self;
+ case 2:
+ tmp=DataArrayDouble::New();
+ tmp->useArray(&v1[0],false,CPP_DEALLOC,v1.size(),1);
+ self->setPartOfValues1(tmp,pt1.first,pt1.second.first,pt1.second.second,0,nbOfComponents,1,false);
+ return self;
+ case 3:
+ self->setPartOfValues1(d1,pt1.first,pt1.second.first,pt1.second.second,0,nbOfComponents,1);
+ return self;
+ default:
+ throw INTERP_KERNEL::Exception(msg);
+ }
+ break;
+ }
+ case 4:
+ {
+ switch(sw1)
+ {
+ case 1:
+ self->setPartOfValuesSimple3(i1,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),0,nbOfComponents,1);
+ return self;
+ case 2:
+ tmp=DataArrayDouble::New();
+ tmp->useArray(&v1[0],false,CPP_DEALLOC,v1.size(),1);
+ self->setPartOfValues3(tmp,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),0,nbOfComponents,1,false);
+ return self;
+ case 3:
+ self->setPartOfValues3(d1,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),0,nbOfComponents,1);
+ return self;
+ default:
+ throw INTERP_KERNEL::Exception(msg);
+ }
+ break;
+ }
+ case 5:
+ {
+ switch(sw1)
+ {
+ case 1:
+ self->setPartOfValuesSimple1(i1,it1,it1+1,1,ic1,ic1+1,1);
+ return self;
+ case 2:
+ tmp=DataArrayDouble::New();
+ tmp->useArray(&v1[0],false,CPP_DEALLOC,v1.size(),1);
+ self->setPartOfValues1(tmp,it1,it1+1,1,ic1,ic1+1,1,false);
+ return self;
+ case 3:
+ self->setPartOfValues1(d1,it1,it1+1,1,ic1,ic1+1,1);
+ return self;
+ default:
+ throw INTERP_KERNEL::Exception(msg);
+ }
+ break;
+ }
+ case 6:
+ {
+ switch(sw1)
+ {
+ case 1:
+ self->setPartOfValuesSimple3(i1,&vt1[0],&vt1[0]+vt1.size(),ic1,ic1+1,1);
+ return self;
+ case 2:
+ tmp=DataArrayDouble::New();
+ tmp->useArray(&v1[0],false,CPP_DEALLOC,v1.size(),1);
+ self->setPartOfValues3(tmp,&vt1[0],&vt1[0]+vt1.size(),ic1,ic1+1,1,false);
+ return self;
+ case 3:
+ self->setPartOfValues3(d1,&vt1[0],&vt1[0]+vt1.size(),ic1,ic1+1,1);
+ return self;
+ default:
+ throw INTERP_KERNEL::Exception(msg);
+ }
+ break;
+ }
+ case 7:
+ {
+ switch(sw1)
+ {
+ case 1:
+ self->setPartOfValuesSimple1(i1,pt1.first,pt1.second.first,pt1.second.second,ic1,ic1+1,1);
+ return self;
+ case 2:
+ tmp=DataArrayDouble::New();
+ tmp->useArray(&v1[0],false,CPP_DEALLOC,v1.size(),1);
+ self->setPartOfValues1(tmp,pt1.first,pt1.second.first,pt1.second.second,ic1,ic1+1,1,false);
+ return self;
+ case 3:
+ self->setPartOfValues1(d1,pt1.first,pt1.second.first,pt1.second.second,ic1,ic1+1,1);
+ return self;
+ default:
+ throw INTERP_KERNEL::Exception(msg);
+ }
+ break;
+ }
+ case 8:
+ {
+ switch(sw1)
+ {
+ case 1:
+ self->setPartOfValuesSimple3(i1,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),ic1,ic1+1,1);
+ return self;
+ case 2:
+ tmp=DataArrayDouble::New();
+ tmp->useArray(&v1[0],false,CPP_DEALLOC,v1.size(),1);
+ self->setPartOfValues3(tmp,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),ic1,ic1+1,1,false);
+ return self;
+ case 3:
+ self->setPartOfValues3(d1,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),ic1,ic1+1,1);
+ return self;
+ default:
+ throw INTERP_KERNEL::Exception(msg);
+ }
+ break;
+ }
+ case 9:
+ {
+ switch(sw1)
+ {
+ case 1:
+ self->setPartOfValuesSimple2(i1,&it1,&it1+1,&vc1[0],&vc1[0]+vc1.size());
+ return self;
+ case 2:
+ tmp=DataArrayDouble::New();
+ tmp->useArray(&v1[0],false,CPP_DEALLOC,v1.size(),1);
+ self->setPartOfValues2(tmp,&it1,&it1+1,&vc1[0],&vc1[0]+vc1.size(),false);
+ return self;
+ case 3:
+ self->setPartOfValues2(d1,&it1,&it1+1,&vc1[0],&vc1[0]+vc1.size());
+ return self;
+ default:
+ throw INTERP_KERNEL::Exception(msg);
+ }
+ break;
+ }
+ case 10:
+ {
+ switch(sw1)
+ {
+ case 1:
+ self->setPartOfValuesSimple2(i1,&vt1[0],&vt1[0]+vt1.size(),&vc1[0],&vc1[0]+vc1.size());
+ return self;
+ case 2:
+ tmp=DataArrayDouble::New();
+ tmp->useArray(&v1[0],false,CPP_DEALLOC,v1.size(),1);
+ self->setPartOfValues2(tmp,&vt1[0],&vt1[0]+vt1.size(),&vc1[0],&vc1[0]+vc1.size(),false);
+ return self;
+ case 3:
+ self->setPartOfValues2(d1,&vt1[0],&vt1[0]+vt1.size(),&vc1[0],&vc1[0]+vc1.size());
+ return self;
+ default:
+ throw INTERP_KERNEL::Exception(msg);
+ }
+ break;
+ }
+ case 11:
+ {
+ int bb=pt1.first;
+ int ee=pt1.second.first;
+ int ss=pt1.second.second;
+ if(ee<bb || ss<=0)
+ throw INTERP_KERNEL::Exception("Invalid slice in tuple selection");
+ int nbOfE=(ee-bb)/ss;
+ std::vector<int> nv(nbOfE);
+ for(int jj=0;jj<nbOfE;jj++)
+ nv[jj]=bb+jj*ss;
+ switch(sw1)
+ {
+ case 1:
+ self->setPartOfValuesSimple2(i1,&nv[0],&nv[0]+nv.size(),&vc1[0],&vc1[0]+vc1.size());
+ return self;
+ case 2:
+ tmp=DataArrayDouble::New();
+ tmp->useArray(&v1[0],false,CPP_DEALLOC,v1.size(),1);
+ self->setPartOfValues2(tmp,&nv[0],&nv[0]+nv.size(),&vc1[0],&vc1[0]+vc1.size(),false);
+ return self;
+ case 3:
+ self->setPartOfValues2(d1,&nv[0],&nv[0]+nv.size(),&vc1[0],&vc1[0]+vc1.size());
+ return self;
+ default:
+ throw INTERP_KERNEL::Exception(msg);
+ }
+ break;
+ }
+ case 12:
+ {
+ switch(sw1)
+ {
+ case 1:
+ self->setPartOfValuesSimple2(i1,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),&vc1[0],&vc1[0]+vc1.size());
+ return self;
+ case 2:
+ tmp=DataArrayDouble::New();
+ tmp->useArray(&v1[0],false,CPP_DEALLOC,v1.size(),1);
+ self->setPartOfValues2(tmp,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),&vc1[0],&vc1[0]+vc1.size(),false);
+ return self;
+ case 3:
+ self->setPartOfValues2(d1,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),&vc1[0],&vc1[0]+vc1.size());
+ return self;
+ default:
+ throw INTERP_KERNEL::Exception(msg);
+ }
+ break;
+ }
+ case 13:
+ {
+ switch(sw1)
+ {
+ case 1:
+ self->setPartOfValuesSimple1(i1,it1,it1+1,1,pc1.first,pc1.second.first,pc1.second.second);
+ return self;
+ case 2:
+ tmp=DataArrayDouble::New();
+ tmp->useArray(&v1[0],false,CPP_DEALLOC,v1.size(),1);
+ self->setPartOfValues1(tmp,it1,it1+1,1,pc1.first,pc1.second.first,pc1.second.second,false);
+ return self;
+ case 3:
+ self->setPartOfValues1(d1,it1,it1+1,1,pc1.first,pc1.second.first,pc1.second.second);
+ return self;
+ default:
+ throw INTERP_KERNEL::Exception(msg);
+ }
+ break;
+ }
+ case 14:
+ {
+ switch(sw1)
+ {
+ case 1:
+ self->setPartOfValuesSimple3(i1,&vt1[0],&vt1[0]+vt1.size(),pc1.first,pc1.second.first,pc1.second.second);
+ return self;
+ case 2:
+ tmp=DataArrayDouble::New();
+ tmp->useArray(&v1[0],false,CPP_DEALLOC,v1.size(),1);
+ self->setPartOfValues3(tmp,&vt1[0],&vt1[0]+vt1.size(),pc1.first,pc1.second.first,pc1.second.second,false);
+ return self;
+ case 3:
+ self->setPartOfValues3(d1,&vt1[0],&vt1[0]+vt1.size(),pc1.first,pc1.second.first,pc1.second.second);
+ return self;
+ default:
+ throw INTERP_KERNEL::Exception(msg);
+ }
+ break;
+ }
+ case 15:
+ {
+ switch(sw1)
+ {
+ case 1:
+ self->setPartOfValuesSimple1(i1,pt1.first,pt1.second.first,pt1.second.second,pc1.first,pc1.second.first,pc1.second.second);
+ return self;
+ case 2:
+ tmp=DataArrayDouble::New();
+ tmp->useArray(&v1[0],false,CPP_DEALLOC,v1.size(),1);
+ self->setPartOfValues1(tmp,pt1.first,pt1.second.first,pt1.second.second,pc1.first,pc1.second.first,pc1.second.second,false);
+ return self;
+ case 3:
+ self->setPartOfValues1(d1,pt1.first,pt1.second.first,pt1.second.second,pc1.first,pc1.second.first,pc1.second.second);
+ return self;
+ default:
+ throw INTERP_KERNEL::Exception(msg);
+ }
+ break;
+ }
+ case 16:
+ {
+ switch(sw1)
+ {
+ case 1:
+ self->setPartOfValuesSimple3(i1,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),pc1.first,pc1.second.first,pc1.second.second);
+ return self;
+ case 2:
+ tmp=DataArrayDouble::New();
+ tmp->useArray(&v1[0],false,CPP_DEALLOC,v1.size(),1);
+ self->setPartOfValues3(tmp,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),pc1.first,pc1.second.first,pc1.second.second,false);
+ return self;
+ case 3:
+ self->setPartOfValues3(d1,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),pc1.first,pc1.second.first,pc1.second.second);
+ return self;
+ default:
+ throw INTERP_KERNEL::Exception(msg);
+ }
+ break;
+ }
+ default:
+ throw INTERP_KERNEL::Exception(msg);
+ }
+ return self;
+ }
+
+ DataArrayDouble *__add__(PyObject *obj) throw(INTERP_KERNEL::Exception)
+ {
+ const char msg[]="Unexpected situation in __add__ !";
+ double val;
+ DataArrayDouble *a;
+ int sw;
+ convertObjToPossibleCpp5(obj,sw,val,a);
+ switch(sw)
+ {
+ case 1:
+ {
+ MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> ret=self->deepCpy();
+ ret->applyLin(1.,val);
+ ret->incrRef();
+ return ret;
+ }
+ case 2:
+ {
+ return DataArrayDouble::Add(self,a);
+ }
+ default:
+ throw INTERP_KERNEL::Exception(msg);
+ }
+ }
+
+ DataArrayDouble *__radd__(PyObject *obj) throw(INTERP_KERNEL::Exception)
+ {
+ const char msg[]="Unexpected situation in __radd__ !";
+ double val;
+ DataArrayDouble *a;
+ int sw;
+ convertObjToPossibleCpp5(obj,sw,val,a);
+ switch(sw)
+ {
+ case 1:
+ {
+ MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> ret=self->deepCpy();
+ ret->applyLin(1.,val);
+ ret->incrRef();
+ return ret;
+ }
+ default:
+ throw INTERP_KERNEL::Exception(msg);
+ }
+ }
+
+ DataArrayDouble *operator+=(PyObject *obj) throw(INTERP_KERNEL::Exception)
+ {
+ const char msg[]="Unexpected situation in __iadd__ !";
+ double val;
+ DataArrayDouble *a;
+ int sw;
+ convertObjToPossibleCpp5(obj,sw,val,a);
+ switch(sw)
+ {
+ case 1:
+ {
+ self->applyLin(1.,val);
+ return self;
+ }
+ case 2:
+ {
+ self->addEqual(a);
+ return self;
+ }
+ default:
+ throw INTERP_KERNEL::Exception(msg);
+ }
+ }
+
+ DataArrayDouble *__sub__(PyObject *obj) throw(INTERP_KERNEL::Exception)
+ {
+ const char msg[]="Unexpected situation in __sub__ !";
+ double val;
+ DataArrayDouble *a;
+ int sw;
+ convertObjToPossibleCpp5(obj,sw,val,a);
+ switch(sw)
+ {
+ case 1:
+ {
+ MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> ret=self->deepCpy();
+ ret->applyLin(1.,-val);
+ ret->incrRef();
+ return ret;
+ }
+ case 2:
+ {
+ return DataArrayDouble::Substract(self,a);
+ }
+ default:
+ throw INTERP_KERNEL::Exception(msg);
+ }
+ }
+
+ DataArrayDouble *__rsub__(PyObject *obj) throw(INTERP_KERNEL::Exception)
+ {
+ const char msg[]="Unexpected situation in __rsub__ !";
+ double val;
+ DataArrayDouble *a;
+ int sw;
+ convertObjToPossibleCpp5(obj,sw,val,a);
+ switch(sw)
+ {
+ case 1:
+ {
+ MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> ret=self->deepCpy();
+ ret->applyLin(-1.,val);
+ ret->incrRef();
+ return ret;
+ }
+ default:
+ throw INTERP_KERNEL::Exception(msg);
+ }
+ }
+
+ DataArrayDouble *operator-=(PyObject *obj) throw(INTERP_KERNEL::Exception)
+ {
+ const char msg[]="Unexpected situation in __isub__ !";
+ double val;
+ DataArrayDouble *a;
+ int sw;
+ convertObjToPossibleCpp5(obj,sw,val,a);
+ switch(sw)
+ {
+ case 1:
+ {
+ self->applyLin(1.,-val);
+ return self;
+ }
+ case 2:
+ {
+ self->substractEqual(a);
+ return self;
+ }
+ default:
+ throw INTERP_KERNEL::Exception(msg);
+ }
+ }
+
+ DataArrayDouble *__mul__(PyObject *obj) throw(INTERP_KERNEL::Exception)
+ {
+ const char msg[]="Unexpected situation in __mul__ !";
+ double val;
+ DataArrayDouble *a;
+ int sw;
+ convertObjToPossibleCpp5(obj,sw,val,a);
+ switch(sw)
+ {
+ case 1:
+ {
+ MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> ret=self->deepCpy();
+ ret->applyLin(val,0.);
+ ret->incrRef();
+ return ret;
+ }
+ case 2:
+ {
+ return DataArrayDouble::Multiply(self,a);
+ }
+ default:
+ throw INTERP_KERNEL::Exception(msg);
+ }
+ }
+
+ DataArrayDouble *__rmul__(PyObject *obj) throw(INTERP_KERNEL::Exception)
+ {
+ const char msg[]="Unexpected situation in __rmul__ !";
+ double val;
+ DataArrayDouble *a;
+ int sw;
+ convertObjToPossibleCpp5(obj,sw,val,a);
+ switch(sw)
+ {
+ case 1:
+ {
+ MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> ret=self->deepCpy();
+ ret->applyLin(val,0.);
+ ret->incrRef();
+ return ret;
+ }
+ default:
+ throw INTERP_KERNEL::Exception(msg);
+ }
+ }
+
+ DataArrayDouble *operator*=(PyObject *obj) throw(INTERP_KERNEL::Exception)
+ {
+ const char msg[]="Unexpected situation in __imul__ !";
+ double val;
+ DataArrayDouble *a;
+ int sw;
+ convertObjToPossibleCpp5(obj,sw,val,a);
+ switch(sw)
+ {
+ case 1:
+ {
+ self->applyLin(val,0.);
+ return self;
+ }
+ case 2:
+ {
+ self->multiplyEqual(a);
+ return self;
+ }
+ default:
+ throw INTERP_KERNEL::Exception(msg);
+ }
+ }
+
+ DataArrayDouble *__div__(PyObject *obj) throw(INTERP_KERNEL::Exception)
+ {
+ const char msg[]="Unexpected situation in __div__ !";
+ double val;
+ DataArrayDouble *a;
+ int sw;
+ convertObjToPossibleCpp5(obj,sw,val,a);
+ switch(sw)
+ {
+ case 1:
+ {
+ if(val==0.)
+ throw INTERP_KERNEL::Exception("DataArrayDouble::__div__ : trying to divide by zero !");
+ MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> ret=self->deepCpy();
+ ret->applyLin(1/val,0.);
+ ret->incrRef();
+ return ret;
+ }
+ case 2:
+ {
+ return DataArrayDouble::Divide(self,a);
+ }
+ default:
+ throw INTERP_KERNEL::Exception(msg);
+ }
+ }
+
+ DataArrayDouble *__rdiv__(PyObject *obj) throw(INTERP_KERNEL::Exception)
+ {
+ const char msg[]="Unexpected situation in __rdiv__ !";
+ double val;
+ DataArrayDouble *a;
+ int sw;
+ convertObjToPossibleCpp5(obj,sw,val,a);
+ switch(sw)
+ {
+ case 1:
+ {
+ MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> ret=self->deepCpy();
+ ret->applyInv(val);
+ ret->incrRef();
+ return ret;
+ }
+ default:
+ throw INTERP_KERNEL::Exception(msg);
+ }
+ }
+
+ DataArrayDouble *operator/=(PyObject *obj) throw(INTERP_KERNEL::Exception)
+ {
+ const char msg[]="Unexpected situation in __imul__ !";
+ double val;
+ DataArrayDouble *a;
+ int sw;
+ convertObjToPossibleCpp5(obj,sw,val,a);
+ switch(sw)
+ {
+ case 1:
+ {
+ if(val==0.)
+ throw INTERP_KERNEL::Exception("DataArrayDouble::__div__ : trying to divide by zero !");
+ self->applyLin(1./val,0.);
+ return self;
+ }
+ case 2:
+ {
+ self->divideEqual(a);
+ return self;
+ }
+ default:
+ throw INTERP_KERNEL::Exception(msg);
+ }
+ }
+ };
+
+%extend ParaMEDMEM::DataArrayInt
+ {
+ std::string __str__() const
+ {
+ return self->repr();
+ }
+
+ PyObject *getDifferentValues(bool val) const throw(INTERP_KERNEL::Exception)
+ {
+ std::set<int> ret=self->getDifferentValues();
+ return convertIntArrToPyList3(ret);
+ }
+
+ void setValues(PyObject *li, int nbOfTuples, int nbOfElsPerTuple) throw(INTERP_KERNEL::Exception)
+ {
+ int *tmp=new int[nbOfTuples*nbOfElsPerTuple];
+ try
+ {
+ fillArrayWithPyListInt(li,tmp,nbOfTuples*nbOfElsPerTuple,0.);
+ }
+ catch(INTERP_KERNEL::Exception& e)
+ {
+ delete [] tmp;
+ throw e;
+ }
+ self->useArray(tmp,true,CPP_DEALLOC,nbOfTuples,nbOfElsPerTuple);
+ }
+
+ PyObject *getValues() throw(INTERP_KERNEL::Exception)
+ {
+ const int *vals=self->getPointer();
+ return convertIntArrToPyList(vals,self->getNbOfElems());
+ }
+
+ PyObject *getValuesAsTuple() throw(INTERP_KERNEL::Exception)
+ {
+ const int *vals=self->getPointer();
+ int nbOfComp=self->getNumberOfComponents();
+ int nbOfTuples=self->getNumberOfTuples();
+ return convertIntArrToPyListOfTuple(vals,nbOfComp,nbOfTuples);
+ }
+
+ static PyObject *MakePartition(PyObject *gps, int newNb) throw(INTERP_KERNEL::Exception)
+ {
+ std::vector<const DataArrayInt *> groups;
+ std::vector< std::vector<int> > fidsOfGroups;
+ convertPyObjToVecDataArrayIntCst(gps,groups);
+ ParaMEDMEM::DataArrayInt *ret0=ParaMEDMEM::DataArrayInt::MakePartition(groups,newNb,fidsOfGroups);
+ PyObject *ret = PyList_New(2);
+ PyList_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(ret0),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 ));
+ int sz=fidsOfGroups.size();
+ PyObject *ret1 = PyList_New(sz);
+ for(int i=0;i<sz;i++)
+ PyList_SetItem(ret1,i,convertIntArrToPyList2(fidsOfGroups[i]));
+ PyList_SetItem(ret,1,ret1);
+ return ret;
+ }
+
+ void transformWithIndArr(PyObject *li)
+ {
+ void *da=0;
+ int res1=SWIG_ConvertPtr(li,&da,SWIGTYPE_p_ParaMEDMEM__DataArrayInt, 0 | 0 );
+ if (!SWIG_IsOK(res1))
+ {
+ int size;
+ INTERP_KERNEL::AutoPtr<int> tmp=convertPyToNewIntArr2(li,&size);
+ self->transformWithIndArr(tmp,tmp+size);
+ }
+ else
+ {
+ DataArrayInt *da2=reinterpret_cast< DataArrayInt * >(da);
+ self->transformWithIndArr(da2->getConstPointer(),da2->getConstPointer()+da2->getNbOfElems());
+ }
+ }
+
+ void renumberInPlace(PyObject *li) throw(INTERP_KERNEL::Exception)
+ {
+ void *da=0;
+ int res1=SWIG_ConvertPtr(li,&da,SWIGTYPE_p_ParaMEDMEM__DataArrayInt, 0 | 0 );
+ if (!SWIG_IsOK(res1))
+ {
+ int size;
+ INTERP_KERNEL::AutoPtr<int> tmp=convertPyToNewIntArr2(li,&size);
+ if(size!=self->getNumberOfTuples())
+ {
+ throw INTERP_KERNEL::Exception("Invalid list length ! Must be equal to number of tuples !");
+ }
+ self->renumberInPlace(tmp);
+ }
+ else
+ {
+ DataArrayInt *da2=reinterpret_cast< DataArrayInt * >(da);
+ if(!da2)
+ throw INTERP_KERNEL::Exception("Not null DataArrayInt instance expected !");
+ da2->checkAllocated();
+ int size=self->getNbOfElems();
+ if(size!=self->getNumberOfTuples())
+ {
+ throw INTERP_KERNEL::Exception("Invalid list length ! Must be equal to number of tuples !");
+ }
+ self->renumberInPlace(da2->getConstPointer());
+ }
+ }
+
+ void renumberInPlaceR(PyObject *li) throw(INTERP_KERNEL::Exception)
+ {
+ void *da=0;
+ int res1=SWIG_ConvertPtr(li,&da,SWIGTYPE_p_ParaMEDMEM__DataArrayInt, 0 | 0 );
+ if (!SWIG_IsOK(res1))
+ {
+ int size;
+ INTERP_KERNEL::AutoPtr<int> tmp=convertPyToNewIntArr2(li,&size);
+ if(size!=self->getNumberOfTuples())
+ {
+ throw INTERP_KERNEL::Exception("Invalid list length ! Must be equal to number of tuples !");
+ }
+ self->renumberInPlaceR(tmp);
+ }
+ else
+ {
+ DataArrayInt *da2=reinterpret_cast< DataArrayInt * >(da);
+ if(!da2)
+ throw INTERP_KERNEL::Exception("Not null DataArrayInt instance expected !");
+ da2->checkAllocated();
+ int size=self->getNbOfElems();
+ if(size!=self->getNumberOfTuples())
+ {
+ throw INTERP_KERNEL::Exception("Invalid list length ! Must be equal to number of tuples !");
+ }
+ self->renumberInPlaceR(da2->getConstPointer());
+ }
+ }
+
+ DataArrayInt *renumberAndReduce(PyObject *li, int newNbOfTuple) throw(INTERP_KERNEL::Exception)
+ {
+ void *da=0;
+ int res1=SWIG_ConvertPtr(li,&da,SWIGTYPE_p_ParaMEDMEM__DataArrayInt, 0 | 0 );
+ if (!SWIG_IsOK(res1))
+ {
+ int size;
+ INTERP_KERNEL::AutoPtr<int> tmp=convertPyToNewIntArr2(li,&size);
+ if(size!=self->getNumberOfTuples())
+ {
+ throw INTERP_KERNEL::Exception("Invalid list length ! Must be equal to number of tuples !");
+ }
+ return self->renumberAndReduce(tmp,newNbOfTuple);
+ }
+ else
+ {
+ DataArrayInt *da2=reinterpret_cast< DataArrayInt * >(da);
+ if(!da2)
+ throw INTERP_KERNEL::Exception("Not null DataArrayInt instance expected !");
+ da2->checkAllocated();
+ int size=self->getNbOfElems();
+ if(size!=self->getNumberOfTuples())
+ {
+ throw INTERP_KERNEL::Exception("Invalid list length ! Must be equal to number of tuples !");
+ }
+ return self->renumberAndReduce(da2->getConstPointer(),newNbOfTuple);
+ }
+ }
+
+ DataArrayInt *renumber(PyObject *li) throw(INTERP_KERNEL::Exception)
+ {
+ void *da=0;
+ int res1=SWIG_ConvertPtr(li,&da,SWIGTYPE_p_ParaMEDMEM__DataArrayInt, 0 | 0 );
+ if (!SWIG_IsOK(res1))
+ {
+ int size;
+ INTERP_KERNEL::AutoPtr<int> tmp=convertPyToNewIntArr2(li,&size);
+ if(size!=self->getNumberOfTuples())
+ {
+ throw INTERP_KERNEL::Exception("Invalid list length ! Must be equal to number of tuples !");
+ }
+ return self->renumber(tmp);
+ }
+ else
+ {
+ DataArrayInt *da2=reinterpret_cast< DataArrayInt * >(da);
+ if(!da2)
+ throw INTERP_KERNEL::Exception("Not null DataArrayInt instance expected !");
+ da2->checkAllocated();
+ int size=self->getNbOfElems();
+ if(size!=self->getNumberOfTuples())
+ {
+ throw INTERP_KERNEL::Exception("Invalid list length ! Must be equal to number of tuples !");
+ }
+ return self->renumber(da2->getConstPointer());
+ }
+ }
+
+ DataArrayInt *renumberR(PyObject *li) throw(INTERP_KERNEL::Exception)
+ {
+ void *da=0;
+ int res1=SWIG_ConvertPtr(li,&da,SWIGTYPE_p_ParaMEDMEM__DataArrayInt, 0 | 0 );
+ if (!SWIG_IsOK(res1))
+ {
+ int size;
+ INTERP_KERNEL::AutoPtr<int> tmp=convertPyToNewIntArr2(li,&size);
+ if(size!=self->getNumberOfTuples())
+ {
+ throw INTERP_KERNEL::Exception("Invalid list length ! Must be equal to number of tuples !");
+ }
+ return self->renumberR(tmp);
+ }
+ else
+ {
+ DataArrayInt *da2=reinterpret_cast< DataArrayInt * >(da);
+ if(!da2)
+ throw INTERP_KERNEL::Exception("Not null DataArrayInt instance expected !");
+ da2->checkAllocated();
+ int size=self->getNbOfElems();
+ if(size!=self->getNumberOfTuples())
+ {
+ throw INTERP_KERNEL::Exception("Invalid list length ! Must be equal to number of tuples !");
+ }
+ return self->renumberR(da2->getConstPointer());
+ }
+ }
+
+ DataArrayInt *selectByTupleId(PyObject *li) const throw(INTERP_KERNEL::Exception)
+ {
+ void *da=0;
+ int res1=SWIG_ConvertPtr(li,&da,SWIGTYPE_p_ParaMEDMEM__DataArrayInt, 0 | 0 );
+ if (!SWIG_IsOK(res1))
+ {
+ int size;
+ INTERP_KERNEL::AutoPtr<int> tmp=convertPyToNewIntArr2(li,&size);
+ return self->selectByTupleId(tmp,tmp+size);
+ }
+ else
+ {
+ DataArrayInt *da2=reinterpret_cast< DataArrayInt * >(da);
+ if(!da2)
+ throw INTERP_KERNEL::Exception("Not null DataArrayInt instance expected !");
+ da2->checkAllocated();
+ return self->selectByTupleId(da2->getConstPointer(),da2->getConstPointer()+da2->getNbOfElems());
+ }
+ }
+
+ DataArrayInt *selectByTupleIdSafe(PyObject *li) const throw(INTERP_KERNEL::Exception)
+ {
+ void *da=0;
+ int res1=SWIG_ConvertPtr(li,&da,SWIGTYPE_p_ParaMEDMEM__DataArrayInt, 0 | 0 );
+ if (!SWIG_IsOK(res1))
+ {
+ int size;
+ INTERP_KERNEL::AutoPtr<int> tmp=convertPyToNewIntArr2(li,&size);
+ return self->selectByTupleIdSafe(tmp,tmp+size);
+ }
+ else
+ {
+ DataArrayInt *da2=reinterpret_cast< DataArrayInt * >(da);
+ if(!da2)
+ throw INTERP_KERNEL::Exception("Not null DataArrayInt instance expected !");
+ da2->checkAllocated();
+ return self->selectByTupleIdSafe(da2->getConstPointer(),da2->getConstPointer()+da2->getNbOfElems());
+ }
+ }
+
+ DataArrayInt *keepSelectedComponents(PyObject *li) const throw(INTERP_KERNEL::Exception)
+ {
+ std::vector<int> tmp;
+ convertPyToNewIntArr3(li,tmp);
+ return self->keepSelectedComponents(tmp);
+ }
+
+ void setSelectedComponents(const DataArrayInt *a, PyObject *li) throw(INTERP_KERNEL::Exception)
+ {
+ std::vector<int> tmp;
+ convertPyToNewIntArr3(li,tmp);
+ self->setSelectedComponents(a,tmp);
+ }
+
+ PyObject *getTuple(int tupleId) throw(INTERP_KERNEL::Exception)
+ {
+ int sz=self->getNumberOfComponents();
+ INTERP_KERNEL::AutoPtr<int> tmp=new int[sz];
+ self->getTuple(tupleId,tmp);
+ return convertIntArrToPyList(tmp,sz);
+ }
+
+ PyObject *changeSurjectiveFormat(int targetNb) const throw(INTERP_KERNEL::Exception)
+ {
+ DataArrayInt *arr=0;
+ DataArrayInt *arrI=0;
+ self->changeSurjectiveFormat(targetNb,arr,arrI);
+ PyObject *res = PyList_New(2);
+ PyList_SetItem(res,0,SWIG_NewPointerObj((void*)arr,SWIGTYPE_p_ParaMEDMEM__DataArrayInt,SWIG_POINTER_OWN | 0));
+ PyList_SetItem(res,1,SWIG_NewPointerObj((void*)arrI,SWIGTYPE_p_ParaMEDMEM__DataArrayInt,SWIG_POINTER_OWN | 0));
+ return res;
+ }
+
+ static DataArrayInt *Meld(PyObject *li) throw(INTERP_KERNEL::Exception)
+ {
+ std::vector<const DataArrayInt *> tmp;
+ convertPyObjToVecDataArrayIntCst(li,tmp);
+ return DataArrayInt::Meld(tmp);
+ }
+
+ static DataArrayInt *Aggregate(PyObject *li) throw(INTERP_KERNEL::Exception)
+ {
+ std::vector<const DataArrayInt *> tmp;
+ convertPyObjToVecDataArrayIntCst(li,tmp);
+ return DataArrayInt::Aggregate(tmp);
+ }
+
+ static DataArrayInt *BuildUnion(PyObject *li) throw(INTERP_KERNEL::Exception)
+ {
+ std::vector<const DataArrayInt *> tmp;
+ convertPyObjToVecDataArrayIntCst(li,tmp);
+ return DataArrayInt::BuildUnion(tmp);
+ }
+
+ static DataArrayInt *BuildIntersection(PyObject *li) throw(INTERP_KERNEL::Exception)
+ {
+ std::vector<const DataArrayInt *> tmp;
+ convertPyObjToVecDataArrayIntCst(li,tmp);
+ return DataArrayInt::BuildIntersection(tmp);
+ }
+
+ PyObject *getMaxValue() const throw(INTERP_KERNEL::Exception)
+ {
+ int tmp;
+ int r1=self->getMaxValue(tmp);
+ PyObject *ret=PyTuple_New(2);
+ PyTuple_SetItem(ret,0,PyInt_FromLong(r1));
+ PyTuple_SetItem(ret,1,PyInt_FromLong(tmp));
+ return ret;
+ }
+
+ PyObject *getMinValue() const throw(INTERP_KERNEL::Exception)
+ {
+ int tmp;
+ int r1=self->getMinValue(tmp);
+ PyObject *ret=PyTuple_New(2);
+ PyTuple_SetItem(ret,0,PyInt_FromLong(r1));
+ PyTuple_SetItem(ret,1,PyInt_FromLong(tmp));
+ return ret;
+ }
+
+ DataArrayInt *__getitem__(PyObject *obj) throw(INTERP_KERNEL::Exception)
+ {
+ const char msg[]="Unexpected situation in __getitem__ !";
+ self->checkAllocated();
+ int nbOfTuples=self->getNumberOfTuples();
+ int nbOfComponents=self->getNumberOfComponents();
+ int it1,ic1;
+ std::vector<int> vt1,vc1;
+ std::pair<int, std::pair<int,int> > pt1,pc1;
+ DataArrayInt *dt1=0,*dc1=0;
+ int sw;
+ convertObjToPossibleCpp3(obj,nbOfTuples,nbOfComponents,sw,it1,ic1,vt1,vc1,pt1,pc1,dt1,dc1);
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ret;
+ switch(sw)
+ {
+ case 1:
+ return self->selectByTupleIdSafe(&it1,&it1+1);
+ case 2:
+ return self->selectByTupleIdSafe(&vt1[0],&vt1[0]+vt1.size());
+ case 3:
+ return self->selectByTupleId2(pt1.first,pt1.second.first,pt1.second.second);
+ case 4:
+ return self->selectByTupleIdSafe(dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems());
+ case 5:
+ {
+ ret=self->selectByTupleIdSafe(&it1,&it1+1);
+ std::vector<int> v2(1,ic1);
+ return ret->keepSelectedComponents(v2);
+ }
+ case 6:
+ {
+ ret=self->selectByTupleIdSafe(&vt1[0],&vt1[0]+vt1.size());
+ std::vector<int> v2(1,ic1);
+ return ret->keepSelectedComponents(v2);
+ }
+ case 7:
+ {
+ ret=self->selectByTupleId2(pt1.first,pt1.second.first,pt1.second.second);
+ std::vector<int> v2(1,ic1);
+ return ret->keepSelectedComponents(v2);
+ }
+ case 8:
+ {
+ ret=self->selectByTupleIdSafe(dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems());
+ std::vector<int> v2(1,ic1);
+ return ret->keepSelectedComponents(v2);
+ }
+ case 9:
+ {
+ ret=self->selectByTupleIdSafe(&it1,&it1+1);
+ return ret->keepSelectedComponents(vc1);
+ }
+ case 10:
+ {
+ ret=self->selectByTupleIdSafe(&vt1[0],&vt1[0]+vt1.size());
+ return ret->keepSelectedComponents(vc1);
+ }
+ case 11:
+ {
+ ret=self->selectByTupleId2(pt1.first,pt1.second.first,pt1.second.second);
+ return ret->keepSelectedComponents(vc1);
+ }
+ case 12:
+ {
+ ret=self->selectByTupleIdSafe(dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems());
+ return ret->keepSelectedComponents(vc1);
+ }
+ case 13:
+ {
+ ret=self->selectByTupleIdSafe(&it1,&it1+1);
+ int nbOfComp=(pc1.second.first-1-pc1.first)/pc1.second.second+1;
+ std::vector<int> v2(nbOfComp);
+ for(int i=0;i<nbOfComp;i++)
+ v2[i]=pc1.first+i*pc1.second.second;
+ return ret->keepSelectedComponents(v2);
+ }
+ case 14:
+ {
+ ret=self->selectByTupleIdSafe(&vt1[0],&vt1[0]+vt1.size());
+ int nbOfComp=(pc1.second.first-1-pc1.first)/pc1.second.second+1;
+ std::vector<int> v2(nbOfComp);
+ for(int i=0;i<nbOfComp;i++)
+ v2[i]=pc1.first+i*pc1.second.second;
+ return ret->keepSelectedComponents(v2);
+ }
+ case 15:
+ {
+ ret=self->selectByTupleId2(pt1.first,pt1.second.first,pt1.second.second);
+ int nbOfComp=(pc1.second.first-1-pc1.first)/pc1.second.second+1;
+ std::vector<int> v2(nbOfComp);
+ for(int i=0;i<nbOfComp;i++)
+ v2[i]=pc1.first+i*pc1.second.second;
+ return ret->keepSelectedComponents(v2);
+ }
+ case 16:
+ {
+ ret=self->selectByTupleIdSafe(dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems());
+ int nbOfComp=(pc1.second.first-1-pc1.first)/pc1.second.second+1;
+ std::vector<int> v2(nbOfComp);
+ for(int i=0;i<nbOfComp;i++)
+ v2[i]=pc1.first+i*pc1.second.second;
+ return ret->keepSelectedComponents(v2);
+ }
+ default:
+ throw INTERP_KERNEL::Exception(msg);
+ }
+ }
+
+ DataArrayInt *__setitem__(PyObject *obj, PyObject *value) throw(INTERP_KERNEL::Exception)
+ {
+ self->checkAllocated();
+ const char msg[]="Unexpected situation in __setitem__ !";
+ int nbOfTuples=self->getNumberOfTuples();
+ int nbOfComponents=self->getNumberOfComponents();
+ int sw1,sw2;
+ int i1;
+ std::vector<int> v1;
+ DataArrayInt *d1=0;
+ convertObjToPossibleCpp1(value,sw1,i1,v1,d1);
+ int it1,ic1;
+ std::vector<int> vt1,vc1;
+ std::pair<int, std::pair<int,int> > pt1,pc1;
+ DataArrayInt *dt1=0,*dc1=0;
+ convertObjToPossibleCpp3(obj,nbOfTuples,nbOfComponents,sw2,it1,ic1,vt1,vc1,pt1,pc1,dt1,dc1);
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> tmp;
+ switch(sw2)
+ {
+ case 1:
+ {
+ switch(sw1)
+ {
+ case 1:
+ self->setPartOfValuesSimple1(i1,it1,it1+1,1,0,nbOfComponents,1);
+ return self;
+ case 2:
+ tmp=DataArrayInt::New();
+ tmp->useArray(&v1[0],false,CPP_DEALLOC,v1.size(),1);
+ self->setPartOfValues1(tmp,it1,it1+1,1,0,nbOfComponents,1,false);
+ return self;
+ case 3:
+ self->setPartOfValues1(d1,it1,it1+1,1,0,nbOfComponents,1);
+ return self;
+ default:
+ throw INTERP_KERNEL::Exception(msg);
+ }
+ break;
+ }
+ case 2:
+ {
+ switch(sw1)
+ {
+ case 1:
+ self->setPartOfValuesSimple3(i1,&vt1[0],&vt1[0]+vt1.size(),0,nbOfComponents,1);
+ return self;
+ case 2:
+ tmp=DataArrayInt::New();
+ tmp->useArray(&v1[0],false,CPP_DEALLOC,v1.size(),1);
+ self->setPartOfValues3(tmp,&vt1[0],&vt1[0]+vt1.size(),0,nbOfComponents,1,false);
+ return self;
+ case 3:
+ self->setPartOfValues3(d1,&vt1[0],&vt1[0]+vt1.size(),0,nbOfComponents,1);
+ return self;
+ default:
+ throw INTERP_KERNEL::Exception(msg);
+ }
+ break;
+ }
+ case 3:
+ {
+ switch(sw1)
+ {
+ case 1:
+ self->setPartOfValuesSimple1(i1,pt1.first,pt1.second.first,pt1.second.second,0,nbOfComponents,1);
+ return self;
+ case 2:
+ tmp=DataArrayInt::New();
+ tmp->useArray(&v1[0],false,CPP_DEALLOC,v1.size(),1);
+ self->setPartOfValues1(tmp,pt1.first,pt1.second.first,pt1.second.second,0,nbOfComponents,1,false);
+ return self;
+ case 3:
+ self->setPartOfValues1(d1,pt1.first,pt1.second.first,pt1.second.second,0,nbOfComponents,1);
+ return self;
+ default:
+ throw INTERP_KERNEL::Exception(msg);
+ }
+ break;
+ }
+ case 4:
+ {
+ switch(sw1)
+ {
+ case 1:
+ self->setPartOfValuesSimple3(i1,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),0,nbOfComponents,1);
+ return self;
+ case 2:
+ tmp=DataArrayInt::New();
+ tmp->useArray(&v1[0],false,CPP_DEALLOC,v1.size(),1);
+ self->setPartOfValues3(tmp,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),0,nbOfComponents,1,false);
+ return self;
+ case 3:
+ self->setPartOfValues3(d1,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),0,nbOfComponents,1);
+ return self;
+ default:
+ throw INTERP_KERNEL::Exception(msg);
+ }
+ break;
+ }
+ case 5:
+ {
+ switch(sw1)
+ {
+ case 1:
+ self->setPartOfValuesSimple1(i1,it1,it1+1,1,ic1,ic1+1,1);
+ return self;
+ case 2:
+ tmp=DataArrayInt::New();
+ tmp->useArray(&v1[0],false,CPP_DEALLOC,v1.size(),1);
+ self->setPartOfValues1(tmp,it1,it1+1,1,ic1,ic1+1,1,false);
+ return self;
+ case 3:
+ self->setPartOfValues1(d1,it1,it1+1,1,ic1,ic1+1,1);
+ return self;
+ default:
+ throw INTERP_KERNEL::Exception(msg);
+ }
+ break;
+ }
+ case 6:
+ {
+ switch(sw1)
+ {
+ case 1:
+ self->setPartOfValuesSimple3(i1,&vt1[0],&vt1[0]+vt1.size(),ic1,ic1+1,1);
+ return self;
+ case 2:
+ tmp=DataArrayInt::New();
+ tmp->useArray(&v1[0],false,CPP_DEALLOC,v1.size(),1);
+ self->setPartOfValues3(tmp,&vt1[0],&vt1[0]+vt1.size(),ic1,ic1+1,1,false);
+ return self;
+ case 3:
+ self->setPartOfValues3(d1,&vt1[0],&vt1[0]+vt1.size(),ic1,ic1+1,1);
+ return self;
+ default:
+ throw INTERP_KERNEL::Exception(msg);
+ }
+ break;
+ }
+ case 7:
+ {
+ switch(sw1)
+ {
+ case 1:
+ self->setPartOfValuesSimple1(i1,pt1.first,pt1.second.first,pt1.second.second,ic1,ic1+1,1);
+ return self;
+ case 2:
+ tmp=DataArrayInt::New();
+ tmp->useArray(&v1[0],false,CPP_DEALLOC,v1.size(),1);
+ self->setPartOfValues1(tmp,pt1.first,pt1.second.first,pt1.second.second,ic1,ic1+1,1,false);
+ return self;
+ case 3:
+ self->setPartOfValues1(d1,pt1.first,pt1.second.first,pt1.second.second,ic1,ic1+1,1);
+ return self;
+ default:
+ throw INTERP_KERNEL::Exception(msg);
+ }
+ break;
+ }
+ case 8:
+ {
+ switch(sw1)
+ {
+ case 1:
+ self->setPartOfValuesSimple3(i1,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),ic1,ic1+1,1);
+ return self;
+ case 2:
+ tmp=DataArrayInt::New();
+ tmp->useArray(&v1[0],false,CPP_DEALLOC,v1.size(),1);
+ self->setPartOfValues3(tmp,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),ic1,ic1+1,1,false);
+ return self;
+ case 3:
+ self->setPartOfValues3(d1,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),ic1,ic1+1,1);
+ return self;
+ default:
+ throw INTERP_KERNEL::Exception(msg);
+ }
+ break;
+ }
+ case 9:
+ {
+ switch(sw1)
+ {
+ case 1:
+ self->setPartOfValuesSimple2(i1,&it1,&it1+1,&vc1[0],&vc1[0]+vc1.size());
+ return self;
+ case 2:
+ tmp=DataArrayInt::New();
+ tmp->useArray(&v1[0],false,CPP_DEALLOC,v1.size(),1);
+ self->setPartOfValues2(tmp,&it1,&it1+1,&vc1[0],&vc1[0]+vc1.size(),false);
+ return self;
+ case 3:
+ self->setPartOfValues2(d1,&it1,&it1+1,&vc1[0],&vc1[0]+vc1.size());
+ return self;
+ default:
+ throw INTERP_KERNEL::Exception(msg);
+ }
+ break;
+ }
+ case 10:
+ {
+ switch(sw1)
+ {
+ case 1:
+ self->setPartOfValuesSimple2(i1,&vt1[0],&vt1[0]+vt1.size(),&vc1[0],&vc1[0]+vc1.size());
+ return self;
+ case 2:
+ tmp=DataArrayInt::New();
+ tmp->useArray(&v1[0],false,CPP_DEALLOC,v1.size(),1);
+ self->setPartOfValues2(tmp,&vt1[0],&vt1[0]+vt1.size(),&vc1[0],&vc1[0]+vc1.size(),false);
+ return self;
+ case 3:
+ self->setPartOfValues2(d1,&vt1[0],&vt1[0]+vt1.size(),&vc1[0],&vc1[0]+vc1.size());
+ return self;
+ default:
+ throw INTERP_KERNEL::Exception(msg);
+ }
+ break;
+ }
+ case 11:
+ {
+ int bb=pt1.first;
+ int ee=pt1.second.first;
+ int ss=pt1.second.second;
+ if(ee<bb || ss<=0)
+ throw INTERP_KERNEL::Exception("Invalid slice in tuple selection");
+ int nbOfE=(ee-bb)/ss;
+ std::vector<int> nv(nbOfE);
+ for(int jj=0;jj<nbOfE;jj++)
+ nv[jj]=bb+jj*ss;
+ switch(sw1)
+ {
+ case 1:
+ self->setPartOfValuesSimple2(i1,&nv[0],&nv[0]+nv.size(),&vc1[0],&vc1[0]+vc1.size());
+ return self;
+ case 2:
+ tmp=DataArrayInt::New();
+ tmp->useArray(&v1[0],false,CPP_DEALLOC,v1.size(),1);
+ self->setPartOfValues2(tmp,&nv[0],&nv[0]+nv.size(),&vc1[0],&vc1[0]+vc1.size(),false);
+ return self;
+ case 3:
+ self->setPartOfValues2(d1,&nv[0],&nv[0]+nv.size(),&vc1[0],&vc1[0]+vc1.size());
+ return self;
+ default:
+ throw INTERP_KERNEL::Exception(msg);
+ }
+ break;
+ }
+ case 12:
+ {
+ switch(sw1)
+ {
+ case 1:
+ self->setPartOfValuesSimple2(i1,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),&vc1[0],&vc1[0]+vc1.size());
+ return self;
+ case 2:
+ tmp=DataArrayInt::New();
+ tmp->useArray(&v1[0],false,CPP_DEALLOC,v1.size(),1);
+ self->setPartOfValues2(tmp,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),&vc1[0],&vc1[0]+vc1.size(),false);
+ return self;
+ case 3:
+ self->setPartOfValues2(d1,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),&vc1[0],&vc1[0]+vc1.size());
+ return self;
+ default:
+ throw INTERP_KERNEL::Exception(msg);
+ }
+ break;
+ }
+ case 13:
+ {
+ switch(sw1)
+ {
+ case 1:
+ self->setPartOfValuesSimple1(i1,it1,it1+1,1,pc1.first,pc1.second.first,pc1.second.second);
+ return self;
+ case 2:
+ tmp=DataArrayInt::New();
+ tmp->useArray(&v1[0],false,CPP_DEALLOC,v1.size(),1);
+ self->setPartOfValues1(tmp,it1,it1+1,1,pc1.first,pc1.second.first,pc1.second.second,false);
+ return self;
+ case 3:
+ self->setPartOfValues1(d1,it1,it1+1,1,pc1.first,pc1.second.first,pc1.second.second);
+ return self;
+ default:
+ throw INTERP_KERNEL::Exception(msg);
+ }
+ break;
+ }
+ case 14:
+ {
+ switch(sw1)
+ {
+ case 1:
+ self->setPartOfValuesSimple3(i1,&vt1[0],&vt1[0]+vt1.size(),pc1.first,pc1.second.first,pc1.second.second);
+ return self;
+ case 2:
+ tmp=DataArrayInt::New();
+ tmp->useArray(&v1[0],false,CPP_DEALLOC,v1.size(),1);
+ self->setPartOfValues3(tmp,&vt1[0],&vt1[0]+vt1.size(),pc1.first,pc1.second.first,pc1.second.second,false);
+ return self;
+ case 3:
+ self->setPartOfValues3(d1,&vt1[0],&vt1[0]+vt1.size(),pc1.first,pc1.second.first,pc1.second.second);
+ return self;
+ default:
+ throw INTERP_KERNEL::Exception(msg);
+ }
+ break;
+ }
+ case 15:
+ {
+ switch(sw1)
+ {
+ case 1:
+ self->setPartOfValuesSimple1(i1,pt1.first,pt1.second.first,pt1.second.second,pc1.first,pc1.second.first,pc1.second.second);
+ return self;
+ case 2:
+ tmp=DataArrayInt::New();
+ tmp->useArray(&v1[0],false,CPP_DEALLOC,v1.size(),1);
+ self->setPartOfValues1(tmp,pt1.first,pt1.second.first,pt1.second.second,pc1.first,pc1.second.first,pc1.second.second,false);
+ return self;
+ case 3:
+ self->setPartOfValues1(d1,pt1.first,pt1.second.first,pt1.second.second,pc1.first,pc1.second.first,pc1.second.second);
+ return self;
+ default:
+ throw INTERP_KERNEL::Exception(msg);
+ }
+ break;
+ }
+ case 16:
+ {
+ switch(sw1)
+ {
+ case 1:
+ self->setPartOfValuesSimple3(i1,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),pc1.first,pc1.second.first,pc1.second.second);
+ return self;
+ case 2:
+ tmp=DataArrayInt::New();
+ tmp->useArray(&v1[0],false,CPP_DEALLOC,v1.size(),1);
+ self->setPartOfValues3(tmp,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),pc1.first,pc1.second.first,pc1.second.second,false);
+ return self;
+ case 3:
+ self->setPartOfValues3(d1,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),pc1.first,pc1.second.first,pc1.second.second);
+ return self;
+ default:
+ throw INTERP_KERNEL::Exception(msg);
+ }
+ break;
+ }
+ default:
+ throw INTERP_KERNEL::Exception(msg);
+ }
+ return self;
+ }
+
+ DataArrayInt *__add__(PyObject *obj) throw(INTERP_KERNEL::Exception)
+ {
+ const char msg[]="Unexpected situation in __add__ !";
+ int val;
+ DataArrayInt *a;
+ std::vector<int> aa;
+ int sw;
+ convertObjToPossibleCpp1(obj,sw,val,aa,a);
+ switch(sw)
+ {
+ case 1:
+ {
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ret=self->deepCpy();
+ ret->applyLin(1,val);
+ ret->incrRef();
+ return ret;
+ }
+ case 3:
+ {
+ return DataArrayInt::Add(self,a);
+ }
+ default:
+ throw INTERP_KERNEL::Exception(msg);
+ }
+ }
+
+ DataArrayInt *__radd__(PyObject *obj) throw(INTERP_KERNEL::Exception)
+ {
+ const char msg[]="Unexpected situation in __radd__ !";
+ int val;
+ DataArrayInt *a;
+ std::vector<int> aa;
+ int sw;
+ convertObjToPossibleCpp1(obj,sw,val,aa,a);
+ switch(sw)
+ {
+ case 1:
+ {
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ret=self->deepCpy();
+ ret->applyLin(1,val);
+ ret->incrRef();
+ return ret;
+ }
+ default:
+ throw INTERP_KERNEL::Exception(msg);
+ }
+ }
+
+ DataArrayInt *operator+=(PyObject *obj) throw(INTERP_KERNEL::Exception)
+ {
+ const char msg[]="Unexpected situation in __iadd__ !";
+ int val;
+ DataArrayInt *a;
+ std::vector<int> aa;
+ int sw;
+ convertObjToPossibleCpp1(obj,sw,val,aa,a);
+ switch(sw)
+ {
+ case 1:
+ {
+ self->applyLin(1,val);
+ return self;
+ }
+ case 3:
+ {
+ self->addEqual(a);
+ return self;
+ }
+ default:
+ throw INTERP_KERNEL::Exception(msg);
+ }
+ }
+
+ DataArrayInt *__sub__(PyObject *obj) throw(INTERP_KERNEL::Exception)
+ {
+ const char msg[]="Unexpected situation in __sub__ !";
+ int val;
+ DataArrayInt *a;
+ std::vector<int> aa;
+ int sw;
+ convertObjToPossibleCpp1(obj,sw,val,aa,a);
+ switch(sw)
+ {
+ case 1:
+ {
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ret=self->deepCpy();
+ ret->applyLin(1,-val);
+ ret->incrRef();
+ return ret;
+ }
+ case 3:
+ {
+ return DataArrayInt::Substract(self,a);
+ }
+ default:
+ throw INTERP_KERNEL::Exception(msg);
+ }
+ }
+
+ DataArrayInt *__rsub__(PyObject *obj) throw(INTERP_KERNEL::Exception)
+ {
+ const char msg[]="Unexpected situation in __rsub__ !";
+ int val;
+ DataArrayInt *a;
+ std::vector<int> aa;
+ int sw;
+ convertObjToPossibleCpp1(obj,sw,val,aa,a);
+ switch(sw)
+ {
+ case 1:
+ {
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ret=self->deepCpy();
+ ret->applyLin(-1,val);
+ ret->incrRef();
+ return ret;
+ }
+ default:
+ throw INTERP_KERNEL::Exception(msg);
+ }
+ }
+
+ DataArrayInt *operator-=(PyObject *obj) throw(INTERP_KERNEL::Exception)
+ {
+ const char msg[]="Unexpected situation in __isub__ !";
+ int val;
+ DataArrayInt *a;
+ std::vector<int> aa;
+ int sw;
+ convertObjToPossibleCpp1(obj,sw,val,aa,a);
+ switch(sw)
+ {
+ case 1:
+ {
+ self->applyLin(1.,-val);
+ return self;
+ }
+ case 3:
+ {
+ self->substractEqual(a);
+ return self;
+ }
+ default:
+ throw INTERP_KERNEL::Exception(msg);
+ }
+ }
+
+ DataArrayInt *__mul__(PyObject *obj) throw(INTERP_KERNEL::Exception)
+ {
+ const char msg[]="Unexpected situation in __mul__ !";
+ int val;
+ DataArrayInt *a;
+ std::vector<int> aa;
+ int sw;
+ convertObjToPossibleCpp1(obj,sw,val,aa,a);
+ switch(sw)
+ {
+ case 1:
+ {
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ret=self->deepCpy();
+ ret->applyLin(val,0);
+ ret->incrRef();
+ return ret;
+ }
+ case 3:
+ {
+ return DataArrayInt::Multiply(self,a);
+ }
+ default:
+ throw INTERP_KERNEL::Exception(msg);
+ }
+ }
+
+ DataArrayInt *__rmul__(PyObject *obj) throw(INTERP_KERNEL::Exception)
+ {
+ const char msg[]="Unexpected situation in __rmul__ !";
+ int val;
+ DataArrayInt *a;
+ std::vector<int> aa;
+ int sw;
+ convertObjToPossibleCpp1(obj,sw,val,aa,a);
+ switch(sw)
+ {
+ case 1:
+ {
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ret=self->deepCpy();
+ ret->applyLin(val,0);
+ ret->incrRef();
+ return ret;
+ }
+ default:
+ throw INTERP_KERNEL::Exception(msg);
+ }
+ }
+
+ DataArrayInt *operator*=(PyObject *obj) throw(INTERP_KERNEL::Exception)
+ {
+ const char msg[]="Unexpected situation in __imul__ !";
+ int val;
+ DataArrayInt *a;
+ std::vector<int> aa;
+ int sw;
+ convertObjToPossibleCpp1(obj,sw,val,aa,a);
+ switch(sw)
+ {
+ case 1:
+ {
+ self->applyLin(val,0);
+ return self;
+ }
+ case 3:
+ {
+ self->multiplyEqual(a);
+ return self;
+ }
+ default:
+ throw INTERP_KERNEL::Exception(msg);
+ }
+ }
+
+ DataArrayInt *__div__(PyObject *obj) throw(INTERP_KERNEL::Exception)
+ {
+ const char msg[]="Unexpected situation in __div__ !";
+ int val;
+ DataArrayInt *a;
+ std::vector<int> aa;
+ int sw;
+ convertObjToPossibleCpp1(obj,sw,val,aa,a);
+ switch(sw)
+ {
+ case 1:
+ {
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ret=self->deepCpy();
+ ret->applyDivideBy(val);
+ ret->incrRef();
+ return ret;
+ }
+ case 3:
+ {
+ return DataArrayInt::Divide(self,a);
+ }
+ default:
+ throw INTERP_KERNEL::Exception(msg);
+ }
+ }
+
+ DataArrayInt *__rdiv__(PyObject *obj) throw(INTERP_KERNEL::Exception)
+ {
+ const char msg[]="Unexpected situation in __rdiv__ !";
+ int val;
+ DataArrayInt *a;
+ std::vector<int> aa;
+ int sw;
+ convertObjToPossibleCpp1(obj,sw,val,aa,a);
+ switch(sw)
+ {
+ case 1:
+ {
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ret=self->deepCpy();
+ ret->applyInv(val);
+ ret->incrRef();
+ return ret;
+ }
+ default:
+ throw INTERP_KERNEL::Exception(msg);
+ }
+ }
+
+ DataArrayInt *operator/=(PyObject *obj) throw(INTERP_KERNEL::Exception)
+ {
+ const char msg[]="Unexpected situation in __imul__ !";
+ int val;
+ DataArrayInt *a;
+ std::vector<int> aa;
+ int sw;
+ convertObjToPossibleCpp1(obj,sw,val,aa,a);
+ switch(sw)
+ {
+ case 1:
+ {
+ self->applyDivideBy(val);
+ return self;
+ }
+ case 3:
+ {
+ self->divideEqual(a);
+ return self;
+ }
+ default:
+ throw INTERP_KERNEL::Exception(msg);
+ }
+ }
+
+ DataArrayInt *__mod__(PyObject *obj) throw(INTERP_KERNEL::Exception)
+ {
+ const char msg[]="Unexpected situation in __mod__ !";
+ int val;
+ DataArrayInt *a;
+ std::vector<int> aa;
+ int sw;
+ convertObjToPossibleCpp1(obj,sw,val,aa,a);
+ switch(sw)
+ {
+ case 1:
+ {
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ret=self->deepCpy();
+ ret->applyModulus(val);
+ ret->incrRef();
+ return ret;
+ }
+ case 3:
+ {
+ return DataArrayInt::Modulus(self,a);
+ }
+ default:
+ throw INTERP_KERNEL::Exception(msg);
+ }
+ }
+
+ DataArrayInt *__rmod__(PyObject *obj) throw(INTERP_KERNEL::Exception)
+ {
+ const char msg[]="Unexpected situation in __rmod__ !";
+ int val;
+ DataArrayInt *a;
+ std::vector<int> aa;
+ int sw;
+ convertObjToPossibleCpp1(obj,sw,val,aa,a);
+ switch(sw)
+ {
+ case 1:
+ {
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ret=self->deepCpy();
+ ret->applyRModulus(val);
+ ret->incrRef();
+ return ret;
+ }
+ case 3:
+ {
+ return DataArrayInt::Modulus(self,a);
+ }
+ default:
+ throw INTERP_KERNEL::Exception(msg);
+ }
+ }
+
+ DataArrayInt *operator%=(PyObject *obj) throw(INTERP_KERNEL::Exception)
+ {
+ const char msg[]="Unexpected situation in __imod__ !";
+ int val;
+ DataArrayInt *a;
+ std::vector<int> aa;
+ int sw;
+ convertObjToPossibleCpp1(obj,sw,val,aa,a);
+ switch(sw)
+ {
+ case 1:
+ {
+ self->applyModulus(val);
+ return self;
+ }
+ case 3:
+ {
+ self->modulusEqual(a);
+ return self;
+ }
+ default:
+ throw INTERP_KERNEL::Exception(msg);
+ }
+ }
+ };
+
+namespace ParaMEDMEM
+{
+ class MEDCouplingField : public ParaMEDMEM::RefCountObject, public ParaMEDMEM::TimeLabel
+ {
+ public:
+ virtual void checkCoherency() const throw(INTERP_KERNEL::Exception);
+ virtual bool areCompatibleForMerge(const MEDCouplingField *other) const throw(INTERP_KERNEL::Exception);
+ virtual bool isEqual(const MEDCouplingField *other, double meshPrec, double valsPrec) const throw(INTERP_KERNEL::Exception);
+ virtual bool isEqualWithoutConsideringStr(const MEDCouplingField *other, double meshPrec, double valsPrec) const throw(INTERP_KERNEL::Exception);
+ void setMesh(const ParaMEDMEM::MEDCouplingMesh *mesh) throw(INTERP_KERNEL::Exception);
+ void setName(const char *name) throw(INTERP_KERNEL::Exception);
+ const char *getDescription() const throw(INTERP_KERNEL::Exception);
+ void setDescription(const char *desc) throw(INTERP_KERNEL::Exception);
+ const char *getName() const throw(INTERP_KERNEL::Exception);
+ TypeOfField getTypeOfField() const throw(INTERP_KERNEL::Exception);
+ NatureOfField getNature() const throw(INTERP_KERNEL::Exception);
+ virtual void setNature(NatureOfField nat) throw(INTERP_KERNEL::Exception);
+ DataArrayDouble *getLocalizationOfDiscr() const throw(INTERP_KERNEL::Exception);
+ MEDCouplingFieldDouble *buildMeasureField(bool isAbs) const throw(INTERP_KERNEL::Exception);
+ MEDCouplingFieldDiscretization *getDiscretization() const throw(INTERP_KERNEL::Exception);
+ int getNumberOfTuplesExpected() const throw(INTERP_KERNEL::Exception);
+ void setGaussLocalizationOnType(INTERP_KERNEL::NormalizedCellType type, const std::vector<double>& refCoo,
+ const std::vector<double>& gsCoo, const std::vector<double>& wg) throw(INTERP_KERNEL::Exception);
+ void clearGaussLocalizations() throw(INTERP_KERNEL::Exception);
+ MEDCouplingGaussLocalization& getGaussLocalization(int locId) throw(INTERP_KERNEL::Exception);
+ int getNbOfGaussLocalization() const throw(INTERP_KERNEL::Exception);
+ int getGaussLocalizationIdOfOneCell(int cellId) const throw(INTERP_KERNEL::Exception);
+ const MEDCouplingGaussLocalization& getGaussLocalization(int locId) const throw(INTERP_KERNEL::Exception);
+ %extend {
+ PyObject *getMesh() const throw(INTERP_KERNEL::Exception)
+ {
+ MEDCouplingMesh *ret1=(MEDCouplingMesh *)self->getMesh();
+ if(ret1)
+ ret1->incrRef();
+ return convertMesh(ret1, SWIG_POINTER_OWN | 0 );
+ }
+
+ PyObject *buildSubMeshData(PyObject *li) const throw(INTERP_KERNEL::Exception)
+ {
+ int size;
+ INTERP_KERNEL::AutoPtr<int> tmp=convertPyToNewIntArr2(li,&size);
+ DataArrayInt *ret1;
+ MEDCouplingMesh *ret0=self->buildSubMeshData(tmp,tmp+size,ret1);
+ PyObject *res = PyList_New(2);
+ PyList_SetItem(res,0,convertMesh(ret0, SWIG_POINTER_OWN | 0 ));
+ PyList_SetItem(res,1,SWIG_NewPointerObj((void*)ret1,SWIGTYPE_p_ParaMEDMEM__DataArrayInt,SWIG_POINTER_OWN | 0));
+ return res;
+ }
+ void setGaussLocalizationOnCells(PyObject *li, const std::vector<double>& refCoo,
+ const std::vector<double>& gsCoo, const std::vector<double>& wg) throw(INTERP_KERNEL::Exception)
+ {
+ int size;
+ INTERP_KERNEL::AutoPtr<int> tmp=convertPyToNewIntArr2(li,&size);
+ self->setGaussLocalizationOnCells(tmp,tmp+size,refCoo,gsCoo,wg);
+ }
+ PyObject *getCellIdsHavingGaussLocalization(int locId) const throw(INTERP_KERNEL::Exception)
+ {
+ std::vector<int> tmp;
+ self->getCellIdsHavingGaussLocalization(locId,tmp);
+ return convertIntArrToPyList2(tmp);
+ }
+ }
+ };
+
+ class MEDCouplingFieldDouble : public ParaMEDMEM::MEDCouplingField
+ {
+ public:
+ static MEDCouplingFieldDouble *New(TypeOfField type, TypeOfTimeDiscretization td=NO_TIME);
+ static MEDCouplingFieldDouble *New(const MEDCouplingFieldTemplate *ft, TypeOfTimeDiscretization td=NO_TIME);
+ void setTimeUnit(const char *unit);
+ const char *getTimeUnit() const;
+ void copyTinyStringsFrom(const MEDCouplingFieldDouble *other) throw(INTERP_KERNEL::Exception);
+ void copyTinyAttrFrom(const MEDCouplingFieldDouble *other) throw(INTERP_KERNEL::Exception);
+ std::string simpleRepr() const;
+ std::string advancedRepr() const;
+ MEDCouplingFieldDouble *clone(bool recDeepCpy) const;
+ MEDCouplingFieldDouble *cloneWithMesh(bool recDeepCpy) const;
+ MEDCouplingFieldDouble *deepCpy() const;
+ MEDCouplingFieldDouble *buildNewTimeReprFromThis(TypeOfTimeDiscretization td, bool deepCpy) const throw(INTERP_KERNEL::Exception);
+ TypeOfTimeDiscretization getTimeDiscretization() const throw(INTERP_KERNEL::Exception);
+ double getIJ(int tupleId, int compoId) const throw(INTERP_KERNEL::Exception);
+ double getIJK(int cellId, int nodeIdInCell, int compoId) const throw(INTERP_KERNEL::Exception);
+ void setArray(DataArrayDouble *array) throw(INTERP_KERNEL::Exception);
+ void setEndArray(DataArrayDouble *array) throw(INTERP_KERNEL::Exception);
+ void setTime(double val, int iteration, int order) throw(INTERP_KERNEL::Exception);
+ void setStartTime(double val, int iteration, int order) throw(INTERP_KERNEL::Exception);
+ void setEndTime(double val, int iteration, int order) throw(INTERP_KERNEL::Exception);
+ void applyLin(double a, double b, int compoId) throw(INTERP_KERNEL::Exception);
+ int getNumberOfComponents() const throw(INTERP_KERNEL::Exception);
+ int getNumberOfTuples() const throw(INTERP_KERNEL::Exception);
+ int getNumberOfValues() const throw(INTERP_KERNEL::Exception);
+ void setTimeTolerance(double val) throw(INTERP_KERNEL::Exception);
+ double getTimeTolerance() const throw(INTERP_KERNEL::Exception);
+ void setIteration(int it) throw(INTERP_KERNEL::Exception);
+ void setEndIteration(int it) throw(INTERP_KERNEL::Exception);
+ void setOrder(int order) throw(INTERP_KERNEL::Exception);
+ void setEndOrder(int order) throw(INTERP_KERNEL::Exception);
+ void setTimeValue(double val) throw(INTERP_KERNEL::Exception);
+ void setEndTimeValue(double val) throw(INTERP_KERNEL::Exception);
+ void updateTime() const throw(INTERP_KERNEL::Exception);
+ void changeUnderlyingMesh(const MEDCouplingMesh *other, int levOfCheck, double prec) throw(INTERP_KERNEL::Exception);
+ void substractInPlaceDM(const MEDCouplingFieldDouble *f, int levOfCheck, double prec) throw(INTERP_KERNEL::Exception);
+ bool mergeNodes(double eps, double epsOnVals=1e-15) throw(INTERP_KERNEL::Exception);
+ bool mergeNodes2(double eps, double epsOnVals=1e-15) throw(INTERP_KERNEL::Exception);
+ bool zipCoords(double epsOnVals=1e-15) throw(INTERP_KERNEL::Exception);
+ bool zipConnectivity(int compType,double epsOnVals=1e-15) throw(INTERP_KERNEL::Exception);
+ bool simplexize(int policy) throw(INTERP_KERNEL::Exception);
+ MEDCouplingFieldDouble *doublyContractedProduct() const throw(INTERP_KERNEL::Exception);
+ MEDCouplingFieldDouble *determinant() const throw(INTERP_KERNEL::Exception);
+ MEDCouplingFieldDouble *eigenValues() const throw(INTERP_KERNEL::Exception);
+ MEDCouplingFieldDouble *eigenVectors() const throw(INTERP_KERNEL::Exception);
+ MEDCouplingFieldDouble *inverse() const throw(INTERP_KERNEL::Exception);
+ MEDCouplingFieldDouble *trace() const throw(INTERP_KERNEL::Exception);
+ MEDCouplingFieldDouble *deviator() const throw(INTERP_KERNEL::Exception);
+ MEDCouplingFieldDouble *magnitude() const throw(INTERP_KERNEL::Exception);
+ MEDCouplingFieldDouble *maxPerTuple() const throw(INTERP_KERNEL::Exception);
+ void changeNbOfComponents(int newNbOfComp, double dftValue=0.) throw(INTERP_KERNEL::Exception);
+ void sortPerTuple(bool asc) throw(INTERP_KERNEL::Exception);
+ MEDCouplingFieldDouble &operator=(double value) throw(INTERP_KERNEL::Exception);
+ void fillFromAnalytic(int nbOfComp, const char *func) throw(INTERP_KERNEL::Exception);
+ void applyFunc(int nbOfComp, const char *func) throw(INTERP_KERNEL::Exception);
+ void applyFunc2(int nbOfComp, const char *func) throw(INTERP_KERNEL::Exception);
+ void applyFunc3(int nbOfComp, const std::vector<std::string>& varsOrder, const char *func) throw(INTERP_KERNEL::Exception);
+ void applyFunc(int nbOfComp, double val) throw(INTERP_KERNEL::Exception);
+ void applyFunc(const char *func) throw(INTERP_KERNEL::Exception);
+ void applyFuncFast32(const char *func) throw(INTERP_KERNEL::Exception);
+ void applyFuncFast64(const char *func) throw(INTERP_KERNEL::Exception);
+ double accumulate(int compId) const throw(INTERP_KERNEL::Exception);
+ double getMaxValue() const throw(INTERP_KERNEL::Exception);
+ double getMinValue() const throw(INTERP_KERNEL::Exception);
+ double getAverageValue() const throw(INTERP_KERNEL::Exception);
+ double getWeightedAverageValue() const throw(INTERP_KERNEL::Exception);
+ double integral(int compId, bool isWAbs) const throw(INTERP_KERNEL::Exception);
+ double normL1(int compId) const throw(INTERP_KERNEL::Exception);
+ double normL2(int compId) const throw(INTERP_KERNEL::Exception);
+ DataArrayInt *getIdsInRange(double vmin, double vmax) const throw(INTERP_KERNEL::Exception);
+ MEDCouplingFieldDouble *buildSubPart(const DataArrayInt *part) const throw(INTERP_KERNEL::Exception);
+ static MEDCouplingFieldDouble *MergeFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2) throw(INTERP_KERNEL::Exception);
+ static MEDCouplingFieldDouble *MeldFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2) throw(INTERP_KERNEL::Exception);
+ static MEDCouplingFieldDouble *DotFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2) throw(INTERP_KERNEL::Exception);
+ MEDCouplingFieldDouble *dot(const MEDCouplingFieldDouble& other) const throw(INTERP_KERNEL::Exception);
+ static MEDCouplingFieldDouble *CrossProductFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2) throw(INTERP_KERNEL::Exception);
+ MEDCouplingFieldDouble *crossProduct(const MEDCouplingFieldDouble& other) const throw(INTERP_KERNEL::Exception);
+ static MEDCouplingFieldDouble *MaxFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2) throw(INTERP_KERNEL::Exception);
+ MEDCouplingFieldDouble *max(const MEDCouplingFieldDouble& other) const throw(INTERP_KERNEL::Exception);
+ static MEDCouplingFieldDouble *MinFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2) throw(INTERP_KERNEL::Exception);
+ static MEDCouplingFieldDouble *AddFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2) throw(INTERP_KERNEL::Exception);
+ static MEDCouplingFieldDouble *SubstractFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2) throw(INTERP_KERNEL::Exception);
+ static MEDCouplingFieldDouble *MultiplyFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2) throw(INTERP_KERNEL::Exception);
+ static MEDCouplingFieldDouble *DivideFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2) throw(INTERP_KERNEL::Exception);
+ MEDCouplingFieldDouble *min(const MEDCouplingFieldDouble& other) const throw(INTERP_KERNEL::Exception);
+ MEDCouplingFieldDouble *operator+(const MEDCouplingFieldDouble& other) const throw(INTERP_KERNEL::Exception);
+ const MEDCouplingFieldDouble &operator+=(const MEDCouplingFieldDouble& other) throw(INTERP_KERNEL::Exception);
+ MEDCouplingFieldDouble *operator-(const MEDCouplingFieldDouble& other) const throw(INTERP_KERNEL::Exception);
+ const MEDCouplingFieldDouble &operator-=(const MEDCouplingFieldDouble& other) throw(INTERP_KERNEL::Exception);
+ MEDCouplingFieldDouble *operator*(const MEDCouplingFieldDouble& other) const throw(INTERP_KERNEL::Exception);
+ const MEDCouplingFieldDouble &operator*=(const MEDCouplingFieldDouble& other) throw(INTERP_KERNEL::Exception);
+ MEDCouplingFieldDouble *operator/(const MEDCouplingFieldDouble& other) const throw(INTERP_KERNEL::Exception);
+ const MEDCouplingFieldDouble &operator/=(const MEDCouplingFieldDouble& other) throw(INTERP_KERNEL::Exception);
+ %extend {
+ std::string __str__() const
+ {
+ return self->simpleRepr();
+ }
+
+ DataArrayDouble *getArray() throw(INTERP_KERNEL::Exception)
+ {
+ DataArrayDouble *ret=self->getArray();
+ if(ret)
+ ret->incrRef();
+ return ret;
+ }
+
+ PyObject *getArrays() const throw(INTERP_KERNEL::Exception)
+ {
+ std::vector<DataArrayDouble *> arrs=self->getArrays();
+ for(std::vector<DataArrayDouble *>::iterator it=arrs.begin();it!=arrs.end();it++)
+ if(*it)
+ (*it)->incrRef();
+ int sz=arrs.size();
+ PyObject *ret=PyTuple_New(sz);
+ for(int i=0;i<sz;i++)
+ {
+ if(arrs[i])
+ PyTuple_SetItem(ret,i,SWIG_NewPointerObj(SWIG_as_voidptr(arrs[i]),SWIGTYPE_p_ParaMEDMEM__DataArrayDouble, SWIG_POINTER_OWN | 0 ));
+ else
+ PyTuple_SetItem(ret,i,SWIG_NewPointerObj(SWIG_as_voidptr(0),SWIGTYPE_p_ParaMEDMEM__DataArrayDouble, 0 | 0 ));
+ }
+ return ret;
+ }
+
+ void setArrays(PyObject *ls) throw(INTERP_KERNEL::Exception)
+ {
+ std::vector<const DataArrayDouble *> tmp;
+ convertPyObjToVecDataArrayDblCst(ls,tmp);
+ int sz=tmp.size();
+ std::vector<DataArrayDouble *> arrs(sz);
+ for(int i=0;i<sz;i++)
+ arrs[i]=const_cast<DataArrayDouble *>(tmp[i]);
+ self->setArrays(arrs);
+ }
+
+ DataArrayDouble *getEndArray() throw(INTERP_KERNEL::Exception)
+ {
+ DataArrayDouble *ret=self->getEndArray();
+ if(ret)
+ ret->incrRef();
+ return ret;
+ }
+
+ PyObject *getValueOn(PyObject *sl) const throw(INTERP_KERNEL::Exception)
+ {
+ int sz;
+ INTERP_KERNEL::AutoPtr<double> spaceLoc=convertPyToNewDblArr2(sl,&sz);
+ sz=self->getNumberOfComponents();
+ INTERP_KERNEL::AutoPtr<double> res=new double[sz];
+ self->getValueOn(spaceLoc,res);
+ return convertDblArrToPyList(res,sz);
+ }
+
+ DataArrayDouble *getValueOnMulti(PyObject *li) const throw(INTERP_KERNEL::Exception)
+ {
+ void *da=0;
+ int res1=SWIG_ConvertPtr(li,&da,SWIGTYPE_p_ParaMEDMEM__DataArrayDouble, 0 | 0 );
+ if (!SWIG_IsOK(res1))
+ {
+ int size;
+ INTERP_KERNEL::AutoPtr<double> tmp=convertPyToNewDblArr2(li,&size);
+ int spaceDim=self->getMesh()->getSpaceDimension();
+ int nbOfPoints=size/spaceDim;
+ if(size%spaceDim!=0)
+ {
+ throw INTERP_KERNEL::Exception("Invalid list length ! Must be a multiple of self.getMesh().getSpaceDimension() !");
+ }
+ return self->getValueOnMulti(tmp,nbOfPoints);
+ }
+ else
+ {
+ DataArrayDouble *da2=reinterpret_cast< DataArrayDouble * >(da);
+ if(!da2)
+ throw INTERP_KERNEL::Exception("Not null DataArrayDouble instance expected !");
+ da2->checkAllocated();
+ int size=da2->getNumberOfTuples();
+ int nbOfCompo=da2->getNumberOfComponents();
+ if(nbOfCompo!=self->getMesh()->getSpaceDimension())
+ {
+ throw INTERP_KERNEL::Exception("Invalid DataArrayDouble nb of components ! Expected same as self.getMesh().getSpaceDimension() !");
+ }
+ return self->getValueOnMulti(da2->getConstPointer(),size);
+ }
+ }
+
+ PyObject *getValueOn(PyObject *sl, double time) const throw(INTERP_KERNEL::Exception)
+ {
+ int sz;
+ INTERP_KERNEL::AutoPtr<double> spaceLoc=convertPyToNewDblArr2(sl,&sz);
+ sz=self->getNumberOfComponents();
+ INTERP_KERNEL::AutoPtr<double> res=new double[sz];
+ self->getValueOn(spaceLoc,time,res);
+ return convertDblArrToPyList(res,sz);
+ }
+ void setValues(PyObject *li) throw(INTERP_KERNEL::Exception)
+ {
+ if(self->getArray()!=0)
+ {
+ int sz;
+ double *tmp=convertPyToNewDblArr2(li,&sz);
+ int nbTuples=self->getArray()->getNumberOfTuples();
+ int nbOfCompo=self->getArray()->getNumberOfComponents();
+ self->getArray()->useArray(tmp,true,CPP_DEALLOC,nbTuples,nbOfCompo);
+ }
+ else
+ PyErr_SetString(PyExc_TypeError,"setValuesCpy : field must contain an array behind");
+ }
+ PyObject *getTime() throw(INTERP_KERNEL::Exception)
+ {
+ int tmp1,tmp2;
+ double tmp0=self->getTime(tmp1,tmp2);
+ PyObject *res = PyList_New(3);
+ PyList_SetItem(res,0,SWIG_From_double(tmp0));
+ PyList_SetItem(res,1,SWIG_From_int(tmp1));
+ PyList_SetItem(res,2,SWIG_From_int(tmp2));
+ return res;
+ }
+
+ PyObject *getStartTime() throw(INTERP_KERNEL::Exception)
+ {
+ int tmp1,tmp2;
+ double tmp0=self->getStartTime(tmp1,tmp2);
+ PyObject *res = PyList_New(3);
+ PyList_SetItem(res,0,SWIG_From_double(tmp0));
+ PyList_SetItem(res,1,SWIG_From_int(tmp1));
+ PyList_SetItem(res,2,SWIG_From_int(tmp2));
+ return res;
+ }
+
+ PyObject *getEndTime() throw(INTERP_KERNEL::Exception)
+ {
+ int tmp1,tmp2;
+ double tmp0=self->getEndTime(tmp1,tmp2);
+ PyObject *res = PyList_New(3);
+ PyList_SetItem(res,0,SWIG_From_double(tmp0));
+ PyList_SetItem(res,1,SWIG_From_int(tmp1));
+ PyList_SetItem(res,2,SWIG_From_int(tmp2));
+ return res;
+ }
+ PyObject *accumulate() const throw(INTERP_KERNEL::Exception)
+ {
+ int sz=self->getNumberOfComponents();
+ INTERP_KERNEL::AutoPtr<double> tmp=new double[sz];
+ self->accumulate(tmp);
+ PyObject *ret=convertDblArrToPyList(tmp,sz);
+ return ret;
+ }
+ PyObject *integral(bool isWAbs) const throw(INTERP_KERNEL::Exception)
+ {
+ int sz=self->getNumberOfComponents();
+ INTERP_KERNEL::AutoPtr<double> tmp=new double[sz];
+ self->integral(isWAbs,tmp);
+ PyObject *ret=convertDblArrToPyList(tmp,sz);
+ return ret;
+ }
+ PyObject *normL1() const throw(INTERP_KERNEL::Exception)
+ {
+ int sz=self->getNumberOfComponents();
+ INTERP_KERNEL::AutoPtr<double> tmp=new double[sz];
+ self->normL1(tmp);
+ PyObject *ret=convertDblArrToPyList(tmp,sz);
+ return ret;
+ }
+ PyObject *normL2() const throw(INTERP_KERNEL::Exception)
+ {
+ int sz=self->getNumberOfComponents();
+ INTERP_KERNEL::AutoPtr<double> tmp=new double[sz];
+ self->normL2(tmp);
+ PyObject *ret=convertDblArrToPyList(tmp,sz);
+ return ret;
+ }
+ void renumberCells(PyObject *li, bool check) throw(INTERP_KERNEL::Exception)
+ {
+ void *da=0;
+ int res1=SWIG_ConvertPtr(li,&da,SWIGTYPE_p_ParaMEDMEM__DataArrayInt, 0 | 0 );
+ if (!SWIG_IsOK(res1))
+ {
+ int size;
+ INTERP_KERNEL::AutoPtr<int> tmp=convertPyToNewIntArr2(li,&size);
+ self->renumberCells(tmp,check);
+ }
+ else
+ {
+ DataArrayInt *da2=reinterpret_cast< DataArrayInt * >(da);
+ if(!da2)
+ throw INTERP_KERNEL::Exception("Not null DataArrayInt instance expected !");
+ da2->checkAllocated();
+ self->renumberCells(da2->getConstPointer(),check);
+ }
+ }
+ void renumberNodes(PyObject *li) throw(INTERP_KERNEL::Exception)
+ {
+ void *da=0;
+ int res1=SWIG_ConvertPtr(li,&da,SWIGTYPE_p_ParaMEDMEM__DataArrayInt, 0 | 0 );
+ if (!SWIG_IsOK(res1))
+ {
+ int size;
+ INTERP_KERNEL::AutoPtr<int> tmp=convertPyToNewIntArr2(li,&size);
+ self->renumberNodes(tmp);
+ }
+ else
+ {
+ DataArrayInt *da2=reinterpret_cast< DataArrayInt * >(da);
+ if(!da2)
+ throw INTERP_KERNEL::Exception("Not null DataArrayInt instance expected !");
+ da2->checkAllocated();
+ self->renumberNodes(da2->getConstPointer());
+ }
+ }
+
+ MEDCouplingFieldDouble *buildSubPart(PyObject *li) const throw(INTERP_KERNEL::Exception)
+ {
+ void *da=0;
+ int res1=SWIG_ConvertPtr(li,&da,SWIGTYPE_p_ParaMEDMEM__DataArrayInt, 0 | 0 );
+ if (!SWIG_IsOK(res1))
+ {
+ int size;
+ INTERP_KERNEL::AutoPtr<int> tmp=convertPyToNewIntArr2(li,&size);
+ return self->buildSubPart(tmp,((const int *)tmp)+size);
+ }
+ else
+ {
+ DataArrayInt *da2=reinterpret_cast< DataArrayInt * >(da);
+ if(!da2)
+ throw INTERP_KERNEL::Exception("Not null DataArrayInt instance expected !");
+ da2->checkAllocated();
+ return self->buildSubPart(da2->getConstPointer(),da2->getConstPointer()+da2->getNbOfElems());
+ }
+ }
+
+ PyObject *getMaxValue2() const throw(INTERP_KERNEL::Exception)
+ {
+ DataArrayInt *tmp;
+ double r1=self->getMaxValue2(tmp);
+ PyObject *ret=PyTuple_New(2);
+ PyTuple_SetItem(ret,0,PyFloat_FromDouble(r1));
+ PyTuple_SetItem(ret,1,SWIG_NewPointerObj(SWIG_as_voidptr(tmp),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 ));
+ return ret;
+ }
+
+ PyObject *getMinValue2() const throw(INTERP_KERNEL::Exception)
+ {
+ DataArrayInt *tmp;
+ double r1=self->getMinValue2(tmp);
+ PyObject *ret=PyTuple_New(2);
+ PyTuple_SetItem(ret,0,PyFloat_FromDouble(r1));
+ PyTuple_SetItem(ret,1,SWIG_NewPointerObj(SWIG_as_voidptr(tmp),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 ));
+ return ret;
+ }
+
+ MEDCouplingFieldDouble *keepSelectedComponents(PyObject *li) const throw(INTERP_KERNEL::Exception)
+ {
+ std::vector<int> tmp;
+ convertPyToNewIntArr3(li,tmp);
+ return self->keepSelectedComponents(tmp);
+ }
+
+ void setSelectedComponents(const MEDCouplingFieldDouble *f, PyObject *li) throw(INTERP_KERNEL::Exception)
+ {
+ std::vector<int> tmp;
+ convertPyToNewIntArr3(li,tmp);
+ self->setSelectedComponents(f,tmp);
+ }
+
+ static MEDCouplingFieldDouble *MergeFields(PyObject *li) throw(INTERP_KERNEL::Exception)
+ {
+ std::vector<const MEDCouplingFieldDouble *> tmp;
+ convertPyObjToVecFieldDblCst(li,tmp);
+ return MEDCouplingFieldDouble::MergeFields(tmp);
+ }
+ }
+ };
+
+ class MEDCouplingFieldTemplate : public ParaMEDMEM::MEDCouplingField
+ {
+ public:
+ static MEDCouplingFieldTemplate *New(const MEDCouplingFieldDouble *f) throw(INTERP_KERNEL::Exception);
+ static MEDCouplingFieldTemplate *New(TypeOfField type);
+ std::string simpleRepr() const;
+ std::string advancedRepr() const;
+ %extend
+ {
+ std::string __str__() const
+ {
+ return self->simpleRepr();
+ }
+ }
+ };
+
+ class MEDCouplingMultiFields : public RefCountObject, public TimeLabel
+ {
+ public:
+ int getNumberOfFields() const;
+ MEDCouplingMultiFields *deepCpy() const;
+ virtual std::string simpleRepr() const;
+ virtual std::string advancedRepr() const;
+ virtual bool isEqual(const MEDCouplingMultiFields *other, double meshPrec, double valsPrec) const;
+ virtual bool isEqualWithoutConsideringStr(const MEDCouplingMultiFields *other, double meshPrec, double valsPrec) const;
+ virtual void checkCoherency() const throw(INTERP_KERNEL::Exception);
+ %extend
+ {
+ std::string __str__() const
+ {
+ return self->simpleRepr();
+ }
+ static MEDCouplingMultiFields *New(PyObject *li) throw(INTERP_KERNEL::Exception)
+ {
+ std::vector<const ParaMEDMEM::MEDCouplingFieldDouble *> tmp;
+ convertPyObjToVecFieldDblCst(li,tmp);
+ int sz=tmp.size();
+ std::vector<MEDCouplingFieldDouble *> fs(sz);
+ for(int i=0;i<sz;i++)
+ fs[i]=const_cast<MEDCouplingFieldDouble *>(tmp[i]);
+ return MEDCouplingMultiFields::New(fs);
+ }
+ PyObject *getFields() const
+ {
+ std::vector<const MEDCouplingFieldDouble *> fields=self->getFields();
+ int sz=fields.size();
+ PyObject *res = PyList_New(sz);
+ for(int i=0;i<sz;i++)
+ {
+ if(fields[i])
+ {
+ fields[i]->incrRef();
+ PyList_SetItem(res,i,SWIG_NewPointerObj(SWIG_as_voidptr(fields[i]),SWIGTYPE_p_ParaMEDMEM__MEDCouplingFieldDouble, SWIG_POINTER_OWN | 0 ));
+ }
+ else
+ {
+ PyList_SetItem(res,i,SWIG_NewPointerObj(SWIG_as_voidptr(0),SWIGTYPE_p_ParaMEDMEM__MEDCouplingFieldDouble, 0 ));
+ }
+ }
+ return res;
+ }
+ PyObject *getFieldAtPos(int id) const throw(INTERP_KERNEL::Exception)
+ {
+ const MEDCouplingFieldDouble *ret=self->getFieldAtPos(id);
+ if(ret)
+ {
+ ret->incrRef();
+ return SWIG_NewPointerObj(SWIG_as_voidptr(ret),SWIGTYPE_p_ParaMEDMEM__MEDCouplingFieldDouble, SWIG_POINTER_OWN | 0 );
+ }
+ else
+ return SWIG_NewPointerObj(SWIG_as_voidptr(0),SWIGTYPE_p_ParaMEDMEM__MEDCouplingFieldDouble, 0 );
+ }
+ PyObject *getMeshes() const throw(INTERP_KERNEL::Exception)
+ {
+ std::vector<MEDCouplingMesh *> ms=self->getMeshes();
+ int sz=ms.size();
+ PyObject *res = PyList_New(sz);
+ for(int i=0;i<sz;i++)
+ {
+ if(ms[i])
+ {
+ ms[i]->incrRef();
+ PyList_SetItem(res,i,convertMesh(ms[i], SWIG_POINTER_OWN | 0 ));
+ }
+ else
+ {
+ PyList_SetItem(res,i,SWIG_NewPointerObj(SWIG_as_voidptr(0),SWIGTYPE_p_ParaMEDMEM__MEDCouplingUMesh, 0 ));
+ }
+ }
+ return res;
+ }
+ PyObject *getDifferentMeshes() const throw(INTERP_KERNEL::Exception)
+ {
+ std::vector<int> refs;
+ std::vector<MEDCouplingMesh *> ms=self->getDifferentMeshes(refs);
+ int sz=ms.size();
+ PyObject *res = PyList_New(sz);
+ for(int i=0;i<sz;i++)
+ {
+ if(ms[i])
+ {
+ ms[i]->incrRef();
+ PyList_SetItem(res,i,convertMesh(ms[i], SWIG_POINTER_OWN | 0 ));
+ }
+ else
+ {
+ PyList_SetItem(res,i,SWIG_NewPointerObj(SWIG_as_voidptr(0),SWIGTYPE_p_ParaMEDMEM__MEDCouplingUMesh, 0 ));
+ }
+ }
+ //
+ PyObject *ret=PyTuple_New(2);
+ PyTuple_SetItem(ret,0,res);
+ PyTuple_SetItem(ret,1,convertIntArrToPyList2(refs));
+ return ret;
+ }
+ PyObject *getArrays() const throw(INTERP_KERNEL::Exception)
+ {
+ std::vector<DataArrayDouble *> ms=self->getArrays();
+ int sz=ms.size();
+ PyObject *res = PyList_New(sz);
+ for(int i=0;i<sz;i++)
+ {
+ if(ms[i])
+ {
+ ms[i]->incrRef();
+ PyList_SetItem(res,i,SWIG_NewPointerObj(SWIG_as_voidptr(ms[i]),SWIGTYPE_p_ParaMEDMEM__DataArrayDouble, SWIG_POINTER_OWN | 0 ));
+ }
+ else
+ {
+ PyList_SetItem(res,i,SWIG_NewPointerObj(SWIG_as_voidptr(0),SWIGTYPE_p_ParaMEDMEM__DataArrayDouble, 0 ));
+ }
+ }
+ return res;
+ }
+ PyObject *getDifferentArrays() const throw(INTERP_KERNEL::Exception)
+ {
+ std::vector< std::vector<int> > refs;
+ std::vector<DataArrayDouble *> ms=self->getDifferentArrays(refs);
+ int sz=ms.size();
+ PyObject *res = PyList_New(sz);
+ PyObject *res2 = PyList_New(sz);
+ for(int i=0;i<sz;i++)
+ {
+ if(ms[i])
+ {
+ ms[i]->incrRef();
+ PyList_SetItem(res,i,SWIG_NewPointerObj(SWIG_as_voidptr(ms[i]),SWIGTYPE_p_ParaMEDMEM__DataArrayDouble, SWIG_POINTER_OWN | 0 ));
+ }
+ else
+ {
+ PyList_SetItem(res,i,SWIG_NewPointerObj(SWIG_as_voidptr(0),SWIGTYPE_p_ParaMEDMEM__DataArrayDouble, 0 ));
+ }
+ PyList_SetItem(res2,i,convertIntArrToPyList2(refs[i]));
+ }
+ //
+ PyObject *ret=PyTuple_New(2);
+ PyTuple_SetItem(ret,0,res);
+ PyTuple_SetItem(ret,1,res2);
+ return ret;
+ }
+ }
+ };
+
+ class MEDCouplingDefinitionTime
+ {
+ public:
+ MEDCouplingDefinitionTime();
+ void assign(const MEDCouplingDefinitionTime& other);
+ bool isEqual(const MEDCouplingDefinitionTime& other) const;
+ double getTimeResolution() const;
+ std::vector<double> getHotSpotsTime() const;
+ %extend
+ {
+ std::string __str__() const
+ {
+ std::ostringstream oss;
+ self->appendRepr(oss);
+ return oss.str();
+ }
+
+ PyObject *getIdsOnTimeRight(double tm) const throw(INTERP_KERNEL::Exception)
+ {
+ int meshId,arrId,arrIdInField,fieldId;
+ self->getIdsOnTimeRight(tm,meshId,arrId,arrIdInField,fieldId);
+ PyObject *res=PyList_New(4);
+ PyList_SetItem(res,0,PyInt_FromLong(meshId));
+ PyList_SetItem(res,1,PyInt_FromLong(arrId));
+ PyList_SetItem(res,2,PyInt_FromLong(arrIdInField));
+ PyList_SetItem(res,3,PyInt_FromLong(fieldId));
+ return res;
+ }
+
+ PyObject *getIdsOnTimeLeft(double tm) const throw(INTERP_KERNEL::Exception)
+ {
+ int meshId,arrId,arrIdInField,fieldId;
+ self->getIdsOnTimeLeft(tm,meshId,arrId,arrIdInField,fieldId);
+ PyObject *res=PyList_New(4);
+ PyList_SetItem(res,0,PyInt_FromLong(meshId));
+ PyList_SetItem(res,1,PyInt_FromLong(arrId));
+ PyList_SetItem(res,2,PyInt_FromLong(arrIdInField));
+ PyList_SetItem(res,3,PyInt_FromLong(fieldId));
+ return res;
+ }
+ }
+ };
+
+ class MEDCouplingFieldOverTime : public MEDCouplingMultiFields
+ {
+ public:
+ double getTimeTolerance() const throw(INTERP_KERNEL::Exception);
+ MEDCouplingDefinitionTime getDefinitionTimeZone() const;
+
+ %extend
+ {
+ std::string __str__() const
+ {
+ return self->simpleRepr();
+ }
+ static MEDCouplingFieldOverTime *New(PyObject *li) throw(INTERP_KERNEL::Exception)
+ {
+ std::vector<const ParaMEDMEM::MEDCouplingFieldDouble *> tmp;
+ convertPyObjToVecFieldDblCst(li,tmp);
+ int sz=tmp.size();
+ std::vector<MEDCouplingFieldDouble *> fs(sz);
+ for(int i=0;i<sz;i++)
+ fs[i]=const_cast<MEDCouplingFieldDouble *>(tmp[i]);
+ return MEDCouplingFieldOverTime::New(fs);
+ }
+ }
+ };
+}
# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
#
-from libMEDCoupling_Swig import *
+from MEDCoupling import *
import unittest
from math import pi,e,sqrt
from MEDCouplingDataForTest import MEDCouplingDataForTest
targetMesh=MEDCouplingUMesh.New();
targetMesh.setMeshDimension(0);
targetMesh.allocateCells(8);
- targetMesh.insertNextCell(NORM_POINT0,0,[]);
- targetMesh.insertNextCell(NORM_POINT0,0,[]);
- targetMesh.insertNextCell(NORM_POINT0,0,[]);
- targetMesh.insertNextCell(NORM_POINT0,0,[]);
- targetMesh.insertNextCell(NORM_POINT0,0,[]);
- targetMesh.insertNextCell(NORM_POINT0,0,[]);
- targetMesh.insertNextCell(NORM_POINT0,0,[]);
- targetMesh.insertNextCell(NORM_POINT0,0,[]);
+ targetMesh.insertNextCell(NORM_POINT1,1,[0]);
+ targetMesh.insertNextCell(NORM_POINT1,1,[1]);
+ targetMesh.insertNextCell(NORM_POINT1,1,[2]);
+ targetMesh.insertNextCell(NORM_POINT1,1,[3]);
+ targetMesh.insertNextCell(NORM_POINT1,1,[4]);
+ targetMesh.insertNextCell(NORM_POINT1,1,[5]);
+ targetMesh.insertNextCell(NORM_POINT1,1,[7]);
+ targetMesh.insertNextCell(NORM_POINT1,1,[6]);
targetMesh.finishInsertingCells();
myCoords=DataArrayDouble.New();
myCoords.setValues(targetCoords,9,3);
pass
def testMeshM1D(self):
meshM1D=MEDCouplingUMesh.New();
- self.assertRaises(Exception,meshM1D.getMeshDimension);
- self.assertRaises(Exception,meshM1D.getNumberOfNodes);
- self.assertRaises(Exception,meshM1D.getNumberOfCells);
- self.assertRaises(Exception,meshM1D.setMeshDimension,-2)
- self.assertRaises(Exception,meshM1D.setMeshDimension,-10)
+ self.assertRaises(InterpKernelException,meshM1D.getMeshDimension);
+ self.assertRaises(InterpKernelException,meshM1D.getNumberOfNodes);
+ self.assertRaises(InterpKernelException,meshM1D.getNumberOfCells);
+ self.assertRaises(InterpKernelException,meshM1D.setMeshDimension,-2)
+ self.assertRaises(InterpKernelException,meshM1D.setMeshDimension,-10)
meshM1D.setMeshDimension(-1);
meshM1D.checkCoherency();
self.assertEqual(meshM1D.getMeshDimension(),-1);
self.assertEqual(meshM1D.getNumberOfCells(),1);
- self.assertRaises(Exception,meshM1D.getNumberOfNodes);
- self.assertRaises(Exception,meshM1D.getSpaceDimension);
+ self.assertRaises(InterpKernelException,meshM1D.getNumberOfNodes);
+ self.assertRaises(InterpKernelException,meshM1D.getSpaceDimension);
cpy=meshM1D.clone(True);
self.assertTrue(cpy.isEqual(meshM1D,1e-12));
fieldOnCells=MEDCouplingFieldDouble.New(ON_CELLS);
array=DataArrayDouble.New();
array.setValues(5*3*[7.],5,3);
self.assertEqual(array.getIJ(3,2),7.);
- array2=array.deepCopy();
+ array2=array.deepCpy();
self.assertEqual(array2.getIJ(3,2),7.)
#
array3=DataArrayInt.New();
array3.setValues(5*3*[17],5,3);
self.assertEqual(array3.getIJ(3,2),17);
- array4=array3.deepCopy();
+ array4=array3.deepCpy();
self.assertEqual(array4.getIJ(3,2),17);
pass
def testRevNodal(self):
mesh=MEDCouplingDataForTest.build2DTargetMesh_1()
- revNodal=DataArrayInt.New();
- revNodalIndx=DataArrayInt.New();
- mesh.getReverseNodalConnectivity(revNodal,revNodalIndx);
+ revNodal,revNodalIndx=mesh.getReverseNodalConnectivity();
revNodalExpected=[0,0,1,1,2,0,3,0,1,2,3,4,2,4,3,3,4,4];
revNodalIndexExpected=[0,1,3,5,7,12,14,15,17,18];
self.assertEqual(revNodal.getNbOfElems(),18)
self.assertEqual(4,subMesh.getNodalConnectivityIndex().getNbOfElems());
self.assertEqual(subConn2[0:14],list(subMesh.getNodalConnectivity().getValues()));
self.assertEqual(subConnIndex2[0:4],list(subMesh.getNodalConnectivityIndex().getValues()));
- subMesh=subMesh.buildPartOfMySelf(range(3),True);
- self.assertEqual("PartOf_Toto",subMesh.getName());
+ dd=DataArrayInt.New()
+ dd.alloc(3,1)
+ dd.iota(0)
+ dd.setName("coucou")
+ subMesh=subMesh.buildPartOfMySelf(dd,True);
+ self.assertEqual("coucou",subMesh.getName());
pass
def testBuildPartOfMySelfNode(self):
mesh=MEDCouplingDataForTest.build2DTargetMesh_1();
self.assertEqual(subConn[0:5],list(subMesh.getNodalConnectivity().getValues()));
self.assertEqual(subConnIndex[0:2],list(subMesh.getNodalConnectivityIndex().getValues()));
#
- subMesh=mesh.buildPartOfMySelfNode(tab1[0:2],False);
+ ddd=DataArrayInt.New()
+ ddd.setValues(tab1[0:2],2,1)
+ ddd.setName("ddd")
+ subMesh=mesh.buildPartOfMySelfNode(ddd,False);
+ self.assertEqual("ddd",subMesh.getName())
self.assertTrue(isinstance(subMesh,MEDCouplingUMesh))
self.assertEqual(2,len(subMesh.getAllTypes()));
self.assertEqual(NORM_TRI3,subMesh.getAllTypes()[0]);
m3=m2.buildPartOfMySelf(cells1,True);
self.assertTrue(isinstance(m3,MEDCouplingUMesh))
m4=MEDCouplingDataForTest.build2DSourceMesh_1();
- m5=MEDCouplingUMesh.mergeUMeshes(m1,m3);
- m6=MEDCouplingUMesh.mergeUMeshes(m5,m4);
+ m5=MEDCouplingUMesh.MergeUMeshes(m1,m3);
+ m6=MEDCouplingUMesh.MergeUMeshes(m5,m4);
#
self.assertEqual(10,m6.getNumberOfCells());
self.assertEqual(22,m6.getNumberOfNodes());
self.assertTrue(fieldOnCells1.isEqual(fieldOnCells2,1e-12,1e-15));
self.assertTrue(fieldOnCells2.isEqual(fieldOnCells1,1e-12,1e-15));
#
- arr2=arr.deepCopy();
+ arr2=arr.deepCpy();
fieldOnCells2.setArray(arr2);
self.assertTrue(fieldOnCells1.isEqual(fieldOnCells2,1e-12,1e-15));
self.assertTrue(fieldOnCells2.isEqual(fieldOnCells1,1e-12,1e-15));
field.setNature(IntegralGlobConstraint);
field=MEDCouplingFieldDouble.New(ON_NODES,NO_TIME);
field.setNature(ConservativeVolumic);
- self.assertRaises(Exception,field.setNature,Integral);
- self.assertRaises(Exception,field.setNature,IntegralGlobConstraint);
+ self.assertRaises(InterpKernelException,field.setNature,Integral);
+ self.assertRaises(InterpKernelException,field.setNature,IntegralGlobConstraint);
pass
def testBuildSubMeshData(self):
center=[0.,0.,0.]
vector=[0.,1.,0.]
m2.rotate(center,vector,-pi/2.);
- m3=m1.buildExtrudedMeshFromThis(m2,0);
+ m3=m1.buildExtrudedMesh(m2,0);
#
m4=MEDCouplingExtrudedMesh.New(m3,m1,0);
self.assertEqual(15,m4.getNumberOfCells());
#play with polygons and polyedrons
cells=[2,3]
m1.convertToPolyTypes(cells);
- m3=m1.buildExtrudedMeshFromThis(m2,0);
+ m3=m1.buildExtrudedMesh(m2,0);
self.assertEqual(NORM_HEXA8,m3.getTypeOfCell(0));
self.assertEqual(NORM_PENTA6,m3.getTypeOfCell(1));
self.assertEqual(NORM_POLYHED,m3.getTypeOfCell(2));
center=[0.,0.,0.]
vector=[0.,1.,0.]
m2.rotate(center,vector,-pi/2.);
- m3=m1.buildExtrudedMeshFromThis(m2,0);
+ m3=m1.buildExtrudedMesh(m2,0);
expected1=[1,3,2,0,6,5,7,10,11,8,12,9,14,13,4]
rexpected1=[3, 0, 2, 1, 14, 5, 4, 6, 9, 11, 7, 8, 10, 13, 12]
m3.renumberCells(expected1,False);
m3=MEDCouplingDataForTest.build2DTargetMesh_1();
m3.tryToShareSameCoords(m2,1e-12);
meshes=[m1,m2,m3]
- m4=MEDCouplingUMesh.mergeUMeshesOnSameCoords(meshes);
+ m4=MEDCouplingUMesh.MergeUMeshesOnSameCoords(meshes);
m4.checkCoherency();
self.assertEqual(15,m4.getNumberOfCells());
cells1=[0,1,2,3,4]
m2.translate(vec);
f1=m1.getMeasureField(True);
f2=m2.getMeasureField(True);
- f3=MEDCouplingFieldDouble.mergeFields(f1,f2);
+ f3=MEDCouplingFieldDouble.MergeFields(f1,f2);
f3.checkCoherency();
m4=MEDCouplingDataForTest.build2DTargetMeshMerged_1();
self.assertTrue(f3.getMesh().isEqual(m4,1.e-12));
self.assertTrue(abs(0.5-values4[0])<1.e-12);
self.assertTrue(abs(1.-values4[1])<1.e-12);
#
- self.assertRaises(Exception,m.fillFromAnalytic,ON_NODES,1,"1./(x-0.2)");
+ self.assertRaises(InterpKernelException,m.fillFromAnalytic,ON_NODES,1,"1./(x-0.2)");
pass
def testFillFromAnalytic2(self):
f4.checkCoherency();
self.assertEqual(f4.getTypeOfField(),ON_NODES);
self.assertEqual(f4.getTimeDiscretization(),ONE_TIME);
- self.assertRaises(Exception,f1.__add__,f4);
+ self.assertRaises(InterpKernelException,f1.__add__,f4);
f5=f4.buildNewTimeReprFromThis(NO_TIME,False);
self.assertEqual(f5.getTypeOfField(),ON_NODES);
self.assertEqual(f5.getTimeDiscretization(),NO_TIME);
f4.checkCoherency();
self.assertEqual(f4.getTypeOfField(),ON_NODES);
self.assertEqual(f4.getTimeDiscretization(),ONE_TIME);
- self.assertRaises(Exception,f1.__add__,f4);
+ self.assertRaises(InterpKernelException,f1.__add__,f4);
f5=f4.buildNewTimeReprFromThis(NO_TIME,True);
self.assertEqual(f5.getTypeOfField(),ON_NODES);
self.assertEqual(f5.getTimeDiscretization(),NO_TIME);
#
f1=m.buildOrthogonalField();
# to avoid valgrind leaks
- # self.assertRaises(Exception,f2.__imul__,f1);
+ # self.assertRaises(InterpKernelException,f2.__imul__,f1);
pass
def testOperationsOnFields4(self):
f1.setMesh(m);
array=DataArrayDouble.New();
f1.setArray(array);
- self.assertRaises(Exception,f1.setEndArray,array);
- self.assertRaises(Exception,f1.getEndArray);
+ self.assertRaises(InterpKernelException,f1.setEndArray,array);
+ self.assertRaises(InterpKernelException,f1.getEndArray);
arr1=[0.,10.,20.,1.,11.,21.,2.,12.,22.,3.,13.,23.,4.,14.,24.]
arr2=[5.,15.,25.,6.,16.,26.,7.,17.,27.,8.,18.,28.,9.,19.,29.]
array.setValues(arr1,nbOfCells,3);
self.assertTrue(abs(arr1[4]-res[1])<1.e-12);
self.assertTrue(abs(arr1[5]-res[2])<1.e-12);
res=None
- self.assertRaises(Exception,f1.getValueOn,pos,3.2)
+ self.assertRaises(InterpKernelException,f1.getValueOn,pos,3.2)
f2=MEDCouplingFieldDouble.New(ON_CELLS,LINEAR_TIME);
f2.setMesh(m);
f2.setArray(f1.getArray());
f2.setStartTime(2.,3,0);
f2.setEndTime(4.,13,0);
- self.assertRaises(Exception,f2.checkCoherency)
+ self.assertRaises(InterpKernelException,f2.checkCoherency)
array2=DataArrayDouble.New();
array2.setValues(arr2,nbOfCells,3);
f2.setEndArray(array2);
f1=targetMesh.fillFromAnalytic(ON_NODES,1,"x+y+z");
tmp=f1.getArray()
tmp.setIJ(1,0,1000.);
- self.assertRaises(Exception,f1.mergeNodes,1.e-10)
+ self.assertRaises(InterpKernelException,f1.mergeNodes,1.e-10)
pass
def testCheckConsecutiveCellTypes(self):
m1=MEDCouplingDataForTest.build3DSurfTargetMesh_1();
v=m1.splitByType();
self.assertEqual(3,len(v));
- m2=MEDCouplingUMesh.mergeUMeshesOnSameCoords(v);
+ m2=MEDCouplingUMesh.MergeUMeshesOnSameCoords(v);
m2.setName(m1.getName());
self.assertTrue(m1.isEqual(m2,1.e-12));
pass
self.assertTrue(isinstance(m5,MEDCouplingUMesh))
meshes=[m3,m4,m5]
#
- m7,corr=MEDCouplingUMesh.fuseUMeshesOnSameCoords(meshes,0);
+ m7,corr=MEDCouplingUMesh.FuseUMeshesOnSameCoords(meshes,0);
self.assertEqual(4,m7.getNumberOfCells());
self.assertEqual(3,len(corr));
expectedVals1=[3,3,2]
vals=arr.getValues();
self.assertEqual(expectedVals2[i],list(vals));
pass
- arr2,fidsOfGroups=DataArrayInt.makePartition(corr,m7.getNumberOfCells());
+ arr2,fidsOfGroups=DataArrayInt.MakePartition(corr,m7.getNumberOfCells());
fidExp=[5,1,3,4]
fidsGrp=[[1,3,5],[3,4,5],[4,5]]
self.assertEqual(3,len(fidsOfGroups));
part2=[5,6,4,7]
m4=m1.buildPartOfMySelf(part2,True);
meshes=[m1,m3,m3,m4]
- m5,corr=MEDCouplingUMesh.fuseUMeshesOnSameCoords(meshes,0);
+ m5,corr=MEDCouplingUMesh.FuseUMeshesOnSameCoords(meshes,0);
self.assertEqual(18,m5.getNumberOfCells());
exp2=[
[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17],
pos=[0.,0.,0.4,0.4,0.,0.4,0.1,0.1,0.25,0.,0.65,0.]
#2D basic
t1,t2=targetMesh.getCellsContainingPoints(pos,6,1e-12);
- self.assertEqual(6,len(t1));
- self.assertEqual(7,len(t2));
+ self.assertEqual(6,t1.getNumberOfTuples());
+ self.assertEqual(1,t1.getNumberOfComponents());
+ self.assertEqual(7,t2.getNumberOfTuples());
+ self.assertEqual(1,t2.getNumberOfComponents());
expectedValues1=[0,4,3,0,1,2]
expectedValues2=[0,1,2,3,4,5,6]
- self.assertEqual(list(t1),expectedValues1);
- self.assertEqual(list(t2),expectedValues2);
+ self.assertEqual(list(t1.getValues()),expectedValues1);
+ self.assertEqual(list(t2.getValues()),expectedValues2);
#2D with no help of bounding box.
center=[0.2,0.2]
- MEDCouplingPointSet.rotate2DAlg(center,0.78539816339744830962,6,pos);
+ MEDCouplingPointSet.Rotate2DAlg(center,0.78539816339744830962,6,pos);
targetMesh.rotate(center,[],0.78539816339744830962);
t1=None
t2=None
t1,t2=targetMesh.getCellsContainingPoints(pos,6,1e-12);
- self.assertEqual(6,len(t1));
- self.assertEqual(7,len(t2));
- self.assertEqual(list(t1),expectedValues1);
- self.assertEqual(list(t2),expectedValues2);
+ self.assertEqual(6,t1.getNumberOfTuples());
+ self.assertEqual(7,t2.getNumberOfTuples());
+ self.assertEqual(list(t1.getValues()),expectedValues1);
+ self.assertEqual(list(t2.getValues()),expectedValues2);
#2D outside
pos1bis=[-0.3303300858899107,-0.11819805153394641]
self.assertEqual(-1,targetMesh.getCellContainingPoint(pos1bis,1e-12));
m1=MEDCouplingDataForTest.build2DTargetMesh_1();
m2=MEDCouplingDataForTest.build2DSourceMesh_1();
#self.assertEqual(m1.getCoords()!=m2.getCoords());
- self.assertRaises(Exception,m1.tryToShareSameCoords,m2,1e-12)
+ self.assertRaises(InterpKernelException,m1.tryToShareSameCoords,m2,1e-12)
pass
def testFindNodeOnPlane(self):
expected=[0,1,2,3,4,5,6,7]
val=da.getValues();
self.assertEqual(expected,list(val));
+ #
+ ddd=DataArrayInt.New()
+ ddd.setValues(n,len(n),1)
+ m3dSurf=mesh.buildFacePartOfMySelfNode(ddd,True);
+ self.assertTrue(isinstance(m3dSurf,MEDCouplingUMesh))
+ me=MEDCouplingExtrudedMesh.New(mesh,m3dSurf,0);
+ da=me.getMesh3DIds();
+ self.assertEqual(8,me.getNumberOfCells());
+ expected=[0,1,2,3,4,5,6,7]
+ val=da.getValues();
+ self.assertEqual(expected,list(val));
pass
def testRenumberCells(self):
f.setMesh(m);
self.assertEqual(0,f.getNbOfGaussLocalization());
f.setGaussLocalizationOnType(NORM_TRI3,_refCoo1,_gsCoo1,_wg1);
- self.assertRaises(Exception,f.setGaussLocalizationOnType,NORM_QUAD4,_refCoo1,_gsCoo1,_wg1)
+ self.assertRaises(InterpKernelException,f.setGaussLocalizationOnType,NORM_QUAD4,_refCoo1,_gsCoo1,_wg1)
self.assertEqual(1,f.getNbOfGaussLocalization());
refCoo2=[ 0.,0., 1.,0., 1.,1., 0.,1. ]
_refCoo2=refCoo2
#
f.clearGaussLocalizations();
self.assertEqual(0,f.getNbOfGaussLocalization());
- self.assertRaises(Exception,f.checkCoherency);
+ self.assertRaises(InterpKernelException,f.checkCoherency);
ids1=[0,1,3,4]
- self.assertRaises(Exception,f.setGaussLocalizationOnCells,ids1,_refCoo2,_gsCoo1,_wg1);
+ self.assertRaises(InterpKernelException,f.setGaussLocalizationOnCells,ids1,_refCoo2,_gsCoo1,_wg1);
self.assertEqual(0,f.getNbOfGaussLocalization());
ids2=[0,4]
f.setGaussLocalizationOnCells(ids2,_refCoo2,_gsCoo1,_wg1);
self.assertEqual(1,f.getNbOfGaussLocalization());
self.assertEqual(0,f.getGaussLocalizationIdOfOneCell(0));
- self.assertRaises(Exception,f.getGaussLocalizationIdOfOneCell,1);
+ self.assertRaises(InterpKernelException,f.getGaussLocalizationIdOfOneCell,1);
ids3=[1,2]
f.setGaussLocalizationOnCells(ids3,_refCoo1,_gsCoo1,_wg1);
self.assertEqual(2,f.getNbOfGaussLocalization());
self.assertEqual(0,f.getGaussLocalizationIdOfOneCell(0));
self.assertEqual(1,f.getGaussLocalizationIdOfOneCell(1));
self.assertEqual(1,f.getGaussLocalizationIdOfOneCell(2));
- self.assertRaises(Exception,f.checkCoherency);#<- cell 3 has no localization
+ self.assertRaises(InterpKernelException,f.checkCoherency);#<- cell 3 has no localization
ids4=[3]
_gsCoo2=_gsCoo1;
_wg2=_wg1;
self.assertEqual(3,f.getNbOfGaussLocalization());
tmpIds=f.getCellIdsHavingGaussLocalization(0);
self.assertEqual(ids2,list(tmpIds));
- self.assertRaises(Exception,f.checkCoherency);#<- it's always not ok because undelying array not with the good size.
+ self.assertRaises(InterpKernelException,f.checkCoherency);#<- it's always not ok because undelying array not with the good size.
array2=f.getArray().substr(0,10);
f.setArray(array2);
f.checkCoherency();#<- here it is OK
def testCellOrientation1(self):
m=MEDCouplingDataForTest.build2DTargetMesh_1();
vec=[0.,0.,1.]
- self.assertRaises(Exception,m.are2DCellsNotCorrectlyOriented,vec,False);
+ self.assertRaises(InterpKernelException,m.are2DCellsNotCorrectlyOriented,vec,False);
m.changeSpaceDimension(3);
res1=m.are2DCellsNotCorrectlyOriented(vec,False);
self.assertTrue(len(res1)==0);
center=[0.,0.,0.]
vector=[0.,1.,0.]
m4.rotate(center,vector,-pi/2.);
- m5=m3.buildExtrudedMeshFromThis(m4,0);
+ m5=m3.buildExtrudedMesh(m4,0);
res1=m5.arePolyhedronsNotCorrectlyOriented();
self.assertEqual(15,len(res1));
m5.orientCorrectlyPolyhedrons();
#Third test : cell permutation by keeping the first the middle and the last as it is.
renum=[0,2,1,3,4,5,6,8,7,9]
mesh2.renumberCells(renum,False);
- self.assertRaises(Exception,mesh1.checkGeoEquivalWith,mesh2,0,1e-12);#deepEqual fails
+ self.assertRaises(InterpKernelException,mesh1.checkGeoEquivalWith,mesh2,0,1e-12);#deepEqual fails
self.assertTrue(cellCor==None);
self.assertTrue(nodeCor==None);
cellCor,nodeCor=mesh1.checkGeoEquivalWith(mesh2,1,1e-12);#fastEqual do not see anything
mesh2.renumberNodes(renum2,11);
cellCor=None
nodeCor=None
- self.assertRaises(Exception,mesh1.checkGeoEquivalWith,mesh2,0,1e-12);#deepEqual fails
+ self.assertRaises(InterpKernelException,mesh1.checkGeoEquivalWith,mesh2,0,1e-12);#deepEqual fails
self.assertTrue(cellCor==None);
self.assertTrue(nodeCor==None);
cellCor,nodeCor=mesh1.checkGeoEquivalWith(mesh2,1,1e-12);#fastEqual do not see anything
mesh2.renumberNodes(renum2,11);
cellCor=None
nodeCor=None
- self.assertRaises(Exception,mesh1.checkGeoEquivalWith,mesh2,0,1e-12)
+ self.assertRaises(InterpKernelException,mesh1.checkGeoEquivalWith,mesh2,0,1e-12)
self.assertTrue(cellCor==None);
self.assertTrue(nodeCor==None);
- self.assertRaises(Exception,mesh1.checkGeoEquivalWith,mesh2,1,1e-12)
+ self.assertRaises(InterpKernelException,mesh1.checkGeoEquivalWith,mesh2,1,1e-12)
self.assertTrue(cellCor==None);
self.assertTrue(nodeCor==None);
cellCor,nodeCor=mesh2.checkGeoEquivalWith(mesh1,10,1e-12);#deepEqual with geo permutations
a1.fillWithZero();
a1.setInfoOnComponent(0,"c");
a1.setInfoOnComponent(1,"d");
- a2=a1.deepCopy();
+ a2=a1.deepCpy();
a2.setInfoOnComponent(0,"e");
a2.setInfoOnComponent(1,"f");
f.setArray(a1);
#self.assertTrue(m.getCoords()==m2.getCoords());
self.assertTrue(m2.isEqual(m,1e-12));
renum1=[1,2,0,5,8,7,4,3,6]
- m.renumberNodes(renum1,9);
+ r1=DataArrayInt.New()
+ r1.setValues(renum1,len(renum1),1)
+ m.renumberNodes(r1,9);
#self.assertTrue(m.getCoords()!=m2.getCoords());
self.assertTrue(not m2.isEqual(m,1e-12));
m.tryToShareSameCoordsPermute(m2,1e-12);
self.assertAlmostEqual(expected1[i],f1.getIJ(i,0),12);
pass
self.assertAlmostEqual(expected1[0],f2.getIJ(0,0),12);
- self.assertRaises(Exception,m1.tryToShareSameCoordsPermute,m2,1e-12);# <- here in this order the sharing is impossible.
+ self.assertRaises(InterpKernelException,m1.tryToShareSameCoordsPermute,m2,1e-12);# <- here in this order the sharing is impossible.
# Let's go for deeper test of tryToShareSameCoordsPermute
m2.tryToShareSameCoordsPermute(m1,1e-12);
f1=m1.getMeasureField(False);
1.2,2.3,3.4,4.5,5.6,6.7, 1.2,2.3,3.4,4.5,5.6,6.7, 1.2,2.3,3.4,4.5,5.6,6.7, 1.2,2.3,3.4,4.5,5.6,6.7]
array.setValues(arr2,mesh1.getNumberOfNodes(),6);
f1.setArray(array);
- self.assertRaises(Exception,f1.checkCoherency);#no end array specified !
+ self.assertRaises(InterpKernelException,f1.checkCoherency);#no end array specified !
#
f2=f1.determinant();
self.assertEqual(LINEAR_TIME,f2.getTimeDiscretization());
self.assertTrue(not mesh1.isEqual(mesh2,1e-12));
self.assertTrue(mesh1.isEqualWithoutConsideringStr(mesh2,1e-12));
da1,da2=mesh1.checkGeoEquivalWith(mesh2,2,1e-12);
- self.assertRaises(Exception,mesh1.checkGeoEquivalWith,mesh2,0,1e-12);
+ self.assertRaises(InterpKernelException,mesh1.checkGeoEquivalWith,mesh2,0,1e-12);
mesh2.setName("");
self.assertTrue(mesh1.isEqual(mesh2,1e-12));
self.assertTrue(mesh1.isEqualWithoutConsideringStr(mesh2,1e-12));
def testFillFromAnalytic3(self):
m=MEDCouplingDataForTest.build2DTargetMesh_1()
f1=MEDCouplingFieldDouble.New(ON_CELLS,ONE_TIME)
- self.assertRaises(Exception,f1.fillFromAnalytic,1,"y+x");
+ self.assertRaises(InterpKernelException,f1.fillFromAnalytic,1,"y+x");
f1.setMesh(m)
f1.setName("myField");
f1.fillFromAnalytic(1,"y+x");
#
f1=MEDCouplingFieldDouble.New(ON_NODES,NO_TIME);
f1.setMesh(m);
- self.assertRaises(Exception,f1.fillFromAnalytic,1,"1./(x-0.2)");
+ self.assertRaises(InterpKernelException,f1.fillFromAnalytic,1,"1./(x-0.2)");
pass
def testFieldDoubleOpEqual1(self):
m=MEDCouplingDataForTest.build2DTargetMesh_1();
f1=MEDCouplingFieldDouble.New(ON_CELLS,ONE_TIME);
- self.assertRaises(Exception,f1.assign,0.07);
+ self.assertRaises(InterpKernelException,f1.assign,0.07);
f1.setMesh(m);
f1.assign(0.07);
f1.checkCoherency();
m3_1=m2.buildPartOfMySelf(cells1,True);
m3=m3_1;
m4=MEDCouplingDataForTest.build2DSourceMesh_1();
- m5=MEDCouplingUMesh.mergeUMeshes(m1,m3);
- m6=MEDCouplingUMesh.mergeUMeshes(m5,m4);
+ m5=MEDCouplingUMesh.MergeUMeshes(m1,m3);
+ m6=MEDCouplingUMesh.MergeUMeshes(m5,m4);
#
self.assertEqual(10,m6.getNumberOfCells());
self.assertEqual(22,m6.getNumberOfNodes());
pos1=[5.,30.,2.]
self.assertEqual(16,m.getCellContainingPoint(pos1,1e-12));
#
- elems=m2.giveElemsInBoundingBox([3.5,6.,12.2,25.,0.,1.5],1e-7)
+ elems=m2.getCellsInBoundingBox([3.5,6.,12.2,25.,0.,1.5],1e-7)
self.assertEqual([1, 2, 4, 5, 7, 8, 10, 11, 13, 14, 16, 17],elems)
#
pt=[2.4,12.7,-3.4]
1.2,2.3,3.4,4.5,5.6,6.7, 1.2,2.3,3.4,4.5,5.6,6.7, 1.2,2.3,3.4,4.5,5.6,6.7, 1.2,2.3,3.4,4.5,5.6,6.7]
array.setValues(arr2,mesh1.getNumberOfNodes(),6);
f1.setArray(array);
- self.assertRaises(Exception,f1.checkCoherency);#no end array specified !
+ self.assertRaises(InterpKernelException,f1.checkCoherency);#no end array specified !
#
f2=f1.determinant();
self.assertEqual(LINEAR_TIME,f2.getTimeDiscretization());
arr1=[1.,2.,3.,4., 11.,12.,13.,14., 21.,22.,23.,24., 31.,32.,33.,34., 41.,42.,43.,44.]
a1=DataArrayDouble.New();
a1.setValues(arr1,5,4);
+ expp=[21.,22.,23.,24.]
+ self.assertEqual(4,len(a1.getTuple(2)));
+ for i in xrange(4):
+ self.assertAlmostEqual(expp[i],a1.getTuple(2)[i],12)
+ pass
a1.setInfoOnComponent(0,"aaaa");
a1.setInfoOnComponent(1,"bbbb");
a1.setInfoOnComponent(2,"cccc");
self.assertAlmostEqual(expected1[i],a2.getIJ(0,i),14);
pass
a3=a1.convertToIntArr();
+ self.assertEqual([21,22,23,24],a3.getTuple(2))
a4=a3.keepSelectedComponents(arr2V);
self.assertEqual(6,a4.getNumberOfComponents());
self.assertEqual(5,a4.getNumberOfTuples());
arr5V=[2,3,6]
arr6V=[2,7,5]
arr7V=[2,1,4,6]
- self.assertRaises(Exception,a2.keepSelectedComponents,arr5V);
- self.assertRaises(Exception,a2.keepSelectedComponents,arr6V);
- self.assertRaises(Exception,a2.setSelectedComponents,a1,arr7V);
+ self.assertRaises(InterpKernelException,a2.keepSelectedComponents,arr5V);
+ self.assertRaises(InterpKernelException,a2.keepSelectedComponents,arr6V);
+ self.assertRaises(InterpKernelException,a2.setSelectedComponents,a1,arr7V);
arr7V=arr7V[0:3]
- self.assertRaises(Exception,a2.setSelectedComponents,a1,arr7V);
+ self.assertRaises(InterpKernelException,a2.setSelectedComponents,a1,arr7V);
#
pass
tmp=DataArrayDouble.New();
vals=[0.2,0.2,0.1,0.2,0.2,0.2]
tmp.setValues(vals,3,2);
- tmp2=DataArrayDouble.aggregate(coords,tmp);
+ tmp2=DataArrayDouble.Aggregate(coords,tmp);
mesh.setCoords(tmp2);
pts=[0.2,0.2,0.1,0.3,-0.3,0.7]
c=mesh.getNodeIdsNearPoint(pts,1e-7);
self.assertEqual([4,9,11],c);
c,cI=mesh.getNodeIdsNearPoints(pts,3,1e-7);
- self.assertEqual([0,3,3,4],cI);
- self.assertEqual([4,9,11,6],c);
+ self.assertEqual([0,3,3,4],cI.getValues());
+ self.assertEqual([4,9,11,6],c.getValues());
pass
def testFieldCopyTinyAttrFrom1(self):
g=f.getCoords().applyFunc(2,"3.5*IVec+x/6*3.14159265359*JVec");
h=g.fromPolarToCart();
f.setCoords(h);
- i=c.buildExtrudedMeshFromThis(f,1);
+ i=c.buildExtrudedMesh(f,1);
self.assertEqual(52,i.getNumberOfNodes());
tmp,tmp2,tmp3=i.mergeNodes(1e-9);
self.assertTrue(tmp2);
#
center=[0.,0.]
f.rotate(center,[],pi/3);
- g=c.buildExtrudedMeshFromThis(f,0);
+ g=c.buildExtrudedMesh(f,0);
g.checkCoherency();
expected1=[ 0.4330127018922193, 0.4330127018922193, 0.649519052838329, 1.2990381056766578, 1.299038105676658, 1.948557158514987, 2.1650635094610955, 2.1650635094610964, 3.2475952641916446, 3.031088913245533, 3.0310889132455352, 4.546633369868303 ]
f1=g.getMeasureField(True);
g=f.getCoords().applyFunc(2,"3.5*IVec+x/6*3.14159265359*JVec");
h=g.fromPolarToCart();
f.setCoords(h);
- i=c.buildExtrudedMeshFromThis(f,1);
+ i=c.buildExtrudedMesh(f,1);
self.assertEqual(52,i.getNumberOfNodes());
tmp,tmp2,tmp3=i.mergeNodes(1e-9);
self.assertTrue(tmp2);
g2=h.applyFunc(3,"13.5/3.5*x*IVec+0*JVec+13.5/3.5*y*KVec");
f.setCoords(g2);
i.changeSpaceDimension(3);
- i3=i.buildExtrudedMeshFromThis(f,1);
+ i3=i.buildExtrudedMesh(f,1);
f2=i3.getMeasureField(True);
tmp,tmp2,tmp3=i.mergeNodes(1e-9);
self.assertTrue(tmp2);
pass
#
pass
+
+ def testDAMeld1(self):
+ da1=DataArrayDouble.New();
+ da1.alloc(7,2);
+ da2=DataArrayDouble.New();
+ da2.alloc(7,1);
+ #
+ da1.fillWithValue(7.);
+ da2.iota(0.);
+ da3=da2.applyFunc(3,"10*x*IVec+100*x*JVec+1000*x*KVec");
+ #
+ da1.setInfoOnComponent(0,"c0da1");
+ da1.setInfoOnComponent(1,"c1da1");
+ da3.setInfoOnComponent(0,"c0da3");
+ da3.setInfoOnComponent(1,"c1da3");
+ da3.setInfoOnComponent(2,"c2da3");
+ #
+ da1C=da1.deepCpy();
+ da1.meldWith(da3);
+ self.assertEqual(5,da1.getNumberOfComponents());
+ self.assertEqual(7,da1.getNumberOfTuples());
+ self.assertTrue(da1.getInfoOnComponent(0)=="c0da1");
+ self.assertTrue(da1.getInfoOnComponent(1)=="c1da1");
+ self.assertTrue(da1.getInfoOnComponent(2)=="c0da3");
+ self.assertTrue(da1.getInfoOnComponent(3)=="c1da3");
+ self.assertTrue(da1.getInfoOnComponent(4)=="c2da3");
+ #
+ expected1=[7.,7.,0.,0.,0., 7.,7.,10.,100.,1000., 7.,7.,20.,200.,2000., 7.,7.,30.,300.,3000., 7.,7.,40.,400.,4000.,7.,7.,50.,500.,5000.,7.,7.,60.,600.,6000.]
+ for i in xrange(35):
+ self.assertAlmostEqual(expected1[i],da1.getIJ(0,i),10);
+ pass
+ #
+ dai1=da1C.convertToIntArr();
+ dai3=da3.convertToIntArr();
+ dai1.meldWith(dai3);
+ self.assertEqual(5,dai1.getNumberOfComponents());
+ self.assertEqual(7,dai1.getNumberOfTuples());
+ self.assertTrue(dai1.getInfoOnComponent(0)=="c0da1");
+ self.assertTrue(dai1.getInfoOnComponent(1)=="c1da1");
+ self.assertTrue(dai1.getInfoOnComponent(2)=="c0da3");
+ self.assertTrue(dai1.getInfoOnComponent(3)=="c1da3");
+ self.assertTrue(dai1.getInfoOnComponent(4)=="c2da3");
+ for i in xrange(35):
+ self.assertEqual(int(expected1[i]),dai1.getIJ(0,i));
+ pass
+ # test of static method DataArrayDouble::meld
+ da4=DataArrayDouble.Meld(da1C,da3);
+ tmp=DataArrayDouble.Meld([da1C,da3]);
+ self.assertTrue(da4.isEqual(tmp,1e-10))
+ self.assertEqual(5,da4.getNumberOfComponents());
+ self.assertEqual(7,da4.getNumberOfTuples());
+ self.assertTrue(da4.getInfoOnComponent(0)=="c0da1");
+ self.assertTrue(da4.getInfoOnComponent(1)=="c1da1");
+ self.assertTrue(da4.getInfoOnComponent(2)=="c0da3");
+ self.assertTrue(da4.getInfoOnComponent(3)=="c1da3");
+ self.assertTrue(da4.getInfoOnComponent(4)=="c2da3");
+ for i in xrange(35):
+ self.assertAlmostEqual(expected1[i],da4.getIJ(0,i),10);
+ pass
+ # test of static method DataArrayInt::meld
+ dai1=da1C.convertToIntArr();
+ dai4=DataArrayInt.Meld(dai1,dai3);
+ tmp=DataArrayInt.Meld([dai1,dai3]);
+ self.assertTrue(dai4.isEqual(tmp))
+ self.assertEqual(5,dai4.getNumberOfComponents());
+ self.assertEqual(7,dai4.getNumberOfTuples());
+ self.assertTrue(dai4.getInfoOnComponent(0)=="c0da1");
+ self.assertTrue(dai4.getInfoOnComponent(1)=="c1da1");
+ self.assertTrue(dai4.getInfoOnComponent(2)=="c0da3");
+ self.assertTrue(dai4.getInfoOnComponent(3)=="c1da3");
+ self.assertTrue(dai4.getInfoOnComponent(4)=="c2da3");
+ for i in xrange(35):
+ self.assertEqual(int(expected1[i]),dai4.getIJ(0,i));
+ pass
+ pass
+
+ def testFieldMeld1(self):
+ m=MEDCouplingDataForTest.build3DSurfTargetMesh_1();
+ f1=MEDCouplingFieldDouble.New(ON_CELLS,ONE_TIME);
+ f1.setMesh(m);
+ da1=DataArrayDouble.New();
+ arr1=[12.,23.,34.,45.,56.]
+ da1.setValues(arr1,5,1);
+ da1.setInfoOnComponent(0,"aaa");
+ f1.setArray(da1);
+ f1.setTime(3.4,2,1);
+ f1.checkCoherency();
+ #
+ f2=f1.deepCpy();
+ f2.setMesh(f1.getMesh());
+ f2.checkCoherency();
+ f2.changeNbOfComponents(2,5.);
+ f2.assign(5.);
+ f2.getArray().setInfoOnComponent(0,"bbb");
+ f2.getArray().setInfoOnComponent(1,"ccc");
+ f2.checkCoherency();
+ #
+ f3=MEDCouplingFieldDouble.MeldFields(f2,f1);
+ f3.checkCoherency();
+ self.assertEqual(5,f3.getNumberOfTuples());
+ self.assertEqual(3,f3.getNumberOfComponents());
+ self.assertTrue(f3.getArray().getInfoOnComponent(0)=="bbb");
+ self.assertTrue(f3.getArray().getInfoOnComponent(1)=="ccc");
+ self.assertTrue(f3.getArray().getInfoOnComponent(2)=="aaa");
+ expected1=[5.,5.,12.,5.,5.,23.,5.,5.,34.,5.,5.,45.,5.,5.,56.]
+ for i in xrange(15):
+ self.assertAlmostEqual(expected1[i],f3.getIJ(0,i),12);
+ pass
+ time,dt,it=f3.getTime();
+ self.assertAlmostEqual(3.4,time,14);
+ self.assertEqual(2,dt);
+ self.assertEqual(1,it);
+ #
+ f4=f2.buildNewTimeReprFromThis(NO_TIME,False);
+ f5=f1.buildNewTimeReprFromThis(NO_TIME,False);
+ f6=MEDCouplingFieldDouble.MeldFields(f4,f5);
+ f6.checkCoherency();
+ self.assertEqual(5,f6.getNumberOfTuples());
+ self.assertEqual(3,f6.getNumberOfComponents());
+ self.assertTrue(f6.getArray().getInfoOnComponent(0)=="bbb");
+ self.assertTrue(f6.getArray().getInfoOnComponent(1)=="ccc");
+ self.assertTrue(f6.getArray().getInfoOnComponent(2)=="aaa");
+ for i in xrange(15):
+ self.assertAlmostEqual(expected1[i],f6.getIJ(0,i),12);
+ pass
+ #
+ pass
+
+ def testMergeNodes2(self):
+ m1=MEDCouplingDataForTest.build2DTargetMesh_1();
+ m2=MEDCouplingDataForTest.build2DTargetMesh_1();
+ vec=[0.002,0.]
+ m2.translate(vec);
+ #
+ m3=MEDCouplingUMesh.MergeUMeshes([m1,m2]);
+ da,b,newNbOfNodes=m3.mergeNodes2(0.01);
+ self.assertEqual(9,m3.getNumberOfNodes());
+ expected1=[-0.299,-0.3, 0.201,-0.3, 0.701,-0.3, -0.299,0.2, 0.201,0.2, 0.701,0.2, -0.299,0.7, 0.201,0.7, 0.701,0.7]
+ for i in xrange(18):
+ self.assertAlmostEqual(expected1[i],m3.getCoords().getIJ(0,i),13);
+ pass
+ #
+ pass
+
+ def testMergeField2(self):
+ m=MEDCouplingDataForTest.build2DTargetMesh_1();
+ f1=MEDCouplingFieldDouble.New(ON_CELLS,ONE_TIME);
+ f1.setMesh(m);
+ arr=DataArrayDouble.New();
+ arr.alloc(5,2);
+ arr.fillWithValue(2.);
+ f1.setArray(arr);
+ f2=MEDCouplingFieldDouble.New(ON_CELLS,ONE_TIME);
+ f2.setMesh(m);
+ arr=DataArrayDouble.New();
+ arr.alloc(5,2);
+ arr.fillWithValue(5.);
+ f2.setArray(arr);
+ f3=MEDCouplingFieldDouble.New(ON_CELLS,ONE_TIME);
+ f3.setMesh(m);
+ arr=DataArrayDouble.New();
+ arr.alloc(5,2);
+ arr.fillWithValue(7.);
+ f3.setArray(arr);
+ #
+ f4=MEDCouplingFieldDouble.MergeFields([f1,f2,f3]);
+ self.assertEqual(15,f4.getMesh().getNumberOfCells());
+ expected1=[2.,2.,2.,2.,2.,2.,2.,2.,2.,2., 5.,5.,5.,5.,5.,5.,5.,5.,5.,5., 7.,7.,7.,7.,7.,7.,7.,7.,7.,7.]
+ for i in xrange(30):
+ self.assertAlmostEqual(expected1[i],f4.getIJ(0,i),13);
+ pass
+ #
+ pass
+
+ def testDAIBuildComplement1(self):
+ a=DataArrayInt.New();
+ tab=[3,1,7,8]
+ a.setValues(tab,4,1);
+ b=a.buildComplement(12);
+ self.assertEqual(8,b.getNumberOfTuples());
+ self.assertEqual(1,b.getNumberOfComponents());
+ expected1=[0,2,4,5,6,9,10,11]
+ for i in xrange(8):
+ self.assertEqual(expected1[i],b.getIJ(0,i));
+ pass
+ pass
+
+ def testDAIBuildUnion1(self):
+ a=DataArrayInt.New();
+ tab1=[3,1,7,8]
+ a.setValues(tab1,4,1);
+ c=DataArrayInt.New();
+ tab2=[5,3,0,18,8]
+ c.setValues(tab2,5,1);
+ b=a.buildUnion(c);
+ self.assertEqual(7,b.getNumberOfTuples());
+ self.assertEqual(1,b.getNumberOfComponents());
+ expected1=[0,1,3,5,7,8,18]
+ for i in xrange(7):
+ self.assertEqual(expected1[i],b.getIJ(0,i));
+ pass
+ b=DataArrayInt.BuildUnion([a,c]);
+ self.assertEqual(7,b.getNumberOfTuples());
+ self.assertEqual(1,b.getNumberOfComponents());
+ expected1=[0,1,3,5,7,8,18]
+ for i in xrange(7):
+ self.assertEqual(expected1[i],b.getIJ(0,i));
+ pass
+ pass
+
+ def testDAIBuildIntersection1(self):
+ a=DataArrayInt.New();
+ tab1=[3,1,7,8]
+ a.setValues(tab1,4,1);
+ c=DataArrayInt.New();
+ tab2=[5,3,0,18,8]
+ c.setValues(tab2,5,1);
+ b=a.buildIntersection(c);
+ self.assertEqual(2,b.getNumberOfTuples());
+ self.assertEqual(1,b.getNumberOfComponents());
+ expected1=[3,8]
+ for i in xrange(2):
+ self.assertEqual(expected1[i],b.getIJ(0,i));
+ pass
+ b=DataArrayInt.BuildIntersection([a,c]);
+ self.assertEqual(2,b.getNumberOfTuples());
+ self.assertEqual(1,b.getNumberOfComponents());
+ expected1=[3,8]
+ for i in xrange(2):
+ self.assertEqual(expected1[i],b.getIJ(0,i));
+ pass
+ pass
+
+ def testDAIDeltaShiftIndex1(self):
+ a=DataArrayInt.New();
+ tab=[1,3,6,7,7,9,15]
+ a.setValues(tab,7,1);
+ b=a.deltaShiftIndex();
+ self.assertEqual(6,b.getNumberOfTuples());
+ self.assertEqual(1,b.getNumberOfComponents());
+ expected1=[2,3,1,0,2,6]
+ for i in xrange(6):
+ self.assertEqual(expected1[i],b.getIJ(0,i));
+ pass
+ pass
+
+ def testDaDoubleSelectByTupleIdSafe1(self):
+ a=DataArrayDouble.New();
+ arr1=[1.1,11.1,2.1,12.1,3.1,13.1,4.1,14.1,5.1,15.1,6.1,16.1,7.1,17.1]
+ a.setValues(arr1,7,2);
+ a.setInfoOnComponent(0,"toto");
+ a.setInfoOnComponent(1,"tata");
+ #
+ arr2=[4,2,0,6,5]
+ b=a.selectByTupleIdSafe(arr2);
+ self.assertEqual(5,b.getNumberOfTuples());
+ self.assertEqual(2,b.getNumberOfComponents());
+ self.assertTrue(b.getInfoOnComponent(0)=="toto");
+ self.assertTrue(b.getInfoOnComponent(1)=="tata");
+ expected1=[5.1,15.1,3.1,13.1,1.1,11.1,7.1,17.1,6.1,16.1]
+ for i in xrange(10):
+ self.assertAlmostEqual(expected1[i],b.getIJ(0,i),14);
+ pass
+ arr4=[4,-1,0,6,5]
+ self.assertRaises(InterpKernelException,a.selectByTupleIdSafe,arr4);
+ arr5=[4,2,0,6,7]
+ self.assertRaises(InterpKernelException,a.selectByTupleIdSafe,arr5);
+ #
+ c=DataArrayInt.New();
+ arr3=[1,11,2,12,3,13,4,14,5,15,6,16,7,17]
+ c.setValues(arr3,7,2);
+ c.setInfoOnComponent(0,"toto");
+ c.setInfoOnComponent(1,"tata");
+ d=c.selectByTupleIdSafe(arr2);
+ self.assertEqual(5,d.getNumberOfTuples());
+ self.assertEqual(2,d.getNumberOfComponents());
+ self.assertTrue(d.getInfoOnComponent(0)=="toto");
+ self.assertTrue(d.getInfoOnComponent(1)=="tata");
+ expected2=[5,15,3,13,1,11,7,17,6,16]
+ for i in xrange(10):
+ self.assertEqual(expected2[i],d.getIJ(0,i));
+ pass
+ self.assertRaises(InterpKernelException,c.selectByTupleIdSafe,arr4);
+ self.assertRaises(InterpKernelException,c.selectByTupleIdSafe,arr5);
+ pass
+
+ def testAreCellsIncludedIn1(self):
+ m=MEDCouplingDataForTest.build3DSurfTargetMesh_1();
+ pt=[1,3]
+ m2=m.buildPartOfMySelf(pt,True);
+ ret,tmp=m.areCellsIncludedIn(m2,0)
+ self.assertTrue(ret);
+ self.assertEqual(2,tmp.getNumberOfTuples());
+ self.assertEqual(1,tmp.getNumberOfComponents());
+ self.assertEqual(pt[0],tmp.getIJ(0,0));
+ self.assertEqual(pt[1],tmp.getIJ(0,1));
+ ret,tmp=m2.areCellsIncludedIn(m,0)
+ self.assertTrue(not ret);
+ pass
+
+ def testSwigErrorProtection1(self):
+ m=MEDCouplingDataForTest.build3DTargetMesh_1();
+ m.rotate([0.,0.,0.],[0.3,0.6,1.2],0.37)
+ m.rotate([0.,0.,0.],[0.3,6,1.2],0.37)
+ self.assertRaises(InterpKernelException,m.rotate,[0.,0.,0.],(0.3,6,"1.2"),0.37)
+ self.assertRaises(InterpKernelException,m.rotate,[0.,"0.",0.],[0.3,0.6,1.2],0.37)
+ self.assertRaises(InterpKernelException,m.rotate,[0.,0.,0.],[0.3,'0.6',1.2],0.37)
+ m2=m.buildPartOfMySelf([2,5],True)
+ m3=m.buildPartOfMySelf((2,5),True)
+ self.assertTrue(m2.isEqual(m3,1e-12))
+ self.assertRaises(InterpKernelException,m.buildPartOfMySelf,[2,5.],True)
+ da1=m.getCoords().keepSelectedComponents([1])
+ da2=m.getCoords().keepSelectedComponents((1,))
+ self.assertTrue(da1.isEqual(da2,1e-12))
+ self.assertRaises(InterpKernelException,m.getCoords().keepSelectedComponents,["1"])
+ pass
+
+ def testDAIBuildSubstraction1(self):
+ a=DataArrayInt.New()
+ aa=[2,3,6,8,9]
+ a.setValues(aa,5,1)
+ b=DataArrayInt.New()
+ bb=[1,3,5,9,11]
+ b.setValues(bb,5,1)
+ self.assertEqual([2,6,8],a.buildSubstraction(b).getValues())
+ pass
+
+ def testBuildOrthogonalField2(self):
+ m=MEDCouplingDataForTest.build2DTargetMesh_1();
+ d1=DataArrayInt.New();
+ d2=DataArrayInt.New();
+ d3=DataArrayInt.New();
+ d4=DataArrayInt.New();
+ m1=m.buildDescendingConnectivity(d1,d2,d3,d4);
+ #
+ f1=m1.buildOrthogonalField();
+ da1=f1.getArray();
+ self.assertEqual(2,da1.getNumberOfComponents());
+ self.assertEqual(13,da1.getNumberOfTuples());
+ #
+ expected1=[-1.,0.,0.,1.,1.,0.,0.,-1.,0.707106781186548,0.707106781186548,0.,-1.,0.,1.,1.,0.,0.,1.,1.,0.,-1.,0.,0.,1.,1.,0.];
+ for i in xrange(26):
+ self.assertAlmostEqual(expected1[i],da1.getIJ(0,i),14);
+ pass
+ pass
+
+ def testSwigErrorProtection2(self):
+ m=MEDCouplingDataForTest.build2DTargetMesh_1();
+ coo=m.getCoords()
+ c=m.getNodalConnectivity()
+ ci=m.getNodalConnectivityIndex()
+ del m
+ self.assertEqual(2,coo.getNumberOfComponents());
+ self.assertEqual(6,ci.getNumberOfTuples());
+ self.assertEqual(23,c.getNumberOfTuples());
+ m=MEDCouplingDataForTest.build2DTargetMesh_1();
+ f=m.getMeasureField(True)
+ c=f.getArray()
+ del f
+ self.assertEqual(1,c.getNumberOfComponents());
+ m=MEDCouplingCMesh.New()
+ x=DataArrayDouble.New()
+ x.setValues([1.,2.,4.],3,1)
+ m.setCoordsAt(0,x)
+ del x
+ xx=m.getCoordsAt(0)
+ del m
+ self.assertEqual(3,xx.getNumberOfTuples());
+ #
+ m=MEDCouplingDataForTest.build2DTargetMesh_1();
+ f=m.getMeasureField(True)
+ m2=f.getMesh()
+ del m
+ del f
+ self.assertEqual(5,m2.getNumberOfCells());
+ pass
+
+ def testUMInsertNextCell1(self):
+ 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();
+ targetMesh.allocateCells(5);
+ self.assertRaises(InterpKernelException,targetMesh.insertNextCell,NORM_QUAD4,4,targetConn[0:4])
+ targetMesh.setMeshDimension(2);
+ targetMesh.insertNextCell(NORM_QUAD4,4,targetConn[0:4])
+ self.assertRaises(InterpKernelException,targetMesh.insertNextCell,NORM_TETRA4,4,targetConn[0:4])
+ self.assertRaises(InterpKernelException,targetMesh.insertNextCell,NORM_SEG2,2,targetConn[0:2])
+ self.assertRaises(InterpKernelException,targetMesh.insertNextCell,NORM_POINT1,1,targetConn[0:1])
+ targetMesh.insertNextCell(NORM_TRI3,3,targetConn[4:7])
+ targetMesh.insertNextCell(NORM_TRI3,3,targetConn[7:10])
+ targetMesh.insertNextCell(NORM_QUAD4,4,targetConn[10:14])
+ targetMesh.insertNextCell(NORM_QUAD4,4,targetConn[14:18])
+ targetMesh.finishInsertingCells();
+ myCoords=DataArrayDouble.New();
+ myCoords.setValues(targetCoords,9,2);
+ targetMesh.setCoords(myCoords);
+ targetMesh.checkCoherency();
+ pass
+
+ def testFieldOperatorDivDiffComp1(self):
+ m=MEDCouplingDataForTest.build2DTargetMesh_1();
+ m1,d0,d1,d2,d3=m.buildDescendingConnectivity();
+ #
+ f1=m1.buildOrthogonalField();
+ arr1=[2.,3.,4.,5.,6.,7.,8.,9.,10.,11.,12.,13.,14.]
+ arr=DataArrayDouble.New();
+ arr.setValues(arr1,13,1);
+ f2=MEDCouplingFieldDouble.New(ON_CELLS);
+ f2.setArray(arr);
+ f2.setMesh(m1);
+ f2.checkCoherency();
+ #
+ f3=f1/f2;
+ self.assertRaises(InterpKernelException,f2.__div__,f1)
+ f3.checkCoherency();
+ f1/=f2;
+ #self.assertRaises(InterpKernelException,f2.__idiv__,f1) # mem leaks
+ self.assertTrue(f1.isEqual(f3,1e-10,1e-10));
+ expected1=[-0.5, 0.0, 0.0, 0.33333333333333331, 0.25, 0.0, 0.0, -0.20000000000000001, 0.117851130197758, 0.117851130197758, 0.0, -0.14285714285714285, 0.0, 0.125, 0.1111111111111111, 0.0, 0.0, 0.10000000000000001, 0.090909090909090912, 0.0, -0.083333333333333329, 0.0, 0.0, 0.076923076923076927, 0.071428571428571425, 0.0]
+ for i in xrange(26):
+ self.assertAlmostEqual(expected1[i],f3.getIJ(0,i),10);
+ pass
+ pass
+
+ def testDARearrange1(self):
+ da1=DataArrayInt.New();
+ da1.alloc(12,1);
+ da1.iota(0);
+ #
+ self.assertEqual(12,da1.getNbOfElems());
+ self.assertEqual(1,da1.getNumberOfComponents());
+ self.assertEqual(12,da1.getNumberOfTuples());
+ da1.rearrange(4);
+ self.assertEqual(12,da1.getNbOfElems());
+ self.assertEqual(4,da1.getNumberOfComponents());
+ self.assertEqual(3,da1.getNumberOfTuples());
+ for i in xrange(12):
+ self.assertEqual(i,da1.getIJ(0,i));
+ #
+ da1.rearrange(6);
+ self.assertEqual(12,da1.getNbOfElems());
+ self.assertEqual(6,da1.getNumberOfComponents());
+ self.assertEqual(2,da1.getNumberOfTuples());
+ for i in xrange(12):
+ self.assertEqual(i,da1.getIJ(0,i));
+ #
+ self.assertRaises(da1.rearrange(7),InterpKernelException);
+ #
+ da1.rearrange(12);
+ self.assertEqual(12,da1.getNbOfElems());
+ self.assertEqual(12,da1.getNumberOfComponents());
+ self.assertEqual(1,da1.getNumberOfTuples());
+ for i in xrange(12):
+ self.assertEqual(i,da1.getIJ(0,i));
+ #
+ da1.rearrange(3);
+ self.assertEqual(12,da1.getNbOfElems());
+ self.assertEqual(3,da1.getNumberOfComponents());
+ self.assertEqual(4,da1.getNumberOfTuples());
+ for i in xrange(12):
+ self.assertEqual(i,da1.getIJ(0,i));
+ #double
+ da2=da1.convertToDblArr();
+ #
+ self.assertEqual(12,da2.getNbOfElems());
+ self.assertEqual(3,da2.getNumberOfComponents());
+ self.assertEqual(4,da2.getNumberOfTuples());
+ da2.rearrange(4);
+ self.assertEqual(12,da2.getNbOfElems());
+ self.assertEqual(4,da2.getNumberOfComponents());
+ self.assertEqual(3,da2.getNumberOfTuples());
+ for i in xrange(12):
+ self.assertAlmostEqual(float(i),da2.getIJ(0,i),14);
+ #
+ da2.rearrange(6);
+ self.assertEqual(12,da2.getNbOfElems());
+ self.assertEqual(6,da2.getNumberOfComponents());
+ self.assertEqual(2,da2.getNumberOfTuples());
+ for i in xrange(12):
+ self.assertAlmostEqual(float(i),da2.getIJ(0,i),14);
+ #
+ self.assertRaises(da2.rearrange(7),InterpKernelException);
+ #
+ da2.rearrange(1);
+ self.assertTrue(ptr2==da2.getConstPointer());
+ self.assertEqual(12,da2.getNbOfElems());
+ self.assertEqual(1,da2.getNumberOfComponents());
+ self.assertEqual(12,da2.getNumberOfTuples());
+ for i in xrange(12):
+ self.assertAlmostEqual(float(i),da2.getIJ(0,i),14);
+ #
+ da2.rearrange(3);
+ self.assertEqual(12,da2.getNbOfElems());
+ self.assertEqual(3,da2.getNumberOfComponents());
+ self.assertEqual(4,da2.getNumberOfTuples());
+ for i in xrange(12):
+ self.assertAlmostEqual(float(i),da2.getIJ(0,i),14);
+ pass
+
+ def testDARearrange1(self):
+ da1=DataArrayInt.New();
+ arr=[1,2,3,2,2,3,5,1,5,5,2,2]
+ da1.setValues(arr,4,3);
+ s=da1.getDifferentValues(True);# API different from C++ because SWIG complains...
+ expected1=[1,2,3,5]
+ self.assertEqual(expected1,s);
+ pass
+
+ def testSwigErrorProtection3(self):
+ da=DataArrayInt.New()
+ da.setValues([1,2,3,4],4,3)
+ self.assertEqual([1, 2, 3, 4, 0, 0, 0, 0, 0, 0, 0, 0],da.getValues())
+ self.assertEqual(3,da.getNumberOfComponents());
+ self.assertEqual(4,da.getNumberOfTuples());
+ da=DataArrayInt.New()
+ da.setValues((1,2,3,4,4,3),4,3)
+ self.assertEqual([1, 2, 3, 4, 4, 3, 0, 0, 0, 0, 0, 0],da.getValues())
+ self.assertEqual(3,da.getNumberOfComponents());
+ self.assertEqual(4,da.getNumberOfTuples());
+ da.setValues(10*[1]+290*[2],4,3)
+ self.assertEqual(10*[1]+[2,2],da.getValues())
+ self.assertEqual(3,da.getNumberOfComponents());
+ self.assertEqual(4,da.getNumberOfTuples());
+ #
+ da=DataArrayDouble.New()
+ da.setValues([1,2,3.,4],4,3)
+ self.assertEqual([1., 2., 3., 4., 0., 0., 0., 0., 0., 0., 0., 0.],da.getValues())
+ self.assertEqual(3,da.getNumberOfComponents());
+ self.assertEqual(4,da.getNumberOfTuples());
+ da=DataArrayDouble.New()
+ da.setValues((1,2,3,4.,4,3),4,3)
+ self.assertEqual([1., 2., 3., 4., 4., 3., 0., 0., 0., 0., 0., 0.],da.getValues())
+ self.assertEqual(3,da.getNumberOfComponents());
+ self.assertEqual(4,da.getNumberOfTuples());
+ da.setValues(10*[1]+290*[2],4,3)
+ self.assertEqual(10*[1.]+[2.,2.],da.getValues())
+ self.assertEqual(3,da.getNumberOfComponents());
+ self.assertEqual(4,da.getNumberOfTuples());
+ pass
+
+ def testDAIBuildPermutationArr1(self):
+ a=DataArrayInt.New()
+ a.setValues([4,5,6,7,8],5,1)
+ b=DataArrayInt.New()
+ b.setValues([5,4,8,6,7],5,1)
+ c=a.buildPermutationArr(b)
+ self.assertEqual([1,0,4,2,3],c.getValues())
+ self.assertTrue(a.isEqualWithoutConsideringStrAndOrder(b))
+ b.setIJ(0,0,9)
+ self.assertTrue(not a.isEqualWithoutConsideringStrAndOrder(b))
+ self.assertRaises(InterpKernelException,a.buildPermutationArr,b)
+ a.setIJ(3,0,4)
+ b.setIJ(0,0,5)
+ b.setIJ(4,0,4)#a==[4,5,6,4,8] and b==[5,4,8,6,4]
+ self.assertTrue(a.isEqualWithoutConsideringStrAndOrder(b))
+ c=a.buildPermutationArr(b)
+ self.assertEqual([1,3,4,2,3],c.getValues())
+ d=b.convertToDblArr()
+ expect3=[4,4,5,6,8]
+ b.sort()
+ self.assertEqual(expect3,b.getValues())
+ d.sort()
+ self.assertEqual(5,d.getNumberOfTuples());
+ self.assertEqual(1,d.getNumberOfComponents());
+ for i in xrange(5):
+ self.assertAlmostEqual(float(expect3[i]),d.getIJ(i,0),14);
+ pass
+ pass
+
+ def testAreCellsIncludedIn2(self):
+ myName="Vitoo";
+ m=MEDCouplingDataForTest.build3DSurfTargetMesh_1();
+ m2=m.buildPartOfMySelf([],True);
+ self.assertEqual(0,m2.getNumberOfCells());
+ self.assertEqual(3,m2.getSpaceDimension());
+ self.assertEqual(2,m2.getMeshDimension());
+ m2.setName(myName);
+ test,tmp=m.areCellsIncludedIn(m2,0)
+ self.assertTrue(test);
+ self.assertEqual(myName,tmp.getName());
+ self.assertEqual(0,tmp.getNumberOfTuples())
+ self.assertEqual(1,tmp.getNumberOfComponents())
+ pass
+
+ def testUMeshGetPartBarycenterAndOwner1(self):
+ m1=MEDCouplingDataForTest.build2DTargetMesh_1();
+ part1=[1,0,4];
+ part=DataArrayInt.New();
+ part.setValues(part1,3,1);
+ b=m1.getPartBarycenterAndOwner(part);
+ self.assertEqual(2,b.getNumberOfComponents());
+ self.assertEqual(3,b.getNumberOfTuples());
+ expected1=[0.36666666666666665,-0.13333333333333333,-0.05,-0.05,0.45,0.45];
+ for i in xrange(6):
+ self.assertAlmostEqual(expected1[i],b.getIJ(0,i),14);
+ pass
+ pass
+
+ def testUMeshGetPartMeasureField1(self):
+ m1=MEDCouplingDataForTest.build2DTargetMesh_1();
+ part1=[1,0,4];
+ part=DataArrayInt.New();
+ part.setValues(part1,3,1);
+ b=m1.getPartMeasureField(True,part);
+ self.assertEqual(1,b.getNumberOfComponents());
+ self.assertEqual(3,b.getNumberOfTuples());
+ expected1=[0.125,0.25,0.25];
+ for i in xrange(3):
+ self.assertAlmostEqual(expected1[i],b.getIJ(0,i),14);
+ pass
+ pass
+
+ def testUMeshBuildPartOrthogonalField1(self):
+ m1=MEDCouplingDataForTest.build2DTargetMesh_1();
+ m1.changeSpaceDimension(3);
+ part1=[1,0,4];
+ part=DataArrayInt.New();
+ part.setValues(part1,3,1);
+ b=m1.buildPartOrthogonalField(part);
+ self.assertEqual(3,b.getArray().getNumberOfComponents());
+ self.assertEqual(3,b.getArray().getNumberOfTuples());
+ expected1=[0.,0.,-1.,0.,0.,-1.,0.,0.,-1.];
+ for i in xrange(9):
+ self.assertAlmostEqual(expected1[i],b.getArray().getIJ(0,i),14);
+ pass
+ pass
+
+ def testUMeshGetTypesOfPart1(self):
+ m1=MEDCouplingDataForTest.build2DTargetMesh_1();
+ part1=[0,3,4];
+ p1=DataArrayInt.New()
+ p1.setValues(part1,3,1)
+ s=m1.getTypesOfPart(p1);
+ self.assertEqual([NORM_QUAD4],s);
+ part2=[2,2,2,1];
+ p2=DataArrayInt.New()
+ p2.setValues(part2,4,1)
+ s=m1.getTypesOfPart(p2);
+ self.assertEqual([NORM_TRI3],s);
+ part3=[3,2,1];
+ p3=DataArrayInt.New()
+ p3.setValues(part3,3,1)
+ s=m1.getTypesOfPart(p3);
+ self.assertEqual(s,[NORM_TRI3,NORM_QUAD4]);
+ pass
+
+ def testUMeshKeepCellIdsByType1(self):
+ m1=MEDCouplingDataForTest.build2DTargetMesh_1();
+ part1=[0,3,4]
+ p1=DataArrayInt.New()
+ p1.setValues(part1,3,1)
+ p1.setName("p1")
+ a=m1.keepCellIdsByType(NORM_TRI3,p1);
+ self.assertEqual("p1",a.getName())
+ self.assertEqual(1,a.getNumberOfComponents());
+ self.assertEqual(0,a.getNumberOfTuples());
+ #
+ part2=[3,2,0,2,4]
+ p2=DataArrayInt.New()
+ p2.setValues(part2,5,1)
+ p2.setName("p2")
+ a=m1.keepCellIdsByType(NORM_TRI3,p2);
+ self.assertEqual("p2",a.getName())
+ self.assertEqual(1,a.getNumberOfComponents());
+ self.assertEqual(2,a.getNumberOfTuples());
+ self.assertEqual(2,a.getIJ(0,0));
+ self.assertEqual(2,a.getIJ(1,0));
+ #
+ a=m1.keepCellIdsByType(NORM_QUAD4,p2);
+ self.assertEqual("p2",a.getName())
+ self.assertEqual(1,a.getNumberOfComponents());
+ self.assertEqual(3,a.getNumberOfTuples());
+ self.assertEqual(3,a.getIJ(0,0));
+ self.assertEqual(0,a.getIJ(1,0));
+ self.assertEqual(4,a.getIJ(2,0));
+ pass
+
+ def testSwigErrorDaIntSelectByTupleId1(self):
+ a=DataArrayInt.New();
+ arr1=[1,11,2,12,3,13,4,14,5,15,6,16,7,17]
+ a.setValues(arr1,7,2);
+ a.setInfoOnComponent(0,"toto");
+ a.setInfoOnComponent(1,"tata");
+ #
+ arr2=[4,2,0,6,5]
+ b=a.selectByTupleId(arr2);
+ self.assertEqual(5,b.getNumberOfTuples());
+ self.assertEqual(2,b.getNumberOfComponents());
+ self.assertTrue(b.getInfoOnComponent(0)=="toto");
+ self.assertTrue(b.getInfoOnComponent(1)=="tata");
+ expected1=[5,15,3,13,1,11,7,17,6,16]
+ self.assertEqual(expected1,b.getValues())
+ #
+ a2=DataArrayInt.New()
+ a2.setValues(arr2,5,1)
+ b=a.selectByTupleId(a2);
+ self.assertEqual(5,b.getNumberOfTuples());
+ self.assertEqual(2,b.getNumberOfComponents());
+ self.assertTrue(b.getInfoOnComponent(0)=="toto");
+ self.assertTrue(b.getInfoOnComponent(1)=="tata");
+ expected1=[5,15,3,13,1,11,7,17,6,16]
+ self.assertEqual(expected1,b.getValues())
+ pass
+
+ def testSwigGetItem1(self):
+ da=DataArrayInt.New()
+ da.alloc(16,3)
+ da.rearrange(1)
+ da.iota(7)
+ da.rearrange(3)
+ da.setInfoOnComponent(0,"X [m]")
+ da.setInfoOnComponent(1,"Y [m]")
+ da.setInfoOnComponent(2,"Z [km]")
+ da2=da[5:-1]
+ self.assertEqual([22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51],da2.getValues())
+ da2=da[4]
+ self.assertEqual([19, 20, 21],da2.getValues())
+ try:
+ da2=da[4:17]
+ except InterpKernelException as e:
+ self.assertTrue(True)
+ else:
+ self.assertTrue(False)
+ pass
+ da2=da[5:-2,2]
+ self.assertEqual([24, 27, 30, 33, 36, 39, 42, 45, 48],da2.getValues())
+ da2=da[5:8,:]
+ self.assertEqual([22, 23, 24, 25, 26, 27, 28, 29, 30],da2.getValues())
+ da2=da[:]
+ self.assertTrue(da2.isEqual(da))
+ da2=da[:,:]
+ self.assertTrue(da2.isEqual(da))
+ try:
+ da2=da[:,:,:]
+ except InterpKernelException as e:
+ self.assertTrue(True)
+ else:
+ self.assertTrue(False)
+ pass
+ try:
+ da2=da[5:8,-2]
+ except InterpKernelException as e:
+ self.assertTrue(True)
+ else:
+ self.assertTrue(False)
+ pass
+ da2=da[5:8,:-2]
+ self.assertEqual([22, 25, 28],da2.getValues())
+ try:
+ da2=da[5:-18,2]
+ except InterpKernelException as e:
+ self.assertTrue(True)
+ else:
+ self.assertTrue(False)
+ pass
+ da2=da[5:5,2]
+ self.assertEqual([],da2.getValues())
+ pass
+
+ def testSwigGetItem2(self):
+ da=DataArrayDouble.New()
+ da.alloc(16,3)
+ da.rearrange(1)
+ da.iota(7)
+ da.rearrange(3)
+ da.setInfoOnComponent(0,"X [m]")
+ da.setInfoOnComponent(1,"Y [m]")
+ da.setInfoOnComponent(2,"Z [km]")
+ da2=da[5:-1]
+ self.assertEqual([22., 23., 24., 25., 26., 27., 28., 29., 30., 31., 32., 33., 34., 35., 36., 37., 38., 39., 40., 41., 42., 43., 44., 45., 46., 47., 48., 49., 50., 51.],da2.getValues())
+ da2=da[4]
+ self.assertEqual([19., 20., 21],da2.getValues())
+ try:
+ da2=da[4:17]
+ except InterpKernelException as e:
+ self.assertTrue(True)
+ else:
+ self.assertTrue(False)
+ pass
+ da2=da[5:-2,2]
+ self.assertEqual([24., 27., 30., 33., 36., 39., 42., 45., 48.],da2.getValues())
+ da2=da[5:8,:]
+ self.assertEqual([22., 23., 24., 25., 26., 27., 28., 29., 30.],da2.getValues())
+ da2=da[:]
+ self.assertTrue(da2.isEqual(da,1e-12))
+ da2=da[:,:]
+ self.assertTrue(da2.isEqual(da,1e-12))
+ try:
+ da2=da[:,:,:]
+ except InterpKernelException as e:
+ self.assertTrue(True)
+ else:
+ self.assertTrue(False)
+ pass
+ try:
+ da2=da[5:8,-2]
+ except InterpKernelException as e:
+ self.assertTrue(True)
+ else:
+ self.assertTrue(False)
+ pass
+ da2=da[5:8,:-2]
+ self.assertEqual([22., 25., 28.],da2.getValues())
+ try:
+ da2=da[5:-18,2]
+ except InterpKernelException as e:
+ self.assertTrue(True)
+ else:
+ self.assertTrue(False)
+ pass
+ da2=da[5:5,2]
+ self.assertEqual([],da2.getValues())
+ pass
+
+ def testSwigSetItem1(self):
+ da=DataArrayInt.New()
+ da.alloc(20,1)
+ da.iota(7)
+ da.rearrange(5)
+ da.setInfoOnComponent(0,"X [m]") ; da.setInfoOnComponent(1,"Y [km]") ; da.setInfoOnComponent(2,"Y [m]")
+ da.setInfoOnComponent(3,"Z [W]") ; da.setInfoOnComponent(4,"ZZ [km]") ;
+ da[:,2]=3
+ self.assertEqual([7, 8, 3, 10, 11, 12, 13, 3, 15, 16, 17, 18, 3, 20, 21, 22, 23, 3, 25, 26],da.getValues())
+ da.rearrange(1) ; da.iota(7) ; da.rearrange(5)
+ da[2]=3
+ self.assertEqual([7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 3, 3, 3, 3, 3, 22, 23, 24, 25, 26],da.getValues())
+ da.rearrange(1) ; da.iota(7) ; da.rearrange(5)
+ da[[0,3]]=-1
+ self.assertEqual([-1, -1, -1, -1, -1, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, -1, -1, -1, -1, -1],da.getValues())
+ da.rearrange(1) ; da.iota(7) ; da.rearrange(5)
+ da[:,[1,3,4]]=-3
+ self.assertEqual([7, -3, 9, -3, -3, 12, -3, 14, -3, -3, 17, -3, 19, -3, -3, 22, -3, 24, -3, -3],da.getValues())
+ da.rearrange(1) ; da.iota(7) ; da.rearrange(5)
+ da2=DataArrayInt.New() ; da2.setValues([0,2,3],3,1)
+ da[da2]=-7
+ self.assertEqual([-7, -7, -7, -7, -7, 12, 13, 14, 15, 16, -7, -7, -7, -7, -7, -7, -7, -7, -7, -7],da.getValues())
+ da.rearrange(1) ; da.iota(7) ; da.rearrange(5)
+ da[da2,-2:]=-7
+ self.assertEqual([7, 8, 9, -7, -7, 12, 13, 14, 15, 16, 17, 18, 19, -7, -7, 22, 23, 24, -7, -7],da.getValues())
+ # Let's test with DAI right hand side
+ da1=DataArrayInt.New()
+ da1.setValues([25,26,27,125,126,127],2,3)
+ #
+ da.rearrange(1) ; da.iota(7) ; da.rearrange(5)
+ da[-2:,1:4]=da1
+ self.assertEqual([7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 25, 26, 27, 21, 22, 125, 126, 127, 26],da.getValues())
+ da.rearrange(1) ; da.iota(7) ; da.rearrange(5)
+ da[1:,3]=[225,226,227]
+ self.assertEqual([7, 8, 9, 10, 11, 12, 13, 14, 225, 16, 17, 18, 19, 226, 21, 22, 23, 24, 227, 26],da.getValues())
+ da.rearrange(1) ; da.iota(7) ; da.rearrange(5)
+ da[1,2:]=[225,226,227]
+ self.assertEqual([7, 8, 9, 10, 11, 12, 13, 225, 226, 227, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26],da.getValues())
+ da.rearrange(1) ; da.iota(7) ; da.rearrange(5)
+ da[da2,-2:]=[88,99,1010,1111,1212,1313]
+ self.assertEqual([7, 8, 9, 88, 99, 12, 13, 14, 15, 16, 17, 18, 19, 1010, 1111, 22, 23, 24, 1212, 1313],da.getValues())
+ da.rearrange(1) ; da.iota(7) ; da.rearrange(5)
+ da3=DataArrayInt.New(); da3.setValues([88,99,1010,1111,1212,1313],3,2)
+ da[da2,-2:]=da3
+ self.assertEqual([7, 8, 9, 88, 99, 12, 13, 14, 15, 16, 17, 18, 19, 1010, 1111, 22, 23, 24, 1212, 1313],da.getValues())
+ da.rearrange(1) ; da.iota(7) ; da.rearrange(5)
+ da[da2,[0,2]]=da3
+ self.assertEqual([88, 8, 99, 10, 11, 12, 13, 14, 15, 16, 1010, 18, 1111, 20, 21, 1212, 23, 1313, 25, 26],da.getValues())
+ da.rearrange(1) ; da.iota(7) ; da.rearrange(5)
+ da[da2,0:3:2]=da3
+ self.assertEqual([88, 8, 99, 10, 11, 12, 13, 14, 15, 16, 1010, 18, 1111, 20, 21, 1212, 23, 1313, 25, 26],da.getValues())
+ da.rearrange(1) ; da.iota(7) ; da.rearrange(5)
+ da[da2,0:3:2]=-8
+ self.assertEqual([-8, 8, -8, 10, 11, 12, 13, 14, 15, 16, -8, 18, -8, 20, 21, -8, 23, -8, 25, 26],da.getValues())
+ pass
+
+ def testSwigSetItem2(self):
+ da=DataArrayDouble.New()
+ da.alloc(20,1)
+ da.iota(7)
+ da.rearrange(5)
+ da.setInfoOnComponent(0,"X [m]") ; da.setInfoOnComponent(1,"Y [km]") ; da.setInfoOnComponent(2,"Y [m]")
+ da.setInfoOnComponent(3,"Z [W]") ; da.setInfoOnComponent(4,"ZZ [km]") ;
+ da[:,2]=3.
+ self.assertEqual([7., 8., 3., 10., 11., 12., 13., 3., 15., 16., 17., 18., 3., 20., 21., 22., 23., 3., 25., 26.],da.getValues())
+ da.rearrange(1) ; da.iota(7) ; da.rearrange(5)
+ da[2]=3.
+ self.assertEqual([7., 8., 9., 10., 11., 12., 13., 14., 15., 16., 3., 3., 3., 3., 3., 22., 23., 24., 25., 26.],da.getValues())
+ da.rearrange(1) ; da.iota(7) ; da.rearrange(5)
+ da[[0,3]]=-1.
+ self.assertEqual([-1., -1., -1., -1., -1., 12., 13., 14., 15., 16., 17., 18., 19., 20., 21., -1., -1., -1., -1., -1.],da.getValues())
+ da.rearrange(1) ; da.iota(7) ; da.rearrange(5)
+ da[:,[1,3,4]]=-3.
+ self.assertEqual([7., -3., 9., -3., -3., 12., -3., 14., -3., -3., 17., -3., 19., -3., -3., 22., -3., 24., -3., -3.],da.getValues())
+ da.rearrange(1) ; da.iota(7) ; da.rearrange(5)
+ da2=DataArrayInt.New() ; da2.setValues([0,2,3],3,1)
+ da[da2]=-7.
+ self.assertEqual([-7., -7., -7., -7., -7., 12., 13., 14., 15., 16., -7., -7., -7., -7., -7., -7., -7., -7., -7., -7.],da.getValues())
+ da.rearrange(1) ; da.iota(7) ; da.rearrange(5)
+ da[da2,-2:]=-7
+ self.assertEqual([7., 8., 9., -7., -7., 12., 13., 14., 15., 16., 17., 18., 19., -7., -7., 22., 23., 24., -7., -7.],da.getValues())
+ # Let's test with DAI right hand side
+ da1=DataArrayDouble.New()
+ da1.setValues([25,26,27,125,126,127],2,3)
+ #
+ da.rearrange(1) ; da.iota(7) ; da.rearrange(5)
+ da[-2:,1:4]=da1
+ self.assertEqual([7., 8., 9., 10., 11., 12., 13., 14., 15., 16., 17., 25., 26., 27., 21., 22., 125., 126., 127., 26.],da.getValues())
+ da.rearrange(1) ; da.iota(7) ; da.rearrange(5)
+ da[1:,3]=[225.,226.,227.]
+ self.assertEqual([7., 8., 9., 10., 11., 12., 13., 14., 225., 16., 17., 18., 19., 226., 21., 22., 23., 24., 227., 26.],da.getValues())
+ da.rearrange(1) ; da.iota(7) ; da.rearrange(5)
+ da[1,2:]=[225,226,227]
+ self.assertEqual([7., 8., 9., 10., 11., 12., 13., 225., 226., 227., 17., 18., 19., 20., 21., 22., 23., 24., 25., 26.],da.getValues())
+ da.rearrange(1) ; da.iota(7) ; da.rearrange(5)
+ da[da2,-2:]=[88,99,1010,1111,1212,1313]
+ self.assertEqual([7., 8., 9., 88., 99., 12., 13., 14., 15., 16., 17., 18., 19., 1010., 1111., 22., 23., 24., 1212., 1313.],da.getValues())
+ da.rearrange(1) ; da.iota(7) ; da.rearrange(5)
+ da3=DataArrayDouble.New(); da3.setValues([88,99,1010,1111,1212,1313],3,2)
+ da[da2,-2:]=da3
+ self.assertEqual([7., 8., 9., 88., 99., 12., 13., 14., 15., 16., 17., 18., 19., 1010., 1111., 22., 23., 24., 1212., 1313.],da.getValues())
+ da.rearrange(1) ; da.iota(7) ; da.rearrange(5)
+ da[da2,[0,2]]=da3
+ self.assertEqual([88., 8., 99., 10., 11., 12., 13., 14., 15., 16., 1010., 18., 1111., 20., 21., 1212., 23., 1313., 25., 26.],da.getValues())
+ da.rearrange(1) ; da.iota(7) ; da.rearrange(5)
+ da[da2,0:3:2]=da3
+ self.assertEqual([88., 8., 99., 10., 11., 12., 13., 14., 15., 16., 1010., 18., 1111., 20., 21., 1212., 23., 1313., 25., 26.],da.getValues())
+ da.rearrange(1) ; da.iota(7) ; da.rearrange(5)
+ da[da2,0:3:2]=-8.
+ self.assertEqual([-8., 8., -8., 10., 11., 12., 13., 14., 15., 16., -8., 18., -8., 20., 21., -8., 23., -8., 25., 26.],da.getValues())
+ pass
+
+ def testSwigDADOp(self):
+ da=DataArrayDouble.New()
+ da.alloc(12,1)
+ da.iota(7.)
+ da1=DataArrayDouble.New()
+ da1.alloc(12,1)
+ da1.iota(8.)
+ da2=da+da1
+ self.assertEqual([15., 17., 19., 21., 23., 25., 27., 29., 31., 33., 35., 37.],da2.getValues())
+ da2=da+3
+ da3=3+da
+ self.assertTrue(da2.isEqual(da3,1e-12))
+ da2=da-1.
+ self.assertEqual([6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0, 17.0],da2.getValues())
+ da2=1-da
+ self.assertEqual([-6.0, -7.0, -8.0, -9.0, -10.0, -11.0, -12.0, -13.0, -14.0, -15.0, -16.0, -17.0],da2.getValues())
+ da2=da*3
+ self.assertEqual([21.0, 24.0, 27.0, 30.0, 33.0, 36.0, 39.0, 42.0, 45.0, 48.0, 51.0, 54.0],da2.getValues())
+ da2=3.*da
+ self.assertEqual([21.0, 24.0, 27.0, 30.0, 33.0, 36.0, 39.0, 42.0, 45.0, 48.0, 51.0, 54.0],da2.getValues())
+ da2=da*da1
+ self.assertEqual([56.0, 72.0, 90.0, 110.0, 132.0, 156.0, 182.0, 210.0, 240.0, 272.0, 306.0, 342.0],da2.getValues())
+ da2=da/4.
+ self.assertEqual([1.75, 2.0, 2.25, 2.5, 2.75, 3.0, 3.25, 3.5, 3.75, 4.0, 4.25, 4.5],da2.getValues())
+ da3=4./da
+ da4=da3*da2
+ self.assertTrue(da4.isUniform(1.,1e-12))
+ st1=da.getHiddenCppPointer()
+ da+=1
+ st2=da.getHiddenCppPointer()
+ self.assertEqual(st1,st2)
+ self.assertTrue(da.isEqual(da1,1e-12))
+ da-=8
+ st2=da.getHiddenCppPointer()
+ self.assertEqual(st1,st2)
+ self.assertEqual(range(12),da.getValues())
+ da+=da1
+ st2=da.getHiddenCppPointer()
+ self.assertEqual(st1,st2)
+ self.assertEqual([8.0, 10.0, 12.0, 14.0, 16.0, 18.0, 20.0, 22.0, 24.0, 26.0, 28.0, 30.0],da.getValues())
+ da*=0.5
+ st2=da.getHiddenCppPointer()
+ self.assertEqual(st1,st2)
+ self.assertEqual([4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0],da.getValues())
+ da*=da1
+ st2=da.getHiddenCppPointer()
+ self.assertEqual(st1,st2)
+ self.assertEqual([32.0, 45.0, 60.0, 77.0, 96.0, 117.0, 140.0, 165.0, 192.0, 221.0, 252.0, 285.0],da.getValues())
+ da/=da1
+ self.assertEqual(st1,st2)
+ self.assertEqual([4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0],da.getValues())
+ da/=2
+ st2=da.getHiddenCppPointer()
+ self.assertEqual(st1,st2)
+ self.assertEqual([2.0, 2.5, 3.0, 3.5, 4.0, 4.5, 5.0, 5.5, 6.0, 6.5, 7.0, 7.5],da.getValues())
+ da.rearrange(3)
+ da5=DataArrayDouble.New()
+ da5.setValues([5.,4.,3.,2.],4,1)
+ da*=da5 # it works with unmathing number of compo
+ st2=da.getHiddenCppPointer()
+ self.assertEqual(st1,st2)
+ self.assertEqual([10.0, 12.5, 15.0, 14.0, 16.0, 18.0, 15.0, 16.5, 18.0, 13.0, 14.0, 15.0],da.getValues())
+ pass
+
+ def testSwigDAIOp(self):
+ da=DataArrayInt.New()
+ da.alloc(12,1)
+ da.iota(7)
+ da1=DataArrayInt.New()
+ da1.alloc(12,1)
+ da1.iota(8)
+ da2=da+da1
+ self.assertEqual([15,17,19,21,23,25,27,29,31,33,35,37],da2.getValues())
+ da2=da+3
+ da3=3+da
+ self.assertTrue(da2.isEqual(da3))
+ da2=da-1
+ self.assertEqual([6,7,8,9,10,11,12,13,14,15,16,17],da2.getValues())
+ da2=1-da
+ self.assertEqual([-6,-7,-8,-9,-10,-11,-12,-13,-14,-15,-16,-17],da2.getValues())
+ da2=da*3
+ self.assertEqual([21,24,27,30,33,36,39,42,45,48,51,54.0],da2.getValues())
+ da2=3*da
+ self.assertEqual([21,24,27,30,33,36,39,42,45,48,51,54.0],da2.getValues())
+ da2=da*da1
+ self.assertEqual([56,72,90,110,132,156,182,210,240,272,306,342.0],da2.getValues())
+ da2=da/4
+ self.assertEqual([1,2,2,2,2,3,3,3,3,4,4,4],da2.getValues())
+ da3=4/da
+ da4=da3*da2
+ self.assertTrue(da4.isUniform(0))
+ st1=da.getHiddenCppPointer()
+ da+=1
+ st2=da.getHiddenCppPointer()
+ self.assertEqual(st1,st2)
+ self.assertTrue(da.isEqual(da1))
+ da-=8
+ st2=da.getHiddenCppPointer()
+ self.assertEqual(st1,st2)
+ self.assertEqual(range(12),da.getValues())
+ da+=da1
+ st2=da.getHiddenCppPointer()
+ self.assertEqual(st1,st2)
+ self.assertEqual([8,10,12,14,16,18,20,22,24,26,28,30],da.getValues())
+ da/=2
+ st2=da.getHiddenCppPointer()
+ self.assertEqual(st1,st2)
+ self.assertEqual([4,5,6,7,8,9,10,11,12,13,14,15],da.getValues())
+ da*=da1
+ st2=da.getHiddenCppPointer()
+ self.assertEqual(st1,st2)
+ self.assertEqual([32,45,60,77,96,117,140,165,192,221,252,285],da.getValues())
+ da/=da1
+ self.assertEqual(st1,st2)
+ self.assertEqual([4,5,6,7,8,9,10,11,12,13,14,15],da.getValues())
+ da/=2
+ st2=da.getHiddenCppPointer()
+ self.assertEqual(st1,st2)
+ self.assertEqual([2,2, 3,3, 4,4, 5,5, 6,6, 7,7],da.getValues())
+ da.rearrange(3)
+ da5=DataArrayInt.New()
+ da5.setValues([5,4,3,2],4,1)
+ da*=da5 # it works with unmathing number of compo
+ st2=da.getHiddenCppPointer()
+ self.assertEqual(st1,st2)
+ self.assertEqual([10,10, 15,12,16,16,15,15, 18,12,14,14],da.getValues())
+ da%=6
+ st2=da.getHiddenCppPointer()
+ self.assertEqual(st1,st2)
+ self.assertEqual([4,4,3,0,4,4,3,3,0,0,2,2],da.getValues())
+ pass
+
+ def testDAIAggregateMulti1(self):
+ a=DataArrayInt.New()
+ a.setValues(range(4),2,2)
+ a.setName("aa")
+ b=DataArrayInt.New()
+ b.setValues(range(6),3,2)
+ c=DataArrayInt.Aggregate([a,b])
+ self.assertEqual(range(4)+range(6),c.getValues())
+ self.assertEqual("aa",c.getName())
+ self.assertEqual(5,c.getNumberOfTuples())
+ self.assertEqual(2,c.getNumberOfComponents())
+ pass
+
+ def testMergeUMeshes2(self):
+ m1=MEDCouplingDataForTest.build3DSurfTargetMesh_1();
+ m2=MEDCouplingDataForTest.build3DSurfTargetMesh_1();
+ m3=MEDCouplingDataForTest.build3DSurfTargetMesh_1();
+ #
+ vec1=[0,2,3]
+ m2_2=m2.buildPartOfMySelf(vec1,False);
+ vec2=[1,1]
+ m3_2=m3.buildPartOfMySelf(vec2,False);
+ #
+ ms=[m1,m2_2,m3_2];
+ #
+ m4=MEDCouplingUMesh.MergeUMeshes(ms);
+ m4.checkCoherency();
+ self.assertEqual(10,m4.getNumberOfCells());
+ self.assertEqual(20,m4.getNumberOfNodes());
+ self.assertEqual(45,m4.getMeshLength());
+ #
+ vec3=[0,1,2,3,4]
+ m4_1=m4.buildPartOfMySelf(vec3,False);
+ m4_1.setName(m1.getName());
+ self.assertTrue(m4_1.isEqual(m1,1e-12));
+ #
+ vec4=[5,6,7]
+ m4_2=m4.buildPartOfMySelf(vec4,False);
+ cellCor,nodeCor=m4_2.checkGeoEquivalWith(m2_2,10,1e-12);
+ #
+ vec5=[8,9]
+ m4_3=m4.buildPartOfMySelf(vec5,False);
+ self.assertEqual(2,m4_3.getNumberOfCells());
+ self.assertEqual(3,m4_3.getNumberOfNodes());
+ m3_2.zipCoords();
+ m4_3.setName(m3_2.getName());
+ self.assertTrue(m4_3.isEqual(m3_2,1e-12));
+ #
+ pass
+
+ def testBuild0DMeshFromCoords1(self):
+ sourceCoords=[-0.3,-0.3,0., 0.7,-0.3,0., -0.3,0.7,0., 0.7,0.7,0.]
+ coo=DataArrayDouble.New();
+ coo.setValues(sourceCoords,4,3);
+ coo.setName("My0D");
+ m=MEDCouplingUMesh.Build0DMeshFromCoords(coo);
+ m.checkCoherency();
+ self.assertEqual(4,m.getNumberOfNodes());
+ self.assertEqual(4,m.getNumberOfCells());
+ self.assertEqual(3,m.getSpaceDimension());
+ self.assertEqual(0,m.getMeshDimension());
+ types1=m.getAllTypes();
+ self.assertEqual([NORM_POINT1],types1);
+ for i in xrange(4):
+ conn=m.getNodeIdsOfCell(i);
+ self.assertEqual([i],conn);
+ self.assertTrue(NORM_POINT1==m.getTypeOfCell(i));
+ pass
+ self.assertEqual(m.getName(),"My0D");
+ pass
+
+ def testDescriptionInMeshTimeUnit1(self):
+ text1="totoTTEDD";
+ m=MEDCouplingDataForTest.build2DTargetMesh_1();
+ m.setDescription(text1);
+ self.assertEqual(m.getDescription(),text1);
+ m2=m.deepCpy();
+ self.assertTrue(m.isEqual(m2,1e-12));
+ self.assertEqual(m2.getDescription(),text1);
+ m2.setDescription("ggg");
+ self.assertTrue(not m.isEqual(m2,1e-12));
+ #
+ f=MEDCouplingFieldDouble.New(ON_CELLS,ONE_TIME);
+ f.setTimeUnit(text1);
+ self.assertEqual(f.getTimeUnit(),text1);
+ f2=f.deepCpy();
+ self.assertEqual(f2.getTimeUnit(),text1);
+ #
+ pass
+
+ def testMultiFields1(self):
+ mfs=MEDCouplingDataForTest.buildMultiFields_1();
+ ms=mfs.getMeshes();
+ dms,refs=mfs.getDifferentMeshes()
+ das=mfs.getArrays();
+ das2,refs2=mfs.getDifferentArrays()
+ self.assertEqual(5,len(mfs.getFields()))
+ self.assertEqual(1,len(mfs.getFields()[0].getArrays()));
+ self.assertEqual(2,len(mfs.getFields()[1].getArrays()));
+ self.assertEqual(1,len(mfs.getFields()[2].getArrays()));
+ self.assertEqual(1,len(mfs.getFields()[3].getArrays()));
+ self.assertEqual(1,len(mfs.getFields()[4].getArrays()));
+ self.assertEqual(5,len(ms));
+ self.assertEqual(2,len(dms));
+ self.assertEqual(6,len(das));
+ self.assertEqual(5,len(das2));
+ mfs2=mfs.deepCpy();
+ self.assertTrue(mfs.isEqual(mfs2,1e-12,1e-12))
+ pass
+
+ def testFieldOverTime1(self):
+ fs=MEDCouplingDataForTest.buildMultiFields_2();
+ self.assertRaises(InterpKernelException,MEDCouplingFieldOverTime.New,fs);
+ f4bis=fs[4].buildNewTimeReprFromThis(ONE_TIME,False);
+ fs[4]=f4bis;
+ self.assertRaises(InterpKernelException,MEDCouplingFieldOverTime.New,fs);
+ f4bis.setTime(2.7,20,21);
+ fot=MEDCouplingFieldOverTime.New(fs);
+ dt=fot.getDefinitionTimeZone();
+ hs=dt.getHotSpotsTime();
+ self.assertEqual(6,len(hs));
+ expected1=[0.2,0.7,1.2,1.35,1.7,2.7]
+ for i in xrange(6):
+ self.assertAlmostEqual(expected1[i],hs[i],12);
+ pass
+ meshId,arrId,arrIdInField,fieldId=dt.getIdsOnTimeRight(0.2);
+ self.assertEqual(0,meshId);
+ self.assertEqual(0,arrId);
+ self.assertEqual(0,arrIdInField);
+ self.assertEqual(0,fieldId);
+ #
+ meshId,arrId,arrIdInField,fieldId=dt.getIdsOnTimeRight(0.7);
+ self.assertEqual(0,meshId);
+ self.assertEqual(1,arrId);
+ self.assertEqual(0,arrIdInField);
+ self.assertEqual(1,fieldId);
+ #
+ meshId,arrId,arrIdInField,fieldId=dt.getIdsOnTimeLeft(1.2);#**** WARNING left here
+ self.assertEqual(0,meshId);
+ self.assertEqual(2,arrId);
+ self.assertEqual(1,arrIdInField);
+ self.assertEqual(1,fieldId);
+ #
+ meshId,arrId,arrIdInField,fieldId=dt.getIdsOnTimeRight(1.2);#**** WARNING right again here
+ self.assertEqual(1,meshId);
+ self.assertEqual(3,arrId);
+ self.assertEqual(0,arrIdInField);
+ self.assertEqual(2,fieldId);
+ #
+ meshId,arrId,arrIdInField,fieldId=dt.getIdsOnTimeRight(1.35);
+ self.assertEqual(1,meshId);
+ self.assertEqual(3,arrId);
+ self.assertEqual(0,arrIdInField);
+ self.assertEqual(2,fieldId);
+ #
+ meshId,arrId,arrIdInField,fieldId=dt.getIdsOnTimeRight(1.7);
+ self.assertEqual(0,meshId);
+ self.assertEqual(3,arrId);
+ self.assertEqual(0,arrIdInField);
+ self.assertEqual(3,fieldId);
+ #
+ meshId,arrId,arrIdInField,fieldId=dt.getIdsOnTimeRight(2.7);
+ self.assertEqual(1,meshId);
+ self.assertEqual(4,arrId);
+ self.assertEqual(0,arrIdInField);
+ self.assertEqual(4,fieldId);
+ #
+ dt2=MEDCouplingDefinitionTime();
+ self.assertTrue(not dt2.isEqual(dt));
+ dt2.assign(dt);
+ dt2.assign(dt);#to check memory management
+ self.assertTrue(dt2.isEqual(dt));
+ #
+ dt3=MEDCouplingDefinitionTime();
+ #
+ pass
+
+ def testDAICheckAndPreparePermutation1(self):
+ vals1=[9,10,0,6,4,11,3,7];
+ expect1=[5,6,0,3,2,7,1,4];
+ vals2=[9,10,0,6,10,11,3,7];
+ da=DataArrayInt.New();
+ da.setValues(vals1,8,1);
+ da2=da.checkAndPreparePermutation();
+ self.assertEqual(8,da2.getNumberOfTuples());
+ self.assertEqual(1,da2.getNumberOfComponents());
+ for i in xrange(8):
+ self.assertEqual(expect1[i],da2.getIJ(i,0));
+ pass
+ #
+ da=DataArrayInt.New();
+ da.alloc(8,1);
+ da.iota(0);
+ da2=da.checkAndPreparePermutation();
+ self.assertEqual(8,da2.getNumberOfTuples());
+ self.assertEqual(1,da2.getNumberOfComponents());
+ self.assertTrue(da2.isIdentity());
+ #
+ da=DataArrayInt.New();
+ da.alloc(8,1);
+ da.setValues(vals2,8,1);
+ self.assertRaises(InterpKernelException,da.checkAndPreparePermutation);
+ pass
+
+ def testDAIChangeSurjectiveFormat1(self):
+ vals1=[0,3,2,3,2,2,1,2]
+ expected1=[0,1,2,6,8]
+ expected2=[0, 6, 2,4,5,7, 1,3]
+ da=DataArrayInt.New();
+ da.setValues(vals1,8,1);
+ #
+ da2,da2I=da.changeSurjectiveFormat(4);
+ self.assertEqual(5,da2I.getNumberOfTuples());
+ self.assertEqual(8,da2.getNumberOfTuples());
+ self.assertEqual(expected1,da2I.getValues());
+ self.assertEqual(expected2,da2.getValues());
+ #
+ self.assertRaises(InterpKernelException,da.changeSurjectiveFormat,3);
+ #
+ pass
+
+ def testUMeshGetCellIdsLyingOnNodes1(self):
+ m=MEDCouplingDataForTest.build3DSurfTargetMesh_1();
+ nodeIds1=[1,2,3,4,6]
+ nodeIds2=[6,7]
+ da=m.getCellIdsLyingOnNodes(nodeIds1,True);
+ self.assertEqual(1,da.getNumberOfTuples());
+ self.assertEqual(1,da.getNumberOfComponents());
+ self.assertEqual(1,da.getIJ(0,0));
+ da2=DataArrayInt.New()
+ da2.setValues(nodeIds2,2,1)
+ da=m.getCellIdsLyingOnNodes(da2,False);
+ self.assertEqual(2,da.getNumberOfTuples());
+ self.assertEqual(1,da.getNumberOfComponents());
+ self.assertEqual(3,da.getIJ(0,0));
+ self.assertEqual(4,da.getIJ(1,0));
+ pass
+
+ def testUMeshFindCellsIdsOnBoundary1(self):
+ m=MEDCouplingDataForTest.build3DSurfTargetMesh_1();
+ da5=m.findCellsIdsOnBoundary();
+ self.assertEqual(5,da5.getNumberOfTuples());
+ self.assertTrue(da5.isIdentity());
+ pass
+
+ def testMeshSetTime1(self):
+ m1=MEDCouplingDataForTest.build3DSurfTargetMesh_1();
+ m2=MEDCouplingDataForTest.build3DSurfTargetMesh_1();
+ #
+ self.assertTrue(m1.isEqual(m2,1e-12));
+ m1.setTime(3.14,6,7);
+ tmp3,tmp1,tmp2=m1.getTime();
+ self.assertEqual(6,tmp1);
+ self.assertEqual(7,tmp2);
+ self.assertAlmostEqual(3.14,tmp3,12);
+ self.assertTrue(not m1.isEqual(m2,1e-12));
+ m2.setTime(3.14,6,7);
+ self.assertTrue(m1.isEqual(m2,1e-12));
+ m1.setTimeUnit("ms");
+ self.assertTrue(m1.getTimeUnit()=="ms");
+ m1.setTimeUnit("us");
+ self.assertTrue(m1.getTimeUnit()=="us");
+ self.assertTrue(not m1.isEqual(m2,1e-12));
+ m2.setTimeUnit("us");
+ self.assertTrue(m1.isEqual(m2,1e-12));
+ m2.setTime(3.14,6,8);
+ self.assertTrue(not m1.isEqual(m2,1e-12));
+ m2.setTime(3.14,7,7);
+ self.assertTrue(not m1.isEqual(m2,1e-12));
+ m2.setTime(3.15,6,7);
+ self.assertTrue(not m1.isEqual(m2,1e-12));
+ #
+ m1.setTime(10.34,55,12);
+ m3=m1.deepCpy();
+ self.assertTrue(m1.isEqual(m3,1e-12));
+ tmp3,tmp1,tmp2=m3.getTime();
+ self.assertEqual(55,tmp1);
+ self.assertEqual(12,tmp2);
+ self.assertAlmostEqual(10.34,tmp3,12);
+ #
+ # testing CMesh
+ coo1=[0.,1.,2.,3.5]
+ a=DataArrayDouble.New();
+ a.setValues(coo1,4,1);
+ b=MEDCouplingCMesh.New();
+ b.setCoordsAt(0,a);
+ #
+ b.setTime(5.67,8,100);
+ tmp3,tmp1,tmp2=b.getTime();
+ self.assertEqual(8,tmp1);
+ self.assertEqual(100,tmp2);
+ self.assertAlmostEqual(5.67,tmp3,12);
+ c=b.deepCpy();
+ self.assertTrue(c.isEqual(b,1e-12));
+ tmp3,tmp1,tmp2=c.getTime();
+ self.assertEqual(8,tmp1);
+ self.assertEqual(100,tmp2);
+ self.assertAlmostEqual(5.67,tmp3,12);
+ pass
+
+ def testApplyFuncTwo1(self):
+ m1=MEDCouplingDataForTest.build3DSurfTargetMesh_1();
+ f1=MEDCouplingFieldDouble.New(ON_CELLS,ONE_TIME);
+ f1.setMesh(m1);
+ #
+ vals=[1.,11.,21.,2.,12.,22.,3.,13.,23.,4.,14.,24.,5.,15.,25.]
+ da=DataArrayDouble.New();
+ da.setValues(vals,5,3);
+ f1.setArray(da);
+ #
+ self.assertRaises(InterpKernelException,da.applyFunc2,1,"y+z");
+ da.setInfoOnComponent(0,"x [m]");
+ da.setInfoOnComponent(1,"y [mm]");
+ da.setInfoOnComponent(2,"z [km]");
+ da2=da.applyFunc2(1,"y+z");
+ self.assertEqual(1,da2.getNumberOfComponents());
+ self.assertEqual(5,da2.getNumberOfTuples());
+ expected1=[32.,34.,36.,38.,40.]
+ for i in xrange(5):
+ self.assertAlmostEqual(expected1[i],da2.getIJ(0,i),12);
+ pass
+ da2=da.applyFunc(1,"y+z");
+ expected2=[12.,14.,16.,18.,20.]
+ for i in xrange(5):
+ self.assertAlmostEqual(expected2[i],da2.getIJ(0,i),12);
+ pass
+ #
+ self.assertEqual(3,f1.getNumberOfComponents());
+ self.assertEqual(5,f1.getNumberOfTuples());
+ f1.applyFunc2(1,"y+z");
+ self.assertEqual(1,f1.getNumberOfComponents());
+ self.assertEqual(5,f1.getNumberOfTuples());
+ for i in xrange(5):
+ self.assertAlmostEqual(expected1[i],f1.getArray().getIJ(0,i),12);
+ pass
+ #
+ pass
+
+ def testApplyFuncThree1(self):
+ m1=MEDCouplingDataForTest.build3DSurfTargetMesh_1();
+ f1=MEDCouplingFieldDouble.New(ON_CELLS,ONE_TIME);
+ f1.setMesh(m1);
+ #
+ vals=[1.,11.,21.,2.,12.,22.,3.,13.,23.,4.,14.,24.,5.,15.,25.]
+ da=DataArrayDouble.New();
+ da.setValues(vals,5,3);
+ f1.setArray(da);
+ #
+ vs=3*[None];
+ vs[0]="x"; vs[1]="Y"; vs[2]="z";
+ self.assertRaises(InterpKernelException,da.applyFunc3,1,vs,"y+z");
+ vs[1]="y";
+ da2=da.applyFunc3(1,vs,"y+z");
+ expected1=[32.,34.,36.,38.,40.]
+ for i in xrange(5):
+ self.assertAlmostEqual(expected1[i],da2.getIJ(0,i),12);
+ pass
+ f1.setArray(da);
+ self.assertEqual(3,f1.getNumberOfComponents());
+ self.assertEqual(5,f1.getNumberOfTuples());
+ f1.applyFunc3(1,vs,"y+z");
+ self.assertEqual(1,f1.getNumberOfComponents());
+ self.assertEqual(5,f1.getNumberOfTuples());
+ for i in xrange(5):
+ self.assertAlmostEqual(expected1[i],f1.getArray().getIJ(0,i),12);
+ pass
+ pass
+
+ def testFillFromAnalyticTwo1(self):
+ m1=MEDCouplingDataForTest.build3DSurfTargetMesh_1();
+ self.assertRaises(InterpKernelException,m1.fillFromAnalytic2,ON_NODES,1,"y+z");
+ m1.getCoords().setInfoOnComponent(0,"x [m]");
+ m1.getCoords().setInfoOnComponent(1,"y");
+ m1.getCoords().setInfoOnComponent(2,"z");
+ f1=m1.fillFromAnalytic2(ON_NODES,1,"y+z");
+ self.assertEqual(1,f1.getNumberOfComponents());
+ self.assertEqual(9,f1.getNumberOfTuples());
+ expected1=[0.2, 0.7, 1.2, 0.7, 1.2, 1.7, 1.2, 1.7, 2.2]
+ for i in xrange(9):
+ self.assertAlmostEqual(expected1[i],f1.getArray().getIJ(0,i),12);
+ pass
+ pass
+
+ def testFillFromAnalyticThree1(self):
+ m1=MEDCouplingDataForTest.build3DSurfTargetMesh_1();
+ vs=3*[None];
+ vs[0]="x"; vs[1]="Y"; vs[2]="z";
+ self.assertRaises(InterpKernelException,m1.fillFromAnalytic3,ON_NODES,1,vs,"y+z");
+ vs[1]="y";
+ f1=m1.fillFromAnalytic3(ON_NODES,1,vs,"y+z");
+ self.assertEqual(1,f1.getNumberOfComponents());
+ self.assertEqual(9,f1.getNumberOfTuples());
+ expected1=[0.2, 0.7, 1.2, 0.7, 1.2, 1.7, 1.2, 1.7, 2.2]
+ for i in xrange(9):
+ self.assertAlmostEqual(expected1[i],f1.getArray().getIJ(0,i),12);
+ pass
+ pass
+
+ def testDAUnitVar1(self):
+ da=DataArrayDouble.New();
+ da.alloc(1,3);
+ da.setInfoOnComponent(0,"XPS [m]");
+ st1=da.getVarOnComponent(0);
+ self.assertTrue(st1=="XPS");
+ st2=da.getUnitOnComponent(0);
+ self.assertTrue(st2=="m");
+ #
+ da.setInfoOnComponent(0,"XPS [m]");
+ st1=da.getVarOnComponent(0);
+ self.assertTrue(st1=="XPS");
+ st2=da.getUnitOnComponent(0);
+ self.assertTrue(st2=="m");
+ #
+ da.setInfoOnComponent(0,"XPP [m]");
+ st1=da.getVarOnComponent(0);
+ self.assertTrue(st1=="XPP");
+ st2=da.getUnitOnComponent(0);
+ self.assertTrue(st2=="m");
+ #
+ da.setInfoOnComponent(0,"XPP kdep kefer [ m ]");
+ st1=da.getVarOnComponent(0);
+ self.assertTrue(st1=="XPP kdep kefer");
+ st2=da.getUnitOnComponent(0);
+ self.assertTrue(st2==" m ");
+ #
+ da.setInfoOnComponent(0," XPP k[ dep k]efer [ m^ 2/s^3*kJ ]");
+ st1=da.getVarOnComponent(0);
+ self.assertTrue(st1==" XPP k[ dep k]efer");
+ st2=da.getUnitOnComponent(0);
+ self.assertTrue(st2==" m^ 2/s^3*kJ ");
+ #
+ da.setInfoOnComponent(0," XPP kefer ");
+ st1=da.getVarOnComponent(0);
+ self.assertTrue(st1==" XPP kefer ");
+ st2=da.getUnitOnComponent(0);
+ self.assertTrue(st2=="");
+ #
+ da.setInfoOnComponent(0,"temperature( bof)");
+ st1=da.getVarOnComponent(0);
+ self.assertTrue(st1=="temperature( bof)");
+ st2=da.getUnitOnComponent(0);
+ self.assertTrue(st2=="");
+ #
+ da.setInfoOnComponent(0,"kkk [m]");
+ da.setInfoOnComponent(1,"ppp [m^2/kJ]");
+ da.setInfoOnComponent(2,"abcde [MW/s]");
+ #
+ vs=da.getVarsOnComponent();
+ self.assertEqual(3,len(vs));
+ self.assertTrue(vs[0]=="kkk");
+ self.assertTrue(vs[1]=="ppp");
+ self.assertTrue(vs[2]=="abcde");
+ vs=da.getUnitsOnComponent();
+ self.assertEqual(3,len(vs));
+ self.assertTrue(vs[0]=="m");
+ self.assertTrue(vs[1]=="m^2/kJ");
+ self.assertTrue(vs[2]=="MW/s");
+ pass
+
+ def testGaussCoordinates1(self):
+ #Testing 1D cell types
+ m1=MEDCouplingDataForTest.build1DMultiTypes_1();
+ f=MEDCouplingFieldDouble.New(ON_GAUSS_PT,ONE_TIME);
+ f.setMesh(m1);
+ wg1=[0.3];
+ gsCoo1=[0.2];
+ refCoo1=[-1.0,1.0];
+ f.setGaussLocalizationOnType(NORM_SEG2,refCoo1,gsCoo1,wg1);
+ wg2=wg1;
+ gsCoo2=[0.2];
+ refCoo2=[-1.0,1.0,0.0];
+ f.setGaussLocalizationOnType(NORM_SEG3,refCoo2,gsCoo2,wg2);
+ #
+ resToTest=f.getLocalizationOfDiscr();
+ self.assertEqual(3,resToTest.getNumberOfComponents());
+ self.assertEqual(2,resToTest.getNumberOfTuples());
+ expected1=[0.6,0.6,0.6, 0.6,0.6,0.6]
+ for i in xrange(6):
+ self.assertAlmostEqual(expected1[i],resToTest.getIJ(0,i),14);
+ pass
+ #
+ #Testing 2D cell types
+ m2=MEDCouplingDataForTest.build2DMultiTypes_1();
+ f=MEDCouplingFieldDouble.New(ON_GAUSS_PT,ONE_TIME);
+ f.setMesh(m2);
+ wg3=[0.3,0.3];
+ tria3CooGauss=[ 0.1, 0.8, 0.2, 0.7 ]
+ gsCoo3=tria3CooGauss
+ tria3CooRef=[ 0.0, 0.0, 1.0 , 0.0, 0.0, 1.0 ]
+ refCoo3=tria3CooRef;
+ f.setGaussLocalizationOnType(NORM_TRI3,refCoo3,gsCoo3,wg3);
+ wg4=[0.3,0.3,0.3];
+ tria6CooGauss=[ 0.3, 0.2, 0.2, 0.1, 0.2, 0.4 ]
+ gsCoo4=tria6CooGauss;
+ tria6CooRef=[0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.5, 0.0, 0.5, 0.5, 0.0, 0.5]
+ refCoo4=tria6CooRef;
+ f.setGaussLocalizationOnType(NORM_TRI6,refCoo4,gsCoo4,wg4);
+ wg5=[0.3,0.3,0.3,0.3];
+ quad4CooGauss=[ 0.3, 0.2, 0.2, 0.1, 0.2, 0.4, 0.15, 0.27 ]
+ gsCoo5=quad4CooGauss;
+ quad4CooRef=[-1.0, 1.0, -1.0, -1.0, 1.0, -1.0, 1.0, 1.0]
+ refCoo5=quad4CooRef;
+ f.setGaussLocalizationOnType(NORM_QUAD4,refCoo5,gsCoo5,wg5);
+ wg6=[0.3,0.3,0.3,0.3];
+ quad8CooGauss=[ 0.34, 0.16, 0.21, 0.3, 0.23, 0.4, 0.14, 0.37 ]
+ gsCoo6=quad8CooGauss;
+ quad8CooRef=[ -1.0, -1.0, 1.0, -1.0, 1.0, 1.0, -1.0, 1.0, 0.0, -1.0, 1.0, 0.0, 0.0, 1.0, -1.0, 0.0]
+ refCoo6=quad8CooRef;
+ f.setGaussLocalizationOnType(NORM_QUAD8,refCoo6,gsCoo6,wg6);
+ #
+ resToTest=f.getLocalizationOfDiscr();
+ self.assertEqual(3,resToTest.getNumberOfComponents());
+ self.assertEqual(13,resToTest.getNumberOfTuples());#2+3+4+4 gauss points for resp TRI3,TRI6,QUAD4,QUAD8
+ expected2=[5.1,1.55,0.0, 4.7,1.65,0.0,
+ 2.32,1.52,0.0, 1.6,1.32,0.0, 3.52,1.26,0.0,#TRI6
+ 2.6,1.6,0.0, 2.4,1.8,0.0, 2.4,1.2,0.0, 2.3,1.46,0.0,#QUAD4
+ 2.32,2.68,0.0, 2.6,2.42,0.0, 2.8,2.46,0.0, 2.74,2.28,0.0 ];#QUAD8
+ for i in xrange(39):
+ self.assertAlmostEqual(expected2[i],resToTest.getIJ(0,i),14);
+ pass
+ #
+ #Testing 3D cell types
+ m3=MEDCouplingDataForTest.build3DMultiTypes_1();
+ f=MEDCouplingFieldDouble.New(ON_GAUSS_PT,ONE_TIME);
+ f.setMesh(m3);
+ #
+ wg7=[0.3];
+ tetra4CooGauss=[0.34, 0.16, 0.21]
+ gsCoo7=tetra4CooGauss;
+ tetra4CooRef=[0.0,1.0,0.0, 0.0,0.0,1.0, 0.0,0.0,0.0, 1.0,0.0,0.0]
+ refCoo7=tetra4CooRef;
+ f.setGaussLocalizationOnType(NORM_TETRA4,refCoo7,gsCoo7,wg7);
+ wg8=[0.3];
+ tetra10CooGauss=[0.2, 0.3, 0.1]
+ gsCoo8=tetra10CooGauss;
+ tetra10CooRef=[0.0,1.0,0.0, 0.0,0.0,0.0, 0.0,0.0,1.0, 1.0,0.0,0.0, 0.0,0.5,0.0, 0.0,0.0,0.5, 0.0,0.5,0.5, 0.5,0.5,0.0, 0.5,0.0,0.0, 0.5,0.0,0.5]
+ refCoo8=tetra10CooRef;
+ f.setGaussLocalizationOnType(NORM_TETRA10,refCoo8,gsCoo8,wg8);
+ wg9=[0.3];
+ pyra5CooGauss=[0.2, 0.3, 0.1]
+ gsCoo9=pyra5CooGauss;
+ pyra5CooRef=[1.0,0.0,0.0, 0.0,1.0,0.0, -1.0,0.0,0.0, 0.0,-1.0,0.0, 0.0,0.0,1.0]
+ refCoo9=pyra5CooRef;
+ f.setGaussLocalizationOnType(NORM_PYRA5,refCoo9,gsCoo9,wg9);
+ wg10=[0.3];
+ pyra13CooGauss=[0.1, 0.2, 0.7]
+ gsCoo10=pyra13CooGauss;
+ pyra13CooRef=[1.0,0.0,0.0, 0.0,1.0,0.0,-1.0,0.0,0.0,0.0,-1.0,0.0,0.0,0.0,1.0,0.5,0.5,0.0,-0.5,0.5,0.0,-0.5,-0.5,0.0,0.5,-0.5,0.0,0.5,0.0,0.5,0.0,0.5,0.5,-0.5,0.0,0.5,0.0,-0.5,0.5]
+ refCoo10=pyra13CooRef;
+ f.setGaussLocalizationOnType(NORM_PYRA13,refCoo10,gsCoo10,wg10);
+ wg11=[0.3];
+ penta6CooGauss=[0.2, 0.3, 0.1]
+ gsCoo11=penta6CooGauss;
+ penta6CooRef=[-1.0,1.0,0.0,-1.0,-0.0,1.0,-1.0,0.0,0.0,1.0,1.0,0.0,1.0,0.0,1.0,1.0,0.0,0.0]
+ refCoo11=penta6CooRef;
+ f.setGaussLocalizationOnType(NORM_PENTA6,refCoo11,gsCoo11,wg11);
+ wg12=[0.3];
+ penta15CooGauss=[0.2, 0.3,0.15]
+ gsCoo12=penta15CooGauss;
+ penta15CooRef=[-1.0,1.0,0.0,-1.0,0.0,1.0,-1.0,0.0,0.0,1.0,1.0,0.0,1.0,0.0,1.0,1.0,0.0,0.0,-1.0,0.5,0.5,-1.0,0.0,0.5,-1.0,0.5,0.0,0.0,1.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,1.0,0.5,0.5,1.0,0.0, 0.5,1.0,0.5,0.0]
+ refCoo12=penta15CooRef;
+ f.setGaussLocalizationOnType(NORM_PENTA15,refCoo12,gsCoo12,wg12);
+ wg13=[0.3];
+ hexa8CooGauss=[0.2,0.3,0.15]
+ gsCoo13=hexa8CooGauss;
+ hexa8CooRef=[-1.0,-1.0,-1.0,1.0,-1.0,-1.0,1.0,1.0,-1.0,-1.0,1.0,-1.0,-1.0,-1.0,1.0,1.0,-1.0,1.0,1.0,1.0,1.0,-1.0,1.0,1.0]
+ refCoo13=hexa8CooRef;
+ f.setGaussLocalizationOnType(NORM_HEXA8,refCoo13,gsCoo13,wg13);
+ wg14=[0.3];
+ hexa20CooGauss=[0.11,0.3,0.55]
+ gsCoo14=hexa20CooGauss;
+ hexa20CooRef=[-1.0,-1.0,-1.0,1.0,-1.0,-1.0,1.0,1.0,-1.0,-1.0,1.0,-1.0,-1.0,-1.0,1.0,1.0,-1.0,1.0,1.0,1.0,1.0,-1.0,1.0,1.0,0.0,-1.0,-1.0,1.0,0.0,-1.0,0.0,1.0,-1.0,-1.0,0.0,-1.0,-1.0,-1.0,0.0,1.0,-1.0,0.0,1.0,1.0,0.0,-1.0,1.0,0.0,0.0,-1.0,1.0,1.0,0.0,1.0,0.0,1.0,1.0,-1.0,0.0,1.0]
+ refCoo14=hexa20CooRef;
+ f.setGaussLocalizationOnType(NORM_HEXA20,refCoo14,gsCoo14,wg14);
+ #
+ resToTest=f.getLocalizationOfDiscr();
+ self.assertEqual(3,resToTest.getNumberOfComponents());
+ self.assertEqual(8,resToTest.getNumberOfTuples());#2+3+4+4 gauss points for resp TRI3,TRI6,QUAD4,QUAD8
+ expected3=[1.312,3.15,1.02, 0.56,3.3,0.6, 2.18,1.1,0.2, 1.18,1.54,0.98, 1.56,0.3,3.6, 1.613,0.801,4.374, 2.6,2.4,2.3, 2.31232,2.3933985,1.553255]
+ for i in xrange(24):
+ self.assertAlmostEqual(expected3[i],resToTest.getIJ(0,i),14);
+ pass
+ #
+ pass
+
+ def testP2Localization1(self):
+ m=MEDCouplingUMesh.New("testP2",2);
+ coords=[0.,2.,3.5,0.,4.5,1.5,1.2,0.32,3.4,1.,2.1,2.4]
+ conn=[0,1,2,3,4,5]
+ coo=DataArrayDouble.New();
+ coo.setValues(coords,6,2);
+ m.setCoords(coo);
+ m.allocateCells(1);
+ m.insertNextCell(NORM_TRI6,6,conn[0:6])
+ m.finishInsertingCells();
+ #
+ f=MEDCouplingFieldDouble.New(ON_NODES,ONE_TIME);
+ f.setMesh(m);
+ da=DataArrayDouble.New();
+ vals1=[1.2,2.3,3.4, 2.2,3.3,4.4, 3.2,4.3,5.4, 4.2,5.3,6.4, 5.2,6.3,7.4, 6.2,7.3,8.4]
+ da.setValues(vals1,6,3);
+ f.setArray(da);
+ #
+ loc=[2.27,1.3]
+ locs=f.getValueOnMulti(loc);
+ expected1=[6.0921164547752236, 7.1921164547752232, 8.2921164547752255]
+ for i in xrange(3):
+ self.assertAlmostEqual(expected1[i],locs.getIJ(0,i),12);
+ pass
+ pass
+
+ def testP2Localization2(self):
+ m=MEDCouplingUMesh.New("testP2_2",3);
+ coords=[0.33312787792955395, -0.35155740179580952, -0.03567564825034563, 1.307146326477638, -0.57234557776250305, -0.08608044208272235, 0.5551834466499993, 0.62324964668794192, -0.014638951108536295, 0.37761817224442129, -0.38324019806913578, 0.96283164472856886, 0.79494856035658679, -0.40628057809270046, 0.0021004190225864614, 1.023740446371799, 0.07665912970471335, -0.072889657161871096, 0.54564584619517376, 0.11132872093429744, 0.039647326652013051, 0.27164784387819052, -0.42018012100866675, 0.46563376500745146, 0.89501965094896418, -0.56148455362735061, 0.43337469695473035, 0.49118025152924394, 0.093884938060727313, 0.47216346905220891]
+ conn=[0,1,2,3,4,5,6,7,8,9]
+ coo=DataArrayDouble.New();
+ coo.setValues(coords,10,3);
+ m.setCoords(coo);
+ m.allocateCells(1);
+ m.insertNextCell(NORM_TETRA10,10,conn[0:10])
+ m.finishInsertingCells();
+ #
+ f=MEDCouplingFieldDouble.New(ON_NODES,ONE_TIME);
+ f.setMesh(m);
+ da=DataArrayDouble.New();
+ vals1=[1.1,2.1,3.1,4.1,5.2,6.2,7.2,8.2,9.2,10.2]
+ da.setValues(vals1,10,1);
+ f.setArray(da);
+ #
+ loc=[0.64637931739890486, -0.16185896817550552, 0.22678966365273748]
+ locs=f.getValueOnMulti(loc);
+ expected1=[10.0844021968047]
+ for i in xrange(1):
+ self.assertAlmostEqual(expected1[i],locs.getIJ(0,i),12);
+ pass
+ pass
+
+ def testGetValueOn2(self):
+ m=MEDCouplingDataForTest.build2DTargetMesh_1();
+ f=MEDCouplingFieldDouble.New(ON_CELLS,NO_TIME);
+ f.setMesh(m);
+ arr=DataArrayDouble.New();
+ nbOfCells=m.getNumberOfCells();
+ f.setArray(arr);
+ values1=[7.,107.,10007.,8.,108.,10008.,9.,109.,10009.,10.,110.,10010.,11.,111.,10011.]
+ arr.setValues(values1,nbOfCells,3);
+ loc=[-0.05,-0.05, 0.55,-0.25, 0.55,0.15, -0.05,0.45, 0.45,0.45]
+ f.checkCoherency();
+ locs=f.getValueOnMulti(loc);
+ self.assertEqual(5,locs.getNumberOfTuples());
+ self.assertEqual(3,locs.getNumberOfComponents());
+ for j in xrange(15):
+ self.assertAlmostEqual(values1[j],locs.getIJ(0,j),12);
+ pass
+ # Testing ON_NODES
+ f=MEDCouplingFieldDouble.New(ON_NODES,NO_TIME);
+ f.setMesh(m);
+ arr=DataArrayDouble.New();
+ nbOfNodes=m.getNumberOfNodes();
+ f.setArray(arr);
+ values2=[7.,107.,10007.,8.,108.,10008.,9.,109.,10009.,10.,110.,10010.,11.,111.,10011.,12.,112.,10012.,13.,113.,10013.,14.,114.,10014.,15.,115.,10015.]
+ arr.setValues(values2,nbOfNodes,3);
+ loc2=[0.5432,-0.2432, 0.5478,0.1528, 0.5432,-0.2432, 0.5432,-0.2432]
+ expected2=[9.0272, 109.0272, 10009.0272, 11.4124,111.4124,10011.4124, 9.0272, 109.0272, 10009.0272, 9.0272, 109.0272, 10009.0272]
+ f.checkCoherency();
+ loc3=DataArrayDouble.New()
+ loc3.setValues(loc2,4,2);
+ locs=f.getValueOnMulti(loc3);
+ self.assertEqual(4,locs.getNumberOfTuples());
+ self.assertEqual(3,locs.getNumberOfComponents());
+ for i in xrange(12):
+ self.assertAlmostEqual(expected2[i],locs.getIJ(0,i),12);
+ pass
+ #
+ pass
+
+ def testDAIGetIdsNotEqual1(self):
+ d=DataArrayInt.New();
+ vals1=[2,3,5,6,8,5,5,6,1,-5]
+ d.setValues(vals1,10,1);
+ d2=d.getIdsNotEqual(5);
+ self.assertEqual(7,d2.getNumberOfTuples());
+ self.assertEqual(1,d2.getNumberOfComponents());
+ expected1=[0,1,3,4,7,8,9]
+ for i in xrange(7):
+ self.assertEqual(expected1[i],d2.getIJ(0,i));
+ pass
+ d.rearrange(2);
+ self.assertRaises(InterpKernelException,d.getIdsNotEqual,5);
+ vals2=[-4,5,6]
+ vals3=vals2;
+ d.rearrange(1);
+ d3=d.getIdsNotEqualList(vals3);
+ self.assertEqual(5,d3.getNumberOfTuples());
+ self.assertEqual(1,d3.getNumberOfComponents());
+ expected2=[0,1,4,8,9]
+ for i in xrange(5):
+ self.assertEqual(expected2[i],d3.getIJ(0,i));
+ pass
+ pass
+
+ def testDAIComputeOffsets1(self):
+ d=DataArrayInt.New();
+ vals1=[3,5,1,2,0,8]
+ expected1=[0,3,8,9,11,11]
+ d.setValues(vals1,6,1);
+ d.computeOffsets();
+ self.assertEqual(6,d.getNumberOfTuples());
+ self.assertEqual(1,d.getNumberOfComponents());
+ for i in xrange(6):
+ self.assertEqual(expected1[i],d.getIJ(0,i));
+ pass
+ pass
+
+ def testUMeshHexagonPrism1(self):
+ coords=[0.8660254037844386, 0.5, 0.0, 0.0, 1.0, 0.0, -0.8660254037844386, 0.5, 0.0, -0.8660254037844386, -0.5, 0.0, 0.0, -1.0, 0.0, 0.8660254037844386, -0.5, 0.0,
+ 0.8660254037844386, 0.5, 2.0, 0.0, 1.0, 2.0, -0.8660254037844386, 0.5, 2.0, -0.8660254037844386, -0.5, 2.0, 0.0, -1.0, 2.0, 0.8660254037844386, -0.5, 2.0];
+ conn=[1,2,3,4,5,0,7,8,9,10,11,6]
+ mesh=MEDCouplingUMesh.New("MyFirstHexagonalPrism",3);
+ coo=DataArrayDouble.New();
+ coo.setValues(coords,12,3);
+ mesh.setCoords(coo);
+ mesh.allocateCells(1);
+ mesh.insertNextCell(NORM_HEXGP12,12,conn[0:12])
+ mesh.finishInsertingCells();
+ #
+ mesh.checkCoherency();
+ vols=mesh.getMeasureField(False);
+ self.assertEqual(1,vols.getNumberOfTuples());
+ self.assertEqual(1,vols.getNumberOfComponents());
+ self.assertAlmostEqual(-5.196152422706632,vols.getIJ(0,0),12);
+ bary=mesh.getBarycenterAndOwner();
+ self.assertEqual(1,bary.getNumberOfTuples());
+ self.assertEqual(3,bary.getNumberOfComponents());
+ expected1=[0.,0.,1.]
+ for i in xrange(3):
+ self.assertAlmostEqual(expected1[i],bary.getIJ(0,i),12);
+ pass
+ d1=DataArrayInt.New();
+ d2=DataArrayInt.New();
+ d3=DataArrayInt.New();
+ d4=DataArrayInt.New();
+ m2=mesh.buildDescendingConnectivity(d1,d2,d3,d4);
+ self.assertEqual(8,m2.getNumberOfCells());
+ expected4=[[1,2,3,4,5,0],[7,6,11,10,9,8],[1,7,8,2],[2,8,9,3],[3,9,10,4],[4,10,11,5],[5,11,6,0],[0,6,7,1]];
+ expected2=[NORM_POLYGON, NORM_POLYGON, NORM_QUAD4, NORM_QUAD4, NORM_QUAD4, NORM_QUAD4, NORM_QUAD4, NORM_QUAD4];
+ expected3=[6,6,4,4,4,4,4,4]
+ for i in xrange(8):
+ self.assertTrue(m2.getTypeOfCell(i)==expected2[i]);
+ v=m2.getNodeIdsOfCell(i);
+ self.assertTrue(len(v)==expected3[i]);
+ self.assertEqual(expected4[i],v);
+ #
+ mesh.convertAllToPoly();
+ self.assertTrue(NORM_POLYHED==mesh.getTypeOfCell(0));
+ mesh.unPolyze();
+ self.assertTrue(NORM_HEXGP12==mesh.getTypeOfCell(0));
+ self.assertEqual(13,mesh.getMeshLength());
+ #
+ pass
+
+ def testDADCheckIsMonotonic(self):
+ da=DataArrayDouble.New();
+ da.setValues([-1.,1.01,2.03,6.],2,2);
+ self.assertRaises(InterpKernelException,da.isMonotonic,1e-12);
+ da.rearrange(1);
+ self.assertTrue(da.isMonotonic(1e-12));
+ da.checkMonotonic(1e-12);
+ da.setIJ(2,0,6.1);
+ self.assertTrue(not da.isMonotonic(1e-12));
+ self.assertRaises(InterpKernelException,da.checkMonotonic,1e-12);
+ da.setIJ(2,0,5.99);
+ self.assertTrue(da.isMonotonic(1e-12));
+ self.assertTrue(not da.isMonotonic(1e-1));
+ pass
+
+ def testCheckCoherencyDeeper1(self):
+ m=MEDCouplingDataForTest.build3DSourceMesh_1();
+ m.checkCoherency();
+ m.checkCoherency1();
+ m.getNodalConnectivity().setIJ(8,0,-1);
+ m.checkCoherency();
+ self.assertRaises(InterpKernelException,m.checkCoherency1);
+ m.getNodalConnectivity().setIJ(8,0,-6);
+ m.checkCoherency();
+ self.assertRaises(InterpKernelException,m.checkCoherency1);
+ m.getNodalConnectivity().setIJ(8,0,9);#9>=NbOfNodes
+ m.checkCoherency();
+ self.assertRaises(InterpKernelException,m.checkCoherency1);
+ m.getNodalConnectivity().setIJ(8,0,8);#OK
+ m.checkCoherency();
+ m.checkCoherency1();
+ elts=[1,5]
+ m.convertToPolyTypes(elts);
+ m.checkCoherency();
+ m.checkCoherency1();
+ m.getNodalConnectivity().setIJ(2,0,9);#9>=NbOfNodes
+ m.checkCoherency();
+ self.assertRaises(InterpKernelException,m.checkCoherency1);
+ m.getNodalConnectivity().setIJ(2,0,-3);
+ m.checkCoherency();
+ self.assertRaises(InterpKernelException,m.checkCoherency1);
+ m.getNodalConnectivity().setIJ(2,0,-1);
+ m.checkCoherency();
+ self.assertRaises(InterpKernelException,m.checkCoherency1);#Throw because cell#0 is not a polyhedron
+ m.getNodalConnectivity().setIJ(2,0,4);
+ m.checkCoherency();
+ m.checkCoherency1();
+ m.getNodalConnectivity().setIJ(7,0,-1);
+ m.checkCoherency();
+ m.checkCoherency1();#OK because we are in polyhedron connec
+ m.getNodalConnectivity().setIJ(36,0,14);
+ m.checkCoherency();
+ self.assertRaises(InterpKernelException,m.checkCoherency1);#Throw beacause now cell 5 is a TETRA4 (14) so mimatch of number index and static type.
+ pass
+
+ def testUnPolyze2(self):
+ m=MEDCouplingUMesh.New("jjj",3);
+ coo=DataArrayDouble.New();
+ coo.alloc(4,3);
+ coo.rearrange(1);
+ coo.iota(0);
+ coo.rearrange(3);
+ m.setCoords(coo);
+ m.allocateCells(2);
+ m.insertNextCell(NORM_TETRA4,4,[0,1,2,3]);
+ m.insertNextCell(NORM_TETRA4,4,[0,1,2,3]);
+ m.finishInsertingCells();
+ m2=MEDCouplingUMesh.MergeUMeshesOnSameCoords(4*[m]);
+ m2.convertToPolyTypes([2]);
+ m2.unPolyze();
+ self.assertEqual(NORM_TETRA4,m2.getTypeOfCell(2));
+ self.assertEqual(40,m2.getMeshLength());
+ temp2=m2.getNodeIdsOfCell(2);
+ self.assertEqual(temp2,[0,1,2,3]);
+ m2.checkCoherency1();
+ m3=m2.deepCpy();
+ m2.unPolyze();
+ self.assertTrue(m3.isEqual(m2,1e-12));
+ pass
+
+ def testDACpyFrom1(self):
+ d=DataArrayDouble.New();
+ d.alloc(12,1);
+ d.iota(14.);
+ d.rearrange(3);
+ d.setName("Toto");
+ d.setInfoOnComponent(0,"X [m]");
+ d.setInfoOnComponent(1,"Y [m]");
+ d.setInfoOnComponent(2,"Z [m]");
+ #
+ d1=DataArrayDouble.New();
+ self.assertTrue(not d.isEqual(d1,1e-12));
+ d1.cpyFrom(d);
+ self.assertTrue(d.isEqual(d1,1e-12));
+ d1.cpyFrom(d);
+ self.assertTrue(d.isEqual(d1,1e-12));
+ d1.rearrange(2);
+ self.assertTrue(not d.isEqual(d1,1e-12));
+ d1.cpyFrom(d);
+ self.assertTrue(d.isEqual(d1,1e-12));
+ #
+ d2=d.convertToIntArr();
+ d4=DataArrayInt.New();
+ self.assertTrue(not d2.isEqual(d4));
+ d4.cpyFrom(d2);
+ self.assertTrue(d2.isEqual(d4));
+ d4.cpyFrom(d2);
+ self.assertTrue(d2.isEqual(d4));
+ d4.rearrange(2);
+ self.assertTrue(not d2.isEqual(d4));
+ d4.cpyFrom(d2);
+ self.assertTrue(d2.isEqual(d4));
+ pass
+
+ def testDAITransformWithIndArr1(self):
+ tab1=[17,18,22,19]
+ tab2=[0,1,1,3,3,0,1,3,2,2,3,0]
+ expected=[17,18,18,19,19,17,18,19,22,22,19,17]
+ d=DataArrayInt.New();
+ d.setValues(tab1,4,1);
+ d1=DataArrayInt.New();
+ d1.setValues(tab2,12,1);
+ d2=d1[:]
+ #
+ d1.transformWithIndArr(d);
+ self.assertEqual(12,d1.getNumberOfTuples());
+ self.assertEqual(1,d1.getNumberOfComponents());
+ for i in xrange(12):
+ self.assertEqual(expected[i],d1.getIJ(i,0));
+ pass
+ #
+ d1=d2
+ d1.transformWithIndArr(tab1)
+ self.assertEqual(12,d1.getNumberOfTuples());
+ self.assertEqual(1,d1.getNumberOfComponents());
+ for i in xrange(12):
+ self.assertEqual(expected[i],d1.getIJ(i,0));
+ pass
+ pass
+
+ def testDAIBuildPermArrPerLevel1(self):
+ arr=[2,0,1,1,0,1,2,0,1,1,0,0]
+ expected1=[10,0,5,6,1,7,11,2,8,9,3,4]
+ da=DataArrayInt.New();
+ da.setValues(arr,12,1);
+ da2=da.buildPermArrPerLevel();
+ self.assertEqual(12,da2.getNumberOfTuples());
+ self.assertEqual(1,da2.getNumberOfComponents());
+ for i in xrange(12):
+ self.assertEqual(expected1[i],da2.getIJ(i,0));
+ pass
+ pass
+
+ def testDAIOperations1(self):
+ arr1=[-1,-2,4,7,3,2,6,6,4,3,0,1]
+ da=DataArrayInt.New();
+ da.setValues(arr1,4,3);
+ da1=DataArrayInt.New();
+ da1.alloc(12,1);
+ da1.iota(2);
+ self.assertRaises(InterpKernelException,DataArrayInt.Add,da,da1);#not same number of tuples/Components
+ da1.rearrange(3);
+ da2=DataArrayInt.Add(da,da1);
+ self.assertEqual(4,da2.getNumberOfTuples());
+ self.assertEqual(3,da2.getNumberOfComponents());
+ expected1=[1,1,8,12,9,9,14,15,14,14,12,14]
+ for i in xrange(12):
+ self.assertEqual(expected1[i],da2.getIJ(0,i));
+ pass
+ da1.substractEqual(da);
+ expected2=[3,5,0,-2,3,5,2,3,6,8,12,12]
+ for i in xrange(12):
+ self.assertEqual(expected2[i],da1.getIJ(0,i));
+ pass
+ da1.rearrange(1); da1.iota(2); da1.rearrange(3);
+ da1.addEqual(da);
+ for i in xrange(12):
+ self.assertEqual(expected1[i],da1.getIJ(0,i));
+ pass
+ da1.rearrange(1); da1.iota(2); da1.rearrange(3);
+ da2=DataArrayInt.Multiply(da,da1);
+ self.assertEqual(4,da2.getNumberOfTuples());
+ self.assertEqual(3,da2.getNumberOfComponents());
+ expected3=[-2,-6,16,35,18,14,48,54,40,33,0,13]
+ for i in xrange(12):
+ self.assertEqual(expected3[i],da2.getIJ(0,i));
+ pass
+ da.divideEqual(da1);
+ self.assertEqual(4,da.getNumberOfTuples());
+ self.assertEqual(3,da.getNumberOfComponents());
+ expected4=[0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0]
+ for i in xrange(12):
+ self.assertEqual(expected4[i],da.getIJ(0,i));
+ pass
+ da.setValues(arr1,4,3);
+ da1.multiplyEqual(da);
+ self.assertEqual(4,da1.getNumberOfTuples());
+ self.assertEqual(3,da1.getNumberOfComponents());
+ for i in xrange(12):
+ self.assertEqual(expected3[i],da1.getIJ(0,i));
+ pass
+ da1.rearrange(1); da1.iota(2); da1.rearrange(3);
+ da2=DataArrayInt.Divide(da,da1);
+ self.assertEqual(4,da2.getNumberOfTuples());
+ self.assertEqual(3,da2.getNumberOfComponents());
+ for i in xrange(12):
+ self.assertEqual(expected4[i],da2.getIJ(0,i));
+ pass
+ da1.applyInv(321);
+ self.assertEqual(4,da1.getNumberOfTuples());
+ self.assertEqual(3,da1.getNumberOfComponents());
+ expected5=[160,107,80,64,53,45,40,35,32,29,26,24]
+ for i in xrange(12):
+ self.assertEqual(expected5[i],da1.getIJ(0,i));
+ pass
+ da1.applyDivideBy(2);
+ self.assertEqual(4,da1.getNumberOfTuples());
+ self.assertEqual(3,da1.getNumberOfComponents());
+ expected6=[80,53,40,32,26,22,20,17,16,14,13,12]
+ for i in xrange(12):
+ self.assertEqual(expected6[i],da1.getIJ(0,i));
+ pass
+ expected7=[3,4,5,4,5,1,6,3,2,0,6,5]
+ da1.applyModulus(7);
+ for i in xrange(12):
+ self.assertEqual(expected7[i],da1.getIJ(0,i));
+ pass
+ da1.applyLin(1,1);
+ expected8=[3,3,3,3,3,1,3,3,0,0,3,3]
+ da1.applyRModulus(3);
+ for i in xrange(12):
+ self.assertEqual(expected8[i],da1.getIJ(0,i));
+ pass
+ pass
+
+ def testEmulateMEDMEMBDC1(self):
+ m,m1=MEDCouplingDataForTest.buildPointe_1();
+ m2,da1,da2,da3,da4,da5,da0=m.emulateMEDMEMBDC(m1)
+ expected0=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,36,37,32,33,34,35,38,39,40,41,42,43,44,45,46]
+ expected1=[1,32,29,23,41,36]
+ self.assertEqual(47,da0.getNumberOfTuples());
+ self.assertEqual(1,da0.getNumberOfComponents());
+ for i in xrange(47):
+ self.assertEqual(expected0[i],da0.getIJ(0,i));
+ pass
+ self.assertEqual(6,da5.getNumberOfTuples());
+ self.assertEqual(1,da5.getNumberOfComponents());
+ for i in xrange(6):
+ self.assertEqual(expected1[i],da5.getIJ(0,i));
+ pass
+ expected2=[0,1,2,3,4,0,5,6,7,4,8,9,1,7,10,11,12,13,14,5,15,16,17,8,18,19,20,10,21,22,23,2,13,24,25,21,16,26,27,12,19,28,29,15,22,30,31,18,36,26,28,30,24,37,32,33,34,35,38,36,39,40,41,42,37,38,43,44,45,46]
+ self.assertEqual(70,da1.getNumberOfTuples());
+ self.assertEqual(1,da1.getNumberOfComponents());
+ for i in xrange(70):
+ self.assertEqual(expected2[i],da1.getIJ(0,i));
+ pass
+ expected3=[0,4,8,12,16,20,24,28,32,36,40,44,48,53,58,64,70]
+ self.assertEqual(17,da2.getNumberOfTuples());
+ self.assertEqual(1,da2.getNumberOfComponents());
+ for i in xrange(17):
+ self.assertEqual(expected3[i],da2.getIJ(0,i));
+ pass
+ expected4=[0,2,4,6,7,9,11,12,14,16,17,19,20,22,24,25,27,29,30,32,34,35,37,39,40,42,43,45,46,48,49,51,52,53,54,55,56,58,60,62,63,64,65,66,67,68,69,70]
+ #expected4=[0,2,4,6,7,9,11,12,14,16,17,19,20,22,24,25,27,29,30,32,34,35,37,39,40,42,43,45,46,48,49,51,52,54,56,57,58,59,60,62,63,64,65,66,67,68,69,70];
+ self.assertEqual(48,da4.getNumberOfTuples());
+ self.assertEqual(1,da4.getNumberOfComponents());
+ for i in xrange(48):
+ self.assertEqual(expected4[i],da4.getIJ(0,i));
+ pass
+ expected5=[0,1,0,3,0,7,0,1,2,1,4,1,2,3,2,5,2,3,6,3,4,9,4,8,4,5,10,5,9,5,6,11,6,10,6,7,8,7,11,7,8,12,8,9,12,9,10,12,10,11,12,11,13,13,13,13,12,14,13,15,14,15,14,14,14,14,15,15,15,15]
+ self.assertEqual(70,da3.getNumberOfTuples());
+ self.assertEqual(1,da3.getNumberOfComponents());
+ for i in xrange(70):
+ self.assertEqual(expected5[i],da3.getIJ(0,i));
+ pass
+ pass
+
+ def testGetLevArrPerCellTypes1(self):
+ m,m1=MEDCouplingDataForTest.buildPointe_1();
+ m1,d0,d1,d2,d3=m.buildDescendingConnectivity();
+ order=[NORM_TRI3,NORM_QUAD4];
+ da0,da1=m1.getLevArrPerCellTypes(order);
+ expected0=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,1,1,1,1,1,1,1,1,1]
+ expected1=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,36,37,32,33,34,35,38,39,40,41,42,43,44,45,46]
+ self.assertEqual(47,da0.getNumberOfTuples());
+ self.assertEqual(1,da0.getNumberOfComponents());
+ for i in xrange(47):
+ self.assertEqual(expected0[i],da0.getIJ(0,i));
+ pass
+ self.assertEqual(2,da1.getNumberOfTuples());
+ self.assertEqual(1,da1.getNumberOfComponents());
+ self.assertEqual(36,da1.getIJ(0,0));#36 TRI3
+ self.assertEqual(11,da1.getIJ(1,0));#11 QUAD4
+ #
+ da2=da0.buildPermArrPerLevel();
+ #
+ self.assertEqual(47,da2.getNumberOfTuples());
+ self.assertEqual(1,da2.getNumberOfComponents());
+ for i in xrange(47):
+ self.assertEqual(expected1[i],da2.getIJ(0,i));
+ pass
+ pass
def setUp(self):
pass
# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
#
-from libMEDCoupling_Swig import *
+from MEDCoupling import *
class MEDCouplingDataForTest:
def build2DTargetMesh_1(cls):
myCoords.setValues(targetCoords,9,2);
targetMesh.setCoords(myCoords);
return targetMesh;
+
def build2DSourceMesh_1(cls):
sourceCoords=[-0.3,-0.3, 0.7,-0.3, -0.3,0.7, 0.7,0.7]
sourceConn=[0,3,1,0,2,3]
targetMesh.setCoords(myCoords);
return targetMesh
+ def build3DSourceMesh_1(self):
+ sourceCoords=[ 0.0, 0.0, 200.0, 0.0, 0.0, 0.0, 0.0, 200.0, 200.0, 0.0, 200.0, 0.0, 200.0, 0.0, 200.0,
+ 200.0, 0.0, 0.0, 200.0, 200.0, 200.0, 200.0, 200.0, 0.0, 100.0, 100.0, 100.0]
+ sourceConn=[8,1,7,3, 6,0,8,2, 7,4,5,8, 6,8,4,7, 6,8,0,4, 6,8,7,3, 8,1,3,0, 4,1,5,8, 1,7,5,8, 0,3,8,2, 8,1,0,4, 3,6,8,2]
+ sourceMesh=MEDCouplingUMesh.New();
+ sourceMesh.setMeshDimension(3);
+ sourceMesh.allocateCells(12);
+ sourceMesh.insertNextCell(NORM_TETRA4,4,sourceConn[0:4])
+ sourceMesh.insertNextCell(NORM_TETRA4,4,sourceConn[4:8])
+ sourceMesh.insertNextCell(NORM_TETRA4,4,sourceConn[8:12])
+ sourceMesh.insertNextCell(NORM_TETRA4,4,sourceConn[12:16])
+ sourceMesh.insertNextCell(NORM_TETRA4,4,sourceConn[16:20])
+ sourceMesh.insertNextCell(NORM_TETRA4,4,sourceConn[20:24])
+ sourceMesh.insertNextCell(NORM_TETRA4,4,sourceConn[24:28])
+ sourceMesh.insertNextCell(NORM_TETRA4,4,sourceConn[28:32])
+ sourceMesh.insertNextCell(NORM_TETRA4,4,sourceConn[32:36])
+ sourceMesh.insertNextCell(NORM_TETRA4,4,sourceConn[36:40])
+ sourceMesh.insertNextCell(NORM_TETRA4,4,sourceConn[40:44])
+ sourceMesh.insertNextCell(NORM_TETRA4,4,sourceConn[44:48])
+ sourceMesh.finishInsertingCells();
+ myCoords=DataArrayDouble.New();
+ myCoords.setValues(sourceCoords,9,3);
+ sourceMesh.setCoords(myCoords);
+ return sourceMesh;
+
+
def build3DSurfTargetMesh_1(self):
targetCoords=[-0.3,-0.3,0.5, 0.2,-0.3,1., 0.7,-0.3,1.5, -0.3,0.2,0.5, 0.2,0.2,1., 0.7,0.2,1.5, -0.3,0.7,0.5, 0.2,0.7,1., 0.7,0.7,1.5]
targetConn=[0,3,4,1, 1,4,2, 4,5,2, 6,7,4,3, 7,8,5,4]
def build3DExtrudedUMesh_1(self):
coords=[
- 0.,0.,0., 1.,1.,0., 1.,1.25,0., 0.,1.,0., 1.,1.5,0., 2.,0.,0., 2.,1.,0., 1.,2.,0., 0.,2.,0., 3.,1.,0.,
+ 0.,0.,0., 1.,1.,0., 1.,1.25,0., 1.,0.,0., 1.,1.5,0., 2.,0.,0., 2.,1.,0., 1.,2.,0., 0.,2.,0., 3.,1.,0.,
3.,2.,0., 0.,1.,0., 1.,3.,0., 2.,2.,0., 2.,3.,0.,
- 0.,0.,1., 1.,1.,1., 1.,1.25,1., 0.,1.,1., 1.,1.5,1., 2.,0.,1., 2.,1.,1., 1.,2.,1., 0.,2.,1., 3.,1.,1.,
+ 0.,0.,1., 1.,1.,1., 1.,1.25,1., 1.,0.,1., 1.,1.5,1., 2.,0.,1., 2.,1.,1., 1.,2.,1., 0.,2.,1., 3.,1.,1.,
3.,2.,1., 0.,1.,1., 1.,3.,1., 2.,2.,1., 2.,3.,1.,
- 0.,0.,2., 1.,1.,2., 1.,1.25,2., 0.,1.,2., 1.,1.5,2., 2.,0.,2., 2.,1.,2., 1.,2.,2., 0.,2.,2., 3.,1.,2.,
+ 0.,0.,2., 1.,1.,2., 1.,1.25,2., 1.,0.,2., 1.,1.5,2., 2.,0.,2., 2.,1.,2., 1.,2.,2., 0.,2.,2., 3.,1.,2.,
3.,2.,2., 0.,1.,2., 1.,3.,2., 2.,2.,2., 2.,3.,2.,
- 0.,0.,3., 1.,1.,3., 1.,1.25,3., 0.,1.,3., 1.,1.5,3., 2.,0.,3., 2.,1.,3., 1.,2.,3., 0.,2.,3., 3.,1.,3.,
+ 0.,0.,3., 1.,1.,3., 1.,1.25,3., 1.,0.,3., 1.,1.5,3., 2.,0.,3., 2.,1.,3., 1.,2.,3., 0.,2.,3., 3.,1.,3.,
3.,2.,3., 0.,1.,3., 1.,3.,3., 2.,2.,3., 2.,3.,3.]
conn=[
targetMesh.setCoords(myCoords);
return targetMesh;
+ def buildMultiFields_1(cls):
+ m1=MEDCouplingDataForTest.build2DTargetMesh_1();
+ m1.setName("m1");
+ m2=MEDCouplingDataForTest.build2DTargetMesh_1();
+ m2.setName("m2");
+ vals0=[-0.7,-1.,-2.,-3.,-4.];
+ vals1=[0.,1.,2.,3.,4.,0.1,0.2,0.3,0.4];
+ vals1_1=[170.,171.,172.,173.,174.,170.1,170.2,170.3,170.4];
+ vals2=[5.,6.,7.,8.,9.];
+ vals4=[15.,16.,17.,18.,19.];
+ d0=DataArrayDouble.New();
+ d0.setValues(vals0,5,1);
+ d1=DataArrayDouble.New();
+ d1.setValues(vals1,9,1);
+ d1_1=DataArrayDouble.New();
+ d1_1.setValues(vals1_1,9,1);
+ d2=DataArrayDouble.New();
+ d2.setValues(vals2,5,1);
+ d4=DataArrayDouble.New();
+ d4.setValues(vals4,5,1);
+ d0.setName("d0"); d1.setName("d1"); d1_1.setName("d1_1"); d2.setName("d2"); d4.setName("d4");
+ d0.setInfoOnComponent(0,"c1");
+ d1.setInfoOnComponent(0,"c6");
+ d1_1.setInfoOnComponent(0,"c9");
+ d2.setInfoOnComponent(0,"c5");
+ d4.setInfoOnComponent(0,"c7");
+ f0=MEDCouplingFieldDouble.New(ON_CELLS,ONE_TIME);
+ f0.setMesh(m1);
+ f0.setArray(d0);
+ f0.setTime(0.2,5,6);
+ f0.setName("f0");
+ f1=MEDCouplingFieldDouble.New(ON_NODES,LINEAR_TIME);
+ f1.setMesh(m1);
+ f1.setArrays([d1,d1_1]);
+ f1.setStartTime(0.7,7,8);
+ f1.setEndTime(1.2,9,10);
+ f1.setName("f1");
+ f2=MEDCouplingFieldDouble.New(ON_CELLS,CONST_ON_TIME_INTERVAL);
+ f2.setMesh(m2);
+ f2.setArray(d2);
+ f2.setTime(1.2,11,12);
+ f2.setEndTime(1.5,13,14);
+ f2.setName("f2");
+ f3=MEDCouplingFieldDouble.New(ON_CELLS,ONE_TIME);
+ f3.setMesh(m1);
+ f3.setArray(d2);
+ f3.setTime(1.7,15,16);
+ f3.setName("f3");
+ f4=MEDCouplingFieldDouble.New(ON_CELLS,NO_TIME);
+ f4.setMesh(m2);
+ f4.setArray(d4);
+ f4.setName("f4");
+ ret=MEDCouplingMultiFields.New([f0,f1,f2,f3,f4]);
+ return ret;
+
+ def buildMultiFields_2(cls):
+ m1=MEDCouplingDataForTest.build2DTargetMesh_1();
+ m1.setName("m1");
+ m2=MEDCouplingDataForTest.build2DTargetMesh_1();
+ m2.setName("m2");
+ vals0=[-0.7,-1.,-2.,-3.,-4.];
+ vals1=[0.,1.,2.,3.,4.];
+ vals1_1=[170.,171.,172.,173.,174.];
+ vals2=[5.,6.,7.,8.,9.];
+ vals4=[15.,16.,17.,18.,19.];
+ d0=DataArrayDouble.New();
+ d0.setValues(vals0,5,1);
+ d1=DataArrayDouble.New();
+ d1.setValues(vals1,5,1);
+ d1_1=DataArrayDouble.New();
+ d1_1.setValues(vals1_1,5,1);
+ d2=DataArrayDouble.New();
+ d2.setValues(vals2,5,1);
+ d4=DataArrayDouble.New();
+ d4.setValues(vals4,5,1);
+ d0.setName("d0"); d1.setName("d1"); d1_1.setName("d1_1"); d2.setName("d2"); d4.setName("d4");
+ d0.setInfoOnComponent(0,"c1");
+ d1.setInfoOnComponent(0,"c6");
+ d1_1.setInfoOnComponent(0,"c9");
+ d2.setInfoOnComponent(0,"c5");
+ d4.setInfoOnComponent(0,"c7");
+ f0=MEDCouplingFieldDouble.New(ON_CELLS,ONE_TIME);
+ f0.setMesh(m1);
+ f0.setArray(d0);
+ f0.setTime(0.2,5,6);
+ f0.setName("f0");
+ f1=MEDCouplingFieldDouble.New(ON_CELLS,LINEAR_TIME);
+ f1.setMesh(m1);
+ f1.setArrays([d1,d1_1]);
+ f1.setStartTime(0.7,7,8);
+ f1.setEndTime(1.2,9,10);
+ f1.setName("f1");
+ f2=MEDCouplingFieldDouble.New(ON_CELLS,CONST_ON_TIME_INTERVAL);
+ f2.setMesh(m2);
+ f2.setArray(d2);
+ f2.setTime(1.2,11,12);
+ f2.setEndTime(1.5,13,14);
+ f2.setName("f2");
+ f3=MEDCouplingFieldDouble.New(ON_CELLS,ONE_TIME);
+ f3.setMesh(m1);
+ f3.setArray(d2);
+ f3.setTime(1.7,15,16);
+ f3.setName("f3");
+ f4=MEDCouplingFieldDouble.New(ON_CELLS,NO_TIME);
+ f4.setMesh(m2);
+ f4.setArray(d4);
+ f4.setName("f4");
+ return [f0,f1,f2,f3,f4]
+
+ def build1DMultiTypes_1(self):
+ mesh=MEDCouplingUMesh.New("Multi1DMesh",1);
+ coo=MEDCouplingDataForTest.buildCoordsForMultiTypes_1();
+ conn=[0,2, 0,2,1]
+ mesh.allocateCells(2);
+ mesh.insertNextCell(NORM_SEG2,2,conn[0:2])
+ mesh.insertNextCell(NORM_SEG3,3,conn[2:5])
+ mesh.finishInsertingCells();
+ mesh.setCoords(coo);
+ return mesh;
+
+ def build2DMultiTypes_1(self):
+ mesh=MEDCouplingUMesh.New("Multi2DMesh",2);
+ coo=MEDCouplingDataForTest.buildCoordsForMultiTypes_1();
+ conn=[3,4,5, 3,4,5,6,7,8, 0,9,10,11, 0,9,10,11,12,13,14,15]
+ mesh.allocateCells(4);
+ mesh.insertNextCell(NORM_TRI3,3,conn[0:3])
+ mesh.insertNextCell(NORM_TRI6,6,conn[3:9])
+ mesh.insertNextCell(NORM_QUAD4,4,conn[9:13])
+ mesh.insertNextCell(NORM_QUAD8,8,conn[13:21])
+ mesh.finishInsertingCells();
+ mesh.setCoords(coo);
+ return mesh;
+
+ def build3DMultiTypes_1(self):
+ mesh=MEDCouplingUMesh.New("Multi3DMesh",3);
+ coo=MEDCouplingDataForTest.buildCoordsForMultiTypes_1();
+ conn=[0,16,17,18,
+ 0,16,17,18,19,20,21,22,23,24,
+ 0,11,10,9,25,
+ 0,11,10,9,25,15,14,13,12,26,27,28,29,
+ 0,30,31,32,33,34,
+ 0,30,31,32,33,34,35,36,37,38,39,40,41,42,43,
+ 0,9,10,11,44,45,46,47,
+ 0,9,10,11,44,45,46,47,12,13,14,15,48,49,50,51,52,53,54,55 ];
+ mesh.allocateCells(8);
+ mesh.insertNextCell(NORM_TETRA4,4,conn[0:4])
+ mesh.insertNextCell(NORM_TETRA10,10,conn[4:14])
+ mesh.insertNextCell(NORM_PYRA5,5,conn[14:19])
+ mesh.insertNextCell(NORM_PYRA13,13,conn[19:32])
+ mesh.insertNextCell(NORM_PENTA6,6,conn[32:38])
+ mesh.insertNextCell(NORM_PENTA15,15,conn[38:53])
+ mesh.insertNextCell(NORM_HEXA8,8,conn[53:61])
+ mesh.insertNextCell(NORM_HEXA20,20,conn[61:81])
+ mesh.finishInsertingCells();
+ mesh.setCoords(coo);
+ return mesh;
+
+ def buildCoordsForMultiTypes_1(self):
+ coords=DataArrayDouble.New();
+ data=[0.0,0.0,0.0, 0.5,0.5,0.5, 1.0,1.0,1.0, 1.0,1.0,0.0, 2.0,2.5,0.0, 6.0,1.5,0.0, 1.0,2.0,0.0, 4.5,2.5,0.0, 4.0,0.5,0.0, 0.0,4.0,0.0, 4.0,4.0,0.0, 4.0,0.0,0.0, 0.0,2.0,0.0, 2.0,4.0,0.0, 4.0,2.0,0.0, 2.0,0.0,0.0, 0.0,6.0,0.0, 3.0,3.0,0.0, 1.3,3.0,3.0, 0.0,3.0,0.0, 1.5,4.5,0.0, 1.5,1.5,0.0, 0.65,1.5,1.5, 0.65,4.5,1.5, 2.15,3.0,1.5, 2.0,2.0,2.0, 3.0,1.0,1.0, 3.0,3.0,1.0, 1.0,3.0,1.0, 1.0,1.0,1.0, 0.0,3.0,0.0, 2.0,0.0,0.0, 0.0,0.0,6.0, 0.0,3.0,6.0, 3.0,0.0,6.0, 0.0,1.5,0.0, 1.5,1.5,0.0, 1.5,0.0,0.0, 0.0,1.5,6.0, 1.5,1.5,6.0, 1.5,0.0,6.0, 0.0,0.0,3.0, 0.0,3.0,3.0, 3.0,0.0,3.0, 0.0,0.0,4.0, 0.0,4.0,4.0, 4.0,4.0,4.0, 4.0,0.0,4.0, 0.0,2.0,4.0, 2.0,4.0,4.0, 4.0,2.0,4.0, 2.0,0.0,4.0, 0.0,0.0,2.0, 0.0,4.0,2.0, 4.0,4.0,2.0, 4.0,0.0,2.0]
+ coords.setValues(data,56,3);
+ coords.setInfoOnComponent(0,"X (cm)");
+ coords.setInfoOnComponent(1,"Y (cm)");
+ coords.setInfoOnComponent(2,"Z (cm)");
+ return coords
+
+ def buildHexa8Mesh_1(self):
+ mesh=MEDCouplingUMesh.New("Hexa8Only",3);
+ coo=DataArrayDouble.New();
+ coords=[0.0, 0.0, 0.0, 0.5, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.5, 0.0, 0.5, 0.5, 0.0, 1.0, 0.5, 0.0, 0.0, 1.0, 0.0, 0.5, 1.0, 0.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.5, 0.5, 0.0, 0.5, 1.0, 0.0, 0.5, 0.0, 0.5, 0.5, 0.5, 0.5, 0.5, 1.0, 0.5, 0.5, 0.0, 1.0, 0.5, 0.5, 1.0, 0.5, 1.0, 1.0, 0.5, 0.0, 0.0, 1.0, 0.5, 0.0, 1.0, 1.0, 0.0, 1.0, 0.0, 0.5, 1.0, 0.5, 0.5, 1.0, 1.0, 0.5, 1.0, 0.0, 1.0, 1.0, 0.5, 1.0, 1.0, 1.0, 1.0, 1.0]
+ coo.setValues(coords,27,3);
+ conn=[3,12,13,4,0,9,10,1,
+ 4,13,14,5,1,10,11,2,
+ 6,15,16,7,3,12,13,4,
+ 7,16,17,8,4,13,14,5,
+ 12,21,22,13,9,18,19,10,
+ 13,22,23,14,10,19,20,11,
+ 15,24,25,16,12,21,22,13,
+ 16,25,26,17,13,22,23,14];
+ mesh.allocateCells(8);
+ for i in xrange(8):
+ mesh.insertNextCell(NORM_HEXA8,8,conn[8*i:8*(i+1)])
+ pass
+ mesh.finishInsertingCells();
+ mesh.setCoords(coo);
+ return mesh;
+
+ def buildPointe_1(self):
+ mesh=MEDCouplingUMesh.New("Pointe.med",3);
+ mesh2=MEDCouplingUMesh.New("Pointe.med",2);
+ coords=[0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 2.0, 0.0, 1.0, 0.0, 2.0, 1.0, -2.0, 0.0, 1.0, 0.0, -2.0, 1.0, 1.0, 1.0, 2.0, -1.0, 1.0, 2.0, -1.0, -1.0, 2.0, 1.0, -1.0, 2.0, 1.0, 1.0, 3.0, -1.0, 1.0, 3.0, -1.0, -1.0, 3.0, 1.0, -1.0, 3.0, 1.0, 1.0, 4.0, -1.0, 1.0, 4.0, -1.0, -1.0, 4.0, 1.0, -1.0, 4.0, 0.0, 0.0, 5.0]
+ conn=[0,1,2,5,0,1,3,2,0,1,4,3,0,1,5,4,1,6,3,2,1,7,4,3,1,8,5,4,1,9,2,5,1,6,2,9,1,7,3,6,1,8,4,7,1,9,5,8, 6,7,8,9,1,14,17,16,15,18, 10,11,12,13,6,7,8,9,14,15,16,17,10,11,12,13]
+ coo=DataArrayDouble.New();
+ coo.setValues(coords,19,3);
+ mesh.setCoords(coo);
+ mesh2.setCoords(coo);
+ mesh.allocateCells(16);
+ for i in xrange(12):
+ mesh.insertNextCell(NORM_TETRA4,4,conn[4*i:4*i+4])
+ pass
+ mesh.insertNextCell(NORM_PYRA5,5,conn[48:53])
+ mesh.insertNextCell(NORM_PYRA5,5,conn[53:58])
+ mesh.insertNextCell(NORM_HEXA8,8,conn[58:66])
+ mesh.insertNextCell(NORM_HEXA8,8,conn[66:74])
+ mesh.finishInsertingCells();
+ #[1,34,29,23,41,32]
+ conn2=[0,5,1,14,18,17,8,7,4,9,5,2, 12,8,9,13,6,7,8,9]
+ mesh2.allocateCells(6);
+ for i in xrange(4):
+ mesh2.insertNextCell(NORM_TRI3,3,conn2[3*i:3*i+3])
+ pass
+ mesh2.insertNextCell(NORM_QUAD4,4,conn2[12:16])
+ mesh2.insertNextCell(NORM_QUAD4,4,conn2[16:20])
+ mesh2.finishInsertingCells();
+ return [mesh,mesh2]
+
build2DTargetMesh_1=classmethod(build2DTargetMesh_1)
build2DSourceMesh_1=classmethod(build2DSourceMesh_1)
build3DTargetMesh_1=classmethod(build3DTargetMesh_1)
+ build3DSourceMesh_1=classmethod(build3DSourceMesh_1)
build3DSurfTargetMesh_1=classmethod(build3DSurfTargetMesh_1)
build3DExtrudedUMesh_1=classmethod(build3DExtrudedUMesh_1)
buildCU1DMesh_U=classmethod(buildCU1DMesh_U)
build2DCurveTargetMesh_3=classmethod(build2DCurveTargetMesh_3)
build2DTargetMesh_3=classmethod(build2DTargetMesh_3)
build2DTargetMesh_4=classmethod(build2DTargetMesh_4)
+ buildMultiFields_1=classmethod(buildMultiFields_1)
+ buildMultiFields_2=classmethod(buildMultiFields_2)
+ build1DMultiTypes_1=classmethod(build1DMultiTypes_1)
+ build2DMultiTypes_1=classmethod(build2DMultiTypes_1)
+ build3DMultiTypes_1=classmethod(build3DMultiTypes_1)
+ buildCoordsForMultiTypes_1=classmethod(buildCoordsForMultiTypes_1)
+ buildHexa8Mesh_1=classmethod(buildHexa8Mesh_1)
+ buildPointe_1=classmethod(buildPointe_1)
pass
--- /dev/null
+// Copyright (C) 2007-2010 CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+%module MEDCouplingRemapper
+
+#define MEDCOUPLING_EXPORT
+#define INTERPKERNEL_EXPORT
+#define MEDCOUPLINGREMAPPER_EXPORT
+
+%{
+#include "MEDCouplingMemArray.hxx"
+#include "MEDCouplingUMesh.hxx"
+#include "MEDCouplingField.hxx"
+#include "MEDCouplingFieldDouble.hxx"
+#include "MEDCouplingRemapper.hxx"
+
+using namespace ParaMEDMEM;
+using namespace INTERP_KERNEL;
+%}
+
+%newobject ParaMEDMEM::MEDCouplingRemapper::transferField;
+%newobject ParaMEDMEM::MEDCouplingRemapper::reverseTransferField;
+
+%include "MEDCoupling.i"
+%include "InterpolationOptions.hxx"
+%include "MEDCouplingRemapper.hxx"
# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
#
-from libMEDCouplingRemapper_Swig import *
+from MEDCouplingRemapper import *
from math import *
import unittest
pass
self.failUnless(1==trgfield.getArray().getNumberOfComponents());
pass
+
+ def testPrepareEx1(self):
+ sourceMesh=self.build2DSourceMesh_1();
+ targetMesh=self.build2DTargetMesh_3();
+ #
+ remapper=MEDCouplingRemapper();
+ remapper.setPrecision(1e-12);
+ remapper.setIntersectionType(Triangulation);
+ srcFt=MEDCouplingFieldTemplate.New(ON_CELLS);
+ trgFt=MEDCouplingFieldTemplate.New(ON_CELLS);
+ srcFt.setMesh(sourceMesh);
+ trgFt.setMesh(targetMesh);
+ self.assertEqual(1,remapper.prepareEx(srcFt,trgFt));
+ srcField=MEDCouplingFieldDouble.New(ON_CELLS);
+ srcField.setNature(ConservativeVolumic);
+ srcField.setMesh(sourceMesh);
+ array=DataArrayDouble.New();
+ ptr=sourceMesh.getNumberOfCells()*[None]
+ for i in xrange(sourceMesh.getNumberOfCells()):
+ ptr[i]=float(i+7);
+ pass
+ array.setValues(ptr,sourceMesh.getNumberOfCells(),1);
+ srcField.setArray(array);
+ trgfield=remapper.transferField(srcField,4.220173);
+ values=trgfield.getArray().getValues();
+ valuesExpected=[7.75, 7.0625, 4.220173,8.0]
+ self.assertEqual(4,trgfield.getArray().getNumberOfTuples());
+ self.assertEqual(1,trgfield.getArray().getNumberOfComponents());
+ for i0 in xrange(4):
+ self.assertAlmostEqual(valuesExpected[i0],values[i0],12);
+ pass
+ pass
def build2DSourceMesh_1(self):
sourceCoords=[-0.3,-0.3, 0.7,-0.3, -0.3,0.7, 0.7,0.7]
myCoords.setValues(targetCoords,9,2);
targetMesh.setCoords(myCoords);
return targetMesh;
+
+ def build2DTargetMesh_3(self):
+ targetCoords=[-0.6,-0.4, -0.1,-0.4, 1.1,-0.4, 2.1,-0.4, -0.6,0.1, -0.1,0.1, 1.1,0.1, 2.1,0.1, -0.6,1.1, -0.1,1.1]
+ targetConn=[0,4,5,1, 1,5,6,2, 2,6,7,3, 4,8,9,5]
+ targetMesh=MEDCouplingUMesh.New();
+ targetMesh.setMeshDimension(2);
+ targetMesh.allocateCells(4);
+ for i in xrange(4):
+ targetMesh.insertNextCell(NORM_QUAD4,4,targetConn[4*i:4*(i+1)])
+ pass
+ targetMesh.finishInsertingCells();
+ myCoords=DataArrayDouble.New();
+ myCoords.setValues(targetCoords,10,2);
+ targetMesh.setCoords(myCoords);
+ return targetMesh;
+ pass
def setUp(self):
pass
#include <numpy/arrayobject.h>
#endif
-static PyObject* convertMesh(ParaMEDMEM::MEDCouplingMesh* mesh, int owner)
+static PyObject* convertMesh(ParaMEDMEM::MEDCouplingMesh* mesh, int owner) throw(INTERP_KERNEL::Exception)
{
PyObject *ret=0;
if(dynamic_cast<ParaMEDMEM::MEDCouplingUMesh *>(mesh))
ret=SWIG_NewPointerObj((void*)mesh,SWIGTYPE_p_ParaMEDMEM__MEDCouplingCMesh,owner);
if(!ret)
{
- PyErr_SetString(PyExc_TypeError,"Not recognized type of mesh on downcast !");
- PyErr_Print();
+ const char msg[]="Not recognized type of mesh on downcast !";
+ PyErr_SetString(PyExc_TypeError,msg);
+ throw INTERP_KERNEL::Exception(msg);
}
return ret;
}
-static PyObject *convertIntArrToPyList(const int *ptr, int size)
+static PyObject* convertMultiFields(ParaMEDMEM::MEDCouplingMultiFields *mfs, int owner) throw(INTERP_KERNEL::Exception)
+{
+ PyObject *ret=0;
+ if(dynamic_cast<ParaMEDMEM::MEDCouplingFieldOverTime *>(mfs))
+ ret=SWIG_NewPointerObj((void*)mfs,SWIGTYPE_p_ParaMEDMEM__MEDCouplingFieldOverTime,owner);
+ else
+ ret=SWIG_NewPointerObj((void*)mfs,SWIGTYPE_p_ParaMEDMEM__MEDCouplingMultiFields,owner);
+ return ret;
+}
+
+static PyObject *convertIntArrToPyList(const int *ptr, int size) throw(INTERP_KERNEL::Exception)
{
#ifndef WITH_NUMPY2
PyObject *ret=PyList_New(size);
#endif
}
-static PyObject *convertIntArrToPyList2(const std::vector<int>& v)
+static PyObject *convertIntArrToPyList2(const std::vector<int>& v) throw(INTERP_KERNEL::Exception)
{
#ifndef WITH_NUMPY2
int size=v.size();
#endif
}
-static PyObject *convertIntArrToPyListOfTuple(const int *vals, int nbOfComp, int nbOfTuples)
+static PyObject *convertIntArrToPyList3(const std::set<int>& v) throw(INTERP_KERNEL::Exception)
+{
+ int size=v.size();
+ PyObject *ret=PyList_New(size);
+ std::set<int>::const_iterator it=v.begin();
+ for(int i=0;i<size;i++,it++)
+ PyList_SetItem(ret,i,PyInt_FromLong(*it));
+ return ret;
+}
+
+static PyObject *convertIntArrToPyListOfTuple(const int *vals, int nbOfComp, int nbOfTuples) throw(INTERP_KERNEL::Exception)
{
PyObject *ret=PyList_New(nbOfTuples);
for(int i=0;i<nbOfTuples;i++)
return ret;
}
-static int *convertPyToNewIntArr2(PyObject *pyLi, int *size)
+static int *convertPyToNewIntArr2(PyObject *pyLi, int *size) throw(INTERP_KERNEL::Exception)
{
if(PyList_Check(pyLi))
{
else
{
delete [] tmp;
- PyErr_SetString(PyExc_TypeError,"list must contain integers only");
- PyErr_Print();
- return NULL;
+ const char msg[]="list must contain integers only";
+ PyErr_SetString(PyExc_TypeError,msg);
+ throw INTERP_KERNEL::Exception(msg);
+ }
+ }
+ return tmp;
+ }
+ else if(PyTuple_Check(pyLi))
+ {
+ *size=PyTuple_Size(pyLi);
+ int *tmp=new int[*size];
+ for(int i=0;i<*size;i++)
+ {
+ PyObject *o=PyTuple_GetItem(pyLi,i);
+ if(PyInt_Check(o))
+ {
+ int val=(int)PyInt_AS_LONG(o);
+ tmp[i]=val;
+ }
+ else
+ {
+ delete [] tmp;
+ const char msg[]="tuple must contain integers only";
+ PyErr_SetString(PyExc_TypeError,msg);
+ throw INTERP_KERNEL::Exception(msg);
}
}
return tmp;
else
{
#ifndef WITH_NUMPY2
- PyErr_SetString(PyExc_TypeError,"convertPyToNewIntArr2 : not a list");
- PyErr_Print();
- return 0;
+ const char msg[]="convertPyToNewIntArr2 : not a list";
+ PyErr_SetString(PyExc_TypeError,msg);
+ throw INTERP_KERNEL::Exception(msg);
#else
if(PyArray_Check(pyLi))
{
}
else
{
- PyErr_SetString(PyExc_TypeError,"convertPyToNewIntArr2 : not a list nor PyArray");
- PyErr_Print();
- return 0;
+ const char msg[]="convertPyToNewIntArr2 : not a list nor PyArray";
+ PyErr_SetString(PyExc_TypeError,msg);
+ throw INTERP_KERNEL::Exception(msg);
}
#endif
}
}
-static void convertPyToNewIntArr3(PyObject *pyLi, std::vector<int>& arr)
+static void convertPyToNewIntArr3(PyObject *pyLi, std::vector<int>& arr) throw(INTERP_KERNEL::Exception)
{
if(PyList_Check(pyLi))
{
}
else
{
- PyErr_SetString(PyExc_TypeError,"list must contain integers only");
- PyErr_Print();
+ const char msg[]="list must contain integers only";
+ PyErr_SetString(PyExc_TypeError,msg);
+ throw INTERP_KERNEL::Exception(msg);
+ }
+ }
+ }
+ else if(PyTuple_Check(pyLi))
+ {
+ int size=PyTuple_Size(pyLi);
+ arr.resize(size);
+ for(int i=0;i<size;i++)
+ {
+ PyObject *o=PyTuple_GetItem(pyLi,i);
+ if(PyInt_Check(o))
+ {
+ int val=(int)PyInt_AS_LONG(o);
+ arr[i]=val;
+ }
+ else
+ {
+ const char msg[]="tuple must contain integers only";
+ PyErr_SetString(PyExc_TypeError,msg);
+ throw INTERP_KERNEL::Exception(msg);
}
}
}
else
{
#ifndef WITH_NUMPY2
- PyErr_SetString(PyExc_TypeError,"convertPyToNewIntArr3 : not a list");
- PyErr_Print();
- return ;
+ const char msg[]="convertPyToNewIntArr3 : not a list";
+ PyErr_SetString(PyExc_TypeError,msg);
+ throw INTERP_KERNEL::Exception(msg);
#else
if(PyArray_Check(pyLi))
{
}
else
{
- PyErr_SetString(PyExc_TypeError,"convertPyToNewIntArr3 : not a list nor PyArray");
- PyErr_Print();
- return ;
+ const char msg[]="convertPyToNewIntArr3 : not a list nor PyArray";
+ PyErr_SetString(PyExc_TypeError,msg);
+ throw INTERP_KERNEL::Exception(msg);
}
#endif
}
}
-static PyObject *convertDblArrToPyList(const double *ptr, int size)
+static void fillArrayWithPyListInt(PyObject *pyLi, int *arrToFill, int sizeOfArray, int dftVal) throw(INTERP_KERNEL::Exception)
+{
+ if(PyList_Check(pyLi))
+ {
+ int size=PyList_Size(pyLi);
+ for(int i=0;i<size;i++)
+ {
+ PyObject *o=PyList_GetItem(pyLi,i);
+ if(PyInt_Check(o))
+ {
+ int val=(int)PyInt_AS_LONG(o);
+ if(i<sizeOfArray)
+ arrToFill[i]=val;
+ }
+ else
+ {
+ const char msg[]="list must contain integers only";
+ PyErr_SetString(PyExc_TypeError,msg);
+ throw INTERP_KERNEL::Exception(msg);
+ }
+ }
+ for(int i=size;i<sizeOfArray;i++)
+ arrToFill[i]=dftVal;
+ return;
+
+ }
+ else if(PyTuple_Check(pyLi))
+ {
+ int size=PyTuple_Size(pyLi);
+ for(int i=0;i<size;i++)
+ {
+ PyObject *o=PyTuple_GetItem(pyLi,i);
+ if(PyInt_Check(o))
+ {
+ int val=(int)PyInt_AS_LONG(o);
+ if(i<sizeOfArray)
+ arrToFill[i]=val;
+ }
+ else
+ {
+ const char msg[]="tuple must contain integers only";
+ PyErr_SetString(PyExc_TypeError,msg);
+ throw INTERP_KERNEL::Exception(msg);
+ }
+ }
+ for(int i=size;i<sizeOfArray;i++)
+ arrToFill[i]=dftVal;
+ return;
+ }
+ else
+ {
+ const char msg[]="fillArrayWithPyListInt : not a list";
+ PyErr_SetString(PyExc_TypeError,msg);
+ throw INTERP_KERNEL::Exception(msg);
+ }
+}
+
+static PyObject *convertDblArrToPyList(const double *ptr, int size) throw(INTERP_KERNEL::Exception)
{
PyObject *ret=PyList_New(size);
for(int i=0;i<size;i++)
return ret;
}
-static PyObject *convertDblArrToPyList2(const std::vector<double>& v)
+static PyObject *convertDblArrToPyList2(const std::vector<double>& v) throw(INTERP_KERNEL::Exception)
{
int size=v.size();
PyObject *ret=PyList_New(size);
return ret;
}
-static PyObject *convertDblArrToPyListOfTuple(const double *vals, int nbOfComp, int nbOfTuples)
+static PyObject *convertDblArrToPyListOfTuple(const double *vals, int nbOfComp, int nbOfTuples) throw(INTERP_KERNEL::Exception)
{
PyObject *ret=PyList_New(nbOfTuples);
for(int i=0;i<nbOfTuples;i++)
return ret;
}
-static double *convertPyToNewDblArr2(PyObject *pyLi, int *size)
+static double *convertPyToNewDblArr2(PyObject *pyLi, int *size) throw(INTERP_KERNEL::Exception)
{
if(PyList_Check(pyLi))
{
double val=PyFloat_AS_DOUBLE(o);
tmp[i]=val;
}
+ else if(PyInt_Check(o))
+ {
+ long val0=PyInt_AS_LONG(o);
+ double val=val0;
+ tmp[i]=val;
+ }
+ else
+ {
+ delete [] tmp;
+ const char msg[]="convertPyToNewDblArr2 : list must contain floats/integers only";
+ PyErr_SetString(PyExc_TypeError,msg);
+ throw INTERP_KERNEL::Exception(msg);
+ }
+ }
+ return tmp;
+ }
+ else if(PyTuple_Check(pyLi))
+ {
+ *size=PyTuple_Size(pyLi);
+ double *tmp=new double[*size];
+ for(int i=0;i<*size;i++)
+ {
+ PyObject *o=PyTuple_GetItem(pyLi,i);
+ if(PyFloat_Check(o))
+ {
+ double val=PyFloat_AS_DOUBLE(o);
+ tmp[i]=val;
+ }
+ else if(PyInt_Check(o))
+ {
+ long val0=PyInt_AS_LONG(o);
+ double val=val0;
+ tmp[i]=val;
+ }
else
{
- PyErr_SetString(PyExc_TypeError,"convertPyToNewDblArr2 : list must contain floats only");
- PyErr_Print();
- return NULL;
+ delete [] tmp;
+ const char msg[]="convertPyToNewDblArr2 : tuple must contain floats/integers only";
+ PyErr_SetString(PyExc_TypeError,msg);
+ throw INTERP_KERNEL::Exception(msg);
}
}
return tmp;
}
else
{
- PyErr_SetString(PyExc_TypeError,"convertPyToNewIntArr : not a list");
- PyErr_Print();
- return 0;
+ const char msg[]="convertPyToNewDblArr2 : not a list";
+ PyErr_SetString(PyExc_TypeError,msg);
+ throw INTERP_KERNEL::Exception(msg);
+ }
+}
+
+static void fillArrayWithPyListDbl(PyObject *pyLi, double *arrToFill, int sizeOfArray, double dftVal) throw(INTERP_KERNEL::Exception)
+{
+ if(PyList_Check(pyLi))
+ {
+ int size=PyList_Size(pyLi);
+ for(int i=0;i<size;i++)
+ {
+ PyObject *o=PyList_GetItem(pyLi,i);
+ if(PyFloat_Check(o))
+ {
+ double val=PyFloat_AS_DOUBLE(o);
+ if(i<sizeOfArray)
+ arrToFill[i]=val;
+ }
+ else if(PyInt_Check(o))
+ {
+ long val0=PyInt_AS_LONG(o);
+ double val=val0;
+ if(i<sizeOfArray)
+ arrToFill[i]=val;
+ }
+ else
+ {
+ const char msg[]="fillArrayWithPyListDbl : list must contain floats/integers only";
+ PyErr_SetString(PyExc_TypeError,msg);
+ throw INTERP_KERNEL::Exception(msg);
+ }
+ }
+ for(int i=size;i<sizeOfArray;i++)
+ arrToFill[i]=dftVal;
+ return;
+ }
+ else if(PyTuple_Check(pyLi))
+ {
+ int size=PyTuple_Size(pyLi);
+ for(int i=0;i<size;i++)
+ {
+ PyObject *o=PyTuple_GetItem(pyLi,i);
+ if(PyFloat_Check(o))
+ {
+ double val=PyFloat_AS_DOUBLE(o);
+ arrToFill[i]=val;
+ }
+ else if(PyInt_Check(o))
+ {
+ long val0=PyInt_AS_LONG(o);
+ double val=val0;
+ arrToFill[i]=val;
+ }
+ else
+ {
+ const char msg[]="fillArrayWithPyListDbl : tuple must contain floats/integers only";
+ PyErr_SetString(PyExc_TypeError,msg);
+ throw INTERP_KERNEL::Exception(msg);
+ }
+ }
+ for(int i=size;i<sizeOfArray;i++)
+ arrToFill[i]=dftVal;
+ return ;
+ }
+ else
+ {
+ const char msg[]="convertPyToNewIntArr : not a list";
+ PyErr_SetString(PyExc_TypeError,msg);
+ throw INTERP_KERNEL::Exception(msg);
}
}
-void convertPyObjToVecUMeshes(PyObject *ms, std::vector<ParaMEDMEM::MEDCouplingUMesh *>& v)
+void convertPyObjToVecUMeshesCst(PyObject *ms, std::vector<const ParaMEDMEM::MEDCouplingUMesh *>& v) throw(INTERP_KERNEL::Exception)
{
if(PyList_Check(ms))
{
int status=SWIG_ConvertPtr(obj,&argp,SWIGTYPE_p_ParaMEDMEM__MEDCouplingUMesh,0|0);
if(!SWIG_IsOK(status))
{
- PyErr_SetString(PyExc_TypeError,"list must contain only DataArrayInt");
- PyErr_Print();
- return;
+ const char msg[]="list must contain only MEDCouplingUMesh";
+ PyErr_SetString(PyExc_TypeError,msg);
+ throw INTERP_KERNEL::Exception(msg);
+ }
+ const ParaMEDMEM::MEDCouplingUMesh *arg=reinterpret_cast< const ParaMEDMEM::MEDCouplingUMesh * >(argp);
+ v[i]=arg;
+ }
+ }
+ else
+ {
+ const char msg[]="convertPyObjToVecUMeshesCst : not a list";
+ PyErr_SetString(PyExc_TypeError,msg);
+ throw INTERP_KERNEL::Exception(msg);
+ }
+}
+
+void convertPyObjToVecDataArrayDblCst(PyObject *ms, std::vector<const ParaMEDMEM::DataArrayDouble *>& v) throw(INTERP_KERNEL::Exception)
+{
+ if(PyList_Check(ms))
+ {
+ int size=PyList_Size(ms);
+ v.resize(size);
+ for(int i=0;i<size;i++)
+ {
+ PyObject *obj=PyList_GetItem(ms,i);
+ void *argp;
+ int status=SWIG_ConvertPtr(obj,&argp,SWIGTYPE_p_ParaMEDMEM__DataArrayDouble,0|0);
+ if(!SWIG_IsOK(status))
+ {
+ const char msg[]="list must contain only DataArrayDouble";
+ PyErr_SetString(PyExc_TypeError,msg);
+ throw INTERP_KERNEL::Exception(msg);
+ }
+ const ParaMEDMEM::DataArrayDouble *arg=reinterpret_cast< const ParaMEDMEM::DataArrayDouble * >(argp);
+ v[i]=arg;
+ }
+ }
+ else
+ {
+ const char msg[]="convertPyObjToVecDataArrayDblCst : not a list";
+ PyErr_SetString(PyExc_TypeError,msg);
+ throw INTERP_KERNEL::Exception(msg);
+ }
+}
+
+void convertPyObjToVecFieldDblCst(PyObject *ms, std::vector<const ParaMEDMEM::MEDCouplingFieldDouble *>& v) throw(INTERP_KERNEL::Exception)
+{
+ if(PyList_Check(ms))
+ {
+ int size=PyList_Size(ms);
+ v.resize(size);
+ for(int i=0;i<size;i++)
+ {
+ PyObject *obj=PyList_GetItem(ms,i);
+ void *argp;
+ int status=SWIG_ConvertPtr(obj,&argp,SWIGTYPE_p_ParaMEDMEM__MEDCouplingFieldDouble,0|0);
+ if(!SWIG_IsOK(status))
+ {
+ const char msg[]="list must contain only MEDCouplingFieldDouble";
+ PyErr_SetString(PyExc_TypeError,msg);
+ throw INTERP_KERNEL::Exception(msg);
}
- ParaMEDMEM::MEDCouplingUMesh *arg=reinterpret_cast< ParaMEDMEM::MEDCouplingUMesh * >(argp);
+ const ParaMEDMEM::MEDCouplingFieldDouble *arg=reinterpret_cast< const ParaMEDMEM::MEDCouplingFieldDouble * >(argp);
v[i]=arg;
}
}
else
{
- PyErr_SetString(PyExc_TypeError,"convertPyObjToVecUMeshes : not a list");
- PyErr_Print();
+ const char msg[]="convertPyObjToVecFieldDblCst : not a list";
+ PyErr_SetString(PyExc_TypeError,msg);
+ throw INTERP_KERNEL::Exception(msg);
}
}
-void convertPyObjToVecDataArrayInt(PyObject *ms, std::vector<ParaMEDMEM::DataArrayInt *>& v)
+void convertPyObjToVecDataArrayIntCst(PyObject *ms, std::vector<const ParaMEDMEM::DataArrayInt *>& v) throw(INTERP_KERNEL::Exception)
{
if(PyList_Check(ms))
{
int status=SWIG_ConvertPtr(obj,&argp,SWIGTYPE_p_ParaMEDMEM__DataArrayInt,0|0);
if(!SWIG_IsOK(status))
{
- PyErr_SetString(PyExc_TypeError,"list must contain only DataArrayInt");
- PyErr_Print();
- return;
+ const char msg[]="list must contain only DataArrayInt";
+ PyErr_SetString(PyExc_TypeError,msg);
+ throw INTERP_KERNEL::Exception(msg);
}
ParaMEDMEM::DataArrayInt *arg=reinterpret_cast< ParaMEDMEM::DataArrayInt * >(argp);
v[i]=arg;
}
else
{
- PyErr_SetString(PyExc_TypeError,"convertPyObjToVecDataArrayInt : not a list");
- PyErr_Print();
+ const char msg[]="convertPyObjToVecDataArrayInt : not a list";
+ PyErr_SetString(PyExc_TypeError,msg);
+ throw INTERP_KERNEL::Exception(msg);
+ }
+}
+
+/*!
+ * if python int -> cpp int sw=1
+ * if python list[int] -> cpp vector<int> sw=2
+ * if python tuple[int] -> cpp vector<int> sw=2
+ * if python DataArrayInt -> cpp DataArrayInt sw=3
+ *
+ * switch between (int,vector<int>,DataArrayInt)
+ */
+static void convertObjToPossibleCpp1(PyObject *value, int& sw, int& iTyypp, std::vector<int>& stdvecTyypp, ParaMEDMEM::DataArrayInt *& daIntTyypp) throw(INTERP_KERNEL::Exception)
+{
+ sw=-1;
+ if(PyInt_Check(value))
+ {
+ iTyypp=(int)PyInt_AS_LONG(value);
+ sw=1;
+ return;
+ }
+ if(PyTuple_Check(value))
+ {
+ int size=PyTuple_Size(value);
+ stdvecTyypp.resize(size);
+ for(int i=0;i<size;i++)
+ {
+ PyObject *o=PyTuple_GetItem(value,i);
+ if(PyInt_Check(o))
+ stdvecTyypp[i]=(int)PyInt_AS_LONG(o);
+ else
+ {
+ std::ostringstream oss; oss << "Tuple as been detected but element #" << i << " is not integer ! only tuples of integers accepted !";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ }
+ sw=2;
+ return;
+ }
+ if(PyList_Check(value))
+ {
+ int size=PyList_Size(value);
+ stdvecTyypp.resize(size);
+ for(int i=0;i<size;i++)
+ {
+ PyObject *o=PyList_GetItem(value,i);
+ if(PyInt_Check(o))
+ stdvecTyypp[i]=(int)PyInt_AS_LONG(o);
+ else
+ {
+ std::ostringstream oss; oss << "List as been detected but element #" << i << " is not integer ! only lists of integers accepted !";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ }
+ sw=2;
+ return;
+ }
+ void *argp;
+ int status=SWIG_ConvertPtr(value,&argp,SWIGTYPE_p_ParaMEDMEM__DataArrayInt,0|0);
+ if(!SWIG_IsOK(status))
+ throw INTERP_KERNEL::Exception("4 types accepted : integer, tuple of integer, list of integer, DataArrayInt");
+ daIntTyypp=reinterpret_cast< ParaMEDMEM::DataArrayInt * >(argp);
+ sw=3;
+}
+
+/*!
+ * if python double -> cpp double sw=1
+ * if python int -> cpp double sw=1
+ * if python list[double] -> cpp vector<double> sw=2
+ * if python list[int] -> cpp vector<double> sw=2
+ * if python tuple[double] -> cpp vector<double> sw=2
+ * if python tuple[int] -> cpp vector<double> sw=2
+ * if python DataArrayDouble -> cpp DataArrayDouble sw=3
+ *
+ * switch between (int,vector<int>,DataArrayInt)
+ */
+static void convertObjToPossibleCpp4(PyObject *value, int& sw, double& iTyypp, std::vector<double>& stdvecTyypp, ParaMEDMEM::DataArrayDouble *& daIntTyypp) throw(INTERP_KERNEL::Exception)
+{
+ sw=-1;
+ if(PyFloat_Check(value))
+ {
+ iTyypp=PyFloat_AS_DOUBLE(value);
+ sw=1;
+ return;
+ }
+ if(PyInt_Check(value))
+ {
+ iTyypp=(double)PyInt_AS_LONG(value);
+ sw=1;
+ return;
+ }
+ if(PyTuple_Check(value))
+ {
+ int size=PyTuple_Size(value);
+ stdvecTyypp.resize(size);
+ for(int i=0;i<size;i++)
+ {
+ PyObject *o=PyTuple_GetItem(value,i);
+ if(PyFloat_Check(o))
+ stdvecTyypp[i]=PyFloat_AS_DOUBLE(o);
+ else if(PyInt_Check(o))
+ stdvecTyypp[i]=(double)PyInt_AS_LONG(o);
+ else
+ {
+ std::ostringstream oss; oss << "Tuple as been detected but element #" << i << " is not double ! only tuples of doubles accepted or integer !";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ }
+ sw=2;
+ return;
+ }
+ if(PyList_Check(value))
+ {
+ int size=PyList_Size(value);
+ stdvecTyypp.resize(size);
+ for(int i=0;i<size;i++)
+ {
+ PyObject *o=PyList_GetItem(value,i);
+ if(PyFloat_Check(o))
+ stdvecTyypp[i]=PyFloat_AS_DOUBLE(o);
+ else if(PyInt_Check(o))
+ stdvecTyypp[i]=(double)PyInt_AS_LONG(o);
+ else
+ {
+ std::ostringstream oss; oss << "List as been detected but element #" << i << " is not double ! only lists of doubles accepted or integer !";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ }
+ sw=2;
+ return;
+ }
+ void *argp;
+ int status=SWIG_ConvertPtr(value,&argp,SWIGTYPE_p_ParaMEDMEM__DataArrayDouble,0|0);
+ if(!SWIG_IsOK(status))
+ throw INTERP_KERNEL::Exception("5 types accepted : double float, integer, tuple of double float or int, list of double float or int, DataArrayDouble");
+ daIntTyypp=reinterpret_cast< ParaMEDMEM::DataArrayDouble * >(argp);
+ sw=3;
+}
+
+/*!
+ * if python int -> cpp int sw=1
+ * if python list[int] -> cpp vector<int> sw=2
+ * if python tuple[int] -> cpp vector<int> sw=2
+ * if python slicp -> cpp pair sw=3
+ * if python DataArrayInt -> cpp DataArrayInt sw=4
+ *
+ * switch between (int,vector<int>,DataArrayInt)
+ */
+static void convertObjToPossibleCpp2(PyObject *value, int nbelem, int& sw, int& iTyypp, std::vector<int>& stdvecTyypp, std::pair<int, std::pair<int,int> >& p, ParaMEDMEM::DataArrayInt *& daIntTyypp) throw(INTERP_KERNEL::Exception)
+{
+ sw=-1;
+ if(PyInt_Check(value))
+ {
+ iTyypp=(int)PyInt_AS_LONG(value);
+ sw=1;
+ return;
+ }
+ if(PyTuple_Check(value))
+ {
+ int size=PyTuple_Size(value);
+ stdvecTyypp.resize(size);
+ for(int i=0;i<size;i++)
+ {
+ PyObject *o=PyTuple_GetItem(value,i);
+ if(PyInt_Check(o))
+ stdvecTyypp[i]=(int)PyInt_AS_LONG(o);
+ else
+ {
+ std::ostringstream oss; oss << "Tuple as been detected but element #" << i << " is not integer ! only tuples of integers accepted !";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ }
+ sw=2;
+ return;
+ }
+ if(PyList_Check(value))
+ {
+ int size=PyList_Size(value);
+ stdvecTyypp.resize(size);
+ for(int i=0;i<size;i++)
+ {
+ PyObject *o=PyList_GetItem(value,i);
+ if(PyInt_Check(o))
+ stdvecTyypp[i]=(int)PyInt_AS_LONG(o);
+ else
+ {
+ std::ostringstream oss; oss << "List as been detected but element #" << i << " is not integer ! only lists of integers accepted !";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ }
+ sw=2;
+ return;
+ }
+ if(PySlice_Check(value))
+ {
+ Py_ssize_t strt,stp,step;
+ PySliceObject *oC=reinterpret_cast<PySliceObject *>(value);
+ if(PySlice_GetIndices(oC,nbelem,&strt,&stp,&step)!=0)
+ {
+ std::ostringstream oss; oss << "Slice in subscriptable object DataArray invalid : number of elemnts is : " << nbelem;
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ p.first=strt;
+ p.second.first=stp;
+ p.second.second=step;
+ sw=3;
+ return ;
+ }
+ void *argp;
+ int status=SWIG_ConvertPtr(value,&argp,SWIGTYPE_p_ParaMEDMEM__DataArrayInt,0|0);
+ if(!SWIG_IsOK(status))
+ throw INTERP_KERNEL::Exception("4 types accepted : integer, tuple of integer, list of integer, slice, DataArrayInt");
+ daIntTyypp=reinterpret_cast< ParaMEDMEM::DataArrayInt * >(argp);
+ sw=4;
+}
+
+/*!
+ * if value int -> cpp it sw=1
+ * if value list[int] -> vt sw=2
+ * if value tuple[int] -> vt sw=2
+ * if value slice -> pt sw=3
+ * if value DataArrayInt -> dt sw=4
+ * if value tuple [int,int] -> cpp it,ip sw=5
+ * if value tuple [list[int],int] -> cpp vt,ip sw=6
+ * if value tuple [tuple[int],int] -> cpp vt,ip sw=6
+ * if value tuple [slice,int] -> cpp pt,ip sw=7
+ * if value tuple [DaI,int] -> cpp dt,ip sw=8
+ * if value tuple [int,list[int]] -> cpp it,vc sw=9
+ * if value tuple [list[int],list[int]] -> cpp vt,vc sw=10
+ * if value tuple [tuple[int],list[int]] -> cpp vt,vc sw=10
+ * if value tuple [slice,list[int]] -> cpp pt,vc sw=11
+ * if value tuple [DaI,list[int]] -> cpp dt,vc sw=12
+ * if value tuple [int,tuple[int]] -> cpp it,vc sw=9
+ * if value tuple [list[int],tuple[int]] -> cpp vt,vc sw=10
+ * if value tuple [tuple[int],tuple[int]] -> cpp vt,vc sw=10
+ * if value tuple [slice,tuple[int]] -> cpp pt,vc sw=11
+ * if value tuple [DaI,tuple[int]] -> cpp dt,vc sw=12
+ * if value tuple [int,slice] -> cpp it,pc sw=13
+ * if value tuple [list[int],slice] -> cpp vt,pc sw=14
+ * if value tuple [tuple[int],slice] -> cpp vt,pc sw=14
+ * if value tuple [slice,slice] -> cpp pt,pc sw=15
+ * if value tuple [DaI,slice] -> cpp dt,pc sw=16
+ *
+ * switch between (int,vector<int>,DataArrayInt)
+ */
+static void convertObjToPossibleCpp3(PyObject *value, int nbTuple, int nbCompo, int& sw, int& it, int& ic, std::vector<int>& vt, std::vector<int>& vc,
+ std::pair<int, std::pair<int,int> >& pt, std::pair<int, std::pair<int,int> >& pc,
+ ParaMEDMEM::DataArrayInt *&dt, ParaMEDMEM::DataArrayInt *&dc) throw(INTERP_KERNEL::Exception)
+{
+ if(!PyTuple_Check(value))
+ {
+ convertObjToPossibleCpp2(value,nbTuple,sw,it,vt,pt,dt);
+ return ;
+ }
+ else
+ {
+ int sz=PyTuple_Size(value);
+ if(sz!=2)
+ throw INTERP_KERNEL::Exception("Unexpected nb of slice element : 1 or 2 expected !\n1st is for tuple selection, 2nd for component selection !");
+ PyObject *ob0=PyTuple_GetItem(value,0);
+ int sw1,sw2;
+ convertObjToPossibleCpp2(ob0,nbTuple,sw1,it,vt,pt,dt);
+ PyObject *ob1=PyTuple_GetItem(value,1);
+ convertObjToPossibleCpp2(ob1,nbCompo,sw2,ic,vc,pc,dc);
+ sw=4*sw2+sw1;
+ }
+}
+
+/*!
+ * if value int -> cpp val sw=1
+ * if value double -> cpp val sw=1
+ * if value DataArrayDouble -> cpp DataArrayDouble sw=2
+ */
+static void convertObjToPossibleCpp5(PyObject *value, int& sw, double& val, ParaMEDMEM::DataArrayDouble *&d)
+{
+ sw=-1;
+ if(PyFloat_Check(value))
+ {
+ val=PyFloat_AS_DOUBLE(value);
+ sw=1;
+ return;
+ }
+ if(PyInt_Check(value))
+ {
+ val=(double)PyInt_AS_LONG(value);
+ sw=1;
+ return;
}
+ void *argp;
+ int status=SWIG_ConvertPtr(value,&argp,SWIGTYPE_p_ParaMEDMEM__DataArrayDouble,0|0);
+ if(!SWIG_IsOK(status))
+ throw INTERP_KERNEL::Exception("3 types accepted : integer, double, DataArrayDouble");
+ d=reinterpret_cast< ParaMEDMEM::DataArrayDouble * >(argp);
+ sw=2;
}
#
include $(top_srcdir)/adm_local/unix/make_common_starter.am
-lib_LTLIBRARIES = _libMEDCoupling_Swig.la _libMEDCouplingRemapper_Swig.la
+lib_LTLIBRARIES = _MEDCoupling.la _MEDCouplingRemapper.la
salomeinclude_HEADERS = \
- libMEDCoupling_Swig.i libMEDCouplingRemapper_Swig.i MEDCouplingTypemaps.i
+ MEDCoupling.i MEDCouplingRemapper.i MEDCouplingTypemaps.i
-BUILT_SOURCES = libMEDCoupling_SwigWRAP.cxx libMEDCouplingRemapper_SwigWRAP.cxx
+BUILT_SOURCES = MEDCouplingWRAP.cxx MEDCouplingRemapperWRAP.cxx
SWIG_FLAGS = @SWIG_FLAGS@ -I$(srcdir) -I$(srcdir)/../MEDCoupling -I$(srcdir)/../INTERP_KERNEL/Bases -I$(srcdir)/../INTERP_KERNEL
-dist__libMEDCoupling_Swig_la_SOURCES = libMEDCoupling_Swig.i MEDCouplingTypemaps.i
-nodist__libMEDCoupling_Swig_la_SOURCES = libMEDCoupling_SwigWRAP.cxx
-libMEDCoupling_Swig.py: libMEDCoupling_SwigWRAP.cxx
+dist__MEDCoupling_la_SOURCES = MEDCoupling.i MEDCouplingTypemaps.i
+nodist__MEDCoupling_la_SOURCES = MEDCouplingWRAP.cxx
+MEDCoupling.py: MEDCouplingWRAP.cxx
-libMEDCoupling_SwigWRAP.cxx: libMEDCoupling_Swig.i MEDCouplingTypemaps.i
+MEDCouplingWRAP.cxx: MEDCoupling.i MEDCouplingTypemaps.i
$(SWIG) $(SWIG_FLAGS) -o $@ $<
-_libMEDCoupling_Swig_la_CPPFLAGS = $(PYTHON_INCLUDES) \
+_MEDCoupling_la_CPPFLAGS = $(PYTHON_INCLUDES) \
@CXXTMPDPTHFLAGS@ -I$(srcdir)/../MEDCoupling -I$(srcdir)/../INTERP_KERNEL -I$(srcdir)/../INTERP_KERNEL/Bases
-_libMEDCoupling_Swig_la_LDFLAGS = -module $(PYTHON_LIBS) \
+_MEDCoupling_la_LDFLAGS = -module $(PYTHON_LIBS) \
../MEDCoupling/libmedcoupling.la ../INTERP_KERNEL/libinterpkernel.la
-dist__libMEDCouplingRemapper_Swig_la_SOURCES = libMEDCouplingRemapper_Swig.i
-nodist__libMEDCouplingRemapper_Swig_la_SOURCES = libMEDCouplingRemapper_SwigWRAP.cxx
-libMEDCouplingRemapper_Swig.py: libMEDCouplingRemapper_SwigWRAP.cxx
+dist__MEDCouplingRemapper_la_SOURCES = MEDCouplingRemapper.i
+nodist__MEDCouplingRemapper_la_SOURCES = MEDCouplingRemapperWRAP.cxx
+MEDCouplingRemapper.py: MEDCouplingRemapperWRAP.cxx
-libMEDCouplingRemapper_SwigWRAP.cxx: libMEDCouplingRemapper_Swig.i MEDCouplingTypemaps.i
+MEDCouplingRemapperWRAP.cxx: MEDCouplingRemapper.i MEDCouplingTypemaps.i
$(SWIG) $(SWIG_FLAGS) -o $@ $<
-_libMEDCouplingRemapper_Swig_la_CPPFLAGS = $(PYTHON_INCLUDES) \
+_MEDCouplingRemapper_la_CPPFLAGS = $(PYTHON_INCLUDES) \
@CXXTMPDPTHFLAGS@ -I$(srcdir)/../MEDCoupling -I$(srcdir)/../INTERP_KERNEL -I$(srcdir)/../INTERP_KERNEL/Bases
-_libMEDCouplingRemapper_Swig_la_LDFLAGS = -module $(PYTHON_LIBS) \
+_MEDCouplingRemapper_la_LDFLAGS = -module $(PYTHON_LIBS) \
../MEDCoupling/libmedcouplingremapper.la ../INTERP_KERNEL/libinterpkernel.la
-CLEANFILES = libMEDCoupling_SwigWRAP.cxx libMEDCoupling_Swig.py libMEDCouplingRemapper_SwigWRAP.cxx libMEDCouplingRemapper_Swig.py
+CLEANFILES = MEDCouplingWRAP.cxx MEDCoupling.py MEDCouplingRemapperWRAP.cxx MEDCouplingRemapper.py
-dist_salomescript_DATA= MEDCouplingBasicsTest.py MEDCouplingRemapperTest.py libMEDCoupling_Swig.py libMEDCouplingRemapper_Swig.py MEDCouplingDataForTest.py
+dist_salomescript_DATA= MEDCouplingBasicsTest.py MEDCouplingRemapperTest.py MEDCoupling.py MEDCouplingRemapper.py MEDCouplingDataForTest.py libMEDCoupling_Swig.py
UNIT_TEST_PROG = MEDCouplingBasicsTest.py MEDCouplingRemapperTest.py
+++ /dev/null
-// Copyright (C) 2007-2010 CEA/DEN, EDF R&D
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-
-%module libMEDCouplingRemapper_Swig
-
-#define MEDCOUPLING_EXPORT
-#define INTERPKERNEL_EXPORT
-#define MEDCOUPLINGREMAPPER_EXPORT
-
-%{
-#include "MEDCouplingMemArray.hxx"
-#include "MEDCouplingUMesh.hxx"
-#include "MEDCouplingField.hxx"
-#include "MEDCouplingFieldDouble.hxx"
-#include "MEDCouplingRemapper.hxx"
-
-using namespace ParaMEDMEM;
-using namespace INTERP_KERNEL;
-%}
-
-%newobject ParaMEDMEM::MEDCouplingRemapper::transferField;
-%newobject ParaMEDMEM::MEDCouplingRemapper::reverseTransferField;
-
-%include "libMEDCoupling_Swig.i"
-%include "InterpolationOptions.hxx"
-%include "MEDCouplingRemapper.hxx"
+++ /dev/null
-// Copyright (C) 2007-2010 CEA/DEN, EDF R&D
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-
-%module libMEDCoupling_Swig
-
-#define MEDCOUPLING_EXPORT
-
-%include std_vector.i
-%include std_string.i
-
-%{
-#include "MEDCouplingMemArray.hxx"
-#include "MEDCouplingUMesh.hxx"
-#include "MEDCouplingExtrudedMesh.hxx"
-#include "MEDCouplingCMesh.hxx"
-#include "MEDCouplingField.hxx"
-#include "MEDCouplingFieldDouble.hxx"
-#include "MEDCouplingGaussLocalization.hxx"
-#include "MEDCouplingTypemaps.i"
-
-using namespace ParaMEDMEM;
-using namespace INTERP_KERNEL;
-%}
-
-%template(ivec) std::vector<int>;
-%template(dvec) std::vector<double>;
-%template(svec) std::vector<std::string>;
-
-%typemap(out) ParaMEDMEM::MEDCouplingMesh*
-{
- $result=convertMesh($1,$owner);
-}
-
-%typemap(out) ParaMEDMEM::MEDCouplingPointSet*
-{
- $result=convertMesh($1,$owner);
-}
-
-#ifdef WITH_NUMPY2
-%init %{ import_array(); %}
-#endif
-
-%feature("autodoc", "1");
-%feature("docstring");
-
-%newobject ParaMEDMEM::MEDCouplingField::buildMeasureField;
-%newobject ParaMEDMEM::MEDCouplingFieldDouble::New;
-%newobject ParaMEDMEM::MEDCouplingFieldDouble::mergeFields;
-%newobject ParaMEDMEM::MEDCouplingFieldDouble::doublyContractedProduct;
-%newobject ParaMEDMEM::MEDCouplingFieldDouble::determinant;
-%newobject ParaMEDMEM::MEDCouplingFieldDouble::eigenValues;
-%newobject ParaMEDMEM::MEDCouplingFieldDouble::eigenVectors;
-%newobject ParaMEDMEM::MEDCouplingFieldDouble::inverse;
-%newobject ParaMEDMEM::MEDCouplingFieldDouble::trace;
-%newobject ParaMEDMEM::MEDCouplingFieldDouble::deviator;
-%newobject ParaMEDMEM::MEDCouplingFieldDouble::magnitude;
-%newobject ParaMEDMEM::MEDCouplingFieldDouble::maxPerTuple;
-%newobject ParaMEDMEM::MEDCouplingFieldDouble::keepSelectedComponents;
-%newobject ParaMEDMEM::MEDCouplingFieldDouble::dotFields;
-%newobject ParaMEDMEM::MEDCouplingFieldDouble::dot;
-%newobject ParaMEDMEM::MEDCouplingFieldDouble::crossProductFields;
-%newobject ParaMEDMEM::MEDCouplingFieldDouble::crossProduct;
-%newobject ParaMEDMEM::MEDCouplingFieldDouble::maxFields;
-%newobject ParaMEDMEM::MEDCouplingFieldDouble::max;
-%newobject ParaMEDMEM::MEDCouplingFieldDouble::minFields;
-%newobject ParaMEDMEM::MEDCouplingFieldDouble::min;
-%newobject ParaMEDMEM::MEDCouplingFieldDouble::getIdsInRange;
-%newobject ParaMEDMEM::MEDCouplingFieldDouble::buildSubPart;
-%newobject ParaMEDMEM::MEDCouplingFieldDouble::operator+;
-%newobject ParaMEDMEM::MEDCouplingFieldDouble::operator-;
-%newobject ParaMEDMEM::MEDCouplingFieldDouble::operator*;
-%newobject ParaMEDMEM::MEDCouplingFieldDouble::operator/;
-%newobject ParaMEDMEM::MEDCouplingFieldDouble::clone;
-%newobject ParaMEDMEM::MEDCouplingFieldDouble::cloneWithMesh;
-%newobject ParaMEDMEM::MEDCouplingFieldDouble::buildNewTimeReprFromThis;
-%newobject ParaMEDMEM::DataArrayInt::New;
-%newobject ParaMEDMEM::DataArrayInt::convertToDblArr;
-%newobject ParaMEDMEM::DataArrayInt::deepCopy;
-%newobject ParaMEDMEM::DataArrayInt::performCpy;
-%newobject ParaMEDMEM::DataArrayInt::substr;
-%newobject ParaMEDMEM::DataArrayInt::changeNbOfComponents;
-%newobject ParaMEDMEM::DataArrayInt::keepSelectedComponents;
-%newobject ParaMEDMEM::DataArrayInt::selectByTupleId;
-%newobject ParaMEDMEM::DataArrayInt::renumber;
-%newobject ParaMEDMEM::DataArrayInt::renumberR;
-%newobject ParaMEDMEM::DataArrayInt::renumberAndReduce;
-%newobject ParaMEDMEM::DataArrayInt::invertArrayO2N2N2O;
-%newobject ParaMEDMEM::DataArrayInt::invertArrayN2O2O2N;
-%newobject ParaMEDMEM::DataArrayInt::getIdsEqual;
-%newobject ParaMEDMEM::DataArrayInt::getIdsEqualList;
-%newobject ParaMEDMEM::DataArrayInt::aggregate;
-%newobject ParaMEDMEM::DataArrayInt::fromNoInterlace;
-%newobject ParaMEDMEM::DataArrayInt::toNoInterlace;
-%newobject ParaMEDMEM::DataArrayDouble::New;
-%newobject ParaMEDMEM::DataArrayDouble::convertToIntArr;
-%newobject ParaMEDMEM::DataArrayDouble::deepCopy;
-%newobject ParaMEDMEM::DataArrayDouble::performCpy;
-%newobject ParaMEDMEM::DataArrayDouble::aggregate;
-%newobject ParaMEDMEM::DataArrayDouble::dot;
-%newobject ParaMEDMEM::DataArrayDouble::crossProduct;
-%newobject ParaMEDMEM::DataArrayDouble::add;
-%newobject ParaMEDMEM::DataArrayDouble::substract;
-%newobject ParaMEDMEM::DataArrayDouble::multiply;
-%newobject ParaMEDMEM::DataArrayDouble::divide;
-%newobject ParaMEDMEM::DataArrayDouble::substr;
-%newobject ParaMEDMEM::DataArrayDouble::changeNbOfComponents;
-%newobject ParaMEDMEM::DataArrayDouble::keepSelectedComponents;
-%newobject ParaMEDMEM::DataArrayDouble::getIdsInRange;
-%newobject ParaMEDMEM::DataArrayDouble::selectByTupleId;
-%newobject ParaMEDMEM::DataArrayDouble::applyFunc;
-%newobject ParaMEDMEM::DataArrayDouble::doublyContractedProduct;
-%newobject ParaMEDMEM::DataArrayDouble::determinant;
-%newobject ParaMEDMEM::DataArrayDouble::eigenValues;
-%newobject ParaMEDMEM::DataArrayDouble::eigenVectors;
-%newobject ParaMEDMEM::DataArrayDouble::inverse;
-%newobject ParaMEDMEM::DataArrayDouble::trace;
-%newobject ParaMEDMEM::DataArrayDouble::deviator;
-%newobject ParaMEDMEM::DataArrayDouble::magnitude;
-%newobject ParaMEDMEM::DataArrayDouble::maxPerTuple;
-%newobject ParaMEDMEM::DataArrayDouble::renumber;
-%newobject ParaMEDMEM::DataArrayDouble::renumberR;
-%newobject ParaMEDMEM::DataArrayDouble::renumberAndReduce;
-%newobject ParaMEDMEM::DataArrayDouble::fromNoInterlace;
-%newobject ParaMEDMEM::DataArrayDouble::toNoInterlace;
-%newobject ParaMEDMEM::DataArrayDouble::fromPolarToCart;
-%newobject ParaMEDMEM::DataArrayDouble::fromCylToCart;
-%newobject ParaMEDMEM::DataArrayDouble::fromSpherToCart;
-%newobject ParaMEDMEM::MEDCouplingMesh::getCoordinatesAndOwner;
-%newobject ParaMEDMEM::MEDCouplingMesh::getBarycenterAndOwner;
-%newobject ParaMEDMEM::MEDCouplingMesh::buildOrthogonalField;
-%newobject ParaMEDMEM::MEDCouplingMesh::getCellIdsFullyIncludedInNodeIds;
-%newobject ParaMEDMEM::MEDCouplingMesh::mergeMyselfWith;
-%newobject ParaMEDMEM::MEDCouplingMesh::fillFromAnalytic;
-%newobject ParaMEDMEM::MEDCouplingMesh::getMeasureField;
-%newobject ParaMEDMEM::MEDCouplingMesh::simplexize;
-%newobject ParaMEDMEM::MEDCouplingPointSet::zipCoordsTraducer;
-%newobject ParaMEDMEM::MEDCouplingPointSet::buildBoundaryMesh;
-%newobject ParaMEDMEM::MEDCouplingUMesh::New;
-%newobject ParaMEDMEM::MEDCouplingUMesh::clone;
-%newobject ParaMEDMEM::MEDCouplingUMesh::zipConnectivityTraducer;
-%newobject ParaMEDMEM::MEDCouplingUMesh::buildDescendingConnectivity;
-%newobject ParaMEDMEM::MEDCouplingUMesh::buildExtrudedMeshFromThis;
-%newobject ParaMEDMEM::MEDCouplingUMesh::mergeUMeshes;
-%newobject ParaMEDMEM::MEDCouplingUMesh::buildNewNumberingFromCommNodesFrmt;
-%newobject ParaMEDMEM::MEDCouplingUMesh::rearrange2ConsecutiveCellTypes;
-%newobject ParaMEDMEM::MEDCouplingUMesh::convertCellArrayPerGeoType;
-%newobject ParaMEDMEM::MEDCouplingUMesh::getRenumArrForConsecutiveCellTypesSpec;
-%newobject ParaMEDMEM::MEDCouplingUMesh::buildDirectionVectorField;
-%newobject ParaMEDMEM::MEDCouplingUMesh::getEdgeRatioField;
-%newobject ParaMEDMEM::MEDCouplingUMesh::getAspectRatioField;
-%newobject ParaMEDMEM::MEDCouplingUMesh::getWarpField;
-%newobject ParaMEDMEM::MEDCouplingUMesh::getSkewField;
-%newobject ParaMEDMEM::MEDCouplingExtrudedMesh::New;
-%newobject ParaMEDMEM::MEDCouplingExtrudedMesh::build3DUnstructuredMesh;
-%newobject ParaMEDMEM::MEDCouplingCMesh::New;
-%newobject ParaMEDMEM::MEDCouplingCMesh::buildUnstructured;
-%feature("unref") DataArrayDouble "$this->decrRef();"
-%feature("unref") MEDCouplingPointSet "$this->decrRef();"
-%feature("unref") MEDCouplingMesh "$this->decrRef();"
-%feature("unref") MEDCouplingUMesh "$this->decrRef();"
-%feature("unref") MEDCouplingExtrudedMesh "$this->decrRef();"
-%feature("unref") MEDCouplingCMesh "$this->decrRef();"
-%feature("unref") DataArrayInt "$this->decrRef();"
-%feature("unref") MEDCouplingField "$this->decrRef();"
-%feature("unref") MEDCouplingFieldDouble "$this->decrRef();"
-
-%rename(assign) *::operator=;
-%ignore ParaMEDMEM::MemArray::operator=;
-%ignore ParaMEDMEM::MemArray::operator[];
-%ignore ParaMEDMEM::MEDCouplingPointSet::getCoords();
-%ignore ParaMEDMEM::MEDCouplingGaussLocalization::pushTinySerializationIntInfo;
-%ignore ParaMEDMEM::MEDCouplingGaussLocalization::pushTinySerializationDblInfo;
-%ignore ParaMEDMEM::MEDCouplingGaussLocalization::fillWithValues;
-%ignore ParaMEDMEM::MEDCouplingGaussLocalization::buildNewInstanceFromTinyInfo;
-
-%rename (Exception) InterpKernelException;
-%nodefaultctor;
-
-namespace INTERP_KERNEL
-{
- class Exception
- {
- public:
- Exception(const char* what);
- ~Exception() throw ();
- const char *what() const throw ();
- };
-}
-
-%include "MEDCouplingTimeLabel.hxx"
-%include "MEDCouplingRefCountObject.hxx"
-
-namespace ParaMEDMEM
-{
- typedef enum
- {
- UNSTRUCTURED = 5,
- UNSTRUCTURED_DESC = 6,
- CARTESIAN = 7,
- EXTRUDED = 8
- } MEDCouplingMeshType;
-
- class DataArrayInt;
- class DataArrayDouble;
- class MEDCouplingFieldDouble;
-
- class MEDCouplingMesh : public RefCountObject, public TimeLabel
- {
- public:
- void setName(const char *name) { _name=name; }
- const char *getName() const { return _name.c_str(); }
- virtual MEDCouplingMeshType getType() const = 0;
- bool isStructured() const;
- virtual bool isEqual(const MEDCouplingMesh *other, double prec) const;
- virtual bool isEqualWithoutConsideringStr(const MEDCouplingMesh *other, double prec) const = 0;
- virtual void copyTinyStringsFrom(const MEDCouplingMesh *other) throw(INTERP_KERNEL::Exception);
- virtual void checkCoherency() const throw(INTERP_KERNEL::Exception) = 0;
- virtual int getNumberOfCells() const throw(INTERP_KERNEL::Exception) = 0;
- virtual int getNumberOfNodes() const throw(INTERP_KERNEL::Exception) = 0;
- virtual int getSpaceDimension() const throw(INTERP_KERNEL::Exception) = 0;
- virtual int getMeshDimension() const throw(INTERP_KERNEL::Exception) = 0;
- virtual DataArrayDouble *getCoordinatesAndOwner() const = 0;
- virtual DataArrayDouble *getBarycenterAndOwner() const = 0;
- virtual int getNumberOfCellsWithType(INTERP_KERNEL::NormalizedCellType type) const = 0;
- virtual INTERP_KERNEL::NormalizedCellType getTypeOfCell(int cellId) const = 0;
- virtual std::string simpleRepr() const = 0;
- virtual std::string advancedRepr() const = 0;
- // tools
- virtual MEDCouplingFieldDouble *getMeasureField(bool isAbs) const = 0;
- virtual MEDCouplingFieldDouble *getMeasureFieldOnNode(bool isAbs) const = 0;
- virtual MEDCouplingFieldDouble *fillFromAnalytic(TypeOfField t, int nbOfComp, const char *func) const throw(INTERP_KERNEL::Exception);
- virtual MEDCouplingFieldDouble *buildOrthogonalField() const = 0;
- virtual MEDCouplingMesh *mergeMyselfWith(const MEDCouplingMesh *other) const throw(INTERP_KERNEL::Exception) = 0;
- virtual bool areCompatibleForMerge(const MEDCouplingMesh *other) const;
- virtual DataArrayInt *simplexize(int policy) throw(INTERP_KERNEL::Exception);
- static MEDCouplingMesh *mergeMeshes(const MEDCouplingMesh *mesh1, const MEDCouplingMesh *mesh2);
- %extend
- {
- std::string __str__() const
- {
- return self->simpleRepr();
- }
-
- int getCellContainingPoint(PyObject *p, double eps) const
- {
- int sz;
- double *pos=convertPyToNewDblArr2(p,&sz);
- int ret=self->getCellContainingPoint(pos,eps);
- delete [] pos;
- return ret;
- }
-
- void renumberCells(PyObject *li, bool check) throw(INTERP_KERNEL::Exception)
- {
- int size;
- int *tmp=convertPyToNewIntArr2(li,&size);
- self->renumberCells(tmp,check);
- delete [] tmp;
- }
-
- PyObject *checkGeoEquivalWith(const MEDCouplingMesh *other, int levOfCheck, double prec) const throw(INTERP_KERNEL::Exception)
- {
- DataArrayInt *cellCor, *nodeCor;
- self->checkGeoEquivalWith(other,levOfCheck,prec,cellCor,nodeCor);
- PyObject *res = PyList_New(2);
- PyList_SetItem(res,0,SWIG_NewPointerObj(SWIG_as_voidptr(cellCor),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, cellCor?SWIG_POINTER_OWN | 0:0 ));
- PyList_SetItem(res,1,SWIG_NewPointerObj(SWIG_as_voidptr(nodeCor),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, nodeCor?SWIG_POINTER_OWN | 0:0 ));
- return res;
- }
- DataArrayInt *getCellIdsFullyIncludedInNodeIds(PyObject *li) const
- {
- int size;
- int *tmp=convertPyToNewIntArr2(li,&size);
- DataArrayInt *ret=self->getCellIdsFullyIncludedInNodeIds(tmp,tmp+size);
- delete [] tmp;
- return ret;
- }
- PyObject *getNodeIdsOfCell(int cellId) const
- {
- std::vector<int> conn;
- self->getNodeIdsOfCell(cellId,conn);
- return convertIntArrToPyList2(conn);
- }
-
- PyObject *getCoordinatesOfNode(int nodeId) const
- {
- std::vector<double> coo;
- self->getCoordinatesOfNode(nodeId,coo);
- return convertDblArrToPyList2(coo);
- }
-
- void scale(PyObject *point, double factor)
- {
- int sz;
- double *p=convertPyToNewDblArr2(point,&sz);
- self->scale(p,factor);
- delete [] p;
- }
-
- PyObject *getBoundingBox() const throw(INTERP_KERNEL::Exception)
- {
- int spaceDim=self->getSpaceDimension();
- double *tmp=new double[2*spaceDim];
- self->getBoundingBox(tmp);
- PyObject *ret=convertDblArrToPyListOfTuple(tmp,2,spaceDim);
- delete [] tmp;
- return ret;
- }
-
- PyObject *buildPart(PyObject *li) const
- {
- int size;
- int *tmp=convertPyToNewIntArr2(li,&size);
- MEDCouplingMesh *ret=self->buildPart(tmp,tmp+size);
- delete [] tmp;
- return convertMesh(ret, SWIG_POINTER_OWN | 0 );
- }
-
- PyObject *buildPartAndReduceNodes(PyObject *li) const
- {
- int size;
- int *tmp=convertPyToNewIntArr2(li,&size);
- DataArrayInt *arr=0;
- MEDCouplingMesh *ret=self->buildPartAndReduceNodes(tmp,tmp+size,arr);
- PyObject *res = PyList_New(2);
- PyObject *obj0=convertMesh(ret, SWIG_POINTER_OWN | 0 );
- PyObject *obj1=SWIG_NewPointerObj(SWIG_as_voidptr(arr),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 );
- PyList_SetItem(res,0,obj0);
- PyList_SetItem(res,1,obj1);
- return res;
- }
-
- void translate(PyObject *vector)
- {
- int sz;
- double *v=convertPyToNewDblArr2(vector,&sz);
- self->translate(v);
- delete [] v;
- }
-
- void rotate(PyObject *center, PyObject *vector, double alpha)
- {
- int sz;
- double *c=convertPyToNewDblArr2(center,&sz);
- if(!c)
- return ;
- double *v=convertPyToNewDblArr2(vector,&sz);
- if(!v)
- { delete [] c; return ; }
- self->rotate(c,v,alpha);
- delete [] c;
- delete [] v;
- }
- }
- };
-}
-
-%include "MEDCouplingMemArray.hxx"
-%include "NormalizedUnstructuredMesh.hxx"
-%include "MEDCouplingNatureOfField.hxx"
-%include "MEDCouplingTimeDiscretization.hxx"
-%include "MEDCouplingGaussLocalization.hxx"
-
-namespace ParaMEDMEM
-{
- class MEDCouplingPointSet : public ParaMEDMEM::MEDCouplingMesh
- {
- public:
- void updateTime();
- void setCoords(DataArrayDouble *coords);
- DataArrayDouble *getCoordinatesAndOwner() const;
- bool areCoordsEqual(const MEDCouplingPointSet& other, double prec) const;
- void zipCoords();
- double getCaracteristicDimension() const;
- void changeSpaceDimension(int newSpaceDim, double dftVal=0.) throw(INTERP_KERNEL::Exception);
- void tryToShareSameCoords(const MEDCouplingPointSet& other, double epsilon) throw(INTERP_KERNEL::Exception);
- virtual void tryToShareSameCoordsPermute(const MEDCouplingPointSet& other, double epsilon) throw(INTERP_KERNEL::Exception) = 0;
- static DataArrayDouble *mergeNodesArray(const MEDCouplingPointSet *m1, const MEDCouplingPointSet *m2);
- static MEDCouplingPointSet *buildInstanceFromMeshType(MEDCouplingMeshType type);
- virtual MEDCouplingPointSet *buildBoundaryMesh(bool keepCoords) const = 0;
- virtual bool isEmptyMesh(const std::vector<int>& tinyInfo) const = 0;
- //! size of returned tinyInfo must be always the same.
- void getTinySerializationInformation(std::vector<int>& tinyInfo, std::vector<std::string>& littleStrings) const;
- void resizeForUnserialization(const std::vector<int>& tinyInfo, DataArrayInt *a1, DataArrayDouble *a2, std::vector<std::string>& littleStrings) const;
- void serialize(DataArrayInt *&a1, DataArrayDouble *&a2) const;
- void unserialization(const std::vector<int>& tinyInfo, const DataArrayInt *a1, DataArrayDouble *a2,
- const std::vector<std::string>& littleStrings);
- virtual void giveElemsInBoundingBox(const INTERP_KERNEL::DirectedBoundingBox& bbox, double eps, std::vector<int>& elems) = 0;
- virtual DataArrayInt *zipCoordsTraducer() = 0;
- %extend
- {
- std::string __str__() const
- {
- return self->simpleRepr();
- }
-
- PyObject *buildNewNumberingFromCommonNodesFormat(const DataArrayInt *comm, const DataArrayInt *commIndex) const
- {
- int newNbOfNodes;
- DataArrayInt *ret0=self->buildNewNumberingFromCommonNodesFormat(comm,commIndex,newNbOfNodes);
- PyObject *res = PyList_New(2);
- PyList_SetItem(res,0,SWIG_NewPointerObj(SWIG_as_voidptr(ret0),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 ));
- PyList_SetItem(res,1,SWIG_From_int(newNbOfNodes));
- return res;
- }
-
- PyObject *findCommonNodes(int limitNodeId, double prec) const
- {
- DataArrayInt *comm, *commIndex;
- self->findCommonNodes(limitNodeId,prec,comm,commIndex);
- PyObject *res = PyList_New(2);
- PyList_SetItem(res,0,SWIG_NewPointerObj(SWIG_as_voidptr(comm),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 ));
- PyList_SetItem(res,1,SWIG_NewPointerObj(SWIG_as_voidptr(commIndex),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 ));
- return res;
- }
-
- PyObject *getCoords() const
- {
- DataArrayDouble *ret1=self->getCoords();
- ret1->incrRef();
- return SWIG_NewPointerObj((void*)ret1,SWIGTYPE_p_ParaMEDMEM__DataArrayDouble,SWIG_POINTER_OWN | 0);
- }
- PyObject *buildPartOfMySelf(PyObject *li, bool keepCoords) const
- {
- int size;
- int *tmp=convertPyToNewIntArr2(li,&size);
- MEDCouplingPointSet *ret=self->buildPartOfMySelf(tmp,tmp+size,keepCoords);
- delete [] tmp;
- return convertMesh(ret, SWIG_POINTER_OWN | 0 );
- }
- PyObject *buildPartOfMySelfNode(PyObject *li, bool fullyIn) const
- {
- int size;
- int *tmp=convertPyToNewIntArr2(li,&size);
- MEDCouplingPointSet *ret=self->buildPartOfMySelfNode(tmp,tmp+size,fullyIn);
- delete [] tmp;
- return convertMesh(ret, SWIG_POINTER_OWN | 0 );
- }
- PyObject *buildFacePartOfMySelfNode(PyObject *li, bool fullyIn) const
- {
- int size;
- int *tmp=convertPyToNewIntArr2(li,&size);
- MEDCouplingPointSet *ret=self->buildFacePartOfMySelfNode(tmp,tmp+size,fullyIn);
- delete [] tmp;
- return convertMesh(ret, SWIG_POINTER_OWN | 0 );
- }
- PyObject *findBoundaryNodes() const
- {
- std::vector<int> nodes;
- self->findBoundaryNodes(nodes);
- return convertIntArrToPyList2(nodes);
- }
- void renumberNodes(PyObject *li, int newNbOfNodes)
- {
- int size;
- int *tmp=convertPyToNewIntArr2(li,&size);
- self->renumberNodes(tmp,newNbOfNodes);
- delete [] tmp;
- }
- PyObject *findNodesOnPlane(PyObject *pt, PyObject *vec, double eps) const throw(INTERP_KERNEL::Exception)
- {
- std::vector<int> nodes;
- int sz;
- double *p=convertPyToNewDblArr2(pt,&sz);
- double *v=convertPyToNewDblArr2(vec,&sz);
- self->findNodesOnPlane(p,v,eps,nodes);
- delete [] v;
- delete [] p;
- return convertIntArrToPyList2(nodes);
- }
- PyObject *getNodeIdsNearPoint(PyObject *pt, double eps) const throw(INTERP_KERNEL::Exception)
- {
- int size;
- double *pos=convertPyToNewDblArr2(pt,&size);
- if(size<self->getSpaceDimension())
- {
- delete [] pos;
- throw INTERP_KERNEL::Exception("getNodeIdsNearPoint : to tiny array ! must be at least of size SpaceDim !");
- }
- std::vector<int> tmp;
- try
- {
- tmp=self->getNodeIdsNearPoint(pos,eps);
- }
- catch(INTERP_KERNEL::Exception& e)
- {
- delete [] pos;
- throw e;
- }
- delete [] pos;
- return convertIntArrToPyList2(tmp);
- }
-
- PyObject *getNodeIdsNearPoints(PyObject *pt, int nbOfNodes, double eps) const throw(INTERP_KERNEL::Exception)
- {
- std::vector<int> c,cI;
- int size;
- double *pos=convertPyToNewDblArr2(pt,&size);
- if(size<self->getSpaceDimension()*nbOfNodes)
- {
- delete [] pos;
- throw INTERP_KERNEL::Exception("getNodeIdsNearPoints : to tiny array ! must be at least of size SpaceDim*nbOfNodes !");
- }
- try
- {
- self->getNodeIdsNearPoints(pos,nbOfNodes,eps,c,cI);
- }
- catch(INTERP_KERNEL::Exception& e)
- {
- delete [] pos;
- throw e;
- }
- delete [] pos;
- PyObject *ret=PyTuple_New(2);
- PyTuple_SetItem(ret,0,convertIntArrToPyList2(c));
- PyTuple_SetItem(ret,1,convertIntArrToPyList2(cI));
- return ret;
- }
-
- PyObject *giveElemsInBoundingBox(PyObject *bbox, double eps)
- {
- std::vector<int> elems;
- int size;
- double *tmp=convertPyToNewDblArr2(bbox,&size);
- self->giveElemsInBoundingBox(tmp,eps,elems);
- delete [] tmp;
- return convertIntArrToPyList2(elems);
- }
-
- static void rotate2DAlg(PyObject *center, double angle, int nbNodes, PyObject *coords)
- {
- int sz;
- double *c=convertPyToNewDblArr2(center,&sz);
- double *coo=convertPyToNewDblArr2(coords,&sz);
- ParaMEDMEM::MEDCouplingPointSet::rotate2DAlg(c,angle,nbNodes,coo);
- for(int i=0;i<sz;i++)
- PyList_SetItem(coords,i,PyFloat_FromDouble(coo[i]));
- delete [] coo;
- delete [] c;
- }
- static void rotate3DAlg(PyObject *center, PyObject *vect, double angle, int nbNodes, PyObject *coords)
- {
- int sz,sz2;
- double *c=convertPyToNewDblArr2(center,&sz);
- double *coo=convertPyToNewDblArr2(coords,&sz);
- double *v=convertPyToNewDblArr2(vect,&sz2);
- ParaMEDMEM::MEDCouplingPointSet::rotate3DAlg(c,v,angle,nbNodes,coo);
- for(int i=0;i<sz;i++)
- PyList_SetItem(coords,i,PyFloat_FromDouble(coo[i]));
- delete [] coo;
- delete [] c;
- }
- }
- };
-
- class MEDCouplingUMesh : public ParaMEDMEM::MEDCouplingPointSet
- {
- public:
- static MEDCouplingUMesh *New();
- static MEDCouplingUMesh *New(const char *meshName, int meshDim);
- MEDCouplingUMesh *clone(bool recDeepCpy) const;
- void updateTime();
- void checkCoherency() const throw(INTERP_KERNEL::Exception);
- void setMeshDimension(int meshDim) throw(INTERP_KERNEL::Exception);
- void allocateCells(int nbOfCells);
- void finishInsertingCells();
- void setConnectivity(DataArrayInt *conn, DataArrayInt *connIndex, bool isComputingTypes=true);
- DataArrayInt *getNodalConnectivity() const;
- DataArrayInt *getNodalConnectivityIndex() const;
- INTERP_KERNEL::NormalizedCellType getTypeOfCell(int cellId) const;
- int getNumberOfNodesInCell(int cellId) const;
- int getMeshLength() const;
- void computeTypes();
- std::string reprConnectivityOfThis() const;
- //tools
- bool checkConsecutiveCellTypes() const;
- DataArrayInt *rearrange2ConsecutiveCellTypes();
- DataArrayInt *convertCellArrayPerGeoType(const DataArrayInt *da) const throw(INTERP_KERNEL::Exception);
- DataArrayInt *zipConnectivityTraducer(int compType);
- void getReverseNodalConnectivity(DataArrayInt *revNodal, DataArrayInt *revNodalIndx) const;
- MEDCouplingUMesh *buildDescendingConnectivity(DataArrayInt *desc, DataArrayInt *descIndx, DataArrayInt *revDesc, DataArrayInt *revDescIndx) const;
- void orientCorrectlyPolyhedrons() throw(INTERP_KERNEL::Exception);
- bool isPresenceOfQuadratic() const;
- MEDCouplingFieldDouble *buildDirectionVectorField() const;
- bool isContiguous1D() const throw(INTERP_KERNEL::Exception);
- void convertQuadraticCellsToLinear() throw(INTERP_KERNEL::Exception);
- void convertDegeneratedCells() throw(INTERP_KERNEL::Exception);
- bool areOnlySimplexCells() const throw(INTERP_KERNEL::Exception);
- MEDCouplingFieldDouble *getEdgeRatioField() const throw(INTERP_KERNEL::Exception);
- MEDCouplingFieldDouble *getAspectRatioField() const throw(INTERP_KERNEL::Exception);
- MEDCouplingFieldDouble *getWarpField() const throw(INTERP_KERNEL::Exception);
- MEDCouplingFieldDouble *getSkewField() const throw(INTERP_KERNEL::Exception);
- %extend {
- std::string __str__() const
- {
- return self->simpleRepr();
- }
- void insertNextCell(INTERP_KERNEL::NormalizedCellType type, int size, PyObject *li)
- {
- int sz;
- int *tmp=convertPyToNewIntArr2(li,&sz);
- self->insertNextCell(type,size,tmp);
- delete [] tmp;
- }
- PyObject *getAllTypes() const
- {
- std::set<INTERP_KERNEL::NormalizedCellType> result=self->getAllTypes();
- std::set<INTERP_KERNEL::NormalizedCellType>::const_iterator iL=result.begin();
- PyObject *res = PyList_New(result.size());
- for (int i=0;iL!=result.end(); i++, iL++)
- PyList_SetItem(res,i,PyInt_FromLong(*iL));
- return res;
- }
- PyObject *mergeNodes(double precision)
- {
- bool ret1;
- int ret2;
- DataArrayInt *ret0=self->mergeNodes(precision,ret1,ret2);
- PyObject *res = PyList_New(3);
- PyList_SetItem(res,0,SWIG_NewPointerObj(SWIG_as_voidptr(ret0),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 ));
- PyList_SetItem(res,1,SWIG_From_bool(ret1));
- PyList_SetItem(res,2,SWIG_From_int(ret2));
- return res;
- }
- PyObject *checkButterflyCells()
- {
- std::vector<int> cells;
- self->checkButterflyCells(cells);
- return convertIntArrToPyList2(cells);
- }
-
- PyObject *splitByType() const
- {
- std::vector<MEDCouplingUMesh *> ms=self->splitByType();
- int sz=ms.size();
- PyObject *ret = PyList_New(sz);
- for(int i=0;i<sz;i++)
- PyList_SetItem(ret,i,SWIG_NewPointerObj(SWIG_as_voidptr(ms[i]),SWIGTYPE_p_ParaMEDMEM__MEDCouplingUMesh, SWIG_POINTER_OWN | 0 ));
- return ret;
- }
-
- PyObject *keepSpecifiedCells(INTERP_KERNEL::NormalizedCellType type, PyObject *ids) const
- {
- std::vector<int> idsPerGeoType;
- convertPyToNewIntArr3(ids,idsPerGeoType);
- MEDCouplingUMesh *ret=self->keepSpecifiedCells(type,idsPerGeoType);
- return SWIG_NewPointerObj(SWIG_as_voidptr(ret),SWIGTYPE_p_ParaMEDMEM__MEDCouplingUMesh, SWIG_POINTER_OWN | 0 );
- }
-
- bool checkConsecutiveCellTypesAndOrder(PyObject *li) const
- {
- int sz;
- INTERP_KERNEL::NormalizedCellType *order=(INTERP_KERNEL::NormalizedCellType *)convertPyToNewIntArr2(li,&sz);
- bool ret=self->checkConsecutiveCellTypesAndOrder(order,order+sz);
- delete [] order;
- return ret;
- }
-
- DataArrayInt *getRenumArrForConsecutiveCellTypesSpec(PyObject *li) const
- {
- int sz;
- INTERP_KERNEL::NormalizedCellType *order=(INTERP_KERNEL::NormalizedCellType *)convertPyToNewIntArr2(li,&sz);
- DataArrayInt *ret=self->getRenumArrForConsecutiveCellTypesSpec(order,order+sz);
- delete [] order;
- return ret;
- }
-
- PyObject *getCellsContainingPoints(PyObject *p, int nbOfPoints, double eps) const
- {
- int sz;
- double *pos=convertPyToNewDblArr2(p,&sz);
- std::vector<int> elts,eltsIndex;
- self->getCellsContainingPoints(pos,nbOfPoints,eps,elts,eltsIndex);
- delete [] pos;
- PyObject *ret=PyList_New(2);
- PyList_SetItem(ret,0,convertIntArrToPyList2(elts));
- PyList_SetItem(ret,1,convertIntArrToPyList2(eltsIndex));
- return ret;
- }
-
- PyObject *getCellsContainingPoint(PyObject *p, double eps) const
- {
- int sz;
- double *pos=convertPyToNewDblArr2(p,&sz);
- std::vector<int> elts;
- self->getCellsContainingPoint(pos,eps,elts);
- delete [] pos;
- return convertIntArrToPyList2(elts);
- }
-
- static PyObject *mergeUMeshesOnSameCoords(PyObject *ms) throw(INTERP_KERNEL::Exception)
- {
- std::vector<ParaMEDMEM::MEDCouplingUMesh *> meshes;
- if(PyList_Check(ms))
- {
- int sz=PyList_Size(ms);
- meshes.resize(sz);
- for(int i=0;i<sz;i++)
- {
- PyObject *o=PyList_GetItem(ms,i);
- void *arg;
- SWIG_ConvertPtr(o,&arg,SWIGTYPE_p_ParaMEDMEM__MEDCouplingUMesh, 0 | 0 );
- meshes[i]=reinterpret_cast<ParaMEDMEM::MEDCouplingUMesh *>(arg);
- }
- }
- else
- {
- PyErr_SetString(PyExc_TypeError,"mergeUMeshesOnSameCoords : not a list as first parameter");
- PyErr_Print();
- return 0;
- }
- MEDCouplingUMesh *ret=MEDCouplingUMesh::mergeUMeshesOnSameCoords(meshes);
- return convertMesh(ret, SWIG_POINTER_OWN | 0 );
- }
-
- static PyObject *fuseUMeshesOnSameCoords(PyObject *ms, int compType)
- {
- int sz;
- std::vector<MEDCouplingUMesh *> meshes;
- convertPyObjToVecUMeshes(ms,meshes);
- std::vector<DataArrayInt *> corr;
- MEDCouplingUMesh *um=MEDCouplingUMesh::fuseUMeshesOnSameCoords(meshes,compType,corr);
- sz=corr.size();
- PyObject *ret1=PyList_New(sz);
- for(int i=0;i<sz;i++)
- PyList_SetItem(ret1,i,SWIG_NewPointerObj(SWIG_as_voidptr(corr[i]),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 ));
- PyObject *ret=PyList_New(2);
- PyList_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(um),SWIGTYPE_p_ParaMEDMEM__MEDCouplingUMesh, SWIG_POINTER_OWN | 0 ));
- PyList_SetItem(ret,1,ret1);
- return ret;
- }
-
- PyObject *are2DCellsNotCorrectlyOriented(PyObject *vec, bool polyOnly) const throw(INTERP_KERNEL::Exception)
- {
- std::vector<int> cells;
- int sz;
- double *v=convertPyToNewDblArr2(vec,&sz);
- try
- {
- self->are2DCellsNotCorrectlyOriented(v,polyOnly,cells);
- }
- catch(INTERP_KERNEL::Exception& e)
- {
- delete [] v;
- throw e;
- }
- delete [] v;
- return convertIntArrToPyList2(cells);
- }
-
- void orientCorrectly2DCells(PyObject *vec, bool polyOnly) throw(INTERP_KERNEL::Exception)
- {
- int sz;
- double *v=convertPyToNewDblArr2(vec,&sz);
- try
- {
- self->orientCorrectly2DCells(v,polyOnly);
- }
- catch(INTERP_KERNEL::Exception& e)
- {
- delete [] v;
- throw e;
- }
- delete [] v;
- }
-
- PyObject *arePolyhedronsNotCorrectlyOriented() const throw(INTERP_KERNEL::Exception)
- {
- std::vector<int> cells;
- self->arePolyhedronsNotCorrectlyOriented(cells);
- return convertIntArrToPyList2(cells);
- }
-
- PyObject *getFastAveragePlaneOfThis() const throw(INTERP_KERNEL::Exception)
- {
- double vec[3];
- double pos[3];
- self->getFastAveragePlaneOfThis(vec,pos);
- double vals[6];
- std::copy(vec,vec+3,vals);
- std::copy(pos,pos+3,vals+3);
- return convertDblArrToPyListOfTuple(vals,3,2);
- }
- }
- void convertToPolyTypes(const std::vector<int>& cellIdsToConvert);
- void unPolyze();
- MEDCouplingUMesh *buildExtrudedMeshFromThis(const MEDCouplingUMesh *mesh1D, int policy);
- static MEDCouplingUMesh *mergeUMeshes(const MEDCouplingUMesh *mesh1, const MEDCouplingUMesh *mesh2) throw(INTERP_KERNEL::Exception);
- };
-
- class MEDCouplingExtrudedMesh : public ParaMEDMEM::MEDCouplingMesh
- {
- public:
- static MEDCouplingExtrudedMesh *New(const MEDCouplingUMesh *mesh3D, MEDCouplingUMesh *mesh2D, int cell2DId) throw(INTERP_KERNEL::Exception);
- MEDCouplingUMesh *build3DUnstructuredMesh() const;
- %extend {
- std::string __str__() const
- {
- return self->simpleRepr();
- }
- PyObject *getMesh2D() const
- {
- MEDCouplingUMesh *ret=self->getMesh2D();
- ret->incrRef();
- return convertMesh(ret, SWIG_POINTER_OWN | 0 );
- }
- PyObject *getMesh1D() const
- {
- MEDCouplingUMesh *ret=self->getMesh1D();
- ret->incrRef();
- return convertMesh(ret, SWIG_POINTER_OWN | 0 );
- }
- PyObject *getMesh3DIds() const
- {
- DataArrayInt *ret=self->getMesh3DIds();
- ret->incrRef();
- return SWIG_NewPointerObj(SWIG_as_voidptr(ret),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 );
- }
- }
- };
-
- class MEDCouplingCMesh : public ParaMEDMEM::MEDCouplingMesh
- {
- public:
- static MEDCouplingCMesh *New();
- void setCoords(DataArrayDouble *coordsX,
- DataArrayDouble *coordsY=0,
- DataArrayDouble *coordsZ=0);
- void setCoordsAt(int i, DataArrayDouble *arr) throw(INTERP_KERNEL::Exception);
- MEDCouplingUMesh *buildUnstructured() const;
- %extend {
- std::string __str__() const
- {
- return self->simpleRepr();
- }
- }
- };
-}
-
-%extend ParaMEDMEM::DataArray
-{
- void copyPartOfStringInfoFrom(const DataArray& other, PyObject *li) throw(INTERP_KERNEL::Exception)
- {
- std::vector<int> tmp;
- convertPyToNewIntArr3(li,tmp);
- self->copyPartOfStringInfoFrom(other,tmp);
- }
-
- void copyPartOfStringInfoFrom2(PyObject *li, const DataArray& other) throw(INTERP_KERNEL::Exception)
- {
- std::vector<int> tmp;
- convertPyToNewIntArr3(li,tmp);
- self->copyPartOfStringInfoFrom2(tmp,other);
- }
-}
-
-%extend ParaMEDMEM::DataArrayDouble
- {
- std::string __str__() const
- {
- return self->repr();
- }
-
- void setValues(PyObject *li, int nbOfTuples, int nbOfElsPerTuple)
- {
- int sz;
- double *tmp=convertPyToNewDblArr2(li,&sz);
- self->useArray(tmp,true,CPP_DEALLOC,nbOfTuples,nbOfElsPerTuple);
- }
-
- PyObject *getValues()
- {
- const double *vals=self->getPointer();
- return convertDblArrToPyList(vals,self->getNbOfElems());
- }
-
- PyObject *getValuesAsTuple()
- {
- const double *vals=self->getPointer();
- int nbOfComp=self->getNumberOfComponents();
- int nbOfTuples=self->getNumberOfTuples();
- return convertDblArrToPyListOfTuple(vals,nbOfComp,nbOfTuples);
- }
-
- DataArrayDouble *renumber(PyObject *li) throw(INTERP_KERNEL::Exception)
- {
- int size;
- int *tmp=convertPyToNewIntArr2(li,&size);
- if(size!=self->getNumberOfTuples())
- {
- throw INTERP_KERNEL::Exception("Invalid list length ! Must be equal to number of tuples !");
- delete [] tmp;
- }
- DataArrayDouble *ret=self->renumber(tmp);
- delete [] tmp;
- return ret;
- }
-
- DataArrayDouble *renumberR(PyObject *li) throw(INTERP_KERNEL::Exception)
- {
- int size;
- int *tmp=convertPyToNewIntArr2(li,&size);
- if(size!=self->getNumberOfTuples())
- {
- throw INTERP_KERNEL::Exception("Invalid list length ! Must be equal to number of tuples !");
- delete [] tmp;
- }
- DataArrayDouble *ret=self->renumberR(tmp);
- delete [] tmp;
- return ret;
- }
-
- DataArrayDouble *renumberAndReduce(PyObject *li, int newNbOfTuple) throw(INTERP_KERNEL::Exception)
- {
- int size;
- int *tmp=convertPyToNewIntArr2(li,&size);
- if(size!=self->getNumberOfTuples())
- {
- throw INTERP_KERNEL::Exception("Invalid list length ! Must be equal to number of tuples !");
- delete [] tmp;
- }
- DataArrayDouble *ret=self->renumberAndReduce(tmp,newNbOfTuple);
- delete [] tmp;
- return ret;
- }
-
- void renumberInPlace(PyObject *li) throw(INTERP_KERNEL::Exception)
- {
- int size;
- int *tmp=convertPyToNewIntArr2(li,&size);
- if(size!=self->getNumberOfTuples())
- {
- throw INTERP_KERNEL::Exception("Invalid list length ! Must be equal to number of tuples !");
- delete [] tmp;
- }
- self->renumberInPlace(tmp);
- delete [] tmp;
- }
-
- void renumberInPlaceR(PyObject *li) throw(INTERP_KERNEL::Exception)
- {
- int size;
- int *tmp=convertPyToNewIntArr2(li,&size);
- if(size!=self->getNumberOfTuples())
- {
- throw INTERP_KERNEL::Exception("Invalid list length ! Must be equal to number of tuples !");
- delete [] tmp;
- }
- self->renumberInPlaceR(tmp);
- delete [] tmp;
- }
-
- DataArrayDouble *selectByTupleId(PyObject *li) const
- {
- int size;
- int *tmp=convertPyToNewIntArr2(li,&size);
- DataArrayDouble *ret=self->selectByTupleId(tmp,tmp+size);
- delete [] tmp;
- return ret;
- }
-
- PyObject *getMaxValue() const throw(INTERP_KERNEL::Exception)
- {
- int tmp;
- double r1=self->getMaxValue(tmp);
- PyObject *ret=PyTuple_New(2);
- PyTuple_SetItem(ret,0,PyFloat_FromDouble(r1));
- PyTuple_SetItem(ret,1,PyInt_FromLong(tmp));
- return ret;
- }
-
- PyObject *getMaxValue2() const throw(INTERP_KERNEL::Exception)
- {
- DataArrayInt *tmp;
- double r1=self->getMaxValue2(tmp);
- PyObject *ret=PyTuple_New(2);
- PyTuple_SetItem(ret,0,PyFloat_FromDouble(r1));
- PyTuple_SetItem(ret,1,SWIG_NewPointerObj(SWIG_as_voidptr(tmp),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 ));
- return ret;
- }
-
- PyObject *getMinValue() const throw(INTERP_KERNEL::Exception)
- {
- int tmp;
- double r1=self->getMinValue(tmp);
- PyObject *ret=PyTuple_New(2);
- PyTuple_SetItem(ret,0,PyFloat_FromDouble(r1));
- PyTuple_SetItem(ret,1,PyInt_FromLong(tmp));
- return ret;
- }
-
- PyObject *getMinValue2() const throw(INTERP_KERNEL::Exception)
- {
- DataArrayInt *tmp;
- double r1=self->getMinValue2(tmp);
- PyObject *ret=PyTuple_New(2);
- PyTuple_SetItem(ret,0,PyFloat_FromDouble(r1));
- PyTuple_SetItem(ret,1,SWIG_NewPointerObj(SWIG_as_voidptr(tmp),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 ));
- return ret;
- }
-
- PyObject *accumulate() const throw(INTERP_KERNEL::Exception)
- {
- int sz=self->getNumberOfComponents();
- double *tmp=new double[sz];
- try
- {
- self->accumulate(tmp);
- }
- catch(INTERP_KERNEL::Exception& e)
- {
- delete [] tmp;
- throw e;
- }
- PyObject *ret=convertDblArrToPyList(tmp,sz);
- delete [] tmp;
- return ret;
- }
-
- DataArrayDouble *keepSelectedComponents(PyObject *li) const throw(INTERP_KERNEL::Exception)
- {
- std::vector<int> tmp;
- convertPyToNewIntArr3(li,tmp);
- return self->keepSelectedComponents(tmp);
- }
-
- void setSelectedComponents(const DataArrayDouble *a, PyObject *li) throw(INTERP_KERNEL::Exception)
- {
- std::vector<int> tmp;
- convertPyToNewIntArr3(li,tmp);
- self->setSelectedComponents(a,tmp);
- }
- };
-
-%extend ParaMEDMEM::DataArrayInt
- {
- std::string __str__() const
- {
- return self->repr();
- }
-
- void setValues(PyObject *li, int nbOfTuples, int nbOfElsPerTuple)
- {
- int size;
- int *tmp=convertPyToNewIntArr2(li,&size);
- self->useArray(tmp,true,CPP_DEALLOC,nbOfTuples,nbOfElsPerTuple);
- }
-
- PyObject *getValues()
- {
- const int *vals=self->getPointer();
- return convertIntArrToPyList(vals,self->getNbOfElems());
- }
-
- PyObject *getValuesAsTuple()
- {
- const int *vals=self->getPointer();
- int nbOfComp=self->getNumberOfComponents();
- int nbOfTuples=self->getNumberOfTuples();
- return convertIntArrToPyListOfTuple(vals,nbOfComp,nbOfTuples);
- }
-
- static PyObject *makePartition(PyObject *gps, int newNb)
- {
- std::vector<DataArrayInt *> groups;
- std::vector< std::vector<int> > fidsOfGroups;
- convertPyObjToVecDataArrayInt(gps,groups);
- ParaMEDMEM::DataArrayInt *ret0=ParaMEDMEM::DataArrayInt::makePartition(groups,newNb,fidsOfGroups);
- PyObject *ret = PyList_New(2);
- PyList_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(ret0),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 ));
- int sz=fidsOfGroups.size();
- PyObject *ret1 = PyList_New(sz);
- for(int i=0;i<sz;i++)
- PyList_SetItem(ret1,i,convertIntArrToPyList2(fidsOfGroups[i]));
- PyList_SetItem(ret,1,ret1);
- return ret;
- }
-
- void renumberInPlace(PyObject *li) throw(INTERP_KERNEL::Exception)
- {
- int size;
- int *tmp=convertPyToNewIntArr2(li,&size);
- if(size!=self->getNumberOfTuples())
- {
- throw INTERP_KERNEL::Exception("Invalid list length ! Must be equal to number of tuples !");
- delete [] tmp;
- }
- self->renumberInPlace(tmp);
- delete [] tmp;
- }
-
- void renumberInPlaceR(PyObject *li) throw(INTERP_KERNEL::Exception)
- {
- int size;
- int *tmp=convertPyToNewIntArr2(li,&size);
- if(size!=self->getNumberOfTuples())
- {
- throw INTERP_KERNEL::Exception("Invalid list length ! Must be equal to number of tuples !");
- delete [] tmp;
- }
- self->renumberInPlaceR(tmp);
- delete [] tmp;
- }
-
- DataArrayInt *renumberAndReduce(PyObject *li, int newNbOfTuple) throw(INTERP_KERNEL::Exception)
- {
- int size;
- int *tmp=convertPyToNewIntArr2(li,&size);
- if(size!=self->getNumberOfTuples())
- {
- throw INTERP_KERNEL::Exception("Invalid list length ! Must be equal to number of tuples !");
- delete [] tmp;
- }
- DataArrayInt *ret=self->renumberAndReduce(tmp,newNbOfTuple);
- delete [] tmp;
- return ret;
- }
-
- DataArrayInt *renumber(PyObject *li) throw(INTERP_KERNEL::Exception)
- {
- int size;
- int *tmp=convertPyToNewIntArr2(li,&size);
- if(size!=self->getNumberOfTuples())
- {
- throw INTERP_KERNEL::Exception("Invalid list length ! Must be equal to number of tuples !");
- delete [] tmp;
- }
- DataArrayInt *ret=self->renumber(tmp);
- delete [] tmp;
- return ret;
- }
-
- DataArrayInt *renumberR(PyObject *li) throw(INTERP_KERNEL::Exception)
- {
- int size;
- int *tmp=convertPyToNewIntArr2(li,&size);
- if(size!=self->getNumberOfTuples())
- {
- throw INTERP_KERNEL::Exception("Invalid list length ! Must be equal to number of tuples !");
- delete [] tmp;
- }
- DataArrayInt *ret=self->renumberR(tmp);
- delete [] tmp;
- return ret;
- }
-
- DataArrayInt *selectByTupleId(PyObject *li) const
- {
- int size;
- int *tmp=convertPyToNewIntArr2(li,&size);
- DataArrayInt *ret=self->selectByTupleId(tmp,tmp+size);
- delete [] tmp;
- return ret;
- }
-
- DataArrayInt *keepSelectedComponents(PyObject *li) const throw(INTERP_KERNEL::Exception)
- {
- std::vector<int> tmp;
- convertPyToNewIntArr3(li,tmp);
- return self->keepSelectedComponents(tmp);
- }
-
- void setSelectedComponents(const DataArrayInt *a, PyObject *li) throw(INTERP_KERNEL::Exception)
- {
- std::vector<int> tmp;
- convertPyToNewIntArr3(li,tmp);
- self->setSelectedComponents(a,tmp);
- }
- };
-
-namespace ParaMEDMEM
-{
- class MEDCouplingField : public ParaMEDMEM::RefCountObject, public ParaMEDMEM::TimeLabel
- {
- public:
- virtual void checkCoherency() const throw(INTERP_KERNEL::Exception);
- virtual bool areCompatibleForMerge(const MEDCouplingField *other) const;
- virtual bool isEqual(const MEDCouplingField *other, double meshPrec, double valsPrec) const;
- virtual bool isEqualWithoutConsideringStr(const MEDCouplingField *other, double meshPrec, double valsPrec) const;
- void setMesh(const ParaMEDMEM::MEDCouplingMesh *mesh);
- void setName(const char *name);
- const char *getDescription() const;
- void setDescription(const char *desc);
- const char *getName() const;
- TypeOfField getTypeOfField() const;
- MEDCouplingFieldDouble *buildMeasureField(bool isAbs) const throw(INTERP_KERNEL::Exception);
- MEDCouplingFieldDiscretization *getDiscretization() const;
- void setGaussLocalizationOnType(INTERP_KERNEL::NormalizedCellType type, const std::vector<double>& refCoo,
- const std::vector<double>& gsCoo, const std::vector<double>& wg) throw(INTERP_KERNEL::Exception);
- void clearGaussLocalizations();
- MEDCouplingGaussLocalization& getGaussLocalization(int locId) throw(INTERP_KERNEL::Exception);
- int getNbOfGaussLocalization() const throw(INTERP_KERNEL::Exception);
- int getGaussLocalizationIdOfOneCell(int cellId) const throw(INTERP_KERNEL::Exception);
- const MEDCouplingGaussLocalization& getGaussLocalization(int locId) const throw(INTERP_KERNEL::Exception);
- %extend {
- PyObject *getMesh() const
- {
- MEDCouplingMesh *ret1=(MEDCouplingMesh *)self->getMesh();
- ret1->incrRef();
- return convertMesh(ret1, SWIG_POINTER_OWN | 0 );
- }
-
- PyObject *buildSubMeshData(PyObject *li) const
- {
- int size;
- int *tmp=convertPyToNewIntArr2(li,&size);
- DataArrayInt *ret1;
- MEDCouplingMesh *ret0=self->buildSubMeshData(tmp,tmp+size,ret1);
- delete [] tmp;
- PyObject *res = PyList_New(2);
- PyList_SetItem(res,0,convertMesh(ret0, SWIG_POINTER_OWN | 0 ));
- PyList_SetItem(res,1,SWIG_NewPointerObj((void*)ret1,SWIGTYPE_p_ParaMEDMEM__DataArrayInt,SWIG_POINTER_OWN | 0));
- return res;
- }
- void setGaussLocalizationOnCells(PyObject *li, const std::vector<double>& refCoo,
- const std::vector<double>& gsCoo, const std::vector<double>& wg) throw(INTERP_KERNEL::Exception)
- {
- int size;
- int *tmp=convertPyToNewIntArr2(li,&size);
- try
- {
- self->setGaussLocalizationOnCells(tmp,tmp+size,refCoo,gsCoo,wg);
- }
- catch(INTERP_KERNEL::Exception& e)
- {
- delete [] tmp;
- throw e;
- }
- delete [] tmp;
- }
- PyObject *getCellIdsHavingGaussLocalization(int locId) const throw(INTERP_KERNEL::Exception)
- {
- std::vector<int> tmp;
- self->getCellIdsHavingGaussLocalization(locId,tmp);
- return convertIntArrToPyList2(tmp);
- }
- }
- };
-
- class MEDCouplingFieldDouble : public ParaMEDMEM::MEDCouplingField
- {
- public:
- static MEDCouplingFieldDouble *New(TypeOfField type, TypeOfTimeDiscretization td=NO_TIME);
- void copyTinyStringsFrom(const MEDCouplingFieldDouble *other) throw(INTERP_KERNEL::Exception);
- void copyTinyAttrFrom(const MEDCouplingFieldDouble *other) throw(INTERP_KERNEL::Exception);
- std::string simpleRepr() const;
- std::string advancedRepr() const;
- MEDCouplingFieldDouble *clone(bool recDeepCpy) const;
- MEDCouplingFieldDouble *cloneWithMesh(bool recDeepCpy) const;
- MEDCouplingFieldDouble *buildNewTimeReprFromThis(TypeOfTimeDiscretization td, bool deepCpy) const;
- TypeOfTimeDiscretization getTimeDiscretization() const;
- void checkCoherency() const throw(INTERP_KERNEL::Exception);
- double getIJ(int tupleId, int compoId) const;
- double getIJK(int cellId, int nodeIdInCell, int compoId) const;
- void setArray(DataArrayDouble *array) throw(INTERP_KERNEL::Exception);
- void setEndArray(DataArrayDouble *array) throw(INTERP_KERNEL::Exception);
- void setTime(double val, int iteration, int order) throw(INTERP_KERNEL::Exception);
- void setStartTime(double val, int iteration, int order) throw(INTERP_KERNEL::Exception);
- void setEndTime(double val, int iteration, int order) throw(INTERP_KERNEL::Exception);
- DataArrayDouble *getArray() const throw(INTERP_KERNEL::Exception);
- DataArrayDouble *getEndArray() const throw(INTERP_KERNEL::Exception);
- void applyLin(double a, double b, int compoId) throw(INTERP_KERNEL::Exception);
- int getNumberOfComponents() const throw(INTERP_KERNEL::Exception);
- int getNumberOfTuples() const throw(INTERP_KERNEL::Exception);
- int getNumberOfValues() const throw(INTERP_KERNEL::Exception);
- NatureOfField getNature() const { return _nature; }
- void setNature(NatureOfField nat) throw(INTERP_KERNEL::Exception);
- void setTimeTolerance(double val);
- double getTimeTolerance() const;
- void updateTime();
- void changeUnderlyingMesh(const MEDCouplingMesh *other, int levOfCheck, double prec) throw(INTERP_KERNEL::Exception);
- void substractInPlaceDM(const MEDCouplingFieldDouble *f, int levOfCheck, double prec) throw(INTERP_KERNEL::Exception);
- bool mergeNodes(double eps) throw(INTERP_KERNEL::Exception);
- bool zipCoords() throw(INTERP_KERNEL::Exception);
- bool zipConnectivity(int compType) throw(INTERP_KERNEL::Exception);
- bool simplexize(int policy) throw(INTERP_KERNEL::Exception);
- MEDCouplingFieldDouble *doublyContractedProduct() const throw(INTERP_KERNEL::Exception);
- MEDCouplingFieldDouble *determinant() const throw(INTERP_KERNEL::Exception);
- MEDCouplingFieldDouble *eigenValues() const throw(INTERP_KERNEL::Exception);
- MEDCouplingFieldDouble *eigenVectors() const throw(INTERP_KERNEL::Exception);
- MEDCouplingFieldDouble *inverse() const throw(INTERP_KERNEL::Exception);
- MEDCouplingFieldDouble *trace() const throw(INTERP_KERNEL::Exception);
- MEDCouplingFieldDouble *deviator() const throw(INTERP_KERNEL::Exception);
- MEDCouplingFieldDouble *magnitude() const throw(INTERP_KERNEL::Exception);
- MEDCouplingFieldDouble *maxPerTuple() const throw(INTERP_KERNEL::Exception);
- void changeNbOfComponents(int newNbOfComp, double dftValue=0.) throw(INTERP_KERNEL::Exception);
- void sortPerTuple(bool asc) throw(INTERP_KERNEL::Exception);
- MEDCouplingFieldDouble &operator=(double value) throw(INTERP_KERNEL::Exception);
- void fillFromAnalytic(int nbOfComp, const char *func) throw(INTERP_KERNEL::Exception);
- void applyFunc(int nbOfComp, const char *func) throw(INTERP_KERNEL::Exception);
- void applyFunc(int nbOfComp, double val) throw(INTERP_KERNEL::Exception);
- void applyFunc(const char *func) throw(INTERP_KERNEL::Exception);
- void applyFuncFast32(const char *func) throw(INTERP_KERNEL::Exception);
- void applyFuncFast64(const char *func) throw(INTERP_KERNEL::Exception);
- double accumulate(int compId) const throw(INTERP_KERNEL::Exception);
- double getMaxValue() const throw(INTERP_KERNEL::Exception);
- double getMinValue() const throw(INTERP_KERNEL::Exception);
- double getAverageValue() const throw(INTERP_KERNEL::Exception);
- double getWeightedAverageValue() const throw(INTERP_KERNEL::Exception);
- double integral(int compId, bool isWAbs) const throw(INTERP_KERNEL::Exception);
- double normL1(int compId) const throw(INTERP_KERNEL::Exception);
- double normL2(int compId) const throw(INTERP_KERNEL::Exception);
- DataArrayInt *getIdsInRange(double vmin, double vmax) const throw(INTERP_KERNEL::Exception);
- MEDCouplingFieldDouble *buildSubPart(const DataArrayInt *part) const throw(INTERP_KERNEL::Exception);
- static MEDCouplingFieldDouble *mergeFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2) throw(INTERP_KERNEL::Exception);
- static MEDCouplingFieldDouble *dotFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2);
- MEDCouplingFieldDouble *dot(const MEDCouplingFieldDouble& other) const;
- static MEDCouplingFieldDouble *crossProductFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2);
- MEDCouplingFieldDouble *crossProduct(const MEDCouplingFieldDouble& other) const;
- static MEDCouplingFieldDouble *maxFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2);
- MEDCouplingFieldDouble *max(const MEDCouplingFieldDouble& other) const;
- static MEDCouplingFieldDouble *minFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2);
- MEDCouplingFieldDouble *min(const MEDCouplingFieldDouble& other) const;
- MEDCouplingFieldDouble *operator+(const MEDCouplingFieldDouble& other) const throw(INTERP_KERNEL::Exception);
- const MEDCouplingFieldDouble &operator+=(const MEDCouplingFieldDouble& other) throw(INTERP_KERNEL::Exception);
- MEDCouplingFieldDouble *operator-(const MEDCouplingFieldDouble& other) const throw(INTERP_KERNEL::Exception);
- const MEDCouplingFieldDouble &operator-=(const MEDCouplingFieldDouble& other) throw(INTERP_KERNEL::Exception);
- MEDCouplingFieldDouble *operator*(const MEDCouplingFieldDouble& other) const throw(INTERP_KERNEL::Exception);
- const MEDCouplingFieldDouble &operator*=(const MEDCouplingFieldDouble& other) throw(INTERP_KERNEL::Exception);
- MEDCouplingFieldDouble *operator/(const MEDCouplingFieldDouble& other) const throw(INTERP_KERNEL::Exception);
- const MEDCouplingFieldDouble &operator/=(const MEDCouplingFieldDouble& other) throw(INTERP_KERNEL::Exception);
- %extend {
- std::string __str__() const
- {
- return self->simpleRepr();
- }
- PyObject *getValueOn(PyObject *sl) const throw(INTERP_KERNEL::Exception)
- {
- int sz;
- double *spaceLoc=convertPyToNewDblArr2(sl,&sz);
- sz=self->getNumberOfComponents();
- double *res=new double[sz];
- try
- {
- self->getValueOn(spaceLoc,res);
- }
- catch(INTERP_KERNEL::Exception& e)
- {
- delete [] spaceLoc;
- delete [] res;
- throw e;
- }
- delete [] spaceLoc;
- PyObject *ret=convertDblArrToPyList(res,sz);
- delete [] res;
- return ret;
- }
- PyObject *getValueOn(PyObject *sl, double time) const throw(INTERP_KERNEL::Exception)
- {
- int sz;
- double *spaceLoc=convertPyToNewDblArr2(sl,&sz);
- sz=self->getNumberOfComponents();
- double *res=new double[sz];
- try
- {
- self->getValueOn(spaceLoc,time,res);
- }
- catch(INTERP_KERNEL::Exception& e)
- {
- delete [] spaceLoc;
- delete [] res;
- throw e;
- }
- delete [] spaceLoc;
- PyObject *ret=convertDblArrToPyList(res,sz);
- delete [] res;
- return ret;
- }
- void setValues(PyObject *li)
- {
- if(self->getArray()!=0)
- {
- int sz;
- double *tmp=convertPyToNewDblArr2(li,&sz);
- int nbTuples=self->getArray()->getNumberOfTuples();
- int nbOfCompo=self->getArray()->getNumberOfComponents();
- self->getArray()->useArray(tmp,true,CPP_DEALLOC,nbTuples,nbOfCompo);
- }
- else
- PyErr_SetString(PyExc_TypeError,"setValuesCpy : field must contain an array behind");
- }
- PyObject *getTime()
- {
- int tmp1,tmp2;
- double tmp0=self->getTime(tmp1,tmp2);
- PyObject *res = PyList_New(3);
- PyList_SetItem(res,0,SWIG_From_double(tmp0));
- PyList_SetItem(res,1,SWIG_From_int(tmp1));
- PyList_SetItem(res,2,SWIG_From_int(tmp2));
- return res;
- }
-
- PyObject *getStartTime()
- {
- int tmp1,tmp2;
- double tmp0=self->getStartTime(tmp1,tmp2);
- PyObject *res = PyList_New(3);
- PyList_SetItem(res,0,SWIG_From_double(tmp0));
- PyList_SetItem(res,1,SWIG_From_int(tmp1));
- PyList_SetItem(res,2,SWIG_From_int(tmp2));
- return res;
- }
-
- PyObject *getEndTime()
- {
- int tmp1,tmp2;
- double tmp0=self->getEndTime(tmp1,tmp2);
- PyObject *res = PyList_New(3);
- PyList_SetItem(res,0,SWIG_From_double(tmp0));
- PyList_SetItem(res,1,SWIG_From_int(tmp1));
- PyList_SetItem(res,2,SWIG_From_int(tmp2));
- return res;
- }
- PyObject *accumulate() const
- {
- int sz=self->getNumberOfComponents();
- double *tmp=new double[sz];
- self->accumulate(tmp);
- PyObject *ret=convertDblArrToPyList(tmp,sz);
- delete [] tmp;
- return ret;
- }
- PyObject *integral(bool isWAbs) const
- {
- int sz=self->getNumberOfComponents();
- double *tmp=new double[sz];
- self->integral(isWAbs,tmp);
- PyObject *ret=convertDblArrToPyList(tmp,sz);
- delete [] tmp;
- return ret;
- }
- PyObject *normL1() const throw(INTERP_KERNEL::Exception)
- {
- int sz=self->getNumberOfComponents();
- double *tmp=new double[sz];
- self->normL1(tmp);
- PyObject *ret=convertDblArrToPyList(tmp,sz);
- delete [] tmp;
- return ret;
- }
- PyObject *normL2() const throw(INTERP_KERNEL::Exception)
- {
- int sz=self->getNumberOfComponents();
- double *tmp=new double[sz];
- self->normL2(tmp);
- PyObject *ret=convertDblArrToPyList(tmp,sz);
- delete [] tmp;
- return ret;
- }
-
- void renumberCells(PyObject *li, bool check) throw(INTERP_KERNEL::Exception)
- {
- int size;
- int *tmp=convertPyToNewIntArr2(li,&size);
- try
- {
- self->renumberCells(tmp,check);
- }
- catch(INTERP_KERNEL::Exception& e)
- {
- delete [] tmp;
- throw e;
- }
- delete [] tmp;
- }
- void renumberNodes(PyObject *li) throw(INTERP_KERNEL::Exception)
- {
- int size;
- int *tmp=convertPyToNewIntArr2(li,&size);
- try
- {
- self->renumberNodes(tmp);
- }
- catch(INTERP_KERNEL::Exception& e)
- {
- delete [] tmp;
- throw e;
- }
- delete [] tmp;
- }
-
- MEDCouplingFieldDouble *buildSubPart(PyObject *li) const throw(INTERP_KERNEL::Exception)
- {
- int size;
- int *tmp=convertPyToNewIntArr2(li,&size);
- MEDCouplingFieldDouble *ret=0;
- try
- {
- ret=self->buildSubPart(tmp,tmp+size);
- }
- catch(INTERP_KERNEL::Exception& e)
- {
- delete [] tmp;
- throw e;
- }
- delete [] tmp;
- return ret;
- }
-
- PyObject *getMaxValue2() const throw(INTERP_KERNEL::Exception)
- {
- DataArrayInt *tmp;
- double r1=self->getMaxValue2(tmp);
- PyObject *ret=PyTuple_New(2);
- PyTuple_SetItem(ret,0,PyFloat_FromDouble(r1));
- PyTuple_SetItem(ret,1,SWIG_NewPointerObj(SWIG_as_voidptr(tmp),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 ));
- return ret;
- }
-
- PyObject *getMinValue2() const throw(INTERP_KERNEL::Exception)
- {
- DataArrayInt *tmp;
- double r1=self->getMinValue2(tmp);
- PyObject *ret=PyTuple_New(2);
- PyTuple_SetItem(ret,0,PyFloat_FromDouble(r1));
- PyTuple_SetItem(ret,1,SWIG_NewPointerObj(SWIG_as_voidptr(tmp),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 ));
- return ret;
- }
-
- MEDCouplingFieldDouble *keepSelectedComponents(PyObject *li) const throw(INTERP_KERNEL::Exception)
- {
- std::vector<int> tmp;
- convertPyToNewIntArr3(li,tmp);
- return self->keepSelectedComponents(tmp);
- }
-
- void setSelectedComponents(const MEDCouplingFieldDouble *f, PyObject *li) throw(INTERP_KERNEL::Exception)
- {
- std::vector<int> tmp;
- convertPyToNewIntArr3(li,tmp);
- self->setSelectedComponents(f,tmp);
- }
- }
- };
-}
--- /dev/null
+# -*- coding: iso-8859-1 -*-
+# Copyright (C) 2007-2010 CEA/DEN, EDF R&D
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+#
+
+print """
+***********************************************************************
+***********************************************************************
+libMEDCoupling_Swig module DEPRECATED !
+Please use instead \"import MEDCoupling\" or \"from MEDCoupling import *\"
+***********************************************************************
+***********************************************************************
+"""
--- /dev/null
+// Copyright (C) 2007-2010 CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#include "MEDFileBasis.hxx"
+
+#include <cstring>
+
+using namespace ParaMEDMEM;
+
+MEDFileString::MEDFileString(int maxLgth):_max_lgth(maxLgth),_content(new char[maxLgth+1])
+{
+ std::fill(_content,_content+maxLgth+1,'\0');
+}
+
+MEDFileString::~MEDFileString()
+{
+ delete [] _content;
+}
+
+void MEDFileString::set(const char *s) throw(INTERP_KERNEL::Exception)
+{
+ if((int)strlen(s)>_max_lgth)
+ throw INTERP_KERNEL::Exception("Name is too long to be stored in MEDfile !");
+ std::fill(_content,_content+_max_lgth+1,'\0');
+ strcpy(_content,s);
+}
+
+std::string MEDFileString::getRepr() const
+{
+ return std::string(_content);
+}
+
--- /dev/null
+// Copyright (C) 2007-2010 CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#ifndef __MEDFILEBASIS_HXX__
+#define __MEDFILEBASIS_HXX__
+
+#include "InterpKernelException.hxx"
+
+#include <string>
+#include <vector>
+
+namespace ParaMEDMEM
+{
+ class MEDFileString
+ {
+ public:
+ MEDFileString(int maxLgth);
+ ~MEDFileString();
+ void set(const char *s) throw(INTERP_KERNEL::Exception);
+ char *getPointer() { return _content; }
+ const char *getReprForWrite() const { return _content; }
+ std::string getRepr() const;
+ private:
+ int _max_lgth;
+ char *_content;
+ };
+
+
+ class MEDFileMultiString
+ {
+ public:
+ MEDFileMultiString(int nbOfCompo, int maxLgthPerCompo);
+ ~MEDFileMultiString();
+ void set(int compoId, const char *s);
+ const char *getReprForWrite() const;
+ std::vector<std::string> getRepr() const;
+ std::string getReprPerComp(int compId) const;
+ private:
+ int _nb_of_comp;
+ int _max_lgth_per_comp;
+ char *_content;
+ };
+}
+
+#endif
--- /dev/null
+// Copyright (C) 2007-2010 CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#include "MEDFileField.hxx"
+#include "MEDLoaderBase.hxx"
+#include "MEDFileUtilities.hxx"
+
+#include "InterpKernelAutoPtr.hxx"
+
+#include <algorithm>
+
+extern med_geometrie_element typmai[MED_NBR_GEOMETRIE_MAILLE+2];
+extern INTERP_KERNEL::NormalizedCellType typmai2[MED_NBR_GEOMETRIE_MAILLE+2];
+extern med_geometrie_element typmainoeud[1];
+extern med_geometrie_element typmai3[32];
+
+using namespace ParaMEDMEM;
+
+MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::New(MEDFileFieldPerMeshPerType *fath, med_idt fid) throw(INTERP_KERNEL::Exception)
+{
+ return new MEDFileFieldPerMeshPerTypePerDisc(fath,fid);
+}
+
+MEDFileFieldPerMeshPerTypePerDisc::MEDFileFieldPerMeshPerTypePerDisc(MEDFileFieldPerMeshPerType *fath, med_idt fid) throw(INTERP_KERNEL::Exception)
+try:_father(fath)
+{
+ INTERP_KERNEL::AutoPtr<char> locname=MEDLoaderBase::buildEmptyString(MED_TAILLE_NOM);
+ INTERP_KERNEL::AutoPtr<char> pflname=MEDLoaderBase::buildEmptyString(MED_TAILLE_NOM);
+ std::string fieldName=getName();
+ std::string meshName=getMeshName();
+ int iteration=getIteration();
+ int order=getOrder();
+ const std::vector<std::string>& infos=getInfos();
+ TypeOfField type=getType();
+ INTERP_KERNEL::NormalizedCellType geoType=getGeoType();
+ int nval=MEDnVal(fid,(char *)fieldName.c_str(),type==ON_CELLS?MED_MAILLE:MED_NOEUD,type==ON_CELLS?typmai3[(int)geoType]:MED_NONE,
+ iteration,order,(char *)meshName.c_str(),MED_COMPACT);
+ _arr=DataArrayDouble::New();
+ _arr->alloc(nval,infos.size());
+ MEDchampLire(fid,(char *)getMeshName().c_str(),(char *)fieldName.c_str(),(unsigned char*)_arr->getPointer(),MED_FULL_INTERLACE,MED_ALL,locname,
+ pflname,MED_COMPACT,type==ON_CELLS?MED_MAILLE:MED_NOEUD,
+ type==ON_CELLS?typmai3[(int)geoType]:MED_NONE,
+ iteration,order);
+ _profile=pflname;
+ _localization=locname;
+}
+catch(INTERP_KERNEL::Exception& e)
+{
+ throw e;
+}
+
+const MEDFileFieldPerMeshPerType *MEDFileFieldPerMeshPerTypePerDisc::getFather() const
+{
+ return _father;
+}
+
+int MEDFileFieldPerMeshPerTypePerDisc::getIteration() const
+{
+ return _father->getIteration();
+}
+
+int MEDFileFieldPerMeshPerTypePerDisc::getOrder() const
+{
+ return _father->getOrder();
+}
+
+std::string MEDFileFieldPerMeshPerTypePerDisc::getName() const
+{
+ return _father->getName();
+}
+
+TypeOfField MEDFileFieldPerMeshPerTypePerDisc::getType() const
+{
+ return _father->getType();
+}
+
+INTERP_KERNEL::NormalizedCellType MEDFileFieldPerMeshPerTypePerDisc::getGeoType() const
+{
+ return _father->getGeoType();
+}
+
+std::string MEDFileFieldPerMeshPerTypePerDisc::getMeshName() const
+{
+ return _father->getMeshName();
+}
+
+int MEDFileFieldPerMeshPerTypePerDisc::getNumberOfComponents() const
+{
+ return _father->getNumberOfComponents();
+}
+
+const std::vector<std::string>& MEDFileFieldPerMeshPerTypePerDisc::getInfos() const
+{
+ return _father->getInfos();
+}
+
+std::string MEDFileFieldPerMeshPerTypePerDisc::getProfile() const
+{
+ return _profile;
+}
+
+std::string MEDFileFieldPerMeshPerTypePerDisc::getLocalization() const
+{
+ return _localization;
+}
+
+MEDFileFieldPerMeshPerType *MEDFileFieldPerMeshPerType::New(MEDFileFieldPerMesh *fath, TypeOfField type, INTERP_KERNEL::NormalizedCellType geoType) throw(INTERP_KERNEL::Exception)
+{
+ return new MEDFileFieldPerMeshPerType(fath,type,geoType);
+}
+
+const MEDFileFieldPerMesh *MEDFileFieldPerMeshPerType::getFather() const
+{
+ return _father;
+}
+
+int MEDFileFieldPerMeshPerType::getIteration() const
+{
+ return _father->getIteration();
+}
+
+int MEDFileFieldPerMeshPerType::getOrder() const
+{
+ return _father->getOrder();
+}
+
+std::string MEDFileFieldPerMeshPerType::getName() const
+{
+ return _father->getName();
+}
+
+std::string MEDFileFieldPerMeshPerType::getMeshName() const
+{
+ return _father->getMeshName();
+}
+
+TypeOfField MEDFileFieldPerMeshPerType::getType() const
+{
+ return _type;
+}
+
+INTERP_KERNEL::NormalizedCellType MEDFileFieldPerMeshPerType::getGeoType() const
+{
+ return _geo_type;
+}
+
+
+int MEDFileFieldPerMeshPerType::getNumberOfComponents() const
+{
+ return _father->getNumberOfComponents();
+}
+
+const std::vector<std::string>& MEDFileFieldPerMeshPerType::getInfos() const
+{
+ return _father->getInfos();
+}
+
+std::vector<std::string> MEDFileFieldPerMeshPerType::getPflsReallyUsed() const
+{
+ std::vector<std::string> ret;
+ for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
+ {
+ std::string tmp=(*it1)->getProfile();
+ if(!tmp.empty())
+ ret.push_back(tmp);
+ }
+ return ret;
+}
+
+std::vector<std::string> MEDFileFieldPerMeshPerType::getLocsReallyUsed() const
+{
+ std::vector<std::string> ret;
+ for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
+ {
+ std::string tmp=(*it1)->getLocalization();
+ if(!tmp.empty())
+ ret.push_back(tmp);
+ }
+ return ret;
+}
+
+MEDFileFieldPerMeshPerType::MEDFileFieldPerMeshPerType(MEDFileFieldPerMesh *fath, TypeOfField type, INTERP_KERNEL::NormalizedCellType geoType) throw(INTERP_KERNEL::Exception):_father(fath),_type(type),_geo_type(geoType)
+{
+}
+
+void MEDFileFieldPerMeshPerType::finishLoading(med_idt fid) throw(INTERP_KERNEL::Exception)
+{
+ //for MED3 porting this limitation will be killed !
+ _field_pm_pt_pd.resize(1);
+ _field_pm_pt_pd[0]=MEDFileFieldPerMeshPerTypePerDisc::New(this,fid);
+}
+
+MEDFileFieldPerMesh *MEDFileFieldPerMesh::New(MEDFileField1TSWithoutDAS *fath, const char *meshName, double time)
+{
+ return new MEDFileFieldPerMesh(fath,meshName,time);
+}
+
+void MEDFileFieldPerMesh::pushBack(TypeOfField type, INTERP_KERNEL::NormalizedCellType geoType)
+{
+ _types.push_back(type);
+ _geo_types.push_back(geoType);
+}
+
+void MEDFileFieldPerMesh::finishLoading(med_idt fid) throw(INTERP_KERNEL::Exception)
+{
+ int sz=_types.size();
+ _field_pm_pt.resize(sz);
+ for(int i=0;i<sz;i++)
+ {
+ _field_pm_pt[i]=MEDFileFieldPerMeshPerType::New(this,_types[i],_geo_types[i]);
+ _field_pm_pt[i]->finishLoading(fid);
+ }
+}
+
+double MEDFileFieldPerMesh::getTime() const
+{
+ return _time;
+}
+
+int MEDFileFieldPerMesh::getIteration() const
+{
+ return _father->getIteration();
+}
+
+int MEDFileFieldPerMesh::getOrder() const
+{
+ return _father->getOrder();
+}
+
+std::string MEDFileFieldPerMesh::getName() const
+{
+ return _father->getName();
+}
+
+std::string MEDFileFieldPerMesh::getMeshName() const
+{
+ return _mesh_name;
+}
+
+int MEDFileFieldPerMesh::getNumberOfComponents() const
+{
+ return _father->getNumberOfComponents();
+}
+
+const std::vector<std::string>& MEDFileFieldPerMesh::getInfos() const
+{
+ return _father->getInfos();
+}
+
+std::vector<std::string> MEDFileFieldPerMesh::getPflsReallyUsed() const
+{
+ std::vector<std::string> ret;
+ std::set<std::string> ret2;
+ for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
+ {
+ std::vector<std::string> tmp=(*it)->getPflsReallyUsed();
+ for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
+ if(ret2.find(*it2)==ret2.end())
+ {
+ ret.push_back(*it2);
+ ret2.insert(*it2);
+ }
+ }
+ return ret;
+}
+
+std::vector<std::string> MEDFileFieldPerMesh::getLocsReallyUsed() const
+{
+ std::vector<std::string> ret;
+ std::set<std::string> ret2;
+ for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
+ {
+ std::vector<std::string> tmp=(*it)->getLocsReallyUsed();
+ for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
+ if(ret2.find(*it2)==ret2.end())
+ {
+ ret.push_back(*it2);
+ ret2.insert(*it2);
+ }
+ }
+ return ret;
+}
+
+MEDFileFieldPerMesh::MEDFileFieldPerMesh(MEDFileField1TSWithoutDAS *fath, const char *meshName, double time):_father(fath),_mesh_name(meshName),_time(time)
+{
+}
+
+void MEDFieldFieldGlobs::loadProfileInFile(med_idt fid, int id, const char *pflName, int lgth) throw(INTERP_KERNEL::Exception)
+{
+ _pfls[id]=DataArrayInt::New();
+ _pfls[id]->alloc(lgth,1);
+ MEDprofilLire(fid,_pfls[id]->getPointer(),(char *)pflName);
+}
+
+void MEDFieldFieldGlobs::loadProfileInFile(med_idt fid, int i)
+{
+ INTERP_KERNEL::AutoPtr<char> pflName=MEDLoaderBase::buildEmptyString(MED_TAILLE_NOM);
+ int sz;
+ MEDprofilInfo(fid,i,pflName,&sz);
+ _pfls[i]=DataArrayInt::New();
+ _pfls[i]->alloc(sz,1);
+ MEDprofilLire(fid,_pfls[i]->getPointer(),(char *)pflName);
+}
+
+std::vector<std::string> MEDFieldFieldGlobs::getPfls() const
+{
+ int sz=_pfls.size();
+ std::vector<std::string> ret(sz);
+ for(int i=0;i<sz;i++)
+ ret[i]=_pfls[i]->getName();
+ return ret;
+}
+
+std::vector<std::string> MEDFieldFieldGlobs::getLocs() const
+{
+ int sz=_locs.size();
+ std::vector<std::string> ret(sz);
+ for(int i=0;i<sz;i++)
+ ret[i]=_locs[i]->getName();
+ return ret;
+}
+
+MEDFileField1TSWithoutDAS *MEDFileField1TSWithoutDAS::New(const char *fieldName, int iteration, int order, const std::vector<std::string>& infos)
+{
+ return new MEDFileField1TSWithoutDAS(fieldName,iteration,order,infos);
+}
+
+void MEDFileField1TSWithoutDAS::pushBack(TypeOfField type, INTERP_KERNEL::NormalizedCellType geoType, double time, const char *meshName) const
+{
+ _types.push_back(type);
+ _geo_types.push_back(geoType);
+ _times.push_back(time);
+ _meshes.push_back(meshName);
+}
+
+void MEDFileField1TSWithoutDAS::finishLoading(med_idt fid) throw(INTERP_KERNEL::Exception)
+{
+ std::vector<std::string> meshesOnlyOnce;
+ int nbOfTurn=_meshes.size();
+ for(int i=0;i<nbOfTurn;i++)
+ {
+ std::vector<std::string>::iterator it=std::find(meshesOnlyOnce.begin(),meshesOnlyOnce.end(),_meshes[i]);
+ if(it==meshesOnlyOnce.end())
+ {
+ _field_per_mesh.push_back(MEDFileFieldPerMesh::New(this,_meshes[i].c_str(),_times[i]));
+ meshesOnlyOnce.push_back(_meshes[i]);
+ _field_per_mesh.back()->pushBack(_types[i],_geo_types[i]);
+ }
+ else
+ {
+ int w=std::distance(meshesOnlyOnce.begin(),it);
+ _field_per_mesh[w]->pushBack(_types[i],_geo_types[i]);
+ }
+ }
+ int nbOfMeshes=_field_per_mesh.size();
+ for(int i=0;i<nbOfMeshes;i++)
+ _field_per_mesh[i]->finishLoading(fid);
+}
+
+std::vector<std::string> MEDFileField1TSWithoutDAS::getPflsReallyUsed() const
+{
+ std::vector<std::string> ret;
+ std::set<std::string> ret2;
+ for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
+ {
+ std::vector<std::string> tmp=(*it)->getPflsReallyUsed();
+ for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
+ if(ret2.find(*it2)==ret2.end())
+ {
+ ret.push_back(*it2);
+ ret2.insert(*it2);
+ }
+ }
+ return ret;
+}
+
+std::vector<std::string> MEDFileField1TSWithoutDAS::getLocsReallyUsed() const
+{
+ std::vector<std::string> ret;
+ std::set<std::string> ret2;
+ for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
+ {
+ std::vector<std::string> tmp=(*it)->getLocsReallyUsed();
+ for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
+ if(ret2.find(*it2)==ret2.end())
+ {
+ ret.push_back(*it2);
+ ret2.insert(*it2);
+ }
+ }
+ return ret;
+}
+
+MEDFileField1TSWithoutDAS::MEDFileField1TSWithoutDAS(const char *fieldName, int iteration, int order, const std::vector<std::string>& infos):_name(fieldName),_infos(infos),_iteration(iteration),_order(order)
+{
+}
+
+MEDFileField1TS *MEDFileField1TS::New(const char *fileName, const char *fieldName, int iteration, int order) throw(INTERP_KERNEL::Exception)
+{
+ return new MEDFileField1TS(fileName,fieldName,iteration,order);
+}
+
+MEDFileField1TS::MEDFileField1TS(const char *fileName, const char *fieldName, int iteration, int order) throw(INTERP_KERNEL::Exception)
+try:MEDFileField1TSWithoutDAS(fieldName,iteration,order,std::vector<std::string>())
+{
+ MEDFileUtilities::CheckFileForRead(fileName);
+ med_idt fid=MEDouvrir((char *)fileName,MED_LECTURE);
+ int nbFields=MEDnChamp(fid,0);
+ med_type_champ typcha;
+ bool found=false;
+ std::vector<std::string> fns(nbFields);
+ for(int i=0;i<nbFields && !found;i++)
+ {
+ int ncomp=MEDnChamp(fid,i+1);
+ INTERP_KERNEL::AutoPtr<char> comp=new char[ncomp*MED_TAILLE_PNOM+1];
+ INTERP_KERNEL::AutoPtr<char> unit=new char[ncomp*MED_TAILLE_PNOM+1];
+ INTERP_KERNEL::AutoPtr<char> nomcha=MEDLoaderBase::buildEmptyString(MED_TAILLE_NOM);
+ MEDchampInfo(fid,i+1,nomcha,&typcha,comp,unit,ncomp);
+ std::string tmp(nomcha);
+ fns[i]=tmp;
+ found=(tmp==fieldName);
+ if(found)
+ {
+ _infos.resize(ncomp);
+ for(int j=0;j<ncomp;j++)
+ _infos[j]=MEDLoaderBase::buildUnionUnit((char *)comp+i*MED_TAILLE_PNOM,MED_TAILLE_PNOM,(char *)unit+i*MED_TAILLE_PNOM,MED_TAILLE_PNOM);
+ }
+ }
+ if(!found)
+ {
+ std::ostringstream oss; oss << "No such field '" << fieldName << "' in file '" << fileName << "' ! Available fields are : ";
+ std::copy(fns.begin(),fns.end(),std::ostream_iterator<std::string>(oss," "));
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ finishLoading(fid);
+ //
+ std::vector<std::string> profiles=getPflsReallyUsed();
+ int sz=profiles.size();
+ _pfls.resize(sz);
+ for(int i=0;i<sz;i++)
+ loadProfileInFile(fid,i,profiles[i].c_str(),37);//tony
+ MEDfermer(fid);
+}
+catch(INTERP_KERNEL::Exception& e)
+ {
+ throw e;
+ }
+
+MEDFileFieldMultiTSWithoutDAS *MEDFileFieldMultiTSWithoutDAS::New(med_idt fid, const char *fieldName, int id, const std::vector<std::string>& infos) throw(INTERP_KERNEL::Exception)
+{
+ return new MEDFileFieldMultiTSWithoutDAS(fid,fieldName,id,infos);
+}
+
+MEDFileFieldMultiTSWithoutDAS::MEDFileFieldMultiTSWithoutDAS(const char *fieldName):_name(fieldName)
+{
+}
+
+MEDFileFieldMultiTSWithoutDAS::MEDFileFieldMultiTSWithoutDAS(med_idt fid, const char *fieldName, int id, const std::vector<std::string>& infos) throw(INTERP_KERNEL::Exception)
+try:_name(fieldName),_infos(infos)
+{
+ finishLoading(fid);
+}
+catch(INTERP_KERNEL::Exception& e)
+ {
+ throw e;
+ }
+
+void MEDFileFieldMultiTSWithoutDAS::finishLoading(med_idt fid) throw(INTERP_KERNEL::Exception)
+{
+ for(int i=0;i<MED_NBR_GEOMETRIE_MAILLE+2;i++)
+ {
+ int nbPdt=MEDnPasdetemps(fid,(char *)_name.c_str(),MED_MAILLE,typmai[i]);
+ for(int j=0;j<nbPdt;j++)
+ appendTimeStepEntry(fid,MED_MAILLE,i,j);
+ }
+ int nbPdt=MEDnPasdetemps(fid,(char *)_name.c_str(),MED_NOEUD,MED_NONE);
+ for(int j=0;j<nbPdt;j++)
+ appendTimeStepEntry(fid,MED_NOEUD,0,j);
+ int nbOfTimeSteps=_time_steps.size();
+ for(int i=0;i<nbOfTimeSteps;i++)
+ _time_steps[i]->finishLoading(fid);
+}
+
+void MEDFileFieldMultiTSWithoutDAS::appendTimeStepEntry(med_idt fid, med_entite_maillage entity, int i, int j) throw(INTERP_KERNEL::Exception)
+{
+ std::vector< std::pair<int,int> > ts;
+ med_int ngauss=0;
+ med_int numdt=0,numo=0,nbrefmaa;
+ med_float dt=0.0;
+ med_booleen local;
+ INTERP_KERNEL::AutoPtr<char> maa_ass=MEDLoaderBase::buildEmptyString(MED_TAILLE_NOM);
+ INTERP_KERNEL::AutoPtr<char> dt_unit=MEDLoaderBase::buildEmptyString(MED_TAILLE_PNOM);
+ MEDpasdetempsInfo(fid,(char *)_name.c_str(),MED_MAILLE,typmai[i],j+1,&ngauss,&numdt,&numo,dt_unit,&dt,maa_ass,&local,&nbrefmaa);
+ std::pair<int,int> p(numdt,numo);
+ std::vector< std::pair<int,int> >::iterator where=std::find(ts.begin(),ts.end(),p);
+ if(where==ts.end())
+ {
+ ts.push_back(p);
+ _time_steps.push_back(MEDFileField1TSWithoutDAS::New(_name.c_str(),numdt,numo,_infos));
+ _time_steps.back()->pushBack(entity==MED_MAILLE?ON_CELLS:ON_NODES,entity==MED_MAILLE?typmai2[i]:INTERP_KERNEL::NORM_ERROR,dt,maa_ass);
+ }
+ else
+ {
+ int w=std::distance(ts.begin(),where);
+ _time_steps[w]->pushBack(entity==MED_MAILLE?ON_CELLS:ON_NODES,entity==MED_MAILLE?typmai2[i]:INTERP_KERNEL::NORM_ERROR,dt,maa_ass);
+ }
+}
+
+std::vector<std::string> MEDFileFieldMultiTSWithoutDAS::getPflsReallyUsed() const
+{
+ std::vector<std::string> ret;
+ std::set<std::string> ret2;
+ for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileField1TSWithoutDAS > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
+ {
+ std::vector<std::string> tmp=(*it)->getPflsReallyUsed();
+ for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
+ if(ret2.find(*it2)==ret2.end())
+ {
+ ret.push_back(*it2);
+ ret2.insert(*it2);
+ }
+ }
+ return ret;
+}
+
+std::vector<std::string> MEDFileFieldMultiTSWithoutDAS::getLocsReallyUsed() const
+{
+ std::vector<std::string> ret;
+ std::set<std::string> ret2;
+ for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileField1TSWithoutDAS > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
+ {
+ std::vector<std::string> tmp=(*it)->getLocsReallyUsed();
+ for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
+ if(ret2.find(*it2)==ret2.end())
+ {
+ ret.push_back(*it2);
+ ret2.insert(*it2);
+ }
+ }
+ return ret;
+}
+
+MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(const char *fileName, const char *fieldName) throw(INTERP_KERNEL::Exception)
+{
+ return new MEDFileFieldMultiTS(fileName,fieldName);
+}
+
+MEDFileFieldMultiTS::MEDFileFieldMultiTS(const char *fileName, const char *fieldName) throw(INTERP_KERNEL::Exception)
+try:MEDFileFieldMultiTSWithoutDAS(fieldName)
+{
+ MEDFileUtilities::CheckFileForRead(fileName);
+ med_idt fid=MEDouvrir((char *)fileName,MED_LECTURE);
+ int nbFields=MEDnChamp(fid,0);
+ med_type_champ typcha;
+ bool found=false;
+ std::vector<std::string> fns(nbFields);
+ for(int i=0;i<nbFields && !found;i++)
+ {
+ int ncomp=MEDnChamp(fid,i+1);
+ INTERP_KERNEL::AutoPtr<char> comp=new char[ncomp*MED_TAILLE_PNOM+1];
+ INTERP_KERNEL::AutoPtr<char> unit=new char[ncomp*MED_TAILLE_PNOM+1];
+ INTERP_KERNEL::AutoPtr<char> nomcha=MEDLoaderBase::buildEmptyString(MED_TAILLE_NOM);
+ MEDchampInfo(fid,i+1,nomcha,&typcha,comp,unit,ncomp);
+ std::string tmp(nomcha);
+ fns[i]=tmp;
+ found=(tmp==fieldName);
+ if(found)
+ {
+ _infos.resize(ncomp);
+ for(int j=0;j<ncomp;j++)
+ _infos[j]=MEDLoaderBase::buildUnionUnit((char *)comp+i*MED_TAILLE_PNOM,MED_TAILLE_PNOM,(char *)unit+i*MED_TAILLE_PNOM,MED_TAILLE_PNOM);
+ }
+ }
+ if(!found)
+ {
+ std::ostringstream oss; oss << "No such field '" << fieldName << "' in file '" << fileName << "' ! Available fields are : ";
+ std::copy(fns.begin(),fns.end(),std::ostream_iterator<std::string>(oss," "));
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ finishLoading(fid);
+ MEDfermer(fid);
+}
+catch(INTERP_KERNEL::Exception& e)
+ {
+ throw e;
+ }
+
+MEDFileFields *MEDFileFields::New(const char *fileName) throw(INTERP_KERNEL::Exception)
+{
+ return new MEDFileFields(fileName);
+}
+
+int MEDFileFields::getNumberOfFields() const
+{
+ return _fields.size();
+}
+
+MEDFileFields::MEDFileFields(const char *fileName) throw(INTERP_KERNEL::Exception)
+try
+ {
+ MEDFileUtilities::CheckFileForRead(fileName);
+ med_idt fid=MEDouvrir((char *)fileName,MED_LECTURE);
+ int nbFields=MEDnChamp(fid,0);
+ _fields.resize(nbFields);
+ med_type_champ typcha;
+ for(int i=0;i<nbFields;i++)
+ {
+ int ncomp=MEDnChamp(fid,i+1);
+ INTERP_KERNEL::AutoPtr<char> comp=new char[ncomp*MED_TAILLE_PNOM+1];
+ INTERP_KERNEL::AutoPtr<char> unit=new char[ncomp*MED_TAILLE_PNOM+1];
+ INTERP_KERNEL::AutoPtr<char> nomcha=MEDLoaderBase::buildEmptyString(MED_TAILLE_NOM);
+ MEDchampInfo(fid,i+1,nomcha,&typcha,comp,unit,ncomp);
+ std::vector<std::string> infos(ncomp);
+ for(int j=0;j<ncomp;j++)
+ infos[j]=MEDLoaderBase::buildUnionUnit((char *)comp+i*MED_TAILLE_PNOM,MED_TAILLE_PNOM,(char *)unit+i*MED_TAILLE_PNOM,MED_TAILLE_PNOM);
+ _fields[i]=MEDFileFieldMultiTSWithoutDAS::New(fid,nomcha,i,infos);
+ }
+ int nProfil=MEDnProfil(fid);
+ _pfls.resize(nProfil);
+ for(int i=0;i<nProfil;i++)
+ loadProfileInFile(fid,i);
+ MEDfermer(fid);
+ }
+catch(INTERP_KERNEL::Exception& e)
+ {
+ throw e;
+ }
--- /dev/null
+// Copyright (C) 2007-2010 CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#ifndef __MEDFILEFIELD_HXX__
+#define __MEDFILEFIELD_HXX__
+
+#include "MEDCouplingAutoRefCountObjectPtr.hxx"
+#include "MEDCouplingRefCountObject.hxx"
+#include "MEDCouplingMemArray.hxx"
+
+#include "NormalizedUnstructuredMesh.hxx"
+#include "InterpKernelException.hxx"
+
+#include <vector>
+#include <string>
+
+extern "C"
+{
+#include "med.h"
+}
+
+namespace ParaMEDMEM
+{
+ class MEDFileFieldLoc : public RefCountObject
+ {
+ public:
+ const std::string& getName() const { return _name; }
+ private:
+ int _dim;
+ int _nb_gauss_pt;
+ int _nb_node_per_cell;
+ std::string _name;
+ INTERP_KERNEL::NormalizedCellType _geo_type;
+ std::vector<double> _ref_coo;
+ std::vector<double> _gs_coo;
+ std::vector<double> _w;
+ };
+
+ class MEDFileFieldPerMeshPerType;
+ class MEDFileField1TSWithoutDAS;
+ class MEDFileFieldPerMesh;
+
+ class MEDFileFieldPerMeshPerTypePerDisc : public RefCountObject
+ {
+ public:
+ static MEDFileFieldPerMeshPerTypePerDisc *New(MEDFileFieldPerMeshPerType *fath, med_idt fid) throw(INTERP_KERNEL::Exception);
+ const MEDFileFieldPerMeshPerType *getFather() const;
+ int getIteration() const;
+ int getOrder() const;
+ std::string getName() const;
+ std::string getMeshName() const;
+ TypeOfField getType() const;
+ INTERP_KERNEL::NormalizedCellType getGeoType() const;
+ int getNumberOfComponents() const;
+ const std::vector<std::string>& getInfos() const;
+ std::string getProfile() const;
+ std::string getLocalization() const;
+ private:
+ MEDFileFieldPerMeshPerTypePerDisc(MEDFileFieldPerMeshPerType *fath, med_idt fid) throw(INTERP_KERNEL::Exception);
+ private:
+ MEDFileFieldPerMeshPerType *_father;
+ MEDCouplingAutoRefCountObjectPtr< DataArrayDouble > _arr;
+ std::string _profile;
+ std::string _localization;
+ std::string _mesh_name;
+ };
+
+ class MEDFileFieldPerMeshPerType : public RefCountObject
+ {
+ public:
+ static MEDFileFieldPerMeshPerType *New(MEDFileFieldPerMesh *fath, TypeOfField type, INTERP_KERNEL::NormalizedCellType geoType) throw(INTERP_KERNEL::Exception);
+ const MEDFileFieldPerMesh *getFather() const;
+ void finishLoading(med_idt fid) throw(INTERP_KERNEL::Exception);
+ int getIteration() const;
+ int getOrder() const;
+ std::string getName() const;
+ std::string getMeshName() const;
+ TypeOfField getType() const;
+ INTERP_KERNEL::NormalizedCellType getGeoType() const;
+ int getNumberOfComponents() const;
+ const std::vector<std::string>& getInfos() const;
+ std::vector<std::string> getPflsReallyUsed() const;
+ std::vector<std::string> getLocsReallyUsed() const;
+ private:
+ MEDFileFieldPerMeshPerType(MEDFileFieldPerMesh *fath, TypeOfField type, INTERP_KERNEL::NormalizedCellType geoType) throw(INTERP_KERNEL::Exception);
+ private:
+ MEDFileFieldPerMesh *_father;
+ std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> > _field_pm_pt_pd;
+ TypeOfField _type;
+ INTERP_KERNEL::NormalizedCellType _geo_type;
+ };
+
+ class MEDFileFieldPerMesh : public RefCountObject
+ {
+ public:
+ static MEDFileFieldPerMesh *New(MEDFileField1TSWithoutDAS *fath, const char *meshName, double time);
+ void pushBack(TypeOfField type, INTERP_KERNEL::NormalizedCellType geoType);
+ void finishLoading(med_idt fid) throw(INTERP_KERNEL::Exception);
+ double getTime() const;
+ int getIteration() const;
+ int getOrder() const;
+ std::string getName() const;
+ std::string getMeshName() const;
+ int getNumberOfComponents() const;
+ const std::vector<std::string>& getInfos() const;
+ std::vector<std::string> getPflsReallyUsed() const;
+ std::vector<std::string> getLocsReallyUsed() const;
+ private:
+ MEDFileFieldPerMesh(MEDFileField1TSWithoutDAS *fath, const char *meshName, double time);
+ private:
+ MEDFileField1TSWithoutDAS *_father;
+ std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > > _field_pm_pt;
+ std::string _mesh_name;
+ double _time;
+ private:
+ mutable std::vector<TypeOfField> _types;
+ mutable std::vector<INTERP_KERNEL::NormalizedCellType> _geo_types;
+ };
+
+ class MEDFieldFieldGlobs
+ {
+ public:
+ void loadProfileInFile(med_idt fid, int id, const char *pflName, int lgth) throw(INTERP_KERNEL::Exception);
+ void loadProfileInFile(med_idt fid, int id);
+ std::vector<std::string> getPfls() const;
+ std::vector<std::string> getLocs() const;
+ protected:
+ std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > _pfls;
+ std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> > _locs;
+ };
+
+ class MEDFileField1TSWithoutDAS : public RefCountObject
+ {
+ public:
+ static MEDFileField1TSWithoutDAS *New(const char *fieldName, int iteration, int order, const std::vector<std::string>& infos);
+ void pushBack(TypeOfField type, INTERP_KERNEL::NormalizedCellType geoType, double time, const char *meshName) const;
+ void finishLoading(med_idt fid) throw(INTERP_KERNEL::Exception);
+ int getIteration() const { return _iteration; }
+ int getOrder() const { return _order; }
+ std::string getName() const { return _name; }
+ int getNumberOfComponents() const { return _infos.size(); }
+ const std::vector<std::string>& getInfos() const { return _infos; }
+ std::vector<std::string> getPflsReallyUsed() const;
+ std::vector<std::string> getLocsReallyUsed() const;
+ protected:
+ MEDFileField1TSWithoutDAS(const char *fieldName, int iteration, int order, const std::vector<std::string>& infos);
+ protected:
+ std::string _name;
+ std::vector<std::string> _infos;
+ std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > > _field_per_mesh;
+ int _iteration;
+ int _order;
+ private:
+ mutable std::vector<TypeOfField> _types;
+ mutable std::vector<INTERP_KERNEL::NormalizedCellType> _geo_types;
+ mutable std::vector<double> _times;
+ mutable std::vector<std::string> _meshes;
+ };
+
+ /*!
+ * User class.
+ */
+ class MEDFileField1TS : public MEDFileField1TSWithoutDAS, public MEDFieldFieldGlobs
+ {
+ public:
+ static MEDFileField1TS *New(const char *fileName, const char *fieldName, int iteration, int order) throw(INTERP_KERNEL::Exception);
+ private:
+ MEDFileField1TS(const char *fileName, const char *fieldName, int iteration, int order) throw(INTERP_KERNEL::Exception);
+ };
+
+ class MEDFileFieldMultiTSWithoutDAS : public RefCountObject
+ {
+ public:
+ static MEDFileFieldMultiTSWithoutDAS *New(med_idt fid, const char *fieldName, int id, const std::vector<std::string>& infos) throw(INTERP_KERNEL::Exception);
+ protected:
+ MEDFileFieldMultiTSWithoutDAS(const char *fieldName);
+ MEDFileFieldMultiTSWithoutDAS(med_idt fid, const char *fieldName, int id, const std::vector<std::string>& infos) throw(INTERP_KERNEL::Exception);
+ void finishLoading(med_idt fid) throw(INTERP_KERNEL::Exception);
+ void appendTimeStepEntry(med_idt fid, med_entite_maillage entity, int i, int j) throw(INTERP_KERNEL::Exception);
+ std::vector<std::string> getPflsReallyUsed() const;
+ std::vector<std::string> getLocsReallyUsed() const;
+ protected:
+ std::string _name;
+ std::vector<std::string> _infos;
+ std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSWithoutDAS> > _time_steps;
+ };
+
+ /*!
+ * User class.
+ */
+ class MEDFileFieldMultiTS : public MEDFileFieldMultiTSWithoutDAS, public MEDFieldFieldGlobs
+ {
+ public:
+ static MEDFileFieldMultiTS *New(const char *fileName, const char *fieldName) throw(INTERP_KERNEL::Exception);
+ private:
+ MEDFileFieldMultiTS(const char *fileName, const char *fieldName) throw(INTERP_KERNEL::Exception);
+ };
+
+ /*!
+ * Use class.
+ */
+ class MEDFileFields : public RefCountObject, public MEDFieldFieldGlobs
+ {
+ public:
+ static MEDFileFields *New(const char *fileName) throw(INTERP_KERNEL::Exception);
+ int getNumberOfFields() const;
+ std::vector<std::string> getPfls() const;
+ std::vector<std::string> getLocs() const;
+ private:
+ MEDFileFields(const char *fileName) throw(INTERP_KERNEL::Exception);
+ private:
+ std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTSWithoutDAS> > _fields;
+ };
+}
+
+#endif
--- /dev/null
+// Copyright (C) 2007-2010 CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#include "MEDFileMesh.hxx"
+#include "MEDFileUtilities.hxx"
+#include "MEDLoader.hxx"
+#include "MEDLoaderBase.hxx"
+
+#include "MEDCouplingUMesh.hxx"
+
+#include "InterpKernelAutoPtr.hxx"
+
+#include <limits>
+
+using namespace ParaMEDMEM;
+
+MEDFileMesh *MEDFileMesh::New(const char *fileName, const char *mName) throw(INTERP_KERNEL::Exception)
+{
+ throw INTERP_KERNEL::Exception("Not implemented yet !");
+}
+
+MEDFileUMesh *MEDFileUMesh::New(const char *fileName, const char *mName) throw(INTERP_KERNEL::Exception)
+{
+ return new MEDFileUMesh(fileName,mName);
+}
+
+MEDFileUMesh *MEDFileUMesh::New(const char *fileName) throw(INTERP_KERNEL::Exception)
+{
+ std::vector<std::string> ms=MEDLoader::GetMeshNames(fileName);
+ if(ms.empty())
+ {
+ std::ostringstream oss; oss << "MEDFileUMesh::New : no meshes in file \"" << fileName << "\" !";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ return new MEDFileUMesh(fileName,ms.front().c_str());
+}
+
+MEDFileUMesh *MEDFileUMesh::New()
+{
+ return new MEDFileUMesh;
+}
+
+MEDFileUMesh::MEDFileUMesh():_too_long_str(0),_zipconn_pol(2)
+{
+}
+
+MEDFileUMesh::MEDFileUMesh(const char *fileName, const char *mName) throw(INTERP_KERNEL::Exception)
+ try:_too_long_str(0)
+ {
+ MEDFileUtilities::CheckFileForRead(fileName);
+ med_idt fid=MEDouvrir((char *)fileName,MED_LECTURE);
+ MEDFileUMeshL2 loaderl2;
+ loaderl2.loadAll(fid,MEDFileUMeshL2::getMeshIdFromName(fid,mName),mName);
+ int lev=loaderl2.getNumberOfLevels();
+ _ms.resize(lev);
+ for(int i=0;i<lev;i++)
+ {
+ if(!loaderl2.emptyLev(i))
+ _ms[i]=new MEDFileUMeshSplitL1(loaderl2,mName,i);
+ else
+ _ms[i]=0;
+ }
+ MEDFileUMeshL2::readFamiliesAndGrps(fid,mName,_families,_groups);
+ MEDfermer(fid);
+ //
+ setName(loaderl2.getName());
+ setDescription(loaderl2.getDescription());
+ _coords=loaderl2.getCoords();
+ _fam_coords=loaderl2.getCoordsFamily();
+ _num_coords=loaderl2.getCoordsNum();
+ computeRevNum();
+ }
+catch(INTERP_KERNEL::Exception& e)
+ {
+ throw e;
+ }
+
+MEDFileUMesh::~MEDFileUMesh()
+{
+}
+
+void MEDFileUMesh::write(const char *fileName, int mode) const throw(INTERP_KERNEL::Exception)
+{
+ if(_name.empty())
+ throw INTERP_KERNEL::Exception("MEDFileUMesh : name is empty. MED file ask for a NON EMPTY name !");
+ if(!existsFamily(0))
+ (const_cast<MEDFileUMesh *>(this))->addFamily(0,"FAMILLE_ZERO");
+ med_mode_acces medmod=MEDFileUtilities::TraduceWriteMode(mode);
+ med_idt fid=MEDouvrir((char *)fileName,medmod);
+ std::ostringstream oss; oss << "MEDFileUMesh : error on attempt to write in file : \"" << fileName << "\"";
+ MEDFileUtilities::CheckMEDCode(fid,fid,oss.str().c_str());
+ const DataArrayDouble *coo=_coords;
+ INTERP_KERNEL::AutoPtr<char> maa=MEDLoaderBase::buildEmptyString(MED_TAILLE_NOM);
+ INTERP_KERNEL::AutoPtr<char> desc=MEDLoaderBase::buildEmptyString(MED_TAILLE_DESC);
+ MEDLoaderBase::safeStrCpy(_name.c_str(),MED_TAILLE_NOM,maa,_too_long_str);
+ MEDLoaderBase::safeStrCpy(_desc_name.c_str(),MED_TAILLE_DESC,desc,_too_long_str);
+ int spaceDim=coo?coo->getNumberOfComponents():0;
+ int mdim=getMeshDimension();
+ MEDmaaCr(fid,maa,spaceDim,MED_NON_STRUCTURE,desc);//spaceDim is false but to make reader happy for 3DSurf and 2DCurve meshes !
+ MEDdimEspaceCr(fid,maa,spaceDim);
+ MEDFileUMeshL2::writeCoords(fid,maa,_coords,_fam_coords,_num_coords);
+ for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileUMeshSplitL1> >::const_iterator it=_ms.begin();it!=_ms.end();it++)
+ if((const MEDFileUMeshSplitL1 *)(*it)!=0)
+ (*it)->write(fid,maa,mdim);
+ MEDFileUMeshL2::writeFamiliesAndGrps(fid,maa,_families,_groups,_too_long_str);
+ MEDfermer(fid);
+}
+
+std::vector<int> MEDFileUMesh::getNonEmptyLevels() const
+{
+ std::vector<int> ret;
+ int lev=0;
+ for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileUMeshSplitL1> >::const_iterator it=_ms.begin();it!=_ms.end();it++,lev--)
+ if((const MEDFileUMeshSplitL1 *)(*it)!=0)
+ if(!(*it)->empty())
+ ret.push_back(lev);
+ return ret;
+}
+
+std::vector<int> MEDFileUMesh::getNonEmptyLevelsExt() const
+{
+ std::vector<int> ret0=getNonEmptyLevels();
+ if((const DataArrayDouble *) _coords)
+ {
+ std::vector<int> ret(ret0.size()+1);
+ ret[0]=1;
+ std::copy(ret0.begin(),ret0.end(),ret.begin()+1);
+ return ret;
+ }
+ return ret0;
+}
+
+int MEDFileUMesh::getFamilyId(const char *name) const throw(INTERP_KERNEL::Exception)
+{
+ std::string oname(name);
+ std::map<std::string, int>::const_iterator it=_families.find(oname);
+ std::vector<std::string> fams=getFamiliesNames();
+ if(it==_families.end())
+ {
+ std::ostringstream oss; oss << "No such familyname \"" << name << "\" !\nAvailable families are :";
+ std::copy(fams.begin(),fams.end(),std::ostream_iterator<std::string>(oss," "));
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ return (*it).second;
+}
+
+int MEDFileUMesh::getMaxFamilyId() const throw(INTERP_KERNEL::Exception)
+{
+ if(_families.empty())
+ throw INTERP_KERNEL::Exception("MEDFileUMesh::getMaxFamilyId : no families set !");
+ int ret=-std::numeric_limits<int>::max();
+ for(std::map<std::string,int>::const_iterator it=_families.begin();it!=_families.end();it++)
+ {
+ ret=std::max((*it).second,ret);
+ }
+ return ret;
+}
+
+std::vector<int> MEDFileUMesh::getFamiliesIds(const std::vector<std::string>& famNames) const throw(INTERP_KERNEL::Exception)
+{
+ std::vector<int> famIds;
+ for(std::vector<std::string>::const_iterator it=famNames.begin();it!=famNames.end();it++)
+ {
+ std::map<std::string,int>::const_iterator it2=_families.find(*it);
+ if(it2==_families.end())
+ {
+ std::ostringstream oss; oss << "No such family in mesh \"" << _name << "\" : " << *it;
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ famIds.push_back((*it2).second);
+ }
+ return famIds;
+}
+
+std::string MEDFileUMesh::getFamilyNameGivenId(int id) const throw(INTERP_KERNEL::Exception)
+{
+ for(std::map<std::string,int>::const_iterator it=_families.begin();it!=_families.end();it++)
+ if((*it).second==id)
+ return (*it).first;
+ std::ostringstream oss; oss << "MEDFileUMesh::getFamilyNameGivenId : no such family id : " << id;
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+}
+
+int MEDFileUMesh::getMeshDimension() const
+{
+ int lev=0;
+ for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileUMeshSplitL1> >::const_iterator it=_ms.begin();it!=_ms.end();it++,lev++)
+ if((const MEDFileUMeshSplitL1 *)(*it)!=0)
+ return (*it)->getMeshDimension()+lev;
+ throw INTERP_KERNEL::Exception("MEDFileUMesh::getMeshDimension : impossible to find a mesh dimension !");
+}
+
+int MEDFileUMesh::getSizeAtLevel(int meshDimRelToMaxExt) const throw(INTERP_KERNEL::Exception)
+{
+ if(meshDimRelToMaxExt==1)
+ {
+ if(!((const DataArrayDouble *)_coords))
+ throw INTERP_KERNEL::Exception("MEDFileUMesh::getSizeAtLevel : no coordinates specified !");
+ return _coords->getNumberOfTuples();
+ }
+ return getMeshAtLevSafe(meshDimRelToMaxExt)->getSize();
+}
+
+const DataArrayInt *MEDFileUMesh::getFamilyFieldAtLevel(int meshDimRelToMaxExt) const throw(INTERP_KERNEL::Exception)
+{
+ if(meshDimRelToMaxExt==1)
+ {
+ if(!((const DataArrayInt *)_fam_coords))
+ throw INTERP_KERNEL::Exception("MEDFileUMesh::getFamilyFieldAtLevel : no coordinates specified !");
+ return _fam_coords;
+ }
+ const MEDFileUMeshSplitL1 *l1=getMeshAtLevSafe(meshDimRelToMaxExt);
+ return l1->getFamilyField();
+}
+
+const DataArrayInt *MEDFileUMesh::getNumberFieldAtLevel(int meshDimRelToMaxExt) const throw(INTERP_KERNEL::Exception)
+{
+ if(meshDimRelToMaxExt==1)
+ {
+ if(!((const DataArrayInt *)_num_coords))
+ throw INTERP_KERNEL::Exception("MEDFileUMesh::getNumberFieldAtLevel : no coordinates renum specified !");
+ return _num_coords;
+ }
+ const MEDFileUMeshSplitL1 *l1=getMeshAtLevSafe(meshDimRelToMaxExt);
+ return l1->getNumberField();
+}
+
+const DataArrayInt *MEDFileUMesh::getRevNumberFieldAtLevel(int meshDimRelToMaxExt) const throw(INTERP_KERNEL::Exception)
+{
+ if(meshDimRelToMaxExt==1)
+ {
+ if(!((const DataArrayInt *)_num_coords))
+ throw INTERP_KERNEL::Exception("MEDFileUMesh::getRevNumberFieldAtLevel : no coordinates renum specified !");
+ return _rev_num_coords;
+ }
+ const MEDFileUMeshSplitL1 *l1=getMeshAtLevSafe(meshDimRelToMaxExt);
+ return l1->getRevNumberField();
+}
+
+std::vector<std::string> MEDFileUMesh::getFamiliesOnGroup(const char *name) const throw(INTERP_KERNEL::Exception)
+{
+ std::string oname(name);
+ std::map<std::string, std::vector<std::string> >::const_iterator it=_groups.find(oname);
+ std::vector<std::string> grps=getGroupsNames();
+ if(it==_groups.end())
+ {
+ std::ostringstream oss; oss << "No such groupname \"" << name << "\" !\nAvailable groups are :";
+ std::copy(grps.begin(),grps.end(),std::ostream_iterator<std::string>(oss," "));
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ return (*it).second;
+}
+
+std::vector<std::string> MEDFileUMesh::getGroupsOnFamily(const char *name) const throw(INTERP_KERNEL::Exception)
+{
+ std::vector<std::string> ret;
+ for(std::map<std::string, std::vector<std::string> >::const_iterator it1=_groups.begin();it1!=_groups.end();it1++)
+ {
+ for(std::vector<std::string>::const_iterator it2=(*it1).second.begin();it2!=(*it1).second.end();it2++)
+ if((*it2)==name)
+ {
+ ret.push_back((*it1).first);
+ break;
+ }
+ }
+ return ret;
+}
+
+std::vector<std::string> MEDFileUMesh::getGroupsNames() const
+{
+ std::vector<std::string> ret(_groups.size());
+ int i=0;
+ for(std::map<std::string, std::vector<std::string> >::const_iterator it=_groups.begin();it!=_groups.end();it++,i++)
+ ret[i]=(*it).first;
+ return ret;
+}
+
+std::vector<std::string> MEDFileUMesh::getFamiliesNames() const
+{
+ std::vector<std::string> ret(_families.size());
+ int i=0;
+ for(std::map<std::string, int >::const_iterator it=_families.begin();it!=_families.end();it++,i++)
+ ret[i]=(*it).first;
+ return ret;
+}
+
+void MEDFileUMesh::removeGroup(const char *name) throw(INTERP_KERNEL::Exception)
+{
+ std::string oname(name);
+ std::map<std::string, std::vector<std::string> >::iterator it=_groups.find(oname);
+ std::vector<std::string> grps=getGroupsNames();
+ if(it==_groups.end())
+ {
+ std::ostringstream oss; oss << "No such groupname \"" << name << "\" !\nAvailable groups are :";
+ std::copy(grps.begin(),grps.end(),std::ostream_iterator<std::string>(oss," "));
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ _groups.erase(it);
+}
+
+void MEDFileUMesh::removeFamily(const char *name) throw(INTERP_KERNEL::Exception)
+{
+ std::string oname(name);
+ std::map<std::string, int >::iterator it=_families.find(oname);
+ std::vector<std::string> fams=getFamiliesNames();
+ if(it==_families.end())
+ {
+ std::ostringstream oss; oss << "No such familyname \"" << name << "\" !\nAvailable families are :";
+ std::copy(fams.begin(),fams.end(),std::ostream_iterator<std::string>(oss," "));
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ _families.erase(it);
+}
+
+void MEDFileUMesh::changeGroupName(const char *oldName, const char *newName) throw(INTERP_KERNEL::Exception)
+{
+ std::string oname(oldName);
+ std::map<std::string, std::vector<std::string> >::iterator it=_groups.find(oname);
+ std::vector<std::string> grps=getGroupsNames();
+ if(it==_groups.end())
+ {
+ std::ostringstream oss; oss << "No such groupname \"" << oldName << "\" !\nAvailable groups are :";
+ std::copy(grps.begin(),grps.end(),std::ostream_iterator<std::string>(oss," "));
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ std::string nname(newName);
+ it=_groups.find(nname);
+ if(it!=_groups.end())
+ {
+ std::ostringstream oss; oss << "Such groupname \"" << newName << " already exists ! Kill it before !";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ std::vector<std::string> cpy=(*it).second;
+ _groups.erase(it);
+ _groups[newName]=cpy;
+}
+
+void MEDFileUMesh::changeFamilyName(const char *oldName, const char *newName) throw(INTERP_KERNEL::Exception)
+{
+ std::string oname(oldName);
+ std::map<std::string, int >::iterator it=_families.find(oname);
+ std::vector<std::string> fams=getFamiliesNames();
+ if(it==_families.end())
+ {
+ std::ostringstream oss; oss << "No such familyname \"" << oldName << "\" !\nAvailable families are :";
+ std::copy(fams.begin(),fams.end(),std::ostream_iterator<std::string>(oss," "));
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ std::string nname(newName);
+ it=_families.find(nname);
+ if(it!=_families.end())
+ {
+ std::ostringstream oss; oss << "Such familyname \"" << newName << " already exists ! Kill it before !";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ int cpy=(*it).second;
+ _families.erase(it);
+ _families[newName]=cpy;
+}
+
+DataArrayDouble *MEDFileUMesh::getCoords() const
+{
+ MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> tmp(_coords);
+ if((DataArrayDouble *)tmp)
+ {
+ tmp->incrRef();
+ return tmp;
+ }
+ return 0;
+}
+
+MEDCouplingUMesh *MEDFileUMesh::getGroup(int meshDimRelToMaxExt, const char *grp, bool renum) const throw(INTERP_KERNEL::Exception)
+{
+ std::vector<std::string> tmp(1);
+ tmp[0]=grp;
+ MEDCouplingUMesh *ret=getGroups(meshDimRelToMaxExt,tmp,renum);
+ ret->setName(grp);
+ return ret;
+}
+
+DataArrayInt *MEDFileUMesh::getGroupArr(int meshDimRelToMaxExt, const char *grp, bool renum) const throw(INTERP_KERNEL::Exception)
+{
+ std::vector<std::string> tmp(1);
+ tmp[0]=grp;
+ DataArrayInt *ret=getGroupsArr(meshDimRelToMaxExt,tmp,renum);
+ ret->setName(grp);
+ return ret;
+}
+
+MEDCouplingUMesh *MEDFileUMesh::getGroups(int meshDimRelToMaxExt, const std::vector<std::string>& grps, bool renum) const throw(INTERP_KERNEL::Exception)
+{
+ std::set<std::string> fams;
+ for(std::vector<std::string>::const_iterator it=grps.begin();it!=grps.end();it++)
+ {
+ std::map<std::string, std::vector<std::string> >::const_iterator it2=_groups.find(*it);
+ if(it2==_groups.end())
+ {
+ std::ostringstream oss; oss << "No such group in mesh \"" << _name << "\" : " << *it;
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ fams.insert((*it2).second.begin(),(*it2).second.end());
+ }
+ std::vector<std::string> fams2(fams.begin(),fams.end());
+ return getFamilies(meshDimRelToMaxExt,fams2,renum);
+}
+
+DataArrayInt *MEDFileUMesh::getGroupsArr(int meshDimRelToMaxExt, const std::vector<std::string>& grps, bool renum) const throw(INTERP_KERNEL::Exception)
+{
+ std::set<std::string> fams;
+ for(std::vector<std::string>::const_iterator it=grps.begin();it!=grps.end();it++)
+ {
+ std::map<std::string, std::vector<std::string> >::const_iterator it2=_groups.find(*it);
+ if(it2==_groups.end())
+ {
+ std::ostringstream oss; oss << "No such group in mesh \"" << _name << "\" : " << *it;
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ fams.insert((*it2).second.begin(),(*it2).second.end());
+ }
+ std::vector<std::string> fams2(fams.begin(),fams.end());
+ return getFamiliesArr(meshDimRelToMaxExt,fams2,renum);
+}
+
+MEDCouplingUMesh *MEDFileUMesh::getFamily(int meshDimRelToMaxExt, const char *fam, bool renum) const throw(INTERP_KERNEL::Exception)
+{
+ std::vector<std::string> tmp(1);
+ tmp[0]=fam;
+ MEDCouplingUMesh *ret=getFamilies(meshDimRelToMaxExt,tmp,renum);
+ ret->setName(fam);
+ return ret;
+}
+
+DataArrayInt *MEDFileUMesh::getFamilyArr(int meshDimRelToMaxExt, const char *fam, bool renum) const throw(INTERP_KERNEL::Exception)
+{
+ std::vector<std::string> tmp(1);
+ tmp[0]=fam;
+ DataArrayInt *ret=getFamiliesArr(meshDimRelToMaxExt,tmp,renum);
+ ret->setName(fam);
+ return ret;
+}
+
+MEDCouplingUMesh *MEDFileUMesh::getFamilies(int meshDimRelToMaxExt, const std::vector<std::string>& fams, bool renum) const throw(INTERP_KERNEL::Exception)
+{
+ if(meshDimRelToMaxExt==1)
+ {
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr=getFamiliesArr(1,fams,renum);
+ MEDCouplingAutoRefCountObjectPtr<MEDCouplingUMesh> ret=MEDCouplingUMesh::New();
+ MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> c=_coords->selectByTupleId(arr->getConstPointer(),arr->getConstPointer()+arr->getNbOfElems());
+ ret->setCoords(c);
+ ret->incrRef();
+ return ret;
+ }
+ std::vector<int> famIds=getFamiliesIds(fams);
+ const MEDFileUMeshSplitL1 *l1=getMeshAtLevSafe(meshDimRelToMaxExt);
+ return l1->getFamilyPart(famIds,renum);
+}
+
+DataArrayInt *MEDFileUMesh::getFamiliesArr(int meshDimRelToMaxExt, const std::vector<std::string>& fams, bool renum) const throw(INTERP_KERNEL::Exception)
+{
+ std::vector<int> famIds=getFamiliesIds(fams);
+ if(meshDimRelToMaxExt==1)
+ {
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da=_fam_coords->getIdsEqualList(famIds);
+ return MEDFileUMeshSplitL1::Renumber(_num_coords,da);
+ }
+ const MEDFileUMeshSplitL1 *l1=getMeshAtLevSafe(meshDimRelToMaxExt);
+ return l1->getFamilyPartArr(famIds,renum);
+}
+
+DataArrayInt *MEDFileUMesh::getNodeGroupArr(const char *grp, bool renum) const throw(INTERP_KERNEL::Exception)
+{
+ std::vector<std::string> tmp(1);
+ tmp[0]=grp;
+ DataArrayInt *ret=getNodeGroupsArr(tmp,renum);
+ ret->setName(grp);
+ return ret;
+}
+
+DataArrayInt *MEDFileUMesh::getNodeGroupsArr(const std::vector<std::string>& grps, bool renum) const throw(INTERP_KERNEL::Exception)
+{
+ return getGroupsArr(1,grps,renum);
+}
+
+DataArrayInt *MEDFileUMesh::getNodeFamilyArr(const char *fam, bool renum) const throw(INTERP_KERNEL::Exception)
+{
+ std::vector<std::string> tmp(1);
+ tmp[0]=fam;
+ DataArrayInt *ret=getNodeFamiliesArr(tmp,renum);
+ ret->setName(fam);
+ return ret;
+}
+
+DataArrayInt *MEDFileUMesh::getNodeFamiliesArr(const std::vector<std::string>& fams, bool renum) const throw(INTERP_KERNEL::Exception)
+{
+ return getFamiliesArr(1,fams,renum);
+}
+
+MEDCouplingUMesh *MEDFileUMesh::getMeshAtLevel(int meshDimRelToMaxExt, bool renum) const throw(INTERP_KERNEL::Exception)
+{
+ if(meshDimRelToMaxExt==1)
+ {
+ if(!renum)
+ {
+ MEDCouplingUMesh *umesh=MEDCouplingUMesh::New();
+ MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> cc=_coords->deepCpy();
+ umesh->setCoords(cc);
+ return umesh;
+ }
+ }
+ const MEDFileUMeshSplitL1 *l1=getMeshAtLevSafe(meshDimRelToMaxExt);
+ return l1->getWholeMesh(renum);
+}
+
+MEDCouplingUMesh *MEDFileUMesh::getLevel0Mesh(bool renum) const throw(INTERP_KERNEL::Exception)
+{
+ return getMeshAtLevel(0,renum);
+}
+
+MEDCouplingUMesh *MEDFileUMesh::getLevelM1Mesh(bool renum) const throw(INTERP_KERNEL::Exception)
+{
+ return getMeshAtLevel(-1,renum);
+}
+
+MEDCouplingUMesh *MEDFileUMesh::getLevelM2Mesh(bool renum) const throw(INTERP_KERNEL::Exception)
+{
+ return getMeshAtLevel(-2,renum);
+}
+
+MEDCouplingUMesh *MEDFileUMesh::getLevelM3Mesh(bool renum) const throw(INTERP_KERNEL::Exception)
+{
+ return getMeshAtLevel(-3,renum);
+}
+
+bool MEDFileUMesh::existsFamily(int famId) const
+{
+ for(std::map<std::string,int>::const_iterator it2=_families.begin();it2!=_families.end();it2++)
+ if((*it2).second==famId)
+ return true;
+ return false;
+}
+
+bool MEDFileUMesh::existsFamily(const char *familyName) const
+{
+ std::string fname(familyName);
+ return _families.find(fname)!=_families.end();
+}
+
+const MEDFileUMeshSplitL1 *MEDFileUMesh::getMeshAtLevSafe(int meshDimRelToMaxExt) const throw(INTERP_KERNEL::Exception)
+{
+ if(meshDimRelToMaxExt==1)
+ throw INTERP_KERNEL::Exception("Dimension request is invalid : asking for node level (1) !");
+ if(meshDimRelToMaxExt>1)
+ throw INTERP_KERNEL::Exception("Dimension request is invalid (>1) !");
+ int tracucedRk=-meshDimRelToMaxExt;
+ if(tracucedRk>=(int)_ms.size())
+ throw INTERP_KERNEL::Exception("Invalid mesh dim relative to max given ! To low !");
+ if((const MEDFileUMeshSplitL1 *)_ms[tracucedRk]==0)
+ throw INTERP_KERNEL::Exception("On specified lev (or entity) no cells exists !");
+ return _ms[tracucedRk];
+}
+
+MEDFileUMeshSplitL1 *MEDFileUMesh::getMeshAtLevSafe(int meshDimRelToMaxExt) throw(INTERP_KERNEL::Exception)
+{
+ if(meshDimRelToMaxExt==1)
+ throw INTERP_KERNEL::Exception("Dimension request is invalid : asking for node level (1) !");
+ if(meshDimRelToMaxExt>1)
+ throw INTERP_KERNEL::Exception("Dimension request is invalid (>1) !");
+ int tracucedRk=-meshDimRelToMaxExt;
+ if(tracucedRk>=(int)_ms.size())
+ throw INTERP_KERNEL::Exception("Invalid mesh dim relative to max given ! To low !");
+ if((const MEDFileUMeshSplitL1 *)_ms[tracucedRk]==0)
+ throw INTERP_KERNEL::Exception("On specified lev (or entity) no cells exists !");
+ return _ms[tracucedRk];
+}
+
+void MEDFileUMesh::checkMeshDimCoherency(int meshDim, int meshDimRelToMax) const throw(INTERP_KERNEL::Exception)
+{
+ if(-meshDimRelToMax>=(int)_ms.size())
+ throw INTERP_KERNEL::Exception("MEDFileUMesh::checkMeshDimCoherency : The meshdim of mesh is not managed by 'this' !");
+ int i=0;
+ for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileUMeshSplitL1> >::const_iterator it=_ms.begin();it!=_ms.end();it++,i++)
+ {
+ if(((const MEDFileUMeshSplitL1*) (*it))!=0)
+ {
+ int ref=(*it)->getMeshDimension();
+ if(ref+i!=meshDim-meshDimRelToMax)
+ throw INTERP_KERNEL::Exception("MEDFileUMesh::checkMeshDimCoherency : no coherency between levels !");
+ }
+ }
+}
+
+void MEDFileUMesh::setCoords(DataArrayDouble *coords) throw(INTERP_KERNEL::Exception)
+{
+ coords->checkAllocated();
+ int nbOfTuples=coords->getNumberOfTuples();
+ _coords=coords;
+ coords->incrRef();
+ _fam_coords=DataArrayInt::New();
+ _fam_coords->alloc(nbOfTuples,1);
+ _fam_coords->fillWithZero();
+}
+
+void MEDFileUMesh::setGroupsAtLevel(int meshDimRelToMaxExt, const std::vector<const DataArrayInt *>& grps, bool renum) throw(INTERP_KERNEL::Exception)
+{
+ if(grps.empty())
+ return ;
+ std::set<std::string> grpsName;
+ std::vector<std::string> grpsName2(grps.size());
+ int i=0;
+
+ for(std::vector<const DataArrayInt *>::const_iterator it=grps.begin();it!=grps.end();it++,i++)
+ {
+ grpsName.insert((*it)->getName());
+ grpsName2[i]=(*it)->getName();
+ }
+ if(grpsName.size()!=grps.size())
+ throw INTERP_KERNEL::Exception("MEDFileUMesh::setGroupsAtLevel : groups name must be different each other !");
+ if(grpsName.find(std::string(""))!=grpsName.end())
+ throw INTERP_KERNEL::Exception("MEDFileUMesh::setGroupsAtLevel : groups name must be different empty string !");
+ int sz=getSizeAtLevel(meshDimRelToMaxExt);
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> fam;
+ std::vector< std::vector<int> > fidsOfGroups;
+ if(!renum)
+ {
+ fam=DataArrayInt::MakePartition(grps,sz,fidsOfGroups);
+ }
+ else
+ {
+ std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > grps2(grps.size());
+ for(unsigned int i=0;i<grps.size();i++)
+ {
+ grps2[i]=MEDFileUMeshSplitL1::Renumber(getRevNumberFieldAtLevel(meshDimRelToMaxExt),grps[i]);
+ grps2[i]->setName(grps[i]->getName().c_str());
+ }
+ std::vector<const DataArrayInt *> grps3(grps2.begin(),grps2.end());
+ fam=DataArrayInt::MakePartition(grps3,sz,fidsOfGroups);
+ }
+ int offset=1;
+ if(!_families.empty())
+ offset=getMaxFamilyId()+1;
+ TranslateFamilyIds(offset,fam,fidsOfGroups);
+ std::set<int> ids=fam->getDifferentValues();
+ appendFamilyEntries(ids,fidsOfGroups,grpsName2);
+ setFamilyArr(meshDimRelToMaxExt,fam);
+}
+
+void MEDFileUMesh::eraseGroupsAtLevel(int meshDimRelToMaxExt) throw(INTERP_KERNEL::Exception)
+{
+ if(meshDimRelToMaxExt==1)
+ {
+ if((DataArrayInt *)_fam_coords)
+ _fam_coords->fillWithZero();
+ return ;
+ }
+ MEDFileUMeshSplitL1 *l1=getMeshAtLevSafe(meshDimRelToMaxExt);
+ l1->eraseFamilyField();
+ optimizeFamilies();
+}
+
+void MEDFileUMesh::optimizeFamilies() throw(INTERP_KERNEL::Exception)
+{
+ std::vector<int> levs=getNonEmptyLevelsExt();
+ std::set<int> allFamsIds;
+ for(std::vector<int>::const_iterator it=levs.begin();it!=levs.end();it++)
+ {
+ const DataArrayInt *ffield=getFamilyFieldAtLevel(*it);
+ std::set<int> ids=ffield->getDifferentValues();
+ std::set<int> res;
+ std::set_union(ids.begin(),ids.end(),allFamsIds.begin(),allFamsIds.end(),std::inserter(res,res.begin()));
+ allFamsIds=res;
+ }
+ std::set<std::string> famNamesToKill;
+ for(std::map<std::string,int>::const_iterator it=_families.begin();it!=_families.end();it++)
+ {
+ if(allFamsIds.find((*it).second)!=allFamsIds.end())
+ famNamesToKill.insert((*it).first);
+ }
+ for(std::set<std::string>::const_iterator it=famNamesToKill.begin();it!=famNamesToKill.end();it++)
+ _families.erase(*it);
+ std::vector<std::string> grpNamesToKill;
+ for(std::map<std::string, std::vector<std::string> >::iterator it=_groups.begin();it!=_groups.end();it++)
+ {
+ std::vector<std::string> tmp;
+ for(std::vector<std::string>::const_iterator it2=(*it).second.begin();it2!=(*it).second.end();it2++)
+ {
+ if(famNamesToKill.find(*it2)==famNamesToKill.end())
+ tmp.push_back(*it2);
+ }
+ if(!tmp.empty())
+ (*it).second=tmp;
+ else
+ tmp.push_back((*it).first);
+ }
+ for(std::vector<std::string>::const_iterator it=grpNamesToKill.begin();it!=grpNamesToKill.end();it++)
+ _groups.erase(*it);
+}
+
+void MEDFileUMesh::setFamilyField(DataArrayInt *arr, const std::vector< std::vector< int > > &userfids, const std::vector<std::string>& grpNames, bool renum) throw(INTERP_KERNEL::Exception)
+{
+
+}
+
+void MEDFileUMesh::addNodeGroup(const std::string& name, const std::vector<int>& ids) throw(INTERP_KERNEL::Exception)
+{
+ const DataArrayDouble *coords=_coords;
+ if(!coords)
+ throw INTERP_KERNEL::Exception("addNodeGroup : no coords set !");
+ DataArrayInt *sub=_fam_coords->selectByTupleIdSafe(&ids[0],&ids[0]+ids.size());
+ std::set<int> ssub(sub->getConstPointer(),sub->getConstPointer()+sub->getNumberOfTuples());
+
+}
+
+void MEDFileUMesh::copyFamGrpMapsFrom(const MEDFileUMesh& other)
+{
+ _groups=other._groups;
+ _families=other._families;
+}
+
+void MEDFileUMesh::setFamilyInfo(const std::map<std::string,int>& info)
+{
+ _families=info;
+}
+
+void MEDFileUMesh::setGroupInfo(const std::map<std::string, std::vector<std::string> >&info)
+{
+ _groups=info;
+}
+
+void MEDFileUMesh::setFamilyNameAttachedOnId(int id, const std::string& newFamName) throw(INTERP_KERNEL::Exception)
+{
+ std::string oldName=getFamilyNameGivenId(id);
+ _families.erase(oldName);
+ _families[newFamName]=id;
+}
+
+void MEDFileUMesh::setMeshAtLevel(int meshDimRelToMax, MEDCouplingUMesh *m) throw(INTERP_KERNEL::Exception)
+{
+ setMeshAtLevelGen(meshDimRelToMax,m,true);
+}
+
+void MEDFileUMesh::setMeshAtLevelOld(int meshDimRelToMax, MEDCouplingUMesh *m) throw(INTERP_KERNEL::Exception)
+{
+ setMeshAtLevelGen(meshDimRelToMax,m,false);
+}
+
+void MEDFileUMesh::setMeshAtLevelGen(int meshDimRelToMax, MEDCouplingUMesh *m, bool newOrOld) throw(INTERP_KERNEL::Exception)
+{
+ std::vector<int> levSet=getNonEmptyLevels();
+ if(std::find(levSet.begin(),levSet.end(),meshDimRelToMax)==levSet.end())
+ {
+ if((DataArrayDouble *)_coords==0)
+ {
+ DataArrayDouble *c=m->getCoords();
+ if(c)
+ c->incrRef();
+ _coords=c;
+ }
+ else
+ {
+ if(m->getCoords()!=_coords)
+ throw INTERP_KERNEL::Exception("MEDFileUMesh::setMeshAtLevel : Invalid Given Mesh ! The coordinates are not the same ! try to use tryToShareSameCoords !");
+ int sz=(-meshDimRelToMax)+1;
+ if(sz>=(int)_ms.size())
+ _ms.resize(sz);
+ checkMeshDimCoherency(m->getMeshDimension(),meshDimRelToMax);
+ _ms[sz-1]=new MEDFileUMeshSplitL1(m,newOrOld);
+ }
+ }
+}
+
+void MEDFileUMesh::setGroupsFromScratch(int meshDimRelToMax, const std::vector<const MEDCouplingUMesh *>& ms) throw(INTERP_KERNEL::Exception)
+{
+ if(ms.empty())
+ throw INTERP_KERNEL::Exception("MEDFileUMesh::setGroupsFromScratch : expecting a non empty vector !");
+ int sz=(-meshDimRelToMax)+1;
+ if(sz>=(int)_ms.size())
+ _ms.resize(sz);
+ checkMeshDimCoherency(ms[0]->getMeshDimension(),meshDimRelToMax);
+ DataArrayDouble *coo=checkMultiMesh(ms);
+ if((DataArrayDouble *)_coords==0)
+ {
+ coo->incrRef();
+ _coords=coo;
+ }
+ else
+ if((DataArrayDouble *)_coords!=coo)
+ throw INTERP_KERNEL::Exception("MEDFileUMesh::setGroupsFromScratch : coordinates mismatches !");
+ std::vector<DataArrayInt *> corr;
+ MEDCouplingAutoRefCountObjectPtr<MEDCouplingUMesh> m=MEDCouplingUMesh::FuseUMeshesOnSameCoords(ms,_zipconn_pol,corr);
+ std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > corr3(corr.begin(),corr.end());
+ setMeshAtLevel(meshDimRelToMax,m);
+ std::vector<const DataArrayInt *> corr2(corr.begin(),corr.end());
+ setGroupsAtLevel(meshDimRelToMax,corr2,true);
+}
+
+void MEDFileUMesh::setGroupsOnSetMesh(int meshDimRelToMax, const std::vector<const MEDCouplingUMesh *>& ms, bool renum) throw(INTERP_KERNEL::Exception)
+{
+ if(ms.empty())
+ throw INTERP_KERNEL::Exception("MEDFileUMesh::setGroupsOnSetMesh : expecting a non empty vector !");
+ int sz=(-meshDimRelToMax)+1;
+ if(sz>=(int)_ms.size())
+ _ms.resize(sz);
+ checkMeshDimCoherency(ms[0]->getMeshDimension(),meshDimRelToMax);
+ DataArrayDouble *coo=checkMultiMesh(ms);
+ if((DataArrayDouble *)_coords==0)
+ {
+ coo->incrRef();
+ _coords=coo;
+ }
+ else
+ if((DataArrayDouble *)_coords!=coo)
+ throw INTERP_KERNEL::Exception("MEDFileUMesh::setGroupsOnSetMesh : coordinates mismatches !");
+ MEDCouplingUMesh *m=getMeshAtLevel(meshDimRelToMax,renum);
+ std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > corr(ms.size());
+ int i=0;
+ for(std::vector<const MEDCouplingUMesh *>::const_iterator it=ms.begin();it!=ms.end();it++,i++)
+ {
+ DataArrayInt *arr=0;
+ bool test=m->areCellsIncludedIn(*it,_zipconn_pol,arr);
+ corr[i]=arr;
+ if(!test)
+ {
+ std::ostringstream oss; oss << "MEDFileUMesh::setGroupsOnSetMesh : mesh #" << i << " is not part of whole mesh !";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ }
+ std::vector<const DataArrayInt *> corr2(corr.begin(),corr.end());
+ setGroupsAtLevel(meshDimRelToMax,corr2,renum);
+}
+
+DataArrayDouble *MEDFileUMesh::checkMultiMesh(const std::vector<const MEDCouplingUMesh *>& ms) const throw(INTERP_KERNEL::Exception)
+{
+ const DataArrayDouble *ret=ms[0]->getCoords();
+ int mdim=ms[0]->getMeshDimension();
+ for(unsigned int i=1;i<ms.size();i++)
+ {
+ ms[i]->checkCoherency();
+ if(ms[i]->getCoords()!=ret)
+ throw INTERP_KERNEL::Exception("MEDFileUMesh::checkMultiMesh : meshes must share the same coords !");
+ if(ms[i]->getMeshDimension()!=mdim)
+ throw INTERP_KERNEL::Exception("MEDFileUMesh::checkMultiMesh : meshes have not same mesh dimension !");
+ }
+ return const_cast<DataArrayDouble *>(ret);
+}
+
+void MEDFileUMesh::setFamilyArr(int meshDimRelToMaxExt, DataArrayInt *famArr)
+{
+ if(meshDimRelToMaxExt==1)
+ {
+ famArr->incrRef();
+ _fam_coords=famArr;
+ return ;
+ }
+ if(meshDimRelToMaxExt>1)
+ throw INTERP_KERNEL::Exception("MEDFileUMesh::setFamilyArr : Dimension request is invalid (>1) !");
+ int traducedRk=-meshDimRelToMaxExt;
+ if(traducedRk>=(int)_ms.size())
+ throw INTERP_KERNEL::Exception("Invalid mesh dim relative to max given ! To low !");
+ if((MEDFileUMeshSplitL1 *)_ms[traducedRk]==0)
+ throw INTERP_KERNEL::Exception("On specified lev (or entity) no cells exists !");
+ return _ms[traducedRk]->setFamilyArr(famArr);
+}
+
+void MEDFileUMesh::setRenumArr(int meshDimRelToMaxExt, DataArrayInt *renumArr)
+{
+ if(meshDimRelToMaxExt==1)
+ {
+ if(renumArr)
+ renumArr->incrRef();
+ _num_coords=renumArr;
+ computeRevNum();
+ return ;
+ }
+ if(meshDimRelToMaxExt>1)
+ throw INTERP_KERNEL::Exception("MEDFileUMesh::setRenumArr : Dimension request is invalid (>1) !");
+ int traducedRk=-meshDimRelToMaxExt;
+ if(traducedRk>=(int)_ms.size())
+ throw INTERP_KERNEL::Exception("Invalid mesh dim relative to max given ! To low !");
+ if((MEDFileUMeshSplitL1 *)_ms[traducedRk]==0)
+ throw INTERP_KERNEL::Exception("On specified lev (or entity) no cells exists !");
+ return _ms[traducedRk]->setRenumArr(renumArr);
+}
+
+void MEDFileUMesh::TranslateFamilyIds(int offset, DataArrayInt *famArr, std::vector< std::vector<int> >& famIdsPerGrp)
+{
+ famArr->applyLin(1,offset,0);
+ for(std::vector< std::vector<int> >::iterator it1=famIdsPerGrp.begin();it1!=famIdsPerGrp.end();it1++)
+ std::transform((*it1).begin(),(*it1).end(),(*it1).begin(),std::bind2nd(std::plus<int>(),offset));
+}
+
+/*!
+ * This method append into '_families' attribute the families whose ids are in 'famIds'. Warning 'famIds' are expected to be ids
+ * not in '_families'. Groups information are given in parameters in order to give to families representative names.
+ * For the moment, the two last input parameters are not taken into account.
+ */
+void MEDFileUMesh::appendFamilyEntries(const std::set<int>& famIds, const std::vector< std::vector<int> >& fidsOfGrps, const std::vector<std::string>& grpNames)
+{
+ std::map<int,std::string> famInv;
+ for(std::set<int>::const_iterator it=famIds.begin();it!=famIds.end();it++)
+ {
+ std::ostringstream oss;
+ oss << "Family_" << (*it);
+ _families[oss.str()]=(*it);
+ famInv[*it]=oss.str();
+ }
+ int i=0;
+ for(std::vector< std::vector<int> >::const_iterator it1=fidsOfGrps.begin();it1!=fidsOfGrps.end();it1++,i++)
+ {
+ for(std::vector<int>::const_iterator it2=(*it1).begin();it2!=(*it1).end();it2++)
+ {
+ _groups[grpNames[i]].push_back(famInv[*it2]);
+ }
+ }
+}
+
+/*!
+ * This method appends a new entry in _families attribute. An exception is thrown if either the famId is already
+ * kept by an another familyName. An exception is thrown if name 'familyName' is alreadyset with a different 'famId'.
+ */
+void MEDFileUMesh::addFamily(int famId, const char *familyName) throw(INTERP_KERNEL::Exception)
+{
+ std::string fname(familyName);
+ std::map<std::string,int>::const_iterator it=_families.find(fname);
+ if(it==_families.end())
+ {
+ for(std::map<std::string,int>::const_iterator it2=_families.begin();it2!=_families.end();it2++)
+ if((*it2).second==famId)
+ {
+ std::ostringstream oss;
+ oss << "MEDFileUMesh::addFamily : Family \"" << (*it2).first << "\" already exists with specified id : " << famId << " !";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ _families[fname]=famId;
+ }
+ else
+ {
+ if((*it).second!=famId)
+ {
+ std::ostringstream oss;
+ oss << "MEDFileUMesh::addFamily : Family \"" << fname << "\" already exists but has id set to " << (*it).second << " different from asked famId " << famId << " !";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ }
+}
+
+void MEDFileUMesh::computeRevNum() const
+{
+ if((const DataArrayInt *)_num_coords)
+ {
+ int pos;
+ int maxValue=_num_coords->getMaxValue(pos);
+ _rev_num_coords=_num_coords->invertArrayN2O2O2N(maxValue+1);
+ }
+}
--- /dev/null
+// Copyright (C) 2007-2010 CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#ifndef __MEDFILEMESH_HXX__
+#define __MEDFILEMESH_HXX__
+
+#include "MEDFileMeshLL.hxx"
+
+#include <map>
+
+namespace ParaMEDMEM
+{
+ class MEDFileMesh : public RefCountObject
+ {
+ public:
+ static MEDFileMesh *New(const char *fileName, const char *mName) throw(INTERP_KERNEL::Exception);
+ void setName(const char *name) { _name=name; }
+ const char *getName() const { return _name.c_str(); }
+ void setUnivName(const char *name) { _univ_name=name; }
+ const char *getUnivName() const { return _univ_name.c_str(); }
+ void setDescription(const char *name) { _desc_name=name; }
+ const char *getDescription() const { return _desc_name.c_str(); }
+ protected:
+ std::string _name;
+ std::string _univ_name;
+ std::string _desc_name;
+ };
+
+ class MEDFileUMesh : public MEDFileMesh
+ {
+ public:
+ static MEDFileUMesh *New(const char *fileName, const char *mName) throw(INTERP_KERNEL::Exception);
+ static MEDFileUMesh *New(const char *fileName) throw(INTERP_KERNEL::Exception);
+ static MEDFileUMesh *New();
+ ~MEDFileUMesh();
+ //
+ void removeGroup(const char *name) throw(INTERP_KERNEL::Exception);
+ void removeFamily(const char *name) throw(INTERP_KERNEL::Exception);
+ void changeGroupName(const char *oldName, const char *newName) throw(INTERP_KERNEL::Exception);
+ void changeFamilyName(const char *oldName, const char *newName) throw(INTERP_KERNEL::Exception);
+ //
+ void write(const char *fileName, int mode) const throw(INTERP_KERNEL::Exception);
+ int getFamilyId(const char *name) const throw(INTERP_KERNEL::Exception);
+ int getMaxFamilyId() const throw(INTERP_KERNEL::Exception);
+ std::vector<int> getFamiliesIds(const std::vector<std::string>& famNames) const throw(INTERP_KERNEL::Exception);
+ std::string getFamilyNameGivenId(int id) const throw(INTERP_KERNEL::Exception);
+ int getMeshDimension() const;
+ int getSizeAtLevel(int meshDimRelToMaxExt) const throw(INTERP_KERNEL::Exception);
+ const DataArrayInt *getFamilyFieldAtLevel(int meshDimRelToMaxExt) const throw(INTERP_KERNEL::Exception);
+ const DataArrayInt *getNumberFieldAtLevel(int meshDimRelToMaxExt) const throw(INTERP_KERNEL::Exception);
+ const DataArrayInt *getRevNumberFieldAtLevel(int meshDimRelToMaxExt) const throw(INTERP_KERNEL::Exception);
+ std::vector<std::string> getFamiliesOnGroup(const char *name) const throw(INTERP_KERNEL::Exception);
+ std::vector<std::string> getGroupsOnFamily(const char *name) const throw(INTERP_KERNEL::Exception);
+ std::vector<std::string> getGroupsNames() const;
+ std::vector<std::string> getFamiliesNames() const;
+ std::vector<int> getNonEmptyLevels() const;
+ std::vector<int> getNonEmptyLevelsExt() const;
+ DataArrayDouble *getCoords() const;
+ MEDCouplingUMesh *getGroup(int meshDimRelToMaxExt, const char *grp, bool renum=false) const throw(INTERP_KERNEL::Exception);
+ DataArrayInt *getGroupArr(int meshDimRelToMaxExt, const char *grp, bool renum=false) const throw(INTERP_KERNEL::Exception);
+ MEDCouplingUMesh *getGroups(int meshDimRelToMaxExt, const std::vector<std::string>& grps, bool renum=false) const throw(INTERP_KERNEL::Exception);
+ DataArrayInt *getGroupsArr(int meshDimRelToMaxExt, const std::vector<std::string>& grps, bool renum=false) const throw(INTERP_KERNEL::Exception);
+ MEDCouplingUMesh *getFamily(int meshDimRelToMaxExt, const char *fam, bool renum=false) const throw(INTERP_KERNEL::Exception);
+ DataArrayInt *getFamilyArr(int meshDimRelToMaxExt, const char *fam, bool renum=false) const throw(INTERP_KERNEL::Exception);
+ MEDCouplingUMesh *getFamilies(int meshDimRelToMaxExt, const std::vector<std::string>& fams, bool renum=false) const throw(INTERP_KERNEL::Exception);
+ DataArrayInt *getFamiliesArr(int meshDimRelToMaxExt, const std::vector<std::string>& fams, bool renum=false) const throw(INTERP_KERNEL::Exception);
+ DataArrayInt *getNodeGroupArr(const char *grp, bool renum=false) const throw(INTERP_KERNEL::Exception);
+ DataArrayInt *getNodeGroupsArr(const std::vector<std::string>& grps, bool renum=false) const throw(INTERP_KERNEL::Exception);
+ DataArrayInt *getNodeFamilyArr(const char *fam, bool renum=false) const throw(INTERP_KERNEL::Exception);
+ DataArrayInt *getNodeFamiliesArr(const std::vector<std::string>& fams, bool renum=false) const throw(INTERP_KERNEL::Exception);
+ MEDCouplingUMesh *getMeshAtLevel(int meshDimRelToMaxExt, bool renum=false) const throw(INTERP_KERNEL::Exception);
+ MEDCouplingUMesh *getLevel0Mesh(bool renum=false) const throw(INTERP_KERNEL::Exception);
+ MEDCouplingUMesh *getLevelM1Mesh(bool renum=false) const throw(INTERP_KERNEL::Exception);
+ MEDCouplingUMesh *getLevelM2Mesh(bool renum=false) const throw(INTERP_KERNEL::Exception);
+ MEDCouplingUMesh *getLevelM3Mesh(bool renum=false) const throw(INTERP_KERNEL::Exception);
+ const std::map<std::string,int>& getFamilyInfo() const { return _families; }
+ const std::map<std::string, std::vector<std::string> >& getGroupInfo() const { return _groups; }
+ bool existsFamily(int famId) const;
+ bool existsFamily(const char *familyName) const;
+ //
+ void copyFamGrpMapsFrom(const MEDFileUMesh& other);
+ void setFamilyInfo(const std::map<std::string,int>& info);
+ void setGroupInfo(const std::map<std::string, std::vector<std::string> >&info);
+ void setFamilyNameAttachedOnId(int id, const std::string& newFamName) throw(INTERP_KERNEL::Exception);
+ void setCoords(DataArrayDouble *coords) throw(INTERP_KERNEL::Exception);
+ void setGroupsAtLevel(int meshDimRelToMaxExt, const std::vector<const DataArrayInt *>& grps, bool renum=false) throw(INTERP_KERNEL::Exception);
+ void eraseGroupsAtLevel(int meshDimRelToMaxExt) throw(INTERP_KERNEL::Exception);
+ void setFamilyField(DataArrayInt *arr, const std::vector< std::vector< int > > &userfids, const std::vector<std::string>& grpNames, bool renum=false) throw(INTERP_KERNEL::Exception);
+ void setFamilyArr(int meshDimRelToMaxExt, DataArrayInt *famArr);
+ void setRenumArr(int meshDimRelToMaxExt, DataArrayInt *renumArr);
+ void addNodeGroup(const std::string& name, const std::vector<int>& ids) throw(INTERP_KERNEL::Exception);
+ void setMeshAtLevel(int meshDimRelToMax, MEDCouplingUMesh *m) throw(INTERP_KERNEL::Exception);
+ void setMeshAtLevelOld(int meshDimRelToMax, MEDCouplingUMesh *m) throw(INTERP_KERNEL::Exception);
+ void setMeshAtLevelGen(int meshDimRelToMax, MEDCouplingUMesh *m, bool newOrOld) throw(INTERP_KERNEL::Exception);
+ void setGroupsFromScratch(int meshDimRelToMax, const std::vector<const MEDCouplingUMesh *>& ms) throw(INTERP_KERNEL::Exception);
+ void setGroupsOnSetMesh(int meshDimRelToMax, const std::vector<const MEDCouplingUMesh *>& ms, bool renum) throw(INTERP_KERNEL::Exception);
+ void optimizeFamilies() throw(INTERP_KERNEL::Exception);
+ void addFamily(int famId, const char *familyName) throw(INTERP_KERNEL::Exception);
+ private:
+ MEDFileUMesh();
+ MEDFileUMesh(const char *fileName, const char *mName) throw(INTERP_KERNEL::Exception);
+ const MEDFileUMeshSplitL1 *getMeshAtLevSafe(int meshDimRelToMaxExt) const throw(INTERP_KERNEL::Exception);
+ MEDFileUMeshSplitL1 *getMeshAtLevSafe(int meshDimRelToMaxExt) throw(INTERP_KERNEL::Exception);
+ void checkMeshDimCoherency(int meshDim, int meshDimRelToMax) const throw(INTERP_KERNEL::Exception);
+ DataArrayDouble *checkMultiMesh(const std::vector<const MEDCouplingUMesh *>& ms) const throw(INTERP_KERNEL::Exception);
+ void appendFamilyEntries(const std::set<int>& famIds, const std::vector< std::vector<int> >& fidsOfGrps, const std::vector<std::string>& grpNames);
+ void computeRevNum() const;
+ static void TranslateFamilyIds(int offset, DataArrayInt *famArr, std::vector< std::vector<int> >& famIdsPerGrp);
+ private:
+ std::map<std::string, std::vector<std::string> > _groups;
+ std::map<std::string,int> _families;
+ std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileUMeshSplitL1> > _ms;
+ MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> _coords;
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> _fam_coords;
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> _num_coords;
+ mutable MEDCouplingAutoRefCountObjectPtr<DataArrayInt> _rev_num_coords;
+ int _too_long_str;
+ int _zipconn_pol;
+ };
+
+
+ class MEDFileCMesh : public MEDFileMesh
+ {
+ };
+}
+
+#endif
--- /dev/null
+// Copyright (C) 2007-2010 CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#include "MEDFileMeshElt.hxx"
+
+#include "MEDCouplingUMesh.hxx"
+
+#include "InterpKernelAutoPtr.hxx"
+#include "CellModel.hxx"
+
+extern med_geometrie_element typmai3[32];
+
+using namespace ParaMEDMEM;
+
+MEDFileUMeshPerType *MEDFileUMeshPerType::New(med_idt fid, const char *mName, int mdim, med_geometrie_element geoElt, INTERP_KERNEL::NormalizedCellType geoElt2)
+{
+ med_entite_maillage whichEntity;
+ if(!isExisting(fid,mName,geoElt,whichEntity))
+ return 0;
+ return new MEDFileUMeshPerType(fid,mName,mdim,geoElt,geoElt2,whichEntity);
+}
+
+bool MEDFileUMeshPerType::isExisting(med_idt fid, const char *mName, med_geometrie_element geoElt, med_entite_maillage& whichEntity)
+{
+ static const med_entite_maillage entities[3]={MED_MAILLE,MED_FACE,MED_ARETE};
+ int nbOfElt=0;
+ for(int i=0;i<3;i++)
+ {
+ int tmp=MEDnEntMaa(fid,(char *)mName,MED_CONN,entities[i],geoElt,MED_NOD);
+ if(tmp>nbOfElt)
+ {
+ nbOfElt=tmp;
+ whichEntity=entities[i];
+ }
+ }
+ return nbOfElt>0;
+}
+
+int MEDFileUMeshPerType::getDim() const
+{
+ const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::getCellModel(_type);
+ return cm.getDimension();
+}
+
+MEDFileUMeshPerType::MEDFileUMeshPerType(med_idt fid, const char *mName, int mdim, med_geometrie_element geoElt, INTERP_KERNEL::NormalizedCellType type,
+ med_entite_maillage entity):_type(type),_entity(entity)
+{
+ int curNbOfElem=MEDnEntMaa(fid,(char *)mName,MED_CONN,entity,geoElt,MED_NOD);
+ if(type!=INTERP_KERNEL::NORM_POLYGON && type!=INTERP_KERNEL::NORM_POLYHED)
+ {
+ loadFromStaticType(fid,mName,mdim,curNbOfElem,geoElt,type,entity);
+ return;
+ }
+ if(type==INTERP_KERNEL::NORM_POLYGON)
+ {
+ loadPolyg(fid,mName,mdim,curNbOfElem,geoElt,entity);
+ return;
+ }
+ //if(type==INTERP_KERNEL::NORM_POLYHED)
+ loadPolyh(fid,mName,mdim,curNbOfElem,geoElt,entity);
+}
+
+void MEDFileUMeshPerType::loadFromStaticType(med_idt fid, const char *mName, int mdim, int curNbOfElem, med_geometrie_element geoElt, INTERP_KERNEL::NormalizedCellType type,
+ med_entite_maillage entity)
+{
+ _conn=DataArrayInt::New();
+ int nbOfNodesPerCell=(geoElt%100);
+ _conn->alloc((nbOfNodesPerCell+1)*curNbOfElem,1);
+ _conn_index=DataArrayInt::New();
+ _conn_index->alloc(curNbOfElem+1,1);
+ int *connTab=new int[(nbOfNodesPerCell)*curNbOfElem];
+ _num=DataArrayInt::New();
+ _num->alloc(curNbOfElem,1);
+ char *noms=new char[MED_TAILLE_PNOM*curNbOfElem+1];
+ med_booleen inoele, inuele;
+ _fam=DataArrayInt::New();
+ _fam->alloc(curNbOfElem,1);
+ MEDelementsLire(fid,(char *)mName,mdim,connTab,MED_FULL_INTERLACE,noms,&inoele,_num->getPointer(),&inuele,_fam->getPointer(),curNbOfElem,entity,geoElt,MED_NOD);
+ delete [] noms;
+ int *w1=_conn->getPointer();
+ int *w2=_conn_index->getPointer();
+ *w2++=0;
+ const int *wi=connTab;
+ for(int i=0;i<curNbOfElem;i++,wi+=nbOfNodesPerCell,w2++)
+ {
+ *w1++=(int)type;
+ w1=std::transform(wi,wi+nbOfNodesPerCell,w1,std::bind2nd(std::plus<int>(),-1));
+ *w2=w2[-1]+nbOfNodesPerCell+1;
+ }
+ delete [] connTab;
+ if(!inuele)
+ _num=0;
+}
+
+void MEDFileUMeshPerType::loadPolyg(med_idt fid, const char *mName, int mdim, int curNbOfElem, med_geometrie_element geoElt,
+ med_entite_maillage entity)
+{
+ med_int arraySize;
+ MEDpolygoneInfo(fid,(char *)mName,entity,MED_NOD,&arraySize);
+ _conn_index=DataArrayInt::New();
+ _conn_index->alloc(curNbOfElem+1,1);
+ _conn=DataArrayInt::New();
+ _conn->alloc(arraySize+curNbOfElem,1);
+ _num=DataArrayInt::New();
+ _num->alloc(curNbOfElem,1);
+ _fam=DataArrayInt::New();
+ _fam->alloc(curNbOfElem,1);
+ int *locConn=new int[arraySize];
+ MEDpolygoneConnLire(fid,(char *)mName,_conn_index->getPointer(),curNbOfElem+1,locConn,entity,MED_NOD);
+ int *w1=_conn->getPointer();
+ int *w2=_conn_index->getPointer();
+ const int *wi=locConn;
+ for(int i=0;i<curNbOfElem;i++,w2++)
+ {
+ *w1++=(int)INTERP_KERNEL::NORM_POLYGON;
+ w1=std::transform(wi,wi+(w2[1]-w2[0]),w1,std::bind2nd(std::plus<int>(),-1));
+ *w2=*w2-1+i;
+ }
+ *w2=*w2-1+curNbOfElem;
+ delete [] locConn;
+ MEDfamLire(fid,(char *)mName,_fam->getPointer(),curNbOfElem,entity,MED_POLYGONE);
+ if(MEDnumLire(fid,(char *)mName,_num->getPointer(),curNbOfElem,entity,MED_POLYGONE)!=0)
+ _num=0;
+}
+
+void MEDFileUMeshPerType::loadPolyh(med_idt fid, const char *mName, int mdim, int curNbOfElem, med_geometrie_element geoElt,
+ med_entite_maillage entity)
+{
+ med_int indexFaceLgth,connFaceLgth;
+ MEDpolyedreInfo(fid,(char*)mName,MED_NOD,&indexFaceLgth,&connFaceLgth);
+ int *index=new int[curNbOfElem+1];
+ int *indexFace=new int[indexFaceLgth];
+ int *locConn=new int[connFaceLgth];
+ _fam=DataArrayInt::New();
+ _fam->alloc(curNbOfElem,1);
+ MEDpolyedreConnLire(fid,(char *)mName,index,curNbOfElem+1,indexFace,indexFaceLgth,locConn,MED_NOD);
+ MEDfamLire(fid,(char *)mName,_fam->getPointer(),curNbOfElem,MED_MAILLE,MED_POLYEDRE);
+ int arraySize=connFaceLgth;
+ for(int i=0;i<curNbOfElem;i++)
+ arraySize+=index[i+1]-index[i]-1;
+ _conn=DataArrayInt::New();
+ _conn->alloc(arraySize+curNbOfElem,1);
+ int *wFinalConn=_conn->getPointer();
+ _conn_index=DataArrayInt::New();
+ _conn_index->alloc(curNbOfElem+1,1);
+ int *finalIndex=_conn_index->getPointer();
+ finalIndex[0]=0;
+ for(int i=0;i<curNbOfElem;i++)
+ {
+ *wFinalConn++=(int)INTERP_KERNEL::NORM_POLYHED;
+ finalIndex[i+1]=finalIndex[i]+index[i+1]-index[i]-1+indexFace[index[i+1]-1]-indexFace[index[i]-1]+1;
+ wFinalConn=std::transform(locConn+indexFace[index[i]-1]-1,locConn+indexFace[index[i]]-1,wFinalConn,std::bind2nd(std::plus<int>(),-1));
+ for(int j=index[i];j<index[i+1]-1;j++)
+ {
+ *wFinalConn++=-1;
+ wFinalConn=std::transform(locConn+indexFace[j]-1,locConn+indexFace[j+1]-1,wFinalConn,std::bind2nd(std::plus<int>(),-1));
+ }
+ }
+ delete [] index;
+ delete [] locConn;
+ delete [] indexFace;
+ _num=DataArrayInt::New();
+ _num->alloc(curNbOfElem,1);
+ if(MEDnumLire(fid,(char *)mName,_num->getPointer(),curNbOfElem,MED_MAILLE,MED_POLYEDRE)!=0)
+ _num=0;
+}
+
+void MEDFileUMeshPerType::write(med_idt fid, const char *mname, int mdim, const MEDCouplingUMesh *m, const DataArrayInt *fam, const DataArrayInt *num)
+{
+ int nbOfCells=m->getNumberOfCells();
+ if(nbOfCells<1)
+ return ;
+ INTERP_KERNEL::NormalizedCellType ikt=m->getTypeOfCell(0);
+ const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::getCellModel(ikt);
+ med_geometrie_element curMedType=typmai3[(int)ikt];
+ const int *conn=m->getNodalConnectivity()->getConstPointer();
+ const int *connI=m->getNodalConnectivityIndex()->getConstPointer();
+ if(ikt!=INTERP_KERNEL::NORM_POLYGON && ikt!=INTERP_KERNEL::NORM_POLYHED)
+ {
+ int nbNodesPerCell=cm.getNumberOfNodes();
+ INTERP_KERNEL::AutoPtr<int> tab=new int[nbNodesPerCell*nbOfCells];
+ int *w=tab;
+ for(int i=0;i<nbOfCells;i++)
+ w=std::transform(conn+connI[i]+1,conn+connI[i+1],w,std::bind2nd(std::plus<int>(),1));
+ MEDconnEcr(fid,(char *)mname,mdim,tab,MED_FULL_INTERLACE,nbOfCells,MED_MAILLE,curMedType,MED_NOD);
+ }
+ else
+ {
+ if(ikt==INTERP_KERNEL::NORM_POLYGON)
+ {
+ INTERP_KERNEL::AutoPtr<int> tab1=new int[nbOfCells+1];
+ INTERP_KERNEL::AutoPtr<int> tab2=new int[m->getMeshLength()];
+ int *wI=tab1; *wI=1;
+ int *w=tab2;
+ for(int i=0;i<nbOfCells;i++,wI++)
+ {
+ wI[1]=wI[0]+connI[i+1]-connI[i]-1;
+ w=std::transform(conn+connI[i]+1,conn+connI[i+1],w,std::bind2nd(std::plus<int>(),1));
+ }
+ MEDpolygoneConnEcr(fid,(char *)mname,tab1,nbOfCells,tab2,MED_MAILLE,MED_NOD);
+ }
+ else
+ {
+ int meshLgth=m->getMeshLength();
+ int nbOfFaces=std::count(conn,conn+meshLgth,-1)+nbOfCells;
+ INTERP_KERNEL::AutoPtr<int> tab1=new int[nbOfCells+1];
+ int *w1=tab1; *w1=1;
+ INTERP_KERNEL::AutoPtr<int> tab2=new int[nbOfFaces+1];
+ int *w2=tab2; *w2=1;
+ INTERP_KERNEL::AutoPtr<int> bigtab=new int[meshLgth-nbOfCells];
+ int *bt=bigtab;
+ for(int i=0;i<nbOfCells;i++,w1++)
+ {
+ int nbOfFaces=0;
+ for(const int *w=conn+connI[i]+1;w!=conn+connI[i+1];w2++)
+ {
+ const int *wend=std::find(w,conn+connI[i+1],-1);
+ bt=std::transform(w,wend,bt,std::bind2nd(std::plus<int>(),1));
+ int nbOfNode=std::distance(w,wend);
+ w2[1]=w2[0]+nbOfNode;
+ if(wend!=conn+connI[i+1])
+ w=wend+1;
+ else
+ w=wend;
+ nbOfFaces++;
+ }
+ w1[1]=w1[0]+nbOfFaces;
+ }
+ MEDpolyedreConnEcr(fid,(char *)mname,tab1,nbOfCells+1,tab2,nbOfFaces+1,
+ bigtab,MED_NOD);
+ }
+ }
+ if(fam)
+ MEDfamEcr(fid,(char *)mname,(int *)fam->getConstPointer(),nbOfCells,MED_MAILLE,curMedType);
+ if(num)
+ MEDnumEcr(fid,(char *)mname,(int *)num->getConstPointer(),nbOfCells,MED_MAILLE,curMedType);
+}
--- /dev/null
+// Copyright (C) 2007-2010 CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#ifndef __MEDFILEMESHELT_HXX__
+#define __MEDFILEMESHELT_HXX__
+
+#include "MEDCouplingMemArray.hxx"
+#include "MEDCouplingAutoRefCountObjectPtr.hxx"
+
+#include "NormalizedUnstructuredMesh.hxx"
+
+extern "C"
+{
+#include "med.h"
+}
+
+namespace ParaMEDMEM
+{
+ class MEDCouplingUMesh;
+
+ class MEDFileUMeshPerType : public RefCountObject
+ {
+ public:
+ static MEDFileUMeshPerType *New(med_idt fid, const char *mName, int mdim, med_geometrie_element geoElt, INTERP_KERNEL::NormalizedCellType geoElt2);
+ static bool isExisting(med_idt fid, const char *mName, med_geometrie_element geoElt, med_entite_maillage& whichEntity);
+ int getDim() const;
+ const DataArrayInt *getNodal() const { return _conn; }
+ const DataArrayInt *getNodalIndex() const { return _conn_index; }
+ const DataArrayInt *getFam() const { return _fam; }
+ const DataArrayInt *getNum() const { return _num; }
+ static void write(med_idt fid, const char *mname, int mdim, const MEDCouplingUMesh *m, const DataArrayInt *fam, const DataArrayInt *num);
+ private:
+ MEDFileUMeshPerType(med_idt fid, const char *mName, int mdim, med_geometrie_element geoElt, INTERP_KERNEL::NormalizedCellType type,
+ med_entite_maillage entity);
+ void loadFromStaticType(med_idt fid, const char *mName, int mdim, int curNbOfElem, med_geometrie_element geoElt, INTERP_KERNEL::NormalizedCellType type,
+ med_entite_maillage entity);
+ void loadPolyg(med_idt fid, const char *mName, int mdim, int curNbOfElem, med_geometrie_element geoElt,
+ med_entite_maillage entity);
+ void loadPolyh(med_idt fid, const char *mName, int mdim, int curNbOfElem, med_geometrie_element geoElt,
+ med_entite_maillage entity);
+ private:
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> _conn;
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> _conn_index;
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> _num;
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> _fam;
+ INTERP_KERNEL::NormalizedCellType _type;
+ med_entite_maillage _entity;
+ };
+}
+
+#endif
--- /dev/null
+// Copyright (C) 2007-2010 CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#include "MEDFileMeshLL.hxx"
+#include "MEDLoaderBase.hxx"
+
+#include "MEDCouplingUMesh.hxx"
+
+#include "InterpKernelAutoPtr.hxx"
+
+#include <set>
+
+extern med_geometrie_element typmai[MED_NBR_GEOMETRIE_MAILLE+2];
+extern INTERP_KERNEL::NormalizedCellType typmai2[MED_NBR_GEOMETRIE_MAILLE+2];
+extern med_geometrie_element typmainoeud[1];
+
+using namespace ParaMEDMEM;
+
+MEDFileMeshL2::MEDFileMeshL2():_name(MED_TAILLE_NOM),_description(MED_TAILLE_DESC)
+{
+}
+
+MEDFileUMeshL2::MEDFileUMeshL2()
+{
+}
+
+void MEDFileUMeshL2::loadAll(med_idt fid, int mId, const char *mName)
+{
+ _name.set(mName);
+ med_maillage type_maillage;
+ med_int Mdim;
+ if(MEDmaaInfo(fid,mId,(char *)mName,&Mdim,&type_maillage,_description.getPointer())!=0)
+ throw INTERP_KERNEL::Exception("A problem has been detected when trying to get info on mesh !");
+ if(type_maillage!=MED_NON_STRUCTURE)
+ throw INTERP_KERNEL::Exception("Invalid mesh type ! You are expected an unstructured one whereas in file it is not an unstructured !");
+ loadConnectivity(fid,Mdim,mName);
+ loadCoords(fid,mId,Mdim,mName);
+}
+
+void MEDFileUMeshL2::loadConnectivity(med_idt fid, int mdim, const char *mName)
+{
+ _per_type_mesh.resize(1);
+ _per_type_mesh[0].clear();
+ for(int j=0;j<MED_NBR_GEOMETRIE_MAILLE+2;j++)
+ {
+ MEDFileUMeshPerType *tmp=MEDFileUMeshPerType::New(fid,mName,mdim,typmai[j],typmai2[j]);
+ if(tmp)
+ _per_type_mesh[0].push_back(tmp);
+ }
+ sortTypes();
+}
+
+void MEDFileUMeshL2::loadCoords(med_idt fid, int mId, int mdim, const char *mName) throw(INTERP_KERNEL::Exception)
+{
+ med_int edim=MEDdimEspaceLire(fid,(char *)mName);
+ int spaceDim=std::max((int)mdim,(int)edim);
+ int nCoords=MEDnEntMaa(fid,(char *)mName,MED_COOR,MED_NOEUD,(med_geometrie_element)0,(med_connectivite)0);
+ _coords=DataArrayDouble::New();
+ _coords->alloc(nCoords,spaceDim);
+ double *coordsPtr=_coords->getPointer();
+ med_repere repere;
+ char *comp=MEDLoaderBase::buildEmptyString(spaceDim*MED_TAILLE_PNOM);
+ char *unit=MEDLoaderBase::buildEmptyString(spaceDim*MED_TAILLE_PNOM);
+ MEDcoordLire(fid,(char *)mName,spaceDim,coordsPtr,MED_FULL_INTERLACE,MED_ALL,NULL,0,&repere,comp,unit);
+ _fam_coords=DataArrayInt::New();
+ _fam_coords->alloc(nCoords,1);
+ _num_coords=DataArrayInt::New();
+ _num_coords->alloc(nCoords,1);
+ MEDfamLire(fid,(char *)mName,_fam_coords->getPointer(),nCoords,MED_NOEUD,MED_NONE);
+ if(MEDnumLire(fid,(char *)mName,_num_coords->getPointer(),nCoords,MED_NOEUD,MED_NONE)!=0)
+ _num_coords=0;
+ for(int i=0;i<spaceDim;i++)
+ {
+ std::string n,u;
+ std::string info=MEDLoaderBase::buildUnionUnit(comp+i*MED_TAILLE_PNOM,MED_TAILLE_PNOM,unit+i*MED_TAILLE_PNOM,MED_TAILLE_PNOM);
+ _coords->setInfoOnComponent(i,info.c_str());
+ }
+ delete [] comp;
+ delete [] unit;
+}
+
+void MEDFileUMeshL2::sortTypes()
+{
+ std::set<int> mdims;
+ std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileUMeshPerType> > tmp(_per_type_mesh[0]);
+ _per_type_mesh.clear();
+ for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileUMeshPerType> >::const_iterator it=tmp.begin();it!=tmp.end();it++)
+ mdims.insert((*it)->getDim());
+ if(mdims.empty())
+ return;
+ int mdim=*mdims.rbegin();
+ _per_type_mesh.resize(mdim+1);
+ for(int dim=mdim+1;dim!=0;dim--)
+ {
+ std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileUMeshPerType> >& elt=_per_type_mesh[mdim+1-dim];
+ for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileUMeshPerType> >::const_iterator it=tmp.begin();it!=tmp.end();it++)
+ if((*it)->getDim()==dim-1)
+ elt.push_back(*it);
+ }
+}
+
+int MEDFileUMeshL2::getMeshIdFromName(med_idt fid, const char *mname) throw(INTERP_KERNEL::Exception)
+{
+ med_maillage type_maillage;
+ char maillage_description[MED_TAILLE_DESC+1];
+ med_int dim;
+ char nommaa[MED_TAILLE_NOM+1];
+ med_int n=MEDnMaa(fid);
+ bool found=false;
+ int ret=-1;
+ std::vector<std::string> ms;
+ for(int i=0;i<n;i++)
+ {
+ MEDmaaInfo(fid,i+1,nommaa,&dim,&type_maillage,maillage_description);
+ std::string cur=MEDLoaderBase::buildStringFromFortran(nommaa,sizeof(nommaa));
+ ms.push_back(cur);
+ if(cur==mname)
+ {
+ found=true;
+ ret=i+1;
+ }
+ }
+ if(!found)
+ {
+ std::ostringstream oss;
+ oss << "No such meshname (" << mname << ") in file ! Must be in :";
+ std::copy(ms.begin(),ms.end(),std::ostream_iterator<std::string>(oss,", "));
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ return ret;
+}
+
+void MEDFileUMeshL2::readFamiliesAndGrps(med_idt fid, const char *meshName, std::map<std::string,int>& fams, std::map<std::string, std::vector<std::string> >& grps)
+{
+ char nomfam[MED_TAILLE_NOM+1];
+ med_int numfam;
+ int nfam=MEDnFam(fid,(char *)meshName);
+ for(int i=0;i<nfam;i++)
+ {
+ int ngro=MEDnGroupe(fid,(char *)meshName,i+1);
+ med_int natt=MEDnAttribut(fid,(char *)meshName,i+1);
+ med_int *attide=new int[natt];
+ med_int *attval=new int[natt];
+ char *attdes=new char[MED_TAILLE_DESC*natt+1];
+ char *gro=new char[MED_TAILLE_LNOM*ngro+1];
+ MEDfamInfo(fid,(char *)meshName,i+1,nomfam,&numfam,attide,attval,attdes,&natt,gro,&ngro);
+ std::string famName=MEDLoaderBase::buildStringFromFortran(nomfam,MED_TAILLE_LNOM);
+ fams[famName]=numfam;
+ for(int j=0;j<ngro;j++)
+ {
+ std::string groupname=MEDLoaderBase::buildStringFromFortran(gro+j*MED_TAILLE_LNOM,MED_TAILLE_LNOM);
+ grps[groupname].push_back(famName);
+ }
+ delete [] attdes;
+ delete [] gro;
+ delete [] attide;
+ delete [] attval;
+ }
+}
+
+void MEDFileUMeshL2::writeFamiliesAndGrps(med_idt fid, const char *mname, const std::map<std::string,int>& fams, const std::map<std::string, std::vector<std::string> >& grps, int tooLongStrPol)
+{
+ for(std::map<std::string,int>::const_iterator it=fams.begin();it!=fams.end();it++)
+ {
+ std::vector<std::string> grpsOfFam;
+ for(std::map<std::string, std::vector<std::string> >::const_iterator it1=grps.begin();it1!=grps.end();it1++)
+ {
+ if(std::find((*it1).second.begin(),(*it1).second.end(),(*it).first)!=(*it1).second.end())
+ grpsOfFam.push_back((*it1).first);
+ }
+ int ngro=grpsOfFam.size();
+ INTERP_KERNEL::AutoPtr<char> groName=MEDLoaderBase::buildEmptyString(MED_TAILLE_LNOM*ngro);
+ int i=0;
+ for(std::vector<std::string>::const_iterator it2=grpsOfFam.begin();it2!=grpsOfFam.end();it2++,i++)
+ MEDLoaderBase::safeStrCpy((*it2).c_str(),MED_TAILLE_LNOM-1,groName+i*MED_TAILLE_LNOM,tooLongStrPol);
+ INTERP_KERNEL::AutoPtr<char> famName=MEDLoaderBase::buildEmptyString(MED_TAILLE_NOM);
+ MEDLoaderBase::safeStrCpy((*it).first.c_str(),MED_TAILLE_NOM,famName,tooLongStrPol);
+ MEDfamCr(fid,(char *)mname,famName,(*it).second,0,0,0,0,groName,ngro);
+ }
+}
+
+void MEDFileUMeshL2::writeCoords(med_idt fid, const char *mname, const DataArrayDouble *coords, const DataArrayInt *famCoords, const DataArrayInt *numCoords)
+{
+ if(!coords)
+ return ;
+ int spaceDim=coords->getNumberOfComponents();
+ INTERP_KERNEL::AutoPtr<char> comp=MEDLoaderBase::buildEmptyString(spaceDim*MED_TAILLE_PNOM);
+ INTERP_KERNEL::AutoPtr<char> unit=MEDLoaderBase::buildEmptyString(spaceDim*MED_TAILLE_PNOM);
+ for(int i=0;i<spaceDim;i++)
+ {
+ std::string info=coords->getInfoOnComponent(i);
+ std::string c,u;
+ MEDLoaderBase::splitIntoNameAndUnit(info,c,u);
+ MEDLoaderBase::safeStrCpy(c.c_str(),MED_TAILLE_PNOM-1,comp+i*MED_TAILLE_PNOM,0);//MED_TAILLE_PNOM-1 to avoid to write '\0' on next compo
+ MEDLoaderBase::safeStrCpy(u.c_str(),MED_TAILLE_PNOM-1,unit+i*MED_TAILLE_PNOM,0);//MED_TAILLE_PNOM-1 to avoid to write '\0' on next compo
+ }
+ MEDcoordEcr(fid,(char *)mname,spaceDim,coords->getPointer(),MED_FULL_INTERLACE,coords->getNumberOfTuples(),MED_CART,comp,unit);
+ MEDfamEcr(fid,(char *)mname,famCoords->getPointer(),famCoords->getNumberOfTuples(),MED_NOEUD,MED_NONE);
+ if(numCoords)
+ MEDnumEcr(fid,(char *)mname,numCoords->getPointer(),numCoords->getNumberOfTuples(),MED_NOEUD,MED_NONE);
+}
+
+bool MEDFileUMeshL2::isFamDefinedOnLev(int levId) const
+{
+ for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileUMeshPerType> >::const_iterator it=_per_type_mesh[levId].begin();it!=_per_type_mesh[levId].end();it++)
+ if((*it)->getFam()==0)
+ return false;
+ return true;
+}
+
+bool MEDFileUMeshL2::isNumDefinedOnLev(int levId) const
+{
+ for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileUMeshPerType> >::const_iterator it=_per_type_mesh[levId].begin();it!=_per_type_mesh[levId].end();it++)
+ if((*it)->getNum()==0)
+ return false;
+ return true;
+}
+
+MEDFileUMeshPermCompute::MEDFileUMeshPermCompute(const MEDFileUMeshSplitL1* st):_st(st),_mpt_time(0),_num_time(0)
+{
+}
+
+/*!
+ * Warning it returns an instance to deallocate !!!!
+ */
+MEDFileUMeshPermCompute::operator MEDCouplingUMesh *() const
+{
+ _st->_m_by_types->updateTime();
+ _st->_num->updateTime();
+ if((MEDCouplingUMesh *)_m==0)
+ {
+ updateTime();
+ MEDCouplingUMesh *ret=(MEDCouplingUMesh *)_st->_m_by_types->deepCpy();
+ _m=ret;
+ _m->renumberCells(_st->_num->getConstPointer(),true);
+ ret->incrRef();
+ return ret;
+ }
+ else
+ {
+ if(_mpt_time==_st->_m_by_types->getTimeOfThis() && _num_time==_st->_num->getTimeOfThis())
+ {
+ _m->incrRef();
+ return _m;
+ }
+ else
+ {
+ updateTime();
+ MEDCouplingUMesh *ret=(MEDCouplingUMesh *)_st->_m_by_types->deepCpy();
+ _m=ret;
+ _m->renumberCells(_st->_num->getConstPointer(),true);
+ ret->incrRef();
+ return ret;
+ }
+ }
+}
+
+void MEDFileUMeshPermCompute::operator=(MEDCouplingUMesh *m)
+{
+ _m=m;
+}
+
+void MEDFileUMeshPermCompute::updateTime() const
+{
+ _mpt_time=_st->_m_by_types->getTimeOfThis();
+ _num_time=_st->_num->getTimeOfThis();
+}
+
+MEDFileUMeshSplitL1::MEDFileUMeshSplitL1(const MEDFileUMeshL2& l2, const char *mName, int id):_m(this)
+{
+ const std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileUMeshPerType> >& v=l2.getLev(id);
+ if(v.empty())
+ return;
+ int sz=v.size();
+ std::vector<const MEDCouplingUMesh *> ms(sz);
+ for(int i=0;i<sz;i++)
+ {
+ MEDCouplingUMesh *tmp=MEDCouplingUMesh::New("",v[i]->getDim());
+ MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> tmp2=l2.getCoords();
+ tmp->setCoords(tmp2);
+ tmp->setConnectivity(const_cast<DataArrayInt *>(v[i]->getNodal()),const_cast<DataArrayInt *>(v[i]->getNodalIndex()));
+ ms[i]=tmp;
+ }
+ _m_by_types=MEDCouplingUMesh::MergeUMeshesOnSameCoords(ms);
+ _m_by_types->setName(mName);
+ if(l2.isFamDefinedOnLev(id))
+ {
+ int nbOfCells=_m_by_types->getNumberOfCells();
+ _fam=DataArrayInt::New();
+ _fam->alloc(nbOfCells,1);
+ int *w=_fam->getPointer();
+ for(int i=0;i<sz;i++)
+ w=std::copy(v[i]->getFam()->getConstPointer(),v[i]->getFam()->getConstPointer()+v[i]->getFam()->getNumberOfTuples(),w);
+ }
+ if(l2.isNumDefinedOnLev(id))
+ {
+ int nbOfCells=_m_by_types->getNumberOfCells();
+ _num=DataArrayInt::New();
+ _num->alloc(nbOfCells,1);
+ int *w=_num->getPointer();
+ for(int i=0;i<sz;i++)
+ w=std::copy(v[i]->getNum()->getConstPointer(),v[i]->getNum()->getConstPointer()+v[i]->getNum()->getNumberOfTuples(),w);
+ computeRevNum();
+ }
+ for(int i=0;i<sz;i++)
+ (const_cast<MEDCouplingUMesh *>(ms[i]))->decrRef();//const cast under control to avoid a copy of array
+}
+
+MEDFileUMeshSplitL1::MEDFileUMeshSplitL1(MEDCouplingUMesh *m):_m(this)
+{
+ assignMesh(m,true);
+}
+
+MEDFileUMeshSplitL1::MEDFileUMeshSplitL1(MEDCouplingUMesh *m, bool newOrOld):_m(this)
+{
+ assignMesh(m,newOrOld);
+}
+
+void MEDFileUMeshSplitL1::assignMesh(MEDCouplingUMesh *m, bool newOrOld) throw(INTERP_KERNEL::Exception)
+{
+ if(newOrOld)
+ {
+ m->incrRef();
+ _m=m;
+ _m_by_types=(MEDCouplingUMesh *)m->deepCpy();
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da=_m_by_types->getRenumArrForConsecutiveCellTypesSpec(typmai2,typmai2+MED_NBR_GEOMETRIE_MAILLE+2);
+ if(!da->isIdentity())
+ {
+ _num=da->invertArrayO2N2N2O(m->getNumberOfCells());
+ _m.updateTime();
+ computeRevNum();
+ _m_by_types->renumberCells(da->getConstPointer(),false);
+ }
+ }
+ else
+ {
+ if(!m->checkConsecutiveCellTypesAndOrder(typmai2,typmai2+MED_NBR_GEOMETRIE_MAILLE+2))
+ throw INTERP_KERNEL::Exception("MEDFileUMeshSplitL1::assignMesh : the mode of mesh setting expects to follow the MED file numbering convention ! it is not the case !");
+ m->incrRef();
+ _m_by_types=m;
+ }
+ _fam=DataArrayInt::New();
+ _fam->alloc(m->getNumberOfCells(),1);
+ _fam->fillWithValue(0);
+}
+
+bool MEDFileUMeshSplitL1::empty() const
+{
+ return ((const MEDCouplingUMesh *)_m_by_types)==0;
+}
+
+int MEDFileUMeshSplitL1::getMeshDimension() const
+{
+ return _m_by_types->getMeshDimension();
+}
+
+int MEDFileUMeshSplitL1::getSize() const throw(INTERP_KERNEL::Exception)
+{
+ if((const MEDCouplingUMesh *)_m_by_types==0)
+ throw INTERP_KERNEL::Exception("MEDFileUMeshSplitL1::getSize : no mesh specified at level !");
+ return _m_by_types->getNumberOfCells();
+}
+
+MEDCouplingUMesh *MEDFileUMeshSplitL1::getFamilyPart(const std::vector<int>& ids, bool renum) const
+{
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> eltsToKeep=_fam->getIdsEqualList(ids);
+ MEDCouplingUMesh *m=(MEDCouplingUMesh *)_m_by_types->buildPartOfMySelf(eltsToKeep->getConstPointer(),eltsToKeep->getConstPointer()+eltsToKeep->getNumberOfTuples(),true);
+ if(renum)
+ return renumIfNeeded(m,eltsToKeep->getConstPointer());
+ return m;
+}
+
+DataArrayInt *MEDFileUMeshSplitL1::getFamilyPartArr(const std::vector<int>& ids, bool renum) const
+{
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da=_fam->getIdsEqualList(ids);
+ if(renum)
+ return renumIfNeededArr(da);
+ da->incrRef();
+ return da;
+}
+
+MEDCouplingUMesh *MEDFileUMeshSplitL1::getWholeMesh(bool renum) const
+{
+ MEDCouplingAutoRefCountObjectPtr<MEDCouplingUMesh> tmp;
+ if(renum)
+ tmp=_m;
+ else
+ tmp=_m_by_types;
+ tmp->incrRef();
+ return tmp;
+}
+
+const DataArrayInt *MEDFileUMeshSplitL1::getFamilyField() const
+{
+ return _fam;
+}
+
+const DataArrayInt *MEDFileUMeshSplitL1::getNumberField() const
+{
+ return _num;
+}
+
+const DataArrayInt *MEDFileUMeshSplitL1::getRevNumberField() const
+{
+ return _rev_num;
+}
+
+void MEDFileUMeshSplitL1::eraseFamilyField()
+{
+ _fam->fillWithZero();
+}
+
+/*!
+ * This method ignores _m and _m_by_types.
+ */
+void MEDFileUMeshSplitL1::setGroupsFromScratch(const std::vector<const MEDCouplingUMesh *>& ms, std::map<std::string,int>& familyIds,
+ std::map<std::string, std::vector<std::string> >& groups) throw(INTERP_KERNEL::Exception)
+{
+ int sz=ms.size();
+ std::vector< DataArrayInt * > corr;
+ _m=MEDCouplingUMesh::FuseUMeshesOnSameCoords(ms,0,corr);
+ std::vector< std::vector<int> > fidsOfGroups;
+ std::vector< const DataArrayInt * > corr2(corr.begin(),corr.end());
+ _fam=DataArrayInt::MakePartition(corr2,((MEDCouplingUMesh *)_m)->getNumberOfCells(),fidsOfGroups);
+ int nbOfCells=((MEDCouplingUMesh *)_m)->getNumberOfCells();
+ std::map<int,std::string> newfams;
+ std::map<int,int> famIdTrad;
+ traduceFamilyNumber(fidsOfGroups,familyIds,famIdTrad,newfams);
+ for(int i=0;i<sz;i++)
+ corr[i]->decrRef();
+ int *w=_fam->getPointer();
+ for(int i=0;i<nbOfCells;i++,w++)
+ *w=famIdTrad[*w];
+}
+
+void MEDFileUMeshSplitL1::write(med_idt fid, const char *mName, int mdim) const
+{
+ std::vector<MEDCouplingUMesh *> ms=_m_by_types->splitByType();
+ int start=0;
+ for(std::vector<MEDCouplingUMesh *>::const_iterator it=ms.begin();it!=ms.end();it++)
+ {
+ int nbCells=(*it)->getNumberOfCells();
+ int end=start+nbCells;
+ DataArrayInt *fam=0,*num=0;
+ if((const DataArrayInt *)_fam)
+ fam=_fam->substr(start,end);
+ if((const DataArrayInt *)_num)
+ num=_num->substr(start,end);
+ MEDFileUMeshPerType::write(fid,mName,mdim,(*it),fam,num);
+ if(fam)
+ fam->decrRef();
+ if(num)
+ num->decrRef();
+ (*it)->decrRef();
+ start=end;
+ }
+}
+
+void MEDFileUMeshSplitL1::setFamilyArr(DataArrayInt *famArr)
+{
+ famArr->incrRef();
+ _fam=famArr;
+}
+
+void MEDFileUMeshSplitL1::setRenumArr(DataArrayInt *renumArr)
+{
+ renumArr->incrRef();
+ _num=renumArr;
+ computeRevNum();
+}
+
+MEDCouplingUMesh *MEDFileUMeshSplitL1::Renumber2(const DataArrayInt *renum, MEDCouplingUMesh *m, const int *cellIds)
+{
+ if(renum==0)
+ return m;
+ if(cellIds==0)
+ m->renumberCells(renum->getConstPointer(),true);
+ else
+ {
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> locnum=renum->selectByTupleId(cellIds,cellIds+m->getNumberOfCells());
+ m->renumberCells(locnum->getConstPointer(),true);
+ }
+ return m;
+}
+
+MEDCouplingUMesh *MEDFileUMeshSplitL1::renumIfNeeded(MEDCouplingUMesh *m, const int *cellIds) const
+{
+ return Renumber2(_num,m,cellIds);
+}
+
+DataArrayInt *MEDFileUMeshSplitL1::Renumber(const DataArrayInt *renum, const DataArrayInt *da)
+{
+ if((const DataArrayInt *)renum==0)
+ {
+ da->incrRef();
+ return const_cast<DataArrayInt *>(da);
+ }
+ return renum->selectByTupleId(da->getConstPointer(),da->getConstPointer()+da->getNumberOfTuples());
+}
+
+DataArrayInt *MEDFileUMeshSplitL1::renumIfNeededArr(const DataArrayInt *da) const
+{
+ return Renumber(_num,da);
+}
+
+std::vector<int> MEDFileUMeshSplitL1::getNewFamiliesNumber(int nb, const std::map<std::string,int>& families)
+{
+ int id=-1;
+ for(std::map<std::string,int>::const_iterator it=families.begin();it!=families.end();it++)
+ id=std::max(id,(*it).second);
+ if(id==-1)
+ id=0;
+ std::vector<int> ret(nb);
+ for(int i=1;i<=nb;i++)
+ ret[i]=id+i;
+ return ret;
+}
+
+void MEDFileUMeshSplitL1::traduceFamilyNumber(const std::vector< std::vector<int> >& fidsGrps, std::map<std::string,int>& familyIds,
+ std::map<int,int>& famIdTrad, std::map<int,std::string>& newfams)
+{
+ std::set<int> allfids;
+
+}
+
+void MEDFileUMeshSplitL1::computeRevNum() const
+{
+ int pos;
+ int maxValue=_num->getMaxValue(pos);
+ _rev_num=_num->invertArrayN2O2O2N(maxValue+1);
+}
--- /dev/null
+// Copyright (C) 2007-2010 CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#ifndef __MEDFILEMESHLL_HXX__
+#define __MEDFILEMESHLL_HXX__
+
+#include "MEDFileBasis.hxx"
+#include "MEDFileMeshElt.hxx"
+
+#include "MEDCouplingAutoRefCountObjectPtr.hxx"
+
+extern "C"
+{
+#include "med.h"
+}
+
+#include <map>
+
+namespace ParaMEDMEM
+{
+ class MEDCouplingUMesh;
+
+ class MEDFileMeshL2 : public RefCountObject
+ {
+ public:
+ MEDFileMeshL2();
+ const char *getName() const { return _name.getReprForWrite(); }
+ const char *getDescription() const { return _description.getReprForWrite(); }
+ protected:
+ MEDFileString _name;
+ MEDFileString _description;
+ };
+
+ class MEDFileUMeshL2 : public MEDFileMeshL2
+ {
+ public:
+ MEDFileUMeshL2();
+ void loadAll(med_idt fid, int mId, const char *mName);
+ void loadConnectivity(med_idt fid, int mdim, const char *mName);
+ void loadCoords(med_idt fid, int mId, int mdim, const char *mName) throw(INTERP_KERNEL::Exception);
+ int getNumberOfLevels() const { return _per_type_mesh.size(); }
+ bool emptyLev(int levId) const { return _per_type_mesh[levId].empty(); }
+ const std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileUMeshPerType> >& getLev(int levId) const { return _per_type_mesh[levId]; }
+ bool isFamDefinedOnLev(int levId) const;
+ bool isNumDefinedOnLev(int levId) const;
+ MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> getCoords() const { return _coords; }
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> getCoordsFamily() const { return _fam_coords; }
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> getCoordsNum() const { return _num_coords; }
+ static int getMeshIdFromName(med_idt fid, const char *mname) throw(INTERP_KERNEL::Exception);
+ static void readFamiliesAndGrps(med_idt fid, const char *mname, std::map<std::string,int>& fams, std::map<std::string, std::vector<std::string> >& grps);
+ static void writeFamiliesAndGrps(med_idt fid, const char *mname, const std::map<std::string,int>& fams, const std::map<std::string, std::vector<std::string> >& grps, int tooLongStrPol);
+ static void writeCoords(med_idt fid, const char *mname, const DataArrayDouble *coords, const DataArrayInt *famCoords, const DataArrayInt *numCoords);
+ private:
+ void sortTypes();
+ private:
+ std::vector< std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileUMeshPerType> > > _per_type_mesh;
+ MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> _coords;
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> _fam_coords;
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> _num_coords;
+ };
+
+ class MEDFileUMeshL2CMesh : public MEDFileMeshL2
+ {
+ };
+
+ class MEDFileUMeshSplitL1;
+
+ class MEDFileUMeshPermCompute
+ {
+ public:
+ MEDFileUMeshPermCompute(const MEDFileUMeshSplitL1* st);
+ operator MEDCouplingUMesh *() const;
+ void operator=(MEDCouplingUMesh *m);
+ void updateTime() const;
+ private:
+ const MEDFileUMeshSplitL1 *_st;
+ mutable unsigned int _mpt_time;
+ mutable unsigned int _num_time;
+ mutable MEDCouplingAutoRefCountObjectPtr<MEDCouplingUMesh> _m;
+ };
+
+ class MEDFileUMeshSplitL1 : public RefCountObject
+ {
+ friend class MEDFileUMeshPermCompute;
+ public:
+ MEDFileUMeshSplitL1(const MEDFileUMeshL2& l2, const char *mName, int id);
+ MEDFileUMeshSplitL1(MEDCouplingUMesh *m);
+ MEDFileUMeshSplitL1(MEDCouplingUMesh *m, bool newOrOld);
+ void assignMesh(MEDCouplingUMesh *m, bool newOrOld) throw(INTERP_KERNEL::Exception);
+ bool empty() const;
+ int getMeshDimension() const;
+ int getSize() const throw(INTERP_KERNEL::Exception);
+ MEDCouplingUMesh *getFamilyPart(const std::vector<int>& ids, bool renum) const;
+ DataArrayInt *getFamilyPartArr(const std::vector<int>& ids, bool renum) const;
+ MEDCouplingUMesh *getWholeMesh(bool renum) const;
+ const DataArrayInt *getFamilyField() const;
+ const DataArrayInt *getNumberField() const;
+ const DataArrayInt *getRevNumberField() const;
+ void eraseFamilyField();
+ void setGroupsFromScratch(const std::vector<const MEDCouplingUMesh *>& ms, std::map<std::string,int>& familyIds,
+ std::map<std::string, std::vector<std::string> >& groups) throw(INTERP_KERNEL::Exception);
+ void write(med_idt fid, const char *mName, int mdim) const;
+ //
+ void setFamilyArr(DataArrayInt *famArr);
+ void setRenumArr(DataArrayInt *renumArr);
+ //
+ static std::vector<int> getNewFamiliesNumber(int nb, const std::map<std::string,int>& families);
+ static void traduceFamilyNumber(const std::vector< std::vector<int> >& fidsGrps, std::map<std::string,int>& familyIds,
+ std::map<int,int>& famIdTrad, std::map<int,std::string>& newfams);
+ static DataArrayInt *Renumber(const DataArrayInt *renum, const DataArrayInt *da);
+ static MEDCouplingUMesh *Renumber2(const DataArrayInt *renum, MEDCouplingUMesh *m, const int *cellIds);
+ private:
+ MEDCouplingUMesh *renumIfNeeded(MEDCouplingUMesh *m, const int *cellIds) const;
+ DataArrayInt *renumIfNeededArr(const DataArrayInt *da) const;
+ void computeRevNum() const;
+ private:
+ MEDCouplingAutoRefCountObjectPtr<MEDCouplingUMesh> _m_by_types;
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> _fam;
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> _num;
+ mutable MEDCouplingAutoRefCountObjectPtr<DataArrayInt> _rev_num;
+ MEDFileUMeshPermCompute _m;
+ };
+}
+
+#endif
--- /dev/null
+// Copyright (C) 2007-2010 CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#include "MEDFileUtilities.hxx"
+#include "MEDLoaderBase.hxx"
+
+#include <sstream>
+
+med_mode_acces MEDFileUtilities::TraduceWriteMode(int medloaderwritemode) throw(INTERP_KERNEL::Exception)
+{
+ switch(medloaderwritemode)
+ {
+ case 2:
+ return MED_CREATION;
+ case 1:
+ return MED_LECTURE_AJOUT;
+ case 0:
+ return MED_LECTURE_ECRITURE;
+ default:
+ throw INTERP_KERNEL::Exception("Invalid write mode specified ! must be 0(write with no question), 1(append) or 2(creation)");
+ }
+}
+
+void MEDFileUtilities::CheckMEDCode(int code, med_idt fid, const char *msg) throw(INTERP_KERNEL::Exception)
+{
+ if(code==-1)
+ {
+ std::ostringstream oss;
+ oss << "MEDFile has returned an error code (" << code <<") : " << msg;
+ MEDfermer(fid);
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+}
+
+void MEDFileUtilities::CheckFileForRead(const char *fileName) throw(INTERP_KERNEL::Exception)
+{
+ int status=MEDLoaderBase::getStatusOfFile(fileName);
+ std::ostringstream oss;
+ oss << " File : \"" << fileName << "\"";
+ switch(status)
+ {
+ case MEDLoaderBase::DIR_LOCKED:
+ {
+ oss << " has been detected as unreadable : impossible to read anything !";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ case MEDLoaderBase::NOT_EXIST:
+ {
+ oss << " has been detected as NOT EXISTING : impossible to read anything !";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ case MEDLoaderBase::EXIST_WRONLY:
+ {
+ oss << " has been detected as WRITE ONLY : impossible to read anything !";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ }
+ int fid=MEDouvrir((char *)fileName,MED_LECTURE);
+ if(fid<0)
+ {
+ oss << " has been detected as unreadable by MED file : impossible to read anything !";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ oss << " has been detected readable but ";
+ int major,minor,release;
+ MEDversionLire(fid,&major,&minor,&release);
+ if(major<2 || (major==2 && minor<2))
+ {
+ oss << "version of MED file is < 2.2 : impossible to read anything !";
+ MEDfermer(fid);
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ MEDfermer(fid);
+}
--- /dev/null
+// Copyright (C) 2007-2010 CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#ifndef __MEDFILEUTILITIES_HXX__
+#define __MEDFILEUTILITIES_HXX__
+
+#include "InterpKernelException.hxx"
+
+extern "C"
+{
+#include "med.h"
+}
+
+namespace MEDFileUtilities
+{
+ med_mode_acces TraduceWriteMode(int medloaderwritemode) throw(INTERP_KERNEL::Exception);
+ void CheckMEDCode(int code, med_idt fid, const char *msg) throw(INTERP_KERNEL::Exception);
+ void CheckFileForRead(const char *fileName) throw(INTERP_KERNEL::Exception);
+}
+
+#endif
#include "MEDLoader.hxx"
#include "MEDLoaderBase.hxx"
+#include "MEDFileUtilities.hxx"
#include "CellModel.hxx"
#include "MEDCouplingUMesh.hxx"
#include "MEDCouplingMemArray.hxx"
#include "MEDCouplingFieldDouble.hxx"
#include "MEDCouplingGaussLocalization.hxx"
+#include "InterpKernelAutoPtr.hxx"
+
extern "C"
{
#include "med.h"
#include <iterator>
#include <algorithm>
#include <numeric>
+#include <limits>
med_geometrie_element typmai[MED_NBR_GEOMETRIE_MAILLE+2] = { MED_POINT1,
MED_SEG2,
MED_SEG3,
MED_TRIA3,
- MED_TRIA6,
MED_QUAD4,
+ MED_TRIA6,
MED_QUAD8,
MED_TETRA4,
- MED_TETRA10,
- MED_HEXA8,
- MED_HEXA20,
- MED_PENTA6,
- MED_PENTA15,
MED_PYRA5,
+ MED_PENTA6,
+ MED_HEXA8,
+ MED_TETRA10,
MED_PYRA13,
+ MED_PENTA15,
+ MED_HEXA20,
MED_POLYGONE,
MED_POLYEDRE };
med_geometrie_element typmainoeud[1] = { MED_NONE };
-INTERP_KERNEL::NormalizedCellType typmai2[MED_NBR_GEOMETRIE_MAILLE+2] = { INTERP_KERNEL::NORM_POINT0,
+INTERP_KERNEL::NormalizedCellType typmai2[MED_NBR_GEOMETRIE_MAILLE+2] = { INTERP_KERNEL::NORM_POINT1,
INTERP_KERNEL::NORM_SEG2,
INTERP_KERNEL::NORM_SEG3,
INTERP_KERNEL::NORM_TRI3,
- INTERP_KERNEL::NORM_TRI6,
INTERP_KERNEL::NORM_QUAD4,
+ INTERP_KERNEL::NORM_TRI6,
INTERP_KERNEL::NORM_QUAD8,
INTERP_KERNEL::NORM_TETRA4,
- INTERP_KERNEL::NORM_TETRA10,
- INTERP_KERNEL::NORM_HEXA8,
- INTERP_KERNEL::NORM_HEXA20,
- INTERP_KERNEL::NORM_PENTA6,
- INTERP_KERNEL::NORM_PENTA15,
INTERP_KERNEL::NORM_PYRA5,
+ INTERP_KERNEL::NORM_PENTA6,
+ INTERP_KERNEL::NORM_HEXA8,
+ INTERP_KERNEL::NORM_TETRA10,
INTERP_KERNEL::NORM_PYRA13,
+ INTERP_KERNEL::NORM_PENTA15,
+ INTERP_KERNEL::NORM_HEXA20,
INTERP_KERNEL::NORM_POLYGON,
INTERP_KERNEL::NORM_POLYHED };
void prepareCellFieldDoubleForWriting(const ParaMEDMEM::MEDCouplingFieldDouble *f, const int *cellIds, std::list<MEDLoader::MEDFieldDoublePerCellType>& split);
void fillGaussDataOnField(const char *fileName, const std::list<MEDLoader::MEDFieldDoublePerCellType>& data, MEDCouplingFieldDouble *f);
void writeUMeshesDirectly(const char *fileName, const std::vector<const ParaMEDMEM::MEDCouplingUMesh *>& mesh, const std::vector<const DataArrayInt *>& families, bool forceFromScratch, bool &isRenumbering);
- void writeUMeshesPartitionDirectly(const char *fileName, const char *meshName, const std::vector<ParaMEDMEM::MEDCouplingUMesh *>& meshes, bool forceFromScratch);
+ void writeUMeshesPartitionDirectly(const char *fileName, const char *meshName, const std::vector<const ParaMEDMEM::MEDCouplingUMesh *>& meshes, bool forceFromScratch);
void writeFieldAndMeshDirectly(const char *fileName, const ParaMEDMEM::MEDCouplingFieldDouble *f, bool forceFromScratch);
void writeFieldTryingToFitExistingMesh(const char *fileName, const ParaMEDMEM::MEDCouplingFieldDouble *f);
}
void MEDLoader::CheckFileForRead(const char *fileName) throw(INTERP_KERNEL::Exception)
{
- int status=MEDLoaderBase::getStatusOfFile(fileName);
- std::ostringstream oss;
- oss << " File : \"" << fileName << "\"";
- switch(status)
- {
- case MEDLoaderBase::DIR_LOCKED:
- {
- oss << " has been detected as unreadable : impossible to read anything !";
- throw INTERP_KERNEL::Exception(oss.str().c_str());
- }
- case MEDLoaderBase::NOT_EXIST:
- {
- oss << " has been detected as NOT EXISTING : impossible to read anything !";
- throw INTERP_KERNEL::Exception(oss.str().c_str());
- }
- case MEDLoaderBase::EXIST_WRONLY:
- {
- oss << " has been detected as WRITE ONLY : impossible to read anything !";
- throw INTERP_KERNEL::Exception(oss.str().c_str());
- }
- }
- int fid=MEDouvrir((char *)fileName,MED_LECTURE);
- if(fid<0)
- {
- oss << " has been detected as unreadable by MED file : impossible to read anything !";
- throw INTERP_KERNEL::Exception(oss.str().c_str());
- }
- oss << " has been detected readable but ";
- int major,minor,release;
- MEDversionLire(fid,&major,&minor,&release);
- if(major<2 || (major==2 && minor<2))
- {
- oss << "version of MED file is < 2.2 : impossible to read anything !";
- MEDfermer(fid);
- throw INTERP_KERNEL::Exception(oss.str().c_str());
- }
- MEDfermer(fid);
+ MEDFileUtilities::CheckFileForRead(fileName);
}
std::vector<std::string> MEDLoader::GetMeshNames(const char *fileName) throw(INTERP_KERNEL::Exception)
MEDfermer(fid);
return ret;
}
+
+std::vector<std::string> MEDLoader::GetMeshFamiliesNamesOnGroup(const char *fileName, const char *meshName, const char *grpName) throw(INTERP_KERNEL::Exception)
+{
+ CheckFileForRead(fileName);
+ med_idt fid=MEDouvrir((char *)fileName,MED_LECTURE);
+ med_int nfam=MEDnFam(fid,(char *)meshName);
+ std::vector<std::string> ret;
+ char nomfam[MED_TAILLE_NOM+1];
+ med_int numfam;
+ for(int i=0;i<nfam;i++)
+ {
+ int ngro=MEDnGroupe(fid,(char *)meshName,i+1);
+ med_int natt=MEDnAttribut(fid,(char *)meshName,i+1);
+ INTERP_KERNEL::AutoPtr<med_int> attide=new int[natt];
+ INTERP_KERNEL::AutoPtr<med_int> attval=new int[natt];
+ INTERP_KERNEL::AutoPtr<char> attdes=new char[MED_TAILLE_DESC*natt+1];
+ INTERP_KERNEL::AutoPtr<char> gro=new char[MED_TAILLE_LNOM*ngro+1];
+ MEDfamInfo(fid,(char *)meshName,i+1,nomfam,&numfam,attide,attval,attdes,&natt,gro,&ngro);
+ std::string cur=MEDLoaderBase::buildStringFromFortran(nomfam,sizeof(nomfam));
+ for(int j=0;j<ngro;j++)
+ {
+ std::string cur2=MEDLoaderBase::buildStringFromFortran(gro+j*MED_TAILLE_LNOM,MED_TAILLE_LNOM);
+ if(cur2==grpName)
+ ret.push_back(cur);
+ }
+ }
+ MEDfermer(fid);
+ return ret;
+}
+
+std::vector<std::string> MEDLoader::GetMeshGroupsNamesOnFamily(const char *fileName, const char *meshName, const char *famName) throw(INTERP_KERNEL::Exception)
+{
+ CheckFileForRead(fileName);
+ med_idt fid=MEDouvrir((char *)fileName,MED_LECTURE);
+ med_int nfam=MEDnFam(fid,(char *)meshName);
+ std::vector<std::string> ret;
+ char nomfam[MED_TAILLE_NOM+1];
+ med_int numfam;
+ bool found=false;
+ for(int i=0;i<nfam && !found;i++)
+ {
+ int ngro=MEDnGroupe(fid,(char *)meshName,i+1);
+ med_int natt=MEDnAttribut(fid,(char *)meshName,i+1);
+ INTERP_KERNEL::AutoPtr<med_int> attide=new int[natt];
+ INTERP_KERNEL::AutoPtr<med_int> attval=new int[natt];
+ INTERP_KERNEL::AutoPtr<char> attdes=new char[MED_TAILLE_DESC*natt+1];
+ INTERP_KERNEL::AutoPtr<char> gro=new char[MED_TAILLE_LNOM*ngro+1];
+ MEDfamInfo(fid,(char *)meshName,i+1,nomfam,&numfam,attide,attval,attdes,&natt,gro,&ngro);
+ std::string cur=MEDLoaderBase::buildStringFromFortran(nomfam,sizeof(nomfam));
+ found=(cur==famName);
+ if(found)
+ for(int j=0;j<ngro;j++)
+ {
+ std::string cur=MEDLoaderBase::buildStringFromFortran(gro+j*MED_TAILLE_LNOM,MED_TAILLE_LNOM);
+ ret.push_back(cur);
+ }
+ }
+ MEDfermer(fid);
+ if(!found)
+ {
+ std::ostringstream oss;
+ oss << "MEDLoader::GetMeshGroupsNamesOnFamily : no such family \"" << famName << "\" in file \"" << fileName << "\" in mesh \"" << meshName << "\" !";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ return ret;
+}
std::vector<std::string> MEDLoader::GetMeshGroupsNames(const char *fileName, const char *meshName) throw(INTERP_KERNEL::Exception)
{
MEDfermer(fid);
return ret;
}
-std::vector<ParaMEDMEM::TypeOfField> MEDLoader::GetTypesOfField(const char *fileName, const char *fieldName, const char *meshName) throw(INTERP_KERNEL::Exception)
+std::vector<ParaMEDMEM::TypeOfField> MEDLoader::GetTypesOfField(const char *fileName, const char *meshName, const char *fieldName) throw(INTERP_KERNEL::Exception)
{
CheckFileForRead(fileName);
std::vector<ParaMEDMEM::TypeOfField> ret;
//
bool found=false;
bool found2=false;
- double ret;
+ double ret=std::numeric_limits<double>::max();
for(int i=0;i<nbFields && !found;i++)
{
med_int ncomp=MEDnChamp(fid,i+1);
MEDCouplingUMesh *MEDLoaderNS::readUMeshFromFileLev1(const char *fileName, const char *meshName, int meshDimRelToMax, const std::vector<int>& ids,
const std::vector<INTERP_KERNEL::NormalizedCellType>& typesToKeep, unsigned& meshDimExtract, int *&cellRenum) throw(INTERP_KERNEL::Exception)
{
+ if(meshDimRelToMax>0)
+ throw INTERP_KERNEL::Exception("meshDimRelToMax must be <=0 !");
//Extraction data from MED file.
med_idt fid=MEDouvrir((char *)fileName,MED_LECTURE);
std::string trueMeshName;
{
std::vector<int> ci(cellIds.size());
std::transform(cellIds.begin(),cellIds.end(),ci.begin(),std::bind2nd(std::plus<int>(),-1));
- ParaMEDMEM::MEDCouplingUMesh *mesh2;
+ ParaMEDMEM::MEDCouplingUMesh *mesh2=0;
if(typeOfOutField==ON_CELLS)
{
if(newMesh)
- mesh2=newMesh->keepSpecifiedCells((*iter).getType(),ci);
+ mesh2=newMesh->keepSpecifiedCells((*iter).getType(),&ci[0],&ci[0]+ci.size());
else
- mesh2=mesh->keepSpecifiedCells((*iter).getType(),ci);
+ mesh2=mesh->keepSpecifiedCells((*iter).getType(),&ci[0],&ci[0]+ci.size());
}
else if(typeOfOutField==ON_NODES)
{
const char DftFamilyName[]="DftFamily";
std::copy(DftFamilyName,DftFamilyName+sizeof(DftFamilyName),familyName);
MEDfamCr(fid,maa,familyName,0,0,0,0,0,0,0);
- DataArrayDouble *arr=mesh[0]->getCoords();
+ const DataArrayDouble *arr=mesh[0]->getCoords();
char *comp=MEDLoaderBase::buildEmptyString(spaceDim*MED_TAILLE_PNOM);
char *unit=MEDLoaderBase::buildEmptyString(spaceDim*MED_TAILLE_PNOM);
for(int i=0;i<spaceDim;i++)
* In this method meshes are assumed to shared the same coords.
* This method makes the assumption that 'meshes' is not empty, no check on that is done (responsability of the caller)
*/
-void MEDLoaderNS::writeUMeshesPartitionDirectly(const char *fileName, const char *meshName, const std::vector<ParaMEDMEM::MEDCouplingUMesh *>& meshes, bool forceFromScratch)
+void MEDLoaderNS::writeUMeshesPartitionDirectly(const char *fileName, const char *meshName, const std::vector<const ParaMEDMEM::MEDCouplingUMesh *>& meshes, bool forceFromScratch)
{
std::string meshNameCpp(meshName);
char *maa=MEDLoaderBase::buildEmptyString(MED_TAILLE_NOM);
if(meshNameCpp=="")
throw INTERP_KERNEL::Exception("writeUMeshesPartitionDirectly : Invalid meshName : Must be different from \"\" !");
std::vector< DataArrayInt * > corr;
- MEDCouplingUMesh *m=ParaMEDMEM::MEDCouplingUMesh::fuseUMeshesOnSameCoords(meshes,0,corr);
+ MEDCouplingUMesh *m=ParaMEDMEM::MEDCouplingUMesh::FuseUMeshesOnSameCoords(meshes,0,corr);
m->setName(meshName);
std::vector< std::vector<int> > fidsOfGroups;
- DataArrayInt *arr2=DataArrayInt::makePartition(corr,m->getNumberOfCells(),fidsOfGroups);
+ std::vector< const DataArrayInt * > corr2(corr.begin(),corr.end());
+ DataArrayInt *arr2=DataArrayInt::MakePartition(corr2,m->getNumberOfCells(),fidsOfGroups);
for(std::vector< DataArrayInt * >::iterator it=corr.begin();it!=corr.end();it++)
(*it)->decrRef();
bool isRenumbering;
throw INTERP_KERNEL::Exception(oss.str().c_str());
}
MEDCouplingUMesh *m=MEDLoader::ReadUMeshFromFile(fileName,f->getMesh()->getName(),f2);
- MEDCouplingUMesh *m2=MEDCouplingUMesh::mergeUMeshes(m,(MEDCouplingUMesh *)f->getMesh());
+ MEDCouplingUMesh *m2=MEDCouplingUMesh::MergeUMeshes(m,(MEDCouplingUMesh *)f->getMesh());
bool areNodesMerged;
int newNbOfNodes;
DataArrayInt *da=m2->mergeNodes(MEDLoader::_EPS_FOR_NODE_COMP,areNodesMerged,newNbOfNodes);
MEDLoaderNS::writeUMeshesDirectly(fileName,meshV,famV,false,isRenumbering);
}
-void MEDLoader::WriteUMeshesPartition(const char *fileName, const char *meshNameC, const std::vector<ParaMEDMEM::MEDCouplingUMesh *>& meshes, bool writeFromScratch) throw(INTERP_KERNEL::Exception)
+void MEDLoader::WriteUMeshesPartition(const char *fileName, const char *meshNameC, const std::vector<const ParaMEDMEM::MEDCouplingUMesh *>& meshes, bool writeFromScratch) throw(INTERP_KERNEL::Exception)
{
std::string meshName(meshNameC);
if(meshName.empty())
}
if(meshes.empty())
throw INTERP_KERNEL::Exception("List of meshes must be not empty !");
- DataArrayDouble *coords=meshes.front()->getCoords();
- for(std::vector<ParaMEDMEM::MEDCouplingUMesh *>::const_iterator iter=meshes.begin();iter!=meshes.end();iter++)
+ const DataArrayDouble *coords=meshes.front()->getCoords();
+ for(std::vector<const ParaMEDMEM::MEDCouplingUMesh *>::const_iterator iter=meshes.begin();iter!=meshes.end();iter++)
if(coords!=(*iter)->getCoords())
throw INTERP_KERNEL::Exception("Meshes does not not share the same coordinates : try method MEDCouplingPointSet::tryToShareSameCoords !");
std::set<std::string> tmp;
- for(std::vector<ParaMEDMEM::MEDCouplingUMesh *>::const_iterator iter=meshes.begin();iter!=meshes.end();iter++)
+ for(std::vector<const ParaMEDMEM::MEDCouplingUMesh *>::const_iterator iter=meshes.begin();iter!=meshes.end();iter++)
{
if(tmp.find((*iter)->getName())==tmp.end())
tmp.insert((*iter)->getName());
}
}
-void MEDLoader::WriteUMeshesPartitionDep(const char *fileName, const char *meshNameC, const std::vector<ParaMEDMEM::MEDCouplingUMesh *>& meshes, bool writeFromScratch) throw(INTERP_KERNEL::Exception)
+void MEDLoader::WriteUMeshesPartitionDep(const char *fileName, const char *meshNameC, const std::vector<const ParaMEDMEM::MEDCouplingUMesh *>& meshes, bool writeFromScratch) throw(INTERP_KERNEL::Exception)
{
std::string meshName(meshNameC);
if(meshName.empty())
}
if(meshes.empty())
throw INTERP_KERNEL::Exception("List of meshes must be not empty !");
- DataArrayDouble *coords=meshes.front()->getCoords();
- for(std::vector<ParaMEDMEM::MEDCouplingUMesh *>::const_iterator iter=meshes.begin();iter!=meshes.end();iter++)
+ const DataArrayDouble *coords=meshes.front()->getCoords();
+ for(std::vector<const ParaMEDMEM::MEDCouplingUMesh *>::const_iterator iter=meshes.begin();iter!=meshes.end();iter++)
if(coords!=(*iter)->getCoords())
throw INTERP_KERNEL::Exception("Meshes does not not share the same coordinates : try method MEDCouplingPointSet::tryToShareSameCoords !");
std::set<std::string> tmp;
- for(std::vector<ParaMEDMEM::MEDCouplingUMesh *>::const_iterator iter=meshes.begin();iter!=meshes.end();iter++)
+ for(std::vector<const ParaMEDMEM::MEDCouplingUMesh *>::const_iterator iter=meshes.begin();iter!=meshes.end();iter++)
{
if(tmp.find((*iter)->getName())==tmp.end())
tmp.insert((*iter)->getName());
std::string meshName(meshes[0]->getName());
if(meshName.empty())
throw INTERP_KERNEL::Exception("Trying to write a unstructured mesh with no name ! MED file format needs a not empty mesh name : change name of first element of 2nd parameter !");
- DataArrayDouble *coords=meshes.front()->getCoords();
+ const DataArrayDouble *coords=meshes.front()->getCoords();
for(std::vector<const ParaMEDMEM::MEDCouplingUMesh *>::const_iterator iter=meshes.begin();iter!=meshes.end();iter++)
if(coords!=(*iter)->getCoords())
throw INTERP_KERNEL::Exception("Meshes does not not share the same coordinates : try method MEDCouplingPointSet::tryToShareSameCoords !");
static std::vector<std::string> GetMeshNamesOnField(const char *fileName, const char *fieldName) throw(INTERP_KERNEL::Exception);
static std::vector<std::string> GetMeshGroupsNames(const char *fileName, const char *meshName) throw(INTERP_KERNEL::Exception);
static std::vector<std::string> GetMeshFamiliesNames(const char *fileName, const char *meshName) throw(INTERP_KERNEL::Exception);
+ static std::vector<std::string> GetMeshFamiliesNamesOnGroup(const char *fileName, const char *meshName, const char *grpName) throw(INTERP_KERNEL::Exception);
+ static std::vector<std::string> GetMeshGroupsNamesOnFamily(const char *fileName, const char *meshName, const char *famName) throw(INTERP_KERNEL::Exception);
static std::vector<std::string> GetAllFieldNames(const char *fileName) throw(INTERP_KERNEL::Exception);
static std::vector<std::string> GetAllFieldNamesOnMesh(const char *fileName, const char *meshName) throw(INTERP_KERNEL::Exception);
- static std::vector<ParaMEDMEM::TypeOfField> GetTypesOfField(const char *fileName, const char *fieldName, const char *meshName) throw(INTERP_KERNEL::Exception);
+ static std::vector<ParaMEDMEM::TypeOfField> GetTypesOfField(const char *fileName, const char *meshName, const char *fieldName) throw(INTERP_KERNEL::Exception);
static std::vector<std::string> GetFieldNamesOnMesh(ParaMEDMEM::TypeOfField type, const char *fileName, const char *meshName) throw(INTERP_KERNEL::Exception);
static std::vector<std::string> GetCellFieldNamesOnMesh(const char *fileName, const char *meshName) throw(INTERP_KERNEL::Exception);
static std::vector<std::string> GetNodeFieldNamesOnMesh(const char *fileName, const char *meshName) throw(INTERP_KERNEL::Exception);
static ParaMEDMEM::MEDCouplingFieldDouble *ReadFieldGaussNE(const char *fileName, const char *meshName, int meshDimRelToMax, const char *fieldName, int iteration, int order) throw(INTERP_KERNEL::Exception);
static void WriteUMesh(const char *fileName, const ParaMEDMEM::MEDCouplingUMesh *mesh, bool writeFromScratch) throw(INTERP_KERNEL::Exception);
static void WriteUMeshDep(const char *fileName, const ParaMEDMEM::MEDCouplingUMesh *mesh, bool writeFromScratch) throw(INTERP_KERNEL::Exception);
- static void WriteUMeshesPartition(const char *fileName, const char *meshName, const std::vector<ParaMEDMEM::MEDCouplingUMesh *>& meshes, bool writeFromScratch) throw(INTERP_KERNEL::Exception);
- static void WriteUMeshesPartitionDep(const char *fileName, const char *meshName, const std::vector<ParaMEDMEM::MEDCouplingUMesh *>& meshes, bool writeFromScratch) throw(INTERP_KERNEL::Exception);
+ static void WriteUMeshesPartition(const char *fileName, const char *meshName, const std::vector<const ParaMEDMEM::MEDCouplingUMesh *>& meshes, bool writeFromScratch) throw(INTERP_KERNEL::Exception);
+ static void WriteUMeshesPartitionDep(const char *fileName, const char *meshName, const std::vector<const ParaMEDMEM::MEDCouplingUMesh *>& meshes, bool writeFromScratch) throw(INTERP_KERNEL::Exception);
static void WriteUMeshes(const char *fileName, const std::vector<const ParaMEDMEM::MEDCouplingUMesh *>& meshes, bool writeFromScratch) throw(INTERP_KERNEL::Exception);
static void WriteField(const char *fileName, const ParaMEDMEM::MEDCouplingFieldDouble *f, bool writeFromScratch) throw(INTERP_KERNEL::Exception);
static void WriteFieldDep(const char *fileName, const ParaMEDMEM::MEDCouplingFieldDouble *f, bool writeFromScratch) throw(INTERP_KERNEL::Exception);
salomeinclude_HEADERS= \
MEDLoaderDefines.hxx \
-MEDLoader.hxx MEDLoaderBase.hxx
+MEDLoader.hxx MEDLoaderBase.hxx MEDFileUtilities.hxx MEDFileMesh.hxx MEDFileMeshLL.hxx \
+MEDFileMeshElt.hxx MEDFileBasis.hxx MEDFileField.hxx
dist_libmedloader_la_SOURCES= \
-MEDLoader.cxx MEDLoaderBase.cxx
+MEDLoader.cxx MEDLoaderBase.cxx MEDFileUtilities.cxx \
+MEDFileMesh.cxx MEDFileMeshElt.cxx MEDFileBasis.cxx \
+MEDFileMeshLL.cxx MEDFileField.cxx
libmedloader_la_CPPFLAGS= $(MED2_INCLUDES) $(HDF5_INCLUDES) @CXXTMPDPTHFLAGS@ \
-I$(srcdir)/../INTERP_KERNEL \
--- /dev/null
+// Copyright (C) 2007-2010 CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+%module MEDLoader
+
+#define MEDCOUPLING_EXPORT
+#define MEDLOADER_EXPORT
+
+%include "MEDCoupling.i"
+
+%{
+#include "MEDLoader.hxx"
+#include "MEDFileMesh.hxx"
+#include "MEDLoaderTypemaps.i"
+
+using namespace ParaMEDMEM;
+%}
+
+#if SWIG_VERSION >= 0x010329
+%template() std::vector<std::string>;
+#endif
+
+%typemap(out) ParaMEDMEM::MEDFileMesh*
+{
+ $result=convertMEDFileMesh($1,$owner);
+}
+
+%newobject MEDLoader::ReadUMeshFromFamilies;
+%newobject MEDLoader::ReadUMeshFromGroups;
+%newobject MEDLoader::ReadUMeshFromFile;
+%newobject MEDLoader::ReadField;
+%newobject MEDLoader::ReadFieldCell;
+%newobject MEDLoader::ReadFieldNode;
+%newobject MEDLoader::ReadFieldGauss;
+%newobject MEDLoader::ReadFieldGaussNE;
+%newobject ParaMEDMEM::MEDFileUMesh::New;
+%newobject ParaMEDMEM::MEDFileUMesh::getCoords;
+%newobject ParaMEDMEM::MEDFileUMesh::getGroup;
+%newobject ParaMEDMEM::MEDFileUMesh::getGroups;
+%newobject ParaMEDMEM::MEDFileUMesh::getFamily;
+%newobject ParaMEDMEM::MEDFileUMesh::getFamilies;
+%newobject ParaMEDMEM::MEDFileUMesh::getGroupArr;
+%newobject ParaMEDMEM::MEDFileUMesh::getGroupsArr;
+%newobject ParaMEDMEM::MEDFileUMesh::getFamilyArr;
+%newobject ParaMEDMEM::MEDFileUMesh::getFamiliesArr;
+%newobject ParaMEDMEM::MEDFileUMesh::getNodeGroupArr;
+%newobject ParaMEDMEM::MEDFileUMesh::getNodeGroupsArr;
+%newobject ParaMEDMEM::MEDFileUMesh::getNodeFamilyArr;
+%newobject ParaMEDMEM::MEDFileUMesh::getNodeFamiliesArr;
+%newobject ParaMEDMEM::MEDFileUMesh::getMeshAtLevel;
+%newobject ParaMEDMEM::MEDFileUMesh::getLevel0Mesh;
+%newobject ParaMEDMEM::MEDFileUMesh::getLevelM1Mesh;
+%newobject ParaMEDMEM::MEDFileUMesh::getLevelM2Mesh;
+%newobject ParaMEDMEM::MEDFileUMesh::getLevelM3Mesh;
+
+class MEDLoader
+{
+public:
+ static void setEpsilonForNodeComp(double val) throw(INTERP_KERNEL::Exception);
+ static void setCompPolicyForCell(int val) throw(INTERP_KERNEL::Exception);
+ static void setTooLongStrPolicy(int val) throw(INTERP_KERNEL::Exception);
+ static void CheckFileForRead(const char *fileName) throw(INTERP_KERNEL::Exception);
+ static std::vector<std::string> GetMeshNames(const char *fileName) throw(INTERP_KERNEL::Exception);
+ static std::vector<std::string> GetMeshNamesOnField(const char *fileName, const char *fieldName) throw(INTERP_KERNEL::Exception);
+ static std::vector<std::string> GetMeshGroupsNames(const char *fileName, const char *meshName) throw(INTERP_KERNEL::Exception);
+ static std::vector<std::string> GetMeshFamiliesNames(const char *fileName, const char *meshName) throw(INTERP_KERNEL::Exception);
+ static std::vector<std::string> GetMeshFamiliesNamesOnGroup(const char *fileName, const char *meshName, const char *grpName) throw(INTERP_KERNEL::Exception);
+ static std::vector<std::string> GetMeshGroupsNamesOnFamily(const char *fileName, const char *meshName, const char *famName) throw(INTERP_KERNEL::Exception);
+ static std::vector<std::string> GetAllFieldNamesOnMesh(const char *fileName, const char *meshName) throw(INTERP_KERNEL::Exception);
+ static std::vector<std::string> GetAllFieldNames(const char *fileName) throw(INTERP_KERNEL::Exception);
+ static std::vector<std::string> GetFieldNamesOnMesh(ParaMEDMEM::TypeOfField type, const char *fileName, const char *meshName) throw(INTERP_KERNEL::Exception);
+ static std::vector<std::string> GetCellFieldNamesOnMesh(const char *fileName, const char *meshName) throw(INTERP_KERNEL::Exception);
+ static std::vector<std::string> GetNodeFieldNamesOnMesh(const char *fileName, const char *meshName) throw(INTERP_KERNEL::Exception);
+ static double GetTimeAttachedOnFieldIteration(const char *fileName, const char *fieldName, int iteration, int order) throw(INTERP_KERNEL::Exception);
+ %extend
+ {
+ static PyObject *GetFieldIterations(ParaMEDMEM::TypeOfField type, const char *fileName, const char *meshName, const char *fieldName) throw(INTERP_KERNEL::Exception)
+ {
+ std::vector< std::pair<int,int> > res=MEDLoader::GetFieldIterations(type,fileName,meshName,fieldName);
+ PyObject *ret=PyList_New(res.size());
+ int rk=0;
+ for(std::vector< std::pair<int,int> >::const_iterator iter=res.begin();iter!=res.end();iter++,rk++)
+ {
+ PyObject *elt=PyTuple_New(2);
+ PyTuple_SetItem(elt,0,SWIG_From_int((*iter).first));
+ PyTuple_SetItem(elt,1,SWIG_From_int((*iter).second));
+ PyList_SetItem(ret,rk,elt);
+ }
+ return ret;
+ }
+
+ static PyObject *GetAllFieldIterations(const char *fileName, const char *meshName, const char *fieldName) throw(INTERP_KERNEL::Exception)
+ {
+ std::vector< std::pair< std::pair<int,int>, double> > res=MEDLoader::GetAllFieldIterations(fileName,meshName,fieldName);
+ PyObject *ret=PyList_New(res.size());
+ int rk=0;
+ for(std::vector< std::pair< std::pair<int,int>, double> >::const_iterator iter=res.begin();iter!=res.end();iter++,rk++)
+ {
+ PyObject *elt=PyTuple_New(3);
+ PyTuple_SetItem(elt,0,SWIG_From_int((*iter).first.first));
+ PyTuple_SetItem(elt,1,SWIG_From_int((*iter).first.second));
+ PyTuple_SetItem(elt,2,SWIG_From_double((*iter).second));
+ PyList_SetItem(ret,rk,elt);
+ }
+ return ret;
+ }
+
+ static PyObject *GetCellFieldIterations(const char *fileName, const char *meshName, const char *fieldName) throw(INTERP_KERNEL::Exception)
+ {
+ std::vector< std::pair<int,int> > res=MEDLoader::GetCellFieldIterations(fileName,meshName,fieldName);
+ PyObject *ret=PyList_New(res.size());
+ int rk=0;
+ for(std::vector< std::pair<int,int> >::const_iterator iter=res.begin();iter!=res.end();iter++,rk++)
+ {
+ PyObject *elt=PyTuple_New(2);
+ PyTuple_SetItem(elt,0,SWIG_From_int((*iter).first));
+ PyTuple_SetItem(elt,1,SWIG_From_int((*iter).second));
+ PyList_SetItem(ret,rk,elt);
+ }
+ return ret;
+ }
+ static PyObject *GetNodeFieldIterations(const char *fileName, const char *meshName, const char *fieldName) throw(INTERP_KERNEL::Exception)
+ {
+ std::vector< std::pair<int,int> > res=MEDLoader::GetNodeFieldIterations(fileName,meshName,fieldName);
+ PyObject *ret=PyList_New(res.size());
+ int rk=0;
+ for(std::vector< std::pair<int,int> >::const_iterator iter=res.begin();iter!=res.end();iter++,rk++)
+ {
+ PyObject *elt=PyTuple_New(2);
+ PyTuple_SetItem(elt,0,SWIG_From_int((*iter).first));
+ PyTuple_SetItem(elt,1,SWIG_From_int((*iter).second));
+ PyList_SetItem(ret,rk,elt);
+ }
+ return ret;
+ }
+ static PyObject *ReadFieldsOnSameMesh(ParaMEDMEM::TypeOfField type, const char *fileName, const char *meshName, int meshDimRelToMax,
+ const char *fieldName, PyObject *liIts) throw(INTERP_KERNEL::Exception)
+ {
+ std::vector<std::pair<int,int> > its=convertTimePairIdsFromPy(liIts);
+ std::vector<ParaMEDMEM::MEDCouplingFieldDouble *> res=MEDLoader::ReadFieldsOnSameMesh(type,fileName,meshName,meshDimRelToMax,fieldName,its);
+ return convertFieldDoubleVecToPy(res);
+ }
+ static void WriteUMeshesPartition(const char *fileName, const char *meshName, PyObject *li, bool writeFromScratch) throw(INTERP_KERNEL::Exception)
+ {
+ std::vector<const ParaMEDMEM::MEDCouplingUMesh *> v=convertUMeshVecFromPy(li);
+ MEDLoader::WriteUMeshesPartition(fileName,meshName,v,writeFromScratch);
+ }
+ static void WriteUMeshesPartitionDep(const char *fileName, const char *meshName, PyObject *li, bool writeFromScratch) throw(INTERP_KERNEL::Exception)
+ {
+ std::vector<const ParaMEDMEM::MEDCouplingUMesh *> v=convertUMeshVecFromPy(li);
+ MEDLoader::WriteUMeshesPartitionDep(fileName,meshName,v,writeFromScratch);
+ }
+ static void WriteUMeshes(const char *fileName, PyObject *li, bool writeFromScratch) throw(INTERP_KERNEL::Exception)
+ {
+ std::vector<const ParaMEDMEM::MEDCouplingUMesh *> v=convertUMeshVecFromPy(li);
+ MEDLoader::WriteUMeshes(fileName,v,writeFromScratch);
+ }
+ static PyObject *GetTypesOfField(const char *fileName, const char *meshName, const char *fieldName) throw(INTERP_KERNEL::Exception)
+ {
+ std::vector< ParaMEDMEM::TypeOfField > v=MEDLoader::GetTypesOfField(fileName,meshName,fieldName);
+ int size=v.size();
+ PyObject *ret=PyList_New(size);
+ for(int i=0;i<size;i++)
+ PyList_SetItem(ret,i,PyInt_FromLong((int)v[i]));
+ return ret;
+ }
+ static ParaMEDMEM::MEDCouplingUMesh *ReadUMeshFromGroups(const char *fileName, const char *meshName, int meshDimRelToMax, PyObject *li) throw(INTERP_KERNEL::Exception)
+ {
+ std::vector<std::string> grps;
+ converPyListToVecString(li,grps);
+ return MEDLoader::ReadUMeshFromGroups(fileName,meshName,meshDimRelToMax,grps);
+ }
+ static ParaMEDMEM::MEDCouplingUMesh *ReadUMeshFromFamilies(const char *fileName, const char *meshName, int meshDimRelToMax, PyObject *li) throw(INTERP_KERNEL::Exception)
+ {
+ std::vector<std::string> fams;
+ converPyListToVecString(li,fams);
+ return MEDLoader::ReadUMeshFromFamilies(fileName,meshName,meshDimRelToMax,fams);
+ }
+ }
+ static ParaMEDMEM::MEDCouplingUMesh *ReadUMeshFromFile(const char *fileName, const char *meshName, int meshDimRelToMax=0) throw(INTERP_KERNEL::Exception);
+ static ParaMEDMEM::MEDCouplingUMesh *ReadUMeshFromFile(const char *fileName, int meshDimRelToMax=0) throw(INTERP_KERNEL::Exception);
+ static ParaMEDMEM::MEDCouplingFieldDouble *ReadField(ParaMEDMEM::TypeOfField type, const char *fileName, const char *meshName, int meshDimRelToMax, const char *fieldName, int iteration, int order) throw(INTERP_KERNEL::Exception);
+ static ParaMEDMEM::MEDCouplingFieldDouble *ReadFieldCell(const char *fileName, const char *meshName, int meshDimRelToMax, const char *fieldName, int iteration, int order) throw(INTERP_KERNEL::Exception);
+ static ParaMEDMEM::MEDCouplingFieldDouble *ReadFieldNode(const char *fileName, const char *meshName, int meshDimRelToMax, const char *fieldName, int iteration, int order) throw(INTERP_KERNEL::Exception);
+ static ParaMEDMEM::MEDCouplingFieldDouble *ReadFieldGauss(const char *fileName, const char *meshName, int meshDimRelToMax, const char *fieldName, int iteration, int order) throw(INTERP_KERNEL::Exception);
+ static ParaMEDMEM::MEDCouplingFieldDouble *ReadFieldGaussNE(const char *fileName, const char *meshName, int meshDimRelToMax, const char *fieldName, int iteration, int order) throw(INTERP_KERNEL::Exception);
+ static void WriteUMesh(const char *fileName, const ParaMEDMEM::MEDCouplingUMesh *mesh, bool writeFromScratch) throw(INTERP_KERNEL::Exception);
+ static void WriteUMeshDep(const char *fileName, const ParaMEDMEM::MEDCouplingUMesh *mesh, bool writeFromScratch) throw(INTERP_KERNEL::Exception);
+ static void WriteField(const char *fileName, const ParaMEDMEM::MEDCouplingFieldDouble *f, bool writeFromScratch) throw(INTERP_KERNEL::Exception);
+ static void WriteFieldDep(const char *fileName, const ParaMEDMEM::MEDCouplingFieldDouble *f, bool writeFromScratch) throw(INTERP_KERNEL::Exception);
+ static void WriteFieldUsingAlreadyWrittenMesh(const char *fileName, const ParaMEDMEM::MEDCouplingFieldDouble *f) throw(INTERP_KERNEL::Exception);
+};
+
+%include "MEDFileMesh.hxx"
+
+%extend ParaMEDMEM::MEDFileUMesh
+{
+ void setGroupsAtLevel(int meshDimRelToMaxExt, PyObject *li, bool renum=false) throw(INTERP_KERNEL::Exception)
+ {
+ std::vector<const DataArrayInt *> grps;
+ convertPyObjToVecDataArrayIntCst(li,grps);
+ self->setGroupsAtLevel(meshDimRelToMaxExt,grps,renum);
+ }
+}
# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
#
-from libMEDLoader_Swig import *
+from MEDLoader import *
from math import pi,e,sqrt
class MEDLoaderDataForTest:
targetMesh.setName("2DMesh_2");
targetMesh.insertNextCell(NORM_TRI3,3,targetConn[0:3])
targetMesh.insertNextCell(NORM_TRI3,3,targetConn[3:6])
- targetMesh.insertNextCell(NORM_TRI6,6,targetConn[6:12])
targetMesh.insertNextCell(NORM_QUAD4,4,targetConn[12:16])
targetMesh.insertNextCell(NORM_QUAD4,4,targetConn[16:20])
+ targetMesh.insertNextCell(NORM_TRI6,6,targetConn[6:12])
targetMesh.finishInsertingCells();
myCoords=DataArrayDouble.New();
myCoords.setValues(targetCoords,12,2);
targetMesh.setName("3DSurfMesh_1");
targetMesh.insertNextCell(NORM_TRI3,3,targetConn[0:3])
targetMesh.insertNextCell(NORM_TRI3,3,targetConn[3:6])
- targetMesh.insertNextCell(NORM_TRI6,6,targetConn[6:12])
targetMesh.insertNextCell(NORM_QUAD4,4,targetConn[12:16])
targetMesh.insertNextCell(NORM_QUAD4,4,targetConn[16:20])
+ targetMesh.insertNextCell(NORM_TRI6,6,targetConn[6:12])
targetMesh.insertNextCell(NORM_POLYGON,4,targetConn[20:24])
targetMesh.finishInsertingCells();
myCoords=DataArrayDouble.New();
def build3DMesh_2(cls):
m3dsurfBase=MEDLoaderDataForTest.build3DSurfMesh_1();
- numbers=[0,1,3,4,5]
+ numbers=[0,1,2,3,5]
m3dsurf=m3dsurfBase.buildPartOfMySelf(numbers,False);
m1dBase=MEDLoaderDataForTest.build1DMesh_1();
numbers2=[0,1,2,3]
vec=[0.,1.,0.]
pt=[0.,0.,0.]
m1d.rotate(pt,vec,-pi/2.);
- ret=m3dsurf.buildExtrudedMeshFromThis(m1d,0);
+ ret=m3dsurf.buildExtrudedMesh(m1d,0);
return ret;
def buildVecFieldOnCells_1(cls):
refCoo2=[-1.0,1.0, -1.0,-1.0, 1.0,-1.0, -1.0,0.0, 0.0,-1.0, 0.0,0.0 ]
_refCoo2=refCoo2;
_gsCoo1=_gsCoo1[0:6];
+ _gsCoo2=_gsCoo1
_wg1=_wg1[0:3];
- f.setGaussLocalizationOnType(NORM_TRI6,_refCoo2,_gsCoo1,_wg1);
+ _wg2=_wg1
refCoo3=[ 0.,0., 1.,0., 1.,1., 0.,1. ]
_refCoo3=refCoo3;
_gsCoo1=_gsCoo1[0:4];
_wg1=_wg1[0:2];
f.setGaussLocalizationOnType(NORM_QUAD4,_refCoo3,_gsCoo1,_wg1);
+ f.setGaussLocalizationOnType(NORM_TRI6,_refCoo2,_gsCoo2,_wg2);
array=DataArrayDouble.New();
array.alloc(19,2);
ptr=array.getPointer();
# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
#
-from libMEDLoader_Swig import *
+import MEDLoader
import unittest
from math import pi,e,sqrt
from MEDLoaderDataForTest import MEDLoaderDataForTest
def testMesh1DRW(self):
mesh=MEDLoaderDataForTest.build1DMesh_1();
mesh.checkCoherency();
- MEDLoader.WriteUMesh("Pyfile1.med",mesh,True);
- mesh_rw=MEDLoader.ReadUMeshFromFile("Pyfile1.med",mesh.getName(),0);
+ MEDLoader.MEDLoader.WriteUMesh("Pyfile1.med",mesh,True);
+ mesh_rw=MEDLoader.MEDLoader.ReadUMeshFromFile("Pyfile1.med",mesh.getName(),0);
self.assertTrue(mesh.isEqual(mesh_rw,1e-12));
pass
def testMesh2DCurveRW(self):
mesh=MEDLoaderDataForTest.build2DCurveMesh_1();
mesh.checkCoherency();
- MEDLoader.WriteUMesh("Pyfile2.med",mesh,True);
- mesh_rw=MEDLoader.ReadUMeshFromFile("Pyfile2.med",mesh.getName(),0);
+ MEDLoader.MEDLoader.WriteUMesh("Pyfile2.med",mesh,True);
+ mesh_rw=MEDLoader.MEDLoader.ReadUMeshFromFile("Pyfile2.med",mesh.getName(),0);
self.assertTrue(mesh.isEqual(mesh_rw,1e-12));
pass
def testMesh2DRW(self):
mesh=MEDLoaderDataForTest.build2DMesh_1();
mesh.checkCoherency();
- MEDLoader.WriteUMesh("Pyfile3.med",mesh,True);
- mesh_rw=MEDLoader.ReadUMeshFromFile("Pyfile3.med",mesh.getName(),0);
+ MEDLoader.MEDLoader.WriteUMesh("Pyfile3.med",mesh,True);
+ mesh_rw=MEDLoader.MEDLoader.ReadUMeshFromFile("Pyfile3.med",mesh.getName(),0);
self.assertTrue(mesh.isEqual(mesh_rw,1e-12));
pass
def testMesh3DSurfRW(self):
mesh=MEDLoaderDataForTest.build3DSurfMesh_1();
mesh.checkCoherency();
- MEDLoader.WriteUMesh("Pyfile4.med",mesh,True);
- mesh_rw=MEDLoader.ReadUMeshFromFile("Pyfile4.med",mesh.getName(),0);
+ MEDLoader.MEDLoader.WriteUMesh("Pyfile4.med",mesh,True);
+ mesh_rw=MEDLoader.MEDLoader.ReadUMeshFromFile("Pyfile4.med",mesh.getName(),0);
self.assertTrue(mesh.isEqual(mesh_rw,1e-12));
pass
def testMesh3DRW(self):
mesh=MEDLoaderDataForTest.build3DMesh_1();
mesh.checkCoherency();
- MEDLoader.WriteUMesh("Pyfile5.med",mesh,True);
- mesh_rw=MEDLoader.ReadUMeshFromFile("Pyfile5.med",mesh.getName(),0);
+ MEDLoader.MEDLoader.WriteUMesh("Pyfile5.med",mesh,True);
+ mesh_rw=MEDLoader.MEDLoader.ReadUMeshFromFile("Pyfile5.med",mesh.getName(),0);
self.assertTrue(mesh.isEqual(mesh_rw,1e-12));
pass
def testFieldRW1(self):
f1=MEDLoaderDataForTest.buildVecFieldOnCells_1();
- MEDLoader.WriteField("Pyfile6.med",f1,True);
- f2=MEDLoader.ReadFieldCell("Pyfile6.med",f1.getMesh().getName(),0,f1.getName(),0,1);
+ MEDLoader.MEDLoader.WriteField("Pyfile6.med",f1,True);
+ f2=MEDLoader.MEDLoader.ReadFieldCell("Pyfile6.med",f1.getMesh().getName(),0,f1.getName(),0,1);
self.assertTrue(f1.isEqual(f2,1e-12,1e-12));
#
f1=MEDLoaderDataForTest.buildVecFieldOnNodes_1();
- MEDLoader.WriteField("Pyfile7.med",f1,True);
- f2=MEDLoader.ReadFieldNode("Pyfile7.med",f1.getMesh().getName(),0,f1.getName(),2,3);
+ MEDLoader.MEDLoader.WriteField("Pyfile7.med",f1,True);
+ f2=MEDLoader.MEDLoader.ReadFieldNode("Pyfile7.med",f1.getMesh().getName(),0,f1.getName(),2,3);
self.assertTrue(f1.isEqual(f2,1e-12,1e-12));
pass
VAL1=12345.67890314;
VAL2=-1111111111111.;
f1=MEDLoaderDataForTest.buildVecFieldOnCells_1();
- MEDLoader.WriteField(fileName,f1,True);
+ MEDLoader.MEDLoader.WriteField(fileName,f1,True);
f1.setTime(10.,8,9);
f1.getArray().setIJ(0,0,VAL1);
- MEDLoader.WriteFieldUsingAlreadyWrittenMesh(fileName,f1);
+ MEDLoader.MEDLoader.WriteFieldUsingAlreadyWrittenMesh(fileName,f1);
f1.setTime(10.14,18,19);
f1.getArray().setIJ(0,0,VAL2);
- MEDLoader.WriteFieldUsingAlreadyWrittenMesh(fileName,f1);
+ MEDLoader.MEDLoader.WriteFieldUsingAlreadyWrittenMesh(fileName,f1);
#retrieving time steps...
- f2=MEDLoader.ReadFieldCell(fileName,f1.getMesh().getName(),0,f1.getName(),8,9);
+ f2=MEDLoader.MEDLoader.ReadFieldCell(fileName,f1.getMesh().getName(),0,f1.getName(),8,9);
f1.setTime(10.,8,9);
f1.getArray().setIJ(0,0,VAL1);
self.assertTrue(f1.isEqual(f2,1e-12,1e-12));
- f2=MEDLoader.ReadFieldCell(fileName,f1.getMesh().getName(),0,f1.getName(),0,1);
+ f2=MEDLoader.MEDLoader.ReadFieldCell(fileName,f1.getMesh().getName(),0,f1.getName(),0,1);
f3=MEDLoaderDataForTest.buildVecFieldOnCells_1();
self.assertTrue(f3.isEqual(f2,1e-12,1e-12));
- f2=MEDLoader.ReadFieldCell(fileName,f1.getMesh().getName(),0,f1.getName(),18,19);
+ f2=MEDLoader.MEDLoader.ReadFieldCell(fileName,f1.getMesh().getName(),0,f1.getName(),18,19);
f1.setTime(10.14,18,19);
f1.getArray().setIJ(0,0,VAL2);
self.assertTrue(f1.isEqual(f2,1e-12,1e-12));
#test of throw on invalid (dt,it)
- self.assertRaises(Exception,MEDLoader.ReadFieldCell,fileName,f1.getMesh().getName(),0,f1.getName(),28,19);
+ self.assertRaises(Exception,MEDLoader.MEDLoader.ReadFieldCell,fileName,f1.getMesh().getName(),0,f1.getName(),28,19);
#ON NODES
f1=MEDLoaderDataForTest.buildVecFieldOnNodes_1();
fileName2="Pyfile9.med";
- MEDLoader.WriteField(fileName2,f1,True);
+ MEDLoader.MEDLoader.WriteField(fileName2,f1,True);
f1.setTime(110.,108,109);
tmp=f1.getArray().getPointer();
f1.getArray().setIJ(0,3,VAL1);
- MEDLoader.WriteFieldUsingAlreadyWrittenMesh(fileName2,f1);
+ MEDLoader.MEDLoader.WriteFieldUsingAlreadyWrittenMesh(fileName2,f1);
f1.setTime(210.,208,209);
f1.getArray().setIJ(0,3,VAL2);
- MEDLoader.WriteFieldUsingAlreadyWrittenMesh(fileName2,f1);
- f2=MEDLoader.ReadFieldNode(fileName2,f1.getMesh().getName(),0,f1.getName(),108,109);
+ MEDLoader.MEDLoader.WriteFieldUsingAlreadyWrittenMesh(fileName2,f1);
+ f2=MEDLoader.MEDLoader.ReadFieldNode(fileName2,f1.getMesh().getName(),0,f1.getName(),108,109);
f1.setTime(110.,108,109);
f1.getArray().setIJ(0,3,VAL1);
self.assertTrue(f1.isEqual(f2,1e-12,1e-12));
- f2=MEDLoader.ReadFieldNode(fileName2,f1.getMesh().getName(),0,f1.getName(),2,3);
+ f2=MEDLoader.MEDLoader.ReadFieldNode(fileName2,f1.getMesh().getName(),0,f1.getName(),2,3);
f3=MEDLoaderDataForTest.buildVecFieldOnNodes_1();
self.assertTrue(f3.isEqual(f2,1e-12,1e-12));
- f2=MEDLoader.ReadFieldNode(fileName2,f1.getMesh().getName(),0,f1.getName(),208,209);
+ f2=MEDLoader.MEDLoader.ReadFieldNode(fileName2,f1.getMesh().getName(),0,f1.getName(),208,209);
f1.setTime(210.,208,209);
f1.getArray().setIJ(0,3,VAL2);
self.assertTrue(f1.isEqual(f2,1e-12,1e-12));
f1.setTime(10.,8,9);
tmp=f1.getArray().getPointer();
f1.getArray().setIJ(0,0,VAL1);
- MEDLoader.WriteField(fileName,f1,True);
+ MEDLoader.MEDLoader.WriteField(fileName,f1,True);
f1.setTime(10.14,18,19);
f1.getArray().setIJ(0,0,VAL2);
- MEDLoader.WriteFieldUsingAlreadyWrittenMesh(fileName,f1);
+ MEDLoader.MEDLoader.WriteFieldUsingAlreadyWrittenMesh(fileName,f1);
f1.getMesh().setName(name2);
f1.setTime(10.55,28,29);
f1.getArray().setIJ(0,0,3*VAL1);
- MEDLoader.WriteField(fileName,f1,False);
- vec=MEDLoader.GetMeshNamesOnField(fileName,name1);
+ MEDLoader.MEDLoader.WriteField(fileName,f1,False);
+ vec=MEDLoader.MEDLoader.GetMeshNamesOnField(fileName,name1);
self.assertEqual(2,len(vec));
self.assertTrue(vec[0]==name3);
self.assertTrue(vec[1]==name2);
f1.setTime(10.66,38,39);
f1.getArray().setIJ(0,0,3*VAL2);
- MEDLoader.WriteFieldUsingAlreadyWrittenMesh(fileName,f1);
+ MEDLoader.MEDLoader.WriteFieldUsingAlreadyWrittenMesh(fileName,f1);
f1.setTime(10.77,48,49);
f1.getArray().setIJ(0,0,4*VAL2);
- MEDLoader.WriteFieldUsingAlreadyWrittenMesh(fileName,f1);
+ MEDLoader.MEDLoader.WriteFieldUsingAlreadyWrittenMesh(fileName,f1);
#ON NODES
f1=MEDLoaderDataForTest.buildVecFieldOnNodes_1();
f1.setName(name1);
f1.getMesh().setName(name2);
f1.setTime(110.,8,9);
- MEDLoader.WriteFieldUsingAlreadyWrittenMesh(fileName,f1);
+ MEDLoader.MEDLoader.WriteFieldUsingAlreadyWrittenMesh(fileName,f1);
f1.setTime(110.,108,109);
tmp=f1.getArray().getPointer();
f1.getArray().setIJ(0,3,VAL1);
- MEDLoader.WriteFieldUsingAlreadyWrittenMesh(fileName,f1);
+ MEDLoader.MEDLoader.WriteFieldUsingAlreadyWrittenMesh(fileName,f1);
f1.setTime(210.,208,209);
f1.getArray().setIJ(0,3,VAL2);
- MEDLoader.WriteFieldUsingAlreadyWrittenMesh(fileName,f1);
+ MEDLoader.MEDLoader.WriteFieldUsingAlreadyWrittenMesh(fileName,f1);
#
- it1=MEDLoader.GetCellFieldIterations(fileName,name3,name1);
+ it1=MEDLoader.MEDLoader.GetCellFieldIterations(fileName,name3,name1);
self.assertEqual(2,len(it1));
self.assertEqual(8,it1[0][0]); self.assertEqual(9,it1[0][1]);
self.assertEqual(18,it1[1][0]); self.assertEqual(19,it1[1][1]);
- it2=MEDLoader.GetCellFieldIterations(fileName,name2,name1);
+ it2=MEDLoader.MEDLoader.GetCellFieldIterations(fileName,name2,name1);
self.assertEqual(3,len(it2));
self.assertEqual(28,it2[0][0]); self.assertEqual(29,it2[0][1]);
self.assertEqual(38,it2[1][0]); self.assertEqual(39,it2[1][1]);
self.assertEqual(48,it2[2][0]); self.assertEqual(49,it2[2][1]);
- it3=MEDLoader.GetNodeFieldIterations(fileName,name2,name1);
+ it3=MEDLoader.MEDLoader.GetNodeFieldIterations(fileName,name2,name1);
self.assertEqual(3,len(it3));
self.assertEqual(8,it3[0][0]); self.assertEqual(9,it3[0][1]);
self.assertEqual(108,it3[1][0]); self.assertEqual(109,it3[1][1]);
self.assertEqual(208,it3[2][0]); self.assertEqual(209,it3[2][1]);
- it4=MEDLoader.GetNodeFieldIterations(fileName,name3,name1);
+ it4=MEDLoader.MEDLoader.GetNodeFieldIterations(fileName,name3,name1);
self.assertTrue(len(it4)==0);
#
#
- f1=MEDLoader.ReadFieldCell(fileName,name3,0,name1,8,9);
+ f1=MEDLoader.MEDLoader.ReadFieldCell(fileName,name3,0,name1,8,9);
self.assertAlmostEqual(VAL1,f1.getArray().getIJ(0,0),13);
- f1=MEDLoader.ReadFieldCell(fileName,name3,0,name1,18,19);
+ f1=MEDLoader.MEDLoader.ReadFieldCell(fileName,name3,0,name1,18,19);
self.assertAlmostEqual(VAL2,f1.getArray().getIJ(0,0),13);
- f1=MEDLoader.ReadFieldCell(fileName,name2,0,name1,28,29);
+ f1=MEDLoader.MEDLoader.ReadFieldCell(fileName,name2,0,name1,28,29);
self.assertAlmostEqual(3*VAL1,f1.getArray().getIJ(0,0),13);
- f1=MEDLoader.ReadFieldCell(fileName,name2,0,name1,38,39);
+ f1=MEDLoader.MEDLoader.ReadFieldCell(fileName,name2,0,name1,38,39);
self.assertAlmostEqual(3*VAL2,f1.getArray().getIJ(0,0),13);
- f1=MEDLoader.ReadFieldCell(fileName,name2,0,name1,48,49);
+ f1=MEDLoader.MEDLoader.ReadFieldCell(fileName,name2,0,name1,48,49);
self.assertAlmostEqual(4*VAL2,f1.getArray().getIJ(0,0),13);
#
- f1=MEDLoader.ReadFieldNode(fileName,name2,0,name1,8,9);
+ f1=MEDLoader.MEDLoader.ReadFieldNode(fileName,name2,0,name1,8,9);
self.assertAlmostEqual(71.,f1.getArray().getIJ(0,3),13);
- f1=MEDLoader.ReadFieldNode(fileName,name2,0,name1,108,109);
+ f1=MEDLoader.MEDLoader.ReadFieldNode(fileName,name2,0,name1,108,109);
self.assertAlmostEqual(VAL1,f1.getArray().getIJ(0,3),13);
- f1=MEDLoader.ReadFieldNode(fileName,name2,0,name1,208,209);
+ f1=MEDLoader.MEDLoader.ReadFieldNode(fileName,name2,0,name1,208,209);
self.assertAlmostEqual(VAL2,f1.getArray().getIJ(0,3),13);
pass
part2=[3,4,13,14]
mesh3=mesh1.buildPartOfMySelf(part2,True);
mesh3.setName("mesh3");
- mesh4=MEDCouplingUMesh.New();
+ mesh4=MEDLoader.MEDCouplingUMesh.New();
mesh4.setName("mesh4");
mesh4.setMeshDimension(3);
mesh4.allocateCells(1);
conn=[0,11,1,3]
- mesh4.insertNextCell(NORM_TETRA4,4,conn[0:4])
+ mesh4.insertNextCell(MEDLoader.NORM_TETRA4,4,conn[0:4])
mesh4.finishInsertingCells();
mesh4.setCoords(mesh1.getCoords());
meshes=[mesh1,mesh2,mesh3,mesh4]
mnane="3DToto";
- MEDLoader.WriteUMeshesPartition(fileName,mnane,meshes,True);
+ MEDLoader.MEDLoader.WriteUMeshesPartition(fileName,mnane,meshes,True);
#
- mesh5=MEDLoader.ReadUMeshFromFile(fileName,mnane);
+ mesh5=MEDLoader.MEDLoader.ReadUMeshFromFile(fileName,mnane);
mesh1.setName(mnane);
part3=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17]
mesh6=mesh5.buildPartOfMySelf(part3,True);
mesh6.setName(mnane);
self.assertTrue(mesh6.isEqual(mesh1,1e-12));
- grps=MEDLoader.GetMeshGroupsNames(fileName,mnane);
+ grps=MEDLoader.MEDLoader.GetMeshGroupsNames(fileName,mnane);
self.assertEqual(4,len(grps));
grps.index("mesh2");
grps.index("mesh3");
grps.index("mesh4");
grps.index("3DMesh_1");
#
- vec=["mesh2"];
- mesh2_2=MEDLoader.ReadUMeshFromGroups(fileName,mnane,0,vec);
+ vec=("mesh2",);
+ mesh2_2=MEDLoader.MEDLoader.ReadUMeshFromGroups(fileName,mnane,0,vec);
self.assertTrue(mesh2_2.isEqual(mesh2,1e-12));
vec=["mesh3"];
- mesh3_2=MEDLoader.ReadUMeshFromGroups(fileName,mnane,0,vec);
+ mesh3_2=MEDLoader.MEDLoader.ReadUMeshFromGroups(fileName,mnane,0,vec);
self.assertTrue(mesh3_2.isEqual(mesh3,1e-12));
vec=["mesh4"];
- mesh4_2=MEDLoader.ReadUMeshFromGroups(fileName,mnane,0,vec);
+ mesh4_2=MEDLoader.MEDLoader.ReadUMeshFromGroups(fileName,mnane,0,vec);
self.assertTrue(mesh4_2.isEqual(mesh4,1e-12));
- vec=["3DMesh_1"];
- mesh1_2=MEDLoader.ReadUMeshFromGroups(fileName,mnane,0,vec);
+ vec="3DMesh_1";
+ mesh1_2=MEDLoader.MEDLoader.ReadUMeshFromGroups(fileName,mnane,0,vec);
mesh1.setName("3DMesh_1");
self.assertTrue(mesh1_2.isEqual(mesh1,1e-12));
#
vec=["Family_4","Family_2"];
- mesh2_2=MEDLoader.ReadUMeshFromFamilies(fileName,mnane,0,vec);
+ mesh2_2=MEDLoader.MEDLoader.ReadUMeshFromFamilies(fileName,mnane,0,vec);
mesh2_2.setName("mesh2");
self.assertTrue(mesh2_2.isEqual(mesh2,1e-12));
+ #
+ ret=MEDLoader.MEDLoader.GetMeshFamiliesNamesOnGroup(fileName,"3DToto","3DMesh_1");
+ self.assertEqual(4,len(ret));
+ self.assertEqual(ret[0],"Family_1");
+ self.assertEqual(ret[1],"Family_2");
+ self.assertEqual(ret[2],"Family_3");
+ self.assertEqual(ret[3],"Family_4");
+ #
+ ret1=MEDLoader.MEDLoader.GetMeshGroupsNamesOnFamily(fileName,"3DToto","Family_2");
+ self.assertEqual(2,len(ret1));
+ self.assertEqual(ret1[0],"3DMesh_1");
+ self.assertEqual(ret1[1],"mesh2");
pass
def testFieldProfilRW1(self):
fileName="Pyfile12.med";
mesh1=MEDLoaderDataForTest.build3DMesh_1();
da,b,newNbOfNodes=mesh1.mergeNodes(1e-12);
- MEDLoader.WriteUMesh(fileName,mesh1,True);
+ MEDLoader.MEDLoader.WriteUMesh(fileName,mesh1,True);
part1=[1,2,4,13,15]
mesh2=mesh1.buildPartOfMySelf(part1,True);
mesh2.setName(mesh1.getName());#<- important for the test
#
nbOfCells=mesh2.getNumberOfCells();
self.assertEqual(5,nbOfCells);
- f1=MEDCouplingFieldDouble.New(ON_CELLS,ONE_TIME);
+ f1=MEDLoader.MEDCouplingFieldDouble.New(MEDLoader.ON_CELLS,MEDLoader.ONE_TIME);
f1.setName("VectorFieldOnCells");
f1.setMesh(mesh2);
- array=DataArrayDouble.New();
+ array=MEDLoader.DataArrayDouble.New();
array.alloc(nbOfCells,2);
f1.setArray(array);
arr1=[71.,171.,10.,110.,20.,120.,30.,130.,40.,140.]
f1.setTime(3.14,2,7);
f1.checkCoherency();
#
- MEDLoader.WriteField(fileName,f1,False);#<- False important for the test
+ MEDLoader.MEDLoader.WriteField(fileName,f1,False);#<- False important for the test
#
- f2=MEDLoader.ReadFieldCell(fileName,f1.getMesh().getName(),0,f1.getName(),2,7);
+ f2=MEDLoader.MEDLoader.ReadFieldCell(fileName,f1.getMesh().getName(),0,f1.getName(),2,7);
f2.checkCoherency();
self.assertTrue(f1.isEqual(f2,1e-12,1e-12));
#
def testFieldGaussRW1(self):
fileName="Pyfile13.med";
f1=MEDLoaderDataForTest.buildVecFieldOnGauss_1();
- MEDLoader.WriteField(fileName,f1,True);
- f2=MEDLoader.ReadField(ON_GAUSS_PT,fileName,f1.getMesh().getName(),0,f1.getName(),1,5);
+ MEDLoader.MEDLoader.WriteField(fileName,f1,True);
+ f2=MEDLoader.MEDLoader.ReadField(MEDLoader.ON_GAUSS_PT,fileName,f1.getMesh().getName(),0,f1.getName(),1,5);
self.assertTrue(f1.isEqual(f2,1e-12,1e-12));
pass
def testFieldGaussNERW1(self):
fileName="Pyfile14.med";
f1=MEDLoaderDataForTest.buildVecFieldOnGaussNE_1();
- MEDLoader.WriteField(fileName,f1,True);
- f2=MEDLoader.ReadField(ON_GAUSS_NE,fileName,f1.getMesh().getName(),0,f1.getName(),1,5);
+ MEDLoader.MEDLoader.WriteField(fileName,f1,True);
+ f2=MEDLoader.MEDLoader.ReadField(MEDLoader.ON_GAUSS_NE,fileName,f1.getMesh().getName(),0,f1.getName(),1,5);
self.assertTrue(f1.isEqual(f2,1e-12,1e-12));
pass
renumber1=[2,5,1,0,3,4]
mesh.renumberCells(renumber1,False);
mesh.checkCoherency();
- MEDLoader.WriteUMesh(fileName,mesh,True);
- mesh_rw=MEDLoader.ReadUMeshFromFile(fileName,mesh.getName(),0);
+ MEDLoader.MEDLoader.WriteUMesh(fileName,mesh,True);
+ mesh_rw=MEDLoader.MEDLoader.ReadUMeshFromFile(fileName,mesh.getName(),0);
self.assertTrue(mesh.isEqual(mesh_rw,1e-12));
pass
m.renumberCells(renum,False);
m.orientCorrectlyPolyhedrons();
# Writing
- MEDLoader.WriteUMesh(fileName,m,True);
+ MEDLoader.MEDLoader.WriteUMesh(fileName,m,True);
f1Tmp=m.getMeasureField(False);
- f1=f1Tmp.buildNewTimeReprFromThis(ONE_TIME,False);
+ f1=f1Tmp.buildNewTimeReprFromThis(MEDLoader.ONE_TIME,False);
f1.setTime(0.,1,2);
f_1=f1.cloneWithMesh(True);
- MEDLoader.WriteFieldUsingAlreadyWrittenMesh(fileName,f1);
+ MEDLoader.MEDLoader.WriteFieldUsingAlreadyWrittenMesh(fileName,f1);
f1.applyFunc("2*x");
f1.setTime(0.01,3,4);
f_2=f1.cloneWithMesh(True);
- MEDLoader.WriteFieldUsingAlreadyWrittenMesh(fileName,f1);
+ MEDLoader.MEDLoader.WriteFieldUsingAlreadyWrittenMesh(fileName,f1);
f1.applyFunc("2*x/3");
f1.setTime(0.02,5,6);
f_3=f1.cloneWithMesh(True);
- MEDLoader.WriteFieldUsingAlreadyWrittenMesh(fileName,f1);
+ MEDLoader.MEDLoader.WriteFieldUsingAlreadyWrittenMesh(fileName,f1);
# Reading
its=[(1,2),(3,4),(5,6)];
- fs=MEDLoader.ReadFieldsOnSameMesh(ON_CELLS,fileName,f_1.getMesh().getName(),0,f_1.getName(),its);
+ fs=MEDLoader.MEDLoader.ReadFieldsOnSameMesh(MEDLoader.ON_CELLS,fileName,f_1.getMesh().getName(),0,f_1.getName(),its);
self.assertEqual(3,len(fs));
self.assertTrue(fs[0].isEqual(f_1,1e-12,1e-12));
self.assertTrue(fs[1].isEqual(f_2,1e-12,1e-12));
m2d.renumberCells(renumber,False);
m2d.setName("ExampleOfMultiDimW");
meshes=[m2d,m3d]
- MEDLoader.WriteUMeshes(fileName,meshes,True);
- m3d_bis=MEDLoader.ReadUMeshFromFile(fileName,m2d.getName(),0);
+ MEDLoader.MEDLoader.WriteUMeshes(fileName,meshes,True);
+ m3d_bis=MEDLoader.MEDLoader.ReadUMeshFromFile(fileName,m2d.getName(),0);
self.assertTrue(not m3d_bis.isEqual(m3d,1e-12));
m3d_bis.setName(m3d.getName());
self.assertTrue(m3d_bis.isEqual(m3d,1e-12));
- m2d_bis=MEDLoader.ReadUMeshFromFile(fileName,m2d.getName(),-1);#-1 for faces
+ m2d_bis=MEDLoader.MEDLoader.ReadUMeshFromFile(fileName,m2d.getName(),-1);#-1 for faces
self.assertTrue(m2d_bis.isEqual(m2d,1e-12));
# Creation of a field on faces.
- f1=MEDCouplingFieldDouble.New(ON_CELLS,ONE_TIME);
+ f1=MEDLoader.MEDCouplingFieldDouble.New(MEDLoader.ON_CELLS,MEDLoader.ONE_TIME);
f1.setName("FieldOnFacesShuffle");
f1.setMesh(m2d);
- array=DataArrayDouble.New();
+ array=MEDLoader.DataArrayDouble.New();
arr1=[71.,171.,10.,110.,20.,120.,30.,130.,40.,140.]
array.setValues(arr1,m2d.getNumberOfCells(),2);
array.setInfoOnComponent(0,"plkj (mm)");
tmp=array.setValues(arr1,m2d.getNumberOfCells(),2);
f1.setTime(3.14,2,7);
f1.checkCoherency();
- MEDLoader.WriteFieldUsingAlreadyWrittenMesh(fileName,f1);
- f2=MEDLoader.ReadFieldCell(fileName,f1.getMesh().getName(),-1,f1.getName(),2,7);
+ MEDLoader.MEDLoader.WriteFieldUsingAlreadyWrittenMesh(fileName,f1);
+ f2=MEDLoader.MEDLoader.ReadFieldCell(fileName,f1.getMesh().getName(),-1,f1.getName(),2,7);
self.assertTrue(f2.isEqual(f1,1e-12,1e-12));
pass
fileName2="Pyfile20.med";
m=MEDLoaderDataForTest.build2DMesh_1();
nbOfNodes=m.getNumberOfNodes();
- MEDLoader.WriteUMesh(fileName,m,True);
- f1=MEDCouplingFieldDouble.New(ON_NODES,ONE_TIME);
+ MEDLoader.MEDLoader.WriteUMesh(fileName,m,True);
+ f1=MEDLoader.MEDCouplingFieldDouble.New(MEDLoader.ON_NODES,MEDLoader.ONE_TIME);
f1.setName("VFieldOnNodes");
f1.setMesh(m);
- array=DataArrayDouble.New();
+ array=MEDLoader.DataArrayDouble.New();
arr1=[1.,101.,2.,102.,3.,103.,4.,104.,5.,105.,6.,106.,7.,107.,8.,108.,9.,109.,10.,110.,11.,111.,12.,112.]
array.setValues(arr1,nbOfNodes,2);
f1.setArray(array);
arr2=[2,4,5,3,6,7]
f2=f1.buildSubPart(arr2);
f2.getMesh().setName(f1.getMesh().getName());
- MEDLoader.WriteField(fileName,f2,False);#<- False important for the test
+ MEDLoader.MEDLoader.WriteField(fileName,f2,False);#<- False important for the test
#
- f3=MEDLoader.ReadFieldNode(fileName,f2.getMesh().getName(),0,f2.getName(),2,7);
+ f3=MEDLoader.MEDLoader.ReadFieldNode(fileName,f2.getMesh().getName(),0,f2.getName(),2,7);
f3.checkCoherency();
self.assertTrue(f3.isEqual(f2,1e-12,1e-12));
#
arr3=[1,3,0,5,2,4]
f2.renumberNodes(arr3);
- MEDLoader.WriteUMesh(fileName2,m,True);
- MEDLoader.WriteField(fileName2,f2,False);#<- False important for the test
- f3=MEDLoader.ReadFieldNode(fileName2,f2.getMesh().getName(),0,f2.getName(),2,7);
+ MEDLoader.MEDLoader.WriteUMesh(fileName2,m,True);
+ MEDLoader.MEDLoader.WriteField(fileName2,f2,False);#<- False important for the test
+ f3=MEDLoader.MEDLoader.ReadFieldNode(fileName2,f2.getMesh().getName(),0,f2.getName(),2,7);
f3.checkCoherency();
self.assertTrue(f3.isEqual(f2,1e-12,1e-12));
#
def testFieldNodeProfilRW2(self):
fileName="Pyfile23.med";
mesh=MEDLoaderDataForTest.build3DSurfMesh_1();
- MEDLoader.WriteUMesh(fileName,mesh,True);
+ MEDLoader.MEDLoader.WriteUMesh(fileName,mesh,True);
#
- f1=MEDCouplingFieldDouble.New(ON_NODES,ONE_TIME);
+ f1=MEDLoader.MEDCouplingFieldDouble.New(MEDLoader.ON_NODES,MEDLoader.ONE_TIME);
f1.setName("FieldMix");
f1.setMesh(mesh);
arr2=[1071.,1171.,1010.,1110.,1020.,1120.,1030.,1130.,1040.,1140.,1050.,1150.,
1060.,1160.,1070.,1170.,1080.,1180.,1090.,1190.,1091.,1191.,1092.,1192.];
- array=DataArrayDouble.New();
+ array=MEDLoader.DataArrayDouble.New();
array.setValues(arr2,12,2);
f1.setArray(array);
array.setInfoOnComponent(0,"plkj (mm)");
renumArr=[3,7,2,1,5,11,10,0,9,6,8,4]
f1.renumberNodes(renumArr);
f1.checkCoherency();
- MEDLoader.WriteField(fileName,f1,False);#<- False important for the test
- f2=MEDLoader.ReadFieldNode(fileName,f1.getMesh().getName(),0,f1.getName(),2,7);
+ MEDLoader.MEDLoader.WriteField(fileName,f1,False);#<- False important for the test
+ f2=MEDLoader.MEDLoader.ReadFieldNode(fileName,f1.getMesh().getName(),0,f1.getName(),2,7);
self.assertTrue(f2.isEqual(f1,1e-12,1e-12));
#
pass
def testMixCellAndNodesFieldRW1(self):
fileName="Pyfile21.med";
mesh=MEDLoaderDataForTest.build3DSurfMesh_1();
- f1=MEDCouplingFieldDouble.New(ON_CELLS,ONE_TIME);
+ f1=MEDLoader.MEDCouplingFieldDouble.New(MEDLoader.ON_CELLS,MEDLoader.ONE_TIME);
f1.setName("FieldMix");
f1.setMesh(mesh);
- array=DataArrayDouble.New();
+ array=MEDLoader.DataArrayDouble.New();
f1.setArray(array);
arr1=[71.,171.,10.,110.,20.,120.,30.,130.,40.,140.,50.,150.]
array.setValues(arr1,6,2);
f1.setTime(3.14,2,7);
f1.checkCoherency();
#
- f2=MEDCouplingFieldDouble.New(ON_NODES,ONE_TIME);
+ f2=MEDLoader.MEDCouplingFieldDouble.New(MEDLoader.ON_NODES,MEDLoader.ONE_TIME);
f2.setName("FieldMix");
f2.setMesh(mesh);
- array=DataArrayDouble.New();
+ array=MEDLoader.DataArrayDouble.New();
f2.setArray(array);
arr2=[1071.,1171.,1010.,1110.,1020.,1120.,1030.,1130.,1040.,1140.,1050.,1150.,
1060.,1160.,1070.,1170.,1080.,1180.,1090.,1190.,1091.,1191.,1092.,1192.]
f2.setTime(3.17,2,7);
f2.checkCoherency();
#
- MEDLoader.WriteField(fileName,f1,True);
- ts=MEDLoader.GetTypesOfField(fileName,f1.getName(),f1.getMesh().getName());
+ MEDLoader.MEDLoader.WriteField(fileName,f1,True);
+ ts=MEDLoader.MEDLoader.GetTypesOfField(fileName,f1.getMesh().getName(),f1.getName());
self.assertEqual(1,len(ts));
- self.assertEqual(ON_CELLS,ts[0]);
- fs=MEDLoader.GetAllFieldNamesOnMesh(fileName,f1.getMesh().getName());
+ self.assertEqual(MEDLoader.ON_CELLS,ts[0]);
+ fs=MEDLoader.MEDLoader.GetAllFieldNamesOnMesh(fileName,f1.getMesh().getName());
self.assertEqual(1,len(fs));
self.assertTrue(fs[0]=="FieldMix");
- MEDLoader.WriteFieldUsingAlreadyWrittenMesh(fileName,f2);
- fs=MEDLoader.GetAllFieldNamesOnMesh(fileName,f1.getMesh().getName());
+ MEDLoader.MEDLoader.WriteFieldUsingAlreadyWrittenMesh(fileName,f2);
+ fs=MEDLoader.MEDLoader.GetAllFieldNamesOnMesh(fileName,f1.getMesh().getName());
self.assertEqual(1,len(fs));
self.assertTrue(fs[0]=="FieldMix");
#
- ts=MEDLoader.GetTypesOfField(fileName,f1.getName(),f1.getMesh().getName());
+ ts=MEDLoader.MEDLoader.GetTypesOfField(fileName,f1.getMesh().getName(),f1.getName());
self.assertEqual(2,len(ts));
- self.assertEqual(ON_NODES,ts[0]);
- self.assertEqual(ON_CELLS,ts[1]);
+ self.assertEqual(MEDLoader.ON_NODES,ts[0]);
+ self.assertEqual(MEDLoader.ON_CELLS,ts[1]);
#
- f3=MEDLoader.ReadFieldNode(fileName,f1.getMesh().getName(),0,f1.getName(),2,7);
+ f3=MEDLoader.MEDLoader.ReadFieldNode(fileName,f1.getMesh().getName(),0,f1.getName(),2,7);
self.assertTrue(f3.isEqual(f2,1e-12,1e-12));
- f3=MEDLoader.ReadFieldCell(fileName,f1.getMesh().getName(),0,f1.getName(),2,7);
+ f3=MEDLoader.MEDLoader.ReadFieldCell(fileName,f1.getMesh().getName(),0,f1.getName(),2,7);
self.assertTrue(f3.isEqual(f1,1e-12,1e-12));
#
pass
def testGetAllFieldNamesRW1(self):
fileName="Pyfile22.med";
mesh=MEDLoaderDataForTest.build2DMesh_2();
- f1=MEDCouplingFieldDouble.New(ON_NODES,ONE_TIME);
+ f1=MEDLoader.MEDCouplingFieldDouble.New(MEDLoader.ON_NODES,MEDLoader.ONE_TIME);
f1.setName("Field1");
f1.setTime(3.44,5,6);
f1.setMesh(mesh);
f1.fillFromAnalytic(2,"x+y");
- MEDLoader.WriteField(fileName,f1,True);
+ MEDLoader.MEDLoader.WriteField(fileName,f1,True);
f1.setTime(1002.3,7,8);
f1.fillFromAnalytic(2,"x+77.*y");
- MEDLoader.WriteFieldUsingAlreadyWrittenMesh(fileName,f1);
+ MEDLoader.MEDLoader.WriteFieldUsingAlreadyWrittenMesh(fileName,f1);
f1.setName("Field2");
- MEDLoader.WriteField(fileName,f1,False);
+ MEDLoader.MEDLoader.WriteField(fileName,f1,False);
f1.setName("Field3");
mesh.setName("2DMesh_2Bis");
- MEDLoader.WriteField(fileName,f1,False);
- f1=MEDCouplingFieldDouble.New(ON_CELLS,ONE_TIME);
+ MEDLoader.MEDLoader.WriteField(fileName,f1,False);
+ f1=MEDLoader.MEDCouplingFieldDouble.New(MEDLoader.ON_CELLS,MEDLoader.ONE_TIME);
f1.setName("Field8");
f1.setTime(8.99,7,9);
f1.setMesh(mesh);
f1.fillFromAnalytic(3,"3*x+y");
- MEDLoader.WriteField(fileName,f1,False);
- fs=MEDLoader.GetAllFieldNames(fileName);
+ MEDLoader.MEDLoader.WriteField(fileName,f1,False);
+ fs=MEDLoader.MEDLoader.GetAllFieldNames(fileName);
self.assertEqual(4,len(fs));
self.assertTrue(fs[0]=="Field1");
self.assertTrue(fs[1]=="Field2");
# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
#
-from libMEDLoader_Swig import *
+from MEDLoader import *
import unittest
from math import pi,e,sqrt
from MEDLoaderDataForTest import MEDLoaderDataForTest
--- /dev/null
+# -*- coding: iso-8859-1 -*-
+# Copyright (C) 2007-2010 CEA/DEN, EDF R&D
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+#
+
+from MEDLoader import *
+import unittest
+from math import pi,e,sqrt
+from MEDLoaderDataForTest import MEDLoaderDataForTest
+
+class MEDLoaderTest(unittest.TestCase):
+ def testMEDMesh1(self):
+ fileName="Pyfile18.med"
+ mname="ExampleOfMultiDimW"
+ medmesh=MEDFileUMesh.New(fileName,mname)
+ self.assertEqual((0,-1),medmesh.getNonEmptyLevels())
+ m1_0=medmesh.getLevel0Mesh(True)
+ m1_1=MEDLoader.ReadUMeshFromFile(fileName,mname,0)
+ self.assertTrue(m1_0.isEqual(m1_1,1e-12));
+ m2_0=medmesh.getLevelM1Mesh(True)
+ m2_1=MEDLoader.ReadUMeshFromFile(fileName,mname,-1)
+ self.assertTrue(m2_0.isEqual(m2_1,1e-12));
+ pass
+ def testMEDMesh2(self):
+ fileName="Pyfile10.med"
+ mname="3DToto"
+ outFileName="MEDFileMesh1.med"
+ medmesh=MEDFileUMesh.New(fileName,mname)
+ self.assertEqual((0,),medmesh.getNonEmptyLevels())
+ m1_0=medmesh.getLevel0Mesh(True)
+ m1_1=MEDLoader.ReadUMeshFromFile(fileName,mname,0)
+ self.assertTrue(m1_0.isEqual(m1_1,1e-12));
+ g1_0=medmesh.getGroup(0,"mesh2",True)
+ g1_1=MEDLoader.ReadUMeshFromGroups(fileName,mname,0,["mesh2"]);
+ self.assertTrue(g1_0.isEqual(g1_1,1e-12));
+ g1_0=medmesh.getGroup(0,"mesh3",True)
+ g1_1=MEDLoader.ReadUMeshFromGroups(fileName,mname,0,["mesh3"]);
+ self.assertTrue(g1_0.isEqual(g1_1,1e-12));
+ g1_0=medmesh.getGroups(0,["mesh3","mesh2"])
+ g1_1=MEDLoader.ReadUMeshFromGroups(fileName,mname,0,["mesh3","mesh2"]);
+ g1_1.setName(g1_0.getName())
+ self.assertTrue(g1_0.isEqual(g1_1,1e-12));
+ g1_0=medmesh.getFamily(0,"Family_2",True)
+ g1_1=MEDLoader.ReadUMeshFromFamilies(fileName,mname,0,["Family_2"]);
+ self.assertTrue(g1_0.isEqual(g1_1,1e-12));
+ g1_0=medmesh.getFamilies(0,["Family_2","Family_4"],True)
+ g1_1=MEDLoader.ReadUMeshFromFamilies(fileName,mname,0,["Family_2","Family_4"]);
+ g1_1.setName(g1_0.getName())
+ self.assertTrue(g1_0.isEqual(g1_1,1e-12));
+ self.assertTrue(g1_0.isEqual(g1_1,1e-12));
+ medmesh.write(outFileName,2);
+ self.assertEqual([2,3,5,14,16],medmesh.getGroupArr(0,"mesh2",True).getValues());
+ self.assertEqual([2,3,16],medmesh.getFamilyArr(0,"Family_2",True).getValues());
+ self.assertEqual([2,3,5,14,16],medmesh.getFamiliesArr(0,["Family_4","Family_2"],True).getValues());
+ self.assertEqual([19,2,3,4,5,14,15,16],medmesh.getGroupsArr(0,["mesh2","mesh4","mesh3"],True).getValues());
+ famn=medmesh.getFamilyNameGivenId(0)
+ self.assertEqual(range(60),medmesh.getNodeFamilyArr(famn,True).getValues());
+ #without renum
+ self.assertEqual([2,3,5,14,16],medmesh.getGroupArr(0,"mesh2",False).getValues());
+ self.assertEqual([2,3,16],medmesh.getFamilyArr(0,"Family_2",False).getValues());
+ self.assertEqual([2,3,5,14,16],medmesh.getFamiliesArr(0,["Family_4","Family_2"],False).getValues());
+ self.assertEqual([0,2,3,4,5,14,15,16],medmesh.getGroupsArr(0,["mesh2","mesh3","mesh4"],False).getValues());
+ self.assertEqual(range(60),medmesh.getNodeFamilyArr(famn,False).getValues());
+ pass
+
+ # this tests emulates MEDMEM ( Except that it works ! ) The permutation are NOT taken into account
+ def testMEDMesh3(self):
+ outFileName="MEDFileMesh3.med"
+ c=DataArrayDouble.New()
+ coords=[-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]
+ c.setValues(coords,9,2)
+ m=MEDCouplingUMesh.New();
+ m.setMeshDimension(2);
+ m.allocateCells(5);
+ m.insertNextCell(NORM_TRI3,3,targetConn[4:7])
+ m.insertNextCell(NORM_TRI3,3,targetConn[7:10])
+ m.insertNextCell(NORM_QUAD4,4,targetConn[0:4])
+ m.insertNextCell(NORM_QUAD4,4,targetConn[10:14])
+ m.insertNextCell(NORM_QUAD4,4,targetConn[14:18])
+ m.finishInsertingCells();
+ m.setCoords(c)
+ m.checkCoherency()
+ m1=MEDCouplingUMesh.New();
+ m1.setMeshDimension(1);
+ m1.allocateCells(3);
+ m1.insertNextCell(NORM_SEG2,2,[1,4])
+ m1.insertNextCell(NORM_SEG2,2,[3,6])
+ m1.insertNextCell(NORM_SEG3,3,[2,8,5])
+ m1.finishInsertingCells();
+ m1.setCoords(c)
+ m1.checkCoherency()
+ m2=MEDCouplingUMesh.New();
+ m2.setMeshDimension(0);
+ m2.allocateCells(4);
+ m2.insertNextCell(NORM_POINT1,1,[1])
+ m2.insertNextCell(NORM_POINT1,1,[3])
+ m2.insertNextCell(NORM_POINT1,1,[2])
+ m2.insertNextCell(NORM_POINT1,1,[6])
+ m2.finishInsertingCells();
+ m2.setCoords(c)
+ m2.checkCoherency()
+ #
+ mm=MEDFileUMesh.New()
+ mm.setName("MyFirstMEDCouplingMEDmesh")
+ mm.setDescription("IHopeToConvinceLastMEDMEMUsers")
+ mm.setCoords(c)
+ mm.setMeshAtLevelOld(-1,m1);
+ mm.setMeshAtLevelOld(0,m);
+ mm.setMeshAtLevelOld(-2,m2);
+ # playing with groups
+ g1_2=DataArrayInt.New()
+ g1_2.setValues([1,3],2,1)
+ g1_2.setName("G1")
+ g2_2=DataArrayInt.New()
+ g2_2.setValues([1,2,3],3,1)
+ g2_2.setName("G2")
+ mm.setGroupsAtLevel(0,[g1_2,g2_2],False)
+ g1_1=DataArrayInt.New()
+ g1_1.setValues([0,1,2],3,1)
+ g1_1.setName("G1")
+ g2_1=DataArrayInt.New()
+ g2_1.setValues([0,2],2,1)
+ g2_1.setName("G2")
+ mm.setGroupsAtLevel(-1,[g1_1,g2_1],False)
+ g1_N=DataArrayInt.New()
+ g1_N.setValues(range(8),8,1)
+ g1_N.setName("G1")
+ g2_N=DataArrayInt.New()
+ g2_N.setValues(range(9),9,1)
+ g2_N.setName("G2")
+ mm.setGroupsAtLevel(1,[g1_N,g2_N],False)
+ # check content of mm
+ t=mm.getGroupArr(0,"G1",False)
+ self.assertTrue(g1_2.isEqual(t));
+ t=mm.getGroupArr(0,"G2",False)
+ self.assertTrue(g2_2.isEqual(t));
+ t=mm.getGroupArr(-1,"G1",False)
+ self.assertTrue(g1_1.isEqual(t));
+ t=mm.getGroupArr(-1,"G2",False)
+ self.assertTrue(g2_1.isEqual(t));
+ t=mm.getGroupArr(1,"G1",False)
+ self.assertTrue(g1_N.isEqual(t));
+ t=mm.getGroupArr(1,"G2",False)
+ self.assertTrue(g2_N.isEqual(t));
+ #
+ mm.write(outFileName,2);
+ pass
+
+ # this test is the testMEDMesh3 except that permutation is dealed here
+ def testMEDMesh4(self):
+ outFileName="MEDFileMesh4.med"
+ c=DataArrayDouble.New()
+ coords=[-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]
+ c.setValues(coords,9,2)
+ m=MEDCouplingUMesh.New();
+ m.setMeshDimension(2);
+ m.allocateCells(5);
+ m.insertNextCell(NORM_QUAD4,4,targetConn[0:4])
+ m.insertNextCell(NORM_TRI3,3,targetConn[4:7])
+ m.insertNextCell(NORM_TRI3,3,targetConn[7:10])
+ m.insertNextCell(NORM_QUAD4,4,targetConn[10:14])
+ m.insertNextCell(NORM_QUAD4,4,targetConn[14:18])
+ m.finishInsertingCells();
+ m.setCoords(c)
+ m.checkCoherency()
+ m1=MEDCouplingUMesh.New();
+ m1.setMeshDimension(1);
+ m1.allocateCells(3);
+ m1.insertNextCell(NORM_SEG2,2,[1,4])
+ m1.insertNextCell(NORM_SEG3,3,[2,8,5])
+ m1.insertNextCell(NORM_SEG2,2,[3,6])
+ m1.finishInsertingCells();
+ m1.setCoords(c)
+ m1.checkCoherency()
+ m2=MEDCouplingUMesh.New();
+ m2.setMeshDimension(0);
+ m2.allocateCells(4);
+ m2.insertNextCell(NORM_POINT1,1,[1])
+ m2.insertNextCell(NORM_POINT1,1,[3])
+ m2.insertNextCell(NORM_POINT1,1,[2])
+ m2.insertNextCell(NORM_POINT1,1,[6])
+ m2.finishInsertingCells();
+ m2.setCoords(c)
+ m2.checkCoherency()
+ #
+ mm=MEDFileUMesh.New()
+ mm.setName("My2ndMEDCouplingMEDmesh")
+ mm.setDescription("ThisIsImpossibleToDoWithMEDMEM")
+ mm.setCoords(c)
+ renumNode=DataArrayInt.New()
+ renumNode.setValues([10,11,12,13,14,15,16,17,18],9,1)
+ mm.setRenumArr(1,renumNode)
+ mm.setMeshAtLevel(-1,m1);
+ mm.setMeshAtLevel(0,m);
+ mm.setMeshAtLevel(-2,m2);
+ # playing with groups
+ g1_2=DataArrayInt.New()
+ g1_2.setValues([2,3],2,1)
+ g1_2.setName("G1")
+ g2_2=DataArrayInt.New()
+ g2_2.setValues([2,0,3],3,1)
+ g2_2.setName("G2")
+ mm.setGroupsAtLevel(0,[g1_2,g2_2],True)
+ g1_1=DataArrayInt.New()
+ g1_1.setValues([0,2,1],3,1)
+ g1_1.setName("G1")
+ g2_1=DataArrayInt.New()
+ g2_1.setValues([0,2],2,1)
+ g2_1.setName("G2")
+ mm.setGroupsAtLevel(-1,[g1_1,g2_1],True)
+ g1_N=DataArrayInt.New()
+ g1_N.setValues([10,11,12,13,14,15,16,17],8,1)
+ g1_N.setName("G1")
+ g2_N=DataArrayInt.New()
+ g2_N.setValues([10,11,12,13,14,15,16,17,18],9,1)
+ g2_N.setName("G2")
+ mm.setGroupsAtLevel(1,[g1_N,g2_N],True)
+ # check content of mm
+ t=mm.getGroupArr(0,"G1",True)
+ self.assertTrue(g1_2.isEqual(t));
+ t=mm.getGroupArr(0,"G2",True)
+ self.assertTrue(g2_2.isEqual(t));
+ t=mm.getGroupArr(-1,"G1",True)
+ self.assertTrue(g1_1.isEqual(t));
+ t=mm.getGroupArr(-1,"G2",True)
+ self.assertTrue(g2_1.isEqual(t));
+ #
+ mm.write(outFileName,2);
+ pass
+ pass
+
+unittest.main()
#include <vector>
+static PyObject* convertMEDFileMesh(ParaMEDMEM::MEDFileMesh* mesh, int owner)
+{
+ PyObject *ret=0;
+ if(dynamic_cast<ParaMEDMEM::MEDFileUMesh *>(mesh))
+ ret=SWIG_NewPointerObj((void*)mesh,SWIGTYPE_p_ParaMEDMEM__MEDFileUMesh,owner);
+ if(dynamic_cast<ParaMEDMEM::MEDFileCMesh *>(mesh))
+ ret=SWIG_NewPointerObj((void*)mesh,SWIGTYPE_p_ParaMEDMEM__MEDFileCMesh,owner);
+ if(!ret)
+ {
+ PyErr_SetString(PyExc_TypeError,"Not recognized type of MEDFileMesh on downcast !");
+ PyErr_Print();
+ }
+ return ret;
+}
+
static std::vector<std::pair<int,int> > convertTimePairIdsFromPy(PyObject *pyLi)
{
std::vector<std::pair<int,int> > ret;
return ret;
}
+static void converPyListToVecString(PyObject *pyLi, std::vector<std::string>& v)
+{
+ if(PyList_Check(pyLi))
+ {
+ int size=PyList_Size(pyLi);
+ v.resize(size);
+ for(int i=0;i<size;i++)
+ {
+ PyObject *o=PyList_GetItem(pyLi,i);
+ if(!PyString_Check(o))
+ throw INTERP_KERNEL::Exception("In list passed in argument some elements are NOT strings ! Expected a list containing only strings !");
+ const char *st=PyString_AsString(o);
+ v[i]=std::string(st);
+ }
+ }
+ else if(PyTuple_Check(pyLi))
+ {
+ int size=PyTuple_Size(pyLi);
+ v.resize(size);
+ for(int i=0;i<size;i++)
+ {
+ PyObject *o=PyTuple_GetItem(pyLi,i);
+ if(!PyString_Check(o))
+ throw INTERP_KERNEL::Exception("In tuple passed in argument some elements are NOT strings ! Expected a tuple containing only strings !");
+ const char *st=PyString_AsString(o);
+ v[i]=std::string(st);
+ }
+ }
+ else if(PyString_Check(pyLi))
+ {
+ v.resize(1);
+ v[0]=std::string((const char *)PyString_AsString(pyLi));
+ }
+ else
+ {
+ throw INTERP_KERNEL::Exception("Unrecognized python argument : expected a list of string or tuple of string or string !");
+ }
+}
+
static PyObject *convertFieldDoubleVecToPy(const std::vector<ParaMEDMEM::MEDCouplingFieldDouble *>& li)
{
int sz=li.size();
return ret;
}
-static std::vector<ParaMEDMEM::MEDCouplingUMesh *> convertFieldDoubleVecFromPy(PyObject *pyLi)
+static std::vector<const ParaMEDMEM::MEDCouplingUMesh *> convertUMeshVecFromPy(PyObject *pyLi)
{
- std::vector<ParaMEDMEM::MEDCouplingUMesh *> ret;
+ std::vector<const ParaMEDMEM::MEDCouplingUMesh *> ret;
if(PyList_Check(pyLi))
{
int size=PyList_Size(pyLi);
#
include $(top_srcdir)/adm_local/unix/make_common_starter.am
-lib_LTLIBRARIES = _libMEDLoader_Swig.la
+lib_LTLIBRARIES = _MEDLoader.la
salomeinclude_HEADERS = \
- libMEDLoader_Swig.i MEDLoaderTypemaps.i
+ MEDLoader.i MEDLoaderTypemaps.i
-SWIG_DEF = libMEDLoader_Swig.i MEDLoaderTypemaps.i
+SWIG_DEF = MEDLoader.i MEDLoaderTypemaps.i
SWIG_FLAGS = @SWIG_FLAGS@ -I$(srcdir) -I$(srcdir)/.. -I$(srcdir)/../../MEDCoupling -I$(srcdir)/../../MEDCoupling_Swig \
-I$(srcdir)/../../INTERP_KERNEL -I$(srcdir)/../../INTERP_KERNEL/Bases
-dist__libMEDLoader_Swig_la_SOURCES = $(SWIG_DEF)
-nodist__libMEDLoader_Swig_la_SOURCES = libMEDLoader_Swig_wrap.cxx
-libMEDLoader_Swig.py: libMEDLoader_Swig_wrap.cxx
+dist__MEDLoader_la_SOURCES = $(SWIG_DEF)
+nodist__MEDLoader_la_SOURCES = MEDLoader_wrap.cxx
+MEDLoader.py: MEDLoader_wrap.cxx
-libMEDLoader_Swig_wrap.cxx: $(SWIG_DEF)
+MEDLoader_wrap.cxx: $(SWIG_DEF)
$(SWIG) $(SWIG_FLAGS) -o $@ $<
-_libMEDLoader_Swig_la_CPPFLAGS = $(PYTHON_INCLUDES) \
+_MEDLoader_la_CPPFLAGS = $(PYTHON_INCLUDES) \
$(MED2_INCLUDES) $(HDF5_INCLUDES) @CXXTMPDPTHFLAGS@ \
-I$(srcdir)/../../INTERP_KERNEL \
-I$(srcdir)/.. -I$(srcdir)/../../MEDCoupling_Swig -I$(srcdir)/../../INTERP_KERNEL/Bases \
-I$(srcdir)/../../MEDCoupling
-_libMEDLoader_Swig_la_LDFLAGS = -module $(MED2_LIBS) $(HDF5_LIBS) $(PYTHON_LIBS) \
+_MEDLoader_la_LDFLAGS = -module $(MED2_LIBS) $(HDF5_LIBS) $(PYTHON_LIBS) \
../../MEDCoupling/libmedcoupling.la ../../INTERP_KERNEL/libinterpkernel.la \
../libmedloader.la
-CLEANFILES = libMEDLoader_Swig_wrap.cxx libMEDLoader_Swig.py
+CLEANFILES = MEDLoader_wrap.cxx MEDLoader.py
-dist_salomescript_DATA= libMEDLoader_Swig.py MEDLoaderDataForTest.py MEDLoaderTest.py MEDLoaderTest2.py
+dist_salomescript_DATA= MEDLoaderDataForTest.py MEDLoaderTest.py MEDLoaderTest2.py MEDLoaderTest3.py libMEDLoader_Swig.py
+nodist_salomescript_DATA = MEDLoader.py
UNIT_TEST_PROG = MEDLoaderTest.py MEDLoaderTest2.py
\ No newline at end of file
+++ /dev/null
-// Copyright (C) 2007-2010 CEA/DEN, EDF R&D
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-
-%module libMEDLoader_Swig
-
-#define MEDCOUPLING_EXPORT
-#define MEDLOADER_EXPORT
-
-%include "libMEDCoupling_Swig.i"
-
-%{
-#include "MEDLoader.hxx"
-#include "MEDLoaderTypemaps.i"
-%}
-
-#if SWIG_VERSION >= 0x010329
-%template() std::vector<std::string>;
-#endif
-
-%newobject MEDLoader::ReadUMeshFromFamilies;
-%newobject MEDLoader::ReadUMeshFromGroups;
-%newobject MEDLoader::ReadUMeshFromFile;
-%newobject MEDLoader::ReadField;
-%newobject MEDLoader::ReadFieldCell;
-%newobject MEDLoader::ReadFieldNode;
-%newobject MEDLoader::ReadFieldGauss;
-%newobject MEDLoader::ReadFieldGaussNE;
-
-class MEDLoader
-{
-public:
- static void setEpsilonForNodeComp(double val) throw(INTERP_KERNEL::Exception);
- static void setCompPolicyForCell(int val) throw(INTERP_KERNEL::Exception);
- static void setTooLongStrPolicy(int val) throw(INTERP_KERNEL::Exception);
- static void CheckFileForRead(const char *fileName) throw(INTERP_KERNEL::Exception);
- static std::vector<std::string> GetMeshNames(const char *fileName) throw(INTERP_KERNEL::Exception);
- static std::vector<std::string> GetMeshNamesOnField(const char *fileName, const char *fieldName) throw(INTERP_KERNEL::Exception);
- static std::vector<std::string> GetMeshGroupsNames(const char *fileName, const char *meshName) throw(INTERP_KERNEL::Exception);
- static std::vector<std::string> GetMeshFamiliesNames(const char *fileName, const char *meshName) throw(INTERP_KERNEL::Exception);
- static std::vector<std::string> GetAllFieldNamesOnMesh(const char *fileName, const char *meshName) throw(INTERP_KERNEL::Exception);
- static std::vector<std::string> GetAllFieldNames(const char *fileName) throw(INTERP_KERNEL::Exception);
- static std::vector<std::string> GetFieldNamesOnMesh(ParaMEDMEM::TypeOfField type, const char *fileName, const char *meshName) throw(INTERP_KERNEL::Exception);
- static std::vector<std::string> GetCellFieldNamesOnMesh(const char *fileName, const char *meshName) throw(INTERP_KERNEL::Exception);
- static std::vector<std::string> GetNodeFieldNamesOnMesh(const char *fileName, const char *meshName) throw(INTERP_KERNEL::Exception);
- static double GetTimeAttachedOnFieldIteration(const char *fileName, const char *fieldName, int iteration, int order) throw(INTERP_KERNEL::Exception);
- %extend
- {
- static PyObject *GetFieldIterations(ParaMEDMEM::TypeOfField type, const char *fileName, const char *meshName, const char *fieldName) throw(INTERP_KERNEL::Exception)
- {
- std::vector< std::pair<int,int> > res=MEDLoader::GetFieldIterations(type,fileName,meshName,fieldName);
- PyObject *ret=PyList_New(res.size());
- int rk=0;
- for(std::vector< std::pair<int,int> >::const_iterator iter=res.begin();iter!=res.end();iter++,rk++)
- {
- PyObject *elt=PyTuple_New(2);
- PyTuple_SetItem(elt,0,SWIG_From_int((*iter).first));
- PyTuple_SetItem(elt,1,SWIG_From_int((*iter).second));
- PyList_SetItem(ret,rk,elt);
- }
- return ret;
- }
-
- static PyObject *GetAllFieldIterations(const char *fileName, const char *meshName, const char *fieldName) throw(INTERP_KERNEL::Exception)
- {
- std::vector< std::pair< std::pair<int,int>, double> > res=MEDLoader::GetAllFieldIterations(fileName,meshName,fieldName);
- PyObject *ret=PyList_New(res.size());
- int rk=0;
- for(std::vector< std::pair< std::pair<int,int>, double> >::const_iterator iter=res.begin();iter!=res.end();iter++,rk++)
- {
- PyObject *elt=PyTuple_New(3);
- PyTuple_SetItem(elt,0,SWIG_From_int((*iter).first.first));
- PyTuple_SetItem(elt,1,SWIG_From_int((*iter).first.second));
- PyTuple_SetItem(elt,2,SWIG_From_double((*iter).second));
- PyList_SetItem(ret,rk,elt);
- }
- return ret;
- }
-
- static PyObject *GetCellFieldIterations(const char *fileName, const char *meshName, const char *fieldName) throw(INTERP_KERNEL::Exception)
- {
- std::vector< std::pair<int,int> > res=MEDLoader::GetCellFieldIterations(fileName,meshName,fieldName);
- PyObject *ret=PyList_New(res.size());
- int rk=0;
- for(std::vector< std::pair<int,int> >::const_iterator iter=res.begin();iter!=res.end();iter++,rk++)
- {
- PyObject *elt=PyTuple_New(2);
- PyTuple_SetItem(elt,0,SWIG_From_int((*iter).first));
- PyTuple_SetItem(elt,1,SWIG_From_int((*iter).second));
- PyList_SetItem(ret,rk,elt);
- }
- return ret;
- }
- static PyObject *GetNodeFieldIterations(const char *fileName, const char *meshName, const char *fieldName) throw(INTERP_KERNEL::Exception)
- {
- std::vector< std::pair<int,int> > res=MEDLoader::GetNodeFieldIterations(fileName,meshName,fieldName);
- PyObject *ret=PyList_New(res.size());
- int rk=0;
- for(std::vector< std::pair<int,int> >::const_iterator iter=res.begin();iter!=res.end();iter++,rk++)
- {
- PyObject *elt=PyTuple_New(2);
- PyTuple_SetItem(elt,0,SWIG_From_int((*iter).first));
- PyTuple_SetItem(elt,1,SWIG_From_int((*iter).second));
- PyList_SetItem(ret,rk,elt);
- }
- return ret;
- }
- static PyObject *ReadFieldsOnSameMesh(ParaMEDMEM::TypeOfField type, const char *fileName, const char *meshName, int meshDimRelToMax,
- const char *fieldName, PyObject *liIts) throw(INTERP_KERNEL::Exception)
- {
- std::vector<std::pair<int,int> > its=convertTimePairIdsFromPy(liIts);
- std::vector<ParaMEDMEM::MEDCouplingFieldDouble *> res=MEDLoader::ReadFieldsOnSameMesh(type,fileName,meshName,meshDimRelToMax,fieldName,its);
- return convertFieldDoubleVecToPy(res);
- }
- static void WriteUMeshesPartition(const char *fileName, const char *meshName, PyObject *li, bool writeFromScratch) throw(INTERP_KERNEL::Exception)
- {
- std::vector<ParaMEDMEM::MEDCouplingUMesh *> v=convertFieldDoubleVecFromPy(li);
- MEDLoader::WriteUMeshesPartition(fileName,meshName,v,writeFromScratch);
- }
- static void WriteUMeshesPartitionDep(const char *fileName, const char *meshName, PyObject *li, bool writeFromScratch) throw(INTERP_KERNEL::Exception)
- {
- std::vector<ParaMEDMEM::MEDCouplingUMesh *> v=convertFieldDoubleVecFromPy(li);
- MEDLoader::WriteUMeshesPartitionDep(fileName,meshName,v,writeFromScratch);
- }
- static void WriteUMeshes(const char *fileName, PyObject *li, bool writeFromScratch) throw(INTERP_KERNEL::Exception)
- {
- std::vector<ParaMEDMEM::MEDCouplingUMesh *> v=convertFieldDoubleVecFromPy(li);
- std::vector<const ParaMEDMEM::MEDCouplingUMesh *> v2(v.begin(),v.end());
- MEDLoader::WriteUMeshes(fileName,v2,writeFromScratch);
- }
- static PyObject *GetTypesOfField(const char *fileName, const char *fieldName, const char *meshName) throw(INTERP_KERNEL::Exception)
- {
- std::vector< ParaMEDMEM::TypeOfField > v=MEDLoader::GetTypesOfField(fileName,fieldName,meshName);
- int size=v.size();
- PyObject *ret=PyList_New(size);
- for(int i=0;i<size;i++)
- PyList_SetItem(ret,i,PyInt_FromLong((int)v[i]));
- return ret;
- }
- }
- static ParaMEDMEM::MEDCouplingUMesh *ReadUMeshFromFamilies(const char *fileName, const char *meshName, int meshDimRelToMax, const std::vector<std::string>& fams) throw(INTERP_KERNEL::Exception);
- static ParaMEDMEM::MEDCouplingUMesh *ReadUMeshFromGroups(const char *fileName, const char *meshName, int meshDimRelToMax, const std::vector<std::string>& grps) throw(INTERP_KERNEL::Exception);
- static ParaMEDMEM::MEDCouplingUMesh *ReadUMeshFromFile(const char *fileName, const char *meshName, int meshDimRelToMax=0) throw(INTERP_KERNEL::Exception);
- static ParaMEDMEM::MEDCouplingUMesh *ReadUMeshFromFile(const char *fileName, int meshDimRelToMax=0) throw(INTERP_KERNEL::Exception);
- static ParaMEDMEM::MEDCouplingFieldDouble *ReadField(ParaMEDMEM::TypeOfField type, const char *fileName, const char *meshName, int meshDimRelToMax, const char *fieldName, int iteration, int order) throw(INTERP_KERNEL::Exception);
- static ParaMEDMEM::MEDCouplingFieldDouble *ReadFieldCell(const char *fileName, const char *meshName, int meshDimRelToMax, const char *fieldName, int iteration, int order) throw(INTERP_KERNEL::Exception);
- static ParaMEDMEM::MEDCouplingFieldDouble *ReadFieldNode(const char *fileName, const char *meshName, int meshDimRelToMax, const char *fieldName, int iteration, int order) throw(INTERP_KERNEL::Exception);
- static ParaMEDMEM::MEDCouplingFieldDouble *ReadFieldGauss(const char *fileName, const char *meshName, int meshDimRelToMax, const char *fieldName, int iteration, int order) throw(INTERP_KERNEL::Exception);
- static ParaMEDMEM::MEDCouplingFieldDouble *ReadFieldGaussNE(const char *fileName, const char *meshName, int meshDimRelToMax, const char *fieldName, int iteration, int order) throw(INTERP_KERNEL::Exception);
- static void WriteUMesh(const char *fileName, const ParaMEDMEM::MEDCouplingUMesh *mesh, bool writeFromScratch) throw(INTERP_KERNEL::Exception);
- static void WriteUMeshDep(const char *fileName, const ParaMEDMEM::MEDCouplingUMesh *mesh, bool writeFromScratch) throw(INTERP_KERNEL::Exception);
- static void WriteField(const char *fileName, const ParaMEDMEM::MEDCouplingFieldDouble *f, bool writeFromScratch) throw(INTERP_KERNEL::Exception);
- static void WriteFieldDep(const char *fileName, const ParaMEDMEM::MEDCouplingFieldDouble *f, bool writeFromScratch) throw(INTERP_KERNEL::Exception);
- static void WriteFieldUsingAlreadyWrittenMesh(const char *fileName, const ParaMEDMEM::MEDCouplingFieldDouble *f) throw(INTERP_KERNEL::Exception);
-};
--- /dev/null
+# -*- coding: iso-8859-1 -*-
+# Copyright (C) 2007-2010 CEA/DEN, EDF R&D
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+#
+
+print """
+**********************************************************************
+**********************************************************************
+libMEDLoader_Swig module DEPRECATED !
+Please use instead \"import MEDLoader\" or \"from MEDLoader import *\"
+**********************************************************************
+**********************************************************************
+"""
mesh4->insertNextCell(INTERP_KERNEL::NORM_TETRA4,4,conn);
mesh4->finishInsertingCells();
mesh4->setCoords(mesh1->getCoords());
- std::vector<MEDCouplingUMesh *> meshes;
+ std::vector<const MEDCouplingUMesh *> meshes;
meshes.push_back(mesh1);
meshes.push_back(mesh2);
meshes.push_back(mesh3);
CPPUNIT_ASSERT(mesh2_2->isEqual(mesh2,1e-12));
mesh2_2->decrRef();
//
+ std::vector<std::string> ret=MEDLoader::GetMeshFamiliesNamesOnGroup(fileName,"3DToto","3DMesh_1");
+ CPPUNIT_ASSERT_EQUAL(4,(int)ret.size());
+ CPPUNIT_ASSERT(ret[0]=="Family_1");
+ CPPUNIT_ASSERT(ret[1]=="Family_2");
+ CPPUNIT_ASSERT(ret[2]=="Family_3");
+ CPPUNIT_ASSERT(ret[3]=="Family_4");
+ //
+ std::vector<std::string> ret1=MEDLoader::GetMeshGroupsNamesOnFamily(fileName,"3DToto","Family_2");
+ CPPUNIT_ASSERT_EQUAL(2,(int)ret1.size());
+ CPPUNIT_ASSERT(ret1[0]=="3DMesh_1");
+ CPPUNIT_ASSERT(ret1[1]=="mesh2");
+ //
mesh4->decrRef();
mesh3->decrRef();
mesh2->decrRef();
f2->checkCoherency();
//
MEDLoader::WriteField(fileName,f1,true);
- std::vector<ParaMEDMEM::TypeOfField> ts=MEDLoader::GetTypesOfField(fileName,f1->getName(),f1->getMesh()->getName());
+ std::vector<ParaMEDMEM::TypeOfField> ts=MEDLoader::GetTypesOfField(fileName,f1->getMesh()->getName(),f1->getName());
CPPUNIT_ASSERT_EQUAL(1,(int)ts.size());
CPPUNIT_ASSERT_EQUAL(ON_CELLS,ts[0]);
std::vector<std::string> fs=MEDLoader::GetAllFieldNamesOnMesh(fileName,f1->getMesh()->getName());
CPPUNIT_ASSERT_EQUAL(1,(int)fs.size());
CPPUNIT_ASSERT(fs[0]=="FieldMix");
//
- ts=MEDLoader::GetTypesOfField(fileName,f1->getName(),f1->getMesh()->getName());
+ ts=MEDLoader::GetTypesOfField(fileName,f1->getMesh()->getName(),f1->getName());
CPPUNIT_ASSERT_EQUAL(2,(int)ts.size());
CPPUNIT_ASSERT_EQUAL(ON_NODES,ts[0]);
CPPUNIT_ASSERT_EQUAL(ON_CELLS,ts[1]);
targetMesh->setName("2DMesh_2");
targetMesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,targetConn);
targetMesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,targetConn+3);
- targetMesh->insertNextCell(INTERP_KERNEL::NORM_TRI6,6,targetConn+6);
targetMesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,targetConn+12);
targetMesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,targetConn+16);
+ targetMesh->insertNextCell(INTERP_KERNEL::NORM_TRI6,6,targetConn+6);
targetMesh->finishInsertingCells();
DataArrayDouble *myCoords=DataArrayDouble::New();
myCoords->alloc(12,2);
targetMesh->setName("3DSurfMesh_1");
targetMesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,targetConn);
targetMesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,targetConn+3);
- targetMesh->insertNextCell(INTERP_KERNEL::NORM_TRI6,6,targetConn+6);
targetMesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,targetConn+12);
targetMesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,targetConn+16);
+ targetMesh->insertNextCell(INTERP_KERNEL::NORM_TRI6,6,targetConn+6);
targetMesh->insertNextCell(INTERP_KERNEL::NORM_POLYGON,4,targetConn+20);
targetMesh->finishInsertingCells();
DataArrayDouble *myCoords=DataArrayDouble::New();
MEDCouplingUMesh *MEDLoaderTest::build3DMesh_2()
{
MEDCouplingUMesh *m3dsurfBase=build3DSurfMesh_1();
- int numbers[5]={0,1,3,4,5};
+ int numbers[5]={0,1,2,3,5};
MEDCouplingUMesh *m3dsurf=(MEDCouplingUMesh *)m3dsurfBase->buildPartOfMySelf(numbers,numbers+5,false);
m3dsurfBase->decrRef();
MEDCouplingUMesh *m1dBase=build1DMesh_1();
const double vec[3]={0.,1.,0.};
const double pt[3]={0.,0.,0.};
m1d->rotate(pt,vec,-M_PI/2.);
- MEDCouplingUMesh *ret=m3dsurf->buildExtrudedMeshFromThis(m1d,0);
+ MEDCouplingUMesh *ret=m3dsurf->buildExtrudedMesh(m1d,0);
m1d->decrRef();
m3dsurf->decrRef();
return ret;
f->setGaussLocalizationOnType(INTERP_KERNEL::NORM_TRI3,_refCoo1,_gsCoo1,_wg1);
const double refCoo2[12]={-1.0,1.0, -1.0,-1.0, 1.0,-1.0, -1.0,0.0, 0.0,-1.0, 0.0,0.0 };
std::vector<double> _refCoo2(refCoo2,refCoo2+12);
- _gsCoo1.resize(6); _wg1.resize(3);
- f->setGaussLocalizationOnType(INTERP_KERNEL::NORM_TRI6,_refCoo2,_gsCoo1,_wg1);
+ std::vector<double> _gsCoo2(_gsCoo1);
+ std::vector<double> _wg2(_wg1);
+ _gsCoo2.resize(6); _wg2.resize(3);
const double refCoo3[8]={ 0.,0., 1.,0., 1.,1., 0.,1. };
std::vector<double> _refCoo3(refCoo3,refCoo3+8);
_gsCoo1.resize(4); _wg1.resize(2);
f->setGaussLocalizationOnType(INTERP_KERNEL::NORM_QUAD4,_refCoo3,_gsCoo1,_wg1);
+ f->setGaussLocalizationOnType(INTERP_KERNEL::NORM_TRI6,_refCoo2,_gsCoo2,_wg2);
DataArrayDouble *array=DataArrayDouble::New();
array->alloc(19,2);
double *ptr=array->getPointer();
#include <cmath>
-/*! \defgroup dec DEC
- *
- * \section decintroduction Introduction
- *
- * Interface class for creation of a link between two
- * processor groups for exhanging mesh or field data.
- * The DEC is defined by attaching a field on the receiving or on the
- * sending side.
- * On top of attaching a ParaMEDMEM::FIELD, it is possible to
- * attach a ICoCo::Field. This class is an abstract class that enables
- * coupling of codes that respect the ICoCo interface \ref icoco. It has two implementations:
- * one for codes that express their fields as MEDCoupling fields (ICoCo::MEDField) and one
- * for codes that express their fields as Trio/U fields.
- *
- * \section dec_options DEC Options
- * Options supported by DEC objects are
- *
- * <TABLE BORDER=1 >
- * <TR><TD>Option</TD><TD>Description</TD><TD>Default value</TD></TR>
- * <TR><TD>ForcedRenormalization</TD><TD>After receiving data, the target field is renormalized so that L2-norms of the source and target fields match.</TD><TD> false </TD></TR>
- *</TABLE>
-
-
- The following code excerpt shows how to set options for an object that inherits from DEC :
-
- \code
- InterpKernelDEC dec(source_group,target_group);
- dec.setOptions("ForcedRenormalization",true);
- dec.attachLocalField(field);
- dec.synchronize();
- if (source_group.containsMyRank())
- dec.sendData();
- else
- dec.recvData();
- \endcode
-*/
-
namespace ParaMEDMEM
{
-
-
- /*! \addtogroup dec
- @{
- */
- DEC::DEC(ProcessorGroup& source_group, ProcessorGroup& target_group):_local_field(0),
- _source_group(&source_group),
- _target_group(&target_group),
- _owns_field(false),
- _owns_groups(false),
- _icoco_field(0)
- {
- _union_group = source_group.fuse(target_group);
- }
- DEC::DEC(const std::set<int>& source_ids, const std::set<int>& target_ids, const MPI_Comm& world_comm):_local_field(0),
- _owns_field(false),
- _owns_groups(true),
- _icoco_field(0)
- {
- ParaMEDMEM::CommInterface comm;
- // Create the list of procs including source and target
- std::set<int> union_ids; // source and target ids in world_comm
- union_ids.insert(source_ids.begin(),source_ids.end());
- union_ids.insert(target_ids.begin(),target_ids.end());
- int* union_ranks_world=new int[union_ids.size()]; // ranks of sources and targets in world_comm
- std::copy<std::set<int>::const_iterator,int*> (union_ids.begin(), union_ids.end(), union_ranks_world);
-
- // Create a communicator on these procs
- MPI_Group union_group,world_group;
- comm.commGroup(world_comm,&world_group);
- comm.groupIncl(world_group,union_ids.size(),union_ranks_world,&union_group);
- MPI_Comm union_comm;
- comm.commCreate(world_comm,union_group,&union_comm);
- delete[] union_ranks_world;
-
- if (union_comm==MPI_COMM_NULL)
- { // This process is not in union
- _source_group=0;
- _target_group=0;
- _union_group=0;
- return;
- }
-
- // Translate source_ids and target_ids from world_comm to union_comm
- int* source_ranks_world=new int[source_ids.size()]; // ranks of sources in world_comm
- std::copy<std::set<int>::const_iterator,int*> (source_ids.begin(), source_ids.end(),source_ranks_world);
- int* source_ranks_union=new int[source_ids.size()]; // ranks of sources in union_comm
- int* target_ranks_world=new int[target_ids.size()]; // ranks of targets in world_comm
- std::copy<std::set<int>::const_iterator,int*> (target_ids.begin(), target_ids.end(),target_ranks_world);
- int* target_ranks_union=new int[target_ids.size()]; // ranks of targets in union_comm
- MPI_Group_translate_ranks(world_group,source_ids.size(),source_ranks_world,union_group,source_ranks_union);
- MPI_Group_translate_ranks(world_group,target_ids.size(),target_ranks_world,union_group,target_ranks_union);
- std::set<int> source_ids_union;
- for (int i=0;i<(int)source_ids.size();i++)
- source_ids_union.insert(source_ranks_union[i]);
- std::set<int> target_ids_union;
- for (int i=0;i<(int)target_ids.size();i++)
- target_ids_union.insert(target_ranks_union[i]);
- delete [] source_ranks_world;
- delete [] source_ranks_union;
- delete [] target_ranks_world;
- delete [] target_ranks_union;
-
- // Create the MPIProcessorGroups
- _source_group= new MPIProcessorGroup(comm,source_ids_union,union_comm);
- _target_group = new MPIProcessorGroup(comm,target_ids_union,union_comm);
- _union_group = _source_group->fuse(*_target_group);
-
- }
-
DEC::~DEC()
{
- if(_owns_field)
- delete _local_field;
- if(_owns_groups)
- {
- delete _source_group;
- delete _target_group;
- }
- delete _icoco_field;
- delete _union_group;
- }
-
- void DEC::setNature(NatureOfField nature)
- {
- if(_local_field)
- _local_field->getField()->setNature(nature);
- }
-
- /*! Attaches a local field to a DEC.
- If the processor is on the receiving end of the DEC, the field
- will be updated by a recvData() call.
- Reversely, if the processor is on the sending end, the field will be read, possibly transformed, and sent appropriately to the other side.
- */
- void DEC::attachLocalField(const ParaFIELD* field, bool ownPt)
- {
- if(!isInUnion())
- return ;
- if(_owns_field)
- delete _local_field;
- _local_field=field;
- _owns_field=ownPt;
- _comm_interface=&(field->getTopology()->getProcGroup()->getCommInterface());
- compareFieldAndMethod();
- }
-
- /*! Attaches a local field to a DEC. The method will test whether the processor
- is on the source or the target side and will associate the mesh underlying the
- field to the local side.
-
- If the processor is on the receiving end of the DEC, the field
- will be updated by a recvData() call.
- Reversely, if the processor is on the sending end, the field will be read, possibly transformed,
- and sent appropriately to the other side.
- */
-
- void DEC::attachLocalField(MEDCouplingFieldDouble* field)
- {
- if(!isInUnion())
- return ;
- ProcessorGroup* local_group;
- if (_source_group->containsMyRank())
- local_group=_source_group;
- else if (_target_group->containsMyRank())
- local_group=_target_group;
- else
- throw INTERP_KERNEL::Exception("Invalid procgroup for field attachment to DEC");
- ParaMESH *paramesh=new ParaMESH((MEDCouplingPointSet *)field->getMesh(),*local_group,field->getMesh()->getName());
- ParaFIELD *tmp=new ParaFIELD(field, paramesh, *local_group);
- tmp->setOwnSupport(true);
- attachLocalField(tmp,true);
- //_comm_interface=&(local_group->getCommInterface());
- }
-
- /*!
- Attaches a local field to a DEC.
- If the processor is on the receiving end of the DEC, the field
- will be updated by a recvData() call.
- Reversely, if the processor is on the sending end, the field will be read, possibly transformed, and sent appropriately to the other side.
- The field type is a generic ICoCo Field, so that the DEC can couple a number of different fields :
- - a ICoCo::MEDField, that is created from a MEDCoupling structure
- - a ICOCo::TrioField, that is created from tables extracted from a TRIO-U structure.
-
- */
-
- void DEC::attachLocalField(const ICoCo::Field* field)
- {
- if(!isInUnion())
- return ;
- const ICoCo::MEDField* medfield=dynamic_cast<const ICoCo::MEDField*> (field);
- if(medfield !=0)
- {
- attachLocalField(medfield->getField());
- return;
- }
- const ICoCo::TrioField* triofield=dynamic_cast<const ICoCo::TrioField*> (field);
- if (triofield !=0)
- {
- ProcessorGroup* localgroup;
- if (_source_group->containsMyRank())
- localgroup=_source_group;
- else
- localgroup=_target_group;
- delete _icoco_field;
-
- _icoco_field=new ICoCo::MEDField(*const_cast<ICoCo::TrioField* >(triofield));
- attachLocalField(_icoco_field);
- return;
- }
- throw INTERP_KERNEL::Exception("incompatible field type");
- }
-
- /*!
- Computes the field norm over its support
- on the source side and renormalizes the field on the target side
- so that the norms match.
-
- \f[
- I_{source}=\sum_{i=1}^{n_{source}}V_{i}.|\Phi^{source}_{i}|^2,
- \f]
-
- \f[
- I_{target}=\sum_{i=1}^{n_{target}}V_{i}.|\Phi^{target}_{i}|^2,
- \f]
-
- \f[
- \Phi^{target}:=\Phi^{target}.\sqrt{I_{source}/I_{target}}.
- \f]
-
- */
- void DEC::renormalizeTargetField(bool isWAbs)
- {
- if (_source_group->containsMyRank())
- for (int icomp=0; icomp<_local_field->getField()->getArray()->getNumberOfComponents(); icomp++)
- {
- double total_norm = _local_field->getVolumeIntegral(icomp+1,isWAbs);
- double source_norm = total_norm;
- _comm_interface->broadcast(&source_norm, 1, MPI_DOUBLE, 0,* dynamic_cast<MPIProcessorGroup*>(_union_group)->getComm());
-
- }
- if (_target_group->containsMyRank())
- {
- for (int icomp=0; icomp<_local_field->getField()->getArray()->getNumberOfComponents(); icomp++)
- {
- double total_norm = _local_field->getVolumeIntegral(icomp+1,isWAbs);
- double source_norm=total_norm;
- _comm_interface->broadcast(&source_norm, 1, MPI_DOUBLE, 0,* dynamic_cast<MPIProcessorGroup*>(_union_group)->getComm());
-
- if (fabs(total_norm)>1e-100)
- _local_field->getField()->applyLin(source_norm/total_norm,0.0,icomp+1);
- }
- }
- }
- /*! @} */
-
- bool DEC::isInSourceSide() const
- {
- if(!_source_group)
- return false;
- return _source_group->containsMyRank();
- }
-
- bool DEC::isInTargetSide() const
- {
- if(!_target_group)
- return false;
- return _target_group->containsMyRank();
- }
-
- bool DEC::isInUnion() const
- {
- if(!_union_group)
- return false;
- return _union_group->containsMyRank();
- }
-
- void DEC::compareFieldAndMethod() const throw(INTERP_KERNEL::Exception)
- {
- if (_local_field)
- {
- TypeOfField entity = _local_field->getField()->getTypeOfField();
- if ( getMethod() == "P0" )
- {
- if ( entity != ON_CELLS )
- throw INTERP_KERNEL::Exception("Field support and interpolation method mismatch."
- " For P0 interpolation, field must be on MED_CELL's");
- }
- else if ( getMethod() == "P1" )
- {
- if ( entity != ON_NODES )
- throw INTERP_KERNEL::Exception("Field support and interpolation method mismatch."
- " For P1 interpolation, field must be on MED_NODE's");
- }
- else if ( getMethod() == "P1d" )
- {
- if ( entity != ON_CELLS )
- throw INTERP_KERNEL::Exception("Field support and interpolation method mismatch."
- " For P1d interpolation, field must be on MED_CELL's");
- if ( _target_group->containsMyRank() )
- throw INTERP_KERNEL::Exception("Projection to P1d field not supported");
- }
- else
- {
- throw INTERP_KERNEL::Exception("Unknown interpolation method. Possible methods: P0, P1, P1d");
- }
- }
- }
-
- /*!
- If way==true, source procs call sendData() and target procs call recvData().
- if way==false, it's the other way round.
- */
- void DEC::sendRecvData(bool way)
- {
- if(!isInUnion())
- return;
- if(isInSourceSide())
- {
- if(way)
- sendData();
- else
- recvData();
- }
- else if(isInTargetSide())
- {
- if(way)
- recvData();
- else
- sendData();
- }
}
}
#include "NormalizedUnstructuredMesh.hxx"
#include "DECOptions.hxx"
-#include <set>
-
-namespace ICoCo
-{
- class Field;
-}
-
namespace ParaMEDMEM
{
- class ProcessorGroup;
- class ParaFIELD;
class CommInterface;
class DEC : public DECOptions
{
public:
- DEC():_local_field(0) { }
- DEC(ProcessorGroup& source_group, ProcessorGroup& target_group);
- DEC(const std::set<int>& src_ids, const std::set<int>& trg_ids,
- const MPI_Comm& world_comm=MPI_COMM_WORLD);
- void setNature(NatureOfField nature);
- void attachLocalField( MEDCouplingFieldDouble* field);
- void attachLocalField(const ParaFIELD* field, bool ownPt=false);
- void attachLocalField(const ICoCo::Field* field);
-
- virtual void prepareSourceDE() = 0;
- virtual void prepareTargetDE() = 0;
- virtual void recvData() = 0;
- virtual void sendData() = 0;
- void sendRecvData(bool way=true);
virtual void synchronize() = 0;
+ virtual void sendRecvData(bool way=true) = 0;
virtual ~DEC();
- virtual void computeProcGroup() { }
- void renormalizeTargetField(bool isWAbs);
- //
- ProcessorGroup *getSourceGrp() const { return _source_group; }
- ProcessorGroup *getTargetGrp() const { return _target_group; }
- bool isInSourceSide() const;
- bool isInTargetSide() const;
- bool isInUnion() const;
- protected:
- void compareFieldAndMethod() const throw(INTERP_KERNEL::Exception);
protected:
- const ParaFIELD* _local_field;
- //! Processor group representing the union of target and source processors
- ProcessorGroup* _union_group;
- ProcessorGroup* _source_group;
- ProcessorGroup* _target_group;
-
const CommInterface* _comm_interface;
- bool _owns_field;
- bool _owns_groups;
- private:
- ICoCo::Field* _icoco_field;
};
}
--- /dev/null
+// Copyright (C) 2007-2010 CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#include "DisjointDEC.hxx"
+#include "CommInterface.hxx"
+#include "Topology.hxx"
+#include "BlockTopology.hxx"
+#include "ComponentTopology.hxx"
+#include "ParaFIELD.hxx"
+#include "ParaMESH.hxx"
+#include "ICoCoField.hxx"
+#include "ICoCoMEDField.hxx"
+#include "ICoCoTrioField.hxx"
+#include "MPIProcessorGroup.hxx"
+
+#include <cmath>
+
+/*! \defgroup dec DEC
+ *
+ * \section decintroduction Introduction
+ *
+ * Interface class for creation of a link between two
+ * processor groups for exhanging mesh or field data.
+ * The DEC is defined by attaching a field on the receiving or on the
+ * sending side.
+ * On top of attaching a ParaMEDMEM::FIELD, it is possible to
+ * attach a ICoCo::Field. This class is an abstract class that enables
+ * coupling of codes that respect the ICoCo interface \ref icoco. It has two implementations:
+ * one for codes that express their fields as MEDCoupling fields (ICoCo::MEDField) and one
+ * for codes that express their fields as Trio/U fields.
+ *
+ * \section dec_options DEC Options
+ * Options supported by DEC objects are
+ *
+ * <TABLE BORDER=1 >
+ * <TR><TD>Option</TD><TD>Description</TD><TD>Default value</TD></TR>
+ * <TR><TD>ForcedRenormalization</TD><TD>After receiving data, the target field is renormalized so that L2-norms of the source and target fields match.</TD><TD> false </TD></TR>
+ *</TABLE>
+
+
+ The following code excerpt shows how to set options for an object that inherits from DEC :
+
+ \code
+ InterpKernelDEC dec(source_group,target_group);
+ dec.setOptions("ForcedRenormalization",true);
+ dec.attachLocalField(field);
+ dec.synchronize();
+ if (source_group.containsMyRank())
+ dec.sendData();
+ else
+ dec.recvData();
+ \endcode
+*/
+
+namespace ParaMEDMEM
+{
+
+
+ /*! \addtogroup dec
+ @{
+ */
+ DisjointDEC::DisjointDEC(ProcessorGroup& source_group, ProcessorGroup& target_group):_local_field(0),
+ _source_group(&source_group),
+ _target_group(&target_group),
+ _owns_field(false),
+ _owns_groups(false),
+ _icoco_field(0)
+ {
+ _union_group = source_group.fuse(target_group);
+ }
+
+ DisjointDEC::DisjointDEC(const std::set<int>& source_ids, const std::set<int>& target_ids, const MPI_Comm& world_comm):_local_field(0),
+ _owns_field(false),
+ _owns_groups(true),
+ _icoco_field(0)
+ {
+ ParaMEDMEM::CommInterface comm;
+ // Create the list of procs including source and target
+ std::set<int> union_ids; // source and target ids in world_comm
+ union_ids.insert(source_ids.begin(),source_ids.end());
+ union_ids.insert(target_ids.begin(),target_ids.end());
+ if(union_ids.size()!=(source_ids.size()+target_ids.size()))
+ throw INTERP_KERNEL::Exception("DisjointDEC constructor : source_ids and target_ids overlap partially or fully. This type of DEC does not support it ! OverlapDEC class could be the solution !");
+ int* union_ranks_world=new int[union_ids.size()]; // ranks of sources and targets in world_comm
+ std::copy(union_ids.begin(), union_ids.end(), union_ranks_world);
+
+ // Create a communicator on these procs
+ MPI_Group union_group,world_group;
+ comm.commGroup(world_comm,&world_group);
+ comm.groupIncl(world_group,union_ids.size(),union_ranks_world,&union_group);
+ MPI_Comm union_comm;
+ comm.commCreate(world_comm,union_group,&union_comm);
+ delete[] union_ranks_world;
+
+ if (union_comm==MPI_COMM_NULL)
+ { // This process is not in union
+ _source_group=0;
+ _target_group=0;
+ _union_group=0;
+ return;
+ }
+
+ // Translate source_ids and target_ids from world_comm to union_comm
+ int* source_ranks_world=new int[source_ids.size()]; // ranks of sources in world_comm
+ std::copy(source_ids.begin(), source_ids.end(),source_ranks_world);
+ int* source_ranks_union=new int[source_ids.size()]; // ranks of sources in union_comm
+ int* target_ranks_world=new int[target_ids.size()]; // ranks of targets in world_comm
+ std::copy(target_ids.begin(), target_ids.end(),target_ranks_world);
+ int* target_ranks_union=new int[target_ids.size()]; // ranks of targets in union_comm
+ MPI_Group_translate_ranks(world_group,source_ids.size(),source_ranks_world,union_group,source_ranks_union);
+ MPI_Group_translate_ranks(world_group,target_ids.size(),target_ranks_world,union_group,target_ranks_union);
+ std::set<int> source_ids_union;
+ for (int i=0;i<(int)source_ids.size();i++)
+ source_ids_union.insert(source_ranks_union[i]);
+ std::set<int> target_ids_union;
+ for (int i=0;i<(int)target_ids.size();i++)
+ target_ids_union.insert(target_ranks_union[i]);
+ delete [] source_ranks_world;
+ delete [] source_ranks_union;
+ delete [] target_ranks_world;
+ delete [] target_ranks_union;
+
+ // Create the MPIProcessorGroups
+ _source_group = new MPIProcessorGroup(comm,source_ids_union,union_comm);
+ _target_group = new MPIProcessorGroup(comm,target_ids_union,union_comm);
+ _union_group = _source_group->fuse(*_target_group);
+
+ }
+
+ DisjointDEC::~DisjointDEC()
+ {
+ if(_owns_field)
+ delete _local_field;
+ if(_owns_groups)
+ {
+ delete _source_group;
+ delete _target_group;
+ }
+ delete _icoco_field;
+ delete _union_group;
+ }
+
+ void DisjointDEC::setNature(NatureOfField nature)
+ {
+ if(_local_field)
+ _local_field->getField()->setNature(nature);
+ }
+
+ /*! Attaches a local field to a DEC.
+ If the processor is on the receiving end of the DEC, the field
+ will be updated by a recvData() call.
+ Reversely, if the processor is on the sending end, the field will be read, possibly transformed, and sent appropriately to the other side.
+ */
+ void DisjointDEC::attachLocalField(const ParaFIELD* field, bool ownPt)
+ {
+ if(!isInUnion())
+ return ;
+ if(_owns_field)
+ delete _local_field;
+ _local_field=field;
+ _owns_field=ownPt;
+ _comm_interface=&(field->getTopology()->getProcGroup()->getCommInterface());
+ compareFieldAndMethod();
+ }
+
+ /*! Attaches a local field to a DEC. The method will test whether the processor
+ is on the source or the target side and will associate the mesh underlying the
+ field to the local side.
+
+ If the processor is on the receiving end of the DEC, the field
+ will be updated by a recvData() call.
+ Reversely, if the processor is on the sending end, the field will be read, possibly transformed,
+ and sent appropriately to the other side.
+ */
+
+ void DisjointDEC::attachLocalField(MEDCouplingFieldDouble* field)
+ {
+ if(!isInUnion())
+ return ;
+ ProcessorGroup* local_group;
+ if (_source_group->containsMyRank())
+ local_group=_source_group;
+ else if (_target_group->containsMyRank())
+ local_group=_target_group;
+ else
+ throw INTERP_KERNEL::Exception("Invalid procgroup for field attachment to DEC");
+ ParaMESH *paramesh=new ParaMESH((MEDCouplingPointSet *)field->getMesh(),*local_group,field->getMesh()->getName());
+ ParaFIELD *tmp=new ParaFIELD(field, paramesh, *local_group);
+ tmp->setOwnSupport(true);
+ attachLocalField(tmp,true);
+ //_comm_interface=&(local_group->getCommInterface());
+ }
+
+ /*!
+ Attaches a local field to a DEC.
+ If the processor is on the receiving end of the DEC, the field
+ will be updated by a recvData() call.
+ Reversely, if the processor is on the sending end, the field will be read, possibly transformed, and sent appropriately to the other side.
+ The field type is a generic ICoCo Field, so that the DEC can couple a number of different fields :
+ - a ICoCo::MEDField, that is created from a MEDCoupling structure
+ - a ICOCo::TrioField, that is created from tables extracted from a TRIO-U structure.
+
+ */
+ void DisjointDEC::attachLocalField(const ICoCo::Field* field)
+ {
+ if(!isInUnion())
+ return ;
+ const ICoCo::MEDField* medfield=dynamic_cast<const ICoCo::MEDField*> (field);
+ if(medfield !=0)
+ {
+ attachLocalField(medfield->getField());
+ return;
+ }
+ const ICoCo::TrioField* triofield=dynamic_cast<const ICoCo::TrioField*> (field);
+ if (triofield !=0)
+ {
+ ProcessorGroup* localgroup;
+ if (_source_group->containsMyRank())
+ localgroup=_source_group;
+ else
+ localgroup=_target_group;
+ delete _icoco_field;
+
+ _icoco_field=new ICoCo::MEDField(*const_cast<ICoCo::TrioField* >(triofield));
+ attachLocalField(_icoco_field);
+ return;
+ }
+ throw INTERP_KERNEL::Exception("incompatible field type");
+ }
+
+ /*!
+ Computes the field norm over its support
+ on the source side and renormalizes the field on the target side
+ so that the norms match.
+
+ \f[
+ I_{source}=\sum_{i=1}^{n_{source}}V_{i}.|\Phi^{source}_{i}|^2,
+ \f]
+
+ \f[
+ I_{target}=\sum_{i=1}^{n_{target}}V_{i}.|\Phi^{target}_{i}|^2,
+ \f]
+
+ \f[
+ \Phi^{target}:=\Phi^{target}.\sqrt{I_{source}/I_{target}}.
+ \f]
+
+ */
+ void DisjointDEC::renormalizeTargetField(bool isWAbs)
+ {
+ if (_source_group->containsMyRank())
+ for (int icomp=0; icomp<_local_field->getField()->getArray()->getNumberOfComponents(); icomp++)
+ {
+ double total_norm = _local_field->getVolumeIntegral(icomp+1,isWAbs);
+ double source_norm = total_norm;
+ _comm_interface->broadcast(&source_norm, 1, MPI_DOUBLE, 0,* dynamic_cast<MPIProcessorGroup*>(_union_group)->getComm());
+
+ }
+ if (_target_group->containsMyRank())
+ {
+ for (int icomp=0; icomp<_local_field->getField()->getArray()->getNumberOfComponents(); icomp++)
+ {
+ double total_norm = _local_field->getVolumeIntegral(icomp+1,isWAbs);
+ double source_norm=total_norm;
+ _comm_interface->broadcast(&source_norm, 1, MPI_DOUBLE, 0,* dynamic_cast<MPIProcessorGroup*>(_union_group)->getComm());
+
+ if (fabs(total_norm)>1e-100)
+ _local_field->getField()->applyLin(source_norm/total_norm,0.0,icomp+1);
+ }
+ }
+ }
+ /*! @} */
+
+ bool DisjointDEC::isInSourceSide() const
+ {
+ if(!_source_group)
+ return false;
+ return _source_group->containsMyRank();
+ }
+
+ bool DisjointDEC::isInTargetSide() const
+ {
+ if(!_target_group)
+ return false;
+ return _target_group->containsMyRank();
+ }
+
+ bool DisjointDEC::isInUnion() const
+ {
+ if(!_union_group)
+ return false;
+ return _union_group->containsMyRank();
+ }
+
+ void DisjointDEC::compareFieldAndMethod() const throw(INTERP_KERNEL::Exception)
+ {
+ if (_local_field)
+ {
+ TypeOfField entity = _local_field->getField()->getTypeOfField();
+ if ( getMethod() == "P0" )
+ {
+ if ( entity != ON_CELLS )
+ throw INTERP_KERNEL::Exception("Field support and interpolation method mismatch."
+ " For P0 interpolation, field must be on MED_CELL's");
+ }
+ else if ( getMethod() == "P1" )
+ {
+ if ( entity != ON_NODES )
+ throw INTERP_KERNEL::Exception("Field support and interpolation method mismatch."
+ " For P1 interpolation, field must be on MED_NODE's");
+ }
+ else if ( getMethod() == "P1d" )
+ {
+ if ( entity != ON_CELLS )
+ throw INTERP_KERNEL::Exception("Field support and interpolation method mismatch."
+ " For P1d interpolation, field must be on MED_CELL's");
+ if ( _target_group->containsMyRank() )
+ throw INTERP_KERNEL::Exception("Projection to P1d field not supported");
+ }
+ else
+ {
+ throw INTERP_KERNEL::Exception("Unknown interpolation method. Possible methods: P0, P1, P1d");
+ }
+ }
+ }
+
+ /*!
+ If way==true, source procs call sendData() and target procs call recvData().
+ if way==false, it's the other way round.
+ */
+ void DisjointDEC::sendRecvData(bool way)
+ {
+ if(!isInUnion())
+ return;
+ if(isInSourceSide())
+ {
+ if(way)
+ sendData();
+ else
+ recvData();
+ }
+ else if(isInTargetSide())
+ {
+ if(way)
+ recvData();
+ else
+ sendData();
+ }
+ }
+}
--- /dev/null
+// Copyright (C) 2007-2010 CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#ifndef __DISJOINTDEC_HXX__
+#define __DISJOINTDEC_HXX__
+
+#include "MEDCouplingFieldDouble.hxx"
+#include "NormalizedUnstructuredMesh.hxx"
+#include "DEC.hxx"
+
+#include <mpi.h>
+#include <set>
+
+namespace ICoCo
+{
+ class Field;
+}
+
+namespace ParaMEDMEM
+{
+ class ProcessorGroup;
+ class ParaFIELD;
+
+ class DisjointDEC : public DEC
+ {
+ public:
+ DisjointDEC():_local_field(0) { }
+ DisjointDEC(ProcessorGroup& source_group, ProcessorGroup& target_group);
+ DisjointDEC(const std::set<int>& src_ids, const std::set<int>& trg_ids,
+ const MPI_Comm& world_comm=MPI_COMM_WORLD);
+ void setNature(NatureOfField nature);
+ void attachLocalField( MEDCouplingFieldDouble* field);
+ void attachLocalField(const ParaFIELD* field, bool ownPt=false);
+ void attachLocalField(const ICoCo::Field* field);
+
+ virtual void prepareSourceDE() = 0;
+ virtual void prepareTargetDE() = 0;
+ virtual void recvData() = 0;
+ virtual void sendData() = 0;
+ void sendRecvData(bool way=true);
+ virtual void synchronize() = 0;
+ virtual ~DisjointDEC();
+ virtual void computeProcGroup() { }
+ void renormalizeTargetField(bool isWAbs);
+ //
+ ProcessorGroup *getSourceGrp() const { return _source_group; }
+ ProcessorGroup *getTargetGrp() const { return _target_group; }
+ bool isInSourceSide() const;
+ bool isInTargetSide() const;
+ bool isInUnion() const;
+ protected:
+ void compareFieldAndMethod() const throw(INTERP_KERNEL::Exception);
+ protected:
+ const ParaFIELD* _local_field;
+ //! Processor group representing the union of target and source processors
+ ProcessorGroup* _union_group;
+ ProcessorGroup* _source_group;
+ ProcessorGroup* _target_group;
+
+ const CommInterface* _comm_interface;
+ bool _owns_field;
+ bool _owns_groups;
+ private:
+ ICoCo::Field* _icoco_field;
+ };
+}
+
+#endif
INTERP_KERNEL::DirectedBoundingBox dbb;
double* distant_bb = _domain_bounding_boxes+rank*dbb.dataSize(_local_cell_mesh_space_dim);
dbb.setData(distant_bb);
- _local_cell_mesh->giveElemsInBoundingBox(dbb,getBoundingBoxAdjustment(),elems);
+ _local_cell_mesh->getCellsInBoundingBox(dbb,getBoundingBoxAdjustment(),elems);
#else
double* distant_bb = _domain_bounding_boxes+rank*2*_local_cell_mesh_space_dim;
- _local_cell_mesh->giveElemsInBoundingBox(distant_bb,getBoundingBoxAdjustment(),elems);
+ _local_cell_mesh->getCellsInBoundingBox(distant_bb,getBoundingBoxAdjustment(),elems);
#endif
DataArrayInt *distant_ids_send;
// First stage : exchanging sizes
// ------------------------------
+ vector<double> tinyInfoLocalD,tinyInfoDistantD(1);//not used for the moment
vector<int> tinyInfoLocal,tinyInfoDistant;
vector<string> tinyInfoLocalS;
//Getting tiny info of local mesh to allow the distant proc to initialize and allocate
//the transmitted mesh.
- local_mesh->getTinySerializationInformation(tinyInfoLocal,tinyInfoLocalS);
+ local_mesh->getTinySerializationInformation(tinyInfoLocalD,tinyInfoLocal,tinyInfoLocalS);
tinyInfoLocal.push_back(distant_ids_send->getNumberOfTuples());
tinyInfoDistant.resize(tinyInfoLocal.size());
std::fill(tinyInfoDistant.begin(),tinyInfoDistant.end(),0);
//serialization of local mesh to send data to distant proc.
local_mesh->serialize(v1Local,v2Local);
//Building the right instance of copy of distant mesh.
- MEDCouplingPointSet *distant_mesh_tmp=MEDCouplingPointSet::buildInstanceFromMeshType((MEDCouplingMeshType)tinyInfoDistant[0]);
+ MEDCouplingPointSet *distant_mesh_tmp=MEDCouplingPointSet::BuildInstanceFromMeshType((MEDCouplingMeshType)tinyInfoDistant[0]);
std::vector<std::string> unusedTinyDistantSts;
distant_mesh_tmp->resizeForUnserialization(tinyInfoDistant,v1Distant,v2Distant,unusedTinyDistantSts);
int nbLocalElems=0;
//
distant_mesh=distant_mesh_tmp;
//finish unserialization
- distant_mesh->unserialization(tinyInfoDistant,v1Distant,v2Distant,unusedTinyDistantSts);
+ distant_mesh->unserialization(tinyInfoDistantD,tinyInfoDistant,v1Distant,v2Distant,unusedTinyDistantSts);
//
distant_ids_recv=new int[tinyInfoDistant.back()];
comm_interface.sendRecv((void *)distant_ids_send->getConstPointer(),tinyInfoLocal.back(), MPI_INT,
#ifndef __EXPLICITCOINCIDENTDEC_HXX__
#define __EXPLICITCOINCIDENTDEC_HXX__
-#include "DEC.hxx"
+#include "DisjointDEC.hxx"
#include "ExplicitMapping.hxx"
#include "ExplicitTopology.hxx"
{
class BlockTopology;
- class ExplicitCoincidentDEC : public DEC
+ class ExplicitCoincidentDEC : public DisjointDEC
{
public:
ExplicitCoincidentDEC();
//creating a connectivity table that complies to MED (1 indexing)
//and passing it to _mesh
int* conn=new int[triofield._nodes_per_elem];
+ _mesh->setMeshDimension(triofield._mesh_dim);
for (int i=0; i<triofield._nb_elems;i++)
{
for(int j=0;j<triofield._nodes_per_elem;j++)
}
delete[] conn;
- _mesh->setMeshDimension(triofield._mesh_dim);
_mesh->finishInsertingCells();
//field on the sending end
*/
InterpKernelDEC::InterpKernelDEC(ProcessorGroup& source_group, ProcessorGroup& target_group):
- DEC(source_group, target_group),_interpolation_matrix(0)
+ DisjointDEC(source_group, target_group),_interpolation_matrix(0)
{
}
InterpKernelDEC::InterpKernelDEC(const std::set<int>& src_ids, const std::set<int>& trg_ids,
- const MPI_Comm& world_comm):DEC(src_ids,trg_ids,world_comm),
+ const MPI_Comm& world_comm):DisjointDEC(src_ids,trg_ids,world_comm),
_interpolation_matrix(0)
{
}
#ifndef __INTERPKERNELDEC_HXX__
#define __INTERPKERNELDEC_HXX__
-#include "DEC.hxx"
+#include "DisjointDEC.hxx"
#include "MxN_Mapping.hxx"
#include "InterpolationOptions.hxx"
{
class InterpolationMatrix;
- class InterpKernelDEC : public DEC, public INTERP_KERNEL::InterpolationOptions
+ class InterpKernelDEC : public DisjointDEC, public INTERP_KERNEL::InterpolationOptions
{
public:
InterpKernelDEC();
#include "TranslationRotationMatrix.hxx"
#include "Interpolation.hxx"
#include "Interpolation1D.txx"
-#include "Interpolation2DCurve.txx"
+#include "Interpolation2DCurve.hxx"
#include "Interpolation2D.txx"
-#include "Interpolation3DSurf.txx"
+#include "Interpolation3DSurf.hxx"
#include "Interpolation3D.txx"
#include "MEDCouplingUMesh.hxx"
#include "MEDCouplingNormalizedUnstructuredMesh.txx"
#ifndef __MPIPROCESSORGROUP_HXX__
#define __MPIPROCESSORGROUP_HXX__
+#include "ProcessorGroup.hxx"
+
#include <set>
#include <mpi.h>
namespace ParaMEDMEM
{
- class ProcessorGroup;
class CommInterface;
class MPIProcessorGroup : public ProcessorGroup
ExplicitTopology.hxx\
ParaFIELD.hxx\
DEC.hxx\
+DisjointDEC.hxx\
+OverlapDEC.hxx\
DECOptions.hxx\
MxN_Mapping.hxx\
+OverlapMapping.hxx\
StructuredCoincidentDEC.hxx\
InterpolationMatrix.hxx\
+OverlapInterpolationMatrix.hxx\
InterpKernelDEC.hxx\
ExplicitCoincidentDEC.hxx\
ElementLocator.hxx\
+OverlapElementLocator.hxx\
ExplicitMapping.hxx\
ICoCoField.hxx \
ICoCoMEDField.hxx \
ComponentTopology.cxx\
MPIAccess.cxx \
InterpolationMatrix.cxx\
+OverlapInterpolationMatrix.cxx\
StructuredCoincidentDEC.cxx\
ExplicitCoincidentDEC.cxx\
InterpKernelDEC.cxx\
ElementLocator.cxx\
+OverlapElementLocator.cxx\
MPIAccessDEC.cxx \
TimeInterpolator.cxx \
LinearTimeInterpolator.cxx\
DEC.cxx\
+DisjointDEC.cxx\
+OverlapDEC.cxx\
ExplicitTopology.cxx\
MxN_Mapping.cxx\
+OverlapMapping.cxx\
ICoCoMEDField.cxx\
ICoCoField.cxx\
ICoCoTrioField.cxx\
namespace ParaMEDMEM
{
+ MxN_Mapping::MxN_Mapping()
+ {
+ }
+
MxN_Mapping::MxN_Mapping(const ProcessorGroup& source_group, const ProcessorGroup& target_group,const DECOptions& dec_options)
: DECOptions(dec_options),_union_group(source_group.fuse(target_group))
--- /dev/null
+// Copyright (C) 2007-2010 CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#include "OverlapDEC.hxx"
+#include "CommInterface.hxx"
+#include "ParaFIELD.hxx"
+#include "MPIProcessorGroup.hxx"
+#include "OverlapElementLocator.hxx"
+#include "OverlapInterpolationMatrix.hxx"
+/*!
+ \defgroup overlapdec OverlapDEC
+ The OverlapDEC enables the \ref InterpKerRemapGlobal "conservative remapping" of fields between two parallel codes. This remapping is based on the computation of intersection volumes on a \b same \b processor \b group. On this processor group is defined a field template defined on A and an another on B. The computation is possible for 3D meshes, 2D meshes, 3D-surface meshes, 1D meshes and 2D-curve meshes. Dimensions must be similar for code A and code B.
+ The main difference with \ref interpkerneldec is that this DEC manage 2 field-templates on each process in processor group A and B called in code source and target.
+ Furthermore all process in process group cooperates in global interpolation matrix computation. In this sense InterpKernelDEC is a specialization of OverlapDEC.
+
+ \section ParaMEDMEMOverlapDECAlgorithmDescription Algorithm Description
+
+ Let's consider the following use case that is ran in ParaMEDMEMTest_OverlapDEC.cxx to describes the different steps in computation. Processor group contains 3 processors.
+ \anchor ParaMEDMEMOverlapDECImgTest1
+ \image html OverlapDEC1.png "Example showing the use case to explain the different steps."
+
+ \subsection ParaMEDMEMOverlapDECAlgoStep1 Step 1 : Bounding box exchange and global interaction between procs computation.
+
+ In order to reduce as fas as possible number of exchange among processors every procs computes a bounding box for A and B. Then a AllToAll is performed so that
+ every procs can compute the \b global interactions between procs.
+ This computation leads every procs to compute the same global TODO list expressed as a list of pair. A pair (x,y) means that proc \b x fieldtemplate A can interacts (because bounding boxes interacts) with fieltemplate B of proc \b y.
+ In the \ref ParaMEDMEMOverlapDECImgTest1 "example above" this computation leads to the following a \b global TODO list :
+
+ \b (0,0),(0,1),(1,0),(1,2),(2,0),(2,1),(2,2)
+
+ Here pair (0,2) does not appear because bounding box of fieldtemplateA of proc#2 does not interact with proc#0 of fieldtemplate B.
+
+ Stage performed by ParaMEDMEM::OverlapElementLocator::computeBoundingBoxes.
+
+ \subsection ParaMEDMEMOverlapDECAlgoStep2 Step 2 : Computation of local TODO list
+
+ Starting from global interaction previously computed in \ref ParaMEDMEMOverlapDECAlgoStep1 "Step 1", each proc computes the TODO list per proc.
+ The following rules is chosen : a pair (x,y) can be treated by either proc #x or proc #y, in order to reduce the amount of data transfert accross
+ procs. The algorithm chosen for loadbalancing is the following : Each proc as an empty \b local TODO list at the beginning. The for each pair (k,m) in
+ \b global TODO list if proc#k has less temporary local list than proc#m pair (k,m) is added to temparary local TODO list of proc#k.
+ If proc#m has less temporary local TODO list than proc#k pair (k,m) is added to temparary local TODO list of proc#m.
+ If proc#k and proc#m have the same amount of temporary local TODO list pair (k,m) is added to temparary local TODO list of proc#k.
+
+ In the \ref ParaMEDMEMOverlapDECImgTest1 "example above" this computation leads to the following a local TODO list :
+
+ - proc#0 : (0,0)
+ - proc#1 : (0,1),(1,0)
+ - proc#2 : (1,2),(2,0),(2,1),(2,2)
+
+ Stage performed by ParaMEDMEM::OverlapElementLocator::computeBoundingBoxes too.
+
+ The algorithm described here is not perfect for this use case. It will be enhanced soon, I hope.
+
+ At this stage each proc knows precisely its \b local TODO list (at interpolation sense). The \b local TODO list of other procs than local
+ is kept for future computation.
+
+ \subsection ParaMEDMEMOverlapDECAlgoStep3 Step 3 : Matrix echange between procs
+
+ At this step knows its \b local TODO list, the aim now is to exchange field-templates between procs. Each proc computes knowing TODO list per
+ proc computed in \ref ParaMEDMEMOverlapDECAlgoStep2 "Step 2" the exchange TODO list :
+
+ In the \ref ParaMEDMEMOverlapDECImgTest1 "example above" the exchange TODO list gives the following results :
+
+ Sending TODO list per proc :
+
+ - proc #0 : Send fieldtemplate A to Proc#1, Send fieldtemplate B to Proc#1, Send fieldtemplate B to Proc#2
+ - Proc #1 : Send fieldtemplate A to Proc#2, Send fieldtemplate B to Proc#2
+ - Proc #2 : No send.
+
+ Receiving TODO list per proc :
+
+ - proc #0 : No receiving
+ - proc #1 : receiving fieldtemplate A from Proc#0, receiving fieldtemplate B from Proc#0
+ - proc #2 : receiving fieldtemplate B from Proc#0, receiving fieldtemplate A from Proc#1, receiving fieldtemplate B from Proc#1
+
+ To avoid as far as possible big amount of exchange between procs only relevant part of mesh. For a proc#k sending fieldtemplate A to fieldtemplate B
+ of proc #m. In this case proc#k computes part of mesh A in boundingbox B of proc#m. It implies that the corresponding cellIds or nodeIds of
+ corresponding part are sent to proc #m too.
+
+ Let's consider the couple (k,m) in TODO list. This couple is treated by either k or m as seen \ref ParaMEDMEMOverlapDECAlgoStep2 "here in Step2".
+
+ As it will be dealt in Step 6, at the end for final matrix-vector computation the result matrix of the couple (k,m) anywhere it is computed (proc #k or proc #m)
+ it will be stored in \b proc#m.
+
+ - If proc #k is in charge (performs matrix computation) of this couple (k,m) target ids (cells or nodes) of mesh in proc #m are renumbered, because proc #m has stripped
+ its target mesh to avoid big amount of data to transfer. In this case as it is finally proc #m in charge finally of the matrix, proc #k must keep preciously the
+ source ids needed to be sent to proc#m. No problem will appear for matrix assembling in proc m, for source ids because no restriction done.
+ Concerning source ids to be sent for matrix-vector computation, proc k will known precisely which source ids field values to send to proc #m.
+ This is incarnated by OverlapMapping::keepTracksOfTargetIds in proc m.
+
+ - If proc #m is in charge (performs matrix computation) of this couple (k,m) source ids (cells or nodes) of mesh in proc #k are renumbered, because proc #k has stripped
+ its source mesh to avoid big amount of data to transfer. In this case as it is finally proc #m in charge finally of the matrix, proc #m receive the source ids
+ from remote proc #k so the matrix is directly OK, no need of renumbering will be needed in \ref ParaMEDMEMOverlapDECAlgoStep5 "Step 5". But proc k must
+ keep tracks of sent ids to proc m for matrix-vector computation.
+ This is incarnated by OverlapMapping::keepTracksOfSourceIds in proc k.
+
+ This step is performed in ParaMEDMEM::OverlapElementLocator::exchangeMeshes method.
+
+ \subsection ParaMEDMEMOverlapDECAlgoStep4 Step 4 : The interpolation matrix computation
+
+ After mesh exchange in \ref ParaMEDMEMOverlapDECAlgoStep3 "Step3" each proc has all information to perform its \b local TODO list computed in
+ \ref ParaMEDMEMOverlapDECAlgoStep2 "Step2". This step is so potentially CPU costly. That's why the \b local TODO list per proc is expected to
+ be as well balanced as possible.
+
+ The interpolation is performed as \ref ParaMEDMEM::MEDCouplingRemapper "Remapper" does.
+
+ This operation is performed by OverlapInterpolationMatrix::addContribution method.
+
+ \subsection ParaMEDMEMOverlapDECAlgoStep5 Step 5 : Global matrix construction.
+
+ After having performed the TODO list at the end of \ref ParaMEDMEMOverlapDECAlgoStep4 "Step4" it is needed to assemble the final matrix.
+
+ The final aim is to have a distributed matrix \f$ M_k \f$ on each proc#k. In order to reduce data exchange during matrix product process.
+ \f$ M_k \f$ is built using sizeof(Proc group) \c std::vector< \c std::map<int,double> \c >.
+
+ For a proc#k, it is necessary to fetch info of all matrix built in \ref ParaMEDMEMOverlapDECAlgoStep4 "Step4" where the first element in pair
+ is equal to k.
+
+ After this step, the matrix repartition is the following after call ParaMEDMEM::OverlapMapping::prepare :
+
+ - proc#0 : (0,0),(1,0),(2,0)
+ - proc#1 : (0,1),(2,1)
+ - proc#2 : (1,2),(2,2)
+
+ Tuple (2,1) computed on proc 2 is stored at the end of "prepare" in proc 1. So it is an example of item 0 in \ref ParaMEDMEMOverlapDECAlgoStep2 "Step2".
+ Tuple (0,1) computed on proc 1 and stored in proc 1 too. So it is an example of item 1 in \ref ParaMEDMEMOverlapDECAlgoStep2 "Step2".
+
+ In ParaMEDMEM::OverlapMapping::_proc_ids_to_send_vector_st will contain :
+
+ - Proc#0 : 0,1
+ - Proc#1 : 0,2
+ - Proc#2 : 0,1,2
+
+ In ParaMEDMEM::OverlapMapping::_proc_ids_to_recv_vector_st will contain :
+
+ - Proc#0 : 0,1,2
+ - Proc#1 : 0,2
+ - Proc#2 : 1,2
+
+ The method in charge to perform this is : ParaMEDMEM::OverlapMapping::prepare.
+*/
+namespace ParaMEDMEM
+{
+ OverlapDEC::OverlapDEC(const std::set<int>& procIds, const MPI_Comm& world_comm):_own_group(true),_interpolation_matrix(0),
+ _source_field(0),_own_source_field(false),
+ _target_field(0),_own_target_field(false)
+ {
+ ParaMEDMEM::CommInterface comm;
+ int *ranks_world=new int[procIds.size()]; // ranks of sources and targets in world_comm
+ std::copy(procIds.begin(),procIds.end(),ranks_world);
+ MPI_Group group,world_group;
+ comm.commGroup(world_comm,&world_group);
+ comm.groupIncl(world_group,procIds.size(),ranks_world,&group);
+ delete [] ranks_world;
+ MPI_Comm theComm;
+ comm.commCreate(world_comm,group,&theComm);
+ comm.groupFree(&group);
+ if(theComm==MPI_COMM_NULL)
+ {
+ _group=0;
+ return ;
+ }
+ std::set<int> idsUnion;
+ for(std::size_t i=0;i<procIds.size();i++)
+ idsUnion.insert(i);
+ _group=new MPIProcessorGroup(comm,idsUnion,theComm);
+ }
+
+ OverlapDEC::~OverlapDEC()
+ {
+ if(_own_group)
+ delete _group;
+ if(_own_source_field)
+ delete _source_field;
+ if(_own_target_field)
+ delete _target_field;
+ delete _interpolation_matrix;
+ }
+
+ void OverlapDEC::sendRecvData(bool way)
+ {
+ if(way)
+ sendData();
+ else
+ recvData();
+ }
+
+ void OverlapDEC::sendData()
+ {
+ _interpolation_matrix->multiply();
+ }
+
+ void OverlapDEC::recvData()
+ {
+ throw INTERP_KERNEL::Exception("Not implemented yet !!!!");
+ //_interpolation_matrix->transposeMultiply();
+ }
+
+ void OverlapDEC::synchronize()
+ {
+ if(!isInGroup())
+ return ;
+ delete _interpolation_matrix;
+ _interpolation_matrix=new OverlapInterpolationMatrix(_source_field,_target_field,*_group,*this,*this);
+ OverlapElementLocator locator(_source_field,_target_field,*_group);
+ locator.copyOptions(*this);
+ locator.exchangeMeshes(*_interpolation_matrix);
+ std::vector< std::pair<int,int> > jobs=locator.getToDoList();
+ std::string srcMeth=locator.getSourceMethod();
+ std::string trgMeth=locator.getTargetMethod();
+ for(std::vector< std::pair<int,int> >::const_iterator it=jobs.begin();it!=jobs.end();it++)
+ {
+ const MEDCouplingPointSet *src=locator.getSourceMesh((*it).first);
+ const DataArrayInt *srcIds=locator.getSourceIds((*it).first);
+ const MEDCouplingPointSet *trg=locator.getTargetMesh((*it).second);
+ const DataArrayInt *trgIds=locator.getTargetIds((*it).second);
+ _interpolation_matrix->addContribution(src,srcIds,srcMeth,(*it).first,trg,trgIds,trgMeth,(*it).second);
+ }
+ _interpolation_matrix->prepare(locator.getProcsInInteraction());
+ _interpolation_matrix->computeDeno();
+ }
+
+ void OverlapDEC::attachSourceLocalField(ParaFIELD *field, bool ownPt)
+ {
+ if(!isInGroup())
+ return ;
+ if(_own_source_field)
+ delete _source_field;
+ _source_field=field;
+ _own_source_field=ownPt;
+ }
+
+ void OverlapDEC::attachTargetLocalField(ParaFIELD *field, bool ownPt)
+ {
+ if(!isInGroup())
+ return ;
+ if(_own_target_field)
+ delete _target_field;
+ _target_field=field;
+ _own_target_field=ownPt;
+ }
+
+ bool OverlapDEC::isInGroup() const
+ {
+ if(!_group)
+ return false;
+ return _group->containsMyRank();
+ }
+}
--- /dev/null
+// Copyright (C) 2007-2010 CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#ifndef __OVERLAPDEC_HXX__
+#define __OVERLAPDEC_HXX__
+
+#include "DEC.hxx"
+#include "InterpolationOptions.hxx"
+
+#include <mpi.h>
+
+namespace ParaMEDMEM
+{
+ class OverlapInterpolationMatrix;
+ class ProcessorGroup;
+ class ParaFIELD;
+
+ class OverlapDEC : public DEC, public INTERP_KERNEL::InterpolationOptions
+ {
+ public:
+ OverlapDEC(const std::set<int>& procIds,const MPI_Comm& world_comm=MPI_COMM_WORLD);
+ virtual ~OverlapDEC();
+ void sendRecvData(bool way=true);
+ void sendData();
+ void recvData();
+ void synchronize();
+ void attachSourceLocalField(ParaFIELD *field, bool ownPt=false);
+ void attachTargetLocalField(ParaFIELD *field, bool ownPt=false);
+ ProcessorGroup *getGrp() { return _group; }
+ bool isInGroup() const;
+ private:
+ bool _own_group;
+ OverlapInterpolationMatrix* _interpolation_matrix;
+ ProcessorGroup *_group;
+ private:
+ ParaFIELD *_source_field;
+ bool _own_source_field;
+ ParaFIELD *_target_field;
+ bool _own_target_field;
+ };
+}
+
+#endif
--- /dev/null
+// Copyright (C) 2007-2010 CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#include "OverlapElementLocator.hxx"
+
+#include <mpi.h>
+#include "CommInterface.hxx"
+#include "Topology.hxx"
+#include "BlockTopology.hxx"
+#include "ParaFIELD.hxx"
+#include "ParaMESH.hxx"
+#include "ProcessorGroup.hxx"
+#include "MPIProcessorGroup.hxx"
+#include "OverlapInterpolationMatrix.hxx"
+#include "MEDCouplingFieldDouble.hxx"
+#include "MEDCouplingFieldDiscretization.hxx"
+#include "DirectedBoundingBox.hxx"
+#include "InterpKernelAutoPtr.hxx"
+
+#include <map>
+#include <set>
+#include <limits>
+
+using namespace std;
+
+namespace ParaMEDMEM
+{
+ OverlapElementLocator::OverlapElementLocator(const ParaFIELD *sourceField, const ParaFIELD *targetField, const ProcessorGroup& group)
+ : _local_source_field(sourceField),
+ _local_target_field(targetField),
+ _local_source_mesh(0),
+ _local_target_mesh(0),
+ _domain_bounding_boxes(0),
+ _group(group)
+ {
+ if(_local_source_field)
+ _local_source_mesh=_local_source_field->getSupport()->getCellMesh();
+ if(_local_target_field)
+ _local_target_mesh=_local_target_field->getSupport()->getCellMesh();
+ _comm=getCommunicator();
+ computeBoundingBoxes();
+ }
+
+ OverlapElementLocator::~OverlapElementLocator()
+ {
+ delete [] _domain_bounding_boxes;
+ }
+
+ const MPI_Comm *OverlapElementLocator::getCommunicator() const
+ {
+ const MPIProcessorGroup* group=static_cast<const MPIProcessorGroup*>(&_group);
+ return group->getComm();
+ }
+
+ void OverlapElementLocator::computeBoundingBoxes()
+ {
+ CommInterface comm_interface=_group.getCommInterface();
+ const MPIProcessorGroup* group=static_cast<const MPIProcessorGroup*> (&_group);
+ _local_space_dim=0;
+ if(_local_source_mesh)
+ _local_space_dim=_local_source_mesh->getSpaceDimension();
+ else
+ _local_space_dim=_local_target_mesh->getSpaceDimension();
+ //
+ const MPI_Comm* comm = group->getComm();
+ int bbSize=2*2*_local_space_dim;//2 (for source/target) 2 (min/max)
+ _domain_bounding_boxes=new double[bbSize*_group.size()];
+ INTERP_KERNEL::AutoPtr<double> minmax=new double[bbSize];
+ //Format minmax : Xmin_src,Xmax_src,Ymin_src,Ymax_src,Zmin_src,Zmax_src,Xmin_trg,Xmax_trg,Ymin_trg,Ymax_trg,Zmin_trg,Zmax_trg
+ if(_local_source_mesh)
+ _local_source_mesh->getBoundingBox(minmax);
+ else
+ {
+ for(int i=0;i<_local_space_dim;i++)
+ {
+ minmax[i*2]=std::numeric_limits<double>::max();
+ minmax[i*2+1]=-std::numeric_limits<double>::max();
+ }
+ }
+ if(_local_target_mesh)
+ _local_target_mesh->getBoundingBox(minmax+2*_local_space_dim);
+ else
+ {
+ for(int i=0;i<_local_space_dim;i++)
+ {
+ minmax[i*2+2*_local_space_dim]=std::numeric_limits<double>::max();
+ minmax[i*2+1+2*_local_space_dim]=-std::numeric_limits<double>::max();
+ }
+ }
+ comm_interface.allGather(minmax, bbSize, MPI_DOUBLE,
+ _domain_bounding_boxes,bbSize, MPI_DOUBLE,
+ *comm);
+
+ // Computation of all pairs needing an interpolation pairs are duplicated now !
+
+ _proc_pairs.clear();//first is source second is target
+ _proc_pairs.resize(_group.size());
+ for(int i=0;i<_group.size();i++)
+ for(int j=0;j<_group.size();j++)
+ {
+ if(intersectsBoundingBox(i,j))
+ _proc_pairs[i].push_back(j);
+ }
+
+ // OK now let's assigning as balanced as possible, job to each proc of group
+ std::vector< std::vector< std::pair<int,int> > > pairsToBeDonePerProc(_group.size());
+ int i=0;
+ for(std::vector< std::vector< int > >::const_iterator it1=_proc_pairs.begin();it1!=_proc_pairs.end();it1++,i++)
+ for(std::vector< int >::const_iterator it2=(*it1).begin();it2!=(*it1).end();it2++)
+ {
+ if(pairsToBeDonePerProc[i].size()<=pairsToBeDonePerProc[*it2].size())//it includes the fact that i==*it2
+ pairsToBeDonePerProc[i].push_back(std::pair<int,int>(i,*it2));
+ else
+ pairsToBeDonePerProc[*it2].push_back(std::pair<int,int>(i,*it2));
+ }
+ //Keeping todo list of current proc. _to_do_list contains a set of pair where at least _group.myRank() appears once.
+ //This proc will be in charge to perform interpolation of any of element of '_to_do_list'
+ //If _group.myRank()==myPair.first, current proc should fetch target mesh of myPair.second (if different from _group.myRank()).
+ //If _group.myRank()==myPair.second, current proc should fetch source mesh of myPair.second.
+
+ int myProcId=_group.myRank();
+ _to_do_list=pairsToBeDonePerProc[myProcId];
+
+ //Feeding now '_procs_to_send'. A same id can appears twice. The second parameter in pair means what to send true=source, false=target
+ _procs_to_send.clear();
+ for(int i=_group.size()-1;i>=0;i--)
+ if(i!=myProcId)
+ {
+ const std::vector< std::pair<int,int> >& anRemoteProcToDoList=pairsToBeDonePerProc[i];
+ for(std::vector< std::pair<int,int> >::const_iterator it=anRemoteProcToDoList.begin();it!=anRemoteProcToDoList.end();it++)
+ {
+ if((*it).first==myProcId)
+ _procs_to_send.push_back(std::pair<int,bool>(i,true));
+ if((*it).second==myProcId)
+ _procs_to_send.push_back(std::pair<int,bool>(i,false));
+ }
+ }
+ }
+
+ /*!
+ * The aim of this method is to perform the communication to get data corresponding to '_to_do_list' attribute.
+ * The principle is the following : if proc n1 and n2 need to perform a cross sending with n1<n2, then n1 will send first and receive then.
+ */
+ void OverlapElementLocator::exchangeMeshes(OverlapInterpolationMatrix& matrix)
+ {
+ int myProcId=_group.myRank();
+ //starting to receive every procs whose id is lower than myProcId.
+ std::vector< std::pair<int,int> > toDoListForFetchRemaining;
+ for(std::vector< std::pair<int,int> >::const_iterator it=_to_do_list.begin();it!=_to_do_list.end();it++)
+ {
+ if((*it).first!=(*it).second)
+ {
+ if((*it).first==myProcId)
+ {
+ if((*it).second<myProcId)
+ receiveRemoteMesh((*it).second,false);
+ else
+ toDoListForFetchRemaining.push_back(std::pair<int,int>((*it).first,(*it).second));
+ }
+ else
+ {//(*it).second==myProcId
+ if((*it).first<myProcId)
+ receiveRemoteMesh((*it).first,true);
+ else
+ toDoListForFetchRemaining.push_back(std::pair<int,int>((*it).first,(*it).second));
+ }
+ }
+ }
+ //sending source or target mesh to remote procs
+ for(std::vector< std::pair<int,bool> >::const_iterator it2=_procs_to_send.begin();it2!=_procs_to_send.end();it2++)
+ sendLocalMeshTo((*it2).first,(*it2).second,matrix);
+ //fetching remaining meshes
+ for(std::vector< std::pair<int,int> >::const_iterator it=toDoListForFetchRemaining.begin();it!=toDoListForFetchRemaining.end();it++)
+ {
+ if((*it).first!=(*it).second)
+ {
+ if((*it).first==myProcId)
+ receiveRemoteMesh((*it).second,false);
+ else//(*it).second==myProcId
+ receiveRemoteMesh((*it).first,true);
+ }
+ }
+ }
+
+ std::string OverlapElementLocator::getSourceMethod() const
+ {
+ return _local_source_field->getField()->getDiscretization()->getStringRepr();
+ }
+
+ std::string OverlapElementLocator::getTargetMethod() const
+ {
+ return _local_target_field->getField()->getDiscretization()->getStringRepr();
+ }
+
+ const MEDCouplingPointSet *OverlapElementLocator::getSourceMesh(int procId) const
+ {
+ int myProcId=_group.myRank();
+ if(myProcId==procId)
+ return _local_source_mesh;
+ std::pair<int,bool> p(procId,true);
+ std::map<std::pair<int,bool>, MEDCouplingAutoRefCountObjectPtr< MEDCouplingPointSet > >::const_iterator it=_remote_meshes.find(p);
+ return (*it).second;
+ }
+
+ const DataArrayInt *OverlapElementLocator::getSourceIds(int procId) const
+ {
+ int myProcId=_group.myRank();
+ if(myProcId==procId)
+ return 0;
+ std::pair<int,bool> p(procId,true);
+ std::map<std::pair<int,bool>, MEDCouplingAutoRefCountObjectPtr< DataArrayInt > >::const_iterator it=_remote_elems.find(p);
+ return (*it).second;
+ }
+
+ const MEDCouplingPointSet *OverlapElementLocator::getTargetMesh(int procId) const
+ {
+ int myProcId=_group.myRank();
+ if(myProcId==procId)
+ return _local_target_mesh;
+ std::pair<int,bool> p(procId,false);
+ std::map<std::pair<int,bool>, MEDCouplingAutoRefCountObjectPtr< MEDCouplingPointSet > >::const_iterator it=_remote_meshes.find(p);
+ return (*it).second;
+ }
+
+ const DataArrayInt *OverlapElementLocator::getTargetIds(int procId) const
+ {
+ int myProcId=_group.myRank();
+ if(myProcId==procId)
+ return 0;
+ std::pair<int,bool> p(procId,false);
+ std::map<std::pair<int,bool>, MEDCouplingAutoRefCountObjectPtr< DataArrayInt > >::const_iterator it=_remote_elems.find(p);
+ return (*it).second;
+ }
+
+ bool OverlapElementLocator::intersectsBoundingBox(int isource, int itarget) const
+ {
+ const double *source_bb=_domain_bounding_boxes+isource*2*2*_local_space_dim;
+ const double *target_bb=_domain_bounding_boxes+itarget*2*2*_local_space_dim+2*_local_space_dim;
+
+ for (int idim=0; idim < _local_space_dim; idim++)
+ {
+ const double eps = -1e-12;//tony to change
+ bool intersects = (target_bb[idim*2]<source_bb[idim*2+1]+eps)
+ && (source_bb[idim*2]<target_bb[idim*2+1]+eps);
+ if (!intersects)
+ return false;
+ }
+ return true;
+ }
+
+ /*!
+ * This methods sends local source if 'sourceOrTarget'==True to proc 'procId'.
+ * This methods sends local target if 'sourceOrTarget'==False to proc 'procId'.
+ *
+ * This method prepares the matrix too, for matrix assembling and future matrix-vector computation.
+ */
+ void OverlapElementLocator::sendLocalMeshTo(int procId, bool sourceOrTarget, OverlapInterpolationMatrix& matrix) const
+ {
+ vector<int> elems;
+ //int myProcId=_group.myRank();
+ const double *distant_bb=0;
+ MEDCouplingPointSet *local_mesh=0;
+ const ParaFIELD *field=0;
+ if(sourceOrTarget)//source for local but target for distant
+ {
+ distant_bb=_domain_bounding_boxes+procId*2*2*_local_space_dim+2*_local_space_dim;
+ local_mesh=_local_source_mesh;
+ field=_local_source_field;
+ }
+ else//target for local but source for distant
+ {
+ distant_bb=_domain_bounding_boxes+procId*2*2*_local_space_dim;
+ local_mesh=_local_target_mesh;
+ field=_local_target_field;
+ }
+ local_mesh->getCellsInBoundingBox(distant_bb,getBoundingBoxAdjustment(),elems);
+ DataArrayInt *idsToSend;
+ MEDCouplingPointSet *send_mesh=static_cast<MEDCouplingPointSet *>(field->getField()->buildSubMeshData(&elems[0],&elems[elems.size()],idsToSend));
+ if(sourceOrTarget)
+ matrix.keepTracksOfSourceIds(procId,idsToSend);//Case#1 in Step2 of main algorithm.
+ else
+ matrix.keepTracksOfTargetIds(procId,idsToSend);//Case#0 in Step2 of main algorithm.
+ sendMesh(procId,send_mesh,idsToSend);
+ send_mesh->decrRef();
+ idsToSend->decrRef();
+ }
+
+ /*!
+ * This method recieves source remote mesh on proc 'procId' if sourceOrTarget==True
+ * This method recieves target remote mesh on proc 'procId' if sourceOrTarget==False
+ */
+ void OverlapElementLocator::receiveRemoteMesh(int procId, bool sourceOrTarget)
+ {
+ DataArrayInt *da=0;
+ MEDCouplingPointSet *m=0;
+ receiveMesh(procId,m,da);
+ std::pair<int,bool> p(procId,sourceOrTarget);
+ _remote_meshes[p]=m;
+ _remote_elems[p]=da;
+ }
+
+ void OverlapElementLocator::sendMesh(int procId, const MEDCouplingPointSet *mesh, const DataArrayInt *idsToSend) const
+ {
+ CommInterface comInterface=_group.getCommInterface();
+ // First stage : exchanging sizes
+ vector<double> tinyInfoLocalD;//tinyInfoLocalD not used for the moment
+ vector<int> tinyInfoLocal;
+ vector<string> tinyInfoLocalS;
+ mesh->getTinySerializationInformation(tinyInfoLocalD,tinyInfoLocal,tinyInfoLocalS);
+ const MPI_Comm *comm=getCommunicator();
+ //
+ int lgth[2];
+ lgth[0]=tinyInfoLocal.size();
+ lgth[1]=idsToSend->getNbOfElems();
+ comInterface.send(&lgth,2,MPI_INT,procId,1140,*_comm);
+ comInterface.send(&tinyInfoLocal[0],tinyInfoLocal.size(),MPI_INT,procId,1141,*comm);
+ //
+ DataArrayInt *v1Local=0;
+ DataArrayDouble *v2Local=0;
+ mesh->serialize(v1Local,v2Local);
+ comInterface.send(v1Local->getPointer(),v1Local->getNbOfElems(),MPI_INT,procId,1142,*comm);
+ comInterface.send(v2Local->getPointer(),v2Local->getNbOfElems(),MPI_DOUBLE,procId,1143,*comm);
+ //finished for mesh, ids now
+ comInterface.send((int *)idsToSend->getConstPointer(),lgth[1],MPI_INT,procId,1144,*comm);
+ //
+ v1Local->decrRef();
+ v2Local->decrRef();
+ }
+
+ void OverlapElementLocator::receiveMesh(int procId, MEDCouplingPointSet* &mesh, DataArrayInt *&ids) const
+ {
+ int lgth[2];
+ MPI_Status status;
+ const MPI_Comm *comm=getCommunicator();
+ CommInterface comInterface=_group.getCommInterface();
+ comInterface.recv(lgth,2,MPI_INT,procId,1140,*_comm,&status);
+ std::vector<int> tinyInfoDistant(lgth[0]);
+ ids=DataArrayInt::New();
+ ids->alloc(lgth[1],1);
+ comInterface.recv(&tinyInfoDistant[0],lgth[0],MPI_INT,procId,1141,*comm,&status);
+ mesh=MEDCouplingPointSet::BuildInstanceFromMeshType((MEDCouplingMeshType)tinyInfoDistant[0]);
+ std::vector<std::string> unusedTinyDistantSts;
+ vector<double> tinyInfoDistantD(1);//tinyInfoDistantD not used for the moment
+ DataArrayInt *v1Distant=DataArrayInt::New();
+ DataArrayDouble *v2Distant=DataArrayDouble::New();
+ mesh->resizeForUnserialization(tinyInfoDistant,v1Distant,v2Distant,unusedTinyDistantSts);
+ comInterface.recv(v1Distant->getPointer(),v1Distant->getNbOfElems(),MPI_INT,procId,1142,*comm,&status);
+ comInterface.recv(v2Distant->getPointer(),v2Distant->getNbOfElems(),MPI_DOUBLE,procId,1143,*comm,&status);
+ mesh->unserialization(tinyInfoDistantD,tinyInfoDistant,v1Distant,v2Distant,unusedTinyDistantSts);
+ //finished for mesh, ids now
+ comInterface.recv(ids->getPointer(),lgth[1],MPI_INT,procId,1144,*comm,&status);
+ //
+ v1Distant->decrRef();
+ v2Distant->decrRef();
+ }
+}
--- /dev/null
+// Copyright (C) 2007-2010 CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#ifndef __OVERLAPELEMENTLOCATOR_HXX__
+#define __OVERLAPELEMENTLOCATOR_HXX__
+
+#include "InterpolationOptions.hxx"
+#include "MEDCouplingNatureOfField.hxx"
+#include "MEDCouplingPointSet.hxx"
+#include "MEDCouplingMemArray.hxx"
+#include "MEDCouplingAutoRefCountObjectPtr.hxx"
+
+#include <mpi.h>
+#include <vector>
+#include <set>
+
+namespace ParaMEDMEM
+{
+ class ParaFIELD;
+ class ProcessorGroup;
+ class ParaSUPPORT;
+ class OverlapInterpolationMatrix;
+
+ class OverlapElementLocator : public INTERP_KERNEL::InterpolationOptions
+ {
+ public:
+ OverlapElementLocator(const ParaFIELD *sourceField, const ParaFIELD *targetField, const ProcessorGroup& group);
+ virtual ~OverlapElementLocator();
+ const MPI_Comm *getCommunicator() const;
+ void exchangeMeshes(OverlapInterpolationMatrix& matrix);
+ std::vector< std::pair<int,int> > getToDoList() const { return _to_do_list; }
+ std::vector< std::vector< int > > getProcsInInteraction() const { return _proc_pairs; }
+ std::string getSourceMethod() const;
+ std::string getTargetMethod() const;
+ const MEDCouplingPointSet *getSourceMesh(int procId) const;
+ const DataArrayInt *getSourceIds(int procId) const;
+ const MEDCouplingPointSet *getTargetMesh(int procId) const;
+ const DataArrayInt *getTargetIds(int procId) const;
+ private:
+ void computeBoundingBoxes();
+ bool intersectsBoundingBox(int i, int j) const;
+ void sendLocalMeshTo(int procId, bool sourceOrTarget, OverlapInterpolationMatrix& matrix) const;
+ void receiveRemoteMesh(int procId, bool sourceOrTarget);
+ void sendMesh(int procId, const MEDCouplingPointSet *mesh, const DataArrayInt *idsToSend) const;
+ void receiveMesh(int procId, MEDCouplingPointSet* &mesh, DataArrayInt *&ids) const;
+ private:
+ const ParaFIELD *_local_source_field;
+ const ParaFIELD *_local_target_field;
+ int _local_space_dim;
+ MEDCouplingPointSet *_local_source_mesh;
+ MEDCouplingPointSet *_local_target_mesh;
+ std::vector<MEDCouplingPointSet*> _distant_cell_meshes;
+ std::vector<MEDCouplingPointSet*> _distant_face_meshes;
+ //! of size _group.size(). Contains for each source proc i, the ids of proc j the targets interact with. This vector is common for all procs in _group.
+ std::vector< std::vector< int > > _proc_pairs;
+ //! list of interpolations couple to be done
+ std::vector< std::pair<int,int> > _to_do_list;
+ std::vector< std::pair<int,bool> > _procs_to_send;
+ std::map<std::pair<int,bool>, MEDCouplingAutoRefCountObjectPtr< MEDCouplingPointSet > > _remote_meshes;
+ std::map<std::pair<int,bool>, MEDCouplingAutoRefCountObjectPtr< DataArrayInt > > _remote_elems;
+ double* _domain_bounding_boxes;
+ const ProcessorGroup& _group;
+ std::vector<int> _distant_proc_ids;
+ const MPI_Comm *_comm;
+ //Attributes only used by lazy side
+ //std::vector<double> _values_added;
+ //std::vector< std::vector<int> > _ids_per_working_proc;
+ //std::vector< std::vector<int> > _ids_per_working_proc3;
+ //std::vector< std::vector<double> > _values_per_working_proc;
+ };
+
+}
+
+#endif
--- /dev/null
+// Copyright (C) 2007-2010 CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#include "OverlapInterpolationMatrix.hxx"
+#include "ParaMESH.hxx"
+#include "ParaFIELD.hxx"
+#include "ProcessorGroup.hxx"
+#include "TranslationRotationMatrix.hxx"
+#include "Interpolation.hxx"
+#include "Interpolation1D.txx"
+#include "Interpolation2DCurve.hxx"
+#include "Interpolation2D.txx"
+#include "Interpolation3DSurf.hxx"
+#include "Interpolation3D.txx"
+#include "MEDCouplingUMesh.hxx"
+#include "MEDCouplingNormalizedUnstructuredMesh.txx"
+#include "InterpolationOptions.hxx"
+#include "NormalizedUnstructuredMesh.hxx"
+#include "ElementLocator.hxx"
+#include "InterpKernelAutoPtr.hxx"
+
+#include <algorithm>
+
+using namespace std;
+
+namespace ParaMEDMEM
+{
+ OverlapInterpolationMatrix::OverlapInterpolationMatrix(ParaFIELD *source_field,
+ ParaFIELD *target_field,
+ const ProcessorGroup& group,
+ const DECOptions& dec_options,
+ const INTERP_KERNEL::InterpolationOptions& i_opt):
+ INTERP_KERNEL::InterpolationOptions(i_opt),
+ DECOptions(dec_options),
+ _source_field(source_field),
+ _target_field(target_field),
+ _source_support(source_field->getSupport()->getCellMesh()),
+ _target_support(target_field->getSupport()->getCellMesh()),
+ _mapping(group),
+ _group(group)
+ {
+ int nbelems = source_field->getField()->getNumberOfTuples();
+ _row_offsets.resize(nbelems+1);
+ _coeffs.resize(nbelems);
+ _target_volume.resize(nbelems);
+ }
+
+ void OverlapInterpolationMatrix::keepTracksOfSourceIds(int procId, DataArrayInt *ids)
+ {
+ _mapping.keepTracksOfSourceIds(procId,ids);
+ }
+
+ void OverlapInterpolationMatrix::keepTracksOfTargetIds(int procId, DataArrayInt *ids)
+ {
+ _mapping.keepTracksOfTargetIds(procId,ids);
+ }
+
+ OverlapInterpolationMatrix::~OverlapInterpolationMatrix()
+ {
+ }
+
+ void OverlapInterpolationMatrix::addContribution(const MEDCouplingPointSet *src, const DataArrayInt *srcIds, const std::string& srcMeth, int srcProcId,
+ const MEDCouplingPointSet *trg, const DataArrayInt *trgIds, const std::string& trgMeth, int trgProcId)
+ {
+ std::string interpMethod(srcMeth);
+ interpMethod+=trgMeth;
+ //creating the interpolator structure
+ vector<map<int,double> > surfaces;
+ int colSize=0;
+ //computation of the intersection volumes between source and target elements
+ const MEDCouplingUMesh *trgC=dynamic_cast<const MEDCouplingUMesh *>(trg);
+ const MEDCouplingUMesh *srcC=dynamic_cast<const MEDCouplingUMesh *>(src);
+ if ( src->getMeshDimension() == -1 )
+ {
+ if(trgC->getMeshDimension()==2 && trgC->getSpaceDimension()==2)
+ {
+ MEDCouplingNormalizedUnstructuredMesh<2,2> target_mesh_wrapper(trgC);
+ INTERP_KERNEL::Interpolation2D interpolation(*this);
+ colSize=interpolation.fromIntegralUniform(target_mesh_wrapper,surfaces,trgMeth.c_str());
+ }
+ else if(trgC->getMeshDimension()==3 && trgC->getSpaceDimension()==3)
+ {
+ MEDCouplingNormalizedUnstructuredMesh<3,3> target_mesh_wrapper(trgC);
+ INTERP_KERNEL::Interpolation3D interpolation(*this);
+ colSize=interpolation.fromIntegralUniform(target_mesh_wrapper,surfaces,trgMeth.c_str());
+ }
+ else if(trgC->getMeshDimension()==2 && trgC->getSpaceDimension()==3)
+ {
+ MEDCouplingNormalizedUnstructuredMesh<3,2> target_mesh_wrapper(trgC);
+ INTERP_KERNEL::Interpolation3DSurf interpolation(*this);
+ colSize=interpolation.fromIntegralUniform(target_mesh_wrapper,surfaces,trgMeth.c_str());
+ }
+ else
+ throw INTERP_KERNEL::Exception("No para interpolation available for the given mesh and space dimension of source mesh to -1D targetMesh");
+ }
+ else if ( trg->getMeshDimension() == -1 )
+ {
+ if(srcC->getMeshDimension()==2 && srcC->getSpaceDimension()==2)
+ {
+ MEDCouplingNormalizedUnstructuredMesh<2,2> local_mesh_wrapper(srcC);
+ INTERP_KERNEL::Interpolation2D interpolation(*this);
+ colSize=interpolation.toIntegralUniform(local_mesh_wrapper,surfaces,srcMeth.c_str());
+ }
+ else if(srcC->getMeshDimension()==3 && srcC->getSpaceDimension()==3)
+ {
+ MEDCouplingNormalizedUnstructuredMesh<3,3> local_mesh_wrapper(srcC);
+ INTERP_KERNEL::Interpolation3D interpolation(*this);
+ colSize=interpolation.toIntegralUniform(local_mesh_wrapper,surfaces,srcMeth.c_str());
+ }
+ else if(srcC->getMeshDimension()==2 && srcC->getSpaceDimension()==3)
+ {
+ MEDCouplingNormalizedUnstructuredMesh<3,2> local_mesh_wrapper(srcC);
+ INTERP_KERNEL::Interpolation3DSurf interpolation(*this);
+ colSize=interpolation.toIntegralUniform(local_mesh_wrapper,surfaces,srcMeth.c_str());
+ }
+ else
+ throw INTERP_KERNEL::Exception("No para interpolation available for the given mesh and space dimension of distant mesh to -1D sourceMesh");
+ }
+ else if (trg->getMeshDimension() != _source_support->getMeshDimension())
+ {
+ throw INTERP_KERNEL::Exception("local and distant meshes do not have the same space and mesh dimensions");
+ }
+ else if( src->getMeshDimension() == 1
+ && src->getSpaceDimension() == 1 )
+ {
+ MEDCouplingNormalizedUnstructuredMesh<1,1> target_wrapper(trgC);
+ MEDCouplingNormalizedUnstructuredMesh<1,1> source_wrapper(srcC);
+
+ INTERP_KERNEL::Interpolation1D interpolation(*this);
+ colSize=interpolation.interpolateMeshes(source_wrapper,target_wrapper,surfaces,interpMethod.c_str());
+ target_wrapper.releaseTempArrays();
+ source_wrapper.releaseTempArrays();
+ }
+ else if( trg->getMeshDimension() == 1
+ && trg->getSpaceDimension() == 2 )
+ {
+ MEDCouplingNormalizedUnstructuredMesh<2,1> target_wrapper(trgC);
+ MEDCouplingNormalizedUnstructuredMesh<2,1> source_wrapper(srcC);
+
+ INTERP_KERNEL::Interpolation2DCurve interpolation(*this);
+ colSize=interpolation.interpolateMeshes(source_wrapper,target_wrapper,surfaces,interpMethod.c_str());
+ target_wrapper.releaseTempArrays();
+ source_wrapper.releaseTempArrays();
+ }
+ else if ( trg->getMeshDimension() == 2
+ && trg->getSpaceDimension() == 3 )
+ {
+ MEDCouplingNormalizedUnstructuredMesh<3,2> target_wrapper(trgC);
+ MEDCouplingNormalizedUnstructuredMesh<3,2> source_wrapper(srcC);
+
+ INTERP_KERNEL::Interpolation3DSurf interpolator (*this);
+ colSize=interpolator.interpolateMeshes(source_wrapper,target_wrapper,surfaces,interpMethod.c_str());
+ target_wrapper.releaseTempArrays();
+ source_wrapper.releaseTempArrays();
+ }
+ else if ( trg->getMeshDimension() == 2
+ && trg->getSpaceDimension() == 2)
+ {
+ MEDCouplingNormalizedUnstructuredMesh<2,2> target_wrapper(trgC);
+ MEDCouplingNormalizedUnstructuredMesh<2,2> source_wrapper(srcC);
+
+ INTERP_KERNEL::Interpolation2D interpolator (*this);
+ colSize=interpolator.interpolateMeshes(source_wrapper,target_wrapper,surfaces,interpMethod.c_str());
+ target_wrapper.releaseTempArrays();
+ source_wrapper.releaseTempArrays();
+ }
+ else if ( trg->getMeshDimension() == 3
+ && trg->getSpaceDimension() == 3 )
+ {
+ MEDCouplingNormalizedUnstructuredMesh<3,3> target_wrapper(trgC);
+ MEDCouplingNormalizedUnstructuredMesh<3,3> source_wrapper(srcC);
+
+ INTERP_KERNEL::Interpolation3D interpolator (*this);
+ colSize=interpolator.interpolateMeshes(source_wrapper,target_wrapper,surfaces,interpMethod.c_str());
+ target_wrapper.releaseTempArrays();
+ source_wrapper.releaseTempArrays();
+ }
+ else
+ {
+ throw INTERP_KERNEL::Exception("no interpolator exists for these mesh and space dimensions ");
+ }
+ bool needSourceSurf=isSurfaceComputationNeeded(srcMeth);
+ MEDCouplingFieldDouble *source_triangle_surf=0;
+ if(needSourceSurf)
+ source_triangle_surf=src->getMeasureField(getMeasureAbsStatus());
+ //
+ fillDistributedMatrix(surfaces,srcIds,srcProcId,trgIds,trgProcId);
+ //
+ if(needSourceSurf)
+ source_triangle_surf->decrRef();
+ }
+
+ /*!
+ * \b res rows refers to target and column (first param of map) to source.
+ */
+ void OverlapInterpolationMatrix::fillDistributedMatrix(const std::vector< std::map<int,double> >& res,
+ const DataArrayInt *srcIds, int srcProc,
+ const DataArrayInt *trgIds, int trgProc)
+ {
+ _mapping.addContributionST(res,srcIds,srcProc,trgIds,trgProc);
+ }
+
+ /*!
+ * 'procsInInteraction' gives the global view of interaction between procs.
+ * In 'procsInInteraction' for a proc with id i, is in interaction with procs listed in procsInInteraction[i]
+ */
+ void OverlapInterpolationMatrix::prepare(const std::vector< std::vector<int> >& procsInInteraction)
+ {
+ if(_source_support)
+ _mapping.prepare(procsInInteraction,_target_field->getField()->getNumberOfTuplesExpected());
+ else
+ _mapping.prepare(procsInInteraction,0);
+ }
+
+ void OverlapInterpolationMatrix::computeDeno()
+ {
+ if(_target_field->getField()->getNature()==ConservativeVolumic)
+ _mapping.computeDenoConservativeVolumic(_target_field->getField()->getNumberOfTuplesExpected());
+ else
+ throw INTERP_KERNEL::Exception("Policy Not implemented yet : only ConservativeVolumic defined !");
+ }
+
+ void OverlapInterpolationMatrix::multiply()
+ {
+ _mapping.multiply(_source_field->getField(),_target_field->getField());
+ }
+
+ void OverlapInterpolationMatrix::transposeMultiply()
+ {
+ _mapping.transposeMultiply(_target_field->getField(),_source_field->getField());
+ }
+
+ bool OverlapInterpolationMatrix::isSurfaceComputationNeeded(const std::string& method) const
+ {
+ return method=="P0";
+ }
+}
--- /dev/null
+// Copyright (C) 2007-2010 CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#ifndef __OVERLAPINTERPOLATIONMATRIX_HXX__
+#define __OVERLAPINTERPOLATIONMATRIX_HXX__
+
+#include "MPIAccessDEC.hxx"
+#include "OverlapMapping.hxx"
+#include "InterpolationOptions.hxx"
+#include "DECOptions.hxx"
+
+namespace ParaMEDMEM
+{
+ class ParaFIELD;
+ class MEDCouplingPointSet;
+
+ class OverlapInterpolationMatrix : public INTERP_KERNEL::InterpolationOptions,
+ public DECOptions
+ {
+ public:
+
+ OverlapInterpolationMatrix(ParaFIELD *source_field,
+ ParaFIELD *target_field,
+ const ProcessorGroup& group,
+ const DECOptions& dec_opt,
+ const InterpolationOptions& i_opt);
+
+ void keepTracksOfSourceIds(int procId, DataArrayInt *ids);
+
+ void keepTracksOfTargetIds(int procId, DataArrayInt *ids);
+
+ void addContribution(const MEDCouplingPointSet *src, const DataArrayInt *srcIds, const std::string& srcMeth, int srcProcId,
+ const MEDCouplingPointSet *trg, const DataArrayInt *trgIds, const std::string& trgMeth, int trgProcId);
+
+ void prepare(const std::vector< std::vector<int> >& procsInInteraction);
+
+ void computeDeno();
+
+ void multiply();
+
+ void transposeMultiply();
+
+ virtual ~OverlapInterpolationMatrix();
+#if 0
+ void addContribution(MEDCouplingPointSet& distant_support, int iproc_distant,
+ const int* distant_elems, const std::string& srcMeth, const std::string& targetMeth);
+ void finishContributionW(ElementLocator& elementLocator);
+ void finishContributionL(ElementLocator& elementLocator);
+ void multiply(MEDCouplingFieldDouble& field) const;
+ void transposeMultiply(MEDCouplingFieldDouble& field)const;
+ void prepare();
+ int getNbRows() const { return _row_offsets.size(); }
+ MPIAccessDEC* getAccessDEC() { return _mapping.getAccessDEC(); }
+ private:
+ void computeConservVolDenoW(ElementLocator& elementLocator);
+ void computeIntegralDenoW(ElementLocator& elementLocator);
+ void computeRevIntegralDenoW(ElementLocator& elementLocator);
+ void computeGlobConstraintDenoW(ElementLocator& elementLocator);
+ void computeConservVolDenoL(ElementLocator& elementLocator);
+ void computeIntegralDenoL(ElementLocator& elementLocator);
+ void computeRevIntegralDenoL(ElementLocator& elementLocator);
+
+ void computeLocalColSum(std::vector<double>& res) const;
+ void computeLocalRowSum(const std::vector<int>& distantProcs, std::vector<std::vector<int> >& resPerProcI,
+ std::vector<std::vector<double> >& resPerProcD) const;
+ void computeGlobalRowSum(ElementLocator& elementLocator, std::vector<std::vector<double> >& denoStrorage, std::vector<std::vector<double> >& denoStrorageInv);
+ void computeGlobalColSum(std::vector<std::vector<double> >& denoStrorage);
+ void resizeGlobalColSum(std::vector<std::vector<double> >& denoStrorage);
+ void fillDSFromVM(int iproc_distant, const int* distant_elems, const std::vector< std::map<int,double> >& values, MEDCouplingFieldDouble *surf);
+ void serializeMe(std::vector< std::vector< std::map<int,double> > >& data1, std::vector<int>& data2) const;
+ void initialize();
+ void findAdditionnalElements(ElementLocator& elementLocator, std::vector<std::vector<int> >& elementsToAdd,
+ const std::vector<std::vector<int> >& resPerProcI, const std::vector<std::vector<int> >& globalIdsPartial);
+ void addGhostElements(const std::vector<int>& distantProcs, const std::vector<std::vector<int> >& elementsToAdd);
+ int mergePolicies(const std::vector<int>& policyPartial);
+ void mergeRowSum(const std::vector< std::vector<double> >& rowsPartialSumD, const std::vector< std::vector<int> >& globalIdsPartial,
+ std::vector<int>& globalIdsLazySideInteraction, std::vector<double>& sumCorresponding);
+ void mergeRowSum2(const std::vector< std::vector<int> >& globalIdsPartial, std::vector< std::vector<double> >& rowsPartialSumD,
+ const std::vector<int>& globalIdsLazySideInteraction, const std::vector<double>& sumCorresponding);
+ void mergeRowSum3(const std::vector< std::vector<int> >& globalIdsPartial, std::vector< std::vector<double> >& rowsPartialSumD);
+ void mergeCoeffs(const std::vector<int>& procsInInteraction, const std::vector< std::vector<int> >& rowsPartialSumI,
+ const std::vector<std::vector<int> >& globalIdsPartial, std::vector<std::vector<double> >& denoStrorageInv);
+ void divideByGlobalRowSum(const std::vector<int>& distantProcs, const std::vector<std::vector<int> >& resPerProcI,
+ const std::vector<std::vector<double> >& resPerProcD, std::vector<std::vector<double> >& deno);
+#endif
+ private:
+ bool isSurfaceComputationNeeded(const std::string& method) const;
+ void fillDistributedMatrix(const std::vector< std::map<int,double> >& res,
+ const DataArrayInt *srcIds, int srcProc,
+ const DataArrayInt *trgIds, int trgProc);
+ private:
+ ParaMEDMEM::ParaFIELD *_source_field;
+ ParaMEDMEM::ParaFIELD *_target_field;
+ std::vector<int> _row_offsets;
+ std::map<std::pair<int,int>, int > _col_offsets;
+ MEDCouplingPointSet *_source_support;
+ MEDCouplingPointSet *_target_support;
+ OverlapMapping _mapping;
+
+ const ProcessorGroup& _group;
+ std::vector< std::vector<double> > _target_volume;
+ std::vector<std::vector<std::pair<int,double> > > _coeffs;
+ std::vector<std::vector<double> > _deno_multiply;
+ std::vector<std::vector<double> > _deno_reverse_multiply;
+ };
+}
+
+#endif
--- /dev/null
+// Copyright (C) 2007-2010 CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#include "OverlapMapping.hxx"
+#include "MPIProcessorGroup.hxx"
+
+#include "MEDCouplingFieldDouble.hxx"
+#include "MEDCouplingAutoRefCountObjectPtr.hxx"
+
+#include "InterpKernelAutoPtr.hxx"
+
+#include <numeric>
+#include <algorithm>
+
+using namespace ParaMEDMEM;
+
+OverlapMapping::OverlapMapping(const ProcessorGroup& group):_group(group)
+{
+}
+
+/*!
+ * This method keeps tracks of source ids to know in step 6 of main algorithm, which tuple ids to send away.
+ * This method incarnates item#1 of step2 algorithm.
+ */
+void OverlapMapping::keepTracksOfSourceIds(int procId, DataArrayInt *ids)
+{
+ ids->incrRef();
+ _src_ids_st2.push_back(ids);
+ _src_proc_st2.push_back(procId);
+}
+
+/*!
+ * This method keeps tracks of target ids to know in step 6 of main algorithm.
+ * This method incarnates item#0 of step2 algorithm.
+ */
+void OverlapMapping::keepTracksOfTargetIds(int procId, DataArrayInt *ids)
+{
+ ids->incrRef();
+ _trg_ids_st2.push_back(ids);
+ _trg_proc_st2.push_back(procId);
+}
+
+/*!
+ * This method stores from a matrix in format Target(rows)/Source(cols) for a source procId 'srcProcId' and for a target procId 'trgProcId'.
+ * All ids (source and target) are in format of local ids.
+ */
+void OverlapMapping::addContributionST(const std::vector< std::map<int,double> >& matrixST, const DataArrayInt *srcIds, int srcProcId, const DataArrayInt *trgIds, int trgProcId)
+{
+ _matrixes_st.push_back(matrixST);
+ _source_proc_id_st.push_back(srcProcId);
+ _target_proc_id_st.push_back(trgProcId);
+ if(srcIds)
+ {//item#1 of step2 algorithm in proc m. Only to know in advanced nb of recv ids [ (0,1) computed on proc1 and Matrix-Vector on proc1 ]
+ _nb_of_src_ids_proc_st2.push_back(srcIds->getNumberOfTuples());
+ _src_ids_proc_st2.push_back(srcProcId);
+ }
+ else
+ {//item#0 of step2 algorithm in proc k
+ std::set<int> s;
+ for(std::vector< std::map<int,double> >::const_iterator it1=matrixST.begin();it1!=matrixST.end();it1++)
+ for(std::map<int,double>::const_iterator it2=(*it1).begin();it2!=(*it1).end();it2++)
+ s.insert((*it2).first);
+ _src_ids_zip_st2.resize(_src_ids_zip_st2.size()+1);
+ _src_ids_zip_st2.back().insert(_src_ids_zip_st2.back().end(),s.begin(),s.end());
+ _src_ids_zip_proc_st2.push_back(trgProcId);
+ }
+}
+
+/*!
+ * 'procsInInteraction' gives the global view of interaction between procs.
+ * In 'procsInInteraction' for a proc with id i, is in interaction with procs listed in procsInInteraction[i].
+ *
+ * This method is in charge to send matrixes in AlltoAll mode.
+ * After the call of this method 'this' contains the matrixST for all source elements of the current proc
+ */
+void OverlapMapping::prepare(const std::vector< std::vector<int> >& procsInInteraction, int nbOfTrgElems)
+{
+ CommInterface commInterface=_group.getCommInterface();
+ const MPIProcessorGroup *group=static_cast<const MPIProcessorGroup*>(&_group);
+ const MPI_Comm *comm=group->getComm();
+ int grpSize=_group.size();
+ INTERP_KERNEL::AutoPtr<int> nbsend=new int[grpSize];
+ INTERP_KERNEL::AutoPtr<int> nbsend2=new int[grpSize];
+ INTERP_KERNEL::AutoPtr<int> nbsend3=new int[grpSize];
+ std::fill<int *>(nbsend,nbsend+grpSize,0);
+ int myProcId=_group.myRank();
+ _proc_ids_to_recv_vector_st.clear();
+ int curProc=0;
+ for(std::vector< std::vector<int> >::const_iterator it1=procsInInteraction.begin();it1!=procsInInteraction.end();it1++,curProc++)
+ if(std::find((*it1).begin(),(*it1).end(),myProcId)!=(*it1).end())
+ _proc_ids_to_recv_vector_st.push_back(curProc);
+ _proc_ids_to_send_vector_st=procsInInteraction[myProcId];
+ for(std::size_t i=0;i<_matrixes_st.size();i++)
+ if(_source_proc_id_st[i]==myProcId)
+ nbsend[_target_proc_id_st[i]]=_matrixes_st[i].size();
+ INTERP_KERNEL::AutoPtr<int> nbrecv=new int[grpSize];
+ commInterface.allToAll(nbsend,1,MPI_INT,nbrecv,1,MPI_INT,*comm);
+ //exchanging matrix
+ //first exchanging offsets+ids_source
+ INTERP_KERNEL::AutoPtr<int> nbrecv1=new int[grpSize];
+ INTERP_KERNEL::AutoPtr<int> nbrecv2=new int[grpSize];
+ //
+ int *tmp=0;
+ serializeMatrixStep0ST(nbrecv,
+ tmp,nbsend2,nbsend3,
+ nbrecv1,nbrecv2);
+ INTERP_KERNEL::AutoPtr<int> bigArr=tmp;
+ INTERP_KERNEL::AutoPtr<int> bigArrRecv=new int[nbrecv2[grpSize-1]+nbrecv1[grpSize-1]];
+ commInterface.allToAllV(bigArr,nbsend2,nbsend3,MPI_INT,
+ bigArrRecv,nbrecv1,nbrecv2,MPI_INT,
+ *comm);// sending ids of sparse matrix (n+1 elems)
+ //second phase echange target ids
+ std::fill<int *>(nbsend2,nbsend2+grpSize,0);
+ INTERP_KERNEL::AutoPtr<int> nbrecv3=new int[grpSize];
+ INTERP_KERNEL::AutoPtr<int> nbrecv4=new int[grpSize];
+ double *tmp2=0;
+ int lgthOfArr=serializeMatrixStep1ST(nbrecv,bigArrRecv,nbrecv1,nbrecv2,
+ tmp,tmp2,
+ nbsend2,nbsend3,nbrecv3,nbrecv4);
+ INTERP_KERNEL::AutoPtr<int> bigArr2=tmp;
+ INTERP_KERNEL::AutoPtr<double> bigArrD2=tmp2;
+ INTERP_KERNEL::AutoPtr<int> bigArrRecv2=new int[lgthOfArr];
+ INTERP_KERNEL::AutoPtr<double> bigArrDRecv2=new double[lgthOfArr];
+ commInterface.allToAllV(bigArr2,nbsend2,nbsend3,MPI_INT,
+ bigArrRecv2,nbrecv3,nbrecv4,MPI_INT,
+ *comm);
+ commInterface.allToAllV(bigArrD2,nbsend2,nbsend3,MPI_DOUBLE,
+ bigArrDRecv2,nbrecv3,nbrecv4,MPI_DOUBLE,
+ *comm);
+ //finishing
+ unserializationST(nbOfTrgElems,nbrecv,bigArrRecv,nbrecv1,nbrecv2,
+ bigArrRecv2,bigArrDRecv2,nbrecv3,nbrecv4);
+ //updating _src_ids_zip_st2 and _src_ids_zip_st2 with received matrix.
+ updateZipSourceIdsForFuture();
+ //finish to fill _the_matrix_st with already in place matrix in _matrixes_st
+ finishToFillFinalMatrixST();
+ //printTheMatrix();
+}
+
+/*!
+ * Compute denominators.
+ */
+void OverlapMapping::computeDenoGlobConstraint()
+{
+ _the_deno_st.clear();
+ std::size_t sz1=_the_matrix_st.size();
+ _the_deno_st.resize(sz1);
+ for(std::size_t i=0;i<sz1;i++)
+ {
+ std::size_t sz2=_the_matrix_st[i].size();
+ _the_deno_st[i].resize(sz2);
+ for(std::size_t j=0;j<sz2;j++)
+ {
+ double sum=0;
+ std::map<int,double>& mToFill=_the_deno_st[i][j];
+ const std::map<int,double>& m=_the_matrix_st[i][j];
+ for(std::map<int,double>::const_iterator it=m.begin();it!=m.end();it++)
+ sum+=(*it).second;
+ for(std::map<int,double>::const_iterator it=m.begin();it!=m.end();it++)
+ mToFill[(*it).first]=sum;
+ }
+ }
+}
+
+/*!
+ * Compute denominators.
+ */
+void OverlapMapping::computeDenoConservativeVolumic(int nbOfTuplesTrg)
+{
+ CommInterface commInterface=_group.getCommInterface();
+ int myProcId=_group.myRank();
+ //
+ _the_deno_st.clear();
+ std::size_t sz1=_the_matrix_st.size();
+ _the_deno_st.resize(sz1);
+ std::vector<double> deno(nbOfTuplesTrg);
+ for(std::size_t i=0;i<sz1;i++)
+ {
+ const std::vector< std::map<int,double> >& mat=_the_matrix_st[i];
+ int curSrcId=_the_matrix_st_source_proc_id[i];
+ std::vector<int>::iterator isItem1=std::find(_trg_proc_st2.begin(),_trg_proc_st2.end(),curSrcId);
+ int rowId=0;
+ if(isItem1==_trg_proc_st2.end() || curSrcId==myProcId)//item1 of step2 main algo. Simple, because rowId of mat are directly target ids.
+ {
+ for(std::vector< std::map<int,double> >::const_iterator it1=mat.begin();it1!=mat.end();it1++,rowId++)
+ for(std::map<int,double>::const_iterator it2=(*it1).begin();it2!=(*it1).end();it2++)
+ deno[rowId]+=(*it2).second;
+ }
+ else
+ {//item0 of step2 main algo. More complicated.
+ std::vector<int>::iterator fnd=isItem1;//std::find(_trg_proc_st2.begin(),_trg_proc_st2.end(),curSrcId);
+ int locId=std::distance(_trg_proc_st2.begin(),fnd);
+ const DataArrayInt *trgIds=_trg_ids_st2[locId];
+ const int *trgIds2=trgIds->getConstPointer();
+ for(std::vector< std::map<int,double> >::const_iterator it1=mat.begin();it1!=mat.end();it1++,rowId++)
+ for(std::map<int,double>::const_iterator it2=(*it1).begin();it2!=(*it1).end();it2++)
+ deno[trgIds2[rowId]]+=(*it2).second;
+ }
+ }
+ //
+ for(std::size_t i=0;i<sz1;i++)
+ {
+ int rowId=0;
+ const std::vector< std::map<int,double> >& mat=_the_matrix_st[i];
+ int curSrcId=_the_matrix_st_source_proc_id[i];
+ std::vector<int>::iterator isItem1=std::find(_trg_proc_st2.begin(),_trg_proc_st2.end(),curSrcId);
+ std::vector< std::map<int,double> >& denoM=_the_deno_st[i];
+ denoM.resize(mat.size());
+ if(isItem1==_trg_proc_st2.end() || curSrcId==myProcId)//item1 of step2 main algo. Simple, because rowId of mat are directly target ids.
+ {
+ int rowId=0;
+ for(std::vector< std::map<int,double> >::const_iterator it1=mat.begin();it1!=mat.end();it1++,rowId++)
+ for(std::map<int,double>::const_iterator it2=(*it1).begin();it2!=(*it1).end();it2++)
+ denoM[rowId][(*it2).first]=deno[rowId];
+ }
+ else
+ {
+ std::vector<int>::iterator fnd=isItem1;
+ int locId=std::distance(_trg_proc_st2.begin(),fnd);
+ const DataArrayInt *trgIds=_trg_ids_st2[locId];
+ const int *trgIds2=trgIds->getConstPointer();
+ for(std::vector< std::map<int,double> >::const_iterator it1=mat.begin();it1!=mat.end();it1++,rowId++)
+ for(std::map<int,double>::const_iterator it2=(*it1).begin();it2!=(*it1).end();it2++)
+ denoM[rowId][(*it2).first]=deno[trgIds2[rowId]];
+ }
+ }
+}
+
+/*!
+ * This method performs step #0/3 in serialization process.
+ * \param count tells specifies nb of elems to send to corresponding proc id. size equal to _group.size().
+ * \param offsets tells for a proc i where to start serialize#0 matrix. size equal to _group.size().
+ * \param nbOfElemsSrc of size _group.size(). Comes from previous all2all call. tells how many srcIds per proc contains matrix for current proc.
+ */
+void OverlapMapping::serializeMatrixStep0ST(const int *nbOfElemsSrc, int *&bigArr, int *count, int *offsets,
+ int *countForRecv, int *offsetsForRecv) const
+{
+ int grpSize=_group.size();
+ std::fill<int *>(count,count+grpSize,0);
+ int szz=0;
+ int myProcId=_group.myRank();
+ for(std::size_t i=0;i<_matrixes_st.size();i++)
+ {
+ if(_source_proc_id_st[i]==myProcId)// && _target_proc_id_st[i]!=myProcId
+ {
+ count[_target_proc_id_st[i]]=_matrixes_st[i].size()+1;
+ szz+=_matrixes_st[i].size()+1;
+ }
+ }
+ bigArr=new int[szz];
+ offsets[0]=0;
+ for(int i=1;i<grpSize;i++)
+ offsets[i]=offsets[i-1]+count[i-1];
+ for(std::size_t i=0;i<_matrixes_st.size();i++)
+ {
+ if(_source_proc_id_st[i]==myProcId)
+ {
+ int start=offsets[_target_proc_id_st[i]];
+ int *work=bigArr+start;
+ *work=0;
+ const std::vector< std::map<int,double> >& mat=_matrixes_st[i];
+ for(std::vector< std::map<int,double> >::const_iterator it=mat.begin();it!=mat.end();it++,work++)
+ work[1]=work[0]+(*it).size();
+ }
+ }
+ //
+ offsetsForRecv[0]=0;
+ for(int i=0;i<grpSize;i++)
+ {
+ if(nbOfElemsSrc[i]>0)
+ countForRecv[i]=nbOfElemsSrc[i]+1;
+ else
+ countForRecv[i]=0;
+ if(i>0)
+ offsetsForRecv[i]=offsetsForRecv[i-1]+countForRecv[i-1];
+ }
+}
+
+/*!
+ * This method performs step#1 and step#2/3. It returns the size of expected array to get allToAllV.
+ */
+int OverlapMapping::serializeMatrixStep1ST(const int *nbOfElemsSrc, const int *recvStep0, const int *countStep0, const int *offsStep0,
+ int *&bigArrI, double *&bigArrD, int *count, int *offsets,
+ int *countForRecv, int *offsForRecv) const
+{
+ int grpSize=_group.size();
+ int myProcId=_group.myRank();
+ offsForRecv[0]=0;
+ int szz=0;
+ for(int i=0;i<grpSize;i++)
+ {
+ if(nbOfElemsSrc[i]!=0)
+ countForRecv[i]=recvStep0[offsStep0[i]+nbOfElemsSrc[i]];
+ else
+ countForRecv[i]=0;
+ szz+=countForRecv[i];
+ if(i>0)
+ offsForRecv[i]=offsForRecv[i-1]+countForRecv[i-1];
+ }
+ //
+ std::fill(count,count+grpSize,0);
+ offsets[0]=0;
+ int fullLgth=0;
+ for(std::size_t i=0;i<_matrixes_st.size();i++)
+ {
+ if(_source_proc_id_st[i]==myProcId)
+ {
+ const std::vector< std::map<int,double> >& mat=_matrixes_st[i];
+ int lgthToSend=0;
+ for(std::vector< std::map<int,double> >::const_iterator it=mat.begin();it!=mat.end();it++)
+ lgthToSend+=(*it).size();
+ count[_target_proc_id_st[i]]=lgthToSend;
+ fullLgth+=lgthToSend;
+ }
+ }
+ for(int i=1;i<grpSize;i++)
+ offsets[i]=offsets[i-1]+count[i-1];
+ //
+ bigArrI=new int[fullLgth];
+ bigArrD=new double[fullLgth];
+ // feeding arrays
+ fullLgth=0;
+ for(std::size_t i=0;i<_matrixes_st.size();i++)
+ {
+ if(_source_proc_id_st[i]==myProcId)
+ {
+ const std::vector< std::map<int,double> >& mat=_matrixes_st[i];
+ for(std::vector< std::map<int,double> >::const_iterator it1=mat.begin();it1!=mat.end();it1++)
+ {
+ int j=0;
+ for(std::map<int,double>::const_iterator it2=(*it1).begin();it2!=(*it1).end();it2++,j++)
+ {
+ bigArrI[fullLgth+j]=(*it2).first;
+ bigArrD[fullLgth+j]=(*it2).second;
+ }
+ fullLgth+=(*it1).size();
+ }
+ }
+ }
+ return szz;
+}
+
+/*!
+ * This is the last step after all2Alls for matrix exchange.
+ * _the_matrix_st is the final matrix :
+ * - The first entry is srcId in current proc.
+ * - The second is the pseudo id of source proc (correspondance with true id is in attribute _the_matrix_st_source_proc_id and _the_matrix_st_source_ids)
+ * - the third is the srcId in the pseudo source proc
+ */
+void OverlapMapping::unserializationST(int nbOfTrgElems,
+ const int *nbOfElemsSrcPerProc,//first all2all
+ const int *bigArrRecv, const int *bigArrRecvCounts, const int *bigArrRecvOffs,//2nd all2all
+ const int *bigArrRecv2, const double *bigArrDRecv2, const int *bigArrRecv2Count, const int *bigArrRecv2Offs)//3rd and 4th all2alls
+{
+ _the_matrix_st.clear();
+ _the_matrix_st_source_proc_id.clear();
+ //
+ int grpSize=_group.size();
+ for(int i=0;i<grpSize;i++)
+ if(nbOfElemsSrcPerProc[i]!=0)
+ _the_matrix_st_source_proc_id.push_back(i);
+ int nbOfPseudoProcs=_the_matrix_st_source_proc_id.size();//_the_matrix_st_target_proc_id.size() contains number of matrix fetched remotely whose sourceProcId==myProcId
+ _the_matrix_st.resize(nbOfPseudoProcs);
+ //
+ int j=0;
+ for(int i=0;i<grpSize;i++)
+ if(nbOfElemsSrcPerProc[i]!=0)
+ {
+ _the_matrix_st[j].resize(nbOfElemsSrcPerProc[i]);
+ for(int k=0;k<nbOfElemsSrcPerProc[i];k++)
+ {
+ int offs=bigArrRecv[bigArrRecvOffs[i]+k];
+ int lgthOfMap=bigArrRecv[bigArrRecvOffs[i]+k+1]-offs;
+ for(int l=0;l<lgthOfMap;l++)
+ _the_matrix_st[j][k][bigArrRecv2[bigArrRecv2Offs[i]+offs+l]]=bigArrDRecv2[bigArrRecv2Offs[i]+offs+l];
+ }
+ j++;
+ }
+}
+
+/*!
+ * This method should be called when all remote matrix with sourceProcId==thisProcId have been retrieved and are in 'this->_the_matrix_st' and 'this->_the_matrix_st_target_proc_id'
+ * and 'this->_the_matrix_st_target_ids'.
+ * This method finish the job of filling 'this->_the_matrix_st' and 'this->_the_matrix_st_target_proc_id' by putting candidates in 'this->_matrixes_st' into them.
+ */
+void OverlapMapping::finishToFillFinalMatrixST()
+{
+ int myProcId=_group.myRank();
+ int sz=_matrixes_st.size();
+ int nbOfEntryToAdd=0;
+ for(int i=0;i<sz;i++)
+ if(_source_proc_id_st[i]!=myProcId)
+ nbOfEntryToAdd++;
+ if(nbOfEntryToAdd==0)
+ return ;
+ int oldNbOfEntry=_the_matrix_st.size();
+ int newNbOfEntry=oldNbOfEntry+nbOfEntryToAdd;
+ _the_matrix_st.resize(newNbOfEntry);
+ int j=oldNbOfEntry;
+ for(int i=0;i<sz;i++)
+ if(_source_proc_id_st[i]!=myProcId)
+ {
+ const std::vector<std::map<int,double> >& mat=_matrixes_st[i];
+ _the_matrix_st[j]=mat;
+ _the_matrix_st_source_proc_id.push_back(_source_proc_id_st[i]);
+ j++;
+ }
+ _matrixes_st.clear();
+}
+
+/*!
+ * This method performs the operation of target ids broadcasting.
+ */
+void OverlapMapping::prepareIdsToSendST()
+{
+ CommInterface commInterface=_group.getCommInterface();
+ const MPIProcessorGroup *group=static_cast<const MPIProcessorGroup*>(&_group);
+ const MPI_Comm *comm=group->getComm();
+ int grpSize=_group.size();
+ _source_ids_to_send_st.clear();
+ _source_ids_to_send_st.resize(grpSize);
+ INTERP_KERNEL::AutoPtr<int> nbsend=new int[grpSize];
+ std::fill<int *>(nbsend,nbsend+grpSize,0);
+ for(std::size_t i=0;i<_the_matrix_st_source_proc_id.size();i++)
+ nbsend[_the_matrix_st_source_proc_id[i]]=_the_matrix_st_source_ids[i].size();
+ INTERP_KERNEL::AutoPtr<int> nbrecv=new int[grpSize];
+ commInterface.allToAll(nbsend,1,MPI_INT,nbrecv,1,MPI_INT,*comm);
+ //
+ INTERP_KERNEL::AutoPtr<int> nbsend2=new int[grpSize];
+ std::copy((int *)nbsend,((int *)nbsend)+grpSize,(int *)nbsend2);
+ INTERP_KERNEL::AutoPtr<int> nbsend3=new int[grpSize];
+ nbsend3[0]=0;
+ for(int i=1;i<grpSize;i++)
+ nbsend3[i]=nbsend3[i-1]+nbsend2[i-1];
+ int sendSz=nbsend3[grpSize-1]+nbsend2[grpSize-1];
+ INTERP_KERNEL::AutoPtr<int> bigDataSend=new int[sendSz];
+ for(std::size_t i=0;i<_the_matrix_st_source_proc_id.size();i++)
+ {
+ int offset=nbsend3[_the_matrix_st_source_proc_id[i]];
+ std::copy(_the_matrix_st_source_ids[i].begin(),_the_matrix_st_source_ids[i].end(),((int *)nbsend3)+offset);
+ }
+ INTERP_KERNEL::AutoPtr<int> nbrecv2=new int[grpSize];
+ INTERP_KERNEL::AutoPtr<int> nbrecv3=new int[grpSize];
+ std::copy((int *)nbrecv,((int *)nbrecv)+grpSize,(int *)nbrecv2);
+ nbrecv3[0]=0;
+ for(int i=1;i<grpSize;i++)
+ nbrecv3[i]=nbrecv3[i-1]+nbrecv2[i-1];
+ int recvSz=nbrecv3[grpSize-1]+nbrecv2[grpSize-1];
+ INTERP_KERNEL::AutoPtr<int> bigDataRecv=new int[recvSz];
+ //
+ commInterface.allToAllV(bigDataSend,nbsend2,nbsend3,MPI_INT,
+ bigDataRecv,nbrecv2,nbrecv3,MPI_INT,
+ *comm);
+ for(int i=0;i<grpSize;i++)
+ {
+ if(nbrecv2[i]>0)
+ {
+ _source_ids_to_send_st[i].insert(_source_ids_to_send_st[i].end(),((int *)bigDataRecv)+nbrecv3[i],((int *)bigDataRecv)+nbrecv3[i]+nbrecv2[i]);
+ }
+ }
+}
+
+/*!
+ * This method performs a transpose multiply of 'fieldInput' and put the result into 'fieldOutput'.
+ * 'fieldInput' is expected to be the sourcefield and 'fieldOutput' the targetfield.
+ */
+void OverlapMapping::multiply(const MEDCouplingFieldDouble *fieldInput, MEDCouplingFieldDouble *fieldOutput) const
+{
+ int nbOfCompo=fieldInput->getNumberOfComponents();//to improve same number of components to test
+ CommInterface commInterface=_group.getCommInterface();
+ const MPIProcessorGroup *group=static_cast<const MPIProcessorGroup*>(&_group);
+ const MPI_Comm *comm=group->getComm();
+ int grpSize=_group.size();
+ int myProcId=_group.myRank();
+ //
+ INTERP_KERNEL::AutoPtr<int> nbsend=new int[grpSize];
+ INTERP_KERNEL::AutoPtr<int> nbsend2=new int[grpSize];
+ INTERP_KERNEL::AutoPtr<int> nbrecv=new int[grpSize];
+ INTERP_KERNEL::AutoPtr<int> nbrecv2=new int[grpSize];
+ std::fill<int *>(nbsend,nbsend+grpSize,0);
+ std::fill<int *>(nbrecv,nbrecv+grpSize,0);
+ nbsend2[0]=0;
+ nbrecv2[0]=0;
+ std::vector<double> valsToSend;
+ for(int i=0;i<grpSize;i++)
+ {
+ if(std::find(_proc_ids_to_send_vector_st.begin(),_proc_ids_to_send_vector_st.end(),i)!=_proc_ids_to_send_vector_st.end())
+ {
+ std::vector<int>::const_iterator isItem1=std::find(_src_proc_st2.begin(),_src_proc_st2.end(),i);
+ MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> vals;
+ if(isItem1!=_src_proc_st2.end())//item1 of step2 main algo
+ {
+ int id=std::distance(_src_proc_st2.begin(),isItem1);
+ vals=fieldInput->getArray()->selectByTupleId(_src_ids_st2[id]->getConstPointer(),_src_ids_st2[id]->getConstPointer()+_src_ids_st2[id]->getNumberOfTuples());
+ }
+ else
+ {//item0 of step2 main algo
+ int id=std::distance(_src_ids_zip_proc_st2.begin(),std::find(_src_ids_zip_proc_st2.begin(),_src_ids_zip_proc_st2.end(),i));
+ vals=fieldInput->getArray()->selectByTupleId(&(_src_ids_zip_st2[id])[0],&(_src_ids_zip_st2[id])[0]+_src_ids_zip_st2[id].size());
+ }
+ nbsend[i]=vals->getNbOfElems();
+ valsToSend.insert(valsToSend.end(),vals->getConstPointer(),vals->getConstPointer()+nbsend[i]);
+ }
+ if(std::find(_proc_ids_to_recv_vector_st.begin(),_proc_ids_to_recv_vector_st.end(),i)!=_proc_ids_to_recv_vector_st.end())
+ {
+ std::vector<int>::const_iterator isItem0=std::find(_trg_proc_st2.begin(),_trg_proc_st2.end(),i);
+ if(isItem0==_trg_proc_st2.end())//item1 of step2 main algo [ (0,1) computed on proc1 and Matrix-Vector on proc1 ]
+ {
+ std::vector<int>::const_iterator it1=std::find(_src_ids_proc_st2.begin(),_src_ids_proc_st2.end(),i);
+ if(it1!=_src_ids_proc_st2.end())
+ {
+ int id=std::distance(_src_ids_proc_st2.begin(),it1);
+ nbrecv[i]=_nb_of_src_ids_proc_st2[id]*nbOfCompo;
+ }
+ else if(i==myProcId)
+ {
+ nbrecv[i]=fieldInput->getNumberOfTuplesExpected()*nbOfCompo;
+ }
+ else
+ throw INTERP_KERNEL::Exception("Plouff ! send email to anthony.geay@cea.fr ! ");
+ }
+ else
+ {//item0 of step2 main algo [ (2,1) computed on proc2 but Matrix-Vector on proc1 ] [(1,0) computed on proc1 but Matrix-Vector on proc0]
+ int id=std::distance(_src_ids_zip_proc_st2.begin(),std::find(_src_ids_zip_proc_st2.begin(),_src_ids_zip_proc_st2.end(),i));
+ nbrecv[i]=_src_ids_zip_st2[id].size()*nbOfCompo;
+ }
+ }
+ }
+ for(int i=1;i<grpSize;i++)
+ {
+ nbsend2[i]=nbsend2[i-1]+nbsend[i-1];
+ nbrecv2[i]=nbrecv2[i-1]+nbrecv[i-1];
+ }
+ INTERP_KERNEL::AutoPtr<double> bigArr=new double[nbrecv2[grpSize-1]+nbrecv[grpSize-1]];
+ commInterface.allToAllV(&valsToSend[0],nbsend,nbsend2,MPI_DOUBLE,
+ bigArr,nbrecv,nbrecv2,MPI_DOUBLE,*comm);
+ fieldOutput->getArray()->fillWithZero();
+ INTERP_KERNEL::AutoPtr<double> tmp=new double[nbOfCompo];
+ for(int i=0;i<grpSize;i++)
+ {
+ if(nbrecv[i]>0)
+ {
+ double *pt=fieldOutput->getArray()->getPointer();
+ std::vector<int>::const_iterator it=std::find(_the_matrix_st_source_proc_id.begin(),_the_matrix_st_source_proc_id.end(),i);
+ if(it==_the_matrix_st_source_proc_id.end())
+ throw INTERP_KERNEL::Exception("Big problem !");
+ int id=std::distance(_the_matrix_st_source_proc_id.begin(),it);
+ const std::vector< std::map<int,double> >& mat=_the_matrix_st[id];
+ const std::vector< std::map<int,double> >& deno=_the_deno_st[id];
+ std::vector<int>::const_iterator isItem0=std::find(_trg_proc_st2.begin(),_trg_proc_st2.end(),i);
+ if(isItem0==_trg_proc_st2.end())//item1 of step2 main algo [ (0,1) computed on proc1 and Matrix-Vector on proc1 ]
+ {
+ int nbOfTrgTuples=mat.size();
+ for(int j=0;j<nbOfTrgTuples;j++,pt+=nbOfCompo)
+ {
+ const std::map<int,double>& mat1=mat[j];
+ const std::map<int,double>& deno1=deno[j];
+ std::map<int,double>::const_iterator it4=deno1.begin();
+ for(std::map<int,double>::const_iterator it3=mat1.begin();it3!=mat1.end();it3++,it4++)
+ {
+ std::transform(bigArr+nbrecv2[i]+((*it3).first)*nbOfCompo,bigArr+nbrecv2[i]+((*it3).first+1)*(nbOfCompo),(double *)tmp,std::bind2nd(std::multiplies<double>(),(*it3).second/(*it4).second));
+ std::transform((double *)tmp,(double *)tmp+nbOfCompo,pt,pt,std::plus<double>());
+ }
+ }
+ }
+ else
+ {//item0 of step2 main algo [ (2,1) computed on proc2 but Matrix-Vector on proc1 ]
+ double *pt=fieldOutput->getArray()->getPointer();
+ std::map<int,int> zipCor;
+ int id=std::distance(_src_ids_zip_proc_st2.begin(),std::find(_src_ids_zip_proc_st2.begin(),_src_ids_zip_proc_st2.end(),i));
+ const std::vector<int> zipIds=_src_ids_zip_st2[id];
+ int newId=0;
+ for(std::vector<int>::const_iterator it=zipIds.begin();it!=zipIds.end();it++,newId++)
+ zipCor[*it]=newId;
+ int id2=std::distance(_trg_proc_st2.begin(),std::find(_trg_proc_st2.begin(),_trg_proc_st2.end(),i));
+ const DataArrayInt *tgrIds=_trg_ids_st2[id2];
+ const int *tgrIds2=tgrIds->getConstPointer();
+ int nbOfTrgTuples=mat.size();
+ for(int j=0;j<nbOfTrgTuples;j++)
+ {
+ const std::map<int,double>& mat1=mat[j];
+ const std::map<int,double>& deno1=deno[j];
+ std::map<int,double>::const_iterator it5=deno1.begin();
+ for(std::map<int,double>::const_iterator it3=mat1.begin();it3!=mat1.end();it3++,it5++)
+ {
+ std::map<int,int>::const_iterator it4=zipCor.find((*it3).first);
+ if(it4==zipCor.end())
+ throw INTERP_KERNEL::Exception("Hmmmmm send e mail to anthony.geay@cea.fr !");
+ std::transform(bigArr+nbrecv2[i]+((*it4).second)*nbOfCompo,bigArr+nbrecv2[i]+((*it4).second+1)*(nbOfCompo),(double *)tmp,std::bind2nd(std::multiplies<double>(),(*it3).second/(*it5).second));
+ std::transform((double *)tmp,(double *)tmp+nbOfCompo,pt+tgrIds2[j]*nbOfCompo,pt+tgrIds2[j]*nbOfCompo,std::plus<double>());
+ }
+ }
+ }
+ }
+ }
+}
+
+/*!
+ * This method performs a transpose multiply of 'fieldInput' and put the result into 'fieldOutput'.
+ * 'fieldInput' is expected to be the targetfield and 'fieldOutput' the sourcefield.
+ */
+void OverlapMapping::transposeMultiply(const MEDCouplingFieldDouble *fieldInput, MEDCouplingFieldDouble *fieldOutput)
+{
+}
+
+/*!
+ * This method should be called immediately after _the_matrix_st has been filled with remote computed matrix put in this proc for Matrix-Vector.
+ * This method computes for these matrix the minimal set of source ids corresponding to the source proc id.
+ */
+void OverlapMapping::updateZipSourceIdsForFuture()
+{
+ CommInterface commInterface=_group.getCommInterface();
+ int myProcId=_group.myRank();
+ int nbOfMatrixRecveived=_the_matrix_st_source_proc_id.size();
+ for(int i=0;i<nbOfMatrixRecveived;i++)
+ {
+ int curSrcProcId=_the_matrix_st_source_proc_id[i];
+ if(curSrcProcId!=myProcId)
+ {
+ const std::vector< std::map<int,double> >& mat=_the_matrix_st[i];
+ _src_ids_zip_proc_st2.push_back(curSrcProcId);
+ _src_ids_zip_st2.resize(_src_ids_zip_st2.size()+1);
+ std::set<int> s;
+ for(std::vector< std::map<int,double> >::const_iterator it1=mat.begin();it1!=mat.end();it1++)
+ for(std::map<int,double>::const_iterator it2=(*it1).begin();it2!=(*it1).end();it2++)
+ s.insert((*it2).first);
+ _src_ids_zip_st2.back().insert(_src_ids_zip_st2.back().end(),s.begin(),s.end());
+ }
+ }
+}
+
+// #include <iostream>
+
+// void OverlapMapping::printTheMatrix() const
+// {
+// CommInterface commInterface=_group.getCommInterface();
+// const MPIProcessorGroup *group=static_cast<const MPIProcessorGroup*>(&_group);
+// const MPI_Comm *comm=group->getComm();
+// int grpSize=_group.size();
+// int myProcId=_group.myRank();
+// std::cerr << "I am proc #" << myProcId << std::endl;
+// int nbOfMat=_the_matrix_st.size();
+// std::cerr << "I do manage " << nbOfMat << "matrix : "<< std::endl;
+// for(int i=0;i<nbOfMat;i++)
+// {
+// std::cerr << " - Matrix #" << i << " on source proc #" << _the_matrix_st_source_proc_id[i];
+// const std::vector< std::map<int,double> >& locMat=_the_matrix_st[i];
+// for(std::vector< std::map<int,double> >::const_iterator it1=locMat.begin();it1!=locMat.end();it1++)
+// {
+// for(std::map<int,double>::const_iterator it2=(*it1).begin();it2!=(*it1).end();it2++)
+// std::cerr << "(" << (*it2).first << "," << (*it2).second << "), ";
+// std::cerr << std::endl;
+// }
+// }
+// std::cerr << "*********" << std::endl;
+// }
--- /dev/null
+// Copyright (C) 2007-2010 CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#ifndef __OVERLAPMAPPING_HXX__
+#define __OVERLAPMAPPING_HXX__
+
+#include "MEDCouplingAutoRefCountObjectPtr.hxx"
+
+#include <vector>
+#include <map>
+
+namespace ParaMEDMEM
+{
+ class ProcessorGroup;
+ class DataArrayInt;
+ class MEDCouplingFieldDouble;
+
+ class OverlapMapping
+ {
+ public:
+ OverlapMapping(const ProcessorGroup& group);
+ void keepTracksOfSourceIds(int procId, DataArrayInt *ids);
+ void keepTracksOfTargetIds(int procId, DataArrayInt *ids);
+ void addContributionST(const std::vector< std::map<int,double> >& matrixST, const DataArrayInt *srcIds, int srcProcId, const DataArrayInt *trgIds, int trgProcId);
+ void prepare(const std::vector< std::vector<int> >& procsInInteraction, int nbOfTrgElems);
+ void computeDenoConservativeVolumic(int nbOfTuplesTrg);
+ void computeDenoGlobConstraint();
+ //
+ void multiply(const MEDCouplingFieldDouble *fieldInput, MEDCouplingFieldDouble *fieldOutput) const;
+ void transposeMultiply(const MEDCouplingFieldDouble *fieldInput, MEDCouplingFieldDouble *fieldOutput);
+ private:
+ void serializeMatrixStep0ST(const int *nbOfElemsSrc, int *&bigArr, int *count, int *offsets,
+ int *countForRecv, int *offsetsForRecv) const;
+ int serializeMatrixStep1ST(const int *nbOfElemsSrc, const int *recvStep0, const int *countStep0, const int *offsStep0,
+ int *&bigArrI, double *&bigArrD, int *count, int *offsets,
+ int *countForRecv, int *offsForRecv) const;
+ void unserializationST(int nbOfTrgElems, const int *nbOfElemsSrcPerProc, const int *bigArrRecv, const int *bigArrRecvCounts, const int *bigArrRecvOffs,
+ const int *bigArrRecv2, const double *bigArrDRecv2, const int *bigArrRecv2Count, const int *bigArrRecv2Offs);
+ void finishToFillFinalMatrixST();
+ void prepareIdsToSendST();
+ void updateZipSourceIdsForFuture();
+ //void printTheMatrix() const;
+ private:
+ const ProcessorGroup &_group;
+ //! vector of ids
+ std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > _src_ids_st2;//item #1
+ std::vector< int > _src_proc_st2;//item #1
+ std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > _trg_ids_st2;//item #0
+ std::vector< int > _trg_proc_st2;//item #0
+ std::vector< int > _nb_of_src_ids_proc_st2;//item #1
+ std::vector< int > _src_ids_proc_st2;//item #1
+ std::vector< std::vector<int> > _src_ids_zip_st2;//same size as _src_ids_zip_proc_st2. Sorted. specifies for each id the corresponding ids to send. This is for item0 of Step2 of main algorithm
+ std::vector< int > _src_ids_zip_proc_st2;
+ //! vector of matrixes the first entry correspond to source proc id in _source_ids_st
+ std::vector< std::vector< std::map<int,double> > > _matrixes_st;
+ std::vector< std::vector<int> > _source_ids_st;
+ std::vector< int > _source_proc_id_st;
+ std::vector< std::vector<int> > _target_ids_st;
+ std::vector< int > _target_proc_id_st;
+ //! the matrix for matrix-vector product. The first dimension the set of target procs that interacts with local source mesh. The second dimension correspond to nb of local source ids.
+ std::vector< std::vector< std::map<int,double> > > _the_matrix_st;
+ std::vector< int > _the_matrix_st_source_proc_id;
+ std::vector< std::vector<int> > _the_matrix_st_source_ids;
+ std::vector< std::vector< std::map<int,double> > > _the_deno_st;
+ //! this attribute stores the proc ids that wait for data from this proc ids for matrix-vector computation
+ std::vector< int > _proc_ids_to_send_vector_st;
+ std::vector< int > _proc_ids_to_recv_vector_st;
+ //! this attribute is of size _group.size(); for each procId in _group _source_ids_to_send_st[procId] contains tupleId to send abroad
+ std::vector< std::vector<int> > _source_ids_to_send_st;
+ };
+}
+
+#endif
void ParaFIELD::synchronizeTarget(ParaFIELD* source_field)
{
- DEC* data_channel;
+ DisjointDEC* data_channel;
if (dynamic_cast<BlockTopology*>(_topology)!=0)
{
data_channel=new StructuredCoincidentDEC;
void ParaFIELD::synchronizeSource(ParaFIELD* target_field)
{
- DEC* data_channel;
+ DisjointDEC* data_channel;
if (dynamic_cast<BlockTopology*>(_topology)!=0)
{
data_channel=new StructuredCoincidentDEC;
\addtogroup structuredcoincidentdec
@{
*/
- StructuredCoincidentDEC::StructuredCoincidentDEC(ProcessorGroup& local_group, ProcessorGroup& distant_group):DEC(local_group,distant_group),
+ StructuredCoincidentDEC::StructuredCoincidentDEC(ProcessorGroup& local_group, ProcessorGroup& distant_group):DisjointDEC(local_group,distant_group),
_topo_source(0),_topo_target(0),
_send_counts(0),_recv_counts(0),
_send_displs(0),_recv_displs(0),
#ifndef __STRUCTUREDCOINCIDENTDEC_HXX__
#define __STRUCTUREDCOINCIDENTDEC_HXX__
-#include "DEC.hxx"
+#include "DisjointDEC.hxx"
#include "BlockTopology.hxx"
{
class DEC;
class BlockTopology;
- class StructuredCoincidentDEC : public DEC
+ class StructuredCoincidentDEC : public DisjointDEC
{
public:
StructuredCoincidentDEC();
ParaMEDMEMTest_Gauthier1.cxx \
ParaMEDMEMTest_FabienAPI.cxx \
ParaMEDMEMTest_NonCoincidentDEC.cxx \
+ ParaMEDMEMTest_OverlapDEC.cxx \
MPIAccessDECTest.cxx \
test_AllToAllDEC.cxx \
test_AllToAllvDEC.cxx \
LDADD = $(MED2_LIBS) $(libMEDMEMTest_la_LDFLAGS) -lm $(MPI_LIBS) \
libParaMEDMEMTest.la \
+ ../INTERP_KERNEL/libinterpkernel.la $(CPPUNIT_LIBS) \
+ ../ParaMEDMEM/libparamedmem.la \
+ ../MEDCoupling/libmedcoupling.la \
+ ../MEDLoader/libmedloader.la
../INTERP_KERNEL/libinterpkernel.la
if MED_ENABLE_FVM
CPPUNIT_TEST(testInterpKernelDEC2DM1D_P0P0);
CPPUNIT_TEST(testInterpKernelDECPartialProcs);
CPPUNIT_TEST(testInterpKernelDEC3DSurfEmptyBBox);
+ CPPUNIT_TEST(testOverlapDEC1);
CPPUNIT_TEST(testSynchronousEqualInterpKernelWithoutInterpNativeDEC_2D);
CPPUNIT_TEST(testSynchronousEqualInterpKernelWithoutInterpDEC_2D);
void testInterpKernelDEC2DM1D_P0P0();
void testInterpKernelDECPartialProcs();
void testInterpKernelDEC3DSurfEmptyBBox();
+ void testOverlapDEC1();
#ifdef MED_ENABLE_FVM
void testNonCoincidentDEC_2D();
void testNonCoincidentDEC_3D();
void ParaMEDMEMTest::testMEDLoaderRead1()
{
- string fileName=getResourceFile("pointe_import22.med");
+ string fileName=getResourceFile("pointe.med");
vector<string> meshNames=MEDLoader::GetMeshNames(fileName.c_str());
CPPUNIT_ASSERT_EQUAL(1,(int)meshNames.size());
MEDCouplingUMesh *mesh=MEDLoader::ReadUMeshFromFile(fileName.c_str(),meshNames[0].c_str(),0);
CPPUNIT_ASSERT(fieldsNameNode[1]=="fieldnodeint");
std::vector<std::pair<int,int> > its0Node=MEDLoader::GetNodeFieldIterations(fileName.c_str(),meshNames[0].c_str(),fieldsNameNode[0].c_str());
CPPUNIT_ASSERT_EQUAL(3,(int)its0Node.size());
- CPPUNIT_ASSERT_EQUAL(1,its0Node[0].first);
+ CPPUNIT_ASSERT_EQUAL(-1,its0Node[0].first);
CPPUNIT_ASSERT_EQUAL(-1,its0Node[0].second);
- CPPUNIT_ASSERT_EQUAL(2,its0Node[1].first);
+ CPPUNIT_ASSERT_EQUAL(1,its0Node[1].first);
CPPUNIT_ASSERT_EQUAL(-1,its0Node[1].second);
- CPPUNIT_ASSERT_EQUAL(-1,its0Node[2].first);//strange but like that
+ CPPUNIT_ASSERT_EQUAL(2,its0Node[2].first);
CPPUNIT_ASSERT_EQUAL(-1,its0Node[2].second);
MEDCouplingFieldDouble *field0Nodes=MEDLoader::ReadFieldNode(fileName.c_str(),meshNames[0].c_str(),0,fieldsNameNode[0].c_str(),its0Node[0].first,its0Node[0].second);
field0Nodes->checkCoherency();
CPPUNIT_ASSERT(constMesh);
field0Nodes->decrRef();
//
- field0Nodes=MEDLoader::ReadFieldNode(fileName.c_str(),meshNames[0].c_str(),0,fieldsNameNode[0].c_str(),its0Node[1].first,its0Node[1].second);
+ field0Nodes=MEDLoader::ReadFieldNode(fileName.c_str(),meshNames[0].c_str(),0,fieldsNameNode[0].c_str(),its0Node[2].first,its0Node[2].second);
field0Nodes->checkCoherency();
CPPUNIT_ASSERT(field0Nodes->getName()==fieldsNameNode[0]);
CPPUNIT_ASSERT_EQUAL(1,field0Nodes->getNumberOfComponents());
CPPUNIT_ASSERT_DOUBLES_EQUAL(46.,std::accumulate(constMesh->getCoords()->getPointer(),constMesh->getCoords()->getPointer()+57,0),1e-12);
field0Nodes->decrRef();
//
- field0Nodes=MEDLoader::ReadFieldNode(fileName.c_str(),meshNames[0].c_str(),0,fieldsNameNode[0].c_str(),its0Node[2].first,its0Node[2].second);
+ field0Nodes=MEDLoader::ReadFieldNode(fileName.c_str(),meshNames[0].c_str(),0,fieldsNameNode[0].c_str(),its0Node[0].first,its0Node[0].second);
field0Nodes->checkCoherency();
CPPUNIT_ASSERT(field0Nodes->getName()==fieldsNameNode[0]);
CPPUNIT_ASSERT_EQUAL(1,field0Nodes->getNumberOfComponents());
--- /dev/null
+// Copyright (C) 2007-2010 CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#include "ParaMEDMEMTest.hxx"
+#include <cppunit/TestAssert.h>
+
+#include "CommInterface.hxx"
+#include "ProcessorGroup.hxx"
+#include "MPIProcessorGroup.hxx"
+#include "Topology.hxx"
+#include "OverlapDEC.hxx"
+#include "ParaMESH.hxx"
+#include "ParaFIELD.hxx"
+#include "ComponentTopology.hxx"
+
+#include "MEDCouplingUMesh.hxx"
+
+#include <set>
+
+void ParaMEDMEMTest::testOverlapDEC1()
+{
+ std::string srcM("P0");
+ std::string targetM("P0");
+ int size;
+ int rank;
+ MPI_Comm_size(MPI_COMM_WORLD,&size);
+ MPI_Comm_rank(MPI_COMM_WORLD,&rank);
+
+ if (size != 3) return ;
+
+ int nproc = 3;
+ std::set<int> procs;
+
+ for (int i=0; i<nproc; i++)
+ procs.insert(i);
+
+ ParaMEDMEM::CommInterface interface;
+
+ ParaMEDMEM::OverlapDEC dec(procs);
+
+ ParaMEDMEM::MEDCouplingUMesh* meshS=0;
+ ParaMEDMEM::MEDCouplingUMesh* meshT=0;
+ ParaMEDMEM::ParaMESH* parameshS=0;
+ ParaMEDMEM::ParaMESH* parameshT=0;
+ ParaMEDMEM::ParaFIELD* parafieldS=0;
+ ParaMEDMEM::ParaFIELD* parafieldT=0;
+
+ MPI_Barrier(MPI_COMM_WORLD);
+ if(rank==0)
+ {
+ const double coordsS[10]={0.,0.,0.5,0.,1.,0.,0.,0.5,0.5,0.5};
+ const double coordsT[6]={0.,0.,1.,0.,1.,1.};
+ meshS=ParaMEDMEM::MEDCouplingUMesh::New();
+ meshS->setMeshDimension(2);
+ ParaMEDMEM::DataArrayDouble *myCoords=ParaMEDMEM::DataArrayDouble::New();
+ myCoords->alloc(5,2);
+ std::copy(coordsS,coordsS+10,myCoords->getPointer());
+ meshS->setCoords(myCoords);
+ myCoords->decrRef();
+ int connS[7]={0,3,4,1, 1,4,2};
+ meshS->allocateCells(2);
+ meshS->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,connS);
+ meshS->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,connS+4);
+ meshS->finishInsertingCells();
+ ParaMEDMEM::ComponentTopology comptopo;
+ parameshS=new ParaMEDMEM::ParaMESH(meshS,*dec.getGrp(),"source mesh");
+ parafieldS=new ParaMEDMEM::ParaFIELD(ParaMEDMEM::ON_CELLS,ParaMEDMEM::NO_TIME,parameshS,comptopo);
+ parafieldS->getField()->setNature(ParaMEDMEM::ConservativeVolumic);//IntegralGlobConstraint
+ double *valsS=parafieldS->getField()->getArray()->getPointer();
+ valsS[0]=7.; valsS[1]=8.;
+ //
+ meshT=ParaMEDMEM::MEDCouplingUMesh::New();
+ meshT->setMeshDimension(2);
+ myCoords=ParaMEDMEM::DataArrayDouble::New();
+ myCoords->alloc(3,2);
+ std::copy(coordsT,coordsT+6,myCoords->getPointer());
+ meshT->setCoords(myCoords);
+ myCoords->decrRef();
+ int connT[3]={0,2,1};
+ meshT->allocateCells(1);
+ meshT->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,connT);
+ meshT->finishInsertingCells();
+ parameshT=new ParaMEDMEM::ParaMESH(meshT,*dec.getGrp(),"target mesh");
+ parafieldT=new ParaMEDMEM::ParaFIELD(ParaMEDMEM::ON_CELLS,ParaMEDMEM::NO_TIME,parameshT,comptopo);
+ parafieldT->getField()->setNature(ParaMEDMEM::ConservativeVolumic);//IntegralGlobConstraint
+ double *valsT=parafieldT->getField()->getArray()->getPointer();
+ valsT[0]=7.;
+ }
+ //
+ if(rank==1)
+ {
+ const double coordsS[10]={1.,0.,0.5,0.5,1.,0.5,0.5,1.,1.,1.};
+ const double coordsT[6]={0.,0.,0.5,0.5,0.,1.};
+ meshS=ParaMEDMEM::MEDCouplingUMesh::New();
+ meshS->setMeshDimension(2);
+ ParaMEDMEM::DataArrayDouble *myCoords=ParaMEDMEM::DataArrayDouble::New();
+ myCoords->alloc(5,2);
+ std::copy(coordsS,coordsS+10,myCoords->getPointer());
+ meshS->setCoords(myCoords);
+ myCoords->decrRef();
+ int connS[7]={0,1,2, 1,3,4,2};
+ meshS->allocateCells(2);
+ meshS->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,connS);
+ meshS->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,connS+3);
+ meshS->finishInsertingCells();
+ ParaMEDMEM::ComponentTopology comptopo;
+ parameshS=new ParaMEDMEM::ParaMESH(meshS,*dec.getGrp(),"source mesh");
+ parafieldS=new ParaMEDMEM::ParaFIELD(ParaMEDMEM::ON_CELLS,ParaMEDMEM::NO_TIME,parameshS,comptopo);
+ parafieldS->getField()->setNature(ParaMEDMEM::ConservativeVolumic);//IntegralGlobConstraint
+ double *valsS=parafieldS->getField()->getArray()->getPointer();
+ valsS[0]=9.; valsS[1]=11.;
+ //
+ meshT=ParaMEDMEM::MEDCouplingUMesh::New();
+ meshT->setMeshDimension(2);
+ myCoords=ParaMEDMEM::DataArrayDouble::New();
+ myCoords->alloc(3,2);
+ std::copy(coordsT,coordsT+6,myCoords->getPointer());
+ meshT->setCoords(myCoords);
+ myCoords->decrRef();
+ int connT[3]={0,2,1};
+ meshT->allocateCells(1);
+ meshT->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,connT);
+ meshT->finishInsertingCells();
+ parameshT=new ParaMEDMEM::ParaMESH(meshT,*dec.getGrp(),"target mesh");
+ parafieldT=new ParaMEDMEM::ParaFIELD(ParaMEDMEM::ON_CELLS,ParaMEDMEM::NO_TIME,parameshT,comptopo);
+ parafieldT->getField()->setNature(ParaMEDMEM::ConservativeVolumic);//IntegralGlobConstraint
+ double *valsT=parafieldT->getField()->getArray()->getPointer();
+ valsT[0]=8.;
+ }
+ //
+ if(rank==2)
+ {
+ const double coordsS[8]={0.,0.5, 0.5,0.5, 0.,1., 0.5,1.};
+ const double coordsT[6]={0.5,0.5,0.,1.,1.,1.};
+ meshS=ParaMEDMEM::MEDCouplingUMesh::New();
+ meshS->setMeshDimension(2);
+ ParaMEDMEM::DataArrayDouble *myCoords=ParaMEDMEM::DataArrayDouble::New();
+ myCoords->alloc(4,2);
+ std::copy(coordsS,coordsS+8,myCoords->getPointer());
+ meshS->setCoords(myCoords);
+ myCoords->decrRef();
+ int connS[4]={0,2,3,1};
+ meshS->allocateCells(1);
+ meshS->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,connS);
+ meshS->finishInsertingCells();
+ ParaMEDMEM::ComponentTopology comptopo;
+ parameshS=new ParaMEDMEM::ParaMESH(meshS,*dec.getGrp(),"source mesh");
+ parafieldS=new ParaMEDMEM::ParaFIELD(ParaMEDMEM::ON_CELLS,ParaMEDMEM::NO_TIME,parameshS,comptopo);
+ parafieldS->getField()->setNature(ParaMEDMEM::ConservativeVolumic);//IntegralGlobConstraint
+ double *valsS=parafieldS->getField()->getArray()->getPointer();
+ valsS[0]=10.;
+ //
+ meshT=ParaMEDMEM::MEDCouplingUMesh::New();
+ meshT->setMeshDimension(2);
+ myCoords=ParaMEDMEM::DataArrayDouble::New();
+ myCoords->alloc(3,2);
+ std::copy(coordsT,coordsT+6,myCoords->getPointer());
+ meshT->setCoords(myCoords);
+ myCoords->decrRef();
+ int connT[3]={0,1,2};
+ meshT->allocateCells(1);
+ meshT->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,connT);
+ meshT->finishInsertingCells();
+ parameshT=new ParaMEDMEM::ParaMESH(meshT,*dec.getGrp(),"target mesh");
+ parafieldT=new ParaMEDMEM::ParaFIELD(ParaMEDMEM::ON_CELLS,ParaMEDMEM::NO_TIME,parameshT,comptopo);
+ parafieldT->getField()->setNature(ParaMEDMEM::ConservativeVolumic);//IntegralGlobConstraint
+ double *valsT=parafieldT->getField()->getArray()->getPointer();
+ valsT[0]=9.;
+ }
+ dec.attachSourceLocalField(parafieldS);
+ dec.attachTargetLocalField(parafieldT);
+ dec.synchronize();
+ dec.sendRecvData(true);
+ //
+ if(rank==0)
+ {
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(8.75,parafieldT->getField()->getArray()->getIJ(0,0),1e-12);
+ }
+ if(rank==1)
+ {
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(8.5,parafieldT->getField()->getArray()->getIJ(0,0),1e-12);
+ }
+ if(rank==2)
+ {
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(10.5,parafieldT->getField()->getArray()->getIJ(0,0),1e-12);
+ }
+ delete parafieldS;
+ delete parafieldT;
+ delete parameshS;
+ delete parameshT;
+ meshS->decrRef();
+ meshT->decrRef();
+
+ MPI_Barrier(MPI_COMM_WORLD);
+}
+
#
include $(top_srcdir)/adm_local/unix/make_common_starter.am
-salomepython_PYTHON = libParaMEDMEM_Swig.py
-salomepyexec_LTLIBRARIES = _libParaMEDMEM_Swig.la
+salomepython_PYTHON = ParaMEDMEM.py
+salomepyexec_LTLIBRARIES = _ParaMEDMEM.la
salomeinclude_HEADERS = \
- libParaMEDMEM_Swig.i
+ ParaMEDMEM.i
-SWIG_DEF = libParaMEDMEM_Swig.i libParaMEDMEM_Swig.typemap
+SWIG_DEF = ParaMEDMEM.i ParaMEDMEM.typemap
SWIG_FLAGS = @SWIG_FLAGS@ -I$(srcdir) $(MPI_INCLUDES) -I$(srcdir)/../ParaMEDMEM -I$(srcdir)/../MEDCoupling -I$(srcdir)/../MEDCoupling_Swig \
-I$(srcdir)/../MEDLoader/Swig -I$(srcdir)/../INTERP_KERNEL -I$(srcdir)/../INTERP_KERNEL/Bases -I$(srcdir)/../ParaMEDLoader \
-I$(srcdir)/../MEDLoader
-dist__libParaMEDMEM_Swig_la_SOURCES = $(SWIG_DEF)
-nodist__libParaMEDMEM_Swig_la_SOURCES = libParaMEDMEM_Swig_wrap.cxx
-libParaMEDMEM_Swig.py: libParaMEDMEM_Swig_wrap.cxx
+dist__ParaMEDMEM_la_SOURCES = $(SWIG_DEF)
+nodist__ParaMEDMEM_la_SOURCES = ParaMEDMEM_wrap.cxx
+ParaMEDMEM.py : ParaMEDMEM_wrap.cxx
-libParaMEDMEM_Swig_wrap.cxx: $(SWIG_DEF)
+ParaMEDMEM_wrap.cxx: $(SWIG_DEF)
$(SWIG) $(SWIG_FLAGS) -o $@ $<
-_libParaMEDMEM_Swig_la_CPPFLAGS = $(PYTHON_INCLUDES) \
+_ParaMEDMEM_la_CPPFLAGS = $(PYTHON_INCLUDES) \
$(MED2_INCLUDES) $(HDF5_INCLUDES) @CXXTMPDPTHFLAGS@ \
-I$(srcdir)/../INTERP_KERNEL \
$(MPI_INCLUDES) -I$(srcdir)/../ParaMEDMEM -I$(srcdir)/../MEDCoupling_Swig -I$(srcdir)/../INTERP_KERNEL/Bases \
-I$(srcdir)/../MEDCoupling -I$(srcdir)/../ParaMEDLoader -I$(srcdir)/../MEDLoader -I$(srcdir)/../MEDLoader/Swig
-_libParaMEDMEM_Swig_la_LDFLAGS = -module $(MED2_LIBS) $(HDF5_LIBS) $(PYTHON_LIBS) $(MPI_LIBS) \
+_ParaMEDMEM_la_LDFLAGS = -module $(MED2_LIBS) $(HDF5_LIBS) $(PYTHON_LIBS) $(MPI_LIBS) \
../MEDCoupling/libmedcoupling.la ../INTERP_KERNEL/libinterpkernel.la \
../ParaMEDMEM/libparamedmem.la ../ParaMEDLoader/libparamedloader.la
if MED_ENABLE_KERNEL
- _libParaMEDMEM_Swig_la_CPPFLAGS += ${KERNEL_CXXFLAGS}
- _libParaMEDMEM_Swig_la_LDFLAGS += ${KERNEL_LDFLAGS} -lSALOMELocalTrace
+ _ParaMEDMEM_la_CPPFLAGS += ${KERNEL_CXXFLAGS}
+ _ParaMEDMEM_la_LDFLAGS += ${KERNEL_LDFLAGS} -lSALOMELocalTrace
endif
-CLEANFILES = libParaMEDMEM_Swig_wrap.cxx libParaMEDMEM_Swig.py
+CLEANFILES = ParaMEDMEM_wrap.cxx ParaMEDMEM.py
dist_salomescript_DATA= test_InterpKernelDEC.py \
test_NonCoincidentDEC.py \
- test_StructuredCoincodentDEC.py \
- ParaMEDMEM.py libParaMEDMEM_Swig.py
+ test_StructuredCoincidentDEC.py \
+ ParaMEDMEM.py
--- /dev/null
+// Copyright (C) 2007-2010 CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+%module ParaMEDMEM
+
+%include "ParaMEDMEM.typemap"
+%include "MEDCoupling.i"
+%include "MEDLoader.i"
+
+%{
+#include "CommInterface.hxx"
+#include "ProcessorGroup.hxx"
+#include "Topology.hxx"
+#include "MPIProcessorGroup.hxx"
+#include "DEC.hxx"
+#include "InterpKernelDEC.hxx"
+#include "NonCoincidentDEC.hxx"
+#include "StructuredCoincidentDEC.hxx"
+#include "ParaMESH.hxx"
+#include "ParaFIELD.hxx"
+#include "ICoCoMEDField.hxx"
+#include "ComponentTopology.hxx"
+
+#include <mpi.h>
+
+using namespace ParaMEDMEM;
+using namespace ICoCo;
+
+enum mpi_constants { mpi_comm_world, mpi_comm_self, mpi_double, mpi_int };
+%}
+
+%include "CommInterface.hxx"
+%include "ProcessorGroup.hxx"
+%include "DECOptions.hxx"
+%include "ParaMESH.hxx"
+%include "ParaFIELD.hxx"
+%include "MPIProcessorGroup.hxx"
+%include "ComponentTopology.hxx"
+%include "DEC.hxx"
+%include "InterpKernelDEC.hxx"
+%include "StructuredCoincidentDEC.hxx"
+
+%rename(ICoCoMEDField) ICoCo::MEDField;
+%include "ICoCoMEDField.hxx"
+
+%nodefaultctor;
+
+/* This object can be used only if MED_ENABLE_FVM is defined*/
+#ifdef MED_ENABLE_FVM
+class NonCoincidentDEC : public DEC
+{
+public:
+ NonCoincidentDEC(ProcessorGroup& source, ProcessorGroup& target);
+};
+#endif
+
+%extend ParaMEDMEM::ParaMESH
+{
+ PyObject *getGlobalNumberingCell2() const
+ {
+ const int *tmp=self->getGlobalNumberingCell();
+ int size=self->getCellMesh()->getNumberOfCells();
+ PyObject *ret=PyList_New(size);
+ for(int i=0;i<size;i++)
+ PyList_SetItem(ret,i,PyInt_FromLong(tmp[i]));
+ return ret;
+ }
+
+ PyObject *getGlobalNumberingFace2() const
+ {
+ const int *tmp=self->getGlobalNumberingFace();
+ int size=self->getFaceMesh()->getNumberOfCells();
+ PyObject *ret=PyList_New(size);
+ for(int i=0;i<size;i++)
+ PyList_SetItem(ret,i,PyInt_FromLong(tmp[i]));
+ return ret;
+ }
+
+ PyObject *getGlobalNumberingNode2() const
+ {
+ const int *tmp=self->getGlobalNumberingNode();
+ int size=self->getCellMesh()->getNumberOfNodes();
+ PyObject *ret=PyList_New(size);
+ for(int i=0;i<size;i++)
+ PyList_SetItem(ret,i,PyInt_FromLong(tmp[i]));
+ return ret;
+ }
+}
+
+//=============================================================================================
+// Interface for MPI-realization-specific constants like MPI_COMM_WORLD.
+//
+// Type and values of constants like MPI_COMM_WORLD depends on MPI realization
+// and usually such constants actually are macros. To have such symbols in python
+// and translate them into correct values we use the following technique.
+// We define some constants (enum mpi_constants) and map them into real MPI values
+// using typemaps, and we create needed python symbols equal to 'mpi_constants'
+// via %pythoncode directive.
+
+// Constants corresponding to similar MPI definitions
+enum mpi_constants { mpi_comm_world, mpi_comm_self, mpi_double, mpi_int };
+
+// Map mpi_comm_world and mpi_comm_self -> MPI_COMM_WORLD and MPI_COMM_SELF
+%typemap(in) MPI_Comm
+{
+ switch (PyInt_AsLong($input))
+ {
+ case mpi_comm_world: $1 = MPI_COMM_WORLD; break;
+ case mpi_comm_self: $1 = MPI_COMM_SELF; break;
+ default:
+ PyErr_SetString(PyExc_TypeError,"unexpected value of MPI_Comm");
+ return NULL;
+ }
+}
+// Map mpi_double and mpi_int -> MPI_DOUBLE and MPI_INT
+%typemap(in) MPI_Datatype
+{
+ switch (PyInt_AsLong($input))
+ {
+ case mpi_double: $1 = MPI_DOUBLE; break;
+ case mpi_int: $1 = MPI_INT; break;
+ default:
+ PyErr_SetString(PyExc_TypeError,"unexpected value of MPI_Datatype");
+ return NULL;
+ }
+}
+// The following code gets inserted into the result python file:
+// create needed python symbols
+%pythoncode %{
+MPI_COMM_WORLD = mpi_comm_world
+MPI_COMM_SELF = mpi_comm_self
+MPI_DOUBLE = mpi_double
+MPI_INT = mpi_int
+%}
+//=============================================================================================
+
+// ==============
+// MPI_Comm_size
+// ==============
+%inline %{ PyObject* MPI_Comm_size(MPI_Comm comm)
+ {
+ int res = 0;
+ int err = MPI_Comm_size(comm, &res);
+ if ( err != MPI_SUCCESS )
+ {
+ PyErr_SetString(PyExc_RuntimeError,"Erorr in MPI_Comm_size()");
+ return NULL;
+ }
+ return PyInt_FromLong( res );
+ } %}
+
+// ==============
+// MPI_Comm_rank
+// ==============
+%inline %{ PyObject* MPI_Comm_rank(MPI_Comm comm)
+ {
+ int res = 0;
+ int err = MPI_Comm_rank(comm, &res);
+ if ( err != MPI_SUCCESS )
+ {
+ PyErr_SetString(PyExc_RuntimeError,"Erorr in MPI_Comm_rank()");
+ return NULL;
+ }
+ return PyInt_FromLong( res );
+ }
+ %}
+
+int MPI_Init(int *argc, char ***argv );
+int MPI_Barrier(MPI_Comm comm);
+int MPI_Finalize();
+
+// ==========
+// MPI_Bcast
+// ==========
+
+%inline %{ PyObject* MPI_Bcast(PyObject* buffer, int nb, MPI_Datatype type, int root, MPI_Comm c)
+ {
+ // buffer must be a list
+ if (!PyList_Check(buffer))
+ {
+ PyErr_SetString(PyExc_TypeError, "buffer is expected to be a list");
+ return NULL;
+ }
+ // check list size
+ int aSize = PyList_Size(buffer);
+ if ( aSize != nb )
+ {
+ std::ostringstream stream; stream << "buffer is expected to be of size " << nb;
+ PyErr_SetString(PyExc_ValueError, stream.str().c_str());
+ return NULL;
+ }
+ // allocate and fill a buffer
+ void* aBuf = 0;
+ int* intBuf = 0;
+ double* dblBuf = 0;
+ if ( type == MPI_DOUBLE )
+ {
+ aBuf = (void*) ( dblBuf = new double[ nb ] );
+ for ( int i = 0; i < aSize; ++i )
+ dblBuf[i] = PyFloat_AS_DOUBLE( PyList_GetItem( buffer, i ));
+ }
+ else if ( type == MPI_INT )
+ {
+ aBuf = (void*) ( intBuf = new int[ nb ] );
+ for ( int i = 0; i < aSize; ++i )
+ intBuf[i] = int( PyInt_AS_LONG( PyList_GetItem( buffer, i )));
+ }
+ else
+ {
+ PyErr_SetString(PyExc_TypeError, "Only MPI_DOUBLE and MPI_INT supported");
+ return NULL;
+ }
+ // call MPI_Bcast
+ int err = MPI_Bcast(aBuf, nb, type, root, c);
+ // treat error
+ if ( err != MPI_SUCCESS )
+ {
+ PyErr_SetString(PyExc_RuntimeError,"Erorr in MPI_Bcast()");
+ delete [] intBuf; delete [] dblBuf;
+ return NULL;
+ }
+ // put recieved data into the list
+ int pyerr = 0;
+ if ( type == MPI_DOUBLE )
+ {
+ for ( int i = 0; i < aSize && !pyerr; ++i )
+ pyerr = PyList_SetItem(buffer, i, PyFloat_FromDouble( dblBuf[i] ));
+ delete [] dblBuf;
+ }
+ else
+ {
+ for ( int i = 0; i < aSize && !pyerr; ++i )
+ pyerr = PyList_SetItem(buffer, i, PyInt_FromLong( intBuf[i] ));
+ delete [] intBuf;
+ }
+ if ( pyerr )
+ {
+ PyErr_SetString(PyExc_RuntimeError, "Error of PyList_SetItem()");
+ return NULL;
+ }
+ return PyInt_FromLong( err );
+
+ }
+ %}
+
+++ /dev/null
-# -*- coding: iso-8859-1 -*-
-# Copyright (C) 2007-2010 CEA/DEN, EDF R&D
-#
-# This library is free software; you can redistribute it and/or
-# modify it under the terms of the GNU Lesser General Public
-# License as published by the Free Software Foundation; either
-# version 2.1 of the License.
-#
-# This library is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-# Lesser General Public License for more details.
-#
-# You should have received a copy of the GNU Lesser General Public
-# License along with this library; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-#
-# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-#
-
-from libParaMEDMEM_Swig import *
--- /dev/null
+// Copyright (C) 2007-2010 CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+%include std_set.i
+%include std_string.i
+
+%template() std::set<int>;
+
+// Creates "int *argc, char ***argv" parameters from input list
+%typemap(in) (int *argc, char ***argv) {
+ int i;
+ if (!PyList_Check($input)) {
+ PyErr_SetString(PyExc_ValueError, "Expecting a list");
+ return NULL;
+ }
+ int aSize = PyList_Size($input);
+ $1 = &aSize;
+ char** aStrs = (char **) malloc((aSize+1)*sizeof(char *));
+ for (i = 0; i < aSize; i++) {
+ PyObject *s = PyList_GetItem($input,i);
+ if (!PyString_Check(s)) {
+ free(aStrs);
+ PyErr_SetString(PyExc_ValueError, "List items must be strings");
+ return NULL;
+ }
+ aStrs[i] = PyString_AsString(s);
+ }
+ aStrs[i] = 0;
+ $2 = &aStrs;
+}
+
+%typemap(freearg) (int *argc, char ***argv) {
+ if ($2) free(*($2));
+}
+
+/* MACRO: IN typemap for std::set<TYPE> C++ object */
+%define TYPEMAP_INPUT_SET_BY_VALUE( TYPE )
+{
+ /* typemap in for set<TYPE> */
+ /* Check if is a list */
+ if (PyList_Check($input))
+ {
+ int size = PyList_Size($input);
+ std::set< TYPE > tmpSet;
+
+ for (int i=0; i < size; i++)
+ {
+ PyObject * tmp = PyList_GetItem($input,i);
+ TYPE elem = PyInt_AsLong(tmp);
+ tmpSet.insert(elem);
+ }
+ $1 = tmpSet;
+ }
+ else
+ {
+ PyErr_SetString(PyExc_TypeError,"not a list");
+ return NULL;
+ }
+}
+%enddef
+
+%typemap(in) std::set<int>
+{
+ TYPEMAP_INPUT_SET_BY_VALUE( int )
+}
+%typecheck(SWIG_TYPECHECK_POINTER) std::set<int> {
+ $1 = PyList_Check($input) ? 1 : 0;
+}
+++ /dev/null
-// Copyright (C) 2007-2010 CEA/DEN, EDF R&D
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-
-%module libParaMEDMEM_Swig
-
-%include "libParaMEDMEM_Swig.typemap"
-%include "libMEDCoupling_Swig.i"
-%include "libMEDLoader_Swig.i"
-
-%{
-#include "CommInterface.hxx"
-#include "ProcessorGroup.hxx"
-#include "Topology.hxx"
-#include "MPIProcessorGroup.hxx"
-#include "DEC.hxx"
-#include "InterpKernelDEC.hxx"
-#include "NonCoincidentDEC.hxx"
-#include "StructuredCoincidentDEC.hxx"
-#include "ParaMESH.hxx"
-#include "ParaFIELD.hxx"
-#include "ICoCoMEDField.hxx"
-#include "ComponentTopology.hxx"
-
-#include <mpi.h>
-
-using namespace ParaMEDMEM;
-using namespace ICoCo;
-
-enum mpi_constants { mpi_comm_world, mpi_comm_self, mpi_double, mpi_int };
-%}
-
-%include "CommInterface.hxx"
-%include "ProcessorGroup.hxx"
-%include "DECOptions.hxx"
-%include "ParaMESH.hxx"
-%include "ParaFIELD.hxx"
-%include "MPIProcessorGroup.hxx"
-%include "ComponentTopology.hxx"
-%include "DEC.hxx"
-%include "InterpKernelDEC.hxx"
-%include "StructuredCoincidentDEC.hxx"
-
-%rename(ICoCoMEDField) ICoCo::MEDField;
-%include "ICoCoMEDField.hxx"
-
-%nodefaultctor;
-
-/* This object can be used only if MED_ENABLE_FVM is defined*/
-#ifdef MED_ENABLE_FVM
-class NonCoincidentDEC : public DEC
-{
-public:
- NonCoincidentDEC(ProcessorGroup& source, ProcessorGroup& target);
-};
-#endif
-
-%extend ParaMEDMEM::ParaMESH
-{
- PyObject *getGlobalNumberingCell2() const
- {
- const int *tmp=self->getGlobalNumberingCell();
- int size=self->getCellMesh()->getNumberOfCells();
- PyObject *ret=PyList_New(size);
- for(int i=0;i<size;i++)
- PyList_SetItem(ret,i,PyInt_FromLong(tmp[i]));
- return ret;
- }
-
- PyObject *getGlobalNumberingFace2() const
- {
- const int *tmp=self->getGlobalNumberingFace();
- int size=self->getFaceMesh()->getNumberOfCells();
- PyObject *ret=PyList_New(size);
- for(int i=0;i<size;i++)
- PyList_SetItem(ret,i,PyInt_FromLong(tmp[i]));
- return ret;
- }
-
- PyObject *getGlobalNumberingNode2() const
- {
- const int *tmp=self->getGlobalNumberingNode();
- int size=self->getCellMesh()->getNumberOfNodes();
- PyObject *ret=PyList_New(size);
- for(int i=0;i<size;i++)
- PyList_SetItem(ret,i,PyInt_FromLong(tmp[i]));
- return ret;
- }
-}
-
-//=============================================================================================
-// Interface for MPI-realization-specific constants like MPI_COMM_WORLD.
-//
-// Type and values of constants like MPI_COMM_WORLD depends on MPI realization
-// and usually such constants actually are macros. To have such symbols in python
-// and translate them into correct values we use the following technique.
-// We define some constants (enum mpi_constants) and map them into real MPI values
-// using typemaps, and we create needed python symbols equal to 'mpi_constants'
-// via %pythoncode directive.
-
-// Constants corresponding to similar MPI definitions
-enum mpi_constants { mpi_comm_world, mpi_comm_self, mpi_double, mpi_int };
-
-// Map mpi_comm_world and mpi_comm_self -> MPI_COMM_WORLD and MPI_COMM_SELF
-%typemap(in) MPI_Comm
-{
- switch (PyInt_AsLong($input))
- {
- case mpi_comm_world: $1 = MPI_COMM_WORLD; break;
- case mpi_comm_self: $1 = MPI_COMM_SELF; break;
- default:
- PyErr_SetString(PyExc_TypeError,"unexpected value of MPI_Comm");
- return NULL;
- }
-}
-// Map mpi_double and mpi_int -> MPI_DOUBLE and MPI_INT
-%typemap(in) MPI_Datatype
-{
- switch (PyInt_AsLong($input))
- {
- case mpi_double: $1 = MPI_DOUBLE; break;
- case mpi_int: $1 = MPI_INT; break;
- default:
- PyErr_SetString(PyExc_TypeError,"unexpected value of MPI_Datatype");
- return NULL;
- }
-}
-// The following code gets inserted into the result python file:
-// create needed python symbols
-%pythoncode %{
-MPI_COMM_WORLD = mpi_comm_world
-MPI_COMM_SELF = mpi_comm_self
-MPI_DOUBLE = mpi_double
-MPI_INT = mpi_int
-%}
-//=============================================================================================
-
-// ==============
-// MPI_Comm_size
-// ==============
-%inline %{ PyObject* MPI_Comm_size(MPI_Comm comm)
- {
- int res = 0;
- int err = MPI_Comm_size(comm, &res);
- if ( err != MPI_SUCCESS )
- {
- PyErr_SetString(PyExc_RuntimeError,"Erorr in MPI_Comm_size()");
- return NULL;
- }
- return PyInt_FromLong( res );
- } %}
-
-// ==============
-// MPI_Comm_rank
-// ==============
-%inline %{ PyObject* MPI_Comm_rank(MPI_Comm comm)
- {
- int res = 0;
- int err = MPI_Comm_rank(comm, &res);
- if ( err != MPI_SUCCESS )
- {
- PyErr_SetString(PyExc_RuntimeError,"Erorr in MPI_Comm_rank()");
- return NULL;
- }
- return PyInt_FromLong( res );
- }
- %}
-
-int MPI_Init(int *argc, char ***argv );
-int MPI_Barrier(MPI_Comm comm);
-int MPI_Finalize();
-
-// ==========
-// MPI_Bcast
-// ==========
-
-%inline %{ PyObject* MPI_Bcast(PyObject* buffer, int nb, MPI_Datatype type, int root, MPI_Comm c)
- {
- // buffer must be a list
- if (!PyList_Check(buffer))
- {
- PyErr_SetString(PyExc_TypeError, "buffer is expected to be a list");
- return NULL;
- }
- // check list size
- int aSize = PyList_Size(buffer);
- if ( aSize != nb )
- {
- std::ostringstream stream; stream << "buffer is expected to be of size " << nb;
- PyErr_SetString(PyExc_ValueError, stream.str().c_str());
- return NULL;
- }
- // allocate and fill a buffer
- void* aBuf = 0;
- int* intBuf = 0;
- double* dblBuf = 0;
- if ( type == MPI_DOUBLE )
- {
- aBuf = (void*) ( dblBuf = new double[ nb ] );
- for ( int i = 0; i < aSize; ++i )
- dblBuf[i] = PyFloat_AS_DOUBLE( PyList_GetItem( buffer, i ));
- }
- else if ( type == MPI_INT )
- {
- aBuf = (void*) ( intBuf = new int[ nb ] );
- for ( int i = 0; i < aSize; ++i )
- intBuf[i] = int( PyInt_AS_LONG( PyList_GetItem( buffer, i )));
- }
- else
- {
- PyErr_SetString(PyExc_TypeError, "Only MPI_DOUBLE and MPI_INT supported");
- return NULL;
- }
- // call MPI_Bcast
- int err = MPI_Bcast(aBuf, nb, type, root, c);
- // treat error
- if ( err != MPI_SUCCESS )
- {
- PyErr_SetString(PyExc_RuntimeError,"Erorr in MPI_Bcast()");
- delete [] intBuf; delete [] dblBuf;
- return NULL;
- }
- // put recieved data into the list
- int pyerr = 0;
- if ( type == MPI_DOUBLE )
- {
- for ( int i = 0; i < aSize && !pyerr; ++i )
- pyerr = PyList_SetItem(buffer, i, PyFloat_FromDouble( dblBuf[i] ));
- delete [] dblBuf;
- }
- else
- {
- for ( int i = 0; i < aSize && !pyerr; ++i )
- pyerr = PyList_SetItem(buffer, i, PyInt_FromLong( intBuf[i] ));
- delete [] intBuf;
- }
- if ( pyerr )
- {
- PyErr_SetString(PyExc_RuntimeError, "Error of PyList_SetItem()");
- return NULL;
- }
- return PyInt_FromLong( err );
-
- }
- %}
-
+++ /dev/null
-// Copyright (C) 2007-2010 CEA/DEN, EDF R&D
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-
-%include std_set.i
-%include std_string.i
-
-%template() std::set<int>;
-
-// Creates "int *argc, char ***argv" parameters from input list
-%typemap(in) (int *argc, char ***argv) {
- int i;
- if (!PyList_Check($input)) {
- PyErr_SetString(PyExc_ValueError, "Expecting a list");
- return NULL;
- }
- int aSize = PyList_Size($input);
- $1 = &aSize;
- char** aStrs = (char **) malloc((aSize+1)*sizeof(char *));
- for (i = 0; i < aSize; i++) {
- PyObject *s = PyList_GetItem($input,i);
- if (!PyString_Check(s)) {
- free(aStrs);
- PyErr_SetString(PyExc_ValueError, "List items must be strings");
- return NULL;
- }
- aStrs[i] = PyString_AsString(s);
- }
- aStrs[i] = 0;
- $2 = &aStrs;
-}
-
-%typemap(freearg) (int *argc, char ***argv) {
- if ($2) free(*($2));
-}
-
-/* MACRO: IN typemap for std::set<TYPE> C++ object */
-%define TYPEMAP_INPUT_SET_BY_VALUE( TYPE )
-{
- /* typemap in for set<TYPE> */
- /* Check if is a list */
- if (PyList_Check($input))
- {
- int size = PyList_Size($input);
- std::set< TYPE > tmpSet;
-
- for (int i=0; i < size; i++)
- {
- PyObject * tmp = PyList_GetItem($input,i);
- TYPE elem = PyInt_AsLong(tmp);
- tmpSet.insert(elem);
- }
- $1 = tmpSet;
- }
- else
- {
- PyErr_SetString(PyExc_TypeError,"not a list");
- return NULL;
- }
-}
-%enddef
-
-%typemap(in) std::set<int>
-{
- TYPEMAP_INPUT_SET_BY_VALUE( int )
-}
-%typecheck(SWIG_TYPECHECK_POINTER) std::set<int> {
- $1 = PyList_Check($input) ? 1 : 0;
-}
# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
#
-from libParaMEDMEM_Swig import *
+from ParaMEDMEM import *
import sys, os
import unittest
import math
--- /dev/null
+#!/usr/bin/env python
+# -*- coding: iso-8859-1 -*-
+# Copyright (C) 2007-2010 CEA/DEN, EDF R&D
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+#
+
+from ParaMEDMEM import *
+import sys, os
+import unittest
+import math
+
+class ParaMEDMEMBasicsTest2(unittest.TestCase):
+ def testStructuredCoincidentDEC(self):
+ MPI_Init(sys.argv)
+ #
+ size = MPI_Comm_size(MPI_COMM_WORLD)
+ rank = MPI_Comm_rank(MPI_COMM_WORLD)
+ #
+ if size < 4:
+ raise RuntimeError, "Expect MPI_COMM_WORLD size >= 4"
+ #
+ interface = CommInterface()
+ #
+ self_group = MPIProcessorGroup(interface, rank, rank)
+ target_group = MPIProcessorGroup(interface, 3, size-1)
+ source_group = MPIProcessorGroup(interface, 0, 2)
+ #
+ mesh = 0
+ support = 0
+ paramesh = 0
+ parafield = 0
+ comptopo = 0
+ icocofield= 0
+ #
+ data_dir = os.environ['MED_ROOT_DIR']
+ tmp_dir = os.environ['TMP']
+ if tmp_dir == '':
+ tmp_dir = "/tmp"
+ pass
+
+ filename_xml1 = data_dir + "/share/salome/resources/med/square1_split"
+ filename_2 = data_dir + "/share/salome/resources/med/square1.med"
+ filename_seq_wr = tmp_dir + "/"
+ filename_seq_med = tmp_dir + "/myWrField_seq_pointe221.med"
+
+ dec = StructuredCoincidentDEC(source_group, target_group)
+ MPI_Barrier(MPI_COMM_WORLD)
+ if source_group.containsMyRank():
+ filename = filename_xml1 + str(rank+1) + ".med"
+ meshname = "Mesh_2_" + str(rank+1)
+ mesh=MEDLoader.ReadUMeshFromFile(filename,meshname,0)
+ paramesh=ParaMESH(mesh,source_group,"source mesh")
+ comptopo=ComponentTopology(6)
+ parafield=ParaFIELD(ON_CELLS,NO_TIME,paramesh,comptopo)
+ parafield.getField().setNature(ConservativeVolumic)
+ nb_local=mesh.getNumberOfCells()
+ global_numbering=paramesh.getGlobalNumberingCell2()
+ value = []
+ for ielem in range(nb_local):
+ for icomp in range(6):
+ value.append(global_numbering[ielem]*6.0+icomp);
+ pass
+ pass
+ parafield.getField().setValues(value)
+ icocofield = ICoCoMEDField(mesh,parafield.getField())
+ dec.setMethod("P0")
+ dec.attachLocalField(parafield)
+ dec.synchronize()
+ dec.sendData()
+ pass
+
+ if target_group.containsMyRank():
+ meshname2 = "Mesh_2"
+ mesh=MEDLoader.ReadUMeshFromFile(filename_2, meshname2,0)
+ paramesh=ParaMESH(mesh, self_group, "target mesh")
+ comptopo=ComponentTopology(6,target_group)
+ parafield=ParaFIELD(ON_CELLS,NO_TIME,paramesh, comptopo)
+ parafield.getField().setNature(ConservativeVolumic)
+ nb_local=mesh.getNumberOfCells()
+ value = [0.0]*(nb_local*comptopo.nbLocalComponents())
+ parafield.getField().setValues(value)
+ icocofield = ICoCoMEDField(mesh,parafield.getField())
+ dec.setMethod("P0")
+ dec.attachLocalField(parafield)
+ dec.synchronize()
+ dec.recvData()
+ recv_value = parafield.getField().getArray().getValues()
+ for i in range(nb_local):
+ first=comptopo.firstLocalComponent()
+ for icomp in range(comptopo.nbLocalComponents()):
+ self.failUnless(math.fabs(recv_value[i*comptopo.nbLocalComponents()+icomp]-
+ (float)(i*6+icomp+first))<1e-12)
+ pass
+ pass
+ pass
+ comptopo=0
+ interface = 0
+ mesh =0
+ support =0
+ paramesh =0
+ parafield =0
+ icocofield =0
+ dec=0
+ self_group =0
+ target_group = 0
+ source_group = 0
+ MPI_Barrier(MPI_COMM_WORLD)
+ MPI_Finalize()
+ print "End of test StructuredCoincidentDEC"
+ pass
+
+
+unittest.main()
+++ /dev/null
-#!/usr/bin/env python
-# -*- coding: iso-8859-1 -*-
-# Copyright (C) 2007-2010 CEA/DEN, EDF R&D
-#
-# This library is free software; you can redistribute it and/or
-# modify it under the terms of the GNU Lesser General Public
-# License as published by the Free Software Foundation; either
-# version 2.1 of the License.
-#
-# This library is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-# Lesser General Public License for more details.
-#
-# You should have received a copy of the GNU Lesser General Public
-# License along with this library; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-#
-# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-#
-
-from libParaMEDMEM_Swig import *
-import sys, os
-import unittest
-import math
-
-class ParaMEDMEMBasicsTest2(unittest.TestCase):
- def testStructuredCoincidentDEC(self):
- MPI_Init(sys.argv)
- #
- size = MPI_Comm_size(MPI_COMM_WORLD)
- rank = MPI_Comm_rank(MPI_COMM_WORLD)
- #
- if size < 4:
- raise RuntimeError, "Expect MPI_COMM_WORLD size >= 4"
- #
- interface = CommInterface()
- #
- self_group = MPIProcessorGroup(interface, rank, rank)
- target_group = MPIProcessorGroup(interface, 3, size-1)
- source_group = MPIProcessorGroup(interface, 0, 2)
- #
- mesh = 0
- support = 0
- paramesh = 0
- parafield = 0
- comptopo = 0
- icocofield= 0
- #
- data_dir = os.environ['MED_ROOT_DIR']
- tmp_dir = os.environ['TMP']
- if tmp_dir == '':
- tmp_dir = "/tmp"
- pass
-
- filename_xml1 = data_dir + "/share/salome/resources/med/square1_split"
- filename_2 = data_dir + "/share/salome/resources/med/square1.med"
- filename_seq_wr = tmp_dir + "/"
- filename_seq_med = tmp_dir + "/myWrField_seq_pointe221.med"
-
- dec = StructuredCoincidentDEC(source_group, target_group)
- MPI_Barrier(MPI_COMM_WORLD)
- if source_group.containsMyRank():
- filename = filename_xml1 + str(rank+1) + ".med"
- meshname = "Mesh_2_" + str(rank+1)
- mesh=MEDLoader.ReadUMeshFromFile(filename,meshname,0)
- paramesh=ParaMESH(mesh,source_group,"source mesh")
- comptopo=ComponentTopology(6)
- parafield=ParaFIELD(ON_CELLS,NO_TIME,paramesh,comptopo)
- parafield.getField().setNature(ConservativeVolumic)
- nb_local=mesh.getNumberOfCells()
- global_numbering=paramesh.getGlobalNumberingCell2()
- value = []
- for ielem in range(nb_local):
- for icomp in range(6):
- value.append(global_numbering[ielem]*6.0+icomp);
- pass
- pass
- parafield.getField().setValues(value)
- icocofield = ICoCoMEDField(mesh,parafield.getField())
- dec.setMethod("P0")
- dec.attachLocalField(parafield)
- dec.synchronize()
- dec.sendData()
- pass
-
- if target_group.containsMyRank():
- meshname2 = "Mesh_2"
- mesh=MEDLoader.ReadUMeshFromFile(filename_2, meshname2,0)
- paramesh=ParaMESH(mesh, self_group, "target mesh")
- comptopo=ComponentTopology(6,target_group)
- parafield=ParaFIELD(ON_CELLS,NO_TIME,paramesh, comptopo)
- parafield.getField().setNature(ConservativeVolumic)
- nb_local=mesh.getNumberOfCells()
- value = [0.0]*(nb_local*comptopo.nbLocalComponents())
- parafield.getField().setValues(value)
- icocofield = ICoCoMEDField(mesh,parafield.getField())
- dec.setMethod("P0")
- dec.attachLocalField(parafield)
- dec.synchronize()
- dec.recvData()
- recv_value = parafield.getField().getArray().getValues()
- for i in range(nb_local):
- first=comptopo.firstLocalComponent()
- for icomp in range(comptopo.nbLocalComponents()):
- self.failUnless(math.fabs(recv_value[i*comptopo.nbLocalComponents()+icomp]-
- (float)(i*6+icomp+first))<1e-12)
- pass
- pass
- pass
- comptopo=0
- interface = 0
- mesh =0
- support =0
- paramesh =0
- parafield =0
- icocofield =0
- dec=0
- self_group =0
- target_group = 0
- source_group = 0
- MPI_Barrier(MPI_COMM_WORLD)
- MPI_Finalize()
- print "End of test StructuredCoincidentDEC"
- pass
-
-
-unittest.main()