From f5ad0bcb9f31cd97002b116e4ebbeed327cec9ff Mon Sep 17 00:00:00 2001 From: ageay Date: Wed, 27 Jan 2010 14:56:34 +0000 Subject: [PATCH] *** empty log message *** --- src/ParaMEDMEM/DEC.cxx | 9 +- src/ParaMEDMEM/ParaFIELD.cxx | 14 +- src/ParaMEDMEM/ParaFIELD.hxx | 8 +- src/ParaMEDMEM/Test/ParaMEDMEMTest.hxx | 3 + .../Test/ParaMEDMEMTest_InterpKernelDEC.cxx | 173 +++++++++++++++++- 5 files changed, 187 insertions(+), 20 deletions(-) diff --git a/src/ParaMEDMEM/DEC.cxx b/src/ParaMEDMEM/DEC.cxx index 8bb1f2d27..fe0d2f874 100644 --- a/src/ParaMEDMEM/DEC.cxx +++ b/src/ParaMEDMEM/DEC.cxx @@ -21,6 +21,7 @@ #include "BlockTopology.hxx" #include "ComponentTopology.hxx" #include "ParaFIELD.hxx" +#include "ParaMESH.hxx" #include "DEC.hxx" #include "ICoCoField.hxx" #include "ICoCoMEDField.hxx" @@ -128,10 +129,12 @@ namespace ParaMEDMEM local_group=_target_group; else throw INTERP_KERNEL::Exception("Invalid procgroup for field attachment to DEC"); - - _local_field= new ParaFIELD(field, *local_group); + ParaMESH *paramesh=new ParaMESH((MEDCouplingPointSet *)field->getMesh(),*local_group,field->getMesh()->getName()); + _local_field = new ParaFIELD(field, paramesh, *local_group); _owns_field=true; - _comm_interface=&(local_group->getCommInterface()); + _local_field->setOwnSupport(true); + attachLocalField(_local_field); + //_comm_interface=&(local_group->getCommInterface()); } /*! diff --git a/src/ParaMEDMEM/ParaFIELD.cxx b/src/ParaMEDMEM/ParaFIELD.cxx index 10fc964aa..a0fb5695b 100644 --- a/src/ParaMEDMEM/ParaFIELD.cxx +++ b/src/ParaMEDMEM/ParaFIELD.cxx @@ -64,7 +64,7 @@ namespace ParaMEDMEM */ ParaFIELD::ParaFIELD(TypeOfField type, TypeOfTimeDiscretization td, ParaMESH* para_support, const ComponentTopology& component_topology) :_field(0), - _component_topology(component_topology),_topology(0), + _component_topology(component_topology),_topology(0),_own_support(false), _support(para_support) { if (para_support->isStructured() || (para_support->getTopology()->getProcGroup()->size()==1 && component_topology.nbBlocks()!=1)) @@ -105,21 +105,23 @@ namespace ParaMEDMEM This constructor supposes that support underlying \a subdomain_field has no ParaSUPPORT attached and it therefore recreates one. It therefore takes ownership over _support. The component topology associated with the field is a basic one (all components on the same processor). */ - ParaFIELD::ParaFIELD(MEDCouplingFieldDouble* subdomain_field, const ProcessorGroup& proc_group): + ParaFIELD::ParaFIELD(MEDCouplingFieldDouble* subdomain_field, ParaMESH *sup, const ProcessorGroup& proc_group): _field(subdomain_field), - _component_topology(ComponentTopology(_field->getNumberOfComponents())),_topology(0), - _support() + _component_topology(ComponentTopology(_field->getNumberOfComponents())),_topology(0),_own_support(false), + _support(sup) { if(_field) _field->incrRef(); - const ExplicitTopology* source_topo=dynamic_cast (_support->getTopology()); - _topology=new ExplicitTopology(*source_topo,_component_topology.nbLocalComponents()); + const BlockTopology* source_topo=dynamic_cast (_support->getTopology()); + _topology=new BlockTopology(*source_topo,_component_topology.nbLocalComponents()); } ParaFIELD::~ParaFIELD() { if(_field) _field->decrRef(); + if(_own_support) + delete _support; delete _topology; } diff --git a/src/ParaMEDMEM/ParaFIELD.hxx b/src/ParaMEDMEM/ParaFIELD.hxx index 3bd12d476..08229a837 100644 --- a/src/ParaMEDMEM/ParaFIELD.hxx +++ b/src/ParaMEDMEM/ParaFIELD.hxx @@ -20,6 +20,7 @@ #define __PARAFIELD_HXX__ #include "MEDCouplingRefCountObject.hxx" +#include "ComponentTopology.hxx" namespace ParaMEDMEM { @@ -37,12 +38,13 @@ namespace ParaMEDMEM ParaFIELD(TypeOfField type, TypeOfTimeDiscretization td, ParaMESH* mesh, const ComponentTopology& component_topology); - ParaFIELD(MEDCouplingFieldDouble* field, const ProcessorGroup& group); + ParaFIELD(MEDCouplingFieldDouble* field, ParaMESH *sup, const ProcessorGroup& group); virtual ~ParaFIELD(); void synchronizeTarget( ParaMEDMEM::ParaFIELD* source_field); void synchronizeSource( ParaMEDMEM::ParaFIELD* target_field); MEDCouplingFieldDouble* getField() const { return _field; } + void setOwnSupport(bool v) const { _own_support=v; } DataArrayInt* returnCumulativeGlobalNumbering() const; DataArrayInt* returnGlobalNumbering() const; Topology* getTopology() const { return _topology; } @@ -52,9 +54,9 @@ namespace ParaMEDMEM double getL2Norm()const { return -1; } private: MEDCouplingFieldDouble* _field; - const ParaMEDMEM::ComponentTopology& _component_topology; + ParaMEDMEM::ComponentTopology _component_topology; Topology* _topology; - + mutable bool _own_support; ParaMESH* _support; }; diff --git a/src/ParaMEDMEM/Test/ParaMEDMEMTest.hxx b/src/ParaMEDMEM/Test/ParaMEDMEMTest.hxx index 3562684f3..140911a42 100644 --- a/src/ParaMEDMEM/Test/ParaMEDMEMTest.hxx +++ b/src/ParaMEDMEM/Test/ParaMEDMEMTest.hxx @@ -36,6 +36,7 @@ class ParaMEDMEMTest : public CppUnit::TestFixture CPPUNIT_TEST(testBlockTopology_constructor); CPPUNIT_TEST(testBlockTopology_serialize); CPPUNIT_TEST(testInterpKernelDEC_2D); + CPPUNIT_TEST(testInterpKernelDEC2_2D); CPPUNIT_TEST(testInterpKernelDEC_2DP0P1); CPPUNIT_TEST(testInterpKernelDEC_3D); CPPUNIT_TEST(testInterpKernelDECNonOverlapp_2D_P0P0); @@ -83,6 +84,7 @@ public: void testBlockTopology_constructor(); void testBlockTopology_serialize(); void testInterpKernelDEC_2D(); + void testInterpKernelDEC2_2D(); void testInterpKernelDEC_2DP0P1(); void testInterpKernelDEC_3D(); void testInterpKernelDECNonOverlapp_2D_P0P0(); @@ -130,6 +132,7 @@ private: double dtB, double tmaxB, bool WithPointToPoint, bool Asynchronous, bool WithInterp, const char *srcMeth, const char *targetMeth); void testInterpKernelDEC_2D_(const char *srcMeth, const char *targetMeth); + void testInterpKernelDEC2_2D_(const char *srcMeth, const char *targetMeth); void testInterpKernelDEC_3D_(const char *srcMeth, const char *targetMeth); }; diff --git a/src/ParaMEDMEM/Test/ParaMEDMEMTest_InterpKernelDEC.cxx b/src/ParaMEDMEM/Test/ParaMEDMEMTest_InterpKernelDEC.cxx index ed54396b6..284a02787 100644 --- a/src/ParaMEDMEM/Test/ParaMEDMEMTest_InterpKernelDEC.cxx +++ b/src/ParaMEDMEM/Test/ParaMEDMEMTest_InterpKernelDEC.cxx @@ -50,6 +50,11 @@ void ParaMEDMEMTest::testInterpKernelDEC_2D() testInterpKernelDEC_2D_("P0","P0"); } +void ParaMEDMEMTest::testInterpKernelDEC2_2D() +{ + testInterpKernelDEC2_2D_("P0","P0"); +} + void ParaMEDMEMTest::testInterpKernelDEC_3D() { testInterpKernelDEC_3D_("P0","P0"); @@ -277,6 +282,161 @@ void ParaMEDMEMTest::testInterpKernelDEC_2D_(const char *srcMeth, const char *ta cout << "end of InterpKernelDEC_2D test"< self_procs; + set procs_source; + set procs_target; + + for (int i=0; icontainsMyRank()) + { + string master = filename_xml1; + + ostringstream strstream; + strstream <setMesh(mesh); + DataArrayDouble *array=DataArrayDouble::New(); + array->alloc(mcfield->getNumberOfTuples(),1); + mcfield->setArray(array); + array->decrRef(); + mcfield->setNature(ConservativeVolumic); + } + else + { + mcfield = MEDCouplingFieldDouble::New(ON_CELLS,NO_TIME); + mcfield->setMesh(mesh); + DataArrayDouble *array=DataArrayDouble::New(); + array->alloc(mcfield->getNumberOfTuples(),1); + mcfield->setArray(array); + array->decrRef(); + } + int nb_local; + if(srcM=="P0") + nb_local=mesh->getNumberOfCells(); + else + nb_local=mesh->getNumberOfNodes(); + double *value=mcfield->getArray()->getPointer(); + for(int ielem=0; ielemcontainsMyRank()) + { + string master= filename_xml2; + ostringstream strstream; + strstream << master<<(rank-nproc_source+1)<<".med"; + ostringstream meshname ; + meshname<< "Mesh_3_"<setMesh(mesh); + DataArrayDouble *array=DataArrayDouble::New(); + array->alloc(mcfield->getNumberOfTuples(),1); + mcfield->setArray(array); + array->decrRef(); + mcfield->setNature(ConservativeVolumic); + } + else + { + mcfield = MEDCouplingFieldDouble::New(ON_NODES,NO_TIME); + mcfield->setMesh(mesh); + DataArrayDouble *array=DataArrayDouble::New(); + array->alloc(mcfield->getNumberOfTuples(),1); + mcfield->setArray(array); + array->decrRef(); + } + int nb_local; + if(targetM=="P0") + nb_local=mesh->getNumberOfCells(); + else + nb_local=mesh->getNumberOfNodes(); + double *value=mcfield->getArray()->getPointer(); + for(int ielem=0; ielemcontainsMyRank()) + { + dec.synchronize(); + dec.setForcedRenormalization(false); + dec.sendData(); + dec.recvData(); + } + + //attaching a DEC to the target group + if (target_group->containsMyRank()) + { + dec.synchronize(); + dec.setForcedRenormalization(false); + dec.recvData(); + dec.sendData(); + } + delete source_group; + delete target_group; + delete self_group; + mcfield->decrRef(); + mesh->decrRef(); + + MPI_Barrier(MPI_COMM_WORLD); + cout << "end of InterpKernelDEC2_2D test"<allocateCells(1); mesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,conn); @@ -823,7 +981,7 @@ void ParaMEDMEMTest::testInterpKernelDECNonOverlapp_2D_P0P1P1P0() { double coords[6]={-0.3,-0.3, -0.3,0.7, 0.7,0.7}; int conn[3]={0,1,2}; - int globalNode[3]={1,3,2}; + //int globalNode[3]={1,3,2}; mesh=MEDCouplingUMesh::New("Source mesh Proc1",2); mesh->allocateCells(1); mesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,conn); @@ -860,7 +1018,7 @@ void ParaMEDMEMTest::testInterpKernelDECNonOverlapp_2D_P0P1P1P0() { double coords[10]={-0.3,-0.3, 0.2,-0.3, 0.7,-0.3, -0.3,0.2, 0.2,0.2 }; int conn[7]={0,3,4,1, 1,4,2}; - int globalNode[5]={4,3,0,2,1}; + //int globalNode[5]={4,3,0,2,1}; mesh=MEDCouplingUMesh::New("Target mesh Proc2",2); mesh->allocateCells(2); mesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,conn); @@ -882,7 +1040,7 @@ void ParaMEDMEMTest::testInterpKernelDECNonOverlapp_2D_P0P1P1P0() { double coords[6]={0.2,0.2, 0.7,-0.3, 0.7,0.2}; int conn[3]={0,2,1}; - int globalNode[3]={1,0,5}; + //int globalNode[3]={1,0,5}; mesh=MEDCouplingUMesh::New("Target mesh Proc3",2); mesh->allocateCells(1); mesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,conn); @@ -903,7 +1061,7 @@ void ParaMEDMEMTest::testInterpKernelDECNonOverlapp_2D_P0P1P1P0() { double coords[12]={-0.3,0.2, -0.3,0.7, 0.2,0.7, 0.2,0.2, 0.7,0.7, 0.7,0.2}; int conn[8]={0,1,2,3, 3,2,4,5}; - int globalNode[6]={2,6,7,1,8,5}; + //int globalNode[6]={2,6,7,1,8,5}; mesh=MEDCouplingUMesh::New("Target mesh Proc4",2); mesh->allocateCells(2); mesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,conn); @@ -1037,7 +1195,6 @@ void ParaMEDMEMTest::testAsynchronousInterpKernelDEC_2D(double dtA, double tmaxA ParaMEDMEM::ParaMESH* paramesh; ParaMEDMEM::ParaFIELD* parafield; - double * value ; ICoCo::Field* icocofield ; string tmp_dir = getenv("TMP"); -- 2.39.2