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

Public Member Functions

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

Private Member Functions

MoFEMErrorCode getOptions ()
 [Run programme]
 
MoFEMErrorCode readMesh ()
 [Read mesh]
 
MoFEMErrorCode setupProblem ()
 [Read mesh]
 
MoFEMErrorCode setOPs ()
 [Set up problem]
 
MoFEMErrorCode solveSystem ()
 [Push operators to pipeline]
 
MoFEMErrorCode outputResults ()
 [Solve]
 

Private Attributes

MoFEM::InterfacemField
 

Detailed Description

Examples
mofem/tutorials/vec-4_shallow_wave/approx_sphere.cpp.

Definition at line 258 of file approx_sphere.cpp.

Constructor & Destructor Documentation

◆ ApproxSphere()

ApproxSphere::ApproxSphere ( MoFEM::Interface m_field)
inline

Definition at line 260 of file approx_sphere.cpp.

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

Member Function Documentation

◆ getOptions()

MoFEMErrorCode ApproxSphere::getOptions ( )
private

[Run programme]

Examples
mofem/tutorials/vec-4_shallow_wave/approx_sphere.cpp.

Definition at line 288 of file approx_sphere.cpp.

288 {
291}
#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 ...

◆ outputResults()

MoFEMErrorCode ApproxSphere::outputResults ( )
private

[Solve]

Examples
mofem/tutorials/vec-4_shallow_wave/approx_sphere.cpp.

Definition at line 390 of file approx_sphere.cpp.

390 {
392
393 auto x_ptr = boost::make_shared<MatrixDouble>();
394 auto det_ptr = boost::make_shared<VectorDouble>();
395 auto jac_ptr = boost::make_shared<MatrixDouble>();
396 auto inv_jac_ptr = boost::make_shared<MatrixDouble>();
397
399 auto dm = simple->getDM();
400
401 auto post_proc_fe =
402 boost::make_shared<PostProcBrokenMeshInMoab<DomainEle>>(mField);
403
404 post_proc_fe->getOpPtrVector().push_back(
405 new OpCalculateVectorFieldValues<3>("HO_POSITIONS", x_ptr));
406
408
409 post_proc_fe->getOpPtrVector().push_back(
410
411 new OpPPMap(post_proc_fe->getPostProcMesh(),
412 post_proc_fe->getMapGaussPts(),
413
414 {},
415
416 {{"HO_POSITIONS", x_ptr}},
417
418 {}, {}
419
420 )
421
422 );
423
424 CHKERR DMoFEMLoopFiniteElements(dm, "dFE", post_proc_fe);
425 CHKERR post_proc_fe->writeFile("out_approx.h5m");
426
427 auto error_fe = boost::make_shared<DomainEle>(mField);
428
429 error_fe->getOpPtrVector().push_back(
430 new OpGetHONormalsOnFace("HO_POSITIONS"));
431 error_fe->getOpPtrVector().push_back(
432 new OpCalculateVectorFieldValues<3>("HO_POSITIONS", x_ptr));
433 error_fe->getOpPtrVector().push_back(new OpError("HO_POSITIONS", x_ptr));
434
435 error_fe->preProcessHook = [&]() {
437 MOFEM_LOG("EXAMPLE", Sev::inform) << "Create vec ";
439 mField.get_comm(), (!mField.get_comm_rank()) ? 1 : 0, 1);
440 VecZeroEntries(OpError::errorVec);
442 };
443
444 error_fe->postProcessHook = [&]() {
446 CHKERR VecAssemblyBegin(OpError::errorVec);
447 CHKERR VecAssemblyEnd(OpError::errorVec);
448 double error2;
449 CHKERR VecSum(OpError::errorVec, &error2);
450 MOFEM_LOG("EXAMPLE", Sev::inform)
451 << "Error " << std::sqrt(error2 / (4 * M_PI * A * A));
452 OpError::errorVec.reset();
454 };
455
456 CHKERR DMoFEMLoopFiniteElements(dm, "dFE", error_fe);
457
458 CHKERR simple->deleteDM();
459 CHKERR simple->deleteFiniteElements();
460 if (mField.get_comm_size() > 1)
461 CHKERR mField.get_moab().write_file("out_ho_mesh.h5m", "MOAB",
462 "PARALLEL=WRITE_PART");
463 else
464 CHKERR mField.get_moab().write_file("out_ho_mesh.h5m");
466}
void simple(double P1[], double P2[], double P3[], double c[], const int N)
Definition acoustic.cpp:69
constexpr double A
#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 DMoFEMLoopFiniteElements(DM dm, const char fe_name[], MoFEM::FEMethod *method, CacheTupleWeakPtr cache_ptr=CacheTupleSharedPtr())
Executes FEMethod for finite elements in DM.
Definition DMMoFEM.cpp:576
#define MOFEM_LOG(channel, severity)
Log.
auto createVectorMPI(MPI_Comm comm, PetscInt n, PetscInt N)
Create MPI Vector.
OpPostProcMapInMoab< SPACE_DIM, SPACE_DIM > OpPPMap
virtual int get_comm_size() const =0
virtual moab::Interface & get_moab()=0
virtual MPI_Comm & get_comm() const =0
virtual int get_comm_rank() const =0
Specialization for MatrixDouble vector field values calculation.
Calculate normal vectors at Gauss points of face elements.
Post post-proc data at points from hash maps.
Simple interface for fast problem set-up.
Definition Simple.hpp:27
MoFEMErrorCode getDM(DM *dm)
Get DM.
Definition Simple.cpp:799
MoFEMErrorCode getInterface(IFACE *&iface) const
Get interface reference to pointer of interface.
static SmartPetscObj< Vec > errorVec

