X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FParaMEDMEM%2FOverlapMapping.hxx;h=858cf5cc99f6ad7de984791d89f4d32dc5b398e6;hb=1b5fb5650409b0ad3a61da3215496f2adf2dae02;hp=2a5b32e4bb82ffa7595cf1974f2a5a9c7daf9b69;hpb=6f841c1f16f8b9d0b7ba50cf000ade240b2484b2;p=tools%2Fmedcoupling.git diff --git a/src/ParaMEDMEM/OverlapMapping.hxx b/src/ParaMEDMEM/OverlapMapping.hxx index 2a5b32e4b..858cf5cc9 100644 --- a/src/ParaMEDMEM/OverlapMapping.hxx +++ b/src/ParaMEDMEM/OverlapMapping.hxx @@ -1,4 +1,4 @@ -// Copyright (C) 2007-2015 CEA/DEN, EDF R&D +// Copyright (C) 2007-2023 CEA, EDF // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public @@ -21,109 +21,109 @@ #ifndef __OVERLAPMAPPING_HXX__ #define __OVERLAPMAPPING_HXX__ -#include "MEDCouplingAutoRefCountObjectPtr.hxx" +#include "MCAuto.hxx" +#include "OverlapElementLocator.hxx" #include #include +//#define DEC_DEBUG -namespace ParaMEDMEM +namespace MEDCoupling { class ProcessorGroup; class DataArrayInt; class MEDCouplingFieldDouble; - typedef std::map SparseDoubleVec; + using namespace std; + typedef map SparseDoubleVec; /*! * Internal class, not part of the public API. * * Used by the impl of OverlapInterpolationMatrix, plays an equivalent role than what the NxM_Mapping * does for the InterpolationMatrix. - * */ class OverlapMapping { public: - OverlapMapping(const ProcessorGroup& group); - void keepTracksOfSourceIds(int procId, DataArrayInt *ids); - void keepTracksOfTargetIds(int procId, DataArrayInt *ids); - void addContributionST(const std::vector< SparseDoubleVec >& matrixST, const DataArrayInt *srcIds, int srcProcId, const DataArrayInt *trgIds, int trgProcId); - void prepare(const std::vector< int >& procsToSendField, int nbOfTrgElems); - void computeDenoConservativeVolumic(int nbOfTuplesTrg); - void computeDenoGlobConstraint(); + OverlapMapping(const ProcessorGroup& group, const OverlapElementLocator& locator); + void keepTracksOfSourceIds(int procId, DataArrayIdType *ids); + void keepTracksOfTargetIds(int procId, DataArrayIdType *ids); + void addContributionST(const vector< SparseDoubleVec >& matrixST, const DataArrayIdType *srcIds, int srcProcId, const DataArrayIdType *trgIds, int trgProcId); + void prepare(const vector< int >& procsToSendField, mcIdType nbOfTrgElems); + void computeDenoConservativeVolumic(mcIdType nbOfTuplesTrg); +// void computeDenoIntegralGlobConstraint(); +// void computeDenoIntegral(); + void computeDenoRevIntegral(const DataArrayDouble & targetAreas); // - void multiply(const MEDCouplingFieldDouble *fieldInput, MEDCouplingFieldDouble *fieldOutput) const; + void multiply(const MEDCouplingFieldDouble *fieldInput, MEDCouplingFieldDouble *fieldOutput, double default_val) const; void transposeMultiply(const MEDCouplingFieldDouble *fieldInput, MEDCouplingFieldDouble *fieldOutput); private: - void fillProcToSendRcvForMultiply(const std::vector< int >& procsToSendField); - void serializeMatrixStep0ST(const int *nbOfElemsSrc, int *&bigArr, int *count, int *offsets, + void serializeMatrixStep0ST(const mcIdType *nbOfElemsSrc, mcIdType *&bigArr, int *count, int *offsets, int *countForRecv, int *offsetsForRecv) const; - int serializeMatrixStep1ST(const int *nbOfElemsSrc, const int *recvStep0, const int *countStep0, const int *offsStep0, - int *&bigArrI, double *&bigArrD, int *count, int *offsets, + mcIdType serializeMatrixStep1ST(const mcIdType *nbOfElemsSrc, const mcIdType *recvStep0, const int *countStep0, const int *offsStep0, + mcIdType *&bigArrI, double *&bigArrD, int *count, int *offsets, int *countForRecv, int *offsForRecv) const; - void unserializationST(int nbOfTrgElems, const int *nbOfElemsSrcPerProc, const int *bigArrRecv, const int *bigArrRecvCounts, const int *bigArrRecvOffs, - const int *bigArrRecv2, const double *bigArrDRecv2, const int *bigArrRecv2Count, const int *bigArrRecv2Offs); + void unserializationST(mcIdType nbOfTrgElems, const mcIdType *nbOfElemsSrcPerProc, const mcIdType *bigArrRecv, const int *bigArrRecvCounts, const int *bigArrRecvOffs, + const mcIdType *bigArrRecv2, const double *bigArrDRecv2, const int *bigArrRecv2Count, const int *bigArrRecv2Offs); void finishToFillFinalMatrixST(); - void updateZipSourceIdsForFuture(); + void fillSourceIdsZipReceivedForMultiply(); - // Debug -// void printMatrixesST() const; -// void printTheMatrix() const; +#ifdef DEC_DEBUG + void printMatrixesST() const; + void printTheMatrix() const; + void printDenoMatrix() const; +#endif private: const ProcessorGroup &_group; - /**! Vector of DAInt of cell identifiers. The 2 following class members work in pair. For a proc ID i, - * first member gives an old2new map for the local part of the source mesh that has been sent. - * Second member gives proc ID. */ - std::vector< MEDCouplingAutoRefCountObjectPtr > _sent_src_ids_st2; - //! see above _sent_src_ids_st2 - std::vector< int > _sent_src_proc_st2; + const OverlapElementLocator& _locator; - //! See _src_ids_st2 and _sent_src_proc_st2. Same for target mesh. - std::vector< MEDCouplingAutoRefCountObjectPtr > _sent_trg_ids_st2; - //! See _src_ids_st2 and _sent_src_proc_st2. Same for target mesh. - std::vector< int > _sent_trg_proc_st2; + /**! Map of DAInt of cell identifiers. For a proc ID i, + * gives an old2new map for the local part of the source mesh that has been sent to proc#i, just based on the + * bounding box computation (this is potentially a larger set than what is finally in the interp matrix). + * Second member gives proc ID. */ + map < int, MCAuto > _sent_src_ids; + //! See _sent_src_ids. Same for target mesh. + map < int, MCAuto > _sent_trg_ids; - /**! Vector of matrixes (partial interpolation ratios), result of the local interpolator run. + /**! Vector of matrixes (partial interpolation ratios), result of the LOCAL interpolator run. * Indexing shared with _source_proc_id_st, and _target_proc_id_st. */ - std::vector< std::vector< SparseDoubleVec > > _matrixes_st; + vector< vector< SparseDoubleVec > > _matrixes_st; //! See _matrixes_st - vec of source proc IDs - std::vector< int > _source_proc_id_st; + vector< int > _source_proc_id_st; //! See _matrixes_st - vec of target proc IDs - std::vector< int > _target_proc_id_st; + vector< int > _target_proc_id_st; - //! Vector of remote remote proc IDs for source mesh. Indexing shared with _nb_of_src_ids_proc_st2 - std::vector< int > _src_ids_proc_st2; - //! Number of cells in the mesh/mapping received from the remote proc i for source mesh. See _src_ids_proc_st2 above - std::vector< int > _nb_of_src_ids_proc_st2; + /**! Number of received source mesh IDs at mesh data exchange. + Counting the number of IDs suffices, as we just need this to prepare the receive side, when doing the final vector matrix multiplication. + First dimension is the remote proc ID from which we received. */ + map _nb_of_rcv_src_ids; - /**! Specifies for each remote proc ID (given in _src_ids_zip_proc_st2 below) the corresponding local - * source cell IDs to use/send. Same indexing as _src_ids_zip_proc_st2. Sorted. - * On a given proc, those two members contain exactly the same set of cell identifiers as what is given - * in the locally held interpolation matrices. */ - std::vector< std::vector > _src_ids_zip_st2; - //! Vector of remote proc ID to which the local source mapping above corresponds. See _src_ids_zip_st2 above. - std::vector< int > _src_ids_zip_proc_st2; + /**! Specifies for each (target) remote proc ID (first dim of the map) the corresponding + * source cell IDs to use. + * This information is stored from the *locally* COMPuted matrices, and corresponds hence to field value that will need to + * sent later on, if this matrix bit itself is sent aways. */ + map > _src_ids_zip_comp; + + /**! Same idea as _src_ids_zip_comp above, but for RECEIVED matrix. */ + map > _src_ids_zip_recv; /**! THE matrix for matrix-vector product. The first dimension is indexed in the set of target procs - * that interacts with local source mesh. The second dim is the pseudo id of source proc. - * Same indexing as _the_matrix_st_source_proc_id */ - std::vector< std::vector< SparseDoubleVec > > _the_matrix_st; + * that interacts with local source mesh. The second dim is the target cell ID. + * Same indexing as _the_matrix_st_source_proc_id and _the_deno_st. + * We don't use a map here to be more efficient in the final matrix-vector computation which requires the joint + * taversal of _the_matrix_st and _the_deno_st. + * This matrix is filled after receival from other procs, contrary to _matrixes_st which contains local computations.*/ + vector< vector< SparseDoubleVec > > _the_matrix_st; //! See _the_matrix_st above. List of source proc IDs contributing to _the_matrix_st - std::vector< int > _the_matrix_st_source_proc_id; + vector< int > _the_matrix_st_source_proc_id; + // Denominators (computed from the numerator matrix). As for _the_matrix_st it is paired with _the_matrix_st_source_proc_id + vector< vector< SparseDoubleVec > > _the_deno_st; //! Proc IDs to which data will be sent (originating this current proc) for matrix-vector computation - std::vector< int > _proc_ids_to_send_vector_st; - //! Proc IDs from which data will be received (on this current proc) for matrix-vector computation - std::vector< int > _proc_ids_to_recv_vector_st; - - // Denominators (computed from the numerator matrix) - std::vector< std::vector< SparseDoubleVec > > _the_deno_st; - -// std::vector< std::vector > _the_matrix_st_source_ids; -// //! this attribute is of size _group.size(); for each procId in _group _source_ids_to_send_st[procId] contains tupleId to send abroad -// std::vector< std::vector > _source_ids_to_send_st; + vector< int > _proc_ids_to_send_vector_st; }; }