v0.15.0
Loading...
Searching...
No Matches
Classes | Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
AtomTest Struct Reference
Collaboration diagram for AtomTest:
[legend]

Classes

struct  CommonData
 Collected data use d by operator to evaluate errors for the test. More...
 
struct  OpError
 Operator to evaluate errors. More...
 
struct  OpError< 1 >
 
struct  OpErrorSkel
 
struct  OpErrorSkel< 1 >
 

Public Member Functions

 AtomTest (MoFEM::Interface &m_field)
 
MoFEMErrorCode runProblem ()
 [Run programme]
 
 AtomTest (MoFEM::Interface &m_field)
 
MoFEMErrorCode runProblem ()
 
 AtomTest (MoFEM::Interface &m_field)
 
MoFEMErrorCode runProblem ()
 
 AtomTest (MoFEM::Interface &m_field)
 
MoFEMErrorCode runProblem ()
 

Private Member Functions

MoFEMErrorCode readMesh ()
 [Run programme]
 
MoFEMErrorCode setupProblem ()
 [Read mesh]
 
MoFEMErrorCode assembleSystem ()
 [Push operators to pipeline]
 
MoFEMErrorCode solveSystem ()
 [Push operators to pipeline]
 
MoFEMErrorCode checkResults (boost::function< bool(FEMethod *fe_method_ptr)> test_bit)
 [Postprocess results]
 
MoFEMErrorCode refineResults ()
 [Solve]
 
MoFEMErrorCode readMesh ()
 
MoFEMErrorCode setupProblem ()
 
MoFEMErrorCode assembleSystem ()
 
MoFEMErrorCode solveSystem ()
 
MoFEMErrorCode checkResults ()
 [Check results]
 
MoFEMErrorCode readMesh ()
 red mesh and randomly refine three times
 
MoFEMErrorCode setupProblem ()
 add field, and set up problem
 
MoFEMErrorCode assembleSystem ()
 
MoFEMErrorCode solveSystem ()
 
MoFEMErrorCode checkResults ()
 
MoFEMErrorCode printResults ()
 [Check results]
 
MoFEMErrorCode readMesh ()
 
MoFEMErrorCode setupProblem ()
 
MoFEMErrorCode assembleSystem ()
 
MoFEMErrorCode solveSystem ()
 
MoFEMErrorCode checkResults ()
 

Private Attributes

MoFEM::InterfacemField
 
SimplesimpleInterface
 

Static Private Attributes

static ApproxFieldFunction< FIELD_DIMapproxFunction
 
static ApproxFieldFunctionDerivative< FIELD_DIMdivApproxFunction
 

Detailed Description

Examples
hanging_node_approx.cpp, higher_derivatives.cpp, and mofem/atom_tests/child_and_parent.cpp.

Definition at line 58 of file child_and_parent.cpp.

Constructor & Destructor Documentation

◆ AtomTest() [1/4]

AtomTest::AtomTest ( MoFEM::Interface m_field)
inline

Definition at line 60 of file child_and_parent.cpp.

60: mField(m_field) {}
MoFEM::Interface & mField

◆ AtomTest() [2/4]

AtomTest::AtomTest ( MoFEM::Interface m_field)
inline

Definition at line 57 of file dg_projection.cpp.

57: mField(m_field) {}

◆ AtomTest() [3/4]

AtomTest::AtomTest ( MoFEM::Interface m_field)
inline

Definition at line 180 of file hanging_node_approx.cpp.

180: mField(m_field) {}

◆ AtomTest() [4/4]

AtomTest::AtomTest ( MoFEM::Interface m_field)
inline

Definition at line 78 of file higher_derivatives.cpp.

78: mField(m_field) {}

Member Function Documentation

◆ assembleSystem() [1/4]

MoFEMErrorCode AtomTest::assembleSystem ( )
private

[Push operators to pipeline]

[Set up problem]

[Push operators to pipeline]

Examples
hanging_node_approx.cpp, higher_derivatives.cpp, and mofem/atom_tests/child_and_parent.cpp.

Definition at line 291 of file child_and_parent.cpp.

