for(std::size_t pos=0;pos!=std::string::npos;id++)
{
std::size_t pos2=_expr.find_first_of(FIGURES,pos,10);
+ if(pos2==std::string::npos)
+ break;
if(pos2>0)
{//treat case of "x*log10(x)" -> "10" should NOT be intercepted by this
if(other.find_first_of(_expr[pos2-1])==std::string::npos)
throw INTERP_KERNEL::Exception(oss.str().c_str());
}
}
- if(pos2==std::string::npos)
- break;
std::size_t pos3=_expr.find_first_not_of(FIGURES,pos2,10);
if(pos3==std::string::npos)
{//"x+1223442320"
#ifndef __INTERPKERNELCELLSIMPLIFY_HXX__
#define __INTERPKERNELCELLSIMPLIFY_HXX__
+#include "INTERPKERNELDefines.hxx"
#include "NormalizedUnstructuredMesh.hxx"
#include "InterpKernelException.hxx"
namespace INTERP_KERNEL
{
- class CellSimplify
+ class INTERPKERNEL_EXPORT CellSimplify
{
public:
static INTERP_KERNEL::NormalizedCellType simplifyDegeneratedCell(INTERP_KERNEL::NormalizedCellType type, const int *conn, int lgth,
#ifndef __INTERPOLATION3D_HXX__
#define __INTERPOLATION3D_HXX__
+#include "INTERPKERNELDefines.hxx"
#include "Interpolation.hxx"
#include "NormalizedUnstructuredMesh.hxx"
#include "InterpolationOptions.hxx"
namespace INTERP_KERNEL
{
- class Interpolation3D : public Interpolation<Interpolation3D>
+ class INTERPKERNEL_EXPORT Interpolation3D : public Interpolation<Interpolation3D>
{
public:
Interpolation3D();
#ifndef __INTERPOLATION3DSURF_HXX__
#define __INTERPOLATION3DSURF_HXX__
-#include "InterpolationPlanar.hxx"
+#include "InterpolationPlanar.txx"
+#include "INTERPKERNELDefines.hxx"
#include "InterpolationOptions.hxx"
namespace INTERP_KERNEL
{
- class Interpolation3DSurf : public InterpolationPlanar<Interpolation3DSurf>
+ class INTERPKERNEL_EXPORT Interpolation3DSurf : public InterpolationPlanar<Interpolation3DSurf>
{
public:
Interpolation3DSurf();
return 0;
}
+/*!
+ * See MEDCouplingUMesh::splitProfilePerType for more information
+ */
+void MEDCouplingCMesh::splitProfilePerType(const DataArrayInt *profile, std::vector<int>& code, std::vector<DataArrayInt *>& idsInPflPerType, std::vector<DataArrayInt *>& idsPerType) const throw(INTERP_KERNEL::Exception)
+{
+ int nbCells=getNumberOfCells();
+ code.resize(3);
+ code[0]=(int)getTypeOfCell(0);
+ code[1]=nbCells;
+ code[2]=0;
+ idsInPflPerType.push_back(profile->deepCpy());
+ idsPerType.push_back(profile->deepCpy());
+}
+
MEDCouplingUMesh *MEDCouplingCMesh::buildUnstructured() const throw(INTERP_KERNEL::Exception)
{
int spaceDim=getSpaceDimension();
const DataArrayDouble *coordsZ=0);
// tools
DataArrayInt *checkTypeConsistencyAndContig(const std::vector<int>& code, const std::vector<const DataArrayInt *>& idsPerType) const throw(INTERP_KERNEL::Exception);
+ void splitProfilePerType(const DataArrayInt *profile, std::vector<int>& code, std::vector<DataArrayInt *>& idsInPflPerType, std::vector<DataArrayInt *>& idsPerType) const throw(INTERP_KERNEL::Exception);
MEDCouplingUMesh *buildUnstructured() const throw(INTERP_KERNEL::Exception);
MEDCouplingMesh *buildPart(const int *start, const int *end) const;
MEDCouplingMesh *buildPartAndReduceNodes(const int *start, const int *end, DataArrayInt*& arr) const;
throw INTERP_KERNEL::Exception("Not implemented yet !");
}
+void MEDCouplingExtrudedMesh::splitProfilePerType(const DataArrayInt *profile, std::vector<int>& code, std::vector<DataArrayInt *>& idsInPflPerType, std::vector<DataArrayInt *>& idsPerType) const throw(INTERP_KERNEL::Exception)
+{
+ throw INTERP_KERNEL::Exception("Not implemented yet !");
+}
+
MEDCouplingMesh *MEDCouplingExtrudedMesh::buildPart(const int *start, const int *end) const
{
// not implemented yet !
void translate(const double *vector);
void scale(const double *point, double factor);
DataArrayInt *checkTypeConsistencyAndContig(const std::vector<int>& code, const std::vector<const DataArrayInt *>& idsPerType) const throw(INTERP_KERNEL::Exception);
+ void splitProfilePerType(const DataArrayInt *profile, std::vector<int>& code, std::vector<DataArrayInt *>& idsInPflPerType, std::vector<DataArrayInt *>& idsPerType) const throw(INTERP_KERNEL::Exception);
MEDCouplingMesh *buildPart(const int *start, const int *end) const;
MEDCouplingMesh *buildPartAndReduceNodes(const int *start, const int *end, DataArrayInt*& arr) const;
DataArrayInt *simplexize(int policy) throw(INTERP_KERNEL::Exception);
declareAsNew();
}
+/*!
+ * 'this' should be allocated and with numberOfComponents set to one. If not an exception will be thrown.
+ * This method takes as input an array defined by ['arrBg','arrEnd'). The size of the array (std::distance(arrBg,arrEnd)) is equal to the number of cast + 1.
+ * The values contained in ['arrBg','arrEnd') should be sorted ascendently. No check of this will be done. If not the result is not waranted.
+ * For each cast j the value range that defines the cast is equal to [arrBg[j],arrBg[j+1]).
+ * This method returns three arrays (to be managed by the caller).
+ * This method is typically usefull for entity number spliting by types for example.
+ * Example : If 'this' contains [6,5,0,3,2,7,8,1,4] and if ['arrBg','arrEnd') contains [0,4,9] then the output of this method will be :
+ * - 'castArr' : [1,1,0,0,0,1,1,0,1]
+ * - 'rankInsideCast' : [2,1,0,3,2,3,4,1,0]
+ * - 'return' : [0,1]
+ *
+ * @param castArr is a returned param has the same number of tuples than 'this' and number of components set to one. In case of sucess, this param contains for each tuple in 'this' in which cast it holds.
+ * @param rankInsideCast is an another returned param has the same number of tuples than 'this' and number of components set to one too. In case of sucess, this param contains for each tuple its rank inside its cast.
+ * @param castsPresent the casts that 'this' contains.
+ * @throw if a value in 'this' is greater or equal to the last value of ['arrBg','arrEnd')
+ */
+void DataArrayInt::splitByValueRange(const int *arrBg, const int *arrEnd,
+ DataArrayInt *& castArr, DataArrayInt *& rankInsideCast, DataArrayInt *& castsPresent) const throw(INTERP_KERNEL::Exception)
+{
+ if(getNumberOfComponents()!=1)
+ throw INTERP_KERNEL::Exception("Call splitByValueRange method on DataArrayInt with only one component, you can call 'rearrange' method before !");
+ int nbOfTuples=getNumberOfTuples();
+ std::size_t nbOfCast=std::distance(arrBg,arrEnd);
+ if(nbOfCast<2)
+ throw INTERP_KERNEL::Exception("DataArrayInt::splitByValueRange : The input array giving the cast range values should be of size >=2 !");
+ nbOfCast--;
+ const int *work=getConstPointer();
+ typedef std::reverse_iterator<const int *> rintstart;
+ rintstart bg(arrEnd);//OK no problem because size of 'arr' is greater of equal 2
+ rintstart end(arrBg);
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ret1=DataArrayInt::New();
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ret2=DataArrayInt::New();
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ret3=DataArrayInt::New();
+ ret1->alloc(nbOfTuples,1);
+ ret2->alloc(nbOfTuples,1);
+ int *ret1Ptr=ret1->getPointer();
+ int *ret2Ptr=ret2->getPointer();
+ std::set<std::size_t> castsDetected;
+ for(int i=0;i<nbOfTuples;i++)
+ {
+ rintstart res=std::find_if(bg,end,std::bind2nd(std::less_equal<int>(), work[i]));
+ std::size_t pos=std::distance(bg,res);
+ std::size_t pos2=nbOfCast-pos;
+ if(pos2<nbOfCast)
+ {
+ ret1Ptr[i]=(int)pos2;
+ ret2Ptr[i]=work[i]-arrBg[pos2];
+ castsDetected.insert(pos2);
+ }
+ else
+ {
+ std::ostringstream oss; oss << "DataArrayInt::splitByValueRange : At rank #" << i << " the value is " << work[i] << " whereas the last value is " << *bg;
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ }
+ ret3->alloc((int)castsDetected.size(),1);
+ std::copy(castsDetected.begin(),castsDetected.end(),ret3->getPointer());
+ ret1->incrRef();
+ castArr=ret1;
+ ret2->incrRef();
+ rankInsideCast=ret2;
+ ret3->incrRef();
+ castsPresent=ret3;
+}
+
DataArrayInt *DataArrayInt::transformWithIndArrR(const int *indArrBg, const int *indArrEnd) const throw(INTERP_KERNEL::Exception)
{
if(getNumberOfComponents()!=1)
declareAsNew();
}
+/*!
+ * Idem DataArrayInt::computeOffsets method execpt that 'this' changes its number of tuples.
+ * After the call in case of success new number of tuples is equal to old number of tuples +1.
+ * The content in 'this' for the first old number of tuples is exactly the same than those given by
+ * DataArrayInt::computeOffsets method.
+ * For an array [3,5,1,2,0,8] it becomes [0,3,8,9,11,11,19].
+ */
+void DataArrayInt::computeOffsets2() throw(INTERP_KERNEL::Exception)
+{
+ checkAllocated();
+ if(getNumberOfComponents()!=1)
+ throw INTERP_KERNEL::Exception("DataArrayInt::computeOffsets2 : only single component allowed !");
+ int nbOfTuples=getNumberOfTuples();
+ int *ret=new int[nbOfTuples+1];
+ if(nbOfTuples==0)
+ return ;
+ const int *work=getConstPointer();
+ ret[0]=0;
+ for(int i=0;i<nbOfTuples;i++)
+ ret[i+1]=work[i]+ret[i];
+ useArray(ret,true,CPP_DEALLOC,nbOfTuples+1,1);
+ declareAsNew();
+}
+
+/*!
+ * This method works on array with number of component equal to one and allocated. If not an exception is thrown.
+ * 'offsets' should be monotic ascendently. If not, an exception will be thrown.
+ * This method retrives a newly created DataArrayInt instance with 1 component and this->getNumberOfTuples()-1 tuples.
+ * If 'this' contains [0,2,3] and 'offsets' [0,3,6,10,14,20] the returned array will contain [0,1,2,6,7,8,9,10,11,12,13]
+ */
+DataArrayInt *DataArrayInt::buildExplicitArrByRanges(const DataArrayInt *offsets) const throw(INTERP_KERNEL::Exception)
+{
+ checkAllocated();
+ if(getNumberOfComponents()!=1)
+ throw INTERP_KERNEL::Exception("DataArrayInt::buildExplicitArrByRanges : only single component allowed !");
+ offsets->checkAllocated();
+ if(offsets->getNumberOfComponents()!=1)
+ throw INTERP_KERNEL::Exception("DataArrayInt::buildExplicitArrByRanges : input array should have only single component !");
+ int othNbTuples=offsets->getNumberOfTuples()-1;
+ int nbOfTuples=getNumberOfTuples();
+ int retNbOftuples=0;
+ const int *work=getConstPointer();
+ const int *offPtr=offsets->getConstPointer();
+ for(int i=0;i<nbOfTuples;i++)
+ {
+ int val=work[i];
+ if(val>=0 && val<othNbTuples)
+ {
+ int delta=offPtr[val+1]-offPtr[val];
+ if(delta>=0)
+ retNbOftuples+=delta;
+ else
+ {
+ std::ostringstream oss; oss << "DataArrayInt::buildExplicitArrByRanges : Tuple #" << val << " of offset array has a delta < 0 !";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ }
+ else
+ {
+ std::ostringstream oss; oss << "DataArrayInt::buildExplicitArrByRanges : Tuple #" << i << " in this contains " << val;
+ oss << " whereas offsets array is of size " << othNbTuples+1 << " !";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ }
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ret=DataArrayInt::New();
+ ret->alloc(retNbOftuples,1);
+ int *retPtr=ret->getPointer();
+ for(int i=0;i<nbOfTuples;i++)
+ {
+ int val=work[i];
+ int start=offPtr[val];
+ int off=offPtr[val+1]-start;
+ for(int j=0;j<off;j++,retPtr++)
+ *retPtr=start+j;
+ }
+ ret->incrRef();
+ return ret;
+}
+
/*!
* This method returns all different values found in 'this'.
*/
MEDCOUPLING_EXPORT void reprZipWithoutNameStream(std::ostream& stream) const;
MEDCOUPLING_EXPORT void transformWithIndArr(const int *indArrBg, const int *indArrEnd) throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT DataArrayInt *transformWithIndArrR(const int *indArrBg, const int *indArrEnd) const throw(INTERP_KERNEL::Exception);
+ MEDCOUPLING_EXPORT void splitByValueRange(const int *arrBg, const int *arrEnd,
+ DataArrayInt *& castArr, DataArrayInt *& rankInsideCast, DataArrayInt *& castsPresent) const throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT DataArrayInt *invertArrayO2N2N2O(int newNbOfElem) const;
MEDCOUPLING_EXPORT DataArrayInt *invertArrayN2O2O2N(int oldNbOfElem) const;
//!alloc or useArray should have been called before.
MEDCOUPLING_EXPORT DataArrayInt *buildIntersection(const DataArrayInt *other) const throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT DataArrayInt *deltaShiftIndex() const throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT void computeOffsets() throw(INTERP_KERNEL::Exception);
+ MEDCOUPLING_EXPORT void computeOffsets2() throw(INTERP_KERNEL::Exception);
+ MEDCOUPLING_EXPORT DataArrayInt *buildExplicitArrByRanges(const DataArrayInt *offsets) const throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT std::set<int> getDifferentValues() const throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT void useArray(const int *array, bool ownership, DeallocType type, int nbOfTuple, int nbOfCompo);
MEDCOUPLING_EXPORT void writeOnPlace(int id, int element0, const int *others, int sizeOfOthers) { _mem.writeOnPlace(id,element0,others,sizeOfOthers); }
virtual std::string advancedRepr() const = 0;
// tools
virtual DataArrayInt *checkTypeConsistencyAndContig(const std::vector<int>& code, const std::vector<const DataArrayInt *>& idsPerType) const throw(INTERP_KERNEL::Exception) = 0;
+ virtual void splitProfilePerType(const DataArrayInt *profile, std::vector<int>& code, std::vector<DataArrayInt *>& idsInPflPerType, std::vector<DataArrayInt *>& idsPerType) const throw(INTERP_KERNEL::Exception) = 0;
virtual void getBoundingBox(double *bbox) const = 0;
virtual MEDCouplingFieldDouble *getMeasureField(bool isAbs) const = 0;
virtual MEDCouplingFieldDouble *getMeasureFieldOnNode(bool isAbs) const = 0;
return ret;
}
+/*!
+ * This method makes the hypothesis that 'this' is sorted by type. If not an exception will be thrown.
+ * This method is the opposite of MEDCouplingUMesh::checkTypeConsistencyAndContig method. Given a list of cells in 'profile' it returns a list of profiles sorted by geo type.
+ * This method has 1 input 'profile' and 2 outputs 'code' and 'idsPerType'.
+ * @throw if 'profile' has not exactly one component. It throws too, if 'profile' contains some values not in [0,getNumberOfCells()) or if 'this' is not fully defined
+ */
+void MEDCouplingUMesh::splitProfilePerType(const DataArrayInt *profile, std::vector<int>& code, std::vector<DataArrayInt *>& idsInPflPerType, std::vector<DataArrayInt *>& idsPerType) const throw(INTERP_KERNEL::Exception)
+{
+ if(profile->getNumberOfComponents()!=1)
+ throw INTERP_KERNEL::Exception("MEDCouplingUMesh::splitProfilePerType : input profile should have exactly one component !");
+ checkConnectivityFullyDefined();
+ const int *conn=_nodal_connec->getConstPointer();
+ const int *connI=_nodal_connec_index->getConstPointer();
+ int nbOfCells=getNumberOfCells();
+ std::vector<INTERP_KERNEL::NormalizedCellType> types;
+ std::vector<int> typeRangeVals(1);
+ for(const int *i=connI;i!=connI+nbOfCells;)
+ {
+ INTERP_KERNEL::NormalizedCellType curType=(INTERP_KERNEL::NormalizedCellType)conn[*i];
+ if(std::find(types.begin(),types.end(),curType)!=types.end())
+ {
+ throw INTERP_KERNEL::Exception("MEDCouplingUMesh::splitProfilePerType : current mesh is not sorted by type !");
+ }
+ types.push_back(curType);
+ i=std::find_if(i+1,connI+nbOfCells,ParaMEDMEMImpl::ConnReader(conn,(int)curType));
+ typeRangeVals.push_back(std::distance(connI,i));
+ }
+ //
+ DataArrayInt *castArr=0,*rankInsideCast=0,*castsPresent=0;
+ profile->splitByValueRange(&typeRangeVals[0],&typeRangeVals[0]+typeRangeVals.size(),castArr,rankInsideCast,castsPresent);
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> tmp0=castArr;
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> tmp1=rankInsideCast;
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> tmp2=castsPresent;
+ //
+ int nbOfCastsFinal=castsPresent->getNumberOfTuples();
+ code.resize(3*nbOfCastsFinal);
+ std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > idsInPflPerType2;
+ std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > idsPerType2;
+ for(int i=0;i<nbOfCastsFinal;i++)
+ {
+ int castId=castsPresent->getIJ(i,0);
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> tmp3=castArr->getIdsEqual(castId);
+ idsInPflPerType2.push_back(tmp3);
+ code[3*i]=(int)types[castId];
+ code[3*i+1]=tmp3->getNumberOfTuples();
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> tmp4=rankInsideCast->selectByTupleId(tmp3->getConstPointer(),tmp3->getConstPointer()+tmp3->getNumberOfTuples());
+ if(tmp4->getNumberOfTuples()!=typeRangeVals[castId+1]-typeRangeVals[castId] || !tmp4->isIdentity())
+ {
+ tmp4->copyStringInfoFrom(*profile);
+ idsPerType2.push_back(tmp4);
+ code[3*i+2]=(int)idsPerType2.size()-1;
+ }
+ else
+ {
+ code[3*i+2]=-1;
+ }
+ }
+ int sz2=idsInPflPerType2.size();
+ idsInPflPerType.resize(sz2);
+ for(int i=0;i<sz2;i++)
+ {
+ DataArrayInt *locDa=idsInPflPerType2[i];
+ locDa->incrRef();
+ idsInPflPerType[i]=locDa;
+ }
+ int sz=idsPerType2.size();
+ idsPerType.resize(sz);
+ for(int i=0;i<sz;i++)
+ {
+ DataArrayInt *locDa=idsPerType2[i];
+ locDa->incrRef();
+ idsPerType[i]=locDa;
+ }
+}
+
/*!
* This method is here too emulate the MEDMEM behaviour on BDC (buildDescendingConnectivity). Hoping this method becomes deprecated very soon.
* This method make the assumption that 'this' and 'nM1LevMesh' mesh lyies on same coords (same pointer) as MED and MEDMEM does.
{
INTERP_KERNEL::NormalizedCellType curType=(INTERP_KERNEL::NormalizedCellType)conn[*i];
if(types.find(curType)!=types.end())
- return false;
+ return false;
types.insert(curType);
i=std::find_if(i+1,connI+nbOfCells,ParaMEDMEMImpl::ConnReader(conn,(int)curType));
}
MEDCOUPLING_EXPORT MEDCouplingFieldDouble *getSkewField() const throw(INTERP_KERNEL::Exception);
//utilities for MED File RW
MEDCOUPLING_EXPORT DataArrayInt *checkTypeConsistencyAndContig(const std::vector<int>& code, const std::vector<const DataArrayInt *>& idsPerType) const throw(INTERP_KERNEL::Exception);
+ MEDCOUPLING_EXPORT void splitProfilePerType(const DataArrayInt *profile, std::vector<int>& code, std::vector<DataArrayInt *>& idsInPflPerType, std::vector<DataArrayInt *>& idsPerType) const throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT MEDCouplingUMesh *emulateMEDMEMBDC(const MEDCouplingUMesh *nM1LevMesh, DataArrayInt *desc, DataArrayInt *descIndx, DataArrayInt *&revDesc, DataArrayInt *&revDescIndx, DataArrayInt *& nM1LevMeshIds, DataArrayInt *&meshnM1Old2New) const throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT DataArrayInt *sortCellsInMEDFileFrmt() throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT bool checkConsecutiveCellTypes() const;
throw INTERP_KERNEL::Exception("Not implemented yet !");
}
+void MEDCouplingUMeshDesc::splitProfilePerType(const DataArrayInt *profile, std::vector<int>& code, std::vector<DataArrayInt *>& idsInPflPerType, std::vector<DataArrayInt *>& idsPerType) const throw(INTERP_KERNEL::Exception)
+{
+ throw INTERP_KERNEL::Exception("Not implemented yet !");
+}
+
void MEDCouplingUMeshDesc::getTinySerializationInformation(std::vector<double>& tinyInfoD, std::vector<int>& tinyInfo, std::vector<std::string>& littleStrings) const
{
MEDCouplingPointSet::getTinySerializationInformation(tinyInfoD,tinyInfo,littleStrings);
MEDCOUPLING_EXPORT void setConnectivity(DataArrayInt *descConn, DataArrayInt *descConnIndex, DataArrayInt *nodalFaceConn, DataArrayInt *nodalFaceConnIndx);
//tools to overload
MEDCOUPLING_EXPORT DataArrayInt *checkTypeConsistencyAndContig(const std::vector<int>& code, const std::vector<const DataArrayInt *>& idsPerType) const throw(INTERP_KERNEL::Exception);
+ MEDCOUPLING_EXPORT void splitProfilePerType(const DataArrayInt *profile, std::vector<int>& code, std::vector<DataArrayInt *>& idsInPflPerType, std::vector<DataArrayInt *>& idsPerType) const throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT void getTinySerializationInformation(std::vector<double>& tinyInfoD, std::vector<int>& tinyInfo, std::vector<std::string>& littleStrings) const;
MEDCOUPLING_EXPORT bool isEmptyMesh(const std::vector<int>& tinyInfo) const;
MEDCOUPLING_EXPORT void resizeForUnserialization(const std::vector<int>& tinyInfo, DataArrayInt *a1, DataArrayDouble *a2, std::vector<std::string>& littleStrings) const;
CPPUNIT_TEST( testSortCellsInMEDFileFrmt1 );
CPPUNIT_TEST( testBuildPartAndReduceNodes1 );
CPPUNIT_TEST( testDAITransformWithIndArrR1 );
+ CPPUNIT_TEST( testDAISplitByValueRange1 );
+ CPPUNIT_TEST( testUMeshSplitProfilePerType1 );
+ CPPUNIT_TEST( testDAIBuildExplicitArrByRanges1 );
+ CPPUNIT_TEST( testDAIComputeOffsets2 );
//MEDCouplingBasicsTestInterp.cxx
CPPUNIT_TEST( test2DInterpP0P0_1 );
CPPUNIT_TEST( test2DInterpP0P0PL_1 );
void testSortCellsInMEDFileFrmt1();
void testBuildPartAndReduceNodes1();
void testDAITransformWithIndArrR1();
+ void testDAISplitByValueRange1();
+ void testUMeshSplitProfilePerType1();
+ void testDAIBuildExplicitArrByRanges1();
+ void testDAIComputeOffsets2();
//MEDCouplingBasicsTestInterp.cxx
void test2DInterpP0P0_1();
void test2DInterpP0P0PL_1();
d->decrRef();
d1->decrRef();
}
+
+void MEDCouplingBasicsTest::testDAISplitByValueRange1()
+{
+ const int val1[9]={6,5,0,3,2,7,8,1,4};
+ const int val2[3]={0,4,9};
+ DataArrayInt *d=DataArrayInt::New();
+ d->alloc(9,1);
+ std::copy(val1,val1+9,d->getPointer());
+ DataArrayInt *e=0,*f=0,*g=0;
+ d->splitByValueRange(val2,val2+3,e,f,g);
+ CPPUNIT_ASSERT_EQUAL(9,e->getNumberOfTuples());
+ CPPUNIT_ASSERT_EQUAL(1,e->getNumberOfComponents());
+ CPPUNIT_ASSERT_EQUAL(9,f->getNumberOfTuples());
+ CPPUNIT_ASSERT_EQUAL(1,f->getNumberOfComponents());
+ CPPUNIT_ASSERT_EQUAL(2,g->getNumberOfTuples());
+ CPPUNIT_ASSERT_EQUAL(1,g->getNumberOfComponents());
+ //
+ const int expected1[9]={1,1,0,0,0,1,1,0,1};
+ const int expected2[9]={2,1,0,3,2,3,4,1,0};
+ for(int i=0;i<9;i++)
+ {
+ CPPUNIT_ASSERT_EQUAL(expected1[i],e->getIJ(i,0));
+ CPPUNIT_ASSERT_EQUAL(expected2[i],f->getIJ(i,0));
+ }
+ CPPUNIT_ASSERT_EQUAL(0,g->getIJ(0,0));
+ CPPUNIT_ASSERT_EQUAL(1,g->getIJ(1,0));
+ //
+ e->decrRef();
+ f->decrRef();
+ g->decrRef();
+ //
+ d->setIJ(6,0,9);
+ CPPUNIT_ASSERT_THROW(d->splitByValueRange(val2,val2+3,e,f,g),INTERP_KERNEL::Exception);
+ //
+ d->decrRef();
+}
+
+void MEDCouplingBasicsTest::testUMeshSplitProfilePerType1()
+{
+ const int val0[5]={2,0,1,3,4};
+ MEDCouplingUMesh *m=build2DTargetMesh_1();
+ m->renumberCells(val0,false);
+ std::vector<int> code;
+ std::vector<DataArrayInt *> idsInPflPerType;
+ std::vector<DataArrayInt *> pfls;
+ //
+ const int val1[3]={0,2,3};
+ DataArrayInt *d=DataArrayInt::New();
+ d->alloc(3,1);
+ d->setName("sup");
+ std::copy(val1,val1+3,d->getPointer());
+ m->splitProfilePerType(d,code,idsInPflPerType,pfls);
+ CPPUNIT_ASSERT_EQUAL(6,(int)code.size());
+ CPPUNIT_ASSERT_EQUAL(2,(int)idsInPflPerType.size());
+ const int expected1[6]={3,1,0, 4,2,1};
+ for(int i=0;i<6;i++)
+ CPPUNIT_ASSERT_EQUAL(expected1[i],code[i]);
+ CPPUNIT_ASSERT_EQUAL(1,idsInPflPerType[0]->getNumberOfTuples());
+ CPPUNIT_ASSERT_EQUAL(0,idsInPflPerType[0]->getIJ(0,0));
+ CPPUNIT_ASSERT_EQUAL(2,idsInPflPerType[1]->getNumberOfTuples());
+ CPPUNIT_ASSERT_EQUAL(1,idsInPflPerType[1]->getIJ(0,0));
+ CPPUNIT_ASSERT_EQUAL(2,idsInPflPerType[1]->getIJ(1,0));
+ idsInPflPerType[0]->decrRef();
+ idsInPflPerType[1]->decrRef();
+ CPPUNIT_ASSERT_EQUAL(2,(int)pfls.size());
+ CPPUNIT_ASSERT(std::string("sup")==pfls[0]->getName());
+ CPPUNIT_ASSERT_EQUAL(1,pfls[0]->getNumberOfTuples());
+ CPPUNIT_ASSERT_EQUAL(0,pfls[0]->getIJ(0,0));
+ CPPUNIT_ASSERT(std::string("sup")==pfls[1]->getName());
+ CPPUNIT_ASSERT_EQUAL(2,pfls[1]->getNumberOfTuples());
+ CPPUNIT_ASSERT_EQUAL(0,pfls[1]->getIJ(0,0));
+ CPPUNIT_ASSERT_EQUAL(1,pfls[1]->getIJ(1,0));
+ pfls[0]->decrRef();
+ pfls[1]->decrRef();
+ d->decrRef();
+ idsInPflPerType.clear();
+ pfls.clear();
+ code.clear();
+ //
+ const int val2[4]={0,2,3,4};// all quad4 are selected here ! So no profile for Quads
+ d=DataArrayInt::New();
+ d->alloc(4,1);
+ std::copy(val2,val2+4,d->getPointer());
+ m->splitProfilePerType(d,code,idsInPflPerType,pfls);
+ CPPUNIT_ASSERT_EQUAL(6,(int)code.size());
+ CPPUNIT_ASSERT_EQUAL(2,(int)idsInPflPerType.size());
+ const int expected2[6]={3,1,0, 4,3,-1};
+ for(int i=0;i<6;i++)
+ CPPUNIT_ASSERT_EQUAL(expected2[i],code[i]);
+ CPPUNIT_ASSERT_EQUAL(1,idsInPflPerType[0]->getNumberOfTuples());
+ CPPUNIT_ASSERT_EQUAL(0,idsInPflPerType[0]->getIJ(0,0));
+ CPPUNIT_ASSERT_EQUAL(3,idsInPflPerType[1]->getNumberOfTuples());
+ CPPUNIT_ASSERT_EQUAL(1,idsInPflPerType[1]->getIJ(0,0));
+ CPPUNIT_ASSERT_EQUAL(2,idsInPflPerType[1]->getIJ(1,0));
+ CPPUNIT_ASSERT_EQUAL(3,idsInPflPerType[1]->getIJ(2,0));
+ idsInPflPerType[0]->decrRef();
+ idsInPflPerType[1]->decrRef();
+ CPPUNIT_ASSERT_EQUAL(1,(int)pfls.size());
+ CPPUNIT_ASSERT_EQUAL(1,pfls[0]->getNumberOfTuples());
+ CPPUNIT_ASSERT_EQUAL(0,pfls[0]->getIJ(0,0));
+ pfls[0]->decrRef();
+ d->decrRef();
+ idsInPflPerType.clear();
+ pfls.clear();
+ code.clear();
+ //
+ const int val3[3]={1,0,2};// all tri3 are selected here but not in the same order ! Profile requested for Tri3
+ d=DataArrayInt::New();
+ d->alloc(3,1);
+ std::copy(val3,val3+3,d->getPointer());
+ m->splitProfilePerType(d,code,idsInPflPerType,pfls);
+ CPPUNIT_ASSERT_EQUAL(6,(int)code.size());
+ CPPUNIT_ASSERT_EQUAL(2,(int)idsInPflPerType.size());
+ const int expected3[6]={3,2,0, 4,1,1};
+ for(int i=0;i<6;i++)
+ CPPUNIT_ASSERT_EQUAL(expected3[i],code[i]);
+ CPPUNIT_ASSERT_EQUAL(2,idsInPflPerType[0]->getNumberOfTuples());
+ CPPUNIT_ASSERT_EQUAL(0,idsInPflPerType[0]->getIJ(0,0));
+ CPPUNIT_ASSERT_EQUAL(1,idsInPflPerType[0]->getIJ(1,0));
+ CPPUNIT_ASSERT_EQUAL(1,idsInPflPerType[1]->getNumberOfTuples());
+ CPPUNIT_ASSERT_EQUAL(2,idsInPflPerType[1]->getIJ(0,0));
+ idsInPflPerType[0]->decrRef();
+ idsInPflPerType[1]->decrRef();
+ CPPUNIT_ASSERT_EQUAL(2,(int)pfls.size());
+ CPPUNIT_ASSERT_EQUAL(2,pfls[0]->getNumberOfTuples());
+ CPPUNIT_ASSERT_EQUAL(1,pfls[0]->getIJ(0,0));
+ CPPUNIT_ASSERT_EQUAL(0,pfls[0]->getIJ(1,0));
+ CPPUNIT_ASSERT_EQUAL(0,pfls[1]->getIJ(0,0));
+ pfls[0]->decrRef();
+ pfls[1]->decrRef();
+ d->decrRef();
+ idsInPflPerType.clear();
+ pfls.clear();
+ code.clear();
+ //
+ const int val4[2]={3,4};// all tri3 are selected here but not in the same order ! Profile requested for Tri3
+ d=DataArrayInt::New();
+ d->alloc(2,1);
+ std::copy(val4,val4+2,d->getPointer());
+ m->splitProfilePerType(d,code,idsInPflPerType,pfls);
+ CPPUNIT_ASSERT_EQUAL(3,(int)code.size());
+ CPPUNIT_ASSERT_EQUAL(1,(int)idsInPflPerType.size());
+ const int expected4[3]={4,2,0};
+ for(int i=0;i<3;i++)
+ CPPUNIT_ASSERT_EQUAL(expected4[i],code[i]);
+ CPPUNIT_ASSERT_EQUAL(2,idsInPflPerType[0]->getNumberOfTuples());
+ CPPUNIT_ASSERT_EQUAL(0,idsInPflPerType[0]->getIJ(0,0));
+ CPPUNIT_ASSERT_EQUAL(1,idsInPflPerType[0]->getIJ(1,0));
+ idsInPflPerType[0]->decrRef();
+ CPPUNIT_ASSERT_EQUAL(1,(int)pfls.size());
+ CPPUNIT_ASSERT_EQUAL(2,pfls[0]->getNumberOfTuples());
+ CPPUNIT_ASSERT_EQUAL(1,pfls[0]->getIJ(0,0));
+ CPPUNIT_ASSERT_EQUAL(2,pfls[0]->getIJ(1,0));
+ pfls[0]->decrRef();
+ d->decrRef();
+ idsInPflPerType.clear();
+ pfls.clear();
+ code.clear();
+ //
+ m->decrRef();
+}
+
+void MEDCouplingBasicsTest::testDAIBuildExplicitArrByRanges1()
+{
+ DataArrayInt *d=DataArrayInt::New();
+ d->alloc(3,1);
+ const int vals1[3]={0,2,3};
+ std::copy(vals1,vals1+3,d->getPointer());
+ DataArrayInt *e=DataArrayInt::New();
+ e->alloc(6,1);
+ const int vals2[6]={0,3,6,10,14,20};
+ std::copy(vals2,vals2+6,e->getPointer());
+ //
+ DataArrayInt *f=d->buildExplicitArrByRanges(e);
+ CPPUNIT_ASSERT_EQUAL(11,f->getNumberOfTuples());
+ CPPUNIT_ASSERT_EQUAL(1,f->getNumberOfComponents());
+ const int expected1[11]={0,1,2,6,7,8,9,10,11,12,13};
+ for(int i=0;i<11;i++)
+ CPPUNIT_ASSERT_EQUAL(expected1[i],f->getIJ(i,0));
+ //
+ f->decrRef();
+ e->decrRef();
+ d->decrRef();
+}
+
+void MEDCouplingBasicsTest::testDAIComputeOffsets2()
+{
+ DataArrayInt *d=DataArrayInt::New();
+ const int vals1[6]={3,5,1,2,0,8};
+ const int expected1[7]={0,3,8,9,11,11,19};
+ d->alloc(6,1);
+ std::copy(vals1,vals1+6,d->getPointer());
+ d->computeOffsets2();
+ CPPUNIT_ASSERT_EQUAL(7,d->getNumberOfTuples());
+ CPPUNIT_ASSERT_EQUAL(1,d->getNumberOfComponents());
+ for(int i=0;i<7;i++)
+ CPPUNIT_ASSERT_EQUAL(expected1[i],d->getIJ(0,i));
+ d->decrRef();
+}
%newobject ParaMEDMEM::DataArrayInt::buildSubstraction;
%newobject ParaMEDMEM::DataArrayInt::buildIntersection;
%newobject ParaMEDMEM::DataArrayInt::deltaShiftIndex;
+%newobject ParaMEDMEM::DataArrayInt::buildExplicitArrByRanges;
%newobject ParaMEDMEM::DataArrayInt::buildPermutationArr;
%newobject ParaMEDMEM::DataArrayInt::buildPermArrPerLevel;
%newobject ParaMEDMEM::DataArrayInt::__getitem__;
%feature("unref") MEDCouplingField "$this->decrRef();"
%feature("unref") MEDCouplingFieldDouble "$this->decrRef();"
%feature("unref") MEDCouplingMultiFields "$this->decrRef();"
+%feature("unref") MEDCouplingFieldTemplate "$this->decrRef();"
+%feature("unref") MEDCouplingMultiFields "$this->decrRef();"
%rename(assign) *::operator=;
+%ignore ParaMEDMEM::RefCountObject::decrRef;
%ignore ParaMEDMEM::MemArray::operator=;
%ignore ParaMEDMEM::MemArray::operator[];
%ignore ParaMEDMEM::MEDCouplingGaussLocalization::pushTinySerializationIntInfo;
return self->checkTypeConsistencyAndContig(code,idsPerType);
}
+ PyObject *splitProfilePerType(const DataArrayInt *profile) const throw(INTERP_KERNEL::Exception)
+ {
+ std::vector<int> code;
+ std::vector<DataArrayInt *> idsInPflPerType;
+ std::vector<DataArrayInt *> idsPerType;
+ self->splitProfilePerType(profile,code,idsInPflPerType,idsPerType);
+ PyObject *ret=PyTuple_New(3);
+ PyTuple_SetItem(ret,0,convertIntArrToPyList2(code));
+ PyObject *ret1=PyList_New(idsInPflPerType.size());
+ for(std::size_t j=0;j<idsInPflPerType.size();j++)
+ PyList_SetItem(ret1,j,SWIG_NewPointerObj(SWIG_as_voidptr(idsInPflPerType[j]),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 ));
+ PyTuple_SetItem(ret,1,ret1);
+ int n=idsPerType.size();
+ PyObject *ret2=PyList_New(n);
+ for(int i=0;i<n;i++)
+ PyList_SetItem(ret2,i,SWIG_NewPointerObj(SWIG_as_voidptr(idsPerType[i]),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 ));
+ PyTuple_SetItem(ret,2,ret2);
+ return ret;
+ }
+
void translate(PyObject *vector) throw(INTERP_KERNEL::Exception)
{
int sz;
}
}
+ PyObject *splitByValueRange(PyObject *li) const throw(INTERP_KERNEL::Exception)
+ {
+ DataArrayInt *ret0=0,*ret1=0,*ret2=0;
+ void *da=0;
+ int res1=SWIG_ConvertPtr(li,&da,SWIGTYPE_p_ParaMEDMEM__DataArrayInt, 0 | 0 );
+ if (!SWIG_IsOK(res1))
+ {
+ int size;
+ INTERP_KERNEL::AutoPtr<int> tmp=convertPyToNewIntArr2(li,&size);
+ self->splitByValueRange(tmp,(int *)tmp+size,ret0,ret1,ret2);
+ }
+ else
+ {
+ DataArrayInt *da2=reinterpret_cast< DataArrayInt * >(da);
+ if(!da2)
+ throw INTERP_KERNEL::Exception("Not null DataArrayInt instance expected !");
+ da2->checkAllocated();
+ int size=self->getNumberOfTuples();
+ self->splitByValueRange(da2->getConstPointer(),da2->getConstPointer()+size,ret0,ret1,ret2);
+ }
+ PyObject *ret = PyList_New(3);
+ PyList_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(ret0),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 ));
+ PyList_SetItem(ret,1,SWIG_NewPointerObj(SWIG_as_voidptr(ret1),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 ));
+ PyList_SetItem(ret,2,SWIG_NewPointerObj(SWIG_as_voidptr(ret2),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 ));
+ return ret;
+ }
+
DataArrayInt *transformWithIndArrR(PyObject *li) const
{
void *da=0;
self.assertEqual(expected[i],d3.getIJ(i,0));
pass
pass
+
+ def testDAISplitByValueRange1(self):
+ val1=[6,5,0,3,2,7,8,1,4]
+ val2=[0,4,9]
+ d=DataArrayInt.New();
+ d.setValues(val1,9,1);
+ e,f,g=d.splitByValueRange(val2);
+ self.assertEqual(9,e.getNumberOfTuples());
+ self.assertEqual(1,e.getNumberOfComponents());
+ self.assertEqual(9,f.getNumberOfTuples());
+ self.assertEqual(1,f.getNumberOfComponents());
+ self.assertEqual(2,g.getNumberOfTuples());
+ self.assertEqual(1,g.getNumberOfComponents());
+ #
+ expected1=[1,1,0,0,0,1,1,0,1]
+ expected2=[2,1,0,3,2,3,4,1,0]
+ for i in xrange(9):
+ self.assertEqual(expected1[i],e.getIJ(i,0));
+ self.assertEqual(expected2[i],f.getIJ(i,0));
+ pass
+ self.assertEqual(0,g.getIJ(0,0));
+ self.assertEqual(1,g.getIJ(1,0));
+ #
+ d.setIJ(6,0,9);
+ self.assertRaises(InterpKernelException,d.splitByValueRange,val2);
+ pass
+
+ def testUMeshSplitProfilePerType1(self):
+ val0=[2,0,1,3,4]
+ m=MEDCouplingDataForTest.build2DTargetMesh_1();
+ m.renumberCells(val0,False);
+ #
+ val1=[0,2,3]
+ d=DataArrayInt.New();
+ d.setValues(val1,3,1);
+ d.setName("sup")
+ code,idsInPflPerType,pfls=m.splitProfilePerType(d);
+ self.assertEqual(6,len(code));
+ self.assertEqual(2,len(idsInPflPerType));
+ expected1=[3,1,0, 4,2,1]
+ for i in xrange(6):
+ self.assertEqual(expected1[i],code[i]);
+ pass
+ self.assertEqual(2,len(idsInPflPerType));
+ self.assertEqual(1,idsInPflPerType[0].getNumberOfTuples());
+ self.assertEqual(0,idsInPflPerType[0].getIJ(0,0));
+ self.assertEqual(2,idsInPflPerType[1].getNumberOfTuples());
+ self.assertEqual(1,idsInPflPerType[1].getIJ(0,0));
+ self.assertEqual(2,idsInPflPerType[1].getIJ(1,0));
+ #
+ self.assertEqual(2,len(pfls));
+ self.assertEqual("sup",pfls[0].getName())
+ self.assertEqual(1,pfls[0].getNumberOfTuples());
+ self.assertEqual(0,pfls[0].getIJ(0,0));
+ self.assertEqual("sup",pfls[1].getName())
+ self.assertEqual(2,pfls[1].getNumberOfTuples());
+ self.assertEqual(0,pfls[1].getIJ(0,0));
+ self.assertEqual(1,pfls[1].getIJ(1,0));
+ #
+ val2=[0,2,3,4]
+ d=DataArrayInt.New();
+ d.setValues(val2,4,1);
+ code,idsInPflPerType,pfls=m.splitProfilePerType(d);
+ self.assertEqual(6,len(code));
+ self.assertEqual(2,len(idsInPflPerType));
+ expected2=[3,1,0, 4,3,-1]
+ for i in xrange(6):
+ self.assertEqual(expected2[i],code[i]);
+ pass
+ self.assertEqual(2,len(idsInPflPerType));
+ self.assertEqual(1,idsInPflPerType[0].getNumberOfTuples());
+ self.assertEqual(0,idsInPflPerType[0].getIJ(0,0));
+ self.assertEqual(3,idsInPflPerType[1].getNumberOfTuples());
+ self.assertEqual(1,idsInPflPerType[1].getIJ(0,0));
+ self.assertEqual(2,idsInPflPerType[1].getIJ(1,0));
+ self.assertEqual(3,idsInPflPerType[1].getIJ(2,0));
+ #
+ self.assertEqual(1,len(pfls));
+ self.assertEqual(1,pfls[0].getNumberOfTuples());
+ self.assertEqual(0,pfls[0].getIJ(0,0));
+ #
+ val3=[1,0,2]
+ d=DataArrayInt.New();
+ d.setValues(val3,3,1);
+ code,idsInPflPerType,pfls=m.splitProfilePerType(d);
+ self.assertEqual(6,len(code));
+ self.assertEqual(2,len(idsInPflPerType));
+ expected3=[3,2,0, 4,1,1]
+ for i in xrange(6):
+ self.assertEqual(expected3[i],code[i]);
+ pass
+ self.assertEqual(2,len(idsInPflPerType));
+ self.assertEqual(2,idsInPflPerType[0].getNumberOfTuples());
+ self.assertEqual(0,idsInPflPerType[0].getIJ(0,0));
+ self.assertEqual(1,idsInPflPerType[0].getIJ(1,0));
+ self.assertEqual(1,idsInPflPerType[1].getNumberOfTuples());
+ self.assertEqual(2,idsInPflPerType[1].getIJ(0,0));
+ #
+ self.assertEqual(2,len(pfls));
+ self.assertEqual(2,pfls[0].getNumberOfTuples());
+ self.assertEqual(1,pfls[0].getIJ(0,0));
+ self.assertEqual(0,pfls[0].getIJ(1,0));
+ self.assertEqual(0,pfls[1].getIJ(0,0));
+ #
+ val4=[3,4]
+ d=DataArrayInt.New();
+ d.setValues(val4,2,1);
+ code,idsInPflPerType,pfls=m.splitProfilePerType(d);
+ self.assertEqual(3,len(code));
+ self.assertEqual(1,len(idsInPflPerType));
+ expected4=[4,2,0]
+ for i in xrange(3):
+ self.assertEqual(expected4[i],code[i]);
+ pass
+ self.assertEqual(1,len(idsInPflPerType));
+ self.assertEqual(2,idsInPflPerType[0].getNumberOfTuples());
+ self.assertEqual(0,idsInPflPerType[0].getIJ(0,0));
+ self.assertEqual(1,idsInPflPerType[0].getIJ(1,0));
+ #
+ self.assertEqual(1,len(pfls));
+ self.assertEqual(2,pfls[0].getNumberOfTuples());
+ self.assertEqual(1,pfls[0].getIJ(0,0));
+ self.assertEqual(2,pfls[0].getIJ(1,0));
+ pass
+
+ def testDAIBuildExplicitArrByRanges1(self):
+ d=DataArrayInt.New();
+ vals1=[0,2,3]
+ d.setValues(vals1,3,1);
+ e=DataArrayInt.New();
+ vals2=[0,3,6,10,14,20]
+ e.setValues(vals2,6,1);
+ #
+ f=d.buildExplicitArrByRanges(e);
+ self.assertEqual(11,f.getNumberOfTuples());
+ self.assertEqual(1,f.getNumberOfComponents());
+ expected1=[0,1,2,6,7,8,9,10,11,12,13]
+ for i in xrange(11):
+ self.assertEqual(expected1[i],f.getIJ(i,0));
+ pass
+ pass
+
+ def testDAIComputeOffsets2(self):
+ d=DataArrayInt.New();
+ vals1=[3,5,1,2,0,8]
+ expected1=[0,3,8,9,11,11,19]
+ d.setValues(vals1,6,1);
+ d.computeOffsets2();
+ self.assertEqual(7,d.getNumberOfTuples());
+ self.assertEqual(1,d.getNumberOfComponents());
+ for i in xrange(7):
+ self.assertEqual(expected1[i],d.getIJ(0,i));
+ pass
+ pass
def setUp(self):
pass
--- /dev/null
+// Copyright (C) 2007-2011 CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#include "MEDFileData.hxx"
+
+using namespace ParaMEDMEM;
+
+MEDFileData *MEDFileData::New(const char *fileName) throw(INTERP_KERNEL::Exception)
+{
+ return new MEDFileData(fileName);
+}
+
+MEDFileData *MEDFileData::New()
+{
+ return new MEDFileData;
+}
+
+MEDFileFields *MEDFileData::getFields() const
+{
+ return const_cast<MEDFileFields *>(static_cast<const MEDFileFields *>(_fields));
+}
+
+MEDFileMeshes *MEDFileData::getMeshes() const
+{
+ return const_cast<MEDFileMeshes *>(static_cast<const MEDFileMeshes *>(_meshes));
+}
+
+void MEDFileData::setFields(MEDFileFields *fields) throw(INTERP_KERNEL::Exception)
+{
+ if(!fields)
+ throw INTERP_KERNEL::Exception("MEDFileData::setFields : input pointer is null !");
+ fields->incrRef();
+ _fields=fields;
+}
+
+void MEDFileData::setMeshes(MEDFileMeshes *meshes) throw(INTERP_KERNEL::Exception)
+{
+ if(!meshes)
+ throw INTERP_KERNEL::Exception("MEDFileData::setMeshes : input pointer is null !");
+ meshes->incrRef();
+ _meshes=meshes;
+}
+
+int MEDFileData::getNumberOfFields() const throw(INTERP_KERNEL::Exception)
+{
+ const MEDFileFields *f=_fields;
+ if(!f)
+ throw INTERP_KERNEL::Exception("MEDFileData::getNumberOfFields : no fields set !");
+ return f->getNumberOfFields();
+}
+
+int MEDFileData::getNumberOfMeshes() const throw(INTERP_KERNEL::Exception)
+{
+ const MEDFileMeshes *m=_meshes;
+ if(!m)
+ throw INTERP_KERNEL::Exception("MEDFileData::getNumberOfMeshes : no meshes set !");
+ return m->getNumberOfMeshes();
+}
+
+MEDFileData::MEDFileData()
+{
+}
+
+MEDFileData::MEDFileData(const char *fileName) throw(INTERP_KERNEL::Exception)
+try
+ {
+ _fields=MEDFileFields::New(fileName);
+ _meshes=MEDFileMeshes::New(fileName);
+ }
+catch(INTERP_KERNEL::Exception& e)
+ {
+ throw e;
+ }
+
+void MEDFileData::write(const char *fileName, int mode) const throw(INTERP_KERNEL::Exception)
+{
+ const MEDFileMeshes *ms=_meshes;
+ if(ms)
+ ms->write(fileName,mode);
+ const MEDFileFields *fs=_fields;
+ if(fs)
+ fs->write(fileName,mode);
+}
--- /dev/null
+// Copyright (C) 2007-2011 CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#ifndef __MEDFILEDATA_HXX__
+#define __MEDFILEDATA_HXX__
+
+#include "MEDCouplingAutoRefCountObjectPtr.hxx"
+#include "MEDFileField.hxx"
+#include "MEDFileMesh.hxx"
+
+namespace ParaMEDMEM
+{
+ /*!
+ * User class.
+ */
+ class MEDFileData : public RefCountObject, public MEDFileWritable
+ {
+ public:
+ static MEDFileData *New(const char *fileName) throw(INTERP_KERNEL::Exception);
+ static MEDFileData *New();
+ MEDFileFields *getFields() const;
+ MEDFileMeshes *getMeshes() const;
+ void setFields(MEDFileFields *fields) throw(INTERP_KERNEL::Exception);
+ void setMeshes(MEDFileMeshes *meshes) throw(INTERP_KERNEL::Exception);
+ int getNumberOfFields() const throw(INTERP_KERNEL::Exception);
+ int getNumberOfMeshes() const throw(INTERP_KERNEL::Exception);
+ //
+ void write(const char *fileName, int mode) const throw(INTERP_KERNEL::Exception);
+ private:
+ MEDFileData();
+ MEDFileData(const char *fileName) throw(INTERP_KERNEL::Exception);
+ private:
+ MEDCouplingAutoRefCountObjectPtr<MEDFileFields> _fields;
+ MEDCouplingAutoRefCountObjectPtr<MEDFileMeshes> _meshes;
+ };
+}
+
+#endif
MEDlocalizationWr(fid,_name.c_str(),typmai3[(int)_geo_type],_dim,&_ref_coo[0],MED_FULL_INTERLACE,_nb_gauss_pt,&_gs_coo[0],&_w[0],MED_NO_INTERPOLATION,MED_NO_MESH_SUPPORT);
}
-void MEDFileFieldPerMeshPerTypePerDisc::assignFieldNoProfile(int offset, int nbOfCells, const MEDCouplingFieldDouble *field, MEDFieldFieldGlobs& glob) throw(INTERP_KERNEL::Exception)
+void MEDFileFieldPerMeshPerTypePerDisc::assignFieldNoProfile(int offset, int nbOfCells, const MEDCouplingFieldDouble *field, MEDFieldFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception)
{
_type=field->getTypeOfField();
const DataArrayDouble *da=field->getArray();
}
}
-void MEDFileFieldPerMeshPerTypePerDisc::assignNodeFieldNoProfile(const MEDCouplingFieldDouble *field, MEDFieldFieldGlobs& glob) throw(INTERP_KERNEL::Exception)
+/*!
+ * Leaf method of field with profile assignement.
+ * @param pflName input containing name of profile if any. 0 if no profile.
+ * @param multiTypePfl input containing the profile array \b including \b all \b types. This array is usefull only for GAUSS_NE.
+ * @param idsInPfl input containing the ids in the profile 'multiTypePfl' concerning the current geo type.
+ */
+void MEDFileFieldPerMeshPerTypePerDisc::assignFieldProfile(const char *pflName, const DataArrayInt *multiTypePfl, const DataArrayInt *idsInPfl, const MEDCouplingFieldDouble *field, const MEDCouplingMesh *mesh, MEDFieldFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception)
+{
+ if(pflName)
+ _profile=pflName;
+ else
+ _profile.clear();
+ _type=field->getTypeOfField();
+ const DataArrayDouble *da=field->getArray();
+ switch(_type)
+ {
+ case ON_NODES:
+ {
+ _nval=idsInPfl->getNumberOfTuples();
+ _arr=da->deepCpy();
+ break;
+ }
+ case ON_CELLS:
+ {
+ _nval=idsInPfl->getNumberOfTuples();
+ _arr=da->selectByTupleId(idsInPfl->getConstPointer(),idsInPfl->getConstPointer()+_nval);
+ break;
+ }
+ case ON_GAUSS_NE:
+ {
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr=field->getDiscretization()->getOffsetArr(mesh);
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr2=arr->deltaShiftIndex();
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr3=arr2->selectByTupleId(multiTypePfl->getConstPointer(),multiTypePfl->getConstPointer()+multiTypePfl->getNumberOfTuples());
+ arr3->computeOffsets2();
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> tmp=idsInPfl->buildExplicitArrByRanges(arr3);
+ int trueNval=tmp->getNumberOfTuples();
+ _nval=idsInPfl->getNumberOfTuples();
+ _arr=da->selectByTupleIdSafe(tmp->getConstPointer(),tmp->getConstPointer()+trueNval);
+ break;
+ }
+ case ON_GAUSS_PT:
+ {
+ throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::assignFieldProfile : not implemented yet for profiles on gauss points !");
+ }
+ default:
+ throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::assignFieldProfile : not implemented yet for such discretization type of field !");
+ }
+}
+
+void MEDFileFieldPerMeshPerTypePerDisc::assignNodeFieldNoProfile(const MEDCouplingFieldDouble *field, MEDFieldFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception)
{
_arr=field->getArray()->deepCpy();
_nval=field->getArray()->getNumberOfTuples();
_profile=MEDLoaderBase::buildStringFromFortran(pflname,MED_NAME_SIZE);
_localization=MEDLoaderBase::buildStringFromFortran(locname,MED_NAME_SIZE);
if(type==ON_CELLS && !_localization.empty())
- setType(ON_GAUSS_PT);
+ {
+ if(_localization!="MED_GAUSS_ELNO")
+ setType(ON_GAUSS_PT);
+ else
+ {
+ setType(ON_GAUSS_NE);
+ _localization.clear();
+ }
+ }
}
catch(INTERP_KERNEL::Exception& e)
{
return _localization;
}
-void MEDFileFieldPerMeshPerTypePerDisc::getFieldAtLevel(TypeOfField type, const MEDFieldFieldGlobs *glob, std::vector<const DataArrayDouble *>& dads, std::vector<const DataArrayInt *>& pfls, std::vector<int>& locs, std::vector<INTERP_KERNEL::NormalizedCellType>& geoTypes) const
+void MEDFileFieldPerMeshPerTypePerDisc::getFieldAtLevel(TypeOfField type, const MEDFieldFieldGlobsReal *glob, std::vector<const DataArrayDouble *>& dads, std::vector<const DataArrayInt *>& pfls, std::vector<int>& locs, std::vector<INTERP_KERNEL::NormalizedCellType>& geoTypes) const
{
if(type!=_type)
return ;
return new MEDFileFieldPerMeshPerType(fath,geoType);
}
-void MEDFileFieldPerMeshPerType::assignFieldNoProfile(int offset, int nbOfCells, const MEDCouplingFieldDouble *field, MEDFieldFieldGlobs& glob) throw(INTERP_KERNEL::Exception)
+void MEDFileFieldPerMeshPerType::assignFieldNoProfile(int offset, int nbOfCells, const MEDCouplingFieldDouble *field, MEDFieldFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception)
{
std::vector<int> pos=addNewEntryIfNecessary(field,offset,nbOfCells);
for(std::vector<int>::const_iterator it=pos.begin();it!=pos.end();it++)
_field_pm_pt_pd[*it]->assignFieldNoProfile(offset,nbOfCells,field,glob);
}
-void MEDFileFieldPerMeshPerType::assignNodeFieldNoProfile(const MEDCouplingFieldDouble *field, MEDFieldFieldGlobs& glob) throw(INTERP_KERNEL::Exception)
+void MEDFileFieldPerMeshPerType::assignFieldProfile(const DataArrayInt *multiTypePfl, const DataArrayInt *idsInPfl, DataArrayInt *locIds, const MEDCouplingFieldDouble *field, const MEDCouplingMesh *mesh, MEDFieldFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception)
+{
+ std::vector<int> pos=addNewEntryIfNecessary(field,idsInPfl);
+ if(locIds)
+ {
+ //
+ std::string pflName(locIds->getName());
+ if(pflName.empty())
+ throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerType::assignFieldProfile : existing profile with empty name !");
+ const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
+ std::ostringstream oss; oss << pflName << "_" << cm.getRepr();
+ locIds->setName(oss.str().c_str());
+ glob.appendProfile(locIds);
+ //
+ for(std::vector<int>::const_iterator it=pos.begin();it!=pos.end();it++)
+ _field_pm_pt_pd[*it]->assignFieldProfile(oss.str().c_str(),multiTypePfl,idsInPfl,field,mesh,glob);
+ }
+ else
+ {
+ for(std::vector<int>::const_iterator it=pos.begin();it!=pos.end();it++)
+ _field_pm_pt_pd[*it]->assignFieldProfile(0,multiTypePfl,idsInPfl,field,mesh,glob);
+ }
+}
+
+void MEDFileFieldPerMeshPerType::assignNodeFieldNoProfile(const MEDCouplingFieldDouble *field, MEDFieldFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception)
{
_field_pm_pt_pd.resize(1);
_field_pm_pt_pd[0]=MEDFileFieldPerMeshPerTypePerDisc::New(this,ON_NODES,-3);
_field_pm_pt_pd[0]->assignNodeFieldNoProfile(field,glob);
}
+void MEDFileFieldPerMeshPerType::assignNodeFieldProfile(const DataArrayInt *pfl, const MEDCouplingFieldDouble *field, MEDFieldFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception)
+{
+ std::string pflName(pfl->getName());
+ if(pflName.empty())
+ throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerType::assignNodeFieldProfile : existing profile with empty name !");
+ std::ostringstream oss; oss << pflName << "_NODE";
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> pfl2=pfl->deepCpy();
+ pfl2->setName(oss.str().c_str());
+ glob.appendProfile(pfl2);
+ //
+ _field_pm_pt_pd.resize(1);
+ _field_pm_pt_pd[0]=MEDFileFieldPerMeshPerTypePerDisc::New(this,ON_NODES,-3);
+ _field_pm_pt_pd[0]->assignFieldProfile(oss.str().c_str(),pfl,pfl2,field,0,glob);//mesh is not requested so 0 is send.
+}
+
std::vector<int> MEDFileFieldPerMeshPerType::addNewEntryIfNecessary(const MEDCouplingFieldDouble *field, int offset, int nbOfCells) throw(INTERP_KERNEL::Exception)
{
TypeOfField type=field->getTypeOfField();
return ret;
}
+std::vector<int> MEDFileFieldPerMeshPerType::addNewEntryIfNecessary(const MEDCouplingFieldDouble *field, const DataArrayInt *subCells) throw(INTERP_KERNEL::Exception)
+{
+ TypeOfField type=field->getTypeOfField();
+ if(type!=ON_GAUSS_PT)
+ {
+ int locIdToFind=MEDFileFieldPerMeshPerTypePerDisc::ConvertType(type,0);
+ int sz=_field_pm_pt_pd.size();
+ bool found=false;
+ for(int j=0;j<sz && !found;j++)
+ {
+ if(_field_pm_pt_pd[j]->getLocId()==locIdToFind)
+ {
+ _field_pm_pt_pd[j]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
+ found=true;
+ }
+ }
+ if(!found)
+ {
+ _field_pm_pt_pd.resize(sz+1);
+ _field_pm_pt_pd[sz]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
+ }
+ std::vector<int> ret(1,0);
+ return ret;
+ }
+ else
+ {
+ std::vector<int> ret2=addNewEntryIfNecessaryGauss(field,subCells);
+ int sz2=ret2.size();
+ std::vector<int> ret3(sz2);
+ int k=0;
+ for(int i=0;i<sz2;i++)
+ {
+ int sz=_field_pm_pt_pd.size();
+ int locIdToFind=ret2[i];
+ bool found=false;
+ for(int j=0;j<sz && !found;j++)
+ {
+ if(_field_pm_pt_pd[j]->getLocId()==locIdToFind)
+ {
+ _field_pm_pt_pd[j]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
+ ret3[k++]=j;
+ found=true;
+ }
+ }
+ if(!found)
+ {
+ _field_pm_pt_pd.resize(sz+1);
+ _field_pm_pt_pd[sz]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
+ ret3[k++]=sz;
+ }
+ }
+ return ret3;
+ }
+}
+
+std::vector<int> MEDFileFieldPerMeshPerType::addNewEntryIfNecessaryGauss(const MEDCouplingFieldDouble *field, const DataArrayInt *subCells) throw(INTERP_KERNEL::Exception)
+{
+ const MEDCouplingFieldDiscretization *disc=field->getDiscretization();
+ const MEDCouplingFieldDiscretizationGauss *disc2=dynamic_cast<const MEDCouplingFieldDiscretizationGauss *>(disc);
+ if(!disc2)
+ throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : invalid call to this method ! Internal Error !");
+ const DataArrayInt *da=disc2->getArrayOfDiscIds();
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da2=da->selectByTupleId(subCells->getConstPointer(),subCells->getConstPointer()+subCells->getNumberOfTuples());
+ std::set<int> retTmp=da2->getDifferentValues();
+ if(retTmp.find(-1)!=retTmp.end())
+ throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : some cells have no dicretization description !");
+ std::vector<int> ret(retTmp.begin(),retTmp.end());
+ return ret;
+}
+
const MEDFileFieldPerMesh *MEDFileFieldPerMeshPerType::getFather() const
{
return _father;
return ret;
}
-void MEDFileFieldPerMeshPerType::getFieldAtLevel(int meshDim, TypeOfField type, const MEDFieldFieldGlobs *glob, std::vector<const DataArrayDouble *>& dads, std::vector<const DataArrayInt *>& pfls, std::vector<int>& locs, std::vector<INTERP_KERNEL::NormalizedCellType>& geoTypes) const
+void MEDFileFieldPerMeshPerType::getFieldAtLevel(int meshDim, TypeOfField type, const MEDFieldFieldGlobsReal *glob, std::vector<const DataArrayDouble *>& dads, std::vector<const DataArrayInt *>& pfls, std::vector<int>& locs, std::vector<INTERP_KERNEL::NormalizedCellType>& geoTypes) const
{
if(_geo_type!=INTERP_KERNEL::NORM_ERROR)
{
void MEDFileFieldPerMeshPerType::writeLL(med_idt fid) const throw(INTERP_KERNEL::Exception)
{
- _field_pm_pt_pd[0]->writeLL(fid);
+ for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
+ {
+ (*it)->copyOptionsFrom(*this);
+ (*it)->writeLL(fid);
+ }
}
med_entity_type MEDFileFieldPerMeshPerType::ConvertIntoMEDFileType(TypeOfField ikType, INTERP_KERNEL::NormalizedCellType ikGeoType, med_geometry_type& medfGeoType)
mesh->getTime(_mesh_iteration,_mesh_order);
}
-void MEDFileFieldPerMesh::assignFieldNoProfile(const std::vector<int>& code, const MEDCouplingFieldDouble *field, MEDFieldFieldGlobs& glob) throw(INTERP_KERNEL::Exception)
+void MEDFileFieldPerMesh::assignFieldProfile(const DataArrayInt *multiTypePfl, const std::vector<int>& code, const std::vector<DataArrayInt *>& idsInPflPerType, const std::vector<DataArrayInt *>& idsPerType, const MEDCouplingFieldDouble *field, const MEDCouplingMesh *mesh, MEDFieldFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception)
+{
+ int nbOfTypes=code.size()/3;
+ bool isProfile=false;
+ for(int i=0;i<nbOfTypes;i++)
+ if(code[3*i+2]!=-1)
+ isProfile=true;
+ if(!isProfile)
+ {
+ if(idsInPflPerType.empty())
+ assignFieldNoProfileNoRenum(code,field,glob);
+ else
+ assignFieldProfileGeneral(multiTypePfl,code,idsInPflPerType,idsPerType,field,mesh,glob);
+ }
+ else
+ assignFieldProfileGeneral(multiTypePfl,code,idsInPflPerType,idsPerType,field,mesh,glob);
+}
+
+void MEDFileFieldPerMesh::assignFieldNoProfileNoRenum(const std::vector<int>& code, const MEDCouplingFieldDouble *field, MEDFieldFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception)
{
int nbOfTypes=code.size()/3;
int offset=0;
}
}
-void MEDFileFieldPerMesh::assignNodeFieldNoProfile(const MEDCouplingFieldDouble *field, MEDFieldFieldGlobs& glob) throw(INTERP_KERNEL::Exception)
+/*!
+ * This method is the most general one. No optimization is done here.
+ */
+void MEDFileFieldPerMesh::assignFieldProfileGeneral(const DataArrayInt *multiTypePfl, const std::vector<int>& code, const std::vector<DataArrayInt *>& idsInPflPerType, const std::vector<DataArrayInt *>& idsPerType, const MEDCouplingFieldDouble *field, const MEDCouplingMesh *mesh, MEDFieldFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception)
+{
+ int nbOfTypes=code.size()/3;
+ for(int i=0;i<nbOfTypes;i++)
+ {
+ INTERP_KERNEL::NormalizedCellType type=(INTERP_KERNEL::NormalizedCellType)code[3*i];
+ int pos=addNewEntryIfNecessary(type);
+ DataArrayInt *pfl=0;
+ if(code[3*i+2]!=-1)
+ pfl=idsPerType[code[3*i+2]];
+ _field_pm_pt[pos]->assignFieldProfile(multiTypePfl,idsInPflPerType[i],pfl,field,mesh,glob);
+ }
+}
+
+void MEDFileFieldPerMesh::assignNodeFieldNoProfile(const MEDCouplingFieldDouble *field, MEDFieldFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception)
{
int pos=addNewEntryIfNecessary(INTERP_KERNEL::NORM_ERROR);
_field_pm_pt[pos]->assignNodeFieldNoProfile(field,glob);
}
+void MEDFileFieldPerMesh::assignNodeFieldProfile(const DataArrayInt *pfl, const MEDCouplingFieldDouble *field, MEDFieldFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception)
+{
+ int pos=addNewEntryIfNecessary(INTERP_KERNEL::NORM_ERROR);
+ _field_pm_pt[pos]->assignNodeFieldProfile(pfl,field,glob);
+}
+
void MEDFileFieldPerMesh::finishLoading(med_idt fid) throw(INTERP_KERNEL::Exception)
{
INTERP_KERNEL::AutoPtr<char> meshName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
{
int nbOfTypes=_field_pm_pt.size();
for(int i=0;i<nbOfTypes;i++)
- _field_pm_pt[i]->writeLL(fid);
+ {
+ _field_pm_pt[i]->copyOptionsFrom(*this);
+ _field_pm_pt[i]->writeLL(fid);
+ }
}
void MEDFileFieldPerMesh::getDimension(int& dim) const
}
/*!
- * geoTypes,dads,pfls,locs are input parameters. They should have the same size.
+ * type,geoTypes,dads,pfls,locs are input parameters. They should have the same size.
* Before the call of this method 'geoTypes','dads','pfls','locs' must be reorganized so that types in geoTypes are contiguous and ordered following typmai2 array.
* It returns 2 output vectors :
* - 'code' of size 3*sz where sz is the number of different values into 'geoTypes'
* - 'notNullPfls' contains sz2 values that are extracted from 'pfls' in which null profiles have been removed.
* 'code' and 'notNullPfls' are in MEDCouplingUMesh::checkTypeConsistencyAndContig format.
*/
-void MEDFileFieldPerMesh::SortArraysPerType(const MEDFieldFieldGlobs *glob, const std::vector<INTERP_KERNEL::NormalizedCellType>& geoTypes, const std::vector<const DataArrayDouble *>& dads, const std::vector<const DataArrayInt *>& pfls, const std::vector<int>& locs, std::vector<int>& code, std::vector<DataArrayInt *>& notNullPfls)
+void MEDFileFieldPerMesh::SortArraysPerType(const MEDFieldFieldGlobsReal *glob, TypeOfField type, const std::vector<INTERP_KERNEL::NormalizedCellType>& geoTypes, const std::vector<const DataArrayDouble *>& dads, const std::vector<const DataArrayInt *>& pfls, const std::vector<int>& locs, std::vector<int>& code, std::vector<DataArrayInt *>& notNullPfls)
{
int notNullPflsSz=0;
int nbOfArrs=geoTypes.size();
std::vector<const DataArrayInt *> tmpPfls(pfls.begin()+startZone,pfls.begin()+j);
std::vector<int> tmpLocs(locs.begin()+startZone,locs.begin()+j);
code[3*i]=(int)refType;
- code[3*i+1]=ComputeNbOfElems(glob,tmpDads,tmpLocs);
+ code[3*i+1]=ComputeNbOfElems(glob,type,refType,tmpDads,tmpLocs);
if(notNullTmp.empty())
code[3*i+2]=-1;
else
/*!
* 'dads' and 'locs' are input parameters that should have same size sz. sz should be >=1.
*/
-int MEDFileFieldPerMesh::ComputeNbOfElems(const MEDFieldFieldGlobs *glob, const std::vector<const DataArrayDouble *>& dads, const std::vector<int>& locs) throw(INTERP_KERNEL::Exception)
+int MEDFileFieldPerMesh::ComputeNbOfElems(const MEDFieldFieldGlobsReal *glob, TypeOfField type, INTERP_KERNEL::NormalizedCellType geoType, const std::vector<const DataArrayDouble *>& dads, const std::vector<int>& locs) throw(INTERP_KERNEL::Exception)
{
int sz=dads.size();
int ret=0;
for(int i=0;i<sz;i++)
{
if(locs[i]==-1)
- ret+=dads[i]->getNumberOfTuples();
+ {
+ if(type!=ON_GAUSS_NE)
+ ret+=dads[i]->getNumberOfTuples();
+ else
+ {
+ const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(geoType);
+ ret+=dads[i]->getNumberOfTuples()/cm.getNumberOfNodes();
+ }
+ }
else
{
int nbOfGaussPtPerCell=glob->getNbOfGaussPtPerCell(locs[i]);
return ret;
}
-MEDCouplingFieldDouble *MEDFileFieldPerMesh::getFieldOnMeshAtLevel(TypeOfField type, int meshDim, const MEDFieldFieldGlobs *glob, const MEDCouplingMesh *mesh, bool& isPfl) const throw(INTERP_KERNEL::Exception)
+MEDCouplingFieldDouble *MEDFileFieldPerMesh::getFieldOnMeshAtLevel(TypeOfField type, const MEDFieldFieldGlobsReal *glob, const MEDCouplingMesh *mesh, bool& isPfl) const throw(INTERP_KERNEL::Exception)
{
if(_field_pm_pt.empty())
throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : no types field set !");
std::vector<int> locs,code;
std::vector<INTERP_KERNEL::NormalizedCellType> geoTypes;
for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
- (*it)->getFieldAtLevel(meshDim,type,glob,dads,pfls,locs,geoTypes);
+ (*it)->getFieldAtLevel(mesh->getMeshDimension(),type,glob,dads,pfls,locs,geoTypes);
// Sort by types
- SortArraysPerType(glob,geoTypes,dads,pfls,locs,code,notNullPflsPerGeoType);
+ SortArraysPerType(glob,type,geoTypes,dads,pfls,locs,code,notNullPflsPerGeoType);
if(code.empty())
{
std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevel : " << "The field \"" << getName() << "\" exists but not with such spatial discretization or such dimension specified !";
}
}
+DataArrayDouble *MEDFileFieldPerMesh::getFieldOnMeshAtLevelWithPfl(TypeOfField type, const MEDCouplingMesh *mesh, DataArrayInt *&pfl, const MEDFieldFieldGlobsReal *glob) const throw(INTERP_KERNEL::Exception)
+{
+ if(_field_pm_pt.empty())
+ throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : no types field set !");
+ //
+ std::vector<const DataArrayDouble *> dads;
+ std::vector<const DataArrayInt *> pfls;
+ std::vector<DataArrayInt *> notNullPflsPerGeoType;
+ std::vector<int> locs,code;
+ std::vector<INTERP_KERNEL::NormalizedCellType> geoTypes;
+ for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
+ (*it)->getFieldAtLevel(mesh->getMeshDimension(),type,glob,dads,pfls,locs,geoTypes);
+ // Sort by types
+ SortArraysPerType(glob,type,geoTypes,dads,pfls,locs,code,notNullPflsPerGeoType);
+ if(code.empty())
+ {
+ std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevelWithPfl : " << "The field \"" << getName() << "\" exists but not with such spatial discretization or such dimension specified !";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > notNullPflsPerGeoType2(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
+ std::vector< const DataArrayInt *> notNullPflsPerGeoType3(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
+ if(type!=ON_NODES)
+ {
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr=mesh->checkTypeConsistencyAndContig(code,notNullPflsPerGeoType3);
+ return finishField4(dads,arr,mesh->getNumberOfCells(),pfl);
+ }
+ else
+ {
+ if(code.size()!=3)
+ throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : internal error #1 !");
+ int nb=code[1];
+ if(code[2]==-1)
+ {
+ if(nb!=mesh->getNumberOfNodes())
+ {
+ std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevel : There is a problem there is " << nb << " nodes in field whereas there is " << mesh->getNumberOfNodes();
+ oss << " nodes in mesh !";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ }
+ return finishField4(dads,code[2]==-1?0:notNullPflsPerGeoType3[0],mesh->getNumberOfNodes(),pfl);
+ }
+ //
+ return 0;
+}
+
int MEDFileFieldPerMesh::addNewEntryIfNecessary(INTERP_KERNEL::NormalizedCellType type)
{
int i=0;
return ret;
}
-MEDCouplingFieldDouble *MEDFileFieldPerMesh::finishField(TypeOfField type, const MEDFieldFieldGlobs *glob,
+MEDCouplingFieldDouble *MEDFileFieldPerMesh::finishField(TypeOfField type, const MEDFieldFieldGlobsReal *glob,
const std::vector<const DataArrayDouble *>& dads, const std::vector<int>& locs,
const MEDCouplingMesh *mesh, bool& isPfl) const throw(INTERP_KERNEL::Exception)
{
for(int i=0;i<nbOfArrs;i++)
{
std::vector<const DataArrayDouble *> dads2(1,dads[i]); const std::vector<int> locs2(1,locs[i]);
- int nbOfElems=ComputeNbOfElems(glob,dads2,locs2);
+ int nbOfElems=ComputeNbOfElems(glob,type,INTERP_KERNEL::NORM_ERROR,dads2,locs2);
MEDCouplingAutoRefCountObjectPtr<DataArrayInt> di=DataArrayInt::New();
di->alloc(nbOfElems,1);
di->iota(offset);
* No check of this is performed. 'da' array contains an array in old2New style to be applyied to mesh to obtain the right support.
* The order of cells in the returned field is those imposed by the profile.
*/
-MEDCouplingFieldDouble *MEDFileFieldPerMesh::finishField2(TypeOfField type, const MEDFieldFieldGlobs *glob,
+MEDCouplingFieldDouble *MEDFileFieldPerMesh::finishField2(TypeOfField type, const MEDFieldFieldGlobsReal *glob,
const std::vector<const DataArrayDouble *>& dads, const std::vector<int>& locs,
const MEDCouplingMesh *mesh, const DataArrayInt *da, bool& isPfl) const throw(INTERP_KERNEL::Exception)
{
if(da->isIdentity())
{
int nbOfTuples=da->getNumberOfTuples();
- if(nbOfTuples==ComputeNbOfElems(glob,dads,locs))
+ if(nbOfTuples==ComputeNbOfElems(glob,type,INTERP_KERNEL::NORM_ERROR,dads,locs))//No problem for NORM_ERROR because it is in context of node
return finishField(type,glob,dads,locs,mesh,isPfl);
}
MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=finishField(type,glob,dads,locs,mesh,isPfl);
/*!
* This method is the complement of MEDFileFieldPerMesh::finishField2 method except that this method works for node profiles.
*/
-MEDCouplingFieldDouble *MEDFileFieldPerMesh::finishField3(const MEDFieldFieldGlobs *glob,
+MEDCouplingFieldDouble *MEDFileFieldPerMesh::finishField3(const MEDFieldFieldGlobsReal *glob,
const std::vector<const DataArrayDouble *>& dads, const std::vector<int>& locs,
const MEDCouplingMesh *mesh, const DataArrayInt *da, bool& isPfl) const throw(INTERP_KERNEL::Exception)
{
if(da->isIdentity())
{
int nbOfTuples=da->getNumberOfTuples();
- if(nbOfTuples==ComputeNbOfElems(glob,dads,locs))
+ if(nbOfTuples==ComputeNbOfElems(glob,ON_NODES,INTERP_KERNEL::NORM_ERROR,dads,locs))//No problem for NORM_ERROR because it is in context of node
return finishField(ON_NODES,glob,dads,locs,mesh,isPfl);
}
MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=finishField(ON_NODES,glob,dads,locs,mesh,isPfl);
return 0;
}
+/*!
+ * This method is the most light method of field retrieving.
+ */
+DataArrayDouble *MEDFileFieldPerMesh::finishField4(const std::vector<const DataArrayDouble *>& dads, const DataArrayInt *pflIn, int nbOfElems, DataArrayInt *&pflOut) const throw(INTERP_KERNEL::Exception)
+{
+ if(!pflIn)
+ {
+ pflOut=DataArrayInt::New();
+ pflOut->alloc(nbOfElems,1);
+ pflOut->iota(0);
+ }
+ else
+ {
+ pflOut=const_cast<DataArrayInt*>(pflIn);
+ pflOut->incrRef();
+ }
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> safePfl(pflOut);
+ MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> da=DataArrayDouble::Aggregate(dads);
+ const std::vector<std::string>& infos=getInfo();
+ int nbOfComp=infos.size();
+ for(int i=0;i<nbOfComp;i++)
+ da->setInfoOnComponent(i,infos[i].c_str());
+ safePfl->incrRef();
+ da->incrRef();
+ return da;
+}
+
MEDFileFieldPerMesh::MEDFileFieldPerMesh(MEDFileField1TSWithoutDAS *fath, int meshCsit, int meshIteration, int meshOrder):_mesh_iteration(meshIteration),_mesh_order(meshOrder),
_mesh_csit(meshCsit),_father(fath)
{
void MEDFieldFieldGlobs::loadProfileInFile(med_idt fid, int id, const char *pflName) throw(INTERP_KERNEL::Exception)
{
+ if(id>=(int)_pfls.size())
+ _pfls.resize(id+1);
_pfls[id]=DataArrayInt::New();
int lgth=MEDprofileSizeByName(fid,pflName);
_pfls[id]->setName(pflName);
int sz;
MEDprofileInfo(fid,i+1,pflName,&sz);
std::string pflCpp=MEDLoaderBase::buildStringFromFortran(pflName,MED_NAME_SIZE);
+ if(i>=(int)_pfls.size())
+ _pfls.resize(i+1);
_pfls[i]=DataArrayInt::New();
_pfls[i]->alloc(sz,1);
_pfls[i]->setName(pflCpp.c_str());
_locs[i]->writeLL(fid);
}
-void MEDFieldFieldGlobs::loadGlobals(med_idt fid) throw(INTERP_KERNEL::Exception)
+void MEDFieldFieldGlobs::loadGlobals(med_idt fid, const MEDFieldFieldGlobsReal& real) throw(INTERP_KERNEL::Exception)
{
- std::vector<std::string> profiles=getPflsReallyUsed();
+ std::vector<std::string> profiles=real.getPflsReallyUsed();
int sz=profiles.size();
_pfls.resize(sz);
for(int i=0;i<sz;i++)
loadProfileInFile(fid,i,profiles[i].c_str());
//
- std::vector<std::string> locs=getLocsReallyUsed();
+ std::vector<std::string> locs=real.getLocsReallyUsed();
sz=locs.size();
_locs.resize(sz);
for(int i=0;i<sz;i++)
_locs[i]=MEDFileFieldLoc::New(fid,locs[i].c_str());
}
+MEDFieldFieldGlobs *MEDFieldFieldGlobs::New(const char *fname)
+{
+ return new MEDFieldFieldGlobs(fname);
+}
+
+MEDFieldFieldGlobs *MEDFieldFieldGlobs::New()
+{
+ return new MEDFieldFieldGlobs;
+}
+
MEDFieldFieldGlobs::MEDFieldFieldGlobs(const char *fname):_file_name(fname)
{
}
{
}
+MEDFieldFieldGlobs::~MEDFieldFieldGlobs()
+{
+}
+
void MEDFieldFieldGlobs::setFileName(const char *fileName)
{
_file_name=fileName;
int MEDFieldFieldGlobs::getNbOfGaussPtPerCell(int locId) const throw(INTERP_KERNEL::Exception)
{
- if(locId<0 || locId>=_locs.size())
+ if(locId<0 || locId>=(int)_locs.size())
throw INTERP_KERNEL::Exception("MEDFieldFieldGlobs::getNbOfGaussPtPerCell : Invalid localization id !");
return _locs[locId]->getNbOfGaussPtPerCell();
}
const MEDFileFieldLoc& MEDFieldFieldGlobs::getLocalizationFromId(int locId) const throw(INTERP_KERNEL::Exception)
{
- if(locId<0 || locId>=_locs.size())
+ if(locId<0 || locId>=(int)_locs.size())
throw INTERP_KERNEL::Exception("MEDFieldFieldGlobs::getLocalizationFromId : Invalid localization id !");
return *_locs[locId];
}
_locs.push_back(obj);
}
+MEDFieldFieldGlobsReal::MEDFieldFieldGlobsReal(const char *fname):_globals(MEDFieldFieldGlobs::New(fname))
+{
+}
+
+MEDFieldFieldGlobsReal::MEDFieldFieldGlobsReal():_globals(MEDFieldFieldGlobs::New())
+{
+}
+
+void MEDFieldFieldGlobsReal::shallowCpyGlobs(const MEDFieldFieldGlobsReal& other)
+{
+ _globals=other._globals;
+}
+
+void MEDFieldFieldGlobsReal::loadProfileInFile(med_idt fid, int id, const char *pflName) throw(INTERP_KERNEL::Exception)
+{
+ _globals->loadProfileInFile(fid,id,pflName);
+}
+
+void MEDFieldFieldGlobsReal::loadProfileInFile(med_idt fid, int id)
+{
+ _globals->loadProfileInFile(fid,id);
+}
+
+void MEDFieldFieldGlobsReal::loadGlobals(med_idt fid) throw(INTERP_KERNEL::Exception)
+{
+ _globals->loadGlobals(fid,*this);
+}
+
+void MEDFieldFieldGlobsReal::writeGlobals(med_idt fid, const MEDFileWritable& opt) const throw(INTERP_KERNEL::Exception)
+{
+ _globals->writeGlobals(fid,opt);
+}
+
+std::vector<std::string> MEDFieldFieldGlobsReal::getPfls() const
+{
+ return _globals->getPfls();
+}
+
+std::vector<std::string> MEDFieldFieldGlobsReal::getLocs() const
+{
+ return _globals->getLocs();
+}
+
+void MEDFieldFieldGlobsReal::setFileName(const char *fileName)
+{
+ _globals->setFileName(fileName);
+}
+
+int MEDFieldFieldGlobsReal::getNbOfGaussPtPerCell(int locId) const throw(INTERP_KERNEL::Exception)
+{
+ return _globals->getNbOfGaussPtPerCell(locId);
+}
+
+int MEDFieldFieldGlobsReal::getLocalizationId(const char *loc) const throw(INTERP_KERNEL::Exception)
+{
+ return _globals->getLocalizationId(loc);
+}
+
+const char *MEDFieldFieldGlobsReal::getFileName() const
+{
+ return _globals->getFileName();
+}
+
+std::string MEDFieldFieldGlobsReal::getFileName2() const
+{
+ return _globals->getFileName2();
+}
+
+const MEDFileFieldLoc& MEDFieldFieldGlobsReal::getLocalizationFromId(int locId) const throw(INTERP_KERNEL::Exception)
+{
+ return _globals->getLocalizationFromId(locId);
+}
+
+const DataArrayInt *MEDFieldFieldGlobsReal::getProfile(const std::string& pflName) const throw(INTERP_KERNEL::Exception)
+{
+ return _globals->getProfile(pflName);
+}
+
+void MEDFieldFieldGlobsReal::appendProfile(DataArrayInt *pfl) throw(INTERP_KERNEL::Exception)
+{
+ _globals->appendProfile(pfl);
+}
+
+void MEDFieldFieldGlobsReal::appendLoc(const char *locName, INTERP_KERNEL::NormalizedCellType geoType, const std::vector<double>& refCoo, const std::vector<double>& gsCoo, const std::vector<double>& w) throw(INTERP_KERNEL::Exception)
+{
+ _globals->appendLoc(locName,geoType,refCoo,gsCoo,w);
+}
+
/*!
* This method returns the max dimension of 'this'.
* This method returns -2 if 'this' is empty, -1 if only nodes are defined.
int nbCells=mesh->getNumberOfCellsWithType(*it);
code[3*pos]=(int)(*it);
code[3*pos+1]=nbCells;
- code[3*pos+2]=0;//no profiles
+ code[3*pos+2]=-1;//no profiles
}
std::vector<const DataArrayInt *> idsPerType;//no profiles
DataArrayInt *da=mesh->checkTypeConsistencyAndContig(code,idsPerType);
throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutDAS::writeLL : empty field !");
if(_field_per_mesh.size()>1)
throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutDAS::writeLL : In MED3.0 mode in writting mode only ONE underlying mesh supported !");
+ _field_per_mesh[0]->copyOptionsFrom(*this);
_field_per_mesh[0]->writeLL(fid);
}
-MEDCouplingFieldDouble *MEDFileField1TSWithoutDAS::getFieldAtLevel(TypeOfField type, int meshDimRelToMax, const char *mName, int renumPol, const MEDFieldFieldGlobs *glob) const throw(INTERP_KERNEL::Exception)
+/*!
+ * SBT means Sort By Type.
+ * This method is the most basic method to assign field in this. Basic in sense that no renumbering is done. Underlying mesh in 'field' is globaly ignored except for type contiguous check.
+ */
+void MEDFileField1TSWithoutDAS::setFieldNoProfileSBT(const MEDCouplingFieldDouble *field, MEDFieldFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception)
+{
+ const MEDCouplingMesh *mesh=field->getMesh();
+ //
+ TypeOfField type=field->getTypeOfField();
+ std::vector<DataArrayInt *> dummy;
+ copyTinyInfoFrom(field);
+ if(type!=ON_NODES)
+ {
+ std::vector<int> code=MEDFileField1TSWithoutDAS::CheckSBTMesh(mesh);
+ //
+ int pos=addNewEntryIfNecessary(mesh);
+ _field_per_mesh[pos]->assignFieldProfile(0,code,dummy,dummy,field,0,glob);//mesh is set to 0 because no external mesh is needed to be sent because no profile.
+ }
+ else
+ {
+ int pos=addNewEntryIfNecessary(mesh);
+ _field_per_mesh[pos]->assignNodeFieldNoProfile(field,glob);
+ }
+}
+
+/*!
+ * Generalization of MEDFileField1TSWithoutDAS::setFieldNoProfileSBT method.
+ */
+void MEDFileField1TSWithoutDAS::setFieldProfile(const MEDCouplingFieldDouble *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile, MEDFieldFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception)
+{
+ TypeOfField type=field->getTypeOfField();
+ copyTinyInfoFrom(field);
+ std::vector<DataArrayInt *> idsInPflPerType;
+ std::vector<DataArrayInt *> idsPerType;
+ std::vector<int> code;
+ MEDCouplingAutoRefCountObjectPtr<MEDCouplingMesh> m=mesh->getGenMeshAtLevel(meshDimRelToMax);
+ if(type!=ON_NODES)
+ {
+ m->splitProfilePerType(profile,code,idsInPflPerType,idsPerType);
+ //
+ std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > idsInPflPerType2(idsInPflPerType.size());
+ for(std::size_t i=0;i<idsInPflPerType.size();i++)
+ idsInPflPerType2[i]=idsInPflPerType[i];
+ std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > idsPerType2(idsPerType.size());
+ for(std::size_t i=0;i<idsPerType.size();i++)
+ idsPerType2[i]=idsPerType[i];
+ //
+ int pos=addNewEntryIfNecessary(m);
+ _field_per_mesh[pos]->assignFieldProfile(profile,code,idsInPflPerType,idsPerType,field,m,glob);
+ }
+ else
+ {
+ int pos=addNewEntryIfNecessary(m);
+ _field_per_mesh[pos]->assignNodeFieldProfile(profile,field,glob);
+ }
+}
+
+MEDCouplingFieldDouble *MEDFileField1TSWithoutDAS::getFieldAtLevel(TypeOfField type, int meshDimRelToMax, const char *mName, int renumPol, const MEDFieldFieldGlobsReal *glob) const throw(INTERP_KERNEL::Exception)
{
MEDCouplingAutoRefCountObjectPtr<MEDFileMesh> mm;
if(mName==0)
return MEDFileField1TSWithoutDAS::getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,glob,mm);
}
-MEDCouplingFieldDouble *MEDFileField1TSWithoutDAS::getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, int renumPol, const MEDFieldFieldGlobs *glob, const MEDFileMesh *mesh) const throw(INTERP_KERNEL::Exception)
+MEDCouplingFieldDouble *MEDFileField1TSWithoutDAS::getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, int renumPol, const MEDFieldFieldGlobsReal *glob, const MEDFileMesh *mesh) const throw(INTERP_KERNEL::Exception)
{
CheckMeshDimRel(meshDimRelToMax);
MEDCouplingAutoRefCountObjectPtr<MEDCouplingMesh> m=mesh->getGenMeshAtLevel(meshDimRelToMax,false);
return MEDFileField1TSWithoutDAS::getFieldOnMeshAtLevel(type,renumPol,glob,m,d,e);
}
-MEDCouplingFieldDouble *MEDFileField1TSWithoutDAS::getFieldOnMeshAtLevel(TypeOfField type, int renumPol, const MEDFieldFieldGlobs *glob, const MEDCouplingMesh *mesh, const DataArrayInt *cellRenum, const DataArrayInt *nodeRenum) const throw(INTERP_KERNEL::Exception)
+MEDCouplingFieldDouble *MEDFileField1TSWithoutDAS::getFieldOnMeshAtLevel(TypeOfField type, int renumPol, const MEDFieldFieldGlobsReal *glob, const MEDCouplingMesh *mesh, const DataArrayInt *cellRenum, const DataArrayInt *nodeRenum) const throw(INTERP_KERNEL::Exception)
{
static const char msg1[]="MEDFileField1TSWithoutDAS::getFieldOnMeshAtLevel : request for a renumbered field following mesh numbering whereas it is a profile field !";
- int dimRequested=mesh->getMeshDimension();
int meshId=getMeshIdFromMeshName(mesh->getName());
bool isPfl=false;
- MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=_field_per_mesh[meshId]->getFieldOnMeshAtLevel(type,dimRequested,glob,mesh,isPfl);
+ MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=_field_per_mesh[meshId]->getFieldOnMeshAtLevel(type,glob,mesh,isPfl);
switch(renumPol)
{
case 0:
}
}
+DataArrayDouble *MEDFileField1TSWithoutDAS::getFieldWithProfile(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl, const MEDFieldFieldGlobsReal *glob) const throw(INTERP_KERNEL::Exception)
+{
+ MEDCouplingAutoRefCountObjectPtr<MEDCouplingMesh> m=mesh->getGenMeshAtLevel(meshDimRelToMax);
+ int meshId=getMeshIdFromMeshName(mesh->getName());
+ return _field_per_mesh[meshId]->getFieldOnMeshAtLevelWithPfl(type,m,pfl,glob);
+}
+
MEDFileField1TSWithoutDAS::MEDFileField1TSWithoutDAS(const char *fieldName, int csit, int iteration, int order,
const std::vector<std::string>& infos):_name(fieldName),_infos(infos),_csit(csit),_iteration(iteration),_order(order)
{
MEDLoaderBase::safeStrCpy2(c.c_str(),MED_SNAME_SIZE-1,comp+i*MED_SNAME_SIZE,_too_long_str);
MEDLoaderBase::safeStrCpy2(u.c_str(),MED_SNAME_SIZE-1,unit+i*MED_SNAME_SIZE,_too_long_str);
}
+ if(_name.empty())
+ throw INTERP_KERNEL::Exception("MEDFileField1TS::write : MED file does not accept field with empty name !");
MEDfieldCr(fid,_name.c_str(),MED_FLOAT64,nbComp,comp,unit,getDtUnit().c_str(),getMeshName().c_str());
writeGlobals(fid,*this);
writeLL(fid);
}
MEDFileField1TS::MEDFileField1TS(const char *fileName, const char *fieldName, int iteration, int order) throw(INTERP_KERNEL::Exception)
-try:MEDFileField1TSWithoutDAS(fieldName,-1,iteration,order,std::vector<std::string>()),MEDFieldFieldGlobs(fileName)
+try:MEDFileField1TSWithoutDAS(fieldName,-1,iteration,order,std::vector<std::string>()),MEDFieldFieldGlobsReal(fileName)
{
MEDFileUtilities::CheckFileForRead(fileName);
MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
*/
MEDCouplingFieldDouble *MEDFileField1TS::getFieldAtLevel(TypeOfField type, int meshDimRelToMax, int renumPol) const throw(INTERP_KERNEL::Exception)
{
- if(_file_name.empty())
+ if(getFileName2().empty())
throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
return MEDFileField1TSWithoutDAS::getFieldAtLevel(type,meshDimRelToMax,0,renumPol,this);
}
*/
MEDCouplingFieldDouble *MEDFileField1TS::getFieldAtLevelOld(TypeOfField type, const char *mname, int meshDimRelToMax, int renumPol) const throw(INTERP_KERNEL::Exception)
{
- if(_file_name.empty())
+ if(getFileName2().empty())
throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
return MEDFileField1TSWithoutDAS::getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this);
}
+DataArrayDouble *MEDFileField1TS::getFieldWithProfile(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const throw(INTERP_KERNEL::Exception)
+{
+ return MEDFileField1TSWithoutDAS::getFieldWithProfile(type,meshDimRelToMax,mesh,pfl,this);
+}
+
/*!
* SBT means Sort By Type.
* This method is the most basic method to assign field in this. Basic in sense that no renumbering is done. Underlying mesh in 'field' is globaly ignored except for type contiguous check.
*/
void MEDFileField1TS::setFieldNoProfileSBT(const MEDCouplingFieldDouble *field) throw(INTERP_KERNEL::Exception)
{
- _file_name="";
- const MEDCouplingMesh *mesh=field->getMesh();
- //
- TypeOfField type=field->getTypeOfField();
- if(type!=ON_NODES)
- {
- std::vector<int> code=MEDFileField1TSWithoutDAS::CheckSBTMesh(mesh);
- copyTinyInfoFrom(field);
- //
- int pos=addNewEntryIfNecessary(mesh);
- _field_per_mesh[pos]->assignFieldNoProfile(code,field,*this);
- }
- else
- {
- copyTinyInfoFrom(field);
- int pos=addNewEntryIfNecessary(mesh);
- _field_per_mesh[pos]->assignNodeFieldNoProfile(field,*this);
- }
+ setFileName("");
+ MEDFileField1TSWithoutDAS::setFieldNoProfileSBT(field,*this);
+}
+
+/*!
+ * This method is a generalization of MEDFileField1TS::setFieldNoProfileSBT method. Here a profile array is given in input.
+ * The support of field 'field' is \b not used by this method, so it can be null or incoherent with field.
+ * This method uses input parameters 'mesh', 'meshDimRelToMax' and 'profile' to determine what is really the support of field 'field'. If field is incoherent regarding this deduced support,
+ * an exception will be thrown.
+ * This method is trying to reduce the size of MEDfile file so profile is created only if it is absolutely necessary. If it is necessary the name of 'profile' will be used to create it in 'this'.
+ * In this case, if this profile name is empty an exception will be thrown.
+ */
+void MEDFileField1TS::setFieldProfile(const MEDCouplingFieldDouble *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile) throw(INTERP_KERNEL::Exception)
+{
+ setFileName("");
+ MEDFileField1TSWithoutDAS::setFieldProfile(field,mesh,meshDimRelToMax,profile,*this);
}
MEDFileFieldMultiTSWithoutDAS *MEDFileFieldMultiTSWithoutDAS::New(med_idt fid, const char *fieldName, int id, const std::vector<std::string>& infos, int nbOfStep) throw(INTERP_KERNEL::Exception)
return new MEDFileFieldMultiTSWithoutDAS(fid,fieldName,id,infos,nbOfStep);
}
+MEDFileFieldMultiTSWithoutDAS::MEDFileFieldMultiTSWithoutDAS()
+{
+}
+
MEDFileFieldMultiTSWithoutDAS::MEDFileFieldMultiTSWithoutDAS(const char *fieldName):_name(fieldName)
{
}
MEDFileFieldMultiTSWithoutDAS::MEDFileFieldMultiTSWithoutDAS(med_idt fid, const char *fieldName, int id, const std::vector<std::string>& infos, int nbOfStep) throw(INTERP_KERNEL::Exception)
-try:_name(fieldName)
+try:_name(fieldName),_infos(infos)
{
finishLoading(fid,nbOfStep);
}
return _time_steps[0]->getDtUnit();
}
+std::string MEDFileFieldMultiTSWithoutDAS::getName() const
+{
+ return _name;
+}
+
+std::vector< std::pair<int,int> > MEDFileFieldMultiTSWithoutDAS::getTimeSteps(std::vector<double>& ret1) const throw(INTERP_KERNEL::Exception)
+{
+ std::size_t sz=_time_steps.size();
+ std::vector< std::pair<int,int> > ret(sz);
+ ret1.resize(sz);
+ for(std::size_t i=0;i<sz;i++)
+ {
+ const MEDFileField1TSWithoutDAS *f1ts=_time_steps[i];
+ if(f1ts)
+ {
+ ret[i].first=f1ts->getIteration();
+ ret[i].second=f1ts->getOrder();
+ ret1[i]=f1ts->getTime();
+ }
+ else
+ {
+ std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutDAS::getTimeSteps : At rank #" << i << " time step is not defined !";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ }
+ return ret;
+}
+
void MEDFileFieldMultiTSWithoutDAS::finishLoading(med_idt fid, int nbPdt) throw(INTERP_KERNEL::Exception)
{
_time_steps.resize(nbPdt);
}
}
+void MEDFileFieldMultiTSWithoutDAS::copyTinyInfoFrom(const MEDCouplingFieldDouble *field) throw(INTERP_KERNEL::Exception)
+{
+ _name=field->getName();
+ if(_name.empty())
+ throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutDAS::copyTinyInfoFrom : unsupported fields with no name in MED file !");
+ const DataArrayDouble *arr=field->getArray();
+ if(!arr)
+ throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutDAS::copyTinyInfoFrom : no array set !");
+ _infos=arr->getInfoOnComponent();
+}
+
+void MEDFileFieldMultiTSWithoutDAS::checkCoherencyOfTinyInfo(const MEDCouplingFieldDouble *field) const throw(INTERP_KERNEL::Exception)
+{
+ static const char MSG[]="MEDFileFieldMultiTSWithoutDAS::checkCoherencyOfTinyInfo : invalid ";
+ if(_name!=field->getName())
+ {
+ std::ostringstream oss; oss << MSG << "name ! should be \"" << _name;
+ oss << "\" and it is set in input field to \"" << field->getName() << "\" !";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ const DataArrayDouble *arr=field->getArray();
+ if(!arr)
+ throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutDAS::checkCoherencyOfTinyInfo : no array set !");
+ if(_infos!=arr->getInfoOnComponent())
+ {
+ std::ostringstream oss; oss << MSG << "components ! should be \"";
+ std::copy(_infos.begin(),_infos.end(),std::ostream_iterator<std::string>(oss,", "));
+ oss << " But compo in input fields are : ";
+ std::vector<std::string> tmp=arr->getInfoOnComponent();
+ std::copy(tmp.begin(),tmp.end(),std::ostream_iterator<std::string>(oss,", "));
+ oss << " !";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+}
+
void MEDFileFieldMultiTSWithoutDAS::writeLL(med_idt fid) const throw(INTERP_KERNEL::Exception)
{
if(_time_steps.empty())
MEDLoaderBase::safeStrCpy2(c.c_str(),MED_SNAME_SIZE-1,comp+i*MED_SNAME_SIZE,_too_long_str);
MEDLoaderBase::safeStrCpy2(u.c_str(),MED_SNAME_SIZE-1,unit+i*MED_SNAME_SIZE,_too_long_str);
}
+ if(_name.empty())
+ throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutDAS::write : MED file does not accept field with empty name !");
MEDfieldCr(fid,_name.c_str(),MED_FLOAT64,nbComp,comp,unit,getDtUnit().c_str(),getMeshName().c_str());
int nbOfTS=_time_steps.size();
for(int i=0;i<nbOfTS;i++)
return ret;
}
+MEDFileFieldMultiTS *MEDFileFieldMultiTS::New()
+{
+ return new MEDFileFieldMultiTS;
+}
+
MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(const char *fileName, const char *fieldName) throw(INTERP_KERNEL::Exception)
{
return new MEDFileFieldMultiTS(fileName,fieldName);
}
+MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(const MEDFileFieldMultiTSWithoutDAS& other)
+{
+ return new MEDFileFieldMultiTS(other);
+}
+
void MEDFileFieldMultiTS::write(const char *fileName, int mode) const throw(INTERP_KERNEL::Exception)
{
med_access_mode medmod=MEDFileUtilities::TraduceWriteMode(mode);
return myF1TS.getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this);
}
+DataArrayDouble *MEDFileFieldMultiTS::getFieldWithProfile(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const throw(INTERP_KERNEL::Exception)
+{
+ const MEDFileField1TSWithoutDAS& myF1TS=getTimeStepEntry(iteration,order);
+ return myF1TS.getFieldWithProfile(type,meshDimRelToMax,mesh,pfl,this);
+}
+
+void MEDFileFieldMultiTS::appendFieldNoProfileSBT(const MEDCouplingFieldDouble *field) throw(INTERP_KERNEL::Exception)
+{
+ if(_time_steps.empty())
+ {
+ MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSWithoutDAS> obj=new MEDFileField1TSWithoutDAS;
+ obj->setFieldNoProfileSBT(field,*this);
+ copyTinyInfoFrom(field);
+ _time_steps.push_back(obj);
+ }
+ else
+ {
+ checkCoherencyOfTinyInfo(field);
+ MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSWithoutDAS> obj=new MEDFileField1TSWithoutDAS;
+ obj->setFieldNoProfileSBT(field,*this);
+ _time_steps.push_back(obj);
+ }
+}
+
+void MEDFileFieldMultiTS::appendFieldProfile(const MEDCouplingFieldDouble *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile) throw(INTERP_KERNEL::Exception)
+{
+ if(_time_steps.empty())
+ {
+ MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSWithoutDAS> obj=new MEDFileField1TSWithoutDAS;
+ obj->setFieldProfile(field,mesh,meshDimRelToMax,profile,*this);
+ copyTinyInfoFrom(field);
+ _time_steps.push_back(obj);
+ }
+ else
+ {
+ checkCoherencyOfTinyInfo(field);
+ MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSWithoutDAS> obj=new MEDFileField1TSWithoutDAS;
+ obj->setFieldProfile(field,mesh,meshDimRelToMax,profile,*this);
+ _time_steps.push_back(obj);
+ }
+}
+
+MEDFileFieldMultiTS::MEDFileFieldMultiTS()
+{
+}
+
MEDFileFieldMultiTS::MEDFileFieldMultiTS(const char *fileName, const char *fieldName) throw(INTERP_KERNEL::Exception)
-try:MEDFileFieldMultiTSWithoutDAS(fieldName),MEDFieldFieldGlobs(fileName)
+try:MEDFileFieldMultiTSWithoutDAS(fieldName),MEDFieldFieldGlobsReal(fileName)
{
MEDFileUtilities::CheckFileForRead(fileName);
MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
throw e;
}
+MEDFileFieldMultiTS::MEDFileFieldMultiTS(const MEDFileFieldMultiTSWithoutDAS& other):MEDFileFieldMultiTSWithoutDAS(other)
+{
+}
+
std::vector<std::string> MEDFileFieldMultiTS::getPflsReallyUsed() const
{
return getPflsReallyUsed2();
return getLocsReallyUsed2();
}
+MEDFileFields *MEDFileFields::New()
+{
+ return new MEDFileFields;
+}
+
MEDFileFields *MEDFileFields::New(const char *fileName) throw(INTERP_KERNEL::Exception)
{
return new MEDFileFields(fileName);
return _fields.size();
}
+std::vector<std::string> MEDFileFields::getFieldsNames() const throw(INTERP_KERNEL::Exception)
+{
+ std::vector<std::string> ret(_fields.size());
+ int i=0;
+ for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTSWithoutDAS> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
+ {
+ const MEDFileFieldMultiTSWithoutDAS *f=(*it);
+ if(f)
+ {
+ ret[i]=f->getName();
+ }
+ else
+ {
+ std::ostringstream oss; oss << "MEDFileFields::getFieldsNames : At rank #" << i << " field is not defined !";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ }
+ return ret;
+}
+
+MEDFileFields::MEDFileFields()
+{
+}
+
MEDFileFields::MEDFileFields(const char *fileName) throw(INTERP_KERNEL::Exception)
-try:MEDFieldFieldGlobs(fileName)
+try:MEDFieldFieldGlobsReal(fileName)
{
MEDFileUtilities::CheckFileForRead(fileName);
MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
MEDfieldInfo(fid,i+1,nomcha,nomMaa,&localMesh,&typcha,comp,unit,dtunit,&nbOfStep);
std::vector<std::string> infos(ncomp);
for(int j=0;j<ncomp;j++)
- infos[j]=MEDLoaderBase::buildUnionUnit((char *)comp+i*MED_SNAME_SIZE,MED_SNAME_SIZE,(char *)unit+i*MED_SNAME_SIZE,MED_SNAME_SIZE);
- _fields[i]=MEDFileFieldMultiTSWithoutDAS::New(fid,nomcha,i,infos,nbOfStep);
+ infos[j]=MEDLoaderBase::buildUnionUnit((char *)comp+j*MED_SNAME_SIZE,MED_SNAME_SIZE,(char *)unit+j*MED_SNAME_SIZE,MED_SNAME_SIZE);
+ _fields[i]=MEDFileFieldMultiTSWithoutDAS::New(fid,nomcha,i+1,infos,nbOfStep);
}
int nProfil=MEDnProfile(fid);
- _pfls.resize(nProfil);
for(int i=0;i<nProfil;i++)
loadProfileInFile(fid,i);
}
throw e;
}
+void MEDFileFields::write(const char *fileName, int mode) const throw(INTERP_KERNEL::Exception)
+{
+ int i=0;
+ med_access_mode medmod=MEDFileUtilities::TraduceWriteMode(mode);
+ MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,medmod);
+ for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTSWithoutDAS> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
+ {
+ const MEDFileFieldMultiTSWithoutDAS *elt=*it;
+ if(!elt)
+ {
+ std::ostringstream oss; oss << "MEDFileFields::write : at rank #" << i << "/" << _fields.size() << " field is empty !";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ elt->copyOptionsFrom(*this);
+ elt->writeLL(fid);
+ }
+}
+
std::vector<std::string> MEDFileFields::getPflsReallyUsed() const
{
std::vector<std::string> ret;
return ret;
}
+void MEDFileFields::resize(int newSize) throw(INTERP_KERNEL::Exception)
+{
+ _fields.resize(newSize);
+}
+
+void MEDFileFields::pushField(MEDFileFieldMultiTS *field) throw(INTERP_KERNEL::Exception)
+{
+ if(!field)
+ throw INTERP_KERNEL::Exception("MEDFileFields::pushMesh : invalid input pointer ! should be different from 0 !");
+ field->incrRef();
+ _fields.push_back(field);
+}
+
+void MEDFileFields::setFieldAtPos(int i, MEDFileFieldMultiTS *field) throw(INTERP_KERNEL::Exception)
+{
+ if(!field)
+ throw INTERP_KERNEL::Exception("MEDFileFields::setFieldAtPos : invalid input pointer ! should be different from 0 !");
+ if(i>=(int)_fields.size())
+ _fields.resize(i+1);
+ field->incrRef();
+ _fields[i]=field;
+}
+
+void MEDFileFields::destroyFieldAtPos(int i) throw(INTERP_KERNEL::Exception)
+{
+ if(i<0 || i>=(int)_fields.size())
+ {
+ std::ostringstream oss; oss << "MEDFileFields::destroyMeshAtPos : Invalid given id in input (" << i << ") should be in [0," << _fields.size() << ") !";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ _fields.erase(_fields.begin()+i);
+}
+
+MEDFileFieldMultiTS *MEDFileFields::getFieldAtPos(int i) const throw(INTERP_KERNEL::Exception)
+{
+ if(i<0 || i>=(int)_fields.size())
+ {
+ std::ostringstream oss; oss << "MEDFileFields::getFieldAtPos : Invalid given id in input (" << i << ") should be in [0," << _fields.size() << ") !";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ const MEDFileFieldMultiTSWithoutDAS *fmts=_fields[i];
+ MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTS> ret=MEDFileFieldMultiTS::New(*fmts);
+ ret->shallowCpyGlobs(*this);
+ ret->incrRef();
+ return ret;
+}
+
+MEDFileFieldMultiTS *MEDFileFields::getField(const char *fieldName) const throw(INTERP_KERNEL::Exception)
+{
+ return getFieldAtPos(getPosFromFieldName(fieldName));
+}
+
+int MEDFileFields::getPosFromFieldName(const char *fieldName) const throw(INTERP_KERNEL::Exception)
+{
+ std::string tmp(fieldName);
+ std::vector<std::string> poss;
+ for(std::size_t i=0;i<_fields.size();i++)
+ {
+ const MEDFileFieldMultiTSWithoutDAS *f=_fields[i];
+ if(f)
+ {
+ std::string fname(f->getName());
+ if(tmp==fname)
+ return i;
+ else
+ poss.push_back(fname);
+ }
+ }
+ std::ostringstream oss; oss << "MEDFileFields::getPosFromFieldName : impossible to find field '" << tmp << "' in this ! Possibilities are : ";
+ std::copy(poss.begin(),poss.end(),std::ostream_iterator<std::string>(oss,", "));
+ oss << " !";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+}
class MEDFileFieldPerMeshPerType;
class MEDFileField1TSWithoutDAS;
+ class MEDFieldFieldGlobsReal;
class MEDFileFieldPerMesh;
class MEDFileFieldPerMeshPerTypePerDisc : public RefCountObject, public MEDFileWritable
public:
static MEDFileFieldPerMeshPerTypePerDisc *New(MEDFileFieldPerMeshPerType *fath, med_idt fid, TypeOfField type, int profileIt) throw(INTERP_KERNEL::Exception);
static MEDFileFieldPerMeshPerTypePerDisc *New(MEDFileFieldPerMeshPerType *fath, TypeOfField type, int locId);
- void assignFieldNoProfile(int offset, int nbOfCells, const MEDCouplingFieldDouble *field, MEDFieldFieldGlobs& glob) throw(INTERP_KERNEL::Exception);
- void assignNodeFieldNoProfile(const MEDCouplingFieldDouble *field, MEDFieldFieldGlobs& glob) throw(INTERP_KERNEL::Exception);
+ void assignFieldNoProfile(int offset, int nbOfCells, const MEDCouplingFieldDouble *field, MEDFieldFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception);
+ void assignFieldProfile(const char *pflName, const DataArrayInt *multiTypePfl, const DataArrayInt *idsInPfl, const MEDCouplingFieldDouble *field, const MEDCouplingMesh *mesh, MEDFieldFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception);
+ void assignNodeFieldNoProfile(const MEDCouplingFieldDouble *field, MEDFieldFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception);
+ void assignNodeFieldProfile(const char *pflName, const DataArrayInt *idsInPfl, const MEDCouplingFieldDouble *field, const MEDCouplingMesh *mesh, MEDFieldFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception);
void writeLL(med_idt fid) const throw(INTERP_KERNEL::Exception);
const MEDFileFieldPerMeshPerType *getFather() const;
int getIteration() const;
std::string getProfile() const;
std::string getLocalization() const;
int getLocId() const { return _loc_id; }
- void getFieldAtLevel(TypeOfField type, const MEDFieldFieldGlobs *glob, std::vector<const DataArrayDouble *>& dads, std::vector<const DataArrayInt *>& pfls, std::vector<int>& locs,
+ void getFieldAtLevel(TypeOfField type, const MEDFieldFieldGlobsReal *glob, std::vector<const DataArrayDouble *>& dads, std::vector<const DataArrayInt *>& pfls, std::vector<int>& locs,
std::vector<INTERP_KERNEL::NormalizedCellType>& geoTypes) const;
static int ConvertType(TypeOfField type, int locId) throw(INTERP_KERNEL::Exception);
private:
{
public:
static MEDFileFieldPerMeshPerType *New(MEDFileFieldPerMesh *fath, INTERP_KERNEL::NormalizedCellType geoType) throw(INTERP_KERNEL::Exception);
- void assignFieldNoProfile(int offset, int nbOfCells, const MEDCouplingFieldDouble *field, MEDFieldFieldGlobs& glob) throw(INTERP_KERNEL::Exception);
- void assignNodeFieldNoProfile(const MEDCouplingFieldDouble *field, MEDFieldFieldGlobs& glob) throw(INTERP_KERNEL::Exception);
+ void assignFieldNoProfile(int offset, int nbOfCells, const MEDCouplingFieldDouble *field, MEDFieldFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception);
+ void assignFieldProfile(const DataArrayInt *multiTypePfl, const DataArrayInt *idsInPfl, DataArrayInt *locIds, const MEDCouplingFieldDouble *field, const MEDCouplingMesh *mesh, MEDFieldFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception);
+ void assignNodeFieldNoProfile(const MEDCouplingFieldDouble *field, MEDFieldFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception);
+ void assignNodeFieldProfile(const DataArrayInt *pfl, const MEDCouplingFieldDouble *field, MEDFieldFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception);
const MEDFileFieldPerMesh *getFather() const;
void finishLoading(med_idt fid, TypeOfField type) throw(INTERP_KERNEL::Exception);
void writeLL(med_idt fid) const throw(INTERP_KERNEL::Exception);
const std::vector<std::string>& getInfo() const;
std::vector<std::string> getPflsReallyUsed() const;
std::vector<std::string> getLocsReallyUsed() const;
- void getFieldAtLevel(int meshDim, TypeOfField type, const MEDFieldFieldGlobs *glob, std::vector<const DataArrayDouble *>& dads, std::vector<const DataArrayInt *>& pfls, std::vector<int>& locs, std::vector<INTERP_KERNEL::NormalizedCellType>& geoTypes) const;
+ void getFieldAtLevel(int meshDim, TypeOfField type, const MEDFieldFieldGlobsReal *glob, std::vector<const DataArrayDouble *>& dads, std::vector<const DataArrayInt *>& pfls, std::vector<int>& locs, std::vector<INTERP_KERNEL::NormalizedCellType>& geoTypes) const;
static med_entity_type ConvertIntoMEDFileType(TypeOfField ikType, INTERP_KERNEL::NormalizedCellType ikGeoType, med_geometry_type& medfGeoType);
private:
std::vector<int> addNewEntryIfNecessary(const MEDCouplingFieldDouble *field, int offset, int nbOfCells) throw(INTERP_KERNEL::Exception);
std::vector<int> addNewEntryIfNecessaryGauss(const MEDCouplingFieldDouble *field, int offset, int nbOfCells) throw(INTERP_KERNEL::Exception);
+ std::vector<int> addNewEntryIfNecessary(const MEDCouplingFieldDouble *field, const DataArrayInt *subCells) throw(INTERP_KERNEL::Exception);
+ std::vector<int> addNewEntryIfNecessaryGauss(const MEDCouplingFieldDouble *field, const DataArrayInt *subCells) throw(INTERP_KERNEL::Exception);
MEDFileFieldPerMeshPerType(MEDFileFieldPerMesh *fath, INTERP_KERNEL::NormalizedCellType geoType) throw(INTERP_KERNEL::Exception);
private:
MEDFileFieldPerMesh *_father;
static MEDFileFieldPerMesh *New(MEDFileField1TSWithoutDAS *fath, const MEDCouplingMesh *mesh);
static MEDFileFieldPerMesh *New(MEDFileField1TSWithoutDAS *fath, int meshCsit, int meshIteration, int meshOrder);
void copyTinyInfoFrom(const MEDCouplingMesh *mesh) throw(INTERP_KERNEL::Exception);
- void assignFieldNoProfile(const std::vector<int>& code, const MEDCouplingFieldDouble *field, MEDFieldFieldGlobs& glob) throw(INTERP_KERNEL::Exception);
- void assignNodeFieldNoProfile(const MEDCouplingFieldDouble *field, MEDFieldFieldGlobs& glob) throw(INTERP_KERNEL::Exception);
+ void assignFieldProfile(const DataArrayInt *multiTypePfl, const std::vector<int>& code, const std::vector<DataArrayInt *>& idsInPflPerType, const std::vector<DataArrayInt *>& idsPerType, const MEDCouplingFieldDouble *field, const MEDCouplingMesh *mesh, MEDFieldFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception);
+ void assignFieldProfileGeneral(const DataArrayInt *multiTypePfl, const std::vector<int>& code, const std::vector<DataArrayInt *>& idsInPflPerType, const std::vector<DataArrayInt *>& idsPerType, const MEDCouplingFieldDouble *field, const MEDCouplingMesh *mesh, MEDFieldFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception);
+ void assignFieldNoProfileNoRenum(const std::vector<int>& code, const MEDCouplingFieldDouble *field, MEDFieldFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception);
+ void assignNodeFieldNoProfile(const MEDCouplingFieldDouble *field, MEDFieldFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception);
+ void assignNodeFieldProfile(const DataArrayInt *pfl, const MEDCouplingFieldDouble *field, MEDFieldFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception);
void finishLoading(med_idt fid) throw(INTERP_KERNEL::Exception);
void writeLL(med_idt fid) const throw(INTERP_KERNEL::Exception);
void getDimension(int& dim) const;
const std::vector<std::string>& getInfo() const;
std::vector<std::string> getPflsReallyUsed() const;
std::vector<std::string> getLocsReallyUsed() const;
- MEDCouplingFieldDouble *getFieldOnMeshAtLevel(TypeOfField type, int meshDim, const MEDFieldFieldGlobs *glob, const MEDCouplingMesh *mesh, bool& isPfl) const throw(INTERP_KERNEL::Exception);
+ MEDCouplingFieldDouble *getFieldOnMeshAtLevel(TypeOfField type, const MEDFieldFieldGlobsReal *glob, const MEDCouplingMesh *mesh, bool& isPfl) const throw(INTERP_KERNEL::Exception);
+ DataArrayDouble *getFieldOnMeshAtLevelWithPfl(TypeOfField type, const MEDCouplingMesh *mesh, DataArrayInt *&pfl, const MEDFieldFieldGlobsReal *glob) const throw(INTERP_KERNEL::Exception);
private:
int addNewEntryIfNecessary(INTERP_KERNEL::NormalizedCellType type);
- MEDCouplingFieldDouble *finishField(TypeOfField type, const MEDFieldFieldGlobs *glob,
+ MEDCouplingFieldDouble *finishField(TypeOfField type, const MEDFieldFieldGlobsReal *glob,
const std::vector<const DataArrayDouble *>& dads, const std::vector<int>& locs, const MEDCouplingMesh *mesh, bool& isPfl) const throw(INTERP_KERNEL::Exception);
- MEDCouplingFieldDouble *finishField2(TypeOfField type, const MEDFieldFieldGlobs *glob,
+ MEDCouplingFieldDouble *finishField2(TypeOfField type, const MEDFieldFieldGlobsReal *glob,
const std::vector<const DataArrayDouble *>& dads, const std::vector<int>& locs,
const MEDCouplingMesh *mesh, const DataArrayInt *da, bool& isPfl) const throw(INTERP_KERNEL::Exception);
- MEDCouplingFieldDouble *finishField3(const MEDFieldFieldGlobs *glob,
+ MEDCouplingFieldDouble *finishField3(const MEDFieldFieldGlobsReal *glob,
const std::vector<const DataArrayDouble *>& dads, const std::vector<int>& locs,
const MEDCouplingMesh *mesh, const DataArrayInt *da, bool& isPfl) const throw(INTERP_KERNEL::Exception);
- static void SortArraysPerType(const MEDFieldFieldGlobs *glob,
+ DataArrayDouble *finishField4(const std::vector<const DataArrayDouble *>& dads, const DataArrayInt *pflIn, int nbOfElems, DataArrayInt *&pflOut) const throw(INTERP_KERNEL::Exception);
+ static void SortArraysPerType(const MEDFieldFieldGlobsReal *glob, TypeOfField type,
const std::vector<INTERP_KERNEL::NormalizedCellType>& geoTypes, const std::vector<const DataArrayDouble *>& dads, const std::vector<const DataArrayInt *>& pfls, const std::vector<int>& locs,
std::vector<int>& code, std::vector<DataArrayInt *>& notNullPfls);
- static int ComputeNbOfElems(const MEDFieldFieldGlobs *glob, const std::vector<const DataArrayDouble *>& dads, const std::vector<int>& locs) throw(INTERP_KERNEL::Exception);
+ static int ComputeNbOfElems(const MEDFieldFieldGlobsReal *glob, TypeOfField type, INTERP_KERNEL::NormalizedCellType geoType, const std::vector<const DataArrayDouble *>& dads, const std::vector<int>& locs) throw(INTERP_KERNEL::Exception);
MEDFileFieldPerMesh(MEDFileField1TSWithoutDAS *fath, int meshCsit, int meshIteration, int meshOrder);
MEDFileFieldPerMesh(MEDFileField1TSWithoutDAS *fath, const MEDCouplingMesh *mesh);
private:
std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > > _field_pm_pt;
};
- class MEDFieldFieldGlobs
+ class MEDFieldFieldGlobsReal;
+
+ class MEDFieldFieldGlobs : public RefCountObject
{
public:
- MEDFieldFieldGlobs(const char *fname);
- MEDFieldFieldGlobs();
+ static MEDFieldFieldGlobs *New(const char *fname);
+ static MEDFieldFieldGlobs *New();
void loadProfileInFile(med_idt fid, int id, const char *pflName) throw(INTERP_KERNEL::Exception);
void loadProfileInFile(med_idt fid, int id);
- void loadGlobals(med_idt fid) throw(INTERP_KERNEL::Exception);
+ void loadGlobals(med_idt fid, const MEDFieldFieldGlobsReal& real) throw(INTERP_KERNEL::Exception);
void writeGlobals(med_idt fid, const MEDFileWritable& opt) const throw(INTERP_KERNEL::Exception);
std::vector<std::string> getPfls() const;
std::vector<std::string> getLocs() const;
int getNbOfGaussPtPerCell(int locId) const throw(INTERP_KERNEL::Exception);
int getLocalizationId(const char *loc) const throw(INTERP_KERNEL::Exception);
const char *getFileName() const { return _file_name.c_str(); }
+ std::string getFileName2() const { return _file_name; }
const MEDFileFieldLoc& getLocalizationFromId(int locId) const throw(INTERP_KERNEL::Exception);
- const DataArrayInt *getProfile(const std::string& pflName) const throw(INTERP_KERNEL::Exception);
- virtual std::vector<std::string> getPflsReallyUsed() const = 0;
- virtual std::vector<std::string> getLocsReallyUsed() const = 0;
+ const DataArrayInt *getProfile(const std::string& pflName) const throw(INTERP_KERNEL::Exception);
//
void appendProfile(DataArrayInt *pfl) throw(INTERP_KERNEL::Exception);
void appendLoc(const char *locName, INTERP_KERNEL::NormalizedCellType geoType, const std::vector<double>& refCoo, const std::vector<double>& gsCoo, const std::vector<double>& w) throw(INTERP_KERNEL::Exception);
+ protected:
+ MEDFieldFieldGlobs(const char *fname);
+ MEDFieldFieldGlobs();
+ ~MEDFieldFieldGlobs();
protected:
std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > _pfls;
std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> > _locs;
std::string _file_name;
};
+ class MEDFieldFieldGlobsReal
+ {
+ public:
+ MEDFieldFieldGlobsReal(const char *fname);
+ MEDFieldFieldGlobsReal();
+ void shallowCpyGlobs(const MEDFieldFieldGlobsReal& other);
+ virtual std::vector<std::string> getPflsReallyUsed() const = 0;
+ virtual std::vector<std::string> getLocsReallyUsed() const = 0;
+ //
+ void loadProfileInFile(med_idt fid, int id, const char *pflName) throw(INTERP_KERNEL::Exception);
+ void loadProfileInFile(med_idt fid, int id);
+ void loadGlobals(med_idt fid) throw(INTERP_KERNEL::Exception);
+ void writeGlobals(med_idt fid, const MEDFileWritable& opt) const throw(INTERP_KERNEL::Exception);
+ std::vector<std::string> getPfls() const;
+ std::vector<std::string> getLocs() const;
+ void setFileName(const char *fileName);
+ int getNbOfGaussPtPerCell(int locId) const throw(INTERP_KERNEL::Exception);
+ int getLocalizationId(const char *loc) const throw(INTERP_KERNEL::Exception);
+ const char *getFileName() const;
+ std::string getFileName2() const;
+ const MEDFileFieldLoc& getLocalizationFromId(int locId) const throw(INTERP_KERNEL::Exception);
+ const DataArrayInt *getProfile(const std::string& pflName) const throw(INTERP_KERNEL::Exception);
+ //
+ void appendProfile(DataArrayInt *pfl) throw(INTERP_KERNEL::Exception);
+ void appendLoc(const char *locName, INTERP_KERNEL::NormalizedCellType geoType, const std::vector<double>& refCoo, const std::vector<double>& gsCoo, const std::vector<double>& w) throw(INTERP_KERNEL::Exception);
+ protected:
+ MEDCouplingAutoRefCountObjectPtr< MEDFieldFieldGlobs > _globals;
+ };
+
class MEDFileField1TSWithoutDAS : public RefCountObject, public MEDFileWritable
{
public:
std::vector<std::string> getLocsReallyUsed2() const;
static void CheckMeshDimRel(int meshDimRelToMax) throw(INTERP_KERNEL::Exception);
static std::vector<int> CheckSBTMesh(const MEDCouplingMesh *mesh) throw(INTERP_KERNEL::Exception);
+ //
+ void setFieldNoProfileSBT(const MEDCouplingFieldDouble *field, MEDFieldFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception);
+ void setFieldProfile(const MEDCouplingFieldDouble *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile, MEDFieldFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception);
public:
- MEDCouplingFieldDouble *getFieldAtLevel(TypeOfField type, int meshDimRelToMax, const char *mName, int renumPol, const MEDFieldFieldGlobs *glob) const throw(INTERP_KERNEL::Exception);
- MEDCouplingFieldDouble *getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, int renumPol, const MEDFieldFieldGlobs *glob, const MEDFileMesh *mesh) const throw(INTERP_KERNEL::Exception);
- MEDCouplingFieldDouble *getFieldOnMeshAtLevel(TypeOfField type, int renumPol, const MEDFieldFieldGlobs *glob, const MEDCouplingMesh *mesh, const DataArrayInt *cellRenum, const DataArrayInt *nodeRenum) 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 *getFieldOnMeshAtLevel(TypeOfField type, int renumPol, const MEDFieldFieldGlobsReal *glob, const MEDCouplingMesh *mesh, const DataArrayInt *cellRenum, const DataArrayInt *nodeRenum) const throw(INTERP_KERNEL::Exception);
+ DataArrayDouble *getFieldWithProfile(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl, const MEDFieldFieldGlobsReal *glob) const throw(INTERP_KERNEL::Exception);
protected:
int addNewEntryIfNecessary(const MEDCouplingMesh *mesh) throw(INTERP_KERNEL::Exception);
int getMeshIdFromMeshName(const char *mName) const throw(INTERP_KERNEL::Exception);
MEDFileField1TSWithoutDAS(const char *fieldName, int csit, int iteration, int order, const std::vector<std::string>& infos);
+ public:
MEDFileField1TSWithoutDAS();
protected:
std::string _name;
/*!
* User class.
*/
- class MEDFileField1TS : public MEDFileField1TSWithoutDAS, public MEDFieldFieldGlobs
+ class MEDFileField1TS : public MEDFileField1TSWithoutDAS, public MEDFieldFieldGlobsReal
{
public:
static MEDFileField1TS *New(const char *fileName, const char *fieldName, int iteration, int order) throw(INTERP_KERNEL::Exception);
static MEDFileField1TS *New();
void write(const char *fileName, int mode) const throw(INTERP_KERNEL::Exception);
- void setFileName(const char *fileName);
MEDCouplingFieldDouble *getFieldAtLevel(TypeOfField type, int meshDimRelToMax, int renumPol=0) const throw(INTERP_KERNEL::Exception);
MEDCouplingFieldDouble *getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol=0) const throw(INTERP_KERNEL::Exception);
MEDCouplingFieldDouble *getFieldOnMeshAtLevel(TypeOfField type, const MEDCouplingMesh *mesh, int renumPol=0) const throw(INTERP_KERNEL::Exception);
MEDCouplingFieldDouble *getFieldAtLevelOld(TypeOfField type, const char *mname, int meshDimRelToMax, int renumPol=0) const throw(INTERP_KERNEL::Exception);
+ DataArrayDouble *getFieldWithProfile(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const throw(INTERP_KERNEL::Exception);
//
void setFieldNoProfileSBT(const MEDCouplingFieldDouble *field) throw(INTERP_KERNEL::Exception);
+ void setFieldProfile(const MEDCouplingFieldDouble *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile) throw(INTERP_KERNEL::Exception);
private:
std::vector<std::string> getPflsReallyUsed() const;
std::vector<std::string> getLocsReallyUsed() const;
static MEDFileFieldMultiTSWithoutDAS *New(med_idt fid, const char *fieldName, int id, const std::vector<std::string>& infos, int nbOfStep) throw(INTERP_KERNEL::Exception);
int getNumberOfTS() const;
std::vector< std::pair<int,int> > getIterations() const;
+ 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);
public:
std::vector<std::string> getPflsReallyUsed2() const;
std::vector<std::string> getLocsReallyUsed2() const;
const std::vector<std::string>& getInfo() const throw(INTERP_KERNEL::Exception);
std::string getMeshName() const throw(INTERP_KERNEL::Exception);
std::string getDtUnit() const throw(INTERP_KERNEL::Exception);
+ MEDFileFieldMultiTSWithoutDAS();
MEDFileFieldMultiTSWithoutDAS(const char *fieldName);
MEDFileFieldMultiTSWithoutDAS(med_idt fid, const char *fieldName, int id, const std::vector<std::string>& infos, int nbOfStep) throw(INTERP_KERNEL::Exception);
void finishLoading(med_idt fid, int nbPdt) throw(INTERP_KERNEL::Exception);
- void writeLL(med_idt fid) const throw(INTERP_KERNEL::Exception);
+ void copyTinyInfoFrom(const MEDCouplingFieldDouble *field) throw(INTERP_KERNEL::Exception);
+ void checkCoherencyOfTinyInfo(const MEDCouplingFieldDouble *field) const throw(INTERP_KERNEL::Exception);
protected:
std::string _name;
std::vector<std::string> _infos;
/*!
* User class.
*/
- class MEDFileFieldMultiTS : public MEDFileFieldMultiTSWithoutDAS, public MEDFieldFieldGlobs
+ class MEDFileFieldMultiTS : public MEDFileFieldMultiTSWithoutDAS, public MEDFieldFieldGlobsReal
{
public:
+ static MEDFileFieldMultiTS *New();
static MEDFileFieldMultiTS *New(const char *fileName, const char *fieldName) throw(INTERP_KERNEL::Exception);
+ static MEDFileFieldMultiTS *New(const MEDFileFieldMultiTSWithoutDAS& other);
void write(const char *fileName, int mode) const throw(INTERP_KERNEL::Exception);
MEDCouplingFieldDouble *getFieldAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, int renumPol=0) const throw(INTERP_KERNEL::Exception);
MEDCouplingFieldDouble *getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol=0) const throw(INTERP_KERNEL::Exception);
MEDCouplingFieldDouble *getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, const MEDCouplingMesh *mesh, int renumPol=0) const throw(INTERP_KERNEL::Exception);
MEDCouplingFieldDouble *getFieldAtLevelOld(TypeOfField type, const char *mname, int iteration, int order, int meshDimRelToMax, int renumPol=0) const throw(INTERP_KERNEL::Exception);
+ DataArrayDouble *getFieldWithProfile(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const throw(INTERP_KERNEL::Exception);
+ //
+ void appendFieldNoProfileSBT(const MEDCouplingFieldDouble *field) throw(INTERP_KERNEL::Exception);
+ void appendFieldProfile(const MEDCouplingFieldDouble *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile) throw(INTERP_KERNEL::Exception);
private:
std::vector<std::string> getPflsReallyUsed() const;
std::vector<std::string> getLocsReallyUsed() const;
private:
+ MEDFileFieldMultiTS();
+ MEDFileFieldMultiTS(const MEDFileFieldMultiTSWithoutDAS& other);
MEDFileFieldMultiTS(const char *fileName, const char *fieldName) throw(INTERP_KERNEL::Exception);
};
/*!
* Use class.
*/
- class MEDFileFields : public RefCountObject, public MEDFieldFieldGlobs, public MEDFileWritable
+ class MEDFileFields : public RefCountObject, public MEDFieldFieldGlobsReal, public MEDFileWritable
{
public:
+ static MEDFileFields *New();
static MEDFileFields *New(const char *fileName) throw(INTERP_KERNEL::Exception);
+ void write(const char *fileName, int mode) const throw(INTERP_KERNEL::Exception);
int getNumberOfFields() const;
+ std::vector<std::string> getFieldsNames() const throw(INTERP_KERNEL::Exception);
+ //
+ void resize(int newSize) throw(INTERP_KERNEL::Exception);
+ void pushField(MEDFileFieldMultiTS *field) throw(INTERP_KERNEL::Exception);
+ void setFieldAtPos(int i, MEDFileFieldMultiTS *field) throw(INTERP_KERNEL::Exception);
+ MEDFileFieldMultiTS *getFieldAtPos(int i) const throw(INTERP_KERNEL::Exception);
+ MEDFileFieldMultiTS *getField(const char *fieldName) const throw(INTERP_KERNEL::Exception);
+ void destroyFieldAtPos(int i) throw(INTERP_KERNEL::Exception);
private:
+ int getPosFromFieldName(const char *fieldName) const throw(INTERP_KERNEL::Exception);
std::vector<std::string> getPflsReallyUsed() const;
std::vector<std::string> getLocsReallyUsed() const;
private:
+ MEDFileFields();
MEDFileFields(const char *fileName) throw(INTERP_KERNEL::Exception);
private:
std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTSWithoutDAS> > _fields;
std::transform((*it1).begin(),(*it1).end(),(*it1).begin(),std::bind2nd(std::plus<int>(),offset));
}
+/*!
+ * This method should be called by any set* method of subclasses to deal automatically with _name attribute.
+ * If _name attribute is empty the name of 'm' if taken as _name attribute.
+ * If _name is not empty and that 'm' has the same name nothing is done.
+ * If _name is not emplt and that 'm' has \b NOT the same name an exception is thrown.
+ */
+void MEDFileMesh::dealWithTinyInfo(const MEDCouplingMesh *m) throw(INTERP_KERNEL::Exception)
+{
+ if(_name.empty())
+ _name=m->getName();
+ else
+ {
+ std::string name(m->getName());
+ if(!name.empty())
+ {
+ if(_name!=name)
+ {
+ std::ostringstream oss; oss << "MEDFileMesh::dealWithTinyInfo : name of current MEDfile mesh is '" << _name << "' whereas name of input mesh is : '";
+ oss << name << "' ! Names must match !";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ }
+ }
+}
+
MEDFileUMesh *MEDFileUMesh::New(const char *fileName, const char *mName, int dt, int it) throw(INTERP_KERNEL::Exception)
{
MEDFileUtilities::CheckFileForRead(fileName);
void MEDFileUMesh::setMeshAtLevelGen(int meshDimRelToMax, MEDCouplingUMesh *m, bool newOrOld) throw(INTERP_KERNEL::Exception)
{
+ dealWithTinyInfo(m);
std::vector<int> levSet=getNonEmptyLevels();
if(std::find(levSet.begin(),levSet.end(),meshDimRelToMax)==levSet.end())
{
return const_cast<MEDCouplingCMesh *>(m);
}
-void MEDFileCMesh::setMesh(MEDCouplingCMesh *m)
+void MEDFileCMesh::setMesh(MEDCouplingCMesh *m) throw(INTERP_KERNEL::Exception)
{
+ dealWithTinyInfo(m);
if(m)
m->incrRef();
_cmesh=m;
throw INTERP_KERNEL::Exception("MEDFileCMesh::getRevNumberFieldAtLevel : no node renumbering for a request on reverse numbering !");
}
}
+
+
+MEDFileMeshMultiTS *MEDFileMeshMultiTS::New()
+{
+ return new MEDFileMeshMultiTS;
+}
+
+MEDFileMeshMultiTS *MEDFileMeshMultiTS::New(const char *fileName) throw(INTERP_KERNEL::Exception)
+{
+ return new MEDFileMeshMultiTS(fileName);
+}
+
+MEDFileMeshMultiTS *MEDFileMeshMultiTS::New(const char *fileName, const char *mName) throw(INTERP_KERNEL::Exception)
+{
+ return new MEDFileMeshMultiTS(fileName,mName);
+}
+
+const char *MEDFileMeshMultiTS::getName() const throw(INTERP_KERNEL::Exception)
+{
+ if(_mesh_one_ts.empty())
+ throw INTERP_KERNEL::Exception("MEDFileMeshMultiTS::getName : no time steps set !");
+ return _mesh_one_ts[0]->getName();
+}
+
+MEDFileMesh *MEDFileMeshMultiTS::getOneTimeStep() const throw(INTERP_KERNEL::Exception)
+{
+ if(_mesh_one_ts.empty())
+ throw INTERP_KERNEL::Exception("MEDFileMeshMultiTS::getOneTimeStep : empty time step set !");
+ return const_cast<MEDFileMesh *>(static_cast<const MEDFileMesh *>(_mesh_one_ts[0]));
+}
+
+void MEDFileMeshMultiTS::setOneTimeStep(MEDFileMesh *mesh1TimeStep) throw(INTERP_KERNEL::Exception)
+{
+ if(!mesh1TimeStep)
+ throw INTERP_KERNEL::Exception("MEDFileMeshMultiTS::setOneTimeStep : input pointer should be different from 0 !");
+ _mesh_one_ts.resize(1);
+ mesh1TimeStep->incrRef();
+ //MEDCouplingAutoRefCountObjectPtr<MEDFileMesh> toto=mesh1TimeStep;
+ _mesh_one_ts[0]=mesh1TimeStep;
+}
+
+void MEDFileMeshMultiTS::write(const char *fileName, int mode) const throw(INTERP_KERNEL::Exception)
+{
+ for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileMesh> >::const_iterator it=_mesh_one_ts.begin();it!=_mesh_one_ts.end();it++)
+ {
+ (*it)->copyOptionsFrom(*this);
+ (*it)->write(fileName,mode);
+ }
+}
+
+void MEDFileMeshMultiTS::loadFromFile(const char *fileName, const char *mName) throw(INTERP_KERNEL::Exception)
+{//for the moment to be improved
+ _mesh_one_ts.resize(1);
+ _mesh_one_ts[0]=MEDFileMesh::New(fileName,mName,-1,-1);
+}
+
+MEDFileMeshMultiTS::MEDFileMeshMultiTS()
+{
+}
+
+MEDFileMeshMultiTS::MEDFileMeshMultiTS(const char *fileName) throw(INTERP_KERNEL::Exception)
+try
+ {
+ std::vector<std::string> ms=MEDLoader::GetMeshNames(fileName);
+ if(ms.empty())
+ {
+ std::ostringstream oss; oss << "MEDFileUMesh::New : no meshes in file \"" << fileName << "\" !";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ MEDFileUtilities::CheckFileForRead(fileName);
+ MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
+ int dt,it;
+ ParaMEDMEM::MEDCouplingMeshType meshType;
+ std::string dummy2;
+ MEDFileMeshL2::GetMeshIdFromName(fid,ms.front().c_str(),meshType,dt,it,dummy2);
+ loadFromFile(fileName,ms.front().c_str());
+ }
+catch(INTERP_KERNEL::Exception& e)
+ {
+ throw e;
+ }
+
+MEDFileMeshMultiTS::MEDFileMeshMultiTS(const char *fileName, const char *mName) throw(INTERP_KERNEL::Exception)
+try
+ {
+ loadFromFile(fileName,mName);
+ }
+catch(INTERP_KERNEL::Exception& e)
+ {
+ throw e;
+ }
+
+MEDFileMeshes *MEDFileMeshes::New()
+{
+ return new MEDFileMeshes;
+}
+
+MEDFileMeshes *MEDFileMeshes::New(const char *fileName) throw(INTERP_KERNEL::Exception)
+{
+ return new MEDFileMeshes(fileName);
+}
+
+void MEDFileMeshes::write(const char *fileName, int mode) const throw(INTERP_KERNEL::Exception)
+{
+ checkCoherency();
+ for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileMeshMultiTS> >::const_iterator it=_meshes.begin();it!=_meshes.end();it++)
+ {
+ (*it)->copyOptionsFrom(*this);
+ (*it)->write(fileName,mode);
+ }
+}
+
+int MEDFileMeshes::getNumberOfMeshes() const throw(INTERP_KERNEL::Exception)
+{
+ return _meshes.size();
+}
+
+MEDFileMesh *MEDFileMeshes::getMeshAtPos(int i) const throw(INTERP_KERNEL::Exception)
+{
+ if(i<0 || i>=(int)_meshes.size())
+ {
+ std::ostringstream oss; oss << "MEDFileMeshes::getMeshAtPos : invalid mesh id given in parameter ! Should be in [0;" << _meshes.size() << ") !";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ return _meshes[i]->getOneTimeStep();
+}
+
+void MEDFileMeshes::resize(int newSize) throw(INTERP_KERNEL::Exception)
+{
+ _meshes.resize(newSize);
+}
+
+void MEDFileMeshes::pushMesh(MEDFileMesh *mesh) throw(INTERP_KERNEL::Exception)
+{
+ if(!mesh)
+ throw INTERP_KERNEL::Exception("MEDFileMeshes::pushMesh : invalid input pointer ! should be different from 0 !");
+ MEDFileMeshMultiTS *elt=MEDFileMeshMultiTS::New();
+ elt->setOneTimeStep(mesh);
+ _meshes.push_back(elt);
+}
+
+void MEDFileMeshes::setMeshAtPos(int i, MEDFileMesh *mesh) throw(INTERP_KERNEL::Exception)
+{
+ if(!mesh)
+ throw INTERP_KERNEL::Exception("MEDFileMeshes::setMeshAtPos : invalid input pointer ! should be different from 0 !");
+ if(i>=(int)_meshes.size())
+ _meshes.resize(i+1);
+ MEDFileMeshMultiTS *elt=MEDFileMeshMultiTS::New();
+ elt->setOneTimeStep(mesh);
+ _meshes[i]=elt;
+}
+
+void MEDFileMeshes::destroyMeshAtPos(int i) throw(INTERP_KERNEL::Exception)
+{
+ if(i<0 || i>=(int)_meshes.size())
+ {
+ std::ostringstream oss; oss << "MEDFileMeshes::destroyMeshAtPos : Invalid given id in input (" << i << ") should be in [0," << _meshes.size() << ") !";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ _meshes.erase(_meshes.begin()+i);
+}
+
+void MEDFileMeshes::loadFromFile(const char *fileName) throw(INTERP_KERNEL::Exception)
+{
+ std::vector<std::string> ms=MEDLoader::GetMeshNames(fileName);
+ int i=0;
+ _meshes.resize(ms.size());
+ for(std::vector<std::string>::const_iterator it=ms.begin();it!=ms.end();it++,i++)
+ _meshes[i]=MEDFileMeshMultiTS::New(fileName,(*it).c_str());
+}
+
+MEDFileMeshes::MEDFileMeshes()
+{
+}
+
+MEDFileMeshes::MEDFileMeshes(const char *fileName) throw(INTERP_KERNEL::Exception)
+try
+ {
+ loadFromFile(fileName);
+ }
+catch(INTERP_KERNEL::Exception& e)
+ {
+ }
+
+void MEDFileMeshes::checkCoherency() const throw(INTERP_KERNEL::Exception)
+{
+ static const char MSG[]="MEDFileMeshes::checkCoherency : mesh at rank ";
+ int i=0;
+ std::set<std::string> s;
+ for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileMeshMultiTS> >::const_iterator it=_meshes.begin();it!=_meshes.end();it++,i++)
+ {
+ const MEDFileMeshMultiTS *elt=(*it);
+ if(!elt)
+ {
+ std::ostringstream oss; oss << MSG << i << "/" << _meshes.size() << " is empty !";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ std::size_t sz=s.size();
+ s.insert(std::string((*it)->getName()));
+ if(s.size()==sz)
+ {
+ std::ostringstream oss; oss << MSG << i << " has a name (\"" << (*it)->getName() << "\") already used by an another mesh in list !";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ }
+}
virtual DataArrayInt *getNodeFamiliesArr(const std::vector<std::string>& fams, bool renum=false) const throw(INTERP_KERNEL::Exception);
protected:
MEDFileMesh();
+ void dealWithTinyInfo(const MEDCouplingMesh *m) throw(INTERP_KERNEL::Exception);
virtual void synchronizeTinyInfoOnLeaves() const = 0;
virtual void appendFamilyEntries(const std::set<int>& famIds, const std::vector< std::vector<int> >& fidsOfGrps, const std::vector<std::string>& grpNames);
static void TranslateFamilyIds(int offset, DataArrayInt *famArr, std::vector< std::vector<int> >& famIdsPerGrp);
mutable MEDCouplingAutoRefCountObjectPtr<DataArrayInt> _rev_num_coords;
};
-
class MEDFileCMesh : public MEDFileMesh
{
friend class MEDFileMesh;
void clearNonDiscrAttributes() const;
const MEDCouplingCMesh *getMesh() const;
MEDCouplingMesh *getGenMeshAtLevel(int meshDimRelToMax, bool renum=false) const throw(INTERP_KERNEL::Exception);
- void setMesh(MEDCouplingCMesh *m);
+ void setMesh(MEDCouplingCMesh *m) throw(INTERP_KERNEL::Exception);
void write(const char *fileName, int mode) const throw(INTERP_KERNEL::Exception);
int getSizeAtLevel(int meshDimRelToMaxExt) const throw(INTERP_KERNEL::Exception);
DataArrayInt *getFamiliesArr(int meshDimRelToMaxExt, const std::vector<std::string>& fams, bool renum=false) const throw(INTERP_KERNEL::Exception);
mutable MEDCouplingAutoRefCountObjectPtr<DataArrayInt> _rev_num_nodes;
mutable MEDCouplingAutoRefCountObjectPtr<DataArrayInt> _rev_num_cells;
};
+
+ class MEDFileMeshMultiTS : public RefCountObject, public MEDFileWritable
+ {
+ public:
+ static MEDFileMeshMultiTS *New();
+ static MEDFileMeshMultiTS *New(const char *fileName) throw(INTERP_KERNEL::Exception);
+ static MEDFileMeshMultiTS *New(const char *fileName, const char *mName) throw(INTERP_KERNEL::Exception);
+ const char *getName() const throw(INTERP_KERNEL::Exception);
+ MEDFileMesh *getOneTimeStep() const throw(INTERP_KERNEL::Exception);
+ void write(const char *fileName, int mode) const throw(INTERP_KERNEL::Exception);
+ void setOneTimeStep(MEDFileMesh *mesh1TimeStep) throw(INTERP_KERNEL::Exception);
+ private:
+ void loadFromFile(const char *fileName, const char *mName) throw(INTERP_KERNEL::Exception);
+ MEDFileMeshMultiTS();
+ MEDFileMeshMultiTS(const char *fileName) throw(INTERP_KERNEL::Exception);
+ MEDFileMeshMultiTS(const char *fileName, const char *mName) throw(INTERP_KERNEL::Exception);
+ private:
+ std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileMesh> > _mesh_one_ts;
+ };
+
+ class MEDFileMeshes : public RefCountObject, public MEDFileWritable
+ {
+ public:
+ static MEDFileMeshes *New();
+ static MEDFileMeshes *New(const char *fileName) throw(INTERP_KERNEL::Exception);
+ void write(const char *fileName, int mode) const throw(INTERP_KERNEL::Exception);
+ int getNumberOfMeshes() const throw(INTERP_KERNEL::Exception);
+ MEDFileMesh *getMeshAtPos(int i) const throw(INTERP_KERNEL::Exception);
+ //
+ void resize(int newSize) throw(INTERP_KERNEL::Exception);
+ void pushMesh(MEDFileMesh *mesh) throw(INTERP_KERNEL::Exception);
+ void setMeshAtPos(int i, MEDFileMesh *mesh) throw(INTERP_KERNEL::Exception);
+ void destroyMeshAtPos(int i) throw(INTERP_KERNEL::Exception);
+ private:
+ void checkCoherency() const throw(INTERP_KERNEL::Exception);
+ void loadFromFile(const char *fileName) throw(INTERP_KERNEL::Exception);
+ MEDFileMeshes();
+ MEDFileMeshes(const char *fileName) throw(INTERP_KERNEL::Exception);
+ private:
+ std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileMeshMultiTS> > _meshes;
+ };
}
#endif
salomeinclude_HEADERS= \
MEDLoaderDefines.hxx \
MEDLoader.hxx MEDLoaderBase.hxx MEDFileUtilities.hxx MEDFileMesh.hxx MEDFileMeshLL.hxx \
-MEDFileMeshElt.hxx MEDFileBasis.hxx MEDFileField.hxx
+MEDFileMeshElt.hxx MEDFileBasis.hxx MEDFileField.hxx MEDFileData.hxx
dist_libmedloader_la_SOURCES= \
MEDLoader.cxx MEDLoaderBase.cxx MEDFileUtilities.cxx \
MEDFileMesh.cxx MEDFileMeshElt.cxx MEDFileBasis.cxx \
-MEDFileMeshLL.cxx MEDFileField.cxx
+MEDFileMeshLL.cxx MEDFileField.cxx MEDFileData.cxx
libmedloader_la_CPPFLAGS= $(MED2_INCLUDES) $(HDF5_INCLUDES) @CXXTMPDPTHFLAGS@ \
-I$(srcdir)/../INTERP_KERNEL \
#include "MEDLoader.hxx"
#include "MEDFileMesh.hxx"
#include "MEDFileField.hxx"
+#include "MEDFileData.hxx"
#include "MEDLoaderTypemaps.i"
using namespace ParaMEDMEM;
%newobject ParaMEDMEM::MEDFileUMesh::getLevelM2Mesh;
%newobject ParaMEDMEM::MEDFileUMesh::getLevelM3Mesh;
%newobject ParaMEDMEM::MEDFileCMesh::New;
+%newobject ParaMEDMEM::MEDFileMeshMultiTS::New;
+%newobject ParaMEDMEM::MEDFileMeshMultiTS::getOneTimeStep;
+%newobject ParaMEDMEM::MEDFileMeshes::New;
+%newobject ParaMEDMEM::MEDFileMeshes::getMeshAtPos;
%newobject ParaMEDMEM::MEDFileFields::New;
+%newobject ParaMEDMEM::MEDFileFields::getField;
+%newobject ParaMEDMEM::MEDFileFields::getFieldAtPos;
%newobject ParaMEDMEM::MEDFileFieldMultiTS::New;
%newobject ParaMEDMEM::MEDFileFieldMultiTS::getFieldAtLevel;
%newobject ParaMEDMEM::MEDFileFieldMultiTS::getFieldOnMeshAtLevel;
%newobject ParaMEDMEM::MEDFileField1TS::getFieldOnMeshAtLevel;
%newobject ParaMEDMEM::MEDFileField1TS::getFieldAtLevelOld;
+%newobject ParaMEDMEM::MEDFileData::New;
+
+%feature("unref") MEDFileMesh "$this->decrRef();"
+%feature("unref") MEDFileUMesh "$this->decrRef();"
+%feature("unref") MEDFileCMesh "$this->decrRef();"
+%feature("unref") MEDFileMeshMultiTS "$this->decrRef();"
+%feature("unref") MEDFileMeshes "$this->decrRef();"
+%feature("unref") MEDFileField1TS "$this->decrRef();"
+%feature("unref") MEDFileFieldMultiTS "$this->decrRef();"
+%feature("unref") MEDFileFields "$this->decrRef();"
+
class MEDLoader
{
public:
static MEDFileCMesh *New();
static MEDFileCMesh *New(const char *fileName) throw(INTERP_KERNEL::Exception);
static MEDFileCMesh *New(const char *fileName, const char *mName, int dt=-1, int it=-1) throw(INTERP_KERNEL::Exception);
- void setMesh(MEDCouplingCMesh *m);
+ void setMesh(MEDCouplingCMesh *m) throw(INTERP_KERNEL::Exception);
%extend
{
PyObject *getMesh() const
}
};
- class MEDFieldFieldGlobs
+ class MEDFileMeshMultiTS : public RefCountObject, public MEDFileWritable
+ {
+ public:
+ static MEDFileMeshMultiTS *New();
+ static MEDFileMeshMultiTS *New(const char *fileName) throw(INTERP_KERNEL::Exception);
+ static MEDFileMeshMultiTS *New(const char *fileName, const char *mName) throw(INTERP_KERNEL::Exception);
+ const char *getName() const throw(INTERP_KERNEL::Exception);
+ void write(const char *fileName, int mode) const throw(INTERP_KERNEL::Exception);
+ void setOneTimeStep(MEDFileMesh *mesh1TimeStep) throw(INTERP_KERNEL::Exception);
+ %extend
+ {
+ MEDFileMesh *getOneTimeStep() const throw(INTERP_KERNEL::Exception)
+ {
+ MEDFileMesh *ret=self->getOneTimeStep();
+ if(ret)
+ ret->incrRef();
+ return ret;
+ }
+ }
+ };
+
+ class MEDFileMeshes : public RefCountObject, public MEDFileWritable
{
public:
+ static MEDFileMeshes *New();
+ static MEDFileMeshes *New(const char *fileName) throw(INTERP_KERNEL::Exception);
+ void write(const char *fileName, int mode) const throw(INTERP_KERNEL::Exception);
+ int getNumberOfMeshes() const throw(INTERP_KERNEL::Exception);
+ //
+ void resize(int newSize) throw(INTERP_KERNEL::Exception);
+ void pushMesh(MEDFileMesh *mesh) throw(INTERP_KERNEL::Exception);
+ void setMeshAtPos(int i, MEDFileMesh *mesh) throw(INTERP_KERNEL::Exception);
+ void destroyMeshAtPos(int i) throw(INTERP_KERNEL::Exception);
+ %extend
+ {
+ MEDFileMesh *getMeshAtPos(int i) const throw(INTERP_KERNEL::Exception)
+ {
+ MEDFileMesh *ret=self->getMeshAtPos(i);
+ if(ret)
+ ret->incrRef();
+ return ret;
+ }
+ }
+ };
+
+ class MEDFieldFieldGlobsReal
+ {
+ public:
+ void shallowCpyGlobs(const MEDFieldFieldGlobsReal& other);
std::vector<std::string> getPfls() const;
std::vector<std::string> getLocs() const;
virtual std::vector<std::string> getPflsReallyUsed() const = 0;
}
};
- class MEDFileField1TS : public MEDFileField1TSWithoutDAS, public MEDFieldFieldGlobs, public MEDFileWritable
+ class MEDFileField1TS : public MEDFileField1TSWithoutDAS, public MEDFieldFieldGlobsReal, public MEDFileWritable
{
public:
static MEDFileField1TS *New(const char *fileName, const char *fieldName, int iteration, int order) throw(INTERP_KERNEL::Exception);
MEDCouplingFieldDouble *getFieldAtLevelOld(TypeOfField type, const char *mname, int meshDimRelToMax, int renumPol=0) const throw(INTERP_KERNEL::Exception);
//
void setFieldNoProfileSBT(const MEDCouplingFieldDouble *field) throw(INTERP_KERNEL::Exception);
+ void setFieldProfile(const MEDCouplingFieldDouble *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile) throw(INTERP_KERNEL::Exception);
+ %extend
+ {
+ PyObject *getFieldWithProfile(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh) const throw(INTERP_KERNEL::Exception)
+ {
+ DataArrayInt *ret1=0;
+ DataArrayDouble *ret0=self->getFieldWithProfile(type,meshDimRelToMax,mesh,ret1);
+ PyObject *ret=PyTuple_New(2);
+ PyTuple_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(ret0),SWIGTYPE_p_ParaMEDMEM__DataArrayDouble, SWIG_POINTER_OWN | 0 ));
+ PyTuple_SetItem(ret,1,SWIG_NewPointerObj(SWIG_as_voidptr(ret1),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 ));
+ return ret;
+ }
+ }
};
class MEDFileFieldMultiTSWithoutDAS
{
public:
int getNumberOfTS() const;
+ std::string getName() const;
%extend
{
PyObject *getIterations() const
}
return ret;
}
+
+ PyObject *getTimeSteps() const throw(INTERP_KERNEL::Exception)
+ {
+ std::vector<double> ret1;
+ std::vector< std::pair<int,int> > ret=self->getTimeSteps(ret1);
+ std::size_t sz=ret.size();
+ PyObject *ret2=PyList_New(sz);
+ for(std::size_t i=0;i<sz;i++)
+ {
+ PyObject *elt=PyTuple_New(3);
+ PyTuple_SetItem(elt,0,SWIG_From_int(ret[i].first));
+ PyTuple_SetItem(elt,1,SWIG_From_int(ret[i].second));
+ PyTuple_SetItem(elt,2,SWIG_From_double(ret1[i]));
+ PyList_SetItem(ret2,i,elt);
+ }
+ return ret2;
+ }
}
};
- class MEDFileFieldMultiTS : public MEDFileFieldMultiTSWithoutDAS, public MEDFieldFieldGlobs, public MEDFileWritable
+ class MEDFileFieldMultiTS : public MEDFileFieldMultiTSWithoutDAS, public MEDFieldFieldGlobsReal, public MEDFileWritable
{
public:
+ static MEDFileFieldMultiTS *New();
static MEDFileFieldMultiTS *New(const char *fileName, const char *fieldName) throw(INTERP_KERNEL::Exception);
void write(const char *fileName, int mode) const throw(INTERP_KERNEL::Exception);
MEDCouplingFieldDouble *getFieldAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, int renumPol=0) const throw(INTERP_KERNEL::Exception);
MEDCouplingFieldDouble *getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol=0) const throw(INTERP_KERNEL::Exception);
MEDCouplingFieldDouble *getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, const MEDCouplingMesh *mesh, int renumPol=0) const throw(INTERP_KERNEL::Exception);
MEDCouplingFieldDouble *getFieldAtLevelOld(TypeOfField type, const char *mname, int iteration, int order, int meshDimRelToMax, int renumPol=0) const throw(INTERP_KERNEL::Exception);
+ //
+ void appendFieldNoProfileSBT(const MEDCouplingFieldDouble *field) throw(INTERP_KERNEL::Exception);
+ void appendFieldProfile(const MEDCouplingFieldDouble *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile) throw(INTERP_KERNEL::Exception);
+ %extend
+ {
+ PyObject *getFieldWithProfile(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh) const throw(INTERP_KERNEL::Exception)
+ {
+ DataArrayInt *ret1=0;
+ DataArrayDouble *ret0=self->getFieldWithProfile(type,iteration,order,meshDimRelToMax,mesh,ret1);
+ PyObject *ret=PyTuple_New(2);
+ PyTuple_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(ret0),SWIGTYPE_p_ParaMEDMEM__DataArrayDouble, SWIG_POINTER_OWN | 0 ));
+ PyTuple_SetItem(ret,1,SWIG_NewPointerObj(SWIG_as_voidptr(ret1),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 ));
+ return ret;
+ }
+ }
};
- class MEDFileFields : public RefCountObject, public MEDFieldFieldGlobs, public MEDFileWritable
+ class MEDFileFields : public RefCountObject, public MEDFieldFieldGlobsReal, public MEDFileWritable
{
public:
+ static MEDFileFields *New();
static MEDFileFields *New(const char *fileName) throw(INTERP_KERNEL::Exception);
+ void write(const char *fileName, int mode) const throw(INTERP_KERNEL::Exception);
int getNumberOfFields() const;
- std::vector<std::string> getPfls() const;
- std::vector<std::string> getLocs() const;
+ std::vector<std::string> getFieldsNames() const throw(INTERP_KERNEL::Exception);
+ //
+ void resize(int newSize) throw(INTERP_KERNEL::Exception);
+ void pushField(MEDFileFieldMultiTS *field) throw(INTERP_KERNEL::Exception);
+ void setFieldAtPos(int i, MEDFileFieldMultiTS *field) throw(INTERP_KERNEL::Exception);
+ MEDFileFieldMultiTS *getFieldAtPos(int i) const throw(INTERP_KERNEL::Exception);
+ MEDFileFieldMultiTS *getField(const char *fieldName) const throw(INTERP_KERNEL::Exception);
+ void destroyFieldAtPos(int i) throw(INTERP_KERNEL::Exception);
+ };
+
+ class MEDFileData : public RefCountObject, public MEDFileWritable
+ {
+ public:
+ static MEDFileData *New(const char *fileName) throw(INTERP_KERNEL::Exception);
+ static MEDFileData *New();
+ MEDFileFields *getFields() const;
+ MEDFileMeshes *getMeshes() const;
+ void setFields(MEDFileFields *fields) throw(INTERP_KERNEL::Exception);
+ void setMeshes(MEDFileMeshes *meshes) throw(INTERP_KERNEL::Exception);
+ int getNumberOfFields() const throw(INTERP_KERNEL::Exception);
+ int getNumberOfMeshes() const throw(INTERP_KERNEL::Exception);
+ //
+ void write(const char *fileName, int mode) const throw(INTERP_KERNEL::Exception);
};
}
f.checkCoherency();
return f;
+ # idem buildVecFieldOnGauss_2 except that different discretizations are sorted inside one type
+ def buildVecFieldOnGauss_2_Simpler(cls):
+ _a=0.446948490915965;
+ _b=0.091576213509771;
+ _p1=0.11169079483905;
+ _p2=0.0549758718227661;
+ refCoo1=[ 0.,0., 1.,0., 0.,1. ]
+ gsCoo1=[ 2*_b-1, 1-4*_b, 2*_b-1, 2.07*_b-1, 1-4*_b,
+ 2*_b-1, 1-4*_a, 2*_a-1, 2*_a-1, 1-4*_a, 2*_a-1, 2*_a-1 ];
+ wg1=[ 4*_p2, 4*_p2, 4*_p2, 4*_p1, 4*_p1, 4*_p1 ]
+ _refCoo1=refCoo1;
+ _gsCoo1=gsCoo1;
+ _wg1=wg1;
+ m=MEDLoaderDataForTest.build2DMesh_3();
+ f=MEDCouplingFieldDouble.New(ON_GAUSS_PT,ONE_TIME);
+ f.setTime(3.14,1,5);
+ f.setMesh(m);
+ di=DataArrayInt.New(); di.setValues([0,1,2],3,1)
+ f.setGaussLocalizationOnCells(di,_refCoo1,_gsCoo1,_wg1)
+ _wg1[-1]*=2
+ f.setGaussLocalizationOnCells([3,4],_refCoo1,_gsCoo1,_wg1);
+ _wg1[-1]*=2
+ f.setGaussLocalizationOnCells([5],_refCoo1,_gsCoo1,_wg1);
+ refCoo2=[-1.0,1.0, -1.0,-1.0, 1.0,-1.0, -1.0,0.0, 0.0,-1.0, 0.0,0.0 ]
+ _refCoo2=refCoo2;
+ _gsCoo1=_gsCoo1[0:6];
+ _gsCoo2=_gsCoo1
+ _wg1=_wg1[0:3];
+ _wg2=_wg1
+ refCoo3=[ 0.,0., 1.,0., 1.,1., 0.,1. ]
+ _refCoo3=refCoo3;
+ _gsCoo1=_gsCoo1[0:4];
+ _wg1=_wg1[0:2];
+ f.setGaussLocalizationOnCells([6,7,8],_refCoo3,_gsCoo1,_wg1);
+ _wg1[-1]*=2
+ f.setGaussLocalizationOnCells([9],_refCoo3,_gsCoo1,_wg1);
+ f.setGaussLocalizationOnType(NORM_TRI6,_refCoo2,_gsCoo2,_wg2);
+ array=DataArrayDouble.New();
+ array.alloc(53,2);
+ ptr=array.getPointer();
+ for i in xrange(53*2):
+ array.setIJ(0,i,float(i+7));
+ pass
+ f.setArray(array);
+ f.setName("MyFirstFieldOnGaussPoint");
+ array.setInfoOnComponent(0,"power [MW/m^3]");
+ array.setInfoOnComponent(1,"density");
+ f.checkCoherency();
+ return f;
+
def buildVecFieldOnGaussNE_1(cls):
m=MEDLoaderDataForTest.build2DMesh_2();
f=MEDCouplingFieldDouble.New(ON_GAUSS_NE,ONE_TIME);
buildVecFieldOnNodes_1=classmethod(buildVecFieldOnNodes_1)
buildVecFieldOnGauss_1=classmethod(buildVecFieldOnGauss_1)
buildVecFieldOnGauss_2=classmethod(buildVecFieldOnGauss_2)
+ buildVecFieldOnGauss_2_Simpler=classmethod(buildVecFieldOnGauss_2_Simpler)
buildVecFieldOnGaussNE_1=classmethod(buildVecFieldOnGaussNE_1)
pass
self.assertTrue(f1.isEqual(f2,1e-12,1e-12))
#
fname="Pyfile28.med"
- f1=MEDLoaderDataForTest.buildVecFieldOnGauss_2();
+ f1=MEDLoaderDataForTest.buildVecFieldOnGauss_2_Simpler();
m1=f1.getMesh()
mm1=MEDFileUMesh.New()
mm1.setCoords(m1.getCoords())
ff1.setFieldNoProfileSBT(f1)
ff1.write(fname,0)
ff2=MEDFileField1TS.New(fname,f1.getName(),f1.getTime()[1],f1.getTime()[2])
- #f2=ff2.getFieldAtLevel(ON_GAUSS_PT,0) BUG TONY
- #self.assertTrue(f1.isEqual(f2,1e-12,1e-12))
+ f2=ff2.getFieldAtLevel(ON_GAUSS_PT,0)
+ self.assertTrue(f1.isEqual(f2,1e-12,1e-12))
+ #
+ pass
+
+ def testMEDFileData1(self):
+ fname="Pyfile29.med"
+ d=MEDFileData.New()
+ #
+ m1=MEDLoaderDataForTest.build1DMesh_1()
+ mm1=MEDFileUMesh.New() ; mm1.setCoords(m1.getCoords()) ; mm1.setMeshAtLevel(0,m1) ; mm1.setName(m1.getName())
+ mmm1=MEDFileMeshMultiTS.New() ;
+ mmm1.setOneTimeStep(mm1)
+ m2=MEDLoaderDataForTest.build2DCurveMesh_1()
+ mm2=MEDFileUMesh.New() ; mm2.setCoords(m2.getCoords()) ; mm2.setMeshAtLevel(0,m2) ; mm2.setName(m2.getName())
+ mmm2=MEDFileMeshMultiTS.New() ; mmm2.setOneTimeStep(mm2)
+ ms=MEDFileMeshes.New(); ms.setMeshAtPos(0,mm1) ; ms.setMeshAtPos(1,mm2)
+ d.setMeshes(ms)
+ #
+ ff1=MEDFileFieldMultiTS.New()
+ ff21=MEDFileFieldMultiTS.New()
+ ff22=MEDFileFieldMultiTS.New()
+ f1=m1.getMeasureField(True) ; f1.setName("f1") ; f1=f1.buildNewTimeReprFromThis(ONE_TIME,False)
+ f1.getArray().setInfoOnComponent(0,"power [kW]")
+ ff1.appendFieldNoProfileSBT(f1)
+ f21=m2.getMeasureField(True) ; f21.setName("f21") ; f21=f21.buildNewTimeReprFromThis(ONE_TIME,False)
+ f21.getArray().setInfoOnComponent(0,"sta [mm]") ;
+ ff21.appendFieldNoProfileSBT(f21)
+ f22=f21.deepCpy() ; f22.setName("f22") ; f22=f22.buildNewTimeReprFromThis(ONE_TIME,False) ;
+ f22.applyFunc(2,"3*x*IVec+2*x*JVec")
+ f22.getArray().setInfoOnComponent(0,"distance [km]") ; f22.getArray().setInfoOnComponent(1,"displacement [cm]")
+ ff22.appendFieldNoProfileSBT(f22)
+ fs=MEDFileFields.New()
+ fs.pushField(ff1) ; fs.pushField(ff21) ; fs.pushField(ff22)
+ d.setFields(fs)
+ #
+ d.write(fname,0)
+ #
+ d2=MEDFileData.New(fname)
+ self.assertEqual(2,d2.getNumberOfMeshes())
+ self.assertEqual(3,d2.getNumberOfFields())
+ self.assertTrue(isinstance(d2.getMeshes().getMeshAtPos(0),MEDFileUMesh))
+ m1bis=d2.getMeshes().getMeshAtPos(0).getMeshAtLevel(0)
+ self.assertTrue(m1.isEqual(m1bis,1e-12))
+ self.assertEqual(('f1', 'f21', 'f22'),d2.getFields().getFieldsNames())
+ self.assertEqual([(-1, -1, 0.0)],d2.getFields().getFieldAtPos(2).getTimeSteps())
+ self.assertEqual([(-1, -1, 0.0)],d2.getFields().getField("f21").getTimeSteps())
+ pass
+
+ def testMEDField9(self):
+ # first test field profile WR. Full type but with some type missing
+ fname="Pyfile30.med"
+ m1=MEDLoaderDataForTest.build2DMesh_3()
+ mm1=MEDFileUMesh.New() ; mm1.setCoords(m1.getCoords()) ; mm1.setMeshAtLevel(0,m1) ;
+ mm1.write(fname,2)
+ ff1=MEDFileField1TS.New()
+ f1=MEDCouplingFieldDouble.New(ON_CELLS,ONE_TIME) ; f1.setName("F1")
+ d=DataArrayDouble.New() ; d.alloc(2*9,1) ; d.iota(7.); d.rearrange(2); d.setInfoOnComponent(0,"sigX [MPa]") ; d.setInfoOnComponent(1,"sigY [GPa]")
+ f1.setArray(d) # note that f1 is NOT defined fully (no mesh !). It is not a bug of test it is too test that MEDFileField1TS.appendFieldProfile is NOT sensible of that.
+ da=DataArrayInt.New(); da.alloc(9,1) ; da.iota(0) ; da.setName("sup1")
+ #
+ ff1.setFieldProfile(f1,mm1,0,da)
+ ff1.write(fname,0)
+ #
+ vals,pfl=ff1.getFieldWithProfile(ON_CELLS,0,mm1)
+ self.assertTrue(pfl.isEqualWithoutConsideringStr(da))# profiles names cannot be contracted in pfl array name
+ self.assertTrue(vals.isEqual(d,1e-14))
+ #
+ ff2=MEDFileField1TS.New(fname,f1.getName(),-1,-1)
+ vals,pfl=ff2.getFieldWithProfile(ON_CELLS,0,mm1)
+ self.assertTrue(pfl.isEqualWithoutConsideringStr(da))
+ self.assertTrue(vals.isEqual(d,1e-14))
+ pass
+
+ def testMEDField10(self):
+ fname="Pyfile31.med"
+ m1=MEDLoaderDataForTest.build2DMesh_1()
+ m1.renumberCells([0,1,4,2,3,5],False)
+ mm1=MEDFileUMesh.New() ; mm1.setCoords(m1.getCoords()) ; mm1.setMeshAtLevel(0,m1) ; mm1.setName(m1.getName())
+ mm1.write(fname,2)
+ ff1=MEDFileFieldMultiTS.New()
+ f1=MEDCouplingFieldDouble.New(ON_CELLS,ONE_TIME) ; f1.setName("F2")
+ d=DataArrayDouble.New() ; d.alloc(2*4,1) ; d.iota(7.); d.rearrange(2); d.setInfoOnComponent(0,"sigX [MPa]") ; d.setInfoOnComponent(1,"sigY [GPa]")
+ f1.setArray(d) # note that f1 is NOT defined fully (no mesh !). It is not a bug of test it is too test that MEDFileField1TS.appendFieldProfile is NOT sensible of that.
+ da=DataArrayInt.New(); da.setValues([0,1,2,4],4,1) ; da.setName("sup2")
+ #
+ ff1.appendFieldProfile(f1,mm1,0,da)
+ f1.setTime(1.2,1,2) ; e=d.applyFunc("2*x") ; e.copyStringInfoFrom(d) ; f1.setArray(e) ;
+ ff1.appendFieldProfile(f1,mm1,0,da)
+ ff1.write(fname,0)
+ #
+ vals,pfl=ff1.getFieldWithProfile(ON_CELLS,1,2,0,mm1)
+ self.assertTrue(pfl.isEqualWithoutConsideringStr(da))
+ self.assertTrue(vals.isEqual(e,1e-14))
+ vals,pfl=ff1.getFieldWithProfile(ON_CELLS,-1,-1,0,mm1)
+ self.assertTrue(pfl.isEqualWithoutConsideringStr(da))
+ self.assertTrue(vals.isEqual(d,1e-14))
+ #
+ ff2=MEDFileFieldMultiTS.New(fname,f1.getName())
+ self.assertEqual([(-1, -1, 0.0), (1, 2, 1.2)],ff2.getTimeSteps())
+ vals,pfl=ff2.getFieldWithProfile(ON_CELLS,1,2,0,mm1)
+ self.assertTrue(pfl.isEqualWithoutConsideringStr(da))
+ self.assertTrue(vals.isEqual(e,1e-14))
+ vals,pfl=ff2.getFieldWithProfile(ON_CELLS,-1,-1,0,mm1)
+ self.assertTrue(pfl.isEqualWithoutConsideringStr(da))
+ self.assertTrue(vals.isEqual(d,1e-14))
+ pass
+
+ # idem testMEDField9 method except that here testing profile on nodes and not on cells.
+ def testMEDField11(self):
+ fname="Pyfile32.med"
+ m1=MEDLoaderDataForTest.build2DMesh_1()
+ m1.renumberCells([0,1,4,2,3,5],False)
+ mm1=MEDFileUMesh.New() ; mm1.setCoords(m1.getCoords()) ; mm1.setMeshAtLevel(0,m1) ;
+ mm1.write(fname,2)
+ ff1=MEDFileField1TS.New()
+ f1=MEDCouplingFieldDouble.New(ON_NODES,ONE_TIME) ; f1.setName("F1Node")
+ d=DataArrayDouble.New() ; d.alloc(2*6,1) ; d.iota(7.); d.rearrange(2); d.setInfoOnComponent(0,"sigX [MPa]") ; d.setInfoOnComponent(1,"sigY [GPa]")
+ f1.setArray(d) # note that f1 is NOT defined fully (no mesh !). It is not a bug of test it is too test that MEDFileField1TS.appendFieldProfile is NOT sensible of that.
+ da=DataArrayInt.New(); da.setValues([1,2,4,5,7,8],6,1) ; da.setName("sup1Node")
+ #
+ ff1.setFieldProfile(f1,mm1,0,da)
+ ff1.write(fname,0)
+ #
+ vals,pfl=ff1.getFieldWithProfile(ON_NODES,0,mm1)
+ self.assertTrue(pfl.isEqualWithoutConsideringStr(da))
+ self.assertTrue(vals.isEqual(d,1e-14))
+ ## #
+ ff2=MEDFileField1TS.New(fname,f1.getName(),-1,-1)
+ vals,pfl=ff2.getFieldWithProfile(ON_NODES,0,mm1)
+ self.assertTrue(pfl.isEqualWithoutConsideringStr(da))
+ self.assertTrue(vals.isEqual(d,1e-14))
+ pass
+
+ def testMEDField12(self):
+ fname="Pyfile33.med"
+ m1=MEDLoaderDataForTest.build2DMesh_1()
+ m1.renumberCells([0,1,4,2,3,5],False)
+ mm1=MEDFileUMesh.New() ; mm1.setCoords(m1.getCoords()) ; mm1.setMeshAtLevel(0,m1) ;
+ mm1.write(fname,2)
+ ff1=MEDFileFieldMultiTS.New()
+ f1=MEDCouplingFieldDouble.New(ON_NODES,ONE_TIME) ; f1.setName("F1Node")
+ d=DataArrayDouble.New() ; d.alloc(2*6,1) ; d.iota(7.); d.rearrange(2); d.setInfoOnComponent(0,"sigX [MPa]") ; d.setInfoOnComponent(1,"sigY [GPa]")
+ f1.setArray(d) # note that f1 is NOT defined fully (no mesh !). It is not a bug of test it is too test that MEDFileField1TS.appendFieldProfile is NOT sensible of that.
+ da=DataArrayInt.New(); da.setValues([1,2,4,5,7,8],6,1) ; da.setName("sup1Node")
+ #
+ ff1.appendFieldProfile(f1,mm1,0,da)
+ f1.setTime(1.2,1,2) ; e=d.applyFunc("2*x") ; e.copyStringInfoFrom(d) ; f1.setArray(e) ;
+ ff1.appendFieldProfile(f1,mm1,0,da)
+ ff1.write(fname,0)
+ #
+ vals,pfl=ff1.getFieldWithProfile(ON_NODES,1,2,0,mm1)
+ self.assertTrue(pfl.isEqualWithoutConsideringStr(da))
+ self.assertTrue(vals.isEqual(e,1e-14))
+ vals,pfl=ff1.getFieldWithProfile(ON_NODES,-1,-1,0,mm1)
+ self.assertTrue(pfl.isEqualWithoutConsideringStr(da))
+ self.assertTrue(vals.isEqual(d,1e-14))
+ #
+ ff2=MEDFileFieldMultiTS.New(fname,f1.getName())
+ vals,pfl=ff2.getFieldWithProfile(ON_NODES,1,2,0,mm1)
+ self.assertTrue(pfl.isEqualWithoutConsideringStr(da))
+ self.assertTrue(vals.isEqual(e,1e-14))
+ vals,pfl=ff2.getFieldWithProfile(ON_NODES,-1,-1,0,mm1)
+ self.assertTrue(pfl.isEqualWithoutConsideringStr(da))
+ self.assertTrue(vals.isEqual(d,1e-14))
+ pass
+
+ def testMEDField13(self):
+ fname="Pyfile34.med"
+ m1=MEDLoaderDataForTest.build2DMesh_1()
+ m1.renumberCells([0,1,4,2,3,5],False)
+ tmp=m1.getName();
+ m1=m1.buildPartOfMySelf(range(5),True) ; m1.setName(tmp) # suppression of last cell that is a polygon
+ mm1=MEDFileUMesh.New() ; mm1.setCoords(m1.getCoords()) ; mm1.setMeshAtLevel(0,m1) ;
+ mm1.write(fname,2)
+ ff1=MEDFileField1TS.New()
+ f1=MEDCouplingFieldDouble.New(ON_GAUSS_NE,ONE_TIME) ; f1.setName("F3Node")
+ d=DataArrayDouble.New() ; d.alloc(2*11,1) ; d.iota(7.); d.rearrange(2); d.setInfoOnComponent(0,"sigX [MPa]") ; d.setInfoOnComponent(1,"sigY [GPa]")
+ f1.setArray(d) # note that f1 is NOT defined fully (no mesh !). It is not a bug of test it is too test that MEDFileField1TS.appendFieldProfile is NOT sensible of that.
+ da=DataArrayInt.New(); da.setValues([0,2,3],3,1) ; da.setName("sup1NodeElt")
+ #
+ ff1.setFieldProfile(f1,mm1,0,da)
+ ff1.write(fname,0)
+ #
+ vals,pfl=ff1.getFieldWithProfile(ON_GAUSS_NE,0,mm1)
+ self.assertTrue(pfl.isEqualWithoutConsideringStr(da))
+ self.assertTrue(vals.isEqual(d,1e-14))
+ #
+ ff2=MEDFileField1TS.New(fname,f1.getName(),-1,-1)
+ vals,pfl=ff2.getFieldWithProfile(ON_GAUSS_NE,0,mm1)
+ self.assertTrue(pfl.isEqualWithoutConsideringStr(da))
+ self.assertTrue(vals.isEqual(d,1e-14))
+ pass
+
+ def testMEDField14(self):
+ fname="Pyfile35.med"
+ m1=MEDLoaderDataForTest.build2DMesh_1()
+ m1.renumberCells([0,1,4,2,3,5],False)
+ tmp=m1.getName();
+ m1=m1.buildPartOfMySelf(range(5),True) ; m1.setName(tmp) # suppression of last cell that is a polygon
+ mm1=MEDFileUMesh.New() ; mm1.setCoords(m1.getCoords()) ; mm1.setMeshAtLevel(0,m1) ;
+ mm1.write(fname,2)
+ ff1=MEDFileFieldMultiTS.New()
+ f1=MEDCouplingFieldDouble.New(ON_GAUSS_NE,ONE_TIME) ; f1.setName("F4Node")
+ d=DataArrayDouble.New() ; d.alloc(2*11,1) ; d.iota(7.); d.rearrange(2); d.setInfoOnComponent(0,"sigX [MPa]") ; d.setInfoOnComponent(1,"sigY [GPa]")
+ f1.setArray(d) # note that f1 is NOT defined fully (no mesh !). It is not a bug of test it is too test that MEDFileField1TS.appendFieldProfile is NOT sensible of that.
+ da=DataArrayInt.New(); da.setValues([0,2,3],3,1) ; da.setName("sup1NodeElt")
+ #
+ ff1.appendFieldProfile(f1,mm1,0,da)
+ f1.setTime(1.2,1,2) ; e=d.applyFunc("2*x") ; e.copyStringInfoFrom(d) ; f1.setArray(e) ;
+ ff1.appendFieldProfile(f1,mm1,0,da)
+ ff1.write(fname,0)
+ #
+ vals,pfl=ff1.getFieldWithProfile(ON_GAUSS_NE,-1,-1,0,mm1)
+ self.assertTrue(pfl.isEqualWithoutConsideringStr(da))
+ self.assertTrue(vals.isEqual(d,1e-14))
+ vals,pfl=ff1.getFieldWithProfile(ON_GAUSS_NE,1,2,0,mm1)
+ self.assertTrue(pfl.isEqualWithoutConsideringStr(da))
+ self.assertTrue(vals.isEqual(e,1e-14))
+ #
+ ff2=MEDFileFieldMultiTS.New(fname,f1.getName())
+ vals,pfl=ff1.getFieldWithProfile(ON_GAUSS_NE,-1,-1,0,mm1)
+ self.assertTrue(pfl.isEqualWithoutConsideringStr(da))
+ self.assertTrue(vals.isEqual(d,1e-14))
+ vals,pfl=ff1.getFieldWithProfile(ON_GAUSS_NE,1,2,0,mm1)
+ self.assertTrue(pfl.isEqualWithoutConsideringStr(da))
+ self.assertTrue(vals.isEqual(e,1e-14))
pass
pass
#include <mpi.h>
#include <vector>
+#include <map>
#include <set>
#include <map>
#include "MPI2Connector.hxx"
#include <iostream>
-#include <string.h>
+#include <cstring>
MPI2Connector::MPI2Connector()
{