int nbf(fs->getNumberOfFields());
std::vector< MCAuto<MEDFileAnyTypeFieldMultiTS> > elts0;
std::vector< MEDFileAnyTypeFieldMultiTS * > elts1;
+ std::string zeMeshName;
for(int i=0;i<nbf;i++)
{
MCAuto<MEDFileAnyTypeFieldMultiTS> elt(fs->getFieldAtPos(i));
MCAuto<MEDFileAnyTypeField1TS> eltt(elt->getTimeStepAtPos(j));
MCAuto<MEDFileAnyTypeField1TS> elttOut(eltt->deepCopy());
std::string meshName(eltt->getMeshName());
- elttOut->setMeshName(BuildNewMeshName(meshName,MED_BALL_STR));
+ zeMeshName=BuildNewMeshName(meshName,MED_BALL_STR);
+ elttOut->setMeshName(zeMeshName);
elttOut->convertMedBallIntoClassic();
eltOut->pushBackTimeStep(elttOut);
}
elts0.push_back(eltOut); elts1.push_back(eltOut);
}
//
+ const MEDFileMesh *zeCurrentMesh(_ms->getMeshWithName(zeMeshName));
+ //
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++)
+ std::vector< MCAuto<MEDFileFastCellSupportComparator> > fsc;
+ std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > sp2(MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport(*it0,zeCurrentMesh,fsc));
+ std::size_t jj(0);
+ for(std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> >::const_iterator it1=sp2.begin();it1!=sp2.end();it1++,jj++)
{
- 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++)
+ for(std::vector<MEDFileAnyTypeFieldMultiTS *>::const_iterator it2=(*it1).begin();it2!=(*it1).end();it2++)
+ zeOutputs->pushField(*it2);
+ // The most exciting part. Users that put profiles on struct elements part of fields. Reduce var att.
+ if((*it1).size()<1)
+ throw INTERP_KERNEL::Exception("MEDFileBlowStrEltUp::dealWithMEDBALLSInFields : take a deep breath !");
+ MCAuto<MEDFileAnyTypeField1TS> zeGuideForPfl;// This var is the reference for pfl management.
+ {
+ if(!(*it1)[0])
+ throw INTERP_KERNEL::Exception("MEDFileBlowStrEltUp::dealWithMEDBALLSInFields : take a deep breath 2 !");
+ int pdm((*it1)[0]->getNumberOfTS());
+ if(pdm<1)
+ throw INTERP_KERNEL::Exception("MEDFileBlowStrEltUp::dealWithMEDBALLSInFields : take a deep breath 3 !");
+ zeGuideForPfl=(*it1)[0]->getTimeStepAtPos(0);
+ }
+ if(zeGuideForPfl.isNull())
+ throw INTERP_KERNEL::Exception("MEDFileBlowStrEltUp::dealWithMEDBALLSInFields : take a deep breath 4 !");
+ std::vector<std::string> pfls(zeGuideForPfl->getPflsReallyUsed());
+ if(pfls.size()>=2)
+ throw INTERP_KERNEL::Exception("MEDFileBlowStrEltUp::dealWithMEDBALLSInFields : drink less coffee");
+ MCAuto<DataArrayInt> pflMyLove;
+ if(pfls.size()==1)
+ pflMyLove.takeRef(zeGuideForPfl->getProfile(pfls[0]));
+ // Yeah we have pfls
+ std::vector<double> t2s;
+ std::vector< std::pair<int,int> > t1s((*it1)[0]->getTimeSteps(t2s));
+ std::size_t nbTS3(t2s.size());
+ int nbf2(varAtt->getNumberOfFields());
+ for(int i=0;i<nbf2;i++)
{
- 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);
+ 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(),jj,sp2.size(),elt3->getName()));
+ if(pflMyLove.isNotNull())
+ elt3->makeReduction(INTERP_KERNEL::NORM_ERROR,ON_NODES,pflMyLove);
+ elt4->pushBackTimeStep(elt3);
+ }
+ zeOutputs->pushField(elt4);
}
- zeOutputs->pushField(elt4);
}
}
-
}
void MEDFileBlowStrEltUp::generate(MEDFileMeshes *msOut, MEDFileFields *allZeOutFields)
return mNameOut.str();
}
-std::string MEDFileBlowStrEltUp::BuildVarAttName(std::size_t iPart, std::size_t totNbParts, const std::string& name)
+std::string MEDFileBlowStrEltUp::BuildVarAttName(std::size_t iPart, std::size_t totINbParts, std::size_t jPart, std::size_t totJNbParts, const std::string& name)
{
- if(totNbParts==1)
+ if(totINbParts==1 && totJNbParts==1)
return name;
std::ostringstream oss;
- oss << name << "@" << iPart;
+ oss << name << "@" << iPart << "@" << jPart;
return oss.str();
}
(*it)->convertMedBallIntoClassic();
}
+void MEDFileAnyTypeField1TSWithoutSDA::makeReduction(INTERP_KERNEL::NormalizedCellType ct, TypeOfField tof, const DataArrayInt *pfl)
+{
+ if(!pfl)
+ throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::makeReduction : null pfl !");
+ std::string name(pfl->getName());
+ pfl->checkAllocated();
+ if(pfl->getNumberOfComponents()!=1)
+ throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::makeReduction : non mono compo array !");
+ if(name.empty())
+ throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::makeReduction : empty pfl name !");
+ if(_field_per_mesh.size()!=1)
+ throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::makeReduction : only single mesh supported !");
+ MCAuto<MEDFileFieldPerMesh> fpm(_field_per_mesh[0]);
+ if(fpm.isNull())
+ throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::makeReduction : only single not null mesh supported !");
+ MEDFileFieldPerMeshPerTypePerDisc *disc(fpm->getLeafGivenTypeAndLocId(ct,0));
+ if(disc->getType()!=tof)
+ throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::makeReduction : error !");
+ int s(disc->getStart()),e(disc->getEnd()),nt(pfl->getNumberOfTuples());
+ DataArray *arr(getUndergroundDataArray());
+ int nt2(arr->getNumberOfTuples()),delta((e-s)-nt);
+ if(delta<0)
+ throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::makeReduction : internal error !");
+ MCAuto<DataArray> arr0(arr->selectByTupleIdSafeSlice(0,s,1)),arr1(arr->selectByTupleIdSafeSlice(s,e,1)),arr2(arr->selectByTupleIdSafeSlice(e,nt2,1));
+ MCAuto<DataArray> arr11(arr1->selectByTupleIdSafe(pfl->begin(),pfl->end()));
+ MCAuto<DataArray> arrOut(arr->buildNewEmptyInstance());
+ arrOut->alloc(nt2-delta,arr->getNumberOfComponents());
+ arrOut->copyStringInfoFrom(*arr);
+ arrOut->setContigPartOfSelectedValuesSlice(0,arr0,0,s,1);
+ arrOut->setContigPartOfSelectedValuesSlice(s,arr11,0,nt,1);
+ arrOut->setContigPartOfSelectedValuesSlice(e-delta,arr2,0,nt2-e,1);
+ setArray(arrOut);
+ disc->setEnd(e-delta);
+ disc->setProfile(name);
+}
+
/*!
* \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()->convertMedBallIntoClassic();
}
+void MEDFileAnyTypeField1TS::makeReduction(INTERP_KERNEL::NormalizedCellType ct, TypeOfField tof, const DataArrayInt *pfl)
+{
+ return contentNotNullBase()->makeReduction(ct,tof,pfl);
+}
+
std::vector<TypeOfField> MEDFileAnyTypeField1TS::getTypesOfFieldAvailable() const
{
return contentNotNullBase()->getTypesOfFieldAvailable();
int getNumberOfTuples() const;
int getStart() const { return _start; }
int getEnd() const { return _end; }
+ void setEnd(int endd) { _end=endd; }
int getNumberOfVals() const { return _nval; }
DataArray *getOrCreateAndGetArray();
const DataArray *getOrCreateAndGetArray() const;
//
MEDLOADER_EXPORT int getNonEmptyLevels(const std::string& mname, std::vector<int>& levs) const;
MEDLOADER_EXPORT void convertMedBallIntoClassic();
+ MEDLOADER_EXPORT void makeReduction(INTERP_KERNEL::NormalizedCellType ct, TypeOfField tof, const DataArrayInt *pfl);
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 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();
+ MEDLOADER_EXPORT void makeReduction(INTERP_KERNEL::NormalizedCellType ct, TypeOfField tof, const DataArrayInt *pfl);
public:
MEDLOADER_EXPORT void loadArrays();
MEDLOADER_EXPORT void loadArraysIfNecessary();