◆ readMesh()

MoFEMErrorCode ApproxSphere::readMesh ( )
private

[Read mesh]

Examples
mofem/tutorials/vec-4_shallow_wave/approx_sphere.cpp.

Definition at line 294 of file approx_sphere.cpp.

294 {
298 CHKERR simple->loadFile();
300}
MoFEMErrorCode getOptions()
get options
Definition Simple.cpp:180

◆ runProblem()

MoFEMErrorCode ApproxSphere::runProblem ( )

[Run programme]

Examples
mofem/tutorials/vec-4_shallow_wave/approx_sphere.cpp.

Definition at line 276 of file approx_sphere.cpp.

276 {
281 CHKERR setOPs();
285}
MoFEMErrorCode readMesh()
[Read mesh]
MoFEMErrorCode solveSystem()
[Push operators to pipeline]
MoFEMErrorCode setupProblem()
[Read mesh]
MoFEMErrorCode setOPs()
[Set up problem]
MoFEMErrorCode getOptions()
[Run programme]
MoFEMErrorCode outputResults()
[Solve]

◆ setOPs()

MoFEMErrorCode ApproxSphere::setOPs ( )
private

[Set up problem]

[Push operators to pipeline]

Examples
mofem/tutorials/vec-4_shallow_wave/approx_sphere.cpp.

Definition at line 321 of file approx_sphere.cpp.

321 {
324
325 auto integration_rule = [](int, int, int approx_order) {
326 return 3 * approx_order;
327 };
330
331 auto x_ptr = boost::make_shared<MatrixDouble>();
332 auto dot_x_ptr = boost::make_shared<MatrixDouble>();
333 auto det_ptr = boost::make_shared<VectorDouble>();
334 auto jac_ptr = boost::make_shared<MatrixDouble>();
335 auto inv_jac_ptr = boost::make_shared<MatrixDouble>();
336
337 auto def_ops = [&](auto &pipeline) {
338 pipeline.push_back(
339 new OpCalculateVectorFieldValues<3>("HO_POSITIONS", x_ptr));
340 pipeline.push_back(
341 new OpCalculateVectorFieldValuesDot<3>("HO_POSITIONS", dot_x_ptr));
342 };
343
344 def_ops(pipeline_mng->getOpDomainRhsPipeline());
345 def_ops(pipeline_mng->getOpDomainLhsPipeline());
346
347 pipeline_mng->getOpDomainRhsPipeline().push_back(
348 new OpRhs("HO_POSITIONS", x_ptr, dot_x_ptr));
349 pipeline_mng->getOpDomainLhsPipeline().push_back(
350 new OpLhs("HO_POSITIONS", x_ptr, dot_x_ptr));
351
353}
auto integration_rule
boost::ptr_deque< UserDataOperator > & getOpDomainLhsPipeline()
Get the Op Domain Lhs Pipeline object.
boost::ptr_deque< UserDataOperator > & getOpDomainRhsPipeline()
Get the Op Domain Rhs Pipeline object.
static constexpr int approx_order
Approximate field values for given petsc vector.
PipelineManager interface.
MoFEMErrorCode setDomainRhsIntegrationRule(RuleHookFun rule)
Set integration rule for domain right-hand side finite element.
MoFEMErrorCode setDomainLhsIntegrationRule(RuleHookFun rule)
Set integration rule for domain left-hand side finite element.

