--- /dev/null
+// Copyright (C) 2007-2008 CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+#ifndef __INTEGRALUNIFORMINTERSECTOR_HXX__
+#define __INTEGRALUNIFORMINTERSECTOR_HXX__
+
+#include "TargetIntersector.hxx"
+
+#include <cmath>
+
+namespace INTERP_KERNEL
+{
+ template<class MyMeshType, class MyMatrix>
+ class IntegralUniformIntersector : public TargetIntersector<MyMeshType,MyMatrix>
+ {
+ public:
+ typedef typename MyMeshType::MyConnType ConnType;
+ public:
+ IntegralUniformIntersector(const MyMeshType& mesh, bool isAbs);
+ double performNormalization(double val) const { if(_is_abs) return fabs(val); else return val; }
+ void setFromTo(bool val) { _from_to=val; }
+ void putValueIn(ConnType i, double val, MyMatrix& res) const;
+ protected:
+ const MyMeshType& _mesh;
+ //! if false means fromIntegralUniform if true means toIntegralUniform
+ bool _from_to;
+ bool _is_abs;
+ };
+
+ template<class MyMeshType, class MyMatrix>
+ class IntegralUniformIntersectorP0 : public IntegralUniformIntersector<MyMeshType,MyMatrix>
+ {
+ public:
+ typedef typename MyMeshType::MyConnType ConnType;
+ public:
+ IntegralUniformIntersectorP0(const MyMeshType& mesh, bool isAbs);
+ int getNumberOfRowsOfResMatrix() const;
+ int getNumberOfColsOfResMatrix() const;
+ void intersectCells(ConnType targetCell, const std::vector<ConnType>& srcCells, MyMatrix& res);
+ };
+
+ template<class MyMeshType, class MyMatrix>
+ class IntegralUniformIntersectorP1 : public IntegralUniformIntersector<MyMeshType,MyMatrix>
+ {
+ public:
+ typedef typename MyMeshType::MyConnType ConnType;
+ public:
+ IntegralUniformIntersectorP1(const MyMeshType& mesh, bool isAbs);
+ int getNumberOfRowsOfResMatrix() const;
+ int getNumberOfColsOfResMatrix() const;
+ void intersectCells(ConnType targetCell, const std::vector<ConnType>& srcCells, MyMatrix& res);
+ };
+}
+
+#endif
--- /dev/null
+// Copyright (C) 2007-2008 CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+#ifndef __INTEGRALUNIFORMINTERSECTOR_TXX__
+#define __INTEGRALUNIFORMINTERSECTOR_TXX__
+
+#include "IntegralUniformIntersector.hxx"
+#include "VolSurfUser.txx"
+
+namespace INTERP_KERNEL
+{
+ template<class MyMeshType, class MyMatrix>
+ IntegralUniformIntersector<MyMeshType,MyMatrix>::IntegralUniformIntersector(const MyMeshType& mesh, bool isAbs):_mesh(mesh),_from_to(false),_is_abs(isAbs)
+ {
+ }
+
+ template<class MyMeshType, class MyMatrix>
+ void IntegralUniformIntersector<MyMeshType,MyMatrix>::putValueIn(ConnType iInCMode, double val1, MyMatrix& res) const
+ {
+ static const NumberingPolicy numPol=MyMeshType::My_numPol;
+ double val=performNormalization(val1);
+ if(_from_to)
+ {
+ typename MyMatrix::value_type& resRow=res[0];
+ typename MyMatrix::value_type::const_iterator iterRes=resRow.find(OTT<ConnType,numPol>::indFC(iInCMode));
+ if(iterRes==resRow.end())
+ resRow.insert(std::make_pair(OTT<ConnType,numPol>::indFC(iInCMode),val));
+ else
+ {
+ double val2=(*iterRes).second+val;
+ resRow.erase(OTT<ConnType,numPol>::indFC(iInCMode));
+ resRow.insert(std::make_pair(OTT<ConnType,numPol>::indFC(iInCMode),val2));
+ }
+ }
+ else
+ {
+ typename MyMatrix::value_type& resRow=res[iInCMode];
+ typename MyMatrix::value_type::const_iterator iterRes=resRow.find(OTT<ConnType,numPol>::indFC(0));
+ if(iterRes==resRow.end())
+ resRow.insert(std::make_pair(OTT<ConnType,numPol>::indFC(0),val));
+ else
+ {
+ double val2=(*iterRes).second+val;
+ resRow.erase(OTT<ConnType,numPol>::indFC(0));
+ resRow.insert(std::make_pair(OTT<ConnType,numPol>::indFC(0),val2));
+ }
+ }
+ }
+
+ template<class MyMeshType, class MyMatrix>
+ IntegralUniformIntersectorP0<MyMeshType,MyMatrix>::IntegralUniformIntersectorP0(const MyMeshType& mesh, bool isAbs):IntegralUniformIntersector<MyMeshType,MyMatrix>(mesh,isAbs)
+ {
+ }
+
+ template<class MyMeshType, class MyMatrix>
+ int IntegralUniformIntersectorP0<MyMeshType,MyMatrix>::getNumberOfRowsOfResMatrix() const
+ {
+ if(IntegralUniformIntersector<MyMeshType,MyMatrix>::_from_to)
+ return 1;
+ else
+ return IntegralUniformIntersector<MyMeshType,MyMatrix>::_mesh.getNumberOfElements();
+ }
+
+ template<class MyMeshType, class MyMatrix>
+ int IntegralUniformIntersectorP0<MyMeshType,MyMatrix>::getNumberOfColsOfResMatrix() const
+ {
+ if(IntegralUniformIntersector<MyMeshType,MyMatrix>::_from_to)
+ return IntegralUniformIntersector<MyMeshType,MyMatrix>::_mesh.getNumberOfElements();
+ else
+ return 1;
+ }
+
+ template<class MyMeshType, class MyMatrix>
+ void IntegralUniformIntersectorP0<MyMeshType,MyMatrix>::intersectCells(ConnType targetCell, const std::vector<ConnType>& srcCells, MyMatrix& res)
+ {
+ static const NumberingPolicy numPol=MyMeshType::My_numPol;
+ res.resize(getNumberOfRowsOfResMatrix());
+ unsigned long nbelem=IntegralUniformIntersector<MyMeshType,MyMatrix>::_mesh.getNumberOfElements();
+ const ConnType *connIndx=IntegralUniformIntersector<MyMeshType,MyMatrix>::_mesh.getConnectivityIndexPtr();
+ const ConnType *conn=IntegralUniformIntersector<MyMeshType,MyMatrix>::_mesh.getConnectivityPtr();
+ const double *coords=IntegralUniformIntersector<MyMeshType,MyMatrix>::_mesh.getCoordinatesPtr();
+ for(unsigned long i=0;i<nbelem;i++)
+ {
+ INTERP_KERNEL::NormalizedCellType t=IntegralUniformIntersector<MyMeshType,MyMatrix>::_mesh.getTypeOfElement(OTT<ConnType,numPol>::indFC(i));
+ double val=computeVolSurfOfCell<ConnType,numPol,MyMeshType::MY_SPACEDIM>(t,conn+OTT<ConnType,numPol>::ind2C(connIndx[i]),connIndx[i+1]-connIndx[i],coords);
+ IntegralUniformIntersector<MyMeshType,MyMatrix>::putValueIn(i,val,res);
+ }
+ }
+
+ template<class MyMeshType, class MyMatrix>
+ IntegralUniformIntersectorP1<MyMeshType,MyMatrix>::IntegralUniformIntersectorP1(const MyMeshType& mesh, bool isAbs):IntegralUniformIntersector<MyMeshType,MyMatrix>(mesh,isAbs)
+ {
+ }
+
+ template<class MyMeshType, class MyMatrix>
+ int IntegralUniformIntersectorP1<MyMeshType,MyMatrix>::getNumberOfRowsOfResMatrix() const
+ {
+ if(IntegralUniformIntersector<MyMeshType,MyMatrix>::_from_to)
+ return 1;
+ else
+ return IntegralUniformIntersector<MyMeshType,MyMatrix>::_mesh.getNumberOfNodes();
+ }
+
+ template<class MyMeshType, class MyMatrix>
+ int IntegralUniformIntersectorP1<MyMeshType,MyMatrix>::getNumberOfColsOfResMatrix() const
+ {
+ if(IntegralUniformIntersector<MyMeshType,MyMatrix>::_from_to)
+ return IntegralUniformIntersector<MyMeshType,MyMatrix>::_mesh.getNumberOfNodes();
+ else
+ return 1;
+ }
+
+ template<class MyMeshType, class MyMatrix>
+ void IntegralUniformIntersectorP1<MyMeshType,MyMatrix>::intersectCells(ConnType targetCell, const std::vector<ConnType>& srcCells, MyMatrix& res)
+ {
+ static const NumberingPolicy numPol=MyMeshType::My_numPol;
+ res.resize(getNumberOfRowsOfResMatrix());
+ unsigned long nbelem=IntegralUniformIntersector<MyMeshType,MyMatrix>::_mesh.getNumberOfElements();
+ const ConnType *connIndx=IntegralUniformIntersector<MyMeshType,MyMatrix>::_mesh.getConnectivityIndexPtr();
+ const ConnType *conn=IntegralUniformIntersector<MyMeshType,MyMatrix>::_mesh.getConnectivityPtr();
+ const double *coords=IntegralUniformIntersector<MyMeshType,MyMatrix>::_mesh.getCoordinatesPtr();
+ for(unsigned long i=0;i<nbelem;i++)
+ {
+ INTERP_KERNEL::NormalizedCellType t=IntegralUniformIntersector<MyMeshType,MyMatrix>::_mesh.getTypeOfElement(OTT<ConnType,numPol>::indFC(i));
+ int lgth=connIndx[i+1]-connIndx[i];
+ const ConnType *locConn=conn+OTT<ConnType,numPol>::ind2C(connIndx[i]);
+ double val=computeVolSurfOfCell<ConnType,numPol,MyMeshType::MY_SPACEDIM>(t,locConn,lgth,coords);
+ if(t==NORM_TRI3)
+ val/=3.;
+ else if(t==NORM_TETRA4)
+ val/=4.;
+ else
+ throw INTERP_KERNEL::Exception("Invalid cell type detected : must be TRI3 or TETRA4 ! ");
+ for(int j=0;j<lgth;j++)
+ IntegralUniformIntersector<MyMeshType,MyMatrix>::putValueIn(OTT<ConnType,numPol>::coo2C(locConn[j]),val,res);
+ }
+ }
+}
+
+#endif
Interpolation(const InterpolationOptions& io) :InterpolationOptions(io){}
//interpolation of two triangular meshes.
template<class MatrixType, class MyMeshType>
- int interpolateMeshes(const MyMeshType& mesh1, const MyMeshType& mesh2, MatrixType& result)
- { return asLeaf().interpolateMeshes(mesh1,mesh2,result); }
+ int interpolateMeshes(const MyMeshType& meshS, const MyMeshType& meshT, MatrixType& result)
+ { return asLeaf().interpolateMeshes(meshS,meshT,result); }
+ template<class MyMeshType, class MatrixType>
+ int fromIntegralUniform(const MyMeshType& meshT, MatrixType& result, const char *method) { return fromToIntegralUniform(true,meshT,result,method); }
+ template<class MyMeshType, class MatrixType>
+ int toIntegralUniform(const MyMeshType& meshS, MatrixType& result, const char *method) { return fromToIntegralUniform(false,meshS,result,method); }
+ protected:
+ template<class MyMeshType, class MatrixType>
+ int fromToIntegralUniform(bool fromTo, const MyMeshType& mesh, MatrixType& result, const char *method);
protected:
TrueMainInterpolator& asLeaf() { return static_cast<TrueMainInterpolator&>(*this); }
};
--- /dev/null
+// Copyright (C) 2007-2008 CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+#ifndef __INTERPOLATION_TXX__
+#define __INTERPOLATION_TXX__
+
+#include "Interpolation.hxx"
+#include "IntegralUniformIntersector.hxx"
+#include "IntegralUniformIntersector.txx"
+
+namespace INTERP_KERNEL
+{
+ template<class TrueMainInterpolator>
+ template<class MyMeshType, class MatrixType>
+ int Interpolation<TrueMainInterpolator>::fromToIntegralUniform(bool fromTo, const MyMeshType& mesh, MatrixType& result, const char *method)
+ {
+ typedef typename MyMeshType::MyConnType ConnType;
+ std::string methodCPP(method);
+ int ret=-1;
+ if(methodCPP=="P0")
+ {
+ IntegralUniformIntersectorP0<MyMeshType,MatrixType> intersector(mesh,InterpolationOptions::getMeasureAbsStatus());
+ intersector.setFromTo(fromTo);
+ std::vector<ConnType> tmp;
+ intersector.intersectCells(0,tmp,result);
+ ret=intersector.getNumberOfColsOfResMatrix();
+ }
+ else if(methodCPP=="P1")
+ {
+ IntegralUniformIntersectorP1<MyMeshType,MatrixType> intersector(mesh,InterpolationOptions::getMeasureAbsStatus());
+ intersector.setFromTo(fromTo);
+ std::vector<ConnType> tmp;
+ intersector.intersectCells(0,tmp,result);
+ ret=intersector.getNumberOfColsOfResMatrix();
+ }
+ else
+ throw INTERP_KERNEL::Exception("Invalid method specified in fromIntegralUniform : must be in { \"P0\", \"P1\"}");
+ return ret;
+ }
+}
+
+#endif
+
#define __INTERPOLATION3D_TXX__
#include "Interpolation3D.hxx"
+#include "Interpolation.txx"
#include "MeshElement.txx"
#include "TransformedTriangle.hxx"
#include "PolyhedronIntersector.txx"
return ret;
}
-
}
#endif
const char INTERP_KERNEL::InterpolationOptions::ORIENTATION_STR[]="Orientation";
+const char INTERP_KERNEL::InterpolationOptions::MEASURE_ABS_STR[]="MeasureAbs";
+
const char INTERP_KERNEL::InterpolationOptions::INTERSEC_TYPE_STR[]="IntersectionType";
const char INTERP_KERNEL::InterpolationOptions::SPLITTING_POLICY_STR[]="SplittingPolicy";
setOrientation(value);
return true;
}
+ else if(key==MEASURE_ABS_STR)
+ {
+ bool valBool=(value!=0);
+ setMeasureAbsStatus(valBool);
+ }
else
return false;
}
double _bounding_box_adjustment_abs ;
double _max_distance_for_3Dsurf_intersect;
int _orientation ;
+ bool _measure_abs;
SplittingPolicy _splitting_policy ;
public:
int getOrientation() const { return _orientation; }
void setOrientation(int o) { _orientation=o; }
+
+ bool getMeasureAbsStatus() const { return _measure_abs; }
+ void setMeasureAbsStatus(bool newStatus) { _measure_abs=newStatus; }
SplittingPolicy getSplittingPolicy() const { return _splitting_policy; }
void setSplittingPolicy(SplittingPolicy sp) { _splitting_policy=sp; }
_bounding_box_adjustment_abs=0.;
_max_distance_for_3Dsurf_intersect=DFT_MAX_DIST_3DSURF_INTERSECT;
_orientation=0;
+ _measure_abs=true;
_splitting_policy=GENERAL_48;
}
bool setOptionDouble(const std::string& key, double value);
static const char PRINT_LEV_STR[];
static const char DO_ROTATE_STR[];
static const char ORIENTATION_STR[];
+ static const char MEASURE_ABS_STR[];
static const char INTERSEC_TYPE_STR[];
static const char SPLITTING_POLICY_STR[];
static const char TRIANGULATION_INTERSECT2D_STR[];
{
private:
double _dim_caracteristic;
- static const double DEFAULT_PRECISION;
-
public:
InterpolationPlanar();
InterpolationPlanar(const InterpolationOptions & io);
// Main function to interpolate triangular and quadratic meshes
template<class MyMeshType, class MatrixType>
- int interpolateMeshes(const MyMeshType& mesh1, const MyMeshType& mesh2, MatrixType& result, const char *method);
-
+ int interpolateMeshes(const MyMeshType& meshS, const MyMeshType& meshT, MatrixType& result, const char *method);
public:
bool doRotate() const { return asLeafInterpPlanar().doRotate(); }
double medianPlane() const { return asLeafInterpPlanar().medianPlane(); }
template<class MyMeshType, class MyMatrixRow>
void performAdjustmentOfBB(PlanarIntersector<MyMeshType,MyMatrixRow>* intersector, std::vector<double>& bbox) const
{ return asLeafInterpPlanar().performAdjustmentOfBB(intersector,bbox); }
-
protected:
RealPlanar& asLeafInterpPlanar() { return static_cast<RealPlanar&>(*this); }
const RealPlanar& asLeafInterpPlanar() const { return static_cast< const RealPlanar& >(*this); }
#define __INTERPOLATIONPLANAR_TXX__
#include "InterpolationPlanar.hxx"
+#include "Interpolation.txx"
#include "InterpolationOptions.hxx"
#include "PlanarIntersector.hxx"
#include "PlanarIntersector.txx"
namespace INTERP_KERNEL
{
-
- template<class RealPlanar>
- const double InterpolationPlanar<RealPlanar>::DEFAULT_PRECISION=1.e-12;
-
/**
* \defgroup interpolationPlanar InterpolationPlanar
*
{
}
-
/**
* \brief Function used to set the options for the intersection calculation
* \details The following options can be modified:
INTERPKERNELDefines.hxx \
InterpKernelMatrix.hxx \
Interpolation.hxx \
+Interpolation.txx \
Interpolation2D.hxx \
Interpolation2D.txx \
Interpolation3D.hxx \
TranslationRotationMatrix.hxx \
TriangulationIntersector.hxx \
TriangulationIntersector.txx \
+IntegralUniformIntersector.hxx \
+IntegralUniformIntersector.txx \
UnitTetraIntersectionBary.hxx \
VTKNormalizedUnstructuredMesh.hxx \
VTKNormalizedUnstructuredMesh.txx \
PlanarIntersectorP0P1.txx \
PlanarIntersectorP1P0.hxx \
PlanarIntersectorP1P0.txx \
-VolSurfFormulae.hxx
+VolSurfFormulae.hxx \
+VolSurfUser.hxx \
+VolSurfUser.txx
# Libraries targets
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
-#ifndef VOLSURFFORMULAE
-#define VOLSURFFORMULAE
+#ifndef __VOLSURFFORMULAE_HXX__
+#define __VOLSURFFORMULAE_HXX__
#include <math.h>
--- /dev/null
+// Copyright (C) 2007-2008 CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+#ifndef __VOLSURFUSER_HXX__
+#define __VOLSURFUSER_HXX__
+
+#include "NormalizedUnstructuredMesh.hxx"
+
+namespace INTERP_KERNEL
+{
+ template<class ConnType, NumberingPolicy numPolConn, int SPACEDIM>
+ double computeVolSurfOfCell(NormalizedCellType type, const ConnType *connec, int lgth, const double *coords);
+
+ template<class ConnType, NumberingPolicy numPolConn>
+ double computeVolSurfOfCell2(NormalizedCellType type, const ConnType *connec, int lgth, const double *coords, int spaceDim);
+}
+
+#endif
--- /dev/null
+// Copyright (C) 2007-2008 CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+#ifndef __VOLSURFUSER_TXX__
+#define __VOLSURFUSER_TXX__
+
+#include "VolSurfUser.hxx"
+#include "VolSurfFormulae.hxx"
+#include "InterpolationUtils.hxx"
+
+namespace INTERP_KERNEL
+{
+ template<class ConnType, NumberingPolicy numPol, int SPACEDIM>
+ double computeVolSurfOfCell(NormalizedCellType type, const ConnType *connec, int lgth, const double *coords)
+ {
+ switch(type)
+ {
+ case INTERP_KERNEL::NORM_TRI3 :
+ case INTERP_KERNEL::NORM_TRI6 :
+ {
+ int N1 = OTT<ConnType,numPol>::coo2C(connec[0]);
+ int N2 = OTT<ConnType,numPol>::coo2C(connec[1]);
+ int N3 = OTT<ConnType,numPol>::coo2C(connec[2]);
+
+ return INTERP_KERNEL::calculateAreaForTria(coords+(SPACEDIM*N1),
+ coords+(SPACEDIM*N2),
+ coords+(SPACEDIM*N3),
+ SPACEDIM);
+ }
+ break;
+
+ case INTERP_KERNEL::NORM_QUAD4 :
+ case INTERP_KERNEL::NORM_QUAD8 :
+ {
+ int N1 = OTT<ConnType,numPol>::coo2C(connec[0]);
+ int N2 = OTT<ConnType,numPol>::coo2C(connec[1]);
+ int N3 = OTT<ConnType,numPol>::coo2C(connec[2]);
+ int N4 = OTT<ConnType,numPol>::coo2C(connec[3]);
+
+ return INTERP_KERNEL::calculateAreaForQuad(coords+SPACEDIM*N1,
+ coords+SPACEDIM*N2,
+ coords+SPACEDIM*N3,
+ coords+SPACEDIM*N4,
+ SPACEDIM);
+ }
+ break;
+
+ case INTERP_KERNEL::NORM_POLYGON :
+ {
+ const double **pts=new const double *[lgth];
+ for(int inod=0;inod<lgth;inod++)
+ pts[inod] = coords+3*OTT<ConnType,numPol>::coo2C(connec[inod]);
+ double val=INTERP_KERNEL::calculateAreaForPolyg(pts,lgth,SPACEDIM);
+ delete [] pts;
+ return val;
+ }
+ break;
+ case INTERP_KERNEL::NORM_TETRA4 :
+ case INTERP_KERNEL::NORM_TETRA10 :
+ {
+ int N1 = OTT<ConnType,numPol>::coo2C(connec[0]);
+ int N2 = OTT<ConnType,numPol>::coo2C(connec[1]);
+ int N3 = OTT<ConnType,numPol>::coo2C(connec[2]);
+ int N4 = OTT<ConnType,numPol>::coo2C(connec[3]);
+
+ return INTERP_KERNEL::calculateVolumeForTetra(coords+SPACEDIM*N1,
+ coords+SPACEDIM*N2,
+ coords+SPACEDIM*N3,
+ coords+SPACEDIM*N4);
+ }
+ break;
+
+ case INTERP_KERNEL::NORM_PYRA5 :
+ case INTERP_KERNEL::NORM_PYRA13 :
+ {
+ int N1 = OTT<ConnType,numPol>::coo2C(connec[0]);
+ int N2 = OTT<ConnType,numPol>::coo2C(connec[1]);
+ int N3 = OTT<ConnType,numPol>::coo2C(connec[2]);
+ int N4 = OTT<ConnType,numPol>::coo2C(connec[3]);
+ int N5 = OTT<ConnType,numPol>::coo2C(connec[4]);
+
+ return INTERP_KERNEL::calculateVolumeForPyra(coords+SPACEDIM*N1,
+ coords+SPACEDIM*N2,
+ coords+SPACEDIM*N3,
+ coords+SPACEDIM*N4,
+ coords+SPACEDIM*N5);
+ }
+ break;
+
+ case INTERP_KERNEL::NORM_PENTA6 :
+ case INTERP_KERNEL::NORM_PENTA15 :
+ {
+ int N1 = OTT<ConnType,numPol>::coo2C(connec[0]);
+ int N2 = OTT<ConnType,numPol>::coo2C(connec[1]);
+ int N3 = OTT<ConnType,numPol>::coo2C(connec[2]);
+ int N4 = OTT<ConnType,numPol>::coo2C(connec[3]);
+ int N5 = OTT<ConnType,numPol>::coo2C(connec[4]);
+ int N6 = OTT<ConnType,numPol>::coo2C(connec[5]);
+
+ return INTERP_KERNEL::calculateVolumeForPenta(coords+SPACEDIM*N1,
+ coords+SPACEDIM*N2,
+ coords+SPACEDIM*N3,
+ coords+SPACEDIM*N4,
+ coords+SPACEDIM*N5,
+ coords+SPACEDIM*N6);
+ }
+ break;
+
+ case INTERP_KERNEL::NORM_HEXA8 :
+ case INTERP_KERNEL::NORM_HEXA20 :
+ {
+ int N1 = OTT<ConnType,numPol>::coo2C(connec[0]);
+ int N2 = OTT<ConnType,numPol>::coo2C(connec[1]);
+ int N3 = OTT<ConnType,numPol>::coo2C(connec[2]);
+ int N4 = OTT<ConnType,numPol>::coo2C(connec[3]);
+ int N5 = OTT<ConnType,numPol>::coo2C(connec[4]);
+ int N6 = OTT<ConnType,numPol>::coo2C(connec[5]);
+ int N7 = OTT<ConnType,numPol>::coo2C(connec[6]);
+ int N8 = OTT<ConnType,numPol>::coo2C(connec[7]);
+
+ return INTERP_KERNEL::calculateVolumeForHexa(coords+SPACEDIM*N1,
+ coords+SPACEDIM*N2,
+ coords+SPACEDIM*N3,
+ coords+SPACEDIM*N4,
+ coords+SPACEDIM*N5,
+ coords+SPACEDIM*N6,
+ coords+SPACEDIM*N7,
+ coords+SPACEDIM*N8);
+ }
+ break;
+
+ case INTERP_KERNEL::NORM_POLYHED :
+ {
+ throw INTERP_KERNEL::Exception("Polyedra Not yet implemented !");
+ }
+ break;
+ default:
+ throw INTERP_KERNEL::Exception("Not recognized cell type to get Area/Volume on it !");
+ }
+ }
+
+ template<class ConnType, NumberingPolicy numPolConn>
+ double computeVolSurfOfCell2(NormalizedCellType type, const ConnType *connec, int lgth, const double *coords, int spaceDim)
+ {
+ if(spaceDim==3)
+ return computeVolSurfOfCell<ConnType,numPolConn,3>(type,connec,lgth,coords);
+ if(spaceDim==2)
+ return computeVolSurfOfCell<ConnType,numPolConn,2>(type,connec,lgth,coords);
+ throw INTERP_KERNEL::Exception("Invalid spaceDim specified : must be 2 or 3");
+ }
+}
+
+#endif
//not implemented yet !
}
-MEDCouplingFieldDouble *MEDCouplingCMesh::getMeasureField() const
+MEDCouplingFieldDouble *MEDCouplingCMesh::getMeasureField(bool isAbs) const
{
//not implemented yet !
return 0;
DataArrayDouble *coordsZ=0);
// tools
void getBoundingBox(double *bbox) const;
- MEDCouplingFieldDouble *getMeasureField() const;
+ MEDCouplingFieldDouble *getMeasureField(bool isAbs) const;
private:
MEDCouplingCMesh();
~MEDCouplingCMesh();
}
}
-MEDCouplingFieldDouble *MEDCouplingFieldDiscretizationP0::getWeightingField(const MEDCouplingMesh *mesh) const
+MEDCouplingFieldDouble *MEDCouplingFieldDiscretizationP0::getWeightingField(const MEDCouplingMesh *mesh, bool isAbs) const
{
- return mesh->getMeasureField();
+ return mesh->getMeasureField(isAbs);
}
/*!
}
}
-MEDCouplingFieldDouble *MEDCouplingFieldDiscretizationP1::getWeightingField(const MEDCouplingMesh *mesh) const
+MEDCouplingFieldDouble *MEDCouplingFieldDiscretizationP1::getWeightingField(const MEDCouplingMesh *mesh, bool isAbs) const
{
//not implemented yet.
//Dual mesh to build
virtual int getNumberOfTuples(const MEDCouplingMesh *mesh) const = 0;
virtual void checkCompatibilityWithNature(NatureOfField nat) const throw(INTERP_KERNEL::Exception) = 0;
virtual void checkCoherencyBetween(const MEDCouplingMesh *mesh, const DataArrayDouble *da) const throw(INTERP_KERNEL::Exception) = 0;
- virtual MEDCouplingFieldDouble *getWeightingField(const MEDCouplingMesh *mesh) const = 0;
+ virtual MEDCouplingFieldDouble *getWeightingField(const MEDCouplingMesh *mesh, bool isAbs) const = 0;
virtual MEDCouplingMesh *buildSubMeshData(const int *start, const int *end, const MEDCouplingMesh *mesh, DataArrayInt *&di) const = 0;
};
int getNumberOfTuples(const MEDCouplingMesh *mesh) const;
void checkCompatibilityWithNature(NatureOfField nat) const throw(INTERP_KERNEL::Exception);
void checkCoherencyBetween(const MEDCouplingMesh *mesh, const DataArrayDouble *da) const throw(INTERP_KERNEL::Exception);
- MEDCouplingFieldDouble *getWeightingField(const MEDCouplingMesh *mesh) const;
+ MEDCouplingFieldDouble *getWeightingField(const MEDCouplingMesh *mesh, bool isAbs) const;
MEDCouplingMesh *buildSubMeshData(const int *start, const int *end, const MEDCouplingMesh *mesh, DataArrayInt *&di) const;
public:
static const char REPR[];
int getNumberOfTuples(const MEDCouplingMesh *mesh) const;
void checkCompatibilityWithNature(NatureOfField nat) const throw(INTERP_KERNEL::Exception);
void checkCoherencyBetween(const MEDCouplingMesh *mesh, const DataArrayDouble *da) const throw(INTERP_KERNEL::Exception);
- MEDCouplingFieldDouble *getWeightingField(const MEDCouplingMesh *mesh) const;
+ MEDCouplingFieldDouble *getWeightingField(const MEDCouplingMesh *mesh, bool isAbs) const;
MEDCouplingMesh *buildSubMeshData(const int *start, const int *end, const MEDCouplingMesh *mesh, DataArrayInt *&di) const;
static DataArrayInt *invertArrayO2N2N2O(const MEDCouplingMesh *mesh, const DataArrayInt *di);
public:
return ret;
}
-double MEDCouplingFieldDouble::measureAccumulate(int compId) const
+double MEDCouplingFieldDouble::measureAccumulate(int compId, bool isWAbs) const
{
if(!_mesh)
throw INTERP_KERNEL::Exception("No mesh underlying this field to perform measureAccumulate");
- MEDCouplingFieldDouble *weight=_type->getWeightingField(_mesh);
+ MEDCouplingFieldDouble *weight=_type->getWeightingField(_mesh,isWAbs);
const double *ptr=weight->getArray()->getConstPointer();
int nbOfValues=weight->getArray()->getNbOfElems();
double ret=0.;
void setArray(DataArrayDouble *array);
DataArrayDouble *getArray() const { return _time_discr->getArray(); }
double accumulate(int compId) const;
- double measureAccumulate(int compId) const;
+ double measureAccumulate(int compId, bool isWAbs) const;
void getValueOn(const double *spaceLoc, double *res) const throw(INTERP_KERNEL::Exception);
void getValueOn(const double *spaceLoc, double time, double *res) const throw(INTERP_KERNEL::Exception);
//! \b temporary
virtual int getMeshDimension() const = 0;
// tools
virtual void getBoundingBox(double *bbox) const = 0;
- virtual MEDCouplingFieldDouble *getMeasureField() const = 0;
+ virtual MEDCouplingFieldDouble *getMeasureField(bool isAbs) const = 0;
protected:
MEDCouplingMesh() { }
MEDCouplingMesh(const MEDCouplingMesh& other):_name(other._name) { }
#include "MEDCouplingUMesh.hxx"
#include "MEDCouplingFieldDouble.hxx"
#include "CellModel.hxx"
-#include "VolSurfFormulae.hxx"
+#include "VolSurfUser.txx"
#include <sstream>
#include <limits>
* param field field on which cells the volumes are required
* return field containing the volumes, area or length depending the meshdimension.
*/
-MEDCouplingFieldDouble *MEDCouplingUMesh::getMeasureField() const
-{
- int ipt, type ;
- int nbelem = getNumberOfCells() ;
- int dim_mesh = getMeshDimension();
- int dim_space = getSpaceDimension() ;
- const double *coords = getCoords()->getConstPointer() ;
- const int *connec = getNodalConnectivity()->getConstPointer() ;
- const int *connec_index = getNodalConnectivityIndex()->getConstPointer() ;
-
-
- MEDCouplingFieldDouble* field = MEDCouplingFieldDouble::New(ON_CELLS);
- DataArrayDouble* array = DataArrayDouble::New() ;
- array->alloc(nbelem, 1) ;
- double *area_vol = array->getPointer() ;
-
- switch (dim_mesh)
+MEDCouplingFieldDouble *MEDCouplingUMesh::getMeasureField(bool isAbs) const
+{
+ int ipt;
+ INTERP_KERNEL::NormalizedCellType type;
+ int nbelem=getNumberOfCells();
+ int dim_space=getSpaceDimension();
+ const double *coords=getCoords()->getConstPointer();
+ const int *connec=getNodalConnectivity()->getConstPointer();
+ const int *connec_index=getNodalConnectivityIndex()->getConstPointer();
+
+ MEDCouplingFieldDouble* field=MEDCouplingFieldDouble::New(ON_CELLS);
+ DataArrayDouble* array=DataArrayDouble::New();
+ array->alloc(nbelem,1);
+ double *area_vol = array->getPointer();
+ for(int iel=0;iel<nbelem;iel++)
{
- case 2: // getting the areas
- for ( int iel=0 ; iel<nbelem ; iel++ )
- {
- ipt = connec_index[iel] ;
- type = connec[ipt] ;
-
- switch ( type )
- {
- case INTERP_KERNEL::NORM_TRI3 :
- case INTERP_KERNEL::NORM_TRI6 :
- {
- int N1 = connec[ipt+1];
- int N2 = connec[ipt+2];
- int N3 = connec[ipt+3];
-
- area_vol[iel]=fabs(INTERP_KERNEL::calculateAreaForTria(coords+(dim_space*N1),
- coords+(dim_space*N2),
- coords+(dim_space*N3),
- dim_space));
- }
- break ;
-
- case INTERP_KERNEL::NORM_QUAD4 :
- case INTERP_KERNEL::NORM_QUAD8 :
- {
- int N1 = connec[ipt+1];
- int N2 = connec[ipt+2];
- int N3 = connec[ipt+3];
- int N4 = connec[ipt+4];
-
- area_vol[iel]=fabs(INTERP_KERNEL::calculateAreaForQuad(coords+dim_space*N1,
- coords+dim_space*N2,
- coords+dim_space*N3,
- coords+dim_space*N4,
- dim_space));
- }
- break ;
-
- case INTERP_KERNEL::NORM_POLYGON :
- {
- // We must remember that the first item is the type. That's
- // why we substract 1 to get the number of nodes of this polygon
- int size = connec_index[iel+1] - connec_index[iel] - 1 ;
-
- const double **pts = new const double *[size] ;
-
- for ( int inod=0 ; inod<size ; inod++ )
- {
- // Remember the first item is the type
- pts[inod] = coords+dim_space*connec[ipt+inod+1] ;
- }
-
- area_vol[iel]=INTERP_KERNEL::calculateAreaForPolyg(pts,size,dim_space);
- delete [] pts;
- }
- break ;
-
- default :
- throw INTERP_KERNEL::Exception("Bad Support to get Areas on it !");
-
- } // End of switch
-
- } // End of the loop over the cells
- break;
- case 3: // getting the volumes
- for ( int iel=0 ; iel<nbelem ; iel++ )
- {
- ipt = connec_index[iel] ;
- type = connec[ipt] ;
-
- switch ( type )
- {
- case INTERP_KERNEL::NORM_TETRA4 :
- case INTERP_KERNEL::NORM_TETRA10 :
- {
- int N1 = connec[ipt+1];
- int N2 = connec[ipt+2];
- int N3 = connec[ipt+3];
- int N4 = connec[ipt+4];
-
- area_vol[iel]=INTERP_KERNEL::calculateVolumeForTetra(coords+dim_space*N1,
- coords+dim_space*N2,
- coords+dim_space*N3,
- coords+dim_space*N4) ;
- }
- break ;
-
- case INTERP_KERNEL::NORM_PYRA5 :
- case INTERP_KERNEL::NORM_PYRA13 :
- {
- int N1 = connec[ipt+1];
- int N2 = connec[ipt+2];
- int N3 = connec[ipt+3];
- int N4 = connec[ipt+4];
- int N5 = connec[ipt+5];
-
- area_vol[iel]=INTERP_KERNEL::calculateVolumeForPyra(coords+dim_space*N1,
- coords+dim_space*N2,
- coords+dim_space*N3,
- coords+dim_space*N4,
- coords+dim_space*N5) ;
- }
- break ;
-
- case INTERP_KERNEL::NORM_PENTA6 :
- case INTERP_KERNEL::NORM_PENTA15 :
- {
- int N1 = connec[ipt+1];
- int N2 = connec[ipt+2];
- int N3 = connec[ipt+3];
- int N4 = connec[ipt+4];
- int N5 = connec[ipt+5];
- int N6 = connec[ipt+6];
-
- area_vol[iel]=INTERP_KERNEL::calculateVolumeForPenta(coords+dim_space*N1,
- coords+dim_space*N2,
- coords+dim_space*N3,
- coords+dim_space*N4,
- coords+dim_space*N5,
- coords+dim_space*N6) ;
- }
- break ;
-
- case INTERP_KERNEL::NORM_HEXA8 :
- case INTERP_KERNEL::NORM_HEXA20 :
- {
- int N1 = connec[ipt+1];
- int N2 = connec[ipt+2];
- int N3 = connec[ipt+3];
- int N4 = connec[ipt+4];
- int N5 = connec[ipt+5];
- int N6 = connec[ipt+6];
- int N7 = connec[ipt+7];
- int N8 = connec[ipt+8];
-
- area_vol[iel]=INTERP_KERNEL::calculateVolumeForHexa(coords+dim_space*N1,
- coords+dim_space*N2,
- coords+dim_space*N3,
- coords+dim_space*N4,
- coords+dim_space*N5,
- coords+dim_space*N6,
- coords+dim_space*N7,
- coords+dim_space*N8) ;
- }
- break ;
-
- case INTERP_KERNEL::NORM_POLYHED :
- {
- throw INTERP_KERNEL::Exception("Not yet implemented !");
- }
- break ;
-
- default:
- throw INTERP_KERNEL::Exception("Bad Support to get Volume on it !");
- }
- }
- break;
- default:
- throw INTERP_KERNEL::Exception("interpolation is not available for this dimension");
+ ipt=connec_index[iel];
+ type=(INTERP_KERNEL::NormalizedCellType)connec[ipt];
+ area_vol[iel]=INTERP_KERNEL::computeVolSurfOfCell2<int,INTERP_KERNEL::ALL_C_MODE>(type,connec+ipt+1,connec_index[iel+1]-ipt-1,coords,dim_space);
}
-
+ if(isAbs)
+ for(int iel=0;iel<nbelem;iel++)
+ area_vol[iel]=fabs(area_vol[iel]);
field->setArray(array) ;
array->decrRef();
field->setMesh(const_cast<MEDCouplingUMesh *>(this));
MEDCouplingPointSet *buildBoundaryMesh(bool keepCoords) const;
void renumberConnectivity(const int *newNodeNumbers);
void giveElemsInBoundingBox(const double *bbox, double eps, std::vector<int>& elems);
- MEDCouplingFieldDouble *getMeasureField() const;
+ MEDCouplingFieldDouble *getMeasureField(bool isAbs) const;
private:
MEDCouplingUMesh();
MEDCouplingUMesh(const MEDCouplingUMesh& other, bool deepCpy);
{
}
-MEDCouplingFieldDouble *MEDCouplingUMeshDesc::getMeasureField() const
+MEDCouplingFieldDouble *MEDCouplingUMeshDesc::getMeasureField(bool isAbs) const
{
//not implemented yet.
return 0;
void findBoundaryNodes(std::vector<int>& nodes) const;
MEDCouplingPointSet *buildBoundaryMesh(bool keepCoords) const;
void renumberConnectivity(const int *newNodeNumbers);
- MEDCouplingFieldDouble *getMeasureField() const;
+ MEDCouplingFieldDouble *getMeasureField(bool isAbs) const;
DataArrayInt *zipCoordsTraducer();
private:
MEDCouplingUMeshDesc();
targetMesh->decrRef();
}
+void MEDCouplingBasicsTest::test2DInterpP0IntegralUniform()
+{
+ MEDCouplingUMesh *targetMesh=build2DTargetMesh_1();
+ //
+ MEDCouplingNormalizedUnstructuredMesh<2,2> targetWrapper(targetMesh);
+ INTERP_KERNEL::Interpolation2D myInterpolator;
+ vector<map<int,double> > res;
+ CPPUNIT_ASSERT_EQUAL(5,myInterpolator.fromIntegralUniform(targetWrapper,res,"P0"));
+ CPPUNIT_ASSERT_EQUAL(1,(int)res.size());
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(0.25,res[0][0],1e-12);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(0.125,res[0][1],1e-12);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(0.125,res[0][2],1e-12);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(0.25,res[0][3],1e-12);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(0.25,res[0][4],1e-12);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,sumAll(res),1e-12);
+ res.clear();
+ CPPUNIT_ASSERT_EQUAL(1,myInterpolator.toIntegralUniform(targetWrapper,res,"P0"));
+ CPPUNIT_ASSERT_EQUAL(5,(int)res.size());
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(0.25,res[0][0],1e-12);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(0.125,res[1][0],1e-12);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(0.125,res[2][0],1e-12);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(0.25,res[3][0],1e-12);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(0.25,res[4][0],1e-12);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,sumAll(res),1e-12);
+ res.clear();
+ targetMesh->decrRef();
+ //
+ targetMesh=build2DTargetMeshPerm_1();
+ MEDCouplingNormalizedUnstructuredMesh<2,2> targetWrapper2(targetMesh);
+ INTERP_KERNEL::Interpolation2D myInterpolator2;
+ CPPUNIT_ASSERT(myInterpolator2.getMeasureAbsStatus());
+ CPPUNIT_ASSERT_EQUAL(5,myInterpolator2.fromIntegralUniform(targetWrapper2,res,"P0"));
+ CPPUNIT_ASSERT_EQUAL(1,(int)res.size());
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(0.25,res[0][0],1e-12);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(0.125,res[0][1],1e-12);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(0.125,res[0][2],1e-12);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(0.25,res[0][3],1e-12);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(0.25,res[0][4],1e-12);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,sumAll(res),1e-12);
+ res.clear();
+ myInterpolator2.setMeasureAbsStatus(false);
+ CPPUNIT_ASSERT(!myInterpolator2.getMeasureAbsStatus());
+ CPPUNIT_ASSERT_EQUAL(5,myInterpolator2.fromIntegralUniform(targetWrapper2,res,"P0"));
+ CPPUNIT_ASSERT_EQUAL(1,(int)res.size());
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(0.25,res[0][0],1e-12);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(-0.125,res[0][1],1e-12);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(0.125,res[0][2],1e-12);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(0.25,res[0][3],1e-12);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(0.25,res[0][4],1e-12);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(0.75,sumAll(res),1e-12);
+ targetMesh->decrRef();
+}
+
+void MEDCouplingBasicsTest::test3DSurfInterpP0IntegralUniform()
+{
+ MEDCouplingUMesh *targetMesh=build3DSurfTargetMesh_1();
+ INTERP_KERNEL::Interpolation3DSurf myInterpolator;
+ MEDCouplingNormalizedUnstructuredMesh<3,2> targetWrapper(targetMesh);
+ vector<map<int,double> > res;
+ CPPUNIT_ASSERT_EQUAL(5,myInterpolator.fromIntegralUniform(targetWrapper,res,"P0"));
+ CPPUNIT_ASSERT_EQUAL(1,(int)res.size());
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(0.25*sqrt(2.),res[0][0],1e-12);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(0.125*sqrt(2.),res[0][1],1e-12);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(0.125*sqrt(2.),res[0][2],1e-12);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(0.25*sqrt(2.),res[0][3],1e-12);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(0.25*sqrt(2.),res[0][4],1e-12);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(1.*sqrt(2.),sumAll(res),1e-12);
+ res.clear();
+ CPPUNIT_ASSERT_EQUAL(1,myInterpolator.toIntegralUniform(targetWrapper,res,"P0"));
+ CPPUNIT_ASSERT_EQUAL(5,(int)res.size());
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(0.25*sqrt(2.),res[0][0],1e-12);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(0.125*sqrt(2.),res[1][0],1e-12);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(0.125*sqrt(2.),res[2][0],1e-12);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(0.25*sqrt(2.),res[3][0],1e-12);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(0.25*sqrt(2.),res[4][0],1e-12);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(1.*sqrt(2.),sumAll(res),1e-12);
+ targetMesh->decrRef();
+}
+
+void MEDCouplingBasicsTest::test3DInterpP0IntegralUniform()
+{
+ MEDCouplingUMesh *targetMesh=build3DTargetMesh_1();
+ INTERP_KERNEL::Interpolation3D myInterpolator;
+ MEDCouplingNormalizedUnstructuredMesh<3,3> targetWrapper(targetMesh);
+ vector<map<int,double> > res;
+ CPPUNIT_ASSERT_EQUAL(8,myInterpolator.fromIntegralUniform(targetWrapper,res,"P0"));
+ CPPUNIT_ASSERT_EQUAL(1,(int)res.size());
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(125000.,res[0][0],1e-6);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(375000.,res[0][1],1e-6);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(375000.,res[0][2],1e-6);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(1125000.,res[0][3],1e-6);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(375000.,res[0][4],1e-6);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(1125000.,res[0][5],1e-6);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(1125000.,res[0][6],1e-6);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(3375000.,res[0][7],1e-6);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(8000000.,sumAll(res),1e-6);
+ res.clear();
+ CPPUNIT_ASSERT_EQUAL(1,myInterpolator.toIntegralUniform(targetWrapper,res,"P0"));
+ CPPUNIT_ASSERT_EQUAL(8,(int)res.size());
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(125000.,res[0][0],1e-6);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(375000.,res[1][0],1e-6);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(375000.,res[2][0],1e-6);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(1125000.,res[3][0],1e-6);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(375000.,res[4][0],1e-6);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(1125000.,res[5][0],1e-6);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(1125000.,res[6][0],1e-6);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(3375000.,res[7][0],1e-6);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(8000000.,sumAll(res),1e-6);
+ res.clear();
+ targetMesh->decrRef();
+}
+
+void MEDCouplingBasicsTest::test2DInterpP1IntegralUniform()
+{
+ MEDCouplingUMesh *targetMesh=build2DSourceMesh_1();
+ //
+ MEDCouplingNormalizedUnstructuredMesh<2,2> targetWrapper(targetMesh);
+ INTERP_KERNEL::Interpolation2D myInterpolator;
+ vector<map<int,double> > res;
+ CPPUNIT_ASSERT_EQUAL(4,myInterpolator.fromIntegralUniform(targetWrapper,res,"P1"));
+ CPPUNIT_ASSERT_EQUAL(1,(int)res.size());
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(0.33333333333333331,res[0][0],1e-12);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(0.16666666666666666,res[0][1],1e-12);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(0.16666666666666666,res[0][2],1e-12);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(0.33333333333333331,res[0][3],1e-12);
+ res.clear();
+ CPPUNIT_ASSERT_EQUAL(1,myInterpolator.toIntegralUniform(targetWrapper,res,"P1"));
+ CPPUNIT_ASSERT_EQUAL(4,(int)res.size());
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(0.33333333333333331,res[0][0],1e-12);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(0.16666666666666666,res[1][0],1e-12);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(0.16666666666666666,res[2][0],1e-12);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(0.33333333333333331,res[3][0],1e-12);
+ res.clear();
+ targetMesh->decrRef();
+}
+
+void MEDCouplingBasicsTest::test3DInterpP1IntegralUniform()
+{
+ MEDCouplingUMesh *sourceMesh=build3DSourceMesh_1();
+ //
+ MEDCouplingNormalizedUnstructuredMesh<3,3> targetWrapper(sourceMesh);
+ INTERP_KERNEL::Interpolation3D myInterpolator;
+ vector<map<int,double> > res;
+ CPPUNIT_ASSERT_EQUAL(9,myInterpolator.fromIntegralUniform(targetWrapper,res,"P1"));
+ CPPUNIT_ASSERT_EQUAL(1,(int)res.size());
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(833333.333333333,res[0][0],1e-6);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(833333.333333333,res[0][1],1e-6);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(500000.,res[0][2],1e-6);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(833333.333333333,res[0][3],1e-6);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(833333.333333333,res[0][4],1e-6);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(500000.,res[0][5],1e-6);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(833333.333333333,res[0][6],1e-6);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(833333.333333333,res[0][7],1e-6);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(2000000.,res[0][8],1e-6);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(8000000.,sumAll(res),1e-6);
+ res.clear();
+ CPPUNIT_ASSERT_EQUAL(1,myInterpolator.toIntegralUniform(targetWrapper,res,"P1"));
+ CPPUNIT_ASSERT_EQUAL(9,(int)res.size());
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(833333.333333333,res[0][0],1e-6);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(833333.333333333,res[1][0],1e-6);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(500000.,res[2][0],1e-6);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(833333.333333333,res[3][0],1e-6);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(833333.333333333,res[4][0],1e-6);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(500000.,res[5][0],1e-6);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(833333.333333333,res[6][0],1e-6);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(833333.333333333,res[7][0],1e-6);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(2000000.,res[8][0],1e-6);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(8000000.,sumAll(res),1e-6);
+ sourceMesh->decrRef();
+}
+
MEDCouplingUMesh *MEDCouplingBasicsTest::build2DSourceMesh_1()
{
double sourceCoords[8]={-0.3,-0.3, 0.7,-0.3, -0.3,0.7, 0.7,0.7};
return targetMesh;
}
+MEDCouplingUMesh *MEDCouplingBasicsTest::build2DTargetMeshPerm_1()
+{
+ double targetCoords[18]={-0.3,-0.3, 0.2,-0.3, 0.7,-0.3, -0.3,0.2, 0.2,0.2, 0.7,0.2, -0.3,0.7, 0.2,0.7, 0.7,0.7 };
+ int targetConn[18]={0,3,4,1, 1,2,4, 4,5,2, 6,7,4,3, 7,8,5,4};
+ MEDCouplingUMesh *targetMesh=MEDCouplingUMesh::New();
+ targetMesh->setMeshDimension(2);
+ targetMesh->allocateCells(5);
+ targetMesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,targetConn);
+ targetMesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,targetConn+4);
+ targetMesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,targetConn+7);
+ targetMesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,targetConn+10);
+ targetMesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,targetConn+14);
+ targetMesh->finishInsertingCells();
+ DataArrayDouble *myCoords=DataArrayDouble::New();
+ myCoords->alloc(9,2);
+ std::copy(targetCoords,targetCoords+18,myCoords->getPointer());
+ targetMesh->setCoords(myCoords);
+ myCoords->decrRef();
+ return targetMesh;
+}
+
MEDCouplingUMesh *MEDCouplingBasicsTest::build2DTargetMesh_2()
{
double targetCoords[18]={-0.3,-0.3, 0.2,-0.3, 0.7,-0.3, -0.3,0.2, 0.2,0.2, 0.7,0.2, -0.3,0.7, 0.2,0.7, 0.7,0.7 };
CPPUNIT_TEST( test3DInterpP0P1_1 );
CPPUNIT_TEST( test3DInterpP1P0_1 );
CPPUNIT_TEST( test3DInterpP0P0Empty );
+ CPPUNIT_TEST( test2DInterpP0IntegralUniform );
+ CPPUNIT_TEST( test3DSurfInterpP0IntegralUniform );
+ CPPUNIT_TEST( test3DInterpP0IntegralUniform );
+ CPPUNIT_TEST( test2DInterpP1IntegralUniform );
+ CPPUNIT_TEST( test3DInterpP1IntegralUniform );
CPPUNIT_TEST_SUITE_END();
public:
void testArray();
void test3DInterpP0P1_1();
void test3DInterpP1P0_1();
void test3DInterpP0P0Empty();
+ void test2DInterpP0IntegralUniform();
+ void test3DSurfInterpP0IntegralUniform();
+ void test3DInterpP0IntegralUniform();
+ void test2DInterpP1IntegralUniform();
+ void test3DInterpP1IntegralUniform();
private:
MEDCouplingUMesh *build2DSourceMesh_1();
MEDCouplingUMesh *build2DTargetMesh_1();
+ MEDCouplingUMesh *build2DTargetMeshPerm_1();
MEDCouplingUMesh *build2DTargetMesh_2();
MEDCouplingUMesh *build3DSurfSourceMesh_1();
MEDCouplingUMesh *build3DSurfSourceMesh_2();
\f]
*/
- void DEC::renormalizeTargetField()
+ void DEC::renormalizeTargetField(bool isWAbs)
{
if (_source_group->containsMyRank())
for (int icomp=0; icomp<_local_field->getField()->getArray()->getNumberOfComponents(); icomp++)
{
- double total_norm = _local_field->getVolumeIntegral(icomp+1);
+ double total_norm = _local_field->getVolumeIntegral(icomp+1,isWAbs);
double source_norm = total_norm;
_comm_interface->broadcast(&source_norm, 1, MPI_DOUBLE, 0,* dynamic_cast<MPIProcessorGroup*>(_union_group)->getComm());
{
for (int icomp=0; icomp<_local_field->getField()->getArray()->getNumberOfComponents(); icomp++)
{
- double total_norm = _local_field->getVolumeIntegral(icomp+1);
+ double total_norm = _local_field->getVolumeIntegral(icomp+1,isWAbs);
double source_norm=total_norm;
_comm_interface->broadcast(&source_norm, 1, MPI_DOUBLE, 0,* dynamic_cast<MPIProcessorGroup*>(_union_group)->getComm());
virtual void synchronize()=0;
virtual ~DEC();
virtual void computeProcGroup() { }
- void renormalizeTargetField();
+ void renormalizeTargetField(bool isWAbs);
protected:
void compareFieldAndMethod() const throw(INTERP_KERNEL::Exception);
protected:
{
_interpolation_matrix->multiply(*_local_field->getField());
if (getForcedRenormalization())
- renormalizeTargetField();
+ renormalizeTargetField(getMeasureAbsStatus());
}
}
_interpolation_matrix->multiply(*_local_field->getField());
if (getForcedRenormalization())
- renormalizeTargetField();
+ renormalizeTargetField(getMeasureAbsStatus());
}
else if (_target_group->containsMyRank())
MEDCouplingFieldDouble *target_triangle_surf=0;
if(needTargetSurf)
- target_triangle_surf = distant_support.getMeasureField();
+ target_triangle_surf = distant_support.getMeasureField(getMeasureAbsStatus());
fillDSFromVM(iproc_distant,distant_elems,surfaces,target_triangle_surf);
if(needTargetSurf)
void InterpolationMatrix::computeIntegralDenoW(ElementLocator& elementLocator)
{
- MEDCouplingFieldDouble *source_triangle_surf = _source_support->getMeasureField();
+ MEDCouplingFieldDouble *source_triangle_surf = _source_support->getMeasureField(getMeasureAbsStatus());
_deno_multiply.resize(_coeffs.size());
vector<vector<double> >::iterator iter6=_deno_multiply.begin();
const double *values=source_triangle_surf->getArray()->getConstPointer();
/*! This method retrieves the integral of component \a icomp
over the all domain. */
- double ParaFIELD::getVolumeIntegral(int icomp) const
+ double ParaFIELD::getVolumeIntegral(int icomp, bool isWAbs) const
{
CommInterface comm_interface = _topology->getProcGroup()->getCommInterface();
- double integral=_field->measureAccumulate(icomp);
+ double integral=_field->measureAccumulate(icomp,isWAbs);
double total=0.;
const MPI_Comm* comm = (dynamic_cast<const MPIProcessorGroup*>(_topology->getProcGroup()))->getComm();
comm_interface.allReduce(&integral, &total, 1, MPI_DOUBLE, MPI_SUM, *comm);
Topology* getTopology() const { return _topology; }
ParaMESH* getSupport() const { return _support; }
int nbComponents() const;
- double getVolumeIntegral(int icomp) const;
+ double getVolumeIntegral(int icomp, bool isWAbs) const;
double getL2Norm()const { return -1; }
private:
MEDCouplingFieldDouble* _field;
if (source_group->containsMyRank())
{
- field_before_int = parafield->getVolumeIntegral(0);
+ field_before_int = parafield->getVolumeIntegral(0,true);
dec.synchronize();
cout<<"DEC usage"<<endl;
dec.setForcedRenormalization(false);
filename<<"./sourcesquare_"<<source_group->myRank()+1;
aRemover.Register(filename.str().c_str());
- field_after_int = parafield->getVolumeIntegral(0);
+ field_after_int = parafield->getVolumeIntegral(0,true);
// MPI_Bcast(&field_before_int,1,MPI_DOUBLE,0,MPI_COMM_WORLD);
if (source_group->containsMyRank())
{
- field_before_int = parafield->getVolumeIntegral(0);
+ field_before_int = parafield->getVolumeIntegral(0,true);
dec.synchronize();
cout<<"DEC usage"<<endl;
dec.setForcedRenormalization(false);
filename<<"./sourcesquare_"<<source_group->myRank()+1;
aRemover.Register(filename.str().c_str());
- field_after_int = parafield->getVolumeIntegral(0);
+ field_after_int = parafield->getVolumeIntegral(0,true);
CPPUNIT_ASSERT_DOUBLES_EQUAL(field_before_int, field_after_int, 1e-6);
cout << "testAsynchronousInterpKernelDEC_2D" << rank << " time " << time
<< " dtB " << dtB << " tmaxB " << tmaxB << endl ;
dec.recvData( time );
- double vi = parafield->getVolumeIntegral(0);
+ double vi = parafield->getVolumeIntegral(0,true);
cout << "testAsynchronousInterpKernelDEC_2D" << rank << " time " << time
<< " VolumeIntegral " << vi
<< " time*10000 " << time*10000 << endl ;
double field_after_int;
if (source_group->containsMyRank()){
- field_before_int = parafield->getVolumeIntegral(0);
+ field_before_int = parafield->getVolumeIntegral(0,true);
get_time( &telps, &tcpu_u, &tcpu_s, &tcpu );
dec.synchronize();
get_time( &telps, &tcpu_u, &tcpu_s, &tcpu );
cout << "SEND DATA : Telapse = " << telps << " TuserCPU = " << tcpu_u << " TsysCPU = " << tcpu_s << " TCPU = " << tcpu << endl;
dec.recvData();
- field_after_int = parafield->getVolumeIntegral(0);
+ field_after_int = parafield->getVolumeIntegral(0,true);
// CPPUNIT_ASSERT_DOUBLES_EQUAL(field_before_int, field_after_int, epsilon);
}