1 // Copyright (C) 2007-2012 CEA/DEN, EDF R&D
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 // Author : Anthony Geay (CEA/DEN)
20 #ifndef __INTERPOLATION_TXX__
21 #define __INTERPOLATION_TXX__
23 #include "Interpolation.hxx"
24 #include "IntegralUniformIntersector.hxx"
25 #include "IntegralUniformIntersector.txx"
26 #include "VectorUtils.hxx"
28 namespace INTERP_KERNEL
30 template<class TrueMainInterpolator>
31 template<class MyMeshType, class MatrixType>
32 int Interpolation<TrueMainInterpolator>::fromToIntegralUniform(bool fromTo, const MyMeshType& mesh, MatrixType& result, const char *method)
34 typedef typename MyMeshType::MyConnType ConnType;
35 std::string methodCPP(method);
39 IntegralUniformIntersectorP0<MyMeshType,MatrixType> intersector(mesh,InterpolationOptions::getMeasureAbsStatus());
40 intersector.setFromTo(fromTo);
41 std::vector<ConnType> tmp;
42 intersector.intersectCells(0,tmp,result);
43 ret=intersector.getNumberOfColsOfResMatrix();
45 else if(methodCPP=="P1")
47 IntegralUniformIntersectorP1<MyMeshType,MatrixType> intersector(mesh,InterpolationOptions::getMeasureAbsStatus());
48 intersector.setFromTo(fromTo);
49 std::vector<ConnType> tmp;
50 intersector.intersectCells(0,tmp,result);
51 ret=intersector.getNumberOfColsOfResMatrix();
54 throw INTERP_KERNEL::Exception("Invalid method specified in fromIntegralUniform : must be in { \"P0\", \"P1\"}");
58 template<class TrueMainInterpolator>
59 void Interpolation<TrueMainInterpolator>::CheckAndSplitInterpolationMethod(const char *method, std::string& srcMeth, std::string& trgMeth) throw(INTERP_KERNEL::Exception)
61 const int NB_OF_METH_MANAGED=4;
62 const char *METH_MANAGED[NB_OF_METH_MANAGED]={"P0P0","P0P1","P1P0","P1P1"};
63 std::string methodC(method);
65 for(int i=0;i<NB_OF_METH_MANAGED && !found;i++)
66 found=(methodC==METH_MANAGED[i]);
69 std::string msg("The interpolation method : \'"); msg+=method; msg+="\' not managed by INTERP_KERNEL interpolators ! Supported are \"P0P0\", \"P0P1\", \"P1P0\" and \"P1P1\".";
70 throw INTERP_KERNEL::Exception(msg.c_str());
72 srcMeth=methodC.substr(0,2);
73 trgMeth=methodC.substr(2);
76 template<class TrueMainInterpolator>
77 template<class MyMeshType>
78 double Interpolation<TrueMainInterpolator>::CalculateCharacteristicSizeOfMeshes(const MyMeshType& myMeshS, const MyMeshType& myMeshT, const int printLevel)
80 static const int SPACEDIM=MyMeshType::MY_SPACEDIM;
82 long nbMailleS=myMeshS.getNumberOfElements();
83 long nbMailleT=myMeshT.getNumberOfElements();
85 /**************************************************/
86 /* Search the characteristic size of the meshes */
87 /**************************************************/
89 double BoxS[2*SPACEDIM]; myMeshS.getBoundingBox(BoxS);
90 double BoxT[2*SPACEDIM]; myMeshT.getBoundingBox(BoxT);
91 double diagonalS,dimCaracteristicS=std::numeric_limits<double>::max();
94 diagonalS=getDistanceBtw2Pts<SPACEDIM>(BoxS+SPACEDIM,BoxS);
95 dimCaracteristicS=diagonalS/nbMailleS;
97 double diagonalT,dimCaracteristicT=std::numeric_limits<double>::max();
100 diagonalT=getDistanceBtw2Pts<SPACEDIM>(BoxT+SPACEDIM,BoxT);
101 dimCaracteristicT=diagonalT/nbMailleT;
105 std::cout << " - Characteristic size of the source mesh : " << dimCaracteristicS << std::endl;
106 std::cout << " - Characteristic size of the target mesh: " << dimCaracteristicT << std::endl;
109 return std::min(dimCaracteristicS, dimCaracteristicT);