◆ setupProblem()

MoFEMErrorCode ApproxSphere::setupProblem ( )
private

[Read mesh]

[Set up problem]

Examples
mofem/tutorials/vec-4_shallow_wave/approx_sphere.cpp.

Definition at line 304 of file approx_sphere.cpp.

304 {
306
309 CHKERR simple->addDataField("HO_POSITIONS", H1, AINSWORTH_LEGENDRE_BASE, 3);
310
311 int order = 3;
312 CHKERR PetscOptionsGetInt(PETSC_NULLPTR, "", "-order", &order, PETSC_NULLPTR);
313 CHKERR simple->setFieldOrder("HO_POSITIONS", order);
314 CHKERR simple->setUp();
315
317}
@ AINSWORTH_LEGENDRE_BASE
Ainsworth Cole (Legendre) approx. base .
Definition definitions.h:60
@ H1
continuous field
Definition definitions.h:85
constexpr int order
PetscErrorCode PetscOptionsGetInt(PetscOptions *, const char pre[], const char name[], PetscInt *ivalue, PetscBool *set)
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

◆ solveSystem()

MoFEMErrorCode ApproxSphere::solveSystem ( )
private

[Push operators to pipeline]

[Solve]

Examples
mofem/tutorials/vec-4_shallow_wave/approx_sphere.cpp.

Definition at line 357 of file approx_sphere.cpp.

357 {
359
360 // Project HO geometry from mesh
361 Projection10NodeCoordsOnField ent_method_material(mField, "HO_POSITIONS");
362 CHKERR mField.loop_dofs("HO_POSITIONS", ent_method_material);
363
364 auto *simple = mField.getInterface<Simple>();
365 auto *pipeline_mng = mField.getInterface<PipelineManager>();
366
367 auto dm = simple->getDM();
369 ts = pipeline_mng->createTSIM();
370
371 double ftime = 1;
372 CHKERR TSSetMaxSteps(ts, 1);
373 CHKERR TSSetExactFinalTime(ts, TS_EXACTFINALTIME_MATCHSTEP);
374
375 auto T = createDMVector(simple->getDM());
376 CHKERR DMoFEMMeshToLocalVector(simple->getDM(), T, INSERT_VALUES,
377 SCATTER_FORWARD);
378 CHKERR TSSetSolution(ts, T);
379 CHKERR TSSetFromOptions(ts);
380
381 CHKERR TSSolve(ts, NULL);
382 CHKERR TSGetTime(ts, &ftime);
383
384 CHKERR mField.getInterface<FieldBlas>()->fieldScale(A, "HO_POSITIONS");
385
387}
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
Definition DMMoFEM.cpp:514
auto createDMVector(DM dm, RowColData rc=RowColData::COL)
Get smart vector from DM.
Definition DMMoFEM.hpp:1237
virtual MoFEMErrorCode loop_dofs(const Problem *problem_ptr, const std::string &field_name, RowColData rc, DofMethod &method, int lower_rank, int upper_rank, int verb=DEFAULT_VERBOSITY)=0
Make a loop over dofs.
Basic algebra on fields.
Definition FieldBlas.hpp:21
Projection of edge entities with one mid-node on hierarchical basis.
intrusive_ptr for managing petsc objects

Member Data Documentation

◆ mField

MoFEM::Interface& ApproxSphere::mField
private

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