From 04b5376c30f7ca0c10487cf7459f06d779d5a19e Mon Sep 17 00:00:00 2001 From: Anthony Geay Date: Thu, 18 Aug 2022 17:21:16 +0200 Subject: [PATCH] wip --- .../GaussPoints/InterpKernelGaussCoords.cxx | 44 +++++++++++++++++++ .../GaussPoints/InterpKernelGaussCoords.hxx | 2 +- .../MEDCouplingGaussLocalization.cxx | 14 ++++++ .../MEDCouplingGaussLocalization.hxx | 1 + src/MEDCoupling_Swig/MEDCouplingCommon.i | 7 +++ 5 files changed, 67 insertions(+), 1 deletion(-) diff --git a/src/INTERP_KERNEL/GaussPoints/InterpKernelGaussCoords.cxx b/src/INTERP_KERNEL/GaussPoints/InterpKernelGaussCoords.cxx index f94be577d..f74d90f58 100644 --- a/src/INTERP_KERNEL/GaussPoints/InterpKernelGaussCoords.cxx +++ b/src/INTERP_KERNEL/GaussPoints/InterpKernelGaussCoords.cxx @@ -462,6 +462,50 @@ std::vector GaussInfo::NormalizeCoordinatesIfNecessary(NormalizedCellTyp return ret; } +std::vector GaussInfo::GetDefaultReferenceCoordinatesOf(NormalizedCellType ct) +{ + switch(ct) + { + case INTERP_KERNEL::NORM_SEG2: + return std::vector(SEG2A_REF,SEG2A_REF+sizeof(SEG2A_REF)/sizeof(double)); + case INTERP_KERNEL::NORM_SEG3: + return std::vector(SEG3_REF,SEG3_REF+sizeof(SEG3_REF)/sizeof(double)); + case INTERP_KERNEL::NORM_TRI3: + return std::vector(TRIA3A_REF,TRIA3A_REF+sizeof(TRIA3A_REF)/sizeof(double)); + case INTERP_KERNEL::NORM_TRI6: + return std::vector(TRIA6A_REF,TRIA6A_REF+sizeof(TRIA6A_REF)/sizeof(double)); + case INTERP_KERNEL::NORM_TRI7: + return std::vector(TRIA7A_REF,TRIA7A_REF+sizeof(TRIA7A_REF)/sizeof(double)); + case INTERP_KERNEL::NORM_QUAD4: + return std::vector(QUAD4A_REF,QUAD4A_REF+sizeof(QUAD4A_REF)/sizeof(double)); + case INTERP_KERNEL::NORM_QUAD8: + return std::vector(QUAD8A_REF,QUAD8A_REF+sizeof(QUAD8A_REF)/sizeof(double)); + case INTERP_KERNEL::NORM_QUAD9: + return std::vector(QUAD9A_REF,QUAD9A_REF+sizeof(QUAD9A_REF)/sizeof(double)); + case INTERP_KERNEL::NORM_TETRA4: + return std::vector(TETRA4A_REF,TETRA4A_REF+sizeof(TETRA4A_REF)/sizeof(double)); + case INTERP_KERNEL::NORM_TETRA10: + return std::vector(TETRA10A_REF,TETRA10A_REF+sizeof(TETRA10A_REF)/sizeof(double)); + case INTERP_KERNEL::NORM_PYRA5: + return std::vector(PYRA5A_REF,PYRA5A_REF+sizeof(PYRA5A_REF)/sizeof(double)); + case INTERP_KERNEL::NORM_PYRA13: + return std::vector(PYRA13A_REF,PYRA13A_REF+sizeof(PYRA13A_REF)/sizeof(double)); + case INTERP_KERNEL::NORM_PENTA6: + return std::vector(PENTA6A_REF,PENTA6A_REF+sizeof(PENTA6A_REF)/sizeof(double)); + case INTERP_KERNEL::NORM_PENTA15: + return std::vector(PENTA15A_REF,PENTA15A_REF+sizeof(PENTA15A_REF)/sizeof(double)); + case INTERP_KERNEL::NORM_PENTA18: + return std::vector(PENTA18A_REF,PENTA18A_REF+sizeof(PENTA18A_REF)/sizeof(double)); + case INTERP_KERNEL::NORM_HEXA8: + return std::vector(HEXA8A_REF,HEXA8A_REF+sizeof(HEXA8A_REF)/sizeof(double)); + case INTERP_KERNEL::NORM_HEXA20: + return std::vector(HEXA20A_REF,HEXA20A_REF+sizeof(HEXA20A_REF)/sizeof(double)); + case INTERP_KERNEL::NORM_HEXA27: + return std::vector(HEXA27A_REF,HEXA27A_REF+sizeof(HEXA27A_REF)/sizeof(double)); + } + THROW_IK_EXCEPTION("Input type " << ct << "is not managed by GetDefaultReferenceCoordinatesOf") +} + typedef void (*MapToShapeFunction)(GaussInfo& obj); /*! diff --git a/src/INTERP_KERNEL/GaussPoints/InterpKernelGaussCoords.hxx b/src/INTERP_KERNEL/GaussPoints/InterpKernelGaussCoords.hxx index 47070488c..4497180e2 100644 --- a/src/INTERP_KERNEL/GaussPoints/InterpKernelGaussCoords.hxx +++ b/src/INTERP_KERNEL/GaussPoints/InterpKernelGaussCoords.hxx @@ -63,7 +63,7 @@ namespace INTERP_KERNEL INTERPKERNEL_EXPORT void initLocalInfo(); INTERPKERNEL_EXPORT static std::vector NormalizeCoordinatesIfNecessary(NormalizedCellType ct, int inputDim, const std::vector& inputArray); - + INTERPKERNEL_EXPORT static std::vector GetDefaultReferenceCoordinatesOf(NormalizedCellType ct); public: static const double SEG2A_REF[2]; static const double SEG2B_REF[2]; diff --git a/src/MEDCoupling/MEDCouplingGaussLocalization.cxx b/src/MEDCoupling/MEDCouplingGaussLocalization.cxx index e533a8d6d..e59f54741 100644 --- a/src/MEDCoupling/MEDCouplingGaussLocalization.cxx +++ b/src/MEDCoupling/MEDCouplingGaussLocalization.cxx @@ -360,3 +360,17 @@ bool MEDCouplingGaussLocalization::AreAlmostEqual(const std::vector& v1, std::transform(tmp.begin(),tmp.end(),tmp.begin(),[](double c){return fabs(c);}); return *std::max_element(tmp.begin(),tmp.end()) MEDCouplingGaussLocalization::GetDefaultReferenceCoordinatesOf(INTERP_KERNEL::NormalizedCellType type) +{ + std::vector retCpp(INTERP_KERNEL::GaussInfo::GetDefaultReferenceCoordinatesOf(type)); + const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(type); + auto nbDim(cm.getDimension()); + std::size_t sz(retCpp.size()); + MCAuto ret(DataArrayDouble::New()); + if( sz%std::size_t(nbDim) != 0 ) + THROW_IK_EXCEPTION("GetDefaultReferenceCoordinatesOf : unexpected size of defaut array : " << sz << " % " << nbDim << " != 0 !"); + ret->alloc(sz/size_t(nbDim),nbDim); + std::copy(retCpp.begin(),retCpp.end(),ret->getPointer()); + return ret; +} diff --git a/src/MEDCoupling/MEDCouplingGaussLocalization.hxx b/src/MEDCoupling/MEDCouplingGaussLocalization.hxx index 65fc265df..49cb19da3 100644 --- a/src/MEDCoupling/MEDCouplingGaussLocalization.hxx +++ b/src/MEDCoupling/MEDCouplingGaussLocalization.hxx @@ -72,6 +72,7 @@ namespace MEDCoupling // MEDCOUPLING_EXPORT static MEDCouplingGaussLocalization BuildNewInstanceFromTinyInfo(mcIdType dim, const std::vector& tinyData); MEDCOUPLING_EXPORT static bool AreAlmostEqual(const std::vector& v1, const std::vector& v2, double eps); + MEDCOUPLING_EXPORT static MCAuto GetDefaultReferenceCoordinatesOf(INTERP_KERNEL::NormalizedCellType type); private: int checkCoherencyOfRequest(mcIdType gaussPtIdInCell, int comp) const; private: diff --git a/src/MEDCoupling_Swig/MEDCouplingCommon.i b/src/MEDCoupling_Swig/MEDCouplingCommon.i index 1caf26e6c..282847b65 100644 --- a/src/MEDCoupling_Swig/MEDCouplingCommon.i +++ b/src/MEDCoupling_Swig/MEDCouplingCommon.i @@ -480,6 +480,7 @@ typedef long mcPyPtrType; %newobject MEDCoupling::MEDCouplingGaussLocalization::buildRefCell; %newobject MEDCoupling::MEDCouplingGaussLocalization::getShapeFunctionValues; %newobject MEDCoupling::MEDCouplingGaussLocalization::getDerivativeOfShapeFunctionValues; +%newobject MEDCoupling::MEDCouplingGaussLocalization::GetDefaultReferenceCoordinatesOf; %newobject MEDCoupling::MEDCouplingSkyLineArray::BuildFromPolyhedronConn; %newobject MEDCoupling::MEDCouplingSkyLineArray::getSuperIndexArray; %newobject MEDCoupling::MEDCouplingSkyLineArray::getIndexArray; @@ -1318,6 +1319,12 @@ namespace MEDCoupling MCAuto ret(self->getDerivativeOfShapeFunctionValues()); return ret.retn(); } + + static DataArrayDouble *GetDefaultReferenceCoordinatesOf(INTERP_KERNEL::NormalizedCellType type) + { + MCAuto ret(MEDCouplingGaussLocalization::GetDefaultReferenceCoordinatesOf(type)); + return ret.retn(); + } } }; -- 2.39.2