PyObject *buildSubMeshData(PyObject *li) const throw(INTERP_KERNEL::Exception)
{
- int size;
- INTERP_KERNEL::AutoPtr<int> tmp=convertPyToNewIntArr2(li,&size);
- DataArrayInt *ret1;
- MEDCouplingMesh *ret0=self->buildSubMeshData(tmp,tmp+size,ret1);
+ DataArrayInt *ret1=0;
+ MEDCouplingMesh *ret0=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);
+ ret0=self->buildSubMeshData(tmp,tmp+size,ret1);
+ }
+ else
+ {
+ DataArrayInt *da2=reinterpret_cast< DataArrayInt * >(da);
+ if(!da2)
+ throw INTERP_KERNEL::Exception("Not null DataArrayInt instance expected !");
+ da2->checkAllocated();
+ ret0=self->buildSubMeshData(da2->getConstPointer(),da2->getConstPointer()+da2->getNbOfElems(),ret1);
+ }
PyObject *res = PyList_New(2);
PyList_SetItem(res,0,convertMesh(ret0, SWIG_POINTER_OWN | 0 ));
PyList_SetItem(res,1,SWIG_NewPointerObj((void*)ret1,SWIGTYPE_p_ParaMEDMEM__DataArrayInt,SWIG_POINTER_OWN | 0));
return res;
}
+
void setGaussLocalizationOnCells(PyObject *li, const std::vector<double>& refCoo,
const std::vector<double>& gsCoo, const std::vector<double>& wg) throw(INTERP_KERNEL::Exception)
{
- int size;
- INTERP_KERNEL::AutoPtr<int> tmp=convertPyToNewIntArr2(li,&size);
- self->setGaussLocalizationOnCells(tmp,tmp+size,refCoo,gsCoo,wg);
+ 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->setGaussLocalizationOnCells(tmp,((int *)tmp)+size,refCoo,gsCoo,wg);
+ }
+ else
+ {
+ DataArrayInt *da2=reinterpret_cast< DataArrayInt * >(da);
+ if(!da2)
+ throw INTERP_KERNEL::Exception("Not null DataArrayInt instance expected !");
+ da2->checkAllocated();
+ self->setGaussLocalizationOnCells(da2->getConstPointer(),da2->getConstPointer()+da2->getNbOfElems(),refCoo,gsCoo,wg);
+ }
}
+
PyObject *getCellIdsHavingGaussLocalization(int locId) const throw(INTERP_KERNEL::Exception)
{
std::vector<int> tmp;
}
MEDFileFieldLoc::MEDFileFieldLoc(const char *locName, INTERP_KERNEL::NormalizedCellType geoType,
- const std::vector<double>& refCoo, const std::vector<double>& gsCoo, const std::vector<double>& w):_name(locName),_geo_type(geoType),_ref_coo(_ref_coo),_gs_coo(gsCoo),
+ const std::vector<double>& refCoo, const std::vector<double>& gsCoo, const std::vector<double>& w):_name(locName),_geo_type(geoType),_ref_coo(refCoo),_gs_coo(gsCoo),
_w(w)
{
const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
+ _dim=cm.getDimension();
_nb_node_per_cell=cm.getNumberOfNodes();
_nb_gauss_pt=_w.size();
}
void MEDFileFieldPerMeshPerTypePerDisc::assignFieldNoProfile(int offset, int nbOfCells, const MEDCouplingFieldDouble *field, MEDFieldFieldGlobs& glob) throw(INTERP_KERNEL::Exception)
{
- INTERP_KERNEL::NormalizedCellType type=getGeoType();
+ _type=field->getTypeOfField();
const DataArrayDouble *da=field->getArray();
- switch(type)
+ switch(_type)
{
case ON_CELLS:
{
case ON_GAUSS_PT:
{
const MEDCouplingFieldDiscretization *disc=field->getDiscretization();
+ const MEDCouplingGaussLocalization& gsLoc=field->getGaussLocalization(_loc_id);
const MEDCouplingFieldDiscretizationGauss *disc2=dynamic_cast<const MEDCouplingFieldDiscretizationGauss *>(disc);
if(!disc2)
throw INTERP_KERNEL::Exception("assignFieldNoProfile : invalid call to this method ! Internal Error !");
- const DataArrayInt *da=disc2->getArrayOfDiscIds();
- MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da2=da->selectByTupleId2(offset,nbOfCells,1);
+ const DataArrayInt *dai=disc2->getArrayOfDiscIds();
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> dai2=disc2->getOffsetArr(field->getMesh());
+ const int *dai2Ptr=dai2->getConstPointer();
+ int nbi=gsLoc.getWeights().size();
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da2=dai->selectByTupleId2(offset,offset+nbOfCells,1);
MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da3=da2->getIdsEqual(_loc_id);
+ const int *da3Ptr=da3->getConstPointer();
if(da3->getNumberOfTuples()!=nbOfCells)
{//profile : for gauss even in NoProfile !!!
std::ostringstream oss; oss << "Pfl_" << getName() << "_" << INTERP_KERNEL::CellModel::GetCellModel(getGeoType()).getRepr() << "_" << _loc_id;
da3->setName(_profile.c_str());
glob.appendProfile(da3);
}
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da4=DataArrayInt::New();
+ _nval=da3->getNbOfElems();
+ da4->alloc(_nval*nbi,1);
+ int *da4Ptr=da4->getPointer();
+ for(int i=0;i<_nval;i++)
+ {
+ int ref=dai2Ptr[offset+da3Ptr[i]];
+ for(int j=0;j<nbi;j++)
+ *da4Ptr++=ref+j;
+ }
std::ostringstream oss2; oss2 << "Loc_" << getName() << "_" << INTERP_KERNEL::CellModel::GetCellModel(getGeoType()).getRepr() << "_" << _loc_id;
_localization=oss2.str();
- const MEDCouplingGaussLocalization& gsLoc=field->getGaussLocalization(_loc_id);
+ _arr=da->selectByTupleId(da4->getConstPointer(),da4->getConstPointer()+_nval*nbi);
glob.appendLoc(_localization.c_str(),getGeoType(),gsLoc.getRefCoords(),gsLoc.getGaussCoords(),gsLoc.getWeights());
+ break;
}
default:
throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::assignFieldNoProfile : not implemented yet for such discretization type of field !");
}
}
+void MEDFileFieldPerMeshPerTypePerDisc::assignNodeFieldNoProfile(const MEDCouplingFieldDouble *field, MEDFieldFieldGlobs& glob) throw(INTERP_KERNEL::Exception)
+{
+ _arr=field->getArray()->deepCpy();
+ _nval=field->getArray()->getNumberOfTuples();
+}
+
MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::New(MEDFileFieldPerMeshPerType *fath, med_idt fid, TypeOfField type, int profileIt) throw(INTERP_KERNEL::Exception)
{
return new MEDFileFieldPerMeshPerTypePerDisc(fath,fid,type,profileIt);
_field_pm_pt_pd[*it]->assignFieldNoProfile(offset,nbOfCells,field,glob);
}
+void MEDFileFieldPerMeshPerType::assignNodeFieldNoProfile(const MEDCouplingFieldDouble *field, MEDFieldFieldGlobs& 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);
+}
+
std::vector<int> MEDFileFieldPerMeshPerType::addNewEntryIfNecessary(const MEDCouplingFieldDouble *field, int offset, int nbOfCells) throw(INTERP_KERNEL::Exception)
{
TypeOfField type=field->getTypeOfField();
{
std::vector<int> ret2=addNewEntryIfNecessaryGauss(field,offset,nbOfCells);
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();
if(_field_pm_pt_pd[j]->getLocId()==locIdToFind)
{
_field_pm_pt_pd[j]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
+ ret3[k++]=j;
found=true;
}
}
{
_field_pm_pt_pd.resize(sz+1);
_field_pm_pt_pd[sz]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
+ ret3[k++]=sz;
}
}
- return ret2;
+ return ret3;
}
}
if(!disc2)
throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : invalid call to this method ! Internal Error !");
const DataArrayInt *da=disc2->getArrayOfDiscIds();
- MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da2=da->selectByTupleId2(offset,nbOfCells,1);
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da2=da->selectByTupleId2(offset,offset+nbOfCells,1);
std::set<int> retTmp=da2->getDifferentValues();
if(retTmp.find(-1)!=retTmp.end())
throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : some cells have no dicretization description !");
return new MEDFileFieldPerMesh(fath,meshCsit,meshIteration,meshOrder);
}
-MEDFileFieldPerMesh *MEDFileFieldPerMesh::New(const MEDCouplingMesh *mesh)
+MEDFileFieldPerMesh *MEDFileFieldPerMesh::New(MEDFileField1TSWithoutDAS *fath, const MEDCouplingMesh *mesh)
{
- return new MEDFileFieldPerMesh(mesh);
+ return new MEDFileFieldPerMesh(fath,mesh);
}
void MEDFileFieldPerMesh::copyTinyInfoFrom(const MEDCouplingMesh *mesh) throw(INTERP_KERNEL::Exception)
}
}
+void MEDFileFieldPerMesh::assignNodeFieldNoProfile(const MEDCouplingFieldDouble *field, MEDFieldFieldGlobs& glob) throw(INTERP_KERNEL::Exception)
+{
+ int pos=addNewEntryIfNecessary(INTERP_KERNEL::NORM_ERROR);
+ _field_pm_pt[pos]->assignNodeFieldNoProfile(field,glob);
+}
+
void MEDFileFieldPerMesh::finishLoading(med_idt fid) throw(INTERP_KERNEL::Exception)
{
INTERP_KERNEL::AutoPtr<char> meshName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
{
}
-MEDFileFieldPerMesh::MEDFileFieldPerMesh(const MEDCouplingMesh *mesh)
+MEDFileFieldPerMesh::MEDFileFieldPerMesh(MEDFileField1TSWithoutDAS *fath, const MEDCouplingMesh *mesh):_father(fath)
{
copyTinyInfoFrom(mesh);
}
{
}
+MEDFieldFieldGlobs::MEDFieldFieldGlobs()
+{
+}
+
void MEDFieldFieldGlobs::setFileName(const char *fileName)
{
_file_name=fileName;
throw INTERP_KERNEL::Exception(oss.str().c_str());
}
}
- obj->incrRef();
_locs.push_back(obj);
}
void MEDFileField1TSWithoutDAS::copyTinyInfoFrom(const MEDCouplingFieldDouble *field) throw(INTERP_KERNEL::Exception)
{
+ _name=field->getName();
+ if(_name.empty())
+ throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutDAS::copyTinyInfoFrom : unsupported fields with no name in MED file !");
const DataArrayDouble *arr=field->getArray();
if(!arr)
throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutDAS::copyTinyInfoFrom : no array set !");
{
}
+MEDFileField1TSWithoutDAS::MEDFileField1TSWithoutDAS()
+{
+}
+
int MEDFileField1TSWithoutDAS::addNewEntryIfNecessary(const MEDCouplingMesh *mesh) throw(INTERP_KERNEL::Exception)
{
std::string tmp(mesh->getName());
}
int sz=_field_per_mesh.size();
_field_per_mesh.resize(sz+1);
- _field_per_mesh[sz]=MEDFileFieldPerMesh::New(mesh);
+ _field_per_mesh[sz]=MEDFileFieldPerMesh::New(this,mesh);
return sz;
}
return new MEDFileField1TS(fileName,fieldName,iteration,order);
}
+MEDFileField1TS *MEDFileField1TS::New()
+{
+ return new MEDFileField1TS;
+}
+
void MEDFileField1TS::write(const char *fileName, int mode) const throw(INTERP_KERNEL::Exception)
{
med_access_mode medmod=MEDFileUtilities::TraduceWriteMode(mode);
throw e;
}
+MEDFileField1TS::MEDFileField1TS()
+{
+}
+
std::vector<std::string> MEDFileField1TS::getPflsReallyUsed() const
{
return getPflsReallyUsed2();
_file_name="";
const MEDCouplingMesh *mesh=field->getMesh();
//
- std::vector<int> code=MEDFileField1TSWithoutDAS::CheckSBTMesh(mesh);
- copyTinyInfoFrom(field);
- //
- int pos=addNewEntryIfNecessary(mesh);
- _field_per_mesh[pos]->assignFieldNoProfile(code,field,*this);
+ 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);
+ }
}
MEDFileFieldMultiTSWithoutDAS *MEDFileFieldMultiTSWithoutDAS::New(med_idt fid, const char *fieldName, int id, const std::vector<std::string>& infos, int nbOfStep) throw(INTERP_KERNEL::Exception)
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 writeLL(med_idt fid) const throw(INTERP_KERNEL::Exception);
const MEDFileFieldPerMeshPerType *getFather() const;
int getIteration() const;
int _profile_it;
std::string _profile;
std::string _localization;
- //! only on assignement -2 : ON_CELLS, -1 : ON_GAUSS_NE, 0..* : ON_GAUSS_PT
+ //! only on assignement -3 : ON_NODES, -2 : ON_CELLS, -1 : ON_GAUSS_NE, 0..* : ON_GAUSS_PT
mutable int _loc_id;
};
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);
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);
class MEDFileFieldPerMesh : public RefCountObject, public MEDFileWritable
{
public:
- static MEDFileFieldPerMesh *New(const MEDCouplingMesh *mesh);
+ 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 finishLoading(med_idt fid) throw(INTERP_KERNEL::Exception);
void writeLL(med_idt fid) const throw(INTERP_KERNEL::Exception);
void getDimension(int& dim) const;
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);
MEDFileFieldPerMesh(MEDFileField1TSWithoutDAS *fath, int meshCsit, int meshIteration, int meshOrder);
- MEDFileFieldPerMesh(const MEDCouplingMesh *mesh);
+ MEDFileFieldPerMesh(MEDFileField1TSWithoutDAS *fath, const MEDCouplingMesh *mesh);
private:
std::string _mesh_name;
int _mesh_iteration;
{
public:
MEDFieldFieldGlobs(const char *fname);
+ MEDFieldFieldGlobs();
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);
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);
+ MEDFileField1TSWithoutDAS();
protected:
std::string _name;
std::string _dt_unit;
{
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);
std::vector<std::string> getPflsReallyUsed() const;
std::vector<std::string> getLocsReallyUsed() const;
MEDFileField1TS(const char *fileName, const char *fieldName, int iteration, int order) throw(INTERP_KERNEL::Exception);
+ MEDFileField1TS();
};
class MEDFileFieldMultiTSWithoutDAS : public RefCountObject, public MEDFileWritable
{
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);
MEDCouplingFieldDouble *getFieldAtLevel(TypeOfField type, int meshDimRelToMax, int renumPol=0) const throw(INTERP_KERNEL::Exception);
MEDCouplingFieldDouble *getFieldOnMeshAtLevel(TypeOfField type, const MEDCouplingMesh *mesh, 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 *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);
};
class MEDFileFieldMultiTSWithoutDAS
targetMesh.setCoords(myCoords);
return targetMesh;
+ #this mesh has several cells duplicated ! it is not beautiful but efficient to test file WR.
+ def build2DMesh_3(cls):
+ targetCoords=[-0.3,-0.3, 0.2,-0.3, 0.7,-0.3, -0.3,0.2, 0.2,0.2, 0.7,0.2, -0.3,0.7, 0.2,0.7, 0.7,0.7,
+ -0.05,0.95, 0.2,1.2, 0.45,0.95]
+ targetConn=[1,4,2, 4,5,2, 6,10,8,9,11,7, 0,3,4,1, 6,7,4,3, 7,8,5,4]
+ targetMesh=MEDCouplingUMesh.New();
+ targetMesh.setMeshDimension(2);
+ targetMesh.allocateCells(13);
+ targetMesh.setName("2DMesh_3");
+ targetMesh.insertNextCell(NORM_TRI3,3,targetConn[0:3])
+ targetMesh.insertNextCell(NORM_TRI3,3,targetConn[3:6])
+ targetMesh.insertNextCell(NORM_TRI3,3,targetConn[0:3])
+ targetMesh.insertNextCell(NORM_TRI3,3,targetConn[3:6])
+ targetMesh.insertNextCell(NORM_TRI3,3,targetConn[0:3])
+ targetMesh.insertNextCell(NORM_TRI3,3,targetConn[3:6])
+ targetMesh.insertNextCell(NORM_QUAD4,4,targetConn[12:16])
+ targetMesh.insertNextCell(NORM_QUAD4,4,targetConn[16:20])
+ targetMesh.insertNextCell(NORM_QUAD4,4,targetConn[12:16])
+ targetMesh.insertNextCell(NORM_QUAD4,4,targetConn[16:20])
+ targetMesh.insertNextCell(NORM_TRI6,6,targetConn[6:12])
+ targetMesh.insertNextCell(NORM_TRI6,6,targetConn[6:12])
+ targetMesh.insertNextCell(NORM_TRI6,6,targetConn[6:12])
+ targetMesh.finishInsertingCells();
+ myCoords=DataArrayDouble.New();
+ myCoords.setValues(targetCoords,12,2);
+ myCoords.setInfoOnComponent(0,"toto [m]");
+ myCoords.setInfoOnComponent(1,"energie [kW]");
+ targetMesh.setCoords(myCoords);
+ return targetMesh;
+
def build3DMesh_1(cls):
coords=[0.,0.,0., 1.,1.,0., 1.,1.25,0., 0.,1.,0., 1.,1.5,0., 2.,0.,0., 2.,1.,0., 1.,2.,0., 0.,2.,0., 3.,1.,0.,
3.,2.,0., 0.,1.,0., 1.,3.,0., 2.,2.,0., 2.,3.,0.,
f.checkCoherency();
return f;
+ def buildVecFieldOnGauss_2(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,2,3],3,1)
+ f.setGaussLocalizationOnCells(di,_refCoo1,_gsCoo1,_wg1)
+ _wg1[-1]*=2
+ f.setGaussLocalizationOnCells([1,5],_refCoo1,_gsCoo1,_wg1);
+ _wg1[-1]*=2
+ f.setGaussLocalizationOnCells([4],_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);
build2DCurveMesh_1=classmethod(build2DCurveMesh_1)
build2DMesh_1=classmethod(build2DMesh_1)
build2DMesh_2=classmethod(build2DMesh_2)
+ build2DMesh_3=classmethod(build2DMesh_3)
build3DMesh_1=classmethod(build3DMesh_1)
build3DSurfMesh_1=classmethod(build3DSurfMesh_1)
build3DMesh_2=classmethod(build3DMesh_2)
buildVecFieldOnCells_1=classmethod(buildVecFieldOnCells_1)
buildVecFieldOnNodes_1=classmethod(buildVecFieldOnNodes_1)
buildVecFieldOnGauss_1=classmethod(buildVecFieldOnGauss_1)
+ buildVecFieldOnGauss_2=classmethod(buildVecFieldOnGauss_2)
buildVecFieldOnGaussNE_1=classmethod(buildVecFieldOnGaussNE_1)
pass
f2=MEDLoader.ReadFieldCell("Pyfile12.med",'3DMesh_1',0,"VectorFieldOnCells",its[0][0],its[0][1])
self.assertTrue(f.isEqual(f2,1e-12,1e-12))
pass
+
+ #first test of assignation. No profile and types sorted by type.
+ def testMEDField8(self):
+ fname="Pyfile25.med"
+ f1=MEDLoaderDataForTest.buildVecFieldOnCells_1();
+ m1=f1.getMesh()
+ mm1=MEDFileUMesh.New()
+ mm1.setCoords(m1.getCoords())
+ mm1.setMeshAtLevel(0,m1)
+ mm1.setName(m1.getName())
+ mm1.write(fname,2)
+ ff1=MEDFileField1TS.New()
+ ff1.setFieldNoProfileSBT(f1)
+ ff1.write(fname,0)
+ f2=MEDLoader.ReadFieldCell(fname,f1.getMesh().getName(),0,f1.getName(),f1.getTime()[1],f1.getTime()[2]);
+ self.assertTrue(f1.isEqual(f2,1e-12,1e-12))
+ #
+ fname="Pyfile26.med"
+ f1=MEDLoaderDataForTest.buildVecFieldOnNodes_1();
+ m1=f1.getMesh()
+ mm1=MEDFileUMesh.New()
+ mm1.setCoords(m1.getCoords())
+ mm1.setMeshAtLevel(0,m1)
+ mm1.setName(m1.getName())
+ mm1.write(fname,2)
+ ff1=MEDFileField1TS.New()
+ ff1.setFieldNoProfileSBT(f1)
+ ff1.write(fname,0)
+ f2=MEDLoader.ReadFieldNode(fname,f1.getMesh().getName(),0,f1.getName(),f1.getTime()[1],f1.getTime()[2])
+ self.assertTrue(f1.isEqual(f2,1e-12,1e-12))
+ #
+ fname="Pyfile27.med"
+ f1=MEDLoaderDataForTest.buildVecFieldOnGaussNE_1();
+ m1=f1.getMesh()
+ mm1=MEDFileUMesh.New()
+ mm1.setCoords(m1.getCoords())
+ mm1.setMeshAtLevel(0,m1)
+ mm1.setName(m1.getName())
+ mm1.write(fname,2)
+ ff1=MEDFileField1TS.New()
+ ff1.setFieldNoProfileSBT(f1)
+ ff1.write(fname,0)
+ f2=MEDLoader.ReadFieldGaussNE(fname,f1.getMesh().getName(),0,f1.getName(),f1.getTime()[1],f1.getTime()[2])
+ self.assertTrue(f1.isEqual(f2,1e-12,1e-12))
+ #
+ fname="Pyfile28.med"
+ f1=MEDLoaderDataForTest.buildVecFieldOnGauss_2();
+ m1=f1.getMesh()
+ mm1=MEDFileUMesh.New()
+ mm1.setCoords(m1.getCoords())
+ mm1.setMeshAtLevel(0,m1)
+ mm1.setName(m1.getName())
+ mm1.write(fname,2)
+ ff1=MEDFileField1TS.New()
+ 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))
+ pass
pass
unittest.main()