// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
-#include "MEDPARTITIONER_ParallelTopology.hxx"
#include "MEDPARTITIONER_MeshCollectionDriver.hxx"
+
+#include "MEDPARTITIONER_ConnectZone.hxx"
#include "MEDPARTITIONER_MeshCollection.hxx"
#include "MEDPARTITIONER_ParaDomainSelector.hxx"
+#include "MEDPARTITIONER_ParallelTopology.hxx"
#include "MEDPARTITIONER_Utils.hxx"
-#include "MEDCouplingUMesh.hxx"
#include "MEDCouplingFieldDouble.hxx"
-#include "MEDLoader.hxx"
-#include "MEDFileMesh.hxx"
+#include "MEDCouplingRefCountObject.hxx"
+#include "MEDCouplingUMesh.hxx"
+#include "MEDFileField.hxx"
#include "MEDFileJoint.hxx"
+#include "MEDFileMesh.hxx"
+#include "MEDLoader.hxx"
#include <map>
#include <set>
if (localFields.size()>0)
MyGlobals::_Field_Descriptions.push_back(SerializeFromVectorOfString(localFields));
}
-std::vector<const ParaMEDMEM::MEDCouplingUMesh*> MeshCollectionDriver::getMeshes(int idomain) const
+
+ParaMEDMEM::MEDFileMesh* MeshCollectionDriver::getMesh(int idomain) const
{
- std::vector<const ParaMEDMEM::MEDCouplingUMesh*> meshes;
+ ParaMEDMEM::MEDFileUMesh* mfm = ParaMEDMEM::MEDFileUMesh::New();
+
ParaMEDMEM::MEDCouplingUMesh* cellMesh=_collection->getMesh(idomain);
ParaMEDMEM::MEDCouplingUMesh* faceMesh=_collection->getFaceMesh(idomain);
std::string finalMeshName=ExtractFromDescription(MyGlobals::_General_Informations[0], "finalMeshName=");
// if (faceMeshFilter!=0)
// faceMeshFilter->decrRef();
cellMesh->setName(finalMeshName);
- meshes.push_back(cellMesh);
+ mfm->setMeshAtLevel( 0, cellMesh );
faceMesh->checkCoherency();
if (faceMesh->getNumberOfCells()>0)
{
faceMesh->tryToShareSameCoordsPermute(*cellMesh, 1e-10);
- meshes.push_back(faceMesh);
+ mfm->setMeshAtLevel( -1, cellMesh );
}
+
// ParaMEDMEM::MEDCouplingUMesh* boundaryMesh=0;
// if (MyGlobals::_Creates_Boundary_Faces>0)
// {
// MEDLoader::WriteUMesh(distfilename, boundaryMesh, false);
// boundaryMesh->decrRef();
// }
- return meshes;
-}
-void MeshCollectionDriver::setFileUMesh(ParaMEDMEM::MEDFileUMesh* mfm,int size, int idomain) const
-{
+
mfm->setFamilyInfo(_collection->getFamilyInfo());
mfm->setGroupInfo(_collection->getGroupInfo());
std::string key=Cle1ToStr("faceFamily_toArray",idomain);
- if ( size == 2 &&
- _collection->getMapDataArrayInt().find(key)!=_collection->getMapDataArrayInt().end())
+ if ( _collection->getMapDataArrayInt().find(key)!=_collection->getMapDataArrayInt().end())
{
ParaMEDMEM::DataArrayInt *fam=_collection->getMapDataArrayInt().find(key)->second;
mfm->setFamilyFieldArr(-1,fam);
key=Cle1ToStr("cellFamily_toArray",idomain);
if (_collection->getMapDataArrayInt().find(key)!=_collection->getMapDataArrayInt().end())
mfm->setFamilyFieldArr(0,_collection->getMapDataArrayInt().find(key)->second);
+
+ // add joints
+
+ using ParaMEDMEM::MEDCouplingAutoRefCountObjectPtr;
+ using ParaMEDMEM::MEDCouplingSkyLineArray;
+ using ParaMEDMEM::MEDFileJoint;
+ using ParaMEDMEM::MEDFileJointCorrespondence;
+ using ParaMEDMEM::MEDFileJointOneStep;
+ using ParaMEDMEM::MEDFileJoints;
+ using ParaMEDMEM::MEDFileJoints;
+
+ if ( _collection->getCZ().size() > 0 )
+ {
+ MEDCouplingAutoRefCountObjectPtr< MEDFileJoints > joints = MEDFileJoints::New();
+
+ for ( size_t i = 0; i < _collection->getCZ().size(); ++i )
+ {
+ ConnectZone* cz = _collection->getCZ()[i];
+ if ( !cz ) continue;
+
+ MEDCouplingAutoRefCountObjectPtr< MEDFileJoint>
+ joint = MEDFileJoint::New( cz->getName(), finalMeshName,
+ finalMeshName, cz->getDistantDomainNumber() );
+ joint->setDescription( cz->getDescription() );
+ joints->pushJoint( joint );
+
+ MEDCouplingAutoRefCountObjectPtr< MEDFileJointOneStep> j1st = MEDFileJointOneStep::New();
+ joint->pushStep( j1st );
+
+ const MEDCouplingSkyLineArray * nodeCorr = cz->getNodeCorresp();
+ if ( nodeCorr )
+ {
+ MEDCouplingAutoRefCountObjectPtr< MEDFileJointCorrespondence >
+ corr = MEDFileJointCorrespondence::New( nodeCorr->getValueArray() );
+ j1st->pushCorrespondence( corr );
+ }
+
+ std::vector< std::pair< int,int > > types = cz->getEntities();
+ INTERP_KERNEL::NormalizedCellType t1, t2;
+ for ( size_t it = 0; it < types.size(); ++it )
+ {
+ const MEDCouplingSkyLineArray * cellCorr =
+ cz->getEntityCorresp( types[it].first, types[it].second );
+ if ( cellCorr )
+ {
+ t1 = INTERP_KERNEL::NormalizedCellType( types[it].first );
+ t2 = INTERP_KERNEL::NormalizedCellType( types[it].second );
+ MEDCouplingAutoRefCountObjectPtr< MEDFileJointCorrespondence>
+ corr = MEDFileJointCorrespondence::New( cellCorr->getValueArray(), t1, t2 );
+ j1st->pushCorrespondence( corr );
+ }
+ }
+ }
+ mfm->setJoints( joints );
+ }
}
-ParaMEDMEM::MEDCouplingFieldDouble* MeshCollectionDriver::getField(std::string key, std::string description, ParaMEDMEM::DataArrayDouble* data, ParaMEDMEM::MEDFileUMesh* mfm, int idomain) const
+
+ParaMEDMEM::MEDCouplingFieldDouble* MeshCollectionDriver::getField(std::string key, std::string description, ParaMEDMEM::DataArrayDouble* data, ParaMEDMEM::MEDFileMesh* mfm, int idomain) const
{
std::string desc=description;
if (MyGlobals::_Verbose>20)
if (field && typeData==6)
{
field->setName(fieldName);
- field->setMesh(mfm->getLevel0Mesh(false));
+ field->setMesh(mfm->getGenMeshAtLevel(0));
ParaMEDMEM::DataArrayDouble *da=data;
//get information for components etc..
std::vector<std::string> r1;
}
return field;
}
+
void MeshCollectionDriver::writeMedFile(int idomain, const std::string& distfilename) const
{
- std::vector<const ParaMEDMEM::MEDCouplingUMesh*> meshes;
- meshes=getMeshes(idomain);
- MEDLoader::WriteUMeshes(distfilename, meshes, true);
-
- ParaMEDMEM::MEDFileUMesh* mfm=ParaMEDMEM::MEDFileUMesh::New(distfilename, _collection->getMesh(idomain)->getName());
- setFileUMesh(mfm,meshes.size(),idomain);
-
+ ParaMEDMEM::MEDFileMesh* mfm = getMesh( idomain );
mfm->write(distfilename,0);
+
std::string key="/inewFieldDouble="+IntToStr(idomain)+"/";
std::map<std::string,ParaMEDMEM::DataArrayDouble*>::iterator it;
int nbfFieldFound=0;
size_t found=(*it).first.find(key);
if (found==std::string::npos)
continue;
- ParaMEDMEM::MEDCouplingFieldDouble* field=0;
- field=getField(key, (*it).first, (*it).second, mfm, idomain);
- nbfFieldFound++;
+ ParaMEDMEM::MEDCouplingFieldDouble* field=0;
+ field = getField(key, (*it).first, (*it).second, mfm, idomain);
+ nbfFieldFound++;
try
{
MEDLoader::WriteField(distfilename,field,false);
ParaMEDMEM::MEDFileData* MeshCollectionDriver::getMEDFileData()
{
- ParaMEDMEM::MEDFileData* newdata=ParaMEDMEM::MEDFileData::New();
- ParaMEDMEM::MEDFileMeshes* meshes(ParaMEDMEM::MEDFileMeshes::New());
- ParaMEDMEM::MEDFileFields* fields(ParaMEDMEM::MEDFileFields::New());
+ ParaMEDMEM::MEDFileData* newdata = ParaMEDMEM::MEDFileData::New();
+ ParaMEDMEM::MEDFileMeshes* meshes = ParaMEDMEM::MEDFileMeshes::New();
+ ParaMEDMEM::MEDFileFields* fields = ParaMEDMEM::MEDFileFields::New();
for (int i=0; i<(_collection->getMesh()).size(); i++)
- {
- ParaMEDMEM::MEDFileUMesh* m(ParaMEDMEM::MEDFileUMesh::New());
- m->setMeshes(getMeshes(i),true);
- meshes->pushMesh(m);
- ParaMEDMEM::MEDFileUMesh *mfm = ParaMEDMEM::MEDFileUMesh::New();
- setFileUMesh(mfm,(_collection->getMesh()).size(),i);
- meshes->pushMesh(mfm);
- std::string key="/inewFieldDouble="+IntToStr(i)+"/";
- std::map<std::string,ParaMEDMEM::DataArrayDouble*>::iterator it;
- ParaMEDMEM::MEDFileAnyTypeFieldMultiTS* fieldsMTS;
- for (it=_collection->getMapDataArrayDouble().begin() ; it!=_collection->getMapDataArrayDouble().end(); it++)
{
- size_t found=(*it).first.find(key);
- if (found==std::string::npos)
- continue;
+ ParaMEDMEM::MEDFileMesh* mfm = getMesh( i );
+ meshes->pushMesh(mfm);
+
+ std::string key="/inewFieldDouble="+IntToStr(i)+"/";
+ std::map<std::string,ParaMEDMEM::DataArrayDouble*>::iterator it;
+ ParaMEDMEM::MEDFileFieldMultiTS* fieldsMTS = ParaMEDMEM::MEDFileFieldMultiTS::New();
+ for (it=_collection->getMapDataArrayDouble().begin() ; it!=_collection->getMapDataArrayDouble().end(); it++)
+ {
+ size_t found=(*it).first.find(key);
+ if (found==std::string::npos)
+ continue;
ParaMEDMEM::MEDCouplingFieldDouble* field=0;
field=getField(key, (*it).first, (*it).second, mfm, i);
- ParaMEDMEM::MEDFileField1TS* f1ts(ParaMEDMEM::MEDFileField1TS::New());
- f1ts->setFieldNoProfileSBT(field);
- fieldsMTS->pushBackTimeStep(f1ts);
+ ParaMEDMEM::MEDFileField1TS* f1ts = ParaMEDMEM::MEDFileField1TS::New();
+ f1ts->setFieldNoProfileSBT(field);
+ fieldsMTS->pushBackTimeStep(f1ts);
+
+ field->decrRef();
+ f1ts->decrRef();
+ }
+ fields->pushField(fieldsMTS);
+
+ fieldsMTS->decrRef();
+ mfm->decrRef();
}
- fields->pushField(fieldsMTS);
- mfm->decrRef();
- }
newdata->setMeshes(meshes);
newdata->setFields(fields);
return newdata;