291 {
294
295 auto rule = [](int, int, int p) -> int { return 2 * p; };
296
297 CHKERR pipeline_mng->setDomainLhsIntegrationRule(rule);
298 CHKERR pipeline_mng->setDomainRhsIntegrationRule(rule);
299
300 auto test_bit_parent = [](FEMethod *fe_ptr) {
301 const auto &bit = fe_ptr->numeredEntFiniteElementPtr->getBitRefLevel();
302 MOFEM_LOG("SELF", Sev::noisy) << bit << " " << bit.test(0);
303 return bit.test(0);
304 };
305
306 pipeline_mng->getDomainLhsFE()->exeTestHook = test_bit_parent;
307 pipeline_mng->getDomainRhsFE()->exeTestHook = test_bit_parent;
308
309 auto beta = [](const double, const double, const double) { return 1; };
310
311 // Make aliased shared pointer, and create child element
312 domainChildLhs = boost::make_shared<DomainEle>(mField);
313 domainChildLhs->getRuleHook = rule;
314 domainChildLhs->getOpPtrVector().push_back(
316
317 domainChildRhs = boost::make_shared<DomainEle>(mField);
318 domainChildLhs->getRuleHook = rule;
319 domainChildRhs->getOpPtrVector().push_back(
321
322 auto parent_op_lhs = new DomainEleOp(NOSPACE, DomainEleOp::OPSPACE);
323 parent_op_lhs->doWorkRhsHook = [&](DataOperator *op_ptr, int side,
324 EntityType type,
326 auto domain_op = static_cast<DomainEleOp *>(op_ptr);
328
329 MOFEM_LOG("SELF", Sev::noisy) << "LHS Pipeline FE";
330
331 if (!domainChildLhs)
332 SETERRQ(PETSC_COMM_SELF, MOFEM_ATOM_TEST_INVALID, "FE not allocated");
333
334 auto &bit =
335 domain_op->getFEMethod()->numeredEntFiniteElementPtr->getBitRefLevel();
336 if (bit == BitRefLevel().set(0)) {
337 CHKERR domain_op->loopChildren(domain_op->getFEName(),
338 domainChildLhs.get(), VERBOSE, Sev::noisy);
339 } else {
340 CHKERR domain_op->loopThis(domain_op->getFEName(), domainChildLhs.get(),
341 VERBOSE, Sev::noisy);
342 }
344 };
345
346 auto parent_op_rhs = new DomainEleOp(NOSPACE, DomainEleOp::OPSPACE);
347 parent_op_rhs->doWorkRhsHook = [&](DataOperator *op_ptr, int side,
348 EntityType type,
350 auto domain_op = static_cast<DomainEleOp *>(op_ptr);
352
353 MOFEM_LOG("SELF", Sev::noisy) << "RHS Pipeline FE";
354
355 if (!domainChildRhs)
356 SETERRQ(PETSC_COMM_SELF, MOFEM_ATOM_TEST_INVALID, "FE not allocated");
357
358 auto &bit =
359 domain_op->getFEMethod()->numeredEntFiniteElementPtr->getBitRefLevel();
360 if (bit == BitRefLevel().set(0)) {
361 CHKERR domain_op->loopChildren(domain_op->getFEName(),
362 domainChildRhs.get(), VERBOSE, Sev::noisy);
363 } else if ((bit & BitRefLevel().set(0)).any()) {
364 CHKERR domain_op->loopThis(domain_op->getFEName(), domainChildRhs.get(),
365 VERBOSE, Sev::noisy);
366 }
368 };
369
370 pipeline_mng->getOpDomainLhsPipeline().push_back(parent_op_lhs);
371 pipeline_mng->getOpDomainRhsPipeline().push_back(parent_op_rhs);
372
374}
boost::shared_ptr< DomainEle > domainChildRhs
boost::shared_ptr< DomainEle > domainChildLhs
[Set up problem]
@ VERBOSE
@ NOSPACE
Definition definitions.h:83
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
@ MOFEM_ATOM_TEST_INVALID
Definition definitions.h:40
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
#define CHKERR
Inline error check.
boost::ptr_deque< UserDataOperator > & getOpDomainLhsPipeline()
Get the Op Domain Lhs Pipeline object.
boost::ptr_deque< UserDataOperator > & getOpDomainRhsPipeline()
Get the Op Domain Rhs Pipeline object.
#define MOFEM_LOG(channel, severity)
Log.
auto bit
set bit
constexpr char FIELD_NAME[]
DomainEle::UserDataOperator DomainEleOp
Finire element operator type.
FormsIntegrators< DomainEleOp >::Assembly< PETSC >::BiLinearForm< GAUSS >::OpMass< BASE_DIM, FIELD_DIM > OpDomainMass
OPerator to integrate mass matrix for least square approximation.
FormsIntegrators< DomainEleOp >::Assembly< PETSC >::LinearForm< GAUSS >::OpSource< BASE_DIM, FIELD_DIM > OpDomainSource
Operator to integrate the right hand side matrix for the problem.
std::bitset< BITREFLEVEL_SIZE > BitRefLevel
Bit structure attached to each entity identifying to what mesh entity is attached.
Definition Types.hpp:40
static ApproxFieldFunction< FIELD_DIM > approxFunction
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
PipelineManager interface.
boost::shared_ptr< FEMethod > & getDomainRhsFE()
boost::shared_ptr< FEMethod > & getDomainLhsFE()
MoFEMErrorCode setDomainRhsIntegrationRule(RuleHookFun rule)
MoFEMErrorCode setDomainLhsIntegrationRule(RuleHookFun rule)
MoFEMErrorCode getInterface(IFACE *&iface) const
Get interface reference to pointer of interface.

◆ assembleSystem() [2/4]

MoFEMErrorCode AtomTest::assembleSystem ( )
private

◆ assembleSystem() [3/4]

MoFEMErrorCode AtomTest::assembleSystem ( )
private

◆ assembleSystem() [4/4]

MoFEMErrorCode AtomTest::assembleSystem ( )
private

◆ checkResults() [1/4]

MoFEMErrorCode AtomTest::checkResults ( )
private

[Check results]

Examples
hanging_node_approx.cpp, higher_derivatives.cpp, and mofem/atom_tests/child_and_parent.cpp.

Definition at line 214 of file dg_projection.cpp.

214 {
217 auto pipeline_mng = mField.getInterface<PipelineManager>();
218 pipeline_mng->getDomainLhsFE().reset();
219 pipeline_mng->getDomainRhsFE().reset();
220 pipeline_mng->getOpDomainRhsPipeline().clear();
221
222 auto rule = [](int, int, int p) -> int { return 2 * p + 1; };
223 CHKERR pipeline_mng->setDomainRhsIntegrationRule(
224 rule); // set integration rule
225
226 auto entity_data_l2 = boost::make_shared<EntitiesFieldData>(
227 MBENTITYSET); // entity data shared between
228 // physical and post proc
229 // elements
230 auto mass_ptr = boost::make_shared<MatrixDouble>(); // integrated mass matrix
231 // of post proc element
232 auto coeffs_ptr =
233 boost::make_shared<MatrixDouble>(); // vector of coeffs shared between
234 // physical and post proc elements
235 auto data_ptr =
236 boost::make_shared<MatrixDouble>(); // data stored at integration points
237 // of the physical element and
238 // evaluated at integration points of
239 // the post proc element
240
241 auto op_this =
242 new OpLoopThis<DomainEle>(mField, simple->getDomainFEName(), Sev::noisy);
243 pipeline_mng->getOpDomainRhsPipeline().push_back(op_this); // 1
244 pipeline_mng->getOpDomainRhsPipeline().push_back(new OpDGProjectionEvaluation(
245 data_ptr, coeffs_ptr, entity_data_l2, AINSWORTH_LEGENDRE_BASE,
246 L2)); // 5
247 pipeline_mng->getOpDomainRhsPipeline().push_back(
248 new OpError(data_ptr)); // 6
249
250 auto fe_physics_ptr = op_this->getThisFEPtr();
251 fe_physics_ptr->getRuleHook = [](int, int, int p) { return 2 * p; };
252
253 fe_physics_ptr->getOpPtrVector().push_back(new OpDGProjectionMassMatrix(
254 order, mass_ptr, entity_data_l2, AINSWORTH_LEGENDRE_BASE, L2)); // 2
255 fe_physics_ptr->getOpPtrVector().push_back(
257 data_ptr)); // 3
258 fe_physics_ptr->getOpPtrVector().push_back(
259 new OpDGProjectionCoefficients(data_ptr, coeffs_ptr, mass_ptr,
260 entity_data_l2, AINSWORTH_LEGENDRE_BASE,
261 L2)); // 4
262
263 CHKERR pipeline_mng->loopFiniteElements();
264
266}
void simple(double P1[], double P2[], double P3[], double c[], const int N)
Definition acoustic.cpp:69
@ AINSWORTH_LEGENDRE_BASE
Ainsworth Cole (Legendre) approx. base .
Definition definitions.h:60
@ L2
field with C-1 continuity
Definition definitions.h:88
constexpr int order
Get values at integration pts for tensor field rank 1, i.e. vector field.
Execute "this" element in the operator.
Simple interface for fast problem set-up.
Definition Simple.hpp:27

◆ checkResults() [2/4]

MoFEMErrorCode AtomTest::checkResults ( )
private

◆ checkResults() [3/4]

MoFEMErrorCode AtomTest::checkResults ( )
private

◆ checkResults() [4/4]

MoFEMErrorCode AtomTest::checkResults ( boost::function< bool(FEMethod *fe_method_ptr)>  test_bit)
private

[Postprocess results]

[Check results]

Definition at line 524 of file child_and_parent.cpp.

525 {
528 pipeline_mng->getDomainLhsFE().reset();
529 pipeline_mng->getDomainRhsFE().reset();
530 pipeline_mng->getBoundaryRhsFE().reset();
531
532 auto rule = [](int, int, int p) -> int { return 2 * p + 1; };
533 CHKERR pipeline_mng->setDomainRhsIntegrationRule(rule);
534 pipeline_mng->getDomainRhsFE()->exeTestHook = test_bit;
535
536 auto common_data_ptr = boost::make_shared<CommonData>();
537 common_data_ptr->resVec = createDMVector(simpleInterface->getDM());
538 common_data_ptr->L2Vec = createVectorMPI(
539 mField.get_comm(), (!mField.get_comm_rank()) ? 1 : 0, 1);
540 common_data_ptr->approxVals = boost::make_shared<VectorDouble>();
541
542 pipeline_mng->getOpDomainRhsPipeline().push_back(
544 common_data_ptr->approxVals));
545 pipeline_mng->getOpDomainRhsPipeline().push_back(
546 new OpError<FIELD_DIM>(common_data_ptr));
547
548 CHKERR VecZeroEntries(common_data_ptr->L2Vec);
549 CHKERR VecZeroEntries(common_data_ptr->resVec);
550
551 CHKERR pipeline_mng->loopFiniteElements();
552
553 CHKERR VecAssemblyBegin(common_data_ptr->L2Vec);
554 CHKERR VecAssemblyEnd(common_data_ptr->L2Vec);
555 CHKERR VecAssemblyBegin(common_data_ptr->resVec);
556 CHKERR VecAssemblyEnd(common_data_ptr->resVec);
557 double nrm2;
558 CHKERR VecNorm(common_data_ptr->resVec, NORM_2, &nrm2);
559 const double *array;
560 CHKERR VecGetArrayRead(common_data_ptr->L2Vec, &array);
561 MOFEM_LOG_C("WORLD", Sev::inform, "Error %6.4e Vec norm %6.4e\n",
562 std::sqrt(array[0]), nrm2);
563 CHKERR VecRestoreArrayRead(common_data_ptr->L2Vec, &array);
564
565 constexpr double eps = 1e-8;
566 if (nrm2 > eps)
567 SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
568 "Not converged solution err = %6.4e", nrm2);
570}
#define MOFEM_LOG_C(channel, severity, format,...)
static const double eps
@ MOFEM_DATA_INCONSISTENCY
Definition definitions.h:31
auto createDMVector(DM dm)
Get smart vector from DM.
Definition DMMoFEM.hpp:1119
MoFEMErrorCode loopFiniteElements(SmartPetscObj< DM > dm=nullptr)
Iterate finite elements.
auto createVectorMPI(MPI_Comm comm, PetscInt n, PetscInt N)
Create MPI Vector.
Simple * simpleInterface
virtual MPI_Comm & get_comm() const =0
virtual int get_comm_rank() const =0
Get value at integration points for scalar field.
boost::shared_ptr< FEMethod > & getBoundaryRhsFE()
MoFEMErrorCode getDM(DM *dm)
Get DM.
Definition Simple.cpp:800

