MCAuto<MEDFileUMeshPerTypeCommon> md(zeStr->getMeshDef());
const DataArrayInt *ff0(md->getFam());
if(ff0)
- {
- MCAuto<DataArrayInt> ff0o(ff0->duplicateEachTupleNTimes(nbCells));
- mOut->setFamilyFieldArr(0,ff0o);
- }
+ mOut->setFamilyFieldArr(0,const_cast<DataArrayInt *>(ff0));
const DataArrayInt *nf0(md->getNum());
if(nf0)
- {
- MCAuto<DataArrayInt> nf0o(ff0->duplicateEachTupleNTimes(nbCells));
- mOut->setRenumFieldArr(0,nf0o);
- }
+ mOut->setRenumFieldArr(0,const_cast<DataArrayInt *>(nf0));
mOut->copyFamGrpMapsFrom(*mesh);
const std::vector< MCAuto<DataArray> >& vars(zeStr->getVars());
for(std::vector< MCAuto<DataArray> >::const_iterator it=vars.begin();it!=vars.end();it++)
* \param [in] varAtt - fields containing var att of current structure element. WARNING at this stage the number of iteration are equal to one for each field in \a varAtt
* \param [out] zeOutputs - ze fields that are the concatenation of fields in \a fs transformed and those in \a varAtt normalized in time space
*/
-void MEDFileBlowStrEltUp::dealWithSEInFields(const std::string& seName, const MEDFileFields *fs, const MEDFileEltStruct4Mesh *zeStr, const MEDFileFields *varAtt, MCAuto<MEDFileFields>& zeOutputs) const
+void MEDFileBlowStrEltUp::dealWithSEInFields(const std::string& seName, const MEDFileFields *fs, const MEDFileEltStruct4Mesh *zeStr, const MEDFileFields *varAtt, MEDFileFields *zeOutputs) const
{
if(!fs)
throw INTERP_KERNEL::Exception("MEDFileBlowStrEltUp::dealWithSEInFields : null pointer !");
throw INTERP_KERNEL::Exception("MEDFileBlowStrEltUp::dealWithSEInFields : only MED_BALL is managed for the moment, but if you are interested please send spec to anthony.geay@edf.fr !");
}
-void MEDFileBlowStrEltUp::dealWithMEDBALLSInFields(const MEDFileFields *fs, const MEDFileEltStruct4Mesh *zeStr, const MEDFileFields *varAtt, MCAuto<MEDFileFields>& zeOutputs) const
+void MEDFileBlowStrEltUp::dealWithMEDBALLSInFields(const MEDFileFields *fs, const MEDFileEltStruct4Mesh *zeStr, const MEDFileFields *varAtt, MEDFileFields *zeOutputs) const
{
+ int nbf(fs->getNumberOfFields());
+ std::vector< MCAuto<MEDFileAnyTypeFieldMultiTS> > elts0;
+ std::vector< MEDFileAnyTypeFieldMultiTS * > elts1;
+ for(int i=0;i<nbf;i++)
+ {
+ MCAuto<MEDFileAnyTypeFieldMultiTS> elt(fs->getFieldAtPos(i));
+ MCAuto<MEDFileAnyTypeFieldMultiTS> eltOut(elt->buildNewEmpty());
+ int nbTS(elt->getNumberOfTS());
+ for(int j=0;j<nbTS;j++)
+ {
+ MCAuto<MEDFileAnyTypeField1TS> eltt(elt->getTimeStepAtPos(j));
+ MCAuto<MEDFileAnyTypeField1TS> elttOut(eltt->deepCopy());
+ std::string meshName(eltt->getMeshName());
+ elttOut->setMeshName(BuildNewMeshName(meshName,MED_BALL_STR));
+ elttOut->convertMedBallIntoClassic();
+ eltOut->pushBackTimeStep(elttOut);
+ }
+ elts0.push_back(eltOut); elts1.push_back(eltOut);
+ }
+ //
+ std::size_t ii(0);
+ std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > sp(MEDFileAnyTypeFieldMultiTS::SplitIntoCommonTimeSeries(elts1));
+ for(std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> >::const_iterator it0=sp.begin();it0!=sp.end();it0++,ii++)
+ {
+ for(std::vector<MEDFileAnyTypeFieldMultiTS *>::const_iterator it1=(*it0).begin();it1!=(*it0).end();it1++)
+ zeOutputs->pushField(*it1);
+ std::vector<double> t2s;
+ std::vector< std::pair<int,int> > t1s((*it0)[0]->getTimeSteps(t2s));
+ std::size_t nbTS3(t2s.size());
+ int nbf2(varAtt->getNumberOfFields());
+ for(int i=0;i<nbf2;i++)
+ {
+ MCAuto<MEDFileAnyTypeFieldMultiTS> elt(varAtt->getFieldAtPos(i));
+ int nbTS2(elt->getNumberOfTS());
+ if(nbTS2!=1)
+ throw INTERP_KERNEL::Exception("MEDFileBlowStrEltUp::dealWithMEDBALLSInFields : internal error ! The dealWithMEDBALLInMesh is expected to return a single TS !");
+ MCAuto<MEDFileAnyTypeField1TS> elt2(elt->getTimeStepAtPos(0));
+ MCAuto<MEDFileAnyTypeFieldMultiTS> elt4(elt->buildNewEmpty());
+ for(std::size_t j=0;j<nbTS3;j++)
+ {
+ MCAuto<MEDFileAnyTypeField1TS> elt3(elt2->deepCopy());
+ elt3->setTime(t1s[j].first,t1s[j].second,t2s[j]);
+ elt3->setName(BuildVarAttName(ii,sp.size(),elt3->getName()));
+ elt4->pushBackTimeStep(elt3);
+ }
+ zeOutputs->pushField(elt4);
+ }
+ }
}
-void MEDFileBlowStrEltUp::generate(MCAuto<MEDFileMeshes>& msOut, MCAuto<MEDFileFields>& allZeOutFields)
+void MEDFileBlowStrEltUp::generate(MEDFileMeshes *msOut, MEDFileFields *allZeOutFields)
{
- msOut=MEDFileMeshes::New();
- allZeOutFields=MEDFileFields::New();
for(std::vector< MCAuto<MEDFileFields> >::iterator elt=_elts.begin();elt!=_elts.end();elt++)
{
std::vector< std::pair<std::string,std::string> > ps;
MCAuto<MEDFileUMesh> mOut;
MCAuto<MEDFileFields> fsOut1;
MCAuto<MEDFileEltStruct4Mesh> zeStr(dealWithSEInMesh(ps[0].second,umesh,mOut,fsOut1));
- msOut->pushMesh(umesh);
- MCAuto<MEDFileFields> fsOut2;
- dealWithSEInFields(ps[0].second,*elt,zeStr,fsOut1,fsOut2);
- allZeOutFields->aggregate(*fsOut2);
+ msOut->pushMesh(mOut);
+ dealWithSEInFields(ps[0].second,*elt,zeStr,fsOut1,allZeOutFields);
}
}
return mNameOut.str();
}
-void MEDFileBlowStrEltUp::DealWithSE(MEDFileFields *fs, const MEDFileMeshes *ms, const MEDFileStructureElements *ses, MCAuto<MEDFileFields>& fsOut, MCAuto<MEDFileMeshes>& msOut)
+std::string MEDFileBlowStrEltUp::BuildVarAttName(std::size_t iPart, std::size_t totNbParts, const std::string& name)
+{
+ if(totNbParts==1)
+ return name;
+ std::ostringstream oss;
+ oss << name << "@" << iPart;
+ return oss.str();
+}
+
+void MEDFileBlowStrEltUp::DealWithSE(MEDFileFields *fs, MEDFileMeshes *ms, const MEDFileStructureElements *ses)
{
MCAuto<MEDFileFields> fsSEOnly(fs->partOfThisOnStructureElements());
fs->killStructureElements();
MEDFileBlowStrEltUp bu(fsSEOnly,ms,ses);
- MCAuto<MEDFileMeshes> msOut1;
- MCAuto<MEDFileFields> allZeOutFields1;
- bu.generate(msOut1,allZeOutFields1);
-
+ bu.generate(ms,fs);
}
{
public:
MEDFileBlowStrEltUp(const MEDFileFields *fsOnlyOnSE, const MEDFileMeshes *ms, const MEDFileStructureElements *ses);
- static void DealWithSE(MEDFileFields *fs, const MEDFileMeshes *ms, const MEDFileStructureElements *ses, MCAuto<MEDFileFields>& fsOut, MCAuto<MEDFileMeshes>& msOut);
+ static void DealWithSE(MEDFileFields *fs, MEDFileMeshes *ms, const MEDFileStructureElements *ses);
private:
- void generate(MCAuto<MEDFileMeshes>& msOut, MCAuto<MEDFileFields>& allZeOutFields);
+ void generate(MEDFileMeshes *msOut, MEDFileFields *allZeOutFields);
MCAuto<MEDFileEltStruct4Mesh> dealWithSEInMesh(const std::string& seName, MEDFileUMesh *mesh, MCAuto<MEDFileUMesh>& mOut, MCAuto<MEDFileFields>& fsOut) const;
MCAuto<MEDFileEltStruct4Mesh> dealWithMEDBALLInMesh(const MEDFileUMesh *mesh, MCAuto<MEDFileUMesh>& mOut, MCAuto<MEDFileFields>& fsOut) const;
- void dealWithSEInFields(const std::string& seName, const MEDFileFields *fs, const MEDFileEltStruct4Mesh *zeStr, const MEDFileFields *varAtt, MCAuto<MEDFileFields>& zeOutputs) const;
- void dealWithMEDBALLSInFields(const MEDFileFields *fs, const MEDFileEltStruct4Mesh *zeStr, const MEDFileFields *varAtt, MCAuto<MEDFileFields>& zeOutputs) const;
+ void dealWithSEInFields(const std::string& seName, const MEDFileFields *fs, const MEDFileEltStruct4Mesh *zeStr, const MEDFileFields *varAtt, MEDFileFields *zeOutputs) const;
+ void dealWithMEDBALLSInFields(const MEDFileFields *fs, const MEDFileEltStruct4Mesh *zeStr, const MEDFileFields *varAtt, MEDFileFields *zeOutputs) const;
static std::string BuildNewMeshName(const std::string& meshName, const std::string& seName);
+ static std::string BuildVarAttName(std::size_t iPart, std::size_t totNbParts, const std::string& name);
public:
static const char MED_BALL_STR[];
private:
#include "MEDFileData.hxx"
#include "MEDLoaderBase.hxx"
#include "MEDFileSafeCaller.txx"
+#include "MEDFileBlowStrEltUp.hxx"
#include "InterpKernelAutoPtr.hxx"
return !meshesImpacted.empty();
}
+void MEDFileData::dealWithStructureElements()
+{
+ if(_struct_elems.isNull())
+ throw INTERP_KERNEL::Exception("MEDFileData::dealWithStructureElements : no structure elements in this !");
+ if(_meshes.isNull() || _fields.isNull())
+ throw INTERP_KERNEL::Exception("MEDFileData::dealWithStructureElements : meshes and fields must be not null !");
+ MEDFileBlowStrEltUp::DealWithSE(_fields,_meshes,_struct_elems);
+}
+
/*!
* Precondition : all instances in \a mfds should have a single mesh with fields on it. If there is an instance with not exactly one mesh an exception will be thrown.
* You can invoke MEDFileFields::partOfThisLyingOnSpecifiedMeshName method to make it work.
MEDLOADER_EXPORT bool changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab);
MEDLOADER_EXPORT bool changeMeshName(const std::string& oldMeshName, const std::string& newMeshName);
MEDLOADER_EXPORT bool unPolyzeMeshes();
+ MEDLOADER_EXPORT void dealWithStructureElements();
MEDLOADER_EXPORT static MCAuto<MEDFileData> Aggregate(const std::vector<const MEDFileData *>& mfds);
//
MEDLOADER_EXPORT void writeLL(med_idt fid) const;
return nb>1;
}
+void MEDFileFieldPerMeshPerTypeCommon::pushDiscretization(MEDFileFieldPerMeshPerTypePerDisc *disc)
+{
+ MCAuto<MEDFileFieldPerMeshPerTypePerDisc> elt;
+ elt.takeRef(disc);
+ _field_pm_pt_pd.push_back(elt);
+}
+
DataArray *MEDFileFieldPerMeshPerTypeCommon::getOrCreateAndGetArray()
{
return _father->getOrCreateAndGetArray();
return false;
}
+void MEDFileFieldPerMesh::convertMedBallIntoClassic()
+{
+ if(_field_pm_pt.size()!=1)
+ throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::convertMedBallIntoClassic : Only managed for single mesh !");
+ if(_field_pm_pt[0].isNull())
+ throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::convertMedBallIntoClassic : null pointer !");
+ MEDFileFieldPerMeshPerTypeDyn *pt(dynamic_cast<MEDFileFieldPerMeshPerTypeDyn *>((MEDFileFieldPerMeshPerTypeCommon *)_field_pm_pt[0]));
+ if(!pt)
+ throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::convertMedBallIntoClassic : this is expected to be marked as structure element !");
+ if(pt->getNumberOfLoc()!=1)
+ throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::convertMedBallIntoClassic : only one loc managed !");
+ const MEDFileFieldPerMeshPerTypePerDisc *disc(pt->getLeafGivenLocId(0));
+ if(!disc)
+ throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::convertMedBallIntoClassic : internal error !");
+ MCAuto<MEDFileFieldPerMeshPerTypePerDisc> disc2(MEDFileFieldPerMeshPerTypePerDisc::New(*disc));
+ disc2->setType(ON_NODES);
+ MCAuto<MEDFileFieldPerMeshPerType> pt2(MEDFileFieldPerMeshPerType::New(this,INTERP_KERNEL::NORM_ERROR));
+ disc2->setFather(pt2);
+ pt2->setFather(this);
+ pt2->pushDiscretization(disc2);
+ _field_pm_pt[0]=DynamicCast<MEDFileFieldPerMeshPerType,MEDFileFieldPerMeshPerTypeCommon>(pt2);
+}
+
bool MEDFileFieldPerMesh::renumberEntitiesLyingOnMesh(const std::string& meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N,
MEDFileFieldGlobsReal& glob)
{
return ret;
}
+void MEDFileAnyTypeField1TSWithoutSDA::convertMedBallIntoClassic()
+{
+ for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it<_field_per_mesh.end();it++)
+ if((*it).isNotNull())
+ (*it)->convertMedBallIntoClassic();
+}
+
/*!
* \param [in] mName specifies the underlying mesh name. This value can be pointer 0 for users that do not deal with fields on multi mesh.
* \param [in] typ is for the geometric cell type (or INTERP_KERNEL::NORM_ERROR for node field) entry to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set.
return contentNotNullBase()->getNonEmptyLevels(mname,levs);
}
+void MEDFileAnyTypeField1TS::convertMedBallIntoClassic()
+{
+ return contentNotNullBase()->convertMedBallIntoClassic();
+}
+
std::vector<TypeOfField> MEDFileAnyTypeField1TS::getTypesOfFieldAvailable() const
{
return contentNotNullBase()->getTypesOfFieldAvailable();
void getSizes(int& globalSz, int& nbOfEntries) const;
int getNumberOfComponents() const;
bool presenceOfMultiDiscPerGeoType() const;
+ void pushDiscretization(MEDFileFieldPerMeshPerTypePerDisc *disc);
DataArray *getOrCreateAndGetArray();
const DataArray *getOrCreateAndGetArray() const;
const std::vector<std::string>& getInfo() const;
bool keepOnlyGaussDiscretization(std::size_t idOfDisc, int &globalNum, std::vector< std::pair<int,int> >& its);
static med_entity_type ConvertIntoMEDFileType(TypeOfField ikType, INTERP_KERNEL::NormalizedCellType ikGeoType, med_geometry_type& medfGeoType);
MEDFileFieldPerMeshPerTypeCommon(MEDFileFieldPerMesh *father):_father(father) { }
+ void setFather(MEDFileFieldPerMesh *father);
public:
virtual ~MEDFileFieldPerMeshPerTypeCommon();
virtual void getDimension(int& dim) const = 0;
virtual MEDFileFieldPerMeshPerTypeCommon *deepCopy(MEDFileFieldPerMesh *father) const = 0;
virtual void getFieldAtLevel(int meshDim, TypeOfField type, const MEDFileFieldGlobsReal *glob, std::vector< std::pair<int,int> >& dads, std::vector<const DataArrayInt *>& pfls, std::vector<int>& locs, std::vector<INTERP_KERNEL::NormalizedCellType>& geoTypes) const = 0;
protected:
- void setFather(MEDFileFieldPerMesh *father);
void deepCopyElements();
std::vector<int> addNewEntryIfNecessary(const MEDCouplingFieldDouble *field, int offset, int nbOfCells);
std::vector<int> addNewEntryIfNecessaryGauss(const MEDCouplingFieldDouble *field, int offset, int nbOfCells);
std::vector<std::string> getLocsReallyUsed() const;
std::vector<std::string> getPflsReallyUsedMulti() const;
std::vector<std::string> getLocsReallyUsedMulti() const;
+ void convertMedBallIntoClassic();
bool changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab);
bool renumberEntitiesLyingOnMesh(const std::string& meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N, MEDFileFieldGlobsReal& glob);
void keepOnlySpatialDiscretization(TypeOfField tof, int &globalNum, std::vector< std::pair<int,int> >& its);
MEDLOADER_EXPORT void changeLocsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif);
//
MEDLOADER_EXPORT int getNonEmptyLevels(const std::string& mname, std::vector<int>& levs) const;
+ MEDLOADER_EXPORT void convertMedBallIntoClassic();
MEDLOADER_EXPORT std::vector< std::vector<std::pair<int,int> > > getFieldSplitedByType(const std::string& mname, std::vector<INTERP_KERNEL::NormalizedCellType>& types, std::vector< std::vector<TypeOfField> >& typesF, std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const;
//
MEDLOADER_EXPORT MEDFileFieldPerMeshPerTypePerDisc *getLeafGivenMeshAndTypeAndLocId(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId);
MEDLOADER_EXPORT MEDFileFieldPerMeshPerTypePerDisc *getLeafGivenMeshAndTypeAndLocId(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId);
MEDLOADER_EXPORT const MEDFileFieldPerMeshPerTypePerDisc *getLeafGivenMeshAndTypeAndLocId(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId) const;
MEDLOADER_EXPORT int getNonEmptyLevels(const std::string& mname, std::vector<int>& levs) const;
+ MEDLOADER_EXPORT void convertMedBallIntoClassic();
public:
MEDLOADER_EXPORT void loadArrays();
MEDLOADER_EXPORT void loadArraysIfNecessary();
arr->alloc(nCells,var->getNbOfComponents());
arr->setName(vns[i]);
MEDFILESAFECALLERRD0(MEDmeshStructElementVarAttRd,(fid,mName.c_str(),dt,it,_geo_type,vns[i].c_str(),arr->getVoidStarPointer()));
+ _vars[i]=arr;
}
}
//
bool changeMeshName(const std::string& oldMeshName, const std::string& newMeshName) throw(INTERP_KERNEL::Exception);
bool unPolyzeMeshes() throw(INTERP_KERNEL::Exception);
+ void dealWithStructureElements() throw(INTERP_KERNEL::Exception);
std::string getHeader() const throw(INTERP_KERNEL::Exception);
void setHeader(const std::string& header) throw(INTERP_KERNEL::Exception);
//