mirror of
https://git.salome-platform.org/gitpub/modules/smesh.git
synced 2024-12-25 17:00:34 +05:00
reading constant size map
This commit is contained in:
parent
af459b337c
commit
b099bfe29f
@ -730,16 +730,16 @@ std::string MgAdapt::getCommandToRun()
|
|||||||
cmd+= " --in "+ meshIn;
|
cmd+= " --in "+ meshIn;
|
||||||
meshFormatOutputMesh = getFileName()+".mesh";
|
meshFormatOutputMesh = getFileName()+".mesh";
|
||||||
cmd+= " --out "+ meshFormatOutputMesh;
|
cmd+= " --out "+ meshFormatOutputMesh;
|
||||||
if (useLocalMap) cmd+= " --sizemap "+ solFileIn;
|
if (useLocalMap || useConstantValue) cmd+= " --sizemap "+ solFileIn;
|
||||||
else if (useBackgroundMap)
|
else // (useBackgroundMap)
|
||||||
{
|
{
|
||||||
cmd+= " --background_mesh "+ sizeMapIn ;
|
cmd+= " --background_mesh "+ sizeMapIn ;
|
||||||
cmd+= " --background_sizemap "+ solFileIn;
|
cmd+= " --background_sizemap "+ solFileIn;
|
||||||
}
|
}
|
||||||
else
|
//~else
|
||||||
{
|
//~{
|
||||||
// constant value TODO
|
//~// constant value TODO
|
||||||
}
|
//~}
|
||||||
|
|
||||||
if (verbosityLevel != defaultVerboseLevel())
|
if (verbosityLevel != defaultVerboseLevel())
|
||||||
{
|
{
|
||||||
@ -1048,25 +1048,7 @@ void MgAdapt::convertMedFile(std::string& meshFormatMeshFileName, std::string& s
|
|||||||
|
|
||||||
meshFormatsizeMapFile = getFileName();
|
meshFormatsizeMapFile = getFileName();
|
||||||
meshFormatsizeMapFile += ".mesh";
|
meshFormatsizeMapFile += ".mesh";
|
||||||
MEDCoupling::MCAuto<MEDCoupling::MEDFileData> tmpMfd = MEDCoupling::MEDFileData::New(sizeMapFile);
|
buildBackGroundMeshAndSolFiles(fieldFileNames, meshFormatsizeMapFile);
|
||||||
MEDCoupling::MEDFileFields* tmpFields = tmpMfd->getFields();
|
|
||||||
MEDCoupling::MEDFileAnyTypeFieldMultiTS* fts = tmpFields->getFieldWithName(fieldName);
|
|
||||||
MEDCoupling::MCAuto<MEDCoupling::MEDFileFieldMultiTS> fts1 = dynamic_cast<MEDCoupling::MEDFileFieldMultiTS *>(fts);
|
|
||||||
MEDCoupling::MCAuto<MEDCoupling::MEDFileAnyTypeField1TS> f = fts1->getTimeStep(timeStep, rank);
|
|
||||||
MEDCoupling::MCAuto<MEDCoupling::MEDFileFieldMultiTS> tmFts = MEDCoupling::MEDFileFieldMultiTS::New();
|
|
||||||
tmFts->pushBackTimeStep(f);
|
|
||||||
|
|
||||||
MEDCoupling::MCAuto<MEDCoupling::MEDFileFields> tmp_fields = MEDCoupling::MEDFileFields::New();
|
|
||||||
tmp_fields->pushField(tmFts);
|
|
||||||
|
|
||||||
|
|
||||||
tmpMfd->setFields( tmp_fields );
|
|
||||||
MeshFormatWriter tmpWriter;
|
|
||||||
tmpWriter.setMeshFileName(meshFormatsizeMapFile);
|
|
||||||
tmpWriter.setFieldFileNames( fieldFileNames);
|
|
||||||
tmpWriter.setMEDFileDS(tmpMfd);
|
|
||||||
tmpWriter.write();
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
else if(useLocalMap)
|
else if(useLocalMap)
|
||||||
@ -1084,19 +1066,12 @@ void MgAdapt::convertMedFile(std::string& meshFormatMeshFileName, std::string& s
|
|||||||
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
MEDCoupling::MEDCouplingMesh* mesh = fileMesh->getMeshAtLevel(1); // nodes mesh
|
MEDCoupling::MCAuto<MEDCoupling::MEDCouplingMesh> mesh = fileMesh->getMeshAtLevel(1); // nodes mesh
|
||||||
MEDCoupling::MEDCouplingFieldDouble* fieldOnNodes=MEDCoupling::MEDCouplingFieldDouble::New(MEDCoupling::ON_NODES,MEDCoupling::NO_TIME);
|
MEDCoupling::MCAuto<MEDCoupling::MEDCouplingUMesh> umesh = mesh->buildUnstructured(); // nodes mesh
|
||||||
fieldOnNodes->setName("MyScalarFieldOnNodeNoTime");
|
int dim = umesh->getSpaceDimension();
|
||||||
fieldOnNodes->setMesh(mesh);
|
int version = sizeof(double) < 8 ? 1 : 2;
|
||||||
mesh->decrRef(); // no more need of mesh because mesh has been attached to fieldOnNodes
|
mcIdType nbNodes = umesh->getNumberOfNodes();
|
||||||
MEDCoupling::DataArrayDouble *array=MEDCoupling::DataArrayDouble::New();
|
buildConstantSizeMapSolFile(solFormatFieldFileName, dim, version, nbNodes);
|
||||||
array->alloc(fieldOnNodes->getMesh()->getNumberOfNodes(),1);//Implicitly fieldOnNodes will be a 1 component field.
|
|
||||||
array->fillWithValue(constantValue);
|
|
||||||
fieldOnNodes->setArray(array);
|
|
||||||
array->decrRef();
|
|
||||||
// fieldOnNodes is now usable
|
|
||||||
// ...
|
|
||||||
// fieldOnNodes is no more useful h
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1200,6 +1175,43 @@ void MgAdapt::restoreGroups(MEDCoupling::MEDFileMesh* fileMesh) const
|
|||||||
|
|
||||||
fileMesh->setGroupInfo(info);
|
fileMesh->setGroupInfo(info);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MgAdapt::buildConstantSizeMapSolFile(const std::string& solFormatFieldFileName, const int dim, const int version, const mcIdType nbNodes) const
|
||||||
|
{
|
||||||
|
MeshFormat::Localizer loc;
|
||||||
|
MeshFormat::MeshFormatParser writer;
|
||||||
|
int fileId = writer.GmfOpenMesh( solFormatFieldFileName.c_str(), GmfWrite, version, dim);
|
||||||
|
int typTab[] = {GmfSca};
|
||||||
|
writer.GmfSetKwd(fileId, MeshFormat::GmfSolAtVertices, (int)nbNodes, 1, typTab);
|
||||||
|
for (mcIdType i = 0; i<nbNodes; i++)
|
||||||
|
{
|
||||||
|
double valTab[1] = {constantValue};
|
||||||
|
writer.GmfSetLin( fileId, MeshFormat::GmfSolAtVertices, valTab);
|
||||||
|
}
|
||||||
|
writer.GmfCloseMesh(fileId);
|
||||||
|
}
|
||||||
|
|
||||||
|
void MgAdapt::buildBackGroundMeshAndSolFiles(const std::vector<std::string>& fieldFileNames, const std::string& meshFormatsizeMapFile) const
|
||||||
|
{
|
||||||
|
MEDCoupling::MCAuto<MEDCoupling::MEDFileData> tmpMfd = MEDCoupling::MEDFileData::New(sizeMapFile);
|
||||||
|
MEDCoupling::MEDFileFields* tmpFields = tmpMfd->getFields();
|
||||||
|
MEDCoupling::MEDFileAnyTypeFieldMultiTS* fts = tmpFields->getFieldWithName(fieldName);
|
||||||
|
MEDCoupling::MCAuto<MEDCoupling::MEDFileFieldMultiTS> fts1 = dynamic_cast<MEDCoupling::MEDFileFieldMultiTS *>(fts);
|
||||||
|
MEDCoupling::MCAuto<MEDCoupling::MEDFileAnyTypeField1TS> f = fts1->getTimeStep(timeStep, rank);
|
||||||
|
MEDCoupling::MCAuto<MEDCoupling::MEDFileFieldMultiTS> tmFts = MEDCoupling::MEDFileFieldMultiTS::New();
|
||||||
|
tmFts->pushBackTimeStep(f);
|
||||||
|
|
||||||
|
MEDCoupling::MCAuto<MEDCoupling::MEDFileFields> tmp_fields = MEDCoupling::MEDFileFields::New();
|
||||||
|
tmp_fields->pushField(tmFts);
|
||||||
|
|
||||||
|
|
||||||
|
tmpMfd->setFields( tmp_fields );
|
||||||
|
MeshFormatWriter tmpWriter;
|
||||||
|
tmpWriter.setMeshFileName(meshFormatsizeMapFile);
|
||||||
|
tmpWriter.setFieldFileNames( fieldFileNames);
|
||||||
|
tmpWriter.setMEDFileDS(tmpMfd);
|
||||||
|
tmpWriter.write();
|
||||||
|
}
|
||||||
// =======================================================================
|
// =======================================================================
|
||||||
med_idt MgAdapt::openMedFile(const std::string aFile)
|
med_idt MgAdapt::openMedFile(const std::string aFile)
|
||||||
// =======================================================================
|
// =======================================================================
|
||||||
|
@ -318,6 +318,8 @@ private :
|
|||||||
void storeGroupsAndFams(MEDCoupling::MEDFileMesh* fileMesh);
|
void storeGroupsAndFams(MEDCoupling::MEDFileMesh* fileMesh);
|
||||||
void restoreGroupsAndFams(MEDCoupling::MEDFileMesh* fileMesh) const;
|
void restoreGroupsAndFams(MEDCoupling::MEDFileMesh* fileMesh) const;
|
||||||
void convertMeshFile(std::string& meshFormatIn, std::vector< std::string>& solFieldFileNames) const ;
|
void convertMeshFile(std::string& meshFormatIn, std::vector< std::string>& solFieldFileNames) const ;
|
||||||
|
void buildConstantSizeMapSolFile(const std::string& solFormatFieldFileName, const int dim, const int version, const mcIdType nbNodes) const;
|
||||||
|
void buildBackGroundMeshAndSolFiles(const std::vector<std::string>& fieldFileNames, const std::string& meshFormatsizeMapFile) const;
|
||||||
void getTimeStepInfos(std::string aFile, med_int& numdt, med_int& numit);
|
void getTimeStepInfos(std::string aFile, med_int& numdt, med_int& numit);
|
||||||
Status addMessage(const std::string& msg, const bool isFatal = false);
|
Status addMessage(const std::string& msg, const bool isFatal = false);
|
||||||
med_idt openMedFile(const std::string aFile) ;
|
med_idt openMedFile(const std::string aFile) ;
|
||||||
|
Loading…
Reference in New Issue
Block a user