/*!
* entry point for users that want to iterate into MEDFile DataStructure without any overhead.
*/
-std::vector< std::vector<const DataArrayDouble *> > MEDFileField1TSWithoutDAS::getFieldSplitedByType(const char *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 throw(INTERP_KERNEL::Exception)
+std::vector< std::vector< std::pair<int,int> > > MEDFileField1TSWithoutDAS::getFieldSplitedByType(const char *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 throw(INTERP_KERNEL::Exception)
+{
+ int meshId=0;
+ if(mname)
+ meshId=getMeshIdFromMeshName(mname);
+ else
+ if(_field_per_mesh.empty())
+ throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutDAS::getFieldSplitedByType : This is empty !");
+ return _field_per_mesh[meshId]->getFieldSplitedByType(types,typesF,pfls,locs);
+}
+
+/*!
+ * entry point for users that want to iterate into MEDFile DataStructure with a reduced overhead because output arrays are extracted (created) specially
+ * for the call of this method. That's why the DataArrayDouble instance in returned vector of vector should be dealed by the caller.
+ */
+std::vector< std::vector<DataArrayDouble *> > MEDFileField1TSWithoutDAS::getFieldSplitedByType2(const char *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 throw(INTERP_KERNEL::Exception)
{
int meshId=0;
if(mname)
throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutDAS::getFieldSplitedByType : This is empty !");
std::vector< std::vector< std::pair<int,int> > > ret0=_field_per_mesh[meshId]->getFieldSplitedByType(types,typesF,pfls,locs);
int nbOfRet=ret0.size();
- std::vector< std::vector<const DataArrayDouble *> > ret(nbOfRet);
+ std::vector< std::vector<DataArrayDouble *> > ret(nbOfRet);
for(int i=0;i<nbOfRet;i++)
{
const std::vector< std::pair<int,int> >& p=ret0[i];
ret[i][j]=tmp;
}
}
- //anthony.geay@cea.fr
return ret;
}
return ret;
}
-std::vector< std::vector<const DataArrayDouble *> > MEDFileFieldMultiTSWithoutDAS::getFieldSplitedByType(int iteration, int order, const char *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 throw(INTERP_KERNEL::Exception)
+/*!
+ * entry point for users that want to iterate into MEDFile DataStructure without any overhead.
+ */
+std::vector< std::vector< std::pair<int,int> > > MEDFileFieldMultiTSWithoutDAS::getFieldSplitedByType(int iteration, int order, const char *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 throw(INTERP_KERNEL::Exception)
{
return getTimeStepEntry(iteration,order).getFieldSplitedByType(mname,types,typesF,pfls,locs);
}
+/*!
+ * entry point for users that want to iterate into MEDFile DataStructure with a reduced overhead because output arrays are extracted (created) specially
+ * for the call of this method. That's why the DataArrayDouble instance in returned vector of vector should be dealed by the caller.
+ */
+std::vector< std::vector<DataArrayDouble *> > MEDFileFieldMultiTSWithoutDAS::getFieldSplitedByType2(int iteration, int order, const char *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 throw(INTERP_KERNEL::Exception)
+{
+ return getTimeStepEntry(iteration,order).getFieldSplitedByType2(mname,types,typesF,pfls,locs);
+}
+
const MEDFileField1TSWithoutDAS& MEDFileFieldMultiTSWithoutDAS::getTimeStepEntry(int iteration, int order) const throw(INTERP_KERNEL::Exception)
{
for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSWithoutDAS> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
void setFieldProfile(const MEDCouplingFieldDouble *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile, MEDFieldFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception);
public:
std::vector<TypeOfField> getTypesOfFieldAvailable() const throw(INTERP_KERNEL::Exception);
- std::vector< std::vector<const DataArrayDouble *> > getFieldSplitedByType(const char *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 throw(INTERP_KERNEL::Exception);
+ std::vector< std::vector<std::pair<int,int> > > getFieldSplitedByType(const char *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 throw(INTERP_KERNEL::Exception);
+ std::vector< std::vector<DataArrayDouble *> > getFieldSplitedByType2(const char *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 throw(INTERP_KERNEL::Exception);
MEDCouplingFieldDouble *getFieldAtLevel(TypeOfField type, int meshDimRelToMax, const char *mName, int renumPol, const MEDFieldFieldGlobsReal *glob) const throw(INTERP_KERNEL::Exception);
MEDCouplingFieldDouble *getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, int renumPol, const MEDFieldFieldGlobsReal *glob, const MEDFileMesh *mesh) const throw(INTERP_KERNEL::Exception);
MEDCouplingFieldDouble *getFieldAtTopLevel(TypeOfField type, const char *mName, int renumPol, const MEDFieldFieldGlobsReal *glob) const throw(INTERP_KERNEL::Exception);
int getNumberOfTS() const;
std::vector< std::pair<int,int> > getIterations() const;
std::vector< std::vector<TypeOfField> > getTypesOfFieldAvailable() const throw(INTERP_KERNEL::Exception);
- std::vector< std::vector<const DataArrayDouble *> > getFieldSplitedByType(int iteration, int order, const char *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 throw(INTERP_KERNEL::Exception);
+ std::vector< std::vector< std::pair<int,int> > > getFieldSplitedByType(int iteration, int order, const char *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 throw(INTERP_KERNEL::Exception);
+ std::vector< std::vector<DataArrayDouble *> > getFieldSplitedByType2(int iteration, int order, const char *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 throw(INTERP_KERNEL::Exception);
virtual void writeLL(med_idt fid) const throw(INTERP_KERNEL::Exception);
std::string getName() const;
std::vector< std::pair<int,int> > getTimeSteps(std::vector<double>& ret1) const throw(INTERP_KERNEL::Exception);
vector<INTERP_KERNEL::NormalizedCellType> types;
vector< vector<TypeOfField> > typesF;
vector< vector<string> > pfls, locs;
- vector< vector<const DataArrayDouble *> > valsVec;
- valsVec = _nodeFields[iF]->getFieldSplitedByType( it.first, it.second, _fileMesh->getName(),
- types, typesF, pfls, locs);
+ vector< vector< std::pair<int,int> > > valsVec;
+ valsVec=_nodeFields[iF]->getFieldSplitedByType( it.first, it.second, _fileMesh->getName(),
+ types, typesF, pfls, locs);
// believe that there can be only one type in a nodal field,
// so do not use a loop on types
if ( pfls[0][0].empty() ) pfls[0][0] = noProfileName( types[0] );
THROW_IK_EXCEPTION( "SauvWriter::writeNodalFields(): no sub-mesh for profile |"
<< pfls[0][0] << "|");
vals[0] = -pfl2Sub->second->_id;
- vals[1] = valsVec[0][0]->getNumberOfTuples() / nbComp;
+ vals[1] = (valsVec[0][0].second-valsVec[0][0].first);
vals[2] = compInfo.size();
for ( size_t i = 0; i < vals.size(); ++i, fcount++ )
*_sauvFile << setw(8) << vals[i];
vector<INTERP_KERNEL::NormalizedCellType> types;
vector< vector<TypeOfField> > typesF;
vector< vector<string> > pfls, locs;
- vector< vector<const DataArrayDouble *> > valsVec;
+ vector< vector< std::pair<int,int> > > valsVec;
valsVec = _nodeFields[iF]->getFieldSplitedByType( it.first, it.second, _fileMesh->getName(),
types, typesF, pfls, locs);
// believe that there can be only one type in a nodal field,
// so do not perform a loop on types
- const DataArrayDouble* valsArray = valsVec[0][0];
+ const DataArrayDouble* valsArray = _nodeFields[iF]->getUndergroundDataArray(it.first, it.second);
for ( size_t j = 0; j < compInfo.size(); ++j )
{
- for ( size_t i = 0; i < (std::size_t)valsArray->getNumberOfTuples(); ++i, fcount++ )
+ for ( size_t i = valsVec[0][0].first; i < (std::size_t)valsVec[0][0].second; ++i, fcount++ )
*_sauvFile << setw(22) << valsArray->getIJ( i, j );
fcount.stop();
}
vector<INTERP_KERNEL::NormalizedCellType> types;
vector< vector<TypeOfField> > typesF;
vector< vector<string> > pfls, locs;
- vector< vector<const DataArrayDouble *> > valsVec;
+ vector< vector< std::pair<int,int> > > valsVec;
valsVec = _cellFields[iF]->getFieldSplitedByType( it.first, it.second, _fileMesh->getName(),
types, typesF, pfls, locs);
for ( size_t i = 0; i < valsVec.size(); ++i )
vector<INTERP_KERNEL::NormalizedCellType> types;
vector< vector<TypeOfField> > typesF;
vector< vector<string> > pfls, locs;
- vector< vector<const DataArrayDouble *> > valsVec;
- valsVec = _cellFields[iF]->getFieldSplitedByType( it.first, it.second, _fileMesh->getName(),
- types, typesF, pfls, locs);
+ _cellFields[iF]->getFieldSplitedByType( it.first, it.second, _fileMesh->getName(),
+ types, typesF, pfls, locs);
for ( size_t iType = 0; iType < pfls.size(); ++iType )
for ( size_t iP = 0; iP < pfls[iType].size(); ++iP )
{
vector<INTERP_KERNEL::NormalizedCellType> types;
vector< vector<TypeOfField> > typesF;
vector< vector<string> > pfls, locs;
- vector< vector<const DataArrayDouble *> > valsVec;
+ vector< vector< std::pair<int,int> > > valsVec;
valsVec = _cellFields[iF]->getFieldSplitedByType( iter, order, _fileMesh->getName(),
types, typesF, pfls, locs);
for ( size_t iType = 0; iType < pfls.size(); ++iType )
}
// (10) values
- const DataArrayDouble* valArray = valsVec[iType][iP];
+ const std::pair<int,int>& bgEnd = valsVec[iType][iP];
+ const DataArrayDouble* valArray = _cellFields[iF]->getUndergroundDataArray(iter, order);
for ( iComp = 0; iComp < nbComp; ++iComp )
{
*_sauvFile << setw(8) << nbPntPerCell
- << setw(8) << valArray->getNbOfElems() / nbPntPerCell / nbComp
+ << setw(8) << (bgEnd.second-bgEnd.first) / nbPntPerCell
<< setw(8) << 0
<< setw(8) << 0
<< endl;
fcount.init(3);
- for ( size_t i = 0; i < (size_t) valArray->getNumberOfTuples(); ++i, fcount++ )
+ for ( size_t i = bgEnd.first; i < (size_t) bgEnd.second; ++i, fcount++ )
*_sauvFile << setw(22) << valArray->getIJ( i, iComp );
fcount.stop();
}
std::vector< std::vector<TypeOfField> > typesF;
std::vector< std::vector<std::string> > pfls;
std::vector< std::vector<std::string> > locs;
- std::vector< std::vector<const DataArrayDouble *> > ret=self->getFieldSplitedByType(mname,types,typesF,pfls,locs);
+ std::vector< std::vector< std::pair<int,int> > > ret=self->getFieldSplitedByType(mname,types,typesF,pfls,locs);
int sz=ret.size();
PyObject *ret2=PyList_New(sz);
for(int i=0;i<sz;i++)
{
- const std::vector<const DataArrayDouble *>& dadsI=ret[i];
+ const std::vector< std::pair<int,int> >& dadsI=ret[i];
+ const std::vector<TypeOfField>& typesFI=typesF[i];
+ const std::vector<std::string>& pflsI=pfls[i];
+ const std::vector<std::string>& locsI=locs[i];
+ PyObject *elt=PyTuple_New(2);
+ PyTuple_SetItem(elt,0,SWIG_From_int(types[i]));
+ int sz2=ret[i].size();
+ PyObject *elt2=PyList_New(sz2);
+ for(int j=0;j<sz2;j++)
+ {
+ PyObject *elt3=PyTuple_New(4);
+ PyTuple_SetItem(elt3,0,SWIG_From_int(typesFI[j]));
+ PyObject *elt4=PyTuple_New(2); PyTuple_SetItem(elt4,0,SWIG_From_int(dadsI[j].first)); PyTuple_SetItem(elt4,1,SWIG_From_int(dadsI[j].second));
+ PyTuple_SetItem(elt3,1,elt4);
+ PyTuple_SetItem(elt3,2,PyString_FromString(pflsI[j].c_str()));
+ PyTuple_SetItem(elt3,3,PyString_FromString(locsI[j].c_str()));
+ PyList_SetItem(elt2,j,elt3);
+ }
+ PyTuple_SetItem(elt,1,elt2);
+ PyList_SetItem(ret2,i,elt);
+ }
+ return ret2;
+ }
+
+ PyObject *getFieldSplitedByType2(const char *mname=0) const throw(INTERP_KERNEL::Exception)
+ {
+ 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;
+ std::vector< std::vector<DataArrayDouble *> > ret=self->getFieldSplitedByType2(mname,types,typesF,pfls,locs);
+ int sz=ret.size();
+ PyObject *ret2=PyList_New(sz);
+ for(int i=0;i<sz;i++)
+ {
+ const std::vector<DataArrayDouble *>& dadsI=ret[i];
const std::vector<TypeOfField>& typesFI=typesF[i];
const std::vector<std::string>& pflsI=pfls[i];
const std::vector<std::string>& locsI=locs[i];
for(int j=0;j<sz2;j++)
{
PyObject *elt3=PyTuple_New(4);
- if(dadsI[j])
- dadsI[j]->incrRef();
PyTuple_SetItem(elt3,0,SWIG_From_int(typesFI[j]));
PyTuple_SetItem(elt3,1,SWIG_NewPointerObj(SWIG_as_voidptr(dadsI[j]),SWIGTYPE_p_ParaMEDMEM__DataArrayDouble, SWIG_POINTER_OWN | 0 ));
PyTuple_SetItem(elt3,2,PyString_FromString(pflsI[j].c_str()));
std::vector< std::vector<TypeOfField> > typesF;
std::vector< std::vector<std::string> > pfls;
std::vector< std::vector<std::string> > locs;
- std::vector< std::vector<const DataArrayDouble *> > ret=self->getFieldSplitedByType(iteration,order,mname,types,typesF,pfls,locs);
+ std::vector< std::vector< std::pair<int,int> > > ret=self->getFieldSplitedByType(iteration,order,mname,types,typesF,pfls,locs);
+ int sz=ret.size();
+ PyObject *ret2=PyList_New(sz);
+ for(int i=0;i<sz;i++)
+ {
+ const std::vector< std::pair<int,int> >& dadsI=ret[i];
+ const std::vector<TypeOfField>& typesFI=typesF[i];
+ const std::vector<std::string>& pflsI=pfls[i];
+ const std::vector<std::string>& locsI=locs[i];
+ PyObject *elt=PyTuple_New(2);
+ PyTuple_SetItem(elt,0,SWIG_From_int(types[i]));
+ int sz2=ret[i].size();
+ PyObject *elt2=PyList_New(sz2);
+ for(int j=0;j<sz2;j++)
+ {
+ PyObject *elt3=PyTuple_New(4);
+ PyTuple_SetItem(elt3,0,SWIG_From_int(typesFI[j]));
+ PyObject *elt4=PyTuple_New(2); PyTuple_SetItem(elt4,0,SWIG_From_int(dadsI[j].first)); PyTuple_SetItem(elt4,1,SWIG_From_int(dadsI[j].second));
+ PyTuple_SetItem(elt3,1,elt4);
+ PyTuple_SetItem(elt3,2,PyString_FromString(pflsI[j].c_str()));
+ PyTuple_SetItem(elt3,3,PyString_FromString(locsI[j].c_str()));
+ PyList_SetItem(elt2,j,elt3);
+ }
+ PyTuple_SetItem(elt,1,elt2);
+ PyList_SetItem(ret2,i,elt);
+ }
+ return ret2;
+ }
+
+ PyObject *getFieldSplitedByType2(int iteration, int order, const char *mname=0) const throw(INTERP_KERNEL::Exception)
+ {
+ 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;
+ std::vector< std::vector<DataArrayDouble *> > ret=self->getFieldSplitedByType2(iteration,order,mname,types,typesF,pfls,locs);
int sz=ret.size();
PyObject *ret2=PyList_New(sz);
for(int i=0;i<sz;i++)
{
- const std::vector<const DataArrayDouble *>& dadsI=ret[i];
+ const std::vector<DataArrayDouble *>& dadsI=ret[i];
const std::vector<TypeOfField>& typesFI=typesF[i];
const std::vector<std::string>& pflsI=pfls[i];
const std::vector<std::string>& locsI=locs[i];
for(int j=0;j<sz2;j++)
{
PyObject *elt3=PyTuple_New(4);
- if(dadsI[j])
- dadsI[j]->incrRef();
PyTuple_SetItem(elt3,0,SWIG_From_int(typesFI[j]));
PyTuple_SetItem(elt3,1,SWIG_NewPointerObj(SWIG_as_voidptr(dadsI[j]),SWIGTYPE_p_ParaMEDMEM__DataArrayDouble, SWIG_POINTER_OWN | 0 ));
PyTuple_SetItem(elt3,2,PyString_FromString(pflsI[j].c_str()));
ff2=MEDFileField1TS.New(fname,f1.getName(),f1.getTime()[1],f1.getTime()[2])
f2=ff2.getFieldAtLevel(ON_GAUSS_PT,0)
self.assertTrue(f1.isEqual(f2,1e-12,1e-12))
- sbt=ff2.getFieldSplitedByType()
+ sbt=ff2.getFieldSplitedByType2()
loc1=ff2.getLocalization("Loc_MyFirstFieldOnGaussPoint_NORM_TRI6_5")
self.assertEqual("Loc_MyFirstFieldOnGaussPoint_NORM_TRI6_5",loc1.getName())
self.assertEqual((-1, 1,-1,-1,1,-1,-1,0,0,-1,0,0),loc1.getRefCoords())
self.assertTrue(vals.isEqual(d,1e-14))
#
ff2=MEDFileField1TS.New(fname,f1.getName(),-1,-1)
- sbt=ff2.getFieldSplitedByType()
+ sbt=ff2.getFieldSplitedByType2()
self.assertEqual(3,sbt[0][0])#TRI3
self.assertEqual(0,sbt[0][1][0][0])#CELL For TRI3
self.assertEqual("",sbt[0][1][0][2])#no profile For TRI3