From: Anthony Geay Date: Fri, 27 Jan 2017 13:33:56 +0000 (+0100) Subject: A small useful method for Gauss points X-Git-Tag: V8_3_0a2~31 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=cb69486cbd6a1561cd5106919e72e57fbfa23a88;p=tools%2Fmedcoupling.git A small useful method for Gauss points --- diff --git a/src/MEDCoupling/MEDCouplingGaussLocalization.cxx b/src/MEDCoupling/MEDCouplingGaussLocalization.cxx index c1919217c..f75cd82a8 100644 --- a/src/MEDCoupling/MEDCouplingGaussLocalization.cxx +++ b/src/MEDCoupling/MEDCouplingGaussLocalization.cxx @@ -20,6 +20,7 @@ #include "MEDCouplingGaussLocalization.hxx" #include "InterpKernelGaussCoords.hxx" +#include "MEDCoupling1GTUMesh.hxx" #include "MEDCouplingUMesh.hxx" #include "CellModel.hxx" @@ -232,6 +233,26 @@ MCAuto MEDCouplingGaussLocalization::localizePtsInRefCooForEach return ret; } +/*! + * This method returns an unstructured mesh that represents the reference cell. + */ +MCAuto MEDCouplingGaussLocalization::buildRefCell() const +{ + MCAuto coo(DataArrayDouble::New()); + const INTERP_KERNEL::CellModel& cm(INTERP_KERNEL::CellModel::GetCellModel(getType())); + if(getDimension()!=cm.getDimension()) + throw INTERP_KERNEL::Exception("BuildRefCell : dimension mistmatch !"); + coo->alloc(cm.getNumberOfNodes(),getDimension()); + std::copy(_ref_coord.begin(),_ref_coord.end(),coo->getPointer()); + MCAuto ret(MEDCoupling1SGTUMesh::New("",getType())); + ret->setCoords(coo); + MCAuto conn(DataArrayInt::New()); + conn->alloc(cm.getNumberOfNodes(),1); + conn->iota(); + ret->setNodalConnectivity(conn); + return MCAuto(ret->buildUnstructured()); +} + /*! * This method sets the comp_th component of ptIdInCell_th point coordinate of reference element of type this->_type. * @throw if not 0<=ptIdInCell localizePtsInRefCooForEachCell(const DataArrayDouble *ptsInRefCoo, const MEDCouplingUMesh *mesh) const; + MEDCOUPLING_EXPORT MCAuto buildRefCell() const; // MEDCOUPLING_EXPORT const std::vector& getRefCoords() const { return _ref_coord; } MEDCOUPLING_EXPORT double getRefCoord(int ptIdInCell, int comp) const; diff --git a/src/MEDCoupling_Swig/MEDCouplingCommon.i b/src/MEDCoupling_Swig/MEDCouplingCommon.i index 14a4510e5..d4ad97677 100644 --- a/src/MEDCoupling_Swig/MEDCouplingCommon.i +++ b/src/MEDCoupling_Swig/MEDCouplingCommon.i @@ -411,6 +411,8 @@ using namespace INTERP_KERNEL; %newobject MEDCoupling::PartDefinition::tryToSimplify; %newobject MEDCoupling::DataArrayPartDefinition::New; %newobject MEDCoupling::SlicePartDefinition::New; +%newobject MEDCoupling::MEDCouplingGaussLocalization::localizePtsInRefCooForEachCell; +%newobject MEDCoupling::MEDCouplingGaussLocalization::buildRefCell; %feature("unref") MEDCouplingPointSet "$this->decrRef();" %feature("unref") MEDCouplingMesh "$this->decrRef();" @@ -1161,6 +1163,21 @@ namespace MEDCoupling void setWeights(const std::vector& w) throw(INTERP_KERNEL::Exception); // static bool AreAlmostEqual(const std::vector& v1, const std::vector& v2, double eps); + // + %extend + { + DataArrayDouble *localizePtsInRefCooForEachCell(const DataArrayDouble *ptsInRefCoo, const MEDCouplingUMesh *mesh) const throw(INTERP_KERNEL::Exception) + { + MCAuto ret(self->localizePtsInRefCooForEachCell(ptsInRefCoo,mesh)); + return ret.retn(); + } + + MEDCouplingUMesh *buildRefCell() const throw(INTERP_KERNEL::Exception) + { + MCAuto ret(self->buildRefCell()); + return ret.retn(); + } + } }; class MEDCouplingSkyLineArray