ENDIF(SALOME_MED_ENABLE_RENUMBER)
IF(SALOME_MED_ENABLE_PARTITIONER)
ADD_SUBDIRECTORY(MEDPartitioner)
+ IF(SALOME_MED_ENABLE_PYTHON)
+ ADD_SUBDIRECTORY(MEDPartitioner_Swig)
+ ENDIF(SALOME_MED_ENABLE_PYTHON)
ENDIF(SALOME_MED_ENABLE_PARTITIONER)
IF(SALOME_BUILD_TESTS)
ADD_SUBDIRECTORY(INTERP_KERNELTest)
MEDCouplingAMRAttribute.cxx
MEDCouplingMatrix.cxx
MEDCouplingPartDefinition.cxx
+ MEDCouplingSkyLineArray.cxx
)
SET(medcouplingremapper_SOURCES
--- /dev/null
+// Copyright (C) 2007-2015 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, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#include "MEDCouplingSkyLineArray.hxx"
+
+#include <vector>
+
+using namespace ParaMEDMEM;
+
+MEDCouplingSkyLineArray::MEDCouplingSkyLineArray()
+{
+}
+
+MEDCouplingSkyLineArray::MEDCouplingSkyLineArray(const MEDCouplingSkyLineArray &myArray)
+{
+ _index=myArray._index;
+ _value=myArray._value;
+}
+
+MEDCouplingSkyLineArray::~MEDCouplingSkyLineArray()
+{
+}
+
+MEDCouplingSkyLineArray::MEDCouplingSkyLineArray(const MEDCouplingAutoRefCountObjectPtr<DataArrayInt>& index, const MEDCouplingAutoRefCountObjectPtr<DataArrayInt>& value)
+{
+ _index=index;
+ _value=value;
+}
+
+
--- /dev/null
+// Copyright (C) 2007-2015 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, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#ifndef __PARAMEDMEM_MEDCOUPLINGSKYLINEARRAY_HXX__
+#define __PARAMEDMEM_MEDCOUPLINGSKYLINEARRAY_HXX__
+
+#include "MEDCoupling.hxx"
+#include "MEDCouplingMesh.hxx"
+#include "MEDCouplingMemArray.hxx"
+#include "MEDCouplingAutoRefCountObjectPtr.hxx"
+#include <vector>
+
+namespace ParaMEDMEM
+{
+class DataArrayInt;
+ class MEDCOUPLING_EXPORT MEDCouplingSkyLineArray
+ {
+ private:
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> _index;
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> _value;
+ public:
+ MEDCouplingSkyLineArray();
+ MEDCouplingSkyLineArray( const MEDCouplingSkyLineArray &myArray );
+ MEDCouplingSkyLineArray( const MEDCouplingAutoRefCountObjectPtr<DataArrayInt>& index, const MEDCouplingAutoRefCountObjectPtr<DataArrayInt>& value );
+ ~MEDCouplingSkyLineArray();
+
+ int getNumberOf() const { return _index->getNbOfElems(); }
+ int getLength() const { return _value->getNbOfElems(); }
+ };
+}
+# endif
return ret.retn();
}
+/*!
+ * generate graph.
+ *
+ * \return sky line array
+ */
+MEDCouplingSkyLineArray *MEDCouplingUMesh::generateGraph() const
+{
+ MEDCouplingSkyLineArray* ret=new MEDCouplingSkyLineArray(_nodal_connec_index, _nodal_connec);
+ return ret;
+}
+
/*!
* This method put in zip format into parameter 'zipFrmt' in full interlace mode.
* This format is often asked by INTERP_KERNEL algorithms to avoid many indirections into coordinates array.
#include "MEDCoupling.hxx"
#include "MEDCouplingPointSet.hxx"
#include "MEDCouplingMemArray.hxx"
+#include "MEDCouplingSkyLineArray.hxx"
#include "CellModel.hxx"
MEDCOUPLING_EXPORT DataArrayInt *buildUnionOf2DMesh() const;
MEDCOUPLING_EXPORT DataArrayInt *buildUnionOf3DMesh() const;
MEDCOUPLING_EXPORT DataArrayInt *orderConsecutiveCells1D() const;
+ MEDCOUPLING_EXPORT MEDCouplingSkyLineArray *generateGraph() const;
private:
MEDCouplingUMesh();
MEDCouplingUMesh(const MEDCouplingUMesh& other, bool deepCopy);
#include "MEDCouplingAMRAttribute.hxx"
#include "MEDCouplingMatrix.hxx"
#include "MEDCouplingPartDefinition.hxx"
+#include "MEDCouplingSkyLineArray.hxx"
#include "MEDCouplingTypemaps.i"
#include "InterpKernelAutoPtr.hxx"
%newobject ParaMEDMEM::MEDCouplingUMesh::ComputeRangesFromTypeDistribution;
%newobject ParaMEDMEM::MEDCouplingUMesh::buildUnionOf2DMesh;
%newobject ParaMEDMEM::MEDCouplingUMesh::buildUnionOf3DMesh;
+%newobject ParaMEDMEM::MEDCouplingUMesh::generateGraph;
%newobject ParaMEDMEM::MEDCouplingUMesh::orderConsecutiveCells1D;
%newobject ParaMEDMEM::MEDCouplingUMesh::getBoundingBoxForBBTreeFast;
%newobject ParaMEDMEM::MEDCouplingUMesh::getBoundingBoxForBBTree2DQuadratic;
static bool AreAlmostEqual(const std::vector<double>& v1, const std::vector<double>& v2, double eps);
};
}
+namespace ParaMEDMEM
+{
+ class MEDCouplingSkyLineArray
+ {
+ public:
+ MEDCouplingSkyLineArray() throw(INTERP_KERNEL::Exception);
+ MEDCouplingSkyLineArray( const MEDCouplingSkyLineArray &myArray ) throw(INTERP_KERNEL::Exception);
+ MEDCouplingSkyLineArray( const MEDCouplingAutoRefCountObjectPtr<DataArrayInt>& index, const MEDCouplingAutoRefCountObjectPtr<DataArrayInt>& value ) throw(INTERP_KERNEL::Exception);
+ ~MEDCouplingSkyLineArray() throw(INTERP_KERNEL::Exception);
+
+ int getNumberOf() const throw(INTERP_KERNEL::Exception);
+ int getLength() const throw(INTERP_KERNEL::Exception);
+ };
+}
%include "MEDCouplingFieldDiscretization.i"
DataArrayInt *convertNodalConnectivityToStaticGeoTypeMesh() const throw(INTERP_KERNEL::Exception);
DataArrayInt *buildUnionOf2DMesh() const throw(INTERP_KERNEL::Exception);
DataArrayInt *buildUnionOf3DMesh() const throw(INTERP_KERNEL::Exception);
+ MEDCouplingSkyLineArray *generateGraph() const throw(INTERP_KERNEL::Exception);
DataArrayInt *orderConsecutiveCells1D() const throw(INTERP_KERNEL::Exception);
DataArrayDouble *getBoundingBoxForBBTreeFast() const throw(INTERP_KERNEL::Exception);
DataArrayDouble *getBoundingBoxForBBTree2DQuadratic(double arcDetEps=1e-12) const throw(INTERP_KERNEL::Exception);
MEDFileBasis.cxx
MEDFileMeshLL.cxx
MEDFileField.cxx
+ MEDFileJoint.cxx
MEDFileParameter.cxx
MEDFileData.cxx
MEDFileFieldOverView.cxx
MEDCouplingAutoRefCountObjectPtr<MEDFileParameters> params;
if((const MEDFileParameters *)_params)
params=_params->deepCpy();
+ MEDCouplingAutoRefCountObjectPtr<MEDFileJoints> joints;
+ if((const MEDFileJoints *)_joints)
+ joints=_joints->deepCpy();
MEDCouplingAutoRefCountObjectPtr<MEDFileData> ret=MEDFileData::New();
- ret->_fields=fields; ret->_meshes=meshes; ret->_params=params;
+ ret->_fields=fields; ret->_meshes=meshes; ret->_params=params; ret->_joints=joints;
return ret.retn();
}
ret.push_back((const MEDFileFields *)_fields);
ret.push_back((const MEDFileMeshes *)_meshes);
ret.push_back((const MEDFileParameters *)_params);
+ ret.push_back((const MEDFileJoints *)_joints);
return ret;
}
return const_cast<MEDFileParameters *>(static_cast<const MEDFileParameters *>(_params));
}
+/** Return a borrowed reference (caller is not responsible for object destruction) */
+MEDFileJoints *MEDFileData::getJoints() const
+{
+ return const_cast<MEDFileJoints *>(static_cast<const MEDFileJoints *>(_joints));
+}
+
void MEDFileData::setFields(MEDFileFields *fields)
{
if(fields)
_params=params;
}
+void MEDFileData::setJoints(MEDFileJoints *joints)
+{
+ if(joints)
+ joints->incrRef();
+ _joints=joints;
+}
+
int MEDFileData::getNumberOfFields() const
{
const MEDFileFields *f=_fields;
return p->getNumberOfParams();
}
+int MEDFileData::getNumberOfJoints() const
+{
+ const MEDFileJoints *p=_joints;
+ if(!p)
+ throw INTERP_KERNEL::Exception("MEDFileData::getNumberOfJoints : no joints set !");
+ return p->getNumberOfJoints();
+}
+
std::string MEDFileData::simpleRepr() const
{
std::ostringstream oss;
}
else
oss << "No params set !!!\n";
+ oss << "Joints part :\n*************\n\n";
+ const MEDFileJoints *tmp4=_joints;
+ if(tmp4)
+ {
+ tmp4->simpleReprWithoutHeader(oss);
+ }
+ else
+ oss << "No joints set !!!\n";
return oss.str();
}
_fields=MEDFileFields::New(fileName);
_meshes=MEDFileMeshes::New(fileName);
_params=MEDFileParameters::New(fileName);
+ _joints=MEDFileJoints::New(fileName);
}
catch(INTERP_KERNEL::Exception& e)
{
const MEDFileParameters *ps=_params;
if(ps)
ps->writeLL(fid);
+ const MEDFileJoints *js=_joints;
+ if(js)
+ js->write(fid);
}
#include "MEDFileParameter.hxx"
#include "MEDFileField.hxx"
#include "MEDFileMesh.hxx"
+#include "MEDFileJoint.hxx"
namespace ParaMEDMEM
{
MEDLOADER_EXPORT MEDFileFields *getFields() const;
MEDLOADER_EXPORT MEDFileMeshes *getMeshes() const;
MEDLOADER_EXPORT MEDFileParameters *getParams() const;
+ MEDLOADER_EXPORT MEDFileJoints *getJoints() const;
MEDLOADER_EXPORT void setFields(MEDFileFields *fields);
MEDLOADER_EXPORT void setMeshes(MEDFileMeshes *meshes);
MEDLOADER_EXPORT void setParams(MEDFileParameters *params);
+ MEDLOADER_EXPORT void setJoints(MEDFileJoints *joints);
MEDLOADER_EXPORT int getNumberOfFields() const;
MEDLOADER_EXPORT int getNumberOfMeshes() const;
MEDLOADER_EXPORT int getNumberOfParams() const;
+ MEDLOADER_EXPORT int getNumberOfJoints() const;
MEDLOADER_EXPORT std::string simpleRepr() const;
//
MEDLOADER_EXPORT bool changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab);
MEDCouplingAutoRefCountObjectPtr<MEDFileFields> _fields;
MEDCouplingAutoRefCountObjectPtr<MEDFileMeshes> _meshes;
MEDCouplingAutoRefCountObjectPtr<MEDFileParameters> _params;
+ MEDCouplingAutoRefCountObjectPtr<MEDFileJoints> _joints;
};
}
--- /dev/null
+// Copyright (C) 2007-2015 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, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#include "MEDFileJoint.hxx"
+#include "MEDFileUtilities.hxx"
+#include "MEDLoader.hxx"
+#include "MEDLoaderBase.hxx"
+
+#include "InterpKernelAutoPtr.hxx"
+
+#include <set>
+
+extern med_geometry_type typmai3[34];
+
+using namespace ParaMEDMEM;
+
+std::size_t MEDFileJointCorrespondence::getHeapMemorySizeWithoutChildren() const
+{
+ return sizeof(MEDCouplingAutoRefCountObjectPtr<DataArrayInt>);
+}
+
+std::vector<const BigMemoryObject *> MEDFileJointCorrespondence::getDirectChildrenWithNull() const
+{
+ return std::vector<const BigMemoryObject *>();
+}
+MEDFileJointCorrespondence::MEDFileJointCorrespondence()
+{
+}
+/*!
+ * Returns a new MEDFileJointCorrespondence.
+ * \param [in] loc_ent_type - the local entity type of correspondence.
+ * \param [in] loc_geo_type - the local geometry type of correspondence.
+ * \param [in] rem_ent_type - the remote entity type of correspondence.
+ * \param [in] rem_geo_type - the remote geometry type of correspondence.
+ * \param [in] num_entity - the number of entity.
+ * \param [in] correspondence - correspondence.
+ * \return MEDFileJointCorrespondence * - a new instance of MEDFileJointCorrespondence.
+ * \throw If the file is not readable.
+ * \throw If there is no mesh with given attributes in the file.
+ * \throw If the mesh in the file is of a not supported type.
+ */
+MEDFileJointCorrespondence::MEDFileJointCorrespondence(TypeOfField loc_ent_type, INTERP_KERNEL::NormalizedCellType loc_geo_type,
+ TypeOfField rem_ent_type, INTERP_KERNEL::NormalizedCellType rem_geo_type,
+ DataArrayInt* correspondence)
+{
+ med_entity_type _cur_loc_ent_type;
+ med_entity_type _cur_rem_ent_type;
+ med_geometry_type _cur_loc_geo_type;
+ med_geometry_type _cur_rem_geo_type;
+
+ _cur_loc_ent_type = ConvertIntoMEDFileType(loc_ent_type,loc_geo_type,_cur_loc_geo_type);
+ _cur_rem_ent_type = ConvertIntoMEDFileType(rem_ent_type,rem_geo_type,_cur_rem_geo_type);
+
+ MEDFileJointCorrespondence::setLocalEntityType(_cur_loc_ent_type);
+ MEDFileJointCorrespondence::setRemoteEntityType(_cur_rem_ent_type);
+ MEDFileJointCorrespondence::setLocalGeometryType(_cur_loc_geo_type);
+ MEDFileJointCorrespondence::setRemoteGeometryType(_cur_rem_geo_type);
+ MEDFileJointCorrespondence::setCorrespondence(correspondence);
+}
+
+MEDFileJointCorrespondence *MEDFileJointCorrespondence::New(TypeOfField loc_ent_type, INTERP_KERNEL::NormalizedCellType loc_geo_type,
+ TypeOfField rem_ent_type, INTERP_KERNEL::NormalizedCellType rem_geo_type,
+ DataArrayInt* correspondence)
+{
+ return new MEDFileJointCorrespondence(loc_ent_type, loc_geo_type, rem_ent_type, rem_geo_type, correspondence);
+}
+
+
+MEDFileJointCorrespondence *MEDFileJointCorrespondence::New()
+{
+ return new MEDFileJointCorrespondence();
+}
+
+med_entity_type MEDFileJointCorrespondence::ConvertIntoMEDFileType(TypeOfField ikType, INTERP_KERNEL::NormalizedCellType ikGeoType, med_geometry_type& medfGeoType)
+{
+ switch(ikType)
+ {
+ case ON_CELLS:
+ medfGeoType=typmai3[(int)ikGeoType];
+ return MED_CELL;
+ case ON_NODES:
+ medfGeoType=MED_NONE;
+ return MED_NODE;
+ case ON_GAUSS_NE:
+ medfGeoType=typmai3[(int)ikGeoType];
+ return MED_NODE_ELEMENT;
+ case ON_GAUSS_PT:
+ medfGeoType=typmai3[(int)ikGeoType];
+ return MED_CELL;
+ default:
+ throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerType::ConvertIntoMEDFileType : unexpected entity type ! internal error");
+ }
+ return MED_UNDEF_ENTITY_TYPE;
+}
+
+/*!
+ * Writes \a this joint into a MED file specified by its name.
+ * \param [in] fileName - the MED file name.
+ * \param [in] mode - the writing mode. For more on \a mode, see \ref AdvMEDLoaderBasics.
+ * \param [in] order - order.
+ * \param [in] iteration - iteration.
+ * - 2 - erase; an existing file is removed.
+ * - 1 - append; same data should not be present in an existing file.
+ * - 0 - overwrite; same data present in an existing file is overwritten.
+ * \throw If the mesh name is not set.
+ * \throw If \a mode == 1 and the same data is present in an existing file.
+ */
+void MEDFileJointCorrespondence::write(const std::string& fileName, int mode, const std::string& localMeshName, const std::string& jointName, int order, int iteration) const
+{
+ med_access_mode medmod=MEDFileUtilities::TraduceWriteMode(mode);
+ MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),medmod);
+ std::ostringstream oss; oss << "MEDFileJointCorrespondence : error on attempt to write in file : \"" << fileName << "\"";
+ MEDFileUtilities::CheckMEDCode(fid,fid,oss.str());
+ writeLL(fid, localMeshName, jointName, order, iteration);
+}
+
+void MEDFileJointCorrespondence::writeLL(med_idt fid, const std::string& localMeshName, const std::string& jointName, int order, int iteration) const
+{
+ if((const DataArrayInt *)_correspondence)
+ MEDsubdomainCorrespondenceWr(fid, localMeshName.c_str(), jointName.c_str(), order, iteration,
+ getLocalEntityType(), getLocalGeometryType(), getRemoteEntityType(),
+ getRemoteGeometryType(), _correspondence->getNbOfElems()/2, _correspondence->getConstPointer());
+}
+void MEDFileJointCorrespondence::setCorrespondence(DataArrayInt *corr)
+{
+ _correspondence=DataArrayInt::New();
+ _correspondence->alloc(corr->getNbOfElems(),1);
+ int *cPtr=_correspondence->getPointer();
+ int *corPtr= corr->getPointer();
+ for(int i=0;i<corr->getNbOfElems();i++)
+ cPtr[i]=corPtr[i];
+}
+/*!
+ * Checks if \a this and another mesh are equal.
+ * \param [in] other - the mesh to compare with.
+ * \param [in,out] what - the string returning description of unequal data.
+ * \return bool - \c true if the meshes are equal, \c false, else.
+ */
+bool MEDFileJointCorrespondence::isEqual(const MEDFileJointCorrespondence *other, std::string& what) const
+{
+ if(_loc_ent_type!=other->_loc_ent_type)
+ {
+ what="Local entity type differ !";
+ return false;
+ }
+ if(_rem_ent_type!=other->_rem_ent_type)
+ {
+ what="Remote entity type differ !";
+ return false;
+ }
+ if(_loc_geo_type!=other->_loc_geo_type)
+ {
+ what="Local geometry type differ !";
+ return false;
+ }
+ if(_rem_geo_type!=other->_rem_geo_type)
+ {
+ what="Remote geometry type differ !";
+ return false;
+ }
+ if(_correspondence!=other->_correspondence)
+ {
+ what="Correspondence differ !";
+ return false;
+ }
+ return true;
+}
+
+MEDFileJointCorrespondence *MEDFileJointCorrespondence::deepCpy() const
+{
+ MEDCouplingAutoRefCountObjectPtr<MEDFileJointCorrespondence> ret=new MEDFileJointCorrespondence(*this);
+ return ret.retn();
+}
+
+MEDFileJointCorrespondence *MEDFileJointCorrespondence::shallowCpy() const
+{
+ MEDCouplingAutoRefCountObjectPtr<MEDFileJointCorrespondence> ret=new MEDFileJointCorrespondence(*this);
+ return ret.retn();
+}
+
+/*!
+ * Returns a string describing \a this mesh. This description includes the correspondence and
+ * the number correspondence.
+ * \return std::string - the joint information string.
+ */
+std::string MEDFileJointCorrespondence::simpleRepr() const
+{
+ std::ostringstream oss;
+ oss << "(*************************************)\n(* JOINT_CORRESPOND INFORMATION: *)\n(*************************************)\n";
+ oss << "- Local entity type of the correspondence : <<" << getLocalEntityType() << ">>\n";
+ oss << "- Local geometry type of the correspondence : <<" << getLocalGeometryType() << ">>\n";
+ oss << "- Remote entity type of the correspondence : <<" << getRemoteEntityType() << ">>\n";
+ oss << "- Remote geometry type of the correspondence : <<" << getRemoteGeometryType() << ">>\n";
+ oss << "- Number entity of the correspondence : <<" << getCorrespondence()->getNumberOfTuples() << ">>\n";
+
+const DataArrayInt* tmp=getCorrespondence();
+ oss << "- Correspondence : <<";
+ for(const int *it=tmp->begin();it!=tmp->end();it++)
+ oss<< *it << " ";
+ oss << std::endl;
+ return oss.str();
+}
+
+
+MEDFileJointOneStep::MEDFileJointOneStep():_order(-1),_iteration(-1)
+{
+}
+
+std::size_t MEDFileJointOneStep::getHeapMemorySizeWithoutChildren() const
+{
+ return _correspondences.capacity()*sizeof(MEDCouplingAutoRefCountObjectPtr<DataArrayInt>);
+}
+
+std::vector<const BigMemoryObject *> MEDFileJointOneStep::getDirectChildrenWithNull() const
+{
+ return std::vector<const BigMemoryObject *>();
+}
+
+MEDFileJointOneStep *MEDFileJointOneStep::New()
+{
+ return new MEDFileJointOneStep();
+}
+
+MEDFileJointOneStep *MEDFileJointOneStep::New(const std::string& fileName, const std::string& mName, const std::string& jointName, int num)
+{
+ return new MEDFileJointOneStep(fileName, mName, jointName, num);
+}
+/*!
+ * Returns a new MEDFileJointOneStep.
+ * \param [in] fileName - the name of MED file to read.
+ * \param [in] mName - the name of the mesh to read.
+ * \param [in] dt - the number of a time step.
+ * \param [in] it - the number of an iteration.
+ * \return MEDFileMesh * - a new instance of MEDFileJointOneStep.
+ * \throw If the file is not readable.
+ * \throw If there is no mesh with given attributes in the file.
+ * \throw If the mesh in the file is of a not supported type.
+ */
+MEDFileJointOneStep::MEDFileJointOneStep(const std::string& fileName, const std::string& mName, const std::string& jointName, int num)
+{
+ MEDFileUtilities::CheckFileForRead(fileName);
+ MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(), MED_ACC_RDONLY);
+ int order, iteration, ncorrespondence;
+ MEDsubdomainComputingStepInfo(fid, mName.c_str(), jointName.c_str(), num, &order, &iteration, &ncorrespondence);
+ MEDFileJointOneStep::setOrder(order);
+ MEDFileJointOneStep::setIteration(iteration);
+ for(int cur_it = 1; cur_it <= ncorrespondence; ++cur_it) {
+ int num_entity;
+ med_entity_type loc_ent_type, rem_ent_type;
+ med_geometry_type loc_geo_type, rem_geo_type;
+ MEDsubdomainCorrespondenceSizeInfo(fid, mName.c_str(), jointName.c_str(), order, iteration, cur_it,
+ &loc_ent_type, &loc_geo_type, &rem_ent_type, &rem_geo_type, &num_entity);
+ if ( num_entity > 0 ) {
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> correspondence=DataArrayInt::New();
+ correspondence->alloc(num_entity*2, 1);
+ MEDsubdomainCorrespondenceRd(fid, mName.c_str(), jointName.c_str(), order, iteration, loc_ent_type,
+ loc_geo_type, rem_ent_type, rem_geo_type, correspondence->getPointer());
+ MEDFileJointCorrespondence *cor=MEDFileJointCorrespondence::New();
+ cor->setLocalEntityType(loc_ent_type);
+ cor->setRemoteEntityType(rem_ent_type);
+ cor->setLocalGeometryType(loc_geo_type);
+ cor->setRemoteGeometryType(rem_geo_type);
+ cor->setCorrespondence(correspondence);
+ _correspondences.push_back(cor);
+ }
+ }
+}
+
+/*!
+ * Writes \a this joint into a MED file specified by its name.
+ * \param [in] fileName - the MED file name.
+ * \param [in] mode - the writing mode. For more on \a mode, see \ref AdvMEDLoaderBasics.
+ * - 2 - erase; an existing file is removed.
+ * - 1 - append; same data should not be present in an existing file.
+ * - 0 - overwrite; same data present in an existing file is overwritten.
+ * \throw If the mesh name is not set.
+ * \throw If \a mode == 1 and the same data is present in an existing file.
+ */
+void MEDFileJointOneStep::write(const std::string& fileName, int mode, const std::string& localMeshName, const std::string& jointName) const
+{
+ med_access_mode medmod=MEDFileUtilities::TraduceWriteMode(mode);
+ MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),medmod);
+ std::ostringstream oss; oss << "MEDFileJointOneStep : error on attempt to write in file : \"" << fileName << "\"";
+ MEDFileUtilities::CheckMEDCode(fid,fid,oss.str());
+ writeLL(fid, localMeshName, jointName);
+}
+
+void MEDFileJointOneStep::writeLL(med_idt fid, const std::string& localMeshName, const std::string& jointName) const
+{
+ for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileJointCorrespondence> >::const_iterator it=_correspondences.begin();it!=_correspondences.end();it++) {
+ (*it)->writeLL(fid, localMeshName, jointName, getOrder(), getIteration());
+ }
+}
+
+void MEDFileJointOneStep::pushCorrespondence(MEDFileJointCorrespondence* correspondence)
+{
+ if(!correspondence)
+ throw INTERP_KERNEL::Exception("MEDFileJointCorrespondence::pushCorrespondence : invalid input pointer ! should be different from 0 !");
+ _correspondences.push_back(correspondence);
+}
+/*!
+ * Checks if \a this and another mesh are equal.
+ * \param [in] other - the mesh to compare with.
+ * \param [in,out] what - the string returning description of unequal data.
+ * \return bool - \c true if the meshes are equal, \c false, else.
+ */
+bool MEDFileJointOneStep::isEqual(const MEDFileJointOneStep *other, std::string& what) const
+{
+ if(_order!=other->_order)
+ {
+ what="Orders differ !";
+ return false;
+ }
+ if(_iteration!=other->_iteration)
+ {
+ what="Iterations differ !";
+ return false;
+ }
+ return true;
+}
+
+MEDFileJointOneStep *MEDFileJointOneStep::deepCpy() const
+{
+ std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileJointCorrespondence> > correspondences(_correspondences.size());
+ std::size_t i=0;
+ for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileJointCorrespondence> >::const_iterator it=_correspondences.begin();it!=_correspondences.end();it++,i++)
+ if((const MEDFileJointCorrespondence *)*it)
+ correspondences[i]=(*it)->deepCpy();
+ MEDCouplingAutoRefCountObjectPtr<MEDFileJointOneStep> ret= new MEDFileJointOneStep;
+ ret->_correspondences=correspondences;
+ return ret.retn();
+}
+
+MEDFileJointOneStep *MEDFileJointOneStep::shallowCpy() const
+{
+ MEDCouplingAutoRefCountObjectPtr<MEDFileJointOneStep> ret=new MEDFileJointOneStep(*this);
+ return ret.retn();
+}
+
+/*!
+ * Returns a string describing \a this mesh. This description includes the correspondence and
+ * the number correspondence.
+ * \return std::string - the joint information string.
+ */
+std::string MEDFileJointOneStep::simpleRepr() const
+{
+ std::ostringstream oss;
+ oss << "(*************************************)\n(* JOINT_ONE_STEP INFORMATION: *)\n(*************************************)\n";
+ oss << "- Number of the correspondence : <<" << _correspondences.size() << ">>\n";
+ for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileJointCorrespondence> >::const_iterator it=_correspondences.begin();it!=_correspondences.end();it++) {
+ oss << (*it)->simpleRepr();
+ }
+ return oss.str();
+}
+
+std::size_t MEDFileJoint::getHeapMemorySizeWithoutChildren() const
+{
+ return _joint.capacity()*sizeof(MEDCouplingAutoRefCountObjectPtr<MEDFileJointOneStep>);
+}
+
+std::vector<const BigMemoryObject *> MEDFileJoint::getDirectChildrenWithNull() const
+{
+ return std::vector<const BigMemoryObject *>();
+}
+
+MEDFileJoint *MEDFileJoint::New()
+{
+ return new MEDFileJoint();
+}
+
+MEDFileJoint *MEDFileJoint::New(const std::string& fileName, const std::string& mName, int curJoint)
+{
+ return new MEDFileJoint(fileName,mName,curJoint);
+}
+
+MEDFileJoint::MEDFileJoint()
+{
+}
+
+/*!
+ * Returns a new MEDFileJoint holding the mesh data that has been read from a given MED
+ * file. The mesh to load is specified by its name and numbers of a time step and an
+ * iteration.
+ * \param [in] fileName - the name of MED file to read.
+ * \param [in] mName - the name of the mesh to read.
+ * \param [in] num - the number of current joint.
+ * \return MEDFileJoint * - a new instance of MEDFileJoint.
+ * \throw If the file is not readable.
+ * \throw If there is no mesh with given attributes in the file.
+ * \throw If the mesh in the file is of a not supported type.
+ */
+MEDFileJoint::MEDFileJoint(const std::string& fileName, const std::string& mName, int curJoint)
+{
+ MEDFileUtilities::CheckFileForRead(fileName);
+ MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
+ INTERP_KERNEL::AutoPtr<char> joint_name=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
+ INTERP_KERNEL::AutoPtr<char> desc_name=MEDLoaderBase::buildEmptyString(MED_COMMENT_SIZE);
+ INTERP_KERNEL::AutoPtr<char> rem_mesh_name=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
+ int domain_number=0, nstep=0, nocstpncorrespondence=0;
+ MEDsubdomainJointInfo(fid,mName.c_str(), curJoint, joint_name, desc_name, &domain_number,rem_mesh_name,
+ &nstep, &nocstpncorrespondence);
+ MEDFileJoint::setLocalMeshName(mName);
+ MEDFileJoint::setRemoteMeshName(MEDLoaderBase::buildStringFromFortran(rem_mesh_name,MED_NAME_SIZE));
+ MEDFileJoint::setDescription(MEDLoaderBase::buildStringFromFortran(desc_name,MED_COMMENT_SIZE));
+ MEDFileJoint::setJointName(MEDLoaderBase::buildStringFromFortran(joint_name,MED_NAME_SIZE));
+ MEDFileJoint::setDomainNumber(domain_number);
+ for(int cur_step=1; cur_step <= nstep; ++cur_step) {
+ MEDFileJointOneStep *cor=MEDFileJointOneStep::New(fileName, mName.c_str(), getJointName(), cur_step);
+ _joint.push_back(cor);
+ }
+}
+
+/*!
+ * Writes \a this joint into a MED file specified by its name.
+ * \param [in] fileName - the MED file name.
+ * \param [in] mode - the writing mode. For more on \a mode, see \ref AdvMEDLoaderBasics.
+ * - 2 - erase; an existing file is removed.
+ * - 1 - append; same data should not be present in an existing file.
+ * - 0 - overwrite; same data present in an existing file is overwritten.
+ * \throw If the mesh name is not set.
+ * \throw If \a mode == 1 and the same data is present in an existing file.
+ */
+void MEDFileJoint::write(const std::string& fileName, int mode) const
+{
+ med_access_mode medmod=MEDFileUtilities::TraduceWriteMode(mode);
+ MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),medmod);
+ std::ostringstream oss; oss << "MEDFileJoint : error on attempt to write in file : \"" << fileName << "\"";
+ MEDFileUtilities::CheckMEDCode(fid,fid,oss.str());
+ write(fid);
+}
+
+void MEDFileJoint::write(med_idt fid) const
+{
+ MEDsubdomainJointCr(fid,getLocalMeshName().c_str(),getJointName().c_str(),getDescription().c_str(),getDomainNumber(),getRemoteMeshName().c_str());
+ for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileJointOneStep> >::const_iterator it=_joint.begin();it!=_joint.end();it++) {
+ (*it)->writeLL(fid, getLocalMeshName(),getJointName());
+ }
+}
+
+void MEDFileJoint::pushStep(MEDFileJointOneStep* step)
+{
+ if(!step)
+ throw INTERP_KERNEL::Exception("MEDFileJoint::pushStep : invalid input pointer ! should be different from 0 !");
+ _joint.push_back(step);
+}
+
+/*!
+ * Checks if \a this and another mesh are equal.
+ * \param [in] other - the mesh to compare with.
+ * \param [in,out] what - the string returning description of unequal data.
+ * \return bool - \c true if the meshes are equal, \c false, else.
+ */
+bool MEDFileJoint::isEqual(const MEDFileJoint *other, std::string& what) const
+{
+ if(_loc_mesh_name!=other->_loc_mesh_name)
+ {
+ what="Local mesh names differ !";
+ return false;
+ }
+ if(_joint_name!=other->_joint_name)
+ {
+ what="Joint names differ !";
+ return false;
+ }
+ if(_desc_name!=other->_desc_name)
+ {
+ what="Description names differ !";
+ return false;
+ }
+ if(_rem_mesh_name!=other->_rem_mesh_name)
+ {
+ what="Remote mesh names differ !";
+ return false;
+ }
+ if(_domain_number!=other->_domain_number)
+ {
+ what="Domain numbers differ !";
+ return false;
+ }
+ return true;
+}
+
+MEDFileJoint *MEDFileJoint::deepCpy() const
+{
+ std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileJointOneStep> > joint(_joint.size());
+ std::size_t i=0;
+ for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileJointOneStep> >::const_iterator it=_joint.begin();it!=_joint.end();it++,i++)
+ if((const MEDFileJointOneStep *)*it)
+ joint[i]=(*it)->deepCpy();
+ MEDCouplingAutoRefCountObjectPtr<MEDFileJoint> ret=MEDFileJoint::New();
+ ret->_joint=joint;
+ return ret.retn();
+}
+
+MEDFileJoint *MEDFileJoint::shallowCpy() const
+{
+ MEDCouplingAutoRefCountObjectPtr<MEDFileJoint> ret=new MEDFileJoint(*this);
+ return ret.retn();
+}
+
+bool MEDFileJoint::changeJointNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
+{
+ for(std::vector< std::pair<std::string,std::string> >::const_iterator it=modifTab.begin();it!=modifTab.end();it++)
+ {
+ if((*it).first==_joint_name)
+ {
+ _joint_name=(*it).second;
+ return true;
+ }
+ }
+ return false;
+}
+
+/*!
+ * Returns a string describing \a this mesh. This description includes the correspondence and
+ * the number correspondence.
+ * \return std::string - the joint information string.
+ */
+std::string MEDFileJoint::simpleRepr() const
+{
+ std::ostringstream oss;
+ oss << "(*************************************)\n(* JOINT INFORMATION: *)\n(*************************************)\n";
+ oss << "- Local Mesh name : <<" << getLocalMeshName() << ">>\n";
+ oss << "- Remote Mesh name : <<" << getRemoteMeshName() << ">>\n";
+ oss << "- Description : <<" << getDescription() << ">>\n";
+ oss << "- Joint name : <<" << getJointName() << ">>\n";
+ oss << "- Domain number : <<" << getJointName() << ">>\n";
+ for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileJointOneStep> >::const_iterator it=_joint.begin();it!=_joint.end();it++) {
+ oss << (*it)->simpleRepr();
+ }
+ return oss.str();
+}
+
+MEDFileJoints *MEDFileJoints::New()
+{
+ return new MEDFileJoints;
+}
+
+MEDFileJoints *MEDFileJoints::New(const std::string& fileName)
+{
+ return new MEDFileJoints(fileName);
+}
+
+void MEDFileJoints::write(med_idt fid) const
+{
+ for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileJoint> >::const_iterator it=_joints.begin();it!=_joints.end();it++) {
+ (*it)->write(fid);
+ }
+}
+
+void MEDFileJoints::write(const std::string& fileName, int mode) const
+{
+ med_access_mode medmod=MEDFileUtilities::TraduceWriteMode(mode);
+ MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),medmod);
+ std::ostringstream oss; oss << "MEDFileJoints : error on attempt to write in file : \"" << fileName << "\"";
+ MEDFileUtilities::CheckMEDCode(fid,fid,oss.str());
+ write(fid);
+}
+
+int MEDFileJoints::getNumberOfJoints() const
+{
+ return _joints.size();
+}
+
+/** Return a borrowed reference (caller is not responsible) */
+MEDFileJoint *MEDFileJoints::getJointAtPos(int i) const
+{
+ const MEDFileJoint *ret;
+ if(i<0 || i>=(int)_joints.size())
+ {
+ std::ostringstream oss; oss << "MEDFileJoints::getMeshAtPos : invalid mesh id given in parameter ! Should be in [0;" << _joints.size() << ") !";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ int cur=0;
+ for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileJoint> >::const_iterator it=_joints.begin();it!=_joints.end();it++,cur++)
+ {
+ if (cur == i)
+ ret=(*it);
+ }
+ return const_cast<MEDFileJoint *>(ret);
+}
+
+
+/** Return a borrowed reference (caller is not responsible) */
+MEDFileJoint *MEDFileJoints::getJointWithName(const std::string& jname) const
+{
+ std::vector<std::string> js=getJointsNames();
+ std::vector<std::string>::iterator it=std::find(js.begin(),js.end(),jname);
+ if(it==js.end())
+ {
+ std::ostringstream oss; oss << "MEDFileJoints::getJointWithName : Joint \"" << jname << "\" does not exist in this ! Existing are : ";
+ std::copy(js.begin(),js.end(),std::ostream_iterator<std::string>(oss," "));
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ return getJointAtPos((int)std::distance(js.begin(),it));
+}
+
+std::vector<std::string> MEDFileJoints::getJointsNames() const
+{
+ std::vector<std::string> ret(_joints.size());
+ int i=0;
+ for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileJoint> >::const_iterator it=_joints.begin();it!=_joints.end();it++,i++)
+ {
+ const MEDFileJoint *f=(*it);
+ if(f)
+ {
+ ret[i]=f->getJointName();
+ }
+ else
+ {
+ std::ostringstream oss; oss << "MEDFileJoints::getJointsNames : At rank #" << i << " joint is not defined !";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ }
+ return ret;
+}
+
+bool MEDFileJoints::changeJointNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
+{
+ bool ret=false;
+ for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileJoint> >::iterator it=_joints.begin();it!=_joints.end();it++)
+ {
+ MEDFileJoint *cur(*it);
+ if(cur)
+ ret=cur->changeJointNames(modifTab) || ret;
+ }
+ return ret;
+}
+
+void MEDFileJoints::resize(int newSize)
+{
+ _joints.resize(newSize);
+}
+
+void MEDFileJoints::pushJoint(MEDFileJoint *joint)
+{
+ if(!joint)
+ throw INTERP_KERNEL::Exception("MEDFileJoints::pushJoint : invalid input pointer ! should be different from 0 !");
+ _joints.push_back(joint);
+}
+
+void MEDFileJoints::setJointAtPos(int i, MEDFileJoint *joint)
+{
+ if(!joint)
+ throw INTERP_KERNEL::Exception("MEDFileJoints::setJointAtPos : invalid input pointer ! should be different from 0 !");
+ if(i>=(int)_joints.size())
+ _joints.resize(i+1);
+ _joints[i]=joint;
+}
+
+void MEDFileJoints::destroyJointAtPos(int i)
+{
+ if(i<0 || i>=(int)_joints.size())
+ {
+ std::ostringstream oss; oss << "MEDFileJoints::destroyJointAtPos : Invalid given id in input (" << i << ") should be in [0," << _joints.size() << ") !";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ _joints.erase(_joints.begin()+i);
+}
+
+void MEDFileJoints::loadFromFile(const std::string& fileName)
+{
+ MEDFileUtilities::CheckFileForRead(fileName);
+ MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
+ std::vector<std::string> ms=MEDLoader::GetMeshNames(fileName);
+ for(std::vector<std::string>::const_iterator it=ms.begin();it!=ms.end();it++) {
+ int num_joint=MEDnSubdomainJoint(fid,(*it).c_str());
+ for(int i = 1; i <= num_joint; i++)
+ _joints.push_back(MEDFileJoint::New(fileName,(*it),i));
+ }
+}
+
+MEDFileJoints::MEDFileJoints()
+{
+}
+
+MEDFileJoints::MEDFileJoints(const std::string& fileName)
+try
+{
+ loadFromFile(fileName);
+}
+catch(INTERP_KERNEL::Exception& /*e*/)
+{
+}
+
+MEDFileJoints *MEDFileJoints::deepCpy() const
+{
+ std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileJoint> > joints(_joints.size());
+ std::size_t i=0;
+ for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileJoint> >::const_iterator it=_joints.begin();it!=_joints.end();it++,i++)
+ if((const MEDFileJoint *)*it)
+ joints[i]=(*it)->deepCpy();
+ MEDCouplingAutoRefCountObjectPtr<MEDFileJoints> ret=MEDFileJoints::New();
+ ret->_joints=joints;
+ return ret.retn();
+}
+
+std::size_t MEDFileJoints::getHeapMemorySizeWithoutChildren() const
+{
+ return _joints.capacity()*(sizeof(MEDCouplingAutoRefCountObjectPtr<MEDFileJoint>));
+}
+
+std::vector<const BigMemoryObject *> MEDFileJoints::getDirectChildrenWithNull() const
+{
+ std::vector<const BigMemoryObject *> ret;
+ for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileJoint> >::const_iterator it=_joints.begin();it!=_joints.end();it++)
+ ret.push_back((const MEDFileJoint *)*it);
+ return ret;
+}
+
+std::string MEDFileJoints::simpleRepr() const
+{
+ std::ostringstream oss;
+ oss << "(*****************)\n(* MEDFileJoints *)\n(*****************)\n\n";
+ simpleReprWithoutHeader(oss);
+ return oss.str();
+}
+
+void MEDFileJoints::simpleReprWithoutHeader(std::ostream& oss) const
+{
+ int nbOfJoints=getNumberOfJoints();
+ oss << "There are " << nbOfJoints << " joints with the following names : \n";
+ std::vector<std::string> jns=getJointsNames();
+ for(int i=0;i<nbOfJoints;i++)
+ oss << " - #" << i << " \"" << jns[i] << "\"\n";
+ for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileJoint> >::const_iterator it=_joints.begin();it!=_joints.end();it++) {
+ oss << (*it)->simpleRepr();
+ }
+}
--- /dev/null
+// Copyright (C) 2007-2015 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, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#ifndef __MEDFILEJOINT_HXX__
+#define __MEDFILEJOINT_HXX__
+
+#include "MEDLoaderDefines.hxx"
+#include "MEDFileUtilities.hxx"
+#include "MEDCouplingMemArray.hxx"
+#include "MEDCouplingAutoRefCountObjectPtr.hxx"
+
+namespace ParaMEDMEM
+{
+class MEDFileJointCorrespondence : public RefCountObject, public MEDFileWritable
+{
+public:
+ MEDLOADER_EXPORT static MEDFileJointCorrespondence *New();
+ MEDLOADER_EXPORT static MEDFileJointCorrespondence *New(TypeOfField loc_ent_type, INTERP_KERNEL::NormalizedCellType loc_geo_type,
+ TypeOfField rem_ent_type, INTERP_KERNEL::NormalizedCellType rem_geo_type,
+ DataArrayInt* correspondence);
+ MEDLOADER_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const;
+ MEDLOADER_EXPORT std::vector<const BigMemoryObject *> getDirectChildrenWithNull() const;
+ MEDLOADER_EXPORT MEDFileJointCorrespondence *deepCpy() const;
+ MEDLOADER_EXPORT MEDFileJointCorrespondence *shallowCpy() const;
+ MEDLOADER_EXPORT bool isEqual(const MEDFileJointCorrespondence *other, std::string& what) const;
+ MEDLOADER_EXPORT void setLocalEntityType(med_entity_type type) { _loc_ent_type=type; }
+ MEDLOADER_EXPORT med_entity_type getLocalEntityType() const { return _loc_ent_type; }
+ MEDLOADER_EXPORT void setRemoteEntityType(med_entity_type type) { _rem_ent_type=type; }
+ MEDLOADER_EXPORT med_entity_type getRemoteEntityType() const { return _rem_ent_type; }
+ MEDLOADER_EXPORT void setLocalGeometryType(med_geometry_type type) { _loc_geo_type=type; }
+ MEDLOADER_EXPORT med_geometry_type getLocalGeometryType() const { return _loc_geo_type; }
+ MEDLOADER_EXPORT void setRemoteGeometryType(med_geometry_type type) { _rem_geo_type=type; }
+ MEDLOADER_EXPORT med_geometry_type getRemoteGeometryType() const { return _rem_geo_type; }
+ MEDLOADER_EXPORT void setCorrespondence(DataArrayInt *corr);
+ MEDLOADER_EXPORT const DataArrayInt *getCorrespondence() const { return _correspondence; }
+ MEDLOADER_EXPORT void write(const std::string& fileName, int mode, const std::string& localMeshName, const std::string& jointName, int order, int iteration) const;
+
+ static med_entity_type ConvertIntoMEDFileType(TypeOfField ikType, INTERP_KERNEL::NormalizedCellType ikGeoType, med_geometry_type& medfGeoType);
+ MEDLOADER_EXPORT std::string simpleRepr() const;
+ MEDLOADER_EXPORT void writeLL(med_idt fid, const std::string& localMeshName, const std::string& jointName, int order, int iteration) const;
+private:
+ MEDFileJointCorrespondence();
+ MEDFileJointCorrespondence(TypeOfField loc_ent_type, INTERP_KERNEL::NormalizedCellType loc_geo_type,
+ TypeOfField rem_ent_type, INTERP_KERNEL::NormalizedCellType rem_geo_type,
+ DataArrayInt* correspondence);
+private:
+ med_entity_type _loc_ent_type;
+ med_entity_type _rem_ent_type;
+ med_geometry_type _loc_geo_type;
+ med_geometry_type _rem_geo_type;
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> _correspondence;
+};
+
+class MEDFileJointOneStep : public RefCountObject, public MEDFileWritable
+{
+public:
+ MEDLOADER_EXPORT static MEDFileJointOneStep *New();
+ MEDLOADER_EXPORT static MEDFileJointOneStep *New(const std::string& fileName, const std::string& mName, const std::string& jointName, int number);
+ MEDLOADER_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const;
+ MEDLOADER_EXPORT std::vector<const BigMemoryObject *> getDirectChildrenWithNull() const;
+ MEDLOADER_EXPORT MEDFileJointOneStep *deepCpy() const;
+ MEDLOADER_EXPORT MEDFileJointOneStep *shallowCpy() const;
+ MEDLOADER_EXPORT bool isEqual(const MEDFileJointOneStep *other, std::string& what) const;
+ MEDLOADER_EXPORT void setOrder(int order) { _order=order; }
+ MEDLOADER_EXPORT int getOrder() const { return _order; }
+ MEDLOADER_EXPORT void setIteration(int it) { _iteration=it; }
+ MEDLOADER_EXPORT int getIteration() const { return _iteration; }
+ MEDLOADER_EXPORT void pushCorrespondence(MEDFileJointCorrespondence* correspondence);
+
+ MEDLOADER_EXPORT void write(const std::string& fileName, int mode, const std::string& localMeshName, const std::string& jointName) const;
+
+ MEDLOADER_EXPORT std::string simpleRepr() const;
+ MEDLOADER_EXPORT void writeLL(med_idt fid, const std::string& localMeshName, const std::string& jointName) const;
+private:
+ MEDFileJointOneStep();
+ MEDFileJointOneStep(const std::string& fileName, const std::string& mName, const std::string& jointName, int number);
+protected:
+ int _order;
+ int _iteration;
+private:
+ std::vector<MEDCouplingAutoRefCountObjectPtr<MEDFileJointCorrespondence> > _correspondences;
+};
+ class MEDFileJoint : public RefCountObject, public MEDFileWritable
+ {
+ public:
+ MEDLOADER_EXPORT static MEDFileJoint *New();
+ MEDLOADER_EXPORT static MEDFileJoint *New(const std::string& fileName, const std::string& mName, int num);
+ MEDLOADER_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const;
+ MEDLOADER_EXPORT std::vector<const BigMemoryObject *> getDirectChildrenWithNull() const;
+ MEDLOADER_EXPORT MEDFileJoint *deepCpy() const;
+ MEDLOADER_EXPORT MEDFileJoint *shallowCpy() const;
+ MEDLOADER_EXPORT bool isEqual(const MEDFileJoint *other, std::string& what) const;
+ MEDLOADER_EXPORT void setLocalMeshName(const std::string& name) { _loc_mesh_name=name; }
+ MEDLOADER_EXPORT std::string getLocalMeshName() const { return _loc_mesh_name; }
+ MEDLOADER_EXPORT void setRemoteMeshName(const std::string& name) { _rem_mesh_name=name; }
+ MEDLOADER_EXPORT std::string getRemoteMeshName() const { return _rem_mesh_name; }
+ MEDLOADER_EXPORT void setDescription(const std::string& name) { _desc_name=name; }
+ MEDLOADER_EXPORT std::string getDescription() const { return _desc_name; }
+ MEDLOADER_EXPORT void setJointName(const std::string& name) { _joint_name=name; }
+ MEDLOADER_EXPORT std::string getJointName() const { return _joint_name; }
+ MEDLOADER_EXPORT bool changeJointNames(const std::vector< std::pair<std::string,std::string> >& modifTab);
+ MEDLOADER_EXPORT void setDomainNumber(const int& number) { _domain_number=number; }
+ MEDLOADER_EXPORT int getDomainNumber() const { return _domain_number; }
+ MEDLOADER_EXPORT void pushStep(MEDFileJointOneStep* step);
+
+ MEDLOADER_EXPORT void write(const std::string& fileName, int mode) const;
+ MEDLOADER_EXPORT void write(med_idt fid) const;
+
+ MEDLOADER_EXPORT std::string simpleRepr() const;
+ private:
+ MEDFileJoint();
+ MEDFileJoint(const std::string& fileName, const std::string& mName, int num);
+ private:
+ std::string _loc_mesh_name;
+ std::string _joint_name;
+ std::string _desc_name;
+ int _domain_number;
+ std::string _rem_mesh_name;
+ std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileJointOneStep> > _joint;
+ };
+
+ class MEDFileJoints : public RefCountObject, public MEDFileWritable
+ {
+ public:
+ MEDLOADER_EXPORT static MEDFileJoints *New();
+ MEDLOADER_EXPORT static MEDFileJoints *New(const std::string& fileName);
+ MEDLOADER_EXPORT MEDFileJoints *deepCpy() const;
+ MEDLOADER_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const;
+ MEDLOADER_EXPORT std::vector<const BigMemoryObject *> getDirectChildrenWithNull() const;
+ MEDLOADER_EXPORT std::string simpleRepr() const;
+ MEDLOADER_EXPORT void simpleReprWithoutHeader(std::ostream& oss) const;
+ MEDLOADER_EXPORT void write(const std::string& fileName, int mode) const;
+ MEDLOADER_EXPORT void write(med_idt fid) const;
+ MEDLOADER_EXPORT int getNumberOfJoints() const;
+ MEDLOADER_EXPORT MEDFileJoint *getJointAtPos(int i) const;
+ MEDLOADER_EXPORT MEDFileJoint *getJointWithName(const std::string& jname) const;
+ MEDLOADER_EXPORT std::vector<std::string> getJointsNames() const;
+ MEDLOADER_EXPORT bool changeJointNames(const std::vector< std::pair<std::string,std::string> >& modifTab);
+ //
+ MEDLOADER_EXPORT void resize(int newSize);
+ MEDLOADER_EXPORT void pushJoint(MEDFileJoint *joint);
+ MEDLOADER_EXPORT void setJointAtPos(int i, MEDFileJoint *joint);
+ MEDLOADER_EXPORT void destroyJointAtPos(int i);
+ private:
+ ~MEDFileJoints() { }
+ void loadFromFile(const std::string& fileName);
+ MEDFileJoints();
+ MEDFileJoints(const std::string& fileName);
+ private:
+ std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileJoint> > _joints;
+ };
+}
+
+#endif
dispatchLoadedPart(fid,loaderl2,mName,mrs);
}
+void MEDFileUMesh::setJoints(const std::string& fileName)
+{
+ _joints=MEDFileJoints::New(fileName);
+}
+
+void MEDFileUMesh::writeJoints(const std::string& fileName, int mode)
+{
+ _joints->write(fileName,mode);
+}
+
/*!
* This method loads \b all \b the \b mesh \a mName in the file with \a fid descriptor.
*
}
loaderl2.loadAll(fid,mid,mName,dt,it,mrs);
dispatchLoadedPart(fid,loaderl2,mName,mrs);
-
}
void MEDFileUMesh::dispatchLoadedPart(med_idt fid, const MEDFileUMeshL2& loaderl2, const std::string& mName, MEDFileMeshReadSelector *mrs)
}
return ret;
}
+/*const MEDFileJoints* MEDFileMeshes::getJoints() const
+{
+ const MEDFileJoints *ret=_joints;
+ if(!ret)
+ {
+ std::ostringstream oss; oss << "MEDFileMeshes::getJoints : joints is not defined !";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ return ret;
+}*/
bool MEDFileMeshes::changeNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
{
#include "MEDFileUtilities.hxx"
#include "MEDCouplingPartDefinition.hxx"
#include "MEDFileMeshReadSelector.hxx"
+#include "MEDFileJoint.hxx"
#include <map>
#include <list>
std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >& bigArraysI, MEDCouplingAutoRefCountObjectPtr<DataArrayDouble>& bigArrayD);
MEDLOADER_EXPORT void unserialize(std::vector<double>& tinyDouble, std::vector<int>& tinyInt, std::vector<std::string>& tinyStr,
std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >& bigArraysI, MEDCouplingAutoRefCountObjectPtr<DataArrayDouble>& bigArrayD);
+ MEDLOADER_EXPORT MEDFileJoints *getJoints() {return _joints;}
+ MEDLOADER_EXPORT void setJoints(const std::string& fileName);
+ MEDLOADER_EXPORT void writeJoints(const std::string& fileName, int mode);
private:
MEDLOADER_EXPORT ~MEDFileUMesh();
void writeLL(med_idt fid) const;
MEDCouplingAutoRefCountObjectPtr<DataArrayAsciiChar> _name_coords;
mutable MEDCouplingAutoRefCountObjectPtr<DataArrayInt> _rev_num_coords;
MEDCouplingAutoRefCountObjectPtr<PartDefinition> _part_coords;
+ MEDCouplingAutoRefCountObjectPtr<MEDFileJoints> _joints;
};
class MEDFileStructuredMesh : public MEDFileMesh
%{
#include "MEDLoader.hxx"
+#include "MEDFileJoint.hxx"
#include "MEDFileMesh.hxx"
#include "MEDFileField.hxx"
#include "MEDFileParameter.hxx"
%newobject ParaMEDMEM::MEDFileData::getMeshes;
%newobject ParaMEDMEM::MEDFileData::getFields;
%newobject ParaMEDMEM::MEDFileData::getParams;
+%newobject ParaMEDMEM::MEDFileData::getJoints;
%newobject ParaMEDMEM::MEDFileParameterDouble1TS::New;
%newobject ParaMEDMEM::MEDFileParameterDouble1TS::deepCpy;
%newobject ParaMEDMEM::MEDFileParameters::getParamWithName;
%newobject ParaMEDMEM::MEDFileParameters::__getitem__;
+%newobject ParaMEDMEM::MEDFileJointCorrespondence::New;
+%newobject ParaMEDMEM::MEDFileJointCorrespondence::deepCpy;
+%newobject ParaMEDMEM::MEDFileJointCorrespondence::shallowCpy;
+%newobject ParaMEDMEM::MEDFileJointOneStep::New;
+%newobject ParaMEDMEM::MEDFileJointOneStep::deepCpy;
+%newobject ParaMEDMEM::MEDFileJointOneStep::shallowCpy;
+%newobject ParaMEDMEM::MEDFileJoint::New;
+%newobject ParaMEDMEM::MEDFileJoint::deepCpy;
+%newobject ParaMEDMEM::MEDFileJoint::shallowCpy;
+%newobject ParaMEDMEM::MEDFileJoints::New;
+%newobject ParaMEDMEM::MEDFileJoints::deepCpy;
+%newobject ParaMEDMEM::MEDFileJoints::getJointAtPos;
+%newobject ParaMEDMEM::MEDFileJoints::getJointWithName;
+%newobject ParaMEDMEM::MEDFileJoints::__getitem__;
+
%newobject ParaMEDMEM::SauvWriter::New;
%newobject ParaMEDMEM::SauvReader::New;
%newobject ParaMEDMEM::SauvReader::loadInMEDFileDS;
%feature("unref") MEDFileParameterDouble1TS "$this->decrRef();"
%feature("unref") MEDFileParameterMultiTS "$this->decrRef();"
%feature("unref") MEDFileParameters "$this->decrRef();"
+%feature("unref") MEDFileJointCorrespondence "$this->decrRef();"
+%feature("unref") MEDFileJointOneStep "$this->decrRef();"
+%feature("unref") MEDFileJoint "$this->decrRef();"
+%feature("unref") MEDFileJoints "$this->decrRef();"
%feature("unref") MEDFileData "$this->decrRef();"
%feature("unref") SauvReader "$this->decrRef();"
%feature("unref") SauvWriter "$this->decrRef();"
}
}
};
+ class MEDFileJointCorrespondence : public RefCountObject, public MEDFileWritable
+ {
+ public:
+ static MEDFileJointCorrespondence *New() throw(INTERP_KERNEL::Exception);
+ static MEDFileJointCorrespondence *New(TypeOfField loc_ent_type, INTERP_KERNEL::NormalizedCellType loc_geo_type,
+ TypeOfField rem_ent_type, INTERP_KERNEL::NormalizedCellType rem_geo_type,
+ DataArrayInt* correspondence) throw(INTERP_KERNEL::Exception);
+ std::size_t getHeapMemorySizeWithoutChildren() const;
+ std::vector<const BigMemoryObject *> getDirectChildrenWithNull() const;
+ MEDFileJointCorrespondence *deepCpy() const;
+ MEDFileJointCorrespondence *shallowCpy() const;
+ void setLocalEntityType(med_entity_type type);
+ med_entity_type getLocalEntityType() const;
+ void setRemoteEntityType(med_entity_type type);
+ med_entity_type getRemoteEntityType() const;
+ void setLocalGeometryType(med_geometry_type type);
+ med_geometry_type getLocalGeometryType() const;
+ void setRemoteGeometryType(med_geometry_type type);
+ med_geometry_type getRemoteGeometryType() const;
+ void setCorrespondence(DataArrayInt *corr);
+ const DataArrayInt *getCorrespondence() const;
+ void write(const std::string& fileName, int mode, const std::string& localMeshName, const std::string& jointName, int order, int iteration) const;
+ std::string simpleRepr() const;
+ void writeLL(med_idt fid, const std::string& localMeshName, const std::string& jointName, int order, int iteration) const;
+ %extend
+ {
+ MEDFileJointCorrespondence()
+ {
+ return MEDFileJointCorrespondence::New();
+ }
+ MEDFileJointCorrespondence(TypeOfField loc_ent_type, INTERP_KERNEL::NormalizedCellType loc_geo_type,
+ TypeOfField rem_ent_type, INTERP_KERNEL::NormalizedCellType rem_geo_type,
+ DataArrayInt* correspondence) throw(INTERP_KERNEL::Exception)
+ {
+ return MEDFileJointCorrespondence::New(loc_ent_type, loc_geo_type, rem_ent_type, rem_geo_type, correspondence);
+ }
+
+ std::string __str__() const throw(INTERP_KERNEL::Exception)
+ {
+ return self->simpleRepr();
+ }
+
+ PyObject *isEqual(const MEDFileJointCorrespondence *other) const throw(INTERP_KERNEL::Exception)
+ {
+ std::string what;
+ bool ret0=self->isEqual(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;
+ }
+
+ }
+};
+
+ class MEDFileJointOneStep : public RefCountObject, public MEDFileWritable
+ {
+ public:
+ static MEDFileJointOneStep *New() throw(INTERP_KERNEL::Exception);
+ static MEDFileJointOneStep *New(const std::string& fileName, const std::string& mName, const std::string& jointName, int number) throw(INTERP_KERNEL::Exception);
+ std::size_t getHeapMemorySizeWithoutChildren() const;
+ std::vector<const BigMemoryObject *> getDirectChildrenWithNull() const;
+ MEDFileJointOneStep *deepCpy() const;
+ MEDFileJointOneStep *shallowCpy() const;
+ bool isEqual(const MEDFileJointOneStep *other, std::string& what) const;
+ void setOrder(int order);
+ int getOrder() const;
+ void setIteration(int it);
+ int getIteration() const;
+ void pushCorrespondence(MEDFileJointCorrespondence* correspondence);
+ void write(const std::string& fileName, int mode, const std::string& localMeshName, const std::string& jointName) const;
+ std::string simpleRepr() const;
+ void writeLL(med_idt fid, const std::string& localMeshName, const std::string& jointName) const;
+ %extend
+ {
+ MEDFileJointOneStep()
+ {
+ return MEDFileJointOneStep::New();
+ }
+
+ MEDFileJointOneStep(const std::string& fileName, const std::string& mName, const std::string& jointName, int number) throw(INTERP_KERNEL::Exception)
+ {
+ return MEDFileJointOneStep::New(fileName,mName,jointName,number);
+ }
+
+ std::string __str__() const throw(INTERP_KERNEL::Exception)
+ {
+ return self->simpleRepr();
+ }
+
+ PyObject *isEqual(const MEDFileJointOneStep *other) const throw(INTERP_KERNEL::Exception)
+ {
+ std::string what;
+ bool ret0=self->isEqual(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;
+ }
+ }
+ };
+ class MEDFileJoint : public RefCountObject, public MEDFileWritable
+ {
+ public:
+ static MEDFileJoint *New() throw(INTERP_KERNEL::Exception);
+ static MEDFileJoint *New(const std::string& fileName, const std::string& mName, int num) throw(INTERP_KERNEL::Exception);
+ std::size_t getHeapMemorySizeWithoutChildren() const;
+ std::vector<const BigMemoryObject *> getDirectChildrenWithNull() const;
+ MEDFileJoint *deepCpy() const;
+ MEDFileJoint *shallowCpy() const;
+ bool isEqual(const MEDFileJoint *other, std::string& what) const;
+ void setLocalMeshName(const std::string& name);
+ std::string getLocalMeshName() const;
+ void setRemoteMeshName(const std::string& name);
+ std::string getRemoteMeshName() const;
+ void setDescription(const std::string& name);
+ std::string getDescription() const;
+ void setJointName(const std::string& name);
+ std::string getJointName() const;
+ bool changeJointNames(const std::vector< std::pair<std::string,std::string> >& modifTab);
+ void setDomainNumber(const int& number);
+ int getDomainNumber() const;
+ void pushStep(MEDFileJointOneStep* step);
+ void write(const std::string& fileName, int mode) const;
+ void write(med_idt fid) const;
+ std::string simpleRepr() const;
+ %extend
+ {
+ MEDFileJoint()
+ {
+ return MEDFileJoint::New();
+ }
+
+ MEDFileJoint(const std::string& fileName, const std::string& mName, int num) throw(INTERP_KERNEL::Exception)
+ {
+ return MEDFileJoint::New(fileName,mName,num);
+ }
+
+ std::string __str__() const throw(INTERP_KERNEL::Exception)
+ {
+ return self->simpleRepr();
+ }
+
+ PyObject *isEqual(const MEDFileJoint *other) const throw(INTERP_KERNEL::Exception)
+ {
+ std::string what;
+ bool ret0=self->isEqual(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;
+ }
+ }
+ };
+
+ class MEDFileJoints : public RefCountObject, public MEDFileWritable
+ {
+ public:
+ static MEDFileJoints *New() throw(INTERP_KERNEL::Exception);
+ static MEDFileJoints *New(const std::string& fileName) throw(INTERP_KERNEL::Exception);
+ MEDFileJoints *deepCpy() const;
+ std::size_t getHeapMemorySizeWithoutChildren() const;
+ std::vector<const BigMemoryObject *> getDirectChildrenWithNull() const;
+ std::string simpleRepr() const;
+ void simpleReprWithoutHeader(std::ostream& oss) const;
+ void write(const std::string& fileName, int mode) const;
+ void write(med_idt fid) const;
+ int getNumberOfJoints() const;
+ std::vector<std::string> getJointsNames() const;
+ bool changeJointNames(const std::vector< std::pair<std::string,std::string> >& modifTab);
+ void resize(int newSize);
+ void pushJoint(MEDFileJoint *joint);
+ void setJointAtPos(int i, MEDFileJoint *joint);
+ void destroyJointAtPos(int i);
+ %extend
+ {
+ MEDFileJoints()
+ {
+ return MEDFileJoints::New();
+ }
+
+ MEDFileJoints(const std::string& fileName)
+ {
+ return MEDFileJoints::New(fileName);
+ }
+
+ std::string __str__() const throw(INTERP_KERNEL::Exception)
+ {
+ return self->simpleRepr();
+ }
+ MEDFileJoint *__getitem__(PyObject *obj) throw(INTERP_KERNEL::Exception)
+ {
+ if(PyInt_Check(obj))
+ {
+ MEDFileJoint *ret=self->getJointAtPos(InterpreteNegativeInt((int)PyInt_AS_LONG(obj),self->getNumberOfJoints()));
+ if(ret)
+ ret->incrRef();
+ return ret;
+ }
+ else if(PyString_Check(obj))
+ {
+ MEDFileJoint *ret=self->getJointWithName(PyString_AsString(obj));
+ if(ret)
+ ret->incrRef();
+ return ret;
+ }
+ else
+ throw INTERP_KERNEL::Exception("MEDFileJoints::__getitem__ : only integer or string with meshname supported !");
+ }
+
+ int __len__() const throw(INTERP_KERNEL::Exception)
+ {
+ return self->getNumberOfJoints();
+ }
+
+ MEDFileJoint *getJointAtPos(int i) const throw(INTERP_KERNEL::Exception)
+ {
+ MEDFileJoint *ret=self->getJointAtPos(i);
+ if(ret)
+ ret->incrRef();
+ return ret;
+ }
+
+ MEDFileJoint *getJointWithName(const std::string& paramName) const throw(INTERP_KERNEL::Exception)
+ {
+ MEDFileJoint *ret=self->getJointWithName(paramName);
+ if(ret)
+ ret->incrRef();
+ return ret;
+ }
+ }
+ };
class MEDFileMesh : public RefCountObject, public MEDFileWritable
{
public:
self.assertEqual(fs2[0].getTimeSteps(),[(i,0,float(i)) for i in xrange(nbPdt)])
pass
pass
+ def testMEDFileJoint1(self):
+ fileName="Pyfile88.med"
+ coo=DataArrayDouble([(0,0,0),(1,0,0),(2,0,0)])
+ coo.setInfoOnComponents(["x [cm]","y [cm]","z [cm]"])
+ mm=MEDFileUMesh()
+ mm.setCoords(coo)
+ mm.setName("maa1")
+ mm.setDescription("un maillage")
+ mm.write(fileName,2)
+ first_correspond=MEDFileJointCorrespondence(ON_NODES,NORM_MAXTYPE,ON_NODES,NORM_MAXTYPE,DataArrayInt([1,2,3,4,5,6,7,8]))
+ second_correspond=MEDFileJointCorrespondence(ON_CELLS,NORM_MAXTYPE,ON_CELLS,NORM_MAXTYPE,DataArrayInt([9,10,11,12]))
+ one_step_joint=MEDFileJointOneStep()
+ one_joint=MEDFileJoint()
+ one_step_joint.pushCorrespondence(first_correspond)
+ one_step_joint.pushCorrespondence(second_correspond)
+ one_joint.pushStep(one_step_joint)
+ one_joint.setLocalMeshName("maa1")
+ one_joint.setRemoteMeshName("maa1")
+ one_joint.setDescription("joint_description")
+ one_joint.setJointName("joint_1")
+ one_joint.setDomainNumber(1)
+ joints=MEDFileJoints(fileName)
+ joints.pushJoint(one_joint);
+ joints.write(fileName,0)
+ #
+ pass
+ def testMEDFileJoint2(self):
+ fileNameRd="Pyfile88.med"
+ fileNameWr="Pyfile89.med"
+ coo=DataArrayDouble([(0,0,0),(1,0,0),(2,0,0)])
+ coo.setInfoOnComponents(["x [cm]","y [cm]","z [cm]"])
+ mm=MEDFileUMesh()
+ mm.setCoords(coo)
+ mm.setName("maa1")
+ mm.setDescription("un maillage")
+ mm.write(fileNameWr,2)
+ joints=MEDFileJoints(fileNameRd)
+ joints.destroyJointAtPos(0)
+ first_correspond=MEDFileJointCorrespondence(ON_NODES,NORM_MAXTYPE,ON_NODES,NORM_MAXTYPE,DataArrayInt([13,14,15,16]))
+ second_correspond=MEDFileJointCorrespondence(ON_CELLS,NORM_MAXTYPE,ON_CELLS,NORM_MAXTYPE,DataArrayInt([17,18]))
+ one_step_joint=MEDFileJointOneStep()
+ two_step_joint=MEDFileJointOneStep()
+ one_joint=MEDFileJoint()
+ two_joint=MEDFileJoint()
+ one_step_joint.pushCorrespondence(first_correspond)
+ one_joint.pushStep(one_step_joint)
+ two_step_joint.pushCorrespondence(first_correspond)
+ two_step_joint.pushCorrespondence(second_correspond)
+ two_joint.pushStep(two_step_joint)
+ one_joint.setLocalMeshName("maa1")
+ one_joint.setRemoteMeshName("maa1")
+ one_joint.setDescription("joint_description_1")
+ one_joint.setJointName("joint_1")
+ one_joint.setDomainNumber(1)
+ two_joint.setLocalMeshName("maa1")
+ two_joint.setRemoteMeshName("maa1")
+ two_joint.setDescription("joint_description_2")
+ two_joint.setJointName("joint_2")
+ two_joint.setDomainNumber(2)
+ joints.pushJoint(one_joint)
+ joints.pushJoint(two_joint)
+ joints.write(fileNameWr,0)
+ #
+ #mm=MEDFileMesh.New(fileNameWr)
+ #self.assertEqual(mm.getName(),"maa1")
+ pass
+ def testMEDFileJoint3(self):
+ fileNameRd="splitted_blade1.med"
+ fileNameWr="Pyfile90.med"
+ coo=DataArrayDouble([(0,0,0),(1,0,0),(2,0,0)])
+ coo.setInfoOnComponents(["x [cm]","y [cm]","z [cm]"])
+ mm=MEDFileUMesh()
+ mm.setCoords(coo)
+ mm.setName("Fuse_1_1")
+ mm.setDescription("un maillage")
+ mm.write(fileNameWr,2)
+ joints=MEDFileJoints(fileNameRd)
+ joints.write(fileNameWr,0)
+ #mm=MEDFileMesh.New(fileNameWr)
+ #self.assertEqual(mm.getName(),"maa1")
+ pass
unittest.main()
MEDPARTITIONER_ConnectZone.hxx
MEDPARTITIONER_SkyLineArray.hxx
MEDPARTITIONER_Topology.hxx
+ MEDPARTITIONER_MEDPartitioner.hxx
)
SET(medpartitionercpp_SOURCES
MEDPARTITIONER_ConnectZone.cxx
MEDPARTITIONER_SkyLineArray.cxx
MEDPARTITIONER_metis.c
+ MEDPARTITIONER_MEDPartitioner.cxx
)
SET(medpartitionercpp_LDFLAGS
--- /dev/null
+// Copyright (C) 2007-2015 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, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#include "MEDPARTITIONER_MEDPartitioner.hxx"
+#include "MEDPARTITIONER_MeshCollection.hxx"
+#include "MEDPARTITIONER_Topology.hxx"
+#include "MEDPARTITIONER_ParaDomainSelector.hxx"
+#include "MEDPARTITIONER_ParallelTopology.hxx"
+#include "MEDPARTITIONER_Utils.hxx"
+#include "MEDPARTITIONER_Graph.hxx"
+#include "MEDPARTITIONER_MetisGraph.hxx"
+#include "MEDPARTITIONER_ScotchGraph.hxx"
+#include "MEDCouplingUMesh.hxx"
+
+#include <iostream>
+#include <vector>
+
+MEDPARTITIONER::MEDPartitioner *MEDPARTITIONER::MEDPartitioner::New(const std::string& filename, int ndomains, const std::string& library,bool creates_boundary_faces, bool create_joints, bool mesure_memory)
+{
+ return new MEDPartitioner(filename,ndomains,library,creates_boundary_faces, create_joints, mesure_memory);
+}
+
+MEDPARTITIONER::MEDPartitioner *MEDPARTITIONER::MEDPartitioner::New(const ParaMEDMEM::MEDFileData* filedata, int ndomains, const std::string& library,bool creates_boundary_faces, bool create_joints, bool mesure_memory)
+{
+ return new MEDPartitioner(filedata,ndomains,library,creates_boundary_faces, create_joints, mesure_memory);
+}
+
+MEDPARTITIONER::MEDPartitioner::MEDPartitioner(const std::string& filename, int ndomains, const std::string& library,bool creates_boundary_faces, bool create_joints, bool mesure_memory)
+{
+ ParaDomainSelector parallelizer(mesure_memory);
+ _input_collection=new MeshCollection(filename,parallelizer);
+ parallelizer.evaluateMemory();
+ createPartitionCollection(ndomains, library, creates_boundary_faces, create_joints, mesure_memory);
+}
+
+MEDPARTITIONER::MEDPartitioner::MEDPartitioner(const ParaMEDMEM::MEDFileData* filedata, int ndomains, const std::string& library,bool creates_boundary_faces, bool create_joints, bool mesure_memory)
+{
+ _input_collection=new MeshCollection();
+ for (int i=0; i<filedata->getMeshes()->getNumberOfMeshes(); i++)
+ {
+ ParaMEDMEM::MEDFileUMesh *mfm = dynamic_cast<ParaMEDMEM::MEDFileUMesh *>(filedata->getMeshes()->getMeshAtPos(i));
+ std::vector<int> nonEmpty=mfm->getNonEmptyLevels();
+ try
+ {
+ (_input_collection->getMesh()).push_back(mfm->getLevel0Mesh(false));
+ //reading families groups
+ ParaMEDMEM::DataArrayInt* cellIds(mfm->getFamilyFieldAtLevel(0)->deepCpy());
+ (_input_collection->getCellFamilyIds()).push_back(cellIds);
+ }
+ catch(...)
+ {
+ (_input_collection->getMesh()).push_back(CreateEmptyMEDCouplingUMesh()); // or 0 if you want tests;
+ ParaMEDMEM::DataArrayInt* empty=ParaMEDMEM::DataArrayInt::New();
+ empty->alloc(0,1);
+ (_input_collection->getCellFamilyIds()).push_back(empty);
+ }
+ try
+ {
+ if (nonEmpty.size()>1 && nonEmpty[1]==-1)
+ {
+ (_input_collection->getFaceMesh()).push_back(mfm->getLevelM1Mesh(false));
+ //reading families groups
+ ParaMEDMEM::DataArrayInt* faceIds(mfm->getFamilyFieldAtLevel(-1)->deepCpy());
+ (_input_collection->getFaceFamilyIds()).push_back(faceIds);
+ }
+ else
+ {
+ throw INTERP_KERNEL::Exception("no faces");
+ }
+ }
+ catch(...)
+ {
+ (_input_collection->getFaceMesh()).push_back(CreateEmptyMEDCouplingUMesh()); // or 0 if you want test;
+ ParaMEDMEM::DataArrayInt* empty=ParaMEDMEM::DataArrayInt::New();
+ (_input_collection->getFaceFamilyIds()).push_back(empty);
+ }
+ //reading groups
+ _input_collection->getFamilyInfo()=mfm->getFamilyInfo();
+ _input_collection->getGroupInfo()=mfm->getGroupInfo();
+ mfm->decrRef();
+ }
+ std::vector<int*> cellglobal;
+ std::vector<int*> nodeglobal;
+ std::vector<int*> faceglobal;
+ int size = (_input_collection->getMesh()).size();
+ cellglobal.resize(size);
+ nodeglobal.resize(size);
+ faceglobal.resize(size);
+
+ for ( int idomain = 0; idomain < size; ++idomain )
+ {
+ cellglobal[idomain]=0;
+ faceglobal[idomain]=0;
+ nodeglobal[idomain]=0;
+ if ( (_input_collection->getMesh())[idomain] && (_input_collection->getMesh())[idomain]->getNumberOfNodes() > 0 )
+ _input_collection->setNonEmptyMesh(idomain);
+ }
+
+ ParallelTopology* aPT = new ParallelTopology((_input_collection->getMesh()), (_input_collection->getCZ()), cellglobal, nodeglobal, faceglobal);
+ _input_collection->setTopology(aPT);
+
+ createPartitionCollection(ndomains, library, creates_boundary_faces, create_joints, mesure_memory);
+}
+
+void MEDPARTITIONER::MEDPartitioner::createPartitionCollection(int ndomains, const std::string& library,bool creates_boundary_faces, bool create_joints, bool mesure_memory)
+{
+ ParallelTopology* aPT = (ParallelTopology*) _input_collection->getTopology();
+ std::auto_ptr< Topology > new_topo;
+ if (library == "metis")
+ new_topo.reset( _input_collection->createPartition(ndomains,MEDPARTITIONER::Graph::METIS));
+ else
+ new_topo.reset(_input_collection->createPartition(ndomains,MEDPARTITIONER::Graph::SCOTCH));
+ _output_collection=new MeshCollection(*_input_collection,new_topo.get(),false,false);
+}
+
+void MEDPARTITIONER::MEDPartitioner::Write(const std::string& filename)
+{
+ _output_collection->write(filename);
+}
+
+ParaMEDMEM::MEDFileData* MEDPARTITIONER::MEDPartitioner::getMEDFileData()
+{
+ return convertToMEDFileData(_output_collection);
+}
+
+ParaMEDMEM::MEDFileData* MEDPARTITIONER::MEDPartitioner::convertToMEDFileData(MeshCollection* collection)
+{
+ ParaMEDMEM::MEDFileData* newdata=ParaMEDMEM::MEDFileData::New();
+ for (int i=0; i<(collection->getMesh()).size(); i++)
+ {
+ ParaMEDMEM::MEDFileUMesh *mfm = ParaMEDMEM::MEDFileUMesh::New();
+ mfm->setMeshAtLevel(0,(collection->getMesh())[i]);
+ mfm->setMeshAtLevel(-1,(collection->getFaceMesh())[i]);
+ mfm->setFamilyFieldArr(0,(collection->getCellFamilyIds())[i]);
+ mfm->setFamilyFieldArr(-1,(collection->getFaceFamilyIds())[i]);
+ mfm->setFamilyInfo(collection->getFamilyInfo());
+ mfm->setGroupInfo(collection->getGroupInfo());
+ }
+ return newdata;
+}
+
+MEDPARTITIONER::Graph* MEDPARTITIONER::MEDPartitioner::Graph(ParaMEDMEM::MEDCouplingSkyLineArray* graph, Graph::splitter_type split, int* edgeweight)
+{
+ MEDPARTITIONER::SkyLineArray* r=0;
+ MEDPARTITIONER::Graph* cellGraph = 0;
+ switch (split)
+ {
+ case Graph::METIS:
+ if ( !cellGraph )
+ {
+ #ifdef MED_ENABLE_METIS
+ cellGraph=new METISGraph(r,edgeweight);
+ #endif
+ }
+ if ( !cellGraph )
+ throw INTERP_KERNEL::Exception("MeshCollection::createPartition : PARMETIS/METIS is not available. Check your products, please.");
+ break;
+ case Graph::SCOTCH:
+ #ifdef MED_ENABLE_SCOTCH
+ cellGraph=new SCOTCHGraph(r,edgeweight);
+ #else
+ throw INTERP_KERNEL::Exception("MeshCollection::createPartition : SCOTCH is not available. Check your products, please.");
+ #endif
+ break;
+ }
+ return cellGraph;
+
+}
--- /dev/null
+// Copyright (C) 2007-2015 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, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#ifndef __MEDPARTITIONER_MEDPARTITIONER_HXX__
+#define __MEDPARTITIONER_MEDPARTITIONER_HXX__
+
+#include "MEDFileData.hxx"
+#include "MEDCouplingSkyLineArray.hxx"
+#include "MEDPARTITIONER_Graph.hxx"
+
+#include <map>
+#include <vector>
+
+namespace ParaMEDMEM
+{
+ class DataArrayInt;
+ class MEDFileData;
+}
+
+namespace MEDPARTITIONER
+{
+ class Topology;
+ class MeshCollection;
+ class ParaDomainSelector;
+ class Graph;
+
+ class MEDPartitioner
+ {
+ public:
+ static MEDPartitioner *New(const std::string& filename, int ndomains=1, const std::string& library="metis",bool creates_boundary_faces=false, bool create_joints=false, bool mesure_memory=false);
+ static MEDPartitioner *New(const ParaMEDMEM::MEDFileData* filedata, int ndomains=1, const std::string& library="metis",bool creates_boundary_faces=false, bool create_joints=false, bool mesure_memory=false);
+ void Write(const std::string& filename);
+ ParaMEDMEM::MEDFileData* getMEDFileData();
+ MEDPARTITIONER::Graph* Graph(ParaMEDMEM::MEDCouplingSkyLineArray* graph, Graph::splitter_type split, int* edgeweight=0);
+ private:
+ MEDPartitioner(const std::string& filename, int ndomains, const std::string& library,bool creates_boundary_faces, bool create_joints, bool mesure_memory);
+ MEDPartitioner(const ParaMEDMEM::MEDFileData* filedata, int ndomains, const std::string& library,bool creates_boundary_faces, bool create_joints, bool mesure_memory);
+ ParaMEDMEM::MEDFileData *convertToMEDFileData(MeshCollection* meshcollection);
+ void createPartitionCollection(int ndomains, const std::string& library,bool creates_boundary_faces, bool create_joints, bool mesure_memory);
+ MeshCollection* _input_collection;
+ MeshCollection* _output_collection;
+ };
+}
+#endif
buildParallelCellGraph(array,edgeweights);
else
buildCellGraph(array,edgeweights);
-
+
Graph* cellGraph = 0;
switch (split)
{
void setName(const std::string& name) { _name=name; }
void setDomainNames(const std::string& name);
+ void setNonEmptyMesh(int number) { _i_non_empty_mesh=number;}
+
//getting/setting the description of the global mesh
std::string getDescription() const { return _description; }
void setDescription(const std::string& name) { _description=name; }
#include "MEDCouplingFieldDouble.hxx"
#include "MEDLoader.hxx"
#include "MEDFileMesh.hxx"
+#include "MEDFileJoint.hxx"
#include <map>
#include <set>
MyGlobals::_File_Names[0]=std::string(filename);
ParaMEDMEM::MEDFileUMesh* mfm=ParaMEDMEM::MEDFileUMesh::New(filename,meshname);
+ mfm->setJoints(std::string(filename));
//puts the only mesh in the mesh vector
(_collection->getMesh()).push_back(mfm->getLevel0Mesh(false));
(_collection->getFaceMesh()).push_back(mfm->getLevelM1Mesh(false));
//reading groups
_collection->getFamilyInfo()=mfm->getFamilyInfo();
_collection->getGroupInfo()=mfm->getGroupInfo();
-
mfm->decrRef();
std::vector<std::string> localInformation;
ParaMEDMEM::MEDFileUMesh* mfm=ParaMEDMEM::MEDFileUMesh::New(file,meshname);
std::vector<int> nonEmpty=mfm->getNonEmptyLevels();
-
try
{
(_collection->getMesh())[idomain]=mfm->getLevel0Mesh(false);
// boundaryMesh->decrRef();
// }
ParaMEDMEM::MEDFileUMesh* mfm=ParaMEDMEM::MEDFileUMesh::New(distfilename, _collection->getMesh(idomain)->getName());
-
+ if (MyGlobals::_Create_Joints) {
+ mfm->setJoints( MyGlobals::_File_Names[0]);
+ mfm->writeJoints(distfilename,0);
+ }
mfm->setFamilyInfo(_collection->getFamilyInfo());
mfm->setGroupInfo(_collection->getGroupInfo());
_nb_domain=nb_domain;
_mesh_dimension=mesh_dimension;
-
+
if (MyGlobals::_Verbose>200)
std::cout << "proc " << MyGlobals::_Rank << " : new topology oldNbDomain " <<
oldTopology->nbDomain() << " newNbDomain " << _nb_domain << std::endl;
int MEDPARTITIONER::MyGlobals::_Randomize=0;
int MEDPARTITIONER::MyGlobals::_Atomize=0;
int MEDPARTITIONER::MyGlobals::_Creates_Boundary_Faces=0;
+int MEDPARTITIONER::MyGlobals::_Create_Joints=0;
std::vector<std::string> MEDPARTITIONER::MyGlobals::_File_Names;
std::vector<std::string> MEDPARTITIONER::MyGlobals::_Mesh_Names;
std::vector<std::string> MEDPARTITIONER::MyGlobals::_Field_Descriptions;
static int _Randomize;
static int _Atomize;
static int _Creates_Boundary_Faces;
+ static int _Create_Joints;
static int _Is0verbose; //trace cout if rank 0 and verbose
static std::vector<std::string> _File_Names; //on [iold]
static std::vector<std::string> _Mesh_Names; //on [iold]
MyGlobals::_World_Size=1;
MyGlobals::_Rank=0;
MyGlobals::_Creates_Boundary_Faces=0;
+ MyGlobals::_Create_Joints=0;
// Primitive parsing of command-line options
string desc ("Available options of medpartitioner V1.0:\n"
"\t--split-method=<string> : name of the splitting library (metis/scotch), default is metis\n"
#endif
"\t--creates-boundary-faces : creates boundary faces mesh in the output files\n"
+ "\t--creates-joints : creates joints in the output files\n"
"\t--dump-cpu-memory : dumps passed CPU time and maximal increase of used memory\n"
);
else if (TestArg(argv[i],"--split-method",value)) library=value;
else if (TestArg(argv[i],"--ndomains",value)) ndomains=atoi(value.c_str());
else if (TestArg(argv[i],"--creates-boundary-faces",value)) MyGlobals::_Creates_Boundary_Faces=1;
+ else if (TestArg(argv[i],"--create-joints",value)) MyGlobals::_Create_Joints=1;
else if (TestArg(argv[i],"--dump-cpu-memory",value)) mesure_memory=true;
else
{
cout << " split-method = " << library << endl;
cout << " ndomains = " << ndomains << endl;
cout << " creates_boundary_faces = " << MyGlobals::_Creates_Boundary_Faces << endl;
+ cout << " create-joints = " << MyGlobals::_Create_Joints<< endl;
cout << " dump-cpu-memory = " << mesure_memory<< endl;
cout << " verbose = " << MyGlobals::_Verbose << endl;
}
--- /dev/null
+# Copyright (C) 2012-2015 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, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+#
+
+INCLUDE(${SWIG_USE_FILE})
+
+ADD_DEFINITIONS(${PYTHON_DEFINITIONS})
+
+SET_SOURCE_FILES_PROPERTIES(MEDPartitioner.i PROPERTIES CPLUSPLUS ON)
+SET_SOURCE_FILES_PROPERTIES(MEDPartitioner.i PROPERTIES SWIG_DEFINITIONS "-shadow")
+SET(SWIG_MODULE_MEDPartitioner_EXTRA_FLAGS "${SWIG_EXTRA_FLAGS_FOR_NUMPYANDSCIPY};-DWITHOUT_AUTOFIELD")
+
+SET (MEDPartitioner_SWIG_DPYS_FILES
+ MEDPartitionerCommon.i)
+
+INCLUDE_DIRECTORIES(
+ ${PYTHON_INCLUDE_DIRS}
+ ${PTHREAD_INCLUDE_DIR} # pthread dependancy due to python2.7 library
+ ${CMAKE_CURRENT_SOURCE_DIR}
+ ${CMAKE_CURRENT_BINARY_DIR}
+ ${MEDFILE_INCLUDE_DIRS}
+ ${CMAKE_CURRENT_SOURCE_DIR}/../MEDPartitioner
+ ${CMAKE_CURRENT_SOURCE_DIR}/../MEDCoupling_Swig
+ ${CMAKE_CURRENT_SOURCE_DIR}/../MEDCoupling
+ ${CMAKE_CURRENT_SOURCE_DIR}/../MEDLoader
+ ${CMAKE_CURRENT_SOURCE_DIR}/../MEDLoader/Swig
+ ${CMAKE_CURRENT_SOURCE_DIR}/../INTERP_KERNEL
+ ${CMAKE_CURRENT_SOURCE_DIR}/../INTERP_KERNEL/Bases
+ ${CMAKE_CURRENT_SOURCE_DIR}/../INTERP_KERNEL/Geometric2D
+ ${CMAKE_CURRENT_SOURCE_DIR}/../INTERP_KERNEL/ExprEval
+ ${CMAKE_CURRENT_SOURCE_DIR}/../INTERP_KERNEL/GaussPoints
+ )
+
+SWIG_ADD_MODULE(MEDPartitioner python MEDPartitioner.i)
+SWIG_LINK_LIBRARIES(MEDPartitioner ${PYTHON_LIBRARIES} ${PLATFORM_LIBS} medpartitionercpp)
+
+IF(WIN32)
+ SET_TARGET_PROPERTIES(_MEDPartitioner PROPERTIES DEBUG_OUTPUT_NAME _MEDPartitioner_d)
+ENDIF(WIN32)
+INSTALL(TARGETS ${SWIG_MODULE_MEDPartitioner_REAL_NAME} DESTINATION ${SALOME_INSTALL_PYTHON})
+
+SET(PYFILES_TO_INSTALL ${CMAKE_CURRENT_BINARY_DIR}/MEDPartitioner.py)
+INSTALL_AND_COMPILE_PYTHON_FILE("${PYFILES_TO_INSTALL}" ${SALOME_INSTALL_SCRIPT_PYTHON})
+
+INSTALL(FILES MEDPartitioner.i MEDPartitionerCommon.i DESTINATION ${SALOME_INSTALL_HEADERS})
+INSTALL(FILES MEDPartitionerTest.py DESTINATION ${SALOME_INSTALL_SCRIPT_PYTHON})
+
+SALOME_GENERATE_TESTS_ENVIRONMENT(tests_env)
+ADD_TEST(MEDPartitionerTest ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/MEDPartitionerTest.py)
+SET_TESTS_PROPERTIES(MEDPartitionerTest PROPERTIES ENVIRONMENT "${tests_env}")
+
+# Application tests
+
+SET(TEST_INSTALL_DIRECTORY ${SALOME_INSTALL_SCRIPT_SCRIPTS}/test/MEDCoupling/MEDPartitioner_Swig)
+INSTALL(FILES MEDPartitionerTest.py DESTINATION ${TEST_INSTALL_DIRECTORY})
+
+INSTALL(FILES CTestTestfileInstall.cmake
+ DESTINATION ${TEST_INSTALL_DIRECTORY}
+ RENAME CTestTestfile.cmake)
+
+
--- /dev/null
+# Copyright (C) 2015 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, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+#
+
+ADD_TEST(MEDPartitionerTest python MEDPartitionerTest.py)
+SET_TESTS_PROPERTIES(MEDPartitionerTest PROPERTIES LABELS "${COMPONENT_NAME}")
--- /dev/null
+// Copyright (C) 2007-2015 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, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+%include "MEDPartitionerCommon.i"
+
+
+%pythoncode %{
+def ParaMEDMEMDataArrayDoublenew(cls,*args):
+ import _MEDPartitioner
+ return _MEDPartitioner.DataArrayDouble____new___(cls,args)
+def ParaMEDMEMDataArrayDoubleIadd(self,*args):
+ import _MEDPartitioner
+ return _MEDPartitioner.DataArrayDouble____iadd___(self, self, *args)
+def ParaMEDMEMDataArrayDoubleIsub(self,*args):
+ import _MEDPartitioner
+ return _MEDPartitioner.DataArrayDouble____isub___(self, self, *args)
+def ParaMEDMEMDataArrayDoubleImul(self,*args):
+ import _MEDPartitioner
+ return _MEDPartitioner.DataArrayDouble____imul___(self, self, *args)
+def ParaMEDMEMDataArrayDoubleIdiv(self,*args):
+ import _MEDPartitioner
+ return _MEDPartitioner.DataArrayDouble____idiv___(self, self, *args)
+def ParaMEDMEMDataArrayDoubleIpow(self,*args):
+ import _MEDPartitioner
+ return _MEDPartitioner.DataArrayDouble____ipow___(self, self, *args)
+def ParaMEDMEMDataArrayIntnew(cls,*args):
+ import _MEDPartitioner
+ return _MEDPartitioner.DataArrayInt____new___(cls,args)
+def ParaMEDMEMDataArrayIntIadd(self,*args):
+ import _MEDPartitioner
+ return _MEDPartitioner.DataArrayInt____iadd___(self, self, *args)
+def ParaMEDMEMDataArrayIntIsub(self,*args):
+ import _MEDPartitioner
+ return _MEDPartitioner.DataArrayInt____isub___(self, self, *args)
+def ParaMEDMEMDataArrayIntImul(self,*args):
+ import _MEDPartitioner
+ return _MEDPartitioner.DataArrayInt____imul___(self, self, *args)
+def ParaMEDMEMDataArrayIntIdiv(self,*args):
+ import _MEDPartitioner
+ return _MEDPartitioner.DataArrayInt____idiv___(self, self, *args)
+def ParaMEDMEMDataArrayIntImod(self,*args):
+ import _MEDPartitioner
+ return _MEDPartitioner.DataArrayInt____imod___(self, self, *args)
+def ParaMEDMEMDataArrayIntIpow(self,*args):
+ import _MEDPartitioner
+ return _MEDPartitioner.DataArrayInt____ipow___(self, self, *args)
+def ParaMEDMEMDataArrayDoubleTupleIadd(self,*args):
+ import _MEDPartitioner
+ return _MEDPartitioner.DataArrayDoubleTuple____iadd___(self, self, *args)
+def ParaMEDMEMDataArrayDoubleTupleIsub(self,*args):
+ import _MEDPartitioner
+ return _MEDPartitioner.DataArrayDoubleTuple____isub___(self, self, *args)
+def ParaMEDMEMDataArrayDoubleTupleImul(self,*args):
+ import _MEDPartitioner
+ return _MEDPartitioner.DataArrayDoubleTuple____imul___(self, self, *args)
+def ParaMEDMEMDataArrayDoubleTupleIdiv(self,*args):
+ import _MEDPartitioner
+ return _MEDPartitioner.DataArrayDoubleTuple____idiv___(self, self, *args)
+def ParaMEDMEMDataArrayIntTupleIadd(self,*args):
+ import _MEDPartitioner
+ return _MEDPartitioner.DataArrayIntTuple____iadd___(self, self, *args)
+def ParaMEDMEMDataArrayIntTupleIsub(self,*args):
+ import _MEDPartitioner
+ return _MEDPartitioner.DataArrayIntTuple____isub___(self, self, *args)
+def ParaMEDMEMDataArrayIntTupleImul(self,*args):
+ import _MEDPartitioner
+ return _MEDPartitioner.DataArrayIntTuple____imul___(self, self, *args)
+def ParaMEDMEMDataArrayIntTupleIdiv(self,*args):
+ import _MEDPartitioner
+ return _MEDPartitioner.DataArrayIntTuple____idiv___(self, self, *args)
+def ParaMEDMEMDataArrayIntTupleImod(self,*args):
+ import _MEDPartitioner
+ return _MEDPartitioner.DataArrayIntTuple____imod___(self, self, *args)
+%}
+
+
+%pythoncode %{
+DataArrayDouble.__new__=classmethod(ParaMEDMEMDataArrayDoublenew)
+DataArrayDouble.__iadd__=ParaMEDMEMDataArrayDoubleIadd
+DataArrayDouble.__isub__=ParaMEDMEMDataArrayDoubleIsub
+DataArrayDouble.__imul__=ParaMEDMEMDataArrayDoubleImul
+DataArrayDouble.__idiv__=ParaMEDMEMDataArrayDoubleIdiv
+DataArrayDouble.__ipow__=ParaMEDMEMDataArrayDoubleIpow
+
+DataArrayInt.__new__=classmethod(ParaMEDMEMDataArrayIntnew)
+DataArrayInt.__iadd__=ParaMEDMEMDataArrayIntIadd
+DataArrayInt.__isub__=ParaMEDMEMDataArrayIntIsub
+DataArrayInt.__imul__=ParaMEDMEMDataArrayIntImul
+DataArrayInt.__idiv__=ParaMEDMEMDataArrayIntIdiv
+DataArrayInt.__imod__=ParaMEDMEMDataArrayIntImod
+DataArrayInt.__ipow__=ParaMEDMEMDataArrayIntIpow
+
+DataArrayDoubleTuple.__iadd__=ParaMEDMEMDataArrayDoubleTupleIadd
+DataArrayDoubleTuple.__isub__=ParaMEDMEMDataArrayDoubleTupleIsub
+DataArrayDoubleTuple.__imul__=ParaMEDMEMDataArrayDoubleTupleImul
+DataArrayDoubleTuple.__idiv__=ParaMEDMEMDataArrayDoubleTupleIdiv
+
+DataArrayIntTuple.__iadd__=ParaMEDMEMDataArrayIntTupleIadd
+DataArrayIntTuple.__isub__=ParaMEDMEMDataArrayIntTupleIsub
+DataArrayIntTuple.__imul__=ParaMEDMEMDataArrayIntTupleImul
+DataArrayIntTuple.__idiv__=ParaMEDMEMDataArrayIntTupleIdiv
+DataArrayIntTuple.__imod__=ParaMEDMEMDataArrayIntTupleImod
+
+del ParaMEDMEMDataArrayDoublenew
+del ParaMEDMEMDataArrayDoubleIadd
+del ParaMEDMEMDataArrayDoubleIsub
+del ParaMEDMEMDataArrayDoubleImul
+del ParaMEDMEMDataArrayDoubleIdiv
+del ParaMEDMEMDataArrayIntnew
+del ParaMEDMEMDataArrayIntIadd
+del ParaMEDMEMDataArrayIntIsub
+del ParaMEDMEMDataArrayIntImul
+del ParaMEDMEMDataArrayIntIdiv
+del ParaMEDMEMDataArrayIntImod
+del ParaMEDMEMDataArrayDoubleTupleIadd
+del ParaMEDMEMDataArrayDoubleTupleIsub
+del ParaMEDMEMDataArrayDoubleTupleImul
+del ParaMEDMEMDataArrayDoubleTupleIdiv
+del ParaMEDMEMDataArrayIntTupleIadd
+del ParaMEDMEMDataArrayIntTupleIsub
+del ParaMEDMEMDataArrayIntTupleImul
+del ParaMEDMEMDataArrayIntTupleIdiv
+del ParaMEDMEMDataArrayIntTupleImod
+%}
--- /dev/null
+// Copyright (C) 2007-2015 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, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+%module MEDPartitioner
+
+%include std_vector.i
+%include std_string.i
+
+%{
+#include "MEDCouplingAutoRefCountObjectPtr.hxx"
+#include "MEDCouplingMemArray.hxx"
+#include "MEDCouplingDataArrayTypemaps.i"
+#include "MEDCouplingSkyLineArray.hxx"
+
+#include "MEDFileData.hxx"
+
+#include "MEDPARTITIONER_MEDPartitioner.hxx"
+
+#include "MEDPARTITIONER_Graph.hxx"
+
+using namespace ParaMEDMEM;
+using namespace INTERP_KERNEL;
+using namespace MEDPARTITIONER;
+%}
+
+%template(ivec) std::vector<int>;
+%template(dvec) std::vector<double>;
+%template(svec) std::vector<std::string>;
+
+#ifdef WITH_NUMPY
+%init %{ import_array(); %}
+#endif
+
+%feature("autodoc", "1");
+%feature("docstring");
+
+%nodefaultctor;
+
+%newobject MEDPARTITIONER::MEDPartitioner::New;
+
+%rename (InterpKernelException) INTERP_KERNEL::Exception;
+
+%include "MEDCouplingRefCountObject.i"
+%include "MEDCouplingMemArray.i"
+
+class MEDPartitioner
+{
+public:
+ static MEDPartitioner *New(const std::string& filename, int ndomains=1, const std::string& library="metis",bool creates_boundary_faces=false, bool create_joints=false, bool mesure_memory=false) throw(INTERP_KERNEL::Exception);
+ static MEDPartitioner *New(const ParaMEDMEM::MEDFileData* filedata, int ndomains=1, const std::string& library="metis",bool creates_boundary_faces=false, bool create_joints=false, bool mesure_memory=false) throw(INTERP_KERNEL::Exception);
+ void Write(const std::string& filename) throw(INTERP_KERNEL::Exception);
+ ParaMEDMEM::MEDFileData* getMEDFileData() throw(INTERP_KERNEL::Exception);
+ MEDPARTITIONER::Graph* Graph(ParaMEDMEM::MEDCouplingSkyLineArray* graph, Graph::splitter_type split, int* edgeweight=0) throw(INTERP_KERNEL::Exception);
+ %extend
+ {
+ MEDPartitioner(const std::string& filename, int ndomains=1, const std::string& library="metis",bool creates_boundary_faces=false, bool create_joints=false, bool mesure_memory=false) throw(INTERP_KERNEL::Exception)
+ {
+ return MEDPartitioner::New(filename,ndomains,library,creates_boundary_faces, create_joints, mesure_memory);
+ }
+ MEDPartitioner(const ParaMEDMEM::MEDFileData* fileData, int ndomains=1, const std::string& library="metis",bool creates_boundary_faces=false, bool create_joints=false, bool mesure_memory=false) throw(INTERP_KERNEL::Exception)
+ {
+ return MEDPartitioner::New(fileData,ndomains,library,creates_boundary_faces, create_joints, mesure_memory);
+ }
+ }
+};
\ No newline at end of file
--- /dev/null
+# Copyright (C) 2012-2015 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, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+#
+
+from MEDPartitioner import *
+from MEDLoader import *
+import unittest
+
+class MEDPartitionerTest(unittest.TestCase):
+
+# @unittest.skipUnless("BOOST" in RenumberAvailableMethods
+#(),"requires BOOST prerequisite !")
+ def test1(self):
+ from MEDCoupling import MEDCouplingCMesh
+ #ren=RenumberingFactory("BOOST")
+ arr=DataArrayDouble(100) ; arr.iota()
+ c=MEDCouplingCMesh() ; c.setCoords(arr,arr)
+ m=c.buildUnstructured()
+ d=MEDFileData.New("/dn20/salome/imn/SALOME7YA/MED_BUILD/src/MEDLoader/Swig/splitted_blade1.med")
+ #mfd1 = MEDFileData.New()
+ p=MEDPartitioner.New(d,2);
+ #p=MEDPartitioner.New("/dn20/salome/imn/SALOME7YA/MED_BUILD/src/MEDLoader/Swig/splitted_blade1.med");
+ #part=MEDPartitioner.Graph(m.generateGraph())
+ #part.partGraph(2)
+ #a=part.getGraph()
+ #n2o,o2n=ren.renumber(a,b)
+ pass
+
+unittest.main()