v0.9.2
PipelineManager.hpp
Go to the documentation of this file.
1 /** \file PipelineManager.hpp
2  * \brief Header file for basic interface
3  * \ingroup mofem_basic_interface
4  *
5  * Make basic interface, to speedup problem setup and analysts.
6  * See discussion here
7  * <a
8  * href=https://groups.google.com/d/msg/mofem-group/Vkc00aia4dU/o9RF3ZmPAAAJ>link
9  * to google groups</a>
10  *
11  */
12 
13 /* MoFEM is distributed in the hope that it will be useful, but WITHOUT
14  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
16  * License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with MoFEM. If not, see <http://www.gnu.org/licenses/>
20  */
21 
22 #ifndef __BASIC_HPP__
23 #define __BASIC_HPP__
24 
25 #include "UnknownInterface.hpp"
26 
27 namespace MoFEM {
28 
29 static const MOFEMuuid IDD_MOFEMBasic =
31 
32 /**
33  * \brief PipelineManager interface
34  * \ingroup mofem_basic_interface
35  */
37 
39  UnknownInterface **iface) const;
40 
41  PipelineManager(const MoFEM::Core &core);
42 
45 
47  FaceElementForcesAndSourcesCore::NO_CONTRAVARIANT_TRANSFORM_HDIV |
48  FaceElementForcesAndSourcesCore::NO_COVARIANT_TRANSFORM_HCURL>;
52 
53  inline boost::shared_ptr<FEMethod> &getDomainLhsFE();
54 
55  inline boost::shared_ptr<FEMethod> &getDomainRhsFE();
56 
57  inline boost::shared_ptr<FEMethod> &getBoundaryLhsFE();
58 
59  inline boost::shared_ptr<FEMethod> &getBoundaryRhsFE();
60 
61  inline boost::shared_ptr<FEMethod> &getSkeletonLhsFE();
62 
63  inline boost::shared_ptr<FEMethod> &getSkeletonRhsFE();
64 
65  template <int DIM = -1>
67 
68  template <int DIM = -1>
70 
71  template <int DIM = -1>
73 
74  template <int DIM = -1>
76 
77  template <int DIM = -1>
79 
80  template <int DIM = -1>
82 
83  /**
84  * @brief Get the Op Domain Lhs Pipeline object
85  * @ingroup mofem_basic_interface
86  *
87  * @tparam -1
88  * @return boost::ptr_vector<UserDataOperator>&
89  */
90  template <int DIM = -1>
91  inline boost::ptr_vector<UserDataOperator> &
93 
94  /**
95  * @brief Get the Op Domain Rhs Pipeline object
96  * @ingroup mofem_basic_interface
97  *
98  * @tparam -1
99  * @return boost::ptr_vector<UserDataOperator>&
100  */
101  template <int DIM = -1>
102  inline boost::ptr_vector<UserDataOperator> &
104 
105  /**
106  * @brief Get the Op Boundary Lhs Pipeline object
107  * @ingroup mofem_basic_interface
108  *
109  * @tparam -1
110  * @return boost::ptr_vector<UserDataOperator>&
111  */
112  template <int DIM = -1>
113  inline boost::ptr_vector<UserDataOperator> &
115 
116  /**
117  * @brief Get the Op Boundary Rhs Pipeline object
118  * @ingroup mofem_basic_interface
119  *
120  * @tparam -1
121  * @return boost::ptr_vector<UserDataOperator>&
122  */
123  template <int DIM = -1>
124  inline boost::ptr_vector<UserDataOperator> &
126 
127  /**
128  * @brief Get the Op Skeleton Lhs Pipeline object
129  * @ingroup mofem_basic_interface
130  *
131  * @return boost::ptr_vector<UserDataOperator>&
132  */
133  template <int DIM = -1>
134  inline boost::ptr_vector<UserDataOperator> &
136 
137  /**
138  * @brief Get the Op Skeleton Rhs Pipeline object
139  * @ingroup mofem_basic_interface
140  *
141  * @tparam -1
142  * @return boost::ptr_vector<UserDataOperator>&
143  */
144  template <int DIM = -1>
145  inline boost::ptr_vector<UserDataOperator> &
147 
148  /**
149  * @brief Iterate finite elements
150  * @ingroup mofem_basic_interface
151  *
152  * @return MoFEMErrorCode
153  */
155 
156  /**
157  * @brief Create KSP (linear) solver
158  * @ingroup mofem_basic_interface
159  *
160  * @param dm
161  * @return SmartPetscObj<KSP>
162  */
164 
165  /**
166  * @brief Create SNES (nonlinear) solver
167  * @ingroup mofem_basic_interface
168  *
169  * @param dm
170  * @return SmartPetscObj<SNES>
171  */
173 
174  /**
175  * @brief Create TS (time) solver
176  * @ingroup mofem_basic_interface
177  *
178  * @param dm
179  * @return SmartPetscObj<TS>
180  */
182 
183 private:
185 
186  boost::shared_ptr<FEMethod>
187  feDomainRhs; ///< Element to assemble RHS side by integrating domain
188  boost::shared_ptr<FEMethod>
189  feDomainLhs; ///< Element to assemble LHS side by integrating domain
190  boost::shared_ptr<FEMethod>
191  feBoundaryRhs; ///< Element to assemble RHS side by integrating boundary
192  boost::shared_ptr<FEMethod>
193  feBoundaryLhs; ///< Element to assemble LHS side by integrating boundary
194  boost::shared_ptr<FEMethod>
195  feSkeletonRhs; ///< Element to assemble RHS side by integrating skeleton
196  boost::shared_ptr<FEMethod>
197  feSkeletonLhs; ///< Element to assemble LHS side by integrating skeleton
198 
199  template <int DIM>
200  inline boost::shared_ptr<FEMethod> &
201  createDomainFEPipeline(boost::shared_ptr<FEMethod> &fe);
202 
203  template <int DIM>
204  inline boost::shared_ptr<FEMethod> &
205  createBoundaryFEPipeline(boost::shared_ptr<FEMethod> &fe);
206 };
207 
208 template <int DIM>
209 boost::shared_ptr<FEMethod> &
210 PipelineManager::createDomainFEPipeline(boost::shared_ptr<FEMethod> &fe) {
211  static_assert(DIM == 1 || DIM == 2 || DIM == 3, "not implemented");
212  fe = boost::make_shared<FEMethod>();
213  return fe;
214 }
215 
216 template <>
217 inline boost::shared_ptr<FEMethod> &
218 PipelineManager::createDomainFEPipeline<3>(boost::shared_ptr<FEMethod> &fe) {
219  if (!fe)
220  fe = boost::make_shared<VolumeElementForcesAndSourcesCore>(cOre);
221  return fe;
222 }
223 
224 template <>
225 inline boost::shared_ptr<FEMethod> &
226 PipelineManager::createDomainFEPipeline<2>(boost::shared_ptr<FEMethod> &fe) {
227  if (!fe)
228  fe = boost::make_shared<FaceEle2D>(cOre);
229  return fe;
230 }
231 
232 template <>
233 inline boost::shared_ptr<FEMethod> &
234 PipelineManager::createDomainFEPipeline<1>(boost::shared_ptr<FEMethod> &fe) {
235  if (!fe)
236  fe = boost::make_shared<EdgeEle1D>(cOre);
237  return fe;
238 }
239 
240 template <int DIM>
241 boost::shared_ptr<FEMethod> &
242 PipelineManager::createBoundaryFEPipeline(boost::shared_ptr<FEMethod> &fe) {
243  static_assert(DIM == 1 || DIM == 2 || DIM == 3, "not implemented");
244  fe = boost::make_shared<FEMethod>();
245  return fe;
246 }
247 
248 template <>
249 inline boost::shared_ptr<FEMethod> &
250 PipelineManager::createBoundaryFEPipeline<3>(boost::shared_ptr<FEMethod> &fe) {
251  if (!fe)
252  fe = boost::make_shared<FaceElementForcesAndSourcesCore>(cOre);
253  return fe;
254 }
255 
256 template <>
257 inline boost::shared_ptr<FEMethod> &
258 PipelineManager::createBoundaryFEPipeline<2>(boost::shared_ptr<FEMethod> &fe) {
259  if (!fe)
260  fe = boost::make_shared<EdgeEle2D>(cOre);
261  return fe;
262 }
263 
264 template <>
265 inline boost::shared_ptr<FEMethod> &
266 PipelineManager::createBoundaryFEPipeline<1>(boost::shared_ptr<FEMethod> &fe) {
267  if (!fe)
268  fe = boost::make_shared<VertexElementForcesAndSourcesCore>(cOre);
269  return fe;
270 }
271 
272 boost::shared_ptr<FEMethod> &PipelineManager::getDomainLhsFE() { return feDomainLhs; }
273 
274 boost::shared_ptr<FEMethod> &PipelineManager::getDomainRhsFE() { return feDomainRhs; }
275 
276 boost::shared_ptr<FEMethod> &PipelineManager::getBoundaryLhsFE() { return feBoundaryLhs; }
277 
278 boost::shared_ptr<FEMethod> &PipelineManager::getBoundaryRhsFE() { return feBoundaryRhs; }
279 
280 boost::shared_ptr<FEMethod> &PipelineManager::getSkeletonLhsFE() { return feSkeletonLhs; }
281 
282 boost::shared_ptr<FEMethod> &PipelineManager::getSkeletonRhsFE() { return feSkeletonRhs; }
283 
284 template <int DIM>
287  boost::dynamic_pointer_cast<ForcesAndSourcesCore>(
288  createDomainFEPipeline<DIM>(feDomainLhs))
289  ->getRuleHook = rule;
291 }
292 
293 template <>
294 inline MoFEMErrorCode
297  switch (cOre.getInterface<Simple>()->getDim()) {
298  case 1:
299  return setDomainLhsIntegrationRule<1>(rule);
300  case 2:
301  return setDomainLhsIntegrationRule<2>(rule);
302  case 3:
303  return setDomainLhsIntegrationRule<3>(rule);
304  default:
305  THROW_MESSAGE("Not implemented");
306  }
308 }
309 
310 template <int DIM>
313  boost::dynamic_pointer_cast<ForcesAndSourcesCore>(
314  createDomainFEPipeline<DIM>(feDomainRhs))
315  ->getRuleHook = rule;
317 }
318 
319 template <>
320 inline MoFEMErrorCode
323  switch (cOre.getInterface<Simple>()->getDim()) {
324  case 1:
325  return setDomainRhsIntegrationRule<1>(rule);
326  case 2:
327  return setDomainRhsIntegrationRule<2>(rule);
328  case 3:
329  return setDomainRhsIntegrationRule<3>(rule);
330  default:
331  THROW_MESSAGE("Not implemented");
332  }
334 }
335 
336 template <int DIM>
339  boost::dynamic_pointer_cast<ForcesAndSourcesCore>(
340  createBoundaryFEPipeline<DIM>(feBoundaryLhs))
341  ->getRuleHook = rule;
343 }
344 
345 template <>
346 inline MoFEMErrorCode
349  switch (cOre.getInterface<Simple>()->getDim()) {
350  case 1:
351  return setBoundaryLhsIntegrationRule<1>(rule);
352  case 2:
353  return setBoundaryLhsIntegrationRule<2>(rule);
354  case 3:
355  return setBoundaryLhsIntegrationRule<3>(rule);
356  default:
357  THROW_MESSAGE("Not implemented");
358  }
360 }
361 
362 template <int DIM>
365  boost::dynamic_pointer_cast<ForcesAndSourcesCore>(
366  createBoundaryFEPipeline<DIM>(feBoundaryRhs))
367  ->getRuleHook = rule;
369 }
370 
371 template <>
372 inline MoFEMErrorCode
375  switch (cOre.getInterface<Simple>()->getDim()) {
376  case 1:
377  return setBoundaryRhsIntegrationRule<1>(rule);
378  case 2:
379  return setBoundaryRhsIntegrationRule<2>(rule);
380  case 3:
381  return setBoundaryRhsIntegrationRule<3>(rule);
382  default:
383  THROW_MESSAGE("Not implemented");
384  }
386 }
387 
388 template <int DIM>
391  boost::dynamic_pointer_cast<ForcesAndSourcesCore>(
392  createBoundaryFEPipeline<DIM>(feSkeletonLhs))
393  ->getRuleHook = rule;
395 }
396 
397 template <>
398 inline MoFEMErrorCode
401  switch (cOre.getInterface<Simple>()->getDim()) {
402  case 1:
403  return setSkeletonLhsIntegrationRule<1>(rule);
404  case 2:
405  return setSkeletonLhsIntegrationRule<2>(rule);
406  case 3:
407  return setSkeletonLhsIntegrationRule<3>(rule);
408  default:
409  THROW_MESSAGE("Not implemented");
410  }
412 }
413 
414 template <int DIM>
417  boost::dynamic_pointer_cast<ForcesAndSourcesCore>(
418  createBoundaryFEPipeline<DIM>(feSkeletonRhs))
419  ->getRuleHook = rule;
421 }
422 
423 template <>
424 inline MoFEMErrorCode
427  switch (cOre.getInterface<Simple>()->getDim()) {
428  case 1:
429  return setSkeletonRhsIntegrationRule<1>(rule);
430  case 2:
431  return setSkeletonRhsIntegrationRule<2>(rule);
432  case 3:
433  return setSkeletonRhsIntegrationRule<3>(rule);
434  default:
435  THROW_MESSAGE("Not implemented");
436  }
438 }
439 
440 template <int DIM>
441 boost::ptr_vector<PipelineManager::UserDataOperator> &
443  return boost::dynamic_pointer_cast<ForcesAndSourcesCore>(
444  createDomainFEPipeline<DIM>(feDomainLhs))
445  ->getOpPtrVector();
446 }
447 
448 template <>
449 inline boost::ptr_vector<PipelineManager::UserDataOperator> &
451  switch (cOre.getInterface<Simple>()->getDim()) {
452  case 1:
453  return getOpDomainLhsPipeline<1>();
454  case 2:
455  return getOpDomainLhsPipeline<2>();
456  case 3:
457  break;
458  default:
459  THROW_MESSAGE("Not implemented");
460  }
461  return getOpDomainLhsPipeline<3>();
462 }
463 
464 template <int DIM>
465 boost::ptr_vector<PipelineManager::UserDataOperator> &
467  return boost::dynamic_pointer_cast<ForcesAndSourcesCore>(
468  createDomainFEPipeline<DIM>(feDomainRhs))
469  ->getOpPtrVector();
470 }
471 
472 template <>
473 inline boost::ptr_vector<PipelineManager::UserDataOperator> &
475  switch (cOre.getInterface<Simple>()->getDim()) {
476  case 1:
477  return getOpDomainRhsPipeline<1>();
478  case 2:
479  return getOpDomainRhsPipeline<2>();
480  case 3:
481  break;
482  default:
483  THROW_MESSAGE("Not implemented");
484  }
485  return getOpDomainRhsPipeline<3>();
486 }
487 
488 template <int DIM>
489 boost::ptr_vector<PipelineManager::UserDataOperator> &
491  return boost::dynamic_pointer_cast<ForcesAndSourcesCore>(
492  createBoundaryFEPipeline<DIM>(feBoundaryLhs))
493  ->getOpPtrVector();
494 }
495 
496 template <>
497 inline boost::ptr_vector<PipelineManager::UserDataOperator> &
499  switch (cOre.getInterface<Simple>()->getDim()) {
500  case 1:
501  return getOpBoundaryLhsPipeline<1>();
502  case 2:
503  return getOpBoundaryLhsPipeline<2>();
504  case 3:
505  break;
506  default:
507  THROW_MESSAGE("Not implemented");
508  }
509  return getOpBoundaryLhsPipeline<3>();
510 }
511 
512 template <int DIM>
513 boost::ptr_vector<PipelineManager::UserDataOperator> &
515  return boost::dynamic_pointer_cast<ForcesAndSourcesCore>(
516  createBoundaryFEPipeline<DIM>(feBoundaryRhs))
517  ->getOpPtrVector();
518 }
519 
520 template <>
521 inline boost::ptr_vector<PipelineManager::UserDataOperator> &
523  switch (cOre.getInterface<Simple>()->getDim()) {
524  case 1:
525  return getOpBoundaryRhsPipeline<1>();
526  case 2:
527  return getOpBoundaryRhsPipeline<2>();
528  case 3:
529  break;
530  default:
531  THROW_MESSAGE("Not implemented");
532  }
533  return getOpBoundaryRhsPipeline<3>();
534 }
535 
536 template <int DIM>
537 boost::ptr_vector<PipelineManager::UserDataOperator> &
539  return boost::dynamic_pointer_cast<ForcesAndSourcesCore>(
540  createBoundaryFEPipeline<DIM>(feSkeletonRhs))
541  ->getOpPtrVector();
542 }
543 
544 template <>
545 inline boost::ptr_vector<PipelineManager::UserDataOperator> &
547  switch (cOre.getInterface<Simple>()->getDim()) {
548  case 1:
549  return getOpSkeletonLhsPipeline<1>();
550  case 2:
551  return getOpSkeletonLhsPipeline<2>();
552  case 3:
553  break;
554  default:
555  THROW_MESSAGE("Not implemented");
556  }
557  return getOpSkeletonLhsPipeline<3>();
558 }
559 
560 template <int DIM>
561 boost::ptr_vector<PipelineManager::UserDataOperator> &
563  return boost::dynamic_pointer_cast<ForcesAndSourcesCore>(
564  createBoundaryFEPipeline<DIM>(feSkeletonLhs))
565  ->getOpPtrVector();
566 }
567 
568 template <>
569 inline boost::ptr_vector<PipelineManager::UserDataOperator> &
571  switch (cOre.getInterface<Simple>()->getDim()) {
572  case 1:
573  return getOpSkeletonRhsPipeline<1>();
574  case 2:
575  return getOpSkeletonRhsPipeline<2>();
576  case 3:
577  break;
578  default:
579  THROW_MESSAGE("Not implemented");
580  }
581  return getOpSkeletonRhsPipeline<3>();
582 }
583 
584 } // namespace MoFEM
585 
586 #endif // __BASIC_HPP__
587 
588 /**
589  * \defgroup mofem_basic_interface PipelineManager interface
590  * \brief Implementation of basic interface for rapid problem implementation.
591  *
592  * \ingroup mofem
593  **/
boost::shared_ptr< FEMethod > & getDomainLhsFE()
int getDim() const
Get the problem dimensio.
Definition: Simple.hpp:274
boost::ptr_vector< UserDataOperator > & getOpDomainRhsPipeline()
Get the Op Domain Rhs Pipeline object.
MoFEM interface unique ID.
MoFEM::EdgeElementForcesAndSourcesCoreSwitch< EdgeElementForcesAndSourcesCore::NO_COVARIANT_TRANSFORM_HCURL > EdgeEle2D
boost::shared_ptr< FEMethod > feBoundaryLhs
Element to assemble LHS side by integrating boundary.
MoFEM::ForcesAndSourcesCore::RuleHookFun RuleHookFun
SmartPetscObj< TS > createTS(SmartPetscObj< DM > dm=nullptr)
Create TS (time) solver.
MoFEMErrorCode setSkeletonRhsIntegrationRule(RuleHookFun rule)
MoFEMErrorCode setBoundaryLhsIntegrationRule(RuleHookFun rule)
base class for all interface classes
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:483
boost::shared_ptr< FEMethod > feDomainLhs
Element to assemble LHS side by integrating domain.
boost::shared_ptr< FEMethod > & createDomainFEPipeline(boost::shared_ptr< FEMethod > &fe)
boost::shared_ptr< FEMethod > feSkeletonRhs
Element to assemble RHS side by integrating skeleton.
boost::shared_ptr< FEMethod > & createBoundaryFEPipeline(boost::shared_ptr< FEMethod > &fe)
#define THROW_MESSAGE(a)
Throw MoFEM exception.
Definition: definitions.h:626
Core (interface) class.
Definition: Core.hpp:50
MoFEM interface.
Edge finite elementUser is implementing own operator at Gauss points level, by own object derived fro...
std::bitset< BITINTERFACEUID_SIZE > BitIntefaceId
Definition: Types.hpp:55
implementation of Data Operators for Forces and Sources
Definition: Common.hpp:21
Simple interface for fast problem set-up.
Definition: Simple.hpp:36
boost::ptr_vector< UserDataOperator > & getOpDomainLhsPipeline()
Get the Op Domain Lhs Pipeline object.
boost::shared_ptr< FEMethod > feDomainRhs
Element to assemble RHS side by integrating domain.
MoFEMErrorCode query_interface(const MOFEMuuid &uuid, UnknownInterface **iface) const
SmartPetscObj< KSP > createKSP(SmartPetscObj< DM > dm=nullptr)
Create KSP (linear) solver.
PetscErrorCode MoFEMErrorCode
MoFEM/PETSc error code.
Definition: Exceptions.hpp:67
boost::ptr_vector< UserDataOperator > & getOpSkeletonLhsPipeline()
Get the Op Skeleton Lhs Pipeline object.
static const MOFEMuuid IDD_MOFEMBasic
boost::shared_ptr< FEMethod > & getDomainRhsFE()
boost::shared_ptr< FEMethod > & getBoundaryRhsFE()
boost::function< int(int order_row, int order_col, int order_data)> RuleHookFun
MoFEMErrorCode setSkeletonLhsIntegrationRule(RuleHookFun rule)
PipelineManager interface.
boost::shared_ptr< FEMethod > & getBoundaryLhsFE()
MoFEMErrorCode loopFiniteElements(SmartPetscObj< DM > dm=nullptr)
Iterate finite elements.
SmartPetscObj< SNES > createSNES(SmartPetscObj< DM > dm=nullptr)
Create SNES (nonlinear) solver.
boost::ptr_vector< UserDataOperator > & getOpSkeletonRhsPipeline()
Get the Op Skeleton Rhs Pipeline object.
PipelineManager(const MoFEM::Core &core)
MoFEMErrorCode setDomainRhsIntegrationRule(RuleHookFun rule)
boost::ptr_vector< UserDataOperator > & getOpBoundaryLhsPipeline()
Get the Op Boundary Lhs Pipeline object.
MoFEMErrorCode setBoundaryRhsIntegrationRule(RuleHookFun rule)
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:413
MoFEMErrorCode setDomainLhsIntegrationRule(RuleHookFun rule)
Data operator to do calculations at integration points.Is inherited and implemented by user to do cal...
boost::shared_ptr< FEMethod > feBoundaryRhs
Element to assemble RHS side by integrating boundary.
boost::ptr_vector< UserDataOperator > & getOpBoundaryRhsPipeline()
Get the Op Boundary Rhs Pipeline object.
boost::shared_ptr< FEMethod > & getSkeletonLhsFE()
boost::shared_ptr< FEMethod > & getSkeletonRhsFE()
boost::shared_ptr< FEMethod > feSkeletonLhs
Element to assemble LHS side by integrating skeleton.