22 {
23
25
26 try {
27
28 moab::Core mb_instance;
29 moab::Interface &moab = mb_instance;
30 int rank;
31 MPI_Comm_rank(PETSC_COMM_WORLD, &rank);
32
33 PetscBool flg = PETSC_TRUE;
35#if PETSC_VERSION_GE(3, 6, 4)
37 255, &flg);
39#else
43#endif
44 if (flg != PETSC_TRUE) {
45 SETERRQ(PETSC_COMM_SELF, 1, "*** ERROR -my_file (MESH FILE NEEDED)");
46 }
47 const char *option;
48 option = "";
50
51
54
55
57 bit_level0.set(0);
59 CHKERR moab.create_meshset(MESHSET_SET, meshset_level0);
60
62 0, 3, bit_level0);
63
64
65
67 3);
68
70
71
72
77
78
79
84 "MESH_NODE_POSITIONS");
85
86
91 "MESH_NODE_POSITIONS");
92
93
98 "MESH_NODE_POSITIONS");
99
100
105 "MESH_NODE_POSITIONS");
106
107
109
110
111
116
117
119
120
121
123
125
126
127
130
131
135
136 Skinner skin(&moab);
138 CHKERR skin.find_skin(0, tets,
false, skin_faces);
140 "SKIN_FE");
141
145
146 faces = subtract(faces, skin_faces);
148
150 CHKERR moab.get_adjacencies(faces, 1,
false, edges, moab::Interface::UNION);
152
154 CHKERR moab.get_adjacencies(skin_faces, 1,
false, skin_edges,
155 moab::Interface::UNION);
157
158
159
164
170
171
172
173
175
176
178
179
181
182
185
186
188
189
190
193
194
195
196
199
200
202
203
207 CHKERR VecSetRandom(
v, PETSC_NULL);
208
210 "TEST_PROBLEM",
ROW,
v, INSERT_VALUES, SCATTER_REVERSE);
211
213
214
215 typedef tee_device<std::ostream, std::ofstream>
TeeDevice;
217 std::ofstream ofs("forces_and_sources_hdiv_continuity_check.txt");
220
221 struct OpTetFluxes
222 : public VolumeElementForcesAndSourcesCore::UserDataOperator {
223
225 Tag tH;
226
230 mField(m_field), tH(
th) {}
231
235
238
239 if (type == MBTRI) {
240
241 boost::shared_ptr<const NumeredEntFiniteElement> mofem_fe =
242 getNumeredEntFiniteElementPtr();
245 .find(boost::make_tuple(type, side))
246 ->get()
247 ->ent;
248 int sense = side_table.get<1>()
249 .find(boost::make_tuple(type, side))
250 ->get()
251 ->sense;
252
254 int nb_dofs = data.
getN().size2();
255 for (
int dd = 0;
dd < nb_dofs;
dd++) {
257 }
258
259 double *t_ptr;
261 (const void **)&t_ptr);
262
264 }
265
266 if (type == MBEDGE) {
267
268 boost::shared_ptr<const NumeredEntFiniteElement> mofem_fe =
269 getNumeredEntFiniteElementPtr();
272 .find(boost::make_tuple(type, side))
273 ->get()
274 ->ent;
276 CHKERR mField.
get_moab().get_adjacencies(&edge, 1, 3,
false, adj_tets,
277 moab::Interface::UNION);
278 const int nb_adj_tets = adj_tets.size();
279
281 int nb_dofs = data.
getN().size2();
282 for (
int dd = 0;
dd < nb_dofs;
dd++) {
284 }
285
286 double *t_ptr;
288 (const void **)&t_ptr);
289
290 *t_ptr +=
t / nb_adj_tets;
291 }
292
294 }
295 };
296
298
302
305
307
308 try {
309
310 N_tri.resize(1, 3);
312
313
314 gaussPts.resize(4, 4 + 6);
315 int ff = 0;
316 for (; ff < 4; ff++) {
318 for (;
dd < 3;
dd++) {
320 cblas_ddot(3, &N_tri(0, 0), 1, &
face_coords[ff][dd], 3);
321 }
323 }
324
325 int ee = 0;
326 for (; ee < 6; ee++) {
328 for (;
dd < 3;
dd++) {
331 }
333 }
334
335
336
337 } catch (std::exception &ex) {
338 std::ostringstream ss;
339 ss << "thorw in method: " << ex.what() << " at line " << __LINE__
340 << " in file " << __FILE__;
342 }
343
345 }
346 };
347
348 struct OpFacesSkinFluxes
349 : public FaceElementForcesAndSourcesCore::UserDataOperator {
350
352 Tag tH1, tH2;
354
359 mField(m_field), tH1(th1), tH2(th2), mySplit(my_split) {}
360
364
365 if (type != MBTRI)
367 EntityHandle face = getNumeredEntFiniteElementPtr()->getEnt();
368
369 double *t_ptr;
371 (const void **)&t_ptr);
372
373 double *tn_ptr;
375 (const void **)&tn_ptr);
376
377
378 *tn_ptr = *t_ptr;
379
381 int nb_dofs = data.
getN().size2();
382 for (;
dd < nb_dofs;
dd++) {
384 *tn_ptr += -data.
getN()(0,
dd) * val;
385 }
386
387 const double eps = 1e-8;
388 if (fabs(*tn_ptr) >
eps) {
390 "H1 continuity failed %6.4e", *tn_ptr);
391 }
392
393 mySplit.precision(5);
394 mySplit << face << " " << fabs(*tn_ptr) << std::endl;
395
397 }
398 };
399
401 : public FaceElementForcesAndSourcesCore::UserDataOperator {
402
404 Tag tH1, tH2;
406
411 mField(m_field), tH1(_th1), tH2(_th2), mySplit(my_split) {}
412
416
417 if (type != MBTRI)
419
420 EntityHandle face = getNumeredEntFiniteElementPtr()->getEnt();
421
422 double *t_ptr;
424 (const void **)&t_ptr);
425
426 double *tn_ptr;
428 (const void **)&tn_ptr);
429
430
431 *tn_ptr = *t_ptr;
432
433 const double eps = 1e-8;
434 if (fabs(*tn_ptr) >
eps) {
436 "H1 continuity failed %6.4e", *tn_ptr);
437 }
438
439 mySplit.precision(5);
440
441 mySplit << face << " " << fabs(*tn_ptr) << std::endl;
442
444 }
445 };
446
448
452
455
456 gaussPts.resize(3, 1);
460
462 }
463 };
464
465 struct OpEdgesFluxes
466 : public EdgeElementForcesAndSourcesCore::UserDataOperator {
467
469 Tag tH1, tH2;
471
476 mField(m_field), tH1(_th1), tH2(_th2), mySplit(my_split) {}
477
481
482 if (type != MBEDGE)
484
485 EntityHandle edge = getNumeredEntFiniteElementPtr()->getEnt();
486
487 double *t_ptr;
489 (const void **)&t_ptr);
490
491 double *tn_ptr;
493 (const void **)&tn_ptr);
494
495
496 *tn_ptr = *t_ptr;
497
498 double tn = 0;
499 int nb_dofs = data.
getN().size2();
501 for (;
dd < nb_dofs;
dd++) {
503 tn += data.
getN()(0,
dd) * val;
504 }
505
506
507 *tn_ptr -= tn;
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523 mySplit.precision(5);
524
525 mySplit << edge << " " << fabs(*tn_ptr) << std::endl;
526
528 }
529 };
530
532
536
539
540 gaussPts.resize(2, 1);
543
545 }
546 };
547
548 MyTetFE tet_fe(m_field);
549 MyTriFE tri_fe(m_field);
550 MyTriFE skin_fe(m_field);
551 MyEdgeFE edge_fe(m_field);
552
553 Tag th1;
554 double def_val[] = {0, 0, 0};
555 CHKERR moab.tag_get_handle(
"T", 3, MB_TYPE_DOUBLE, th1,
556 MB_TAG_CREAT | MB_TAG_SPARSE, &def_val);
557
558 tet_fe.getOpPtrVector().push_back(
560 tet_fe.getOpPtrVector().push_back(new OpTetFluxes(m_field, th1));
561
562 Tag th2;
563 CHKERR moab.tag_get_handle(
"TN", 1, MB_TYPE_DOUBLE, th2,
564 MB_TAG_CREAT | MB_TAG_SPARSE, &def_val);
565
566 tri_fe.getOpPtrVector().push_back(
568 tri_fe.getOpPtrVector().push_back(
570 tri_fe.getOpPtrVector().push_back(
572 skin_fe.getOpPtrVector().push_back(
573 new OpFacesSkinFluxes(m_field, th1, th2, my_split));
574
575 edge_fe.getOpPtrVector().push_back(
577 edge_fe.getOpPtrVector().push_back(
579 edge_fe.getOpPtrVector().push_back(
580 new OpEdgesFluxes(m_field, th1, th2, my_split));
581
582 for (Range::iterator fit = faces.begin(); fit != faces.end(); fit++) {
583 CHKERR moab.tag_set_data(th1, &*fit, 1, &def_val);
584
585 CHKERR moab.tag_set_data(th2, &*fit, 1, &def_val);
586
587 }
588
590 my_split << "internal\n";
592 my_split << "skin\n";
594 my_split << "edges\n";
596
597
599 CHKERR moab.create_meshset(MESHSET_SET, meshset);
602
603 CHKERR moab.write_file(
"out.vtk",
"VTK",
"", &meshset, 1);
604
605 }
607
609}
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()
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
#define CHKERRG(n)
Check error code of MoFEM/MOAB/PETSc function.
@ MOFEM_STD_EXCEPTION_THROW
@ MOFEM_ATOM_TEST_INVALID
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
#define CHKERR
Inline error check.
static const double face_coords[4][9]
static const double edge_coords[6][6]
multi_index_container< boost::shared_ptr< SideNumber >, indexed_by< ordered_unique< member< SideNumber, EntityHandle, &SideNumber::ent > >, ordered_non_unique< composite_key< SideNumber, const_mem_fun< SideNumber, EntityType, &SideNumber::getEntType >, member< SideNumber, signed char, &SideNumber::side_number > > > > > SideNumber_multiIndex
SideNumber_multiIndex for SideNumber.
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_dofs(const Problem *problem_ptr, const std::string &field_name, RowColData rc, DofMethod &method, int lower_rank, int upper_rank, int verb=DEFAULT_VERBOSITY)=0
Make a loop over dofs.
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 double v
phase velocity of light in medium (cm/ns)
const FTensor::Tensor2< T, Dim, Dim > Vec
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)
static MoFEMErrorCodeGeneric< PetscErrorCode > ierr
PetscErrorCode MoFEMErrorCode
MoFEM/PETSc error code.
std::bitset< BITREFLEVEL_SIZE > BitRefLevel
Bit structure attached to each entity identifying to what mesh entity is attached.
PetscErrorCode PetscOptionsGetString(PetscOptions *, const char pre[], const char name[], char str[], size_t size, PetscBool *set)
constexpr double t
plate stiffness
virtual moab::Interface & get_moab()=0
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 & 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 MoFEMErrorCode setGaussPts(int order_row, int order_col, int order_data)
set user specific integration rule
virtual int getRule(int order_row, int order_col, int order_data)
another variant of getRule
MatrixDouble gaussPts
Matrix of integration points.
Calculate HO coordinates at gauss points.
Calculate normals at Gauss points of triangle element.
Calculate tangent vector on edge form HO geometry approximation.
Problem manager is used to build and partition problems.
Projection of edge entities with one mid-node on hierarchical basis.
MoFEMErrorCode getInterface(IFACE *&iface) const
Get interface refernce to pointer of interface.
Vector manager is used to create vectors \mofem_vectors.
Volume finite element base.
MoFEMErrorCode doWork(int side, EntityType type, EntitiesFieldData::EntData &data)