13 {
14
16
17 try {
18
19 moab::Core mb_instance;
20 moab::Interface &moab = mb_instance;
21 int rank;
22 MPI_Comm_rank(PETSC_COMM_WORLD, &rank);
23
24
25 double tet_coords[] = {0, 0, 0, 2, 0, 0, 0, 2, 0, 0, 0, 2};
27 for (int nn = 0; nn < 4; nn++) {
28 CHKERR moab.create_vertex(&tet_coords[3 * nn], nodes[nn]);
29 }
31 CHKERR moab.create_element(MBTET, nodes, 4, tet);
32
33
36
37
39 bit_level0.set(0);
41 0, 3, bit_level0);
42
43
45
46
48
52 "HCURL");
53
54
56
60 "HCURL");
61
62
64
66 "HCURL");
68 "HCURL");
70 "HCURL");
71
72
74
75
77 "HCURL_TET_FE");
79 "HCURL_TRI_FE");
81 "HCURL_EDGE_FE");
82
84
85
87
89
91 "HCURL_TET_FE");
92
96 Skinner skin(&moab);
98 CHKERR skin.find_skin(0, tets,
false, skin_faces);
100 "HCURL_TRI_FE");
102 CHKERR moab.get_adjacencies(skin_faces, 1,
false, skin_edges,
103 moab::Interface::UNION);
105 "HCURL_EDGE_FE");
106
107
112
113
114
115
117
119
121
125
126
127
128
131
133
134 typedef tee_device<std::ostream, std::ofstream>
TeeDevice;
136
137 std::ofstream ofs("forces_and_sources_hcurl_approximation_functions.txt");
140
141 struct OpPrintingHdivApproximationFunctions
142 : public VolumeElementForcesAndSourcesCore::UserDataOperator {
143
145 OpPrintingHdivApproximationFunctions(
TeeStream &my_split)
148 mySplit(my_split) {}
149
153
156
157 mySplit << std::endl
158 <<
"type " <<
type <<
" side " << side << std::endl;
159
160 const double eps = 1e-4;
161 for (
unsigned int dd = 0;
dd < data.
getN().data().size();
dd++) {
162 if (std::abs(data.
getN().data()[dd]) <
eps)
163 data.
getN().data()[
dd] = 0;
164 }
165 for (
unsigned int dd = 0;
dd < data.
getDiffN().data().size();
dd++) {
168 }
169
170 mySplit << std::fixed << std::setprecision(5) << data.
getN()
171 << std::endl;
172 mySplit << std::fixed << std::setprecision(5) << data.
getDiffN()
173 << std::endl;
174
176 }
177 };
178
180
184 };
185
186 struct OpFacePrintingHdivApproximationFunctions
187 : public FaceElementForcesAndSourcesCore::UserDataOperator {
188
190 OpFacePrintingHdivApproximationFunctions(
TeeStream &my_split)
193 mySplit(my_split) {}
194
198
201
202 mySplit << std::endl
203 <<
"type " <<
type <<
" side " << side << std::endl;
204 mySplit.precision(5);
205
206 const double eps = 1e-4;
207 for (
unsigned int dd = 0;
dd < data.
getN().data().size();
dd++) {
208 if (std::abs(data.
getN().data()[dd]) <
eps)
209 data.
getN().data()[
dd] = 0;
210 }
211 for (
unsigned int dd = 0;
dd < data.
getDiffN().data().size();
dd++) {
214 }
215
216 mySplit << std::fixed << std::setprecision(5) << data.
getN()
217 << std::endl;
218 mySplit << std::fixed << std::setprecision(5) << data.
getDiffN()
219 << std::endl;
220
222 }
223 };
224
226
230 };
231
232 struct OpEdgePrintingHdivApproximationFunctions
233 : public EdgeElementForcesAndSourcesCore::UserDataOperator {
234
236 OpEdgePrintingHdivApproximationFunctions(
TeeStream &my_split)
239 mySplit(my_split) {}
240
244
247
248 mySplit << std::endl
249 <<
"type " <<
type <<
" side " << side << std::endl;
250 mySplit.precision(5);
251
252 const double eps = 1e-4;
253 for (
unsigned int dd = 0;
dd < data.
getN().data().size();
dd++) {
254 if (std::abs(data.
getN().data()[dd]) <
eps)
255 data.
getN().data()[
dd] = 0;
256 }
257
258 mySplit << std::fixed << std::setprecision(5) << data.
getN()
259 << std::endl;
260
262 }
263 };
264
266
270 };
271
272 MyFE tet_fe(m_field);
273 MyFaceFE tri_fe(m_field);
274 MyEdgeFE edge_fe(m_field);
275
276 tet_fe.getOpPtrVector().push_back(
277 new OpPrintingHdivApproximationFunctions(my_split));
278 tri_fe.getOpPtrVector().push_back(
280 tri_fe.getOpPtrVector().push_back(
281 new OpFacePrintingHdivApproximationFunctions(my_split));
282 edge_fe.getOpPtrVector().push_back(
284 edge_fe.getOpPtrVector().push_back(
285 new OpEdgePrintingHdivApproximationFunctions(my_split));
286
290 edge_fe);
291
292
293 }
295
297}
ForcesAndSourcesCore::UserDataOperator UserDataOperator
#define CATCH_ERRORS
Catch errors.
@ AINSWORTH_LEGENDRE_BASE
Ainsworth Cole (Legendre) approx. base .
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return()
@ HCURL
field with continuous tangents
#define CHKERR
Inline error check.
#define MoFEMFunctionBeginHot
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
virtual MoFEMErrorCode add_finite_element(const std::string &fe_name, enum MoFEMTypes bh=MF_EXCL, int verb=DEFAULT_VERBOSITY)=0
add finite element
virtual MoFEMErrorCode build_finite_elements(int verb=DEFAULT_VERBOSITY)=0
Build finite elements.
virtual MoFEMErrorCode modify_finite_element_add_field_col(const std::string &fe_name, const std::string name_row)=0
set field col which finite element use
virtual MoFEMErrorCode add_ents_to_finite_element_by_type(const EntityHandle entities, const EntityType type, const std::string &name, const bool recursive=true)=0
add entities to finite element
virtual MoFEMErrorCode modify_finite_element_add_field_data(const std::string &fe_name, const std::string name_filed)=0
set finite element field data
virtual MoFEMErrorCode modify_finite_element_add_field_row(const std::string &fe_name, const std::string name_row)=0
set field row which finite element use
virtual MoFEMErrorCode build_fields(int verb=DEFAULT_VERBOSITY)=0
virtual MoFEMErrorCode set_field_order(const EntityHandle meshset, const EntityType type, const std::string &name, const ApproximationOrder order, int verb=DEFAULT_VERBOSITY)=0
Set order approximation of the entities in the field.
virtual MoFEMErrorCode add_ents_to_field_by_type(const Range &ents, const EntityType type, const std::string &name, int verb=DEFAULT_VERBOSITY)=0
Add entities to field meshset.
virtual MoFEMErrorCode loop_finite_elements(const std::string problem_name, const std::string &fe_name, FEMethod &method, boost::shared_ptr< NumeredEntFiniteElement_multiIndex > fe_ptr=nullptr, MoFEMTypes bh=MF_EXIST, CacheTupleWeakPtr cache_ptr=CacheTupleSharedPtr(), int verb=DEFAULT_VERBOSITY)=0
Make a loop over finite elements.
MoFEMErrorCode partitionGhostDofs(const std::string name, int verb=VERBOSE)
determine ghost nodes
MoFEMErrorCode partitionSimpleProblem(const std::string name, int verb=VERBOSE)
partition problem dofs
MoFEMErrorCode buildProblem(const std::string name, const bool square_matrix, int verb=VERBOSE)
build problem data structures
MoFEMErrorCode partitionFiniteElements(const std::string name, bool part_from_moab=false, int low_proc=-1, int hi_proc=-1, int verb=VERBOSE)
partition finite elements
virtual MoFEMErrorCode add_problem(const std::string &name, enum MoFEMTypes bh=MF_EXCL, int verb=DEFAULT_VERBOSITY)=0
Add problem.
virtual MoFEMErrorCode modify_problem_ref_level_add_bit(const std::string &name_problem, const BitRefLevel &bit)=0
add ref level to problem
virtual MoFEMErrorCode modify_problem_add_finite_element(const std::string name_problem, const std::string &fe_name)=0
add finite element to problem, this add entities assigned to finite element to a particular problem
const Tensor2_symmetric_Expr< const ddTensor0< T, Dim, i, j >, typename promote< T, double >::V, Dim, i, j > dd(const Tensor0< T * > &a, const Index< i, Dim > index1, const Index< j, Dim > index2, const Tensor1< int, Dim > &d_ijk, const Tensor1< double, Dim > &d_xyz)
PetscErrorCode MoFEMErrorCode
MoFEM/PETSc error code.
std::bitset< BITREFLEVEL_SIZE > BitRefLevel
Bit structure attached to each entity identifying to what mesh entity is attached.
virtual MoFEMErrorCode build_adjacencies(const Range &ents, int verb=DEFAULT_VERBOSITY)=0
build adjacencies
virtual MoFEMErrorCode add_field(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_EXCL, int verb=DEFAULT_VERBOSITY)=0
Add field.
static MoFEMErrorCode Initialize(int *argc, char ***args, const char file[], const char help[])
Initializes the MoFEM database PETSc, MOAB and MPI.
static MoFEMErrorCode Finalize()
Checks for options to be called at the conclusion of the program.
Deprecated interface functions.
Data on single entity (This is passed as argument to DataOperator::doWork)
MatrixDouble & getDiffN(const FieldApproximationBase base)
get derivatives of base functions
MatrixDouble & getN(const FieldApproximationBase base)
get base functions this return matrix (nb. of rows is equal to nb. of Gauss pts, nb....
const VectorDouble & getFieldData() const
get dofs values
virtual int getRule(int order_row, int order_col, int order_data)
another variant of getRule
Problem manager is used to build and partition problems.
MoFEMErrorCode getInterface(IFACE *&iface) const
Get interface refernce to pointer of interface.
Volume finite element base.