-# Copyright (C) 2007-2010 CEA/DEN, EDF R&D
+# Copyright (C) 2007-2011 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 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.
+# 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
+# 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
+# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
#
# File : Makefile.am
noinst_LTLIBRARIES = libinterpkernelgauss.la
salomeinclude_HEADERS = \
-GaussCoords.hxx
+InterpKernelGaussCoords.hxx
# Libraries targets
dist_libinterpkernelgauss_la_SOURCES = \
-GaussCoords.cxx
+InterpKernelGaussCoords.cxx
libinterpkernelgauss_la_CPPFLAGS=-I$(srcdir)/../Bases -I$(srcdir)/..
-AM_CPPFLAGS += $(libinterpkernelgauss_la_CPPFLAGS)
\ No newline at end of file
+AM_CPPFLAGS += $(libinterpkernelgauss_la_CPPFLAGS)
return true;
}
-/*!
- * Method with same principle than MEDCouplingFieldDouble::areStrictlyCompatible method except that
- * number of components between 'this' and 'other' can be different here (for operator/).
- */
-bool MEDCouplingFieldDouble::areCompatibleForDiv(const MEDCouplingField *other) const
-{
- if(!MEDCouplingField::areStrictlyCompatible(other))
- return false;
- const MEDCouplingFieldDouble *otherC=dynamic_cast<const MEDCouplingFieldDouble *>(other);
- if(!otherC)
- return false;
- if(_nature!=otherC->_nature)
- return false;
- if(!_time_discr->areStrictlyCompatibleForDiv(otherC->_time_discr))
- return false;
- return true;
-}
-
-/*!
- * This method is invocated before any attempt of melding. This method is very close to areStrictlyCompatible,
- * except that 'this' and other can have different number of components.
- */
-bool MEDCouplingFieldDouble::areCompatibleForMeld(const MEDCouplingFieldDouble *other) const
-{
- if(!MEDCouplingField::areStrictlyCompatible(other))
- return false;
- if(_nature!=other->_nature)
- return false;
- if(!_time_discr->areCompatibleForMeld(other->_time_discr))
- return false;
- return true;
-}
-
/*!
* This method performs a clone of mesh and a renumbering of underlying cells of it. The number of cells remains the same.
* The values of field are impacted in consequence to have the same geometrical field.
return true;
}
-/*!
- * Merge nodes with (barycenter computation) of underlying mesh. In case of some node will be merged the underlying mesh instance will change.
- */
-bool MEDCouplingFieldDouble::mergeNodes2(double eps) throw(INTERP_KERNEL::Exception)
-{
- const MEDCouplingPointSet *meshC=dynamic_cast<const MEDCouplingPointSet *>(_mesh);
- if(!meshC)
- throw INTERP_KERNEL::Exception("Invalid support mesh to apply mergeNodes on it : must be a MEDCouplingPointSet one !");
- MEDCouplingAutoRefCountObjectPtr<MEDCouplingPointSet> meshC2((MEDCouplingPointSet *)meshC->deepCpy());
- bool ret;
- int ret2;
- MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr=meshC2->mergeNodes2(eps,ret,ret2);
- if(!ret)//no nodes have been merged.
- return ret;
- std::vector<DataArrayDouble *> arrays;
- _time_discr->getArrays(arrays);
- for(std::vector<DataArrayDouble *>::const_iterator iter=arrays.begin();iter!=arrays.end();iter++)
- if(*iter)
- _type->renumberValuesOnNodes(arr->getConstPointer(),*iter);
- setMesh(meshC2);
- return true;
-}
-
/*!
* This method applyies ParaMEDMEM::MEDCouplingPointSet::zipCoords method on 'this->_mesh' that should be set and of type ParaMEDMEM::MEDCouplingPointSet.
* If some nodes have disappeared true is returned.
}
/*!
- * Given a point given by its position 'pos' this method finds the set of node ids that are a a distance lower than eps.
- * Position 'pos' is expected to be of size getSpaceDimension()*nbOfNodes. If not the behabiour is not warranted.
+ * Given a set of points given by their position 'pos' this method finds the set of node ids that are a a distance lower than eps.
+ * Position 'pos' is expected to be of size getSpaceDimension()*nbOfNodes. If not the behaviour is not warranted.
* This method throws an exception if no coordiantes are set.
+ *
+ * Information is returned via a (value, index) integer array giving the number
+ * of nodes in (this) point set found for each node in pos : (c,cI)
+ * cI has size nbOfNodes+1
+ * c has size cI[nbOfNodes]
*/
void MEDCouplingPointSet::getNodeIdsNearPoints(const double *pos, int nbOfNodes, double eps, std::vector<int>& c, std::vector<int>& cI) const throw(INTERP_KERNEL::Exception)
{
#include "MEDCouplingAutoRefCountObjectPtr.hxx"
#include "InterpKernelAutoPtr.hxx"
-
#include <sstream>
#include <numeric>
#include <cstring>
throw INTERP_KERNEL::Exception("Nodal connectivity index array is expected to be with number of components set to one !");
if(_nodal_connec_index->getInfoOnComponent(0)!="")
throw INTERP_KERNEL::Exception("Nodal connectivity index array is expected to have no info on its single component !");
- int curNbOfCell=getNumberOfCells();
- const int *curCI=_nodal_connec_index->getConstPointer();
- for (int i=0; i<curNbOfCell; i++)
- if(curCI[i+1]<curCI[i])
- {
- std::ostringstream oss;
- oss<<"pb in connectivity index --> cell "<<i<<" conn_index[i]=" <<curCI[i]<<" conn_index[i+1]="<<curCI[i+1];
- throw INTERP_KERNEL::Exception(oss.str().c_str());
- }
}
}
-// Copyright (C) 2007-2010 CEA/DEN, EDF R&D
+// Copyright (C) 2007-2011 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 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.
+// 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
+// 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
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
%module MEDCoupling
#include "MEDCouplingCMesh.hxx"
#include "MEDCouplingField.hxx"
#include "MEDCouplingFieldDouble.hxx"
+#include "MEDCouplingFieldTemplate.hxx"
#include "MEDCouplingGaussLocalization.hxx"
#include "MEDCouplingAutoRefCountObjectPtr.hxx"
+#include "MEDCouplingMultiFields.hxx"
+#include "MEDCouplingFieldOverTime.hxx"
+#include "MEDCouplingDefinitionTime.hxx"
#include "MEDCouplingTypemaps.i"
#include "InterpKernelAutoPtr.hxx"
$result=convertMesh($1,$owner);
}
+%typemap(out) ParaMEDMEM::MEDCouplingMultiFields*
+{
+ $result=convertMultiFields($1,$owner);
+}
+
#ifdef WITH_NUMPY2
%init %{ import_array(); %}
#endif
%feature("autodoc", "1");
%feature("docstring");
+%newobject ParaMEDMEM::MEDCouplingFieldDiscretization::getOffsetArr;
%newobject ParaMEDMEM::MEDCouplingField::buildMeasureField;
+%newobject ParaMEDMEM::MEDCouplingField::getLocalizationOfDiscr;
%newobject ParaMEDMEM::MEDCouplingFieldDouble::New;
%newobject ParaMEDMEM::MEDCouplingFieldDouble::getArray;
%newobject ParaMEDMEM::MEDCouplingFieldDouble::getEndArray;
%newobject ParaMEDMEM::MEDCouplingFieldDouble::cloneWithMesh;
%newobject ParaMEDMEM::MEDCouplingFieldDouble::deepCpy;
%newobject ParaMEDMEM::MEDCouplingFieldDouble::buildNewTimeReprFromThis;
+%newobject ParaMEDMEM::MEDCouplingFieldDouble::getValueOnMulti;
+%newobject ParaMEDMEM::MEDCouplingFieldTemplate::New;
%newobject ParaMEDMEM::DataArrayInt::New;
%newobject ParaMEDMEM::DataArrayInt::convertToDblArr;
%newobject ParaMEDMEM::DataArrayInt::deepCpy;
%newobject ParaMEDMEM::DataArrayInt::keepSelectedComponents;
%newobject ParaMEDMEM::DataArrayInt::selectByTupleId;
%newobject ParaMEDMEM::DataArrayInt::selectByTupleIdSafe;
+%newobject ParaMEDMEM::DataArrayInt::selectByTupleId2;
+%newobject ParaMEDMEM::DataArrayInt::checkAndPreparePermutation;
+%newobject ParaMEDMEM::DataArrayInt::transformWithIndArrR;
%newobject ParaMEDMEM::DataArrayInt::renumber;
%newobject ParaMEDMEM::DataArrayInt::renumberR;
%newobject ParaMEDMEM::DataArrayInt::renumberAndReduce;
%newobject ParaMEDMEM::DataArrayInt::invertArrayO2N2N2O;
%newobject ParaMEDMEM::DataArrayInt::invertArrayN2O2O2N;
%newobject ParaMEDMEM::DataArrayInt::getIdsEqual;
+%newobject ParaMEDMEM::DataArrayInt::getIdsNotEqual;
%newobject ParaMEDMEM::DataArrayInt::getIdsEqualList;
+%newobject ParaMEDMEM::DataArrayInt::getIdsNotEqualList;
%newobject ParaMEDMEM::DataArrayInt::Aggregate;
%newobject ParaMEDMEM::DataArrayInt::Meld;
+%newobject ParaMEDMEM::DataArrayInt::Add;
+%newobject ParaMEDMEM::DataArrayInt::Substract;
+%newobject ParaMEDMEM::DataArrayInt::Multiply;
+%newobject ParaMEDMEM::DataArrayInt::Divide;
%newobject ParaMEDMEM::DataArrayInt::BuildUnion;
%newobject ParaMEDMEM::DataArrayInt::BuildIntersection;
%newobject ParaMEDMEM::DataArrayInt::fromNoInterlace;
%newobject ParaMEDMEM::DataArrayInt::buildSubstraction;
%newobject ParaMEDMEM::DataArrayInt::buildIntersection;
%newobject ParaMEDMEM::DataArrayInt::deltaShiftIndex;
+%newobject ParaMEDMEM::DataArrayInt::buildExplicitArrByRanges;
%newobject ParaMEDMEM::DataArrayInt::buildPermutationArr;
+%newobject ParaMEDMEM::DataArrayInt::buildPermArrPerLevel;
+%newobject ParaMEDMEM::DataArrayInt::__getitem__;
+%newobject ParaMEDMEM::DataArrayInt::__add__;
+%newobject ParaMEDMEM::DataArrayInt::__radd__;
+%newobject ParaMEDMEM::DataArrayInt::__sub__;
+%newobject ParaMEDMEM::DataArrayInt::__rsub__;
+%newobject ParaMEDMEM::DataArrayInt::__mul__;
+%newobject ParaMEDMEM::DataArrayInt::__rmul__;
+%newobject ParaMEDMEM::DataArrayInt::__div__;
+%newobject ParaMEDMEM::DataArrayInt::__rdiv__;
+%newobject ParaMEDMEM::DataArrayInt::__mod__;
+%newobject ParaMEDMEM::DataArrayInt::__rmod__;
%newobject ParaMEDMEM::DataArrayDouble::New;
%newobject ParaMEDMEM::DataArrayDouble::convertToIntArr;
%newobject ParaMEDMEM::DataArrayDouble::deepCpy;
%newobject ParaMEDMEM::DataArrayDouble::getIdsInRange;
%newobject ParaMEDMEM::DataArrayDouble::selectByTupleId;
%newobject ParaMEDMEM::DataArrayDouble::selectByTupleIdSafe;
+%newobject ParaMEDMEM::DataArrayDouble::selectByTupleId2;
%newobject ParaMEDMEM::DataArrayDouble::applyFunc;
+%newobject ParaMEDMEM::DataArrayDouble::applyFunc2;
+%newobject ParaMEDMEM::DataArrayDouble::applyFunc3;
%newobject ParaMEDMEM::DataArrayDouble::doublyContractedProduct;
%newobject ParaMEDMEM::DataArrayDouble::determinant;
%newobject ParaMEDMEM::DataArrayDouble::eigenValues;
%newobject ParaMEDMEM::DataArrayDouble::fromPolarToCart;
%newobject ParaMEDMEM::DataArrayDouble::fromCylToCart;
%newobject ParaMEDMEM::DataArrayDouble::fromSpherToCart;
+%newobject ParaMEDMEM::DataArrayDouble::__getitem__;
+%newobject ParaMEDMEM::DataArrayDouble::__add__;
+%newobject ParaMEDMEM::DataArrayDouble::__radd__;
+%newobject ParaMEDMEM::DataArrayDouble::__sub__;
+%newobject ParaMEDMEM::DataArrayDouble::__rsub__;
+%newobject ParaMEDMEM::DataArrayDouble::__mul__;
+%newobject ParaMEDMEM::DataArrayDouble::__rmul__;
+%newobject ParaMEDMEM::DataArrayDouble::__div__;
+%newobject ParaMEDMEM::DataArrayDouble::__rdiv__;
+%newobject ParaMEDMEM::MEDCouplingMesh::deepCpy;
+%newobject ParaMEDMEM::MEDCouplingMesh::checkTypeConsistencyAndContig;
%newobject ParaMEDMEM::MEDCouplingMesh::getCoordinatesAndOwner;
%newobject ParaMEDMEM::MEDCouplingMesh::getBarycenterAndOwner;
%newobject ParaMEDMEM::MEDCouplingMesh::buildOrthogonalField;
%newobject ParaMEDMEM::MEDCouplingMesh::getCellIdsFullyIncludedInNodeIds;
%newobject ParaMEDMEM::MEDCouplingMesh::mergeMyselfWith;
%newobject ParaMEDMEM::MEDCouplingMesh::fillFromAnalytic;
+%newobject ParaMEDMEM::MEDCouplingMesh::fillFromAnalytic2;
+%newobject ParaMEDMEM::MEDCouplingMesh::fillFromAnalytic3;
%newobject ParaMEDMEM::MEDCouplingMesh::getMeasureField;
%newobject ParaMEDMEM::MEDCouplingMesh::simplexize;
%newobject ParaMEDMEM::MEDCouplingMesh::buildUnstructured;
%newobject ParaMEDMEM::MEDCouplingUMesh::MergeUMeshesOnSameCoords;
%newobject ParaMEDMEM::MEDCouplingUMesh::buildNewNumberingFromCommNodesFrmt;
%newobject ParaMEDMEM::MEDCouplingUMesh::rearrange2ConsecutiveCellTypes;
+%newobject ParaMEDMEM::MEDCouplingUMesh::sortCellsInMEDFileFrmt;
%newobject ParaMEDMEM::MEDCouplingUMesh::convertCellArrayPerGeoType;
%newobject ParaMEDMEM::MEDCouplingUMesh::getRenumArrForConsecutiveCellTypesSpec;
%newobject ParaMEDMEM::MEDCouplingUMesh::buildDirectionVectorField;
%newobject ParaMEDMEM::MEDCouplingUMesh::getAspectRatioField;
%newobject ParaMEDMEM::MEDCouplingUMesh::getWarpField;
%newobject ParaMEDMEM::MEDCouplingUMesh::getSkewField;
+%newobject ParaMEDMEM::MEDCouplingUMesh::getPartBarycenterAndOwner;
+%newobject ParaMEDMEM::MEDCouplingUMesh::getPartMeasureField;
+%newobject ParaMEDMEM::MEDCouplingUMesh::buildPartOrthogonalField;
+%newobject ParaMEDMEM::MEDCouplingUMesh::keepCellIdsByType;
+%newobject ParaMEDMEM::MEDCouplingUMesh::Build0DMeshFromCoords;
+%newobject ParaMEDMEM::MEDCouplingUMesh::findCellsIdsOnBoundary;
+%newobject ParaMEDMEM::MEDCouplingUMesh::getCellIdsLyingOnNodes;
%newobject ParaMEDMEM::MEDCouplingExtrudedMesh::New;
%newobject ParaMEDMEM::MEDCouplingExtrudedMesh::build3DUnstructuredMesh;
%newobject ParaMEDMEM::MEDCouplingCMesh::New;
%newobject ParaMEDMEM::MEDCouplingCMesh::getCoordsAt;
+%newobject ParaMEDMEM::MEDCouplingMultiFields::New;
+%newobject ParaMEDMEM::MEDCouplingMultiFields::deepCpy;
+%newobject ParaMEDMEM::MEDCouplingFieldOverTime::New;
+
%feature("unref") DataArrayDouble "$this->decrRef();"
%feature("unref") MEDCouplingPointSet "$this->decrRef();"
%feature("unref") MEDCouplingMesh "$this->decrRef();"
%feature("unref") DataArrayInt "$this->decrRef();"
%feature("unref") MEDCouplingField "$this->decrRef();"
%feature("unref") MEDCouplingFieldDouble "$this->decrRef();"
+%feature("unref") MEDCouplingMultiFields "$this->decrRef();"
+%feature("unref") MEDCouplingFieldTemplate "$this->decrRef();"
+%feature("unref") MEDCouplingMultiFields "$this->decrRef();"
%rename(assign) *::operator=;
+%ignore ParaMEDMEM::RefCountObject::decrRef;
%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;
+%rename (InterpKernelException) INTERP_KERNEL::Exception;
+
namespace INTERP_KERNEL
{
class Exception
class MEDCouplingUMesh;
class MEDCouplingFieldDouble;
+ %extend RefCountObject
+ {
+ std::string getHiddenCppPointer() const
+ {
+ std::ostringstream oss; oss << "C++ Pointer address is : " << self;
+ return oss.str();
+ }
+ }
+
class MEDCouplingMesh : public RefCountObject, public TimeLabel
{
public:
- void setName(const char *name) { _name=name; }
- const char *getName() const { return _name.c_str(); }
+ void setName(const char *name);
+ const char *getName() const;
+ void setDescription(const char *descr);
+ const char *getDescription() const;
+ void setTime(double val, int iteration, int order);
+ void setTimeUnit(const char *unit);
+ const char *getTimeUnit() const;
virtual MEDCouplingMeshType getType() const throw(INTERP_KERNEL::Exception) = 0;
bool isStructured() const throw(INTERP_KERNEL::Exception);
+ virtual MEDCouplingMesh *deepCpy() const = 0;
virtual bool isEqual(const MEDCouplingMesh *other, double prec) const throw(INTERP_KERNEL::Exception);
virtual bool isEqualWithoutConsideringStr(const MEDCouplingMesh *other, double prec) const throw(INTERP_KERNEL::Exception) = 0;
virtual void copyTinyStringsFrom(const MEDCouplingMesh *other) throw(INTERP_KERNEL::Exception);
+ virtual void copyTinyInfoFrom(const MEDCouplingMesh *other) throw(INTERP_KERNEL::Exception);
virtual void checkCoherency() const throw(INTERP_KERNEL::Exception) = 0;
+ virtual void checkCoherency1(double eps=1e-12) const throw(INTERP_KERNEL::Exception) = 0;
+ virtual void checkCoherency2(double eps=1e-12) const throw(INTERP_KERNEL::Exception) = 0;
virtual int getNumberOfCells() const throw(INTERP_KERNEL::Exception) = 0;
virtual int getNumberOfNodes() const throw(INTERP_KERNEL::Exception) = 0;
virtual int getSpaceDimension() const throw(INTERP_KERNEL::Exception) = 0;
virtual MEDCouplingFieldDouble *getMeasureField(bool isAbs) const throw(INTERP_KERNEL::Exception) = 0;
virtual MEDCouplingFieldDouble *getMeasureFieldOnNode(bool isAbs) const throw(INTERP_KERNEL::Exception) = 0;
virtual MEDCouplingFieldDouble *fillFromAnalytic(TypeOfField t, int nbOfComp, const char *func) const throw(INTERP_KERNEL::Exception);
+ virtual MEDCouplingFieldDouble *fillFromAnalytic2(TypeOfField t, int nbOfComp, const char *func) const throw(INTERP_KERNEL::Exception);
+ virtual MEDCouplingFieldDouble *fillFromAnalytic3(TypeOfField t, int nbOfComp, const std::vector<std::string>& varsOrder, const char *func) const throw(INTERP_KERNEL::Exception);
virtual MEDCouplingFieldDouble *buildOrthogonalField() const throw(INTERP_KERNEL::Exception) = 0;
virtual MEDCouplingUMesh *buildUnstructured() const throw(INTERP_KERNEL::Exception);
virtual MEDCouplingMesh *mergeMyselfWith(const MEDCouplingMesh *other) const throw(INTERP_KERNEL::Exception) = 0;
return self->simpleRepr();
}
+ PyObject *getTime() throw(INTERP_KERNEL::Exception)
+ {
+ int tmp1,tmp2;
+ double tmp0=self->getTime(tmp1,tmp2);
+ PyObject *res = PyList_New(3);
+ PyList_SetItem(res,0,SWIG_From_double(tmp0));
+ PyList_SetItem(res,1,SWIG_From_int(tmp1));
+ PyList_SetItem(res,2,SWIG_From_int(tmp2));
+ return res;
+ }
+
int getCellContainingPoint(PyObject *p, double eps) const throw(INTERP_KERNEL::Exception)
{
int sz;
delete [] pos;
return ret;
}
+
+ PyObject *getCellsContainingPoints(PyObject *p, int nbOfPoints, double eps) const throw(INTERP_KERNEL::Exception)
+ {
+ int sz;
+ INTERP_KERNEL::AutoPtr<double> pos=convertPyToNewDblArr2(p,&sz);
+ std::vector<int> elts,eltsIndex;
+ self->getCellsContainingPoints(pos,nbOfPoints,eps,elts,eltsIndex);
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> d0=DataArrayInt::New();
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> d1=DataArrayInt::New();
+ d0->alloc(elts.size(),1);
+ d1->alloc(eltsIndex.size(),1);
+ std::copy(elts.begin(),elts.end(),d0->getPointer());
+ std::copy(eltsIndex.begin(),eltsIndex.end(),d1->getPointer());
+ PyObject *ret=PyTuple_New(2);
+ PyTuple_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(d0),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 ));
+ PyTuple_SetItem(ret,1,SWIG_NewPointerObj(SWIG_as_voidptr(d1),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 ));
+ d0->incrRef();
+ d1->incrRef();
+ return ret;
+ }
+
+ PyObject *getCellsContainingPoint(PyObject *p, double eps) const throw(INTERP_KERNEL::Exception)
+ {
+ int sz;
+ INTERP_KERNEL::AutoPtr<double> pos=convertPyToNewDblArr2(p,&sz);
+ std::vector<int> elts;
+ self->getCellsContainingPoint(pos,eps,elts);
+ return convertIntArrToPyList2(elts);
+ }
void renumberCells(PyObject *li, bool check) throw(INTERP_KERNEL::Exception)
{
- int size;
- INTERP_KERNEL::AutoPtr<int> tmp=convertPyToNewIntArr2(li,&size);
- self->renumberCells(tmp,check);
+ void *da=0;
+ int res1=SWIG_ConvertPtr(li,&da,SWIGTYPE_p_ParaMEDMEM__DataArrayInt, 0 | 0 );
+ if (!SWIG_IsOK(res1))
+ {
+ int size;
+ INTERP_KERNEL::AutoPtr<int> tmp=convertPyToNewIntArr2(li,&size);
+ self->renumberCells(tmp,check);
+ }
+ else
+ {
+ DataArrayInt *da2=reinterpret_cast< DataArrayInt * >(da);
+ if(!da2)
+ throw INTERP_KERNEL::Exception("Not null DataArrayInt instance expected !");
+ da2->checkAllocated();
+ self->renumberCells(da2->getConstPointer(),check);
+ }
}
PyObject *checkGeoEquivalWith(const MEDCouplingMesh *other, int levOfCheck, double prec) const throw(INTERP_KERNEL::Exception)
}
DataArrayInt *getCellIdsFullyIncludedInNodeIds(PyObject *li) const throw(INTERP_KERNEL::Exception)
{
- int size;
- INTERP_KERNEL::AutoPtr<int> tmp=convertPyToNewIntArr2(li,&size);
- DataArrayInt *ret=self->getCellIdsFullyIncludedInNodeIds(tmp,tmp+size);
- return ret;
+ void *da=0;
+ int res1=SWIG_ConvertPtr(li,&da,SWIGTYPE_p_ParaMEDMEM__DataArrayInt, 0 | 0 );
+ if (!SWIG_IsOK(res1))
+ {
+ int size;
+ INTERP_KERNEL::AutoPtr<int> tmp=convertPyToNewIntArr2(li,&size);
+ return self->getCellIdsFullyIncludedInNodeIds(tmp,((const int *)tmp)+size);
+ }
+ else
+ {
+ DataArrayInt *da2=reinterpret_cast< DataArrayInt * >(da);
+ if(!da2)
+ throw INTERP_KERNEL::Exception("Not null DataArrayInt instance expected !");
+ da2->checkAllocated();
+ return self->getCellIdsFullyIncludedInNodeIds(da2->getConstPointer(),da2->getConstPointer()+da2->getNbOfElems());
+ }
}
PyObject *getNodeIdsOfCell(int cellId) const throw(INTERP_KERNEL::Exception)
{
PyObject *buildPart(PyObject *li) const throw(INTERP_KERNEL::Exception)
{
- int size;
- INTERP_KERNEL::AutoPtr<int> tmp=convertPyToNewIntArr2(li,&size);
- MEDCouplingMesh *ret=self->buildPart(tmp,tmp+size);
- return convertMesh(ret, SWIG_POINTER_OWN | 0 );
+ void *da=0;
+ int res1=SWIG_ConvertPtr(li,&da,SWIGTYPE_p_ParaMEDMEM__DataArrayInt, 0 | 0 );
+ if (!SWIG_IsOK(res1))
+ {
+ int size;
+ INTERP_KERNEL::AutoPtr<int> tmp=convertPyToNewIntArr2(li,&size);
+ MEDCouplingMesh *ret=self->buildPart(tmp,((const int *)tmp)+size);
+ return convertMesh(ret, SWIG_POINTER_OWN | 0 );
+ }
+ else
+ {
+ DataArrayInt *da2=reinterpret_cast< DataArrayInt * >(da);
+ if(!da2)
+ throw INTERP_KERNEL::Exception("Not null DataArrayInt instance expected !");
+ da2->checkAllocated();
+ MEDCouplingMesh *ret=self->buildPart(da2->getConstPointer(),da2->getConstPointer()+da2->getNbOfElems());
+ ret->setName(da2->getName().c_str());
+ return convertMesh(ret, SWIG_POINTER_OWN | 0 );
+ }
}
-
+
PyObject *buildPartAndReduceNodes(PyObject *li) const throw(INTERP_KERNEL::Exception)
{
- int size;
- INTERP_KERNEL::AutoPtr<int> tmp=convertPyToNewIntArr2(li,&size);
+ void *da=0;
DataArrayInt *arr=0;
- MEDCouplingMesh *ret=self->buildPartAndReduceNodes(tmp,tmp+size,arr);
+ MEDCouplingMesh *ret=0;
+ int res1=SWIG_ConvertPtr(li,&da,SWIGTYPE_p_ParaMEDMEM__DataArrayInt, 0 | 0 );
+ if (!SWIG_IsOK(res1))
+ {
+ int size;
+ INTERP_KERNEL::AutoPtr<int> tmp=convertPyToNewIntArr2(li,&size);
+ ret=self->buildPartAndReduceNodes(tmp,((const int *)tmp)+size,arr);
+ }
+ else
+ {
+ DataArrayInt *da2=reinterpret_cast< DataArrayInt * >(da);
+ if(!da2)
+ throw INTERP_KERNEL::Exception("Not null DataArrayInt instance expected !");
+ da2->checkAllocated();
+ ret=self->buildPartAndReduceNodes(da2->getConstPointer(),da2->getConstPointer()+da2->getNbOfElems(),arr);
+ ret->setName(da2->getName().c_str());
+ }
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 );
return res;
}
+ DataArrayInt *checkTypeConsistencyAndContig(PyObject *li, PyObject *li2) const throw(INTERP_KERNEL::Exception)
+ {
+ std::vector<int> code;
+ std::vector<const DataArrayInt *> idsPerType;
+ convertPyObjToVecDataArrayIntCst(li2,idsPerType);
+ convertPyToNewIntArr3(li,code);
+ return self->checkTypeConsistencyAndContig(code,idsPerType);
+ }
+
+ PyObject *splitProfilePerType(const DataArrayInt *profile) const throw(INTERP_KERNEL::Exception)
+ {
+ std::vector<int> code;
+ std::vector<DataArrayInt *> idsInPflPerType;
+ std::vector<DataArrayInt *> idsPerType;
+ self->splitProfilePerType(profile,code,idsInPflPerType,idsPerType);
+ PyObject *ret=PyTuple_New(3);
+ PyTuple_SetItem(ret,0,convertIntArrToPyList2(code));
+ PyObject *ret1=PyList_New(idsInPflPerType.size());
+ for(std::size_t j=0;j<idsInPflPerType.size();j++)
+ PyList_SetItem(ret1,j,SWIG_NewPointerObj(SWIG_as_voidptr(idsInPflPerType[j]),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 ));
+ PyTuple_SetItem(ret,1,ret1);
+ int n=idsPerType.size();
+ PyObject *ret2=PyList_New(n);
+ for(int i=0;i<n;i++)
+ PyList_SetItem(ret2,i,SWIG_NewPointerObj(SWIG_as_voidptr(idsPerType[i]),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 ));
+ PyTuple_SetItem(ret,2,ret2);
+ return ret;
+ }
+
void translate(PyObject *vector) throw(INTERP_KERNEL::Exception)
{
int sz;
{ return ; }
self->rotate(c,v,alpha);
}
+
+ PyObject *getAllGeoTypes() const throw(INTERP_KERNEL::Exception)
+ {
+ std::set<INTERP_KERNEL::NormalizedCellType> result=self->getAllGeoTypes();
+ 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;
+ }
}
};
}
class MEDCouplingPointSet : public ParaMEDMEM::MEDCouplingMesh
{
public:
- void updateTime();
- void setCoords(DataArrayDouble *coords) throw(INTERP_KERNEL::Exception);
+ void updateTime() const;
+ void setCoords(const DataArrayDouble *coords) throw(INTERP_KERNEL::Exception);
DataArrayDouble *getCoordinatesAndOwner() const throw(INTERP_KERNEL::Exception);
bool areCoordsEqual(const MEDCouplingPointSet& other, double prec) const throw(INTERP_KERNEL::Exception);
void zipCoords() throw(INTERP_KERNEL::Exception);
virtual MEDCouplingPointSet *buildBoundaryMesh(bool keepCoords) const throw(INTERP_KERNEL::Exception) = 0;
virtual bool isEmptyMesh(const std::vector<int>& tinyInfo) const throw(INTERP_KERNEL::Exception) = 0;
//! size of returned tinyInfo must be always the same.
- void getTinySerializationInformation(std::vector<int>& tinyInfo, std::vector<std::string>& littleStrings) const throw(INTERP_KERNEL::Exception);
+ void getTinySerializationInformation(std::vector<double>& tinyInfoD, std::vector<int>& tinyInfo, std::vector<std::string>& littleStrings) const throw(INTERP_KERNEL::Exception);
void resizeForUnserialization(const std::vector<int>& tinyInfo, DataArrayInt *a1, DataArrayDouble *a2, std::vector<std::string>& littleStrings) const throw(INTERP_KERNEL::Exception);
void serialize(DataArrayInt *&a1, DataArrayDouble *&a2) const throw(INTERP_KERNEL::Exception);
- void unserialization(const std::vector<int>& tinyInfo, const DataArrayInt *a1, DataArrayDouble *a2,
+ void unserialization(const std::vector<double>& tinyInfoD, const std::vector<int>& tinyInfo, const DataArrayInt *a1, DataArrayDouble *a2,
const std::vector<std::string>& littleStrings) throw(INTERP_KERNEL::Exception);
- virtual void giveElemsInBoundingBox(const INTERP_KERNEL::DirectedBoundingBox& bbox, double eps, std::vector<int>& elems) throw(INTERP_KERNEL::Exception) = 0;
+ virtual void getCellsInBoundingBox(const INTERP_KERNEL::DirectedBoundingBox& bbox, double eps, std::vector<int>& elems) throw(INTERP_KERNEL::Exception) = 0;
virtual DataArrayInt *zipCoordsTraducer() throw(INTERP_KERNEL::Exception) = 0;
%extend
{
return res;
}
- PyObject *getCoords() const throw(INTERP_KERNEL::Exception)
+ PyObject *getCoords() throw(INTERP_KERNEL::Exception)
{
DataArrayDouble *ret1=self->getCoords();
ret1->incrRef();
}
PyObject *buildPartOfMySelf(PyObject *li, bool keepCoords) const throw(INTERP_KERNEL::Exception)
{
- int size;
- INTERP_KERNEL::AutoPtr<int> tmp=convertPyToNewIntArr2(li,&size);
- MEDCouplingPointSet *ret=self->buildPartOfMySelf(tmp,tmp+size,keepCoords);
- return convertMesh(ret, SWIG_POINTER_OWN | 0 );
+ void *da=0;
+ int res1=SWIG_ConvertPtr(li,&da,SWIGTYPE_p_ParaMEDMEM__DataArrayInt, 0 | 0 );
+ if (!SWIG_IsOK(res1))
+ {
+ int size;
+ INTERP_KERNEL::AutoPtr<int> tmp=convertPyToNewIntArr2(li,&size);
+ MEDCouplingPointSet *ret=self->buildPartOfMySelf(tmp,((const int *)tmp)+size,keepCoords);
+ return convertMesh(ret, SWIG_POINTER_OWN | 0 );
+ }
+ else
+ {
+ DataArrayInt *da2=reinterpret_cast< DataArrayInt * >(da);
+ if(!da2)
+ throw INTERP_KERNEL::Exception("Not null DataArrayInt instance expected !");
+ da2->checkAllocated();
+ MEDCouplingPointSet *ret=self->buildPartOfMySelf(da2->getConstPointer(),da2->getConstPointer()+da2->getNbOfElems(),keepCoords);
+ ret->setName(da2->getName().c_str());
+ return convertMesh(ret, SWIG_POINTER_OWN | 0 );
+ }
}
PyObject *buildPartOfMySelfNode(PyObject *li, bool fullyIn) const throw(INTERP_KERNEL::Exception)
{
- int size;
- INTERP_KERNEL::AutoPtr<int> tmp=convertPyToNewIntArr2(li,&size);
- MEDCouplingPointSet *ret=self->buildPartOfMySelfNode(tmp,(int *)tmp+size,fullyIn);
- return convertMesh(ret, SWIG_POINTER_OWN | 0 );
+ void *da=0;
+ int res1=SWIG_ConvertPtr(li,&da,SWIGTYPE_p_ParaMEDMEM__DataArrayInt, 0 | 0 );
+ if (!SWIG_IsOK(res1))
+ {
+ int size;
+ INTERP_KERNEL::AutoPtr<int> tmp=convertPyToNewIntArr2(li,&size);
+ MEDCouplingPointSet *ret=self->buildPartOfMySelfNode(tmp,((const int *)tmp)+size,fullyIn);
+ return convertMesh(ret, SWIG_POINTER_OWN | 0 );
+ }
+ else
+ {
+ DataArrayInt *da2=reinterpret_cast< DataArrayInt * >(da);
+ if(!da2)
+ throw INTERP_KERNEL::Exception("Not null DataArrayInt instance expected !");
+ da2->checkAllocated();
+ MEDCouplingPointSet *ret=self->buildPartOfMySelfNode(da2->getConstPointer(),da2->getConstPointer()+da2->getNbOfElems(),fullyIn);
+ ret->setName(da2->getName().c_str());
+ return convertMesh(ret, SWIG_POINTER_OWN | 0 );
+ }
}
PyObject *buildFacePartOfMySelfNode(PyObject *li, bool fullyIn) const throw(INTERP_KERNEL::Exception)
{
- int size;
- INTERP_KERNEL::AutoPtr<int> tmp=convertPyToNewIntArr2(li,&size);
- MEDCouplingPointSet *ret=self->buildFacePartOfMySelfNode(tmp,(int *)tmp+size,fullyIn);
- return convertMesh(ret, SWIG_POINTER_OWN | 0 );
+ void *da=0;
+ int res1=SWIG_ConvertPtr(li,&da,SWIGTYPE_p_ParaMEDMEM__DataArrayInt, 0 | 0 );
+ if (!SWIG_IsOK(res1))
+ {
+ int size;
+ INTERP_KERNEL::AutoPtr<int> tmp=convertPyToNewIntArr2(li,&size);
+ MEDCouplingPointSet *ret=self->buildFacePartOfMySelfNode(tmp,((const int *)tmp)+size,fullyIn);
+ return convertMesh(ret, SWIG_POINTER_OWN | 0 );
+ }
+ else
+ {
+ DataArrayInt *da2=reinterpret_cast< DataArrayInt * >(da);
+ if(!da2)
+ throw INTERP_KERNEL::Exception("Not null DataArrayInt instance expected !");
+ da2->checkAllocated();
+ MEDCouplingPointSet *ret=self->buildFacePartOfMySelfNode(da2->getConstPointer(),da2->getConstPointer()+da2->getNbOfElems(),fullyIn);
+ ret->setName(da2->getName().c_str());
+ return convertMesh(ret, SWIG_POINTER_OWN | 0 );
+ }
}
PyObject *findBoundaryNodes() const throw(INTERP_KERNEL::Exception)
{
}
void renumberNodes(PyObject *li, int newNbOfNodes) throw(INTERP_KERNEL::Exception)
{
- int size;
- INTERP_KERNEL::AutoPtr<int> tmp=convertPyToNewIntArr2(li,&size);
- self->renumberNodes(tmp,newNbOfNodes);
+ void *da=0;
+ int res1=SWIG_ConvertPtr(li,&da,SWIGTYPE_p_ParaMEDMEM__DataArrayInt, 0 | 0 );
+ if (!SWIG_IsOK(res1))
+ {
+ int size;
+ INTERP_KERNEL::AutoPtr<int> tmp=convertPyToNewIntArr2(li,&size);
+ self->renumberNodes(tmp,newNbOfNodes);
+ }
+ else
+ {
+ DataArrayInt *da2=reinterpret_cast< DataArrayInt * >(da);
+ if(!da2)
+ throw INTERP_KERNEL::Exception("Not null DataArrayInt instance expected !");
+ da2->checkAllocated();
+ self->renumberNodes(da2->getConstPointer(),newNbOfNodes);
+ }
}
void renumberNodes2(PyObject *li, int newNbOfNodes) throw(INTERP_KERNEL::Exception)
{
- int size;
- INTERP_KERNEL::AutoPtr<int> tmp=convertPyToNewIntArr2(li,&size);
- self->renumberNodes2(tmp,newNbOfNodes);
+ void *da=0;
+ int res1=SWIG_ConvertPtr(li,&da,SWIGTYPE_p_ParaMEDMEM__DataArrayInt, 0 | 0 );
+ if (!SWIG_IsOK(res1))
+ {
+ int size;
+ INTERP_KERNEL::AutoPtr<int> tmp=convertPyToNewIntArr2(li,&size);
+ self->renumberNodes2(tmp,newNbOfNodes);
+ }
+ else
+ {
+ DataArrayInt *da2=reinterpret_cast< DataArrayInt * >(da);
+ if(!da2)
+ throw INTERP_KERNEL::Exception("Not null DataArrayInt instance expected !");
+ da2->checkAllocated();
+ self->renumberNodes2(da2->getConstPointer(),newNbOfNodes);
+ }
}
PyObject *findNodesOnPlane(PyObject *pt, PyObject *vec, double eps) const throw(INTERP_KERNEL::Exception)
{
PyObject *getNodeIdsNearPoint(PyObject *pt, double eps) const throw(INTERP_KERNEL::Exception)
{
int size;
- double *pos=convertPyToNewDblArr2(pt,&size);
+ INTERP_KERNEL::AutoPtr<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;
+ throw INTERP_KERNEL::Exception("getNodeIdsNearPoint : to tiny array ! must be at least of size SpaceDim !");
+ std::vector<int> tmp=self->getNodeIdsNearPoint(pos,eps);
return convertIntArrToPyList2(tmp);
}
{
std::vector<int> c,cI;
int size;
- double *pos=convertPyToNewDblArr2(pt,&size);
+ INTERP_KERNEL::AutoPtr<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;
+ throw INTERP_KERNEL::Exception("getNodeIdsNearPoints : to tiny array ! must be at least of size SpaceDim*nbOfNodes !");
+ self->getNodeIdsNearPoints(pos,nbOfNodes,eps,c,cI);
PyObject *ret=PyTuple_New(2);
- PyTuple_SetItem(ret,0,convertIntArrToPyList2(c));
- PyTuple_SetItem(ret,1,convertIntArrToPyList2(cI));
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> d0=DataArrayInt::New();
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> d1=DataArrayInt::New();
+ d0->alloc(c.size(),1);
+ d1->alloc(cI.size(),1);
+ std::copy(c.begin(),c.end(),d0->getPointer());
+ std::copy(cI.begin(),cI.end(),d1->getPointer());
+ PyTuple_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(d0),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 ));
+ PyTuple_SetItem(ret,1,SWIG_NewPointerObj(SWIG_as_voidptr(d1),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 ));
+ d0->incrRef();
+ d1->incrRef();
return ret;
}
- PyObject *giveElemsInBoundingBox(PyObject *bbox, double eps) throw(INTERP_KERNEL::Exception)
+ PyObject *getCellsInBoundingBox(PyObject *bbox, double eps) throw(INTERP_KERNEL::Exception)
{
std::vector<int> elems;
int size;
double *tmp=convertPyToNewDblArr2(bbox,&size);
- self->giveElemsInBoundingBox(tmp,eps,elems);
+ self->getCellsInBoundingBox(tmp,eps,elems);
delete [] tmp;
return convertIntArrToPyList2(elems);
}
static MEDCouplingUMesh *New();
static MEDCouplingUMesh *New(const char *meshName, int meshDim);
MEDCouplingUMesh *clone(bool recDeepCpy) const;
- void updateTime();
+ void updateTime() const;
void checkCoherency() const throw(INTERP_KERNEL::Exception);
void setMeshDimension(int meshDim) throw(INTERP_KERNEL::Exception);
void allocateCells(int nbOfCells) throw(INTERP_KERNEL::Exception);
void computeTypes() throw(INTERP_KERNEL::Exception);
std::string reprConnectivityOfThis() const throw(INTERP_KERNEL::Exception);
//tools
+ DataArrayInt *findCellsIdsOnBoundary() const throw(INTERP_KERNEL::Exception);
bool checkConsecutiveCellTypes() const throw(INTERP_KERNEL::Exception);
DataArrayInt *rearrange2ConsecutiveCellTypes() throw(INTERP_KERNEL::Exception);
+ DataArrayInt *sortCellsInMEDFileFrmt() throw(INTERP_KERNEL::Exception);
DataArrayInt *convertCellArrayPerGeoType(const DataArrayInt *da) const throw(INTERP_KERNEL::Exception);
DataArrayInt *zipConnectivityTraducer(int compType) throw(INTERP_KERNEL::Exception);
- void getReverseNodalConnectivity(DataArrayInt *revNodal, DataArrayInt *revNodalIndx) const throw(INTERP_KERNEL::Exception);
MEDCouplingUMesh *buildDescendingConnectivity(DataArrayInt *desc, DataArrayInt *descIndx, DataArrayInt *revDesc, DataArrayInt *revDescIndx) const throw(INTERP_KERNEL::Exception);
void orientCorrectlyPolyhedrons() throw(INTERP_KERNEL::Exception);
bool isPresenceOfQuadratic() const throw(INTERP_KERNEL::Exception);
MEDCouplingFieldDouble *getAspectRatioField() const throw(INTERP_KERNEL::Exception);
MEDCouplingFieldDouble *getWarpField() const throw(INTERP_KERNEL::Exception);
MEDCouplingFieldDouble *getSkewField() const throw(INTERP_KERNEL::Exception);
+ static MEDCouplingUMesh *Build0DMeshFromCoords(DataArrayDouble *da) throw(INTERP_KERNEL::Exception);
static MEDCouplingUMesh *MergeUMeshes(const MEDCouplingUMesh *mesh1, const MEDCouplingUMesh *mesh2) throw(INTERP_KERNEL::Exception);
static MEDCouplingUMesh *MergeUMeshesOnSameCoords(const MEDCouplingUMesh *mesh1, const MEDCouplingUMesh *mesh2) throw(INTERP_KERNEL::Exception);
%extend {
INTERP_KERNEL::AutoPtr<int> tmp=convertPyToNewIntArr2(li,&sz);
self->insertNextCell(type,size,tmp);
}
- DataArrayInt *getNodalConnectivity() const throw(INTERP_KERNEL::Exception)
+ DataArrayInt *getNodalConnectivity() throw(INTERP_KERNEL::Exception)
{
DataArrayInt *ret=self->getNodalConnectivity();
if(ret)
ret->incrRef();
return ret;
}
- DataArrayInt *getNodalConnectivityIndex() const throw(INTERP_KERNEL::Exception)
+ DataArrayInt *getNodalConnectivityIndex() throw(INTERP_KERNEL::Exception)
{
DataArrayInt *ret=self->getNodalConnectivityIndex();
if(ret)
PyObject *keepSpecifiedCells(INTERP_KERNEL::NormalizedCellType type, PyObject *ids) const throw(INTERP_KERNEL::Exception)
{
- std::vector<int> idsPerGeoType;
- convertPyToNewIntArr3(ids,idsPerGeoType);
- MEDCouplingUMesh *ret=self->keepSpecifiedCells(type,idsPerGeoType);
+ int size;
+ INTERP_KERNEL::AutoPtr<int> tmp=convertPyToNewIntArr2(ids,&size);
+ MEDCouplingUMesh *ret=self->keepSpecifiedCells(type,tmp,tmp+size);
return SWIG_NewPointerObj(SWIG_as_voidptr(ret),SWIGTYPE_p_ParaMEDMEM__MEDCouplingUMesh, SWIG_POINTER_OWN | 0 );
}
return ret;
}
- PyObject *getCellsContainingPoints(PyObject *p, int nbOfPoints, double eps) const throw(INTERP_KERNEL::Exception)
+ PyObject *getLevArrPerCellTypes(PyObject *li) const throw(INTERP_KERNEL::Exception)
{
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));
+ INTERP_KERNEL::AutoPtr<INTERP_KERNEL::NormalizedCellType> order=(INTERP_KERNEL::NormalizedCellType *)convertPyToNewIntArr2(li,&sz);
+ DataArrayInt *tmp0,*tmp1=0;
+ tmp0=self->getLevArrPerCellTypes(order,(INTERP_KERNEL::NormalizedCellType *)order+sz,tmp1);
+ PyObject *ret=PyTuple_New(2);
+ PyTuple_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(tmp0),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 ));
+ PyTuple_SetItem(ret,1,SWIG_NewPointerObj(SWIG_as_voidptr(tmp1),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 ));
return ret;
}
- PyObject *getCellsContainingPoint(PyObject *p, double eps) const throw(INTERP_KERNEL::Exception)
- {
- 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<const ParaMEDMEM::MEDCouplingUMesh *> meshes;
d3->incrRef();
return ret;
}
+
+ PyObject *emulateMEDMEMBDC(const MEDCouplingUMesh *nM1LevMesh)
+ {
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> d0=DataArrayInt::New();
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> d1=DataArrayInt::New();
+ DataArrayInt *d2,*d3,*d4,*dd5;
+ MEDCouplingUMesh *mOut=self->emulateMEDMEMBDC(nM1LevMesh,d0,d1,d2,d3,d4,dd5);
+ PyObject *ret=PyTuple_New(7);
+ PyTuple_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(mOut),SWIGTYPE_p_ParaMEDMEM__MEDCouplingUMesh, SWIG_POINTER_OWN | 0 ));
+ PyTuple_SetItem(ret,1,SWIG_NewPointerObj(SWIG_as_voidptr((DataArrayInt *)d0),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 ));
+ PyTuple_SetItem(ret,2,SWIG_NewPointerObj(SWIG_as_voidptr((DataArrayInt *)d1),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 ));
+ PyTuple_SetItem(ret,3,SWIG_NewPointerObj(SWIG_as_voidptr(d2),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 ));
+ PyTuple_SetItem(ret,4,SWIG_NewPointerObj(SWIG_as_voidptr(d3),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 ));
+ PyTuple_SetItem(ret,5,SWIG_NewPointerObj(SWIG_as_voidptr(d4),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 ));
+ PyTuple_SetItem(ret,6,SWIG_NewPointerObj(SWIG_as_voidptr(dd5),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 ));
+ d0->incrRef();
+ d1->incrRef();
+ return ret;
+ }
+
+ PyObject *getReverseNodalConnectivity() const throw(INTERP_KERNEL::Exception)
+ {
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> d0=DataArrayInt::New();
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> d1=DataArrayInt::New();
+ self->getReverseNodalConnectivity(d0,d1);
+ PyObject *ret=PyTuple_New(2);
+ PyTuple_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(d0),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 ));
+ PyTuple_SetItem(ret,1,SWIG_NewPointerObj(SWIG_as_voidptr(d1),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 ));
+ d0->incrRef();
+ d1->incrRef();
+ return ret;
+ }
+
+ DataArrayDouble *getPartBarycenterAndOwner(DataArrayInt *da) const throw(INTERP_KERNEL::Exception)
+ {
+ if(!da)
+ throw INTERP_KERNEL::Exception("Not null DataArrayInt instance expected !");
+ da->checkAllocated();
+ return self->getPartBarycenterAndOwner(da->getConstPointer(),da->getConstPointer()+da->getNbOfElems());
+ }
+
+ DataArrayDouble *getPartMeasureField(bool isAbs, DataArrayInt *da) const throw(INTERP_KERNEL::Exception)
+ {
+ if(!da)
+ throw INTERP_KERNEL::Exception("Not null DataArrayInt instance expected !");
+ da->checkAllocated();
+ return self->getPartMeasureField(isAbs,da->getConstPointer(),da->getConstPointer()+da->getNbOfElems());
+ }
+
+ MEDCouplingFieldDouble *buildPartOrthogonalField(DataArrayInt *da) const throw(INTERP_KERNEL::Exception)
+ {
+ if(!da)
+ throw INTERP_KERNEL::Exception("Not null DataArrayInt instance expected !");
+ da->checkAllocated();
+ return self->buildPartOrthogonalField(da->getConstPointer(),da->getConstPointer()+da->getNbOfElems());
+ }
+
+ PyObject *getTypesOfPart(DataArrayInt *da) const throw(INTERP_KERNEL::Exception)
+ {
+ if(!da)
+ throw INTERP_KERNEL::Exception("Not null DataArrayInt instance expected !");
+ da->checkAllocated();
+ std::set<INTERP_KERNEL::NormalizedCellType> result=self->getTypesOfPart(da->getConstPointer(),da->getConstPointer()+da->getNbOfElems());
+ std::set<INTERP_KERNEL::NormalizedCellType>::const_iterator iL=result.begin();
+ PyObject *res = PyList_New(result.size());
+ for (int i=0;iL!=result.end(); i++, iL++)
+ PyList_SetItem(res,i,PyInt_FromLong(*iL));
+ return res;
+ }
+
+ DataArrayInt *keepCellIdsByType(INTERP_KERNEL::NormalizedCellType type, DataArrayInt *da) const throw(INTERP_KERNEL::Exception)
+ {
+ if(!da)
+ throw INTERP_KERNEL::Exception("Not null DataArrayInt instance expected !");
+ da->checkAllocated();
+ DataArrayInt *ret=self->keepCellIdsByType(type,da->getConstPointer(),da->getConstPointer()+da->getNbOfElems());
+ ret->setName(da->getName().c_str());
+ return ret;
+ }
+
+ DataArrayInt *getCellIdsLyingOnNodes(PyObject *li, bool fullyIn) const throw(INTERP_KERNEL::Exception)
+ {
+ void *da=0;
+ int res1=SWIG_ConvertPtr(li,&da,SWIGTYPE_p_ParaMEDMEM__DataArrayInt, 0 | 0 );
+ if (!SWIG_IsOK(res1))
+ {
+ int size;
+ INTERP_KERNEL::AutoPtr<int> tmp=convertPyToNewIntArr2(li,&size);
+ return self->getCellIdsLyingOnNodes(tmp,((const int *)tmp)+size,fullyIn);
+ }
+ else
+ {
+ DataArrayInt *da2=reinterpret_cast< DataArrayInt * >(da);
+ if(!da2)
+ throw INTERP_KERNEL::Exception("Not null DataArrayInt instance expected !");
+ da2->checkAllocated();
+ return self->getCellIdsLyingOnNodes(da2->getConstPointer(),da2->getConstPointer()+da2->getNbOfElems(),fullyIn);
+ }
+ }
}
void convertToPolyTypes(const std::vector<int>& cellIdsToConvert) throw(INTERP_KERNEL::Exception);
+ void convertAllToPoly();
void unPolyze() throw(INTERP_KERNEL::Exception);
MEDCouplingUMesh *buildExtrudedMesh(const MEDCouplingUMesh *mesh1D, int policy) throw(INTERP_KERNEL::Exception);
};
{
public:
static MEDCouplingCMesh *New();
- void setCoords(DataArrayDouble *coordsX,
- DataArrayDouble *coordsY=0,
- DataArrayDouble *coordsZ=0) throw(INTERP_KERNEL::Exception);
- void setCoordsAt(int i, DataArrayDouble *arr) throw(INTERP_KERNEL::Exception);
+ void setCoords(const DataArrayDouble *coordsX,
+ const DataArrayDouble *coordsY=0,
+ const DataArrayDouble *coordsZ=0) throw(INTERP_KERNEL::Exception);
+ void setCoordsAt(int i, const DataArrayDouble *arr) throw(INTERP_KERNEL::Exception);
%extend {
std::string __str__() const
{
return self->simpleRepr();
}
- DataArrayDouble *getCoordsAt(int i) const throw(INTERP_KERNEL::Exception)
+ DataArrayDouble *getCoordsAt(int i) throw(INTERP_KERNEL::Exception)
{
DataArrayDouble *ret=self->getCoordsAt(i);
if(ret)
DataArrayDouble *renumber(PyObject *li) throw(INTERP_KERNEL::Exception)
{
- int size;
- INTERP_KERNEL::AutoPtr<int> tmp=convertPyToNewIntArr2(li,&size);
- if(size!=self->getNumberOfTuples())
+ void *da=0;
+ int res1=SWIG_ConvertPtr(li,&da,SWIGTYPE_p_ParaMEDMEM__DataArrayInt, 0 | 0 );
+ if (!SWIG_IsOK(res1))
{
- throw INTERP_KERNEL::Exception("Invalid list length ! Must be equal to number of tuples !");
+ int size;
+ INTERP_KERNEL::AutoPtr<int> tmp=convertPyToNewIntArr2(li,&size);
+ if(size!=self->getNumberOfTuples())
+ {
+ throw INTERP_KERNEL::Exception("Invalid list length ! Must be equal to number of tuples !");
+ }
+ return self->renumber(tmp);
+ }
+ else
+ {
+ DataArrayInt *da2=reinterpret_cast< DataArrayInt * >(da);
+ if(!da2)
+ throw INTERP_KERNEL::Exception("Not null DataArrayInt instance expected !");
+ da2->checkAllocated();
+ int size=self->getNumberOfTuples();
+ if(size!=self->getNumberOfTuples())
+ {
+ throw INTERP_KERNEL::Exception("Invalid list length ! Must be equal to number of tuples !");
+ }
+ return self->renumber(da2->getConstPointer());
}
- DataArrayDouble *ret=self->renumber(tmp);
- return ret;
}
DataArrayDouble *renumberR(PyObject *li) throw(INTERP_KERNEL::Exception)
{
- int size;
- INTERP_KERNEL::AutoPtr<int> tmp=convertPyToNewIntArr2(li,&size);
- if(size!=self->getNumberOfTuples())
+ void *da=0;
+ int res1=SWIG_ConvertPtr(li,&da,SWIGTYPE_p_ParaMEDMEM__DataArrayInt, 0 | 0 );
+ if (!SWIG_IsOK(res1))
+ {
+ int size;
+ INTERP_KERNEL::AutoPtr<int> tmp=convertPyToNewIntArr2(li,&size);
+ if(size!=self->getNumberOfTuples())
+ {
+ throw INTERP_KERNEL::Exception("Invalid list length ! Must be equal to number of tuples !");
+ }
+ return self->renumberR(tmp);
+ }
+ else
{
- throw INTERP_KERNEL::Exception("Invalid list length ! Must be equal to number of tuples !");
+ DataArrayInt *da2=reinterpret_cast< DataArrayInt * >(da);
+ if(!da2)
+ throw INTERP_KERNEL::Exception("Not null DataArrayInt instance expected !");
+ da2->checkAllocated();
+ int size=self->getNumberOfTuples();
+ if(size!=self->getNumberOfTuples())
+ {
+ throw INTERP_KERNEL::Exception("Invalid list length ! Must be equal to number of tuples !");
+ }
+ return self->renumberR(da2->getConstPointer());
}
- DataArrayDouble *ret=self->renumberR(tmp);
- return ret;
}
DataArrayDouble *renumberAndReduce(PyObject *li, int newNbOfTuple) throw(INTERP_KERNEL::Exception)
{
- int size;
- INTERP_KERNEL::AutoPtr<int> tmp=convertPyToNewIntArr2(li,&size);
- if(size!=self->getNumberOfTuples())
+ void *da=0;
+ int res1=SWIG_ConvertPtr(li,&da,SWIGTYPE_p_ParaMEDMEM__DataArrayInt, 0 | 0 );
+ if (!SWIG_IsOK(res1))
+ {
+ int size;
+ INTERP_KERNEL::AutoPtr<int> tmp=convertPyToNewIntArr2(li,&size);
+ if(size!=self->getNumberOfTuples())
+ {
+ throw INTERP_KERNEL::Exception("Invalid list length ! Must be equal to number of tuples !");
+ }
+ return self->renumberAndReduce(tmp,newNbOfTuple);
+ }
+ else
{
- throw INTERP_KERNEL::Exception("Invalid list length ! Must be equal to number of tuples !");
+ DataArrayInt *da2=reinterpret_cast< DataArrayInt * >(da);
+ if(!da2)
+ throw INTERP_KERNEL::Exception("Not null DataArrayInt instance expected !");
+ da2->checkAllocated();
+ int size=self->getNumberOfTuples();
+ if(size!=self->getNumberOfTuples())
+ {
+ throw INTERP_KERNEL::Exception("Invalid list length ! Must be equal to number of tuples !");
+ }
+ return self->renumberAndReduce(da2->getConstPointer(),newNbOfTuple);
}
- DataArrayDouble *ret=self->renumberAndReduce(tmp,newNbOfTuple);
- return ret;
}
void renumberInPlace(PyObject *li) throw(INTERP_KERNEL::Exception)
{
- int size;
- INTERP_KERNEL::AutoPtr<int> tmp=convertPyToNewIntArr2(li,&size);
- if(size!=self->getNumberOfTuples())
+ void *da=0;
+ int res1=SWIG_ConvertPtr(li,&da,SWIGTYPE_p_ParaMEDMEM__DataArrayInt, 0 | 0 );
+ if (!SWIG_IsOK(res1))
+ {
+ int size;
+ INTERP_KERNEL::AutoPtr<int> tmp=convertPyToNewIntArr2(li,&size);
+ if(size!=self->getNumberOfTuples())
+ {
+ throw INTERP_KERNEL::Exception("Invalid list length ! Must be equal to number of tuples !");
+ }
+ self->renumberInPlace(tmp);
+ }
+ else
{
- throw INTERP_KERNEL::Exception("Invalid list length ! Must be equal to number of tuples !");
+ DataArrayInt *da2=reinterpret_cast< DataArrayInt * >(da);
+ if(!da2)
+ throw INTERP_KERNEL::Exception("Not null DataArrayInt instance expected !");
+ da2->checkAllocated();
+ int size=self->getNumberOfTuples();
+ if(size!=self->getNumberOfTuples())
+ {
+ throw INTERP_KERNEL::Exception("Invalid list length ! Must be equal to number of tuples !");
+ }
+ self->renumberInPlace(da2->getConstPointer());
}
- self->renumberInPlace(tmp);
}
void renumberInPlaceR(PyObject *li) throw(INTERP_KERNEL::Exception)
{
- int size;
- INTERP_KERNEL::AutoPtr<int> tmp=convertPyToNewIntArr2(li,&size);
- if(size!=self->getNumberOfTuples())
+ void *da=0;
+ int res1=SWIG_ConvertPtr(li,&da,SWIGTYPE_p_ParaMEDMEM__DataArrayInt, 0 | 0 );
+ if (!SWIG_IsOK(res1))
+ {
+ int size;
+ INTERP_KERNEL::AutoPtr<int> tmp=convertPyToNewIntArr2(li,&size);
+ if(size!=self->getNumberOfTuples())
+ {
+ throw INTERP_KERNEL::Exception("Invalid list length ! Must be equal to number of tuples !");
+ }
+ self->renumberInPlaceR(tmp);
+ }
+ else
{
- throw INTERP_KERNEL::Exception("Invalid list length ! Must be equal to number of tuples !");
+ DataArrayInt *da2=reinterpret_cast< DataArrayInt * >(da);
+ if(!da2)
+ throw INTERP_KERNEL::Exception("Not null DataArrayInt instance expected !");
+ da2->checkAllocated();
+ int size=self->getNumberOfTuples();
+ if(size!=self->getNumberOfTuples())
+ {
+ throw INTERP_KERNEL::Exception("Invalid list length ! Must be equal to number of tuples !");
+ }
+ self->renumberInPlaceR(da2->getConstPointer());
}
- self->renumberInPlaceR(tmp);
}
DataArrayDouble *selectByTupleId(PyObject *li) const throw(INTERP_KERNEL::Exception)
{
- int size;
- INTERP_KERNEL::AutoPtr<int> tmp=convertPyToNewIntArr2(li,&size);
- DataArrayDouble *ret=self->selectByTupleId(tmp,tmp+size);
- return ret;
+ void *da=0;
+ int res1=SWIG_ConvertPtr(li,&da,SWIGTYPE_p_ParaMEDMEM__DataArrayInt, 0 | 0 );
+ if (!SWIG_IsOK(res1))
+ {
+ int size;
+ INTERP_KERNEL::AutoPtr<int> tmp=convertPyToNewIntArr2(li,&size);
+ return self->selectByTupleId(tmp,tmp+size);
+ }
+ else
+ {
+ DataArrayInt *da2=reinterpret_cast< DataArrayInt * >(da);
+ if(!da2)
+ throw INTERP_KERNEL::Exception("Not null DataArrayInt instance expected !");
+ da2->checkAllocated();
+ return self->selectByTupleId(da2->getConstPointer(),da2->getConstPointer()+da2->getNbOfElems());
+ }
}
DataArrayDouble *selectByTupleIdSafe(PyObject *li) const throw(INTERP_KERNEL::Exception)
{
- int size;
- INTERP_KERNEL::AutoPtr<int> tmp=convertPyToNewIntArr2(li,&size);
- DataArrayDouble *ret=self->selectByTupleIdSafe(tmp,tmp+size);
- return ret;
+ void *da=0;
+ int res1=SWIG_ConvertPtr(li,&da,SWIGTYPE_p_ParaMEDMEM__DataArrayInt, 0 | 0 );
+ if (!SWIG_IsOK(res1))
+ {
+ int size;
+ INTERP_KERNEL::AutoPtr<int> tmp=convertPyToNewIntArr2(li,&size);
+ return self->selectByTupleIdSafe(tmp,tmp+size);
+ }
+ else
+ {
+ DataArrayInt *da2=reinterpret_cast< DataArrayInt * >(da);
+ if(!da2)
+ throw INTERP_KERNEL::Exception("Not null DataArrayInt instance expected !");
+ da2->checkAllocated();
+ return self->selectByTupleIdSafe(da2->getConstPointer(),da2->getConstPointer()+da2->getNbOfElems());
+ }
}
PyObject *getMaxValue() const throw(INTERP_KERNEL::Exception)
convertPyObjToVecDataArrayDblCst(li,tmp);
return DataArrayDouble::Meld(tmp);
}
- };
-
-%extend ParaMEDMEM::DataArrayInt
- {
- std::string __str__() const
- {
- return self->repr();
- }
-
- PyObject *getDifferentValues(bool val) const throw(INTERP_KERNEL::Exception)
- {
- std::set<int> ret=self->getDifferentValues();
- return convertIntArrToPyList3(ret);
- }
- void setValues(PyObject *li, int nbOfTuples, int nbOfElsPerTuple) throw(INTERP_KERNEL::Exception)
+ DataArrayDouble *__getitem__(PyObject *obj) throw(INTERP_KERNEL::Exception)
{
- int *tmp=new int[nbOfTuples*nbOfElsPerTuple];
- try
- {
- fillArrayWithPyListInt(li,tmp,nbOfTuples*nbOfElsPerTuple,0.);
- }
- catch(INTERP_KERNEL::Exception& e)
+ const char msg[]="Unexpected situation in __getitem__ !";
+ self->checkAllocated();
+ int nbOfTuples=self->getNumberOfTuples();
+ int nbOfComponents=self->getNumberOfComponents();
+ int it1,ic1;
+ std::vector<int> vt1,vc1;
+ std::pair<int, std::pair<int,int> > pt1,pc1;
+ DataArrayInt *dt1=0,*dc1=0;
+ int sw;
+ convertObjToPossibleCpp3(obj,nbOfTuples,nbOfComponents,sw,it1,ic1,vt1,vc1,pt1,pc1,dt1,dc1);
+ MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> ret;
+ switch(sw)
{
- delete [] tmp;
- throw e;
+ case 1:
+ return self->selectByTupleIdSafe(&it1,&it1+1);
+ case 2:
+ return self->selectByTupleIdSafe(&vt1[0],&vt1[0]+vt1.size());
+ case 3:
+ return self->selectByTupleId2(pt1.first,pt1.second.first,pt1.second.second);
+ case 4:
+ return self->selectByTupleIdSafe(dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems());
+ case 5:
+ {
+ ret=self->selectByTupleIdSafe(&it1,&it1+1);
+ std::vector<int> v2(1,ic1);
+ return ret->keepSelectedComponents(v2);
+ }
+ case 6:
+ {
+ ret=self->selectByTupleIdSafe(&vt1[0],&vt1[0]+vt1.size());
+ std::vector<int> v2(1,ic1);
+ return ret->keepSelectedComponents(v2);
+ }
+ case 7:
+ {
+ ret=self->selectByTupleId2(pt1.first,pt1.second.first,pt1.second.second);
+ std::vector<int> v2(1,ic1);
+ return ret->keepSelectedComponents(v2);
+ }
+ case 8:
+ {
+ ret=self->selectByTupleIdSafe(dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems());
+ std::vector<int> v2(1,ic1);
+ return ret->keepSelectedComponents(v2);
+ }
+ case 9:
+ {
+ ret=self->selectByTupleIdSafe(&it1,&it1+1);
+ return ret->keepSelectedComponents(vc1);
+ }
+ case 10:
+ {
+ ret=self->selectByTupleIdSafe(&vt1[0],&vt1[0]+vt1.size());
+ return ret->keepSelectedComponents(vc1);
+ }
+ case 11:
+ {
+ ret=self->selectByTupleId2(pt1.first,pt1.second.first,pt1.second.second);
+ return ret->keepSelectedComponents(vc1);
+ }
+ case 12:
+ {
+ ret=self->selectByTupleIdSafe(dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems());
+ return ret->keepSelectedComponents(vc1);
+ }
+ case 13:
+ {
+ ret=self->selectByTupleIdSafe(&it1,&it1+1);
+ int nbOfComp=(pc1.second.first-1-pc1.first)/pc1.second.second+1;
+ std::vector<int> v2(nbOfComp);
+ for(int i=0;i<nbOfComp;i++)
+ v2[i]=pc1.first+i*pc1.second.second;
+ return ret->keepSelectedComponents(v2);
+ }
+ case 14:
+ {
+ ret=self->selectByTupleIdSafe(&vt1[0],&vt1[0]+vt1.size());
+ int nbOfComp=(pc1.second.first-1-pc1.first)/pc1.second.second+1;
+ std::vector<int> v2(nbOfComp);
+ for(int i=0;i<nbOfComp;i++)
+ v2[i]=pc1.first+i*pc1.second.second;
+ return ret->keepSelectedComponents(v2);
+ }
+ case 15:
+ {
+ ret=self->selectByTupleId2(pt1.first,pt1.second.first,pt1.second.second);
+ int nbOfComp=(pc1.second.first-1-pc1.first)/pc1.second.second+1;
+ std::vector<int> v2(nbOfComp);
+ for(int i=0;i<nbOfComp;i++)
+ v2[i]=pc1.first+i*pc1.second.second;
+ return ret->keepSelectedComponents(v2);
+ }
+ case 16:
+ {
+ ret=self->selectByTupleIdSafe(dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems());
+ int nbOfComp=(pc1.second.first-1-pc1.first)/pc1.second.second+1;
+ std::vector<int> v2(nbOfComp);
+ for(int i=0;i<nbOfComp;i++)
+ v2[i]=pc1.first+i*pc1.second.second;
+ return ret->keepSelectedComponents(v2);
+ }
+ default:
+ throw INTERP_KERNEL::Exception(msg);
}
- self->useArray(tmp,true,CPP_DEALLOC,nbOfTuples,nbOfElsPerTuple);
- }
-
- PyObject *getValues() throw(INTERP_KERNEL::Exception)
- {
- const int *vals=self->getPointer();
- return convertIntArrToPyList(vals,self->getNbOfElems());
}
- PyObject *getValuesAsTuple() throw(INTERP_KERNEL::Exception)
+ DataArrayDouble *__setitem__(PyObject *obj, PyObject *value) throw(INTERP_KERNEL::Exception)
{
- const int *vals=self->getPointer();
- int nbOfComp=self->getNumberOfComponents();
+ self->checkAllocated();
+ const char msg[]="Unexpected situation in __setitem__ !";
int nbOfTuples=self->getNumberOfTuples();
- return convertIntArrToPyListOfTuple(vals,nbOfComp,nbOfTuples);
- }
-
- static PyObject *MakePartition(PyObject *gps, int newNb) throw(INTERP_KERNEL::Exception)
- {
- std::vector<const DataArrayInt *> groups;
- std::vector< std::vector<int> > fidsOfGroups;
- convertPyObjToVecDataArrayIntCst(gps,groups);
- ParaMEDMEM::DataArrayInt *ret0=ParaMEDMEM::DataArrayInt::MakePartition(groups,newNb,fidsOfGroups);
- PyObject *ret = PyList_New(2);
- PyList_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(ret0),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 ));
+ int nbOfComponents=self->getNumberOfComponents();
+ int sw1,sw2;
+ double i1;
+ std::vector<double> v1;
+ DataArrayDouble *d1=0;
+ convertObjToPossibleCpp4(value,sw1,i1,v1,d1);
+ int it1,ic1;
+ std::vector<int> vt1,vc1;
+ std::pair<int, std::pair<int,int> > pt1,pc1;
+ DataArrayInt *dt1=0,*dc1=0;
+ convertObjToPossibleCpp3(obj,nbOfTuples,nbOfComponents,sw2,it1,ic1,vt1,vc1,pt1,pc1,dt1,dc1);
+ MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> tmp;
+ switch(sw2)
+ {
+ case 1:
+ {
+ switch(sw1)
+ {
+ case 1:
+ self->setPartOfValuesSimple1(i1,it1,it1+1,1,0,nbOfComponents,1);
+ return self;
+ case 2:
+ tmp=DataArrayDouble::New();
+ tmp->useArray(&v1[0],false,CPP_DEALLOC,v1.size(),1);
+ self->setPartOfValues1(tmp,it1,it1+1,1,0,nbOfComponents,1,false);
+ return self;
+ case 3:
+ self->setPartOfValues1(d1,it1,it1+1,1,0,nbOfComponents,1);
+ return self;
+ default:
+ throw INTERP_KERNEL::Exception(msg);
+ }
+ break;
+ }
+ case 2:
+ {
+ switch(sw1)
+ {
+ case 1:
+ self->setPartOfValuesSimple3(i1,&vt1[0],&vt1[0]+vt1.size(),0,nbOfComponents,1);
+ return self;
+ case 2:
+ tmp=DataArrayDouble::New();
+ tmp->useArray(&v1[0],false,CPP_DEALLOC,v1.size(),1);
+ self->setPartOfValues3(tmp,&vt1[0],&vt1[0]+vt1.size(),0,nbOfComponents,1,false);
+ return self;
+ case 3:
+ self->setPartOfValues3(d1,&vt1[0],&vt1[0]+vt1.size(),0,nbOfComponents,1);
+ return self;
+ default:
+ throw INTERP_KERNEL::Exception(msg);
+ }
+ break;
+ }
+ case 3:
+ {
+ switch(sw1)
+ {
+ case 1:
+ self->setPartOfValuesSimple1(i1,pt1.first,pt1.second.first,pt1.second.second,0,nbOfComponents,1);
+ return self;
+ case 2:
+ tmp=DataArrayDouble::New();
+ tmp->useArray(&v1[0],false,CPP_DEALLOC,v1.size(),1);
+ self->setPartOfValues1(tmp,pt1.first,pt1.second.first,pt1.second.second,0,nbOfComponents,1,false);
+ return self;
+ case 3:
+ self->setPartOfValues1(d1,pt1.first,pt1.second.first,pt1.second.second,0,nbOfComponents,1);
+ return self;
+ default:
+ throw INTERP_KERNEL::Exception(msg);
+ }
+ break;
+ }
+ case 4:
+ {
+ switch(sw1)
+ {
+ case 1:
+ self->setPartOfValuesSimple3(i1,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),0,nbOfComponents,1);
+ return self;
+ case 2:
+ tmp=DataArrayDouble::New();
+ tmp->useArray(&v1[0],false,CPP_DEALLOC,v1.size(),1);
+ self->setPartOfValues3(tmp,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),0,nbOfComponents,1,false);
+ return self;
+ case 3:
+ self->setPartOfValues3(d1,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),0,nbOfComponents,1);
+ return self;
+ default:
+ throw INTERP_KERNEL::Exception(msg);
+ }
+ break;
+ }
+ case 5:
+ {
+ switch(sw1)
+ {
+ case 1:
+ self->setPartOfValuesSimple1(i1,it1,it1+1,1,ic1,ic1+1,1);
+ return self;
+ case 2:
+ tmp=DataArrayDouble::New();
+ tmp->useArray(&v1[0],false,CPP_DEALLOC,v1.size(),1);
+ self->setPartOfValues1(tmp,it1,it1+1,1,ic1,ic1+1,1,false);
+ return self;
+ case 3:
+ self->setPartOfValues1(d1,it1,it1+1,1,ic1,ic1+1,1);
+ return self;
+ default:
+ throw INTERP_KERNEL::Exception(msg);
+ }
+ break;
+ }
+ case 6:
+ {
+ switch(sw1)
+ {
+ case 1:
+ self->setPartOfValuesSimple3(i1,&vt1[0],&vt1[0]+vt1.size(),ic1,ic1+1,1);
+ return self;
+ case 2:
+ tmp=DataArrayDouble::New();
+ tmp->useArray(&v1[0],false,CPP_DEALLOC,v1.size(),1);
+ self->setPartOfValues3(tmp,&vt1[0],&vt1[0]+vt1.size(),ic1,ic1+1,1,false);
+ return self;
+ case 3:
+ self->setPartOfValues3(d1,&vt1[0],&vt1[0]+vt1.size(),ic1,ic1+1,1);
+ return self;
+ default:
+ throw INTERP_KERNEL::Exception(msg);
+ }
+ break;
+ }
+ case 7:
+ {
+ switch(sw1)
+ {
+ case 1:
+ self->setPartOfValuesSimple1(i1,pt1.first,pt1.second.first,pt1.second.second,ic1,ic1+1,1);
+ return self;
+ case 2:
+ tmp=DataArrayDouble::New();
+ tmp->useArray(&v1[0],false,CPP_DEALLOC,v1.size(),1);
+ self->setPartOfValues1(tmp,pt1.first,pt1.second.first,pt1.second.second,ic1,ic1+1,1,false);
+ return self;
+ case 3:
+ self->setPartOfValues1(d1,pt1.first,pt1.second.first,pt1.second.second,ic1,ic1+1,1);
+ return self;
+ default:
+ throw INTERP_KERNEL::Exception(msg);
+ }
+ break;
+ }
+ case 8:
+ {
+ switch(sw1)
+ {
+ case 1:
+ self->setPartOfValuesSimple3(i1,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),ic1,ic1+1,1);
+ return self;
+ case 2:
+ tmp=DataArrayDouble::New();
+ tmp->useArray(&v1[0],false,CPP_DEALLOC,v1.size(),1);
+ self->setPartOfValues3(tmp,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),ic1,ic1+1,1,false);
+ return self;
+ case 3:
+ self->setPartOfValues3(d1,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),ic1,ic1+1,1);
+ return self;
+ default:
+ throw INTERP_KERNEL::Exception(msg);
+ }
+ break;
+ }
+ case 9:
+ {
+ switch(sw1)
+ {
+ case 1:
+ self->setPartOfValuesSimple2(i1,&it1,&it1+1,&vc1[0],&vc1[0]+vc1.size());
+ return self;
+ case 2:
+ tmp=DataArrayDouble::New();
+ tmp->useArray(&v1[0],false,CPP_DEALLOC,v1.size(),1);
+ self->setPartOfValues2(tmp,&it1,&it1+1,&vc1[0],&vc1[0]+vc1.size(),false);
+ return self;
+ case 3:
+ self->setPartOfValues2(d1,&it1,&it1+1,&vc1[0],&vc1[0]+vc1.size());
+ return self;
+ default:
+ throw INTERP_KERNEL::Exception(msg);
+ }
+ break;
+ }
+ case 10:
+ {
+ switch(sw1)
+ {
+ case 1:
+ self->setPartOfValuesSimple2(i1,&vt1[0],&vt1[0]+vt1.size(),&vc1[0],&vc1[0]+vc1.size());
+ return self;
+ case 2:
+ tmp=DataArrayDouble::New();
+ tmp->useArray(&v1[0],false,CPP_DEALLOC,v1.size(),1);
+ self->setPartOfValues2(tmp,&vt1[0],&vt1[0]+vt1.size(),&vc1[0],&vc1[0]+vc1.size(),false);
+ return self;
+ case 3:
+ self->setPartOfValues2(d1,&vt1[0],&vt1[0]+vt1.size(),&vc1[0],&vc1[0]+vc1.size());
+ return self;
+ default:
+ throw INTERP_KERNEL::Exception(msg);
+ }
+ break;
+ }
+ case 11:
+ {
+ int bb=pt1.first;
+ int ee=pt1.second.first;
+ int ss=pt1.second.second;
+ if(ee<bb || ss<=0)
+ throw INTERP_KERNEL::Exception("Invalid slice in tuple selection");
+ int nbOfE=(ee-bb)/ss;
+ std::vector<int> nv(nbOfE);
+ for(int jj=0;jj<nbOfE;jj++)
+ nv[jj]=bb+jj*ss;
+ switch(sw1)
+ {
+ case 1:
+ self->setPartOfValuesSimple2(i1,&nv[0],&nv[0]+nv.size(),&vc1[0],&vc1[0]+vc1.size());
+ return self;
+ case 2:
+ tmp=DataArrayDouble::New();
+ tmp->useArray(&v1[0],false,CPP_DEALLOC,v1.size(),1);
+ self->setPartOfValues2(tmp,&nv[0],&nv[0]+nv.size(),&vc1[0],&vc1[0]+vc1.size(),false);
+ return self;
+ case 3:
+ self->setPartOfValues2(d1,&nv[0],&nv[0]+nv.size(),&vc1[0],&vc1[0]+vc1.size());
+ return self;
+ default:
+ throw INTERP_KERNEL::Exception(msg);
+ }
+ break;
+ }
+ case 12:
+ {
+ switch(sw1)
+ {
+ case 1:
+ self->setPartOfValuesSimple2(i1,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),&vc1[0],&vc1[0]+vc1.size());
+ return self;
+ case 2:
+ tmp=DataArrayDouble::New();
+ tmp->useArray(&v1[0],false,CPP_DEALLOC,v1.size(),1);
+ self->setPartOfValues2(tmp,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),&vc1[0],&vc1[0]+vc1.size(),false);
+ return self;
+ case 3:
+ self->setPartOfValues2(d1,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),&vc1[0],&vc1[0]+vc1.size());
+ return self;
+ default:
+ throw INTERP_KERNEL::Exception(msg);
+ }
+ break;
+ }
+ case 13:
+ {
+ switch(sw1)
+ {
+ case 1:
+ self->setPartOfValuesSimple1(i1,it1,it1+1,1,pc1.first,pc1.second.first,pc1.second.second);
+ return self;
+ case 2:
+ tmp=DataArrayDouble::New();
+ tmp->useArray(&v1[0],false,CPP_DEALLOC,v1.size(),1);
+ self->setPartOfValues1(tmp,it1,it1+1,1,pc1.first,pc1.second.first,pc1.second.second,false);
+ return self;
+ case 3:
+ self->setPartOfValues1(d1,it1,it1+1,1,pc1.first,pc1.second.first,pc1.second.second);
+ return self;
+ default:
+ throw INTERP_KERNEL::Exception(msg);
+ }
+ break;
+ }
+ case 14:
+ {
+ switch(sw1)
+ {
+ case 1:
+ self->setPartOfValuesSimple3(i1,&vt1[0],&vt1[0]+vt1.size(),pc1.first,pc1.second.first,pc1.second.second);
+ return self;
+ case 2:
+ tmp=DataArrayDouble::New();
+ tmp->useArray(&v1[0],false,CPP_DEALLOC,v1.size(),1);
+ self->setPartOfValues3(tmp,&vt1[0],&vt1[0]+vt1.size(),pc1.first,pc1.second.first,pc1.second.second,false);
+ return self;
+ case 3:
+ self->setPartOfValues3(d1,&vt1[0],&vt1[0]+vt1.size(),pc1.first,pc1.second.first,pc1.second.second);
+ return self;
+ default:
+ throw INTERP_KERNEL::Exception(msg);
+ }
+ break;
+ }
+ case 15:
+ {
+ switch(sw1)
+ {
+ case 1:
+ self->setPartOfValuesSimple1(i1,pt1.first,pt1.second.first,pt1.second.second,pc1.first,pc1.second.first,pc1.second.second);
+ return self;
+ case 2:
+ tmp=DataArrayDouble::New();
+ tmp->useArray(&v1[0],false,CPP_DEALLOC,v1.size(),1);
+ self->setPartOfValues1(tmp,pt1.first,pt1.second.first,pt1.second.second,pc1.first,pc1.second.first,pc1.second.second,false);
+ return self;
+ case 3:
+ self->setPartOfValues1(d1,pt1.first,pt1.second.first,pt1.second.second,pc1.first,pc1.second.first,pc1.second.second);
+ return self;
+ default:
+ throw INTERP_KERNEL::Exception(msg);
+ }
+ break;
+ }
+ case 16:
+ {
+ switch(sw1)
+ {
+ case 1:
+ self->setPartOfValuesSimple3(i1,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),pc1.first,pc1.second.first,pc1.second.second);
+ return self;
+ case 2:
+ tmp=DataArrayDouble::New();
+ tmp->useArray(&v1[0],false,CPP_DEALLOC,v1.size(),1);
+ self->setPartOfValues3(tmp,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),pc1.first,pc1.second.first,pc1.second.second,false);
+ return self;
+ case 3:
+ self->setPartOfValues3(d1,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),pc1.first,pc1.second.first,pc1.second.second);
+ return self;
+ default:
+ throw INTERP_KERNEL::Exception(msg);
+ }
+ break;
+ }
+ default:
+ throw INTERP_KERNEL::Exception(msg);
+ }
+ return self;
+ }
+
+ DataArrayDouble *__add__(PyObject *obj) throw(INTERP_KERNEL::Exception)
+ {
+ const char msg[]="Unexpected situation in __add__ !";
+ double val;
+ DataArrayDouble *a;
+ int sw;
+ convertObjToPossibleCpp5(obj,sw,val,a);
+ switch(sw)
+ {
+ case 1:
+ {
+ MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> ret=self->deepCpy();
+ ret->applyLin(1.,val);
+ ret->incrRef();
+ return ret;
+ }
+ case 2:
+ {
+ return DataArrayDouble::Add(self,a);
+ }
+ default:
+ throw INTERP_KERNEL::Exception(msg);
+ }
+ }
+
+ DataArrayDouble *__radd__(PyObject *obj) throw(INTERP_KERNEL::Exception)
+ {
+ const char msg[]="Unexpected situation in __radd__ !";
+ double val;
+ DataArrayDouble *a;
+ int sw;
+ convertObjToPossibleCpp5(obj,sw,val,a);
+ switch(sw)
+ {
+ case 1:
+ {
+ MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> ret=self->deepCpy();
+ ret->applyLin(1.,val);
+ ret->incrRef();
+ return ret;
+ }
+ default:
+ throw INTERP_KERNEL::Exception(msg);
+ }
+ }
+
+ DataArrayDouble *operator+=(PyObject *obj) throw(INTERP_KERNEL::Exception)
+ {
+ const char msg[]="Unexpected situation in __iadd__ !";
+ double val;
+ DataArrayDouble *a;
+ int sw;
+ convertObjToPossibleCpp5(obj,sw,val,a);
+ switch(sw)
+ {
+ case 1:
+ {
+ self->applyLin(1.,val);
+ return self;
+ }
+ case 2:
+ {
+ self->addEqual(a);
+ return self;
+ }
+ default:
+ throw INTERP_KERNEL::Exception(msg);
+ }
+ }
+
+ DataArrayDouble *__sub__(PyObject *obj) throw(INTERP_KERNEL::Exception)
+ {
+ const char msg[]="Unexpected situation in __sub__ !";
+ double val;
+ DataArrayDouble *a;
+ int sw;
+ convertObjToPossibleCpp5(obj,sw,val,a);
+ switch(sw)
+ {
+ case 1:
+ {
+ MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> ret=self->deepCpy();
+ ret->applyLin(1.,-val);
+ ret->incrRef();
+ return ret;
+ }
+ case 2:
+ {
+ return DataArrayDouble::Substract(self,a);
+ }
+ default:
+ throw INTERP_KERNEL::Exception(msg);
+ }
+ }
+
+ DataArrayDouble *__rsub__(PyObject *obj) throw(INTERP_KERNEL::Exception)
+ {
+ const char msg[]="Unexpected situation in __rsub__ !";
+ double val;
+ DataArrayDouble *a;
+ int sw;
+ convertObjToPossibleCpp5(obj,sw,val,a);
+ switch(sw)
+ {
+ case 1:
+ {
+ MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> ret=self->deepCpy();
+ ret->applyLin(-1.,val);
+ ret->incrRef();
+ return ret;
+ }
+ default:
+ throw INTERP_KERNEL::Exception(msg);
+ }
+ }
+
+ DataArrayDouble *operator-=(PyObject *obj) throw(INTERP_KERNEL::Exception)
+ {
+ const char msg[]="Unexpected situation in __isub__ !";
+ double val;
+ DataArrayDouble *a;
+ int sw;
+ convertObjToPossibleCpp5(obj,sw,val,a);
+ switch(sw)
+ {
+ case 1:
+ {
+ self->applyLin(1.,-val);
+ return self;
+ }
+ case 2:
+ {
+ self->substractEqual(a);
+ return self;
+ }
+ default:
+ throw INTERP_KERNEL::Exception(msg);
+ }
+ }
+
+ DataArrayDouble *__mul__(PyObject *obj) throw(INTERP_KERNEL::Exception)
+ {
+ const char msg[]="Unexpected situation in __mul__ !";
+ double val;
+ DataArrayDouble *a;
+ int sw;
+ convertObjToPossibleCpp5(obj,sw,val,a);
+ switch(sw)
+ {
+ case 1:
+ {
+ MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> ret=self->deepCpy();
+ ret->applyLin(val,0.);
+ ret->incrRef();
+ return ret;
+ }
+ case 2:
+ {
+ return DataArrayDouble::Multiply(self,a);
+ }
+ default:
+ throw INTERP_KERNEL::Exception(msg);
+ }
+ }
+
+ DataArrayDouble *__rmul__(PyObject *obj) throw(INTERP_KERNEL::Exception)
+ {
+ const char msg[]="Unexpected situation in __rmul__ !";
+ double val;
+ DataArrayDouble *a;
+ int sw;
+ convertObjToPossibleCpp5(obj,sw,val,a);
+ switch(sw)
+ {
+ case 1:
+ {
+ MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> ret=self->deepCpy();
+ ret->applyLin(val,0.);
+ ret->incrRef();
+ return ret;
+ }
+ default:
+ throw INTERP_KERNEL::Exception(msg);
+ }
+ }
+
+ DataArrayDouble *operator*=(PyObject *obj) throw(INTERP_KERNEL::Exception)
+ {
+ const char msg[]="Unexpected situation in __imul__ !";
+ double val;
+ DataArrayDouble *a;
+ int sw;
+ convertObjToPossibleCpp5(obj,sw,val,a);
+ switch(sw)
+ {
+ case 1:
+ {
+ self->applyLin(val,0.);
+ return self;
+ }
+ case 2:
+ {
+ self->multiplyEqual(a);
+ return self;
+ }
+ default:
+ throw INTERP_KERNEL::Exception(msg);
+ }
+ }
+
+ DataArrayDouble *__div__(PyObject *obj) throw(INTERP_KERNEL::Exception)
+ {
+ const char msg[]="Unexpected situation in __div__ !";
+ double val;
+ DataArrayDouble *a;
+ int sw;
+ convertObjToPossibleCpp5(obj,sw,val,a);
+ switch(sw)
+ {
+ case 1:
+ {
+ if(val==0.)
+ throw INTERP_KERNEL::Exception("DataArrayDouble::__div__ : trying to divide by zero !");
+ MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> ret=self->deepCpy();
+ ret->applyLin(1/val,0.);
+ ret->incrRef();
+ return ret;
+ }
+ case 2:
+ {
+ return DataArrayDouble::Divide(self,a);
+ }
+ default:
+ throw INTERP_KERNEL::Exception(msg);
+ }
+ }
+
+ DataArrayDouble *__rdiv__(PyObject *obj) throw(INTERP_KERNEL::Exception)
+ {
+ const char msg[]="Unexpected situation in __rdiv__ !";
+ double val;
+ DataArrayDouble *a;
+ int sw;
+ convertObjToPossibleCpp5(obj,sw,val,a);
+ switch(sw)
+ {
+ case 1:
+ {
+ MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> ret=self->deepCpy();
+ ret->applyInv(val);
+ ret->incrRef();
+ return ret;
+ }
+ default:
+ throw INTERP_KERNEL::Exception(msg);
+ }
+ }
+
+ DataArrayDouble *operator/=(PyObject *obj) throw(INTERP_KERNEL::Exception)
+ {
+ const char msg[]="Unexpected situation in __imul__ !";
+ double val;
+ DataArrayDouble *a;
+ int sw;
+ convertObjToPossibleCpp5(obj,sw,val,a);
+ switch(sw)
+ {
+ case 1:
+ {
+ if(val==0.)
+ throw INTERP_KERNEL::Exception("DataArrayDouble::__div__ : trying to divide by zero !");
+ self->applyLin(1./val,0.);
+ return self;
+ }
+ case 2:
+ {
+ self->divideEqual(a);
+ return self;
+ }
+ default:
+ throw INTERP_KERNEL::Exception(msg);
+ }
+ }
+ };
+
+%extend ParaMEDMEM::DataArrayInt
+ {
+ std::string __str__() const
+ {
+ return self->repr();
+ }
+
+ PyObject *getDifferentValues(bool val) const throw(INTERP_KERNEL::Exception)
+ {
+ std::set<int> ret=self->getDifferentValues();
+ return convertIntArrToPyList3(ret);
+ }
+
+ void setValues(PyObject *li, int nbOfTuples, int nbOfElsPerTuple) throw(INTERP_KERNEL::Exception)
+ {
+ int *tmp=new int[nbOfTuples*nbOfElsPerTuple];
+ try
+ {
+ fillArrayWithPyListInt(li,tmp,nbOfTuples*nbOfElsPerTuple,0.);
+ }
+ catch(INTERP_KERNEL::Exception& e)
+ {
+ delete [] tmp;
+ throw e;
+ }
+ self->useArray(tmp,true,CPP_DEALLOC,nbOfTuples,nbOfElsPerTuple);
+ }
+
+ PyObject *getValues() throw(INTERP_KERNEL::Exception)
+ {
+ const int *vals=self->getPointer();
+ return convertIntArrToPyList(vals,self->getNbOfElems());
+ }
+
+ PyObject *getValuesAsTuple() throw(INTERP_KERNEL::Exception)
+ {
+ const int *vals=self->getPointer();
+ int nbOfComp=self->getNumberOfComponents();
+ int nbOfTuples=self->getNumberOfTuples();
+ return convertIntArrToPyListOfTuple(vals,nbOfComp,nbOfTuples);
+ }
+
+ static PyObject *MakePartition(PyObject *gps, int newNb) throw(INTERP_KERNEL::Exception)
+ {
+ std::vector<const DataArrayInt *> groups;
+ std::vector< std::vector<int> > fidsOfGroups;
+ convertPyObjToVecDataArrayIntCst(gps,groups);
+ ParaMEDMEM::DataArrayInt *ret0=ParaMEDMEM::DataArrayInt::MakePartition(groups,newNb,fidsOfGroups);
+ PyObject *ret = PyList_New(2);
+ PyList_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(ret0),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 ));
int sz=fidsOfGroups.size();
PyObject *ret1 = PyList_New(sz);
for(int i=0;i<sz;i++)
return ret;
}
+ void transformWithIndArr(PyObject *li)
+ {
+ void *da=0;
+ int res1=SWIG_ConvertPtr(li,&da,SWIGTYPE_p_ParaMEDMEM__DataArrayInt, 0 | 0 );
+ if (!SWIG_IsOK(res1))
+ {
+ int size;
+ INTERP_KERNEL::AutoPtr<int> tmp=convertPyToNewIntArr2(li,&size);
+ self->transformWithIndArr(tmp,tmp+size);
+ }
+ else
+ {
+ DataArrayInt *da2=reinterpret_cast< DataArrayInt * >(da);
+ self->transformWithIndArr(da2->getConstPointer(),da2->getConstPointer()+da2->getNbOfElems());
+ }
+ }
+
+ PyObject *splitByValueRange(PyObject *li) const throw(INTERP_KERNEL::Exception)
+ {
+ DataArrayInt *ret0=0,*ret1=0,*ret2=0;
+ void *da=0;
+ int res1=SWIG_ConvertPtr(li,&da,SWIGTYPE_p_ParaMEDMEM__DataArrayInt, 0 | 0 );
+ if (!SWIG_IsOK(res1))
+ {
+ int size;
+ INTERP_KERNEL::AutoPtr<int> tmp=convertPyToNewIntArr2(li,&size);
+ self->splitByValueRange(tmp,(int *)tmp+size,ret0,ret1,ret2);
+ }
+ else
+ {
+ DataArrayInt *da2=reinterpret_cast< DataArrayInt * >(da);
+ if(!da2)
+ throw INTERP_KERNEL::Exception("Not null DataArrayInt instance expected !");
+ da2->checkAllocated();
+ int size=self->getNumberOfTuples();
+ self->splitByValueRange(da2->getConstPointer(),da2->getConstPointer()+size,ret0,ret1,ret2);
+ }
+ PyObject *ret = PyList_New(3);
+ PyList_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(ret0),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 ));
+ PyList_SetItem(ret,1,SWIG_NewPointerObj(SWIG_as_voidptr(ret1),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 ));
+ PyList_SetItem(ret,2,SWIG_NewPointerObj(SWIG_as_voidptr(ret2),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 ));
+ return ret;
+ }
+
+ DataArrayInt *transformWithIndArrR(PyObject *li) const
+ {
+ void *da=0;
+ int res1=SWIG_ConvertPtr(li,&da,SWIGTYPE_p_ParaMEDMEM__DataArrayInt, 0 | 0 );
+ if (!SWIG_IsOK(res1))
+ {
+ int size;
+ INTERP_KERNEL::AutoPtr<int> tmp=convertPyToNewIntArr2(li,&size);
+ return self->transformWithIndArrR(tmp,tmp+size);
+ }
+ else
+ {
+ DataArrayInt *da2=reinterpret_cast< DataArrayInt * >(da);
+ return self->transformWithIndArrR(da2->getConstPointer(),da2->getConstPointer()+da2->getNbOfElems());
+ }
+ }
+
void renumberInPlace(PyObject *li) throw(INTERP_KERNEL::Exception)
{
- int size;
- INTERP_KERNEL::AutoPtr<int> tmp=convertPyToNewIntArr2(li,&size);
- if(size!=self->getNumberOfTuples())
+ void *da=0;
+ int res1=SWIG_ConvertPtr(li,&da,SWIGTYPE_p_ParaMEDMEM__DataArrayInt, 0 | 0 );
+ if (!SWIG_IsOK(res1))
+ {
+ int size;
+ INTERP_KERNEL::AutoPtr<int> tmp=convertPyToNewIntArr2(li,&size);
+ if(size!=self->getNumberOfTuples())
+ {
+ throw INTERP_KERNEL::Exception("Invalid list length ! Must be equal to number of tuples !");
+ }
+ self->renumberInPlace(tmp);
+ }
+ else
{
- throw INTERP_KERNEL::Exception("Invalid list length ! Must be equal to number of tuples !");
+ DataArrayInt *da2=reinterpret_cast< DataArrayInt * >(da);
+ if(!da2)
+ throw INTERP_KERNEL::Exception("Not null DataArrayInt instance expected !");
+ da2->checkAllocated();
+ int size=self->getNumberOfTuples();
+ if(size!=self->getNumberOfTuples())
+ {
+ throw INTERP_KERNEL::Exception("Invalid list length ! Must be equal to number of tuples !");
+ }
+ self->renumberInPlace(da2->getConstPointer());
}
- self->renumberInPlace(tmp);
}
void renumberInPlaceR(PyObject *li) throw(INTERP_KERNEL::Exception)
{
- int size;
- INTERP_KERNEL::AutoPtr<int> tmp=convertPyToNewIntArr2(li,&size);
- if(size!=self->getNumberOfTuples())
+ void *da=0;
+ int res1=SWIG_ConvertPtr(li,&da,SWIGTYPE_p_ParaMEDMEM__DataArrayInt, 0 | 0 );
+ if (!SWIG_IsOK(res1))
{
- throw INTERP_KERNEL::Exception("Invalid list length ! Must be equal to number of tuples !");
+ int size;
+ INTERP_KERNEL::AutoPtr<int> tmp=convertPyToNewIntArr2(li,&size);
+ if(size!=self->getNumberOfTuples())
+ {
+ throw INTERP_KERNEL::Exception("Invalid list length ! Must be equal to number of tuples !");
+ }
+ self->renumberInPlaceR(tmp);
+ }
+ else
+ {
+ DataArrayInt *da2=reinterpret_cast< DataArrayInt * >(da);
+ if(!da2)
+ throw INTERP_KERNEL::Exception("Not null DataArrayInt instance expected !");
+ da2->checkAllocated();
+ int size=self->getNumberOfTuples();
+ if(size!=self->getNumberOfTuples())
+ {
+ throw INTERP_KERNEL::Exception("Invalid list length ! Must be equal to number of tuples !");
+ }
+ self->renumberInPlaceR(da2->getConstPointer());
}
- self->renumberInPlaceR(tmp);
}
DataArrayInt *renumberAndReduce(PyObject *li, int newNbOfTuple) throw(INTERP_KERNEL::Exception)
{
- int size;
- INTERP_KERNEL::AutoPtr<int> tmp=convertPyToNewIntArr2(li,&size);
- if(size!=self->getNumberOfTuples())
+ void *da=0;
+ int res1=SWIG_ConvertPtr(li,&da,SWIGTYPE_p_ParaMEDMEM__DataArrayInt, 0 | 0 );
+ if (!SWIG_IsOK(res1))
+ {
+ int size;
+ INTERP_KERNEL::AutoPtr<int> tmp=convertPyToNewIntArr2(li,&size);
+ if(size!=self->getNumberOfTuples())
+ {
+ throw INTERP_KERNEL::Exception("Invalid list length ! Must be equal to number of tuples !");
+ }
+ return self->renumberAndReduce(tmp,newNbOfTuple);
+ }
+ else
{
- throw INTERP_KERNEL::Exception("Invalid list length ! Must be equal to number of tuples !");
+ DataArrayInt *da2=reinterpret_cast< DataArrayInt * >(da);
+ if(!da2)
+ throw INTERP_KERNEL::Exception("Not null DataArrayInt instance expected !");
+ da2->checkAllocated();
+ int size=self->getNumberOfTuples();
+ if(size!=self->getNumberOfTuples())
+ {
+ throw INTERP_KERNEL::Exception("Invalid list length ! Must be equal to number of tuples !");
+ }
+ return self->renumberAndReduce(da2->getConstPointer(),newNbOfTuple);
}
- DataArrayInt *ret=self->renumberAndReduce(tmp,newNbOfTuple);
- return ret;
}
DataArrayInt *renumber(PyObject *li) throw(INTERP_KERNEL::Exception)
{
- int size;
- INTERP_KERNEL::AutoPtr<int> tmp=convertPyToNewIntArr2(li,&size);
- if(size!=self->getNumberOfTuples())
+ void *da=0;
+ int res1=SWIG_ConvertPtr(li,&da,SWIGTYPE_p_ParaMEDMEM__DataArrayInt, 0 | 0 );
+ if (!SWIG_IsOK(res1))
{
- throw INTERP_KERNEL::Exception("Invalid list length ! Must be equal to number of tuples !");
+ int size;
+ INTERP_KERNEL::AutoPtr<int> tmp=convertPyToNewIntArr2(li,&size);
+ if(size!=self->getNumberOfTuples())
+ {
+ throw INTERP_KERNEL::Exception("Invalid list length ! Must be equal to number of tuples !");
+ }
+ return self->renumber(tmp);
+ }
+ else
+ {
+ DataArrayInt *da2=reinterpret_cast< DataArrayInt * >(da);
+ if(!da2)
+ throw INTERP_KERNEL::Exception("Not null DataArrayInt instance expected !");
+ da2->checkAllocated();
+ int size=self->getNumberOfTuples();
+ if(size!=self->getNumberOfTuples())
+ {
+ throw INTERP_KERNEL::Exception("Invalid list length ! Must be equal to number of tuples !");
+ }
+ return self->renumber(da2->getConstPointer());
}
- DataArrayInt *ret=self->renumber(tmp);
- return ret;
}
DataArrayInt *renumberR(PyObject *li) throw(INTERP_KERNEL::Exception)
{
- int size;
- INTERP_KERNEL::AutoPtr<int> tmp=convertPyToNewIntArr2(li,&size);
- if(size!=self->getNumberOfTuples())
+ void *da=0;
+ int res1=SWIG_ConvertPtr(li,&da,SWIGTYPE_p_ParaMEDMEM__DataArrayInt, 0 | 0 );
+ if (!SWIG_IsOK(res1))
+ {
+ int size;
+ INTERP_KERNEL::AutoPtr<int> tmp=convertPyToNewIntArr2(li,&size);
+ if(size!=self->getNumberOfTuples())
+ {
+ throw INTERP_KERNEL::Exception("Invalid list length ! Must be equal to number of tuples !");
+ }
+ return self->renumberR(tmp);
+ }
+ else
+ {
+ DataArrayInt *da2=reinterpret_cast< DataArrayInt * >(da);
+ if(!da2)
+ throw INTERP_KERNEL::Exception("Not null DataArrayInt instance expected !");
+ da2->checkAllocated();
+ int size=self->getNumberOfTuples();
+ if(size!=self->getNumberOfTuples())
+ {
+ throw INTERP_KERNEL::Exception("Invalid list length ! Must be equal to number of tuples !");
+ }
+ return self->renumberR(da2->getConstPointer());
+ }
+ }
+
+ DataArrayInt *selectByTupleId(PyObject *li) const throw(INTERP_KERNEL::Exception)
+ {
+ void *da=0;
+ int res1=SWIG_ConvertPtr(li,&da,SWIGTYPE_p_ParaMEDMEM__DataArrayInt, 0 | 0 );
+ if (!SWIG_IsOK(res1))
+ {
+ int size;
+ INTERP_KERNEL::AutoPtr<int> tmp=convertPyToNewIntArr2(li,&size);
+ return self->selectByTupleId(tmp,tmp+size);
+ }
+ else
+ {
+ DataArrayInt *da2=reinterpret_cast< DataArrayInt * >(da);
+ if(!da2)
+ throw INTERP_KERNEL::Exception("Not null DataArrayInt instance expected !");
+ da2->checkAllocated();
+ return self->selectByTupleId(da2->getConstPointer(),da2->getConstPointer()+da2->getNbOfElems());
+ }
+ }
+
+ DataArrayInt *selectByTupleIdSafe(PyObject *li) const throw(INTERP_KERNEL::Exception)
+ {
+ void *da=0;
+ int res1=SWIG_ConvertPtr(li,&da,SWIGTYPE_p_ParaMEDMEM__DataArrayInt, 0 | 0 );
+ if (!SWIG_IsOK(res1))
+ {
+ int size;
+ INTERP_KERNEL::AutoPtr<int> tmp=convertPyToNewIntArr2(li,&size);
+ return self->selectByTupleIdSafe(tmp,tmp+size);
+ }
+ else
+ {
+ DataArrayInt *da2=reinterpret_cast< DataArrayInt * >(da);
+ if(!da2)
+ throw INTERP_KERNEL::Exception("Not null DataArrayInt instance expected !");
+ da2->checkAllocated();
+ return self->selectByTupleIdSafe(da2->getConstPointer(),da2->getConstPointer()+da2->getNbOfElems());
+ }
+ }
+
+ DataArrayInt *keepSelectedComponents(PyObject *li) const throw(INTERP_KERNEL::Exception)
+ {
+ std::vector<int> tmp;
+ convertPyToNewIntArr3(li,tmp);
+ return self->keepSelectedComponents(tmp);
+ }
+
+ void setSelectedComponents(const DataArrayInt *a, PyObject *li) throw(INTERP_KERNEL::Exception)
+ {
+ std::vector<int> tmp;
+ convertPyToNewIntArr3(li,tmp);
+ self->setSelectedComponents(a,tmp);
+ }
+
+ PyObject *getTuple(int tupleId) throw(INTERP_KERNEL::Exception)
+ {
+ int sz=self->getNumberOfComponents();
+ INTERP_KERNEL::AutoPtr<int> tmp=new int[sz];
+ self->getTuple(tupleId,tmp);
+ return convertIntArrToPyList(tmp,sz);
+ }
+
+ PyObject *changeSurjectiveFormat(int targetNb) const throw(INTERP_KERNEL::Exception)
+ {
+ DataArrayInt *arr=0;
+ DataArrayInt *arrI=0;
+ self->changeSurjectiveFormat(targetNb,arr,arrI);
+ PyObject *res = PyList_New(2);
+ PyList_SetItem(res,0,SWIG_NewPointerObj((void*)arr,SWIGTYPE_p_ParaMEDMEM__DataArrayInt,SWIG_POINTER_OWN | 0));
+ PyList_SetItem(res,1,SWIG_NewPointerObj((void*)arrI,SWIGTYPE_p_ParaMEDMEM__DataArrayInt,SWIG_POINTER_OWN | 0));
+ return res;
+ }
+
+ static DataArrayInt *Meld(PyObject *li) throw(INTERP_KERNEL::Exception)
+ {
+ std::vector<const DataArrayInt *> tmp;
+ convertPyObjToVecDataArrayIntCst(li,tmp);
+ return DataArrayInt::Meld(tmp);
+ }
+
+ static DataArrayInt *Aggregate(PyObject *li) throw(INTERP_KERNEL::Exception)
+ {
+ std::vector<const DataArrayInt *> tmp;
+ convertPyObjToVecDataArrayIntCst(li,tmp);
+ return DataArrayInt::Aggregate(tmp);
+ }
+
+ static DataArrayInt *BuildUnion(PyObject *li) throw(INTERP_KERNEL::Exception)
+ {
+ std::vector<const DataArrayInt *> tmp;
+ convertPyObjToVecDataArrayIntCst(li,tmp);
+ return DataArrayInt::BuildUnion(tmp);
+ }
+
+ static DataArrayInt *BuildIntersection(PyObject *li) throw(INTERP_KERNEL::Exception)
+ {
+ std::vector<const DataArrayInt *> tmp;
+ convertPyObjToVecDataArrayIntCst(li,tmp);
+ return DataArrayInt::BuildIntersection(tmp);
+ }
+
+ PyObject *getMaxValue() const throw(INTERP_KERNEL::Exception)
+ {
+ int tmp;
+ int r1=self->getMaxValue(tmp);
+ PyObject *ret=PyTuple_New(2);
+ PyTuple_SetItem(ret,0,PyInt_FromLong(r1));
+ PyTuple_SetItem(ret,1,PyInt_FromLong(tmp));
+ return ret;
+ }
+
+ PyObject *getMinValue() const throw(INTERP_KERNEL::Exception)
+ {
+ int tmp;
+ int r1=self->getMinValue(tmp);
+ PyObject *ret=PyTuple_New(2);
+ PyTuple_SetItem(ret,0,PyInt_FromLong(r1));
+ PyTuple_SetItem(ret,1,PyInt_FromLong(tmp));
+ return ret;
+ }
+
+ DataArrayInt *__getitem__(PyObject *obj) throw(INTERP_KERNEL::Exception)
+ {
+ const char msg[]="Unexpected situation in __getitem__ !";
+ self->checkAllocated();
+ int nbOfTuples=self->getNumberOfTuples();
+ int nbOfComponents=self->getNumberOfComponents();
+ int it1,ic1;
+ std::vector<int> vt1,vc1;
+ std::pair<int, std::pair<int,int> > pt1,pc1;
+ DataArrayInt *dt1=0,*dc1=0;
+ int sw;
+ convertObjToPossibleCpp3(obj,nbOfTuples,nbOfComponents,sw,it1,ic1,vt1,vc1,pt1,pc1,dt1,dc1);
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ret;
+ switch(sw)
+ {
+ case 1:
+ return self->selectByTupleIdSafe(&it1,&it1+1);
+ case 2:
+ return self->selectByTupleIdSafe(&vt1[0],&vt1[0]+vt1.size());
+ case 3:
+ return self->selectByTupleId2(pt1.first,pt1.second.first,pt1.second.second);
+ case 4:
+ return self->selectByTupleIdSafe(dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems());
+ case 5:
+ {
+ ret=self->selectByTupleIdSafe(&it1,&it1+1);
+ std::vector<int> v2(1,ic1);
+ return ret->keepSelectedComponents(v2);
+ }
+ case 6:
+ {
+ ret=self->selectByTupleIdSafe(&vt1[0],&vt1[0]+vt1.size());
+ std::vector<int> v2(1,ic1);
+ return ret->keepSelectedComponents(v2);
+ }
+ case 7:
+ {
+ ret=self->selectByTupleId2(pt1.first,pt1.second.first,pt1.second.second);
+ std::vector<int> v2(1,ic1);
+ return ret->keepSelectedComponents(v2);
+ }
+ case 8:
+ {
+ ret=self->selectByTupleIdSafe(dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems());
+ std::vector<int> v2(1,ic1);
+ return ret->keepSelectedComponents(v2);
+ }
+ case 9:
+ {
+ ret=self->selectByTupleIdSafe(&it1,&it1+1);
+ return ret->keepSelectedComponents(vc1);
+ }
+ case 10:
+ {
+ ret=self->selectByTupleIdSafe(&vt1[0],&vt1[0]+vt1.size());
+ return ret->keepSelectedComponents(vc1);
+ }
+ case 11:
+ {
+ ret=self->selectByTupleId2(pt1.first,pt1.second.first,pt1.second.second);
+ return ret->keepSelectedComponents(vc1);
+ }
+ case 12:
+ {
+ ret=self->selectByTupleIdSafe(dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems());
+ return ret->keepSelectedComponents(vc1);
+ }
+ case 13:
+ {
+ ret=self->selectByTupleIdSafe(&it1,&it1+1);
+ int nbOfComp=(pc1.second.first-1-pc1.first)/pc1.second.second+1;
+ std::vector<int> v2(nbOfComp);
+ for(int i=0;i<nbOfComp;i++)
+ v2[i]=pc1.first+i*pc1.second.second;
+ return ret->keepSelectedComponents(v2);
+ }
+ case 14:
+ {
+ ret=self->selectByTupleIdSafe(&vt1[0],&vt1[0]+vt1.size());
+ int nbOfComp=(pc1.second.first-1-pc1.first)/pc1.second.second+1;
+ std::vector<int> v2(nbOfComp);
+ for(int i=0;i<nbOfComp;i++)
+ v2[i]=pc1.first+i*pc1.second.second;
+ return ret->keepSelectedComponents(v2);
+ }
+ case 15:
+ {
+ ret=self->selectByTupleId2(pt1.first,pt1.second.first,pt1.second.second);
+ int nbOfComp=(pc1.second.first-1-pc1.first)/pc1.second.second+1;
+ std::vector<int> v2(nbOfComp);
+ for(int i=0;i<nbOfComp;i++)
+ v2[i]=pc1.first+i*pc1.second.second;
+ return ret->keepSelectedComponents(v2);
+ }
+ case 16:
+ {
+ ret=self->selectByTupleIdSafe(dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems());
+ int nbOfComp=(pc1.second.first-1-pc1.first)/pc1.second.second+1;
+ std::vector<int> v2(nbOfComp);
+ for(int i=0;i<nbOfComp;i++)
+ v2[i]=pc1.first+i*pc1.second.second;
+ return ret->keepSelectedComponents(v2);
+ }
+ default:
+ throw INTERP_KERNEL::Exception(msg);
+ }
+ }
+
+ DataArrayInt *__setitem__(PyObject *obj, PyObject *value) throw(INTERP_KERNEL::Exception)
+ {
+ self->checkAllocated();
+ const char msg[]="Unexpected situation in __setitem__ !";
+ int nbOfTuples=self->getNumberOfTuples();
+ int nbOfComponents=self->getNumberOfComponents();
+ int sw1,sw2;
+ int i1;
+ std::vector<int> v1;
+ DataArrayInt *d1=0;
+ convertObjToPossibleCpp1(value,sw1,i1,v1,d1);
+ int it1,ic1;
+ std::vector<int> vt1,vc1;
+ std::pair<int, std::pair<int,int> > pt1,pc1;
+ DataArrayInt *dt1=0,*dc1=0;
+ convertObjToPossibleCpp3(obj,nbOfTuples,nbOfComponents,sw2,it1,ic1,vt1,vc1,pt1,pc1,dt1,dc1);
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> tmp;
+ switch(sw2)
+ {
+ case 1:
+ {
+ switch(sw1)
+ {
+ case 1:
+ self->setPartOfValuesSimple1(i1,it1,it1+1,1,0,nbOfComponents,1);
+ return self;
+ case 2:
+ tmp=DataArrayInt::New();
+ tmp->useArray(&v1[0],false,CPP_DEALLOC,v1.size(),1);
+ self->setPartOfValues1(tmp,it1,it1+1,1,0,nbOfComponents,1,false);
+ return self;
+ case 3:
+ self->setPartOfValues1(d1,it1,it1+1,1,0,nbOfComponents,1);
+ return self;
+ default:
+ throw INTERP_KERNEL::Exception(msg);
+ }
+ break;
+ }
+ case 2:
+ {
+ switch(sw1)
+ {
+ case 1:
+ self->setPartOfValuesSimple3(i1,&vt1[0],&vt1[0]+vt1.size(),0,nbOfComponents,1);
+ return self;
+ case 2:
+ tmp=DataArrayInt::New();
+ tmp->useArray(&v1[0],false,CPP_DEALLOC,v1.size(),1);
+ self->setPartOfValues3(tmp,&vt1[0],&vt1[0]+vt1.size(),0,nbOfComponents,1,false);
+ return self;
+ case 3:
+ self->setPartOfValues3(d1,&vt1[0],&vt1[0]+vt1.size(),0,nbOfComponents,1);
+ return self;
+ default:
+ throw INTERP_KERNEL::Exception(msg);
+ }
+ break;
+ }
+ case 3:
+ {
+ switch(sw1)
+ {
+ case 1:
+ self->setPartOfValuesSimple1(i1,pt1.first,pt1.second.first,pt1.second.second,0,nbOfComponents,1);
+ return self;
+ case 2:
+ tmp=DataArrayInt::New();
+ tmp->useArray(&v1[0],false,CPP_DEALLOC,v1.size(),1);
+ self->setPartOfValues1(tmp,pt1.first,pt1.second.first,pt1.second.second,0,nbOfComponents,1,false);
+ return self;
+ case 3:
+ self->setPartOfValues1(d1,pt1.first,pt1.second.first,pt1.second.second,0,nbOfComponents,1);
+ return self;
+ default:
+ throw INTERP_KERNEL::Exception(msg);
+ }
+ break;
+ }
+ case 4:
+ {
+ switch(sw1)
+ {
+ case 1:
+ self->setPartOfValuesSimple3(i1,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),0,nbOfComponents,1);
+ return self;
+ case 2:
+ tmp=DataArrayInt::New();
+ tmp->useArray(&v1[0],false,CPP_DEALLOC,v1.size(),1);
+ self->setPartOfValues3(tmp,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),0,nbOfComponents,1,false);
+ return self;
+ case 3:
+ self->setPartOfValues3(d1,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),0,nbOfComponents,1);
+ return self;
+ default:
+ throw INTERP_KERNEL::Exception(msg);
+ }
+ break;
+ }
+ case 5:
+ {
+ switch(sw1)
+ {
+ case 1:
+ self->setPartOfValuesSimple1(i1,it1,it1+1,1,ic1,ic1+1,1);
+ return self;
+ case 2:
+ tmp=DataArrayInt::New();
+ tmp->useArray(&v1[0],false,CPP_DEALLOC,v1.size(),1);
+ self->setPartOfValues1(tmp,it1,it1+1,1,ic1,ic1+1,1,false);
+ return self;
+ case 3:
+ self->setPartOfValues1(d1,it1,it1+1,1,ic1,ic1+1,1);
+ return self;
+ default:
+ throw INTERP_KERNEL::Exception(msg);
+ }
+ break;
+ }
+ case 6:
+ {
+ switch(sw1)
+ {
+ case 1:
+ self->setPartOfValuesSimple3(i1,&vt1[0],&vt1[0]+vt1.size(),ic1,ic1+1,1);
+ return self;
+ case 2:
+ tmp=DataArrayInt::New();
+ tmp->useArray(&v1[0],false,CPP_DEALLOC,v1.size(),1);
+ self->setPartOfValues3(tmp,&vt1[0],&vt1[0]+vt1.size(),ic1,ic1+1,1,false);
+ return self;
+ case 3:
+ self->setPartOfValues3(d1,&vt1[0],&vt1[0]+vt1.size(),ic1,ic1+1,1);
+ return self;
+ default:
+ throw INTERP_KERNEL::Exception(msg);
+ }
+ break;
+ }
+ case 7:
+ {
+ switch(sw1)
+ {
+ case 1:
+ self->setPartOfValuesSimple1(i1,pt1.first,pt1.second.first,pt1.second.second,ic1,ic1+1,1);
+ return self;
+ case 2:
+ tmp=DataArrayInt::New();
+ tmp->useArray(&v1[0],false,CPP_DEALLOC,v1.size(),1);
+ self->setPartOfValues1(tmp,pt1.first,pt1.second.first,pt1.second.second,ic1,ic1+1,1,false);
+ return self;
+ case 3:
+ self->setPartOfValues1(d1,pt1.first,pt1.second.first,pt1.second.second,ic1,ic1+1,1);
+ return self;
+ default:
+ throw INTERP_KERNEL::Exception(msg);
+ }
+ break;
+ }
+ case 8:
+ {
+ switch(sw1)
+ {
+ case 1:
+ self->setPartOfValuesSimple3(i1,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),ic1,ic1+1,1);
+ return self;
+ case 2:
+ tmp=DataArrayInt::New();
+ tmp->useArray(&v1[0],false,CPP_DEALLOC,v1.size(),1);
+ self->setPartOfValues3(tmp,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),ic1,ic1+1,1,false);
+ return self;
+ case 3:
+ self->setPartOfValues3(d1,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),ic1,ic1+1,1);
+ return self;
+ default:
+ throw INTERP_KERNEL::Exception(msg);
+ }
+ break;
+ }
+ case 9:
+ {
+ switch(sw1)
+ {
+ case 1:
+ self->setPartOfValuesSimple2(i1,&it1,&it1+1,&vc1[0],&vc1[0]+vc1.size());
+ return self;
+ case 2:
+ tmp=DataArrayInt::New();
+ tmp->useArray(&v1[0],false,CPP_DEALLOC,v1.size(),1);
+ self->setPartOfValues2(tmp,&it1,&it1+1,&vc1[0],&vc1[0]+vc1.size(),false);
+ return self;
+ case 3:
+ self->setPartOfValues2(d1,&it1,&it1+1,&vc1[0],&vc1[0]+vc1.size());
+ return self;
+ default:
+ throw INTERP_KERNEL::Exception(msg);
+ }
+ break;
+ }
+ case 10:
+ {
+ switch(sw1)
+ {
+ case 1:
+ self->setPartOfValuesSimple2(i1,&vt1[0],&vt1[0]+vt1.size(),&vc1[0],&vc1[0]+vc1.size());
+ return self;
+ case 2:
+ tmp=DataArrayInt::New();
+ tmp->useArray(&v1[0],false,CPP_DEALLOC,v1.size(),1);
+ self->setPartOfValues2(tmp,&vt1[0],&vt1[0]+vt1.size(),&vc1[0],&vc1[0]+vc1.size(),false);
+ return self;
+ case 3:
+ self->setPartOfValues2(d1,&vt1[0],&vt1[0]+vt1.size(),&vc1[0],&vc1[0]+vc1.size());
+ return self;
+ default:
+ throw INTERP_KERNEL::Exception(msg);
+ }
+ break;
+ }
+ case 11:
+ {
+ int bb=pt1.first;
+ int ee=pt1.second.first;
+ int ss=pt1.second.second;
+ if(ee<bb || ss<=0)
+ throw INTERP_KERNEL::Exception("Invalid slice in tuple selection");
+ int nbOfE=(ee-bb)/ss;
+ std::vector<int> nv(nbOfE);
+ for(int jj=0;jj<nbOfE;jj++)
+ nv[jj]=bb+jj*ss;
+ switch(sw1)
+ {
+ case 1:
+ self->setPartOfValuesSimple2(i1,&nv[0],&nv[0]+nv.size(),&vc1[0],&vc1[0]+vc1.size());
+ return self;
+ case 2:
+ tmp=DataArrayInt::New();
+ tmp->useArray(&v1[0],false,CPP_DEALLOC,v1.size(),1);
+ self->setPartOfValues2(tmp,&nv[0],&nv[0]+nv.size(),&vc1[0],&vc1[0]+vc1.size(),false);
+ return self;
+ case 3:
+ self->setPartOfValues2(d1,&nv[0],&nv[0]+nv.size(),&vc1[0],&vc1[0]+vc1.size());
+ return self;
+ default:
+ throw INTERP_KERNEL::Exception(msg);
+ }
+ break;
+ }
+ case 12:
+ {
+ switch(sw1)
+ {
+ case 1:
+ self->setPartOfValuesSimple2(i1,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),&vc1[0],&vc1[0]+vc1.size());
+ return self;
+ case 2:
+ tmp=DataArrayInt::New();
+ tmp->useArray(&v1[0],false,CPP_DEALLOC,v1.size(),1);
+ self->setPartOfValues2(tmp,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),&vc1[0],&vc1[0]+vc1.size(),false);
+ return self;
+ case 3:
+ self->setPartOfValues2(d1,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),&vc1[0],&vc1[0]+vc1.size());
+ return self;
+ default:
+ throw INTERP_KERNEL::Exception(msg);
+ }
+ break;
+ }
+ case 13:
+ {
+ switch(sw1)
+ {
+ case 1:
+ self->setPartOfValuesSimple1(i1,it1,it1+1,1,pc1.first,pc1.second.first,pc1.second.second);
+ return self;
+ case 2:
+ tmp=DataArrayInt::New();
+ tmp->useArray(&v1[0],false,CPP_DEALLOC,v1.size(),1);
+ self->setPartOfValues1(tmp,it1,it1+1,1,pc1.first,pc1.second.first,pc1.second.second,false);
+ return self;
+ case 3:
+ self->setPartOfValues1(d1,it1,it1+1,1,pc1.first,pc1.second.first,pc1.second.second);
+ return self;
+ default:
+ throw INTERP_KERNEL::Exception(msg);
+ }
+ break;
+ }
+ case 14:
+ {
+ switch(sw1)
+ {
+ case 1:
+ self->setPartOfValuesSimple3(i1,&vt1[0],&vt1[0]+vt1.size(),pc1.first,pc1.second.first,pc1.second.second);
+ return self;
+ case 2:
+ tmp=DataArrayInt::New();
+ tmp->useArray(&v1[0],false,CPP_DEALLOC,v1.size(),1);
+ self->setPartOfValues3(tmp,&vt1[0],&vt1[0]+vt1.size(),pc1.first,pc1.second.first,pc1.second.second,false);
+ return self;
+ case 3:
+ self->setPartOfValues3(d1,&vt1[0],&vt1[0]+vt1.size(),pc1.first,pc1.second.first,pc1.second.second);
+ return self;
+ default:
+ throw INTERP_KERNEL::Exception(msg);
+ }
+ break;
+ }
+ case 15:
+ {
+ switch(sw1)
+ {
+ case 1:
+ self->setPartOfValuesSimple1(i1,pt1.first,pt1.second.first,pt1.second.second,pc1.first,pc1.second.first,pc1.second.second);
+ return self;
+ case 2:
+ tmp=DataArrayInt::New();
+ tmp->useArray(&v1[0],false,CPP_DEALLOC,v1.size(),1);
+ self->setPartOfValues1(tmp,pt1.first,pt1.second.first,pt1.second.second,pc1.first,pc1.second.first,pc1.second.second,false);
+ return self;
+ case 3:
+ self->setPartOfValues1(d1,pt1.first,pt1.second.first,pt1.second.second,pc1.first,pc1.second.first,pc1.second.second);
+ return self;
+ default:
+ throw INTERP_KERNEL::Exception(msg);
+ }
+ break;
+ }
+ case 16:
+ {
+ switch(sw1)
+ {
+ case 1:
+ self->setPartOfValuesSimple3(i1,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),pc1.first,pc1.second.first,pc1.second.second);
+ return self;
+ case 2:
+ tmp=DataArrayInt::New();
+ tmp->useArray(&v1[0],false,CPP_DEALLOC,v1.size(),1);
+ self->setPartOfValues3(tmp,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),pc1.first,pc1.second.first,pc1.second.second,false);
+ return self;
+ case 3:
+ self->setPartOfValues3(d1,dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems(),pc1.first,pc1.second.first,pc1.second.second);
+ return self;
+ default:
+ throw INTERP_KERNEL::Exception(msg);
+ }
+ break;
+ }
+ default:
+ throw INTERP_KERNEL::Exception(msg);
+ }
+ return self;
+ }
+
+ DataArrayInt *__add__(PyObject *obj) throw(INTERP_KERNEL::Exception)
+ {
+ const char msg[]="Unexpected situation in __add__ !";
+ int val;
+ DataArrayInt *a;
+ std::vector<int> aa;
+ int sw;
+ convertObjToPossibleCpp1(obj,sw,val,aa,a);
+ switch(sw)
+ {
+ case 1:
+ {
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ret=self->deepCpy();
+ ret->applyLin(1,val);
+ ret->incrRef();
+ return ret;
+ }
+ case 3:
+ {
+ return DataArrayInt::Add(self,a);
+ }
+ default:
+ throw INTERP_KERNEL::Exception(msg);
+ }
+ }
+
+ DataArrayInt *__radd__(PyObject *obj) throw(INTERP_KERNEL::Exception)
+ {
+ const char msg[]="Unexpected situation in __radd__ !";
+ int val;
+ DataArrayInt *a;
+ std::vector<int> aa;
+ int sw;
+ convertObjToPossibleCpp1(obj,sw,val,aa,a);
+ switch(sw)
+ {
+ case 1:
+ {
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ret=self->deepCpy();
+ ret->applyLin(1,val);
+ ret->incrRef();
+ return ret;
+ }
+ default:
+ throw INTERP_KERNEL::Exception(msg);
+ }
+ }
+
+ DataArrayInt *operator+=(PyObject *obj) throw(INTERP_KERNEL::Exception)
+ {
+ const char msg[]="Unexpected situation in __iadd__ !";
+ int val;
+ DataArrayInt *a;
+ std::vector<int> aa;
+ int sw;
+ convertObjToPossibleCpp1(obj,sw,val,aa,a);
+ switch(sw)
+ {
+ case 1:
+ {
+ self->applyLin(1,val);
+ return self;
+ }
+ case 3:
+ {
+ self->addEqual(a);
+ return self;
+ }
+ default:
+ throw INTERP_KERNEL::Exception(msg);
+ }
+ }
+
+ DataArrayInt *__sub__(PyObject *obj) throw(INTERP_KERNEL::Exception)
+ {
+ const char msg[]="Unexpected situation in __sub__ !";
+ int val;
+ DataArrayInt *a;
+ std::vector<int> aa;
+ int sw;
+ convertObjToPossibleCpp1(obj,sw,val,aa,a);
+ switch(sw)
+ {
+ case 1:
+ {
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ret=self->deepCpy();
+ ret->applyLin(1,-val);
+ ret->incrRef();
+ return ret;
+ }
+ case 3:
+ {
+ return DataArrayInt::Substract(self,a);
+ }
+ default:
+ throw INTERP_KERNEL::Exception(msg);
+ }
+ }
+
+ DataArrayInt *__rsub__(PyObject *obj) throw(INTERP_KERNEL::Exception)
+ {
+ const char msg[]="Unexpected situation in __rsub__ !";
+ int val;
+ DataArrayInt *a;
+ std::vector<int> aa;
+ int sw;
+ convertObjToPossibleCpp1(obj,sw,val,aa,a);
+ switch(sw)
{
- throw INTERP_KERNEL::Exception("Invalid list length ! Must be equal to number of tuples !");
+ case 1:
+ {
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ret=self->deepCpy();
+ ret->applyLin(-1,val);
+ ret->incrRef();
+ return ret;
+ }
+ default:
+ throw INTERP_KERNEL::Exception(msg);
}
- DataArrayInt *ret=self->renumberR(tmp);
- return ret;
}
- DataArrayInt *selectByTupleId(PyObject *li) const throw(INTERP_KERNEL::Exception)
+ DataArrayInt *operator-=(PyObject *obj) throw(INTERP_KERNEL::Exception)
{
- int size;
- INTERP_KERNEL::AutoPtr<int> tmp=convertPyToNewIntArr2(li,&size);
- DataArrayInt *ret=self->selectByTupleId(tmp,tmp+size);
- return ret;
+ const char msg[]="Unexpected situation in __isub__ !";
+ int val;
+ DataArrayInt *a;
+ std::vector<int> aa;
+ int sw;
+ convertObjToPossibleCpp1(obj,sw,val,aa,a);
+ switch(sw)
+ {
+ case 1:
+ {
+ self->applyLin(1.,-val);
+ return self;
+ }
+ case 3:
+ {
+ self->substractEqual(a);
+ return self;
+ }
+ default:
+ throw INTERP_KERNEL::Exception(msg);
+ }
}
- DataArrayInt *selectByTupleIdSafe(PyObject *li) const throw(INTERP_KERNEL::Exception)
+ DataArrayInt *__mul__(PyObject *obj) throw(INTERP_KERNEL::Exception)
{
- int size;
- INTERP_KERNEL::AutoPtr<int> tmp=convertPyToNewIntArr2(li,&size);
- DataArrayInt *ret=self->selectByTupleIdSafe(tmp,tmp+size);
- return ret;
+ const char msg[]="Unexpected situation in __mul__ !";
+ int val;
+ DataArrayInt *a;
+ std::vector<int> aa;
+ int sw;
+ convertObjToPossibleCpp1(obj,sw,val,aa,a);
+ switch(sw)
+ {
+ case 1:
+ {
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ret=self->deepCpy();
+ ret->applyLin(val,0);
+ ret->incrRef();
+ return ret;
+ }
+ case 3:
+ {
+ return DataArrayInt::Multiply(self,a);
+ }
+ default:
+ throw INTERP_KERNEL::Exception(msg);
+ }
}
- DataArrayInt *keepSelectedComponents(PyObject *li) const throw(INTERP_KERNEL::Exception)
+ DataArrayInt *__rmul__(PyObject *obj) throw(INTERP_KERNEL::Exception)
{
- std::vector<int> tmp;
- convertPyToNewIntArr3(li,tmp);
- return self->keepSelectedComponents(tmp);
+ const char msg[]="Unexpected situation in __rmul__ !";
+ int val;
+ DataArrayInt *a;
+ std::vector<int> aa;
+ int sw;
+ convertObjToPossibleCpp1(obj,sw,val,aa,a);
+ switch(sw)
+ {
+ case 1:
+ {
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ret=self->deepCpy();
+ ret->applyLin(val,0);
+ ret->incrRef();
+ return ret;
+ }
+ default:
+ throw INTERP_KERNEL::Exception(msg);
+ }
}
- void setSelectedComponents(const DataArrayInt *a, PyObject *li) throw(INTERP_KERNEL::Exception)
+ DataArrayInt *operator*=(PyObject *obj) throw(INTERP_KERNEL::Exception)
{
- std::vector<int> tmp;
- convertPyToNewIntArr3(li,tmp);
- self->setSelectedComponents(a,tmp);
+ const char msg[]="Unexpected situation in __imul__ !";
+ int val;
+ DataArrayInt *a;
+ std::vector<int> aa;
+ int sw;
+ convertObjToPossibleCpp1(obj,sw,val,aa,a);
+ switch(sw)
+ {
+ case 1:
+ {
+ self->applyLin(val,0);
+ return self;
+ }
+ case 3:
+ {
+ self->multiplyEqual(a);
+ return self;
+ }
+ default:
+ throw INTERP_KERNEL::Exception(msg);
+ }
}
- PyObject *getTuple(int tupleId) throw(INTERP_KERNEL::Exception)
+ DataArrayInt *__div__(PyObject *obj) throw(INTERP_KERNEL::Exception)
{
- int sz=self->getNumberOfComponents();
- INTERP_KERNEL::AutoPtr<int> tmp=new int[sz];
- self->getTuple(tupleId,tmp);
- return convertIntArrToPyList(tmp,sz);
+ const char msg[]="Unexpected situation in __div__ !";
+ int val;
+ DataArrayInt *a;
+ std::vector<int> aa;
+ int sw;
+ convertObjToPossibleCpp1(obj,sw,val,aa,a);
+ switch(sw)
+ {
+ case 1:
+ {
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ret=self->deepCpy();
+ ret->applyDivideBy(val);
+ ret->incrRef();
+ return ret;
+ }
+ case 3:
+ {
+ return DataArrayInt::Divide(self,a);
+ }
+ default:
+ throw INTERP_KERNEL::Exception(msg);
+ }
}
- static DataArrayInt *Meld(PyObject *li) throw(INTERP_KERNEL::Exception)
+ DataArrayInt *__rdiv__(PyObject *obj) throw(INTERP_KERNEL::Exception)
{
- std::vector<const DataArrayInt *> tmp;
- convertPyObjToVecDataArrayIntCst(li,tmp);
- return DataArrayInt::Meld(tmp);
+ const char msg[]="Unexpected situation in __rdiv__ !";
+ int val;
+ DataArrayInt *a;
+ std::vector<int> aa;
+ int sw;
+ convertObjToPossibleCpp1(obj,sw,val,aa,a);
+ switch(sw)
+ {
+ case 1:
+ {
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ret=self->deepCpy();
+ ret->applyInv(val);
+ ret->incrRef();
+ return ret;
+ }
+ default:
+ throw INTERP_KERNEL::Exception(msg);
+ }
}
- static DataArrayInt *BuildUnion(PyObject *li) throw(INTERP_KERNEL::Exception)
+ DataArrayInt *operator/=(PyObject *obj) throw(INTERP_KERNEL::Exception)
{
- std::vector<const DataArrayInt *> tmp;
- convertPyObjToVecDataArrayIntCst(li,tmp);
- return DataArrayInt::BuildUnion(tmp);
+ const char msg[]="Unexpected situation in __imul__ !";
+ int val;
+ DataArrayInt *a;
+ std::vector<int> aa;
+ int sw;
+ convertObjToPossibleCpp1(obj,sw,val,aa,a);
+ switch(sw)
+ {
+ case 1:
+ {
+ self->applyDivideBy(val);
+ return self;
+ }
+ case 3:
+ {
+ self->divideEqual(a);
+ return self;
+ }
+ default:
+ throw INTERP_KERNEL::Exception(msg);
+ }
}
- static DataArrayInt *BuildIntersection(PyObject *li) throw(INTERP_KERNEL::Exception)
+ DataArrayInt *__mod__(PyObject *obj) throw(INTERP_KERNEL::Exception)
{
- std::vector<const DataArrayInt *> tmp;
- convertPyObjToVecDataArrayIntCst(li,tmp);
- return DataArrayInt::BuildIntersection(tmp);
+ const char msg[]="Unexpected situation in __mod__ !";
+ int val;
+ DataArrayInt *a;
+ std::vector<int> aa;
+ int sw;
+ convertObjToPossibleCpp1(obj,sw,val,aa,a);
+ switch(sw)
+ {
+ case 1:
+ {
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ret=self->deepCpy();
+ ret->applyModulus(val);
+ ret->incrRef();
+ return ret;
+ }
+ case 3:
+ {
+ return DataArrayInt::Modulus(self,a);
+ }
+ default:
+ throw INTERP_KERNEL::Exception(msg);
+ }
}
- PyObject *getMaxValue() const throw(INTERP_KERNEL::Exception)
+ DataArrayInt *__rmod__(PyObject *obj) throw(INTERP_KERNEL::Exception)
{
- int tmp;
- int r1=self->getMaxValue(tmp);
- PyObject *ret=PyTuple_New(2);
- PyTuple_SetItem(ret,0,PyInt_FromLong(r1));
- PyTuple_SetItem(ret,1,PyInt_FromLong(tmp));
- return ret;
+ const char msg[]="Unexpected situation in __rmod__ !";
+ int val;
+ DataArrayInt *a;
+ std::vector<int> aa;
+ int sw;
+ convertObjToPossibleCpp1(obj,sw,val,aa,a);
+ switch(sw)
+ {
+ case 1:
+ {
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ret=self->deepCpy();
+ ret->applyRModulus(val);
+ ret->incrRef();
+ return ret;
+ }
+ case 3:
+ {
+ return DataArrayInt::Modulus(self,a);
+ }
+ default:
+ throw INTERP_KERNEL::Exception(msg);
+ }
}
- PyObject *getMinValue() const throw(INTERP_KERNEL::Exception)
+ DataArrayInt *operator%=(PyObject *obj) throw(INTERP_KERNEL::Exception)
{
- int tmp;
- int r1=self->getMinValue(tmp);
- PyObject *ret=PyTuple_New(2);
- PyTuple_SetItem(ret,0,PyInt_FromLong(r1));
- PyTuple_SetItem(ret,1,PyInt_FromLong(tmp));
- return ret;
+ const char msg[]="Unexpected situation in __imod__ !";
+ int val;
+ DataArrayInt *a;
+ std::vector<int> aa;
+ int sw;
+ convertObjToPossibleCpp1(obj,sw,val,aa,a);
+ switch(sw)
+ {
+ case 1:
+ {
+ self->applyModulus(val);
+ return self;
+ }
+ case 3:
+ {
+ self->modulusEqual(a);
+ return self;
+ }
+ default:
+ throw INTERP_KERNEL::Exception(msg);
+ }
}
};
void setDescription(const char *desc) throw(INTERP_KERNEL::Exception);
const char *getName() const throw(INTERP_KERNEL::Exception);
TypeOfField getTypeOfField() const throw(INTERP_KERNEL::Exception);
+ NatureOfField getNature() const throw(INTERP_KERNEL::Exception);
+ virtual void setNature(NatureOfField nat) throw(INTERP_KERNEL::Exception);
+ DataArrayDouble *getLocalizationOfDiscr() const throw(INTERP_KERNEL::Exception);
MEDCouplingFieldDouble *buildMeasureField(bool isAbs) const throw(INTERP_KERNEL::Exception);
MEDCouplingFieldDiscretization *getDiscretization() const throw(INTERP_KERNEL::Exception);
+ int getNumberOfTuplesExpected() const throw(INTERP_KERNEL::Exception);
+ int getNumberOfMeshPlacesExpected() const throw(INTERP_KERNEL::Exception);
void setGaussLocalizationOnType(INTERP_KERNEL::NormalizedCellType type, const std::vector<double>& refCoo,
const std::vector<double>& gsCoo, const std::vector<double>& wg) throw(INTERP_KERNEL::Exception);
void clearGaussLocalizations() throw(INTERP_KERNEL::Exception);
PyObject *buildSubMeshData(PyObject *li) const throw(INTERP_KERNEL::Exception)
{
- int size;
- INTERP_KERNEL::AutoPtr<int> tmp=convertPyToNewIntArr2(li,&size);
- DataArrayInt *ret1;
- MEDCouplingMesh *ret0=self->buildSubMeshData(tmp,tmp+size,ret1);
+ DataArrayInt *ret1=0;
+ MEDCouplingMesh *ret0=0;
+ void *da=0;
+ int res1=SWIG_ConvertPtr(li,&da,SWIGTYPE_p_ParaMEDMEM__DataArrayInt, 0 | 0 );
+ if (!SWIG_IsOK(res1))
+ {
+ int size;
+ INTERP_KERNEL::AutoPtr<int> tmp=convertPyToNewIntArr2(li,&size);
+ ret0=self->buildSubMeshData(tmp,tmp+size,ret1);
+ }
+ else
+ {
+ DataArrayInt *da2=reinterpret_cast< DataArrayInt * >(da);
+ if(!da2)
+ throw INTERP_KERNEL::Exception("Not null DataArrayInt instance expected !");
+ da2->checkAllocated();
+ ret0=self->buildSubMeshData(da2->getConstPointer(),da2->getConstPointer()+da2->getNbOfElems(),ret1);
+ }
PyObject *res = PyList_New(2);
PyList_SetItem(res,0,convertMesh(ret0, SWIG_POINTER_OWN | 0 ));
PyList_SetItem(res,1,SWIG_NewPointerObj((void*)ret1,SWIGTYPE_p_ParaMEDMEM__DataArrayInt,SWIG_POINTER_OWN | 0));
return res;
}
+
void setGaussLocalizationOnCells(PyObject *li, const std::vector<double>& refCoo,
const std::vector<double>& gsCoo, const std::vector<double>& wg) throw(INTERP_KERNEL::Exception)
{
- int size;
- INTERP_KERNEL::AutoPtr<int> tmp=convertPyToNewIntArr2(li,&size);
- try
+ void *da=0;
+ int res1=SWIG_ConvertPtr(li,&da,SWIGTYPE_p_ParaMEDMEM__DataArrayInt, 0 | 0 );
+ if (!SWIG_IsOK(res1))
{
- self->setGaussLocalizationOnCells(tmp,tmp+size,refCoo,gsCoo,wg);
+ int size;
+ INTERP_KERNEL::AutoPtr<int> tmp=convertPyToNewIntArr2(li,&size);
+ self->setGaussLocalizationOnCells(tmp,((int *)tmp)+size,refCoo,gsCoo,wg);
}
- catch(INTERP_KERNEL::Exception& e)
+ else
{
- throw e;
+ DataArrayInt *da2=reinterpret_cast< DataArrayInt * >(da);
+ if(!da2)
+ throw INTERP_KERNEL::Exception("Not null DataArrayInt instance expected !");
+ da2->checkAllocated();
+ self->setGaussLocalizationOnCells(da2->getConstPointer(),da2->getConstPointer()+da2->getNbOfElems(),refCoo,gsCoo,wg);
}
}
+
PyObject *getCellIdsHavingGaussLocalization(int locId) const throw(INTERP_KERNEL::Exception)
{
std::vector<int> tmp;
{
public:
static MEDCouplingFieldDouble *New(TypeOfField type, TypeOfTimeDiscretization td=NO_TIME);
+ static MEDCouplingFieldDouble *New(const MEDCouplingFieldTemplate *ft, TypeOfTimeDiscretization td=NO_TIME);
+ void setTimeUnit(const char *unit);
+ const char *getTimeUnit() const;
void copyTinyStringsFrom(const MEDCouplingFieldDouble *other) throw(INTERP_KERNEL::Exception);
void copyTinyAttrFrom(const MEDCouplingFieldDouble *other) throw(INTERP_KERNEL::Exception);
std::string simpleRepr() const;
MEDCouplingFieldDouble *deepCpy() const;
MEDCouplingFieldDouble *buildNewTimeReprFromThis(TypeOfTimeDiscretization td, bool deepCpy) const throw(INTERP_KERNEL::Exception);
TypeOfTimeDiscretization getTimeDiscretization() const throw(INTERP_KERNEL::Exception);
- void checkCoherency() const throw(INTERP_KERNEL::Exception);
double getIJ(int tupleId, int compoId) const throw(INTERP_KERNEL::Exception);
double getIJK(int cellId, int nodeIdInCell, int compoId) const throw(INTERP_KERNEL::Exception);
void setArray(DataArrayDouble *array) throw(INTERP_KERNEL::Exception);
int getNumberOfComponents() const throw(INTERP_KERNEL::Exception);
int getNumberOfTuples() const throw(INTERP_KERNEL::Exception);
int getNumberOfValues() const throw(INTERP_KERNEL::Exception);
- NatureOfField getNature() const throw(INTERP_KERNEL::Exception);
- void setNature(NatureOfField nat) throw(INTERP_KERNEL::Exception);
void setTimeTolerance(double val) throw(INTERP_KERNEL::Exception);
double getTimeTolerance() const throw(INTERP_KERNEL::Exception);
void setIteration(int it) throw(INTERP_KERNEL::Exception);
void setEndOrder(int order) throw(INTERP_KERNEL::Exception);
void setTimeValue(double val) throw(INTERP_KERNEL::Exception);
void setEndTimeValue(double val) throw(INTERP_KERNEL::Exception);
- void updateTime() throw(INTERP_KERNEL::Exception);
+ void updateTime() const throw(INTERP_KERNEL::Exception);
void changeUnderlyingMesh(const MEDCouplingMesh *other, int levOfCheck, double prec) throw(INTERP_KERNEL::Exception);
void substractInPlaceDM(const MEDCouplingFieldDouble *f, int levOfCheck, double prec) throw(INTERP_KERNEL::Exception);
- bool mergeNodes(double eps) 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 mergeNodes(double eps, double epsOnVals=1e-15) throw(INTERP_KERNEL::Exception);
+ bool mergeNodes2(double eps, double epsOnVals=1e-15) throw(INTERP_KERNEL::Exception);
+ bool zipCoords(double epsOnVals=1e-15) throw(INTERP_KERNEL::Exception);
+ bool zipConnectivity(int compType,double epsOnVals=1e-15) throw(INTERP_KERNEL::Exception);
bool simplexize(int policy) throw(INTERP_KERNEL::Exception);
MEDCouplingFieldDouble *doublyContractedProduct() const throw(INTERP_KERNEL::Exception);
MEDCouplingFieldDouble *determinant() const throw(INTERP_KERNEL::Exception);
MEDCouplingFieldDouble &operator=(double value) throw(INTERP_KERNEL::Exception);
void fillFromAnalytic(int nbOfComp, const char *func) throw(INTERP_KERNEL::Exception);
void applyFunc(int nbOfComp, const char *func) throw(INTERP_KERNEL::Exception);
+ void applyFunc2(int nbOfComp, const char *func) throw(INTERP_KERNEL::Exception);
+ void applyFunc3(int nbOfComp, const std::vector<std::string>& varsOrder, const char *func) throw(INTERP_KERNEL::Exception);
void applyFunc(int nbOfComp, double val) throw(INTERP_KERNEL::Exception);
void applyFunc(const char *func) throw(INTERP_KERNEL::Exception);
void applyFuncFast32(const char *func) throw(INTERP_KERNEL::Exception);
return self->simpleRepr();
}
- DataArrayDouble *getArray() const throw(INTERP_KERNEL::Exception)
+ DataArrayDouble *getArray() throw(INTERP_KERNEL::Exception)
{
DataArrayDouble *ret=self->getArray();
if(ret)
return ret;
}
- DataArrayDouble *getEndArray() const throw(INTERP_KERNEL::Exception)
+ PyObject *getArrays() const throw(INTERP_KERNEL::Exception)
+ {
+ std::vector<DataArrayDouble *> arrs=self->getArrays();
+ for(std::vector<DataArrayDouble *>::iterator it=arrs.begin();it!=arrs.end();it++)
+ if(*it)
+ (*it)->incrRef();
+ int sz=arrs.size();
+ PyObject *ret=PyTuple_New(sz);
+ for(int i=0;i<sz;i++)
+ {
+ if(arrs[i])
+ PyTuple_SetItem(ret,i,SWIG_NewPointerObj(SWIG_as_voidptr(arrs[i]),SWIGTYPE_p_ParaMEDMEM__DataArrayDouble, SWIG_POINTER_OWN | 0 ));
+ else
+ PyTuple_SetItem(ret,i,SWIG_NewPointerObj(SWIG_as_voidptr(0),SWIGTYPE_p_ParaMEDMEM__DataArrayDouble, 0 | 0 ));
+ }
+ return ret;
+ }
+
+ void setArrays(PyObject *ls) throw(INTERP_KERNEL::Exception)
+ {
+ std::vector<const DataArrayDouble *> tmp;
+ convertPyObjToVecDataArrayDblCst(ls,tmp);
+ int sz=tmp.size();
+ std::vector<DataArrayDouble *> arrs(sz);
+ for(int i=0;i<sz;i++)
+ arrs[i]=const_cast<DataArrayDouble *>(tmp[i]);
+ self->setArrays(arrs);
+ }
+
+ DataArrayDouble *getEndArray() throw(INTERP_KERNEL::Exception)
{
DataArrayDouble *ret=self->getEndArray();
if(ret)
PyObject *getValueOn(PyObject *sl) const throw(INTERP_KERNEL::Exception)
{
int sz;
- double *spaceLoc=convertPyToNewDblArr2(sl,&sz);
+ INTERP_KERNEL::AutoPtr<double> spaceLoc=convertPyToNewDblArr2(sl,&sz);
sz=self->getNumberOfComponents();
- double *res=new double[sz];
- try
+ INTERP_KERNEL::AutoPtr<double> res=new double[sz];
+ self->getValueOn(spaceLoc,res);
+ return convertDblArrToPyList(res,sz);
+ }
+
+ DataArrayDouble *getValueOnMulti(PyObject *li) const throw(INTERP_KERNEL::Exception)
+ {
+ void *da=0;
+ int res1=SWIG_ConvertPtr(li,&da,SWIGTYPE_p_ParaMEDMEM__DataArrayDouble, 0 | 0 );
+ if (!SWIG_IsOK(res1))
{
- self->getValueOn(spaceLoc,res);
+ int size;
+ INTERP_KERNEL::AutoPtr<double> tmp=convertPyToNewDblArr2(li,&size);
+ int spaceDim=self->getMesh()->getSpaceDimension();
+ int nbOfPoints=size/spaceDim;
+ if(size%spaceDim!=0)
+ {
+ throw INTERP_KERNEL::Exception("Invalid list length ! Must be a multiple of self.getMesh().getSpaceDimension() !");
+ }
+ return self->getValueOnMulti(tmp,nbOfPoints);
}
- catch(INTERP_KERNEL::Exception& e)
+ else
{
- delete [] spaceLoc;
- delete [] res;
- throw e;
+ DataArrayDouble *da2=reinterpret_cast< DataArrayDouble * >(da);
+ if(!da2)
+ throw INTERP_KERNEL::Exception("Not null DataArrayDouble instance expected !");
+ da2->checkAllocated();
+ int size=da2->getNumberOfTuples();
+ int nbOfCompo=da2->getNumberOfComponents();
+ if(nbOfCompo!=self->getMesh()->getSpaceDimension())
+ {
+ throw INTERP_KERNEL::Exception("Invalid DataArrayDouble nb of components ! Expected same as self.getMesh().getSpaceDimension() !");
+ }
+ return self->getValueOnMulti(da2->getConstPointer(),size);
}
- 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);
+ INTERP_KERNEL::AutoPtr<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;
+ INTERP_KERNEL::AutoPtr<double> res=new double[sz];
+ self->getValueOn(spaceLoc,time,res);
+ return convertDblArrToPyList(res,sz);
}
void setValues(PyObject *li) throw(INTERP_KERNEL::Exception)
{
PyObject *accumulate() const throw(INTERP_KERNEL::Exception)
{
int sz=self->getNumberOfComponents();
- double *tmp=new double[sz];
+ INTERP_KERNEL::AutoPtr<double> tmp=new double[sz];
self->accumulate(tmp);
PyObject *ret=convertDblArrToPyList(tmp,sz);
- delete [] tmp;
return ret;
}
PyObject *integral(bool isWAbs) const throw(INTERP_KERNEL::Exception)
{
int sz=self->getNumberOfComponents();
- double *tmp=new double[sz];
+ INTERP_KERNEL::AutoPtr<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];
+ INTERP_KERNEL::AutoPtr<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];
+ INTERP_KERNEL::AutoPtr<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;
- INTERP_KERNEL::AutoPtr<int> tmp=convertPyToNewIntArr2(li,&size);
- try
+ void *da=0;
+ int res1=SWIG_ConvertPtr(li,&da,SWIGTYPE_p_ParaMEDMEM__DataArrayInt, 0 | 0 );
+ if (!SWIG_IsOK(res1))
{
+ int size;
+ INTERP_KERNEL::AutoPtr<int> tmp=convertPyToNewIntArr2(li,&size);
self->renumberCells(tmp,check);
}
- catch(INTERP_KERNEL::Exception& e)
+ else
{
- throw e;
+ DataArrayInt *da2=reinterpret_cast< DataArrayInt * >(da);
+ if(!da2)
+ throw INTERP_KERNEL::Exception("Not null DataArrayInt instance expected !");
+ da2->checkAllocated();
+ self->renumberCells(da2->getConstPointer(),check);
}
}
void renumberNodes(PyObject *li) throw(INTERP_KERNEL::Exception)
{
- int size;
- INTERP_KERNEL::AutoPtr<int> tmp=convertPyToNewIntArr2(li,&size);
- try
+ void *da=0;
+ int res1=SWIG_ConvertPtr(li,&da,SWIGTYPE_p_ParaMEDMEM__DataArrayInt, 0 | 0 );
+ if (!SWIG_IsOK(res1))
{
+ int size;
+ INTERP_KERNEL::AutoPtr<int> tmp=convertPyToNewIntArr2(li,&size);
self->renumberNodes(tmp);
}
- catch(INTERP_KERNEL::Exception& e)
+ else
{
- throw e;
+ DataArrayInt *da2=reinterpret_cast< DataArrayInt * >(da);
+ if(!da2)
+ throw INTERP_KERNEL::Exception("Not null DataArrayInt instance expected !");
+ da2->checkAllocated();
+ self->renumberNodes(da2->getConstPointer());
}
}
MEDCouplingFieldDouble *buildSubPart(PyObject *li) const throw(INTERP_KERNEL::Exception)
{
- int size;
- INTERP_KERNEL::AutoPtr<int> tmp=convertPyToNewIntArr2(li,&size);
- MEDCouplingFieldDouble *ret=0;
- try
+ void *da=0;
+ int res1=SWIG_ConvertPtr(li,&da,SWIGTYPE_p_ParaMEDMEM__DataArrayInt, 0 | 0 );
+ if (!SWIG_IsOK(res1))
{
- ret=self->buildSubPart(tmp,tmp+size);
+ int size;
+ INTERP_KERNEL::AutoPtr<int> tmp=convertPyToNewIntArr2(li,&size);
+ return self->buildSubPart(tmp,((const int *)tmp)+size);
}
- catch(INTERP_KERNEL::Exception& e)
+ else
{
- throw e;
+ DataArrayInt *da2=reinterpret_cast< DataArrayInt * >(da);
+ if(!da2)
+ throw INTERP_KERNEL::Exception("Not null DataArrayInt instance expected !");
+ da2->checkAllocated();
+ return self->buildSubPart(da2->getConstPointer(),da2->getConstPointer()+da2->getNbOfElems());
}
- return ret;
}
PyObject *getMaxValue2() const throw(INTERP_KERNEL::Exception)
}
}
};
+
+ class MEDCouplingFieldTemplate : public ParaMEDMEM::MEDCouplingField
+ {
+ public:
+ static MEDCouplingFieldTemplate *New(const MEDCouplingFieldDouble *f) throw(INTERP_KERNEL::Exception);
+ static MEDCouplingFieldTemplate *New(TypeOfField type);
+ std::string simpleRepr() const;
+ std::string advancedRepr() const;
+ %extend
+ {
+ std::string __str__() const
+ {
+ return self->simpleRepr();
+ }
+ }
+ };
+
+ class MEDCouplingMultiFields : public RefCountObject, public TimeLabel
+ {
+ public:
+ int getNumberOfFields() const;
+ MEDCouplingMultiFields *deepCpy() const;
+ virtual std::string simpleRepr() const;
+ virtual std::string advancedRepr() const;
+ virtual bool isEqual(const MEDCouplingMultiFields *other, double meshPrec, double valsPrec) const;
+ virtual bool isEqualWithoutConsideringStr(const MEDCouplingMultiFields *other, double meshPrec, double valsPrec) const;
+ virtual void checkCoherency() const throw(INTERP_KERNEL::Exception);
+ %extend
+ {
+ std::string __str__() const
+ {
+ return self->simpleRepr();
+ }
+ static MEDCouplingMultiFields *New(PyObject *li) throw(INTERP_KERNEL::Exception)
+ {
+ std::vector<const ParaMEDMEM::MEDCouplingFieldDouble *> tmp;
+ convertPyObjToVecFieldDblCst(li,tmp);
+ int sz=tmp.size();
+ std::vector<MEDCouplingFieldDouble *> fs(sz);
+ for(int i=0;i<sz;i++)
+ fs[i]=const_cast<MEDCouplingFieldDouble *>(tmp[i]);
+ return MEDCouplingMultiFields::New(fs);
+ }
+ PyObject *getFields() const
+ {
+ std::vector<const MEDCouplingFieldDouble *> fields=self->getFields();
+ int sz=fields.size();
+ PyObject *res = PyList_New(sz);
+ for(int i=0;i<sz;i++)
+ {
+ if(fields[i])
+ {
+ fields[i]->incrRef();
+ PyList_SetItem(res,i,SWIG_NewPointerObj(SWIG_as_voidptr(fields[i]),SWIGTYPE_p_ParaMEDMEM__MEDCouplingFieldDouble, SWIG_POINTER_OWN | 0 ));
+ }
+ else
+ {
+ PyList_SetItem(res,i,SWIG_NewPointerObj(SWIG_as_voidptr(0),SWIGTYPE_p_ParaMEDMEM__MEDCouplingFieldDouble, 0 ));
+ }
+ }
+ return res;
+ }
+ PyObject *getFieldAtPos(int id) const throw(INTERP_KERNEL::Exception)
+ {
+ const MEDCouplingFieldDouble *ret=self->getFieldAtPos(id);
+ if(ret)
+ {
+ ret->incrRef();
+ return SWIG_NewPointerObj(SWIG_as_voidptr(ret),SWIGTYPE_p_ParaMEDMEM__MEDCouplingFieldDouble, SWIG_POINTER_OWN | 0 );
+ }
+ else
+ return SWIG_NewPointerObj(SWIG_as_voidptr(0),SWIGTYPE_p_ParaMEDMEM__MEDCouplingFieldDouble, 0 );
+ }
+ PyObject *getMeshes() const throw(INTERP_KERNEL::Exception)
+ {
+ std::vector<MEDCouplingMesh *> ms=self->getMeshes();
+ int sz=ms.size();
+ PyObject *res = PyList_New(sz);
+ for(int i=0;i<sz;i++)
+ {
+ if(ms[i])
+ {
+ ms[i]->incrRef();
+ PyList_SetItem(res,i,convertMesh(ms[i], SWIG_POINTER_OWN | 0 ));
+ }
+ else
+ {
+ PyList_SetItem(res,i,SWIG_NewPointerObj(SWIG_as_voidptr(0),SWIGTYPE_p_ParaMEDMEM__MEDCouplingUMesh, 0 ));
+ }
+ }
+ return res;
+ }
+ PyObject *getDifferentMeshes() const throw(INTERP_KERNEL::Exception)
+ {
+ std::vector<int> refs;
+ std::vector<MEDCouplingMesh *> ms=self->getDifferentMeshes(refs);
+ int sz=ms.size();
+ PyObject *res = PyList_New(sz);
+ for(int i=0;i<sz;i++)
+ {
+ if(ms[i])
+ {
+ ms[i]->incrRef();
+ PyList_SetItem(res,i,convertMesh(ms[i], SWIG_POINTER_OWN | 0 ));
+ }
+ else
+ {
+ PyList_SetItem(res,i,SWIG_NewPointerObj(SWIG_as_voidptr(0),SWIGTYPE_p_ParaMEDMEM__MEDCouplingUMesh, 0 ));
+ }
+ }
+ //
+ PyObject *ret=PyTuple_New(2);
+ PyTuple_SetItem(ret,0,res);
+ PyTuple_SetItem(ret,1,convertIntArrToPyList2(refs));
+ return ret;
+ }
+ PyObject *getArrays() const throw(INTERP_KERNEL::Exception)
+ {
+ std::vector<DataArrayDouble *> ms=self->getArrays();
+ int sz=ms.size();
+ PyObject *res = PyList_New(sz);
+ for(int i=0;i<sz;i++)
+ {
+ if(ms[i])
+ {
+ ms[i]->incrRef();
+ PyList_SetItem(res,i,SWIG_NewPointerObj(SWIG_as_voidptr(ms[i]),SWIGTYPE_p_ParaMEDMEM__DataArrayDouble, SWIG_POINTER_OWN | 0 ));
+ }
+ else
+ {
+ PyList_SetItem(res,i,SWIG_NewPointerObj(SWIG_as_voidptr(0),SWIGTYPE_p_ParaMEDMEM__DataArrayDouble, 0 ));
+ }
+ }
+ return res;
+ }
+ PyObject *getDifferentArrays() const throw(INTERP_KERNEL::Exception)
+ {
+ std::vector< std::vector<int> > refs;
+ std::vector<DataArrayDouble *> ms=self->getDifferentArrays(refs);
+ int sz=ms.size();
+ PyObject *res = PyList_New(sz);
+ PyObject *res2 = PyList_New(sz);
+ for(int i=0;i<sz;i++)
+ {
+ if(ms[i])
+ {
+ ms[i]->incrRef();
+ PyList_SetItem(res,i,SWIG_NewPointerObj(SWIG_as_voidptr(ms[i]),SWIGTYPE_p_ParaMEDMEM__DataArrayDouble, SWIG_POINTER_OWN | 0 ));
+ }
+ else
+ {
+ PyList_SetItem(res,i,SWIG_NewPointerObj(SWIG_as_voidptr(0),SWIGTYPE_p_ParaMEDMEM__DataArrayDouble, 0 ));
+ }
+ PyList_SetItem(res2,i,convertIntArrToPyList2(refs[i]));
+ }
+ //
+ PyObject *ret=PyTuple_New(2);
+ PyTuple_SetItem(ret,0,res);
+ PyTuple_SetItem(ret,1,res2);
+ return ret;
+ }
+ }
+ };
+
+ class MEDCouplingDefinitionTime
+ {
+ public:
+ MEDCouplingDefinitionTime();
+ void assign(const MEDCouplingDefinitionTime& other);
+ bool isEqual(const MEDCouplingDefinitionTime& other) const;
+ double getTimeResolution() const;
+ std::vector<double> getHotSpotsTime() const;
+ %extend
+ {
+ std::string __str__() const
+ {
+ std::ostringstream oss;
+ self->appendRepr(oss);
+ return oss.str();
+ }
+
+ PyObject *getIdsOnTimeRight(double tm) const throw(INTERP_KERNEL::Exception)
+ {
+ int meshId,arrId,arrIdInField,fieldId;
+ self->getIdsOnTimeRight(tm,meshId,arrId,arrIdInField,fieldId);
+ PyObject *res=PyList_New(4);
+ PyList_SetItem(res,0,PyInt_FromLong(meshId));
+ PyList_SetItem(res,1,PyInt_FromLong(arrId));
+ PyList_SetItem(res,2,PyInt_FromLong(arrIdInField));
+ PyList_SetItem(res,3,PyInt_FromLong(fieldId));
+ return res;
+ }
+
+ PyObject *getIdsOnTimeLeft(double tm) const throw(INTERP_KERNEL::Exception)
+ {
+ int meshId,arrId,arrIdInField,fieldId;
+ self->getIdsOnTimeLeft(tm,meshId,arrId,arrIdInField,fieldId);
+ PyObject *res=PyList_New(4);
+ PyList_SetItem(res,0,PyInt_FromLong(meshId));
+ PyList_SetItem(res,1,PyInt_FromLong(arrId));
+ PyList_SetItem(res,2,PyInt_FromLong(arrIdInField));
+ PyList_SetItem(res,3,PyInt_FromLong(fieldId));
+ return res;
+ }
+ }
+ };
+
+ class MEDCouplingFieldOverTime : public MEDCouplingMultiFields
+ {
+ public:
+ double getTimeTolerance() const throw(INTERP_KERNEL::Exception);
+ MEDCouplingDefinitionTime getDefinitionTimeZone() const;
+
+ %extend
+ {
+ std::string __str__() const
+ {
+ return self->simpleRepr();
+ }
+ static MEDCouplingFieldOverTime *New(PyObject *li) throw(INTERP_KERNEL::Exception)
+ {
+ std::vector<const ParaMEDMEM::MEDCouplingFieldDouble *> tmp;
+ convertPyObjToVecFieldDblCst(li,tmp);
+ int sz=tmp.size();
+ std::vector<MEDCouplingFieldDouble *> fs(sz);
+ for(int i=0;i<sz;i++)
+ fs[i]=const_cast<MEDCouplingFieldDouble *>(tmp[i]);
+ return MEDCouplingFieldOverTime::New(fs);
+ }
+ }
+ };
}
-// Copyright (C) 2007-2010 CEA/DEN, EDF R&D
+// Copyright (C) 2007-2011 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 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.
+// 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
+// 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
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
%module MEDCouplingRemapper
# -*- coding: iso-8859-1 -*-
-# Copyright (C) 2007-2010 CEA/DEN, EDF R&D
+# Copyright (C) 2007-2011 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 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.
+# 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
+# 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
+# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
#
print """
-// Copyright (C) 2007-2010 CEA/DEN, EDF R&D
+// Copyright (C) 2007-2011 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 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.
+// 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
+// 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
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
#include "MEDFileBasis.hxx"
-// Copyright (C) 2007-2010 CEA/DEN, EDF R&D
+// Copyright (C) 2007-2011 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 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.
+// 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
+// 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
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
#ifndef __MEDFILEBASIS_HXX__
-// Copyright (C) 2007-2010 CEA/DEN, EDF R&D
+// Copyright (C) 2007-2011 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 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.
+// 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
+// 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
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
#include "MEDFileMesh.hxx"
#include "InterpKernelAutoPtr.hxx"
#include <limits>
+#include <cmath>
using namespace ParaMEDMEM;
-MEDFileMesh *MEDFileMesh::New(const char *fileName, const char *mName) throw(INTERP_KERNEL::Exception)
-{
- throw INTERP_KERNEL::Exception("Not implemented yet !");
-}
+const char MEDFileMesh::DFT_FAM_NAME[]="FAMILLE_ZERO";
-MEDFileUMesh *MEDFileUMesh::New(const char *fileName, const char *mName) throw(INTERP_KERNEL::Exception)
+MEDFileMesh::MEDFileMesh():_order(-1),_iteration(-1),_time(0.)
{
- return new MEDFileUMesh(fileName,mName);
}
-MEDFileUMesh *MEDFileUMesh::New(const char *fileName) throw(INTERP_KERNEL::Exception)
+MEDFileMesh *MEDFileMesh::New(const char *fileName) throw(INTERP_KERNEL::Exception)
{
std::vector<std::string> ms=MEDLoader::GetMeshNames(fileName);
if(ms.empty())
{
- std::ostringstream oss; oss << "MEDFileUMesh::New : no meshes in file \"" << fileName << "\" !";
+ std::ostringstream oss; oss << "MEDFileMesh::New : no meshes in file \"" << fileName << "\" !";
throw INTERP_KERNEL::Exception(oss.str().c_str());
}
- return new MEDFileUMesh(fileName,ms.front().c_str());
-}
-
-MEDFileUMesh *MEDFileUMesh::New()
-{
- return new MEDFileUMesh;
-}
-
-MEDFileUMesh::MEDFileUMesh():_too_long_str(0),_zipconn_pol(2)
-{
-}
-
-MEDFileUMesh::MEDFileUMesh(const char *fileName, const char *mName) throw(INTERP_KERNEL::Exception)
- try:_too_long_str(0)
- {
- MEDFileUtilities::CheckFileForRead(fileName);
- med_idt fid=MEDouvrir((char *)fileName,MED_LECTURE);
- MEDFileUMeshL2 loaderl2;
- loaderl2.loadAll(fid,MEDFileUMeshL2::getMeshIdFromName(fid,mName),mName);
- int lev=loaderl2.getNumberOfLevels();
- _ms.resize(lev);
- for(int i=0;i<lev;i++)
- {
- if(!loaderl2.emptyLev(i))
- _ms[i]=new MEDFileUMeshSplitL1(loaderl2,mName,i);
- else
- _ms[i]=0;
- }
- MEDFileUMeshL2::readFamiliesAndGrps(fid,mName,_families,_groups);
- MEDfermer(fid);
- //
- setName(loaderl2.getName());
- setDescription(loaderl2.getDescription());
- _coords=loaderl2.getCoords();
- _fam_coords=loaderl2.getCoordsFamily();
- _num_coords=loaderl2.getCoordsNum();
- computeRevNum();
- }
-catch(INTERP_KERNEL::Exception& e)
- {
- throw e;
- }
-
-MEDFileUMesh::~MEDFileUMesh()
-{
-}
-
-void MEDFileUMesh::write(const char *fileName, int mode) const throw(INTERP_KERNEL::Exception)
-{
- if(_name.empty())
- throw INTERP_KERNEL::Exception("MEDFileUMesh : name is empty. MED file ask for a NON EMPTY name !");
- if(!existsFamily(0))
- (const_cast<MEDFileUMesh *>(this))->addFamily(0,"FAMILLE_ZERO");
- med_mode_acces medmod=MEDFileUtilities::TraduceWriteMode(mode);
- med_idt fid=MEDouvrir((char *)fileName,medmod);
- std::ostringstream oss; oss << "MEDFileUMesh : error on attempt to write in file : \"" << fileName << "\"";
- MEDFileUtilities::CheckMEDCode(fid,fid,oss.str().c_str());
- const DataArrayDouble *coo=_coords;
- INTERP_KERNEL::AutoPtr<char> maa=MEDLoaderBase::buildEmptyString(MED_TAILLE_NOM);
- INTERP_KERNEL::AutoPtr<char> desc=MEDLoaderBase::buildEmptyString(MED_TAILLE_DESC);
- MEDLoaderBase::safeStrCpy(_name.c_str(),MED_TAILLE_NOM,maa,_too_long_str);
- MEDLoaderBase::safeStrCpy(_desc_name.c_str(),MED_TAILLE_DESC,desc,_too_long_str);
- int spaceDim=coo?coo->getNumberOfComponents():0;
- MEDmaaCr(fid,maa,spaceDim,MED_NON_STRUCTURE,desc);
- MEDdimEspaceCr(fid,maa,spaceDim);
- MEDFileUMeshL2::writeCoords(fid,maa,_coords,_fam_coords,_num_coords);
- int mdim=getMeshDimension();
- for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileUMeshSplitL1> >::const_iterator it=_ms.begin();it!=_ms.end();it++)
- if((const MEDFileUMeshSplitL1 *)(*it)!=0)
- (*it)->write(fid,maa,mdim);
- MEDFileUMeshL2::writeFamiliesAndGrps(fid,maa,_families,_groups,_too_long_str);
- MEDfermer(fid);
-}
-
-int MEDFileUMesh::getNumberOfNonEmptyLevels() const
-{
- int ret=0;
- for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileUMeshSplitL1> >::const_iterator it=_ms.begin();it!=_ms.end();it++)
- if((const MEDFileUMeshSplitL1 *)(*it)!=0)
- if(!(*it)->empty())
- ret++;
- return ret;
-}
-
-std::vector<int> MEDFileUMesh::getNonEmptyLevels() const
-{
- std::vector<int> ret;
- int lev=0;
- for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileUMeshSplitL1> >::const_iterator it=_ms.begin();it!=_ms.end();it++,lev--)
- if((const MEDFileUMeshSplitL1 *)(*it)!=0)
- if(!(*it)->empty())
- ret.push_back(lev);
- return ret;
-}
-
-std::vector<int> MEDFileUMesh::getNonEmptyLevelsExt() const
-{
- std::vector<int> ret0=getNonEmptyLevels();
- if((const DataArrayDouble *) _coords)
+ MEDFileUtilities::CheckFileForRead(fileName);
+ ParaMEDMEM::MEDCouplingMeshType meshType;
+ MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
+ int dt,it;
+ std::string dummy2;
+ MEDFileMeshL2::GetMeshIdFromName(fid,ms.front().c_str(),meshType,dt,it,dummy2);
+ switch(meshType)
{
- std::vector<int> ret(ret0.size()+1);
- ret[0]=1;
- std::copy(ret0.begin(),ret0.end(),ret.begin()+1);
- return ret;
+ case UNSTRUCTURED:
+ {
+ MEDCouplingAutoRefCountObjectPtr<MEDFileUMesh> ret=MEDFileUMesh::New();
+ ret->loadUMeshFromFile(fid,ms.front().c_str(),dt,it);
+ ret->incrRef();
+ return (MEDFileUMesh *)ret;
+ }
+ case CARTESIAN:
+ {
+ MEDCouplingAutoRefCountObjectPtr<MEDFileCMesh> ret=MEDFileCMesh::New();
+ ret->loadCMeshFromFile(fid,ms.front().c_str(),dt,it);
+ ret->incrRef();
+ return (MEDFileCMesh *)ret;
+ }
+ default:
+ {
+ std::ostringstream oss; oss << "MEDFileMesh::New : MED file exists and has mesh '" << ms.front() << "' exists but unsupported type yet !";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
}
- return ret0;
}
-int MEDFileUMesh::getFamilyId(const char *name) const throw(INTERP_KERNEL::Exception)
+MEDFileMesh *MEDFileMesh::New(const char *fileName, const char *mName, int dt, int it) throw(INTERP_KERNEL::Exception)
{
- std::string oname(name);
- std::map<std::string, int>::const_iterator it=_families.find(oname);
- std::vector<std::string> fams=getFamiliesNames();
- if(it==_families.end())
+ MEDFileUtilities::CheckFileForRead(fileName);
+ ParaMEDMEM::MEDCouplingMeshType meshType;
+ MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
+ int dummy0,dummy1;
+ std::string dummy2;
+ MEDFileMeshL2::GetMeshIdFromName(fid,mName,meshType,dummy0,dummy1,dummy2);
+ switch(meshType)
{
- std::ostringstream oss; oss << "No such familyname \"" << name << "\" !\nAvailable families are :";
- std::copy(fams.begin(),fams.end(),std::ostream_iterator<std::string>(oss," "));
- throw INTERP_KERNEL::Exception(oss.str().c_str());
+ case UNSTRUCTURED:
+ {
+ MEDCouplingAutoRefCountObjectPtr<MEDFileUMesh> ret=MEDFileUMesh::New();
+ ret->loadUMeshFromFile(fid,mName,dt,it);
+ ret->incrRef();
+ return (MEDFileUMesh *)ret;
+ }
+ case CARTESIAN:
+ {
+ MEDCouplingAutoRefCountObjectPtr<MEDFileCMesh> ret=MEDFileCMesh::New();
+ ret->loadCMeshFromFile(fid,mName,dt,it);
+ ret->incrRef();
+ return (MEDFileCMesh *)ret;
+ }
+ default:
+ {
+ std::ostringstream oss; oss << "MEDFileMesh::New : MED file exists and has mesh '" << mName << "' exists but unsupported type yet !";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
}
- return (*it).second;
}
-int MEDFileUMesh::getMaxFamilyId() const throw(INTERP_KERNEL::Exception)
+bool MEDFileMesh::isEqual(const MEDFileMesh *other, double eps, std::string& what) const
{
- if(_families.empty())
- throw INTERP_KERNEL::Exception("MEDFileUMesh::getMaxFamilyId : no families set !");
- int ret=-std::numeric_limits<int>::max();
- for(std::map<std::string,int>::const_iterator it=_families.begin();it!=_families.end();it++)
+ if(_order!=other->_order)
{
- ret=std::max((*it).second,ret);
+ what="Orders differ !";
+ return false;
}
- return ret;
-}
-
-std::vector<int> MEDFileUMesh::getFamiliesIds(const std::vector<std::string>& famNames) const throw(INTERP_KERNEL::Exception)
-{
- std::vector<int> famIds;
- for(std::vector<std::string>::const_iterator it=famNames.begin();it!=famNames.end();it++)
+ if(_iteration!=other->_iteration)
{
- std::map<std::string,int>::const_iterator it2=_families.find(*it);
- if(it2==_families.end())
- {
- std::ostringstream oss; oss << "No such family in mesh \"" << _name << "\" : " << *it;
- throw INTERP_KERNEL::Exception(oss.str().c_str());
- }
- famIds.push_back((*it2).second);
+ what="Iterations differ !";
+ return false;
+ }
+ if(fabs(_time-other->_time)>eps)
+ {
+ what="Time values differ !";
+ return false;
+ }
+ if(_dt_unit!=other->_dt_unit)
+ {
+ what="Time units differ !";
+ return false;
+ }
+ if(_name!=other->_name)
+ {
+ what="Names differ !";
+ return false;
+ }
+ if(_univ_name!=other->_univ_name)
+ {
+ what="Univ names differ !";
+ return false;
+ }
+ if(_desc_name!=other->_desc_name)
+ {
+ what="Description names differ !";
+ return false;
}
- return famIds;
+ if(!areGrpsEqual(other,what))
+ return false;
+ if(!areFamsEqual(other,what))
+ return false;
+ return true;
}
-std::string MEDFileUMesh::getFamilyNameGivenId(int id) const throw(INTERP_KERNEL::Exception)
+void MEDFileMesh::clearNonDiscrAttributes() const
{
- for(std::map<std::string,int>::const_iterator it=_families.begin();it!=_families.end();it++)
- if((*it).second==id)
- return (*it).first;
- std::ostringstream oss; oss << "MEDFileUMesh::getFamilyNameGivenId : no such family id : " << id;
- throw INTERP_KERNEL::Exception(oss.str().c_str());
+
}
-int MEDFileUMesh::getMeshDimension() const
+void MEDFileMesh::copyFamGrpMapsFrom(const MEDFileMesh& other)
{
- int lev=0;
- for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileUMeshSplitL1> >::const_iterator it=_ms.begin();it!=_ms.end();it++,lev++)
- if((const MEDFileUMeshSplitL1 *)(*it)!=0)
- return (*it)->getMeshDimension()+lev;
- throw INTERP_KERNEL::Exception("MEDFileUMesh::getMeshDimension : impossible to find a mesh dimension !");
+ _groups=other._groups;
+ _families=other._families;
}
-int MEDFileUMesh::getSizeAtLevel(int meshDimRelToMaxExt) const throw(INTERP_KERNEL::Exception)
+std::vector<std::string> MEDFileMesh::getFamiliesOnGroup(const char *name) const throw(INTERP_KERNEL::Exception)
{
- if(meshDimRelToMaxExt==1)
+ std::string oname(name);
+ std::map<std::string, std::vector<std::string> >::const_iterator it=_groups.find(oname);
+ std::vector<std::string> grps=getGroupsNames();
+ if(it==_groups.end())
{
- if(!((const DataArrayDouble *)_coords))
- throw INTERP_KERNEL::Exception("MEDFileUMesh::getSizeAtLevel : no coordinates specified !");
- return _coords->getNumberOfTuples();
+ std::ostringstream oss; oss << "No such groupname \"" << name << "\" !\nAvailable groups are :";
+ std::copy(grps.begin(),grps.end(),std::ostream_iterator<std::string>(oss," "));
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
}
- return getMeshAtLevSafe(meshDimRelToMaxExt)->getSize();
+ return (*it).second;
}
-const DataArrayInt *MEDFileUMesh::getFamilyFieldAtLevel(int meshDimRelToMaxExt) const throw(INTERP_KERNEL::Exception)
+std::vector<std::string> MEDFileMesh::getFamiliesOnGroups(const std::vector<std::string>& grps) const throw(INTERP_KERNEL::Exception)
{
- if(meshDimRelToMaxExt==1)
+ std::set<std::string> fams;
+ for(std::vector<std::string>::const_iterator it=grps.begin();it!=grps.end();it++)
{
- if(!((const DataArrayInt *)_fam_coords))
- throw INTERP_KERNEL::Exception("MEDFileUMesh::getFamilyFieldAtLevel : no coordinates specified !");
- return _fam_coords;
+ std::map<std::string, std::vector<std::string> >::const_iterator it2=_groups.find(*it);
+ if(it2==_groups.end())
+ {
+ std::ostringstream oss; oss << "No such group in mesh \"" << _name << "\" : " << *it;
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ fams.insert((*it2).second.begin(),(*it2).second.end());
}
- const MEDFileUMeshSplitL1 *l1=getMeshAtLevSafe(meshDimRelToMaxExt);
- return l1->getFamilyField();
+ std::vector<std::string> fams2(fams.begin(),fams.end());
+ return fams2;
}
-const DataArrayInt *MEDFileUMesh::getNumberFieldAtLevel(int meshDimRelToMaxExt) const throw(INTERP_KERNEL::Exception)
+std::vector<int> MEDFileMesh::getFamiliesIdsOnGroup(const char *name) const throw(INTERP_KERNEL::Exception)
{
- if(meshDimRelToMaxExt==1)
+ std::string oname(name);
+ std::map<std::string, std::vector<std::string> >::const_iterator it=_groups.find(oname);
+ std::vector<std::string> grps=getGroupsNames();
+ if(it==_groups.end())
{
- if(!((const DataArrayInt *)_num_coords))
- throw INTERP_KERNEL::Exception("MEDFileUMesh::getNumberFieldAtLevel : no coordinates renum specified !");
- return _num_coords;
+ std::ostringstream oss; oss << "No such groupname \"" << name << "\" !\nAvailable groups are :";
+ std::copy(grps.begin(),grps.end(),std::ostream_iterator<std::string>(oss," "));
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
}
- const MEDFileUMeshSplitL1 *l1=getMeshAtLevSafe(meshDimRelToMaxExt);
- return l1->getNumberField();
+ return getFamiliesIds((*it).second);
}
-const DataArrayInt *MEDFileUMesh::getRevNumberFieldAtLevel(int meshDimRelToMaxExt) const throw(INTERP_KERNEL::Exception)
+/*!
+ * This method sets families at a corresponding groups existing or not. If it existed, it is replaced by new 'fams'.
+ * Each entry in 'fams' is checked if it is not still existing default id 0 is set.
+ */
+void MEDFileMesh::setFamiliesOnGroup(const char *name, const std::vector<std::string>& fams) throw(INTERP_KERNEL::Exception)
{
- if(meshDimRelToMaxExt==1)
+ std::string oname(name);
+ _groups[oname]=fams;
+ for(std::vector<std::string>::const_iterator it1=fams.begin();it1!=fams.end();it1++)
{
- if(!((const DataArrayInt *)_num_coords))
- throw INTERP_KERNEL::Exception("MEDFileUMesh::getRevNumberFieldAtLevel : no coordinates renum specified !");
- return _rev_num_coords;
+ std::map<std::string,int>::iterator it2=_families.find(*it1);
+ if(it2==_families.end())
+ _families[*it1]=0;
}
- const MEDFileUMeshSplitL1 *l1=getMeshAtLevSafe(meshDimRelToMaxExt);
- return l1->getRevNumberField();
}
-std::vector<std::string> MEDFileUMesh::getFamiliesOnGroup(const char *name) const throw(INTERP_KERNEL::Exception)
+/*!
+ * Behaves as MEDFileMesh::setFamiliesOnGroup, except that if there is presence of a family id in 'famIds' not existing an exception is thrown.
+ * If several families have same id the first one in lexical order is taken into account.
+ */
+void MEDFileMesh::setFamiliesIdsOnGroup(const char *name, const std::vector<int>& famIds) throw(INTERP_KERNEL::Exception)
{
std::string oname(name);
- std::map<std::string, std::vector<std::string> >::const_iterator it=_groups.find(oname);
- std::vector<std::string> grps=getGroupsNames();
- if(it==_groups.end())
+ std::vector<std::string> fams(famIds.size());
+ int i=0;
+ for(std::vector<int>::const_iterator it1=famIds.begin();it1!=famIds.end();it1++,i++)
{
- std::ostringstream oss; oss << "No such groupname \"" << name << "\" !\nAvailable groups are :";
- std::copy(grps.begin(),grps.end(),std::ostream_iterator<std::string>(oss," "));
- throw INTERP_KERNEL::Exception(oss.str().c_str());
+ std::string name=getFamilyNameGivenId(*it1);
+ fams[i]=name;
}
- return (*it).second;
+ _groups[oname]=fams;
}
-std::vector<std::string> MEDFileUMesh::getGroupsOnFamily(const char *name) const throw(INTERP_KERNEL::Exception)
+std::vector<std::string> MEDFileMesh::getGroupsOnFamily(const char *name) const throw(INTERP_KERNEL::Exception)
{
std::vector<std::string> ret;
for(std::map<std::string, std::vector<std::string> >::const_iterator it1=_groups.begin();it1!=_groups.end();it1++)
return ret;
}
-std::vector<std::string> MEDFileUMesh::getGroupsNames() const
+/*!
+ * This method expects that family 'famName' is already existing. If not an exception will be thrown.
+ */
+void MEDFileMesh::setGroupsOnFamily(const char *famName, const std::vector<std::string>& grps) throw(INTERP_KERNEL::Exception)
+{
+ std::string fName(famName);
+ const std::map<std::string,int>::const_iterator it=_families.find(fName);
+ if(it==_families.end())
+ {
+ std::vector<std::string> fams=getFamiliesNames();
+ std::ostringstream oss; oss << "No such familyname \"" << fName << "\" !\nAvailable families are :";
+ std::copy(fams.begin(),fams.end(),std::ostream_iterator<std::string>(oss," "));
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ for(std::vector<std::string>::const_iterator it=grps.begin();it!=grps.end();it++)
+ {
+ std::map< std::string, std::vector<std::string> >::iterator it2=_groups.find(*it);
+ if(it2!=_groups.end())
+ (*it2).second.push_back(fName);
+ else
+ {
+ std::vector<std::string> grps(1,fName);
+ _groups[*it]=grps;
+ }
+ }
+}
+
+std::vector<std::string> MEDFileMesh::getGroupsNames() const
{
std::vector<std::string> ret(_groups.size());
int i=0;
return ret;
}
-std::vector<std::string> MEDFileUMesh::getFamiliesNames() const
+std::vector<std::string> MEDFileMesh::getFamiliesNames() const
{
std::vector<std::string> ret(_families.size());
int i=0;
return ret;
}
-void MEDFileUMesh::removeGroup(const char *name) throw(INTERP_KERNEL::Exception)
+void MEDFileMesh::removeGroup(const char *name) throw(INTERP_KERNEL::Exception)
{
std::string oname(name);
std::map<std::string, std::vector<std::string> >::iterator it=_groups.find(oname);
_groups.erase(it);
}
-void MEDFileUMesh::removeFamily(const char *name) throw(INTERP_KERNEL::Exception)
+void MEDFileMesh::removeFamily(const char *name) throw(INTERP_KERNEL::Exception)
{
std::string oname(name);
std::map<std::string, int >::iterator it=_families.find(oname);
_families.erase(it);
}
-void MEDFileUMesh::changeGroupName(const char *oldName, const char *newName) throw(INTERP_KERNEL::Exception)
+void MEDFileMesh::changeGroupName(const char *oldName, const char *newName) throw(INTERP_KERNEL::Exception)
{
std::string oname(oldName);
std::map<std::string, std::vector<std::string> >::iterator it=_groups.find(oname);
it=_groups.find(nname);
if(it!=_groups.end())
{
- std::ostringstream oss; oss << "Such groupname \"" << newName << " already exists ! Kill it before !";
+ std::ostringstream oss; oss << "Such groupname \"" << newName << "\" already exists ! Kill it before !";
throw INTERP_KERNEL::Exception(oss.str().c_str());
}
std::vector<std::string> cpy=(*it).second;
_groups[newName]=cpy;
}
-void MEDFileUMesh::changeFamilyName(const char *oldName, const char *newName) throw(INTERP_KERNEL::Exception)
+void MEDFileMesh::changeFamilyName(const char *oldName, const char *newName) throw(INTERP_KERNEL::Exception)
{
std::string oname(oldName);
std::map<std::string, int >::iterator it=_families.find(oname);
_families[newName]=cpy;
}
-DataArrayDouble *MEDFileUMesh::getCoords() const
-{
- MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> tmp(_coords);
- if((DataArrayDouble *)tmp)
- {
- tmp->incrRef();
- return tmp;
- }
- return 0;
-}
-
-MEDCouplingUMesh *MEDFileUMesh::getGroup(int meshDimRelToMaxExt, const char *grp, bool renum) const throw(INTERP_KERNEL::Exception)
-{
- std::vector<std::string> tmp(1);
- tmp[0]=grp;
- MEDCouplingUMesh *ret=getGroups(meshDimRelToMaxExt,tmp,renum);
- ret->setName(grp);
- return ret;
-}
-
-DataArrayInt *MEDFileUMesh::getGroupArr(int meshDimRelToMaxExt, const char *grp, bool renum) const throw(INTERP_KERNEL::Exception)
+bool MEDFileMesh::areFamsEqual(const MEDFileMesh *other, std::string& what) const
{
- std::vector<std::string> tmp(1);
- tmp[0]=grp;
- DataArrayInt *ret=getGroupsArr(meshDimRelToMaxExt,tmp,renum);
- ret->setName(grp);
- return ret;
+ if(_families==other->_families)
+ return true;
+ std::map<std::string,int> fam0;
+ std::map<std::string,int> fam1;
+ for(std::map<std::string,int>::const_iterator it=_families.begin();it!=_families.end();it++)
+ if((*it).second!=0)
+ fam0[(*it).first]=(*it).second;
+ for(std::map<std::string,int>::const_iterator it=other->_families.begin();it!=other->_families.end();it++)
+ if((*it).second!=0)
+ fam1[(*it).first]=(*it).second;
+ return fam0==fam1;
}
-MEDCouplingUMesh *MEDFileUMesh::getGroups(int meshDimRelToMaxExt, const std::vector<std::string>& grps, bool renum) const throw(INTERP_KERNEL::Exception)
+bool MEDFileMesh::areGrpsEqual(const MEDFileMesh *other, std::string& what) const
{
- std::set<std::string> fams;
- for(std::vector<std::string>::const_iterator it=grps.begin();it!=grps.end();it++)
+ if(_groups==other->_groups)
+ return true;
+ bool ret=true;
+ std::size_t sz=_groups.size();
+ if(sz!=other->_groups.size())
{
- std::map<std::string, std::vector<std::string> >::const_iterator it2=_groups.find(*it);
- if(it2==_groups.end())
+ what="Groups differ because not same number !\n";
+ ret=false;
+ }
+ if(ret)
+ {
+ std::map<std::string, std::vector<std::string> >::const_iterator it1=_groups.begin();
+ for(std::size_t i=0;i<sz && ret;i++,it1++)
{
- std::ostringstream oss; oss << "No such group in mesh \"" << _name << "\" : " << *it;
- throw INTERP_KERNEL::Exception(oss.str().c_str());
+ std::map<std::string, std::vector<std::string> >::const_iterator it2=other->_groups.find((*it1).first);
+ if(it2!=other->_groups.end())
+ {
+ std::set<std::string> s1((*it1).second.begin(),(*it1).second.end());
+ std::set<std::string> s2((*it2).second.begin(),(*it2).second.end());
+ ret=(s1==s2);
+ }
+ else
+ {
+ ret=false;
+ what="A group in first mesh exists not in other !\n";
+ }
}
- fams.insert((*it2).second.begin(),(*it2).second.end());
}
- std::vector<std::string> fams2(fams.begin(),fams.end());
- return getFamilies(meshDimRelToMaxExt,fams2,renum);
-}
-
-DataArrayInt *MEDFileUMesh::getGroupsArr(int meshDimRelToMaxExt, const std::vector<std::string>& grps, bool renum) const throw(INTERP_KERNEL::Exception)
-{
- std::set<std::string> fams;
- for(std::vector<std::string>::const_iterator it=grps.begin();it!=grps.end();it++)
+ if(!ret)
{
- std::map<std::string, std::vector<std::string> >::const_iterator it2=_groups.find(*it);
- if(it2==_groups.end())
+ std::ostringstream oss; oss << "Groups description differs :\n";
+ oss << "First group description :\n";
+ for(std::map<std::string, std::vector<std::string> >::const_iterator it=_groups.begin();it!=_groups.end();it++)
{
- std::ostringstream oss; oss << "No such group in mesh \"" << _name << "\" : " << *it;
- throw INTERP_KERNEL::Exception(oss.str().c_str());
+ oss << " Group \"" << (*it).first << "\" on following families :\n";
+ for(std::vector<std::string>::const_iterator it2=(*it).second.begin();it2!=(*it).second.end();it2++)
+ oss << " \"" << *it2 << "\n";
}
- fams.insert((*it2).second.begin(),(*it2).second.end());
+ oss << "Second group description :\n";
+ for(std::map<std::string, std::vector<std::string> >::const_iterator it=other->_groups.begin();it!=other->_groups.end();it++)
+ {
+ oss << " Group \"" << (*it).first << "\" on following families :\n";
+ for(std::vector<std::string>::const_iterator it2=(*it).second.begin();it2!=(*it).second.end();it2++)
+ oss << " \"" << *it2 << "\n";
+ }
+ what+=oss.str();
}
- std::vector<std::string> fams2(fams.begin(),fams.end());
- return getFamiliesArr(meshDimRelToMaxExt,fams2,renum);
+ return ret;
}
-MEDCouplingUMesh *MEDFileUMesh::getFamily(int meshDimRelToMaxExt, const char *fam, bool renum) const throw(INTERP_KERNEL::Exception)
+bool MEDFileMesh::existsFamily(int famId) const
{
- std::vector<std::string> tmp(1);
- tmp[0]=fam;
- MEDCouplingUMesh *ret=getFamilies(meshDimRelToMaxExt,tmp,renum);
- ret->setName(fam);
- return ret;
+ for(std::map<std::string,int>::const_iterator it2=_families.begin();it2!=_families.end();it2++)
+ if((*it2).second==famId)
+ return true;
+ return false;
}
-DataArrayInt *MEDFileUMesh::getFamilyArr(int meshDimRelToMaxExt, const char *fam, bool renum) const throw(INTERP_KERNEL::Exception)
+bool MEDFileMesh::existsFamily(const char *familyName) const
{
- std::vector<std::string> tmp(1);
- tmp[0]=fam;
- DataArrayInt *ret=getFamiliesArr(meshDimRelToMaxExt,tmp,renum);
- ret->setName(fam);
- return ret;
+ std::string fname(familyName);
+ return _families.find(fname)!=_families.end();
}
-MEDCouplingUMesh *MEDFileUMesh::getFamilies(int meshDimRelToMaxExt, const std::vector<std::string>& fams, bool renum) const throw(INTERP_KERNEL::Exception)
+void MEDFileMesh::setFamilyId(const char *familyName, int id)
{
- if(meshDimRelToMaxExt==1)
- {
- MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr=getFamiliesArr(1,fams,renum);
- MEDCouplingAutoRefCountObjectPtr<MEDCouplingUMesh> ret=MEDCouplingUMesh::New();
- MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> c=_coords->selectByTupleId(arr->getConstPointer(),arr->getConstPointer()+arr->getNbOfElems());
- ret->setCoords(c);
- ret->incrRef();
- return ret;
- }
- std::vector<int> famIds=getFamiliesIds(fams);
- const MEDFileUMeshSplitL1 *l1=getMeshAtLevSafe(meshDimRelToMaxExt);
- return l1->getFamilyPart(famIds,renum);
+ std::string fname(familyName);
+ _families[fname]=id;
}
-DataArrayInt *MEDFileUMesh::getFamiliesArr(int meshDimRelToMaxExt, const std::vector<std::string>& fams, bool renum) const throw(INTERP_KERNEL::Exception)
+/*!
+ * This method appends a new entry in _families attribute. An exception is thrown if either the famId is already
+ * kept by an another familyName. An exception is thrown if name 'familyName' is alreadyset with a different 'famId'.
+ */
+void MEDFileMesh::addFamily(const char *familyName, int famId) throw(INTERP_KERNEL::Exception)
{
- std::vector<int> famIds=getFamiliesIds(fams);
- if(meshDimRelToMaxExt==1)
+ std::string fname(familyName);
+ std::map<std::string,int>::const_iterator it=_families.find(fname);
+ if(it==_families.end())
+ {
+ for(std::map<std::string,int>::const_iterator it2=_families.begin();it2!=_families.end();it2++)
+ if((*it2).second==famId)
+ {
+ std::ostringstream oss;
+ oss << "MEDFileMesh::addFamily : Family \"" << (*it2).first << "\" already exists with specified id : " << famId << " !";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ _families[fname]=famId;
+ }
+ else
{
- MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da=_fam_coords->getIdsEqualList(famIds);
- return MEDFileUMeshSplitL1::Renumber(_num_coords,da);
+ if((*it).second!=famId)
+ {
+ std::ostringstream oss;
+ oss << "MEDFileMesh::addFamily : Family \"" << fname << "\" already exists but has id set to " << (*it).second << " different from asked famId " << famId << " !";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
}
- const MEDFileUMeshSplitL1 *l1=getMeshAtLevSafe(meshDimRelToMaxExt);
- return l1->getFamilyPartArr(famIds,renum);
}
-DataArrayInt *MEDFileUMesh::getNodeGroupArr(const char *grp, bool renum) const throw(INTERP_KERNEL::Exception)
+void MEDFileMesh::addGrpOnFamily(const char *grpName, const char *famName) throw(INTERP_KERNEL::Exception)
{
- std::vector<std::string> tmp(1);
- tmp[0]=grp;
- DataArrayInt *ret=getNodeGroupsArr(tmp,renum);
- ret->setName(grp);
- return ret;
+ std::string grpn(grpName);
+ std::string famn(famName);
+ if(grpn.empty() || famn.empty())
+ throw INTERP_KERNEL::Exception("MEDFileMesh::addGrpOnFamily : input strings must be non null !");
+ std::map<std::string, std::vector<std::string> >::iterator it=_groups.find(grpn);
+ if(it==_groups.end())
+ {
+ _groups[grpn].push_back(famn);
+ }
+ else
+ {
+ std::vector<std::string>::iterator it2=std::find((*it).second.begin(),(*it).second.end(),famn);
+ if(it2==(*it).second.end())
+ (*it).second.push_back(famn);
+ }
}
-DataArrayInt *MEDFileUMesh::getNodeGroupsArr(const std::vector<std::string>& grps, bool renum) const throw(INTERP_KERNEL::Exception)
+void MEDFileMesh::setFamilyInfo(const std::map<std::string,int>& info)
{
- return getGroupsArr(1,grps,renum);
+ _families=info;
}
-DataArrayInt *MEDFileUMesh::getNodeFamilyArr(const char *fam, bool renum) const throw(INTERP_KERNEL::Exception)
+void MEDFileMesh::setGroupInfo(const std::map<std::string, std::vector<std::string> >&info)
{
- std::vector<std::string> tmp(1);
- tmp[0]=fam;
- DataArrayInt *ret=getNodeFamiliesArr(tmp,renum);
- ret->setName(fam);
- return ret;
+ _groups=info;
}
-DataArrayInt *MEDFileUMesh::getNodeFamiliesArr(const std::vector<std::string>& fams, bool renum) const throw(INTERP_KERNEL::Exception)
+int MEDFileMesh::getFamilyId(const char *name) const throw(INTERP_KERNEL::Exception)
{
- return getFamiliesArr(1,fams,renum);
+ std::string oname(name);
+ std::map<std::string, int>::const_iterator it=_families.find(oname);
+ std::vector<std::string> fams=getFamiliesNames();
+ if(it==_families.end())
+ {
+ std::ostringstream oss; oss << "No such familyname \"" << name << "\" !\nAvailable families are :";
+ std::copy(fams.begin(),fams.end(),std::ostream_iterator<std::string>(oss," "));
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ return (*it).second;
}
-MEDCouplingUMesh *MEDFileUMesh::getMeshAtLevel(int meshDimRelToMaxExt, bool renum) const throw(INTERP_KERNEL::Exception)
+std::vector<int> MEDFileMesh::getFamiliesIds(const std::vector<std::string>& fams) const throw(INTERP_KERNEL::Exception)
{
- if(meshDimRelToMaxExt==1)
+ std::vector<int> ret(fams.size());
+ int i=0;
+ for(std::vector<std::string>::const_iterator it=fams.begin();it!=fams.end();it++,i++)
{
- if(!renum)
+ std::map<std::string, int>::const_iterator it2=_families.find(*it);
+ if(it2==_families.end())
{
- MEDCouplingUMesh *umesh=MEDCouplingUMesh::New();
- MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> cc=_coords->deepCpy();
- umesh->setCoords(cc);
- return umesh;
+ std::vector<std::string> fams2=getFamiliesNames();
+ std::ostringstream oss; oss << "No such familyname \"" << *it << "\" in input list !\nAvailable families are :";
+ std::copy(fams2.begin(),fams2.end(),std::ostream_iterator<std::string>(oss," "));
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
}
+ ret[i]=(*it2).second;
}
- const MEDFileUMeshSplitL1 *l1=getMeshAtLevSafe(meshDimRelToMaxExt);
- return l1->getWholeMesh(renum);
-}
-
-MEDCouplingUMesh *MEDFileUMesh::getLevel0Mesh(bool renum) const throw(INTERP_KERNEL::Exception)
-{
- return getMeshAtLevel(0,renum);
+ return ret;
}
-MEDCouplingUMesh *MEDFileUMesh::getLevelM1Mesh(bool renum) const throw(INTERP_KERNEL::Exception)
+int MEDFileMesh::getMaxFamilyId() const throw(INTERP_KERNEL::Exception)
{
- return getMeshAtLevel(-1,renum);
+ if(_families.empty())
+ throw INTERP_KERNEL::Exception("MEDFileUMesh::getMaxFamilyId : no families set !");
+ int ret=-std::numeric_limits<int>::max();
+ for(std::map<std::string,int>::const_iterator it=_families.begin();it!=_families.end();it++)
+ {
+ ret=std::max((*it).second,ret);
+ }
+ return ret;
}
-MEDCouplingUMesh *MEDFileUMesh::getLevelM2Mesh(bool renum) const throw(INTERP_KERNEL::Exception)
+/*!
+ * Returns the first (in lexical order) family name having family id equal to 'id'.
+ */
+std::string MEDFileMesh::getFamilyNameGivenId(int id) const throw(INTERP_KERNEL::Exception)
{
- return getMeshAtLevel(-2,renum);
+ for(std::map<std::string,int>::const_iterator it=_families.begin();it!=_families.end();it++)
+ if((*it).second==id)
+ return (*it).first;
+ std::ostringstream oss; oss << "MEDFileUMesh::getFamilyNameGivenId : no such family id : " << id;
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
}
-MEDCouplingUMesh *MEDFileUMesh::getLevelM3Mesh(bool renum) const throw(INTERP_KERNEL::Exception)
+DataArrayInt *MEDFileMesh::getGroupArr(int meshDimRelToMaxExt, const char *grp, bool renum) const throw(INTERP_KERNEL::Exception)
{
- return getMeshAtLevel(-3,renum);
+ std::vector<std::string> tmp(1);
+ tmp[0]=grp;
+ DataArrayInt *ret=getGroupsArr(meshDimRelToMaxExt,tmp,renum);
+ ret->setName(grp);
+ return ret;
}
-bool MEDFileUMesh::existsFamily(int famId) const
+DataArrayInt *MEDFileMesh::getGroupsArr(int meshDimRelToMaxExt, const std::vector<std::string>& grps, bool renum) const throw(INTERP_KERNEL::Exception)
{
- for(std::map<std::string,int>::const_iterator it2=_families.begin();it2!=_families.end();it2++)
- if((*it2).second==famId)
- return true;
- return false;
+ std::vector<std::string> fams2=getFamiliesOnGroups(grps);
+ return getFamiliesArr(meshDimRelToMaxExt,fams2,renum);
}
-bool MEDFileUMesh::existsFamily(const char *familyName) const
+DataArrayInt *MEDFileMesh::getFamilyArr(int meshDimRelToMaxExt, const char *fam, bool renum) const throw(INTERP_KERNEL::Exception)
{
- std::string fname(familyName);
- return _families.find(fname)!=_families.end();
+ std::vector<std::string> tmp(1);
+ tmp[0]=fam;
+ DataArrayInt *ret=getFamiliesArr(meshDimRelToMaxExt,tmp,renum);
+ ret->setName(fam);
+ return ret;
}
-const MEDFileUMeshSplitL1 *MEDFileUMesh::getMeshAtLevSafe(int meshDimRelToMaxExt) const throw(INTERP_KERNEL::Exception)
+DataArrayInt *MEDFileMesh::getNodeGroupArr(const char *grp, bool renum) const throw(INTERP_KERNEL::Exception)
{
- if(meshDimRelToMaxExt==1)
- throw INTERP_KERNEL::Exception("Dimension request is invalid : asking for node level (1) !");
- if(meshDimRelToMaxExt>1)
- throw INTERP_KERNEL::Exception("Dimension request is invalid (>1) !");
- int tracucedRk=-meshDimRelToMaxExt;
- if(tracucedRk>=(int)_ms.size())
- throw INTERP_KERNEL::Exception("Invalid mesh dim relative to max given ! To low !");
- if((const MEDFileUMeshSplitL1 *)_ms[tracucedRk]==0)
- throw INTERP_KERNEL::Exception("On specified lev (or entity) no cells exists !");
- return _ms[tracucedRk];
+ std::vector<std::string> tmp(1);
+ tmp[0]=grp;
+ DataArrayInt *ret=getNodeGroupsArr(tmp,renum);
+ ret->setName(grp);
+ return ret;
}
-MEDFileUMeshSplitL1 *MEDFileUMesh::getMeshAtLevSafe(int meshDimRelToMaxExt) throw(INTERP_KERNEL::Exception)
+DataArrayInt *MEDFileMesh::getNodeGroupsArr(const std::vector<std::string>& grps, bool renum) const throw(INTERP_KERNEL::Exception)
{
- if(meshDimRelToMaxExt==1)
- throw INTERP_KERNEL::Exception("Dimension request is invalid : asking for node level (1) !");
- if(meshDimRelToMaxExt>1)
- throw INTERP_KERNEL::Exception("Dimension request is invalid (>1) !");
- int tracucedRk=-meshDimRelToMaxExt;
- if(tracucedRk>=(int)_ms.size())
- throw INTERP_KERNEL::Exception("Invalid mesh dim relative to max given ! To low !");
- if((const MEDFileUMeshSplitL1 *)_ms[tracucedRk]==0)
- throw INTERP_KERNEL::Exception("On specified lev (or entity) no cells exists !");
- return _ms[tracucedRk];
+ return getGroupsArr(1,grps,renum);
}
-void MEDFileUMesh::checkMeshDimCoherency(int meshDim, int meshDimRelToMax) const throw(INTERP_KERNEL::Exception)
+DataArrayInt *MEDFileMesh::getNodeFamilyArr(const char *fam, bool renum) const throw(INTERP_KERNEL::Exception)
{
- if(-meshDimRelToMax>=(int)_ms.size())
- throw INTERP_KERNEL::Exception("MEDFileUMesh::checkMeshDimCoherency : The meshdim of mesh is not managed by 'this' !");
- int i=0;
- for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileUMeshSplitL1> >::const_iterator it=_ms.begin();it!=_ms.end();it++,i++)
- {
- if(((const MEDFileUMeshSplitL1*) (*it))!=0)
- {
- int ref=(*it)->getMeshDimension();
- if(ref+i!=meshDim-meshDimRelToMax)
- throw INTERP_KERNEL::Exception("MEDFileUMesh::checkMeshDimCoherency : no coherency between levels !");
- }
- }
+ std::vector<std::string> tmp(1);
+ tmp[0]=fam;
+ DataArrayInt *ret=getNodeFamiliesArr(tmp,renum);
+ ret->setName(fam);
+ return ret;
}
-void MEDFileUMesh::setCoords(DataArrayDouble *coords) throw(INTERP_KERNEL::Exception)
+DataArrayInt *MEDFileMesh::getNodeFamiliesArr(const std::vector<std::string>& fams, bool renum) const throw(INTERP_KERNEL::Exception)
{
- coords->checkAllocated();
- int nbOfTuples=coords->getNumberOfTuples();
- _coords=coords;
- coords->incrRef();
- _fam_coords=DataArrayInt::New();
- _fam_coords->alloc(nbOfTuples,1);
- _fam_coords->fillWithZero();
+ return getFamiliesArr(1,fams,renum);
}
-void MEDFileUMesh::setGroupsAtLevel(int meshDimRelToMaxExt, const std::vector<const DataArrayInt *>& grps, bool renum) throw(INTERP_KERNEL::Exception)
+void MEDFileMesh::setGroupsAtLevel(int meshDimRelToMaxExt, const std::vector<const DataArrayInt *>& grps, bool renum) throw(INTERP_KERNEL::Exception)
{
if(grps.empty())
return ;
TranslateFamilyIds(offset,fam,fidsOfGroups);
std::set<int> ids=fam->getDifferentValues();
appendFamilyEntries(ids,fidsOfGroups,grpsName2);
- setFamilyArr(meshDimRelToMaxExt,fam);
-}
-
-void MEDFileUMesh::eraseGroupsAtLevel(int meshDimRelToMaxExt) throw(INTERP_KERNEL::Exception)
-{
- if(meshDimRelToMaxExt==1)
- {
- if((DataArrayInt *)_fam_coords)
- _fam_coords->fillWithZero();
- return ;
- }
- MEDFileUMeshSplitL1 *l1=getMeshAtLevSafe(meshDimRelToMaxExt);
- l1->eraseFamilyField();
- optimizeFamilies();
+ setFamilyFieldArr(meshDimRelToMaxExt,fam);
}
-void MEDFileUMesh::optimizeFamilies() throw(INTERP_KERNEL::Exception)
+/*!
+ * This method append into '_families' attribute the families whose ids are in 'famIds'. Warning 'famIds' are expected to be ids
+ * not in '_families'. Groups information are given in parameters in order to give to families representative names.
+ * For the moment, the two last input parameters are not taken into account.
+ */
+void MEDFileMesh::appendFamilyEntries(const std::set<int>& famIds, const std::vector< std::vector<int> >& fidsOfGrps, const std::vector<std::string>& grpNames)
{
- std::vector<int> levs=getNonEmptyLevelsExt();
- std::set<int> allFamsIds;
- for(std::vector<int>::const_iterator it=levs.begin();it!=levs.end();it++)
- {
- const DataArrayInt *ffield=getFamilyFieldAtLevel(*it);
- std::set<int> ids=ffield->getDifferentValues();
- std::set<int> res;
- std::set_union(ids.begin(),ids.end(),allFamsIds.begin(),allFamsIds.end(),std::inserter(res,res.begin()));
- allFamsIds=res;
- }
- std::set<std::string> famNamesToKill;
- for(std::map<std::string,int>::const_iterator it=_families.begin();it!=_families.end();it++)
+ std::map<int,std::string> famInv;
+ for(std::set<int>::const_iterator it=famIds.begin();it!=famIds.end();it++)
{
- if(allFamsIds.find((*it).second)!=allFamsIds.end())
- famNamesToKill.insert((*it).first);
+ std::ostringstream oss;
+ oss << "Family_" << (*it);
+ _families[oss.str()]=(*it);
+ famInv[*it]=oss.str();
}
- for(std::set<std::string>::const_iterator it=famNamesToKill.begin();it!=famNamesToKill.end();it++)
- _families.erase(*it);
- std::vector<std::string> grpNamesToKill;
- for(std::map<std::string, std::vector<std::string> >::iterator it=_groups.begin();it!=_groups.end();it++)
+ int i=0;
+ for(std::vector< std::vector<int> >::const_iterator it1=fidsOfGrps.begin();it1!=fidsOfGrps.end();it1++,i++)
{
- std::vector<std::string> tmp;
- for(std::vector<std::string>::const_iterator it2=(*it).second.begin();it2!=(*it).second.end();it2++)
+ for(std::vector<int>::const_iterator it2=(*it1).begin();it2!=(*it1).end();it2++)
{
- if(famNamesToKill.find(*it2)==famNamesToKill.end())
- tmp.push_back(*it2);
+ _groups[grpNames[i]].push_back(famInv[*it2]);
}
- if(!tmp.empty())
- (*it).second=tmp;
- else
- tmp.push_back((*it).first);
}
- for(std::vector<std::string>::const_iterator it=grpNamesToKill.begin();it!=grpNamesToKill.end();it++)
- _groups.erase(*it);
}
-void MEDFileUMesh::setFamilyField(DataArrayInt *arr, const std::vector< std::vector< int > > &userfids, const std::vector<std::string>& grpNames, bool renum) throw(INTERP_KERNEL::Exception)
+void MEDFileMesh::TranslateFamilyIds(int offset, DataArrayInt *famArr, std::vector< std::vector<int> >& famIdsPerGrp)
{
-
+ famArr->applyLin(1,offset,0);
+ for(std::vector< std::vector<int> >::iterator it1=famIdsPerGrp.begin();it1!=famIdsPerGrp.end();it1++)
+ std::transform((*it1).begin(),(*it1).end(),(*it1).begin(),std::bind2nd(std::plus<int>(),offset));
}
-void MEDFileUMesh::addNodeGroup(const std::string& name, const std::vector<int>& ids) throw(INTERP_KERNEL::Exception)
+/*!
+ * This method should be called by any set* method of subclasses to deal automatically with _name attribute.
+ * If _name attribute is empty the name of 'm' if taken as _name attribute.
+ * If _name is not empty and that 'm' has the same name nothing is done.
+ * If _name is not emplt and that 'm' has \b NOT the same name an exception is thrown.
+ */
+void MEDFileMesh::dealWithTinyInfo(const MEDCouplingMesh *m) throw(INTERP_KERNEL::Exception)
{
- const DataArrayDouble *coords=_coords;
- if(!coords)
- throw INTERP_KERNEL::Exception("addNodeGroup : no coords set !");
+ if(_name.empty())
+ _name=m->getName();
+ else
+ {
+ std::string name(m->getName());
+ if(!name.empty())
+ {
+ if(_name!=name)
+ {
+ std::ostringstream oss; oss << "MEDFileMesh::dealWithTinyInfo : name of current MEDfile mesh is '" << _name << "' whereas name of input mesh is : '";
+ oss << name << "' ! Names must match !";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ }
+ }
+}
+
+MEDFileUMesh *MEDFileUMesh::New(const char *fileName, const char *mName, int dt, int it) throw(INTERP_KERNEL::Exception)
+{
+ MEDFileUtilities::CheckFileForRead(fileName);
+ MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
+ return new MEDFileUMesh(fid,mName,dt,it);
+}
+
+MEDFileUMesh *MEDFileUMesh::New(const char *fileName) throw(INTERP_KERNEL::Exception)
+{
+ std::vector<std::string> ms=MEDLoader::GetMeshNames(fileName);
+ if(ms.empty())
+ {
+ std::ostringstream oss; oss << "MEDFileUMesh::New : no meshes in file \"" << fileName << "\" !";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ MEDFileUtilities::CheckFileForRead(fileName);
+ MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
+ int dt,it;
+ ParaMEDMEM::MEDCouplingMeshType meshType;
+ std::string dummy2;
+ MEDFileMeshL2::GetMeshIdFromName(fid,ms.front().c_str(),meshType,dt,it,dummy2);
+ return new MEDFileUMesh(fid,ms.front().c_str(),dt,it);
+}
+
+MEDFileUMesh *MEDFileUMesh::New()
+{
+ return new MEDFileUMesh;
+}
+
+bool MEDFileUMesh::isEqual(const MEDFileMesh *other, double eps, std::string& what) const
+{
+ if(!MEDFileMesh::isEqual(other,eps,what))
+ return false;
+ const MEDFileUMesh *otherC=dynamic_cast<const MEDFileUMesh *>(other);
+ if(!otherC)
+ {
+ what="Mesh types differ ! This is unstructured and other is NOT !";
+ return false;
+ }
+ clearNonDiscrAttributes();
+ otherC->clearNonDiscrAttributes();
+ const DataArrayDouble *coo1=_coords;
+ const DataArrayDouble *coo2=otherC->_coords;
+ if((coo1==0 && coo2!=0) || (coo1!=0 && coo2==0))
+ {
+ what="Mismatch of coordinates ! One is defined and not other !";
+ return false;
+ }
+ if(coo1)
+ {
+ bool ret=coo1->isEqual(*coo2,eps);
+ if(!ret)
+ {
+ what="Coords differ !";
+ return false;
+ }
+ }
+ const DataArrayInt *famc1=_fam_coords;
+ const DataArrayInt *famc2=otherC->_fam_coords;
+ if((famc1==0 && famc2!=0) || (famc1!=0 && famc2==0))
+ {
+ what="Mismatch of families arr on nodes ! One is defined and not other !";
+ return false;
+ }
+ if(famc1)
+ {
+ bool ret=famc1->isEqual(*famc2);
+ if(!ret)
+ {
+ what="Families arr on node differ !";
+ return false;
+ }
+ }
+ const DataArrayInt *numc1=_num_coords;
+ const DataArrayInt *numc2=otherC->_num_coords;
+ if((numc1==0 && numc2!=0) || (numc1!=0 && numc2==0))
+ {
+ what="Mismatch of numbering arr on nodes ! One is defined and not other !";
+ return false;
+ }
+ if(numc1)
+ {
+ bool ret=numc1->isEqual(*numc2);
+ if(!ret)
+ {
+ what="Numbering arr on node differ !";
+ return false;
+ }
+ }
+ if(_ms.size()!=otherC->_ms.size())
+ {
+ what="Number of levels differs !";
+ return false;
+ }
+ std::size_t sz=_ms.size();
+ for(std::size_t i=0;i<sz;i++)
+ {
+ const MEDFileUMeshSplitL1 *s1=_ms[i];
+ const MEDFileUMeshSplitL1 *s2=otherC->_ms[i];
+ if((s1==0 && s2!=0) || (s1!=0 && s2==0))
+ {
+ what="Mismatch of presence of sub levels !";
+ return false;
+ }
+ if(s1)
+ {
+ bool ret=s1->isEqual(s2,eps,what);
+ if(!ret)
+ return false;
+ }
+ }
+ std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileUMeshSplitL1> > _ms;
+ return true;
+}
+
+void MEDFileUMesh::clearNonDiscrAttributes() const
+{
+ MEDFileMesh::clearNonDiscrAttributes();
+ const DataArrayDouble *coo1=_coords;
+ if(coo1)
+ ((DataArrayDouble *)coo1)->setName("");//This parameter is not discriminant for comparison
+ const DataArrayInt *famc1=_fam_coords;
+ if(famc1)
+ ((DataArrayInt *)famc1)->setName("");//This parameter is not discriminant for comparison
+ const DataArrayInt *numc1=_num_coords;
+ if(numc1)
+ ((DataArrayInt *)numc1)->setName("");//This parameter is not discriminant for comparison
+ for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileUMeshSplitL1> >::const_iterator it=_ms.begin();it!=_ms.end();it++)
+ {
+ const MEDFileUMeshSplitL1 *tmp=(*it);
+ if(tmp)
+ tmp->clearNonDiscrAttributes();
+ }
+}
+
+MEDFileUMesh::MEDFileUMesh()
+{
+}
+
+MEDFileUMesh::MEDFileUMesh(med_idt fid, const char *mName, int dt, int it) throw(INTERP_KERNEL::Exception)
+try
+ {
+ loadUMeshFromFile(fid,mName,dt,it);
+ }
+catch(INTERP_KERNEL::Exception& e)
+ {
+ throw e;
+ }
+
+void MEDFileUMesh::loadUMeshFromFile(med_idt fid, const char *mName, int dt, int it) throw(INTERP_KERNEL::Exception)
+{
+ MEDFileUMeshL2 loaderl2;
+ ParaMEDMEM::MEDCouplingMeshType meshType;
+ int dummy0,dummy1;
+ std::string dummy2;
+ int mid=MEDFileUMeshL2::GetMeshIdFromName(fid,mName,meshType,dummy0,dummy1,dummy2);
+ if(meshType!=UNSTRUCTURED)
+ {
+ std::ostringstream oss; oss << "Trying to load as unstructured an existing mesh with name '" << mName << "' !";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ loaderl2.loadAll(fid,mid,mName,dt,it);
+ int lev=loaderl2.getNumberOfLevels();
+ _ms.resize(lev);
+ for(int i=0;i<lev;i++)
+ {
+ if(!loaderl2.emptyLev(i))
+ _ms[i]=new MEDFileUMeshSplitL1(loaderl2,mName,i);
+ else
+ _ms[i]=0;
+ }
+ MEDFileMeshL2::ReadFamiliesAndGrps(fid,mName,_families,_groups);
+ //
+ setName(loaderl2.getName());
+ setDescription(loaderl2.getDescription());
+ setIteration(loaderl2.getIteration());
+ setOrder(loaderl2.getOrder());
+ setTimeValue(loaderl2.getTime());
+ setTimeUnit(loaderl2.getTimeUnit());
+ _coords=loaderl2.getCoords();
+ _fam_coords=loaderl2.getCoordsFamily();
+ _num_coords=loaderl2.getCoordsNum();
+ computeRevNum();
+}
+
+MEDFileUMesh::~MEDFileUMesh()
+{
+}
+
+void MEDFileUMesh::write(const char *fileName, int mode) const throw(INTERP_KERNEL::Exception)
+{
+ if(_name.empty())
+ throw INTERP_KERNEL::Exception("MEDFileUMesh : name is empty. MED file ask for a NON EMPTY name !");
+ if(!existsFamily(0))
+ (const_cast<MEDFileUMesh *>(this))->addFamily(DFT_FAM_NAME,0);
+ med_access_mode medmod=MEDFileUtilities::TraduceWriteMode(mode);
+ MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,medmod);
+ std::ostringstream oss; oss << "MEDFileUMesh : error on attempt to write in file : \"" << fileName << "\"";
+ MEDFileUtilities::CheckMEDCode(fid,fid,oss.str().c_str());
+ const DataArrayDouble *coo=_coords;
+ INTERP_KERNEL::AutoPtr<char> maa=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
+ INTERP_KERNEL::AutoPtr<char> desc=MEDLoaderBase::buildEmptyString(MED_COMMENT_SIZE);
+ MEDLoaderBase::safeStrCpy(_name.c_str(),MED_NAME_SIZE,maa,_too_long_str);
+ MEDLoaderBase::safeStrCpy(_desc_name.c_str(),MED_COMMENT_SIZE,desc,_too_long_str);
+ int spaceDim=coo?coo->getNumberOfComponents():0;
+ int mdim=getMeshDimension();
+ INTERP_KERNEL::AutoPtr<char> comp=MEDLoaderBase::buildEmptyString(spaceDim*MED_SNAME_SIZE);
+ INTERP_KERNEL::AutoPtr<char> unit=MEDLoaderBase::buildEmptyString(spaceDim*MED_SNAME_SIZE);
+ for(int i=0;i<spaceDim;i++)
+ {
+ std::string info=coo->getInfoOnComponent(i);
+ std::string c,u;
+ MEDLoaderBase::splitIntoNameAndUnit(info,c,u);
+ MEDLoaderBase::safeStrCpy2(c.c_str(),MED_SNAME_SIZE-1,comp+i*MED_SNAME_SIZE,_too_long_str);//MED_TAILLE_PNOM-1 to avoid to write '\0' on next compo
+ MEDLoaderBase::safeStrCpy2(u.c_str(),MED_SNAME_SIZE-1,unit+i*MED_SNAME_SIZE,_too_long_str);//MED_TAILLE_PNOM-1 to avoid to write '\0' on next compo
+ }
+ MEDmeshCr(fid,maa,spaceDim,mdim,MED_UNSTRUCTURED_MESH,desc,"",MED_SORT_DTIT,MED_CARTESIAN,comp,unit);
+ MEDFileUMeshL2::WriteCoords(fid,maa,_iteration,_order,_time,_coords,_fam_coords,_num_coords);
+ for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileUMeshSplitL1> >::const_iterator it=_ms.begin();it!=_ms.end();it++)
+ if((const MEDFileUMeshSplitL1 *)(*it)!=0)
+ (*it)->write(fid,maa,mdim);
+ MEDFileUMeshL2::WriteFamiliesAndGrps(fid,maa,_families,_groups,_too_long_str);
+}
+
+std::vector<int> MEDFileUMesh::getNonEmptyLevels() const
+{
+ std::vector<int> ret;
+ int lev=0;
+ for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileUMeshSplitL1> >::const_iterator it=_ms.begin();it!=_ms.end();it++,lev--)
+ if((const MEDFileUMeshSplitL1 *)(*it)!=0)
+ if(!(*it)->empty())
+ ret.push_back(lev);
+ return ret;
+}
+
+std::vector<int> MEDFileUMesh::getNonEmptyLevelsExt() const
+{
+ std::vector<int> ret0=getNonEmptyLevels();
+ if((const DataArrayDouble *) _coords)
+ {
+ std::vector<int> ret(ret0.size()+1);
+ ret[0]=1;
+ std::copy(ret0.begin(),ret0.end(),ret.begin()+1);
+ return ret;
+ }
+ return ret0;
+}
+
+/*!
+ * This methods returns all relative mesh levels where group 'grp' is defined \b excluded \b nodes.
+ * To include nodes call MEDFileUMesh::getGrpNonEmptyLevelsExt method.
+ */
+std::vector<int> MEDFileUMesh::getGrpNonEmptyLevels(const char *grp) const throw(INTERP_KERNEL::Exception)
+{
+ std::vector<std::string> fams=getFamiliesOnGroup(grp);
+ return getFamsNonEmptyLevels(fams);
+}
+
+/*!
+ * This method is a generalization of MEDFileUMesh::getGrpNonEmptyLevelsExt. It looks at the node level to state if the group 'grp' has a part lying on node.
+ */
+std::vector<int> MEDFileUMesh::getGrpNonEmptyLevelsExt(const char *grp) const throw(INTERP_KERNEL::Exception)
+{
+ std::vector<std::string> fams=getFamiliesOnGroup(grp);
+ return getFamsNonEmptyLevelsExt(fams);
+}
+
+/*!
+ * This methods returns all relative mesh levels where family 'fam' is defined \b excluded \b nodes.
+ * To include nodes call MEDFileUMesh::getFamNonEmptyLevelsExt method.
+ */
+std::vector<int> MEDFileUMesh::getFamNonEmptyLevels(const char *fam) const throw(INTERP_KERNEL::Exception)
+{
+ std::vector<std::string> fams(1,std::string(fam));
+ return getFamsNonEmptyLevels(fams);
+}
+
+/*!
+ * This method is a generalization of MEDFileUMesh::getFamNonEmptyLevels. It looks at the node level to state if the family 'fam' has a part lying on node.
+ */
+std::vector<int> MEDFileUMesh::getFamNonEmptyLevelsExt(const char *fam) const throw(INTERP_KERNEL::Exception)
+{
+ std::vector<std::string> fams(1,std::string(fam));
+ return getFamsNonEmptyLevelsExt(fams);
+}
+
+/*!
+ * This methods returns all relative mesh levels where groups 'grps' are defined \b excluded \b nodes.
+ * To include nodes call MEDFileUMesh::getGrpsNonEmptyLevelsExt method.
+ */
+std::vector<int> MEDFileUMesh::getGrpsNonEmptyLevels(const std::vector<std::string>& grps) const throw(INTERP_KERNEL::Exception)
+{
+ std::vector<std::string> fams=getFamiliesOnGroups(grps);
+ return getFamsNonEmptyLevels(fams);
+}
+
+/*!
+ * This method is a generalization of MEDFileUMesh::getGrpsNonEmptyLevels. It looks at the node level to state if the families 'fams' has a part lying on node.
+ */
+std::vector<int> MEDFileUMesh::getGrpsNonEmptyLevelsExt(const std::vector<std::string>& grps) const throw(INTERP_KERNEL::Exception)
+{
+ std::vector<std::string> fams=getFamiliesOnGroups(grps);
+ return getFamsNonEmptyLevelsExt(fams);
+}
+
+/*!
+ * This methods returns all relative mesh levels where families 'fams' are defined \b excluded \b nodes.
+ * To include nodes call MEDFileUMesh::getFamsNonEmptyLevelsExt method.
+ */
+std::vector<int> MEDFileUMesh::getFamsNonEmptyLevels(const std::vector<std::string>& fams) const throw(INTERP_KERNEL::Exception)
+{
+ std::vector<int> ret;
+ std::vector<int> levs=getNonEmptyLevels();
+ std::vector<int> famIds=getFamiliesIds(fams);
+ for(std::vector<int>::const_iterator it=levs.begin();it!=levs.end();it++)
+ if(_ms[-(*it)]->presenceOfOneFams(famIds))
+ ret.push_back(*it);
+ return ret;
+}
+
+/*!
+ * This method is a generalization of MEDFileUMesh::getFamsNonEmptyLevels. It looks at the node level to state if the families 'fams' has a part lying on node.
+ */
+std::vector<int> MEDFileUMesh::getFamsNonEmptyLevelsExt(const std::vector<std::string>& fams) const throw(INTERP_KERNEL::Exception)
+{
+ std::vector<int> ret0=getFamsNonEmptyLevels(fams);
+ const DataArrayInt *famCoords=_fam_coords;
+ if(!famCoords)
+ return ret0;
+ std::vector<int> famIds=getFamiliesIds(fams);
+ if(famCoords->presenceOfValue(famIds))
+ {
+ std::vector<int> ret(ret0.size()+1);
+ ret[0]=1;
+ std::copy(ret0.begin(),ret0.end(),ret.begin()+1);
+ return ret;
+ }
+ else
+ return ret0;
+}
+
+int MEDFileUMesh::getMeshDimension() const throw(INTERP_KERNEL::Exception)
+{
+ int lev=0;
+ for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileUMeshSplitL1> >::const_iterator it=_ms.begin();it!=_ms.end();it++,lev++)
+ if((const MEDFileUMeshSplitL1 *)(*it)!=0)
+ return (*it)->getMeshDimension()+lev;
+ throw INTERP_KERNEL::Exception("MEDFileUMesh::getMeshDimension : impossible to find a mesh dimension !");
+}
+
+int MEDFileUMesh::getSizeAtLevel(int meshDimRelToMaxExt) const throw(INTERP_KERNEL::Exception)
+{
+ if(meshDimRelToMaxExt==1)
+ {
+ if(!((const DataArrayDouble *)_coords))
+ throw INTERP_KERNEL::Exception("MEDFileUMesh::getSizeAtLevel : no coordinates specified !");
+ return _coords->getNumberOfTuples();
+ }
+ return getMeshAtLevSafe(meshDimRelToMaxExt)->getSize();
+}
+
+const DataArrayInt *MEDFileUMesh::getFamilyFieldAtLevel(int meshDimRelToMaxExt) const throw(INTERP_KERNEL::Exception)
+{
+ if(meshDimRelToMaxExt==1)
+ {
+ if(!((const DataArrayInt *)_fam_coords))
+ throw INTERP_KERNEL::Exception("MEDFileUMesh::getFamilyFieldAtLevel : no coordinates specified !");
+ return _fam_coords;
+ }
+ const MEDFileUMeshSplitL1 *l1=getMeshAtLevSafe(meshDimRelToMaxExt);
+ return l1->getFamilyField();
+}
+
+const DataArrayInt *MEDFileUMesh::getNumberFieldAtLevel(int meshDimRelToMaxExt) const throw(INTERP_KERNEL::Exception)
+{
+ if(meshDimRelToMaxExt==1)
+ return _num_coords;
+ const MEDFileUMeshSplitL1 *l1=getMeshAtLevSafe(meshDimRelToMaxExt);
+ return l1->getNumberField();
+}
+
+const DataArrayInt *MEDFileUMesh::getRevNumberFieldAtLevel(int meshDimRelToMaxExt) const throw(INTERP_KERNEL::Exception)
+{
+ if(meshDimRelToMaxExt==1)
+ {
+ if(!((const DataArrayInt *)_num_coords))
+ throw INTERP_KERNEL::Exception("MEDFileUMesh::getRevNumberFieldAtLevel : no coordinates renum specified !");
+ return _rev_num_coords;
+ }
+ const MEDFileUMeshSplitL1 *l1=getMeshAtLevSafe(meshDimRelToMaxExt);
+ return l1->getRevNumberField();
+}
+
+DataArrayDouble *MEDFileUMesh::getCoords() const
+{
+ MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> tmp(_coords);
+ if((DataArrayDouble *)tmp)
+ {
+ tmp->incrRef();
+ return tmp;
+ }
+ return 0;
+}
+
+MEDCouplingUMesh *MEDFileUMesh::getGroup(int meshDimRelToMaxExt, const char *grp, bool renum) const throw(INTERP_KERNEL::Exception)
+{
+ synchronizeTinyInfoOnLeaves();
+ std::vector<std::string> tmp(1);
+ tmp[0]=grp;
+ MEDCouplingUMesh *ret=getGroups(meshDimRelToMaxExt,tmp,renum);
+ ret->setName(grp);
+ return ret;
+}
+
+MEDCouplingUMesh *MEDFileUMesh::getGroups(int meshDimRelToMaxExt, const std::vector<std::string>& grps, bool renum) const throw(INTERP_KERNEL::Exception)
+{
+ synchronizeTinyInfoOnLeaves();
+ std::vector<std::string> fams2=getFamiliesOnGroups(grps);
+ return getFamilies(meshDimRelToMaxExt,fams2,renum);
+}
+
+MEDCouplingUMesh *MEDFileUMesh::getFamily(int meshDimRelToMaxExt, const char *fam, bool renum) const throw(INTERP_KERNEL::Exception)
+{
+ synchronizeTinyInfoOnLeaves();
+ std::vector<std::string> tmp(1);
+ tmp[0]=fam;
+ MEDCouplingUMesh *ret=getFamilies(meshDimRelToMaxExt,tmp,renum);
+ ret->setName(fam);
+ return ret;
+}
+
+MEDCouplingUMesh *MEDFileUMesh::getFamilies(int meshDimRelToMaxExt, const std::vector<std::string>& fams, bool renum) const throw(INTERP_KERNEL::Exception)
+{
+ synchronizeTinyInfoOnLeaves();
+ if(meshDimRelToMaxExt==1)
+ {
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr=getFamiliesArr(1,fams,renum);
+ MEDCouplingAutoRefCountObjectPtr<MEDCouplingUMesh> ret=MEDCouplingUMesh::New();
+ MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> c=_coords->selectByTupleId(arr->getConstPointer(),arr->getConstPointer()+arr->getNbOfElems());
+ ret->setCoords(c);
+ ret->incrRef();
+ return ret;
+ }
+ std::vector<int> famIds=getFamiliesIds(fams);
+ const MEDFileUMeshSplitL1 *l1=getMeshAtLevSafe(meshDimRelToMaxExt);
+ return l1->getFamilyPart(famIds,renum);
+}
+
+DataArrayInt *MEDFileUMesh::getFamiliesArr(int meshDimRelToMaxExt, const std::vector<std::string>& fams, bool renum) const throw(INTERP_KERNEL::Exception)
+{
+ std::vector<int> famIds=getFamiliesIds(fams);
+ if(meshDimRelToMaxExt==1)
+ {
+ if((const DataArrayInt *)_fam_coords)
+ {
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da=_fam_coords->getIdsEqualList(famIds);
+ if(renum)
+ return MEDFileUMeshSplitL1::Renumber(_num_coords,da);
+ else
+ {
+ da->incrRef();
+ return da;
+ }
+ }
+ else
+ throw INTERP_KERNEL::Exception("MEDFileUMesh::getFamiliesArr : no family array specified on nodes !");
+ }
+ const MEDFileUMeshSplitL1 *l1=getMeshAtLevSafe(meshDimRelToMaxExt);
+ return l1->getFamilyPartArr(famIds,renum);
+}
+
+MEDCouplingUMesh *MEDFileUMesh::getMeshAtLevel(int meshDimRelToMaxExt, bool renum) const throw(INTERP_KERNEL::Exception)
+{
+ synchronizeTinyInfoOnLeaves();
+ if(meshDimRelToMaxExt==1)
+ {
+ if(!renum)
+ {
+ MEDCouplingUMesh *umesh=MEDCouplingUMesh::New();
+ MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> cc=_coords->deepCpy();
+ umesh->setCoords(cc);
+ MEDFileUMeshSplitL1::ClearNonDiscrAttributes(umesh);
+ return umesh;
+ }
+ }
+ const MEDFileUMeshSplitL1 *l1=getMeshAtLevSafe(meshDimRelToMaxExt);
+ return l1->getWholeMesh(renum);
+}
+
+MEDCouplingMesh *MEDFileUMesh::getGenMeshAtLevel(int meshDimRelToMax, bool renum) const throw(INTERP_KERNEL::Exception)
+{
+ return getMeshAtLevel(meshDimRelToMax,renum);
+}
+
+MEDCouplingUMesh *MEDFileUMesh::getLevel0Mesh(bool renum) const throw(INTERP_KERNEL::Exception)
+{
+ return getMeshAtLevel(0,renum);
+}
+
+MEDCouplingUMesh *MEDFileUMesh::getLevelM1Mesh(bool renum) const throw(INTERP_KERNEL::Exception)
+{
+ return getMeshAtLevel(-1,renum);
+}
+
+MEDCouplingUMesh *MEDFileUMesh::getLevelM2Mesh(bool renum) const throw(INTERP_KERNEL::Exception)
+{
+ return getMeshAtLevel(-2,renum);
+}
+
+MEDCouplingUMesh *MEDFileUMesh::getLevelM3Mesh(bool renum) const throw(INTERP_KERNEL::Exception)
+{
+ return getMeshAtLevel(-3,renum);
+}
+
+const MEDFileUMeshSplitL1 *MEDFileUMesh::getMeshAtLevSafe(int meshDimRelToMaxExt) const throw(INTERP_KERNEL::Exception)
+{
+ if(meshDimRelToMaxExt==1)
+ throw INTERP_KERNEL::Exception("Dimension request is invalid : asking for node level (1) !");
+ if(meshDimRelToMaxExt>1)
+ throw INTERP_KERNEL::Exception("Dimension request is invalid (>1) !");
+ int tracucedRk=-meshDimRelToMaxExt;
+ if(tracucedRk>=(int)_ms.size())
+ throw INTERP_KERNEL::Exception("Invalid mesh dim relative to max given ! To low !");
+ if((const MEDFileUMeshSplitL1 *)_ms[tracucedRk]==0)
+ throw INTERP_KERNEL::Exception("On specified lev (or entity) no cells exists !");
+ return _ms[tracucedRk];
+}
+
+MEDFileUMeshSplitL1 *MEDFileUMesh::getMeshAtLevSafe(int meshDimRelToMaxExt) throw(INTERP_KERNEL::Exception)
+{
+ if(meshDimRelToMaxExt==1)
+ throw INTERP_KERNEL::Exception("Dimension request is invalid : asking for node level (1) !");
+ if(meshDimRelToMaxExt>1)
+ throw INTERP_KERNEL::Exception("Dimension request is invalid (>1) !");
+ int tracucedRk=-meshDimRelToMaxExt;
+ if(tracucedRk>=(int)_ms.size())
+ throw INTERP_KERNEL::Exception("Invalid mesh dim relative to max given ! To low !");
+ if((const MEDFileUMeshSplitL1 *)_ms[tracucedRk]==0)
+ throw INTERP_KERNEL::Exception("On specified lev (or entity) no cells exists !");
+ return _ms[tracucedRk];
+}
+
+void MEDFileUMesh::checkMeshDimCoherency(int meshDim, int meshDimRelToMax) const throw(INTERP_KERNEL::Exception)
+{
+ if(-meshDimRelToMax>=(int)_ms.size())
+ throw INTERP_KERNEL::Exception("MEDFileUMesh::checkMeshDimCoherency : The meshdim of mesh is not managed by 'this' !");
+ int i=0;
+ for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileUMeshSplitL1> >::const_iterator it=_ms.begin();it!=_ms.end();it++,i++)
+ {
+ if(((const MEDFileUMeshSplitL1*) (*it))!=0)
+ {
+ int ref=(*it)->getMeshDimension();
+ if(ref+i!=meshDim-meshDimRelToMax)
+ throw INTERP_KERNEL::Exception("MEDFileUMesh::checkMeshDimCoherency : no coherency between levels !");
+ }
+ }
+}
+
+void MEDFileUMesh::setCoords(DataArrayDouble *coords) throw(INTERP_KERNEL::Exception)
+{
+ coords->checkAllocated();
+ int nbOfTuples=coords->getNumberOfTuples();
+ _coords=coords;
+ coords->incrRef();
+ _fam_coords=DataArrayInt::New();
+ _fam_coords->alloc(nbOfTuples,1);
+ _fam_coords->fillWithZero();
+}
+
+void MEDFileUMesh::eraseGroupsAtLevel(int meshDimRelToMaxExt) throw(INTERP_KERNEL::Exception)
+{
+ if(meshDimRelToMaxExt==1)
+ {
+ if((DataArrayInt *)_fam_coords)
+ _fam_coords->fillWithZero();
+ return ;
+ }
+ MEDFileUMeshSplitL1 *l1=getMeshAtLevSafe(meshDimRelToMaxExt);
+ l1->eraseFamilyField();
+ optimizeFamilies();
+}
+
+void MEDFileUMesh::optimizeFamilies() throw(INTERP_KERNEL::Exception)
+{
+ std::vector<int> levs=getNonEmptyLevelsExt();
+ std::set<int> allFamsIds;
+ for(std::vector<int>::const_iterator it=levs.begin();it!=levs.end();it++)
+ {
+ const DataArrayInt *ffield=getFamilyFieldAtLevel(*it);
+ std::set<int> ids=ffield->getDifferentValues();
+ std::set<int> res;
+ std::set_union(ids.begin(),ids.end(),allFamsIds.begin(),allFamsIds.end(),std::inserter(res,res.begin()));
+ allFamsIds=res;
+ }
+ std::set<std::string> famNamesToKill;
+ for(std::map<std::string,int>::const_iterator it=_families.begin();it!=_families.end();it++)
+ {
+ if(allFamsIds.find((*it).second)!=allFamsIds.end())
+ famNamesToKill.insert((*it).first);
+ }
+ for(std::set<std::string>::const_iterator it=famNamesToKill.begin();it!=famNamesToKill.end();it++)
+ _families.erase(*it);
+ std::vector<std::string> grpNamesToKill;
+ for(std::map<std::string, std::vector<std::string> >::iterator it=_groups.begin();it!=_groups.end();it++)
+ {
+ std::vector<std::string> tmp;
+ for(std::vector<std::string>::const_iterator it2=(*it).second.begin();it2!=(*it).second.end();it2++)
+ {
+ if(famNamesToKill.find(*it2)==famNamesToKill.end())
+ tmp.push_back(*it2);
+ }
+ if(!tmp.empty())
+ (*it).second=tmp;
+ else
+ tmp.push_back((*it).first);
+ }
+ for(std::vector<std::string>::const_iterator it=grpNamesToKill.begin();it!=grpNamesToKill.end();it++)
+ _groups.erase(*it);
+}
+
+void MEDFileUMesh::setFamilyField(DataArrayInt *arr, const std::vector< std::vector< int > > &userfids, const std::vector<std::string>& grpNames, bool renum) throw(INTERP_KERNEL::Exception)
+{
+
+}
+
+void MEDFileUMesh::addNodeGroup(const std::string& name, const std::vector<int>& ids) throw(INTERP_KERNEL::Exception)
+{
+ const DataArrayDouble *coords=_coords;
+ if(!coords)
+ throw INTERP_KERNEL::Exception("addNodeGroup : no coords set !");
DataArrayInt *sub=_fam_coords->selectByTupleIdSafe(&ids[0],&ids[0]+ids.size());
std::set<int> ssub(sub->getConstPointer(),sub->getConstPointer()+sub->getNumberOfTuples());
}
-void MEDFileUMesh::copyFamGrpMapsFrom(const MEDFileUMesh& other)
+void MEDFileUMesh::setFamilyNameAttachedOnId(int id, const std::string& newFamName) throw(INTERP_KERNEL::Exception)
+{
+ std::string oldName=getFamilyNameGivenId(id);
+ _families.erase(oldName);
+ _families[newFamName]=id;
+}
+
+void MEDFileUMesh::removeMeshAtLevel(int meshDimRelToMax) throw(INTERP_KERNEL::Exception)
+{
+ std::vector<int> levSet=getNonEmptyLevels();
+ std::vector<int>::const_iterator it=std::find(levSet.begin(),levSet.end(),meshDimRelToMax);
+ if(it==levSet.end())
+ throw INTERP_KERNEL::Exception("MEDFileUMesh::removeMeshAtLevel : the requested level is not existing !");
+ int pos=(-meshDimRelToMax);
+ _ms[pos]=0;
+}
+
+void MEDFileUMesh::setMeshAtLevel(int meshDimRelToMax, MEDCouplingUMesh *m, bool newOrOld) throw(INTERP_KERNEL::Exception)
+{
+ setMeshAtLevelGen(meshDimRelToMax,m,newOrOld);
+}
+
+void MEDFileUMesh::setMeshAtLevelGen(int meshDimRelToMax, MEDCouplingUMesh *m, bool newOrOld) throw(INTERP_KERNEL::Exception)
+{
+ dealWithTinyInfo(m);
+ std::vector<int> levSet=getNonEmptyLevels();
+ if(std::find(levSet.begin(),levSet.end(),meshDimRelToMax)==levSet.end())
+ {
+ if((DataArrayDouble *)_coords==0)
+ {
+ DataArrayDouble *c=m->getCoords();
+ if(c)
+ c->incrRef();
+ _coords=c;
+ }
+ else
+ {
+ if(m->getCoords()!=_coords)
+ throw INTERP_KERNEL::Exception("MEDFileUMesh::setMeshAtLevel : Invalid Given Mesh ! The coordinates are not the same ! try to use tryToShareSameCoords !");
+ int sz=(-meshDimRelToMax)+1;
+ if(sz>=(int)_ms.size())
+ _ms.resize(sz);
+ checkMeshDimCoherency(m->getMeshDimension(),meshDimRelToMax);
+ _ms[sz-1]=new MEDFileUMeshSplitL1(m,newOrOld);
+ }
+ }
+}
+
+void MEDFileUMesh::setGroupsFromScratch(int meshDimRelToMax, const std::vector<const MEDCouplingUMesh *>& ms) throw(INTERP_KERNEL::Exception)
+{
+ if(ms.empty())
+ throw INTERP_KERNEL::Exception("MEDFileUMesh::setGroupsFromScratch : expecting a non empty vector !");
+ int sz=(-meshDimRelToMax)+1;
+ if(sz>=(int)_ms.size())
+ _ms.resize(sz);
+ checkMeshDimCoherency(ms[0]->getMeshDimension(),meshDimRelToMax);
+ DataArrayDouble *coo=checkMultiMesh(ms);
+ if((DataArrayDouble *)_coords==0)
+ {
+ coo->incrRef();
+ _coords=coo;
+ }
+ else
+ if((DataArrayDouble *)_coords!=coo)
+ throw INTERP_KERNEL::Exception("MEDFileUMesh::setGroupsFromScratch : coordinates mismatches !");
+ std::vector<DataArrayInt *> corr;
+ MEDCouplingAutoRefCountObjectPtr<MEDCouplingUMesh> m=MEDCouplingUMesh::FuseUMeshesOnSameCoords(ms,_zipconn_pol,corr);
+ std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > corr3(corr.begin(),corr.end());
+ setMeshAtLevel(meshDimRelToMax,m);
+ std::vector<const DataArrayInt *> corr2(corr.begin(),corr.end());
+ setGroupsAtLevel(meshDimRelToMax,corr2,true);
+}
+
+void MEDFileUMesh::setGroupsOnSetMesh(int meshDimRelToMax, const std::vector<const MEDCouplingUMesh *>& ms, bool renum) throw(INTERP_KERNEL::Exception)
+{
+ if(ms.empty())
+ throw INTERP_KERNEL::Exception("MEDFileUMesh::setGroupsOnSetMesh : expecting a non empty vector !");
+ int sz=(-meshDimRelToMax)+1;
+ if(sz>=(int)_ms.size())
+ _ms.resize(sz);
+ checkMeshDimCoherency(ms[0]->getMeshDimension(),meshDimRelToMax);
+ DataArrayDouble *coo=checkMultiMesh(ms);
+ if((DataArrayDouble *)_coords==0)
+ {
+ coo->incrRef();
+ _coords=coo;
+ }
+ else
+ if((DataArrayDouble *)_coords!=coo)
+ throw INTERP_KERNEL::Exception("MEDFileUMesh::setGroupsOnSetMesh : coordinates mismatches !");
+ MEDCouplingUMesh *m=getMeshAtLevel(meshDimRelToMax,renum);
+ std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > corr(ms.size());
+ int i=0;
+ for(std::vector<const MEDCouplingUMesh *>::const_iterator it=ms.begin();it!=ms.end();it++,i++)
+ {
+ DataArrayInt *arr=0;
+ bool test=m->areCellsIncludedIn(*it,_zipconn_pol,arr);
+ corr[i]=arr;
+ if(!test)
+ {
+ std::ostringstream oss; oss << "MEDFileUMesh::setGroupsOnSetMesh : mesh #" << i << " is not part of whole mesh !";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ }
+ std::vector<const DataArrayInt *> corr2(corr.begin(),corr.end());
+ setGroupsAtLevel(meshDimRelToMax,corr2,renum);
+}
+
+DataArrayDouble *MEDFileUMesh::checkMultiMesh(const std::vector<const MEDCouplingUMesh *>& ms) const throw(INTERP_KERNEL::Exception)
+{
+ const DataArrayDouble *ret=ms[0]->getCoords();
+ int mdim=ms[0]->getMeshDimension();
+ for(unsigned int i=1;i<ms.size();i++)
+ {
+ ms[i]->checkCoherency();
+ if(ms[i]->getCoords()!=ret)
+ throw INTERP_KERNEL::Exception("MEDFileUMesh::checkMultiMesh : meshes must share the same coords !");
+ if(ms[i]->getMeshDimension()!=mdim)
+ throw INTERP_KERNEL::Exception("MEDFileUMesh::checkMultiMesh : meshes have not same mesh dimension !");
+ }
+ return const_cast<DataArrayDouble *>(ret);
+}
+
+void MEDFileUMesh::setFamilyFieldArr(int meshDimRelToMaxExt, DataArrayInt *famArr) throw(INTERP_KERNEL::Exception)
+{
+ if(meshDimRelToMaxExt==1)
+ {
+ famArr->incrRef();
+ _fam_coords=famArr;
+ return ;
+ }
+ if(meshDimRelToMaxExt>1)
+ throw INTERP_KERNEL::Exception("MEDFileUMesh::setFamilyFieldArr : Dimension request is invalid (>1) !");
+ int traducedRk=-meshDimRelToMaxExt;
+ if(traducedRk>=(int)_ms.size())
+ throw INTERP_KERNEL::Exception("Invalid mesh dim relative to max given ! To low !");
+ if((MEDFileUMeshSplitL1 *)_ms[traducedRk]==0)
+ throw INTERP_KERNEL::Exception("On specified lev (or entity) no cells exists !");
+ return _ms[traducedRk]->setFamilyArr(famArr);
+}
+
+void MEDFileUMesh::setRenumFieldArr(int meshDimRelToMaxExt, DataArrayInt *renumArr) throw(INTERP_KERNEL::Exception)
+{
+ if(meshDimRelToMaxExt==1)
+ {
+ if(renumArr)
+ renumArr->incrRef();
+ _num_coords=renumArr;
+ computeRevNum();
+ return ;
+ }
+ if(meshDimRelToMaxExt>1)
+ throw INTERP_KERNEL::Exception("MEDFileUMesh::setRenumArr : Dimension request is invalid (>1) !");
+ int traducedRk=-meshDimRelToMaxExt;
+ if(traducedRk>=(int)_ms.size())
+ throw INTERP_KERNEL::Exception("Invalid mesh dim relative to max given ! To low !");
+ if((MEDFileUMeshSplitL1 *)_ms[traducedRk]==0)
+ throw INTERP_KERNEL::Exception("On specified lev (or entity) no cells exists !");
+ return _ms[traducedRk]->setRenumArr(renumArr);
+}
+
+void MEDFileUMesh::synchronizeTinyInfoOnLeaves() const
+{
+ for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileUMeshSplitL1> >::const_iterator it=_ms.begin();it!=_ms.end();it++)
+ if((const MEDFileUMeshSplitL1 *)(*it))
+ (*it)->synchronizeTinyInfo(*this);
+}
+
+void MEDFileUMesh::computeRevNum() const
+{
+ if((const DataArrayInt *)_num_coords)
+ {
+ int pos;
+ int maxValue=_num_coords->getMaxValue(pos);
+ _rev_num_coords=_num_coords->invertArrayN2O2O2N(maxValue+1);
+ }
+}
+
+MEDFileCMesh *MEDFileCMesh::New()
+{
+ return new MEDFileCMesh;
+}
+
+MEDFileCMesh *MEDFileCMesh::New(const char *fileName) throw(INTERP_KERNEL::Exception)
+{
+ std::vector<std::string> ms=MEDLoader::GetMeshNames(fileName);
+ if(ms.empty())
+ {
+ std::ostringstream oss; oss << "MEDFileUMesh::New : no meshes in file \"" << fileName << "\" !";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ MEDFileUtilities::CheckFileForRead(fileName);
+ MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
+ int dt,it;
+ ParaMEDMEM::MEDCouplingMeshType meshType;
+ std::string dummy2;
+ MEDFileMeshL2::GetMeshIdFromName(fid,ms.front().c_str(),meshType,dt,it,dummy2);
+ return new MEDFileCMesh(fid,ms.front().c_str(),dt,it);
+}
+
+MEDFileCMesh *MEDFileCMesh::New(const char *fileName, const char *mName, int dt, int it) throw(INTERP_KERNEL::Exception)
+{
+ MEDFileUtilities::CheckFileForRead(fileName);
+ MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
+ return new MEDFileCMesh(fid,mName,dt,it);
+}
+
+int MEDFileCMesh::getMeshDimension() const throw(INTERP_KERNEL::Exception)
+{
+ if(!((const MEDCouplingCMesh*)_cmesh))
+ throw INTERP_KERNEL::Exception("MEDFileCMesh::getMeshDimension : unable to get meshdimension because no mesh set !");
+ return _cmesh->getMeshDimension();
+}
+
+bool MEDFileCMesh::isEqual(const MEDFileMesh *other, double eps, std::string& what) const
+{
+ if(!MEDFileMesh::isEqual(other,eps,what))
+ return false;
+ const MEDFileCMesh *otherC=dynamic_cast<const MEDFileCMesh *>(other);
+ if(!otherC)
+ {
+ what="Mesh types differ ! This is cartesian and other is NOT !";
+ return false;
+ }
+ clearNonDiscrAttributes();
+ otherC->clearNonDiscrAttributes();
+ const MEDCouplingCMesh *coo1=_cmesh;
+ const MEDCouplingCMesh *coo2=otherC->_cmesh;
+ if((coo1==0 && coo2!=0) || (coo1!=0 && coo2==0))
+ {
+ what="Mismatch of cartesian meshes ! One is defined and not other !";
+ return false;
+ }
+ if(coo1)
+ {
+ bool ret=coo1->isEqual(coo2,eps);
+ if(!ret)
+ {
+ what="cartesian meshes differ !";
+ return false;
+ }
+ }
+ const DataArrayInt *famc1=_fam_nodes;
+ const DataArrayInt *famc2=otherC->_fam_nodes;
+ if((famc1==0 && famc2!=0) || (famc1!=0 && famc2==0))
+ {
+ what="Mismatch of families arr on nodes ! One is defined and not other !";
+ return false;
+ }
+ if(famc1)
+ {
+ bool ret=famc1->isEqual(*famc2);
+ if(!ret)
+ {
+ what="Families arr on nodes differ !";
+ return false;
+ }
+ }
+ famc1=_fam_cells;
+ famc2=otherC->_fam_cells;
+ if((famc1==0 && famc2!=0) || (famc1!=0 && famc2==0))
+ {
+ what="Mismatch of families arr on cells ! One is defined and not other !";
+ return false;
+ }
+ if(famc1)
+ {
+ bool ret=famc1->isEqual(*famc2);
+ if(!ret)
+ {
+ what="Families arr on cells differ !";
+ return false;
+ }
+ }
+ famc1=_num_nodes;
+ famc2=otherC->_num_nodes;
+ if((famc1==0 && famc2!=0) || (famc1!=0 && famc2==0))
+ {
+ what="Mismatch of numbering arr on nodes ! One is defined and not other !";
+ return false;
+ }
+ if(famc1)
+ {
+ bool ret=famc1->isEqual(*famc2);
+ if(!ret)
+ {
+ what="Numbering arr on nodes differ !";
+ return false;
+ }
+ }
+ famc1=_num_cells;
+ famc2=otherC->_num_cells;
+ if((famc1==0 && famc2!=0) || (famc1!=0 && famc2==0))
+ {
+ what="Mismatch of numbering arr on cells ! One is defined and not other !";
+ return false;
+ }
+ if(famc1)
+ {
+ bool ret=famc1->isEqual(*famc2);
+ if(!ret)
+ {
+ what="Numbering arr on cells differ !";
+ return false;
+ }
+ }
+ return true;
+}
+
+void MEDFileCMesh::clearNonDiscrAttributes() const
+{
+ MEDFileMesh::clearNonDiscrAttributes();
+ MEDFileUMeshSplitL1::ClearNonDiscrAttributes(_cmesh);
+ const DataArrayInt *tmp=_fam_nodes;
+ if(tmp)
+ (const_cast<DataArrayInt *>(tmp))->setName("");
+ tmp=_num_nodes;
+ if(tmp)
+ (const_cast<DataArrayInt *>(tmp))->setName("");
+ tmp=_fam_cells;
+ if(tmp)
+ (const_cast<DataArrayInt *>(tmp))->setName("");
+ tmp=_num_cells;
+ if(tmp)
+ (const_cast<DataArrayInt *>(tmp))->setName("");
+}
+
+MEDFileCMesh::MEDFileCMesh()
+{
+}
+
+MEDFileCMesh::MEDFileCMesh(med_idt fid, const char *mName, int dt, int it) throw(INTERP_KERNEL::Exception)
+try
+ {
+ loadCMeshFromFile(fid,mName,dt,it);
+ }
+catch(INTERP_KERNEL::Exception& e)
+ {
+ throw e;
+ }
+
+
+
+void MEDFileCMesh::loadCMeshFromFile(med_idt fid, const char *mName, int dt, int it) throw(INTERP_KERNEL::Exception)
+{
+ MEDFileCMeshL2 loaderl2;
+ ParaMEDMEM::MEDCouplingMeshType meshType;
+ int dummy0,dummy1;
+ std::string dtunit;
+ int mid=MEDFileMeshL2::GetMeshIdFromName(fid,mName,meshType,dummy0,dummy1,dtunit);
+ if(meshType!=CARTESIAN)
+ {
+ std::ostringstream oss; oss << "Trying to load as cartesian an existing mesh with name '" << mName << "' that is NOT cartesian !";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ loaderl2.loadAll(fid,mid,mName,dt,it);
+ MEDCouplingCMesh *mesh=loaderl2.getMesh();
+ mesh->incrRef();
+ _cmesh=mesh;
+ setName(loaderl2.getName());
+ setDescription(loaderl2.getDescription());
+ setIteration(loaderl2.getIteration());
+ setOrder(loaderl2.getOrder());
+ setTimeValue(loaderl2.getTime());
+ setTimeUnit(loaderl2.getTimeUnit());
+ MEDFileMeshL2::ReadFamiliesAndGrps(fid,mName,_families,_groups);
+ med_bool chgt=MED_FALSE,trsf=MED_FALSE;
+ int nbOfElt=MEDmeshnEntity(fid,mName,dt,it,MED_NODE,MED_NONE,MED_FAMILY_NUMBER,MED_NODAL,&chgt,&trsf);
+ if(nbOfElt>0)
+ {
+ _fam_nodes=DataArrayInt::New();
+ _fam_nodes->alloc(nbOfElt,1);
+ MEDmeshEntityFamilyNumberRd(fid,mName,dt,it,MED_NODE,MED_NONE,_fam_nodes->getPointer());
+ }
+ nbOfElt=MEDmeshnEntity(fid,mName,dt,it,MED_NODE,MED_NONE,MED_NUMBER,MED_NODAL,&chgt,&trsf);
+ if(nbOfElt>0)
+ {
+ _num_nodes=DataArrayInt::New();
+ _num_nodes->alloc(nbOfElt,1);
+ MEDmeshEntityNumberRd(fid,mName,dt,it,MED_NODE,MED_NONE,_num_nodes->getPointer());
+ }
+ int spaceDim=mesh->getSpaceDimension();
+ med_geometry_type geoTypeReq=MED_NONE;
+ switch(spaceDim)
+ {
+ case 3:
+ geoTypeReq=MED_HEXA8;
+ break;
+ case 2:
+ geoTypeReq=MED_QUAD4;
+ break;
+ case 1:
+ geoTypeReq=MED_SEG2;
+ break;
+ case 0:
+ geoTypeReq=MED_POINT1;
+ break;
+ default:
+ throw INTERP_KERNEL::Exception("Invalid spacedim detected for cartesian mesh ! Must be in (1,2,3) !");
+ }
+ nbOfElt=MEDmeshnEntity(fid,mName,dt,it,MED_CELL,geoTypeReq,MED_FAMILY_NUMBER,MED_NODAL,&chgt,&trsf);
+ if(nbOfElt>0)
+ {
+ _fam_cells=DataArrayInt::New();
+ _fam_cells->alloc(nbOfElt,1);
+ MEDmeshEntityFamilyNumberRd(fid,mName,dt,it,MED_CELL,geoTypeReq,_fam_cells->getPointer());
+ }
+ nbOfElt=MEDmeshnEntity(fid,mName,dt,it,MED_CELL,geoTypeReq,MED_NUMBER,MED_NODAL,&chgt,&trsf);
+ if(nbOfElt>0)
+ {
+ _num_cells=DataArrayInt::New();
+ _num_cells->alloc(nbOfElt,1);
+ MEDmeshEntityNumberRd(fid,mName,dt,it,MED_CELL,geoTypeReq,_num_cells->getPointer());
+ }
+}
+
+const MEDCouplingCMesh *MEDFileCMesh::getMesh() const
+{
+ synchronizeTinyInfoOnLeaves();
+ return _cmesh;
+}
+
+MEDCouplingMesh *MEDFileCMesh::getGenMeshAtLevel(int meshDimRelToMax, bool renum) const throw(INTERP_KERNEL::Exception)
+{
+ if(renum)
+ throw INTERP_KERNEL::Exception("MEDFileCMesh does not support renumbering ! To do it perform request of renum array directly !");
+ if(meshDimRelToMax!=0)
+ throw INTERP_KERNEL::Exception("MEDFileCMesh does not support multi level for mesh 0 expected as input !");
+ const MEDCouplingCMesh *m=getMesh();
+ if(m)
+ m->incrRef();
+ return const_cast<MEDCouplingCMesh *>(m);
+}
+
+void MEDFileCMesh::setMesh(MEDCouplingCMesh *m) throw(INTERP_KERNEL::Exception)
+{
+ dealWithTinyInfo(m);
+ if(m)
+ m->incrRef();
+ _cmesh=m;
+}
+
+void MEDFileCMesh::write(const char *fileName, int mode) const throw(INTERP_KERNEL::Exception)
+{
+ if(_name.empty())
+ throw INTERP_KERNEL::Exception("MEDFileCMesh : name is empty. MED file ask for a NON EMPTY name !");
+ if(!existsFamily(0))
+ (const_cast<MEDFileCMesh *>(this))->addFamily(DFT_FAM_NAME,0);
+ med_access_mode medmod=MEDFileUtilities::TraduceWriteMode(mode);
+ MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,medmod);
+ std::ostringstream oss; oss << "MEDFileCMesh : error on attempt to write in file : \"" << fileName << "\"";
+ MEDFileUtilities::CheckMEDCode(fid,fid,oss.str().c_str());
+ INTERP_KERNEL::AutoPtr<char> maa=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
+ INTERP_KERNEL::AutoPtr<char> desc=MEDLoaderBase::buildEmptyString(MED_COMMENT_SIZE);
+ INTERP_KERNEL::AutoPtr<char> dtunit=MEDLoaderBase::buildEmptyString(MED_LNAME_SIZE);
+ MEDLoaderBase::safeStrCpy(_name.c_str(),MED_NAME_SIZE,maa,_too_long_str);
+ MEDLoaderBase::safeStrCpy(_desc_name.c_str(),MED_COMMENT_SIZE,desc,_too_long_str);
+ MEDLoaderBase::safeStrCpy(_dt_unit.c_str(),MED_LNAME_SIZE,dtunit,_too_long_str);
+ int spaceDim=_cmesh->getSpaceDimension();
+ INTERP_KERNEL::AutoPtr<char> comp=MEDLoaderBase::buildEmptyString(spaceDim*MED_SNAME_SIZE);
+ INTERP_KERNEL::AutoPtr<char> unit=MEDLoaderBase::buildEmptyString(spaceDim*MED_SNAME_SIZE);
+ for(int i=0;i<spaceDim;i++)
+ {
+ std::string info(_cmesh->getCoordsAt(i)->getInfoOnComponent(0));
+ std::string c,u;
+ MEDLoaderBase::splitIntoNameAndUnit(info,c,u);
+ MEDLoaderBase::safeStrCpy2(c.c_str(),MED_SNAME_SIZE-1,comp+i*MED_SNAME_SIZE,_too_long_str);//MED_TAILLE_PNOM-1 to avoid to write '\0' on next compo
+ MEDLoaderBase::safeStrCpy2(u.c_str(),MED_SNAME_SIZE-1,unit+i*MED_SNAME_SIZE,_too_long_str);//MED_TAILLE_PNOM-1 to avoid to write '\0' on next compo
+ }
+ MEDmeshCr(fid,maa,spaceDim,spaceDim,MED_STRUCTURED_MESH,desc,dtunit,MED_SORT_DTIT,MED_CARTESIAN,comp,unit);
+ MEDmeshGridTypeWr(fid,maa,MED_CARTESIAN_GRID);
+ for(int i=0;i<spaceDim;i++)
+ {
+ const DataArrayDouble *da=_cmesh->getCoordsAt(i);
+ MEDmeshGridIndexCoordinateWr(fid,maa,_iteration,_order,_time,i+1,da->getNumberOfTuples(),da->getConstPointer());
+ }
+ //
+ med_geometry_type geoTypeReq=MED_NONE;
+ switch(spaceDim)
+ {
+ case 3:
+ geoTypeReq=MED_HEXA8;
+ break;
+ case 2:
+ geoTypeReq=MED_QUAD4;
+ break;
+ case 1:
+ geoTypeReq=MED_SEG2;
+ break;
+ case 0:
+ geoTypeReq=MED_POINT1;
+ break;
+ default:
+ throw INTERP_KERNEL::Exception("Invalid spacedim detected for cartesian mesh ! Must be in (1,2,3) !");
+ }
+ //
+ if((const DataArrayInt *)_fam_cells)
+ MEDmeshEntityFamilyNumberWr(fid,maa,_iteration,_order,MED_CELL,geoTypeReq,_fam_cells->getNumberOfTuples(),_fam_cells->getConstPointer());
+ if((const DataArrayInt *)_fam_nodes)
+ MEDmeshEntityFamilyNumberWr(fid,maa,_iteration,_order,MED_NODE,MED_NONE,_fam_nodes->getNumberOfTuples(),_fam_nodes->getConstPointer());
+ //
+ MEDFileUMeshL2::WriteFamiliesAndGrps(fid,maa,_families,_groups,_too_long_str);
+}
+
+int MEDFileCMesh::getSizeAtLevel(int meshDimRelToMaxExt) const throw(INTERP_KERNEL::Exception)
+{
+ if(meshDimRelToMaxExt!=0 && meshDimRelToMaxExt!=1)
+ throw INTERP_KERNEL::Exception("MEDFileCMesh::getSizeAtLevel : Only available for levels 0 or 1 !");
+ if(!((const MEDCouplingCMesh *)_cmesh))
+ throw INTERP_KERNEL::Exception("MEDFileCMesh::getSizeAtLevel : No cartesian mesh set !");
+ if(meshDimRelToMaxExt==0)
+ return _cmesh->getNumberOfCells();
+ else
+ return _cmesh->getNumberOfNodes();
+}
+
+void MEDFileCMesh::synchronizeTinyInfoOnLeaves() const
{
- _groups=other._groups;
- _families=other._families;
+ const MEDCouplingCMesh *cmesh=_cmesh;
+ (const_cast<MEDCouplingCMesh *>(cmesh))->setName(_name.c_str());
+ (const_cast<MEDCouplingCMesh *>(cmesh))->setDescription(_desc_name.c_str());
+ (const_cast<MEDCouplingCMesh *>(cmesh))->setTime(_time,_iteration,_order);
+ (const_cast<MEDCouplingCMesh *>(cmesh))->setTimeUnit(_dt_unit.c_str());
}
-void MEDFileUMesh::setFamilyInfo(const std::map<std::string,int>& info)
+DataArrayInt *MEDFileCMesh::getFamiliesArr(int meshDimRelToMaxExt, const std::vector<std::string>& fams, bool renum) const throw(INTERP_KERNEL::Exception)
{
- _families=info;
+ if(meshDimRelToMaxExt!=0 && meshDimRelToMaxExt!=1)
+ throw INTERP_KERNEL::Exception("MEDFileCMesh::getFamiliesArr : Only available for levels 0 or 1 !");
+ std::vector<int> famIds=getFamiliesIds(fams);
+ if(meshDimRelToMaxExt==1)
+ {
+ if((const DataArrayInt *)_fam_nodes)
+ {
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da=_fam_nodes->getIdsEqualList(famIds);
+ if(renum)
+ return MEDFileUMeshSplitL1::Renumber(_num_nodes,da);
+ else
+ {
+ da->incrRef();
+ return da;
+ }
+ }
+ else
+ throw INTERP_KERNEL::Exception("MEDFileCMesh::getFamiliesArr : no family array specified on nodes !");
+ }
+ else
+ {
+ if((const DataArrayInt *)_fam_cells)
+ {
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da=_fam_cells->getIdsEqualList(famIds);
+ if(renum)
+ return MEDFileUMeshSplitL1::Renumber(_num_cells,da);
+ else
+ {
+ da->incrRef();
+ return da;
+ }
+ }
+ else
+ throw INTERP_KERNEL::Exception("MEDFileCMesh::getFamiliesArr : no family array specified on cells !");
+ }
}
-void MEDFileUMesh::setGroupInfo(const std::map<std::string, std::vector<std::string> >&info)
+void MEDFileCMesh::setFamilyFieldArr(int meshDimRelToMaxExt, DataArrayInt *famArr) throw(INTERP_KERNEL::Exception)
{
- _groups=info;
+ if(meshDimRelToMaxExt!=0 && meshDimRelToMaxExt!=1)
+ throw INTERP_KERNEL::Exception("MEDFileCMesh::setRenumFieldArr : Only available for levels 0 or 1 !");
+ if(famArr)
+ famArr->incrRef();
+ if(meshDimRelToMaxExt==0)
+ _fam_cells=famArr;
+ else
+ _fam_nodes=famArr;
}
-void MEDFileUMesh::setFamilyNameAttachedOnId(int id, const std::string& newFamName) throw(INTERP_KERNEL::Exception)
+void MEDFileCMesh::setRenumFieldArr(int meshDimRelToMaxExt, DataArrayInt *renumArr) throw(INTERP_KERNEL::Exception)
{
- std::string oldName=getFamilyNameGivenId(id);
- _families.erase(oldName);
- _families[newFamName]=id;
+ if(meshDimRelToMaxExt!=0 && meshDimRelToMaxExt!=1)
+ throw INTERP_KERNEL::Exception("MEDFileCMesh::setRenumFieldArr : Only available for levels 0 or 1 !");
+ if(renumArr)
+ renumArr->incrRef();
+ if(meshDimRelToMaxExt==0)
+ _num_cells=renumArr;
+ else
+ _num_nodes=renumArr;
}
-void MEDFileUMesh::setMeshAtLevel(int meshDimRelToMax, MEDCouplingUMesh *m) throw(INTERP_KERNEL::Exception)
+const DataArrayInt *MEDFileCMesh::getFamilyFieldAtLevel(int meshDimRelToMaxExt) const throw(INTERP_KERNEL::Exception)
{
- setMeshAtLevelGen(meshDimRelToMax,m,true);
+ if(meshDimRelToMaxExt!=0 && meshDimRelToMaxExt!=1)
+ throw INTERP_KERNEL::Exception("MEDFileCMesh::getFamilyFieldAtLevel : Only available for levels 0 or 1 !");
+ if(meshDimRelToMaxExt==0)
+ return _fam_cells;
+ else
+ return _fam_nodes;
}
-void MEDFileUMesh::setMeshAtLevelOld(int meshDimRelToMax, MEDCouplingUMesh *m) throw(INTERP_KERNEL::Exception)
+const DataArrayInt *MEDFileCMesh::getNumberFieldAtLevel(int meshDimRelToMaxExt) const throw(INTERP_KERNEL::Exception)
{
- setMeshAtLevelGen(meshDimRelToMax,m,false);
+ if(meshDimRelToMaxExt!=0 && meshDimRelToMaxExt!=1)
+ throw INTERP_KERNEL::Exception("MEDFileCMesh::getNumberFieldAtLevel : Only available for levels 0 or 1 !");
+ if(meshDimRelToMaxExt==0)
+ return _num_cells;
+ else
+ return _num_nodes;
}
-void MEDFileUMesh::setMeshAtLevelGen(int meshDimRelToMax, MEDCouplingUMesh *m, bool newOrOld) throw(INTERP_KERNEL::Exception)
+const DataArrayInt *MEDFileCMesh::getRevNumberFieldAtLevel(int meshDimRelToMaxExt) const throw(INTERP_KERNEL::Exception)
{
- std::vector<int> levSet=getNonEmptyLevels();
- if(std::find(levSet.begin(),levSet.end(),meshDimRelToMax)==levSet.end())
+ if(meshDimRelToMaxExt!=0 && meshDimRelToMaxExt!=1)
+ throw INTERP_KERNEL::Exception("MEDFileCMesh::getRevNumberFieldAtLevel : Only available for levels 0 or 1 !");
+ if(meshDimRelToMaxExt==0)
{
- if((DataArrayDouble *)_coords==0)
+ if((const DataArrayInt *)_num_cells)
{
- DataArrayDouble *c=m->getCoords();
- if(c)
- c->incrRef();
- _coords=c;
+ int pos;
+ int maxValue=_num_cells->getMaxValue(pos);
+ _rev_num_cells=_num_cells->invertArrayN2O2O2N(maxValue+1);
+ return _rev_num_cells;
}
else
+ throw INTERP_KERNEL::Exception("MEDFileCMesh::getRevNumberFieldAtLevel : no cell renumbering for a request on reverse numbering !");
+ }
+ else
+ {
+ if((const DataArrayInt *)_num_nodes)
{
- if(m->getCoords()!=_coords)
- throw INTERP_KERNEL::Exception("MEDFileUMesh::setMeshAtLevel : Invalid Given Mesh ! The coordinates are not the same ! try to use tryToShareSameCoords !");
- int sz=(-meshDimRelToMax)+1;
- if(sz>=(int)_ms.size())
- _ms.resize(sz);
- checkMeshDimCoherency(m->getMeshDimension(),meshDimRelToMax);
- _ms[sz-1]=new MEDFileUMeshSplitL1(m,newOrOld);
+ int pos;
+ int maxValue=_num_nodes->getMaxValue(pos);
+ _rev_num_nodes=_num_nodes->invertArrayN2O2O2N(maxValue+1);
+ return _rev_num_nodes;
}
+ else
+ throw INTERP_KERNEL::Exception("MEDFileCMesh::getRevNumberFieldAtLevel : no node renumbering for a request on reverse numbering !");
}
}
-void MEDFileUMesh::setGroupsFromScratch(int meshDimRelToMax, const std::vector<const MEDCouplingUMesh *>& ms) throw(INTERP_KERNEL::Exception)
+
+MEDFileMeshMultiTS *MEDFileMeshMultiTS::New()
{
- if(ms.empty())
- throw INTERP_KERNEL::Exception("MEDFileUMesh::setGroupsFromScratch : expecting a non empty vector !");
- int sz=(-meshDimRelToMax)+1;
- if(sz>=(int)_ms.size())
- _ms.resize(sz);
- checkMeshDimCoherency(ms[0]->getMeshDimension(),meshDimRelToMax);
- DataArrayDouble *coo=checkMultiMesh(ms);
- if((DataArrayDouble *)_coords==0)
- {
- coo->incrRef();
- _coords=coo;
- }
- else
- if((DataArrayDouble *)_coords!=coo)
- throw INTERP_KERNEL::Exception("MEDFileUMesh::setGroupsFromScratch : coordinates mismatches !");
- std::vector<DataArrayInt *> corr;
- MEDCouplingAutoRefCountObjectPtr<MEDCouplingUMesh> m=MEDCouplingUMesh::FuseUMeshesOnSameCoords(ms,_zipconn_pol,corr);
- std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > corr3(corr.begin(),corr.end());
- setMeshAtLevel(meshDimRelToMax,m);
- std::vector<const DataArrayInt *> corr2(corr.begin(),corr.end());
- setGroupsAtLevel(meshDimRelToMax,corr2,true);
+ return new MEDFileMeshMultiTS;
}
-void MEDFileUMesh::setGroupsOnSetMesh(int meshDimRelToMax, const std::vector<const MEDCouplingUMesh *>& ms, bool renum) throw(INTERP_KERNEL::Exception)
+MEDFileMeshMultiTS *MEDFileMeshMultiTS::New(const char *fileName) throw(INTERP_KERNEL::Exception)
{
- if(ms.empty())
- throw INTERP_KERNEL::Exception("MEDFileUMesh::setGroupsOnSetMesh : expecting a non empty vector !");
- int sz=(-meshDimRelToMax)+1;
- if(sz>=(int)_ms.size())
- _ms.resize(sz);
- checkMeshDimCoherency(ms[0]->getMeshDimension(),meshDimRelToMax);
- DataArrayDouble *coo=checkMultiMesh(ms);
- if((DataArrayDouble *)_coords==0)
- {
- coo->incrRef();
- _coords=coo;
- }
- else
- if((DataArrayDouble *)_coords!=coo)
- throw INTERP_KERNEL::Exception("MEDFileUMesh::setGroupsOnSetMesh : coordinates mismatches !");
- MEDCouplingUMesh *m=getMeshAtLevel(meshDimRelToMax,renum);
- std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > corr(ms.size());
- int i=0;
- for(std::vector<const MEDCouplingUMesh *>::const_iterator it=ms.begin();it!=ms.end();it++,i++)
+ return new MEDFileMeshMultiTS(fileName);
+}
+
+MEDFileMeshMultiTS *MEDFileMeshMultiTS::New(const char *fileName, const char *mName) throw(INTERP_KERNEL::Exception)
+{
+ return new MEDFileMeshMultiTS(fileName,mName);
+}
+
+const char *MEDFileMeshMultiTS::getName() const throw(INTERP_KERNEL::Exception)
+{
+ if(_mesh_one_ts.empty())
+ throw INTERP_KERNEL::Exception("MEDFileMeshMultiTS::getName : no time steps set !");
+ return _mesh_one_ts[0]->getName();
+}
+
+MEDFileMesh *MEDFileMeshMultiTS::getOneTimeStep() const throw(INTERP_KERNEL::Exception)
+{
+ if(_mesh_one_ts.empty())
+ throw INTERP_KERNEL::Exception("MEDFileMeshMultiTS::getOneTimeStep : empty time step set !");
+ return const_cast<MEDFileMesh *>(static_cast<const MEDFileMesh *>(_mesh_one_ts[0]));
+}
+
+void MEDFileMeshMultiTS::setOneTimeStep(MEDFileMesh *mesh1TimeStep) throw(INTERP_KERNEL::Exception)
+{
+ if(!mesh1TimeStep)
+ throw INTERP_KERNEL::Exception("MEDFileMeshMultiTS::setOneTimeStep : input pointer should be different from 0 !");
+ _mesh_one_ts.resize(1);
+ mesh1TimeStep->incrRef();
+ //MEDCouplingAutoRefCountObjectPtr<MEDFileMesh> toto=mesh1TimeStep;
+ _mesh_one_ts[0]=mesh1TimeStep;
+}
+
+void MEDFileMeshMultiTS::write(const char *fileName, int mode) const throw(INTERP_KERNEL::Exception)
+{
+ for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileMesh> >::const_iterator it=_mesh_one_ts.begin();it!=_mesh_one_ts.end();it++)
{
- DataArrayInt *arr=0;
- bool test=m->areCellsIncludedIn(*it,_zipconn_pol,arr);
- corr[i]=arr;
- if(!test)
- {
- std::ostringstream oss; oss << "MEDFileUMesh::setGroupsOnSetMesh : mesh #" << i << " is not part of whole mesh !";
- throw INTERP_KERNEL::Exception(oss.str().c_str());
- }
+ (*it)->copyOptionsFrom(*this);
+ (*it)->write(fileName,mode);
}
- std::vector<const DataArrayInt *> corr2(corr.begin(),corr.end());
- setGroupsAtLevel(meshDimRelToMax,corr2,renum);
}
-DataArrayDouble *MEDFileUMesh::checkMultiMesh(const std::vector<const MEDCouplingUMesh *>& ms) const throw(INTERP_KERNEL::Exception)
+void MEDFileMeshMultiTS::loadFromFile(const char *fileName, const char *mName) throw(INTERP_KERNEL::Exception)
+{//for the moment to be improved
+ _mesh_one_ts.resize(1);
+ _mesh_one_ts[0]=MEDFileMesh::New(fileName,mName,-1,-1);
+}
+
+MEDFileMeshMultiTS::MEDFileMeshMultiTS()
{
- DataArrayDouble *ret=ms[0]->getCoords();
- int mdim=ms[0]->getMeshDimension();
- for(unsigned int i=1;i<ms.size();i++)
+}
+
+MEDFileMeshMultiTS::MEDFileMeshMultiTS(const char *fileName) throw(INTERP_KERNEL::Exception)
+try
+ {
+ std::vector<std::string> ms=MEDLoader::GetMeshNames(fileName);
+ if(ms.empty())
{
- ms[i]->checkCoherency();
- if(ms[i]->getCoords()!=ret)
- throw INTERP_KERNEL::Exception("MEDFileUMesh::checkMultiMesh : meshes must share the same coords !");
- if(ms[i]->getMeshDimension()!=mdim)
- throw INTERP_KERNEL::Exception("MEDFileUMesh::checkMultiMesh : meshes have not same mesh dimension !");
+ std::ostringstream oss; oss << "MEDFileUMesh::New : no meshes in file \"" << fileName << "\" !";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
}
- return ret;
+ MEDFileUtilities::CheckFileForRead(fileName);
+ MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
+ int dt,it;
+ ParaMEDMEM::MEDCouplingMeshType meshType;
+ std::string dummy2;
+ MEDFileMeshL2::GetMeshIdFromName(fid,ms.front().c_str(),meshType,dt,it,dummy2);
+ loadFromFile(fileName,ms.front().c_str());
+ }
+catch(INTERP_KERNEL::Exception& e)
+ {
+ throw e;
+ }
+
+MEDFileMeshMultiTS::MEDFileMeshMultiTS(const char *fileName, const char *mName) throw(INTERP_KERNEL::Exception)
+try
+ {
+ loadFromFile(fileName,mName);
+ }
+catch(INTERP_KERNEL::Exception& e)
+ {
+ throw e;
+ }
+
+MEDFileMeshes *MEDFileMeshes::New()
+{
+ return new MEDFileMeshes;
}
-void MEDFileUMesh::setFamilyArr(int meshDimRelToMaxExt, DataArrayInt *famArr)
+MEDFileMeshes *MEDFileMeshes::New(const char *fileName) throw(INTERP_KERNEL::Exception)
{
- if(meshDimRelToMaxExt==1)
+ return new MEDFileMeshes(fileName);
+}
+
+void MEDFileMeshes::write(const char *fileName, int mode) const throw(INTERP_KERNEL::Exception)
+{
+ checkCoherency();
+ for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileMeshMultiTS> >::const_iterator it=_meshes.begin();it!=_meshes.end();it++)
{
- famArr->incrRef();
- _fam_coords=famArr;
- return ;
+ (*it)->copyOptionsFrom(*this);
+ (*it)->write(fileName,mode);
}
- if(meshDimRelToMaxExt>1)
- throw INTERP_KERNEL::Exception("MEDFileUMesh::setFamilyArr : Dimension request is invalid (>1) !");
- int traducedRk=-meshDimRelToMaxExt;
- if(traducedRk>=(int)_ms.size())
- throw INTERP_KERNEL::Exception("Invalid mesh dim relative to max given ! To low !");
- if((MEDFileUMeshSplitL1 *)_ms[traducedRk]==0)
- throw INTERP_KERNEL::Exception("On specified lev (or entity) no cells exists !");
- return _ms[traducedRk]->setFamilyArr(famArr);
}
-void MEDFileUMesh::setRenumArr(int meshDimRelToMaxExt, DataArrayInt *renumArr)
+int MEDFileMeshes::getNumberOfMeshes() const throw(INTERP_KERNEL::Exception)
{
- if(meshDimRelToMaxExt==1)
+ return _meshes.size();
+}
+
+MEDFileMesh *MEDFileMeshes::getMeshAtPos(int i) const throw(INTERP_KERNEL::Exception)
+{
+ if(i<0 || i>=(int)_meshes.size())
{
- if(renumArr)
- renumArr->incrRef();
- _num_coords=renumArr;
- computeRevNum();
- return ;
+ std::ostringstream oss; oss << "MEDFileMeshes::getMeshAtPos : invalid mesh id given in parameter ! Should be in [0;" << _meshes.size() << ") !";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
}
- if(meshDimRelToMaxExt>1)
- throw INTERP_KERNEL::Exception("MEDFileUMesh::setRenumArr : Dimension request is invalid (>1) !");
- int traducedRk=-meshDimRelToMaxExt;
- if(traducedRk>=(int)_ms.size())
- throw INTERP_KERNEL::Exception("Invalid mesh dim relative to max given ! To low !");
- if((MEDFileUMeshSplitL1 *)_ms[traducedRk]==0)
- throw INTERP_KERNEL::Exception("On specified lev (or entity) no cells exists !");
- return _ms[traducedRk]->setRenumArr(renumArr);
+ return _meshes[i]->getOneTimeStep();
}
-void MEDFileUMesh::TranslateFamilyIds(int offset, DataArrayInt *famArr, std::vector< std::vector<int> >& famIdsPerGrp)
+void MEDFileMeshes::resize(int newSize) throw(INTERP_KERNEL::Exception)
{
- famArr->applyLin(1,offset,0);
- for(std::vector< std::vector<int> >::iterator it1=famIdsPerGrp.begin();it1!=famIdsPerGrp.end();it1++)
- std::transform((*it1).begin(),(*it1).end(),(*it1).begin(),std::bind2nd(std::plus<int>(),offset));
+ _meshes.resize(newSize);
}
-/*!
- * This method append into '_families' attribute the families whose ids are in 'famIds'. Warning 'famIds' are expected to be ids
- * not in '_families'. Groups information are given in parameters in order to give to families representative names.
- * For the moment, the two last input parameters are not taken into account.
- */
-void MEDFileUMesh::appendFamilyEntries(const std::set<int>& famIds, const std::vector< std::vector<int> >& fidsOfGrps, const std::vector<std::string>& grpNames)
+void MEDFileMeshes::pushMesh(MEDFileMesh *mesh) throw(INTERP_KERNEL::Exception)
{
- std::map<int,std::string> famInv;
- for(std::set<int>::const_iterator it=famIds.begin();it!=famIds.end();it++)
+ if(!mesh)
+ throw INTERP_KERNEL::Exception("MEDFileMeshes::pushMesh : invalid input pointer ! should be different from 0 !");
+ MEDFileMeshMultiTS *elt=MEDFileMeshMultiTS::New();
+ elt->setOneTimeStep(mesh);
+ _meshes.push_back(elt);
+}
+
+void MEDFileMeshes::setMeshAtPos(int i, MEDFileMesh *mesh) throw(INTERP_KERNEL::Exception)
+{
+ if(!mesh)
+ throw INTERP_KERNEL::Exception("MEDFileMeshes::setMeshAtPos : invalid input pointer ! should be different from 0 !");
+ if(i>=(int)_meshes.size())
+ _meshes.resize(i+1);
+ MEDFileMeshMultiTS *elt=MEDFileMeshMultiTS::New();
+ elt->setOneTimeStep(mesh);
+ _meshes[i]=elt;
+}
+
+void MEDFileMeshes::destroyMeshAtPos(int i) throw(INTERP_KERNEL::Exception)
+{
+ if(i<0 || i>=(int)_meshes.size())
{
- std::ostringstream oss;
- oss << "Family_" << (*it);
- _families[oss.str()]=(*it);
- famInv[*it]=oss.str();
+ std::ostringstream oss; oss << "MEDFileMeshes::destroyMeshAtPos : Invalid given id in input (" << i << ") should be in [0," << _meshes.size() << ") !";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
}
+ _meshes.erase(_meshes.begin()+i);
+}
+
+void MEDFileMeshes::loadFromFile(const char *fileName) throw(INTERP_KERNEL::Exception)
+{
+ std::vector<std::string> ms=MEDLoader::GetMeshNames(fileName);
int i=0;
- for(std::vector< std::vector<int> >::const_iterator it1=fidsOfGrps.begin();it1!=fidsOfGrps.end();it1++,i++)
- {
- for(std::vector<int>::const_iterator it2=(*it1).begin();it2!=(*it1).end();it2++)
- {
- _groups[grpNames[i]].push_back(famInv[*it2]);
- }
- }
+ _meshes.resize(ms.size());
+ for(std::vector<std::string>::const_iterator it=ms.begin();it!=ms.end();it++,i++)
+ _meshes[i]=MEDFileMeshMultiTS::New(fileName,(*it).c_str());
}
-/*!
- * This method appends a new entry in _families attribute. An exception is thrown if either the famId is already
- * kept by an another familyName. An exception is thrown if name 'familyName' is alreadyset with a different 'famId'.
- */
-void MEDFileUMesh::addFamily(int famId, const char *familyName) throw(INTERP_KERNEL::Exception)
+MEDFileMeshes::MEDFileMeshes()
{
- std::string fname(familyName);
- std::map<std::string,int>::const_iterator it=_families.find(fname);
- if(it==_families.end())
- {
- for(std::map<std::string,int>::const_iterator it2=_families.begin();it2!=_families.end();it2++)
- if((*it2).second==famId)
- {
- std::ostringstream oss;
- oss << "MEDFileUMesh::addFamily : Family \"" << (*it2).first << "\" already exists with specified id : " << famId << " !";
- throw INTERP_KERNEL::Exception(oss.str().c_str());
- }
- _families[fname]=famId;
- }
- else
- {
- if((*it).second!=famId)
- {
- std::ostringstream oss;
- oss << "MEDFileUMesh::addFamily : Family \"" << fname << "\" already exists but has id set to " << (*it).second << " different from asked famId " << famId << " !";
- throw INTERP_KERNEL::Exception(oss.str().c_str());
- }
- }
}
-void MEDFileUMesh::computeRevNum() const
+MEDFileMeshes::MEDFileMeshes(const char *fileName) throw(INTERP_KERNEL::Exception)
+try
+ {
+ loadFromFile(fileName);
+ }
+catch(INTERP_KERNEL::Exception& e)
+ {
+ }
+
+void MEDFileMeshes::checkCoherency() const throw(INTERP_KERNEL::Exception)
{
- if((const DataArrayInt *)_num_coords)
+ static const char MSG[]="MEDFileMeshes::checkCoherency : mesh at rank ";
+ int i=0;
+ std::set<std::string> s;
+ for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileMeshMultiTS> >::const_iterator it=_meshes.begin();it!=_meshes.end();it++,i++)
{
- int pos;
- int maxValue=_num_coords->getMaxValue(pos);
- _rev_num_coords=_num_coords->invertArrayN2O2O2N(maxValue+1);
+ const MEDFileMeshMultiTS *elt=(*it);
+ if(!elt)
+ {
+ std::ostringstream oss; oss << MSG << i << "/" << _meshes.size() << " is empty !";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ std::size_t sz=s.size();
+ s.insert(std::string((*it)->getName()));
+ if(s.size()==sz)
+ {
+ std::ostringstream oss; oss << MSG << i << " has a name (\"" << (*it)->getName() << "\") already used by an another mesh in list !";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
}
}
-// Copyright (C) 2007-2010 CEA/DEN, EDF R&D
+// Copyright (C) 2007-2011 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 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.
+// 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
+// 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
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
#ifndef __MEDFILEMESH_HXX__
#define __MEDFILEMESH_HXX__
#include "MEDFileMeshLL.hxx"
+#include "MEDFileUtilities.hxx"
#include <map>
namespace ParaMEDMEM
{
- class MEDFileMesh : public RefCountObject
+ class MEDFileMesh : public RefCountObject, public MEDFileWritable
{
public:
- static MEDFileMesh *New(const char *fileName, const char *mName) throw(INTERP_KERNEL::Exception);
+ static MEDFileMesh *New(const char *fileName) throw(INTERP_KERNEL::Exception);
+ static MEDFileMesh *New(const char *fileName, const char *mName, int dt=-1, int it=-1) throw(INTERP_KERNEL::Exception);
+ virtual bool isEqual(const MEDFileMesh *other, double eps, std::string& what) const;
+ virtual void clearNonDiscrAttributes() const;
void setName(const char *name) { _name=name; }
const char *getName() const { return _name.c_str(); }
void setUnivName(const char *name) { _univ_name=name; }
const char *getUnivName() const { return _univ_name.c_str(); }
void setDescription(const char *name) { _desc_name=name; }
const char *getDescription() const { return _desc_name.c_str(); }
+ void setOrder(int order) { _order=order; }
+ int getOrder() const { return _order; }
+ void setIteration(int it) { _iteration=it; }
+ int getIteration() const { return _iteration; }
+ void setTimeValue(double time) { _time=time; }
+ void setTime(double time, int dt, int it) { _time=time; _iteration=dt; _order=it; }
+ double getTime(int& dt, int& it) { dt=_iteration; it=_order; return _time; }
+ double getTimeValue() const { return _time; }
+ void setTimeUnit(const char *unit) { _dt_unit=unit; }
+ const char *getTimeUnit() const { return _dt_unit.c_str(); }
+ virtual void write(const char *fileName, int mode) const throw(INTERP_KERNEL::Exception) = 0;
+ virtual int getSizeAtLevel(int meshDimRelToMaxExt) const throw(INTERP_KERNEL::Exception) = 0;
+ virtual MEDCouplingMesh *getGenMeshAtLevel(int meshDimRelToMax, bool renum=false) const throw(INTERP_KERNEL::Exception) = 0;
+ //
+ bool areFamsEqual(const MEDFileMesh *other, std::string& what) const;
+ bool areGrpsEqual(const MEDFileMesh *other, std::string& what) const;
+ bool existsFamily(int famId) const;
+ bool existsFamily(const char *familyName) const;
+ void setFamilyId(const char *familyName, int id);
+ void addFamily(const char *familyName, int id) throw(INTERP_KERNEL::Exception);
+ void addGrpOnFamily(const char *grpName, const char *famName) throw(INTERP_KERNEL::Exception);
+ void setFamilyInfo(const std::map<std::string,int>& info);
+ void setGroupInfo(const std::map<std::string, std::vector<std::string> >&info);
+ void copyFamGrpMapsFrom(const MEDFileMesh& other);
+ const std::map<std::string,int>& getFamilyInfo() const { return _families; }
+ const std::map<std::string, std::vector<std::string> >& getGroupInfo() const { return _groups; }
+ std::vector<std::string> getFamiliesOnGroup(const char *name) const throw(INTERP_KERNEL::Exception);
+ std::vector<std::string> getFamiliesOnGroups(const std::vector<std::string>& grps) const throw(INTERP_KERNEL::Exception);
+ std::vector<int> getFamiliesIdsOnGroup(const char *name) const throw(INTERP_KERNEL::Exception);
+ void setFamiliesOnGroup(const char *name, const std::vector<std::string>& fams) throw(INTERP_KERNEL::Exception);
+ void setFamiliesIdsOnGroup(const char *name, const std::vector<int>& famIds) throw(INTERP_KERNEL::Exception);
+ std::vector<std::string> getGroupsOnFamily(const char *name) const throw(INTERP_KERNEL::Exception);
+ void setGroupsOnFamily(const char *famName, const std::vector<std::string>& grps) throw(INTERP_KERNEL::Exception);
+ std::vector<std::string> getGroupsNames() const;
+ std::vector<std::string> getFamiliesNames() const;
+ void removeGroup(const char *name) throw(INTERP_KERNEL::Exception);
+ void removeFamily(const char *name) throw(INTERP_KERNEL::Exception);
+ void changeGroupName(const char *oldName, const char *newName) throw(INTERP_KERNEL::Exception);
+ void changeFamilyName(const char *oldName, const char *newName) throw(INTERP_KERNEL::Exception);
+ int getFamilyId(const char *name) const throw(INTERP_KERNEL::Exception);
+ int getMaxFamilyId() const throw(INTERP_KERNEL::Exception);
+ std::vector<int> getFamiliesIds(const std::vector<std::string>& famNames) const throw(INTERP_KERNEL::Exception);
+ std::string getFamilyNameGivenId(int id) const throw(INTERP_KERNEL::Exception);
+ virtual int getMeshDimension() const throw(INTERP_KERNEL::Exception) = 0;
+ //
+ virtual void setGroupsAtLevel(int meshDimRelToMaxExt, const std::vector<const DataArrayInt *>& grps, bool renum=false) throw(INTERP_KERNEL::Exception);
+ virtual void setFamilyFieldArr(int meshDimRelToMaxExt, DataArrayInt *famArr) throw(INTERP_KERNEL::Exception) = 0;
+ virtual void setRenumFieldArr(int meshDimRelToMaxExt, DataArrayInt *renumArr) throw(INTERP_KERNEL::Exception) = 0;
+ virtual const DataArrayInt *getFamilyFieldAtLevel(int meshDimRelToMaxExt) const throw(INTERP_KERNEL::Exception) = 0;
+ virtual const DataArrayInt *getNumberFieldAtLevel(int meshDimRelToMaxExt) const throw(INTERP_KERNEL::Exception) = 0;
+ virtual const DataArrayInt *getRevNumberFieldAtLevel(int meshDimRelToMaxExt) const throw(INTERP_KERNEL::Exception) = 0;
+ virtual DataArrayInt *getFamiliesArr(int meshDimRelToMaxExt, const std::vector<std::string>& fams, bool renum=false) const throw(INTERP_KERNEL::Exception) = 0;
+ virtual DataArrayInt *getGroupsArr(int meshDimRelToMaxExt, const std::vector<std::string>& grps, bool renum=false) const throw(INTERP_KERNEL::Exception);
+ virtual DataArrayInt *getGroupArr(int meshDimRelToMaxExt, const char *grp, bool renum=false) const throw(INTERP_KERNEL::Exception);
+ virtual DataArrayInt *getFamilyArr(int meshDimRelToMaxExt, const char *fam, bool renum=false) const throw(INTERP_KERNEL::Exception);
+ virtual DataArrayInt *getNodeGroupArr(const char *grp, bool renum=false) const throw(INTERP_KERNEL::Exception);
+ virtual DataArrayInt *getNodeGroupsArr(const std::vector<std::string>& grps, bool renum=false) const throw(INTERP_KERNEL::Exception);
+ virtual DataArrayInt *getNodeFamilyArr(const char *fam, bool renum=false) const throw(INTERP_KERNEL::Exception);
+ virtual DataArrayInt *getNodeFamiliesArr(const std::vector<std::string>& fams, bool renum=false) const throw(INTERP_KERNEL::Exception);
protected:
+ MEDFileMesh();
+ void dealWithTinyInfo(const MEDCouplingMesh *m) throw(INTERP_KERNEL::Exception);
+ virtual void synchronizeTinyInfoOnLeaves() const = 0;
+ virtual void appendFamilyEntries(const std::set<int>& famIds, const std::vector< std::vector<int> >& fidsOfGrps, const std::vector<std::string>& grpNames);
+ static void TranslateFamilyIds(int offset, DataArrayInt *famArr, std::vector< std::vector<int> >& famIdsPerGrp);
+ protected:
+ int _order;
+ int _iteration;
+ double _time;
+ std::string _dt_unit;
std::string _name;
std::string _univ_name;
std::string _desc_name;
+ protected:
+ std::map<std::string, std::vector<std::string> > _groups;
+ std::map<std::string,int> _families;
+ public:
+ static const char DFT_FAM_NAME[];
};
class MEDFileUMesh : public MEDFileMesh
{
+ friend class MEDFileMesh;
public:
- static MEDFileUMesh *New(const char *fileName, const char *mName) throw(INTERP_KERNEL::Exception);
+ static MEDFileUMesh *New(const char *fileName, const char *mName, int dt=-1, int it=-1) throw(INTERP_KERNEL::Exception);
static MEDFileUMesh *New(const char *fileName) throw(INTERP_KERNEL::Exception);
static MEDFileUMesh *New();
+ bool isEqual(const MEDFileMesh *other, double eps, std::string& what) const;
+ void clearNonDiscrAttributes() const;
~MEDFileUMesh();
//
- void removeGroup(const char *name) throw(INTERP_KERNEL::Exception);
- void removeFamily(const char *name) throw(INTERP_KERNEL::Exception);
- void changeGroupName(const char *oldName, const char *newName) throw(INTERP_KERNEL::Exception);
- void changeFamilyName(const char *oldName, const char *newName) throw(INTERP_KERNEL::Exception);
- //
void write(const char *fileName, int mode) const throw(INTERP_KERNEL::Exception);
- int getNumberOfLevels() const { return _ms.size(); }
- int getNumberOfNonEmptyLevels() const;
- int getFamilyId(const char *name) const throw(INTERP_KERNEL::Exception);
- int getMaxFamilyId() const throw(INTERP_KERNEL::Exception);
- std::vector<int> getFamiliesIds(const std::vector<std::string>& famNames) const throw(INTERP_KERNEL::Exception);
- std::string getFamilyNameGivenId(int id) const throw(INTERP_KERNEL::Exception);
- int getMeshDimension() const;
+ int getMeshDimension() const throw(INTERP_KERNEL::Exception);
int getSizeAtLevel(int meshDimRelToMaxExt) const throw(INTERP_KERNEL::Exception);
const DataArrayInt *getFamilyFieldAtLevel(int meshDimRelToMaxExt) const throw(INTERP_KERNEL::Exception);
const DataArrayInt *getNumberFieldAtLevel(int meshDimRelToMaxExt) const throw(INTERP_KERNEL::Exception);
const DataArrayInt *getRevNumberFieldAtLevel(int meshDimRelToMaxExt) const throw(INTERP_KERNEL::Exception);
- std::vector<std::string> getFamiliesOnGroup(const char *name) const throw(INTERP_KERNEL::Exception);
- std::vector<std::string> getGroupsOnFamily(const char *name) const throw(INTERP_KERNEL::Exception);
- std::vector<std::string> getGroupsNames() const;
- std::vector<std::string> getFamiliesNames() const;
std::vector<int> getNonEmptyLevels() const;
std::vector<int> getNonEmptyLevelsExt() const;
+ std::vector<int> getGrpNonEmptyLevels(const char *grp) const throw(INTERP_KERNEL::Exception);
+ std::vector<int> getGrpNonEmptyLevelsExt(const char *grp) const throw(INTERP_KERNEL::Exception);
+ std::vector<int> getFamNonEmptyLevels(const char *fam) const throw(INTERP_KERNEL::Exception);
+ std::vector<int> getFamNonEmptyLevelsExt(const char *fam) const throw(INTERP_KERNEL::Exception);
+ std::vector<int> getGrpsNonEmptyLevels(const std::vector<std::string>& grps) const throw(INTERP_KERNEL::Exception);
+ std::vector<int> getGrpsNonEmptyLevelsExt(const std::vector<std::string>& grps) const throw(INTERP_KERNEL::Exception);
+ std::vector<int> getFamsNonEmptyLevels(const std::vector<std::string>& fams) const throw(INTERP_KERNEL::Exception);
+ std::vector<int> getFamsNonEmptyLevelsExt(const std::vector<std::string>& fams) const throw(INTERP_KERNEL::Exception);
DataArrayDouble *getCoords() const;
- MEDCouplingUMesh *getGroup(int meshDimRelToMaxExt, const char *grp, bool renum=true) const throw(INTERP_KERNEL::Exception);
- DataArrayInt *getGroupArr(int meshDimRelToMaxExt, const char *grp, bool renum=true) const throw(INTERP_KERNEL::Exception);
- MEDCouplingUMesh *getGroups(int meshDimRelToMaxExt, const std::vector<std::string>& grps, bool renum=true) const throw(INTERP_KERNEL::Exception);
- DataArrayInt *getGroupsArr(int meshDimRelToMaxExt, const std::vector<std::string>& grps, bool renum=true) const throw(INTERP_KERNEL::Exception);
- MEDCouplingUMesh *getFamily(int meshDimRelToMaxExt, const char *fam, bool renum=true) const throw(INTERP_KERNEL::Exception);
- DataArrayInt *getFamilyArr(int meshDimRelToMaxExt, const char *fam, bool renum=true) const throw(INTERP_KERNEL::Exception);
- MEDCouplingUMesh *getFamilies(int meshDimRelToMaxExt, const std::vector<std::string>& fams, bool renum=true) const throw(INTERP_KERNEL::Exception);
- DataArrayInt *getFamiliesArr(int meshDimRelToMaxExt, const std::vector<std::string>& fams, bool renum=true) const throw(INTERP_KERNEL::Exception);
- DataArrayInt *getNodeGroupArr(const char *grp, bool renum=true) const throw(INTERP_KERNEL::Exception);
- DataArrayInt *getNodeGroupsArr(const std::vector<std::string>& grps, bool renum=true) const throw(INTERP_KERNEL::Exception);
- DataArrayInt *getNodeFamilyArr(const char *fam, bool renum=true) const throw(INTERP_KERNEL::Exception);
- DataArrayInt *getNodeFamiliesArr(const std::vector<std::string>& fams, bool renum=true) const throw(INTERP_KERNEL::Exception);
- MEDCouplingUMesh *getMeshAtLevel(int meshDimRelToMaxExt, bool renum=true) const throw(INTERP_KERNEL::Exception);
- MEDCouplingUMesh *getLevel0Mesh(bool renum=true) const throw(INTERP_KERNEL::Exception);
- MEDCouplingUMesh *getLevelM1Mesh(bool renum=true) const throw(INTERP_KERNEL::Exception);
- MEDCouplingUMesh *getLevelM2Mesh(bool renum=true) const throw(INTERP_KERNEL::Exception);
- MEDCouplingUMesh *getLevelM3Mesh(bool renum=true) const throw(INTERP_KERNEL::Exception);
- const std::map<std::string,int>& getFamilyInfo() const { return _families; }
- const std::map<std::string, std::vector<std::string> >& getGroupInfo() const { return _groups; }
- bool existsFamily(int famId) const;
- bool existsFamily(const char *familyName) const;
+ MEDCouplingUMesh *getGroup(int meshDimRelToMaxExt, const char *grp, bool renum=false) const throw(INTERP_KERNEL::Exception);
+ MEDCouplingUMesh *getGroups(int meshDimRelToMaxExt, const std::vector<std::string>& grps, bool renum=false) const throw(INTERP_KERNEL::Exception);
+ MEDCouplingUMesh *getFamily(int meshDimRelToMaxExt, const char *fam, bool renum=false) const throw(INTERP_KERNEL::Exception);
+ MEDCouplingUMesh *getFamilies(int meshDimRelToMaxExt, const std::vector<std::string>& fams, bool renum=false) const throw(INTERP_KERNEL::Exception);
+ DataArrayInt *getFamiliesArr(int meshDimRelToMaxExt, const std::vector<std::string>& fams, bool renum=false) const throw(INTERP_KERNEL::Exception);
+ MEDCouplingUMesh *getMeshAtLevel(int meshDimRelToMaxExt, bool renum=false) const throw(INTERP_KERNEL::Exception);
+ MEDCouplingMesh *getGenMeshAtLevel(int meshDimRelToMax, bool renum=false) const throw(INTERP_KERNEL::Exception);
+ MEDCouplingUMesh *getLevel0Mesh(bool renum=false) const throw(INTERP_KERNEL::Exception);
+ MEDCouplingUMesh *getLevelM1Mesh(bool renum=false) const throw(INTERP_KERNEL::Exception);
+ MEDCouplingUMesh *getLevelM2Mesh(bool renum=false) const throw(INTERP_KERNEL::Exception);
+ MEDCouplingUMesh *getLevelM3Mesh(bool renum=false) const throw(INTERP_KERNEL::Exception);
//
- void copyFamGrpMapsFrom(const MEDFileUMesh& other);
- void setFamilyInfo(const std::map<std::string,int>& info);
- void setGroupInfo(const std::map<std::string, std::vector<std::string> >&info);
void setFamilyNameAttachedOnId(int id, const std::string& newFamName) throw(INTERP_KERNEL::Exception);
void setCoords(DataArrayDouble *coords) throw(INTERP_KERNEL::Exception);
- void setGroupsAtLevel(int meshDimRelToMaxExt, const std::vector<const DataArrayInt *>& grps, bool renum=true) throw(INTERP_KERNEL::Exception);
void eraseGroupsAtLevel(int meshDimRelToMaxExt) throw(INTERP_KERNEL::Exception);
- void setFamilyField(DataArrayInt *arr, const std::vector< std::vector< int > > &userfids, const std::vector<std::string>& grpNames, bool renum=true) throw(INTERP_KERNEL::Exception);
- void setFamilyArr(int meshDimRelToMaxExt, DataArrayInt *famArr);
- void setRenumArr(int meshDimRelToMaxExt, DataArrayInt *renumArr);
+ void setFamilyField(DataArrayInt *arr, const std::vector< std::vector< int > > &userfids, const std::vector<std::string>& grpNames, bool renum=false) throw(INTERP_KERNEL::Exception);
+ void setFamilyFieldArr(int meshDimRelToMaxExt, DataArrayInt *famArr) throw(INTERP_KERNEL::Exception);
+ void setRenumFieldArr(int meshDimRelToMaxExt, DataArrayInt *renumArr) throw(INTERP_KERNEL::Exception);
void addNodeGroup(const std::string& name, const std::vector<int>& ids) throw(INTERP_KERNEL::Exception);
- void setMeshAtLevel(int meshDimRelToMax, MEDCouplingUMesh *m) throw(INTERP_KERNEL::Exception);
- void setMeshAtLevelOld(int meshDimRelToMax, MEDCouplingUMesh *m) throw(INTERP_KERNEL::Exception);
+ void removeMeshAtLevel(int meshDimRelToMax) throw(INTERP_KERNEL::Exception);
+ void setMeshAtLevel(int meshDimRelToMax, MEDCouplingUMesh *m, bool newOrOld=false) throw(INTERP_KERNEL::Exception);
void setMeshAtLevelGen(int meshDimRelToMax, MEDCouplingUMesh *m, bool newOrOld) throw(INTERP_KERNEL::Exception);
void setGroupsFromScratch(int meshDimRelToMax, const std::vector<const MEDCouplingUMesh *>& ms) throw(INTERP_KERNEL::Exception);
void setGroupsOnSetMesh(int meshDimRelToMax, const std::vector<const MEDCouplingUMesh *>& ms, bool renum) throw(INTERP_KERNEL::Exception);
void optimizeFamilies() throw(INTERP_KERNEL::Exception);
- void addFamily(int famId, const char *familyName) throw(INTERP_KERNEL::Exception);
private:
MEDFileUMesh();
- MEDFileUMesh(const char *fileName, const char *mName) throw(INTERP_KERNEL::Exception);
+ MEDFileUMesh(med_idt fid, const char *mName, int dt, int it) throw(INTERP_KERNEL::Exception);
+ void loadUMeshFromFile(med_idt fid, const char *mName, int dt, int it) throw(INTERP_KERNEL::Exception);
const MEDFileUMeshSplitL1 *getMeshAtLevSafe(int meshDimRelToMaxExt) const throw(INTERP_KERNEL::Exception);
MEDFileUMeshSplitL1 *getMeshAtLevSafe(int meshDimRelToMaxExt) throw(INTERP_KERNEL::Exception);
void checkMeshDimCoherency(int meshDim, int meshDimRelToMax) const throw(INTERP_KERNEL::Exception);
DataArrayDouble *checkMultiMesh(const std::vector<const MEDCouplingUMesh *>& ms) const throw(INTERP_KERNEL::Exception);
- void appendFamilyEntries(const std::set<int>& famIds, const std::vector< std::vector<int> >& fidsOfGrps, const std::vector<std::string>& grpNames);
void computeRevNum() const;
- static void TranslateFamilyIds(int offset, DataArrayInt *famArr, std::vector< std::vector<int> >& famIdsPerGrp);
+ void synchronizeTinyInfoOnLeaves() const;
private:
- std::map<std::string, std::vector<std::string> > _groups;
- std::map<std::string,int> _families;
std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileUMeshSplitL1> > _ms;
MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> _coords;
MEDCouplingAutoRefCountObjectPtr<DataArrayInt> _fam_coords;
MEDCouplingAutoRefCountObjectPtr<DataArrayInt> _num_coords;
mutable MEDCouplingAutoRefCountObjectPtr<DataArrayInt> _rev_num_coords;
- int _too_long_str;
- int _zipconn_pol;
};
-
class MEDFileCMesh : public MEDFileMesh
{
+ friend class MEDFileMesh;
+ public:
+ static MEDFileCMesh *New();
+ static MEDFileCMesh *New(const char *fileName) throw(INTERP_KERNEL::Exception);
+ static MEDFileCMesh *New(const char *fileName, const char *mName, int dt=-1, int it=-1) throw(INTERP_KERNEL::Exception);
+ bool isEqual(const MEDFileMesh *other, double eps, std::string& what) const;
+ int getMeshDimension() const throw(INTERP_KERNEL::Exception);
+ void clearNonDiscrAttributes() const;
+ const MEDCouplingCMesh *getMesh() const;
+ MEDCouplingMesh *getGenMeshAtLevel(int meshDimRelToMax, bool renum=false) const throw(INTERP_KERNEL::Exception);
+ void setMesh(MEDCouplingCMesh *m) throw(INTERP_KERNEL::Exception);
+ void write(const char *fileName, int mode) const throw(INTERP_KERNEL::Exception);
+ int getSizeAtLevel(int meshDimRelToMaxExt) const throw(INTERP_KERNEL::Exception);
+ DataArrayInt *getFamiliesArr(int meshDimRelToMaxExt, const std::vector<std::string>& fams, bool renum=false) const throw(INTERP_KERNEL::Exception);
+ void setFamilyFieldArr(int meshDimRelToMaxExt, DataArrayInt *famArr) throw(INTERP_KERNEL::Exception);
+ void setRenumFieldArr(int meshDimRelToMaxExt, DataArrayInt *renumArr) throw(INTERP_KERNEL::Exception);
+ const DataArrayInt *getFamilyFieldAtLevel(int meshDimRelToMaxExt) const throw(INTERP_KERNEL::Exception);
+ const DataArrayInt *getNumberFieldAtLevel(int meshDimRelToMaxExt) const throw(INTERP_KERNEL::Exception);
+ const DataArrayInt *getRevNumberFieldAtLevel(int meshDimRelToMaxExt) const throw(INTERP_KERNEL::Exception);
+ private:
+ MEDFileCMesh();
+ void synchronizeTinyInfoOnLeaves() const;
+ MEDFileCMesh(med_idt fid, const char *mName, int dt, int it) throw(INTERP_KERNEL::Exception);
+ void loadCMeshFromFile(med_idt fid, const char *mName, int dt, int it) throw(INTERP_KERNEL::Exception);
+ private:
+ MEDCouplingAutoRefCountObjectPtr<MEDCouplingCMesh> _cmesh;
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> _fam_nodes;
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> _num_nodes;
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> _fam_cells;
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> _num_cells;
+ mutable MEDCouplingAutoRefCountObjectPtr<DataArrayInt> _rev_num_nodes;
+ mutable MEDCouplingAutoRefCountObjectPtr<DataArrayInt> _rev_num_cells;
+ };
+
+ class MEDFileMeshMultiTS : public RefCountObject, public MEDFileWritable
+ {
+ public:
+ static MEDFileMeshMultiTS *New();
+ static MEDFileMeshMultiTS *New(const char *fileName) throw(INTERP_KERNEL::Exception);
+ static MEDFileMeshMultiTS *New(const char *fileName, const char *mName) throw(INTERP_KERNEL::Exception);
+ const char *getName() const throw(INTERP_KERNEL::Exception);
+ MEDFileMesh *getOneTimeStep() const throw(INTERP_KERNEL::Exception);
+ void write(const char *fileName, int mode) const throw(INTERP_KERNEL::Exception);
+ void setOneTimeStep(MEDFileMesh *mesh1TimeStep) throw(INTERP_KERNEL::Exception);
+ private:
+ void loadFromFile(const char *fileName, const char *mName) throw(INTERP_KERNEL::Exception);
+ MEDFileMeshMultiTS();
+ MEDFileMeshMultiTS(const char *fileName) throw(INTERP_KERNEL::Exception);
+ MEDFileMeshMultiTS(const char *fileName, const char *mName) throw(INTERP_KERNEL::Exception);
+ private:
+ std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileMesh> > _mesh_one_ts;
+ };
+
+ class MEDFileMeshes : public RefCountObject, public MEDFileWritable
+ {
+ public:
+ static MEDFileMeshes *New();
+ static MEDFileMeshes *New(const char *fileName) throw(INTERP_KERNEL::Exception);
+ void write(const char *fileName, int mode) const throw(INTERP_KERNEL::Exception);
+ int getNumberOfMeshes() const throw(INTERP_KERNEL::Exception);
+ MEDFileMesh *getMeshAtPos(int i) const throw(INTERP_KERNEL::Exception);
+ //
+ void resize(int newSize) throw(INTERP_KERNEL::Exception);
+ void pushMesh(MEDFileMesh *mesh) throw(INTERP_KERNEL::Exception);
+ void setMeshAtPos(int i, MEDFileMesh *mesh) throw(INTERP_KERNEL::Exception);
+ void destroyMeshAtPos(int i) throw(INTERP_KERNEL::Exception);
+ private:
+ void checkCoherency() const throw(INTERP_KERNEL::Exception);
+ void loadFromFile(const char *fileName) throw(INTERP_KERNEL::Exception);
+ MEDFileMeshes();
+ MEDFileMeshes(const char *fileName) throw(INTERP_KERNEL::Exception);
+ private:
+ std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileMeshMultiTS> > _meshes;
};
}
-// Copyright (C) 2007-2010 CEA/DEN, EDF R&D
+// Copyright (C) 2007-2011 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 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.
+// 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
+// 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
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
#include "MEDFileMeshElt.hxx"
#include "InterpKernelAutoPtr.hxx"
#include "CellModel.hxx"
-extern med_geometrie_element typmai3[32];
+#include <iostream>
+
+extern med_geometry_type typmai3[32];
using namespace ParaMEDMEM;
-MEDFileUMeshPerType *MEDFileUMeshPerType::New(med_idt fid, const char *mName, int mdim, med_geometrie_element geoElt, INTERP_KERNEL::NormalizedCellType geoElt2)
+MEDFileUMeshPerType *MEDFileUMeshPerType::New(med_idt fid, const char *mName, int dt, int it, int mdim, med_geometry_type geoElt, INTERP_KERNEL::NormalizedCellType geoElt2)
{
- med_entite_maillage whichEntity;
- if(!isExisting(fid,mName,geoElt,whichEntity))
+ med_entity_type whichEntity;
+ if(!isExisting(fid,mName,dt,it,geoElt,whichEntity))
return 0;
- return new MEDFileUMeshPerType(fid,mName,mdim,geoElt,geoElt2,whichEntity);
+ return new MEDFileUMeshPerType(fid,mName,dt,it,mdim,geoElt,geoElt2,whichEntity);
}
-bool MEDFileUMeshPerType::isExisting(med_idt fid, const char *mName, med_geometrie_element geoElt, med_entite_maillage& whichEntity)
+bool MEDFileUMeshPerType::isExisting(med_idt fid, const char *mName, int dt, int it, med_geometry_type geoElt, med_entity_type& whichEntity)
{
- static const med_entite_maillage entities[3]={MED_MAILLE,MED_FACE,MED_ARETE};
+ static const med_entity_type entities[3]={MED_CELL,MED_DESCENDING_FACE,MED_DESCENDING_EDGE};
int nbOfElt=0;
for(int i=0;i<3;i++)
{
- int tmp=MEDnEntMaa(fid,(char *)mName,MED_CONN,entities[i],geoElt,MED_NOD);
+ med_bool changement,transformation;
+ int tmp=MEDmeshnEntity(fid,mName,dt,it,entities[i],geoElt,MED_CONNECTIVITY,MED_NODAL,
+ &changement,&transformation);
if(tmp>nbOfElt)
{
nbOfElt=tmp;
whichEntity=entities[i];
+ if(i>0)
+ std::cerr << "WARNING : MEDFile has been detected to be no compilant with MED 3 : Please change entity in MEDFile for geotype " << geoElt << std::endl;
}
}
return nbOfElt>0;
int MEDFileUMeshPerType::getDim() const
{
- const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::getCellModel(_type);
+ const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_type);
return cm.getDimension();
}
-MEDFileUMeshPerType::MEDFileUMeshPerType(med_idt fid, const char *mName, int mdim, med_geometrie_element geoElt, INTERP_KERNEL::NormalizedCellType type,
- med_entite_maillage entity):_type(type),_entity(entity)
+MEDFileUMeshPerType::MEDFileUMeshPerType(med_idt fid, const char *mName, int dt, int it, int mdim, med_geometry_type geoElt, INTERP_KERNEL::NormalizedCellType type,
+ med_entity_type entity):_type(type),_entity(entity)
{
- int curNbOfElem=MEDnEntMaa(fid,(char *)mName,MED_CONN,entity,geoElt,MED_NOD);
+ med_bool changement,transformation;
+ int curNbOfElem=MEDmeshnEntity(fid,mName,dt,it,entity,geoElt,MED_CONNECTIVITY,MED_NODAL,
+ &changement,&transformation);
if(type!=INTERP_KERNEL::NORM_POLYGON && type!=INTERP_KERNEL::NORM_POLYHED)
{
- loadFromStaticType(fid,mName,mdim,curNbOfElem,geoElt,type,entity);
+ loadFromStaticType(fid,mName,dt,it,mdim,curNbOfElem,geoElt,type,entity);
return;
}
if(type==INTERP_KERNEL::NORM_POLYGON)
{
- loadPolyg(fid,mName,mdim,curNbOfElem,geoElt,entity);
+ loadPolyg(fid,mName,dt,it,mdim,curNbOfElem,geoElt,entity);
return;
}
//if(type==INTERP_KERNEL::NORM_POLYHED)
- loadPolyh(fid,mName,mdim,curNbOfElem,geoElt,entity);
+ loadPolyh(fid,mName,dt,it,mdim,curNbOfElem,geoElt,entity);
}
-void MEDFileUMeshPerType::loadFromStaticType(med_idt fid, const char *mName, int mdim, int curNbOfElem, med_geometrie_element geoElt, INTERP_KERNEL::NormalizedCellType type,
- med_entite_maillage entity)
+void MEDFileUMeshPerType::loadFromStaticType(med_idt fid, const char *mName, int dt, int it, int mdim, int curNbOfElem, med_geometry_type geoElt, INTERP_KERNEL::NormalizedCellType type,
+ med_entity_type entity)
{
_conn=DataArrayInt::New();
int nbOfNodesPerCell=(geoElt%100);
_conn->alloc((nbOfNodesPerCell+1)*curNbOfElem,1);
_conn_index=DataArrayInt::New();
_conn_index->alloc(curNbOfElem+1,1);
- int *connTab=new int[(nbOfNodesPerCell)*curNbOfElem];
+ INTERP_KERNEL::AutoPtr<int> connTab=new int[(nbOfNodesPerCell)*curNbOfElem];
_num=DataArrayInt::New();
_num->alloc(curNbOfElem,1);
- char *noms=new char[MED_TAILLE_PNOM*curNbOfElem+1];
- med_booleen inoele, inuele;
_fam=DataArrayInt::New();
_fam->alloc(curNbOfElem,1);
- MEDelementsLire(fid,(char *)mName,mdim,connTab,MED_FULL_INTERLACE,noms,&inoele,_num->getPointer(),&inuele,_fam->getPointer(),curNbOfElem,entity,geoElt,MED_NOD);
- delete [] noms;
+ med_bool changement,transformation;
+ INTERP_KERNEL::AutoPtr<char> noms=new char[MED_SNAME_SIZE*curNbOfElem+1];
+ MEDmeshElementConnectivityRd(fid,mName,dt,it,entity,geoElt,MED_NODAL,MED_FULL_INTERLACE,connTab);
+ if(MEDmeshnEntity(fid,mName,dt,it,entity,geoElt,MED_FAMILY_NUMBER,MED_NODAL,&changement,&transformation)>0)
+ {
+ if(MEDmeshEntityFamilyNumberRd(fid,mName,dt,it,entity,geoElt,_fam->getPointer())!=0)
+ std::fill(_fam->getPointer(),_fam->getPointer()+curNbOfElem,0);
+ }
+ else
+ std::fill(_fam->getPointer(),_fam->getPointer()+curNbOfElem,0);
+ if(MEDmeshnEntity(fid,mName,dt,it,entity,geoElt,MED_NUMBER,MED_NODAL,&changement,&transformation)>0)
+ {
+ _num=DataArrayInt::New();
+ _num->alloc(curNbOfElem,1);
+ if(MEDmeshEntityNumberRd(fid,mName,dt,it,entity,geoElt,_num->getPointer())!=0)
+ _num=0;
+ }
+ else
+ _num=0;
int *w1=_conn->getPointer();
int *w2=_conn_index->getPointer();
*w2++=0;
w1=std::transform(wi,wi+nbOfNodesPerCell,w1,std::bind2nd(std::plus<int>(),-1));
*w2=w2[-1]+nbOfNodesPerCell+1;
}
- delete [] connTab;
- if(!inuele)
- _num=0;
}
-void MEDFileUMeshPerType::loadPolyg(med_idt fid, const char *mName, int mdim, int curNbOfElem, med_geometrie_element geoElt,
- med_entite_maillage entity)
+void MEDFileUMeshPerType::loadPolyg(med_idt fid, const char *mName, int dt, int it, int mdim, int arraySize, med_geometry_type geoElt,
+ med_entity_type entity)
{
- med_int arraySize;
- MEDpolygoneInfo(fid,(char *)mName,entity,MED_NOD,&arraySize);
+ med_bool changement,transformation;
+ med_int curNbOfElem=MEDmeshnEntity(fid,mName,dt,it,entity,MED_POLYGON,MED_INDEX_NODE,MED_NODAL,&changement,&transformation)-1;
_conn_index=DataArrayInt::New();
_conn_index->alloc(curNbOfElem+1,1);
_conn=DataArrayInt::New();
_num->alloc(curNbOfElem,1);
_fam=DataArrayInt::New();
_fam->alloc(curNbOfElem,1);
- int *locConn=new int[arraySize];
- MEDpolygoneConnLire(fid,(char *)mName,_conn_index->getPointer(),curNbOfElem+1,locConn,entity,MED_NOD);
+ INTERP_KERNEL::AutoPtr<int> locConn=new int[arraySize];
+ MEDmeshPolygonRd(fid,mName,dt,it,MED_CELL,MED_NODAL,_conn_index->getPointer(),locConn);
int *w1=_conn->getPointer();
int *w2=_conn_index->getPointer();
const int *wi=locConn;
*w2=*w2-1+i;
}
*w2=*w2-1+curNbOfElem;
- delete [] locConn;
- MEDfamLire(fid,(char *)mName,_fam->getPointer(),curNbOfElem,entity,MED_POLYGONE);
- if(MEDnumLire(fid,(char *)mName,_num->getPointer(),curNbOfElem,entity,MED_POLYGONE)!=0)
+ if(MEDmeshnEntity(fid,mName,dt,it,entity,MED_POLYGON,MED_FAMILY_NUMBER,MED_NODAL,&changement,&transformation)>0)
+ {
+ if(MEDmeshEntityFamilyNumberRd(fid,mName,dt,it,entity,MED_POLYGON,_fam->getPointer())!=0)
+ std::fill(_fam->getPointer(),_fam->getPointer()+curNbOfElem,0);
+ }
+ else
+ std::fill(_fam->getPointer(),_fam->getPointer()+curNbOfElem,0);
+ if(MEDmeshnEntity(fid,mName,dt,it,entity,MED_POLYGON,MED_NUMBER,MED_NODAL,&changement,&transformation)>0)
+ {
+ if(MEDmeshEntityNumberRd(fid,mName,dt,it,entity,MED_POLYGON,_num->getPointer())!=0)
+ _num=0;
+ }
+ else
_num=0;
}
-void MEDFileUMeshPerType::loadPolyh(med_idt fid, const char *mName, int mdim, int curNbOfElem, med_geometrie_element geoElt,
- med_entite_maillage entity)
+void MEDFileUMeshPerType::loadPolyh(med_idt fid, const char *mName, int dt, int it, int mdim, int connFaceLgth, med_geometry_type geoElt,
+ med_entity_type entity)
{
- med_int indexFaceLgth,connFaceLgth;
- MEDpolyedreInfo(fid,(char*)mName,MED_NOD,&indexFaceLgth,&connFaceLgth);
- int *index=new int[curNbOfElem+1];
- int *indexFace=new int[indexFaceLgth];
- int *locConn=new int[connFaceLgth];
+ med_bool changement,transformation;
+ med_int indexFaceLgth=MEDmeshnEntity(fid,mName,dt,it,MED_CELL,MED_POLYHEDRON,MED_INDEX_NODE,MED_NODAL,&changement,&transformation);
+ int curNbOfElem=MEDmeshnEntity(fid,mName,dt,it,MED_CELL,MED_POLYHEDRON,MED_INDEX_FACE,MED_NODAL,&changement,&transformation)-1;
+ INTERP_KERNEL::AutoPtr<int> index=new int[curNbOfElem+1];
+ INTERP_KERNEL::AutoPtr<int> indexFace=new int[indexFaceLgth];
+ INTERP_KERNEL::AutoPtr<int> locConn=new int[connFaceLgth];
_fam=DataArrayInt::New();
_fam->alloc(curNbOfElem,1);
- MEDpolyedreConnLire(fid,(char *)mName,index,curNbOfElem+1,indexFace,indexFaceLgth,locConn,MED_NOD);
- MEDfamLire(fid,(char *)mName,_fam->getPointer(),curNbOfElem,MED_MAILLE,MED_POLYEDRE);
+ MEDmeshPolyhedronRd(fid,mName,dt,it,MED_CELL,MED_NODAL,index,indexFace,locConn);
+ if(MEDmeshnEntity(fid,mName,dt,it,entity,MED_POLYHEDRON,MED_FAMILY_NUMBER,MED_NODAL,&changement,&transformation)>0)
+ {
+ if(MEDmeshEntityFamilyNumberRd(fid,mName,dt,it,entity,MED_POLYHEDRON,_fam->getPointer())!=0)
+ std::fill(_fam->getPointer(),_fam->getPointer()+curNbOfElem,0);
+ }
+ else
+ std::fill(_fam->getPointer(),_fam->getPointer()+curNbOfElem,0);
int arraySize=connFaceLgth;
for(int i=0;i<curNbOfElem;i++)
arraySize+=index[i+1]-index[i]-1;
wFinalConn=std::transform(locConn+indexFace[j]-1,locConn+indexFace[j+1]-1,wFinalConn,std::bind2nd(std::plus<int>(),-1));
}
}
- delete [] index;
- delete [] locConn;
- delete [] indexFace;
_num=DataArrayInt::New();
_num->alloc(curNbOfElem,1);
- if(MEDnumLire(fid,(char *)mName,_num->getPointer(),curNbOfElem,MED_MAILLE,MED_POLYEDRE)!=0)
+ if(MEDmeshnEntity(fid,mName,dt,it,entity,MED_POLYHEDRON,MED_NUMBER,MED_NODAL,&changement,&transformation)>0)
+ {
+ if(MEDmeshEntityNumberRd(fid,mName,dt,it,entity,MED_POLYHEDRON,_num->getPointer())!=0)
+ _num=0;
+ }
+ else
_num=0;
}
int nbOfCells=m->getNumberOfCells();
if(nbOfCells<1)
return ;
+ int dt,it;
+ double timm=m->getTime(dt,it);
INTERP_KERNEL::NormalizedCellType ikt=m->getTypeOfCell(0);
- const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::getCellModel(ikt);
- med_geometrie_element curMedType=typmai3[(int)ikt];
+ const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(ikt);
+ med_geometry_type curMedType=typmai3[(int)ikt];
const int *conn=m->getNodalConnectivity()->getConstPointer();
const int *connI=m->getNodalConnectivityIndex()->getConstPointer();
if(ikt!=INTERP_KERNEL::NORM_POLYGON && ikt!=INTERP_KERNEL::NORM_POLYHED)
int *w=tab;
for(int i=0;i<nbOfCells;i++)
w=std::transform(conn+connI[i]+1,conn+connI[i+1],w,std::bind2nd(std::plus<int>(),1));
- MEDconnEcr(fid,(char *)mname,mdim,tab,MED_FULL_INTERLACE,nbOfCells,MED_MAILLE,curMedType,MED_NOD);
+ MEDmeshElementConnectivityWr(fid,mname,dt,it,timm,MED_CELL,curMedType,MED_NODAL,MED_FULL_INTERLACE,nbOfCells,tab);
}
else
{
wI[1]=wI[0]+connI[i+1]-connI[i]-1;
w=std::transform(conn+connI[i]+1,conn+connI[i+1],w,std::bind2nd(std::plus<int>(),1));
}
- MEDpolygoneConnEcr(fid,(char *)mname,tab1,nbOfCells,tab2,MED_MAILLE,MED_NOD);
+ MEDmeshPolygonWr(fid,mname,dt,it,timm,MED_CELL,MED_NODAL,nbOfCells+1,tab1,tab2);
}
else
{
}
w1[1]=w1[0]+nbOfFaces;
}
- MEDpolyedreConnEcr(fid,(char *)mname,tab1,nbOfCells+1,tab2,nbOfFaces+1,
- bigtab,MED_NOD);
+ MEDmeshPolyhedronWr(fid,mname,dt,it,timm,MED_CELL,MED_NODAL,nbOfCells+1,tab1,nbOfFaces+1,tab2,bigtab);
}
}
if(fam)
- MEDfamEcr(fid,(char *)mname,(int *)fam->getConstPointer(),nbOfCells,MED_MAILLE,curMedType);
+ MEDmeshEntityFamilyNumberWr(fid,mname,dt,it,MED_CELL,curMedType,nbOfCells,fam->getConstPointer());
if(num)
- MEDnumEcr(fid,(char *)mname,(int *)num->getConstPointer(),nbOfCells,MED_MAILLE,curMedType);
+ MEDmeshEntityNumberWr(fid,mname,dt,it,MED_CELL,curMedType,nbOfCells,num->getConstPointer());
}
-// Copyright (C) 2007-2010 CEA/DEN, EDF R&D
+// Copyright (C) 2007-2011 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 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.
+// 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
+// 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
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
#ifndef __MEDFILEMESHELT_HXX__
class MEDFileUMeshPerType : public RefCountObject
{
public:
- static MEDFileUMeshPerType *New(med_idt fid, const char *mName, int mdim, med_geometrie_element geoElt, INTERP_KERNEL::NormalizedCellType geoElt2);
- static bool isExisting(med_idt fid, const char *mName, med_geometrie_element geoElt, med_entite_maillage& whichEntity);
+ static MEDFileUMeshPerType *New(med_idt fid, const char *mName, int dt, int it, int mdim, med_geometry_type geoElt, INTERP_KERNEL::NormalizedCellType geoElt2);
+ static bool isExisting(med_idt fid, const char *mName, int dt, int it, med_geometry_type geoElt, med_entity_type& whichEntity);
int getDim() const;
const DataArrayInt *getNodal() const { return _conn; }
const DataArrayInt *getNodalIndex() const { return _conn_index; }
const DataArrayInt *getNum() const { return _num; }
static void write(med_idt fid, const char *mname, int mdim, const MEDCouplingUMesh *m, const DataArrayInt *fam, const DataArrayInt *num);
private:
- MEDFileUMeshPerType(med_idt fid, const char *mName, int mdim, med_geometrie_element geoElt, INTERP_KERNEL::NormalizedCellType type,
- med_entite_maillage entity);
- void loadFromStaticType(med_idt fid, const char *mName, int mdim, int curNbOfElem, med_geometrie_element geoElt, INTERP_KERNEL::NormalizedCellType type,
- med_entite_maillage entity);
- void loadPolyg(med_idt fid, const char *mName, int mdim, int curNbOfElem, med_geometrie_element geoElt,
- med_entite_maillage entity);
- void loadPolyh(med_idt fid, const char *mName, int mdim, int curNbOfElem, med_geometrie_element geoElt,
- med_entite_maillage entity);
+ MEDFileUMeshPerType(med_idt fid, const char *mName, int dt, int it, int mdim, med_geometry_type geoElt, INTERP_KERNEL::NormalizedCellType type,
+ med_entity_type entity);
+ void loadFromStaticType(med_idt fid, const char *mName, int dt, int it, int mdim, int curNbOfElem, med_geometry_type geoElt, INTERP_KERNEL::NormalizedCellType type,
+ med_entity_type entity);
+ void loadPolyg(med_idt fid, const char *mName, int dt, int it, int mdim, int arraySize, med_geometry_type geoElt,
+ med_entity_type entity);
+ void loadPolyh(med_idt fid, const char *mName, int dt, int it, int mdim, int connFaceLgth, med_geometry_type geoElt,
+ med_entity_type entity);
private:
MEDCouplingAutoRefCountObjectPtr<DataArrayInt> _conn;
MEDCouplingAutoRefCountObjectPtr<DataArrayInt> _conn_index;
MEDCouplingAutoRefCountObjectPtr<DataArrayInt> _num;
MEDCouplingAutoRefCountObjectPtr<DataArrayInt> _fam;
INTERP_KERNEL::NormalizedCellType _type;
- med_entite_maillage _entity;
+ med_entity_type _entity;
};
}
-// Copyright (C) 2007-2010 CEA/DEN, EDF R&D
+// Copyright (C) 2007-2011 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 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.
+// 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
+// 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
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
#include "MEDFileMeshLL.hxx"
+#include "MEDFileMesh.hxx"
#include "MEDLoaderBase.hxx"
#include "MEDCouplingUMesh.hxx"
#include <set>
-extern med_geometrie_element typmai[MED_NBR_GEOMETRIE_MAILLE+2];
-extern INTERP_KERNEL::NormalizedCellType typmai2[MED_NBR_GEOMETRIE_MAILLE+2];
-extern med_geometrie_element typmainoeud[1];
+extern med_geometry_type typmai[MED_N_CELL_FIXED_GEO];
+extern INTERP_KERNEL::NormalizedCellType typmai2[MED_N_CELL_FIXED_GEO];
+extern med_geometry_type typmainoeud[1];
using namespace ParaMEDMEM;
-MEDFileMeshL2::MEDFileMeshL2():_name(MED_TAILLE_NOM),_description(MED_TAILLE_DESC)
+MEDFileMeshL2::MEDFileMeshL2():_name(MED_NAME_SIZE),_description(MED_COMMENT_SIZE),_dt_unit(MED_LNAME_SIZE)
{
}
+int MEDFileMeshL2::GetMeshIdFromName(med_idt fid, const char *mname, ParaMEDMEM::MEDCouplingMeshType& meshType, int& dt, int& it, std::string& dtunit1) throw(INTERP_KERNEL::Exception)
+{
+ med_mesh_type type_maillage;
+ char maillage_description[MED_COMMENT_SIZE+1];
+ char dtunit[MED_LNAME_SIZE+1];
+ med_int spaceDim,dim;
+ char nommaa[MED_NAME_SIZE+1];
+ med_int n=MEDnMesh(fid);
+ bool found=false;
+ int ret=-1;
+ med_sorting_type stype;
+ std::vector<std::string> ms;
+ int nstep;
+ med_axis_type axistype;
+ for(int i=0;i<n && !found;i++)
+ {
+ int naxis=MEDmeshnAxis(fid,i+1);
+ INTERP_KERNEL::AutoPtr<char> axisname=MEDLoaderBase::buildEmptyString(naxis*MED_SNAME_SIZE);
+ INTERP_KERNEL::AutoPtr<char> axisunit=MEDLoaderBase::buildEmptyString(naxis*MED_SNAME_SIZE);
+ MEDmeshInfo(fid,i+1,nommaa,&spaceDim,&dim,&type_maillage,maillage_description,dtunit,&stype,&nstep,&axistype,axisname,axisunit);
+ dtunit1=MEDLoaderBase::buildStringFromFortran(dtunit,sizeof(dtunit));
+ std::string cur=MEDLoaderBase::buildStringFromFortran(nommaa,sizeof(nommaa));
+ ms.push_back(cur);
+ if(cur==mname)
+ {
+ found=true;
+ ret=i+1;
+ }
+ }
+ if(!found)
+ {
+ std::ostringstream oss;
+ oss << "No such meshname (" << mname << ") in file ! Must be in :";
+ std::copy(ms.begin(),ms.end(),std::ostream_iterator<std::string>(oss,", "));
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ switch(type_maillage)
+ {
+ case MED_UNSTRUCTURED_MESH:
+ meshType=UNSTRUCTURED;
+ break;
+ case MED_STRUCTURED_MESH:
+ meshType=CARTESIAN;
+ break;
+ default:
+ throw INTERP_KERNEL::Exception("MEDFileUMeshL2::getMeshIdFromName : unrecognized mesh type !");
+ }
+ med_int numdt,numit;
+ med_float dtt;
+ MEDmeshComputationStepInfo(fid,mname,1,&numdt,&numit,&dtt);
+ dt=numdt; it=numit;
+ return ret;
+}
+
+double MEDFileMeshL2::CheckMeshTimeStep(med_idt fid, const char *mName, int nstep, int dt, int it) throw(INTERP_KERNEL::Exception)
+{
+ bool found=false;
+ med_int numdt,numit;
+ med_float dtt;
+ std::vector< std::pair<int,int> > p(nstep);
+ for(int i=0;i<nstep;i++)
+ {
+ MEDmeshComputationStepInfo(fid,mName,i+1,&numdt,&numit,&dtt);
+ p[i]=std::make_pair<int,int>(numdt,numit);
+ found=(numdt==dt) && (numit==numit);
+ }
+ if(!found)
+ {
+ std::ostringstream oss; oss << "No such iteration=" << dt << ",order=" << it << " numbers found for mesh '" << mName << "' ! ";
+ oss << "Possibilities are : ";
+ for(int i=0;i<nstep;i++)
+ oss << "(" << p[i].first << "," << p[i].second << "), ";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ return dtt;
+}
+
+std::vector<std::string> MEDFileMeshL2::getAxisInfoOnMesh(med_idt fid, int mId, const char *mName, ParaMEDMEM::MEDCouplingMeshType& meshType, int& nstep, int& Mdim) throw(INTERP_KERNEL::Exception)
+{
+ med_mesh_type type_maillage;
+ med_int spaceDim;
+ med_sorting_type stype;
+ med_axis_type axistype;
+ int naxis=MEDmeshnAxis(fid,mId);
+ INTERP_KERNEL::AutoPtr<char> nameTmp=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
+ INTERP_KERNEL::AutoPtr<char> axisname=MEDLoaderBase::buildEmptyString(naxis*MED_SNAME_SIZE);
+ INTERP_KERNEL::AutoPtr<char> axisunit=MEDLoaderBase::buildEmptyString(naxis*MED_SNAME_SIZE);
+ if(MEDmeshInfo(fid,mId,nameTmp,&spaceDim,&Mdim,&type_maillage,_description.getPointer(),_dt_unit.getPointer(),
+ &stype,&nstep,&axistype,axisname,axisunit)!=0)
+ throw INTERP_KERNEL::Exception("A problem has been detected when trying to get info on mesh !");
+ switch(type_maillage)
+ {
+ case MED_UNSTRUCTURED_MESH:
+ meshType=UNSTRUCTURED;
+ break;
+ case MED_STRUCTURED_MESH:
+ meshType=CARTESIAN;
+ break;
+ default:
+ throw INTERP_KERNEL::Exception("MEDFileUMeshL2::getMeshIdFromName : unrecognized mesh type !");
+ }
+ //
+ std::vector<std::string> infosOnComp(naxis);
+ for(int i=0;i<naxis;i++)
+ {
+ std::string info=MEDLoaderBase::buildUnionUnit(((char *)axisname)+i*MED_SNAME_SIZE,MED_SNAME_SIZE,((char *)axisunit)+i*MED_SNAME_SIZE,MED_SNAME_SIZE);
+ infosOnComp[i]=info;
+ }
+ return infosOnComp;
+}
+
+void MEDFileMeshL2::ReadFamiliesAndGrps(med_idt fid, const char *meshName, std::map<std::string,int>& fams, std::map<std::string, std::vector<std::string> >& grps)
+{
+ char nomfam[MED_NAME_SIZE+1];
+ med_int numfam;
+ int nfam=MEDnFamily(fid,meshName);
+ for(int i=0;i<nfam;i++)
+ {
+ int ngro=MEDnFamilyGroup(fid,meshName,i+1);
+ med_int natt=MEDnFamily23Attribute(fid,meshName,i+1);
+ INTERP_KERNEL::AutoPtr<med_int> attide=new med_int[natt];
+ INTERP_KERNEL::AutoPtr<med_int> attval=new med_int[natt];
+ INTERP_KERNEL::AutoPtr<char> attdes=new char[MED_COMMENT_SIZE*natt+1];
+ INTERP_KERNEL::AutoPtr<char> gro=new char[MED_LNAME_SIZE*ngro+1];
+ MEDfamily23Info(fid,meshName,i+1,nomfam,attide,attval,attdes,&numfam,gro);
+ std::string famName=MEDLoaderBase::buildStringFromFortran(nomfam,MED_NAME_SIZE);
+ fams[famName]=numfam;
+ for(int j=0;j<ngro;j++)
+ {
+ std::string groupname=MEDLoaderBase::buildStringFromFortran(gro+j*MED_LNAME_SIZE,MED_LNAME_SIZE);
+ grps[groupname].push_back(famName);
+ }
+ }
+}
+
+void MEDFileMeshL2::WriteFamiliesAndGrps(med_idt fid, const char *mname, const std::map<std::string,int>& fams, const std::map<std::string, std::vector<std::string> >& grps, int tooLongStrPol)
+{
+ for(std::map<std::string,int>::const_iterator it=fams.begin();it!=fams.end();it++)
+ {
+ std::vector<std::string> grpsOfFam;
+ for(std::map<std::string, std::vector<std::string> >::const_iterator it1=grps.begin();it1!=grps.end();it1++)
+ {
+ if(std::find((*it1).second.begin(),(*it1).second.end(),(*it).first)!=(*it1).second.end())
+ grpsOfFam.push_back((*it1).first);
+ }
+ int ngro=grpsOfFam.size();
+ INTERP_KERNEL::AutoPtr<char> groName=MEDLoaderBase::buildEmptyString(MED_LNAME_SIZE*ngro);
+ int i=0;
+ for(std::vector<std::string>::const_iterator it2=grpsOfFam.begin();it2!=grpsOfFam.end();it2++,i++)
+ MEDLoaderBase::safeStrCpy2((*it2).c_str(),MED_LNAME_SIZE-1,groName+i*MED_LNAME_SIZE,tooLongStrPol);
+ INTERP_KERNEL::AutoPtr<char> famName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
+ MEDLoaderBase::safeStrCpy((*it).first.c_str(),MED_NAME_SIZE,famName,tooLongStrPol);
+ int ret=MEDfamilyCr(fid,mname,famName,(*it).second,ngro,groName);
+ ret++;
+ }
+}
+
MEDFileUMeshL2::MEDFileUMeshL2()
{
}
-void MEDFileUMeshL2::loadAll(med_idt fid, int mId, const char *mName)
+void MEDFileUMeshL2::loadAll(med_idt fid, int mId, const char *mName, int dt, int it)
{
_name.set(mName);
- med_maillage type_maillage;
- med_int Mdim;
- if(MEDmaaInfo(fid,mId,(char *)mName,&Mdim,&type_maillage,_description.getPointer())!=0)
- throw INTERP_KERNEL::Exception("A problem has been detected when trying to get info on mesh !");
- if(type_maillage!=MED_NON_STRUCTURE)
+ int nstep;
+ int Mdim;
+ ParaMEDMEM::MEDCouplingMeshType meshType;
+ std::vector<std::string> infosOnComp=getAxisInfoOnMesh(fid,mId,mName,meshType,nstep,Mdim);
+ if(meshType!=UNSTRUCTURED)
throw INTERP_KERNEL::Exception("Invalid mesh type ! You are expected an unstructured one whereas in file it is not an unstructured !");
- loadConnectivity(fid,Mdim,mName);
- loadCoords(fid,mId,Mdim,mName);
+ _time=CheckMeshTimeStep(fid,mName,nstep,dt,it);
+ _iteration=dt;
+ _order=it;
+ loadConnectivity(fid,Mdim,mName,dt,it);//to improve check (dt,it) coherency
+ loadCoords(fid,mId,infosOnComp,mName,dt,it);
}
-void MEDFileUMeshL2::loadConnectivity(med_idt fid, int mdim, const char *mName)
+void MEDFileUMeshL2::loadConnectivity(med_idt fid, int mdim, const char *mName, int dt, int it)
{
_per_type_mesh.resize(1);
_per_type_mesh[0].clear();
- for(int j=0;j<MED_NBR_GEOMETRIE_MAILLE+2;j++)
+ for(int j=0;j<MED_N_CELL_FIXED_GEO;j++)
{
- MEDFileUMeshPerType *tmp=MEDFileUMeshPerType::New(fid,mName,mdim,typmai[j],typmai2[j]);
+ MEDFileUMeshPerType *tmp=MEDFileUMeshPerType::New(fid,mName,dt,it,mdim,typmai[j],typmai2[j]);
if(tmp)
_per_type_mesh[0].push_back(tmp);
}
sortTypes();
}
-void MEDFileUMeshL2::loadCoords(med_idt fid, int mId, int mdim, const char *mName) throw(INTERP_KERNEL::Exception)
+void MEDFileUMeshL2::loadCoords(med_idt fid, int mId, const std::vector<std::string>& infosOnComp, const char *mName, int dt, int it) throw(INTERP_KERNEL::Exception)
{
- med_int edim=MEDdimEspaceLire(fid,(char *)mName);
- int spaceDim=std::max((int)mdim,(int)edim);
- int nCoords=MEDnEntMaa(fid,(char *)mName,MED_COOR,MED_NOEUD,(med_geometrie_element)0,(med_connectivite)0);
+ int spaceDim=infosOnComp.size();
+ med_bool changement,transformation;
+ int nCoords=MEDmeshnEntity(fid,mName,dt,it,MED_NODE,MED_NONE,MED_COORDINATE,MED_NO_CMODE,&changement,&transformation);
_coords=DataArrayDouble::New();
_coords->alloc(nCoords,spaceDim);
double *coordsPtr=_coords->getPointer();
- med_repere repere;
- char *comp=MEDLoaderBase::buildEmptyString(spaceDim*MED_TAILLE_PNOM);
- char *unit=MEDLoaderBase::buildEmptyString(spaceDim*MED_TAILLE_PNOM);
- MEDcoordLire(fid,(char *)mName,spaceDim,coordsPtr,MED_FULL_INTERLACE,MED_ALL,NULL,0,&repere,comp,unit);
+ MEDmeshNodeCoordinateRd(fid,mName,dt,it,MED_FULL_INTERLACE,coordsPtr);
_fam_coords=DataArrayInt::New();
_fam_coords->alloc(nCoords,1);
_num_coords=DataArrayInt::New();
_num_coords->alloc(nCoords,1);
- MEDfamLire(fid,(char *)mName,_fam_coords->getPointer(),nCoords,MED_NOEUD,MED_NONE);
- if(MEDnumLire(fid,(char *)mName,_num_coords->getPointer(),nCoords,MED_NOEUD,MED_NONE)!=0)
+ if(MEDmeshnEntity(fid,mName,dt,it,MED_NODE,MED_NO_GEOTYPE,MED_FAMILY_NUMBER,MED_NODAL,&changement,&transformation)>0)
+ MEDmeshEntityFamilyNumberRd(fid,mName,dt,it,MED_NODE,MED_NO_GEOTYPE,_fam_coords->getPointer());
+ else
+ _fam_coords=0;
+ if(MEDmeshnEntity(fid,mName,dt,it,MED_NODE,MED_NO_GEOTYPE,MED_NUMBER,MED_NODAL,&changement,&transformation)>0)
+ MEDmeshEntityNumberRd(fid,mName,dt,it,MED_NODE,MED_NO_GEOTYPE,_num_coords->getPointer());
+ else
_num_coords=0;
for(int i=0;i<spaceDim;i++)
- {
- std::string n,u;
- std::string info=MEDLoaderBase::buildUnionUnit(comp+i*MED_TAILLE_PNOM,MED_TAILLE_PNOM,unit+i*MED_TAILLE_PNOM,MED_TAILLE_PNOM);
- _coords->setInfoOnComponent(i,info.c_str());
- }
- delete [] comp;
- delete [] unit;
+ _coords->setInfoOnComponent(i,infosOnComp[i].c_str());
}
void MEDFileUMeshL2::sortTypes()
}
}
-int MEDFileUMeshL2::getMeshIdFromName(med_idt fid, const char *mname) throw(INTERP_KERNEL::Exception)
+void MEDFileUMeshL2::WriteCoords(med_idt fid, const char *mname, int dt, int it, double time, const DataArrayDouble *coords, const DataArrayInt *famCoords, const DataArrayInt *numCoords)
{
- med_maillage type_maillage;
- char maillage_description[MED_TAILLE_DESC+1];
- med_int dim;
- char nommaa[MED_TAILLE_NOM+1];
- med_int n=MEDnMaa(fid);
- bool found=false;
- int ret=-1;
- std::vector<std::string> ms;
- for(int i=0;i<n;i++)
- {
- MEDmaaInfo(fid,i+1,nommaa,&dim,&type_maillage,maillage_description);
- std::string cur=MEDLoaderBase::buildStringFromFortran(nommaa,sizeof(nommaa));
- ms.push_back(cur);
- if(cur==mname)
- {
- found=true;
- ret=i+1;
- }
- }
- if(!found)
- {
- std::ostringstream oss;
- oss << "No such meshname (" << mname << ") in file ! Must be in :";
- std::copy(ms.begin(),ms.end(),std::ostream_iterator<std::string>(oss,", "));
- throw INTERP_KERNEL::Exception(oss.str().c_str());
- }
- return ret;
+ if(!coords)
+ return ;
+ MEDmeshNodeCoordinateWr(fid,mname,dt,it,time,MED_FULL_INTERLACE,coords->getNumberOfTuples(),coords->getPointer());
+ if(famCoords)
+ MEDmeshEntityFamilyNumberWr(fid,mname,dt,it,MED_NODE,MED_NO_GEOTYPE,famCoords->getNumberOfTuples(),famCoords->getPointer());
+ if(numCoords)
+ MEDmeshEntityNumberWr(fid,mname,dt,it,MED_NODE,MED_NO_GEOTYPE,numCoords->getNumberOfTuples(),numCoords->getPointer());
}
-void MEDFileUMeshL2::readFamiliesAndGrps(med_idt fid, const char *meshName, std::map<std::string,int>& fams, std::map<std::string, std::vector<std::string> >& grps)
+bool MEDFileUMeshL2::isFamDefinedOnLev(int levId) const
{
- char nomfam[MED_TAILLE_NOM+1];
- med_int numfam;
- int nfam=MEDnFam(fid,(char *)meshName);
- for(int i=0;i<nfam;i++)
+ for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileUMeshPerType> >::const_iterator it=_per_type_mesh[levId].begin();it!=_per_type_mesh[levId].end();it++)
+ if((*it)->getFam()==0)
+ return false;
+ return true;
+}
+
+bool MEDFileUMeshL2::isNumDefinedOnLev(int levId) const
+{
+ for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileUMeshPerType> >::const_iterator it=_per_type_mesh[levId].begin();it!=_per_type_mesh[levId].end();it++)
+ if((*it)->getNum()==0)
+ return false;
+ return true;
+}
+
+MEDFileCMeshL2::MEDFileCMeshL2()
+{
+}
+
+void MEDFileCMeshL2::loadAll(med_idt fid, int mId, const char *mName, int dt, int it) throw(INTERP_KERNEL::Exception)
+{
+ _name.set(mName);
+ int nstep;
+ int Mdim;
+ ParaMEDMEM::MEDCouplingMeshType meshType;
+ std::vector<std::string> infosOnComp=getAxisInfoOnMesh(fid,mId,mName,meshType,nstep,Mdim);
+ if(meshType!=CARTESIAN)
+ throw INTERP_KERNEL::Exception("Invalid mesh type ! You are expected a structured one whereas in file it is not a structured !");
+ _time=CheckMeshTimeStep(fid,mName,nstep,dt,it);
+ _iteration=dt;
+ _order=it;
+ //
+ med_grid_type gridtype;
+ MEDmeshGridTypeRd(fid,mName,&gridtype);
+ if(gridtype!=MED_CARTESIAN_GRID)
+ throw INTERP_KERNEL::Exception("Invalid cartesion mesh type ! Only Cartesian Grid supported ! Curvilinear grid will come soon !");
+ _cmesh=MEDCouplingCMesh::New();
+ for(int i=0;i<Mdim;i++)
{
- int ngro=MEDnGroupe(fid,(char *)meshName,i+1);
- med_int natt=MEDnAttribut(fid,(char *)meshName,i+1);
- med_int *attide=new int[natt];
- med_int *attval=new int[natt];
- char *attdes=new char[MED_TAILLE_DESC*natt+1];
- char *gro=new char[MED_TAILLE_LNOM*ngro+1];
- MEDfamInfo(fid,(char *)meshName,i+1,nomfam,&numfam,attide,attval,attdes,&natt,gro,&ngro);
- std::string famName=MEDLoaderBase::buildStringFromFortran(nomfam,MED_TAILLE_LNOM);
- fams[famName]=numfam;
- for(int j=0;j<ngro;j++)
- {
- std::string groupname=MEDLoaderBase::buildStringFromFortran(gro+j*MED_TAILLE_LNOM,MED_TAILLE_LNOM);
- grps[groupname].push_back(famName);
- }
- delete [] attdes;
- delete [] gro;
- delete [] attide;
- delete [] attval;
+ med_data_type dataTypeReq=GetDataTypeCorrespondingToSpaceId(i);
+ med_bool chgt=MED_FALSE,trsf=MED_FALSE;
+ int nbOfElt=MEDmeshnEntity(fid,mName,dt,it,MED_NODE,MED_NONE,dataTypeReq,MED_NO_CMODE,&chgt,&trsf);
+ MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> da=DataArrayDouble::New();
+ da->alloc(nbOfElt,1);
+ da->setInfoOnComponent(0,infosOnComp[i].c_str());
+ MEDmeshGridIndexCoordinateRd(fid,mName,dt,it,i+1,da->getPointer());
+ _cmesh->setCoordsAt(i,da);
}
}
-void MEDFileUMeshL2::writeFamiliesAndGrps(med_idt fid, const char *mname, const std::map<std::string,int>& fams, const std::map<std::string, std::vector<std::string> >& grps, int tooLongStrPol)
+med_data_type MEDFileCMeshL2::GetDataTypeCorrespondingToSpaceId(int id) throw(INTERP_KERNEL::Exception)
{
- for(std::map<std::string,int>::const_iterator it=fams.begin();it!=fams.end();it++)
+ switch(id)
{
- std::vector<std::string> grpsOfFam;
- for(std::map<std::string, std::vector<std::string> >::const_iterator it1=grps.begin();it1!=grps.end();it1++)
- {
- if(std::find((*it1).second.begin(),(*it1).second.end(),(*it).first)!=(*it1).second.end())
- grpsOfFam.push_back((*it1).first);
- }
- int ngro=grpsOfFam.size();
- INTERP_KERNEL::AutoPtr<char> groName=MEDLoaderBase::buildEmptyString(MED_TAILLE_LNOM*ngro);
- int i=0;
- for(std::vector<std::string>::const_iterator it2=grpsOfFam.begin();it2!=grpsOfFam.end();it2++,i++)
- MEDLoaderBase::safeStrCpy((*it2).c_str(),MED_TAILLE_LNOM-1,groName+i*MED_TAILLE_LNOM,tooLongStrPol);
- INTERP_KERNEL::AutoPtr<char> famName=MEDLoaderBase::buildEmptyString(MED_TAILLE_NOM);
- MEDLoaderBase::safeStrCpy((*it).first.c_str(),MED_TAILLE_NOM,famName,tooLongStrPol);
- MEDfamCr(fid,(char *)mname,famName,(*it).second,0,0,0,0,groName,ngro);
+ case 0:
+ return MED_COORDINATE_AXIS1;
+ case 1:
+ return MED_COORDINATE_AXIS2;
+ case 2:
+ return MED_COORDINATE_AXIS3;
+ default:
+ throw INTERP_KERNEL::Exception("Invalid meshdim detected in Cartesian Grid !");
}
}
-void MEDFileUMeshL2::writeCoords(med_idt fid, const char *mname, const DataArrayDouble *coords, const DataArrayInt *famCoords, const DataArrayInt *numCoords)
+MEDFileUMeshPermCompute::MEDFileUMeshPermCompute(const MEDFileUMeshSplitL1* st):_st(st),_mpt_time(0),_num_time(0)
{
- if(!coords)
- return ;
- int spaceDim=coords->getNumberOfComponents();
- INTERP_KERNEL::AutoPtr<char> comp=MEDLoaderBase::buildEmptyString(spaceDim*MED_TAILLE_PNOM);
- INTERP_KERNEL::AutoPtr<char> unit=MEDLoaderBase::buildEmptyString(spaceDim*MED_TAILLE_PNOM);
- for(int i=0;i<spaceDim;i++)
+}
+
+/*!
+ * Warning it returns an instance to deallocate !!!!
+ */
+MEDFileUMeshPermCompute::operator MEDCouplingUMesh *() const
+{
+ _st->_m_by_types->updateTime();
+ _st->_num->updateTime();
+ if((MEDCouplingUMesh *)_m==0)
{
- std::string info=coords->getInfoOnComponent(i);
- std::string c,u;
- MEDLoaderBase::splitIntoNameAndUnit(info,c,u);
- MEDLoaderBase::safeStrCpy(c.c_str(),MED_TAILLE_PNOM-1,comp+i*MED_TAILLE_PNOM,0);//MED_TAILLE_PNOM-1 to avoid to write '\0' on next compo
- MEDLoaderBase::safeStrCpy(u.c_str(),MED_TAILLE_PNOM-1,unit+i*MED_TAILLE_PNOM,0);//MED_TAILLE_PNOM-1 to avoid to write '\0' on next compo
+ updateTime();
+ MEDCouplingUMesh *ret=(MEDCouplingUMesh *)_st->_m_by_types->deepCpy();
+ _m=ret;
+ _m->renumberCells(_st->_num->getConstPointer(),true);
+ ret->incrRef();
+ return ret;
+ }
+ else
+ {
+ if(_mpt_time==_st->_m_by_types->getTimeOfThis() && _num_time==_st->_num->getTimeOfThis())
+ {
+ _m->incrRef();
+ return _m;
+ }
+ else
+ {
+ updateTime();
+ MEDCouplingUMesh *ret=(MEDCouplingUMesh *)_st->_m_by_types->deepCpy();
+ _m=ret;
+ _m->renumberCells(_st->_num->getConstPointer(),true);
+ ret->incrRef();
+ return ret;
+ }
}
- MEDcoordEcr(fid,(char *)mname,spaceDim,coords->getPointer(),MED_FULL_INTERLACE,coords->getNumberOfTuples(),MED_CART,comp,unit);
- MEDfamEcr(fid,(char *)mname,famCoords->getPointer(),famCoords->getNumberOfTuples(),MED_NOEUD,MED_NONE);
- if(numCoords)
- MEDnumEcr(fid,(char *)mname,numCoords->getPointer(),numCoords->getNumberOfTuples(),MED_NOEUD,MED_NONE);
}
-bool MEDFileUMeshL2::isFamDefinedOnLev(int levId) const
+void MEDFileUMeshPermCompute::operator=(MEDCouplingUMesh *m)
{
- for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileUMeshPerType> >::const_iterator it=_per_type_mesh[levId].begin();it!=_per_type_mesh[levId].end();it++)
- if((*it)->getFam()==0)
- return false;
- return true;
+ _m=m;
}
-bool MEDFileUMeshL2::isNumDefinedOnLev(int levId) const
+void MEDFileUMeshPermCompute::updateTime() const
{
- for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileUMeshPerType> >::const_iterator it=_per_type_mesh[levId].begin();it!=_per_type_mesh[levId].end();it++)
- if((*it)->getNum()==0)
- return false;
- return true;
+ _mpt_time=_st->_m_by_types->getTimeOfThis();
+ _num_time=_st->_num->getTimeOfThis();
}
-MEDFileUMeshSplitL1::MEDFileUMeshSplitL1(const MEDFileUMeshL2& l2, const char *mName, int id)
+MEDFileUMeshSplitL1::MEDFileUMeshSplitL1(const MEDFileUMeshL2& l2, const char *mName, int id):_m(this)
{
const std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileUMeshPerType> >& v=l2.getLev(id);
if(v.empty())
for(int i=0;i<sz;i++)
w=std::copy(v[i]->getNum()->getConstPointer(),v[i]->getNum()->getConstPointer()+v[i]->getNum()->getNumberOfTuples(),w);
computeRevNum();
- _m=(MEDCouplingUMesh *)_m_by_types->deepCpy();
- _m->renumberCells(_num->getConstPointer(),true);
}
- else
- _m=_m_by_types;
for(int i=0;i<sz;i++)
(const_cast<MEDCouplingUMesh *>(ms[i]))->decrRef();//const cast under control to avoid a copy of array
}
-MEDFileUMeshSplitL1::MEDFileUMeshSplitL1(MEDCouplingUMesh *m)
+MEDFileUMeshSplitL1::MEDFileUMeshSplitL1(MEDCouplingUMesh *m):_m(this)
{
assignMesh(m,true);
}
-MEDFileUMeshSplitL1::MEDFileUMeshSplitL1(MEDCouplingUMesh *m, bool newOrOld)
+MEDFileUMeshSplitL1::MEDFileUMeshSplitL1(MEDCouplingUMesh *m, bool newOrOld):_m(this)
{
assignMesh(m,newOrOld);
}
+bool MEDFileUMeshSplitL1::isEqual(const MEDFileUMeshSplitL1 *other, double eps, std::string& what) const
+{
+ const MEDCouplingUMesh *m1=_m_by_types;
+ const MEDCouplingUMesh *m2=other->_m_by_types;
+ if((m1==0 && m2!=0) || (m1!=0 && m2==0))
+ {
+ what="Presence of mesh in one sublevel and not in other!";
+ return false;
+ }
+ if(m1)
+ if(!m1->isEqual(m2,eps))
+ {
+ what="meshes at a sublevel are not deeply equal !";
+ return false;
+ }
+ const DataArrayInt *d1=_fam;
+ const DataArrayInt *d2=other->_fam;
+ if((d1==0 && d2!=0) || (d1!=0 && d2==0))
+ {
+ what="Presence of family arr in one sublevel and not in other!";
+ return false;
+ }
+ if(d1)
+ if(!d1->isEqual(*d2))
+ {
+ what="family arr at a sublevel are not deeply equal !";
+ return false;
+ }
+ d1=_num;
+ d2=other->_num;
+ if((d1==0 && d2!=0) || (d1!=0 && d2==0))
+ {
+ what="Presence of cell numbering arr in one sublevel and not in other!";
+ return false;
+ }
+ if(d1)
+ if(!d1->isEqual(*d2))
+ {
+ what="Numbering cell arr at a sublevel are not deeply equal !";
+ return false;
+ }
+ return true;
+}
+
+void MEDFileUMeshSplitL1::synchronizeTinyInfo(const MEDFileMesh& master) const
+{
+ const MEDCouplingUMesh *tmp=_m_by_types;
+ if(!tmp)
+ return ;
+ (const_cast<MEDCouplingUMesh *>(tmp))->setName(master.getName());
+ (const_cast<MEDCouplingUMesh *>(tmp))->setDescription(master.getDescription());
+ (const_cast<MEDCouplingUMesh *>(tmp))->setTime(master.getTimeValue(),master.getIteration(),master.getOrder());
+ (const_cast<MEDCouplingUMesh *>(tmp))->setTimeUnit(master.getTimeUnit());
+}
+
+void MEDFileUMeshSplitL1::clearNonDiscrAttributes() const
+{
+ ClearNonDiscrAttributes(_m_by_types);
+}
+
+void MEDFileUMeshSplitL1::ClearNonDiscrAttributes(const MEDCouplingMesh *tmp)
+{
+ if(!tmp)
+ return ;
+ (const_cast<MEDCouplingMesh *>(tmp))->setName("");
+ (const_cast<MEDCouplingMesh *>(tmp))->setDescription("");
+ (const_cast<MEDCouplingMesh *>(tmp))->setTime(0.,-1,-1);
+ (const_cast<MEDCouplingMesh *>(tmp))->setTimeUnit("");
+}
+
void MEDFileUMeshSplitL1::assignMesh(MEDCouplingUMesh *m, bool newOrOld) throw(INTERP_KERNEL::Exception)
{
if(newOrOld)
{
m->incrRef();
_m=m;
- _m_by_types=(MEDCouplingUMesh *)_m->deepCpy();
- MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da=_m_by_types->getRenumArrForConsecutiveCellTypesSpec(typmai2,typmai2+MED_NBR_GEOMETRIE_MAILLE+2);
+ _m_by_types=(MEDCouplingUMesh *)m->deepCpy();
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da=_m_by_types->getRenumArrForConsecutiveCellTypesSpec(typmai2,typmai2+MED_N_CELL_FIXED_GEO);
if(!da->isIdentity())
{
_num=da->invertArrayO2N2N2O(m->getNumberOfCells());
+ _m.updateTime();
computeRevNum();
_m_by_types->renumberCells(da->getConstPointer(),false);
}
}
else
{
- if(!m->checkConsecutiveCellTypesAndOrder(typmai2,typmai2+MED_NBR_GEOMETRIE_MAILLE+2))
+ if(!m->checkConsecutiveCellTypesAndOrder(typmai2,typmai2+MED_N_CELL_FIXED_GEO))
throw INTERP_KERNEL::Exception("MEDFileUMeshSplitL1::assignMesh : the mode of mesh setting expects to follow the MED file numbering convention ! it is not the case !");
m->incrRef();
_m_by_types=m;
return ((const MEDCouplingUMesh *)_m_by_types)==0;
}
+bool MEDFileUMeshSplitL1::presenceOfOneFams(const std::vector<int>& ids) const
+{
+ const DataArrayInt *fam=_fam;
+ if(!fam)
+ return false;
+ return fam->presenceOfValue(ids);
+}
+
int MEDFileUMeshSplitL1::getMeshDimension() const
{
return _m_by_types->getMeshDimension();
_m=MEDCouplingUMesh::FuseUMeshesOnSameCoords(ms,0,corr);
std::vector< std::vector<int> > fidsOfGroups;
std::vector< const DataArrayInt * > corr2(corr.begin(),corr.end());
- _fam=DataArrayInt::MakePartition(corr2,_m->getNumberOfCells(),fidsOfGroups);
- int nbOfCells=_m->getNumberOfCells();
+ _fam=DataArrayInt::MakePartition(corr2,((MEDCouplingUMesh *)_m)->getNumberOfCells(),fidsOfGroups);
+ int nbOfCells=((MEDCouplingUMesh *)_m)->getNumberOfCells();
std::map<int,std::string> newfams;
std::map<int,int> famIdTrad;
- traduceFamilyNumber(fidsOfGroups,familyIds,famIdTrad,newfams);
+ TraduceFamilyNumber(fidsOfGroups,familyIds,famIdTrad,newfams);
for(int i=0;i<sz;i++)
corr[i]->decrRef();
int *w=_fam->getPointer();
return Renumber(_num,da);
}
-std::vector<int> MEDFileUMeshSplitL1::getNewFamiliesNumber(int nb, const std::map<std::string,int>& families)
+std::vector<int> MEDFileUMeshSplitL1::GetNewFamiliesNumber(int nb, const std::map<std::string,int>& families)
{
int id=-1;
for(std::map<std::string,int>::const_iterator it=families.begin();it!=families.end();it++)
return ret;
}
-void MEDFileUMeshSplitL1::traduceFamilyNumber(const std::vector< std::vector<int> >& fidsGrps, std::map<std::string,int>& familyIds,
+void MEDFileUMeshSplitL1::TraduceFamilyNumber(const std::vector< std::vector<int> >& fidsGrps, std::map<std::string,int>& familyIds,
std::map<int,int>& famIdTrad, std::map<int,std::string>& newfams)
{
std::set<int> allfids;
-// Copyright (C) 2007-2010 CEA/DEN, EDF R&D
+// Copyright (C) 2007-2011 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 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.
+// 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
+// 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
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
#ifndef __MEDFILEMESHLL_HXX__
#include "MEDFileBasis.hxx"
#include "MEDFileMeshElt.hxx"
+#include "MEDCouplingUMesh.hxx"
+#include "MEDCouplingCMesh.hxx"
#include "MEDCouplingAutoRefCountObjectPtr.hxx"
extern "C"
namespace ParaMEDMEM
{
- class MEDCouplingUMesh;
-
class MEDFileMeshL2 : public RefCountObject
{
public:
MEDFileMeshL2();
const char *getName() const { return _name.getReprForWrite(); }
- const char *getDescription() const { return _description.getReprForWrite(); }
+ const char *getDescription() const { return _description.getReprForWrite(); }
+ const char *getTimeUnit() const { return _dt_unit.getReprForWrite(); }
+ int getIteration() const { return _iteration; }
+ int getOrder() const { return _order; }
+ double getTime() { return _time; }
+ std::vector<std::string> getAxisInfoOnMesh(med_idt fid, int mId, const char *mName, ParaMEDMEM::MEDCouplingMeshType& meshType, int& nstep, int& Mdim) throw(INTERP_KERNEL::Exception);
+ static int GetMeshIdFromName(med_idt fid, const char *mName, ParaMEDMEM::MEDCouplingMeshType& meshType, int& dt, int& it, std::string& dtunit1) throw(INTERP_KERNEL::Exception);
+ static double CheckMeshTimeStep(med_idt fid, const char *mname, int nstep, int dt, int it) throw(INTERP_KERNEL::Exception);
+ static void ReadFamiliesAndGrps(med_idt fid, const char *mname, std::map<std::string,int>& fams, std::map<std::string, std::vector<std::string> >& grps);
+ static void WriteFamiliesAndGrps(med_idt fid, const char *mname, const std::map<std::string,int>& fams, const std::map<std::string, std::vector<std::string> >& grps, int tooLongStrPol);
protected:
MEDFileString _name;
MEDFileString _description;
+ MEDFileString _dt_unit;
+ int _iteration;
+ int _order;
+ double _time;
};
class MEDFileUMeshL2 : public MEDFileMeshL2
{
public:
MEDFileUMeshL2();
- void loadAll(med_idt fid, int mId, const char *mName);
- void loadConnectivity(med_idt fid, int mdim, const char *mName);
- void loadCoords(med_idt fid, int mId, int mdim, const char *mName) throw(INTERP_KERNEL::Exception);
+ void loadAll(med_idt fid, int mId, const char *mName, int dt, int it);
+ void loadConnectivity(med_idt fid, int mdim, const char *mName, int dt, int it);
+ void loadCoords(med_idt fid, int mId, const std::vector<std::string>& infosOnComp, const char *mName, int dt, int it) throw(INTERP_KERNEL::Exception);
int getNumberOfLevels() const { return _per_type_mesh.size(); }
bool emptyLev(int levId) const { return _per_type_mesh[levId].empty(); }
const std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileUMeshPerType> >& getLev(int levId) const { return _per_type_mesh[levId]; }
MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> getCoords() const { return _coords; }
MEDCouplingAutoRefCountObjectPtr<DataArrayInt> getCoordsFamily() const { return _fam_coords; }
MEDCouplingAutoRefCountObjectPtr<DataArrayInt> getCoordsNum() const { return _num_coords; }
- static int getMeshIdFromName(med_idt fid, const char *mname) throw(INTERP_KERNEL::Exception);
- static void readFamiliesAndGrps(med_idt fid, const char *mname, std::map<std::string,int>& fams, std::map<std::string, std::vector<std::string> >& grps);
- static void writeFamiliesAndGrps(med_idt fid, const char *mname, const std::map<std::string,int>& fams, const std::map<std::string, std::vector<std::string> >& grps, int tooLongStrPol);
- static void writeCoords(med_idt fid, const char *mname, const DataArrayDouble *coords, const DataArrayInt *famCoords, const DataArrayInt *numCoords);
+ static void WriteCoords(med_idt fid, const char *mname, int dt, int it, double time, const DataArrayDouble *coords, const DataArrayInt *famCoords, const DataArrayInt *numCoords);
private:
void sortTypes();
private:
MEDCouplingAutoRefCountObjectPtr<DataArrayInt> _num_coords;
};
- class MEDFileUMeshL2CMesh : public MEDFileMeshL2
+ class MEDFileCMeshL2 : public MEDFileMeshL2
+ {
+ public:
+ MEDFileCMeshL2();
+ void loadAll(med_idt fid, int mId, const char *mName, int dt, int it) throw(INTERP_KERNEL::Exception);
+ MEDCouplingCMesh *getMesh() { return _cmesh; }
+ private:
+ static med_data_type GetDataTypeCorrespondingToSpaceId(int id) throw(INTERP_KERNEL::Exception);
+ private:
+ MEDCouplingAutoRefCountObjectPtr<MEDCouplingCMesh> _cmesh;
+ };
+
+ class MEDFileMesh;
+ class MEDFileUMeshSplitL1;
+
+ class MEDFileUMeshPermCompute
{
+ public:
+ MEDFileUMeshPermCompute(const MEDFileUMeshSplitL1* st);
+ operator MEDCouplingUMesh *() const;
+ void operator=(MEDCouplingUMesh *m);
+ void updateTime() const;
+ private:
+ const MEDFileUMeshSplitL1 *_st;
+ mutable unsigned int _mpt_time;
+ mutable unsigned int _num_time;
+ mutable MEDCouplingAutoRefCountObjectPtr<MEDCouplingUMesh> _m;
};
class MEDFileUMeshSplitL1 : public RefCountObject
{
+ friend class MEDFileUMeshPermCompute;
public:
MEDFileUMeshSplitL1(const MEDFileUMeshL2& l2, const char *mName, int id);
MEDFileUMeshSplitL1(MEDCouplingUMesh *m);
MEDFileUMeshSplitL1(MEDCouplingUMesh *m, bool newOrOld);
+ bool isEqual(const MEDFileUMeshSplitL1 *other, double eps, std::string& what) const;
+ void clearNonDiscrAttributes() const;
+ void synchronizeTinyInfo(const MEDFileMesh& master) const;
void assignMesh(MEDCouplingUMesh *m, bool newOrOld) throw(INTERP_KERNEL::Exception);
bool empty() const;
+ bool presenceOfOneFams(const std::vector<int>& ids) const;
int getMeshDimension() const;
int getSize() const throw(INTERP_KERNEL::Exception);
MEDCouplingUMesh *getFamilyPart(const std::vector<int>& ids, bool renum) const;
void setFamilyArr(DataArrayInt *famArr);
void setRenumArr(DataArrayInt *renumArr);
//
- static std::vector<int> getNewFamiliesNumber(int nb, const std::map<std::string,int>& families);
- static void traduceFamilyNumber(const std::vector< std::vector<int> >& fidsGrps, std::map<std::string,int>& familyIds,
+ static void ClearNonDiscrAttributes(const MEDCouplingMesh *tmp);
+ static std::vector<int> GetNewFamiliesNumber(int nb, const std::map<std::string,int>& families);
+ static void TraduceFamilyNumber(const std::vector< std::vector<int> >& fidsGrps, std::map<std::string,int>& familyIds,
std::map<int,int>& famIdTrad, std::map<int,std::string>& newfams);
static DataArrayInt *Renumber(const DataArrayInt *renum, const DataArrayInt *da);
static MEDCouplingUMesh *Renumber2(const DataArrayInt *renum, MEDCouplingUMesh *m, const int *cellIds);
MEDCouplingAutoRefCountObjectPtr<DataArrayInt> _fam;
MEDCouplingAutoRefCountObjectPtr<DataArrayInt> _num;
mutable MEDCouplingAutoRefCountObjectPtr<DataArrayInt> _rev_num;
- MEDCouplingAutoRefCountObjectPtr<MEDCouplingUMesh> _m;
+ MEDFileUMeshPermCompute _m;
};
}
-// Copyright (C) 2007-2010 CEA/DEN, EDF R&D
+// Copyright (C) 2007-2011 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 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.
+// 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
+// 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
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
#include "MEDFileUtilities.hxx"
#include <sstream>
-med_mode_acces MEDFileUtilities::TraduceWriteMode(int medloaderwritemode) throw(INTERP_KERNEL::Exception)
+med_access_mode MEDFileUtilities::TraduceWriteMode(int medloaderwritemode) throw(INTERP_KERNEL::Exception)
{
switch(medloaderwritemode)
{
case 2:
- return MED_CREATION;
+ return MED_ACC_CREAT;
case 1:
- return MED_LECTURE_AJOUT;
+ return MED_ACC_RDEXT;
case 0:
- return MED_LECTURE_ECRITURE;
+ return MED_ACC_RDWR;
default:
throw INTERP_KERNEL::Exception("Invalid write mode specified ! must be 0(write with no question), 1(append) or 2(creation)");
}
{
std::ostringstream oss;
oss << "MEDFile has returned an error code (" << code <<") : " << msg;
- MEDfermer(fid);
throw INTERP_KERNEL::Exception(oss.str().c_str());
}
}
throw INTERP_KERNEL::Exception(oss.str().c_str());
}
}
- int fid=MEDouvrir((char *)fileName,MED_LECTURE);
+ AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
if(fid<0)
{
oss << " has been detected as unreadable by MED file : impossible to read anything !";
}
oss << " has been detected readable but ";
int major,minor,release;
- MEDversionLire(fid,&major,&minor,&release);
+ MEDfileNumVersionRd(fid,&major,&minor,&release);
if(major<2 || (major==2 && minor<2))
{
oss << "version of MED file is < 2.2 : impossible to read anything !";
- MEDfermer(fid);
throw INTERP_KERNEL::Exception(oss.str().c_str());
}
- MEDfermer(fid);
+}
+
+MEDFileUtilities::AutoFid::AutoFid(med_idt fid):_fid(fid)
+{
+}
+
+MEDFileUtilities::AutoFid::operator med_idt() const
+{
+ return _fid;
+}
+
+MEDFileUtilities::AutoFid::~AutoFid()
+{
+ MEDfileClose(_fid);
+}
+
+ParaMEDMEM::MEDFileWritable::MEDFileWritable():_too_long_str(0),_zipconn_pol(2)
+{
+}
+
+void ParaMEDMEM::MEDFileWritable::copyOptionsFrom(const MEDFileWritable& other) const
+{
+ _too_long_str=other._too_long_str;
+ _zipconn_pol=other._zipconn_pol;
+}
+
+int ParaMEDMEM::MEDFileWritable::getTooLongStrPolicy() const throw(INTERP_KERNEL::Exception)
+{
+ return _too_long_str;
+}
+
+void ParaMEDMEM::MEDFileWritable::setTooLongStrPolicy(int newVal) throw(INTERP_KERNEL::Exception)
+{
+ if(newVal!=2 && newVal!=1 && newVal!=0)
+ throw INTERP_KERNEL::Exception("MEDFileWritable::setTooLongStrPolicy : invalid policy should be in 0,1 or 2 !");
+ _too_long_str=newVal;
+}
+
+int ParaMEDMEM::MEDFileWritable::getZipConnPolicy() throw(INTERP_KERNEL::Exception)
+{
+ return _zipconn_pol;
+}
+
+void ParaMEDMEM::MEDFileWritable::setZipConnPolicy(int newVal) throw(INTERP_KERNEL::Exception)
+{
+ _zipconn_pol=newVal;
}
-// Copyright (C) 2007-2010 CEA/DEN, EDF R&D
+// Copyright (C) 2007-2011 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 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.
+// 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
+// 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
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
#ifndef __MEDFILEUTILITIES_HXX__
namespace MEDFileUtilities
{
- med_mode_acces TraduceWriteMode(int medloaderwritemode) throw(INTERP_KERNEL::Exception);
+ med_access_mode TraduceWriteMode(int medloaderwritemode) throw(INTERP_KERNEL::Exception);
void CheckMEDCode(int code, med_idt fid, const char *msg) throw(INTERP_KERNEL::Exception);
void CheckFileForRead(const char *fileName) throw(INTERP_KERNEL::Exception);
+
+ class AutoFid
+ {
+ public:
+ AutoFid(med_idt fid);
+ operator med_idt() const;
+ ~AutoFid();
+ private:
+ med_idt _fid;
+ };
}
+namespace ParaMEDMEM
+{
+ class MEDFileWritable
+ {
+ public:
+ MEDFileWritable();
+ void copyOptionsFrom(const MEDFileWritable& other) const;
+ int getTooLongStrPolicy() const throw(INTERP_KERNEL::Exception);
+ void setTooLongStrPolicy(int newVal) throw(INTERP_KERNEL::Exception);
+ int getZipConnPolicy() throw(INTERP_KERNEL::Exception);
+ void setZipConnPolicy(int newVal) throw(INTERP_KERNEL::Exception);
+ protected://policies on write
+ mutable int _too_long_str;
+ mutable int _zipconn_pol;
+ };
+}
+
#endif
#include "InterpKernelAutoPtr.hxx"
-#include "InterpKernelAutoPtr.hxx"
-
extern "C"
{
#include "med.h"
-// Copyright (C) 2007-2010 CEA/DEN, EDF R&D
+// Copyright (C) 2007-2011 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 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.
+// 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
+// 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
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
%module MEDLoader
%{
#include "MEDLoader.hxx"
#include "MEDFileMesh.hxx"
+#include "MEDFileField.hxx"
+#include "MEDFileData.hxx"
#include "MEDLoaderTypemaps.i"
using namespace ParaMEDMEM;
%newobject MEDLoader::ReadFieldNode;
%newobject MEDLoader::ReadFieldGauss;
%newobject MEDLoader::ReadFieldGaussNE;
+%newobject ParaMEDMEM::MEDFileMesh::New;
+%newobject ParaMEDMEM::MEDFileMesh::getGenMeshAtLevel;
+%newobject ParaMEDMEM::MEDFileMesh::getGroupArr;
+%newobject ParaMEDMEM::MEDFileMesh::getGroupsArr;
+%newobject ParaMEDMEM::MEDFileMesh::getFamilyArr;
+%newobject ParaMEDMEM::MEDFileMesh::getFamiliesArr;
+%newobject ParaMEDMEM::MEDFileMesh::getNodeGroupArr;
+%newobject ParaMEDMEM::MEDFileMesh::getNodeGroupsArr;
+%newobject ParaMEDMEM::MEDFileMesh::getNodeFamilyArr;
+%newobject ParaMEDMEM::MEDFileMesh::getNodeFamiliesArr;
%newobject ParaMEDMEM::MEDFileUMesh::New;
%newobject ParaMEDMEM::MEDFileUMesh::getCoords;
%newobject ParaMEDMEM::MEDFileUMesh::getGroup;
%newobject ParaMEDMEM::MEDFileUMesh::getGroups;
%newobject ParaMEDMEM::MEDFileUMesh::getFamily;
%newobject ParaMEDMEM::MEDFileUMesh::getFamilies;
-%newobject ParaMEDMEM::MEDFileUMesh::getGroupArr;
-%newobject ParaMEDMEM::MEDFileUMesh::getGroupsArr;
-%newobject ParaMEDMEM::MEDFileUMesh::getFamilyArr;
-%newobject ParaMEDMEM::MEDFileUMesh::getFamiliesArr;
-%newobject ParaMEDMEM::MEDFileUMesh::getNodeGroupArr;
-%newobject ParaMEDMEM::MEDFileUMesh::getNodeGroupsArr;
-%newobject ParaMEDMEM::MEDFileUMesh::getNodeFamilyArr;
-%newobject ParaMEDMEM::MEDFileUMesh::getNodeFamiliesArr;
%newobject ParaMEDMEM::MEDFileUMesh::getMeshAtLevel;
%newobject ParaMEDMEM::MEDFileUMesh::getLevel0Mesh;
%newobject ParaMEDMEM::MEDFileUMesh::getLevelM1Mesh;
%newobject ParaMEDMEM::MEDFileUMesh::getLevelM2Mesh;
%newobject ParaMEDMEM::MEDFileUMesh::getLevelM3Mesh;
+%newobject ParaMEDMEM::MEDFileCMesh::New;
+%newobject ParaMEDMEM::MEDFileMeshMultiTS::New;
+%newobject ParaMEDMEM::MEDFileMeshMultiTS::getOneTimeStep;
+%newobject ParaMEDMEM::MEDFileMeshes::New;
+%newobject ParaMEDMEM::MEDFileMeshes::getMeshAtPos;
+
+%newobject ParaMEDMEM::MEDFileFields::New;
+%newobject ParaMEDMEM::MEDFileFields::getField;
+%newobject ParaMEDMEM::MEDFileFields::getFieldAtPos;
+%newobject ParaMEDMEM::MEDFileFieldMultiTS::New;
+%newobject ParaMEDMEM::MEDFileFieldMultiTS::getFieldAtLevel;
+%newobject ParaMEDMEM::MEDFileFieldMultiTS::getFieldOnMeshAtLevel;
+%newobject ParaMEDMEM::MEDFileFieldMultiTS::getFieldAtLevelOld;
+%newobject ParaMEDMEM::MEDFileField1TS::New;
+%newobject ParaMEDMEM::MEDFileField1TS::getFieldAtLevel;
+%newobject ParaMEDMEM::MEDFileField1TS::getFieldOnMeshAtLevel;
+%newobject ParaMEDMEM::MEDFileField1TS::getFieldAtLevelOld;
+
+%newobject ParaMEDMEM::MEDFileData::New;
+
+%feature("unref") MEDFileMesh "$this->decrRef();"
+%feature("unref") MEDFileUMesh "$this->decrRef();"
+%feature("unref") MEDFileCMesh "$this->decrRef();"
+%feature("unref") MEDFileMeshMultiTS "$this->decrRef();"
+%feature("unref") MEDFileMeshes "$this->decrRef();"
+%feature("unref") MEDFileField1TS "$this->decrRef();"
+%feature("unref") MEDFileFieldMultiTS "$this->decrRef();"
+%feature("unref") MEDFileFields "$this->decrRef();"
class MEDLoader
{
std::vector<const ParaMEDMEM::MEDCouplingUMesh *> v=convertUMeshVecFromPy(li);
MEDLoader::WriteUMeshes(fileName,v,writeFromScratch);
}
- static PyObject *GetTypesOfField(const char *fileName, const char *fieldName, const char *meshName) throw(INTERP_KERNEL::Exception)
+ static PyObject *GetTypesOfField(const char *fileName, const char *meshName, const char *fieldName) throw(INTERP_KERNEL::Exception)
{
- std::vector< ParaMEDMEM::TypeOfField > v=MEDLoader::GetTypesOfField(fileName,fieldName,meshName);
+ std::vector< ParaMEDMEM::TypeOfField > v=MEDLoader::GetTypesOfField(fileName,meshName,fieldName);
int size=v.size();
PyObject *ret=PyList_New(size);
for(int i=0;i<size;i++)
static void WriteFieldUsingAlreadyWrittenMesh(const char *fileName, const ParaMEDMEM::MEDCouplingFieldDouble *f) throw(INTERP_KERNEL::Exception);
};
-%include "MEDFileMesh.hxx"
-
-%extend ParaMEDMEM::MEDFileUMesh
+namespace ParaMEDMEM
{
- void setGroupsAtLevel(int meshDimRelToMaxExt, PyObject *li, bool renum=true) throw(INTERP_KERNEL::Exception)
+ class MEDFileWritable
+ {
+ public:
+ void copyOptionsFrom(const MEDFileWritable& other) const;
+ int getTooLongStrPolicy() const throw(INTERP_KERNEL::Exception);
+ void setTooLongStrPolicy(int newVal) throw(INTERP_KERNEL::Exception);
+ int getZipConnPolicy() throw(INTERP_KERNEL::Exception);
+ void setZipConnPolicy(int newVal) throw(INTERP_KERNEL::Exception);
+ };
+
+ class MEDFileMesh : public RefCountObject, public MEDFileWritable
+ {
+ public:
+ static MEDFileMesh *New(const char *fileName) throw(INTERP_KERNEL::Exception);
+ static MEDFileMesh *New(const char *fileName, const char *mName, int dt=-1, int it=-1);
+ virtual void clearNonDiscrAttributes() const;
+ void setName(const char *name);
+ const char *getName();
+ void setUnivName(const char *name);
+ const char *getUnivName() const;
+ void setDescription(const char *name);
+ const char *getDescription() const;
+ void setOrder(int order);
+ int getOrder() const;
+ void setIteration(int it);
+ int getIteration();
+ void setTimeValue(double time);
+ void setTime(double time, int dt, int it);
+ double getTimeValue() const;
+ void setTimeUnit(const char *unit);
+ const char *getTimeUnit() const;
+ void write(const char *fileName, int mode) const throw(INTERP_KERNEL::Exception);
+ int getSizeAtLevel(int meshDimRelToMaxExt) const throw(INTERP_KERNEL::Exception);
+ //
+ bool existsFamily(int famId) const;
+ bool existsFamily(const char *familyName) const;
+ void setFamilyId(const char *familyName, int id);
+ void addFamily(const char *familyName, int id) throw(INTERP_KERNEL::Exception);
+ void addGrpOnFamily(const char *grpName, const char *famName) throw(INTERP_KERNEL::Exception);
+ void copyFamGrpMapsFrom(const MEDFileMesh& other);
+ const std::map<std::string,int>& getFamilyInfo() const;
+ const std::map<std::string, std::vector<std::string> >& getGroupInfo() const;
+ std::vector<std::string> getFamiliesOnGroup(const char *name) const throw(INTERP_KERNEL::Exception);
+ std::vector<std::string> getFamiliesOnGroups(const std::vector<std::string>& grps) const throw(INTERP_KERNEL::Exception);
+ std::vector<int> getFamiliesIdsOnGroup(const char *name) const throw(INTERP_KERNEL::Exception);
+ void setFamiliesOnGroup(const char *name, const std::vector<std::string>& fams) throw(INTERP_KERNEL::Exception);
+ void setFamiliesIdsOnGroup(const char *name, const std::vector<int>& famIds) throw(INTERP_KERNEL::Exception);
+ std::vector<std::string> getGroupsOnFamily(const char *name) const throw(INTERP_KERNEL::Exception);
+ void setGroupsOnFamily(const char *famName, const std::vector<std::string>& grps) throw(INTERP_KERNEL::Exception);
+ std::vector<std::string> getGroupsNames() const;
+ std::vector<std::string> getFamiliesNames() const;
+ void removeGroup(const char *name) throw(INTERP_KERNEL::Exception);
+ void removeFamily(const char *name) throw(INTERP_KERNEL::Exception);
+ void changeGroupName(const char *oldName, const char *newName) throw(INTERP_KERNEL::Exception);
+ void changeFamilyName(const char *oldName, const char *newName) throw(INTERP_KERNEL::Exception);
+ void setFamilyInfo(const std::map<std::string,int>& info);
+ void setGroupInfo(const std::map<std::string, std::vector<std::string> >&info);
+ int getFamilyId(const char *name) const throw(INTERP_KERNEL::Exception);
+ int getMaxFamilyId() const throw(INTERP_KERNEL::Exception);
+ std::vector<int> getFamiliesIds(const std::vector<std::string>& famNames) const throw(INTERP_KERNEL::Exception);
+ std::string getFamilyNameGivenId(int id) const throw(INTERP_KERNEL::Exception);
+ virtual int getMeshDimension() const throw(INTERP_KERNEL::Exception);
+ //
+ virtual MEDCouplingMesh *getGenMeshAtLevel(int meshDimRelToMax, bool renum=false) const throw(INTERP_KERNEL::Exception);
+ virtual void setFamilyFieldArr(int meshDimRelToMaxExt, DataArrayInt *famArr) throw(INTERP_KERNEL::Exception);
+ virtual void setRenumFieldArr(int meshDimRelToMaxExt, DataArrayInt *renumArr) throw(INTERP_KERNEL::Exception);
+ virtual DataArrayInt *getFamiliesArr(int meshDimRelToMaxExt, const std::vector<std::string>& fams, bool renum=false) const throw(INTERP_KERNEL::Exception);
+ virtual DataArrayInt *getGroupsArr(int meshDimRelToMaxExt, const std::vector<std::string>& grps, bool renum=false) const throw(INTERP_KERNEL::Exception);
+ virtual DataArrayInt *getGroupArr(int meshDimRelToMaxExt, const char *grp, bool renum=false) const throw(INTERP_KERNEL::Exception);
+ virtual DataArrayInt *getFamilyArr(int meshDimRelToMaxExt, const char *fam, bool renum=false) const throw(INTERP_KERNEL::Exception);
+ virtual DataArrayInt *getNodeGroupArr(const char *grp, bool renum=false) const throw(INTERP_KERNEL::Exception);
+ virtual DataArrayInt *getNodeGroupsArr(const std::vector<std::string>& grps, bool renum=false) const throw(INTERP_KERNEL::Exception);
+ virtual DataArrayInt *getNodeFamilyArr(const char *fam, bool renum=false) const throw(INTERP_KERNEL::Exception);
+ virtual DataArrayInt *getNodeFamiliesArr(const std::vector<std::string>& fams, bool renum=false) const throw(INTERP_KERNEL::Exception);
+ %extend
+ {
+ 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;
+ }
+
+ virtual PyObject *isEqual(const MEDFileMesh *other, double eps) const
+ {
+ std::string what;
+ bool ret0=self->isEqual(other,eps,what);
+ PyObject *res=PyList_New(2);
+ PyObject *ret0Py=ret0?Py_True:Py_False;
+ Py_XINCREF(ret0Py);
+ PyList_SetItem(res,0,ret0Py);
+ PyList_SetItem(res,1,PyString_FromString(what.c_str()));
+ return res;
+ }
+
+ PyObject *areFamsEqual(const MEDFileMesh *other) const
+ {
+ std::string what;
+ bool ret0=self->areFamsEqual(other,what);
+ PyObject *res=PyList_New(2);
+ PyObject *ret0Py=ret0?Py_True:Py_False;
+ Py_XINCREF(ret0Py);
+ PyList_SetItem(res,0,ret0Py);
+ PyList_SetItem(res,1,PyString_FromString(what.c_str()));
+ return res;
+ }
+
+ PyObject *areGrpsEqual(const MEDFileMesh *other) const
+ {
+ std::string what;
+ bool ret0=self->areGrpsEqual(other,what);
+ PyObject *res=PyList_New(2);
+ PyObject *ret0Py=ret0?Py_True:Py_False;
+ Py_XINCREF(ret0Py);
+ PyList_SetItem(res,0,ret0Py);
+ PyList_SetItem(res,1,PyString_FromString(what.c_str()));
+ return res;
+ }
+
+ PyObject *getFamilyFieldAtLevel(int meshDimRelToMaxExt) const throw(INTERP_KERNEL::Exception)
+ {
+ const DataArrayInt *tmp=self->getFamilyFieldAtLevel(meshDimRelToMaxExt);
+ if(tmp)
+ tmp->incrRef();
+ return SWIG_NewPointerObj(SWIG_as_voidptr(tmp),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 );
+ }
+
+ PyObject *getNumberFieldAtLevel(int meshDimRelToMaxExt) const throw(INTERP_KERNEL::Exception)
+ {
+ const DataArrayInt *tmp=self->getNumberFieldAtLevel(meshDimRelToMaxExt);
+ if(tmp)
+ tmp->incrRef();
+ return SWIG_NewPointerObj(SWIG_as_voidptr(tmp),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 );
+ }
+ }
+ };
+
+ class MEDFileUMesh : public MEDFileMesh
+ {
+ public:
+ static MEDFileUMesh *New(const char *fileName, const char *mName, int dt=-1, int it=-1) throw(INTERP_KERNEL::Exception);
+ static MEDFileUMesh *New(const char *fileName) throw(INTERP_KERNEL::Exception);
+ static MEDFileUMesh *New();
+ ~MEDFileUMesh();
+ //
+ std::vector<int> getNonEmptyLevels() const;
+ std::vector<int> getNonEmptyLevelsExt() const;
+ std::vector<int> getGrpNonEmptyLevels(const char *grp) const throw(INTERP_KERNEL::Exception);
+ std::vector<int> getGrpNonEmptyLevelsExt(const char *grp) const throw(INTERP_KERNEL::Exception);
+ std::vector<int> getFamNonEmptyLevels(const char *fam) const throw(INTERP_KERNEL::Exception);
+ std::vector<int> getFamNonEmptyLevelsExt(const char *fam) const throw(INTERP_KERNEL::Exception);
+ std::vector<int> getGrpsNonEmptyLevels(const std::vector<std::string>& grps) const throw(INTERP_KERNEL::Exception);
+ std::vector<int> getGrpsNonEmptyLevelsExt(const std::vector<std::string>& grps) const throw(INTERP_KERNEL::Exception);
+ std::vector<int> getFamsNonEmptyLevels(const std::vector<std::string>& fams) const throw(INTERP_KERNEL::Exception);
+ std::vector<int> getFamsNonEmptyLevelsExt(const std::vector<std::string>& fams) const throw(INTERP_KERNEL::Exception);
+ DataArrayDouble *getCoords() const;
+ MEDCouplingUMesh *getGroup(int meshDimRelToMaxExt, const char *grp, bool renum=false) const throw(INTERP_KERNEL::Exception);
+ DataArrayInt *getGroupArr(int meshDimRelToMaxExt, const char *grp, bool renum=false) const throw(INTERP_KERNEL::Exception);
+ MEDCouplingUMesh *getGroups(int meshDimRelToMaxExt, const std::vector<std::string>& grps, bool renum=false) const throw(INTERP_KERNEL::Exception);
+ DataArrayInt *getGroupsArr(int meshDimRelToMaxExt, const std::vector<std::string>& grps, bool renum=false) const throw(INTERP_KERNEL::Exception);
+ MEDCouplingUMesh *getFamily(int meshDimRelToMaxExt, const char *fam, bool renum=false) const throw(INTERP_KERNEL::Exception);
+ DataArrayInt *getFamilyArr(int meshDimRelToMaxExt, const char *fam, bool renum=false) const throw(INTERP_KERNEL::Exception);
+ MEDCouplingUMesh *getFamilies(int meshDimRelToMaxExt, const std::vector<std::string>& fams, bool renum=false) const throw(INTERP_KERNEL::Exception);
+ DataArrayInt *getFamiliesArr(int meshDimRelToMaxExt, const std::vector<std::string>& fams, bool renum=false) const throw(INTERP_KERNEL::Exception);
+ DataArrayInt *getNodeGroupArr(const char *grp, bool renum=false) const throw(INTERP_KERNEL::Exception);
+ DataArrayInt *getNodeGroupsArr(const std::vector<std::string>& grps, bool renum=false) const throw(INTERP_KERNEL::Exception);
+ DataArrayInt *getNodeFamilyArr(const char *fam, bool renum=false) const throw(INTERP_KERNEL::Exception);
+ DataArrayInt *getNodeFamiliesArr(const std::vector<std::string>& fams, bool renum=false) const throw(INTERP_KERNEL::Exception);
+ MEDCouplingUMesh *getMeshAtLevel(int meshDimRelToMaxExt, bool renum=false) const throw(INTERP_KERNEL::Exception);
+ MEDCouplingUMesh *getLevel0Mesh(bool renum=false) const throw(INTERP_KERNEL::Exception);
+ MEDCouplingUMesh *getLevelM1Mesh(bool renum=false) const throw(INTERP_KERNEL::Exception);
+ MEDCouplingUMesh *getLevelM2Mesh(bool renum=false) const throw(INTERP_KERNEL::Exception);
+ MEDCouplingUMesh *getLevelM3Mesh(bool renum=false) const throw(INTERP_KERNEL::Exception);
+ //
+ void setFamilyNameAttachedOnId(int id, const std::string& newFamName) throw(INTERP_KERNEL::Exception);
+ void setCoords(DataArrayDouble *coords) throw(INTERP_KERNEL::Exception);
+ void eraseGroupsAtLevel(int meshDimRelToMaxExt) throw(INTERP_KERNEL::Exception);
+ void setFamilyField(DataArrayInt *arr, const std::vector< std::vector< int > > &userfids, const std::vector<std::string>& grpNames, bool renum=false) throw(INTERP_KERNEL::Exception);
+ void addNodeGroup(const std::string& name, const std::vector<int>& ids) throw(INTERP_KERNEL::Exception);
+ void removeMeshAtLevel(int meshDimRelToMax) throw(INTERP_KERNEL::Exception);
+ void setMeshAtLevel(int meshDimRelToMax, MEDCouplingUMesh *m, bool newOrOld=false) throw(INTERP_KERNEL::Exception);
+ void setMeshAtLevelGen(int meshDimRelToMax, MEDCouplingUMesh *m, bool newOrOld) throw(INTERP_KERNEL::Exception);
+ void setGroupsFromScratch(int meshDimRelToMax, const std::vector<const MEDCouplingUMesh *>& ms) throw(INTERP_KERNEL::Exception);
+ void setGroupsOnSetMesh(int meshDimRelToMax, const std::vector<const MEDCouplingUMesh *>& ms, bool renum) throw(INTERP_KERNEL::Exception);
+ void optimizeFamilies() throw(INTERP_KERNEL::Exception);
+ %extend
+ {
+ PyObject *getRevNumberFieldAtLevel(int meshDimRelToMaxExt) const throw(INTERP_KERNEL::Exception)
+ {
+ const DataArrayInt *tmp=self->getRevNumberFieldAtLevel(meshDimRelToMaxExt);
+ if(tmp)
+ tmp->incrRef();
+ return SWIG_NewPointerObj(SWIG_as_voidptr(tmp),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 );
+ }
+
+ void setGroupsAtLevel(int meshDimRelToMaxExt, PyObject *li, bool renum=false) throw(INTERP_KERNEL::Exception)
+ {
+ std::vector<const DataArrayInt *> grps;
+ convertPyObjToVecDataArrayIntCst(li,grps);
+ self->setGroupsAtLevel(meshDimRelToMaxExt,grps,renum);
+ }
+ }
+ };
+
+ class MEDFileCMesh : public MEDFileMesh
+ {
+ public:
+ static MEDFileCMesh *New();
+ static MEDFileCMesh *New(const char *fileName) throw(INTERP_KERNEL::Exception);
+ static MEDFileCMesh *New(const char *fileName, const char *mName, int dt=-1, int it=-1) throw(INTERP_KERNEL::Exception);
+ void setMesh(MEDCouplingCMesh *m) throw(INTERP_KERNEL::Exception);
+ %extend
+ {
+ PyObject *getMesh() const
+ {
+ const MEDCouplingCMesh *tmp=self->getMesh();
+ if(tmp)
+ tmp->incrRef();
+ return SWIG_NewPointerObj(SWIG_as_voidptr(tmp),SWIGTYPE_p_ParaMEDMEM__MEDCouplingCMesh, SWIG_POINTER_OWN | 0 );
+ }
+ }
+ };
+
+ class MEDFileMeshMultiTS : public RefCountObject, public MEDFileWritable
+ {
+ public:
+ static MEDFileMeshMultiTS *New();
+ static MEDFileMeshMultiTS *New(const char *fileName) throw(INTERP_KERNEL::Exception);
+ static MEDFileMeshMultiTS *New(const char *fileName, const char *mName) throw(INTERP_KERNEL::Exception);
+ const char *getName() const throw(INTERP_KERNEL::Exception);
+ void write(const char *fileName, int mode) const throw(INTERP_KERNEL::Exception);
+ void setOneTimeStep(MEDFileMesh *mesh1TimeStep) throw(INTERP_KERNEL::Exception);
+ %extend
+ {
+ MEDFileMesh *getOneTimeStep() const throw(INTERP_KERNEL::Exception)
+ {
+ MEDFileMesh *ret=self->getOneTimeStep();
+ if(ret)
+ ret->incrRef();
+ return ret;
+ }
+ }
+ };
+
+ class MEDFileMeshes : public RefCountObject, public MEDFileWritable
+ {
+ public:
+ static MEDFileMeshes *New();
+ static MEDFileMeshes *New(const char *fileName) throw(INTERP_KERNEL::Exception);
+ void write(const char *fileName, int mode) const throw(INTERP_KERNEL::Exception);
+ int getNumberOfMeshes() const throw(INTERP_KERNEL::Exception);
+ //
+ void resize(int newSize) throw(INTERP_KERNEL::Exception);
+ void pushMesh(MEDFileMesh *mesh) throw(INTERP_KERNEL::Exception);
+ void setMeshAtPos(int i, MEDFileMesh *mesh) throw(INTERP_KERNEL::Exception);
+ void destroyMeshAtPos(int i) throw(INTERP_KERNEL::Exception);
+ %extend
+ {
+ MEDFileMesh *getMeshAtPos(int i) const throw(INTERP_KERNEL::Exception)
+ {
+ MEDFileMesh *ret=self->getMeshAtPos(i);
+ if(ret)
+ ret->incrRef();
+ return ret;
+ }
+ }
+ };
+
+ class MEDFieldFieldGlobsReal
+ {
+ public:
+ void shallowCpyGlobs(const MEDFieldFieldGlobsReal& other);
+ std::vector<std::string> getPfls() const;
+ std::vector<std::string> getLocs() const;
+ virtual std::vector<std::string> getPflsReallyUsed() const = 0;
+ virtual std::vector<std::string> getLocsReallyUsed() const = 0;
+ };
+
+ class MEDFileField1TSWithoutDAS : public RefCountObject
+ {
+ public:
+ void copyTinyInfoFrom(const MEDCouplingFieldDouble *field) throw(INTERP_KERNEL::Exception);
+ //
+ int getDimension() const;
+ int getIteration() const;
+ int getOrder() const;
+ std::string getName();
+ std::string getMeshName();
+ int getNumberOfComponents() const;
+ bool isDealingTS(int iteration, int order) const;
+ const std::vector<std::string>& getInfo() const;
+ %extend
+ {
+ PyObject *getDtIt() const
+ {
+ std::pair<int,int> res=self->getDtIt();
+ PyObject *elt=PyTuple_New(2);
+ PyTuple_SetItem(elt,0,SWIG_From_int(res.first));
+ PyTuple_SetItem(elt,1,SWIG_From_int(res.second));
+ return elt;
+ }
+ }
+ };
+
+ class MEDFileField1TS : public MEDFileField1TSWithoutDAS, public MEDFieldFieldGlobsReal, public MEDFileWritable
+ {
+ public:
+ static MEDFileField1TS *New(const char *fileName, const char *fieldName, int iteration, int order) throw(INTERP_KERNEL::Exception);
+ static MEDFileField1TS *New();
+ void write(const char *fileName, int mode) const throw(INTERP_KERNEL::Exception);
+ MEDCouplingFieldDouble *getFieldAtLevel(TypeOfField type, int meshDimRelToMax, int renumPol=0) const throw(INTERP_KERNEL::Exception);
+ MEDCouplingFieldDouble *getFieldOnMeshAtLevel(TypeOfField type, const MEDCouplingMesh *mesh, int renumPol=0) const throw(INTERP_KERNEL::Exception);
+ MEDCouplingFieldDouble *getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol=0) const throw(INTERP_KERNEL::Exception);
+ MEDCouplingFieldDouble *getFieldAtLevelOld(TypeOfField type, const char *mname, int meshDimRelToMax, int renumPol=0) const throw(INTERP_KERNEL::Exception);
+ //
+ void setFieldNoProfileSBT(const MEDCouplingFieldDouble *field) throw(INTERP_KERNEL::Exception);
+ void setFieldProfile(const MEDCouplingFieldDouble *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile) throw(INTERP_KERNEL::Exception);
+ %extend
+ {
+ PyObject *getFieldWithProfile(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh) const throw(INTERP_KERNEL::Exception)
+ {
+ DataArrayInt *ret1=0;
+ DataArrayDouble *ret0=self->getFieldWithProfile(type,meshDimRelToMax,mesh,ret1);
+ PyObject *ret=PyTuple_New(2);
+ PyTuple_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(ret0),SWIGTYPE_p_ParaMEDMEM__DataArrayDouble, SWIG_POINTER_OWN | 0 ));
+ PyTuple_SetItem(ret,1,SWIG_NewPointerObj(SWIG_as_voidptr(ret1),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 ));
+ return ret;
+ }
+ }
+ };
+
+ class MEDFileFieldMultiTSWithoutDAS
+ {
+ public:
+ int getNumberOfTS() const;
+ std::string getName() const;
+ %extend
+ {
+ PyObject *getIterations() const
+ {
+ std::vector< std::pair<int,int> > res=self->getIterations();
+ 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;
+ }
+
+ PyObject *getTimeSteps() const throw(INTERP_KERNEL::Exception)
+ {
+ std::vector<double> ret1;
+ std::vector< std::pair<int,int> > ret=self->getTimeSteps(ret1);
+ std::size_t sz=ret.size();
+ PyObject *ret2=PyList_New(sz);
+ for(std::size_t i=0;i<sz;i++)
+ {
+ PyObject *elt=PyTuple_New(3);
+ PyTuple_SetItem(elt,0,SWIG_From_int(ret[i].first));
+ PyTuple_SetItem(elt,1,SWIG_From_int(ret[i].second));
+ PyTuple_SetItem(elt,2,SWIG_From_double(ret1[i]));
+ PyList_SetItem(ret2,i,elt);
+ }
+ return ret2;
+ }
+ }
+ };
+
+ class MEDFileFieldMultiTS : public MEDFileFieldMultiTSWithoutDAS, public MEDFieldFieldGlobsReal, public MEDFileWritable
+ {
+ public:
+ static MEDFileFieldMultiTS *New();
+ static MEDFileFieldMultiTS *New(const char *fileName, const char *fieldName) throw(INTERP_KERNEL::Exception);
+ void write(const char *fileName, int mode) const throw(INTERP_KERNEL::Exception);
+ MEDCouplingFieldDouble *getFieldAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, int renumPol=0) const throw(INTERP_KERNEL::Exception);
+ MEDCouplingFieldDouble *getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol=0) const throw(INTERP_KERNEL::Exception);
+ MEDCouplingFieldDouble *getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, const MEDCouplingMesh *mesh, int renumPol=0) const throw(INTERP_KERNEL::Exception);
+ MEDCouplingFieldDouble *getFieldAtLevelOld(TypeOfField type, const char *mname, int iteration, int order, int meshDimRelToMax, int renumPol=0) const throw(INTERP_KERNEL::Exception);
+ //
+ void appendFieldNoProfileSBT(const MEDCouplingFieldDouble *field) throw(INTERP_KERNEL::Exception);
+ void appendFieldProfile(const MEDCouplingFieldDouble *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile) throw(INTERP_KERNEL::Exception);
+ %extend
+ {
+ PyObject *getFieldWithProfile(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh) const throw(INTERP_KERNEL::Exception)
+ {
+ DataArrayInt *ret1=0;
+ DataArrayDouble *ret0=self->getFieldWithProfile(type,iteration,order,meshDimRelToMax,mesh,ret1);
+ PyObject *ret=PyTuple_New(2);
+ PyTuple_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(ret0),SWIGTYPE_p_ParaMEDMEM__DataArrayDouble, SWIG_POINTER_OWN | 0 ));
+ PyTuple_SetItem(ret,1,SWIG_NewPointerObj(SWIG_as_voidptr(ret1),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 ));
+ return ret;
+ }
+ }
+ };
+
+ class MEDFileFields : public RefCountObject, public MEDFieldFieldGlobsReal, public MEDFileWritable
+ {
+ public:
+ static MEDFileFields *New();
+ static MEDFileFields *New(const char *fileName) throw(INTERP_KERNEL::Exception);
+ void write(const char *fileName, int mode) const throw(INTERP_KERNEL::Exception);
+ int getNumberOfFields() const;
+ std::vector<std::string> getFieldsNames() const throw(INTERP_KERNEL::Exception);
+ //
+ void resize(int newSize) throw(INTERP_KERNEL::Exception);
+ void pushField(MEDFileFieldMultiTS *field) throw(INTERP_KERNEL::Exception);
+ void setFieldAtPos(int i, MEDFileFieldMultiTS *field) throw(INTERP_KERNEL::Exception);
+ MEDFileFieldMultiTS *getFieldAtPos(int i) const throw(INTERP_KERNEL::Exception);
+ MEDFileFieldMultiTS *getField(const char *fieldName) const throw(INTERP_KERNEL::Exception);
+ void destroyFieldAtPos(int i) throw(INTERP_KERNEL::Exception);
+ };
+
+ class MEDFileData : public RefCountObject, public MEDFileWritable
{
- std::vector<const DataArrayInt *> grps;
- convertPyObjToVecDataArrayIntCst(li,grps);
- self->setGroupsAtLevel(meshDimRelToMaxExt,grps,renum);
- }
+ public:
+ static MEDFileData *New(const char *fileName) throw(INTERP_KERNEL::Exception);
+ static MEDFileData *New();
+ MEDFileFields *getFields() const;
+ MEDFileMeshes *getMeshes() const;
+ void setFields(MEDFileFields *fields) throw(INTERP_KERNEL::Exception);
+ void setMeshes(MEDFileMeshes *meshes) throw(INTERP_KERNEL::Exception);
+ int getNumberOfFields() const throw(INTERP_KERNEL::Exception);
+ int getNumberOfMeshes() const throw(INTERP_KERNEL::Exception);
+ //
+ void write(const char *fileName, int mode) const throw(INTERP_KERNEL::Exception);
+ };
}
# -*- coding: iso-8859-1 -*-
-# Copyright (C) 2007-2010 CEA/DEN, EDF R&D
+# Copyright (C) 2007-2011 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 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.
+# 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
+# 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
+# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
#
from MEDLoader import *
def testMEDMesh1(self):
fileName="Pyfile18.med"
mname="ExampleOfMultiDimW"
- medmesh=MEDFileUMesh.New(fileName,mname)
+ medmesh=MEDFileMesh.New(fileName,mname)
self.assertEqual((0,-1),medmesh.getNonEmptyLevels())
- m1_0=medmesh.getLevel0Mesh()
+ m1_0=medmesh.getLevel0Mesh(True)
m1_1=MEDLoader.ReadUMeshFromFile(fileName,mname,0)
self.assertTrue(m1_0.isEqual(m1_1,1e-12));
- m2_0=medmesh.getLevelM1Mesh()
+ m2_0=medmesh.getLevelM1Mesh(True)
m2_1=MEDLoader.ReadUMeshFromFile(fileName,mname,-1)
self.assertTrue(m2_0.isEqual(m2_1,1e-12));
pass
outFileName="MEDFileMesh1.med"
medmesh=MEDFileUMesh.New(fileName,mname)
self.assertEqual((0,),medmesh.getNonEmptyLevels())
- m1_0=medmesh.getLevel0Mesh()
+ m1_0=medmesh.getLevel0Mesh(True)
m1_1=MEDLoader.ReadUMeshFromFile(fileName,mname,0)
self.assertTrue(m1_0.isEqual(m1_1,1e-12));
- g1_0=medmesh.getGroup(0,"mesh2")
+ g1_0=medmesh.getGroup(0,"mesh2",True)
g1_1=MEDLoader.ReadUMeshFromGroups(fileName,mname,0,["mesh2"]);
self.assertTrue(g1_0.isEqual(g1_1,1e-12));
- g1_0=medmesh.getGroup(0,"mesh3")
+ g1_0=medmesh.getGroup(0,"mesh3",True)
g1_1=MEDLoader.ReadUMeshFromGroups(fileName,mname,0,["mesh3"]);
self.assertTrue(g1_0.isEqual(g1_1,1e-12));
g1_0=medmesh.getGroups(0,["mesh3","mesh2"])
g1_1=MEDLoader.ReadUMeshFromGroups(fileName,mname,0,["mesh3","mesh2"]);
g1_1.setName(g1_0.getName())
self.assertTrue(g1_0.isEqual(g1_1,1e-12));
- g1_0=medmesh.getFamily(0,"Family_2")
+ g1_0=medmesh.getFamily(0,"Family_2",True)
g1_1=MEDLoader.ReadUMeshFromFamilies(fileName,mname,0,["Family_2"]);
self.assertTrue(g1_0.isEqual(g1_1,1e-12));
- g1_0=medmesh.getFamilies(0,["Family_2","Family_4"])
+ g1_0=medmesh.getFamilies(0,["Family_2","Family_4"],True)
g1_1=MEDLoader.ReadUMeshFromFamilies(fileName,mname,0,["Family_2","Family_4"]);
g1_1.setName(g1_0.getName())
self.assertTrue(g1_0.isEqual(g1_1,1e-12));
self.assertTrue(g1_0.isEqual(g1_1,1e-12));
medmesh.write(outFileName,2);
- self.assertEqual([2,3,5,14,16],medmesh.getGroupArr(0,"mesh2").getValues());
- self.assertEqual([2,3,16],medmesh.getFamilyArr(0,"Family_2").getValues());
- self.assertEqual([2,3,5,14,16],medmesh.getFamiliesArr(0,["Family_4","Family_2"]).getValues());
- self.assertEqual([19,2,3,4,5,14,15,16],medmesh.getGroupsArr(0,["mesh2","mesh4","mesh3"]).getValues());
+ self.assertEqual([2,3,5,14,16],medmesh.getGroupArr(0,"mesh2",True).getValues());
+ self.assertEqual([2,3,16],medmesh.getFamilyArr(0,"Family_2",True).getValues());
+ self.assertEqual([2,3,5,14,16],medmesh.getFamiliesArr(0,["Family_4","Family_2"],True).getValues());
+ self.assertEqual([19,2,3,4,5,14,15,16],medmesh.getGroupsArr(0,["mesh2","mesh4","mesh3"],True).getValues());
famn=medmesh.getFamilyNameGivenId(0)
- self.assertEqual(range(60),medmesh.getNodeFamilyArr(famn).getValues());
+ self.assertRaises(InterpKernelException,medmesh.getNodeFamilyArr,famn,True);
#without renum
self.assertEqual([2,3,5,14,16],medmesh.getGroupArr(0,"mesh2",False).getValues());
self.assertEqual([2,3,16],medmesh.getFamilyArr(0,"Family_2",False).getValues());
self.assertEqual([2,3,5,14,16],medmesh.getFamiliesArr(0,["Family_4","Family_2"],False).getValues());
self.assertEqual([0,2,3,4,5,14,15,16],medmesh.getGroupsArr(0,["mesh2","mesh3","mesh4"],False).getValues());
- self.assertEqual(range(60),medmesh.getNodeFamilyArr(famn,False).getValues());
+ self.assertRaises(InterpKernelException,medmesh.getNodeFamilyArr,famn,False);
pass
# this tests emulates MEDMEM ( Except that it works ! ) The permutation are NOT taken into account
mm.setName("MyFirstMEDCouplingMEDmesh")
mm.setDescription("IHopeToConvinceLastMEDMEMUsers")
mm.setCoords(c)
- mm.setMeshAtLevelOld(-1,m1);
- mm.setMeshAtLevelOld(0,m);
- mm.setMeshAtLevelOld(-2,m2);
+ mm.setMeshAtLevel(-1,m1);
+ mm.setMeshAtLevel(0,m);
+ mm.setMeshAtLevel(-2,m2);
# playing with groups
g1_2=DataArrayInt.New()
g1_2.setValues([1,3],2,1)
coords=[-0.3,-0.3, 0.2,-0.3, 0.7,-0.3, -0.3,0.2, 0.2,0.2, 0.7,0.2, -0.3,0.7, 0.2,0.7, 0.7,0.7 ];
targetConn=[0,3,4,1, 1,4,2, 4,5,2, 6,7,4,3, 7,8,5,4]
c.setValues(coords,9,2)
+ c.setInfoOnComponent(0,"abcdef [km]")
+ c.setInfoOnComponent(1,"ghij [MW]")
m=MEDCouplingUMesh.New();
m.setMeshDimension(2);
m.allocateCells(5);
mm.setCoords(c)
renumNode=DataArrayInt.New()
renumNode.setValues([10,11,12,13,14,15,16,17,18],9,1)
- mm.setRenumArr(1,renumNode)
- mm.setMeshAtLevel(-1,m1);
- mm.setMeshAtLevel(0,m);
- mm.setMeshAtLevel(-2,m2);
+ mm.setRenumFieldArr(1,renumNode)
+ mm.setMeshAtLevel(-1,m1,True);
+ mm.setMeshAtLevel(0,m,True);
+ mm.setMeshAtLevel(-2,m2,True);
+ mm.removeMeshAtLevel(-2)
+ mm.setMeshAtLevel(-2,m2,True);
# playing with groups
g1_2=DataArrayInt.New()
g1_2.setValues([2,3],2,1)
self.assertTrue(g2_1.isEqual(t));
#
mm.write(outFileName,2);
+ mm2=MEDFileMesh.New(outFileName)
+ res=mm.isEqual(mm2,1e-12)
+ self.assertTrue(res[0])
+ pass
+
+ #testing persistence of retrieved arrays
+ def testMEDMesh5(self):
+ fileName="Pyfile18.med"
+ mname="ExampleOfMultiDimW"
+ medmesh=MEDFileUMesh.New(fileName,mname)
+ m1_0=medmesh.getLevel0Mesh(True)
+ da1=medmesh.getFamilyFieldAtLevel(0)
+ del medmesh
+ self.assertEqual(20,m1_0.getNumberOfCells())
+ self.assertEqual(20,da1.getNumberOfTuples())
+ pass
+
+ def testMEDMesh6(self):
+ outFileName="MEDFileMesh5.med"
+ m=MEDFileCMesh.New()
+ m.setTime(2.3,-1,-1)
+ m1=MEDCouplingCMesh.New();
+ da=DataArrayDouble.New()
+ da.setValues([0.,1.,2.],3,1)
+ da.setInfoOnComponent(0,"XX [mm]")
+ m1.setCoordsAt(0,da)
+ da=DataArrayDouble.New()
+ da.setValues([0.,1.2],2,1)
+ da.setInfoOnComponent(0,"YY [km]")
+ m1.setCoordsAt(1,da)
+ da=DataArrayDouble.New()
+ da.setValues([0.,1.3],2,1)
+ da.setInfoOnComponent(0,"ZZ [um]")
+ m1.setCoordsAt(2,da)
+ m.setMesh(m1)
+ m.setName("myFirstCartMesh")
+ m.setDescription("mmmmpppppppp")
+ m.setTimeValue(2.3)
+ m.setTimeUnit("ms")
+ da=DataArrayInt.New()
+ da.setValues([0,0,1,0,1,2,4,3,0,1,2,2],12,1)
+ m.setFamilyFieldArr(1,da)
+ m.setFamilyId("family1",1)
+ da=m.getFamilyArr(1,"family1")
+ expected1=[2,4,9]
+ self.assertEqual(expected1,da.getValues())
+ m.write(outFileName,2);
+ mm=MEDFileMesh.New(outFileName)
+ self.assertTrue(m.isEqual(mm,1e-12)[0])
+ self.assertEqual(expected1,mm.getFamilyArr(1,"family1").getValues())
+ m2=mm.getMesh()
+ tt=m.getTime()
+ m1.setTime(tt[0],tt[1],tt[2])
+ m1.setName(m.getName())
+ m1.setTimeUnit(m.getTimeUnit())
+ m1.setDescription(m.getDescription())
+ self.assertTrue(m2.isEqual(m1,1e-12));
+ pass
+
+ def testMEDMesh7(self):
+ fileName="Pyfile24.med"
+ m2,m1,m0,f2,f1,f0,p,n2,n1,n0,fns,fids,grpns,famIdsPerGrp=MEDLoaderDataForTest.buildMultiLevelMesh_1()
+ m=MEDFileUMesh.New()
+ m.setCoords(m2.getCoords())
+ m.setMeshAtLevel(0,m2)
+ m.setMeshAtLevel(-1,m1)
+ m.setMeshAtLevel(-2,m0)
+ m.setFamilyFieldArr(0,f2)
+ m.setFamilyFieldArr(-1,f1)
+ m.setFamilyFieldArr(-2,f0)
+ m.setFamilyFieldArr(1,p)
+ m.setRenumFieldArr(0,n2)
+ m.setRenumFieldArr(-1,n1)
+ m.setRenumFieldArr(-2,n0)
+ nbOfFams=len(fns)
+ for i in xrange(nbOfFams):
+ m.addFamily(fns[i],fids[i])
+ pass
+ nbOfGrps=len(grpns)
+ for i in xrange(nbOfGrps):
+ m.setFamiliesIdsOnGroup(grpns[i],famIdsPerGrp[i])
+ pass
+ m.setName(m2.getName())
+ m.setDescription(m2.getDescription())
+ #
+ self.assertEqual((-1,),m.getGrpNonEmptyLevels("A2A4"))
+ self.assertEqual((),m.getGrpNonEmptyLevels("A1"))
+ self.assertEqual((-2,),m.getGrpNonEmptyLevels("AP2"))
+ self.assertEqual((-1,-2),m.getGrpsNonEmptyLevels(["A2A4","AP2"]))
+ self.assertEqual((-1,),m.getFamNonEmptyLevels('A4A3____________________________'))
+ self.assertEqual((0,),m.getFamNonEmptyLevels('MESH____DALT3___DALLE___________'))
+ self.assertEqual((0,-1,),m.getFamsNonEmptyLevels(['MESH____DALT3___DALLE___________','A4A3____________________________']))
+ #
+ m.write(fileName,2)
+ pass
+
+ #emulation of pointe.med file.
+ def testMEDField1(self):
+ mm=MEDFileMesh.New("Pyfile17.med")
+ mm.write("Pyfile17_bis.med",2)
+ ff=MEDFileFieldMultiTS.New("Pyfile17.med","MeasureOfMesh_Extruded")
+ ff.write("Pyfile17_bis.med",0)
+ pass
+
+ #profiles
+ def testMEDField2(self):
+ mm=MEDFileMesh.New("Pyfile19.med")
+ mm.write("Pyfile19_bis.med",2)
+ ff=MEDFileFieldMultiTS.New("Pyfile19.med","VFieldOnNodes")
+ ff.write("Pyfile19_bis.med",0)
+ pass
+
+ #gauss points
+ def testMEDField3(self):
+ mm=MEDFileMesh.New("Pyfile13.med")
+ mm.write("Pyfile13_bis.med",2)
+ ff=MEDFileFieldMultiTS.New("Pyfile13.med","MyFirstFieldOnGaussPoint")
+ ff.write("Pyfile13_bis.med",0)
+ ff=MEDFileField1TS.New("Pyfile13.med","MyFirstFieldOnGaussPoint",1,5)
+ f=ff.getFieldAtLevel(ON_GAUSS_PT,0)
+ f2=MEDLoader.ReadFieldGauss("Pyfile13.med",'2DMesh_2',0,'MyFirstFieldOnGaussPoint',1,5)
+ self.assertTrue(f.isEqual(f2,1e-12,1e-12))
+ pass
+
+ #gauss NE
+ def testMEDField4(self):
+ mm=MEDFileMesh.New("Pyfile14.med")
+ mm.write("Pyfile14_bis.med",2)
+ ff=MEDFileFieldMultiTS.New("Pyfile14.med","MyFieldOnGaussNE")
+ ff.write("Pyfile14_bis.med",0)
+ ff=MEDFileField1TS.New("Pyfile14.med","MyFieldOnGaussNE",1,5)
+ f=ff.getFieldAtLevel(ON_GAUSS_NE,0)
+ f2=MEDLoader.ReadFieldGaussNE("Pyfile14.med",'2DMesh_2',0,"MyFieldOnGaussNE",1,5)
+ self.assertTrue(f.isEqual(f2,1e-12,1e-12))
+ pass
+
+ # MEDField get/set on pointe.med
+ def testMEDField5(self):
+ ff=MEDFileField1TS.New("Pyfile17.med","MeasureOfMesh_Extruded",1,2)
+ f=ff.getFieldAtLevel(ON_CELLS,0)
+ f2=MEDLoader.ReadFieldCell("Pyfile17.med","Extruded",0,"MeasureOfMesh_Extruded",1,2)
+ self.assertTrue(f.getMesh().getCoords().isEqual(f2.getMesh().getCoords(),1e-12))
+ f.getMesh().tryToShareSameCoords(f2.getMesh(),1e-12)
+ f.changeUnderlyingMesh(f2.getMesh(),22,1e-12)
+ self.assertTrue(f.isEqual(f2,1e-12,1e-12))
+ # no with renumbering
+ f=ff.getFieldAtLevel(ON_CELLS,0,1)
+ f2=MEDLoader.ReadFieldCell("Pyfile17.med","Extruded",0,"MeasureOfMesh_Extruded",1,2)
+ self.assertTrue(f.isEqual(f2,1e-12,1e-12))
+ f=ff.getFieldAtLevel(ON_CELLS,0,3)
+ self.assertTrue(f.isEqual(f2,1e-12,1e-12))
+ f=ff.getFieldAtLevel(ON_CELLS,0,2)
+ self.assertTrue(not f.isEqual(f2,1e-12,1e-12))
+ f.changeUnderlyingMesh(f2.getMesh(),12,1e-12)
+ self.assertTrue(f.isEqual(f2,1e-12,1e-12))
+ pass
+
+ # MEDField get/set on profiles nodes
+ def testMEDField6(self):
+ ff=MEDFileFieldMultiTS.New("Pyfile7.med","VectorFieldOnNodes")
+ its=ff.getIterations()
+ self.assertRaises(InterpKernelException,ff.getFieldAtLevel,ON_CELLS,its[0][0],its[0][1],0)# request on cell and it is not on cells
+ f=ff.getFieldAtLevel(ON_NODES,its[0][0],its[0][1],0)
+ f2=MEDLoader.ReadFieldNode("Pyfile7.med",'3DSurfMesh_1',0,"VectorFieldOnNodes",its[0][0],its[0][1])
+ self.assertTrue(f.isEqual(f2,1e-12,1e-12))
+ ff=MEDFileFieldMultiTS.New("Pyfile19.med","VFieldOnNodes")
+ its=ff.getIterations()
+ f=ff.getFieldAtLevel(ON_NODES,its[0][0],its[0][1],0)
+ f2=MEDLoader.ReadFieldNode("Pyfile19.med",'2DMesh_1',0,"VFieldOnNodes",its[0][0],its[0][1])
+ self.assertTrue(f.isEqual(f2,1e-12,1e-12))
+ self.assertRaises(InterpKernelException,ff.getFieldAtLevel,ON_CELLS,its[0][0],its[0][1],0)# request on cell and it is not on cells
+ self.assertRaises(InterpKernelException,ff.getFieldAtLevel,ON_NODES,its[0][0],its[0][1],0,1)#request renumber following mesh : it is on profile !
+ pass
+
+ # MEDField get/set on profiles cells
+ def testMEDField7(self):
+ ff=MEDFileFieldMultiTS.New("Pyfile12.med","VectorFieldOnCells")
+ its=ff.getIterations()
+ f=ff.getFieldAtLevel(ON_CELLS,its[0][0],its[0][1],0)
+ f2=MEDLoader.ReadFieldCell("Pyfile12.med",'3DMesh_1',0,"VectorFieldOnCells",its[0][0],its[0][1])
+ self.assertTrue(f.isEqual(f2,1e-12,1e-12))
+ pass
+
+ #first test of assignation. No profile and types sorted by type.
+ def testMEDField8(self):
+ fname="Pyfile25.med"
+ f1=MEDLoaderDataForTest.buildVecFieldOnCells_1();
+ m1=f1.getMesh()
+ mm1=MEDFileUMesh.New()
+ mm1.setCoords(m1.getCoords())
+ mm1.setMeshAtLevel(0,m1)
+ mm1.setName(m1.getName())
+ mm1.write(fname,2)
+ ff1=MEDFileField1TS.New()
+ ff1.setFieldNoProfileSBT(f1)
+ ff1.write(fname,0)
+ f2=MEDLoader.ReadFieldCell(fname,f1.getMesh().getName(),0,f1.getName(),f1.getTime()[1],f1.getTime()[2]);
+ self.assertTrue(f1.isEqual(f2,1e-12,1e-12))
+ #
+ fname="Pyfile26.med"
+ f1=MEDLoaderDataForTest.buildVecFieldOnNodes_1();
+ m1=f1.getMesh()
+ mm1=MEDFileUMesh.New()
+ mm1.setCoords(m1.getCoords())
+ mm1.setMeshAtLevel(0,m1)
+ mm1.setName(m1.getName())
+ mm1.write(fname,2)
+ ff1=MEDFileField1TS.New()
+ ff1.setFieldNoProfileSBT(f1)
+ ff1.write(fname,0)
+ f2=MEDLoader.ReadFieldNode(fname,f1.getMesh().getName(),0,f1.getName(),f1.getTime()[1],f1.getTime()[2])
+ self.assertTrue(f1.isEqual(f2,1e-12,1e-12))
+ #
+ fname="Pyfile27.med"
+ f1=MEDLoaderDataForTest.buildVecFieldOnGaussNE_1();
+ m1=f1.getMesh()
+ mm1=MEDFileUMesh.New()
+ mm1.setCoords(m1.getCoords())
+ mm1.setMeshAtLevel(0,m1)
+ mm1.setName(m1.getName())
+ mm1.write(fname,2)
+ ff1=MEDFileField1TS.New()
+ ff1.setFieldNoProfileSBT(f1)
+ ff1.write(fname,0)
+ f2=MEDLoader.ReadFieldGaussNE(fname,f1.getMesh().getName(),0,f1.getName(),f1.getTime()[1],f1.getTime()[2])
+ self.assertTrue(f1.isEqual(f2,1e-12,1e-12))
+ #
+ fname="Pyfile28.med"
+ f1=MEDLoaderDataForTest.buildVecFieldOnGauss_2_Simpler();
+ m1=f1.getMesh()
+ mm1=MEDFileUMesh.New()
+ mm1.setCoords(m1.getCoords())
+ mm1.setMeshAtLevel(0,m1)
+ mm1.setName(m1.getName())
+ mm1.write(fname,2)
+ ff1=MEDFileField1TS.New()
+ ff1.setFieldNoProfileSBT(f1)
+ ff1.write(fname,0)
+ ff2=MEDFileField1TS.New(fname,f1.getName(),f1.getTime()[1],f1.getTime()[2])
+ f2=ff2.getFieldAtLevel(ON_GAUSS_PT,0)
+ self.assertTrue(f1.isEqual(f2,1e-12,1e-12))
+ #
+ pass
+
+ def testMEDFileData1(self):
+ fname="Pyfile29.med"
+ d=MEDFileData.New()
+ #
+ m1=MEDLoaderDataForTest.build1DMesh_1()
+ mm1=MEDFileUMesh.New() ; mm1.setCoords(m1.getCoords()) ; mm1.setMeshAtLevel(0,m1) ; mm1.setName(m1.getName())
+ mmm1=MEDFileMeshMultiTS.New() ;
+ mmm1.setOneTimeStep(mm1)
+ m2=MEDLoaderDataForTest.build2DCurveMesh_1()
+ mm2=MEDFileUMesh.New() ; mm2.setCoords(m2.getCoords()) ; mm2.setMeshAtLevel(0,m2) ; mm2.setName(m2.getName())
+ mmm2=MEDFileMeshMultiTS.New() ; mmm2.setOneTimeStep(mm2)
+ ms=MEDFileMeshes.New(); ms.setMeshAtPos(0,mm1) ; ms.setMeshAtPos(1,mm2)
+ d.setMeshes(ms)
+ #
+ ff1=MEDFileFieldMultiTS.New()
+ ff21=MEDFileFieldMultiTS.New()
+ ff22=MEDFileFieldMultiTS.New()
+ f1=m1.getMeasureField(True) ; f1.setName("f1") ; f1=f1.buildNewTimeReprFromThis(ONE_TIME,False)
+ f1.getArray().setInfoOnComponent(0,"power [kW]")
+ ff1.appendFieldNoProfileSBT(f1)
+ f21=m2.getMeasureField(True) ; f21.setName("f21") ; f21=f21.buildNewTimeReprFromThis(ONE_TIME,False)
+ f21.getArray().setInfoOnComponent(0,"sta [mm]") ;
+ ff21.appendFieldNoProfileSBT(f21)
+ f22=f21.deepCpy() ; f22.setName("f22") ; f22=f22.buildNewTimeReprFromThis(ONE_TIME,False) ;
+ f22.applyFunc(2,"3*x*IVec+2*x*JVec")
+ f22.getArray().setInfoOnComponent(0,"distance [km]") ; f22.getArray().setInfoOnComponent(1,"displacement [cm]")
+ ff22.appendFieldNoProfileSBT(f22)
+ fs=MEDFileFields.New()
+ fs.pushField(ff1) ; fs.pushField(ff21) ; fs.pushField(ff22)
+ d.setFields(fs)
+ #
+ d.write(fname,0)
+ #
+ d2=MEDFileData.New(fname)
+ self.assertEqual(2,d2.getNumberOfMeshes())
+ self.assertEqual(3,d2.getNumberOfFields())
+ self.assertTrue(isinstance(d2.getMeshes().getMeshAtPos(0),MEDFileUMesh))
+ m1bis=d2.getMeshes().getMeshAtPos(0).getMeshAtLevel(0)
+ self.assertTrue(m1.isEqual(m1bis,1e-12))
+ self.assertEqual(('f1', 'f21', 'f22'),d2.getFields().getFieldsNames())
+ self.assertEqual([(-1, -1, 0.0)],d2.getFields().getFieldAtPos(2).getTimeSteps())
+ self.assertEqual([(-1, -1, 0.0)],d2.getFields().getField("f21").getTimeSteps())
+ pass
+
+ def testMEDField9(self):
+ # first test field profile WR. Full type but with some type missing
+ fname="Pyfile30.med"
+ m1=MEDLoaderDataForTest.build2DMesh_3()
+ mm1=MEDFileUMesh.New() ; mm1.setCoords(m1.getCoords()) ; mm1.setMeshAtLevel(0,m1) ;
+ mm1.write(fname,2)
+ ff1=MEDFileField1TS.New()
+ f1=MEDCouplingFieldDouble.New(ON_CELLS,ONE_TIME) ; f1.setName("F1")
+ d=DataArrayDouble.New() ; d.alloc(2*9,1) ; d.iota(7.); d.rearrange(2); d.setInfoOnComponent(0,"sigX [MPa]") ; d.setInfoOnComponent(1,"sigY [GPa]")
+ f1.setArray(d) # note that f1 is NOT defined fully (no mesh !). It is not a bug of test it is too test that MEDFileField1TS.appendFieldProfile is NOT sensible of that.
+ da=DataArrayInt.New(); da.alloc(9,1) ; da.iota(0) ; da.setName("sup1")
+ #
+ ff1.setFieldProfile(f1,mm1,0,da)
+ ff1.write(fname,0)
+ #
+ vals,pfl=ff1.getFieldWithProfile(ON_CELLS,0,mm1)
+ self.assertTrue(pfl.isEqualWithoutConsideringStr(da))# profiles names cannot be contracted in pfl array name
+ self.assertTrue(vals.isEqual(d,1e-14))
+ #
+ ff2=MEDFileField1TS.New(fname,f1.getName(),-1,-1)
+ vals,pfl=ff2.getFieldWithProfile(ON_CELLS,0,mm1)
+ self.assertTrue(pfl.isEqualWithoutConsideringStr(da))
+ self.assertTrue(vals.isEqual(d,1e-14))
+ pass
+
+ def testMEDField10(self):
+ fname="Pyfile31.med"
+ m1=MEDLoaderDataForTest.build2DMesh_1()
+ m1.renumberCells([0,1,4,2,3,5],False)
+ mm1=MEDFileUMesh.New() ; mm1.setCoords(m1.getCoords()) ; mm1.setMeshAtLevel(0,m1) ; mm1.setName(m1.getName())
+ mm1.write(fname,2)
+ ff1=MEDFileFieldMultiTS.New()
+ f1=MEDCouplingFieldDouble.New(ON_CELLS,ONE_TIME) ; f1.setName("F2")
+ d=DataArrayDouble.New() ; d.alloc(2*4,1) ; d.iota(7.); d.rearrange(2); d.setInfoOnComponent(0,"sigX [MPa]") ; d.setInfoOnComponent(1,"sigY [GPa]")
+ f1.setArray(d) # note that f1 is NOT defined fully (no mesh !). It is not a bug of test it is too test that MEDFileField1TS.appendFieldProfile is NOT sensible of that.
+ da=DataArrayInt.New(); da.setValues([0,1,2,4],4,1) ; da.setName("sup2")
+ #
+ ff1.appendFieldProfile(f1,mm1,0,da)
+ f1.setTime(1.2,1,2) ; e=d.applyFunc("2*x") ; e.copyStringInfoFrom(d) ; f1.setArray(e) ;
+ ff1.appendFieldProfile(f1,mm1,0,da)
+ ff1.write(fname,0)
+ #
+ vals,pfl=ff1.getFieldWithProfile(ON_CELLS,1,2,0,mm1)
+ self.assertTrue(pfl.isEqualWithoutConsideringStr(da))
+ self.assertTrue(vals.isEqual(e,1e-14))
+ vals,pfl=ff1.getFieldWithProfile(ON_CELLS,-1,-1,0,mm1)
+ self.assertTrue(pfl.isEqualWithoutConsideringStr(da))
+ self.assertTrue(vals.isEqual(d,1e-14))
+ #
+ ff2=MEDFileFieldMultiTS.New(fname,f1.getName())
+ self.assertEqual([(-1, -1, 0.0), (1, 2, 1.2)],ff2.getTimeSteps())
+ vals,pfl=ff2.getFieldWithProfile(ON_CELLS,1,2,0,mm1)
+ self.assertTrue(pfl.isEqualWithoutConsideringStr(da))
+ self.assertTrue(vals.isEqual(e,1e-14))
+ vals,pfl=ff2.getFieldWithProfile(ON_CELLS,-1,-1,0,mm1)
+ self.assertTrue(pfl.isEqualWithoutConsideringStr(da))
+ self.assertTrue(vals.isEqual(d,1e-14))
+ pass
+
+ # idem testMEDField9 method except that here testing profile on nodes and not on cells.
+ def testMEDField11(self):
+ fname="Pyfile32.med"
+ m1=MEDLoaderDataForTest.build2DMesh_1()
+ m1.renumberCells([0,1,4,2,3,5],False)
+ mm1=MEDFileUMesh.New() ; mm1.setCoords(m1.getCoords()) ; mm1.setMeshAtLevel(0,m1) ;
+ mm1.write(fname,2)
+ ff1=MEDFileField1TS.New()
+ f1=MEDCouplingFieldDouble.New(ON_NODES,ONE_TIME) ; f1.setName("F1Node")
+ d=DataArrayDouble.New() ; d.alloc(2*6,1) ; d.iota(7.); d.rearrange(2); d.setInfoOnComponent(0,"sigX [MPa]") ; d.setInfoOnComponent(1,"sigY [GPa]")
+ f1.setArray(d) # note that f1 is NOT defined fully (no mesh !). It is not a bug of test it is too test that MEDFileField1TS.appendFieldProfile is NOT sensible of that.
+ da=DataArrayInt.New(); da.setValues([1,2,4,5,7,8],6,1) ; da.setName("sup1Node")
+ #
+ ff1.setFieldProfile(f1,mm1,0,da)
+ ff1.write(fname,0)
+ #
+ vals,pfl=ff1.getFieldWithProfile(ON_NODES,0,mm1)
+ self.assertTrue(pfl.isEqualWithoutConsideringStr(da))
+ self.assertTrue(vals.isEqual(d,1e-14))
+ ## #
+ ff2=MEDFileField1TS.New(fname,f1.getName(),-1,-1)
+ vals,pfl=ff2.getFieldWithProfile(ON_NODES,0,mm1)
+ self.assertTrue(pfl.isEqualWithoutConsideringStr(da))
+ self.assertTrue(vals.isEqual(d,1e-14))
+ pass
+
+ def testMEDField12(self):
+ fname="Pyfile33.med"
+ m1=MEDLoaderDataForTest.build2DMesh_1()
+ m1.renumberCells([0,1,4,2,3,5],False)
+ mm1=MEDFileUMesh.New() ; mm1.setCoords(m1.getCoords()) ; mm1.setMeshAtLevel(0,m1) ;
+ mm1.write(fname,2)
+ ff1=MEDFileFieldMultiTS.New()
+ f1=MEDCouplingFieldDouble.New(ON_NODES,ONE_TIME) ; f1.setName("F1Node")
+ d=DataArrayDouble.New() ; d.alloc(2*6,1) ; d.iota(7.); d.rearrange(2); d.setInfoOnComponent(0,"sigX [MPa]") ; d.setInfoOnComponent(1,"sigY [GPa]")
+ f1.setArray(d) # note that f1 is NOT defined fully (no mesh !). It is not a bug of test it is too test that MEDFileField1TS.appendFieldProfile is NOT sensible of that.
+ da=DataArrayInt.New(); da.setValues([1,2,4,5,7,8],6,1) ; da.setName("sup1Node")
+ #
+ ff1.appendFieldProfile(f1,mm1,0,da)
+ f1.setTime(1.2,1,2) ; e=d.applyFunc("2*x") ; e.copyStringInfoFrom(d) ; f1.setArray(e) ;
+ ff1.appendFieldProfile(f1,mm1,0,da)
+ ff1.write(fname,0)
+ #
+ vals,pfl=ff1.getFieldWithProfile(ON_NODES,1,2,0,mm1)
+ self.assertTrue(pfl.isEqualWithoutConsideringStr(da))
+ self.assertTrue(vals.isEqual(e,1e-14))
+ vals,pfl=ff1.getFieldWithProfile(ON_NODES,-1,-1,0,mm1)
+ self.assertTrue(pfl.isEqualWithoutConsideringStr(da))
+ self.assertTrue(vals.isEqual(d,1e-14))
+ #
+ ff2=MEDFileFieldMultiTS.New(fname,f1.getName())
+ vals,pfl=ff2.getFieldWithProfile(ON_NODES,1,2,0,mm1)
+ self.assertTrue(pfl.isEqualWithoutConsideringStr(da))
+ self.assertTrue(vals.isEqual(e,1e-14))
+ vals,pfl=ff2.getFieldWithProfile(ON_NODES,-1,-1,0,mm1)
+ self.assertTrue(pfl.isEqualWithoutConsideringStr(da))
+ self.assertTrue(vals.isEqual(d,1e-14))
+ pass
+
+ def testMEDField13(self):
+ fname="Pyfile34.med"
+ m1=MEDLoaderDataForTest.build2DMesh_1()
+ m1.renumberCells([0,1,4,2,3,5],False)
+ tmp=m1.getName();
+ m1=m1.buildPartOfMySelf(range(5),True) ; m1.setName(tmp) # suppression of last cell that is a polygon
+ mm1=MEDFileUMesh.New() ; mm1.setCoords(m1.getCoords()) ; mm1.setMeshAtLevel(0,m1) ;
+ mm1.write(fname,2)
+ ff1=MEDFileField1TS.New()
+ f1=MEDCouplingFieldDouble.New(ON_GAUSS_NE,ONE_TIME) ; f1.setName("F3Node")
+ d=DataArrayDouble.New() ; d.alloc(2*11,1) ; d.iota(7.); d.rearrange(2); d.setInfoOnComponent(0,"sigX [MPa]") ; d.setInfoOnComponent(1,"sigY [GPa]")
+ f1.setArray(d) # note that f1 is NOT defined fully (no mesh !). It is not a bug of test it is too test that MEDFileField1TS.appendFieldProfile is NOT sensible of that.
+ da=DataArrayInt.New(); da.setValues([0,2,3],3,1) ; da.setName("sup1NodeElt")
+ #
+ ff1.setFieldProfile(f1,mm1,0,da)
+ ff1.write(fname,0)
+ #
+ vals,pfl=ff1.getFieldWithProfile(ON_GAUSS_NE,0,mm1)
+ self.assertTrue(pfl.isEqualWithoutConsideringStr(da))
+ self.assertTrue(vals.isEqual(d,1e-14))
+ #
+ ff2=MEDFileField1TS.New(fname,f1.getName(),-1,-1)
+ vals,pfl=ff2.getFieldWithProfile(ON_GAUSS_NE,0,mm1)
+ self.assertTrue(pfl.isEqualWithoutConsideringStr(da))
+ self.assertTrue(vals.isEqual(d,1e-14))
+ pass
+
+ def testMEDField14(self):
+ fname="Pyfile35.med"
+ m1=MEDLoaderDataForTest.build2DMesh_1()
+ m1.renumberCells([0,1,4,2,3,5],False)
+ tmp=m1.getName();
+ m1=m1.buildPartOfMySelf(range(5),True) ; m1.setName(tmp) # suppression of last cell that is a polygon
+ mm1=MEDFileUMesh.New() ; mm1.setCoords(m1.getCoords()) ; mm1.setMeshAtLevel(0,m1) ;
+ mm1.write(fname,2)
+ ff1=MEDFileFieldMultiTS.New()
+ f1=MEDCouplingFieldDouble.New(ON_GAUSS_NE,ONE_TIME) ; f1.setName("F4Node")
+ d=DataArrayDouble.New() ; d.alloc(2*11,1) ; d.iota(7.); d.rearrange(2); d.setInfoOnComponent(0,"sigX [MPa]") ; d.setInfoOnComponent(1,"sigY [GPa]")
+ f1.setArray(d) # note that f1 is NOT defined fully (no mesh !). It is not a bug of test it is too test that MEDFileField1TS.appendFieldProfile is NOT sensible of that.
+ da=DataArrayInt.New(); da.setValues([0,2,3],3,1) ; da.setName("sup1NodeElt")
+ #
+ ff1.appendFieldProfile(f1,mm1,0,da)
+ f1.setTime(1.2,1,2) ; e=d.applyFunc("2*x") ; e.copyStringInfoFrom(d) ; f1.setArray(e) ;
+ ff1.appendFieldProfile(f1,mm1,0,da)
+ ff1.write(fname,0)
+ #
+ vals,pfl=ff1.getFieldWithProfile(ON_GAUSS_NE,-1,-1,0,mm1)
+ self.assertTrue(pfl.isEqualWithoutConsideringStr(da))
+ self.assertTrue(vals.isEqual(d,1e-14))
+ vals,pfl=ff1.getFieldWithProfile(ON_GAUSS_NE,1,2,0,mm1)
+ self.assertTrue(pfl.isEqualWithoutConsideringStr(da))
+ self.assertTrue(vals.isEqual(e,1e-14))
+ #
+ ff2=MEDFileFieldMultiTS.New(fname,f1.getName())
+ vals,pfl=ff1.getFieldWithProfile(ON_GAUSS_NE,-1,-1,0,mm1)
+ self.assertTrue(pfl.isEqualWithoutConsideringStr(da))
+ self.assertTrue(vals.isEqual(d,1e-14))
+ vals,pfl=ff1.getFieldWithProfile(ON_GAUSS_NE,1,2,0,mm1)
+ self.assertTrue(pfl.isEqualWithoutConsideringStr(da))
+ self.assertTrue(vals.isEqual(e,1e-14))
pass
pass
# -*- coding: iso-8859-1 -*-
-# Copyright (C) 2007-2010 CEA/DEN, EDF R&D
+# Copyright (C) 2007-2011 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 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.
+# 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
+# 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
+# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
#
print """