290 DMType dm_name =
"DMMOFEM";
297 auto core_log = logging::core::get();
299 LogManager::createSink(LogManager::getStrmWorld(),
"AT"));
300 LogManager::setLog(
"AT");
311 simple->getAddBoundaryFE() =
true;
323 const char *list_bases[] = {
"ainsworth",
"ainsworth_lobatto",
"demkowicz",
326 PetscInt choice_base_value = AINSWORTH;
328 LASBASETOP, &choice_base_value, &flg);
330 if (flg != PETSC_TRUE)
333 if (choice_base_value == AINSWORTH)
335 if (choice_base_value == AINSWORTH_LOBATTO)
337 else if (choice_base_value == DEMKOWICZ)
339 else if (choice_base_value == BERNSTEIN)
342 enum spaces { H1SPACE, L2SPACE, LASBASETSPACE };
343 const char *list_spaces[] = {
"h1",
"l2"};
344 PetscInt choice_space_value = H1SPACE;
346 LASBASETSPACE, &choice_space_value, &flg);
347 if (flg != PETSC_TRUE)
350 if (choice_space_value == H1SPACE)
352 else if (choice_space_value == L2SPACE)
358 CHKERR simple->addDomainField(
"FIELD1", space, base, 1);
362 CHKERR moab.get_entities_by_dimension(0, 1, edges);
363 CHKERR moab.get_entities_by_dimension(0, 2, faces);
365 if (choice_base_value != BERNSTEIN) {
369 for (
auto e : edges) {
371 rise_order.insert(e);
376 for (
auto f : faces) {
378 rise_order.insert(
f);
384 for (
auto e : rise_order) {
386 rise_twice.insert(e);
400 std::vector<EntityHandle> &adjacency) {
403 switch (field.getSpace()) {
405 CHKERR moab.get_connectivity(&fe_ent, 1, adjacency,
true);
407 CHKERR moab.get_adjacencies(&fe_ent, 1, 1,
false, adjacency,
408 moab::Interface::UNION);
411 CHKERR moab.get_adjacencies(&fe_ent, 1, 2,
false, adjacency,
412 moab::Interface::UNION);
413 adjacency.push_back(fe_ent);
415 for (
auto ent : adjacency)
416 fe.getSideNumberPtr(ent);
419 CHKERR moab.get_entities_by_handle(field.getMeshset(), adjacency,
421 for (
auto ent : adjacency) {
424 boost::shared_ptr<SideNumber>(
new SideNumber(ent, -1, 0, 0)));
429 "this field is not implemented for TRI finite element");
436 simple->getDomainFEName(), MBTET, volume_adj);
438 simple->getDomainFEName(), MBHEX, volume_adj);
445 auto dm =
simple->getDM();
450 auto assemble_matrices_and_vectors = [&]() {
454 PETSC>::LinearForm<GAUSS>::OpSource<1, 1>;
457 pipeline_mng->getOpDomainLhsPipeline(), {space});
459 pipeline_mng->getOpDomainRhsPipeline(), {space});
464 pipeline_mng->getOpDomainLhsPipeline().push_back(
466 pipeline_mng->getOpDomainLhsPipeline().push_back(
new OpMass(
467 "FIELD1",
"FIELD1", [](
double,
double,
double) {
return 1.; }));
468 pipeline_mng->getOpDomainLhsPipeline().push_back(
471 pipeline_mng->getOpDomainRhsPipeline().push_back(
475 return 2 * p_data + 1;
483 auto solve_problem = [&] {
485 auto solver = pipeline_mng->createKSP();
486 CHKERR KSPSetFromOptions(solver);
489 auto dm =
simple->getDM();
494 CHKERR VecGhostUpdateBegin(
D, INSERT_VALUES, SCATTER_FORWARD);
495 CHKERR VecGhostUpdateEnd(
D, INSERT_VALUES, SCATTER_FORWARD);
501 auto check_solution = [&] {
504 auto ptr_values = boost::make_shared<VectorDouble>();
505 auto ptr_diff_vals = boost::make_shared<MatrixDouble>();
507 pipeline_mng->getDomainLhsFE().reset();
508 pipeline_mng->getOpDomainRhsPipeline().clear();
511 pipeline_mng->getOpDomainRhsPipeline(), {space});
513 pipeline_mng->getOpDomainRhsPipeline().push_back(
515 pipeline_mng->getOpDomainRhsPipeline().push_back(
517 pipeline_mng->getOpDomainRhsPipeline().push_back(
521 vals, diff_vals, ptr_values, ptr_diff_vals,
true));
523 CHKERR pipeline_mng->loopFiniteElements();
528 auto post_proc = [&] {
533 auto get_domain_post_proc_fe = [&](
auto post_proc_mesh_ptr) {
535 boost::make_shared<PostProcBrokenMeshInMoabBaseCont<DomainEle>>(
536 m_field, post_proc_mesh_ptr);
539 post_proc_fe->getOpPtrVector(), {space});
541 auto ptr_values = boost::make_shared<VectorDouble>();
542 auto ptr_diff_vals = boost::make_shared<MatrixDouble>();
544 post_proc_fe->getOpPtrVector().push_back(
546 post_proc_fe->getOpPtrVector().push_back(
550 post_proc_fe->getOpPtrVector().push_back(
554 post_proc_fe->getPostProcMesh(), post_proc_fe->getMapGaussPts(),
556 {{
"FIELD1", ptr_values}},
558 {{
"FIELD1_GRAD", ptr_diff_vals}},
566 auto get_bdy_post_proc_fe = [&](
auto post_proc_mesh_ptr) {
567 auto bdy_post_proc_fe =
568 boost::make_shared<PostProcBrokenMeshInMoabBaseCont<BoundaryEle>>(
569 m_field, post_proc_mesh_ptr);
576 auto ptr_values = boost::make_shared<VectorDouble>();
577 auto ptr_diff_vals = boost::make_shared<MatrixDouble>();
581 op_loop_side->getOpPtrVector(), {space});
582 op_loop_side->getOpPtrVector().push_back(
584 op_loop_side->getOpPtrVector().push_back(
588 bdy_post_proc_fe->getOpPtrVector().push_back(op_loop_side);
590 bdy_post_proc_fe->getOpPtrVector().push_back(
594 bdy_post_proc_fe->getPostProcMesh(),
595 bdy_post_proc_fe->getMapGaussPts(),
597 {{
"FIELD1", ptr_values}},
599 {{
"FIELD1_GRAD", ptr_diff_vals}},
605 return bdy_post_proc_fe;
608 auto post_proc_mesh_ptr = boost::make_shared<moab::Core>();
609 auto post_proc_begin =
610 boost::make_shared<PostProcBrokenMeshInMoabBaseBegin>(
611 m_field, post_proc_mesh_ptr);
613 boost::make_shared<PostProcBrokenMeshInMoabBaseEnd>(
614 m_field, post_proc_mesh_ptr);
615 auto domain_post_proc_fe = get_domain_post_proc_fe(post_proc_mesh_ptr);
616 auto bdy_post_proc_fe = get_bdy_post_proc_fe(post_proc_mesh_ptr);
620 domain_post_proc_fe);
624 CHKERR post_proc_end->writeFile(
"out_post_proc.h5m");
629 CHKERR assemble_matrices_and_vectors();