// Author : Anthony Geay
#include "MEDCouplingAMRAttribute.hxx"
+#include "MEDCouplingFieldDouble.hxx"
#include "MEDCouplingMemArray.hxx"
+#include "MEDCouplingIMesh.hxx"
#include <sstream>
/*!
* This method builds a newly created field on cell just lying on mesh \a mesh without its eventual refinement.
+ * The output field also displays ghost cells.
*
* \return MEDCouplingFieldDouble * - a field on cells that the caller has to deal with (deallocate it).
*
*/
MEDCouplingFieldDouble *MEDCouplingAMRAttribute::buildCellFieldOnWithGhost(int ghostLev, MEDCouplingCartesianAMRMeshGen *mesh, const std::string& fieldName) const
{
+ const DataArrayDouble *arr(0);
for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDCouplingGridCollection> >::const_iterator it=_levs.begin();it!=_levs.end();it++)
{
int tmp(-1);
if((*it)->presenceOf(mesh,tmp))
{
const DataArrayDoubleCollection& ddc((*it)->retrieveFieldsAt(tmp));
- const DataArrayDouble *arr(ddc.getFieldWithName(fieldName));
+ arr=ddc.getFieldWithName(fieldName);
}
}
- throw INTERP_KERNEL::Exception("MEDCouplingAMRAttribute::buildCellFieldOnWithGhost : the mesh specified is not in the progeny of this !");
+ if(!arr)
+ throw INTERP_KERNEL::Exception("MEDCouplingAMRAttribute::buildCellFieldOnWithGhost : the mesh specified is not in the progeny of this !");
+ MEDCouplingAutoRefCountObjectPtr<MEDCouplingIMesh> im(mesh->getImageMesh()->buildWithGhost(ghostLev));
+ MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret(MEDCouplingFieldDouble::New(ON_CELLS));
+ ret->setMesh(im);
+ ret->setArray(const_cast<DataArrayDouble *>(arr));
+ ret->setName(arr->getName());
+ return ret.retn();
}
/*!
//
for(std::size_t i=1;i<sz;i++)
{
- const MEDCouplingGridCollection *fine(_levs[sz]),*coarse(_levs[sz-1]);
+ const MEDCouplingGridCollection *fine(_levs[i]),*coarse(_levs[i-1]);
MEDCouplingGridCollection::SynchronizeCoarseToFine(ghostLev,coarse,fine);
}
}
//
for(std::size_t i=1;i<sz;i++)
{
- const MEDCouplingGridCollection *fine(_levs[sz]),*coarse(_levs[sz-1]);
+ const MEDCouplingGridCollection *fine(_levs[i]),*coarse(_levs[i-1]);
MEDCouplingGridCollection::SynchronizeCoarseToFineOnlyInGhostZone(ghostLev,coarse,fine);
}
}
//
for(std::size_t i=1;i<sz;i++)
{
- const MEDCouplingGridCollection *fine(_levs[sz]);
+ const MEDCouplingGridCollection *fine(_levs[i]);
if(!fine)
throw INTERP_KERNEL::Exception("MEDCouplingAMRAttribute::synchronizeFineEachOtherInGhostZone : presence of a NULL element !");
fine->synchronizeFineEachOther(ghostLev);