v0.14.0
AuxPETSc.hpp
Go to the documentation of this file.
1 /** \file AuxPETSc.hpp
2  * \brief Auxiliary MoFEM-PETSc structures
3  */
4 
5 
6 
7 #ifndef __AUXPETSC_HPP__
8 #define __AUXPETSC_HPP__
9 
10 namespace MoFEM {
11 
12 struct PairNameFEMethodPtr : public std::pair<std::string, FEMethod *> {
13 
14  PairNameFEMethodPtr(std::string name, FEMethod *ptr)
15  : std::pair<std::string, FEMethod *>(name, ptr) {}
16  template <typename FEMETHOD>
17  PairNameFEMethodPtr(std::string name, boost::shared_ptr<FEMETHOD> ptr)
18  : std::pair<std::string, FEMethod *>(name, ptr.get()), fePtr(ptr) {}
19 
20  virtual ~PairNameFEMethodPtr() = default;
21 
22  inline boost::shared_ptr<BasicMethod> getSharedPtr() const {
23  if (!fePtr)
24  THROW_MESSAGE("Shared pointer not set. You have to be using raw "
25  "pointer, that is unsafe.");
26  return fePtr;
27  }
28 
29 private:
30  boost::shared_ptr<FEMethod> fePtr;
31 };
32 
35  template <typename BASICMETHOD>
36  BasicMethodPtr(boost::shared_ptr<BASICMETHOD> ptr)
37  : rawPtr(ptr.get()), bmPtr(ptr) {}
38 
39  virtual ~BasicMethodPtr() = default;
40 
41  inline BasicMethod &operator*() const { return *rawPtr; };
42  inline BasicMethod *operator->() const { return rawPtr; }
43 
44  inline boost::shared_ptr<BasicMethod> getSharedPtr() const {
45  if (!bmPtr)
46  THROW_MESSAGE("Shared pointer not set. You have to be using raw "
47  "pointer, that is unsafe.");
48  return bmPtr;
49  }
50 
51 private:
53  boost::shared_ptr<BasicMethod> bmPtr;
54 };
55 
56 typedef std::deque<PairNameFEMethodPtr> FEMethodsSequence;
57 typedef std::deque<BasicMethodPtr> BasicMethodsSequence;
58 
59 } // namespace MoFEM
60 
61 #endif // __AUXPETSC_HPP__
62 
63 /**
64  * \defgroup mofem_petsc_solvers PETSc solvers
65  * \brief PETSc solvers
66  *
67  * \ingroup mofem
68  */
MoFEM::PairNameFEMethodPtr::PairNameFEMethodPtr
PairNameFEMethodPtr(std::string name, boost::shared_ptr< FEMETHOD > ptr)
Definition: AuxPETSc.hpp:17
MoFEM::BasicMethodPtr::BasicMethodPtr
BasicMethodPtr(BasicMethod *ptr)
Definition: AuxPETSc.hpp:34
MoFEM::PairNameFEMethodPtr::fePtr
boost::shared_ptr< FEMethod > fePtr
Definition: AuxPETSc.hpp:30
MoFEM::FEMethod
structure for User Loop Methods on finite elements
Definition: LoopMethods.hpp:369
MoFEM::FEMethodsSequence
std::deque< PairNameFEMethodPtr > FEMethodsSequence
Definition: AuxPETSc.hpp:56
MoFEM::BasicMethodPtr::BasicMethodPtr
BasicMethodPtr(boost::shared_ptr< BASICMETHOD > ptr)
Definition: AuxPETSc.hpp:36
THROW_MESSAGE
#define THROW_MESSAGE(msg)
Throw MoFEM exception.
Definition: definitions.h:574
MoFEM::BasicMethodPtr::operator*
BasicMethod & operator*() const
Definition: AuxPETSc.hpp:41
MoFEM::BasicMethodPtr::getSharedPtr
boost::shared_ptr< BasicMethod > getSharedPtr() const
Definition: AuxPETSc.hpp:44
MoFEM
implementation of Data Operators for Forces and Sources
Definition: Common.hpp:10
MoFEM::BasicMethodPtr::operator->
BasicMethod * operator->() const
Definition: AuxPETSc.hpp:42
MoFEM::BasicMethodsSequence
std::deque< BasicMethodPtr > BasicMethodsSequence
Definition: AuxPETSc.hpp:57
MoFEM::PairNameFEMethodPtr
Definition: AuxPETSc.hpp:12
MoFEM::BasicMethodPtr::bmPtr
boost::shared_ptr< BasicMethod > bmPtr
Definition: AuxPETSc.hpp:53
MoFEM::BasicMethod
Data structure to exchange data between mofem and User Loop Methods.
Definition: LoopMethods.hpp:183
MoFEM::BasicMethodPtr::~BasicMethodPtr
virtual ~BasicMethodPtr()=default
MoFEM::PairNameFEMethodPtr::~PairNameFEMethodPtr
virtual ~PairNameFEMethodPtr()=default
MoFEM::PairNameFEMethodPtr::getSharedPtr
boost::shared_ptr< BasicMethod > getSharedPtr() const
Definition: AuxPETSc.hpp:22
MoFEM::BasicMethodPtr::rawPtr
BasicMethod * rawPtr
Definition: AuxPETSc.hpp:52
std
Definition: enable_if.hpp:5
MoFEM::PairNameFEMethodPtr::PairNameFEMethodPtr
PairNameFEMethodPtr(std::string name, FEMethod *ptr)
Definition: AuxPETSc.hpp:14
MoFEM::BasicMethodPtr
Definition: AuxPETSc.hpp:33