Commit 826905a8 authored by Alexis SALZMAN's avatar Alexis SALZMAN

[xFEM,xTLS]revamping the last commit regarding attached gauss point

This is removing the statics and encapsulate things

GP data manager is now encapsulated into a class
xIntegrationRuleStoredDataManager from which all
xIntegrationRuleStoredxxx class derive. This way xIntegrationRule
is not anymore impacted and when xIntegrationRuleStoredxxx is deleted
every thing is automatically cleaned. xIntegrationRuleStoredxxx is
responsible of the management of attached gauss points to entity.

xIntegrationRuleStoredDataManager encapsulate the DATAMANAGER thus in
future switching to others things will be easy. It retake almost the
same API as DATAMANAGER with other names.

Now that static are removed xExtendShapeFcts had to be modified to store
a reference of xIntegrationRuleStoredxxx so that adding GP to entity is
possible through functor call like before but with a new parameter
passing xIntegrationRuleStoredxxx viewd as a
xIntegrationRuleStoredDataManager. The xIntegrationRuleStoredxxx
instance and the xExtendShapeFcts generator are now more tied together.
This induce that the xSpaceExtendedShape based on generator is tied to
xIntegrationRuleStoredxxx and assemble is now a little more
secure as the field (base on xSpaceExtendedShape) is now in coherence
with xIntegrationRuleStoredxxx explicitly.

