2401 {
2403
2404
2409
2410 auto lhs_fe = boost::make_shared<DomainEle>(
mField);
2411 auto rhs_fe_prj = boost::make_shared<DomainEle>(
mField);
2412 auto rhs_fe_current = boost::make_shared<DomainEle>(
mField);
2413
2414 lhs_fe->getRuleHook = [](int, int, int o) { return 3 * o; };
2415 rhs_fe_prj->getRuleHook = [](int, int, int o) { return 3 * o; };
2416 rhs_fe_current->getRuleHook = [](int, int, int o) { return 3 * o; };
2417
2425
2429 current_ents);
2431 CHKERR bit_mng->getEntitiesByDimAndRefLevel(
2434 CHKERR bit_mng->updateRangeByParent(prj_ents, prj_ents);
2435 }
2436 current_ents = subtract(
2437 current_ents, prj_ents);
2438
2439 auto test_mesh_bit = [&](
FEMethod *fe_ptr) {
2440 return fe_ptr->numeredEntFiniteElementPtr->getBitRefLevel().test(
2442 };
2443 auto test_prj_bit = [&](
FEMethod *fe_ptr) {
2444 return fe_ptr->numeredEntFiniteElementPtr->getBitRefLevel().test(
2446 };
2447 auto test_current_bit = [&](
FEMethod *fe_ptr) {
2448 return current_ents.find(fe_ptr->getFEEntityHandle()) != current_ents.end();
2449 };
2450
2451 lhs_fe->exeTestHook =
2452 test_mesh_bit;
2453 rhs_fe_prj->exeTestHook =
2454 test_prj_bit;
2455 rhs_fe_current->exeTestHook =
2456 test_current_bit;
2457
2459 remove_mask.flip();
2460 CHKERR prb_mng->removeDofsOnEntities(
2461 "DG_PROJECTION",
"L",
BitRefLevel().set(), remove_mask,
nullptr, 0,
2463 true);
2464
2465
2467 {L2});
2468 lhs_fe->getOpPtrVector().push_back(
2470
2471
2472 auto set_prj_from_child = [&](auto rhs_fe_prj) {
2474 rhs_fe_prj->getOpPtrVector(), {L2});
2475
2476
2477 auto l_vec = boost::make_shared<MatrixDouble>();
2478 rhs_fe_prj->getOpPtrVector().push_back(
2480
2481
2482 auto get_parent_this = [&]() {
2483 auto fe_parent_this = boost::make_shared<DomianParentEle>(
mField);
2484 fe_parent_this->getOpPtrVector().push_back(
2486 return fe_parent_this;
2487 };
2488
2489
2490
2491 auto get_parents_fe_ptr = [&](auto this_fe_ptr) {
2492 std::vector<boost::shared_ptr<DomianParentEle>> parents_elems_ptr_vec;
2494 parents_elems_ptr_vec.emplace_back(
2495 boost::make_shared<DomianParentEle>(
mField));
2497 parents_elems_ptr_vec[
l - 1]->getOpPtrVector().push_back(
2502 }
2503 return parents_elems_ptr_vec[0];
2504 };
2505
2506 auto this_fe_ptr = get_parent_this();
2507 auto parent_fe_ptr = get_parents_fe_ptr(this_fe_ptr);
2508 rhs_fe_prj->getOpPtrVector().push_back(
2512 };
2513
2514
2515 auto set_prj_from_parent = [&](auto rhs_fe_current) {
2516
2517
2518 auto l_vec = boost::make_shared<MatrixDouble>();
2519
2520
2521 auto get_parent_this = [&]() {
2522 auto fe_parent_this = boost::make_shared<DomianParentEle>(
mField);
2523 fe_parent_this->getOpPtrVector().push_back(
2525 return fe_parent_this;
2526 };
2527
2528
2529 auto get_parents_fe_ptr = [&](auto this_fe_ptr) {
2530 std::vector<boost::shared_ptr<DomianParentEle>> parents_elems_ptr_vec;
2532 parents_elems_ptr_vec.emplace_back(
2533 boost::make_shared<DomianParentEle>(
mField));
2535 parents_elems_ptr_vec[
l - 1]->getOpPtrVector().push_back(
2540 }
2541 return parents_elems_ptr_vec[0];
2542 };
2543
2544 auto this_fe_ptr = get_parent_this();
2545 auto parent_fe_ptr = get_parents_fe_ptr(this_fe_ptr);
2546
2548 reset_op_ptr->doWorkRhsHook = [&](
DataOperator *op_ptr, int, EntityType,
2550 l_vec->resize(
static_cast<DomainEleOp *
>(op_ptr)->getGaussPts().size2(),
2551 false);
2552 l_vec->clear();
2553 return 0;
2554 };
2555 rhs_fe_current->getOpPtrVector().push_back(reset_op_ptr);
2556 rhs_fe_current->getOpPtrVector().push_back(
2560
2561
2562 rhs_fe_current->getOpPtrVector().push_back(
new OpScalarFieldL(
"L", l_vec));
2563 };
2564
2565 set_prj_from_child(rhs_fe_prj);
2566 set_prj_from_parent(rhs_fe_current);
2567
2568 boost::shared_ptr<FEMethod> null_fe;
2571 lhs_fe, null_fe, null_fe);
2573 null_fe, null_fe);
2575 rhs_fe_current, null_fe, null_fe);
2577 CHKERR KSPSetDM(ksp, sub_dm);
2578
2579 CHKERR KSPSetDM(ksp, sub_dm);
2580 CHKERR KSPSetFromOptions(ksp);
2582
2585
2587 CHKERR VecGhostUpdateBegin(
L, INSERT_VALUES, SCATTER_FORWARD);
2588 CHKERR VecGhostUpdateEnd(
L, INSERT_VALUES, SCATTER_FORWARD);
2590
2592 MOFEM_LOG(
"LevelSet", Sev::inform) <<
"Error indicator " << error;
2593
2594 auto post_proc = [&](auto dm, auto out_name, auto th_error) {
2596 auto post_proc_fe =
2597 boost::make_shared<PostProcBrokenMeshInMoab<DomainEle>>(
mField);
2598 post_proc_fe->setTagsToTransfer({th_error});
2599 post_proc_fe->exeTestHook = test_mesh_bit;
2600
2601 if constexpr (
DIM1 == 1 &&
DIM2 == 1) {
2603 auto l_vec = boost::make_shared<VectorDouble>();
2604 auto l_grad_mat = boost::make_shared<MatrixDouble>();
2606 post_proc_fe->getOpPtrVector(), {L2});
2607 post_proc_fe->getOpPtrVector().push_back(
2609 post_proc_fe->getOpPtrVector().push_back(
2611
2612 post_proc_fe->getOpPtrVector().push_back(
2613
2615
2616 post_proc_fe->getPostProcMesh(), post_proc_fe->getMapGaussPts(),
2617
2618 {{"L", l_vec}},
2619
2620 {{"GradL", l_grad_mat}},
2621
2622 {}, {})
2623
2624 );
2625 }
2626
2628 post_proc_fe);
2629 post_proc_fe->writeFile(out_name);
2631 };
2632
2633 if constexpr (
debug)
2634 CHKERR post_proc(sub_dm,
"dg_projection.h5m", th_error);
2635
2637}
void simple(double P1[], double P2[], double P3[], double c[], const int N)
DomainEle::UserDataOperator DomainEleOp
Finire element operator type.
#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 DMoFEMMeshToLocalVector(DM dm, Vec l, InsertMode mode, ScatterMode scatter_mode)
set local (or ghosted) vector values on mesh for partition only
PetscErrorCode DMMoFEMAddSubFieldRow(DM dm, const char field_name[])
PetscErrorCode DMMoFEMKSPSetComputeRHS(DM dm, const char fe_name[], MoFEM::FEMethod *method, MoFEM::BasicMethod *pre_only, MoFEM::BasicMethod *post_only)
Set compute operator for KSP solver via sub-matrix and IS.
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)
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
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.
Get value at integration points for scalar field.
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...
PipelineManager interface.
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.