v0.9.0
Simple.hpp
Go to the documentation of this file.
1 /** \file Simple.hpp
2  * \brief Header file for simple interface
3  * \ingroup mofem_simple_interface
4  *
5  * Make simplified 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 __SIMPLE_HPP__
23 #define __SIMPLE_HPP__
24 
25 #include "UnknownInterface.hpp"
26 
27 namespace MoFEM {
28 
29 static const MOFEMuuid IDD_MOFEMSimple =
31 
32 /**
33  * \brief Simple interface for fast problem set-up
34  * \ingroup mofem_simple_interface
35  */
36 struct Simple : public UnknownInterface {
37 
39  UnknownInterface **iface) const;
40 
42  Simple(const MoFEM::Core &core);
43 
44  /**
45  * \brief Destructor
46  */
47  ~Simple();
48 
49  /**
50  * \brief get options
51  * @return error code
52  */
54 
55  /**
56  * \brief Load mesh file
57  * @param field_name file name
58  * @return error code
59  */
61  loadFile(const std::string options = "PARALLEL=READ_PART;"
62  "PARALLEL_RESOLVE_SHARED_ENTS;"
63  "PARTITION=PARALLEL_PARTITION;");
64 
65  /**
66  * \brief Add field on domain
67  * @param name name of the filed
68  * @param space space (L2,H1,Hdiv,Hcurl)
69  * @param base approximation base, see FieldApproximationBase
70  * @param nb_of_coefficients number of field coefficients
71  * @param tag_type type of the tag MB_TAG_DENSE or MB_TAG_SPARSE
72  * (DENSE is faster and uses less memory, SPARSE is more flexible if you
73  * define field on subdomains)
74  * @param bh if MF_EXCL throws error if field exits, MF_ZERO
75  * no error if field exist
76  * @param verb verbosity level
77  * @return error code
78  */
80  addDomainField(const std::string &name, const FieldSpace space,
81  const FieldApproximationBase base,
82  const FieldCoefficientsNumber nb_of_coefficients,
83  const TagType tag_type = MB_TAG_SPARSE,
84  const enum MoFEMTypes bh = MF_ZERO, int verb = -1);
85 
86  /**
87  * \brief Add field on boundary
88  * @param name name of the filed
89  * @param space space (L2,H1,Hdiv,Hcurl)
90  * @param base approximation base, see FieldApproximationBase
91  * @param nb_of_coefficients number of field coefficients
92  * @param tag_type type of the tag MB_TAG_DENSE or MB_TAG_SPARSE
93  * (DENSE is faster and uses less memory, SPARSE is more flexible if you
94  * define field on subdomains)
95  * @param bh if MF_EXCL throws error if field exits, MF_ZERO
96  * no error if field exist
97  * @param verb verbosity level
98  * @return error code
99  */
101  addBoundaryField(const std::string &name, const FieldSpace space,
102  const FieldApproximationBase base,
103  const FieldCoefficientsNumber nb_of_coefficients,
104  const TagType tag_type = MB_TAG_SPARSE,
105  const enum MoFEMTypes bh = MF_ZERO, int verb = -1);
106 
107  /**
108  * \brief Add field on skeleton
109  * @param name name of the filed
110  * @param space space (L2,H1,Hdiv,Hcurl)
111  * @param base approximation base, see FieldApproximationBase
112  * @param nb_of_coefficients number of field coefficients
113  * @param tag_type type of the tag MB_TAG_DENSE or MB_TAG_SPARSE
114  * (DENSE is faster and uses less memory, SPARSE is more flexible if you
115  * define field on subdomains)
116  * @param bh if MF_EXCL throws error if field exits, MF_ZERO
117  * no error if field exist
118  * @param verb verbosity level
119  * @return error code
120  */
122  addSkeletonField(const std::string &name, const FieldSpace space,
123  const FieldApproximationBase base,
124  const FieldCoefficientsNumber nb_of_coefficients,
125  const TagType tag_type = MB_TAG_SPARSE,
126  const enum MoFEMTypes bh = MF_ZERO, int verb = -1);
127 
128  /**
129  * \brief Add field on domain
130  * @param name name of the filed
131  * @param space space (L2,H1,Hdiv,Hcurl)
132  * @param base approximation base, see FieldApproximationBase
133  * @param nb_of_coefficients number of field coefficients
134  * @param tag_type type of the tag MB_TAG_DENSE or MB_TAG_SPARSE
135  * (DENSE is faster and uses less memory, SPARSE is more flexible if you
136  * define field on subdomains)
137  * @param bh if MF_EXCL throws error if field exits, MF_ZERO
138  * no error if field exist
139  * @param verb verbosity level
140  * @return error code
141  */
142  MoFEMErrorCode addDataField(const std::string &name, const FieldSpace space,
143  const FieldApproximationBase base,
144  const FieldCoefficientsNumber nb_of_coefficients,
145  const TagType tag_type = MB_TAG_SPARSE,
146  const enum MoFEMTypes bh = MF_ZERO,
147  int verb = -1);
148 
149  /**
150  * \brief Define finite elements
151  * @return Error code
152  */
154 
155  /**
156  * \brief define problem
157  * @return error code
158  */
159  MoFEMErrorCode defineProblem(const PetscBool is_partitioned = PETSC_TRUE);
160 
161  /**
162  * \brief Set field order
163  * @param std::field_name field name
164  * @param order order
165  * @param range of entities to which order is set (If null it sat to all
166  * entities)
167  * @return error code
168  */
169  MoFEMErrorCode setFieldOrder(const std::string field_name, const int order,
170  const Range *ents = NULL);
171 
172  /**
173  * \brief Build fields
174  * @return error code
175  */
177 
178  /**
179  * \brief Build finite elements
180  * @return error code
181  */
183 
184  /**
185  * \brief Build problem
186  * @return error code
187  */
189 
190  /**
191  * \brief Setup problem
192  * @return error code
193  */
194  MoFEMErrorCode setUp(const PetscBool is_partitioned = PETSC_TRUE);
195 
196  /**
197  * \brief Get DM
198  * @param dm discrete manager
199  * @return error code
200  */
201  MoFEMErrorCode getDM(DM *dm);
202 
203  /**
204  * @brief Return smart DM object
205  *
206  * \code
207  * {
208  * auto dm = simple_interface->getDM();
209  *
210  * // ...
211  *
212  * // dm is automatically destroyed when out of the scope
213  * }
214  * \endcode
215  *
216  * @return SmartPetscObj<DM>
217  */
218  inline SmartPetscObj<DM> getDM() { return dM; }
219 
220  inline int getDim() const { return dIm; }
221  inline const std::string getDomainFEName() const { return domainFE; }
222  inline const std::string getBoundaryFEName() const { return boundaryFE; }
223  inline const std::string getSkeletonFEName() const { return skeletonFE; }
224  inline const std::string getProblemName() const { return nameOfProblem; }
225 
226  inline std::string &getDomainFEName() { return domainFE; }
227  inline std::string &getBoundaryFEName() { return boundaryFE; }
228  inline std::string &getSkeletonFEName() { return skeletonFE; }
229  inline std::string &getProblemName() { return nameOfProblem; }
230 
231  inline std::vector<std::string> &getOtherFiniteElements() { return otherFEs; }
232 
233 private:
235 
241 
242  EntityHandle meshSet; ///< domain meshset
243  EntityHandle boundaryMeshset; ///< meshset with boundary
244  std::vector<std::string> domainFields; ///< domain fields
245  std::vector<std::string> boundaryFields; ///< boundary fields
246  std::vector<std::string> skeletonFields; ///< fields on the skeleton
247  std::vector<std::string> dataFields; ///< Data fields
248 
249  std::map<std::string, std::pair<int, Range>> fieldsOrder; ///< fields order
250 
251  std::string nameOfProblem; ///< problem name
252  std::string domainFE; ///< domain finite element
253  std::string boundaryFE; ///< boundary finite element
254  std::string skeletonFE; ///< skeleton finite element
255 
256  std::vector<std::string> otherFEs; ///< Other finite elements
257 
258  char meshFileName[255]; ///< mesh file name
259  int dIm; ///< dimension of problem
260 
262 };
263 
264 } // namespace MoFEM
265 
266 #endif // __SIMPLE_HPP__
267 
268 /**
269  * \defgroup mofem_simple_interface Simple interface
270  * \brief Implementation of simple interface for fast problem set-up.
271  *
272  * \ingroup mofem
273  **/
std::string boundaryFE
boundary finite element
Definition: Simple.hpp:253
std::string domainFE
domain finite element
Definition: Simple.hpp:252
MoFEM::Core & cOre
Definition: Simple.hpp:41
MoFEMErrorCode buildFiniteElements()
Build finite elements.
Definition: Simple.cpp:468
EntityHandle meshSet
domain meshset
Definition: Simple.hpp:242
MoFEMErrorCode setUp(const PetscBool is_partitioned=PETSC_TRUE)
Setup problem.
Definition: Simple.cpp:507
int getDim() const
Definition: Simple.hpp:220
MoFEM interface unique ID.
const std::string getBoundaryFEName() const
Definition: Simple.hpp:222
MoFEMErrorCode defineFiniteElements()
Define finite elements.
Definition: Simple.cpp:159
char meshFileName[255]
mesh file name
Definition: Simple.hpp:258
int dIm
dimension of problem
Definition: Simple.hpp:259
SmartPetscObj< DM > dM
Definition: Simple.hpp:261
base class for all interface classes
const std::string getSkeletonFEName() const
Definition: Simple.hpp:223
std::vector< std::string > boundaryFields
boundary fields
Definition: Simple.hpp:245
Core (interface) class.
Definition: Core.hpp:50
MoFEM interface.
MoFEMErrorCode loadFile(const std::string options="PARALLEL=READ_PART;" "PARALLEL_RESOLVE_SHARED_ENTS;" "PARTITION=PARALLEL_PARTITION;")
Load mesh file.
Definition: Simple.cpp:62
std::string & getSkeletonFEName()
Definition: Simple.hpp:228
std::vector< std::string > otherFEs
Other finite elements.
Definition: Simple.hpp:256
std::bitset< BITINTERFACEUID_SIZE > BitIntefaceId
Definition: Types.hpp:56
implementation of Data Operators for Forces and Sources
Definition: Common.hpp:21
std::string skeletonFE
skeleton finite element
Definition: Simple.hpp:254
Simple interface for fast problem set-up.
Definition: Simple.hpp:36
static const MOFEMuuid IDD_MOFEMSimple
Definition: Simple.hpp:29
std::map< std::string, std::pair< int, Range > > fieldsOrder
fields order
Definition: Simple.hpp:249
std::vector< std::string > domainFields
domain fields
Definition: Simple.hpp:244
MoFEMErrorCode addDataField(const std::string &name, const FieldSpace space, const FieldApproximationBase base, const FieldCoefficientsNumber nb_of_coefficients, const TagType tag_type=MB_TAG_SPARSE, const enum MoFEMTypes bh=MF_ZERO, int verb=-1)
Add field on domain.
Definition: Simple.cpp:145
MoFEMErrorCode addBoundaryField(const std::string &name, const FieldSpace space, const FieldApproximationBase base, const FieldCoefficientsNumber nb_of_coefficients, const TagType tag_type=MB_TAG_SPARSE, const enum MoFEMTypes bh=MF_ZERO, int verb=-1)
Add field on boundary.
Definition: Simple.cpp:116
MoFEMErrorCode buildProblem()
Build problem.
Definition: Simple.cpp:494
FieldApproximationBase
approximation base
Definition: definitions.h:144
std::vector< std::string > dataFields
Data fields.
Definition: Simple.hpp:247
Simple(const MoFEM::Core &core)
Definition: Simple.cpp:34
MoFEMErrorCode buildFields()
Build fields.
Definition: Simple.cpp:264
PetscErrorCode MoFEMErrorCode
MoFEM/PETSc error code.
Definition: Exceptions.hpp:66
std::string & getDomainFEName()
Definition: Simple.hpp:226
MoFEMErrorCode query_interface(const MOFEMuuid &uuid, UnknownInterface **iface) const
Definition: Simple.cpp:22
~Simple()
Destructor.
Definition: Simple.cpp:46
MoFEMErrorCode addDomainField(const std::string &name, const FieldSpace space, const FieldApproximationBase base, const FieldCoefficientsNumber nb_of_coefficients, const TagType tag_type=MB_TAG_SPARSE, const enum MoFEMTypes bh=MF_ZERO, int verb=-1)
Add field on domain.
Definition: Simple.cpp:101
PetscLogEvent MOFEM_EVENT_SimpleLoadMesh
Definition: Simple.hpp:236
PetscLogEvent MOFEM_EVENT_SimpleBuildFields
Definition: Simple.hpp:237
std::string & getProblemName()
Definition: Simple.hpp:229
FieldSpace
approximation spaces
Definition: definitions.h:168
std::string nameOfProblem
problem name
Definition: Simple.hpp:251
const std::string getProblemName() const
Definition: Simple.hpp:224
MoFEMErrorCode addSkeletonField(const std::string &name, const FieldSpace space, const FieldApproximationBase base, const FieldCoefficientsNumber nb_of_coefficients, const TagType tag_type=MB_TAG_SPARSE, const enum MoFEMTypes bh=MF_ZERO, int verb=-1)
Add field on skeleton.
Definition: Simple.cpp:130
const std::string getDomainFEName() const
Definition: Simple.hpp:221
std::string & getBoundaryFEName()
Definition: Simple.hpp:227
std::bitset< BITREFLEVEL_SIZE > BitRefLevel
Bit structure attached to each entity identifying to what mesh entity is attached.
Definition: Types.hpp:51
EntityHandle boundaryMeshset
meshset with boundary
Definition: Simple.hpp:243
PetscLogEvent MOFEM_EVENT_SimpleBuildFiniteElements
Definition: Simple.hpp:238
SmartPetscObj< DM > getDM()
Return smart DM object.
Definition: Simple.hpp:218
PetscLogEvent MOFEM_EVENT_SimpleBuildProblem
Definition: Simple.hpp:239
std::vector< std::string > skeletonFields
fields on the skeleton
Definition: Simple.hpp:246
MoFEMErrorCode getOptions()
get options
Definition: Simple.cpp:48
std::vector< std::string > & getOtherFiniteElements()
Definition: Simple.hpp:231
MoFEMErrorCode setFieldOrder(const std::string field_name, const int order, const Range *ents=NULL)
Set field order.
Definition: Simple.cpp:256
const BitRefLevel bitLevel
Definition: Simple.hpp:234
MoFEMErrorCode defineProblem(const PetscBool is_partitioned=PETSC_TRUE)
define problem
Definition: Simple.cpp:233
MoFEMTypes
Those types control how functions respond on arguments, f.e. error handling.
Definition: definitions.h:183
PetscLogEvent MOFEM_EVENT_SimpleKSPSolve
Definition: Simple.hpp:240