21 {
22
24
25 try {
26
27 enum bases { HDIV_AINSWORTH, HDIV_DEMKOWICZ,
LASTOP };
28
29 const char *list[] = {"hdiv_ainsworth", "hdiv_demkowicz"};
30
31 PetscBool flg;
32 PetscInt choise_value = HDIV_AINSWORTH;
34 &choise_value, &flg);
35 if (flg != PETSC_TRUE) {
37 }
38
39 moab::Core mb_instance;
40 moab::Interface &moab = mb_instance;
41 int rank;
42 MPI_Comm_rank(PETSC_COMM_WORLD, &rank);
43
45#if PETSC_VERSION_GE(3, 6, 4)
47 255, &flg);
48#else
51#endif
52 if (flg != PETSC_TRUE) {
53 SETERRQ(PETSC_COMM_SELF, 1, "*** ERROR -my_file (MESH FILE NEEDED)");
54 }
55 const char *option;
56 option = "";
58
61
62
64 bit_level0.set(0);
66 CHKERR moab.create_meshset(MESHSET_SET, meshset_level0);
68 0, 3, bit_level0);
69
70
72 3);
73 switch (choise_value) {
74 case HDIV_AINSWORTH:
76 break;
77 case HDIV_DEMKOWICZ:
79 break;
80 }
81
82
86
87
92 "MESH_NODE_POSITIONS");
93
98 "MESH_NODE_POSITIONS");
99
104 "MESH_NODE_POSITIONS");
105
106
108
109
113
114
116
117
119
121
122
124 "TET_FE");
125
129 Skinner skin(&moab);
131 CHKERR skin.find_skin(0, tets,
false, skin_faces);
133 "SKIN_FE");
134
138 faces = subtract(faces, skin_faces);
140
141
145
151
152
154
156
158
162
163
166
167
168
171
173
177 CHKERR VecSetRandom(
v, PETSC_NULL);
179 "TEST_PROBLEM",
ROW,
v, INSERT_VALUES, SCATTER_REVERSE);
181
182 typedef tee_device<std::ostream, std::ofstream>
TeeDevice;
184 std::ofstream ofs("forces_and_sources_hdiv_continuity_check.txt");
187
188 struct OpTetFluxes
189 : public VolumeElementForcesAndSourcesCore::UserDataOperator {
190
192 Tag tH;
193
197 m_field(m_field), tH(
th) {}
198
202
205
206 if (type == MBTRI) {
207
208 boost::shared_ptr<const NumeredEntFiniteElement> mofem_fe =
209 getNumeredEntFiniteElementPtr();
212 .find(boost::make_tuple(type, side))
213 ->get()
214 ->ent;
215 int sense = side_table.get<1>()
216 .find(boost::make_tuple(type, side))
217 ->get()
218 ->sense;
219
221 int nb_dofs = data.
getN().size2() / 3;
222 for (
int dd = 0;
dd != nb_dofs;
dd++) {
223 for (int ddd = 0; ddd != 3; ddd++)
226 }
227
228 double *t_ptr;
230 (const void **)&t_ptr);
231 for (
int dd = 0;
dd < 3;
dd++)
232 t_ptr[dd] += sense *
t[dd];
233 }
234
236 }
237 };
238
240
244
248
251
252 gaussPts.resize(4, 4);
253 for (int ff = 0; ff < 4; ff++) {
254 for (
int dd = 0;
dd < 3;
dd++) {
257 }
259 }
260
262 }
263 };
264
265 struct OpFacesSkinFluxes
266 : public FaceElementForcesAndSourcesCore::UserDataOperator {
267
269 Tag tH1, tH2;
271
276 m_field(m_field), tH1(th1), tH2(th2), mySplit(my_split) {}
277
281
282 if (type != MBTRI)
284
285 EntityHandle face = getNumeredEntFiniteElementPtr()->getEnt();
286
287 double *t_ptr;
289 (const void **)&t_ptr);
290 double *tn_ptr;
292 (const void **)&tn_ptr);
293
294 *tn_ptr = getNormalsAtGaussPts()(0, 0) * t_ptr[0] +
295 getNormalsAtGaussPts()(0, 1) * t_ptr[1] +
296 getNormalsAtGaussPts()(0, 2) * t_ptr[2];
297
298 int nb_dofs = data.
getN().size2() / 3;
300 for (;
dd < nb_dofs;
dd++) {
301 *tn_ptr += -getNormalsAtGaussPts()(0, 0) *
303 getNormalsAtGaussPts()(0, 1) * data.
getN()(0, 3 *
dd + 1) *
305 getNormalsAtGaussPts()(0, 2) * data.
getN()(0, 3 *
dd + 2) *
307 }
308
309 const double eps = 1e-8;
310 if (fabs(*tn_ptr) >
eps) {
312 "HDiv continuity failed %6.4e", *tn_ptr);
313 }
314
315 mySplit.precision(5);
316
317 mySplit << face << " " << fabs(*tn_ptr) << std::endl;
318
320 }
321 };
322
324 : public FaceElementForcesAndSourcesCore::UserDataOperator {
325
327 Tag tH1, tH2;
329
334 m_field(m_field), tH1(th1), tH2(th2), mySplit(my_split) {}
335
339
340 if (type != MBTRI)
342
343 EntityHandle face = getNumeredEntFiniteElementPtr()->getEnt();
344
345 double *t_ptr;
347 (const void **)&t_ptr);
348 double *tn_ptr;
350 (const void **)&tn_ptr);
351
352 *tn_ptr = getNormalsAtGaussPts()(0, 0) * t_ptr[0] +
353 getNormalsAtGaussPts()(0, 1) * t_ptr[1] +
354 getNormalsAtGaussPts()(0, 2) * t_ptr[2];
355
356 const double eps = 1e-8;
357 if (fabs(*tn_ptr) >
eps) {
359 "HDiv continuity failed %6.4e", *tn_ptr);
360 }
361
362 mySplit.precision(5);
363
364 mySplit << face << " " << fabs(*tn_ptr) << std::endl;
365
367 }
368 };
369
371
375
378
379 gaussPts.resize(3, 1);
383
385 }
386 };
387
388 MyTetFE tet_fe(m_field);
389 MyTriFE tri_fe(m_field);
390 MyTriFE skin_fe(m_field);
391
392 Tag th1;
393 double def_val[] = {0, 0, 0};
394 CHKERR moab.tag_get_handle(
"T", 3, MB_TYPE_DOUBLE, th1,
395 MB_TAG_CREAT | MB_TAG_SPARSE, &def_val);
396
397 auto material_grad_mat = boost::make_shared<MatrixDouble>();
398 auto material_det_vec = boost::make_shared<VectorDouble>();
399 auto material_inv_grad_mat = boost::make_shared<MatrixDouble>();
400
402 "MESH_NODE_POSITIONS", material_grad_mat));
404 material_grad_mat, material_det_vec, material_inv_grad_mat));
405 tet_fe.getOpPtrVector().push_back(
new OpSetHOWeights(material_det_vec));
407 HDIV, material_det_vec, material_grad_mat));
408 tet_fe.getOpPtrVector().push_back(
410 tet_fe.getOpPtrVector().push_back(new OpTetFluxes(m_field, th1));
411
412 Tag th2;
413 CHKERR moab.tag_get_handle(
"TN", 1, MB_TYPE_DOUBLE, th2,
414 MB_TAG_CREAT | MB_TAG_SPARSE, &def_val);
415 tri_fe.getOpPtrVector().push_back(
417 tri_fe.getOpPtrVector().push_back(
419 tri_fe.getOpPtrVector().push_back(
421
422 skin_fe.getOpPtrVector().push_back(
424 skin_fe.getOpPtrVector().push_back(
426 skin_fe.getOpPtrVector().push_back(
427 new OpFacesSkinFluxes(m_field, th1, th2, my_split));
428
429 for (Range::iterator fit = faces.begin(); fit != faces.end(); fit++) {
430 CHKERR moab.tag_set_data(th1, &*fit, 1, &def_val);
431 CHKERR moab.tag_set_data(th2, &*fit, 1, &def_val);
432 }
433
435 my_split << "internal\n";
437 my_split << "skin\n";
439
441 CHKERR moab.create_meshset(MESHSET_SET, meshset);
444 CHKERR moab.write_file(
"out.vtk",
"VTK",
"", &meshset, 1);
445 }
447
449}
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()
@ HDIV
field with continuous normal traction
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
@ 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.
#define MoFEMFunctionBeginHot
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
static const double face_coords[4][9]
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)
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 PetscOptionsGetEList(PetscOptions *, const char pre[], const char name[], const char *const *list, PetscInt next, PetscInt *value, PetscBool *set)
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
const MatrixAdaptor getVectorN(const FieldApproximationBase base, const int gg)
get Hdiv of base functions at Gauss pts
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.
Get field gradients at integration pts for scalar filed rank 0, i.e. vector field.
Calculate normals at Gauss points of triangle element.
transform local reference derivatives of shape function to global derivatives if higher order geometr...
Set inverse jacobian to base functions.
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)