1 // Copyright (C) 2007-2015 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, or (at your option) any later version.
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)
21 #ifndef __OVERLAPMAPPING_HXX__
22 #define __OVERLAPMAPPING_HXX__
24 #include "MEDCouplingAutoRefCountObjectPtr.hxx"
33 class MEDCouplingFieldDouble;
35 typedef std::map<int,double> SparseDoubleVec;
38 * Internal class, not part of the public API.
40 * Used by the impl of OverlapInterpolationMatrix, plays an equivalent role than what the NxM_Mapping
41 * does for the InterpolationMatrix.
48 OverlapMapping(const ProcessorGroup& group);
49 void keepTracksOfSourceIds(int procId, DataArrayInt *ids);
50 void keepTracksOfTargetIds(int procId, DataArrayInt *ids);
51 void addContributionST(const std::vector< SparseDoubleVec >& matrixST, const DataArrayInt *srcIds, int srcProcId, const DataArrayInt *trgIds, int trgProcId);
52 void prepare(const std::vector< int >& procsToSendField, int nbOfTrgElems);
53 void computeDenoConservativeVolumic(int nbOfTuplesTrg);
54 void computeDenoGlobConstraint();
56 void multiply(const MEDCouplingFieldDouble *fieldInput, MEDCouplingFieldDouble *fieldOutput) const;
57 void transposeMultiply(const MEDCouplingFieldDouble *fieldInput, MEDCouplingFieldDouble *fieldOutput);
59 void fillProcToSendRcvForMultiply(const std::vector< int >& procsToSendField);
60 void serializeMatrixStep0ST(const int *nbOfElemsSrc, int *&bigArr, int *count, int *offsets,
61 int *countForRecv, int *offsetsForRecv) const;
62 int serializeMatrixStep1ST(const int *nbOfElemsSrc, const int *recvStep0, const int *countStep0, const int *offsStep0,
63 int *&bigArrI, double *&bigArrD, int *count, int *offsets,
64 int *countForRecv, int *offsForRecv) const;
65 void unserializationST(int nbOfTrgElems, const int *nbOfElemsSrcPerProc, const int *bigArrRecv, const int *bigArrRecvCounts, const int *bigArrRecvOffs,
66 const int *bigArrRecv2, const double *bigArrDRecv2, const int *bigArrRecv2Count, const int *bigArrRecv2Offs);
67 void finishToFillFinalMatrixST();
68 void updateZipSourceIdsForFuture();
71 // void printMatrixesST() const;
72 // void printTheMatrix() const;
74 const ProcessorGroup &_group;
75 /**! Vector of DAInt of cell identifiers. The 2 following class members work in pair. For a proc ID i,
76 * first member gives an old2new map for the local part of the source mesh that has been sent.
77 * Second member gives proc ID. */
78 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > _sent_src_ids_st2;
79 //! see above _sent_src_ids_st2
80 std::vector< int > _sent_src_proc_st2;
82 //! See _src_ids_st2 and _sent_src_proc_st2. Same for target mesh.
83 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > _sent_trg_ids_st2;
84 //! See _src_ids_st2 and _sent_src_proc_st2. Same for target mesh.
85 std::vector< int > _sent_trg_proc_st2;
88 /**! Vector of matrixes (partial interpolation ratios), result of the local interpolator run.
89 * Indexing shared with _source_proc_id_st, and _target_proc_id_st. */
90 std::vector< std::vector< SparseDoubleVec > > _matrixes_st;
91 //! See _matrixes_st - vec of source proc IDs
92 std::vector< int > _source_proc_id_st;
93 //! See _matrixes_st - vec of target proc IDs
94 std::vector< int > _target_proc_id_st;
96 //! Vector of remote remote proc IDs for source mesh. Indexing shared with _nb_of_src_ids_proc_st2
97 std::vector< int > _src_ids_proc_st2;
98 //! Number of cells in the mesh/mapping received from the remote proc i for source mesh. See _src_ids_proc_st2 above
99 std::vector< int > _nb_of_src_ids_proc_st2;
101 /**! Specifies for each remote proc ID (given in _src_ids_zip_proc_st2 below) the corresponding local
102 * source cell IDs to use/send. Same indexing as _src_ids_zip_proc_st2. Sorted.
103 * On a given proc, those two members contain exactly the same set of cell identifiers as what is given
104 * in the locally held interpolation matrices. */
105 std::vector< std::vector<int> > _src_ids_zip_st2;
106 //! Vector of remote proc ID to which the local source mapping above corresponds. See _src_ids_zip_st2 above.
107 std::vector< int > _src_ids_zip_proc_st2;
109 /**! THE matrix for matrix-vector product. The first dimension is indexed in the set of target procs
110 * that interacts with local source mesh. The second dim is the pseudo id of source proc.
111 * Same indexing as _the_matrix_st_source_proc_id */
112 std::vector< std::vector< SparseDoubleVec > > _the_matrix_st;
113 //! See _the_matrix_st above. List of source proc IDs contributing to _the_matrix_st
114 std::vector< int > _the_matrix_st_source_proc_id;
116 //! Proc IDs to which data will be sent (originating this current proc) for matrix-vector computation
117 std::vector< int > _proc_ids_to_send_vector_st;
118 //! Proc IDs from which data will be received (on this current proc) for matrix-vector computation
119 std::vector< int > _proc_ids_to_recv_vector_st;
121 // Denominators (computed from the numerator matrix)
122 std::vector< std::vector< SparseDoubleVec > > _the_deno_st;
124 // std::vector< std::vector<int> > _the_matrix_st_source_ids;
125 // //! this attribute is of size _group.size(); for each procId in _group _source_ids_to_send_st[procId] contains tupleId to send abroad
126 // std::vector< std::vector<int> > _source_ids_to_send_st;