v0.14.0
ISManager.hpp
Go to the documentation of this file.
1 /** \file ISManager.hpp
2  * \brief Interface managing IS
3  * \ingroup mofem_is_managers
4  *
5  * Managing problems, build and partitioning.
6  *
7  */
8 
9 #ifndef _ISMANAGER_HPP__
10 #define _ISMANAGER_HPP__
11 
12 #include "UnknownInterface.hpp"
13 
14 namespace MoFEM {
15 
16 /**
17  * \brief Section manager is used to create indexes and sections
18  * \ingroup mofem_is_managers
19  *
20  * FIXME: ISManager is not properly tested by atom tests.
21  *
22  */
23 struct ISManager : public UnknownInterface {
24 
25  MoFEMErrorCode query_interface(boost::typeindex::type_index type_index,
26  UnknownInterface **iface) const;
27 
29  bool dEbug;
30 
31  ISManager(const MoFEM::Core &core);
32 
33  /**
34  * \brief Destructor
35  */
36  virtual ~ISManager() = default;
37 
38  /**
39  * \brief Create global selection
40  * \ingroup mofem_is_managers
41  *
42  * Create section for given problem, such that points are sorted by UId,
43  * and number of dofs on point is equal to number of dofs on entity
44  *
45  * It takes all fields
46  *
47  * @param problem_name
48  * @param fields_list
49  * @param s
50  * @param row_col ROE or COL, default is ROW
51  * @return error code
52  */
53  MoFEMErrorCode sectionCreate(const std::string problem_name, PetscSection *s,
54  const RowColData row_col = COL) const;
55 
56  /**
57  * \brief Create global selection
58  * \ingroup mofem_is_managers
59  *
60  * Create section for given problem, such that points are sorted by UId,
61  * and number of dofs on point is equal to number of dofs on entity
62  *
63  * It takes all fields
64  *
65  * @param problem_name
66  * @param fields_list
67  * @param s
68  * @param row_col ROE or COL, default is ROW
69  * @return error code
70  */
72  sectionCreate(const std::string problem_name,
73  const RowColData row_col = COL) const;
74 
75  /**
76  * @brief Create IS for problem
77  *
78  * @param problem_name
79  * @param rc
80  * @param is
81  * @return MoFEMErrorCode
82  */
83  MoFEMErrorCode isCreateProblem(const std::string problem_name, RowColData rc,
84  IS *is) const;
85 
86  /**
87  * @brief Create IS for problem
88  *
89  * @param problem_name
90  * @param rc
91  * @param is
92  * @return MoFEMErrorCode
93  */
94  MoFEMErrorCode isCreateProblem(const std::string problem_name, RowColData rc,
95  SmartPetscObj<IS> &is) const;
96 
97  /**
98  * @brief Create problem IS
99  *
100  * @param problem_name
101  * @param rc
102  * @return SmartPetscObj<IS>
103  */
104  SmartPetscObj<IS> isCreateProblem(std::string problem_name,
105  RowColData rc) const;
106 
107  /**
108  * \brief create IS for given order range (collective)
109  * \ingroup mofem_is_managers
110 
111  * \param problem name
112  * \param rc ROW or COL
113  * \param min_order
114  * \param max_order
115  * \retval is out value
116 
117  */
118  MoFEMErrorCode isCreateProblemOrder(const std::string problem_name,
119  RowColData rc, int min_order,
120  int max_order, IS *is) const;
121 
122  /**
123  * @copydoc MoFEM::ISManager::isCreateProblemOrder
124  */
125  MoFEMErrorCode isCreateProblemOrder(const std::string problem_name,
126  RowColData rc, int min_order,
127  int max_order,
128  SmartPetscObj<IS> &is) const;
129 
130  /**
131  * \brief create IS for given problem, field and rank range (collective)
132  * \ingroup mofem_is_managers
133 
134  * \param problem name
135  * \param rc ROW or COL
136  * \param field name
137  * \param min_coeff_idx
138  * \param max_coeff_idx
139  * \param ents if not null get dofs only on given entities
140  * \retval is out value
141 
142  */
143  MoFEMErrorCode isCreateProblemFieldAndRank(const std::string problem_name,
144  RowColData rc,
145  const std::string field,
146  int min_coeff_idx,
147  int max_coeff_idx, IS *is,
148  Range *ents = nullptr) const;
149 
150  /**
151  * \copybrief create IS for given problem, field and rank range (collective)
152  * \ingroup mofem_is_managers
153  *
154  * \param problem name
155  * \param rc ROW or COL
156  * \param field name
157  * \param min_coeff_idx
158  * \param max_coeff_idx
159  * \param ents if not null get dofs only on given entities
160  * \retval is out value
161  */
163  isCreateProblemFieldAndRank(const std::string problem_name, RowColData rc,
164  const std::string field, int min_coeff_idx,
165  int max_coeff_idx, SmartPetscObj<IS> &smart_is,
166  Range *ents = nullptr) const;
167 
168  /**
169  * \copybrief create IS for given problem, field and rank range (collective)
170  * \ingroup mofem_is_managers
171  *
172  * \param dofs_vec vector of dofs
173  * \param smart_is IS
174  * \retval is out value
175  *
176  * \retval is out value
177  */
179  const std::vector<boost::weak_ptr<NumeredDofEntity>> &dofs_vec,
180  SmartPetscObj<IS> &smart_is, MPI_Comm comm = PETSC_COMM_SELF) const;
181 
182  /**
183  * \copybrief create IS for given problem, field and rank range (collective)
184  * \ingroup mofem_is_managers
185  *
186  * \param dofs_vec vector of dofs
187  * \param smart_is IS
188  * \retval is out value
189  *
190  * \retval is out value
191  */
193  const std::vector<boost::weak_ptr<NumeredDofEntity>> &dofs_vec,
194  SmartPetscObj<IS> &smart_is) const;
195 
196  /**
197  * \brief create IS for given problem, field and rank range (collective)
198  * \ingroup mofem_is_managers
199 
200  * \param problem name
201  * \param rc ROW or COL
202  * \param field name
203  * \param min_coeff_idx
204  * \param max_coeff_idx
205  * \param ents if not null get dofs only on given entities
206  * \retval is out value
207 
208  */
210  isCreateProblemFieldAndRankLocal(const std::string problem_name,
211  RowColData rc, const std::string field,
212  int min_coeff_idx, int max_coeff_idx, IS *is,
213  Range *ents = nullptr) const;
214 
215  /**
216  * \copybrief create IS for given problem, field and rank range (collective)
217  * \ingroup mofem_is_managers
218  *
219  * \param problem name
220  * \param rc ROW or COL
221  * \param field name
222  * \param min_coeff_idx
223  * \param max_coeff_idx
224  * \param ents if not null get dofs only on given entities
225  * \retval is out value
226  */
228  const std::string problem_name, RowColData rc, const std::string field,
229  int min_coeff_idx, int max_coeff_idx, SmartPetscObj<IS> &smart_is,
230  Range *ents = nullptr) const;
231 
232  /**
233  * @brief create IS for given problem, field and type range (collective)
234  * \ingroup mofem_is_managers
235  *
236  * @param problem
237  * @param rc
238  * @param field
239  * @param low_type
240  * @param hi_type
241  * @param min_coeff_idx
242  * @param max_coeff_idx
243  * @param is
244  * @param ents
245  * @return MoFEMErrorCode
246  */
248  const std::string problem_name, RowColData rc, const std::string field,
249  EntityType low_type, EntityType hi_type, int min_coeff_idx,
250  int max_coeff_idx, IS *is, Range *ents = nullptr) const;
251 
252  /** \brief create IS for give two problems and field
253  * \ingroup mofem_is_managers
254 
255  Note that indices are ordered in ascending order of local indices in
256  problem_y
257 
258  \param x_problem name of problem
259  \param x_field_name name of field in problem_x
260  \param x_rc that is ROW or COL
261  \param y_problem name of problem
262  \param y_field_name name of field in problem_y
263  \param y_rc that is ROW or COL
264 
265  \retval idx indexes in problem_x
266  \retval idy indexes in problem_y
267 
268  */
270  const std::string x_problem, const std::string x_field_name,
271  RowColData x_rc, const std::string y_problem,
272  const std::string y_field_name, RowColData y_rc, std::vector<int> &idx,
273  std::vector<int> &idy) const;
274 
275  /** \brief create IS for give two problems and field
276  * \ingroup mofem_is_managers
277 
278  Indices are sorted by global PETSc index in problem_x.
279 
280  \param x_problem name of problem
281  \param x_field_name name of field in problem_x
282  \param x_rc that is ROW or COL
283  \param y_problem name of problem
284  \param y_field_name name of field in problem_y
285  \param y_rc that is ROW or COL
286 
287  \retval ix IS indexes in problem_x (can be PETSC_NULL)
288  \retval iy IS indexes in problem_y
289 
290  */
292  const std::string x_problem, const std::string x_field_name,
293  RowColData x_rc, const std::string y_problem,
294  const std::string y_field_name, RowColData y_rc, IS *ix, IS *iy) const;
295 
296  /**
297  * @brief Create is from one problem to other problem
298  * @ingroup mofem_is_managers
299  *
300  * @param x_problem
301  * @param x_rc
302  * @param y_problem
303  * @param y_rc
304  * @param idx
305  * @param idy
306  * @return MoFEMErrorCode
307  */
309  const std::string x_problem, RowColData x_rc, const std::string y_problem,
310  RowColData y_rc, std::vector<int> &idx, std::vector<int> &idy) const;
311 
312  /**
313  * @brief Create is from one problem to other problem
314  * @ingroup mofem_is_managers
315  *
316  * @param x_problem
317  * @param x_rc
318  * @param y_problem
319  * @param y_rc
320  * @param ix
321  * @param iy
322  * @return MoFEMErrorCode
323  */
324  MoFEMErrorCode isCreateFromProblemToOtherProblem(const std::string x_problem,
325  RowColData x_rc,
326  const std::string y_problem,
327  RowColData y_rc, IS *ix,
328  IS *iy) const;
329 };
330 
331 } // namespace MoFEM
332 
333 /**
334  * \defgroup mofem_is_managers Index sets (IS)
335  * \brief Construct index sets for MoFEM problems
336  *
337  * \ingroup mofem
338  */
339 
340 #endif // _ISMANAGER_HPP__
MoFEM::ISManager::isCreateProblemFieldAndRank
MoFEMErrorCode isCreateProblemFieldAndRank(const std::string problem_name, RowColData rc, const std::string field, int min_coeff_idx, int max_coeff_idx, IS *is, Range *ents=nullptr) const
create IS for given problem, field and rank range (collective)
Definition: ISManager.cpp:272
MoFEM::CoreTmp< 0 >
Core (interface) class.
Definition: Core.hpp:82
MoFEM::ISManager::query_interface
MoFEMErrorCode query_interface(boost::typeindex::type_index type_index, UnknownInterface **iface) const
Definition: ISManager.cpp:10
MoFEM::ISManager::isCreateFromProblemFieldToOtherProblemField
MoFEMErrorCode isCreateFromProblemFieldToOtherProblemField(const std::string x_problem, const std::string x_field_name, RowColData x_rc, const std::string y_problem, const std::string y_field_name, RowColData y_rc, std::vector< int > &idx, std::vector< int > &idy) const
create IS for give two problems and field
Definition: ISManager.cpp:523
MoFEM::Exceptions::MoFEMErrorCode
PetscErrorCode MoFEMErrorCode
MoFEM/PETSc error code.
Definition: Exceptions.hpp:56
MoFEM::DeprecatedCoreInterface
Deprecated interface functions.
Definition: DeprecatedCoreInterface.hpp:16
MoFEM::ISManager::isCreateProblem
MoFEMErrorCode isCreateProblem(const std::string problem_name, RowColData rc, IS *is) const
Create IS for problem.
Definition: ISManager.cpp:149
MoFEM::ISManager::isCreateProblemBrokenFieldAndRankLocal
MoFEMErrorCode isCreateProblemBrokenFieldAndRankLocal(const std::vector< boost::weak_ptr< NumeredDofEntity >> &dofs_vec, SmartPetscObj< IS > &smart_is) const
IS for given problem, field and rank range (collective)
Definition: ISManager.cpp:381
MoFEM
implementation of Data Operators for Forces and Sources
Definition: Common.hpp:10
MoFEM::ISManager
Section manager is used to create indexes and sections.
Definition: ISManager.hpp:23
MoFEM::ISManager::cOre
const MoFEM::Interface & cOre
Definition: ISManager.hpp:28
RowColData
RowColData
RowColData.
Definition: definitions.h:136
COL
@ COL
Definition: definitions.h:136
UnknownInterface.hpp
MoFEM interface.
MoFEM::ISManager::dEbug
bool dEbug
Definition: ISManager.hpp:29
MoFEM::ISManager::isCreateProblemFieldAndRankLocal
MoFEMErrorCode isCreateProblemFieldAndRankLocal(const std::string problem_name, RowColData rc, const std::string field, int min_coeff_idx, int max_coeff_idx, IS *is, Range *ents=nullptr) const
create IS for given problem, field and rank range (collective)
Definition: ISManager.cpp:406
MoFEM::UnknownInterface
base class for all interface classes
Definition: UnknownInterface.hpp:34
MoFEM::ISManager::ISManager
ISManager(const MoFEM::Core &core)
Definition: ISManager.cpp:17
Range
MoFEM::ISManager::isCreateProblemBrokenFieldAndRank
MoFEMErrorCode isCreateProblemBrokenFieldAndRank(const std::vector< boost::weak_ptr< NumeredDofEntity >> &dofs_vec, SmartPetscObj< IS > &smart_is, MPI_Comm comm=PETSC_COMM_SELF) const
IS for given problem, field and rank range (collective)
Definition: ISManager.cpp:357
MoFEM::ISManager::isCreateFromProblemToOtherProblem
MoFEMErrorCode isCreateFromProblemToOtherProblem(const std::string x_problem, RowColData x_rc, const std::string y_problem, RowColData y_rc, std::vector< int > &idx, std::vector< int > &idy) const
Create is from one problem to other problem.
Definition: ISManager.cpp:648
MoFEM::ISManager::sectionCreate
MoFEMErrorCode sectionCreate(const std::string problem_name, PetscSection *s, const RowColData row_col=COL) const
Create global selection.
Definition: ISManager.cpp:20
MoFEM::ISManager::isCreateProblemFieldAndEntityType
MoFEMErrorCode isCreateProblemFieldAndEntityType(const std::string problem_name, RowColData rc, const std::string field, EntityType low_type, EntityType hi_type, int min_coeff_idx, int max_coeff_idx, IS *is, Range *ents=nullptr) const
create IS for given problem, field and type range (collective)
Definition: ISManager.cpp:505
MoFEM::SmartPetscObj
intrusive_ptr for managing petsc objects
Definition: PetscSmartObj.hpp:82
MoFEM::ISManager::isCreateProblemOrder
MoFEMErrorCode isCreateProblemOrder(const std::string problem_name, RowColData rc, int min_order, int max_order, IS *is) const
create IS for given order range (collective)
Definition: ISManager.cpp:204
MoFEM::ISManager::~ISManager
virtual ~ISManager()=default
Destructor.