◆ printResults()

MoFEMErrorCode AtomTest::printResults ( )
private

[Check results]

Examples
hanging_node_approx.cpp.

Definition at line 655 of file hanging_node_approx.cpp.

655 {
658 pipeline_mng->getDomainLhsFE().reset();
659 pipeline_mng->getDomainRhsFE().reset();
660
661 auto rule = [](int, int, int p) -> int { return -1; };
662 CHKERR pipeline_mng->setDomainRhsIntegrationRule(rule);
663
664 static_cast<ForcesAndSourcesCore *>(pipeline_mng->getDomainRhsFE().get())
665 ->setRuleHook = [](ForcesAndSourcesCore *fe_raw_ptr, int order_row,
666 int order_col, int order_data) -> MoFEMErrorCode {
668 fe_raw_ptr->gaussPts.resize(3, 3);
669 fe_raw_ptr->gaussPts(0, 0) = 0;
670 fe_raw_ptr->gaussPts(1, 0) = 0;
671 fe_raw_ptr->gaussPts(2, 0) = 0;
672 fe_raw_ptr->gaussPts(0, 1) = 1;
673 fe_raw_ptr->gaussPts(1, 1) = 0;
674 fe_raw_ptr->gaussPts(2, 1) = 0;
675 fe_raw_ptr->gaussPts(0, 2) = 0;
676 fe_raw_ptr->gaussPts(1, 2) = 1;
677 fe_raw_ptr->gaussPts(2, 2) = 0;
679 };
680
681 auto field_op_row = new ForcesAndSourcesCore::UserDataOperator(
682 FIELD_NAME, DomainEleOp::OPROW);
683
684 auto approx_vals = boost::make_shared<VectorDouble>();
685
686 auto &moab = mField.get_moab();
687 Tag th;
688 double def_val[] = {0};
689 CHKERR moab.tag_get_handle("FIELD", 1, MB_TYPE_DOUBLE, th,
690 MB_TAG_CREAT | MB_TAG_SPARSE, &def_val);
691
692 field_op_row->doWorkRhsHook = [&](DataOperator *base_op_ptr, int side,
693 EntityType type,
696 if (type == MBVERTEX) {
697 auto op_ptr =
698 static_cast<FaceElementForcesAndSourcesCore::UserDataOperator *>(
699 base_op_ptr);
700 auto t_field = getFTensor0FromVec(*approx_vals);
701 auto nb_gauss_pts = op_ptr->getGaussPts().size2();
702 if (nb_gauss_pts != 3)
703 SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
704 "Should be three guass pts.");
705 auto conn = op_ptr->getConn();
706 for (auto gg = 0; gg != nb_gauss_pts; ++gg) {
707 const double v = t_field;
708 CHKERR moab.tag_set_data(th, &conn[gg], 1, &v);
709 ++t_field;
710 }
711 }
713 };
714
715 set_parent_dofs<DomainParentEle>(mField, pipeline_mng->getDomainRhsFE(),
716 DomainEleOp::OPSPACE, VERBOSE, Sev::noisy);
717 set_parent_dofs<DomainParentEle>(mField, pipeline_mng->getDomainRhsFE(),
718 DomainEleOp::OPROW, VERBOSE, Sev::noisy);
719 pipeline_mng->getOpDomainRhsPipeline().push_back(
720 new OpCalculateScalarFieldValues(FIELD_NAME, approx_vals));
721 pipeline_mng->getOpDomainRhsPipeline().push_back(field_op_row);
722 CHKERR pipeline_mng->loopFiniteElements();
723
724 CHKERR mField.getInterface<BitRefManager>()->writeBitLevelByType(
725 bit(nb_ref_levels), BitRefLevel().set(), MBTRI, "out.vtk", "VTK", "");
726
728}
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return()
#define MoFEMFunctionBeginHot
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
constexpr int nb_ref_levels
Three levels of refinement.
const double v
phase velocity of light in medium (cm/ns)
PetscErrorCode MoFEMErrorCode
MoFEM/PETSc error code.
static auto getFTensor0FromVec(ublas::vector< T, A > &data)
Get tensor rank 0 (scalar) form data vector.
Managing BitRefLevels.
virtual moab::Interface & get_moab()=0
structure to get information form mofem into EntitiesFieldData
MatrixDouble gaussPts
Matrix of integration points.

