v0.13.0
CommInterface.hpp
Go to the documentation of this file.
1 /** \file CommInterface.hpp
2  * \brief Interface for communication functions
3  * \ingroup mofem_comm
4  *
5  * Functions used to communicate, share entities, share data, etc.
6  *
7  */
8 
9 /*
10  * MoFEM is distributed in the hope that it will be useful, but WITHOUT
11  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
13  * License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with MoFEM. If not, see <http://www.gnu.org/licenses/>
17  */
18 
19 #ifndef __COMMINTERFACE_HPP__
20 #define __COMMINTERFACE_HPP__
21 
22 #include "UnknownInterface.hpp"
23 
24 namespace MoFEM {
25 
26 /**
27  * \brief Managing BitRefLevels
28  * \ingroup mofem_bit_ref
29  * \nosubgrouping
30  */
32 
33  MoFEMErrorCode query_interface(boost::typeindex::type_index type_index,
34  UnknownInterface **iface) const;
35 
37  bool dEbug;
38 
39  CommInterface(const MoFEM::Core &core);
40 
41  /**
42  * \brief Destructor
43  */
45 
46  /** \name Make elemnts multishared */
47 
48  /**@{*/
49 
50  /**
51  * \brief resolve shared entities for finite elements in the problem
52  * \ingroup mofem_problems
53 
54  * @param problem_ptr problem pointer
55  * @param fe_name finite element name
56  * @param verb verbosity level
57  * @return error code
58  *
59  * This allows for tag reduction or tag exchange, f.e.
60 
61  \code
62  CHKERR m_field.resolveSharedFiniteElements(problem_ptr,"SHELL_ELEMENT");
63  Tag th;
64  CHKERR mField.get_moab().tag_get_handle("ADAPT_ORDER",th);
65  CHKERR ParallelComm* pcomm =
66  ParallelComm::get_pcomm(&mField.get_moab(),MYPCOMM_INDEX);
67  CHKERR pcomm->exchange_tags(th,prisms);
68  \endcode
69 
70  *
71  */
73  const std::string &fe_name,
74  int verb = DEFAULT_VERBOSITY);
75 
76  /**
77  * \brief resolve shared entities for finite elements in the problem
78  * \ingroup mofem_problems
79 
80  * @param name problem name
81  * @param fe_name finite element name
82  * @param verb verbosity level
83  * @return error code
84  *
85  * This allows for tag reduction or tag exchange, f.e.
86 
87  \code
88  CHKERR m_field.resolveSharedFiniteElements(problem_ptr,"SHELL_ELEMENT");
89  Tag th;
90  CHKERR mField.get_moab().tag_get_handle("ADAPT_ORDER",th);
91  ParallelComm* pcomm =
92  ParallelComm::get_pcomm(&mField.get_moab(),MYPCOMM_INDEX);
93  // CHKERR pcomm->reduce_tags(th,MPI_SUM,prisms);
94  CHKERR pcomm->exchange_tags(th,prisms);
95  \endcode
96 
97  *
98  */
99  MoFEMErrorCode resolveSharedFiniteElements(const std::string &name,
100  const std::string &fe_name,
101  int verb = DEFAULT_VERBOSITY);
102 
103  /** \name Make entities multishared */
104 
105  /**
106  * @brief make entities from proc 0 shared on all proc
107  *
108  * \note collective - need tu be run on all processors in communicator
109  *
110  * @param entities
111  * @param num_entities
112  * @param my_proc default proc id to share from
113  * @param verb
114  * @return MoFEMErrorCode
115  */
117  const int num_entities,
118  const int owner_proc = 0,
119  int verb = DEFAULT_VERBOSITY);
120 
121  /**
122  * @brief make entities from proc 0 shared on all proc
123  *
124  * \note collective - need tu be run on all processors in communicator
125  *
126  * @param entities
127  * @param my_proc default proc id to share from
128  * @param verb
129  * @return MoFEMErrorCode
130  */
131  MoFEMErrorCode makeEntitiesMultishared(Range &entities,
132  const int owner_proc = 0,
133  int verb = DEFAULT_VERBOSITY);
134 
135  /**
136  * @brief make field entities multi shared
137  *
138  * \note collective - need tu be run on all processors in communicator
139  *
140  * @param field_name
141  * @param owner_proc
142  * @param verb
143  * @return MoFEMErrorCode
144  */
145  MoFEMErrorCode makeFieldEntitiesMultishared(const std::string field_name,
146  const int owner_proc = 0,
147  int verb = DEFAULT_VERBOSITY);
148 
149  /**
150  * @brief Exchange field data
151  *
152  * Exchange field for all shared and ghosted entities. This function should be
153  * called collectively over the communicator for this ParallelComm. If the
154  * entities vector is empty, all shared entities participate in the exchange.
155  * If a proc has no owned entities this function must still be called since it
156  * is collective.
157  *
158  * \note collective - need tu be run on all processors in communicator
159  *
160  * \todo It is not working if field has entities diffrent than vertices.
161  *
162  * @param verb
163  * @param field_name @return MoFEMErrorCode
164  */
165  MoFEMErrorCode exchangeFieldData(const std::string field_name,
166  int verb = DEFAULT_VERBOSITY);
167 
168  /**@}*/
169 
170  /** \name Synchronize entities (Following functions in future will be
171  * deprecated) */
172 
173  /**@{*/
174 
175  /** synchronize entity range on processors (collective)
176  *
177  * \note collective - need tu be run on all processors in communicator
178  *
179  */
180  MoFEMErrorCode synchroniseEntities(Range &ent, int verb = DEFAULT_VERBOSITY);
181 
182  /** synchronize entity range on processors (collective)
183  * \ingroup mofem_field
184  *
185  * \note collective - need tu be run on all processors in communicator
186  *
187  * \param name field
188  * \param verbose level
189  *
190  */
191  MoFEMErrorCode synchroniseFieldEntities(const std::string name,
192  int verb = DEFAULT_VERBOSITY);
193 
194  /**@}*/
195 
196  /**@*/
197 
198  /** \name Read load and boradcoast */
199 
200  /**
201  * \brief Set partition tag to each finite element in the problem
202  * \ingroup mofem_problems_manager
203  *
204  * This will use one of the mesh partitioning programs available from PETSc
205  * See
206  * <http://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Mat/MatPartitioningType.html>
207  *
208  * @param ents Entities to partition
209  * @param dim Dimension of entities to partition
210  * @param adj_dim Adjacency dimension
211  * @param n_parts Number of partitions
212  * @param verb Verbosity level
213  * @return Error code
214  */
215  MoFEMErrorCode partitionMesh(const Range &ents, const int dim,
216  const int adj_dim, const int n_parts,
217  Tag *th_vertex_weights = nullptr,
218  Tag *th_edge_weights = nullptr,
219  Tag *th_part_weights = nullptr,
220  int verb = VERBOSE, const bool debug = false);
221 
222 
223  // /**
224  // * @brief
225  // *
226  // * @param meshset
227  // * @param overlap
228  // * @param dim
229  // * @param adj_dim
230  // * @param n_parts
231  // * @param th_vertex_weights
232  // * @param th_edge_weights
233  // * @param th_part_weights
234  // * @param verb
235  // * @return MoFEMErrorCode
236  // */
237  // MoFEMErrorCode partitionAndShare(const EntityHandle meshset,
238  // const int overlap = 0, const int dim,
239  // const int adj_dim, const int n_parts,
240  // Tag *th_vertex_weights = nullptr,
241  // Tag *th_edge_weights = nullptr,
242  // Tag *th_part_weights = nullptr,
243  // int verb = VERBOSE);
244 
245  /**@}*/
246 
247 };
248 } // namespace MoFEM
249 
250 #endif //__COMMINTERFACE_HPP__
251 
252 /**
253  * \defgroup mofem_comm Comm intrface
254  * \brief Comm interface
255  *
256  * \ingroup mofem
257  */
MoFEM interface.
@ DEFAULT_VERBOSITY
Definition: definitions.h:220
@ VERBOSE
Definition: definitions.h:222
static const bool debug
const int dim
MoFEMErrorCode synchroniseFieldEntities(const std::string name, int verb=DEFAULT_VERBOSITY)
MoFEMErrorCode partitionMesh(const Range &ents, const int dim, const int adj_dim, const int n_parts, Tag *th_vertex_weights=nullptr, Tag *th_edge_weights=nullptr, Tag *th_part_weights=nullptr, int verb=VERBOSE, const bool debug=false)
Set partition tag to each finite element in the problem.
MoFEMErrorCode resolveSharedFiniteElements(const Problem *problem_ptr, const std::string &fe_name, int verb=DEFAULT_VERBOSITY)
resolve shared entities for finite elements in the problem
PetscErrorCode MoFEMErrorCode
MoFEM/PETSc error code.
Definition: Exceptions.hpp:67
implementation of Data Operators for Forces and Sources
Definition: Common.hpp:21
Managing BitRefLevels.
MoFEMErrorCode query_interface(boost::typeindex::type_index type_index, UnknownInterface **iface) const
~CommInterface()
Destructor.
CommInterface(const MoFEM::Core &core)
MoFEMErrorCode makeEntitiesMultishared(const EntityHandle *entities, const int num_entities, const int owner_proc=0, int verb=DEFAULT_VERBOSITY)
make entities from proc 0 shared on all proc
MoFEMErrorCode synchroniseEntities(Range &ent, int verb=DEFAULT_VERBOSITY)
MoFEMErrorCode makeFieldEntitiesMultishared(const std::string field_name, const int owner_proc=0, int verb=DEFAULT_VERBOSITY)
make field entities multi shared
MoFEMErrorCode exchangeFieldData(const std::string field_name, int verb=DEFAULT_VERBOSITY)
Exchange field data.
Core (interface) class.
Definition: Core.hpp:92
keeps basic data about problem
base class for all interface classes