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