From 55a1a2f772ed6b339fd5bca490a486042c2a1805 Mon Sep 17 00:00:00 2001 From: vbd Date: Wed, 24 Sep 2008 14:27:16 +0000 Subject: [PATCH] adding OptionManager --- src/INTERP_KERNEL/Interpolation3D.hxx | 7 ++-- src/INTERP_KERNEL/Interpolation3D.txx | 8 +++-- src/INTERP_KERNEL/Interpolation3DSurf.hxx | 2 +- src/INTERP_KERNEL/Interpolation3DSurf.txx | 3 ++ src/INTERP_KERNEL/InterpolationPlanar.hxx | 3 +- src/INTERP_KERNEL/InterpolationPlanar.txx | 5 +-- src/INTERP_KERNEL/IntersectorHexa.hxx | 17 ++++++---- src/ParaMEDMEM/DEC.cxx | 13 ++++++++ src/ParaMEDMEM/DEC.hxx | 4 +-- src/ParaMEDMEM/ElementLocator.hxx | 4 +-- src/ParaMEDMEM/InterpolationMatrix.cxx | 14 ++++++-- src/ParaMEDMEM/InterpolationMatrix.hxx | 6 ++-- src/ParaMEDMEM/IntersectionDEC.cxx | 40 +++++++++++++++-------- src/ParaMEDMEM/IntersectionDEC.hxx | 16 +++++++-- 14 files changed, 102 insertions(+), 40 deletions(-) diff --git a/src/INTERP_KERNEL/Interpolation3D.hxx b/src/INTERP_KERNEL/Interpolation3D.hxx index e93d42482..5584b898f 100644 --- a/src/INTERP_KERNEL/Interpolation3D.hxx +++ b/src/INTERP_KERNEL/Interpolation3D.hxx @@ -3,15 +3,18 @@ #include "Interpolation.hxx" #include "NormalizedUnstructuredMesh.hxx" - +#include "IntersectorHexa.hxx" +#include "OptionManager.hxx" namespace INTERP_KERNEL { - class Interpolation3D : public Interpolation + class Interpolation3D : public Interpolation,OptionManager { public: Interpolation3D(); template void interpolateMeshes(const MyMeshType& srcMesh, const MyMeshType& targetMesh, MatrixType& result); + private: + SplittingPolicy _splitting_policy; }; } diff --git a/src/INTERP_KERNEL/Interpolation3D.txx b/src/INTERP_KERNEL/Interpolation3D.txx index 135bd9d75..a1654cb69 100644 --- a/src/INTERP_KERNEL/Interpolation3D.txx +++ b/src/INTERP_KERNEL/Interpolation3D.txx @@ -7,7 +7,7 @@ #include "IntersectorTetra.txx" #include "IntersectorHexa.txx" #include "Log.hxx" - +#include "OptionManager.hxx" /// If defined, use recursion to traverse the binary search tree, else use the BBTree class #define USE_RECURSIVE_BBOX_FILTER @@ -36,6 +36,7 @@ namespace INTERP_KERNEL */ Interpolation3D::Interpolation3D() { + registerOption(&_splitting_policy,"SplittingPolicy",GENERAL_48); } /** @@ -162,7 +163,10 @@ namespace INTERP_KERNEL break; case 8: - intersector = new IntersectorHexa(srcMesh, targetMesh, targetIdx); + + SplittingPolicy sp; + getOption("SplittingPolicy",sp); + intersector = new IntersectorHexa(srcMesh, targetMesh, targetIdx,sp); break; default: diff --git a/src/INTERP_KERNEL/Interpolation3DSurf.hxx b/src/INTERP_KERNEL/Interpolation3DSurf.hxx index 2c2eb107d..f6c884c72 100644 --- a/src/INTERP_KERNEL/Interpolation3DSurf.hxx +++ b/src/INTERP_KERNEL/Interpolation3DSurf.hxx @@ -2,7 +2,7 @@ #define __INTERPOLATION3DSURF_HXX__ #include "InterpolationPlanar.hxx" - +#include "OptionManager.hxx" namespace INTERP_KERNEL { class Interpolation3DSurf : public InterpolationPlanar diff --git a/src/INTERP_KERNEL/Interpolation3DSurf.txx b/src/INTERP_KERNEL/Interpolation3DSurf.txx index f51e1eb55..b9e14f57f 100644 --- a/src/INTERP_KERNEL/Interpolation3DSurf.txx +++ b/src/INTERP_KERNEL/Interpolation3DSurf.txx @@ -13,6 +13,9 @@ namespace INTERP_KERNEL ,_medianPlane(DFT_MEDIAN_PLANE) ,_surf3DAdjustmentEps(DFT_SURF3D_ADJ_EPS) { + registerOption(&_medianPlane,"MedianPlane",DFT_MEDIAN_PLANE); + registerOption(&_doRotate,"DoRotate",true); + registerOption(&_surf3DAdjustmentEps,"BoundingBoxAdjustment",DFT_SURF3D_ADJ_EPS); } /** diff --git a/src/INTERP_KERNEL/InterpolationPlanar.hxx b/src/INTERP_KERNEL/InterpolationPlanar.hxx index e1db1e4b1..22307e8b3 100755 --- a/src/INTERP_KERNEL/InterpolationPlanar.hxx +++ b/src/INTERP_KERNEL/InterpolationPlanar.hxx @@ -4,13 +4,14 @@ #include "Interpolation.hxx" #include "PlanarIntersector.hxx" #include "NormalizedUnstructuredMesh.hxx" +#include "OptionManager.hxx" namespace INTERP_KERNEL { typedef enum {Triangulation, Convex, Geometric2D, Generic} IntersectionType; template - class InterpolationPlanar : public Interpolation< InterpolationPlanar > + class InterpolationPlanar : public Interpolation< InterpolationPlanar >, public OptionManager { private: int _printLevel; diff --git a/src/INTERP_KERNEL/InterpolationPlanar.txx b/src/INTERP_KERNEL/InterpolationPlanar.txx index b2d2ade7a..3aa78b5c3 100644 --- a/src/INTERP_KERNEL/InterpolationPlanar.txx +++ b/src/INTERP_KERNEL/InterpolationPlanar.txx @@ -10,8 +10,6 @@ #include "ConvexIntersector.txx" #include "Geometric2DIntersector.hxx" #include "Geometric2DIntersector.txx" -//#include "GenericIntersector.hxx" -//#include "GenericIntersector.cxx" #include "VectorUtils.hxx" #include "BBTree.txx" #include @@ -33,6 +31,9 @@ namespace INTERP_KERNEL InterpolationPlanar::InterpolationPlanar():_printLevel(0),_precision(DEFAULT_PRECISION),_dimCaracteristic(1), _intersectionType(Triangulation) { + registerOption(&_precision, "Precision",DEFAULT_PRECISION); + registerOption(&_intersectionType, "IntersectionType",Triangulation); + registerOption(&_printLevel, "PrintLevel",0); } /** diff --git a/src/INTERP_KERNEL/IntersectorHexa.hxx b/src/INTERP_KERNEL/IntersectorHexa.hxx index 9105dafbc..b50e3552c 100644 --- a/src/INTERP_KERNEL/IntersectorHexa.hxx +++ b/src/INTERP_KERNEL/IntersectorHexa.hxx @@ -4,25 +4,28 @@ #include "TargetIntersector.hxx" #include "IntersectorTetra.hxx" #include "NormalizedUnstructuredMesh.hxx" - +#include "OptionManager.hxx" namespace INTERP_KERNEL { + + /// Type describing the different ways in which the hexahedron can be split into tetrahedra. + /// The PLANAR_* policies persume that each face is to be considered planar, while the general + /// policies make no such hypothesis. The integer at the end gives the number of tetrahedra + /// that result from the split. + enum SplittingPolicy { PLANAR_FACE_5 = 5, PLANAR_FACE_6 = 6, GENERAL_24 = 24, GENERAL_48 = 48 }; + /** * \brief Class responsible for calculating intersection between a hexahedron target element and * the source elements. * */ template - class IntersectorHexa : public TargetIntersector + class IntersectorHexa : public TargetIntersector, public OptionManager { public: - /// Type describing the different ways in which the hexahedron can be split into tetrahedra. - /// The PLANAR_* policies persume that each face is to be considered planar, while the general - /// policies make no such hypothesis. The integer at the end gives the number of tetrahedra - /// that result from the split. - enum SplittingPolicy { PLANAR_FACE_5 = 5, PLANAR_FACE_6 = 6, GENERAL_24 = 24, GENERAL_48 = 48 }; + IntersectorHexa(const MyMeshType& srcMesh, const MyMeshType& targetMesh, typename MyMeshType::MyConnType targetCell, SplittingPolicy policy = GENERAL_24); diff --git a/src/ParaMEDMEM/DEC.cxx b/src/ParaMEDMEM/DEC.cxx index 315a971d2..84e694f9a 100644 --- a/src/ParaMEDMEM/DEC.cxx +++ b/src/ParaMEDMEM/DEC.cxx @@ -31,6 +31,19 @@ * ForcedRenormalizationAfter receiving data, the target field is renormalized so that L2-norms of the source and target fields match. false * + +The following code excerpt shows how to set options for an object that inherits from DEC : + +\code + IntersectionDEC dec(local_group,distant_group); + dec.setOptions("ForcedRenormalization",true); + dec.attachLocalField(field); + dec.synchronize(); + if (local_group.containsMyRank()) + dec.sendData(); + else + dec.recvData(); +\endcode */ namespace ParaMEDMEM diff --git a/src/ParaMEDMEM/DEC.hxx b/src/ParaMEDMEM/DEC.hxx index 02f8666ff..6c627a067 100644 --- a/src/ParaMEDMEM/DEC.hxx +++ b/src/ParaMEDMEM/DEC.hxx @@ -1,7 +1,7 @@ #ifndef DEC_HXX_ #define DEC_HXX_ -#include "MEDMEM_OptionManager.hxx" +#include "OptionManager.hxx" #include #include @@ -15,7 +15,7 @@ namespace ParaMEDMEM class ProcessorGroup; class ParaFIELD; class CommInterface; - class DEC : public MEDMEM::OptionManager + class DEC : public INTERP_KERNEL::OptionManager { public: DEC():_local_field(0),_forced_renormalization_flag(false){} diff --git a/src/ParaMEDMEM/ElementLocator.hxx b/src/ParaMEDMEM/ElementLocator.hxx index 2423cfb36..5345db3cd 100644 --- a/src/ParaMEDMEM/ElementLocator.hxx +++ b/src/ParaMEDMEM/ElementLocator.hxx @@ -3,7 +3,7 @@ #include #include -#include "MEDMEM_OptionManager.hxx" +#include "OptionManager.hxx" namespace MEDMEM { @@ -17,7 +17,7 @@ class ParaSUPPORT; class InterpolationMatrix; - class ElementLocator: public MEDMEM::OptionManager + class ElementLocator: public INTERP_KERNEL::OptionManager { public: ElementLocator(const ParaMESH& mesh, const ProcessorGroup& distant_group); diff --git a/src/ParaMEDMEM/InterpolationMatrix.cxx b/src/ParaMEDMEM/InterpolationMatrix.cxx index 6a55b6abc..0bf7d7c0a 100644 --- a/src/ParaMEDMEM/InterpolationMatrix.cxx +++ b/src/ParaMEDMEM/InterpolationMatrix.cxx @@ -33,10 +33,10 @@ InterpolationMatrix::InterpolationMatrix( const ParaMEDMEM::ParaMESH& source_support, const ProcessorGroup& source_group, const ProcessorGroup& target_group, -const string& method): +const OptionManager& option_manager): + OptionManager(option_manager), _source_support(*source_support.getMesh()), _mapping(source_group, target_group), - _method(method), _source_group(source_group), _target_group(target_group), _source_volume(0) @@ -86,6 +86,16 @@ void InterpolationMatrix::addContribution(MEDMEM::MESH& distant_support, int ipr MEDNormalizedUnstructuredMesh<3,2>target_wrapper(&distant_support); MEDNormalizedUnstructuredMesh<3,2> source_wrapper(&_source_support); INTERP_KERNEL::Interpolation3DSurf interpolator; + double precision, median_plane; + int print_level; + INTERP_KERNEL::IntersectionType inter_type; + bool do_rotate; + getOption("DoRotate",do_rotate); + getOption("Precision",precision); + getOption("MedianPlane",median_plane); + getOption("PrintLevel",print_level); + getOption("IntersectionType",inter_type); + interpolator.setOptions(precision,print_level,median_plane,inter_type,do_rotate); interpolator.interpolateMeshes(target_wrapper,source_wrapper,surfaces); } else if (distant_support.getMeshDimension()==2 && distant_support.getSpaceDimension()==2) diff --git a/src/ParaMEDMEM/InterpolationMatrix.hxx b/src/ParaMEDMEM/InterpolationMatrix.hxx index 642783581..bc55d9a78 100644 --- a/src/ParaMEDMEM/InterpolationMatrix.hxx +++ b/src/ParaMEDMEM/InterpolationMatrix.hxx @@ -4,17 +4,17 @@ #include "MEDMEM_Field.hxx" #include "MPI_AccessDEC.hxx" #include "MxN_Mapping.hxx" - +#include "OptionManager.hxx" namespace ParaMEDMEM { - class InterpolationMatrix + class InterpolationMatrix : public INTERP_KERNEL::OptionManager { public: InterpolationMatrix(const ParaMEDMEM::ParaMESH& source_support, const ProcessorGroup& local_group, const ProcessorGroup& distant_group, - const string& method); + const INTERP_KERNEL::OptionManager& option_manager); virtual ~InterpolationMatrix(); void addContribution(MEDMEM::MESH& distant_support, int iproc_distant, int* distant_elems); diff --git a/src/ParaMEDMEM/IntersectionDEC.cxx b/src/ParaMEDMEM/IntersectionDEC.cxx index ace1f9f04..3a88d4c54 100644 --- a/src/ParaMEDMEM/IntersectionDEC.cxx +++ b/src/ParaMEDMEM/IntersectionDEC.cxx @@ -7,12 +7,12 @@ #include "MPIProcessorGroup.hxx" #include "ParaMESH.hxx" #include "ParaSUPPORT.hxx" -#include "MEDMEM_OptionManager.hxx" +#include "OptionManager.hxx" #include "DEC.hxx" #include "InterpolationMatrix.hxx" #include "IntersectionDEC.hxx" #include "ElementLocator.hxx" -#include "MEDMEM_OptionManager.hxx" +#include "OptionManager.hxx" namespace ParaMEDMEM @@ -66,16 +66,24 @@ In the P0-P0 case, this matrix is a plain rectangular matrix with coefficients e -/* \section intersectiondec_options Options - * On top of \ref dec_options, options supported by IntersectionDEC objects are - * - * - * - * - - *
OptionDescriptionDefault value
BoundingBoxAdjustmentWhen detecting an intersection between bounding boxes, the bounding are expanded by a factor (1+BoundingBoxAdjustment). It is particularly useful when detecting intersections for 3D surfaces for which the bounding boxes might not actually intersect. 0.1
MethodSpecifies the field representation used for the remapping.P0
- + \section intersectiondec_options Options + On top of \ref dec_options, options supported by %IntersectionDEC objects are + related to the underlying Intersector class. + All the options available in the intersector objects are + available for the %IntersectionDEC object. The various options available for * intersectors can be reviewed in \ref InterpKerIntersectors. + + For instance : + \verbatim + IntersectionDEC dec(source_group, target_group); + dec.attachLocalField(field); + dec.setOptions("DoRotate",false); + dec.setOptions("Precision",1e-12); + dec.synchronize(); + \endverbatim + + \warning{ Options must be set before calling the synchronize method. } */ + /*! \addtogroup intersectiondec @{ @@ -99,7 +107,13 @@ IntersectionDEC::IntersectionDEC(ProcessorGroup& local_group, ProcessorGroup& di { registerOption(&_method,string("Method"),string("P0")); registerOption(&_bb_adjustment, "BoundingBoxAdjustment",0.1); + registerOption(&_intersection_type, "IntersectionType",INTERP_KERNEL::Triangulation); + registerOption(&_precision, "Precision", 1e-12); + registerOption(&_median_plane, "MedianPlane",0.5); + registerOption(&_do_rotate, "DoRotate",true); registerOption(&_asynchronous, "Asynchronous",false); + registerOption(&_splitting_policy, "SplittingPolicy",INTERP_KERNEL::GENERAL_48); + registerOption(&_print_level,"PrintLevel",0); registerOption(&_timeinterpolationmethod,"TimeInterpolation",WithoutTimeInterp); registerOption(&_allToAllMethod,"AllToAllMethod",Native); } @@ -127,7 +141,7 @@ void IntersectionDEC::synchronize() { const ParaMEDMEM::ParaMESH* para_mesh = _local_field->getSupport()->getMesh(); //cout <<"size of Interpolation Matrix"<setAllToAllMethod(_allToAllMethod); _interpolation_matrix->getAccessDEC()->Asynchronous( _asynchronous ) ; _interpolation_matrix->getAccessDEC()->SetTimeInterpolator( _timeinterpolationmethod ) ; @@ -174,7 +188,7 @@ void IntersectionDEC::synchronize() ElementLocator locator(*para_mesh, *_source_group); //transfering option from IntersectionDEC to ElementLocator double bb_adj; - MEDMEM::OptionManager::getOption("BoundingBoxAdjustment",bb_adj); + INTERP_KERNEL::OptionManager::getOption("BoundingBoxAdjustment",bb_adj); locator.setOption("BoundingBoxAdjustment",bb_adj); MESH* distant_mesh=0; diff --git a/src/ParaMEDMEM/IntersectionDEC.hxx b/src/ParaMEDMEM/IntersectionDEC.hxx index 5133c9e94..09ec5067f 100644 --- a/src/ParaMEDMEM/IntersectionDEC.hxx +++ b/src/ParaMEDMEM/IntersectionDEC.hxx @@ -1,12 +1,14 @@ #ifndef INTERSECTIONDEC_HXX_ #define INTERSECTIONDEC_HXX_ -#include "MEDMEM_OptionManager.hxx" +#include "DEC.hxx" #include "MPI_AccessDEC.hxx" #include "MxN_Mapping.hxx" +#include "InterpolationPlanar.hxx" +#include "IntersectorHexa.hxx" + namespace ParaMEDMEM { - class DEC; class InterpolationMatrix; class IntersectionDEC:public DEC @@ -45,11 +47,19 @@ namespace ParaMEDMEM InterpolationMatrix* _interpolation_matrix; + //options double _bb_adjustment; - bool _asynchronous; TimeInterpolationMethod _timeinterpolationmethod ; AllToAllMethod _allToAllMethod; + INTERP_KERNEL::IntersectionType _intersection_type; + double _precision; + double _median_plane; + bool _do_rotate; + INTERP_KERNEL::SplittingPolicy _splitting_policy; + int _print_level; + + }; } -- 2.39.2