throw INTERP_KERNEL::Exception(oss.str().c_str());
}
+DataArrayDouble *DataArrayDoubleCollection::getFieldWithName(const std::string& name)
+{
+ std::vector<std::string> vec;
+ for(std::vector< std::pair< MEDCouplingAutoRefCountObjectPtr<DataArrayDouble>, NatureOfField > >::iterator it=_arrs.begin();it!=_arrs.end();it++)
+ {
+ DataArrayDouble *obj((*it).first);
+ if(obj)
+ {
+ if(obj->getName()==name)
+ return obj;
+ else
+ vec.push_back(obj->getName());
+ }
+ }
+ std::ostringstream oss; oss << "DataArrayDoubleCollection::getFieldWithName non const : fieldName \"" << name << "\" does not exist in this ! Possibilities are :";
+ std::copy(vec.begin(),vec.end(),std::ostream_iterator<std::string>(oss," "));
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+}
+
DataArrayDouble *DataArrayDoubleCollection::at(int pos)
{
if(pos<0 || pos>=(int)_arrs.size())
for(std::size_t i=0;i<sz;i++)
{
const std::pair<std::string,int>& info(fieldNames[i]);
+ if(info.second<=0)
+ {
+ std::ostringstream oss; oss << "DataArrayDoubleCollection constructor : At pos #" << i << " the array with name \"" << info.first << "\" as a number of components equal to " << info.second;
+ oss << " It has to be >=1 !";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
_arrs[i].first=DataArrayDouble::New();
_arrs[i].first->alloc(0,info.second);
_arrs[i].first->setName(info.first);
return ddc.getFieldWithName(fieldName);
}
}
- throw INTERP_KERNEL::Exception("MEDCouplingAMRAttribute::retrieveFieldOn : the mesh specified is not in the progeny of this !");
+ throw INTERP_KERNEL::Exception("MEDCouplingAMRAttribute::getFieldOn : the mesh specified is not in the progeny of this !");
+}
+
+DataArrayDouble *MEDCouplingAMRAttribute::getFieldOn(MEDCouplingCartesianAMRMeshGen *mesh, const std::string& fieldName)
+{
+ for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDCouplingGridCollection> >::iterator it=_levs.begin();it!=_levs.end();it++)
+ {
+ int tmp(-1);
+ if((*it)->presenceOf(mesh,tmp))
+ {
+ DataArrayDoubleCollection& ddc((*it)->getFieldsAt(tmp));
+ return ddc.getFieldWithName(fieldName);
+ }
+ }
+ throw INTERP_KERNEL::Exception("MEDCouplingAMRAttribute::getFieldOn non const : the mesh specified is not in the progeny of this !");
}
/*!
std::vector<NatureOfField> getNatures() const;
std::vector<DataArrayDouble *> retrieveFields() const;
const DataArrayDouble *getFieldWithName(const std::string& name) const;
+ DataArrayDouble *getFieldWithName(const std::string& name);
DataArrayDouble *at(int pos);
const DataArrayDouble *at(int pos) const;
int size() const;
MEDCOUPLING_EXPORT int getNumberOfLevels() const;
MEDCOUPLING_EXPORT std::vector<DataArrayDouble *> retrieveFieldsOn(MEDCouplingCartesianAMRMeshGen *mesh) const;
MEDCOUPLING_EXPORT const DataArrayDouble *getFieldOn(MEDCouplingCartesianAMRMeshGen *mesh, const std::string& fieldName) const;
+ MEDCOUPLING_EXPORT DataArrayDouble *getFieldOn(MEDCouplingCartesianAMRMeshGen *mesh, const std::string& fieldName);
MEDCOUPLING_EXPORT MEDCouplingFieldDouble *buildCellFieldOnRecurseWithoutOverlapWithoutGhost(MEDCouplingCartesianAMRMeshGen *mesh, const std::string& fieldName) const;
MEDCOUPLING_EXPORT MEDCouplingFieldDouble *buildCellFieldOnWithGhost(MEDCouplingCartesianAMRMeshGen *mesh, const std::string& fieldName) const;
MEDCOUPLING_EXPORT MEDCouplingFieldDouble *buildCellFieldOnWithoutGhost(MEDCouplingCartesianAMRMeshGen *mesh, const std::string& fieldName) const;
return new MEDCouplingCartesianAMRMesh(meshName,spaceDim,nodeStrctStart,nodeStrctStop,originStart,originStop,dxyzStart,dxyzStop);
}
+MEDCouplingCartesianAMRMesh *MEDCouplingCartesianAMRMesh::New(MEDCouplingIMesh *mesh)
+{
+ return new MEDCouplingCartesianAMRMesh(mesh);
+}
+
const MEDCouplingCartesianAMRMeshGen *MEDCouplingCartesianAMRMesh::getFather() const
{
//I'm god father ! No father !
{
}
+MEDCouplingCartesianAMRMesh::MEDCouplingCartesianAMRMesh(MEDCouplingIMesh *mesh):MEDCouplingCartesianAMRMeshGen(mesh)
+{
+}
+
std::vector<const BigMemoryObject *> MEDCouplingCartesianAMRMesh::getDirectChildren() const
{
std::vector<const BigMemoryObject *> ret(MEDCouplingCartesianAMRMeshGen::getDirectChildren());
public:
MEDCOUPLING_EXPORT static MEDCouplingCartesianAMRMesh *New(const std::string& meshName, int spaceDim, const int *nodeStrctStart, const int *nodeStrctStop,
const double *originStart, const double *originStop, const double *dxyzStart, const double *dxyzStop);
+ MEDCOUPLING_EXPORT static MEDCouplingCartesianAMRMesh *New(MEDCouplingIMesh *mesh);
MEDCOUPLING_EXPORT const MEDCouplingCartesianAMRMeshGen *getFather() const;
MEDCOUPLING_EXPORT const MEDCouplingCartesianAMRMeshGen *getGodFather() const;
MEDCOUPLING_EXPORT int getAbsoluteLevel() const;
MEDCouplingCartesianAMRMesh(const MEDCouplingCartesianAMRMesh& other);
MEDCouplingCartesianAMRMesh(const std::string& meshName, int spaceDim, const int *nodeStrctStart, const int *nodeStrctStop,
const double *originStart, const double *originStop, const double *dxyzStart, const double *dxyzStop);
+ MEDCouplingCartesianAMRMesh(MEDCouplingIMesh *mesh);
MEDCOUPLING_EXPORT std::vector<const BigMemoryObject *> getDirectChildren() const;
~MEDCouplingCartesianAMRMesh();
};
ids=b.getIdsInRange(0.4,0.7)
f=MEDCouplingFieldDouble(ON_CELLS) ; f.setMesh(im) ; f.setName("toto") ; arr=DataArrayDouble(im.getNumberOfCells()) ; arr[:]=0. ; arr[ids]=1. ; f.setArray(arr)
# f.write("test.vti")
- amr=MEDCouplingCartesianAMRMesh("mesh",2,[51,51],[0.,0.],[0.04,0.04])
+ amr=MEDCouplingCartesianAMRMesh(MEDCouplingIMesh("mesh",2,[51,51],[0.,0.],[0.04,0.04]))
arr2=DataArrayByte(im.getNumberOfCells()) ; arr2[:]=0 ; arr2[ids]=1
bso=BoxSplittingOptions() ; bso.setEfficiencyGoal(0.5); bso.setEfficiencyThreshold(0.8) ; bso.setMaximumNbOfCellsInPatch(3000) ; bso.setMinimumPatchLength(6) ; bso.setMaximumPatchLength(11)
amr.createPatchesFromCriterion(bso,arr2,[2,2])
class MEDCouplingCartesianAMRMesh : public MEDCouplingCartesianAMRMeshGen
{
public:
+ static MEDCouplingCartesianAMRMesh *New(MEDCouplingIMesh *mesh) throw(INTERP_KERNEL::Exception);
%extend
{
static MEDCouplingCartesianAMRMesh *New(const std::string& meshName, int spaceDim, PyObject *nodeStrct, PyObject *origin, PyObject *dxyz) throw(INTERP_KERNEL::Exception)
MEDCouplingCartesianAMRMesh(const std::string& meshName, int spaceDim, PyObject *nodeStrct, PyObject *origin, PyObject *dxyz) throw(INTERP_KERNEL::Exception)
{
- return ParaMEDMEM_MEDCouplingCartesianAMRMesh_New(meshName,spaceDim,nodeStrct,origin,dxyz);
+ return ParaMEDMEM_MEDCouplingCartesianAMRMesh_New__SWIG_1(meshName,spaceDim,nodeStrct,origin,dxyz);
+ }
+
+ MEDCouplingCartesianAMRMesh(MEDCouplingIMesh *mesh) throw(INTERP_KERNEL::Exception)
+ {
+ return MEDCouplingCartesianAMRMesh::New(mesh);
}
}
};