Hope I did not break something somewhere. I mean test pass but there is
not much of them on those things ....
parent 64ed8890
......@@ -45,9 +45,11 @@ class xExtendShapeGenerator : public xExtendShapeGeneratorBase
{
public:
template <typename ITERFRONT>
xExtendShapeGenerator(
ITERFRONT beg, ITERFRONT end, xEntityToEntity upper_, xfem::xField<VT> &vgama,
std::function<void(AOMD::mEntity *, const xtensor::xPoint &, xmapping::xMapping *)> integration_order_function_object_);
xExtendShapeGenerator(ITERFRONT beg, ITERFRONT end, xEntityToEntity upper_, xfem::xField<VT> &vgama,
std::function<void(AOMD::mEntity *, const xtensor::xPoint &, xmapping::xMapping *,
xfem::xIntegrationRuleStoredDataManager &)>
integration_order_function_object_,
xfem::xIntegrationRuleStoredDataManager &gp_storage_);
xExtendShapeFcts *generateExtendShapeFcts(AOMD::mEntity *e) override;
template <typename ITER>
void cleanExtendShapeFcts(ITER begin, ITER end);
......@@ -56,7 +58,10 @@ class xExtendShapeGenerator : public xExtendShapeGeneratorBase
DIST distance_kd_tree;
xEntityToEntity upper;
xfem::xField<VT> &vgama;
std::function<void(AOMD::mEntity *, const xtensor::xPoint &, xmapping::xMapping *)> integration_order_function_object;
xfem::xIntegrationRuleStoredDataManager &gp_storage;
std::function<void(AOMD::mEntity *, const xtensor::xPoint &, xmapping::xMapping *,
xfem::xIntegrationRuleStoredDataManager &gp_manager)>
integration_order_function_object;
void cleanExtendShapeFctsElem(AOMD::mEntity *e);
};
......
......@@ -15,10 +15,13 @@ template <typename DIST, typename VT>
template <typename ITERFRONT>
xExtendShapeGenerator<DIST, VT>::xExtendShapeGenerator(
ITERFRONT beg, ITERFRONT end, xEntityToEntity upper_, xfem::xField<VT> &vgama_,
std::function<void(AOMD::mEntity *, const xtensor::xPoint &, xmapping::xMapping *)> integration_order_function_object_)
std::function<void(AOMD::mEntity *, const xtensor::xPoint &, xmapping::xMapping *, xIntegrationRuleStoredDataManager &)>
integration_order_function_object_,
xfem::xIntegrationRuleStoredDataManager &gp_storage_)
: distance_kd_tree(beg, end),
upper(upper_),
vgama(vgama_),
gp_storage(gp_storage_),
integration_order_function_object(integration_order_function_object_)
{
}
......@@ -41,11 +44,10 @@ xExtendShapeFcts *xExtendShapeGenerator<DIST, VT>::generateExtendShapeFcts(AOMD:
xmapping::xMapping *mapping = const_cast<xmapping::xMapping *>(elem.getMapping());
// set gauss point and attach them to this element based on CDG
integration_order_function_object(e, elem.getCDGxyz(), mapping);
integration_order_function_object(e, elem.getCDGxyz(), mapping, gp_storage);
// set integrator based on integration_order_function_object generation
datamanager_gauss_points_t &data_gp = xIntegrationRule::get_gauss_points_datamanager();
xGaussPoints *agp = data_gp.getData(*e);
xGaussPoints *agp = gp_storage.getStored(*e);
if (!agp)
{
throw -78545;
......@@ -192,33 +194,8 @@ void xExtendShapeGenerator<DIST, VT>::cleanExtendShapeFcts(ITER begin, ITER end)
template <typename DIST, typename VT>
void xExtendShapeGenerator<DIST, VT>::cleanExtendShapeFctsElem(AOMD::mEntity *e)
{
// look for attached extention shape
xExtendShapeFcts *extention = data.getData(*e);
// if attached extention
if (extention)
{
data.deleteData(*e);
// look for attached GP
// nota : a more conservative way might to use a apaired to integration_order_function_object object function that distroy
// this part. but as generateExtendShapeFcts is expecting that xStoredIntegrationPoints works, it expect that
// xAttachableGaussPoints is set by integration_order_function_object. So what ever integration_order_function_object do it
// will give a xAttachableGaussPoints So looking to xAttachableGaussPoints here is rather correct and there is no real need
// for a specific conterpart of integration_order_function_object.
datamanager_gauss_points_t &data_gp = xIntegrationRule::get_gauss_points_datamanager();
xGaussPoints *agp = data_gp.getData(*e);
if (agp)
{
data_gp.deleteData(*e);
}
else
{
// strange but should it be considered as a error ? For now lets start with "yes it is a error"
throw -78854;
}
}
gp_storage.delStored(*e);
data.deleteData(*e);
return;
}
......
......@@ -44,13 +44,7 @@ void xRectangleIntegrator::iPoint(int i, int level, double& u, double& v, double
weight = 0.5 / rectangleRulePointsTri[level]->size();
}
datamanager_gauss_points_t& xIntegrationRule::get_gauss_points_datamanager()
{
static datamanager_gauss_points_t data_gp;
return data_gp;
};
xIntegrationRule::xIntegrationRule() : currentRule(GAUSS), integrator(nullptr) { get_gauss_points_datamanager(); };
xIntegrationRule::xIntegrationRule() : currentRule(GAUSS), integrator(nullptr) {}
void xIntegrationRuleBasic::accept(xCommandOnGeomElem& command, mEntity* e_integ) const
{
......
......@@ -25,9 +25,6 @@
namespace xfem
{
using xGaussPoints = std::vector<std::pair<xtensor::xPoint, double>>;
using datamanager_gauss_points_t = xinterface::aomd::xAttachedDataManagerAOMD<xGaussPoints>;
class xCommandOnGeomElem;
class xLevelSet;
......@@ -55,7 +52,6 @@ class xIntegrationRule
if (integrator) delete integrator;
};
xIntegrationRule();
static datamanager_gauss_points_t& get_gauss_points_datamanager();
virtual void accept(xCommandOnGeomElem& command, AOMD::mEntity* e_integ) const = 0;
void setIntegrator(integrationRuleType rule) { currentRule = rule; };
xquadrature::xIntegrator* getIntegrator(AOMD::mEntity* e_integ) const
......
......@@ -16,12 +16,18 @@ namespace xfem
{
using std::cout;
using std::endl;
xGaussPoints* xIntegrationRuleStoredDataManager::getStored(AOMD::mEntity& e) { return gauss_points.getData(e); }
void xIntegrationRuleStoredDataManager::delStored(AOMD::mEntity& e) { gauss_points.deleteData(e); }
xGaussPoints& xIntegrationRuleStoredDataManager::createEmptyStorageOrGet(AOMD::mEntity& e) { return gauss_points.setData(e); }
void xIntegrationRuleStoredDataManager::clearStored() { gauss_points.clear(); }
void xIntegrationRuleStoredBasic::accept(xCommandOnGeomElem& command, AOMD::mEntity* e_integ) const
{
if (!filter(e_integ)) return;
xmapping::xMapping* mapping = xMappingBuilderHolderSingleton::instance().buildMapping(*e_integ);
xquadrature::xIntegrator* integrator = nullptr;
const xGaussPoints* agp = xIntegrationRule::get_gauss_points_datamanager().getData(*e_integ);
const xGaussPoints* agp = gauss_points.getData(*e_integ);
if (!agp)
{
integrator = new xquadrature::xGaussIntegrator(e_integ);
......@@ -43,7 +49,7 @@ void xIntegrationRuleStoredBasicFallBackPartition::accept(xCommandOnGeomElem& co
const bool debug = false;
if (!filter(e_integ)) return;
const xGaussPoints* agp = xIntegrationRule::get_gauss_points_datamanager().getData(*e_integ);
const xGaussPoints* agp = gauss_points.getData(*e_integ);
// If stored rule, use it
if (agp)
......@@ -103,7 +109,7 @@ void xIntegrationRuleStoredPartition::accept(xCommandOnGeomElem& command, AOMD::
if (debug) es_integ->print();
xmapping::xMapping* mapping = xMappingBuilderHolderSingleton::instance().buildMapping(*es_integ);
xquadrature::xIntegrator* integrator = nullptr;
const xGaussPoints* agp = xIntegrationRule::get_gauss_points_datamanager().getData(*es_integ);
const xGaussPoints* agp = gauss_points.getData(*es_integ);
if (!agp)
{
integrator = new xquadrature::xGaussIntegrator(es_integ);
......
......@@ -15,6 +15,8 @@
namespace xfem
{
using xGaussPoints = std::vector<std::pair<xtensor::xPoint, double>>;
/// Class to get the integration points attached to the elements
class xStoredIntegrationPoints : public xquadrature::xIntegrator
{
......@@ -33,7 +35,19 @@ class xStoredIntegrationPoints : public xquadrature::xIntegrator
}
};
class xIntegrationRuleStoredBasic : public xIntegrationRule
class xIntegrationRuleStoredDataManager
{
public:
xGaussPoints* getStored(AOMD::mEntity& e);
void delStored(AOMD::mEntity& e);
xGaussPoints& createEmptyStorageOrGet(AOMD::mEntity& e);
void clearStored();
protected:
xinterface::aomd::xAttachedDataManagerAOMD<xGaussPoints> gauss_points;
};
class xIntegrationRuleStoredBasic : public xIntegrationRule, public xIntegrationRuleStoredDataManager
{
public:
template <class T>
......@@ -50,7 +64,7 @@ class xIntegrationRuleStoredBasic : public xIntegrationRule
};
/// Integration rule that uses stored integration points if they are present, and partition otherwise
class xIntegrationRuleStoredBasicFallBackPartition : public xIntegrationRule
class xIntegrationRuleStoredBasicFallBackPartition : public xIntegrationRule, public xIntegrationRuleStoredDataManager
{
public:
template <class T>
......@@ -71,7 +85,7 @@ class xIntegrationRuleStoredBasicFallBackPartition : public xIntegrationRule
xGetPartition getpartition;
};
class xIntegrationRuleStoredPartition : public xIntegrationRule
class xIntegrationRuleStoredPartition : public xIntegrationRule, public xIntegrationRuleStoredDataManager
{
public:
template <class T>
......
......@@ -153,18 +153,11 @@ class doubleContainer
class generatAndAttach
{
public:
void operator()(AOMD::mEntity* e, const xtensor::xPoint& cdg, xmapping::xMapping* mapping)
void operator()(AOMD::mEntity* e, const xtensor::xPoint& cdg, xmapping::xMapping* mapping,
xfem::xIntegrationRuleStoredDataManager& gp_storage)
{
xfem::xGaussPoints* agp = xfem::xIntegrationRule::get_gauss_points_datamanager().getData(*e);
if (agp)
{
agp->clear();
}
else
{
agp = new xfem::xGaussPoints;
xfem::xIntegrationRule::get_gauss_points_datamanager().setData(*e) = *agp;
}
xfem::xGaussPoints& agp = gp_storage.createEmptyStorageOrGet(*e);
agp.clear();
xquadrature::xGaussIntegrator integration_points(mapping->getType());
......@@ -187,8 +180,7 @@ class generatAndAttach
int nb_gp = integration_points.nbIntegrationPoints(order);
// create attached container
agp = xfem::xIntegrationRule::get_gauss_points_datamanager().getData(*e);
agp->resize(nb_gp);
agp.resize(nb_gp);
// store gauss points
xtensor::xPoint uvw;
......@@ -196,7 +188,7 @@ class generatAndAttach
for (int ipt = 0; ipt < nb_gp; ++ipt)
{
integration_points.iPoint(ipt, order, uvw(0), uvw(1), uvw(2), Weight);
(*agp)[ipt] = std::make_pair(uvw, Weight);
agp[ipt] = std::make_pair(uvw, Weight);
}
}
};
......@@ -212,11 +204,10 @@ class xEvalWeigthedDirectionalAverage2 : public xfem::xEval<double>
}
// compute the field_X_average for the given arguments
template <typename SOLVER, typename ITERVOLUME, typename ITERBOUNDARY>
template <typename SOLVER, typename ITERVOLUME, typename ITERBOUNDARY, typename IR>
void compute(SOLVER& solver, const ITERVOLUME begin_iter, const ITERVOLUME end_iter, const ITERBOUNDARY begin_iter_boundary,
const ITERBOUNDARY end_iter_boundary, xfem::xEval<double>& eval_weigth, xfem::xEval<double>& eval_X,
const xfem::xMesh* boundary_mesh, xfem::xIntegrationRule& integrule, xfem::xEntityToEntity upper,
double diffusiv_coef = 0.);
const xfem::xMesh* boundary_mesh, IR& integrule, xfem::xEntityToEntity upper, double diffusiv_coef = 0.);
private:
class xAcceptNotHanging
......@@ -247,11 +238,10 @@ class xEvalWeigthedDirectionalAverage3 : public xfem::xEval<double>
}
// compute the field_X_average for the given arguments
template <typename SOLVER, typename ITERVOLUME, typename ITERBOUNDARY>
template <typename SOLVER, typename ITERVOLUME, typename ITERBOUNDARY, typename IR>
void compute(SOLVER& solver, const ITERVOLUME begin_iter, const ITERVOLUME end_iter, const ITERBOUNDARY begin_iter_boundary,
const ITERBOUNDARY end_iter_boundary, xfem::xEval<double>& eval_weigth, xfem::xEval<double>& eval_X,
const xfem::xMesh* boundary_mesh, xfem::xIntegrationRule& integrule, xfem::xEntityToEntity upper,
double diffusiv_coef = 0.);
const xfem::xMesh* boundary_mesh, IR& integrule, xfem::xEntityToEntity upper, double diffusiv_coef = 0.);
private:
class xAcceptNotHanging
......@@ -283,11 +273,10 @@ class xEvalWeigthedDirectionalAverage4 : public xfem::xEval<double>
}
// compute the field_X_average for the given arguments
template <typename SOLVER, typename ITERVOLUME, typename ITERBOUNDARY>
template <typename SOLVER, typename ITERVOLUME, typename ITERBOUNDARY, typename IR>
void compute(SOLVER& solver, const ITERVOLUME begin_iter, const ITERVOLUME end_iter, const ITERBOUNDARY begin_iter_boundary,
const ITERBOUNDARY end_iter_boundary, xfem::xEval<double>& eval_weigth, xfem::xEval<double>& eval_X,
const xfem::xMesh* boundary_mesh, xfem::xIntegrationRule& integrule, xfem::xEntityToEntity upper,
double wave_lenght = 0.01);
const xfem::xMesh* boundary_mesh, IR& integrule, xfem::xEntityToEntity upper, double wave_lenght = 0.01);
private:
class xEvalTang : public xfem::xEval<xtensor::xVector<>>
......
......@@ -859,12 +859,12 @@ void TLSVelocity::averaging(const ITERBAND begin_iter_band, const ITERBAND end_i
}
#ifdef HAVE_CGAL
template <typename SOLVER, typename ITERVOLUME, typename ITERBOUNDARY>
template <typename SOLVER, typename ITERVOLUME, typename ITERBOUNDARY, typename IR>
void xEvalWeigthedDirectionalAverage2::compute(SOLVER &solver, const ITERVOLUME begin_iter, const ITERVOLUME end_iter,
const ITERBOUNDARY begin_iter_boundary, const ITERBOUNDARY end_iter_boundary,
xfem::xEval<double> &eval_weigth, xfem::xEval<double> &eval_X,
const xfem::xMesh *boundary_mesh, xfem::xIntegrationRule &integrule,
xfem::xEntityToEntity upper, double diffusiv_coef)
const xfem::xMesh *boundary_mesh, IR &integrule, xfem::xEntityToEntity upper,
double diffusiv_coef)
{
// local
#ifndef NDEBUG
......@@ -879,11 +879,10 @@ void xEvalWeigthedDirectionalAverage2::compute(SOLVER &solver, const ITERVOLUME
field_VGAMA.ResetStoragePolicy();
field_X_average.clear();
xfem::datamanager_gauss_points_t &data_gp = integrule.get_gauss_points_datamanager();
// create generator
// by using template we check that given iterator are what we expect
generator = new xfem::xExtendShapeGenerator<xgeom::xDistanceNearestPoint<ITERBOUNDARY, xgeom::xAOMDEdgeToCGALEdge>>(
begin_iter_boundary, end_iter_boundary, upper, field_VGAMA, gen_gauss_point);
begin_iter_boundary, end_iter_boundary, upper, field_VGAMA, gen_gauss_point, integrule);
// setting field average with new space
field_X_average.insert(xfem::xSpaceExtendedShape("extendspace", "X_average", generator));
......@@ -984,12 +983,12 @@ void xEvalWeigthedDirectionalAverage2::compute(SOLVER &solver, const ITERVOLUME
return;
}
template <typename SOLVER, typename ITERVOLUME, typename ITERBOUNDARY>
template <typename SOLVER, typename ITERVOLUME, typename ITERBOUNDARY, typename IR>
void xEvalWeigthedDirectionalAverage3::compute(SOLVER &solver, const ITERVOLUME begin_iter, const ITERVOLUME end_iter,
const ITERBOUNDARY begin_iter_boundary, const ITERBOUNDARY end_iter_boundary,
xfem::xEval<double> &eval_weigth, xfem::xEval<double> &eval_X,
const xfem::xMesh *boundary_mesh, xfem::xIntegrationRule &integrule,
xfem::xEntityToEntity upper, double diffusiv_coef)
const xfem::xMesh *boundary_mesh, IR &integrule, xfem::xEntityToEntity upper,
double diffusiv_coef)
{
// local
#ifndef NDEBUG
......@@ -1003,12 +1002,11 @@ void xEvalWeigthedDirectionalAverage3::compute(SOLVER &solver, const ITERVOLUME
double_manager_X.clear();
field_VGAMA.ResetStoragePolicy();
field_X_average.clear();
// xfem::datamanager_gauss_points_t& data_gp= integrule.get_gauss_points_datamanager();
// create generator
// by using template we check that given iterator are what we expect
generator =
new xfem::xExtendShapeGenerator<ITERBOUNDARY, xgeom::xDistanceNearestPoint<ITERBOUNDARY, xgeom::xAOMDEdgeToCGALEdge>>(
begin_iter_boundary, end_iter_boundary, upper, field_VGAMA, gen_gauss_point);
begin_iter_boundary, end_iter_boundary, upper, field_VGAMA, gen_gauss_point, integrule);
// setting field average with new space
field_X_average.insert(xfem::xSpaceExtendedShape("extendspace", "X_average", generator));
......@@ -1152,12 +1150,12 @@ void xEvalWeigthedDirectionalAverage3::compute(SOLVER &solver, const ITERVOLUME
return;
}
template <typename SOLVER, typename ITERVOLUME, typename ITERBOUNDARY>
template <typename SOLVER, typename ITERVOLUME, typename ITERBOUNDARY, typename IR>
void xEvalWeigthedDirectionalAverage4::compute(SOLVER &solver, const ITERVOLUME begin_iter, const ITERVOLUME end_iter,
const ITERBOUNDARY begin_iter_boundary, const ITERBOUNDARY end_iter_boundary,
xfem::xEval<double> &eval_weigth, xfem::xEval<double> &eval_X,
const xfem::xMesh *boundary_mesh, xfem::xIntegrationRule &integrule,
xfem::xEntityToEntity upper, double wave_lenght)
const xfem::xMesh *boundary_mesh, IR &integrule, xfem::xEntityToEntity upper,
double wave_lenght)
{
// local
#ifndef NDEBUG
......@@ -1171,11 +1169,10 @@ void xEvalWeigthedDirectionalAverage4::compute(SOLVER &solver, const ITERVOLUME
double_manager_X.clear();
field_VGAMA.ResetStoragePolicy();
field_X_average.clear();
// xfem::datamanager_gauss_points_t& data_gp= integrule.get_gauss_points_datamanager();
// create generator
// by using template we check that given iterator are what we expect
generator = new xfem::xExtendShapeGenerator<xgeom::xDistanceNearestPoint<ITERBOUNDARY, xgeom::xAOMDEdgeToCGALEdge>>(
begin_iter_boundary, end_iter_boundary, upper, field_VGAMA, gen_gauss_point);
begin_iter_boundary, end_iter_boundary, upper, field_VGAMA, gen_gauss_point, integrule);
// setting field average with new space
field_X_average.insert(xfem::xSpaceExtendedShape("extendspace", "X_average", generator));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment