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

Public Member Functions

 FreeSurface (MoFEM::Interface &m_field)
 
MoFEMErrorCode runProblem ()
 [Run programme] More...
 
MoFEMErrorCode makeRefProblem ()
 

Public Attributes

MoFEM::InterfacemField
 

Private Member Functions

MoFEMErrorCode readMesh ()
 [Run programme] More...
 
MoFEMErrorCode setupProblem ()
 [Read mesh] More...
 
MoFEMErrorCode boundaryCondition ()
 [Set up problem] More...
 
MoFEMErrorCode assembleSystem ()
 [Boundary condition] More...
 
MoFEMErrorCode solveSystem ()
 [Solve] More...
 

Private Attributes

boost::shared_ptr< FEMethoddomianLhsFEPtr
 

Detailed Description

Examples
free_surface.cpp.

Definition at line 237 of file free_surface.cpp.

Constructor & Destructor Documentation

◆ FreeSurface()

FreeSurface::FreeSurface ( MoFEM::Interface m_field)
inline

Definition at line 239 of file free_surface.cpp.

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

Member Function Documentation

◆ assembleSystem()

MoFEMErrorCode FreeSurface::assembleSystem ( )
private

[Boundary condition]

[Push operators to pipeline]

Examples
free_surface.cpp.

Definition at line 487 of file free_surface.cpp.

487 {
489
490 auto dot_u_ptr = boost::make_shared<MatrixDouble>();
491 auto u_ptr = boost::make_shared<MatrixDouble>();
492 auto grad_u_ptr = boost::make_shared<MatrixDouble>();
493 auto dot_h_ptr = boost::make_shared<VectorDouble>();
494 auto h_ptr = boost::make_shared<VectorDouble>();
495 auto grad_h_ptr = boost::make_shared<MatrixDouble>();
496 auto g_ptr = boost::make_shared<VectorDouble>();
497 auto grad_g_ptr = boost::make_shared<MatrixDouble>();
498 auto lambda_ptr = boost::make_shared<VectorDouble>();
499 auto p_ptr = boost::make_shared<VectorDouble>();
500 auto div_u_ptr = boost::make_shared<VectorDouble>();
501
502 // Push element from reference configuration to current configuration in 3d
503 // space
504 auto set_domain_general = [&](auto &pipeline, auto &fe) {
505 auto det_ptr = boost::make_shared<VectorDouble>();
506 auto jac_ptr = boost::make_shared<MatrixDouble>();
507 auto inv_jac_ptr = boost::make_shared<MatrixDouble>();
508 pipeline.push_back(new OpCalculateHOJac<SPACE_DIM>(jac_ptr));
509 pipeline.push_back(
510 new OpInvertMatrix<SPACE_DIM>(jac_ptr, det_ptr, inv_jac_ptr));
511 pipeline.push_back(
512 new OpSetHOInvJacToScalarBases<SPACE_DIM>(H1, inv_jac_ptr));
513 pipeline.push_back(new OpSetHOWeightsOnFace());
514
515 pipeline.push_back(
517 pipeline.push_back(
519 pipeline.push_back(
521 grad_u_ptr));
522 pipeline.push_back(
524 "U", div_u_ptr));
525
526 pipeline.push_back(new OpCalculateScalarFieldValuesDot("H", dot_h_ptr));
527 pipeline.push_back(new OpCalculateScalarFieldValues("H", h_ptr));
528 pipeline.push_back(
529 new OpCalculateScalarFieldGradient<SPACE_DIM>("H", grad_h_ptr));
530
531 pipeline.push_back(new OpCalculateScalarFieldValues("G", g_ptr));
532 pipeline.push_back(
533 new OpCalculateScalarFieldGradient<SPACE_DIM>("G", grad_g_ptr));
534
535 pipeline.push_back(new OpCalculateScalarFieldValues("P", p_ptr));
536 };
537
538 auto set_domain_rhs = [&](auto &pipeline, auto &fe) {
539 set_domain_general(pipeline, fe);
540 pipeline.push_back(new OpRhsU("U", dot_u_ptr, u_ptr, grad_u_ptr, h_ptr,
541 grad_h_ptr, g_ptr, p_ptr));
542 pipeline.push_back(new OpRhsH<false>("H", u_ptr, dot_h_ptr, h_ptr,
543 grad_h_ptr, grad_g_ptr));
544 pipeline.push_back(new OpRhsG<false>("G", h_ptr, grad_h_ptr, g_ptr));
545 pipeline.push_back(new OpBaseTimesScalar(
546 "P", div_u_ptr, [](const double r, const double, const double) {
547 return cylindrical(r);
548 }));
549 pipeline.push_back(new OpBaseTimesScalar(
550 "P", p_ptr, [](const double r, const double, const double) {
551 return eps * cylindrical(r);
552 }));
553 };
554
555 auto set_domain_lhs = [&](auto &pipeline, auto &fe) {
556 set_domain_general(pipeline, fe);
557 pipeline.push_back(new OpLhsU_dU("U", u_ptr, grad_u_ptr, h_ptr));
558 pipeline.push_back(
559 new OpLhsU_dH("U", "H", dot_u_ptr, u_ptr, grad_u_ptr, h_ptr, g_ptr));
560 pipeline.push_back(new OpLhsU_dG("U", "G", grad_h_ptr));
561
562 pipeline.push_back(new OpLhsH_dU("H", "U", grad_h_ptr));
563 pipeline.push_back(new OpLhsH_dH<false>("H", u_ptr, h_ptr, grad_g_ptr));
564 pipeline.push_back(new OpLhsH_dG<false>("H", "G", h_ptr));
565
566 pipeline.push_back(new OpLhsG_dH<false>("G", "H", h_ptr));
567 pipeline.push_back(new OpLhsG_dG("G"));
568
569 pipeline.push_back(new OpMixScalarTimesDiv(
570 "P", "U",
571 [](const double r, const double, const double) {
572 return cylindrical(r);
573 },
574 true, false));
575 pipeline.push_back(
576 new OpDomainMassP("P", "P", [](double r, double, double) {
577 return eps * cylindrical(r);
578 }));
579 };
580
581 auto set_boundary_rhs = [&](auto &pipeline, auto &fe) {
582 pipeline.push_back(
584 pipeline.push_back(new OpCalculateScalarFieldValues("L", lambda_ptr));
585 pipeline.push_back(new OpNormalConstrainRhs("L", u_ptr));
586 pipeline.push_back(new OpNormalForceRhs("U", lambda_ptr));
587 };
588
589 auto set_boundary_lhs = [&](auto &pipeline, auto &fe) {
590 pipeline.push_back(new OpNormalConstrainLhs("L", "U"));
591 };
592
593 auto *pipeline_mng = mField.getInterface<PipelineManager>();
594
595 CHKERR pipeline_mng->setDomainRhsIntegrationRule(integration_rule);
596 CHKERR pipeline_mng->setDomainLhsIntegrationRule(integration_rule);
597
598 CHKERR pipeline_mng->setBoundaryRhsIntegrationRule(integration_rule);
599 CHKERR pipeline_mng->setBoundaryLhsIntegrationRule(integration_rule);
600
601 set_domain_rhs(pipeline_mng->getOpDomainRhsPipeline(),
602 pipeline_mng->getDomainRhsFE());
603 set_domain_lhs(pipeline_mng->getOpDomainLhsPipeline(),
604 pipeline_mng->getDomainLhsFE());
605
606 set_boundary_rhs(pipeline_mng->getOpBoundaryRhsPipeline(),
607 pipeline_mng->getBoundaryRhsFE());
608 set_boundary_lhs(pipeline_mng->getOpBoundaryLhsPipeline(),
609 pipeline_mng->getBoundaryLhsFE());
610
611 domianLhsFEPtr = pipeline_mng->getDomainLhsFE();
612
614}
@ H1
continuous field
Definition: definitions.h:85
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:346
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:416
#define CHKERR
Inline error check.
Definition: definitions.h:535
auto cylindrical
auto integration_rule
constexpr double eps
OpDomainMassH OpDomainMassP
FormsIntegrators< DomainEleOp >::Assembly< PETSC >::LinearForm< GAUSS >::OpBaseTimesScalar< 1, 1 > OpBaseTimesScalar
FormsIntegrators< DomainEleOp >::Assembly< PETSC >::BiLinearForm< GAUSS >::OpMixScalarTimesDiv< SPACE_DIM, coord_type > OpMixScalarTimesDiv
OpCalculateScalarFieldValuesFromPetscVecImpl< PetscData::CTX_SET_X_T > OpCalculateScalarFieldValuesDot
boost::shared_ptr< FEMethod > domianLhsFEPtr
Calculate field values (template specialization) for tensor field rank 1, i.e. vector field.
Get field gradients at integration pts for scalar filed rank 0, i.e. vector field.
Get value at integration points for scalar field.
Get field gradients at integration pts for scalar filed rank 0, i.e. vector field.
Approximate field valuse for given petsc vector.
Get values at integration pts for tensor filed rank 1, i.e. vector field.
Set inverse jacobian to base functions.
Modify integration weights on face to take in account higher-order geometry.
PipelineManager interface.
MoFEMErrorCode getInterface(IFACE *&iface) const
Get interface refernce to pointer of interface.

◆ boundaryCondition()

MoFEMErrorCode FreeSurface::boundaryCondition ( )
private

[Set up problem]

[Boundary condition]

Examples
free_surface.cpp.

Definition at line 319 of file free_surface.cpp.

319 {
321
323 auto pipeline_mng = mField.getInterface<PipelineManager>();
324 auto bc_mng = mField.getInterface<BcManager>();
325 auto dm = simple->getDM();
326
327 auto h_ptr = boost::make_shared<VectorDouble>();
328 auto grad_h_ptr = boost::make_shared<MatrixDouble>();
329 auto g_ptr = boost::make_shared<VectorDouble>();
330 auto grad_g_ptr = boost::make_shared<MatrixDouble>();
331
332 auto set_generic = [&](auto &pipeline, auto &fe) {
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 pipeline.push_back(new OpCalculateHOJac<SPACE_DIM>(jac_ptr));
337 pipeline.push_back(
338 new OpInvertMatrix<SPACE_DIM>(jac_ptr, det_ptr, inv_jac_ptr));
339 pipeline.push_back(
340 new OpSetHOInvJacToScalarBases<SPACE_DIM>(H1, inv_jac_ptr));
341
342 pipeline.push_back(new OpCalculateScalarFieldValues("H", h_ptr));
343 pipeline.push_back(
344 new OpCalculateScalarFieldGradient<SPACE_DIM>("H", grad_h_ptr));
345
346 pipeline.push_back(new OpCalculateScalarFieldValues("G", g_ptr));
347 pipeline.push_back(
348 new OpCalculateScalarFieldGradient<SPACE_DIM>("G", grad_g_ptr));
349 };
350
351 auto post_proc = [&]() {
353 auto post_proc_fe = boost::make_shared<PostProcEle>(mField);
354
355 set_generic(post_proc_fe->getOpPtrVector(), post_proc_fe);
356
358
359 post_proc_fe->getOpPtrVector().push_back(
360
361 new OpPPMap(
362 post_proc_fe->getPostProcMesh(), post_proc_fe->getMapGaussPts(),
363
364 {{"H", h_ptr}, {"G", g_ptr}},
365
366 {{"GRAD_H", grad_h_ptr}, {"GRAD_G", grad_g_ptr}},
367
368 {},
369
370 {}
371
372 )
373
374 );
375
376 CHKERR DMoFEMLoopFiniteElements(dm, "dFE", post_proc_fe);
377 CHKERR post_proc_fe->writeFile("out_init.h5m");
378
380 };
381
382 auto solve_init = [&]() {
384
385 auto set_domain_rhs = [&](auto &pipeline, auto &fe) {
386 set_generic(pipeline, fe);
387 pipeline.push_back(new OpRhsH<true>("H", nullptr, nullptr, h_ptr,
388 grad_h_ptr, grad_g_ptr));
389 pipeline.push_back(new OpRhsG<true>("G", h_ptr, grad_h_ptr, g_ptr));
390 };
391
392 auto set_domain_lhs = [&](auto &pipeline, auto &fe) {
393 set_generic(pipeline, fe);
394 pipeline.push_back(new OpLhsH_dH<true>("H", nullptr, h_ptr, grad_g_ptr));
395 pipeline.push_back(new OpLhsH_dG<true>("H", "G", h_ptr));
396 pipeline.push_back(new OpLhsG_dG("G"));
397 pipeline.push_back(new OpLhsG_dH<true>("G", "H", h_ptr));
398 };
399
400 auto create_subdm = [&]() {
401 DM subdm;
402 CHKERR DMCreate(mField.get_comm(), &subdm);
403 CHKERR DMSetType(subdm, "DMMOFEM");
404 CHKERR DMMoFEMCreateSubDM(subdm, dm, "SUB");
405 CHKERR DMMoFEMAddElement(subdm, simple->getDomainFEName().c_str());
406 CHKERR DMMoFEMSetSquareProblem(subdm, PETSC_TRUE);
407 CHKERR DMMoFEMSetDestroyProblem(subdm, PETSC_TRUE);
408 CHKERR DMMoFEMAddSubFieldRow(subdm, "H");
409 CHKERR DMMoFEMAddSubFieldRow(subdm, "G");
410 CHKERR DMMoFEMAddSubFieldCol(subdm, "H");
411 CHKERR DMMoFEMAddSubFieldCol(subdm, "G");
412 CHKERR DMSetUp(subdm);
413 return SmartPetscObj<DM>(subdm);
414 };
415
416 auto subdm = create_subdm();
417
418 auto prb_ents = get_dofs_ents(subdm);
419
420 pipeline_mng->getDomainRhsFE().reset();
421 pipeline_mng->getDomainLhsFE().reset();
422 CHKERR pipeline_mng->setDomainRhsIntegrationRule(integration_rule);
423 CHKERR pipeline_mng->setDomainLhsIntegrationRule(integration_rule);
424
425 set_domain_rhs(pipeline_mng->getOpDomainRhsPipeline(),
426 pipeline_mng->getDomainRhsFE());
427 set_domain_lhs(pipeline_mng->getOpDomainLhsPipeline(),
428 pipeline_mng->getDomainLhsFE());
429
430 auto D = smartCreateDMVector(subdm);
431 auto snes = pipeline_mng->createSNES(subdm);
432 auto snes_ctx_ptr = smartGetDMSnesCtx(subdm);
433
434 auto set_section_monitor = [&](auto solver) {
436 CHKERR SNESMonitorSet(snes,
437 (MoFEMErrorCode(*)(SNES, PetscInt, PetscReal,
439 (void *)(snes_ctx_ptr.get()), nullptr);
440 auto section = mField.getInterface<ISManager>()->sectionCreate("SUB");
441 PetscInt num_fields;
442 CHKERR PetscSectionGetNumFields(section, &num_fields);
443 for (int f = 0; f < num_fields; ++f) {
444 const char *field_name;
445 CHKERR PetscSectionGetFieldName(section, f, &field_name);
446 MOFEM_LOG("FS", Sev::inform)
447 << "Field " << f << " " << std::string(field_name);
448 }
450 };
451
452 CHKERR set_section_monitor(snes);
453
454 CHKERR SNESSetFromOptions(snes);
455 CHKERR SNESSolve(snes, PETSC_NULL, D);
456
457 CHKERR VecGhostUpdateBegin(D, INSERT_VALUES, SCATTER_FORWARD);
458 CHKERR VecGhostUpdateEnd(D, INSERT_VALUES, SCATTER_FORWARD);
459 CHKERR DMoFEMMeshToLocalVector(subdm, D, INSERT_VALUES, SCATTER_REVERSE);
460
462 };
463
464 CHKERR solve_init();
465 CHKERR post_proc();
466
467 CHKERR bc_mng->removeBlockDOFsOnEntities(simple->getProblemName(), "SYMETRY",
468 "U", 0, 0);
469 CHKERR bc_mng->removeBlockDOFsOnEntities(simple->getProblemName(), "SYMETRY",
470 "L", 0, 0);
471 CHKERR bc_mng->removeBlockDOFsOnEntities(simple->getProblemName(), "FIX", "U",
472 0, SPACE_DIM);
473 CHKERR bc_mng->removeBlockDOFsOnEntities(simple->getProblemName(), "FIX", "L",
474 0, 0);
475 CHKERR bc_mng->removeBlockDOFsOnEntities(simple->getProblemName(), "ZERO",
476 "L", 0, 0);
477
478 // Clear pipelines
479 pipeline_mng->getOpDomainRhsPipeline().clear();
480 pipeline_mng->getOpDomainLhsPipeline().clear();
481
483}
void simple(double P1[], double P2[], double P3[], double c[], const int N)
Definition: acoustic.cpp:69
constexpr int SPACE_DIM
auto get_dofs_ents
PetscErrorCode DMMoFEMCreateSubDM(DM subdm, DM dm, const char problem_name[])
Must be called by user to set Sub DM MoFEM data structures.
Definition: DMMMoFEM.cpp:201
PetscErrorCode DMMoFEMSetSquareProblem(DM dm, PetscBool square_problem)
set squared problem
Definition: DMMMoFEM.cpp:403
PetscErrorCode DMMoFEMAddSubFieldRow(DM dm, const char field_name[], EntityType lo_type=MBVERTEX, EntityType hi_type=MBMAXTYPE)
Definition: DMMMoFEM.cpp:223
PetscErrorCode DMMoFEMAddElement(DM dm, const char fe_name[])
add element to dm
Definition: DMMMoFEM.cpp:450
PetscErrorCode DMoFEMMeshToLocalVector(DM dm, Vec l, InsertMode mode, ScatterMode scatter_mode)
set local (or ghosted) vector values on mesh for partition only
Definition: DMMMoFEM.cpp:470
PetscErrorCode DMMoFEMAddSubFieldCol(DM dm, const char field_name[], EntityType lo_type=MBVERTEX, EntityType hi_type=MBMAXTYPE)
Definition: DMMMoFEM.cpp:246
PetscErrorCode DMoFEMLoopFiniteElements(DM dm, const char fe_name[], MoFEM::FEMethod *method, CacheTupleWeakPtr cache_ptr=CacheTupleSharedPtr())
Executes FEMethod for finite elements in DM.
Definition: DMMMoFEM.cpp:533
auto smartCreateDMVector(DM dm)
Get smart vector from DM.
Definition: DMMoFEM.hpp:965
#define MOFEM_LOG(channel, severity)
Log.
Definition: LogManager.hpp:301
double D
auto f
Definition: HenckyOps.hpp:5
PetscErrorCode MoFEMErrorCode
MoFEM/PETSc error code.
Definition: Exceptions.hpp:56
PetscErrorCode DMMoFEMSetDestroyProblem(DM dm, PetscBool destroy_problem)
Definition: DMMMoFEM.cpp:385
MoFEMErrorCode MoFEMSNESMonitorFields(SNES snes, PetscInt its, PetscReal fgnorm, SnesCtx *snes_ctx)
Sens monitor printing residual field by field.
Definition: SnesCtx.cpp:224
auto smartGetDMSnesCtx(DM dm)
Get SNES context data structure used by DM.
Definition: DMMoFEM.hpp:987
OpPostProcMapInMoab< SPACE_DIM, SPACE_DIM > OpPPMap
constexpr auto field_name
Simple interface for fast problem set-up.
Definition: BcManager.hpp:23
virtual MPI_Comm & get_comm() const =0
Section manager is used to create indexes and sections.
Definition: ISManager.hpp:23
Post post-proc data at points from hash maps.
Simple interface for fast problem set-up.
Definition: Simple.hpp:26
intrusive_ptr for managing petsc objects

◆ makeRefProblem()

MoFEMErrorCode FreeSurface::makeRefProblem ( )
Examples
free_surface.cpp.

◆ readMesh()

MoFEMErrorCode FreeSurface::readMesh ( )
private

[Run programme]

[Read mesh]

Examples
free_surface.cpp.

Definition at line 270 of file free_surface.cpp.

270 {
272
274
275 CHKERR simple->getOptions();
276 CHKERR simple->loadFile();
277
279}

◆ runProblem()

MoFEMErrorCode FreeSurface::runProblem ( )

[Run programme]

Examples
free_surface.cpp.

Definition at line 258 of file free_surface.cpp.

258 {
266}
MoFEMErrorCode setupProblem()
[Read mesh]
MoFEMErrorCode boundaryCondition()
[Set up problem]
MoFEMErrorCode readMesh()
[Run programme]
MoFEMErrorCode assembleSystem()
[Boundary condition]
MoFEMErrorCode solveSystem()
[Solve]

◆ setupProblem()

MoFEMErrorCode FreeSurface::setupProblem ( )
private

[Read mesh]

[Set up problem]

Examples
free_surface.cpp.

Definition at line 283 of file free_surface.cpp.

283 {
285
287
288 // Fields on domain
289
290 // Velocity field
291 CHKERR simple->addDomainField("U", H1, AINSWORTH_LEGENDRE_BASE, U_FIELD_DIM);
292 // Pressure field
293 CHKERR simple->addDomainField("P", H1, AINSWORTH_LEGENDRE_BASE, 1);
294 // Order/phase fild
295 CHKERR simple->addDomainField("H", H1, AINSWORTH_LEGENDRE_BASE, 1);
296 // Chemical potential
297 CHKERR simple->addDomainField("G", H1, AINSWORTH_LEGENDRE_BASE, 1);
298
299 // Field on boundary
300 CHKERR simple->addBoundaryField("U", H1, AINSWORTH_LEGENDRE_BASE,
302 CHKERR simple->addBoundaryField("H", H1, AINSWORTH_LEGENDRE_BASE, 1);
303 // Lagrange multiplier which constrains slip conditions
304 CHKERR simple->addBoundaryField("L", H1, AINSWORTH_LEGENDRE_BASE, 1);
305
306 CHKERR simple->setFieldOrder("U", order);
307 CHKERR simple->setFieldOrder("P", order - 1);
308 CHKERR simple->setFieldOrder("H", order);
309 CHKERR simple->setFieldOrder("G", order);
310 CHKERR simple->setFieldOrder("L", order);
311
312 CHKERR simple->setUp();
313
315}
@ AINSWORTH_LEGENDRE_BASE
Ainsworth Cole (Legendre) approx. base .
Definition: definitions.h:60
constexpr int U_FIELD_DIM
constexpr int order
approximation order

◆ solveSystem()

MoFEMErrorCode FreeSurface::solveSystem ( )
private

[Solve]

Examples
free_surface.cpp.

Definition at line 667 of file free_surface.cpp.

667 {
669
670 auto *simple = mField.getInterface<Simple>();
671 auto *pipeline_mng = mField.getInterface<PipelineManager>();
672 auto dm = simple->getDM();
673
674 auto get_fe_post_proc = [&]() {
675 auto post_proc_fe = boost::make_shared<PostProcEle>(mField);
676
677 auto det_ptr = boost::make_shared<VectorDouble>();
678 auto jac_ptr = boost::make_shared<MatrixDouble>();
679 auto inv_jac_ptr = boost::make_shared<MatrixDouble>();
680
681 auto u_ptr = boost::make_shared<MatrixDouble>();
682 auto grad_u_ptr = boost::make_shared<MatrixDouble>();
683 auto h_ptr = boost::make_shared<VectorDouble>();
684 auto grad_h_ptr = boost::make_shared<MatrixDouble>();
685 auto p_ptr = boost::make_shared<VectorDouble>();
686 auto g_ptr = boost::make_shared<VectorDouble>();
687 auto grad_g_ptr = boost::make_shared<MatrixDouble>();
688
689 post_proc_fe->getOpPtrVector().push_back(
690 new OpCalculateHOJac<SPACE_DIM>(jac_ptr));
691 post_proc_fe->getOpPtrVector().push_back(
692 new OpInvertMatrix<SPACE_DIM>(jac_ptr, det_ptr, inv_jac_ptr));
693 post_proc_fe->getOpPtrVector().push_back(
694 new OpSetHOInvJacToScalarBases<SPACE_DIM>(H1, inv_jac_ptr));
695
696 post_proc_fe->getOpPtrVector().push_back(
698 post_proc_fe->getOpPtrVector().push_back(
700 grad_u_ptr));
701
702 post_proc_fe->getOpPtrVector().push_back(
703 new OpCalculateScalarFieldValues("H", h_ptr));
704 post_proc_fe->getOpPtrVector().push_back(
705 new OpCalculateScalarFieldGradient<SPACE_DIM>("H", grad_h_ptr));
706
707 post_proc_fe->getOpPtrVector().push_back(
708 new OpCalculateScalarFieldValues("P", p_ptr));
709 post_proc_fe->getOpPtrVector().push_back(
710 new OpCalculateScalarFieldValues("G", g_ptr));
711 post_proc_fe->getOpPtrVector().push_back(
712 new OpCalculateScalarFieldGradient<SPACE_DIM>("G", grad_g_ptr));
713
715
716 post_proc_fe->getOpPtrVector().push_back(
717
718 new OpPPMap(
719 post_proc_fe->getPostProcMesh(), post_proc_fe->getMapGaussPts(),
720
721 {{"H", h_ptr}, {"P", p_ptr}, {"G", g_ptr}},
722
723 {{"U", u_ptr}, {"H_GRAD", grad_h_ptr}, {"G_GRAD", grad_g_ptr}},
724
725 {{"GRAD_U", grad_u_ptr}},
726
727 {}
728
729 )
730
731 );
732
733 return post_proc_fe;
734 };
735
736 auto get_bdy_post_proc_fe = [&]() {
737 auto post_proc_fe = boost::make_shared<PostProcEdgeEle>(mField);
738
739 auto u_ptr = boost::make_shared<MatrixDouble>();
740 auto p_ptr = boost::make_shared<VectorDouble>();
741 auto lambda_ptr = boost::make_shared<VectorDouble>();
742
743 post_proc_fe->getOpPtrVector().push_back(
745 post_proc_fe->getOpPtrVector().push_back(
746 new OpCalculateScalarFieldValues("L", lambda_ptr));
747 post_proc_fe->getOpPtrVector().push_back(
748 new OpCalculateScalarFieldValues("P", p_ptr));
749
751
752 post_proc_fe->getOpPtrVector().push_back(
753
754 new OpPPMap(post_proc_fe->getPostProcMesh(),
755 post_proc_fe->getMapGaussPts(),
756
757 OpPPMap::DataMapVec{{"L", lambda_ptr}, {"P", p_ptr}},
758
759 OpPPMap::DataMapMat{{"U", u_ptr}},
760
762
764
765 )
766
767 );
768
769 return post_proc_fe;
770 };
771
772 auto get_lift_fe = [&]() {
773 auto fe = boost::make_shared<BoundaryEle>(mField);
774 auto lift_ptr = boost::make_shared<VectorDouble>();
775 auto p_ptr = boost::make_shared<VectorDouble>();
776 auto ents_ptr = boost::make_shared<Range>();
777
778 std::vector<const CubitMeshSets *> vec_ptr;
779 CHKERR mField.getInterface<MeshsetsManager>()->getCubitMeshsetPtr(
780 std::regex("LIFT"), vec_ptr);
781 for (auto m_ptr : vec_ptr) {
782 auto meshset = m_ptr->getMeshset();
783 Range ents;
784 CHKERR mField.get_moab().get_entities_by_dimension(meshset, SPACE_DIM - 1,
785 ents, true);
786 ents_ptr->merge(ents);
787 }
788
789 MOFEM_LOG("FS", Sev::noisy) << "Lift ents " << (*ents_ptr);
790
791 fe->getOpPtrVector().push_back(
792 new OpCalculateScalarFieldValues("P", p_ptr));
793 fe->getOpPtrVector().push_back(
794 new OpCalculateLift("P", p_ptr, lift_ptr, ents_ptr));
795
796 return std::make_pair(fe, lift_ptr);
797 };
798
799 auto set_ts = [&](auto solver) {
801 SNES snes;
802 CHKERR TSGetSNES(solver, &snes);
803 KSP ksp;
804 CHKERR SNESGetKSP(snes, &ksp);
806 };
807
808 auto ts = pipeline_mng->createTSIM();
809 CHKERR TSSetType(ts, TSALPHA);
810
811 auto set_post_proc_monitor = [&](auto dm) {
813 boost::shared_ptr<FEMethod> null_fe;
814 auto monitor_ptr = boost::make_shared<Monitor>(
815 dm, get_fe_post_proc(), get_bdy_post_proc_fe(), get_lift_fe());
816 CHKERR DMMoFEMTSSetMonitor(dm, ts, simple->getDomainFEName(), null_fe,
817 null_fe, monitor_ptr);
819 };
820 CHKERR set_post_proc_monitor(dm);
821
822 // Add monitor to time solver
823 double ftime = 1;
824 // CHKERR TSSetMaxTime(ts, ftime);
825 CHKERR TSSetExactFinalTime(ts, TS_EXACTFINALTIME_MATCHSTEP);
826
827 auto T = smartCreateDMVector(simple->getDM());
828 CHKERR DMoFEMMeshToLocalVector(simple->getDM(), T, INSERT_VALUES,
829 SCATTER_FORWARD);
830 CHKERR TSSetSolution(ts, T);
831 CHKERR TSSetFromOptions(ts);
832 CHKERR set_ts(ts);
833 CHKERR TSSetUp(ts);
834
835 auto print_fields_in_section = [&]() {
837
838 auto section = mField.getInterface<ISManager>()->sectionCreate(
839 simple->getProblemName());
840 PetscInt num_fields;
841 CHKERR PetscSectionGetNumFields(section, &num_fields);
842 for (int f = 0; f < num_fields; ++f) {
843 const char *field_name;
844 CHKERR PetscSectionGetFieldName(section, f, &field_name);
845 MOFEM_LOG("FS", Sev::inform)
846 << "Field " << f << " " << std::string(field_name);
847 }
849 };
850
851 CHKERR print_fields_in_section();
852
853 CHKERR TSSolve(ts, NULL);
854 CHKERR TSGetTime(ts, &ftime);
855
857}
MoFEMErrorCode getMeshset(const int ms_id, const unsigned int cubit_bc_type, EntityHandle &meshset) const
get meshset from CUBIT Id and CUBIT type
const double T
PetscErrorCode DMMoFEMTSSetMonitor(DM dm, TS ts, const std::string fe_name, boost::shared_ptr< MoFEM::FEMethod > method, boost::shared_ptr< MoFEM::BasicMethod > pre_only, boost::shared_ptr< MoFEM::BasicMethod > post_only)
Set Monitor To TS solver.
Definition: DMMMoFEM.cpp:1003
virtual moab::Interface & get_moab()=0
Interface for managing meshsets containing materials and boundary conditions.
std::map< std::string, boost::shared_ptr< VectorDouble > > DataMapVec
std::map< std::string, boost::shared_ptr< MatrixDouble > > DataMapMat

Member Data Documentation

◆ domianLhsFEPtr

boost::shared_ptr<FEMethod> FreeSurface::domianLhsFEPtr
private
Examples
free_surface.cpp.

Definition at line 254 of file free_surface.cpp.

◆ mField

MoFEM::Interface& FreeSurface::mField
Examples
free_surface.cpp.

Definition at line 245 of file free_surface.cpp.


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