--- /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 "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::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::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::DataArrayInt::New;
+%newobject ParaMEDMEM::DataArrayInt::convertToDblArr;
+%newobject ParaMEDMEM::DataArrayInt::deepCopy;
+%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::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::meld;
+%newobject ParaMEDMEM::DataArrayInt::fromNoInterlace;
+%newobject ParaMEDMEM::DataArrayInt::toNoInterlace;
+%newobject ParaMEDMEM::DataArrayDouble::New;
+%newobject ParaMEDMEM::DataArrayDouble::convertToIntArr;
+%newobject ParaMEDMEM::DataArrayDouble::deepCopy;
+%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::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::MEDCouplingMesh::buildUnstructured;
+%newobject ParaMEDMEM::MEDCouplingPointSet::zipCoordsTraducer;
+%newobject ParaMEDMEM::MEDCouplingPointSet::buildBoundaryMesh;
+%newobject ParaMEDMEM::MEDCouplingPointSet::mergeNodesArray;
+%newobject ParaMEDMEM::MEDCouplingPointSet::buildInstanceFromMeshType;
+%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;
+%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 MEDCouplingUMesh;
+ 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 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;
+ 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) throw(INTERP_KERNEL::Exception);
+ 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;
+ }
+ void renumberNodes2(PyObject *li, int newNbOfNodes)
+ {
+ int size;
+ int *tmp=convertPyToNewIntArr2(li,&size);
+ self->renumberNodes2(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);
+ static MEDCouplingUMesh *mergeUMeshes(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)
+ {
+ 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 *mergeNodes2(double precision)
+ {
+ 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()
+ {
+ 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);
+ }
+
+ static MEDCouplingUMesh *mergeUMeshes(PyObject *li) throw(INTERP_KERNEL::Exception)
+ {
+ std::vector<const ParaMEDMEM::MEDCouplingUMesh *> tmp;
+ convertPyObjToVecUMeshesCst(li,tmp);
+ return MEDCouplingUMesh::mergeUMeshes(tmp);
+ }
+ }
+ void convertToPolyTypes(const std::vector<int>& cellIdsToConvert);
+ void unPolyze();
+ MEDCouplingUMesh *buildExtrudedMeshFromThis(const MEDCouplingUMesh *mesh1D, int policy);
+ };
+
+ 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);
+ %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);
+ }
+
+ 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);
+ }
+ };
+
+%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);
+ }
+
+ static DataArrayInt *meld(PyObject *li) throw(INTERP_KERNEL::Exception)
+ {
+ std::vector<const DataArrayInt *> tmp;
+ convertPyObjToVecDataArrayIntCst(li,tmp);
+ return DataArrayInt::meld(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 *deepCpy() 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 mergeNodes2(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 *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);
+ 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();
+ }
+ 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);
+ }
+
+ static MEDCouplingFieldDouble *mergeFields(PyObject *li) throw(INTERP_KERNEL::Exception)
+ {
+ std::vector<const MEDCouplingFieldDouble *> tmp;
+ convertPyObjToVecFieldDblCst(li,tmp);
+ return MEDCouplingFieldDouble::mergeFields(tmp);
+ }
+ }
+ };
+}
# 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
# 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):
--- /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
#
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
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::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::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::DataArrayInt::New;
-%newobject ParaMEDMEM::DataArrayInt::convertToDblArr;
-%newobject ParaMEDMEM::DataArrayInt::deepCopy;
-%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::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::meld;
-%newobject ParaMEDMEM::DataArrayInt::fromNoInterlace;
-%newobject ParaMEDMEM::DataArrayInt::toNoInterlace;
-%newobject ParaMEDMEM::DataArrayDouble::New;
-%newobject ParaMEDMEM::DataArrayDouble::convertToIntArr;
-%newobject ParaMEDMEM::DataArrayDouble::deepCopy;
-%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::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::MEDCouplingMesh::buildUnstructured;
-%newobject ParaMEDMEM::MEDCouplingPointSet::zipCoordsTraducer;
-%newobject ParaMEDMEM::MEDCouplingPointSet::buildBoundaryMesh;
-%newobject ParaMEDMEM::MEDCouplingPointSet::mergeNodesArray;
-%newobject ParaMEDMEM::MEDCouplingPointSet::buildInstanceFromMeshType;
-%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;
-%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 MEDCouplingUMesh;
- 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 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;
- 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) throw(INTERP_KERNEL::Exception);
- 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;
- }
- void renumberNodes2(PyObject *li, int newNbOfNodes)
- {
- int size;
- int *tmp=convertPyToNewIntArr2(li,&size);
- self->renumberNodes2(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);
- static MEDCouplingUMesh *mergeUMeshes(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)
- {
- 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 *mergeNodes2(double precision)
- {
- 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()
- {
- 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);
- }
-
- static MEDCouplingUMesh *mergeUMeshes(PyObject *li) throw(INTERP_KERNEL::Exception)
- {
- std::vector<const ParaMEDMEM::MEDCouplingUMesh *> tmp;
- convertPyObjToVecUMeshesCst(li,tmp);
- return MEDCouplingUMesh::mergeUMeshes(tmp);
- }
- }
- void convertToPolyTypes(const std::vector<int>& cellIdsToConvert);
- void unPolyze();
- MEDCouplingUMesh *buildExtrudedMeshFromThis(const MEDCouplingUMesh *mesh1D, int policy);
- };
-
- 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);
- %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);
- }
-
- 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);
- }
- };
-
-%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);
- }
-
- static DataArrayInt *meld(PyObject *li) throw(INTERP_KERNEL::Exception)
- {
- std::vector<const DataArrayInt *> tmp;
- convertPyObjToVecDataArrayIntCst(li,tmp);
- return DataArrayInt::meld(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 *deepCpy() 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 mergeNodes2(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 *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);
- 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();
- }
- 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);
- }
-
- static MEDCouplingFieldDouble *mergeFields(PyObject *li) throw(INTERP_KERNEL::Exception)
- {
- std::vector<const MEDCouplingFieldDouble *> tmp;
- convertPyObjToVecFieldDblCst(li,tmp);
- return MEDCouplingFieldDouble::mergeFields(tmp);
- }
- }
- };
-}
--- /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::getMeshAtRank;
+%newobject ParaMEDMEM::MEDFileUMesh::getRank0Mesh;
+%newobject ParaMEDMEM::MEDFileUMesh::getRankM1Mesh;
+%newobject ParaMEDMEM::MEDFileUMesh::getRankM2Mesh;
+%newobject ParaMEDMEM::MEDFileUMesh::getRankM3Mesh;
+
+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);
+};
+
+%include "MEDFileMesh.hxx"
+
# 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("3DMesh_1");
#
vec=["mesh2"];
- mesh2_2=MEDLoader.ReadUMeshFromGroups(fileName,mnane,0,vec);
+ 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);
+ 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));
pass
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.getName(),f1.getMesh().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.getName(),f1.getMesh().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
# 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
#
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
-dist_salomescript_DATA= libMEDLoader_Swig.py MEDLoaderDataForTest.py MEDLoaderTest.py MEDLoaderTest2.py
+dist_salomescript_DATA= MEDLoader.py MEDLoaderDataForTest.py MEDLoaderTest.py MEDLoaderTest2.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 "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::getMeshAtRank;
-%newobject ParaMEDMEM::MEDFileUMesh::getRank0Mesh;
-%newobject ParaMEDMEM::MEDFileUMesh::getRankM1Mesh;
-%newobject ParaMEDMEM::MEDFileUMesh::getRankM2Mesh;
-%newobject ParaMEDMEM::MEDFileUMesh::getRankM3Mesh;
-
-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);
-};
-
-%include "MEDFileMesh.hxx"
-
#
include $(top_srcdir)/adm_local/unix/make_common_starter.am
-lib_LTLIBRARIES = _libParaMEDMEM_Swig.la
+lib_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()