13#include <petsc/private/petscimpl.h>
17static char help[] =
"...\n\n";
19#ifdef PYTHON_INIT_SURFACE
20#include <boost/python.hpp>
21#include <boost/python/def.hpp>
22namespace bp = boost::python;
25 SurfacePython() =
default;
26 virtual ~SurfacePython() =
default;
44 auto main_module = bp::import(
"__main__");
45 mainNamespace = main_module.attr(
"__dict__");
46 bp::exec_file(py_file.c_str(), mainNamespace, mainNamespace);
48 surfaceFun = mainNamespace[
"surface"];
50 }
catch (bp::error_already_set
const &) {
73 double x,
double y,
double z,
double eta,
double &s
80 s = bp::extract<double>(surfaceFun(x, y, z,
eta));
82 }
catch (bp::error_already_set
const &) {
91 bp::object mainNamespace;
92 bp::object surfaceFun;
95static boost::weak_ptr<SurfacePython> surfacePythonWeakPtr;
107 IntegrationType::GAUSS;
147template <CoordinateTypes COORD_TYPE>
198double tol = std::numeric_limits<float>::epsilon();
236 constexpr int sub_stepping = 16;
237 return std::min(1.,
static_cast<double>(ts_step) / sub_stepping);
248auto my_max = [](
const double x) {
return (x - 1 + std::abs(x + 1)) / 2; };
255auto my_min = [](
const double x) {
return (x + 1 - std::abs(x - 1)) / 2; };
272 if (
h >= -1 &&
h < 1)
289 return diff *
h + ave;
312auto get_f = [](
const double h) {
return 4 *
W *
h * (
h *
h - 1); };
343 return md * (1 -
h *
h);
361 const double h2 =
h *
h;
362 const double h3 = h2 *
h;
364 return md * (2 * h3 - 3 * h2 + 1);
366 return md * (-2 * h3 - 3 * h2 + 1);
376 return md * (6 *
h * (
h - 1));
378 return md * (-6 *
h * (
h + 1));
416 constexpr double R = 0.0125;
417 constexpr double A =
R * 0.2;
418 const double theta = atan2(r, y);
419 const double w =
R +
A * cos(
n * theta);
420 const double d = std::sqrt(r * r + y * y);
421 return tanh((w - d) / (
eta * std::sqrt(2)));
434 constexpr double y0 = 0.5;
435 constexpr double R = 0.4;
437 const double d = std::sqrt(r * r + y * y);
438 return tanh((
R - d) / (
eta * std::sqrt(2)));
451 constexpr double water_height = 0.;
452 return tanh((water_height - y) / (
eta * std::sqrt(2)));
466 return -tanh((-0.039 - x) / (
eta * std::sqrt(2)));
477auto init_h = [](
double r,
double y,
double theta) {
478#ifdef PYTHON_INIT_SURFACE
480 if (
auto ptr = surfacePythonWeakPtr.lock()) {
482 "error eval python");
522 return fe_ptr->numeredEntFiniteElementPtr->getBitRefLevel();
532 MPI_Allreduce(&l_size, &g_size, 1, MPI_INT, MPI_SUM, MPI_COMM_WORLD);
545auto save_range = [](moab::Interface &moab,
const std::string name,
550 CHKERR moab.add_entities(*out_meshset, r);
551 CHKERR moab.write_file(name.c_str(),
"MOAB",
"PARALLEL=WRITE_PART",
552 out_meshset->get_ptr(), 1);
569 std::vector<EntityHandle> ents_vec;
575 auto dofs = prb_ptr->numeredRowDofsPtr;
578 ents_vec.reserve(std::distance(lo_it, hi_it));
580 for (; lo_it != hi_it; ++lo_it) {
581 ents_vec.push_back((*lo_it)->getEnt());
584 std::sort(ents_vec.begin(), ents_vec.end());
585 auto it = std::unique(ents_vec.begin(), ents_vec.end());
587 r.insert_list(ents_vec.begin(), it);
601 std::vector<EntityHandle> ents_vec;
606 auto dofs = prb_ptr->numeredRowDofsPtr;
607 ents_vec.reserve(dofs->size());
609 for (
auto d : *dofs) {
610 ents_vec.push_back(d->getEnt());
613 std::sort(ents_vec.begin(), ents_vec.end());
614 auto it = std::unique(ents_vec.begin(), ents_vec.end());
616 r.insert_list(ents_vec.begin(), it);
745 PetscReal
a, Mat A, Mat
B,
789 boost::shared_ptr<SnesCtx>
791 boost::shared_ptr<TsCtx>
958 boost::shared_ptr<FEMethod> fe_top, std::string
field_name,
961 boost::function<boost::shared_ptr<ForcesAndSourcesCore>()> get_elem,
990 MOFEM_LOG(
"FS", Sev::inform) <<
"Read mesh for problem";
1013 const char *coord_type_names[] = {
"cartesian",
"polar",
"cylindrical",
1018 MOFEM_LOG(
"FS", Sev::inform) <<
"Approximation order = " <<
order;
1020 <<
"Number of refinement levels nb_levels = " <<
nb_levels;
1045 MOFEM_LOG(
"FS", Sev::inform) <<
"Acceleration a0 = " <<
a0;
1046 MOFEM_LOG(
"FS", Sev::inform) <<
"\"Minus\" phase density rho_m = " <<
rho_m;
1047 MOFEM_LOG(
"FS", Sev::inform) <<
"\"Minus\" phase viscosity mu_m = " <<
mu_m;
1048 MOFEM_LOG(
"FS", Sev::inform) <<
"\"Plus\" phase density rho_p = " <<
rho_p;
1049 MOFEM_LOG(
"FS", Sev::inform) <<
"\"Plus\" phase viscosity mu_p = " <<
mu_p;
1050 MOFEM_LOG(
"FS", Sev::inform) <<
"Surface tension lambda = " <<
lambda;
1052 <<
"Height of the well in energy functional W = " <<
W;
1053 MOFEM_LOG(
"FS", Sev::inform) <<
"Characteristic mesh size h = " <<
h;
1054 MOFEM_LOG(
"FS", Sev::inform) <<
"Mobility md = " <<
md;
1058 MOFEM_LOG(
"FS", Sev::inform) <<
"Average viscosity mu_ave = " <<
mu_ave;
1059 MOFEM_LOG(
"FS", Sev::inform) <<
"Difference viscosity mu_diff = " <<
mu_diff;
1089 auto set_problem_bit = [&]() {
1100 CHKERR set_problem_bit();
1112#ifdef PYTHON_INIT_SURFACE
1113 auto get_py_surface_init = []() {
1114 auto py_surf_init = boost::make_shared<SurfacePython>();
1115 CHKERR py_surf_init->surfaceInit(
"surface.py");
1116 surfacePythonWeakPtr = py_surf_init;
1117 return py_surf_init;
1119 auto py_surf_init = get_py_surface_init();
1126 auto dm =
simple->getDM();
1130 auto reset_bits = [&]() {
1134 start_mask[s] =
true;
1136 CHKERR bit_mng->lambdaBitRefLevel(
1145 auto add_parent_field = [&](
auto fe,
auto op,
auto field) {
1150 boost::shared_ptr<ForcesAndSourcesCore> fe_parent(
1158 auto h_ptr = boost::make_shared<VectorDouble>();
1159 auto grad_h_ptr = boost::make_shared<MatrixDouble>();
1160 auto g_ptr = boost::make_shared<VectorDouble>();
1161 auto grad_g_ptr = boost::make_shared<MatrixDouble>();
1163 auto set_generic = [&](
auto fe) {
1165 auto &pip = fe->getOpPtrVector();
1173 boost::shared_ptr<ForcesAndSourcesCore> fe_parent(
1176 fe_parent->getOpPtrVector(), {H1});
1182 CHKERR add_parent_field(fe, UDO::OPCOL,
"H");
1187 CHKERR add_parent_field(fe, UDO::OPCOL,
"G");
1195 auto post_proc = [&](
auto exe_test) {
1197 auto post_proc_fe = boost::make_shared<PostProcEleDomain>(
mField);
1198 post_proc_fe->exeTestHook = exe_test;
1200 CHKERR set_generic(post_proc_fe);
1204 post_proc_fe->getOpPtrVector().push_back(
1206 new OpPPMap(post_proc_fe->getPostProcMesh(),
1207 post_proc_fe->getMapGaussPts(),
1209 {{
"H", h_ptr}, {
"G", g_ptr}},
1211 {{
"GRAD_H", grad_h_ptr}, {
"GRAD_G", grad_g_ptr}},
1222 CHKERR post_proc_fe->writeFile(
"out_init.h5m");
1227 auto solve_init = [&](
auto exe_test) {
1230 pip_mng->getOpDomainRhsPipeline().clear();
1231 pip_mng->getOpDomainLhsPipeline().clear();
1233 auto set_domain_rhs = [&](
auto fe) {
1236 auto &pip = fe->getOpPtrVector();
1238 CHKERR add_parent_field(fe, UDO::OPROW,
"H");
1239 pip.push_back(
new OpRhsH<true>(
"H",
nullptr,
nullptr, h_ptr, grad_h_ptr,
1241 CHKERR add_parent_field(fe, UDO::OPROW,
"G");
1242 pip.push_back(
new OpRhsG<true>(
"G", h_ptr, grad_h_ptr, g_ptr));
1246 auto set_domain_lhs = [&](
auto fe) {
1250 auto &pip = fe->getOpPtrVector();
1252 CHKERR add_parent_field(fe, UDO::OPROW,
"H");
1253 CHKERR add_parent_field(fe, UDO::OPCOL,
"H");
1256 CHKERR add_parent_field(fe, UDO::OPCOL,
"G");
1259 CHKERR add_parent_field(fe, UDO::OPROW,
"G");
1262 CHKERR add_parent_field(fe, UDO::OPCOL,
"H");
1267 auto create_subdm = [&]() {
1268 auto level_ents_ptr = boost::make_shared<Range>();
1274 CHKERR DMSetType(subdm,
"DMMOFEM");
1280 for (
auto f : {
"H",
"G"}) {
1286 if constexpr (
debug) {
1290 dm_ents.subset_by_type(MBVERTEX));
1291 dm_ents = subtract(dm_ents, dm_ents.subset_by_type(MBVERTEX));
1299 auto subdm = create_subdm();
1301 pip_mng->getDomainRhsFE().reset();
1302 pip_mng->getDomainLhsFE().reset();
1305 pip_mng->getDomainLhsFE()->exeTestHook = exe_test;
1306 pip_mng->getDomainRhsFE()->exeTestHook = exe_test;
1308 CHKERR set_domain_rhs(pip_mng->getCastDomainRhsFE());
1309 CHKERR set_domain_lhs(pip_mng->getCastDomainLhsFE());
1312 auto snes = pip_mng->createSNES(subdm);
1315 auto set_section_monitor = [&](
auto solver) {
1317 CHKERR SNESMonitorSet(solver,
1320 (
void *)(snes_ctx_ptr.get()),
nullptr);
1325 auto print_section_field = [&]() {
1330 PetscInt num_fields;
1331 CHKERR PetscSectionGetNumFields(section, &num_fields);
1332 for (
int f = 0;
f < num_fields; ++
f) {
1336 <<
"Field " <<
f <<
" " << std::string(
field_name);
1342 CHKERR set_section_monitor(snes);
1343 CHKERR print_section_field();
1345 for (
auto f : {
"U",
"P",
"H",
"G",
"L"}) {
1349 CHKERR SNESSetFromOptions(snes);
1352 PETSC_NULLPTR, PETSC_NULLPTR);
1353 CHKERR SNESSolve(snes, PETSC_NULLPTR,
D);
1355 CHKERR VecGhostUpdateBegin(
D, INSERT_VALUES, SCATTER_FORWARD);
1356 CHKERR VecGhostUpdateEnd(
D, INSERT_VALUES, SCATTER_FORWARD);
1367 for (
auto f : {
"U",
"P",
"H",
"G",
"L"}) {
1378 pip_mng->getOpDomainRhsPipeline().clear();
1379 pip_mng->getOpDomainLhsPipeline().clear();
1382 CHKERR bc_mng->removeBlockDOFsOnEntities(
simple->getProblemName(),
"SYM_X",
1384 CHKERR bc_mng->removeBlockDOFsOnEntities(
simple->getProblemName(),
"SYM_X",
1386 CHKERR bc_mng->removeBlockDOFsOnEntities(
simple->getProblemName(),
"SYM_Y",
1388 CHKERR bc_mng->removeBlockDOFsOnEntities(
simple->getProblemName(),
"SYM_Y",
1390 CHKERR bc_mng->removeBlockDOFsOnEntities(
simple->getProblemName(),
"FIX",
"U",
1392 CHKERR bc_mng->removeBlockDOFsOnEntities(
simple->getProblemName(),
"FIX",
"L",
1394 CHKERR bc_mng->removeBlockDOFsOnEntities(
simple->getProblemName(),
"ZERO",
1416 auto fe_domain_lhs = pip_mng->getDomainLhsFE();
1417 auto fe_domain_rhs = pip_mng->getDomainRhsFE();
1418 auto fe_bdy_lhs = pip_mng->getBoundaryLhsFE();
1419 auto fe_bdy_rhs = pip_mng->getBoundaryRhsFE();
1421 pip_mng->getDomainLhsFE().reset();
1422 pip_mng->getDomainRhsFE().reset();
1423 pip_mng->getBoundaryLhsFE().reset();
1424 pip_mng->getBoundaryRhsFE().reset();
1429 auto add_parent_field_domain = [&](
auto fe,
auto op,
auto field,
auto bit) {
1434 boost::shared_ptr<ForcesAndSourcesCore> fe_parent(
1443 auto add_parent_field_bdy = [&](
auto fe,
auto op,
auto field,
auto bit) {
1448 boost::shared_ptr<ForcesAndSourcesCore> fe_parent(
1458 auto create_run_parent_op = [&](
auto parent_fe_ptr,
auto this_fe_ptr,
1460 auto parent_mask = fe_bit;
1468 auto get_parents_vel_fe_ptr = [&](
auto this_fe_ptr,
auto fe_bit) {
1469 std::vector<boost::shared_ptr<DomainParentEle>> parents_elems_ptr_vec;
1471 parents_elems_ptr_vec.emplace_back(
1472 boost::make_shared<DomainParentEle>(
mField));
1474 parents_elems_ptr_vec[
l - 1]->getOpPtrVector().push_back(
1475 create_run_parent_op(parents_elems_ptr_vec[
l], this_fe_ptr, fe_bit));
1477 return parents_elems_ptr_vec[0];
1481 auto solve_projection = [&](
auto exe_test) {
1484 auto set_domain_rhs = [&](
auto fe) {
1486 auto &pip = fe->getOpPtrVector();
1488 auto u_ptr = boost::make_shared<MatrixDouble>();
1489 auto p_ptr = boost::make_shared<VectorDouble>();
1490 auto h_ptr = boost::make_shared<VectorDouble>();
1491 auto g_ptr = boost::make_shared<VectorDouble>();
1493 auto eval_fe_ptr = boost::make_shared<DomainParentEle>(
mField);
1495 auto &pip = eval_fe_ptr->getOpPtrVector();
1501 boost::shared_ptr<ForcesAndSourcesCore> fe_parent(
1509 CHKERR add_parent_field_domain(eval_fe_ptr, UDO::OPCOL,
"U",
1512 CHKERR add_parent_field_domain(eval_fe_ptr, UDO::OPCOL,
"P",
1515 CHKERR add_parent_field_domain(eval_fe_ptr, UDO::OPCOL,
"H",
1518 CHKERR add_parent_field_domain(eval_fe_ptr, UDO::OPCOL,
"G",
1522 auto parent_eval_fe_ptr =
1524 pip.push_back(create_run_parent_op(parent_eval_fe_ptr, eval_fe_ptr,
1527 auto assemble_fe_ptr = boost::make_shared<DomainParentEle>(
mField);
1529 auto &pip = assemble_fe_ptr->getOpPtrVector();
1535 boost::shared_ptr<ForcesAndSourcesCore> fe_parent(
1541 CHKERR add_parent_field_domain(assemble_fe_ptr, UDO::OPROW,
"U",
1544 CHKERR add_parent_field_domain(assemble_fe_ptr, UDO::OPROW,
"P",
1547 CHKERR add_parent_field_domain(assemble_fe_ptr, UDO::OPROW,
"H",
1550 CHKERR add_parent_field_domain(assemble_fe_ptr, UDO::OPROW,
"G",
1554 auto parent_assemble_fe_ptr =
1556 pip.push_back(create_run_parent_op(
1562 auto set_domain_lhs = [&](
auto fe) {
1565 auto &pip = fe->getOpPtrVector();
1573 boost::shared_ptr<ForcesAndSourcesCore> fe_parent(
1582 CHKERR add_parent_field_domain(fe, UDO::OPROW,
"U",
1584 CHKERR add_parent_field_domain(fe, UDO::OPCOL,
"U",
1587 CHKERR add_parent_field_domain(fe, UDO::OPROW,
"P",
1589 CHKERR add_parent_field_domain(fe, UDO::OPCOL,
"P",
1592 CHKERR add_parent_field_domain(fe, UDO::OPROW,
"H",
1594 CHKERR add_parent_field_domain(fe, UDO::OPCOL,
"H",
1597 CHKERR add_parent_field_domain(fe, UDO::OPROW,
"G",
1599 CHKERR add_parent_field_domain(fe, UDO::OPCOL,
"G",
1606 auto set_bdy_rhs = [&](
auto fe) {
1608 auto &pip = fe->getOpPtrVector();
1610 auto l_ptr = boost::make_shared<VectorDouble>();
1612 auto eval_fe_ptr = boost::make_shared<BoundaryParentEle>(
mField);
1614 auto &pip = eval_fe_ptr->getOpPtrVector();
1619 boost::shared_ptr<ForcesAndSourcesCore> fe_parent(
1627 CHKERR add_parent_field_bdy(eval_fe_ptr, UDO::OPCOL,
"L",
1631 auto parent_eval_fe_ptr =
1633 pip.push_back(create_run_parent_op(parent_eval_fe_ptr, eval_fe_ptr,
1636 auto assemble_fe_ptr = boost::make_shared<BoundaryParentEle>(
mField);
1638 auto &pip = assemble_fe_ptr->getOpPtrVector();
1643 boost::shared_ptr<ForcesAndSourcesCore> fe_parent(
1651 OpLSize(boost::shared_ptr<VectorDouble> l_ptr)
1655 if (lPtr->size() != getGaussPts().size2()) {
1656 lPtr->resize(getGaussPts().size2());
1663 boost::shared_ptr<VectorDouble> lPtr;
1666 pip.push_back(
new OpLSize(l_ptr));
1668 CHKERR add_parent_field_bdy(assemble_fe_ptr, UDO::OPROW,
"L",
1672 auto parent_assemble_fe_ptr =
1674 pip.push_back(create_run_parent_op(
1680 auto set_bdy_lhs = [&](
auto fe) {
1683 auto &pip = fe->getOpPtrVector();
1689 boost::shared_ptr<ForcesAndSourcesCore> fe_parent(
1698 CHKERR add_parent_field_bdy(fe, UDO::OPROW,
"L",
1700 CHKERR add_parent_field_bdy(fe, UDO::OPCOL,
"L",
1708 auto level_ents_ptr = boost::make_shared<Range>();
1712 auto get_prj_ents = [&]() {
1717 auto common_ents = intersect(prj_mesh, *level_ents_ptr);
1718 prj_mesh = subtract(unite(*level_ents_ptr, prj_mesh), common_ents)
1724 auto prj_ents = get_prj_ents();
1728 auto rebuild = [&]() {
1732 std::vector<std::string> fields{
"U",
"P",
"H",
"G",
"L"};
1733 std::map<std::string, boost::shared_ptr<Range>> range_maps{
1735 {
"U", level_ents_ptr},
1736 {
"P", level_ents_ptr},
1737 {
"H", level_ents_ptr},
1738 {
"G", level_ents_ptr},
1739 {
"L", level_ents_ptr}
1744 simple->getProblemName(), PETSC_TRUE,
1745 &range_maps, &range_maps);
1748 CHKERR prb_mng->partitionFiniteElements(
"SUB_SOLVER",
true, 0,
1751 CHKERR prb_mng->partitionGhostDofsOnDistributedMesh(
"SUB_SOLVER");
1756 MOFEM_LOG(
"FS", Sev::verbose) <<
"Create projection problem";
1760 auto dm =
simple->getDM();
1763 CHKERR DMSetType(subdm,
"DMMOFEM");
1768 MOFEM_LOG(
"FS", Sev::inform) <<
"Nothing to project";
1773 auto create_dummy_dm = [&]() {
1776 simple->getProblemName().c_str(),
1782 auto subdm = create_subdm();
1785 pip_mng->getDomainRhsFE().reset();
1786 pip_mng->getDomainLhsFE().reset();
1787 pip_mng->getBoundaryRhsFE().reset();
1788 pip_mng->getBoundaryLhsFE().reset();
1793 pip_mng->getDomainLhsFE()->exeTestHook = exe_test;
1794 pip_mng->getDomainRhsFE()->exeTestHook = [](
FEMethod *fe_ptr) {
1797 pip_mng->getBoundaryLhsFE()->exeTestHook = exe_test;
1798 pip_mng->getBoundaryRhsFE()->exeTestHook = [](
FEMethod *fe_ptr) {
1802 CHKERR set_domain_rhs(pip_mng->getCastDomainRhsFE());
1803 CHKERR set_domain_lhs(pip_mng->getCastDomainLhsFE());
1804 CHKERR set_bdy_rhs(pip_mng->getCastBoundaryRhsFE());
1805 CHKERR set_bdy_lhs(pip_mng->getCastBoundaryLhsFE());
1810 auto ksp = pip_mng->createKSP(subdm);
1811 CHKERR KSPSetFromOptions(ksp);
1815 auto get_norm = [&](
auto x) {
1817 CHKERR VecNorm(x, NORM_2, &nrm);
1824 auto zero_dofs = [](boost::shared_ptr<FieldEntity> ent_ptr) {
1826 for (
auto &
v : ent_ptr->getEntFieldData()) {
1832 auto solve = [&](
auto S) {
1834 CHKERR VecZeroEntries(S);
1836 CHKERR VecGhostUpdateBegin(
F, INSERT_VALUES, SCATTER_FORWARD);
1837 CHKERR VecGhostUpdateEnd(
F, INSERT_VALUES, SCATTER_FORWARD);
1839 CHKERR VecGhostUpdateBegin(S, INSERT_VALUES, SCATTER_FORWARD);
1840 CHKERR VecGhostUpdateEnd(S, INSERT_VALUES, SCATTER_FORWARD);
1847 MOFEM_LOG(
"FS", Sev::inform) <<
"Solve projection";
1852 auto dummy_dm = create_dummy_dm();
1857 auto apply_restrict = [&]() {
1858 auto get_is = [](
auto v) {
1860 auto create = [&]() {
1864 CHKERR VecGetOwnershipRange(
v, &ystart, NULL);
1865 CHKERR ISCreateStride(PETSC_COMM_SELF,
n, ystart, 1, &iy);
1872 auto iy = get_is(glob_x);
1876 DMSubDomainRestrict(
simple->getDM(), s, PETSC_NULLPTR, dummy_dm),
1882 DMGetNamedGlobalVector(dummy_dm,
"TSTheta_Xdot", &Xdot),
1885 auto forward_ghost = [](
auto g) {
1887 CHKERR VecGhostUpdateBegin(
g, INSERT_VALUES, SCATTER_FORWARD);
1888 CHKERR VecGhostUpdateEnd(
g, INSERT_VALUES, SCATTER_FORWARD);
1895 if constexpr (
debug) {
1897 <<
"Reverse restrict: X0 " << get_norm(X0) <<
" Xdot "
1901 return std::vector<Vec>{X0, Xdot};
1904 auto ts_solver_vecs = apply_restrict();
1906 if (ts_solver_vecs.size()) {
1908 for (
auto v : ts_solver_vecs) {
1909 MOFEM_LOG(
"FS", Sev::inform) <<
"Solve projection vector";
1915 for (
auto f : {
"U",
"P",
"H",
"G",
"L"}) {
1916 MOFEM_LOG(
"WORLD", Sev::verbose) <<
"Zero field " << f;
1917 CHKERR field_blas->fieldLambdaOnEntities(zero_dofs, f);
1925 MOFEM_LOG(
"FS", Sev::inform) <<
"Norm V " << get_norm(
v);
1928 CHKERR DMRestoreNamedGlobalVector(dummy_dm,
"TSTheta_X0",
1929 &ts_solver_vecs[0]);
1930 CHKERR DMRestoreNamedGlobalVector(dummy_dm,
"TSTheta_Xdot",
1931 &ts_solver_vecs[1]);
1934 for (
auto f : {
"U",
"P",
"H",
"G",
"L"}) {
1935 MOFEM_LOG(
"WORLD", Sev::verbose) <<
"Zero field " << f;
1936 CHKERR field_blas->fieldLambdaOnEntities(zero_dofs, f);
1945 auto post_proc = [&](
auto exe_test) {
1947 auto post_proc_fe = boost::make_shared<PostProcEleDomain>(
mField);
1948 auto &pip = post_proc_fe->getOpPtrVector();
1949 post_proc_fe->exeTestHook = exe_test;
1957 boost::shared_ptr<ForcesAndSourcesCore> fe_parent(
1960 fe_parent->getOpPtrVector(), {H1});
1968 auto u_ptr = boost::make_shared<MatrixDouble>();
1969 auto p_ptr = boost::make_shared<VectorDouble>();
1970 auto h_ptr = boost::make_shared<VectorDouble>();
1971 auto g_ptr = boost::make_shared<VectorDouble>();
1973 CHKERR add_parent_field_domain(post_proc_fe, UDO::OPCOL,
"U",
1976 CHKERR add_parent_field_domain(post_proc_fe, UDO::OPCOL,
"P",
1979 CHKERR add_parent_field_domain(post_proc_fe, UDO::OPCOL,
"H",
1982 CHKERR add_parent_field_domain(post_proc_fe, UDO::OPCOL,
"G",
1986 post_proc_fe->getOpPtrVector().push_back(
1988 new OpPPMap(post_proc_fe->getPostProcMesh(),
1989 post_proc_fe->getMapGaussPts(),
1991 {{
"P", p_ptr}, {
"H", h_ptr}, {
"G", g_ptr}},
2003 auto dm =
simple->getDM();
2005 CHKERR post_proc_fe->writeFile(
"out_projection.h5m");
2014 if constexpr (
debug) {
2020 fe_domain_lhs.swap(pip_mng->getDomainLhsFE());
2021 fe_domain_rhs.swap(pip_mng->getDomainRhsFE());
2022 fe_bdy_lhs.swap(pip_mng->getBoundaryLhsFE());
2023 fe_bdy_rhs.swap(pip_mng->getBoundaryRhsFE());
2036 auto add_parent_field_domain = [&](
auto fe,
auto op,
auto field) {
2041 boost::shared_ptr<ForcesAndSourcesCore> fe_parent(
2049 auto add_parent_field_bdy = [&](
auto fe,
auto op,
auto field) {
2054 boost::shared_ptr<ForcesAndSourcesCore> fe_parent(
2067 auto dot_u_ptr = boost::make_shared<MatrixDouble>();
2068 auto u_ptr = boost::make_shared<MatrixDouble>();
2069 auto grad_u_ptr = boost::make_shared<MatrixDouble>();
2070 auto dot_h_ptr = boost::make_shared<VectorDouble>();
2071 auto h_ptr = boost::make_shared<VectorDouble>();
2072 auto grad_h_ptr = boost::make_shared<MatrixDouble>();
2073 auto g_ptr = boost::make_shared<VectorDouble>();
2074 auto grad_g_ptr = boost::make_shared<MatrixDouble>();
2075 auto lambda_ptr = boost::make_shared<VectorDouble>();
2076 auto p_ptr = boost::make_shared<VectorDouble>();
2077 auto div_u_ptr = boost::make_shared<VectorDouble>();
2081 auto set_domain_general = [&](
auto fe) {
2083 auto &pip = fe->getOpPtrVector();
2091 boost::shared_ptr<ForcesAndSourcesCore> fe_parent(
2094 fe_parent->getOpPtrVector(), {H1});
2100 CHKERR add_parent_field_domain(fe, UDO::OPROW,
"U");
2101 CHKERR add_parent_field_domain(fe, UDO::OPCOL,
"U");
2121 "Coordinate system not implemented");
2124 CHKERR add_parent_field_domain(fe, UDO::OPCOL,
"H");
2130 CHKERR add_parent_field_domain(fe, UDO::OPCOL,
"G");
2135 CHKERR add_parent_field_domain(fe, UDO::OPCOL,
"P");
2140 auto set_domain_rhs = [&](
auto fe) {
2142 auto &pip = fe->getOpPtrVector();
2144 CHKERR set_domain_general(fe);
2146 CHKERR add_parent_field_domain(fe, UDO::OPROW,
"U");
2147 pip.push_back(
new OpRhsU(
"U", dot_u_ptr, u_ptr, grad_u_ptr, h_ptr,
2148 grad_h_ptr, g_ptr, p_ptr));
2150 CHKERR add_parent_field_domain(fe, UDO::OPROW,
"H");
2151 pip.push_back(
new OpRhsH<false>(
"H", u_ptr, dot_h_ptr, h_ptr, grad_h_ptr,
2154 CHKERR add_parent_field_domain(fe, UDO::OPROW,
"G");
2155 pip.push_back(
new OpRhsG<false>(
"G", h_ptr, grad_h_ptr, g_ptr));
2157 CHKERR add_parent_field_domain(fe, UDO::OPROW,
"P");
2159 "P", div_u_ptr, [](
const double r,
const double,
const double) {
2163 "P", p_ptr, [](
const double r,
const double,
const double) {
2169 auto set_domain_lhs = [&](
auto fe) {
2171 auto &pip = fe->getOpPtrVector();
2173 CHKERR set_domain_general(fe);
2175 CHKERR add_parent_field_domain(fe, UDO::OPROW,
"U");
2177 CHKERR add_parent_field_domain(fe, UDO::OPCOL,
"U");
2178 pip.push_back(
new OpLhsU_dU(
"U", u_ptr, grad_u_ptr, h_ptr));
2179 CHKERR add_parent_field_domain(fe, UDO::OPCOL,
"H");
2181 new OpLhsU_dH(
"U",
"H", dot_u_ptr, u_ptr, grad_u_ptr, h_ptr, g_ptr));
2183 CHKERR add_parent_field_domain(fe, UDO::OPCOL,
"G");
2184 pip.push_back(
new OpLhsU_dG(
"U",
"G", grad_h_ptr));
2187 CHKERR add_parent_field_domain(fe, UDO::OPROW,
"H");
2189 CHKERR add_parent_field_domain(fe, UDO::OPCOL,
"U");
2190 pip.push_back(
new OpLhsH_dU(
"H",
"U", grad_h_ptr));
2191 CHKERR add_parent_field_domain(fe, UDO::OPCOL,
"H");
2193 CHKERR add_parent_field_domain(fe, UDO::OPCOL,
"G");
2197 CHKERR add_parent_field_domain(fe, UDO::OPROW,
"G");
2199 CHKERR add_parent_field_domain(fe, UDO::OPCOL,
"H");
2201 CHKERR add_parent_field_domain(fe, UDO::OPCOL,
"G");
2205 CHKERR add_parent_field_domain(fe, UDO::OPROW,
"P");
2207 CHKERR add_parent_field_domain(fe, UDO::OPCOL,
"U");
2213 [](
const double r,
const double,
const double) {
2221 [](
const double r,
const double,
const double) {
2228 "Coordinate system not implemented");
2231 CHKERR add_parent_field_domain(fe, UDO::OPCOL,
"P");
2232 pip.push_back(
new OpDomainMassP(
"P",
"P", [](
double r,
double,
double) {
2240 auto get_block_name = [](
auto name) {
2241 return boost::format(
"%s(.*)") %
"WETTING_ANGLE";
2244 auto get_blocks = [&](
auto &&name) {
2246 std::regex(name.str()));
2249 auto set_boundary_rhs = [&](
auto fe) {
2251 auto &pip = fe->getOpPtrVector();
2257 boost::shared_ptr<ForcesAndSourcesCore> fe_parent(
2264 CHKERR add_parent_field_bdy(fe, UDO::OPCOL,
"U");
2267 CHKERR add_parent_field_bdy(fe, UDO::OPCOL,
"L");
2272 pip,
mField,
"L", {},
"INFLUX",
2275 CHKERR add_parent_field_bdy(fe, UDO::OPROW,
"U");
2278 auto wetting_block = get_blocks(get_block_name(
"WETTING_ANGLE"));
2279 if (wetting_block.size()) {
2286 op_bdy_side->getOpPtrVector(), {H1});
2289 op_bdy_side->getSideFEPtr(),
"", UDO::OPSPACE,
2293 boost::shared_ptr<ForcesAndSourcesCore> fe_parent(
2296 fe_parent->getOpPtrVector(), {H1});
2302 CHKERR add_parent_field_domain(op_bdy_side->getSideFEPtr(), UDO::OPCOL,
2304 op_bdy_side->getOpPtrVector().push_back(
2307 pip.push_back(op_bdy_side);
2310 for (
auto &b : wetting_block) {
2312 std::vector<double> attr_vec;
2313 CHKERR b->getMeshsetIdEntitiesByDimension(
2315 b->getAttributes(attr_vec);
2316 if (attr_vec.size() != 1)
2318 "Should be one attribute");
2319 MOFEM_LOG(
"FS", Sev::inform) <<
"Wetting angle: " << attr_vec.front();
2321 CHKERR add_parent_field_bdy(fe, UDO::OPROW,
"G");
2322 CHKERR add_parent_field_bdy(fe, UDO::OPCOL,
"G");
2324 "G", grad_h_ptr, boost::make_shared<Range>(force_edges),
2332 auto set_boundary_lhs = [&](
auto fe) {
2334 auto &pip = fe->getOpPtrVector();
2340 boost::shared_ptr<ForcesAndSourcesCore> fe_parent(
2347 CHKERR add_parent_field_bdy(fe, UDO::OPROW,
"L");
2348 CHKERR add_parent_field_bdy(fe, UDO::OPCOL,
"U");
2351 auto wetting_block = get_blocks(get_block_name(
"WETTING_ANGLE"));
2352 if (wetting_block.size()) {
2353 auto col_ind_ptr = boost::make_shared<std::vector<VectorInt>>();
2354 auto col_diff_base_ptr = boost::make_shared<std::vector<MatrixDouble>>();
2362 op_bdy_side->getOpPtrVector(), {H1});
2365 op_bdy_side->getSideFEPtr(),
"", UDO::OPSPACE,
2369 boost::shared_ptr<ForcesAndSourcesCore> fe_parent(
2372 fe_parent->getOpPtrVector(), {H1});
2378 CHKERR add_parent_field_domain(op_bdy_side->getSideFEPtr(), UDO::OPROW,
2380 CHKERR add_parent_field_domain(op_bdy_side->getSideFEPtr(), UDO::OPCOL,
2382 op_bdy_side->getOpPtrVector().push_back(
2384 op_bdy_side->getOpPtrVector().push_back(
2388 pip.push_back(op_bdy_side);
2391 for (
auto &b : wetting_block) {
2393 std::vector<double> attr_vec;
2394 CHKERR b->getMeshsetIdEntitiesByDimension(
2396 b->getAttributes(attr_vec);
2397 if (attr_vec.size() != 1)
2399 "Should be one attribute");
2401 <<
"wetting angle edges size " << force_edges.size();
2403 CHKERR add_parent_field_bdy(fe, UDO::OPROW,
"G");
2404 CHKERR add_parent_field_bdy(fe, UDO::OPCOL,
"G");
2406 "G", grad_h_ptr, col_ind_ptr, col_diff_base_ptr,
2407 boost::make_shared<Range>(force_edges), attr_vec.front()));
2416 CHKERR set_domain_rhs(pip_mng->getCastDomainRhsFE());
2417 CHKERR set_domain_lhs(pip_mng->getCastDomainLhsFE());
2418 CHKERR set_boundary_rhs(pip_mng->getCastBoundaryRhsFE());
2419 CHKERR set_boundary_lhs(pip_mng->getCastBoundaryLhsFE());
2443 boost::shared_ptr<PostProcEleDomainCont> post_proc,
2444 boost::shared_ptr<PostProcEleBdyCont> post_proc_edge,
2445 std::pair<boost::shared_ptr<BoundaryEle>, boost::shared_ptr<VectorDouble>>
2452 MOFEM_LOG(
"FS", Sev::verbose) <<
"Monitor";
2457 MOFEM_LOG(
"FS", Sev::verbose) <<
"Mesh pre proc";
2460 auto post_proc_begin =
2461 boost::make_shared<PostProcBrokenMeshInMoabBaseBegin>(*m_field_ptr,
2463 auto post_proc_end = boost::make_shared<PostProcBrokenMeshInMoabBaseEnd>(
2471 CHKERR post_proc_end->writeFile(
2472 "out_step_" + boost::lexical_cast<std::string>(
ts_step) +
".h5m");
2473 MOFEM_LOG(
"FS", Sev::verbose) <<
"Mesh pre proc done";
2479 MPI_Allreduce(MPI_IN_PLACE, &(*
liftVec)[0],
SPACE_DIM, MPI_DOUBLE, MPI_SUM,
2483 <<
" lift vec x: " << (*liftVec)[0] <<
" y: " << (*liftVec)[1];
2509 auto setup_subdm = [&](
auto dm) {
2513 auto dm =
simple->getDM();
2514 auto level_ents_ptr = boost::make_shared<Range>();
2515 CHKERR bit_mng->getEntitiesByRefLevel(
2518 CHKERR DMSetType(subdm,
"DMMOFEM");
2524 for (
auto f : {
"U",
"P",
"H",
"G",
"L"}) {
2537 auto get_fe_post_proc = [&](
auto post_proc_mesh) {
2538 auto add_parent_field_domain = [&](
auto fe,
auto op,
auto field) {
2543 boost::shared_ptr<ForcesAndSourcesCore> fe_parent(
2552 boost::make_shared<PostProcEleDomainCont>(
mField, post_proc_mesh);
2553 post_proc_fe->exeTestHook = [](
FEMethod *fe_ptr) {
2558 auto u_ptr = boost::make_shared<MatrixDouble>();
2559 auto grad_u_ptr = boost::make_shared<MatrixDouble>();
2560 auto h_ptr = boost::make_shared<VectorDouble>();
2561 auto grad_h_ptr = boost::make_shared<MatrixDouble>();
2562 auto p_ptr = boost::make_shared<VectorDouble>();
2563 auto g_ptr = boost::make_shared<VectorDouble>();
2564 auto grad_g_ptr = boost::make_shared<MatrixDouble>();
2567 post_proc_fe->getOpPtrVector(), {H1});
2573 boost::shared_ptr<ForcesAndSourcesCore> fe_parent(
2576 fe_parent->getOpPtrVector(), {H1});
2582 CHKERR add_parent_field_domain(post_proc_fe, UDO::OPCOL,
"U");
2583 post_proc_fe->getOpPtrVector().push_back(
2585 post_proc_fe->getOpPtrVector().push_back(
2589 CHKERR add_parent_field_domain(post_proc_fe, UDO::OPCOL,
"H");
2590 post_proc_fe->getOpPtrVector().push_back(
2592 post_proc_fe->getOpPtrVector().push_back(
2595 CHKERR add_parent_field_domain(post_proc_fe, UDO::OPCOL,
"P");
2596 post_proc_fe->getOpPtrVector().push_back(
2599 CHKERR add_parent_field_domain(post_proc_fe, UDO::OPCOL,
"G");
2600 post_proc_fe->getOpPtrVector().push_back(
2602 post_proc_fe->getOpPtrVector().push_back(
2607 post_proc_fe->getOpPtrVector().push_back(
2610 post_proc_fe->getPostProcMesh(), post_proc_fe->getMapGaussPts(),
2612 {{
"H", h_ptr}, {
"P", p_ptr}, {
"G", g_ptr}},
2614 {{
"U", u_ptr}, {
"H_GRAD", grad_h_ptr}, {
"G_GRAD", grad_g_ptr}},
2616 {{
"GRAD_U", grad_u_ptr}},
2624 return post_proc_fe;
2627 auto get_bdy_post_proc_fe = [&](
auto post_proc_mesh) {
2628 auto add_parent_field_bdy = [&](
auto fe,
auto op,
auto field) {
2629 return setParentDofs(
2633 boost::shared_ptr<ForcesAndSourcesCore> fe_parent(
2642 boost::make_shared<PostProcEleBdyCont>(mField, post_proc_mesh);
2643 post_proc_fe->exeTestHook = [](
FEMethod *fe_ptr) {
2652 boost::shared_ptr<ForcesAndSourcesCore> fe_parent(
2661 OpGetNormal(boost::shared_ptr<VectorDouble> l_ptr,
2662 boost::shared_ptr<MatrixDouble> n_ptr)
2670 auto t_n_fe = getFTensor1NormalsAtGaussPts();
2671 ptrNormal->resize(
SPACE_DIM, getGaussPts().size2(),
false);
2672 auto t_n = getFTensor1FromMat<SPACE_DIM>(*ptrNormal);
2673 for (
auto gg = 0; gg != getGaussPts().size2(); ++gg) {
2674 t_n(
i) = t_n_fe(
i) * t_l / std::sqrt(t_n_fe(
i) * t_n_fe(
i));
2683 boost::shared_ptr<VectorDouble> ptrL;
2684 boost::shared_ptr<MatrixDouble> ptrNormal;
2687 auto u_ptr = boost::make_shared<MatrixDouble>();
2688 auto p_ptr = boost::make_shared<VectorDouble>();
2689 auto lambda_ptr = boost::make_shared<VectorDouble>();
2690 auto normal_l_ptr = boost::make_shared<MatrixDouble>();
2692 CHKERR add_parent_field_bdy(post_proc_fe, UDO::OPCOL,
"U");
2693 post_proc_fe->getOpPtrVector().push_back(
2696 CHKERR add_parent_field_bdy(post_proc_fe, UDO::OPCOL,
"L");
2697 post_proc_fe->getOpPtrVector().push_back(
2699 post_proc_fe->getOpPtrVector().push_back(
2700 new OpGetNormal(lambda_ptr, normal_l_ptr));
2702 CHKERR add_parent_field_bdy(post_proc_fe, UDO::OPCOL,
"P");
2703 post_proc_fe->getOpPtrVector().push_back(
2707 op_ptr->doWorkRhsHook = [&](
DataOperator *base_op_ptr,
int side,
2716 post_proc_fe->getOpPtrVector().push_back(
2718 new OpPPMap(post_proc_fe->getPostProcMesh(),
2719 post_proc_fe->getMapGaussPts(),
2733 return post_proc_fe;
2736 auto get_lift_fe = [&]() {
2737 auto add_parent_field_bdy = [&](
auto fe,
auto op,
auto field) {
2738 return setParentDofs(
2742 boost::shared_ptr<ForcesAndSourcesCore> fe_parent(
2750 auto fe = boost::make_shared<BoundaryEle>(mField);
2751 fe->exeTestHook = [](
FEMethod *fe_ptr) {
2756 auto lift_ptr = boost::make_shared<VectorDouble>();
2757 auto p_ptr = boost::make_shared<VectorDouble>();
2758 auto ents_ptr = boost::make_shared<Range>();
2764 boost::shared_ptr<ForcesAndSourcesCore> fe_parent(
2771 std::vector<const CubitMeshSets *> vec_ptr;
2773 std::regex(
"LIFT"), vec_ptr);
2774 for (
auto m_ptr : vec_ptr) {
2779 ents_ptr->merge(ents);
2782 MOFEM_LOG(
"FS", Sev::noisy) <<
"Lift ents " << (*ents_ptr);
2783 CHKERR add_parent_field_bdy(fe, UDO::OPROW,
"L");
2784 CHKERR add_parent_field_bdy(fe, UDO::OPCOL,
"L");
2785 fe->getOpPtrVector().push_back(
2787 fe->getOpPtrVector().push_back(
2790 return std::make_pair(fe, lift_ptr);
2793 auto set_post_proc_monitor = [&](
auto ts) {
2797 boost::shared_ptr<FEMethod> null_fe;
2798 auto post_proc_mesh = boost::make_shared<moab::Core>();
2799 auto monitor_ptr = boost::make_shared<Monitor>(
2801 get_fe_post_proc(post_proc_mesh), get_bdy_post_proc_fe(post_proc_mesh),
2804 null_fe, monitor_ptr);
2808 auto dm =
simple->getDM();
2812 auto ts_pre_post_proc = boost::make_shared<TSPrePostProc>();
2817 ptr->fsRawPtr =
this;
2818 ptr->solverSubDM = create_solver_dm(
simple->getDM());
2822 CHKERR VecAssemblyBegin(ptr->globSol);
2823 CHKERR VecAssemblyEnd(ptr->globSol);
2825 auto sub_ts = pip_mng->createTSIM(ptr->solverSubDM);
2827 CHKERR set_post_proc_monitor(sub_ts);
2830 CHKERR TSSetFromOptions(ts);
2834 auto print_fields_in_section = [&]() {
2837 simple->getProblemName());
2838 PetscInt num_fields;
2839 CHKERR PetscSectionGetNumFields(section, &num_fields);
2840 for (
int f = 0;
f < num_fields; ++
f) {
2844 <<
"Field " <<
f <<
" " << std::string(
field_name);
2849 CHKERR print_fields_in_section();
2851 CHKERR TSSolve(ts, ptr->globSol);
2876#ifdef PYTHON_INIT_SURFACE
2881 const char param_file[] =
"param_file.petsc";
2885 auto core_log = logging::core::get();
2893 DMType dm_name =
"DMMOFEM";
2898 moab::Core mb_instance;
2899 moab::Interface &moab = mb_instance;
2916#ifdef PYTHON_INIT_SURFACE
2917 if (Py_FinalizeEx() < 0) {
2933 "can not get vertices on bit 0");
2938 Range plus_range, minus_range;
2939 std::vector<EntityHandle> plus, minus;
2942 for (
auto p = vertices.pair_begin(); p != vertices.pair_end(); ++p) {
2944 const auto f = p->first;
2945 const auto s = p->second;
2950 auto it = dofs_mi.lower_bound(lo_uid);
2951 const auto hi_it = dofs_mi.upper_bound(hi_uid);
2955 plus.reserve(std::distance(it, hi_it));
2956 minus.reserve(std::distance(it, hi_it));
2958 for (; it != hi_it; ++it) {
2959 const auto v = (*it)->getFieldData();
2961 plus.push_back((*it)->getEnt());
2963 minus.push_back((*it)->getEnt());
2966 plus_range.insert_list(plus.begin(), plus.end());
2967 minus_range.insert_list(minus.begin(), minus.end());
2972 <<
"Plus range " << plus_range << endl;
2974 <<
"Minus range " << minus_range << endl;
2977 auto get_elems = [&](
auto &ents,
auto bit,
auto mask) {
2980 moab::Interface::UNION),
2981 "can not get adjacencies");
2983 "can not filter elements with bit 0");
2987 CHKERR comm_mng->synchroniseEntities(plus_range);
2988 CHKERR comm_mng->synchroniseEntities(minus_range);
2991 ele_plus[0] = get_elems(plus_range,
bit(0),
BitRefLevel().set());
2992 ele_minus[0] = get_elems(minus_range,
bit(0),
BitRefLevel().set());
2993 auto common = intersect(ele_plus[0], ele_minus[0]);
2994 ele_plus[0] = subtract(ele_plus[0], common);
2995 ele_minus[0] = subtract(ele_minus[0], common);
2997 auto get_children = [&](
auto &p,
auto &
c) {
2999 CHKERR bit_mng->updateRangeByChildren(p,
c);
3011 auto get_level = [&](
auto &p,
auto &
m,
auto z,
auto bit,
auto mask) {
3014 bit_mng->getEntitiesByDimAndRefLevel(
bit, mask,
SPACE_DIM,
l),
3015 "can not get vertices on bit");
3018 for (
auto f = 0; f != z; ++f) {
3022 l = get_elems(conn,
bit, mask);
3027 std::vector<Range> vec_levels(
nb_levels);
3029 vec_levels[
l] = get_level(ele_plus[
l], ele_minus[
l], 2 * overlap,
bit(
l),
3033 if constexpr (
debug) {
3036 std::string name = (boost::format(
"out_r%d.h5m") %
l).str();
3053 start_mask[s] =
true;
3059 Range prev_level_skin;
3063 CHKERR bit_mng->lambdaBitRefLevel(
3070 auto set_levels = [&](
auto &&
3080 auto get_adj = [&](
auto ents) {
3086 ents.subset_by_dimension(
SPACE_DIM), d,
false, conn,
3087 moab::Interface::UNION),
3101 CHKERR bit_mng->updateRangeByParent(vec_levels[
l], parents);
3104 level_prev = subtract(level_prev, parents);
3106 level_prev.merge(vec_levels[
l]);
3114 CHKERR bit_mng->getEntitiesByDimAndRefLevel(
3116 level = get_adj(level);
3125 auto set_skins = [&]() {
3129 ParallelComm *pcomm =
3138 "can't get bit level");
3145 auto get_level_skin = [&]() {
3151 CHKERR pcomm->filter_pstatus(skin_level_mesh,
3152 PSTATUS_SHARED | PSTATUS_MULTISHARED,
3153 PSTATUS_NOT, -1,
nullptr);
3156 skin_level = subtract(skin_level,
3160 Range skin_level_verts;
3163 skin_level.merge(skin_level_verts);
3166 bit_prev.set(
l - 1);
3170 skin.merge(subtract(skin_level, level_prev));
3176 auto resolve_shared = [&](
auto &&skin) {
3177 Range tmp_skin = skin;
3179 map<int, Range> map_procs;
3181 tmp_skin, &map_procs);
3183 Range from_other_procs;
3184 for (
auto &
m : map_procs) {
3186 from_other_procs.merge(
m.second);
3190 auto common = intersect(
3191 skin, from_other_procs);
3192 skin.merge(from_other_procs);
3196 if (!common.empty()) {
3198 skin = subtract(skin, common);
3205 auto get_parent_level_skin = [&](
auto skin) {
3207 CHKERR bit_mng->updateRangeByParent(
3208 skin.subset_by_dimension(
SPACE_DIM - 1), skin_parents);
3209 Range skin_parent_verts;
3212 skin_parents.merge(skin_parent_verts);
3215 return skin_parents;
3218 auto child_skin = resolve_shared(get_level_skin());
3219 auto parent_skin = get_parent_level_skin(child_skin);
3221 child_skin = subtract(child_skin, parent_skin);
3229 auto set_current = [&]() {
3238 last_level = subtract(last_level, skin_child);
3250 if constexpr (
debug) {
3253 std::string name = (boost::format(
"out_level%d.h5m") %
l).str();
3256 "PARALLEL=WRITE_PART");
3260 "MOAB",
"PARALLEL=WRITE_PART");
3263 "MOAB",
"PARALLEL=WRITE_PART");
3267 "MOAB",
"PARALLEL=WRITE_PART");
3270 "MOAB",
"PARALLEL=WRITE_PART");
3278 boost::shared_ptr<FEMethod> fe_top, std::string
field_name,
3281 boost::function<boost::shared_ptr<ForcesAndSourcesCore>()> get_elem,
3288 boost::function<void(boost::shared_ptr<ForcesAndSourcesCore>,
int)>
3290 [&](boost::shared_ptr<ForcesAndSourcesCore> parent_fe_pt,
int level) {
3295 auto fe_ptr_current = get_elem();
3299 boost::dynamic_pointer_cast<ForcesAndSourcesCore>(
3307 parent_fe_pt->getOpPtrVector().push_back(
3311 H1, op, fe_ptr_current,
3322 parent_fe_pt->getOpPtrVector().push_back(
3337 add_parent_level(boost::dynamic_pointer_cast<ForcesAndSourcesCore>(fe_top),
3352 auto cut_off_dofs = [&]() {
3355 auto &m_field = ptr->fsRawPtr->mField;
3357 Range current_verts;
3362 auto cut_off_verts = [&](boost::shared_ptr<FieldEntity> ent_ptr) {
3364 for (
auto &
h : ent_ptr->getEntFieldData()) {
3370 auto field_blas = m_field.getInterface<
FieldBlas>();
3380 MOFEM_LOG(
"FS", Sev::inform) <<
"Run step pre proc";
3382 auto &m_field = ptr->fsRawPtr->mField;
3386 auto get_norm = [&](
auto x) {
3388 CHKERR VecNorm(x, NORM_2, &nrm);
3393 auto refine_problem = [&]() {
3395 MOFEM_LOG(
"FS", Sev::inform) <<
"Refine problem";
3397 CHKERR ptr->fsRawPtr->projectData();
3403 auto set_jacobian_operators = [&]() {
3406 CHKERR KSPReset(ptr->subKSP);
3411 auto set_solution = [&]() {
3413 MOFEM_LOG(
"FS", Sev::inform) <<
"Set solution";
3415 PetscObjectState state;
3426 INSERT_VALUES, SCATTER_FORWARD);
3429 <<
"Set solution, vector norm " << get_norm(ptr->globSol);
3434 PetscObjectTypeCompare((PetscObject)ts, TSTHETA, &is_theta);
3438 CHKERR set_jacobian_operators();
3443 "Sorry, only TSTheta handling is implemented");
3448 PetscBarrier((PetscObject)ts);
3460 auto &m_field = ptr->fsRawPtr->mField;
3472 auto sub_u = ptr->getSubVector();
3475 auto scatter = ptr->getScatter(sub_u, u,
R);
3477 auto apply_scatter_and_update = [&](
auto x,
auto sub_x) {
3479 CHKERR VecScatterBegin(scatter, x, sub_x, INSERT_VALUES, SCATTER_REVERSE);
3480 CHKERR VecScatterEnd(scatter, x, sub_x, INSERT_VALUES, SCATTER_REVERSE);
3481 CHKERR VecGhostUpdateBegin(sub_x, INSERT_VALUES, SCATTER_FORWARD);
3482 CHKERR VecGhostUpdateEnd(sub_x, INSERT_VALUES, SCATTER_FORWARD);
3486 CHKERR apply_scatter_and_update(u, sub_u);
3487 CHKERR apply_scatter_and_update(u_t, sub_u_t);
3490 CHKERR VecScatterBegin(scatter, sub_f,
f, INSERT_VALUES, SCATTER_FORWARD);
3491 CHKERR VecScatterEnd(scatter, sub_f,
f, INSERT_VALUES, SCATTER_FORWARD);
3497 PetscReal
a, Mat
A, Mat
B,
3501 auto sub_u = ptr->getSubVector();
3503 auto scatter = ptr->getScatter(sub_u, u,
R);
3505 auto apply_scatter_and_update = [&](
auto x,
auto sub_x) {
3507 CHKERR VecScatterBegin(scatter, x, sub_x, INSERT_VALUES, SCATTER_REVERSE);
3508 CHKERR VecScatterEnd(scatter, x, sub_x, INSERT_VALUES, SCATTER_REVERSE);
3509 CHKERR VecGhostUpdateBegin(sub_x, INSERT_VALUES, SCATTER_FORWARD);
3510 CHKERR VecGhostUpdateEnd(sub_x, INSERT_VALUES, SCATTER_FORWARD);
3514 CHKERR apply_scatter_and_update(u, sub_u);
3515 CHKERR apply_scatter_and_update(u_t, sub_u_t);
3518 ptr->tsCtxPtr.get());
3527 auto get_norm = [&](
auto x) {
3529 CHKERR VecNorm(x, NORM_2, &nrm);
3533 auto sub_u = ptr->getSubVector();
3534 auto scatter = ptr->getScatter(sub_u, u,
R);
3535 CHKERR VecScatterBegin(scatter, u, sub_u, INSERT_VALUES, SCATTER_REVERSE);
3536 CHKERR VecScatterEnd(scatter, u, sub_u, INSERT_VALUES, SCATTER_REVERSE);
3537 CHKERR VecGhostUpdateBegin(sub_u, INSERT_VALUES, SCATTER_FORWARD);
3538 CHKERR VecGhostUpdateEnd(sub_u, INSERT_VALUES, SCATTER_FORWARD);
3541 <<
"u norm " << get_norm(u) <<
" u sub nom " << get_norm(sub_u);
3551 MOFEM_LOG(
"FS", Sev::verbose) <<
"SetUP sub PC";
3552 ptr->subKSP =
createKSP(ptr->fsRawPtr->mField.get_comm());
3553 CHKERR KSPSetFromOptions(ptr->subKSP);
3561 auto sub_x = ptr->getSubVector();
3563 auto scatter = ptr->getScatter(sub_x, pc_x,
R);
3564 CHKERR VecScatterBegin(scatter, pc_f, sub_f, INSERT_VALUES,
3566 CHKERR VecScatterEnd(scatter, pc_f, sub_f, INSERT_VALUES, SCATTER_REVERSE);
3567 CHKERR KSPSetOperators(ptr->subKSP, ptr->subB, ptr->subB);
3568 MOFEM_LOG(
"FS", Sev::verbose) <<
"PCShell solve";
3569 CHKERR KSPSolve(ptr->subKSP, sub_f, sub_x);
3570 MOFEM_LOG(
"FS", Sev::verbose) <<
"PCShell solve <- done";
3571 CHKERR VecScatterBegin(scatter, sub_x, pc_x, INSERT_VALUES,
3573 CHKERR VecScatterEnd(scatter, sub_x, pc_x, INSERT_VALUES, SCATTER_FORWARD);
3580 auto prb_ptr = ptr->fsRawPtr->mField.get_problem(
"SUB_SOLVER");
3581 if (
auto sub_data = prb_ptr->getSubData()) {
3582 auto is = sub_data->getSmartColIs();
3617 CHKERR TSGetSNES(ts, &snes);
3620 auto set_section_monitor = [&](
auto snes) {
3622 CHKERR SNESMonitorSet(snes,
3625 (
void *)(snes_ctx_ptr.get()),
nullptr);
3629 CHKERR set_section_monitor(snes);
3631 auto ksp =
createKSP(m_field.get_comm());
3632 CHKERR KSPSetType(ksp, KSPPREONLY);
3634 CHKERR PCSetType(sub_pc, PCSHELL);
3637 CHKERR KSPSetPC(ksp, sub_pc);
3638 CHKERR SNESSetKSP(snes, ksp);
3652 PetscInt test_nb = 0;
3653 PetscBool test_flg = PETSC_FALSE;
3654 double regression_value = 0.0;
3664 CHKERR VecNorm(T, NORM_2, &nrm2);
3665 MOFEM_LOG(
"FS", Sev::verbose) <<
"Regression norm " << nrm2;
3673 if (fabs(nrm2 - regression_value) > 1e-2)
3675 "Regression test field; wrong norm value. %6.4e != %6.4e", nrm2,
Implements operators for assembling residuals and Jacobians for the Navier–Stokes–Cahn–Hilliard free-...
#define MOFEM_LOG_SEVERITY_SYNC(comm, severity)
Synchronise "SYNC" on curtain severity level.
#define MOFEM_TAG_AND_LOG(channel, severity, tag)
Tag and log in channel.
void simple(double P1[], double P2[], double P3[], double c[], const int N)
ElementsAndOps< SPACE_DIM >::DomainParentEle DomainParentEle
ElementsAndOps< SPACE_DIM >::BoundaryParentEle BoundaryParentEle
ElementsAndOps< SPACE_DIM >::DomainEle DomainEle
ElementsAndOps< SPACE_DIM >::BoundaryEle BoundaryEle
BoundaryEle::UserDataOperator BoundaryEleOp
Kronecker Delta class symmetric.
#define CATCH_ERRORS
Catch errors.
@ AINSWORTH_LEGENDRE_BASE
Ainsworth Cole (Legendre) approx. base .
#define BITREFLEVEL_SIZE
max number of refinements
#define CHK_THROW_MESSAGE(err, msg)
Check and throw MoFEM exception.
#define MYPCOMM_INDEX
default communicator number PCOMM
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
#define CHK_MOAB_THROW(err, msg)
Check error code of MoAB function and throw MoFEM exception.
@ MOFEM_OPERATION_UNSUCCESSFUL
@ MOFEM_ATOM_TEST_INVALID
@ MOFEM_DATA_INCONSISTENCY
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
#define CHKERR
Inline error check.
PostProcEleByDim< SPACE_DIM >::PostProcEleDomain PostProcEleDomain
auto cylindrical
[cylindrical]
auto marker
Create marker bit reference level
auto bubble_device
Bubble device initialization.
ElementsAndOps< SPACE_DIM >::DomainParentEle DomainParentEle
auto save_range
Save range of entities to file.
auto get_M2
Degenerate mobility function M₂
constexpr int U_FIELD_DIM
ElementsAndOps< SPACE_DIM >::BoundaryParentEle BoundaryParentEle
static boost::weak_ptr< TSPrePostProc > tsPrePostProc
FTensor::Index< 'j', SPACE_DIM > j
auto get_M2_dh
Derivative of degenerate mobility M₂
auto kernel_eye
Eye-shaped interface initialization
double lambda
surface tension
FTensor::Index< 'k', SPACE_DIM > k
OpDomainMassH OpDomainMassG
auto get_M3_dh
Derivative of non-linear mobility M₃
FTensor::Index< 'i', SPACE_DIM > i
auto init_h
Initialisation function.
auto d_phase_function_h
Derivative of phase function with respect to h.
auto get_fe_bit
Get bit reference level from finite element.
FTensor::Index< 'l', SPACE_DIM > l
auto kernel_oscillation
Oscillating interface initialization.
auto get_M0
Constant mobility function M₀
auto get_f_dh
Derivative of double-well potential.
auto get_M3
Non-linear mobility function M₃
FormsIntegrators< DomainEleOp >::Assembly< A >::LinearForm< I >::OpBaseTimesVector< BASE_DIM, SPACE_DIM, 1 > OpDomainAssembleVector
OpDomainMassH OpDomainMassP
FormsIntegrators< DomainEleOp >::Assembly< A >::BiLinearForm< I >::OpMass< BASE_DIM, 1 > OpDomainMassH
auto wetting_angle
Wetting angle function (placeholder)
FormsIntegrators< DomainEleOp >::Assembly< A >::LinearForm< I >::OpBaseTimesScalar< BASE_DIM > OpDomainAssembleScalar
auto get_dofs_ents_all
Get all entities with DOFs in the problem - used for debugging.
auto phase_function
Phase-dependent material property interpolation.
constexpr IntegrationType I
auto get_skin_projection_bit
auto get_global_size
Get global size across all processors.
auto get_dofs_ents_by_field_name
Get entities of DOFs by field name - used for debugging.
auto get_D
Create deviatoric stress tensor.
auto wetting_angle_sub_stepping
[cylindrical]
auto get_M0_dh
Derivative of constant mobility.
auto my_max
[wetting_angle_sub_stepping]
FormsIntegrators< BoundaryEleOp >::Assembly< A >::BiLinearForm< I >::OpMass< BASE_DIM, 1 > OpBoundaryMassL
auto cut_off
Phase field cutoff function.
int order
approximation order
SideEle::UserDataOperator SideOp
FormsIntegrators< DomainEleOp >::Assembly< A >::BiLinearForm< I >::OpMixScalarTimesDiv< SPACE_DIM, COORD_TYPE > OpMixScalarTimesDiv
FormsIntegrators< BoundaryEleOp >::Assembly< A >::LinearForm< I >::OpBaseTimesScalar< BASE_DIM > OpBoundaryAssembleScalar
auto get_current_bit
dofs bit used to do calculations
BoundaryEle::UserDataOperator BoundaryEleOp
auto bit
Create bit reference level.
auto capillary_tube
Capillary tube initialization.
auto get_f
Double-well potential function.
auto d_cut_off
Derivative of cutoff function.
auto my_min
Minimum function with smooth transition
FormsIntegrators< DomainEleOp >::Assembly< A >::BiLinearForm< I >::OpMass< BASE_DIM, U_FIELD_DIM > OpDomainMassU
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 DMMoFEMCreateMoFEM(DM dm, MoFEM::Interface *m_field_ptr, const char problem_name[], const MoFEM::BitRefLevel bit_level, const MoFEM::BitRefLevel bit_mask=MoFEM::BitRefLevel().set())
Must be called by user to set MoFEM data structures.
PetscErrorCode DMoFEMPostProcessFiniteElements(DM dm, MoFEM::FEMethod *method)
execute finite element method for each element in dm (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 DMRegister_MoFEM(const char sname[])
Register MoFEM problem.
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 DMoFEMGetInterfacePtr(DM dm, MoFEM::Interface **m_field_ptr)
Get pointer to MoFEM::Interface.
PetscErrorCode DMMoFEMAddSubFieldCol(DM dm, const char field_name[])
auto createDMMatrix(DM dm)
Get smart matrix from DM.
PetscErrorCode DMoFEMPreProcessFiniteElements(DM dm, MoFEM::FEMethod *method)
execute finite element method for each element in dm (problem)
virtual const DofEntity_multiIndex * get_dofs() const =0
Get the dofs object.
MoFEMErrorCode getEntitiesByDimAndRefLevel(const BitRefLevel bit, const BitRefLevel mask, const int dim, const EntityHandle meshset, int verb=0) const
add all ents from ref level given by bit to meshset
MoFEMErrorCode getEntitiesByTypeAndRefLevel(const BitRefLevel bit, const BitRefLevel mask, const EntityType type, const EntityHandle meshset, int verb=0) const
add all ents from ref level given by bit to meshset
static LoggerType & setLog(const std::string channel)
Set ans resset chanel logger.
#define MOFEM_LOG(channel, severity)
Log.
SeverityLevel
Severity levels.
#define MOFEM_LOG_TAG(channel, tag)
Tag channel.
#define MOFEM_LOG_CHANNEL(channel)
Set and reset channel.
MoFEMErrorCode getMeshset(const int ms_id, const unsigned int cubit_bc_type, EntityHandle &meshset) const
get meshset from CUBIT Id and CUBIT type
MoFEMErrorCode buildSubProblem(const std::string out_name, const std::vector< std::string > &fields_row, const std::vector< std::string > &fields_col, const std::string main_problem, const bool square_matrix=true, const map< std::string, boost::shared_ptr< Range > > *entityMapRow=nullptr, const map< std::string, boost::shared_ptr< Range > > *entityMapCol=nullptr, int verb=VERBOSE)
build sub problem
auto test_bit_child
lambda function used to select elements on which finite element pipelines are executed.
FTensor::Index< 'i', SPACE_DIM > i
const double c
speed of light (cm/ns)
const double v
phase velocity of light in medium (cm/ns)
const double n
refractive index of diffusive medium
PetscErrorCode MoFEMErrorCode
MoFEM/PETSc error code.
std::bitset< BITREFLEVEL_SIZE > BitRefLevel
Bit structure attached to each entity identifying to what mesh entity is attached.
implementation of Data Operators for Forces and Sources
auto createKSP(MPI_Comm comm)
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.
PetscErrorCode TsSetIJacobian(TS ts, PetscReal t, Vec u, Vec u_t, PetscReal a, Mat A, Mat B, void *ctx)
Set function evaluating jacobian in TS solver.
PetscErrorCode TsMonitorSet(TS ts, PetscInt step, PetscReal t, Vec u, void *ctx)
Set monitor for TS solver.
auto getDMTsCtx(DM dm)
Get TS context data structure used by DM.
PetscErrorCode DMMoFEMSetDestroyProblem(DM dm, PetscBool destroy_problem)
PetscErrorCode PetscOptionsGetInt(PetscOptions *, const char pre[], const char name[], PetscInt *ivalue, PetscBool *set)
MoFEMErrorCode MoFEMSNESMonitorFields(SNES snes, PetscInt its, PetscReal fgnorm, SnesCtx *ctx)
Sens monitor printing residual field by field.
PetscErrorCode PetscOptionsGetScalar(PetscOptions *, const char pre[], const char name[], PetscScalar *dval, PetscBool *set)
PetscErrorCode TsSetIFunction(TS ts, PetscReal t, Vec u, Vec u_t, Vec F, void *ctx)
Set IFunction for TS solver.
SmartPetscObj< Vec > vectorDuplicate(Vec vec)
Create duplicate vector of smart vector.
auto createVecScatter(Vec x, IS ix, Vec y, IS iy)
Create a Vec Scatter object.
static PetscErrorCode solve(Mat mat, Vec x, Vec y)
auto createTS(MPI_Comm comm)
auto createPC(MPI_Comm comm)
static auto getFTensor0FromVec(ublas::vector< T, A > &data)
Get tensor rank 0 (scalar) form data vector.
OpCalculateScalarFieldValuesFromPetscVecImpl< PetscData::CTX_SET_X_T > OpCalculateScalarFieldValuesDot
PetscErrorCode PetscOptionsGetEList(PetscOptions *, const char pre[], const char name[], const char *const *list, PetscInt next, PetscInt *value, PetscBool *set)
PetscObject getPetscObject(T obj)
auto get_temp_meshset_ptr(moab::Interface &moab)
Create smart pointer to temporary meshset.
auto getDMSnesCtx(DM dm)
Get SNES context data structure used by DM.
auto createDM(MPI_Comm comm, const std::string dm_type_name)
Creates smart DM object.
auto getProblemPtr(DM dm)
get problem pointer from DM
OpPostProcMapInMoab< SPACE_DIM, SPACE_DIM > OpPPMap
constexpr double t
plate stiffness
constexpr auto field_name
FormsIntegrators< DomainEleOp >::Assembly< PETSC >::BiLinearForm< GAUSS >::OpMass< 1, SPACE_DIM > OpMass
[Only used with Hooke equation (linear material model)]
FTensor::Index< 'm', 3 > m
MoFEM::Interface & mField
Reference to MoFEM interface.
Calculate lift force on free surface boundary.
Lhs for H dH (Jacobian block ∂R_H/∂H)
Lhs for U dG (Jacobian block ∂R_U/∂G)
Lhs for U dH (Jacobian block ∂R_U/∂H)
Rhs for G (chemical potential residual)
Rhs for H (phase-field residual)
Range findParentsToRefine(Range ents, BitRefLevel level, BitRefLevel mask)
Find parent entities that need refinement.
MoFEMErrorCode setupProblem()
Setup problem fields and parameters.
MoFEMErrorCode runProblem()
Main function to run the complete free surface simulation.
FreeSurface(MoFEM::Interface &m_field)
Constructor.
MoFEMErrorCode projectData()
Project solution data between mesh levels.
MoFEMErrorCode boundaryCondition()
Apply boundary conditions and initialize fields.
MoFEMErrorCode readMesh()
Read mesh from input file.
MoFEMErrorCode setParentDofs(boost::shared_ptr< FEMethod > fe_top, std::string field_name, ForcesAndSourcesCore::UserDataOperator::OpType op, BitRefLevel child_ent_bit, boost::function< boost::shared_ptr< ForcesAndSourcesCore >()> get_elem, int verbosity, LogManager::SeverityLevel sev)
Create hierarchy of elements run on parent levels.
std::vector< Range > findEntitiesCrossedByPhaseInterface(size_t overlap)
Find entities on refinement levels.
MoFEMErrorCode assembleSystem()
Assemble system operators and matrices.
MoFEMErrorCode checkResults()
Check results for correctness.
MoFEM::Interface & mField
MoFEMErrorCode refineMesh(size_t overlap)
Perform adaptive mesh refinement.
MoFEMErrorCode makeRefProblem()
Create refined problem for mesh adaptation.
MoFEMErrorCode solveSystem()
Solve the time-dependent free surface problem.
Add operators pushing bases from local to physical configuration.
boost::weak_ptr< CacheTuple > getCacheWeakPtr() const
Get the cache weak pointer object.
Boundary condition manager for finite element problem setup.
virtual int get_comm_size() const =0
virtual FieldBitNumber get_field_bit_number(const std::string name) const =0
get field bit number
virtual moab::Interface & get_moab()=0
virtual MPI_Comm & get_comm() const =0
virtual int get_comm_rank() const =0
static MoFEMErrorCode Initialize(int *argc, char ***args, const char file[], const char help[])
Initializes the MoFEM database PETSc, MOAB and MPI.
static MoFEMErrorCode Finalize()
Checks for options to be called at the conclusion of the program.
base operator to do operations at Gauss Pt. level
Deprecated interface functions.
static UId getLoFieldEntityUId(const FieldBitNumber bit, const EntityHandle ent)
static UId getHiFieldEntityUId(const FieldBitNumber bit, const EntityHandle ent)
Data on single entity (This is passed as argument to DataOperator::doWork)
Structure for user loop methods on finite elements.
boost::shared_ptr< const NumeredEntFiniteElement > numeredEntFiniteElementPtr
Shared pointer to finite element database structure.
MoFEMErrorCode fieldLambdaOnEntities(OneFieldFunctionOnEntities lambda, const std::string field_name, Range *ents_ptr=nullptr)
field lambda
static UId getHiBitNumberUId(const FieldBitNumber bit_number)
static UId getLoBitNumberUId(const FieldBitNumber bit_number)
OpType
Controls loop over entities on element.
@ OPSPACE
operator do Work is execute on space data
Section manager is used to create indexes and sections.
static boost::shared_ptr< SinkType > createSink(boost::shared_ptr< std::ostream > stream_ptr, std::string comm_filter)
Create a sink object.
static boost::shared_ptr< std::ostream > getStrmWorld()
Get the strm world object.
Interface for managing meshsets containing materials and boundary conditions.
Operator to project base functions from parent entity to child.
Calculate divergence of vector field at integration points.
Get field gradients at integration pts for scalar field rank 0, i.e. vector field.
Specialization for double precision scalar field values calculation.
Get field gradients at integration pts for scalar field rank 0, i.e. vector field.
Approximate field values for given petsc vector.
Specialization for double precision vector field values calculation.
Element used to execute operators on side of the element.
Post post-proc data at points from hash maps.
std::map< std::string, boost::shared_ptr< MatrixDouble > > DataMapMat
std::map< std::string, boost::shared_ptr< VectorDouble > > DataMapVec
Operator to execute finite element instance on parent element. This operator is typically used to pro...
Template struct for dimension-specific finite element types.
PipelineManager interface.
Problem manager is used to build and partition problems.
Simple interface for fast problem set-up.
MoFEMErrorCode getDM(DM *dm)
Get DM.
bool & getParentAdjacencies()
Get the addParentAdjacencies flag.
intrusive_ptr for managing petsc objects
PetscReal ts_t
Current time value.
PetscInt ts_step
Current time step number.
MoFEMErrorCode getInterface(IFACE *&iface) const
Get interface reference to pointer of interface.
[Push operators to pipeline]
boost::shared_ptr< moab::Core > postProcMesh
MoFEMErrorCode postProcess()
Post-processing function executed at loop completion.
Monitor(SmartPetscObj< DM > dm, boost::shared_ptr< moab::Core > post_proc_mesh, boost::shared_ptr< PostProcEleDomainCont > post_proc, boost::shared_ptr< PostProcEleBdyCont > post_proc_edge, std::pair< boost::shared_ptr< BoundaryEle >, boost::shared_ptr< VectorDouble > > p)
boost::shared_ptr< VectorDouble > liftVec
boost::shared_ptr< BoundaryEle > liftFE
boost::shared_ptr< PostProcEle > postProc
boost::shared_ptr< PostProcEleBdyCont > postProcEdge
boost::shared_ptr< PostProcEleDomainCont > postProc
Set of functions called by PETSc solver used to refine and update mesh.
boost::shared_ptr< TsCtx > tsCtxPtr
virtual ~TSPrePostProc()=default
SmartPetscObj< Vec > globRes
SmartPetscObj< Mat > subB
SmartPetscObj< Vec > globSol
SmartPetscObj< Vec > getSubVector()
Create sub-problem vector.
static MoFEMErrorCode tsMonitor(TS ts, PetscInt step, PetscReal t, Vec u, void *ctx)
Monitor solution during time stepping.
static MoFEMErrorCode pcApply(PC pc, Vec pc_f, Vec pc_x)
Apply preconditioner.
SmartPetscObj< VecScatter > getScatter(Vec x, Vec y, enum FR fr)
Get scatter context for vector operations.
SmartPetscObj< DM > solverSubDM
static MoFEMErrorCode tsSetIJacobian(TS ts, PetscReal t, Vec u, Vec u_t, PetscReal a, Mat A, Mat B, void *ctx)
Set implicit Jacobian for time stepping.
boost::shared_ptr< SnesCtx > snesCtxPtr
static MoFEMErrorCode tsPreProc(TS ts)
Pre process time step.
static MoFEMErrorCode tsSetIFunction(TS ts, PetscReal t, Vec u, Vec u_t, Vec f, void *ctx)
Set implicit function for time stepping.
static MoFEMErrorCode pcSetup(PC pc)
Setup preconditioner.
static MoFEMErrorCode tsPostProc(TS ts)
Post process time step.
static MoFEMErrorCode tsPreStage(TS ts)
Pre-stage processing for time stepping.
MoFEMErrorCode tsSetUp(TS ts)
Used to setup TS solver.
SmartPetscObj< KSP > subKSP
constexpr CoordinateTypes COORD_TYPE
static boost::weak_ptr< TSPrePostProc > tsPrePostProc
ElementsAndOps< SPACE_DIM >::SideEle SideEle