Commit 64ed8890 authored by Gilles MARCKMANN's avatar Gilles MARCKMANN

Remove use of xAttachableGP in Xfiles. Now a datamanager is added to class to...

Remove use of xAttachableGP in Xfiles. Now a datamanager is added to class to attach Gauss Points data.
    The type xGaussPoints is defined as std::vector<std::pair<xtensor::xPoint, double>> and the datamanager type is datamanager_gauss_points_t (defined in xIntegrationRule.h).
    A static function of xIntegrationRule allows to get the datamanger.

    Example 1:
        agp = new xfem::xGaussPoints;
        xfem::xIntegrationRule::get_gauss_points_datamanager().setData(*e) = *agp;

    Example 2:
        xfem::datamanager_gauss_points_t& _data_GP_= xfem::xIntegrationRule::get_gauss_points_datamanager();
        xfem::xGaussPoints* agp = _data_GP_.getData(*e);
parent 97168a67
......@@ -11,7 +11,6 @@
#include <map>
#include <set>
// xfem
#include "xAttachableGP.h"
#include "xField.h"
#include "xFiniteElement.h"
#include "xGeomElem.h"
......@@ -39,7 +38,6 @@ class xExtendShapeGeneratorBase
protected:
xinterface::aomd::xAttachedDataManagerAOMD<xExtendShapeFcts> data;
unsigned int gp_tag;
};
template <typename DIST, typename VT = double>
......@@ -59,6 +57,7 @@ class xExtendShapeGenerator : public xExtendShapeGeneratorBase
xEntityToEntity upper;
xfem::xField<VT> &vgama;
std::function<void(AOMD::mEntity *, const xtensor::xPoint &, xmapping::xMapping *)> integration_order_function_object;
void cleanExtendShapeFctsElem(AOMD::mEntity *e);
};
......
......@@ -21,7 +21,6 @@ xExtendShapeGenerator<DIST, VT>::xExtendShapeGenerator(
vgama(vgama_),
integration_order_function_object(integration_order_function_object_)
{
gp_tag = AOMD::AOMD_Util::Instance()->lookupMeshDataId("gauss_points");
}
template <typename DIST, typename VT>
......@@ -45,12 +44,13 @@ xExtendShapeFcts *xExtendShapeGenerator<DIST, VT>::generateExtendShapeFcts(AOMD:
integration_order_function_object(e, elem.getCDGxyz(), mapping);
// set integrator based on integration_order_function_object generation
xAttachableGaussPoints *agp = (xAttachableGaussPoints *)e->getData(gp_tag);
datamanager_gauss_points_t &data_gp = xIntegrationRule::get_gauss_points_datamanager();
xGaussPoints *agp = data_gp.getData(*e);
if (!agp)
{
throw -78545;
}
xfem::xStoredIntegrationPoints integration_points(agp->gauss_points);
xfem::xStoredIntegrationPoints integration_points(*agp);
elem.setIntegrator(&integration_points);
// get number of gauss point for e
......@@ -205,10 +205,12 @@ void xExtendShapeGenerator<DIST, VT>::cleanExtendShapeFctsElem(AOMD::mEntity *e)
// 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.
xAttachableGaussPoints *agp = (xAttachableGaussPoints *)e->getData(gp_tag);
datamanager_gauss_points_t &data_gp = xIntegrationRule::get_gauss_points_datamanager();
xGaussPoints *agp = data_gp.getData(*e);
if (agp)
{
e->deleteData(gp_tag);
data_gp.deleteData(*e);
}
else
{
......
......@@ -20,7 +20,6 @@
#include "xLevelSet.h"
#include "xMappingBuilderHolder.h"
using namespace std;
using AOMD::mEntity;
namespace xfem
......@@ -45,6 +44,14 @@ 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(); };
void xIntegrationRuleBasic::accept(xCommandOnGeomElem& command, mEntity* e_integ) const
{
if (!filter(e_integ)) return;
......
......@@ -20,8 +20,14 @@
#include "xGeomElem.h"
#include "xPartition.h"
// xinterface aomd
#include "xAttachedDataManagerAOMD.h"
namespace xfem
{
using xGaussPoints = std::vector<std::pair<xtensor::xPoint, double>>;
using datamanager_gauss_points_t = xinterface::aomd::xAttachedDataManagerAOMD<xGaussPoints>;
class xCommandOnGeomElem;
class xLevelSet;
......@@ -48,7 +54,8 @@ class xIntegrationRule
{
if (integrator) delete integrator;
};
xIntegrationRule() : currentRule(GAUSS), integrator(nullptr){};
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
......
......@@ -8,7 +8,6 @@
// xfem
#include "xIntegrationRuleStored.h"
#include "xAttachableGP.h"
#include "xCommandOnGeomElem.h"
// xmapping
#include "xMappingBuilderHolder.h"
......@@ -22,14 +21,14 @@ void xIntegrationRuleStoredBasic::accept(xCommandOnGeomElem& command, AOMD::mEnt
if (!filter(e_integ)) return;
xmapping::xMapping* mapping = xMappingBuilderHolderSingleton::instance().buildMapping(*e_integ);
xquadrature::xIntegrator* integrator = nullptr;
xAttachableGaussPoints* agp = (xAttachableGaussPoints*)e_integ->getData(gp_tag);
const xGaussPoints* agp = xIntegrationRule::get_gauss_points_datamanager().getData(*e_integ);
if (!agp)
{
integrator = new xquadrature::xGaussIntegrator(e_integ);
}
else
{
integrator = new xStoredIntegrationPoints(agp->gauss_points);
integrator = new xStoredIntegrationPoints(*agp);
}
xGeomElem geo_integ(e_integ, mapping, integrator);
geo_integ.SetIntegrationPointNumberForDegree(degree);
......@@ -44,7 +43,7 @@ void xIntegrationRuleStoredBasicFallBackPartition::accept(xCommandOnGeomElem& co
const bool debug = false;
if (!filter(e_integ)) return;
xAttachableGaussPoints* agp = (xAttachableGaussPoints*)e_integ->getData(gp_tag);
const xGaussPoints* agp = xIntegrationRule::get_gauss_points_datamanager().getData(*e_integ);
// If stored rule, use it
if (agp)
......@@ -53,7 +52,7 @@ void xIntegrationRuleStoredBasicFallBackPartition::accept(xCommandOnGeomElem& co
xmapping::xMapping* mapping = xMappingBuilderHolderSingleton::instance().buildMapping(*e_integ);
xquadrature::xIntegrator* integrator = nullptr;
integrator = new xStoredIntegrationPoints(agp->gauss_points);
integrator = new xStoredIntegrationPoints(*agp);
xGeomElem geo_integ(e_integ, mapping, integrator);
geo_integ.SetIntegrationPointNumberForDegree(degree);
command.execute(&geo_integ);
......@@ -104,14 +103,14 @@ void xIntegrationRuleStoredPartition::accept(xCommandOnGeomElem& command, AOMD::
if (debug) es_integ->print();
xmapping::xMapping* mapping = xMappingBuilderHolderSingleton::instance().buildMapping(*es_integ);
xquadrature::xIntegrator* integrator = nullptr;
xAttachableGaussPoints* agp = (xAttachableGaussPoints*)es_integ->getData(gp_tag);
const xGaussPoints* agp = xIntegrationRule::get_gauss_points_datamanager().getData(*es_integ);
if (!agp)
{
integrator = new xquadrature::xGaussIntegrator(es_integ);
}
else
{
integrator = new xStoredIntegrationPoints(agp->gauss_points);
integrator = new xStoredIntegrationPoints(*agp);
}
xGeomElem geo_integ_es(es_integ, mapping, integrator);
geo_integ_es.SetIntegrationPointNumberForDegree(degree);
......
......@@ -12,19 +12,16 @@
#include "xIntegrator.h"
// xfem include
#include "xIntegrationRule.h"
// xinterface aomd
#include "xAttachedDataManagerAOMD.h"
namespace xfem
{
/// Class to get the integration points attached to the elements
class xStoredIntegrationPoints : public xquadrature::xIntegrator
{
typedef std::vector<std::pair<xtensor::xPoint, double>> Container;
const Container& gauss_points;
const xGaussPoints& gauss_points;
public:
xStoredIntegrationPoints(const Container& gauss_points) : gauss_points(gauss_points) {}
xStoredIntegrationPoints(const xGaussPoints& gauss_points) : gauss_points(gauss_points) {}
int nbIntegrationPoints(int order) const override { return gauss_points.size(); }
void iPoint(int i, int order, double& u, double& v, double& w, double& weight) const override
{
......@@ -40,8 +37,7 @@ class xIntegrationRuleStoredBasic : public xIntegrationRule
{
public:
template <class T>
xIntegrationRuleStoredBasic(const T& f, int d = 0)
: degree(d), gp_tag(AOMD::AOMD_Util::Instance()->lookupMeshDataId("gauss_points")), filter(f), nbpoint(0)
xIntegrationRuleStoredBasic(const T& f, int d = 0) : degree(d), filter(f), nbpoint(0)
{
}
xIntegrationRuleStoredBasic(int d = 0) : xIntegrationRuleStoredBasic(xAcceptAll(), d) {}
......@@ -49,7 +45,6 @@ class xIntegrationRuleStoredBasic : public xIntegrationRule
private:
const int degree;
const unsigned int gp_tag;
xEntityFilter filter;
mutable int nbpoint;
};
......@@ -60,11 +55,7 @@ class xIntegrationRuleStoredBasicFallBackPartition : public xIntegrationRule
public:
template <class T>
xIntegrationRuleStoredBasicFallBackPartition(xGetPartition _getpartition, const T& f, int d = 0)
: degree(d),
gp_tag(AOMD::AOMD_Util::Instance()->lookupMeshDataId("gauss_points")),
filter(f),
nbpoint(0),
getpartition(_getpartition)
: degree(d), filter(f), nbpoint(0), getpartition(_getpartition)
{
}
xIntegrationRuleStoredBasicFallBackPartition(xGetPartition _getpartition, int d = 0)
......@@ -75,7 +66,6 @@ class xIntegrationRuleStoredBasicFallBackPartition : public xIntegrationRule
private:
const int degree;
const unsigned int gp_tag;
xEntityFilter filter;
mutable int nbpoint;
xGetPartition getpartition;
......@@ -86,11 +76,7 @@ class xIntegrationRuleStoredPartition : public xIntegrationRule
public:
template <class T>
xIntegrationRuleStoredPartition(xGetPartition _getpartition, const T& f, int d = 0)
: degree(d),
gp_tag(AOMD::AOMD_Util::Instance()->lookupMeshDataId("gauss_points")),
filter(f),
getpartition(_getpartition),
nbpoint(0)
: degree(d), filter(f), getpartition(_getpartition), nbpoint(0)
{
}
xIntegrationRuleStoredPartition(xGetPartition _getpartition, int d = 0)
......@@ -101,7 +87,6 @@ class xIntegrationRuleStoredPartition : public xIntegrationRule
private:
const int degree;
const unsigned int gp_tag;
xEntityFilter filter;
xGetPartition getpartition;
mutable int nbpoint;
......
......@@ -9,13 +9,13 @@
// xfem
#include "xAlgorithm.h"
#include "xAttachableGP.h"
#include "xEntityFilter.h"
#include "xEntityToEntity.h"
#include "xEval.h"
#include "xExtendShapeFcts.h"
#include "xField.h"
#include "xForm.h"
#include "xIntegrationRule.h"
#include "xSolVisitor.h"
#include "xSpace.h"
#include "xSpaceExtendedShape.h"
......@@ -149,21 +149,21 @@ class doubleContainer
};
#ifdef HAVE_CGAL
class generatAndAttach
{
public:
void operator()(AOMD::mEntity* e, const xtensor::xPoint& cdg, xmapping::xMapping* mapping)
{
unsigned int gp_tag = AOMD::AOMD_Util::Instance()->lookupMeshDataId("gauss_points");
xfem::xAttachableGaussPoints* agp = (xfem::xAttachableGaussPoints*)e->getData(gp_tag);
xfem::xGaussPoints* agp = xfem::xIntegrationRule::get_gauss_points_datamanager().getData(*e);
if (agp)
{
agp->gauss_points.clear();
agp->clear();
}
else
{
agp = new xfem::xAttachableGaussPoints;
e->attachData(gp_tag, agp);
agp = new xfem::xGaussPoints;
xfem::xIntegrationRule::get_gauss_points_datamanager().setData(*e) = *agp;
}
xquadrature::xGaussIntegrator integration_points(mapping->getType());
......@@ -187,7 +187,8 @@ class generatAndAttach
int nb_gp = integration_points.nbIntegrationPoints(order);
// create attached container
agp->gauss_points.resize(nb_gp);
agp = xfem::xIntegrationRule::get_gauss_points_datamanager().getData(*e);
agp->resize(nb_gp);
// store gauss points
xtensor::xPoint uvw;
......@@ -195,7 +196,7 @@ class generatAndAttach
for (int ipt = 0; ipt < nb_gp; ++ipt)
{
integration_points.iPoint(ipt, order, uvw(0), uvw(1), uvw(2), Weight);
agp->gauss_points[ipt] = std::make_pair(uvw, Weight);
(*agp)[ipt] = std::make_pair(uvw, Weight);
}
}
};
......
......@@ -879,6 +879,7 @@ 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>>(
......@@ -1002,7 +1003,7 @@ 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 =
......@@ -1170,7 +1171,7 @@ 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>>(
......
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