2407 {
2409
2410
2414
2415 auto lhs_fe = boost::make_shared<DomainEle>(
mField);
2416 auto rhs_fe_prj = boost::make_shared<DomainEle>(
mField);
2417 auto rhs_fe_current = boost::make_shared<DomainEle>(
mField);
2418
2419 lhs_fe->getRuleHook = [](
int,
int,
int o) {
return 3 * o; };
2420 rhs_fe_prj->getRuleHook = [](
int,
int,
int o) {
return 3 * o; };
2421 rhs_fe_current->getRuleHook = [](
int,
int,
int o) {
return 3 * o; };
2422
2430
2434 current_ents);
2436 CHKERR bit_mng->getEntitiesByDimAndRefLevel(
2439 CHKERR bit_mng->updateRangeByParent(prj_ents, prj_ents);
2440 }
2441 current_ents = subtract(
2442 current_ents, prj_ents);
2443
2444 auto test_mesh_bit = [&](
FEMethod *fe_ptr) {
2445 return fe_ptr->numeredEntFiniteElementPtr->getBitRefLevel().test(
2447 };
2448 auto test_prj_bit = [&](
FEMethod *fe_ptr) {
2449 return fe_ptr->numeredEntFiniteElementPtr->getBitRefLevel().test(
2451 };
2452 auto test_current_bit = [&](
FEMethod *fe_ptr) {
2453 return current_ents.find(fe_ptr->getFEEntityHandle()) != current_ents.end();
2454 };
2455
2456 lhs_fe->exeTestHook =
2457 test_mesh_bit;
2458 rhs_fe_prj->exeTestHook =
2459 test_prj_bit;
2460 rhs_fe_current->exeTestHook =
2461 test_current_bit;
2462
2464 remove_mask.flip();
2465 CHKERR prb_mng->removeDofsOnEntities(
2466 "DG_PROJECTION",
"L",
BitRefLevel().set(), remove_mask,
nullptr, 0,
2468 true);
2469
2470
2472 {L2});
2473 lhs_fe->getOpPtrVector().push_back(
2475
2476
2477 auto set_prj_from_child = [&](auto rhs_fe_prj) {
2479 rhs_fe_prj->getOpPtrVector(), {L2});
2480
2481
2482 auto l_mat = boost::make_shared<MatrixDouble>();
2483 rhs_fe_prj->getOpPtrVector().push_back(
2485
2486
2487 auto get_parent_this = [&]() {
2488 auto fe_parent_this = boost::make_shared<DomainParentEle>(
mField);
2489 fe_parent_this->getOpPtrVector().push_back(
new OpScalarFieldL(
"L", l_mat));
2490 return fe_parent_this;
2491 };
2492
2493
2494
2495 auto get_parents_fe_ptr = [&](auto this_fe_ptr) {
2496 std::vector<boost::shared_ptr<DomainParentEle>> parents_elems_ptr_vec;
2498 parents_elems_ptr_vec.emplace_back(
2499 boost::make_shared<DomainParentEle>(
mField));
2501 parents_elems_ptr_vec[
l - 1]->getOpPtrVector().push_back(
2506 }
2507 return parents_elems_ptr_vec[0];
2508 };
2509
2510 auto this_fe_ptr = get_parent_this();
2511 auto parent_fe_ptr = get_parents_fe_ptr(this_fe_ptr);
2512 rhs_fe_prj->getOpPtrVector().push_back(
2516 };
2517
2518
2519 auto set_prj_from_parent = [&](auto rhs_fe_current) {
2520
2521
2522 auto l_mat = boost::make_shared<MatrixDouble>();
2523
2524
2525 auto get_parent_this = [&]() {
2526 auto fe_parent_this = boost::make_shared<DomainParentEle>(
mField);
2527 fe_parent_this->getOpPtrVector().push_back(
2529 return fe_parent_this;
2530 };
2531
2532
2533 auto get_parents_fe_ptr = [&](auto this_fe_ptr) {
2534 std::vector<boost::shared_ptr<DomainParentEle>> parents_elems_ptr_vec;
2536 parents_elems_ptr_vec.emplace_back(
2537 boost::make_shared<DomainParentEle>(
mField));
2539 parents_elems_ptr_vec[
l - 1]->getOpPtrVector().push_back(
2544 }
2545 return parents_elems_ptr_vec[0];
2546 };
2547
2548 auto this_fe_ptr = get_parent_this();
2549 auto parent_fe_ptr = get_parents_fe_ptr(this_fe_ptr);
2550
2552 reset_op_ptr->doWorkRhsHook = [&](
DataOperator *op_ptr,
int, EntityType,
2554 l_mat->resize(
static_cast<DomainEleOp *
>(op_ptr)->getGaussPts().size2(),
2556 l_mat->clear();
2557 return 0;
2558 };
2559 rhs_fe_current->getOpPtrVector().push_back(reset_op_ptr);
2560 rhs_fe_current->getOpPtrVector().push_back(
2564
2565
2566 rhs_fe_current->getOpPtrVector().push_back(
new OpScalarFieldL(
"L", l_mat));
2567 };
2568
2569 set_prj_from_child(rhs_fe_prj);
2570 set_prj_from_parent(rhs_fe_current);
2571
2572 boost::shared_ptr<FEMethod> null_fe;
2575 lhs_fe, null_fe, null_fe);
2577 null_fe, null_fe);
2579 rhs_fe_current, null_fe, null_fe);
2582
2586
2589
2592 ksp,
"level set DG projection");
2593 CHKERR VecGhostUpdateBegin(
L, INSERT_VALUES, SCATTER_FORWARD);
2594 CHKERR VecGhostUpdateEnd(
L, INSERT_VALUES, SCATTER_FORWARD);
2596
2598 MOFEM_LOG(
"LevelSet", Sev::inform) <<
"Error indicator " << error;
2599
2600 auto post_proc = [&](auto dm, auto out_name, auto th_error) {
2602 auto post_proc_fe =
2603 boost::make_shared<PostProcBrokenMeshInMoab<DomainEle>>(
mField);
2604 post_proc_fe->setTagsToTransfer({th_error});
2605 post_proc_fe->exeTestHook = test_mesh_bit;
2606
2607 if constexpr (
DIM1 == 1 &&
DIM2 == 1) {
2609 auto l_vec = boost::make_shared<VectorDouble>();
2610 auto l_grad_mat = boost::make_shared<MatrixDouble>();
2612 post_proc_fe->getOpPtrVector(), {L2});
2613 post_proc_fe->getOpPtrVector().push_back(
2615 post_proc_fe->getOpPtrVector().push_back(
2617
2618 post_proc_fe->getOpPtrVector().push_back(
2619
2621
2622 post_proc_fe->getPostProcMesh(), post_proc_fe->getMapGaussPts(),
2623
2624 {{"L", l_vec}},
2625
2626 {{"GradL", l_grad_mat}},
2627
2628 {}, {})
2629
2630 );
2631 }
2632
2634 post_proc_fe);
2635 post_proc_fe->writeFile(out_name);
2637 };
2638
2639 if constexpr (
debug)
2640 CHKERR post_proc(sub_dm,
"dg_projection.h5m", th_error);
2641
2643}
void simple(double P1[], double P2[], double P3[], double c[], const int N)
#define MAX_DOFS_ON_ENTITY
Maximal number of DOFs on entity.
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
#define CHKERR
Inline error check.
PetscErrorCode DMMoFEMCreateSubDM(DM subdm, DM dm, const char problem_name[])
Must be called by user to set Sub DM MoFEM data structures.
PetscErrorCode DMMoFEMAddElement(DM dm, std::string fe_name)
add element to dm
PetscErrorCode DMMoFEMSetSquareProblem(DM dm, PetscBool square_problem)
set squared problem
PetscErrorCode DMMoFEMAddSubFieldRow(DM dm, const char field_name[])
PetscErrorCode DMoFEMMeshToLocalVector(DM dm, Vec l, InsertMode mode, ScatterMode scatter_mode, RowColData rc=RowColData::COL)
set local (or ghosted) vector values on mesh for partition only
PetscErrorCode DMMoFEMKSPSetComputeRHS(DM dm, const char fe_name[], MoFEM::FEMethod *method, MoFEM::BasicMethod *pre_only, MoFEM::BasicMethod *post_only)
set KSP right hand side evaluation function
PetscErrorCode DMoFEMLoopFiniteElements(DM dm, const char fe_name[], MoFEM::FEMethod *method, CacheTupleWeakPtr cache_ptr=CacheTupleSharedPtr())
Executes FEMethod for finite elements in DM.
auto createDMVector(DM dm, RowColData rc=RowColData::COL)
Get smart vector from DM.
PetscErrorCode DMMoFEMKSPSetComputeOperators(DM dm, const char fe_name[], MoFEM::FEMethod *method, MoFEM::BasicMethod *pre_only, MoFEM::BasicMethod *post_only)
Set KSP operators and push mofem finite element methods.
#define MOFEM_LOG(channel, severity)
Log.
constexpr int FE_DIM
[Define dimension]
constexpr int current_bit
dofs bit used to do calculations
DomainEle::UserDataOperator DomainEleOp
constexpr int projection_bit
FTensor::Index< 'l', 3 > l
std::bitset< BITREFLEVEL_SIZE > BitRefLevel
Bit structure attached to each entity identifying to what mesh entity is attached.
auto createKSP(MPI_Comm comm)
PetscErrorCode DMMoFEMSetDestroyProblem(DM dm, PetscBool destroy_problem)
SmartPetscObj< Vec > vectorDuplicate(Vec vec)
Create duplicate vector of smart vector.
auto getDMKspCtx(DM dm)
Get KSP context data structure used by DM.
auto createDM(MPI_Comm comm, const std::string dm_type_name)
Creates smart DM object.
OpPostProcMapInMoab< SPACE_DIM, SPACE_DIM > OpPPMap
FormsIntegrators< DomainEleOp >::Assembly< A >::BiLinearForm< G >::OpMass< 1, DIM1 *DIM2 > OpMassLL
FormsIntegrators< DomainEleOp >::Assembly< A >::LinearForm< G >::OpBaseTimesVector< 1, DIM1 *DIM2, 1 > OpScalarFieldL
std::tuple< double, Tag > evaluateError()
evaluate error
Add operators pushing bases from local to physical configuration.
virtual MPI_Comm & get_comm() const =0
base operator to do operations at Gauss Pt. level
Data on single entity (This is passed as argument to DataOperator::doWork)
Structure for user loop methods on finite elements.
Get field gradients at integration pts for scalar field rank 0, i.e. vector field.
Specialization for double precision scalar field values calculation.
Get values at integration pts for tensor field rank 2, i.e. matrix field.
Post post-proc data at points from hash maps.
Operator to execute finite element instance on parent element. This operator is typically used to pro...
Problem manager is used to build and partition problems.
Simple interface for fast problem set-up.
MoFEMErrorCode getInterface(IFACE *&iface) const
Get interface reference to pointer of interface.