v0.9.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 
27 
28 /**
29  * \brief Managing BitRefLevels
30  * \ingroup mofem_bit_ref
31  * \nosubgrouping
32  */
34 
36  UnknownInterface **iface) const;
37 
39  bool dEbug;
40 
41  CommInterface(const MoFEM::Core &core);
42 
43  /**
44  * \brief Destructor
45  */
47 
48  /** \name Make elemnts multishared */
49 
50  /**@{*/
51 
52  /**
53  * \brief resolve shared entities for finite elements in the problem
54  * \ingroup mofem_problems
55 
56  * @param problem_ptr problem pointer
57  * @param fe_name finite element name
58  * @param verb verbosity level
59  * @return error code
60  *
61  * This allows for tag reduction or tag exchange, f.e.
62 
63  \code
64  CHKERR m_field.resolveSharedFiniteElements(problem_ptr,"SHELL_ELEMENT");
65  Tag th;
66  CHKERR mField.get_moab().tag_get_handle("ADAPT_ORDER",th);
67  CHKERR ParallelComm* pcomm =
68  ParallelComm::get_pcomm(&mField.get_moab(),MYPCOMM_INDEX);
69  CHKERR pcomm->exchange_tags(th,prisms);
70  \endcode
71 
72  *
73  */
75  const std::string &fe_name,
76  int verb = DEFAULT_VERBOSITY);
77 
78  /**
79  * \brief resolve shared entities for finite elements in the problem
80  * \ingroup mofem_problems
81 
82  * @param name problem name
83  * @param fe_name finite element name
84  * @param verb verbosity level
85  * @return error code
86  *
87  * This allows for tag reduction or tag exchange, f.e.
88 
89  \code
90  CHKERR m_field.resolveSharedFiniteElements(problem_ptr,"SHELL_ELEMENT");
91  Tag th;
92  CHKERR mField.get_moab().tag_get_handle("ADAPT_ORDER",th);
93  ParallelComm* pcomm =
94  ParallelComm::get_pcomm(&mField.get_moab(),MYPCOMM_INDEX);
95  // CHKERR pcomm->reduce_tags(th,MPI_SUM,prisms);
96  CHKERR pcomm->exchange_tags(th,prisms);
97  \endcode
98 
99  *
100  */
101  MoFEMErrorCode resolveSharedFiniteElements(const std::string &name,
102  const std::string &fe_name,
103  int verb = DEFAULT_VERBOSITY);
104 
105  /** \name Make entities multishared */
106 
107  /**
108  * @brief make entities from proc 0 shared on all proc
109  *
110  * \note collective - need tu be run on all processors in communicator
111  *
112  * @param entities
113  * @param num_entities
114  * @param my_proc default proc id to share from
115  * @param verb
116  * @return MoFEMErrorCode
117  */
119  const int num_entities,
120  const int owner_proc = 0,
121  int verb = DEFAULT_VERBOSITY);
122 
123  /**
124  * @brief make entities from proc 0 shared on all proc
125  *
126  * \note collective - need tu be run on all processors in communicator
127  *
128  * @param entities
129  * @param my_proc default proc id to share from
130  * @param verb
131  * @return MoFEMErrorCode
132  */
133  MoFEMErrorCode makeEntitiesMultishared(Range &entities,
134  const int owner_proc = 0,
135  int verb = DEFAULT_VERBOSITY);
136 
137  /**
138  * @brief make field entities multi shared
139  *
140  * \note collective - need tu be run on all processors in communicator
141  *
142  * @param field_name
143  * @param owner_proc
144  * @param verb
145  * @return MoFEMErrorCode
146  */
147  MoFEMErrorCode makeFieldEntitiesMultishared(const std::string field_name,
148  const int owner_proc = 0,
149  int verb = DEFAULT_VERBOSITY);
150 
151  /**
152  * @brief Exchange field data
153  *
154  * Exchange field for all shared and ghosted entities. This function should be
155  * called collectively over the communicator for this ParallelComm. If the
156  * entities vector is empty, all shared entities participate in the exchange.
157  * If a proc has no owned entities this function must still be called since it
158  * is collective.
159  *
160  * \note collective - need tu be run on all processors in communicator
161  *
162  * \todo It is not working if field has entities diffrent than vertices.
163  *
164  * @param verb
165  * @param field_name @return MoFEMErrorCode
166  */
167  MoFEMErrorCode exchangeFieldData(const std::string field_name,
168  int verb = DEFAULT_VERBOSITY);
169 
170  /**@}*/
171 
172  /** \name Synchronize entities (Following functions in future will be
173  * deprecated) */
174 
175  /**@{*/
176 
177  /** synchronize entity range on processors (collective)
178  *
179  * \note collective - need tu be run on all processors in communicator
180  *
181  */
182  MoFEMErrorCode synchroniseEntities(Range &ent, int verb = DEFAULT_VERBOSITY);
183 
184  /** synchronize entity range on processors (collective)
185  * \ingroup mofem_field
186  *
187  * \note collective - need tu be run on all processors in communicator
188  *
189  * \param name field
190  * \param verbose level
191  *
192  */
193  MoFEMErrorCode synchroniseFieldEntities(const std::string name,
194  int verb = DEFAULT_VERBOSITY);
195 
196  /**@}*/
197 };
198 } // namespace MoFEM
199 
200 #endif //__COMMINTERFACE_HPP__
201 
202 /**
203  * \defgroup mofem_comm Comm intrface
204  * \brief Comm interface
205  *
206  * \ingroup mofem
207  */
MoFEMErrorCode query_interface(const MOFEMuuid &uuid, UnknownInterface **iface) const
MoFEM interface unique ID.
Managing BitRefLevels.
base class for all interface classes
Core (interface) class.
Definition: Core.hpp:50
MoFEM interface.
keeps basic data about problemThis is low level structure with information about problem,...
MoFEMErrorCode makeFieldEntitiesMultishared(const std::string field_name, const int owner_proc=0, int verb=DEFAULT_VERBOSITY)
make field entities multi shared
std::bitset< BITINTERFACEUID_SIZE > BitIntefaceId
Definition: Types.hpp:56
implementation of Data Operators for Forces and Sources
Definition: Common.hpp:21
MoFEMErrorCode resolveSharedFiniteElements(const Problem *problem_ptr, const std::string &fe_name, int verb=DEFAULT_VERBOSITY)
resolve shared entities for finite elements in the problem
MoFEMErrorCode synchroniseEntities(Range &ent, int verb=DEFAULT_VERBOSITY)
~CommInterface()
Destructor.
PetscErrorCode MoFEMErrorCode
MoFEM/PETSc error code.
Definition: Exceptions.hpp:66
MoFEMErrorCode synchroniseFieldEntities(const std::string name, int verb=DEFAULT_VERBOSITY)
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 exchangeFieldData(const std::string field_name, int verb=DEFAULT_VERBOSITY)
Exchange field data.
CommInterface(const MoFEM::Core &core)
static const MOFEMuuid IDD_MOFEMComm