2395 {
2397
2398
2402
2403 auto lhs_fe = boost::make_shared<DomainEle>(
mField);
2404 auto rhs_fe_prj = boost::make_shared<DomainEle>(
mField);
2405 auto rhs_fe_current = boost::make_shared<DomainEle>(
mField);
2406
2407 lhs_fe->getRuleHook = [](
int,
int,
int o) {
return 3 * o; };
2408 rhs_fe_prj->getRuleHook = [](
int,
int,
int o) {
return 3 * o; };
2409 rhs_fe_current->getRuleHook = [](
int,
int,
int o) {
return 3 * o; };
2410
2418
2422 current_ents);
2424 CHKERR bit_mng->getEntitiesByDimAndRefLevel(
2427 CHKERR bit_mng->updateRangeByParent(prj_ents, prj_ents);
2428 }
2429 current_ents = subtract(
2430 current_ents, prj_ents);
2431
2432 auto test_mesh_bit = [&](
FEMethod *fe_ptr) {
2433 return fe_ptr->numeredEntFiniteElementPtr->getBitRefLevel().test(
2435 };
2436 auto test_prj_bit = [&](
FEMethod *fe_ptr) {
2437 return fe_ptr->numeredEntFiniteElementPtr->getBitRefLevel().test(
2439 };
2440 auto test_current_bit = [&](
FEMethod *fe_ptr) {
2441 return current_ents.find(fe_ptr->getFEEntityHandle()) != current_ents.end();
2442 };
2443
2444 lhs_fe->exeTestHook =
2445 test_mesh_bit;
2446 rhs_fe_prj->exeTestHook =
2447 test_prj_bit;
2448 rhs_fe_current->exeTestHook =
2449 test_current_bit;
2450
2452 remove_mask.flip();
2453 CHKERR prb_mng->removeDofsOnEntities(
2454 "DG_PROJECTION",
"L",
BitRefLevel().set(), remove_mask,
nullptr, 0,
2456 true);
2457
2458
2460 {L2});
2461 lhs_fe->getOpPtrVector().push_back(
2463
2464
2465 auto set_prj_from_child = [&](auto rhs_fe_prj) {
2467 rhs_fe_prj->getOpPtrVector(), {L2});
2468
2469
2470 auto l_mat = boost::make_shared<MatrixDouble>();
2471 rhs_fe_prj->getOpPtrVector().push_back(
2473
2474
2475 auto get_parent_this = [&]() {
2476 auto fe_parent_this = boost::make_shared<DomainParentEle>(
mField);
2477 fe_parent_this->getOpPtrVector().push_back(
new OpScalarFieldL(
"L", l_mat));
2478 return fe_parent_this;
2479 };
2480
2481
2482
2483 auto get_parents_fe_ptr = [&](auto this_fe_ptr) {
2484 std::vector<boost::shared_ptr<DomainParentEle>> parents_elems_ptr_vec;
2486 parents_elems_ptr_vec.emplace_back(
2487 boost::make_shared<DomainParentEle>(
mField));
2489 parents_elems_ptr_vec[
l - 1]->getOpPtrVector().push_back(
2494 }
2495 return parents_elems_ptr_vec[0];
2496 };
2497
2498 auto this_fe_ptr = get_parent_this();
2499 auto parent_fe_ptr = get_parents_fe_ptr(this_fe_ptr);
2500 rhs_fe_prj->getOpPtrVector().push_back(
2504 };
2505
2506
2507 auto set_prj_from_parent = [&](auto rhs_fe_current) {
2508
2509
2510 auto l_mat = boost::make_shared<MatrixDouble>();
2511
2512
2513 auto get_parent_this = [&]() {
2514 auto fe_parent_this = boost::make_shared<DomainParentEle>(
mField);
2515 fe_parent_this->getOpPtrVector().push_back(
2517 return fe_parent_this;
2518 };
2519
2520
2521 auto get_parents_fe_ptr = [&](auto this_fe_ptr) {
2522 std::vector<boost::shared_ptr<DomainParentEle>> parents_elems_ptr_vec;
2524 parents_elems_ptr_vec.emplace_back(
2525 boost::make_shared<DomainParentEle>(
mField));
2527 parents_elems_ptr_vec[
l - 1]->getOpPtrVector().push_back(
2532 }
2533 return parents_elems_ptr_vec[0];
2534 };
2535
2536 auto this_fe_ptr = get_parent_this();
2537 auto parent_fe_ptr = get_parents_fe_ptr(this_fe_ptr);
2538
2540 reset_op_ptr->doWorkRhsHook = [&](
DataOperator *op_ptr,
int, EntityType,
2542 l_mat->resize(
static_cast<DomainEleOp *
>(op_ptr)->getGaussPts().size2(),
2544 l_mat->clear();
2545 return 0;
2546 };
2547 rhs_fe_current->getOpPtrVector().push_back(reset_op_ptr);
2548 rhs_fe_current->getOpPtrVector().push_back(
2552
2553
2554 rhs_fe_current->getOpPtrVector().push_back(
new OpScalarFieldL(
"L", l_mat));
2555 };
2556
2557 set_prj_from_child(rhs_fe_prj);
2558 set_prj_from_parent(rhs_fe_current);
2559
2560 boost::shared_ptr<FEMethod> null_fe;
2563 lhs_fe, null_fe, null_fe);
2565 null_fe, null_fe);
2567 rhs_fe_current, null_fe, null_fe);
2569 CHKERR KSPSetDM(ksp, sub_dm);
2570
2571 CHKERR KSPSetDM(ksp, sub_dm);
2572 CHKERR KSPSetFromOptions(ksp);
2574
2577
2579 CHKERR VecGhostUpdateBegin(
L, INSERT_VALUES, SCATTER_FORWARD);
2580 CHKERR VecGhostUpdateEnd(
L, INSERT_VALUES, SCATTER_FORWARD);
2582
2584 MOFEM_LOG(
"LevelSet", Sev::inform) <<
"Error indicator " << error;
2585
2586 auto post_proc = [&](auto dm, auto out_name, auto th_error) {
2588 auto post_proc_fe =
2589 boost::make_shared<PostProcBrokenMeshInMoab<DomainEle>>(
mField);
2590 post_proc_fe->setTagsToTransfer({th_error});
2591 post_proc_fe->exeTestHook = test_mesh_bit;
2592
2593 if constexpr (
DIM1 == 1 &&
DIM2 == 1) {
2595 auto l_vec = boost::make_shared<VectorDouble>();
2596 auto l_grad_mat = boost::make_shared<MatrixDouble>();
2598 post_proc_fe->getOpPtrVector(), {L2});
2599 post_proc_fe->getOpPtrVector().push_back(
2601 post_proc_fe->getOpPtrVector().push_back(
2603
2604 post_proc_fe->getOpPtrVector().push_back(
2605
2607
2608 post_proc_fe->getPostProcMesh(), post_proc_fe->getMapGaussPts(),
2609
2610 {{"L", l_vec}},
2611
2612 {{"GradL", l_grad_mat}},
2613
2614 {}, {})
2615
2616 );
2617 }
2618
2620 post_proc_fe);
2621 post_proc_fe->writeFile(out_name);
2623 };
2624
2625 if constexpr (
debug)
2626 CHKERR post_proc(sub_dm,
"dg_projection.h5m", th_error);
2627
2629}
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.