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);
}
+std::string MEDFileFieldLoc::repr() const
+{
+ std::ostringstream oss; oss.precision(15);
+ const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
+ oss << "Localization \"" << _name << "\" :\n" << " - Geometric Type : " << cm.getRepr();
+ oss << "\n - Dimension : " << _dim << "\n - Number of gauss points : ";
+ oss << _nb_gauss_pt << "\n - Number of nodes in cell : " << _nb_node_per_cell;
+ oss << "\n - Ref coords are : ";
+ int sz=_ref_coo.size();
+ if(sz%_dim==0)
+ {
+ int nbOfTuples=sz/_dim;
+ for(int i=0;i<nbOfTuples;i++)
+ {
+ oss << "(";
+ for(int j=0;j<_dim;j++)
+ { oss << _ref_coo[i*_dim+j]; if(j!=_dim-1) oss << ", "; }
+ oss << ") ";
+ }
+ }
+ else
+ std::copy(_ref_coo.begin(),_ref_coo.end(),std::ostream_iterator<double>(oss," "));
+ oss << "\n - Gauss coords in reference element : ";
+ sz=_gs_coo.size();
+ if(sz%_dim==0)
+ {
+ int nbOfTuples=sz/_dim;
+ for(int i=0;i<nbOfTuples;i++)
+ {
+ oss << "(";
+ for(int j=0;j<_dim;j++)
+ { oss << _gs_coo[i*_dim+j]; if(j!=_dim-1) oss << ", "; }
+ oss << ") ";
+ }
+ }
+ else
+ std::copy(_gs_coo.begin(),_gs_coo.end(),std::ostream_iterator<double>(oss," "));
+ oss << "\n - Weights of Gauss coords are : "; std::copy(_w.begin(),_w.end(),std::ostream_iterator<double>(oss," "));
+ return oss.str();
+}
+
void MEDFileFieldPerMeshPerTypePerDisc::assignFieldNoProfile(int offset, int nbOfCells, const MEDCouplingFieldDouble *field, MEDFieldFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception)
{
_type=field->getTypeOfField();
return _locs[locId]->getNbOfGaussPtPerCell();
}
+const MEDFileFieldLoc& MEDFieldFieldGlobs::getLocalization(const char *pflName) const throw(INTERP_KERNEL::Exception)
+{
+ return getLocalizationFromId(getLocalizationId(pflName));
+}
+
const MEDFileFieldLoc& MEDFieldFieldGlobs::getLocalizationFromId(int locId) const throw(INTERP_KERNEL::Exception)
{
if(locId<0 || locId>=(int)_locs.size())
return _globals->getFileName2();
}
+const MEDFileFieldLoc& MEDFieldFieldGlobsReal::getLocalization(const char *pflName) const throw(INTERP_KERNEL::Exception)
+{
+ return _globals->getLocalization(pflName);
+}
+
const MEDFileFieldLoc& MEDFieldFieldGlobsReal::getLocalizationFromId(int locId) const throw(INTERP_KERNEL::Exception)
{
return _globals->getLocalizationFromId(locId);
static MEDFileFieldLoc *New(const char *locName, INTERP_KERNEL::NormalizedCellType geoType, const std::vector<double>& refCoo, const std::vector<double>& gsCoo, const std::vector<double>& w);
int getNbOfGaussPtPerCell() const { return _nb_gauss_pt; }
void writeLL(med_idt fid) const;
+ std::string repr() const;
bool isName(const char *name) const { return _name==name; }
+ int getDimension() const { return _dim; }
+ int getNumberOfGaussPoints() const { return _nb_gauss_pt; }
+ int getNumberOfPointsInCells() const { return _nb_node_per_cell; }
const std::vector<double>& getRefCoords() const { return _ref_coo; }
const std::vector<double>& getGaussCoords() const { return _gs_coo; }
const std::vector<double>& getGaussWeights() const { return _w; }
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 MEDFileFieldLoc& getLocalization(const char *pflName) 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);
const char *getFileName() const;
std::string getFileName2() const;
const MEDFileFieldLoc& getLocalizationFromId(int locId) const throw(INTERP_KERNEL::Exception);
+ const MEDFileFieldLoc& getLocalization(const char *pflName) 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);
%feature("unref") MEDFileCMesh "$this->decrRef();"
%feature("unref") MEDFileMeshMultiTS "$this->decrRef();"
%feature("unref") MEDFileMeshes "$this->decrRef();"
+%feature("unref") MEDFileFieldLoc "$this->decrRef();"
%feature("unref") MEDFileField1TS "$this->decrRef();"
%feature("unref") MEDFileFieldMultiTS "$this->decrRef();"
%feature("unref") MEDFileFields "$this->decrRef();"
}
};
+ class MEDFileFieldLoc : public RefCountObject
+ {
+ public:
+ const std::string& getName() const;
+ int getDimension() const;
+ int getNumberOfGaussPoints() const;
+ int getNumberOfPointsInCells() const;
+ const std::vector<double>& getRefCoords() const;
+ const std::vector<double>& getGaussCoords() const;
+ const std::vector<double>& getGaussWeights() const;
+ bool isEqual(const MEDFileFieldLoc& other, double eps) const;
+ %extend
+ {
+ std::string __str__() const
+ {
+ return self->repr();
+ }
+ }
+ };
+
class MEDFieldFieldGlobsReal
{
public:
std::vector<std::string> getLocs() const;
virtual std::vector<std::string> getPflsReallyUsed() const = 0;
virtual std::vector<std::string> getLocsReallyUsed() const = 0;
+ %extend
+ {
+ PyObject *getProfile(const std::string& pflName) const throw(INTERP_KERNEL::Exception)
+ {
+ const DataArrayInt *ret=self->getProfile(pflName);
+ if(ret)
+ ret->incrRef();
+ return SWIG_NewPointerObj(SWIG_as_voidptr(ret),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 );
+ }
+
+ PyObject *getLocalizationFromId(int locId) const throw(INTERP_KERNEL::Exception)
+ {
+ const MEDFileFieldLoc *loc=&self->getLocalizationFromId(locId);
+ loc->incrRef();
+ return SWIG_NewPointerObj(SWIG_as_voidptr(loc),SWIGTYPE_p_ParaMEDMEM__MEDFileFieldLoc, SWIG_POINTER_OWN | 0 );
+ }
+
+ PyObject *getLocalization(const char *pflName) const throw(INTERP_KERNEL::Exception)
+ {
+ const MEDFileFieldLoc *loc=&self->getLocalization(pflName);
+ loc->incrRef();
+ return SWIG_NewPointerObj(SWIG_as_voidptr(loc),SWIGTYPE_p_ParaMEDMEM__MEDFileFieldLoc, SWIG_POINTER_OWN | 0 );
+ }
+ }
};
class MEDFileField1TSWithoutDAS : public RefCountObject
ff2=MEDFileField1TS.New(fname,f1.getName(),f1.getTime()[1],f1.getTime()[2])
f2=ff2.getFieldAtLevel(ON_GAUSS_PT,0)
self.assertTrue(f1.isEqual(f2,1e-12,1e-12))
+ sbt=ff2.getFieldSplitedByType()
+ loc1=ff2.getLocalization("Loc_MyFirstFieldOnGaussPoint_NORM_TRI6_5")
+ self.assertEqual("Loc_MyFirstFieldOnGaussPoint_NORM_TRI6_5",loc1.getName())
+ self.assertEqual((-1, 1,-1,-1,1,-1,-1,0,0,-1,0,0),loc1.getRefCoords())
+ self.assertEqual(6,loc1.getNumberOfPointsInCells())
+ self.assertEqual(3,loc1.getNumberOfGaussPoints())
+ self.assertEqual(2,loc1.getDimension())
#
pass
self.assertTrue(vals.isEqual(d,1e-14))
#
ff2=MEDFileField1TS.New(fname,f1.getName(),-1,-1)
+ sbt=ff2.getFieldSplitedByType()
+ self.assertEqual(3,sbt[0][0])#TRI3
+ self.assertEqual(0,sbt[0][1][0][0])#CELL For TRI3
+ self.assertEqual("",sbt[0][1][0][2])#no profile For TRI3
+ self.assertEqual([7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18],sbt[0][1][0][1].getValues())# values for TRI3
+ self.assertEqual(4,sbt[1][0])#QUAD4
+ self.assertEqual(0,sbt[1][1][0][0])#CELL For QUAD4
+ self.assertEqual("sup1_NORM_QUAD4",sbt[1][1][0][2])# profile For QUAD4
+ self.assertEqual([19, 20, 21, 22, 23, 24],sbt[1][1][0][1].getValues())# values for QUAD4
self.assertEqual([0],ff2.getTypesOfFieldAvailable())
vals,pfl=ff2.getFieldWithProfile(ON_CELLS,0,mm1)
self.assertTrue(pfl.isEqualWithoutConsideringStr(da))
self.assertTrue(f4.getArray().isEqual(f1.getArray(),1e-12))
pass
pass
-
+
unittest.main()