◆ readMesh() [1/4]

MoFEMErrorCode AtomTest::readMesh ( )
private

[Run programme]

[Read mesh]

Examples
hanging_node_approx.cpp, higher_derivatives.cpp, and mofem/atom_tests/child_and_parent.cpp.

Definition at line 209 of file child_and_parent.cpp.

209 {
211
215
216 MOFEM_LOG("WORLD", Sev::verbose) << "Dim " << simpleInterface->getDim();
217
218 auto bit_level0 = simpleInterface->getBitRefLevel();
219
220 auto &moab = mField.get_moab();
221
222 auto refine_mesh = [&](auto bit_level1) {
224
225 auto refine = mField.getInterface<MeshRefinement>();
226
227 auto meshset_level0_ptr = get_temp_meshset_ptr(moab);
228 CHKERR mField.getInterface<BitRefManager>()->getEntitiesByRefLevel(
229 bit_level0, BitRefLevel().set(), *meshset_level0_ptr);
230
231 // random mesh refinement
232 auto meshset_ref_edges_ptr = get_temp_meshset_ptr(moab);
233 Range edges_to_refine;
234 CHKERR moab.get_entities_by_type(*meshset_level0_ptr, MBEDGE,
235 edges_to_refine);
236 int ii = 0;
237 for (Range::iterator eit = edges_to_refine.begin();
238 eit != edges_to_refine.end(); eit++, ii++) {
239 int numb = ii % 2;
240 if (numb == 0) {
241 CHKERR moab.add_entities(*meshset_ref_edges_ptr, &*eit, 1);
242 }
243 }
244 CHKERR refine->addVerticesInTheMiddleOfEdges(*meshset_ref_edges_ptr,
245 bit_level1, false, VERBOSE);
246 if (simpleInterface->getDim() == 3) {
247 CHKERR refine->refineTets(*meshset_level0_ptr, bit_level1, VERBOSE);
248 } else if (simpleInterface->getDim() == 2) {
249 CHKERR refine->refineTris(*meshset_level0_ptr, bit_level1, VERBOSE);
250 } else {
251 SETERRQ(PETSC_COMM_WORLD, MOFEM_ATOM_TEST_INVALID,
252 "Dimension not handled by test");
253 }
254
256 };
257
258 BitRefLevel bit_level1;
259 bit_level1.set(1);
260 CHKERR refine_mesh(bit_level1);
263
265}
auto get_temp_meshset_ptr(moab::Interface &moab)
Create smart pointer to temporary meshset.
Mesh refinement interface.
int getDim() const
Get the problem dimension.
Definition Simple.hpp:333
MoFEMErrorCode loadFile(const std::string options, const std::string mesh_file_name, LoadFileFunc loadFunc=defaultLoadFileFunc)
Load mesh file.
Definition Simple.cpp:191
MoFEMErrorCode getOptions()
get options
Definition Simple.cpp:180
BitRefLevel & getBitRefLevelMask()
Get the BitRefLevel.
Definition Simple.hpp:382
BitRefLevel & getBitRefLevel()
Get the BitRefLevel.
Definition Simple.hpp:375

◆ readMesh() [2/4]

MoFEMErrorCode AtomTest::readMesh ( )
private

◆ readMesh() [3/4]

MoFEMErrorCode AtomTest::readMesh ( )
private

red mesh and randomly refine three times

Returns
MoFEMErrorCode

◆ readMesh() [4/4]

MoFEMErrorCode AtomTest::readMesh ( )
private

◆ refineResults()

MoFEMErrorCode AtomTest::refineResults ( )
private

[Solve]

Examples
mofem/atom_tests/child_and_parent.cpp.

Definition at line 400 of file child_and_parent.cpp.

400 {
402
403 auto &moab = mField.get_moab();
404
405 auto bit_level0 = BitRefLevel().set(0);
406 auto bit_level1 = BitRefLevel().set(1);
407 auto bit_level2 = BitRefLevel().set(2);
408
409 auto refine_mesh = [&]() {
411
412 auto refine = mField.getInterface<MeshRefinement>();
413
414 auto meshset_level1_ptr = get_temp_meshset_ptr(moab);
415 CHKERR mField.getInterface<BitRefManager>()->getEntitiesByDimAndRefLevel(
416 bit_level1, BitRefLevel().set(), simpleInterface->getDim(),
417 *meshset_level1_ptr);
418
419 // random mesh refinement
420 auto meshset_ref_edges_ptr = get_temp_meshset_ptr(moab);
421 Range edges_to_refine;
422 CHKERR mField.getInterface<BitRefManager>()->getEntitiesByTypeAndRefLevel(
423 bit_level1, BitRefLevel().set(), MBEDGE, edges_to_refine);
424
425 CHKERR refine->addVerticesInTheMiddleOfEdges(edges_to_refine, bit_level2,
426 VERBOSE);
427 if (simpleInterface->getDim() == 3) {
428 CHKERR refine->refineTets(*meshset_level1_ptr, bit_level2, VERBOSE);
429 } else if (simpleInterface->getDim() == 2) {
430 CHKERR refine->refineTris(*meshset_level1_ptr, bit_level2, VERBOSE);
431 } else {
432 SETERRQ(PETSC_COMM_WORLD, MOFEM_ATOM_TEST_INVALID,
433 "Dimension not handled by test");
434 }
435
436 Range meshsets;
437 CHKERR moab.get_entities_by_type(0, MBENTITYSET, meshsets, true);
438 for (auto m : meshsets) {
440 ->updateMeshsetByEntitiesChildren(m, bit_level2, m, MBMAXTYPE, false);
441 }
442
444 };
445
446 CHKERR refine_mesh();
447
448 simpleInterface->getBitRefLevel() = bit_level1 | bit_level2;
450
452
453 CHKERR mField.getInterface<ProblemsManager>()->removeDofsOnEntities(
455 bit_level0 | bit_level1);
456
457 auto project_data = [&]() {
459
461
462 pipeline_mng->getDomainLhsFE().reset();
463 pipeline_mng->getDomainRhsFE().reset();
464 pipeline_mng->getBoundaryRhsFE().reset();
465
466 auto rule = [](int, int, int p) -> int { return 2 * p; };
467
468 CHKERR pipeline_mng->setDomainLhsIntegrationRule(rule);
469 CHKERR pipeline_mng->setDomainRhsIntegrationRule(rule);
470 CHKERR pipeline_mng->setBoundaryRhsIntegrationRule(rule);
471
472 auto test_bit_ref = [](FEMethod *fe_ptr) {
473 const auto &bit = fe_ptr->numeredEntFiniteElementPtr->getBitRefLevel();
474 MOFEM_LOG("SELF", Sev::noisy) << "ref : " << bit << " " << bit.test(2);
475 return bit.test(2);
476 };
477
478 pipeline_mng->getDomainLhsFE()->exeTestHook = test_bit_ref;
479 pipeline_mng->getDomainRhsFE()->exeTestHook = test_bit_ref;
480 pipeline_mng->getBoundaryRhsFE()->exeTestHook = test_bit_ref;
481
482 auto beta = [](const double, const double, const double) { return 1; };
483 auto field_vals_ptr = boost::make_shared<VectorDouble>();
484
485 auto domainParentRhs = boost::make_shared<DomainParentEle>(mField);
486 domainParentRhs->getOpPtrVector().push_back(
487 new OpCalculateScalarFieldValues(FIELD_NAME, field_vals_ptr));
488
489 pipeline_mng->getOpDomainLhsPipeline().push_back(
491 pipeline_mng->getOpDomainRhsPipeline().push_back(
492 new OpRunParent(domainParentRhs, bit_level2, bit_level2,
493 domainParentRhs, bit_level2, BitRefLevel().set()));
494
497 pipeline_mng->getOpDomainRhsPipeline().push_back(
498 new OpDomainTimesScalarField(FIELD_NAME, field_vals_ptr, beta));
499
500 pipeline_mng->getOpDomainRhsPipeline().push_back(
502
503 pipeline_mng->getOpBoundaryRhsPipeline().push_back(
505
507
508 simpleInterface->getBitRefLevel() = bit_level2;
511
512 CHKERR checkResults([](FEMethod *fe_ptr) { return true; });
513
515 };
516
517 CHKERR project_data();
518
520}
boost::ptr_deque< UserDataOperator > & getOpBoundaryRhsPipeline()
Get the Op Boundary Rhs Pipeline object.
FormsIntegrators< DomainEleOp >::Assembly< PETSC >::LinearForm< GAUSS >::OpBaseTimesScalar< 1 > OpDomainTimesScalarField
FTensor::Index< 'm', 3 > m
MoFEMErrorCode checkResults()
[Check results]
MoFEMErrorCode solveSystem()
[Push operators to pipeline]
Operator to execute finite element instance on parent element. This operator is typically used to pro...
MoFEMErrorCode setBoundaryRhsIntegrationRule(RuleHookFun rule)
Problem manager is used to build and partition problems.
MoFEMErrorCode reSetUp(bool only_dm=false)
Rebuild internal MoFEM data structures.
Definition Simple.cpp:762
const std::string getProblemName() const
Get the Problem Name.
Definition Simple.hpp:410

◆ runProblem() [1/4]

MoFEMErrorCode AtomTest::runProblem ( )

[Run programme]

Examples
hanging_node_approx.cpp, higher_derivatives.cpp, and mofem/atom_tests/child_and_parent.cpp.

Definition at line 189 of file child_and_parent.cpp.

189 {
195
196 auto test_bit_child = [](FEMethod *fe_ptr) {
197 const auto &bit = fe_ptr->numeredEntFiniteElementPtr->getBitRefLevel();
198 MOFEM_LOG("SELF", Sev::noisy) << bit << " " << bit.test(0);
199 return bit.test(1);
200 };
201
205}
auto test_bit_child
lambda function used to select elements on which finite element pipelines are executed.
MoFEMErrorCode setupProblem()
[Read mesh]
MoFEMErrorCode refineResults()
[Solve]
MoFEMErrorCode readMesh()
[Run programme]
MoFEMErrorCode assembleSystem()
[Push operators to pipeline]

◆ runProblem() [2/4]

MoFEMErrorCode AtomTest::runProblem ( )

◆ runProblem() [3/4]

MoFEMErrorCode AtomTest::runProblem ( )

◆ runProblem() [4/4]

MoFEMErrorCode AtomTest::runProblem ( )

◆ setupProblem() [1/4]

MoFEMErrorCode AtomTest::setupProblem ( )
private

[Read mesh]

[Set up problem]

Examples
hanging_node_approx.cpp, higher_derivatives.cpp, and mofem/atom_tests/child_and_parent.cpp.

Definition at line 269 of file child_and_parent.cpp.

269 {
271 // Add field
276 constexpr int order = 4;
279
280 CHKERR mField.getInterface<ProblemsManager>()->removeDofsOnEntities(
282 BitRefLevel().set(0));
283
285}
@ H1
continuous field
Definition definitions.h:85
constexpr int FIELD_DIM
MoFEMErrorCode addDomainField(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_ZERO, int verb=-1)
Add field on domain.
Definition Simple.cpp:261
MoFEMErrorCode addBoundaryField(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_ZERO, int verb=-1)
Add field on boundary.
Definition Simple.cpp:355
MoFEMErrorCode setFieldOrder(const std::string field_name, const int order, const Range *ents=NULL)
Set field order.
Definition Simple.cpp:575
MoFEMErrorCode setUp(const PetscBool is_partitioned=PETSC_TRUE)
Setup problem.
Definition Simple.cpp:736

◆ setupProblem() [2/4]

MoFEMErrorCode AtomTest::setupProblem ( )
private

◆ setupProblem() [3/4]

MoFEMErrorCode AtomTest::setupProblem ( )
private

add field, and set up problem

Returns
MoFEMErrorCode

◆ setupProblem() [4/4]

MoFEMErrorCode AtomTest::setupProblem ( )
private

◆ solveSystem() [1/4]

MoFEMErrorCode AtomTest::solveSystem ( )
private

[Push operators to pipeline]

[Solve]

Examples
hanging_node_approx.cpp, higher_derivatives.cpp, and mofem/atom_tests/child_and_parent.cpp.

Definition at line 378 of file child_and_parent.cpp.

378 {
381
382 MOFEM_LOG("WORLD", Sev::inform) << "Solve problem";
383
384 auto solver = pipeline_mng->createKSP();
385 CHKERR KSPSetFromOptions(solver);
386 CHKERR KSPSetUp(solver);
387
388 auto dm = simpleInterface->getDM();
389 auto D = createDMVector(dm);
390 auto F = vectorDuplicate(D);
391
392 CHKERR KSPSolve(solver, F, D);
393 CHKERR VecGhostUpdateBegin(D, INSERT_VALUES, SCATTER_FORWARD);
394 CHKERR VecGhostUpdateEnd(D, INSERT_VALUES, SCATTER_FORWARD);
395 CHKERR DMoFEMMeshToLocalVector(dm, D, INSERT_VALUES, SCATTER_REVERSE);
397}
@ F
PetscErrorCode DMoFEMMeshToLocalVector(DM dm, Vec l, InsertMode mode, ScatterMode scatter_mode)
set local (or ghosted) vector values on mesh for partition only
Definition DMMoFEM.cpp:514
SmartPetscObj< KSP > createKSP(SmartPetscObj< DM > dm=nullptr)
Create KSP (linear) solver.
double D
SmartPetscObj< Vec > vectorDuplicate(Vec vec)
Create duplicate vector of smart vector.

◆ solveSystem() [2/4]

MoFEMErrorCode AtomTest::solveSystem ( )
private

◆ solveSystem() [3/4]

MoFEMErrorCode AtomTest::solveSystem ( )
private

◆ solveSystem() [4/4]

MoFEMErrorCode AtomTest::solveSystem ( )
private

Member Data Documentation

◆ approxFunction

ApproxFieldFunction< FIELD_DIM > AtomTest::approxFunction
staticprivate

◆ divApproxFunction

ApproxFieldFunctionDerivative< FIELD_DIM > AtomTest::divApproxFunction
staticprivate

◆ mField

MoFEM::Interface & AtomTest::mField
private

◆ simpleInterface

Simple * AtomTest::simpleInterface
private

The documentation for this struct was generated from the following files: