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");
516[[maybe_unused]]
auto marker = [](
auto b) {
526 return fe_ptr->numeredEntFiniteElementPtr->getBitRefLevel();
536 MPI_Allreduce(&l_size, &g_size, 1, MPI_INT, MPI_SUM, MPI_COMM_WORLD);
549auto save_range = [](moab::Interface &moab,
const std::string name,
554 CHKERR moab.add_entities(*out_meshset, r);
555 CHKERR moab.write_file(name.c_str(),
"MOAB",
"PARALLEL=WRITE_PART",
556 out_meshset->get_ptr(), 1);
574 std::vector<EntityHandle> ents_vec;
580 auto dofs = prb_ptr->numeredRowDofsPtr;
583 ents_vec.reserve(std::distance(lo_it, hi_it));
585 for (; lo_it != hi_it; ++lo_it) {
586 ents_vec.push_back((*lo_it)->getEnt());
589 std::sort(ents_vec.begin(), ents_vec.end());
590 auto it = std::unique(ents_vec.begin(), ents_vec.end());
592 r.insert_list(ents_vec.begin(), it);
606 std::vector<EntityHandle> ents_vec;
611 auto dofs = prb_ptr->numeredRowDofsPtr;
612 ents_vec.reserve(dofs->size());
614 for (
auto d : *dofs) {
615 ents_vec.push_back(d->getEnt());
618 std::sort(ents_vec.begin(), ents_vec.end());
619 auto it = std::unique(ents_vec.begin(), ents_vec.end());
621 r.insert_list(ents_vec.begin(), it);
750 PetscReal
a, Mat A, Mat
B,
794 boost::shared_ptr<SnesCtx>
796 boost::shared_ptr<TsCtx>
963 boost::shared_ptr<FEMethod> fe_top, std::string
field_name,
966 boost::function<boost::shared_ptr<ForcesAndSourcesCore>()> get_elem,
995 MOFEM_LOG(
"FS", Sev::inform) <<
"Read mesh for problem";
1018 const char *coord_type_names[] = {
"cartesian",
"polar",
"cylindrical",
1023 MOFEM_LOG(
"FS", Sev::inform) <<
"Approximation order = " <<
order;
1025 <<
"Number of refinement levels nb_levels = " <<
nb_levels;
1050 MOFEM_LOG(
"FS", Sev::inform) <<
"Acceleration a0 = " <<
a0;
1051 MOFEM_LOG(
"FS", Sev::inform) <<
"\"Minus\" phase density rho_m = " <<
rho_m;
1052 MOFEM_LOG(
"FS", Sev::inform) <<
"\"Minus\" phase viscosity mu_m = " <<
mu_m;
1053 MOFEM_LOG(
"FS", Sev::inform) <<
"\"Plus\" phase density rho_p = " <<
rho_p;
1054 MOFEM_LOG(
"FS", Sev::inform) <<
"\"Plus\" phase viscosity mu_p = " <<
mu_p;
1055 MOFEM_LOG(
"FS", Sev::inform) <<
"Surface tension lambda = " <<
lambda;
1057 <<
"Height of the well in energy functional W = " <<
W;
1058 MOFEM_LOG(
"FS", Sev::inform) <<
"Characteristic mesh size h = " <<
h;
1059 MOFEM_LOG(
"FS", Sev::inform) <<
"Mobility md = " <<
md;
1063 MOFEM_LOG(
"FS", Sev::inform) <<
"Average viscosity mu_ave = " <<
mu_ave;
1064 MOFEM_LOG(
"FS", Sev::inform) <<
"Difference viscosity mu_diff = " <<
mu_diff;
1094 auto set_problem_bit = [&]() {
1105 CHKERR set_problem_bit();
1117#ifdef PYTHON_INIT_SURFACE
1118 auto get_py_surface_init = []() {
1119 auto py_surf_init = boost::make_shared<SurfacePython>();
1120 CHKERR py_surf_init->surfaceInit(
"surface.py");
1121 surfacePythonWeakPtr = py_surf_init;
1122 return py_surf_init;
1124 auto py_surf_init = get_py_surface_init();
1131 auto dm =
simple->getDM();
1135 auto reset_bits = [&]() {
1139 start_mask[s] =
true;
1141 CHKERR bit_mng->lambdaBitRefLevel(
1150 auto add_parent_field = [&](
auto fe,
auto op,
auto field) {
1155 boost::shared_ptr<ForcesAndSourcesCore> fe_parent(
1163 auto h_ptr = boost::make_shared<VectorDouble>();
1164 auto grad_h_ptr = boost::make_shared<MatrixDouble>();
1165 auto g_ptr = boost::make_shared<VectorDouble>();
1166 auto grad_g_ptr = boost::make_shared<MatrixDouble>();
1168 auto set_generic = [&](
auto fe) {
1170 auto &pip = fe->getOpPtrVector();
1178 boost::shared_ptr<ForcesAndSourcesCore> fe_parent(
1181 fe_parent->getOpPtrVector(), {H1});
1187 CHKERR add_parent_field(fe, UDO::OPCOL,
"H");
1192 CHKERR add_parent_field(fe, UDO::OPCOL,
"G");
1200 auto post_proc = [&](
auto exe_test) {
1202 auto post_proc_fe = boost::make_shared<PostProcEleDomain>(
mField);
1203 post_proc_fe->exeTestHook = exe_test;
1205 CHKERR set_generic(post_proc_fe);
1209 post_proc_fe->getOpPtrVector().push_back(
1211 new OpPPMap(post_proc_fe->getPostProcMesh(),
1212 post_proc_fe->getMapGaussPts(),
1214 {{
"H", h_ptr}, {
"G", g_ptr}},
1216 {{
"GRAD_H", grad_h_ptr}, {
"GRAD_G", grad_g_ptr}},
1227 CHKERR post_proc_fe->writeFile(
"out_init.h5m");
1232 auto solve_init = [&](
auto exe_test) {
1235 pip_mng->getOpDomainRhsPipeline().clear();
1236 pip_mng->getOpDomainLhsPipeline().clear();
1238 auto set_domain_rhs = [&](
auto fe) {
1241 auto &pip = fe->getOpPtrVector();
1243 CHKERR add_parent_field(fe, UDO::OPROW,
"H");
1244 pip.push_back(
new OpRhsH<true>(
"H",
nullptr,
nullptr, h_ptr, grad_h_ptr,
1246 CHKERR add_parent_field(fe, UDO::OPROW,
"G");
1247 pip.push_back(
new OpRhsG<true>(
"G", h_ptr, grad_h_ptr, g_ptr));
1251 auto set_domain_lhs = [&](
auto fe) {
1255 auto &pip = fe->getOpPtrVector();
1257 CHKERR add_parent_field(fe, UDO::OPROW,
"H");
1258 CHKERR add_parent_field(fe, UDO::OPCOL,
"H");
1261 CHKERR add_parent_field(fe, UDO::OPCOL,
"G");
1264 CHKERR add_parent_field(fe, UDO::OPROW,
"G");
1267 CHKERR add_parent_field(fe, UDO::OPCOL,
"H");
1272 auto create_subdm = [&]() {
1273 auto level_ents_ptr = boost::make_shared<Range>();
1279 CHKERR DMSetType(subdm,
"DMMOFEM");
1285 for (
auto f : {
"H",
"G"}) {
1291 if constexpr (
debug) {
1295 dm_ents.subset_by_type(MBVERTEX));
1296 dm_ents = subtract(dm_ents, dm_ents.subset_by_type(MBVERTEX));
1304 auto subdm = create_subdm();
1306 pip_mng->getDomainRhsFE().reset();
1307 pip_mng->getDomainLhsFE().reset();
1310 pip_mng->getDomainLhsFE()->exeTestHook = exe_test;
1311 pip_mng->getDomainRhsFE()->exeTestHook = exe_test;
1313 CHKERR set_domain_rhs(pip_mng->getCastDomainRhsFE());
1314 CHKERR set_domain_lhs(pip_mng->getCastDomainLhsFE());
1317 auto snes = pip_mng->createSNES(subdm);
1320 auto set_section_monitor = [&](
auto solver) {
1322 CHKERR SNESMonitorSet(solver,
1325 (
void *)(snes_ctx_ptr.get()),
nullptr);
1330 auto print_section_field = [&]() {
1335 PetscInt num_fields;
1336 CHKERR PetscSectionGetNumFields(section, &num_fields);
1337 for (
int f = 0;
f < num_fields; ++
f) {
1341 <<
"Field " <<
f <<
" " << std::string(
field_name);
1347 CHKERR set_section_monitor(snes);
1348 CHKERR print_section_field();
1350 for (
auto f : {
"U",
"P",
"H",
"G",
"L"}) {
1354 CHKERR SNESSetFromOptions(snes);
1357 PETSC_NULLPTR, PETSC_NULLPTR);
1358 CHKERR SNESSolve(snes, PETSC_NULLPTR,
D);
1360 CHKERR VecGhostUpdateBegin(
D, INSERT_VALUES, SCATTER_FORWARD);
1361 CHKERR VecGhostUpdateEnd(
D, INSERT_VALUES, SCATTER_FORWARD);
1372 for (
auto f : {
"U",
"P",
"H",
"G",
"L"}) {
1383 pip_mng->getOpDomainRhsPipeline().clear();
1384 pip_mng->getOpDomainLhsPipeline().clear();
1387 CHKERR bc_mng->removeBlockDOFsOnEntities(
simple->getProblemName(),
"SYM_X",
1389 CHKERR bc_mng->removeBlockDOFsOnEntities(
simple->getProblemName(),
"SYM_X",
1391 CHKERR bc_mng->removeBlockDOFsOnEntities(
simple->getProblemName(),
"SYM_Y",
1393 CHKERR bc_mng->removeBlockDOFsOnEntities(
simple->getProblemName(),
"SYM_Y",
1395 CHKERR bc_mng->removeBlockDOFsOnEntities(
simple->getProblemName(),
"FIX",
"U",
1397 CHKERR bc_mng->removeBlockDOFsOnEntities(
simple->getProblemName(),
"FIX",
"L",
1399 CHKERR bc_mng->removeBlockDOFsOnEntities(
simple->getProblemName(),
"ZERO",
1421 auto fe_domain_lhs = pip_mng->getDomainLhsFE();
1422 auto fe_domain_rhs = pip_mng->getDomainRhsFE();
1423 auto fe_bdy_lhs = pip_mng->getBoundaryLhsFE();
1424 auto fe_bdy_rhs = pip_mng->getBoundaryRhsFE();
1426 pip_mng->getDomainLhsFE().reset();
1427 pip_mng->getDomainRhsFE().reset();
1428 pip_mng->getBoundaryLhsFE().reset();
1429 pip_mng->getBoundaryRhsFE().reset();
1434 auto add_parent_field_domain = [&](
auto fe,
auto op,
auto field,
auto bit) {
1439 boost::shared_ptr<ForcesAndSourcesCore> fe_parent(
1448 auto add_parent_field_bdy = [&](
auto fe,
auto op,
auto field,
auto bit) {
1453 boost::shared_ptr<ForcesAndSourcesCore> fe_parent(
1463 auto create_run_parent_op = [&](
auto parent_fe_ptr,
auto this_fe_ptr,
1465 auto parent_mask = fe_bit;
1473 auto get_parents_vel_fe_ptr = [&](
auto this_fe_ptr,
auto fe_bit) {
1474 std::vector<boost::shared_ptr<DomainParentEle>> parents_elems_ptr_vec;
1476 parents_elems_ptr_vec.emplace_back(
1477 boost::make_shared<DomainParentEle>(
mField));
1479 parents_elems_ptr_vec[
l - 1]->getOpPtrVector().push_back(
1480 create_run_parent_op(parents_elems_ptr_vec[
l], this_fe_ptr, fe_bit));
1482 return parents_elems_ptr_vec[0];
1486 auto solve_projection = [&](
auto exe_test) {
1489 auto set_domain_rhs = [&](
auto fe) {
1491 auto &pip = fe->getOpPtrVector();
1493 auto u_ptr = boost::make_shared<MatrixDouble>();
1494 auto p_ptr = boost::make_shared<VectorDouble>();
1495 auto h_ptr = boost::make_shared<VectorDouble>();
1496 auto g_ptr = boost::make_shared<VectorDouble>();
1498 auto eval_fe_ptr = boost::make_shared<DomainParentEle>(
mField);
1500 auto &pip = eval_fe_ptr->getOpPtrVector();
1506 boost::shared_ptr<ForcesAndSourcesCore> fe_parent(
1514 CHKERR add_parent_field_domain(eval_fe_ptr, UDO::OPCOL,
"U",
1517 CHKERR add_parent_field_domain(eval_fe_ptr, UDO::OPCOL,
"P",
1520 CHKERR add_parent_field_domain(eval_fe_ptr, UDO::OPCOL,
"H",
1523 CHKERR add_parent_field_domain(eval_fe_ptr, UDO::OPCOL,
"G",
1527 auto parent_eval_fe_ptr =
1529 pip.push_back(create_run_parent_op(parent_eval_fe_ptr, eval_fe_ptr,
1532 auto assemble_fe_ptr = boost::make_shared<DomainParentEle>(
mField);
1534 auto &pip = assemble_fe_ptr->getOpPtrVector();
1540 boost::shared_ptr<ForcesAndSourcesCore> fe_parent(
1546 CHKERR add_parent_field_domain(assemble_fe_ptr, UDO::OPROW,
"U",
1549 CHKERR add_parent_field_domain(assemble_fe_ptr, UDO::OPROW,
"P",
1552 CHKERR add_parent_field_domain(assemble_fe_ptr, UDO::OPROW,
"H",
1555 CHKERR add_parent_field_domain(assemble_fe_ptr, UDO::OPROW,
"G",
1559 auto parent_assemble_fe_ptr =
1561 pip.push_back(create_run_parent_op(
1567 auto set_domain_lhs = [&](
auto fe) {
1570 auto &pip = fe->getOpPtrVector();
1578 boost::shared_ptr<ForcesAndSourcesCore> fe_parent(
1587 CHKERR add_parent_field_domain(fe, UDO::OPROW,
"U",
1589 CHKERR add_parent_field_domain(fe, UDO::OPCOL,
"U",
1592 CHKERR add_parent_field_domain(fe, UDO::OPROW,
"P",
1594 CHKERR add_parent_field_domain(fe, UDO::OPCOL,
"P",
1597 CHKERR add_parent_field_domain(fe, UDO::OPROW,
"H",
1599 CHKERR add_parent_field_domain(fe, UDO::OPCOL,
"H",
1602 CHKERR add_parent_field_domain(fe, UDO::OPROW,
"G",
1604 CHKERR add_parent_field_domain(fe, UDO::OPCOL,
"G",
1611 auto set_bdy_rhs = [&](
auto fe) {
1613 auto &pip = fe->getOpPtrVector();
1615 auto l_ptr = boost::make_shared<VectorDouble>();
1617 auto eval_fe_ptr = boost::make_shared<BoundaryParentEle>(
mField);
1619 auto &pip = eval_fe_ptr->getOpPtrVector();
1624 boost::shared_ptr<ForcesAndSourcesCore> fe_parent(
1632 CHKERR add_parent_field_bdy(eval_fe_ptr, UDO::OPCOL,
"L",
1636 auto parent_eval_fe_ptr =
1638 pip.push_back(create_run_parent_op(parent_eval_fe_ptr, eval_fe_ptr,
1641 auto assemble_fe_ptr = boost::make_shared<BoundaryParentEle>(
mField);
1643 auto &pip = assemble_fe_ptr->getOpPtrVector();
1648 boost::shared_ptr<ForcesAndSourcesCore> fe_parent(
1656 OpLSize(boost::shared_ptr<VectorDouble> l_ptr)
1660 if (lPtr->size() != getGaussPts().size2()) {
1661 lPtr->resize(getGaussPts().size2());
1668 boost::shared_ptr<VectorDouble> lPtr;
1671 pip.push_back(
new OpLSize(l_ptr));
1673 CHKERR add_parent_field_bdy(assemble_fe_ptr, UDO::OPROW,
"L",
1677 auto parent_assemble_fe_ptr =
1679 pip.push_back(create_run_parent_op(
1685 auto set_bdy_lhs = [&](
auto fe) {
1688 auto &pip = fe->getOpPtrVector();
1694 boost::shared_ptr<ForcesAndSourcesCore> fe_parent(
1703 CHKERR add_parent_field_bdy(fe, UDO::OPROW,
"L",
1705 CHKERR add_parent_field_bdy(fe, UDO::OPCOL,
"L",
1713 auto level_ents_ptr = boost::make_shared<Range>();
1717 auto get_prj_ents = [&]() {
1722 auto common_ents = intersect(prj_mesh, *level_ents_ptr);
1723 prj_mesh = subtract(unite(*level_ents_ptr, prj_mesh), common_ents)
1729 auto prj_ents = get_prj_ents();
1733 auto rebuild = [&]() {
1737 std::vector<std::string> fields{
"U",
"P",
"H",
"G",
"L"};
1738 std::map<std::string, boost::shared_ptr<Range>> range_maps{
1740 {
"U", level_ents_ptr},
1741 {
"P", level_ents_ptr},
1742 {
"H", level_ents_ptr},
1743 {
"G", level_ents_ptr},
1744 {
"L", level_ents_ptr}
1749 simple->getProblemName(), PETSC_TRUE,
1750 &range_maps, &range_maps);
1753 CHKERR prb_mng->partitionFiniteElements(
"SUB_SOLVER",
true, 0,
1756 CHKERR prb_mng->partitionGhostDofsOnDistributedMesh(
"SUB_SOLVER");
1761 MOFEM_LOG(
"FS", Sev::verbose) <<
"Create projection problem";
1765 auto dm =
simple->getDM();
1768 CHKERR DMSetType(subdm,
"DMMOFEM");
1773 MOFEM_LOG(
"FS", Sev::inform) <<
"Nothing to project";
1778 auto create_dummy_dm = [&]() {
1781 simple->getProblemName().c_str(),
1787 auto subdm = create_subdm();
1790 pip_mng->getDomainRhsFE().reset();
1791 pip_mng->getDomainLhsFE().reset();
1792 pip_mng->getBoundaryRhsFE().reset();
1793 pip_mng->getBoundaryLhsFE().reset();
1798 pip_mng->getDomainLhsFE()->exeTestHook = exe_test;
1799 pip_mng->getDomainRhsFE()->exeTestHook = [](
FEMethod *fe_ptr) {
1802 pip_mng->getBoundaryLhsFE()->exeTestHook = exe_test;
1803 pip_mng->getBoundaryRhsFE()->exeTestHook = [](
FEMethod *fe_ptr) {
1807 CHKERR set_domain_rhs(pip_mng->getCastDomainRhsFE());
1808 CHKERR set_domain_lhs(pip_mng->getCastDomainLhsFE());
1809 CHKERR set_bdy_rhs(pip_mng->getCastBoundaryRhsFE());
1810 CHKERR set_bdy_lhs(pip_mng->getCastBoundaryLhsFE());
1815 auto ksp = pip_mng->createKSP(subdm);
1816 CHKERR KSPSetFromOptions(ksp);
1820 auto get_norm = [&](
auto x) {
1822 CHKERR VecNorm(x, NORM_2, &nrm);
1829 auto zero_dofs = [](boost::shared_ptr<FieldEntity> ent_ptr) {
1831 for (
auto &
v : ent_ptr->getEntFieldData()) {
1837 auto solve = [&](
auto S) {
1839 CHKERR VecZeroEntries(S);
1841 CHKERR VecGhostUpdateBegin(
F, INSERT_VALUES, SCATTER_FORWARD);
1842 CHKERR VecGhostUpdateEnd(
F, INSERT_VALUES, SCATTER_FORWARD);
1844 CHKERR VecGhostUpdateBegin(S, INSERT_VALUES, SCATTER_FORWARD);
1845 CHKERR VecGhostUpdateEnd(S, INSERT_VALUES, SCATTER_FORWARD);
1852 MOFEM_LOG(
"FS", Sev::inform) <<
"Solve projection";
1857 auto dummy_dm = create_dummy_dm();
1862 auto apply_restrict = [&]() {
1863 auto get_is = [](
auto v) {
1865 auto create = [&]() {
1869 CHKERR VecGetOwnershipRange(
v, &ystart, NULL);
1870 CHKERR ISCreateStride(PETSC_COMM_SELF,
n, ystart, 1, &iy);
1877 auto iy = get_is(glob_x);
1881 DMSubDomainRestrict(
simple->getDM(), s, PETSC_NULLPTR, dummy_dm),
1887 DMGetNamedGlobalVector(dummy_dm,
"TSTheta_Xdot", &Xdot),
1890 auto forward_ghost = [](
auto g) {
1892 CHKERR VecGhostUpdateBegin(
g, INSERT_VALUES, SCATTER_FORWARD);
1893 CHKERR VecGhostUpdateEnd(
g, INSERT_VALUES, SCATTER_FORWARD);
1900 if constexpr (
debug) {
1902 <<
"Reverse restrict: X0 " << get_norm(X0) <<
" Xdot "
1906 return std::vector<Vec>{X0, Xdot};
1909 auto ts_solver_vecs = apply_restrict();
1911 if (ts_solver_vecs.size()) {
1913 for (
auto v : ts_solver_vecs) {
1914 MOFEM_LOG(
"FS", Sev::inform) <<
"Solve projection vector";
1920 for (
auto f : {
"U",
"P",
"H",
"G",
"L"}) {
1921 MOFEM_LOG(
"WORLD", Sev::verbose) <<
"Zero field " << f;
1922 CHKERR field_blas->fieldLambdaOnEntities(zero_dofs, f);
1930 MOFEM_LOG(
"FS", Sev::inform) <<
"Norm V " << get_norm(
v);
1933 CHKERR DMRestoreNamedGlobalVector(dummy_dm,
"TSTheta_X0",
1934 &ts_solver_vecs[0]);
1935 CHKERR DMRestoreNamedGlobalVector(dummy_dm,
"TSTheta_Xdot",
1936 &ts_solver_vecs[1]);
1939 for (
auto f : {
"U",
"P",
"H",
"G",
"L"}) {
1940 MOFEM_LOG(
"WORLD", Sev::verbose) <<
"Zero field " << f;
1941 CHKERR field_blas->fieldLambdaOnEntities(zero_dofs, f);
1950 auto post_proc = [&](
auto exe_test) {
1952 auto post_proc_fe = boost::make_shared<PostProcEleDomain>(
mField);
1953 auto &pip = post_proc_fe->getOpPtrVector();
1954 post_proc_fe->exeTestHook = exe_test;
1962 boost::shared_ptr<ForcesAndSourcesCore> fe_parent(
1965 fe_parent->getOpPtrVector(), {H1});
1973 auto u_ptr = boost::make_shared<MatrixDouble>();
1974 auto p_ptr = boost::make_shared<VectorDouble>();
1975 auto h_ptr = boost::make_shared<VectorDouble>();
1976 auto g_ptr = boost::make_shared<VectorDouble>();
1978 CHKERR add_parent_field_domain(post_proc_fe, UDO::OPCOL,
"U",
1981 CHKERR add_parent_field_domain(post_proc_fe, UDO::OPCOL,
"P",
1984 CHKERR add_parent_field_domain(post_proc_fe, UDO::OPCOL,
"H",
1987 CHKERR add_parent_field_domain(post_proc_fe, UDO::OPCOL,
"G",
1991 post_proc_fe->getOpPtrVector().push_back(
1993 new OpPPMap(post_proc_fe->getPostProcMesh(),
1994 post_proc_fe->getMapGaussPts(),
1996 {{
"P", p_ptr}, {
"H", h_ptr}, {
"G", g_ptr}},
2008 auto dm =
simple->getDM();
2010 CHKERR post_proc_fe->writeFile(
"out_projection.h5m");
2019 if constexpr (
debug) {
2025 fe_domain_lhs.swap(pip_mng->getDomainLhsFE());
2026 fe_domain_rhs.swap(pip_mng->getDomainRhsFE());
2027 fe_bdy_lhs.swap(pip_mng->getBoundaryLhsFE());
2028 fe_bdy_rhs.swap(pip_mng->getBoundaryRhsFE());
2041 auto add_parent_field_domain = [&](
auto fe,
auto op,
auto field) {
2046 boost::shared_ptr<ForcesAndSourcesCore> fe_parent(
2054 auto add_parent_field_bdy = [&](
auto fe,
auto op,
auto field) {
2059 boost::shared_ptr<ForcesAndSourcesCore> fe_parent(
2072 auto dot_u_ptr = boost::make_shared<MatrixDouble>();
2073 auto u_ptr = boost::make_shared<MatrixDouble>();
2074 auto grad_u_ptr = boost::make_shared<MatrixDouble>();
2075 auto dot_h_ptr = boost::make_shared<VectorDouble>();
2076 auto h_ptr = boost::make_shared<VectorDouble>();
2077 auto grad_h_ptr = boost::make_shared<MatrixDouble>();
2078 auto g_ptr = boost::make_shared<VectorDouble>();
2079 auto grad_g_ptr = boost::make_shared<MatrixDouble>();
2080 auto lambda_ptr = boost::make_shared<VectorDouble>();
2081 auto p_ptr = boost::make_shared<VectorDouble>();
2082 auto div_u_ptr = boost::make_shared<VectorDouble>();
2086 auto set_domain_general = [&](
auto fe) {
2088 auto &pip = fe->getOpPtrVector();
2096 boost::shared_ptr<ForcesAndSourcesCore> fe_parent(
2099 fe_parent->getOpPtrVector(), {H1});
2105 CHKERR add_parent_field_domain(fe, UDO::OPROW,
"U");
2106 CHKERR add_parent_field_domain(fe, UDO::OPCOL,
"U");
2126 "Coordinate system not implemented");
2129 CHKERR add_parent_field_domain(fe, UDO::OPCOL,
"H");
2135 CHKERR add_parent_field_domain(fe, UDO::OPCOL,
"G");
2140 CHKERR add_parent_field_domain(fe, UDO::OPCOL,
"P");
2145 auto set_domain_rhs = [&](
auto fe) {
2147 auto &pip = fe->getOpPtrVector();
2149 CHKERR set_domain_general(fe);
2151 CHKERR add_parent_field_domain(fe, UDO::OPROW,
"U");
2152 pip.push_back(
new OpRhsU(
"U", dot_u_ptr, u_ptr, grad_u_ptr, h_ptr,
2153 grad_h_ptr, g_ptr, p_ptr));
2155 CHKERR add_parent_field_domain(fe, UDO::OPROW,
"H");
2156 pip.push_back(
new OpRhsH<false>(
"H", u_ptr, dot_h_ptr, h_ptr, grad_h_ptr,
2159 CHKERR add_parent_field_domain(fe, UDO::OPROW,
"G");
2160 pip.push_back(
new OpRhsG<false>(
"G", h_ptr, grad_h_ptr, g_ptr));
2162 CHKERR add_parent_field_domain(fe, UDO::OPROW,
"P");
2164 "P", div_u_ptr, [](
const double r,
const double,
const double) {
2168 "P", p_ptr, [](
const double r,
const double,
const double) {
2174 auto set_domain_lhs = [&](
auto fe) {
2176 auto &pip = fe->getOpPtrVector();
2178 CHKERR set_domain_general(fe);
2180 CHKERR add_parent_field_domain(fe, UDO::OPROW,
"U");
2182 CHKERR add_parent_field_domain(fe, UDO::OPCOL,
"U");
2183 pip.push_back(
new OpLhsU_dU(
"U", u_ptr, grad_u_ptr, h_ptr));
2184 CHKERR add_parent_field_domain(fe, UDO::OPCOL,
"H");
2186 new OpLhsU_dH(
"U",
"H", dot_u_ptr, u_ptr, grad_u_ptr, h_ptr, g_ptr));
2188 CHKERR add_parent_field_domain(fe, UDO::OPCOL,
"G");
2189 pip.push_back(
new OpLhsU_dG(
"U",
"G", grad_h_ptr));
2192 CHKERR add_parent_field_domain(fe, UDO::OPROW,
"H");
2194 CHKERR add_parent_field_domain(fe, UDO::OPCOL,
"U");
2195 pip.push_back(
new OpLhsH_dU(
"H",
"U", grad_h_ptr));
2196 CHKERR add_parent_field_domain(fe, UDO::OPCOL,
"H");
2198 CHKERR add_parent_field_domain(fe, UDO::OPCOL,
"G");
2202 CHKERR add_parent_field_domain(fe, UDO::OPROW,
"G");
2204 CHKERR add_parent_field_domain(fe, UDO::OPCOL,
"H");
2206 CHKERR add_parent_field_domain(fe, UDO::OPCOL,
"G");
2210 CHKERR add_parent_field_domain(fe, UDO::OPROW,
"P");
2212 CHKERR add_parent_field_domain(fe, UDO::OPCOL,
"U");
2218 [](
const double r,
const double,
const double) {
2226 [](
const double r,
const double,
const double) {
2233 "Coordinate system not implemented");
2236 CHKERR add_parent_field_domain(fe, UDO::OPCOL,
"P");
2237 pip.push_back(
new OpDomainMassP(
"P",
"P", [](
double r,
double,
double) {
2245 auto get_block_name = [](
auto name) {
2246 return boost::format(
"%s(.*)") %
"WETTING_ANGLE";
2249 auto get_blocks = [&](
auto &&name) {
2251 std::regex(name.str()));
2254 auto set_boundary_rhs = [&](
auto fe) {
2256 auto &pip = fe->getOpPtrVector();
2262 boost::shared_ptr<ForcesAndSourcesCore> fe_parent(
2269 CHKERR add_parent_field_bdy(fe, UDO::OPCOL,
"U");
2272 CHKERR add_parent_field_bdy(fe, UDO::OPCOL,
"L");
2277 pip,
mField,
"L", {},
"INFLUX",
2280 CHKERR add_parent_field_bdy(fe, UDO::OPROW,
"U");
2283 auto wetting_block = get_blocks(get_block_name(
"WETTING_ANGLE"));
2284 if (wetting_block.size()) {
2291 op_bdy_side->getOpPtrVector(), {H1});
2294 op_bdy_side->getSideFEPtr(),
"", UDO::OPSPACE,
2298 boost::shared_ptr<ForcesAndSourcesCore> fe_parent(
2301 fe_parent->getOpPtrVector(), {H1});
2307 CHKERR add_parent_field_domain(op_bdy_side->getSideFEPtr(), UDO::OPCOL,
2309 op_bdy_side->getOpPtrVector().push_back(
2312 pip.push_back(op_bdy_side);
2315 for (
auto &b : wetting_block) {
2317 std::vector<double> attr_vec;
2318 CHKERR b->getMeshsetIdEntitiesByDimension(
2320 b->getAttributes(attr_vec);
2321 if (attr_vec.size() != 1)
2323 "Should be one attribute");
2324 MOFEM_LOG(
"FS", Sev::inform) <<
"Wetting angle: " << attr_vec.front();
2326 CHKERR add_parent_field_bdy(fe, UDO::OPROW,
"G");
2327 CHKERR add_parent_field_bdy(fe, UDO::OPCOL,
"G");
2329 "G", grad_h_ptr, boost::make_shared<Range>(force_edges),
2337 auto set_boundary_lhs = [&](
auto fe) {
2339 auto &pip = fe->getOpPtrVector();
2345 boost::shared_ptr<ForcesAndSourcesCore> fe_parent(
2352 CHKERR add_parent_field_bdy(fe, UDO::OPROW,
"L");
2353 CHKERR add_parent_field_bdy(fe, UDO::OPCOL,
"U");
2356 auto wetting_block = get_blocks(get_block_name(
"WETTING_ANGLE"));
2357 if (wetting_block.size()) {
2358 auto col_ind_ptr = boost::make_shared<std::vector<VectorInt>>();
2359 auto col_diff_base_ptr = boost::make_shared<std::vector<MatrixDouble>>();
2367 op_bdy_side->getOpPtrVector(), {H1});
2370 op_bdy_side->getSideFEPtr(),
"", UDO::OPSPACE,
2374 boost::shared_ptr<ForcesAndSourcesCore> fe_parent(
2377 fe_parent->getOpPtrVector(), {H1});
2383 CHKERR add_parent_field_domain(op_bdy_side->getSideFEPtr(), UDO::OPROW,
2385 CHKERR add_parent_field_domain(op_bdy_side->getSideFEPtr(), UDO::OPCOL,
2387 op_bdy_side->getOpPtrVector().push_back(
2389 op_bdy_side->getOpPtrVector().push_back(
2393 pip.push_back(op_bdy_side);
2396 for (
auto &b : wetting_block) {
2398 std::vector<double> attr_vec;
2399 CHKERR b->getMeshsetIdEntitiesByDimension(
2401 b->getAttributes(attr_vec);
2402 if (attr_vec.size() != 1)
2404 "Should be one attribute");
2406 <<
"wetting angle edges size " << force_edges.size();
2408 CHKERR add_parent_field_bdy(fe, UDO::OPROW,
"G");
2409 CHKERR add_parent_field_bdy(fe, UDO::OPCOL,
"G");
2411 "G", grad_h_ptr, col_ind_ptr, col_diff_base_ptr,
2412 boost::make_shared<Range>(force_edges), attr_vec.front()));
2421 CHKERR set_domain_rhs(pip_mng->getCastDomainRhsFE());
2422 CHKERR set_domain_lhs(pip_mng->getCastDomainLhsFE());
2423 CHKERR set_boundary_rhs(pip_mng->getCastBoundaryRhsFE());
2424 CHKERR set_boundary_lhs(pip_mng->getCastBoundaryLhsFE());
2448 boost::shared_ptr<PostProcEleDomainCont> post_proc,
2449 boost::shared_ptr<PostProcEleBdyCont> post_proc_edge,
2450 std::pair<boost::shared_ptr<BoundaryEle>, boost::shared_ptr<VectorDouble>>
2457 MOFEM_LOG(
"FS", Sev::verbose) <<
"Monitor";
2462 MOFEM_LOG(
"FS", Sev::verbose) <<
"Mesh pre proc";
2465 auto post_proc_begin =
2466 boost::make_shared<PostProcBrokenMeshInMoabBaseBegin>(*m_field_ptr,
2468 auto post_proc_end = boost::make_shared<PostProcBrokenMeshInMoabBaseEnd>(
2476 CHKERR post_proc_end->writeFile(
2477 "out_step_" + boost::lexical_cast<std::string>(
ts_step) +
".h5m");
2478 MOFEM_LOG(
"FS", Sev::verbose) <<
"Mesh pre proc done";
2484 MPI_Allreduce(MPI_IN_PLACE, &(*
liftVec)[0],
SPACE_DIM, MPI_DOUBLE, MPI_SUM,
2488 <<
" lift vec x: " << (*liftVec)[0] <<
" y: " << (*liftVec)[1];
2514 auto setup_subdm = [&](
auto dm) {
2518 auto dm =
simple->getDM();
2519 auto level_ents_ptr = boost::make_shared<Range>();
2520 CHKERR bit_mng->getEntitiesByRefLevel(
2523 CHKERR DMSetType(subdm,
"DMMOFEM");
2529 for (
auto f : {
"U",
"P",
"H",
"G",
"L"}) {
2542 auto get_fe_post_proc = [&](
auto post_proc_mesh) {
2543 auto add_parent_field_domain = [&](
auto fe,
auto op,
auto field) {
2548 boost::shared_ptr<ForcesAndSourcesCore> fe_parent(
2557 boost::make_shared<PostProcEleDomainCont>(
mField, post_proc_mesh);
2558 post_proc_fe->exeTestHook = [](
FEMethod *fe_ptr) {
2563 auto u_ptr = boost::make_shared<MatrixDouble>();
2564 auto grad_u_ptr = boost::make_shared<MatrixDouble>();
2565 auto h_ptr = boost::make_shared<VectorDouble>();
2566 auto grad_h_ptr = boost::make_shared<MatrixDouble>();
2567 auto p_ptr = boost::make_shared<VectorDouble>();
2568 auto g_ptr = boost::make_shared<VectorDouble>();
2569 auto grad_g_ptr = boost::make_shared<MatrixDouble>();
2572 post_proc_fe->getOpPtrVector(), {H1});
2578 boost::shared_ptr<ForcesAndSourcesCore> fe_parent(
2581 fe_parent->getOpPtrVector(), {H1});
2587 CHKERR add_parent_field_domain(post_proc_fe, UDO::OPCOL,
"U");
2588 post_proc_fe->getOpPtrVector().push_back(
2590 post_proc_fe->getOpPtrVector().push_back(
2594 CHKERR add_parent_field_domain(post_proc_fe, UDO::OPCOL,
"H");
2595 post_proc_fe->getOpPtrVector().push_back(
2597 post_proc_fe->getOpPtrVector().push_back(
2600 CHKERR add_parent_field_domain(post_proc_fe, UDO::OPCOL,
"P");
2601 post_proc_fe->getOpPtrVector().push_back(
2604 CHKERR add_parent_field_domain(post_proc_fe, UDO::OPCOL,
"G");
2605 post_proc_fe->getOpPtrVector().push_back(
2607 post_proc_fe->getOpPtrVector().push_back(
2612 post_proc_fe->getOpPtrVector().push_back(
2615 post_proc_fe->getPostProcMesh(), post_proc_fe->getMapGaussPts(),
2617 {{
"H", h_ptr}, {
"P", p_ptr}, {
"G", g_ptr}},
2619 {{
"U", u_ptr}, {
"H_GRAD", grad_h_ptr}, {
"G_GRAD", grad_g_ptr}},
2621 {{
"GRAD_U", grad_u_ptr}},
2629 return post_proc_fe;
2632 auto get_bdy_post_proc_fe = [&](
auto post_proc_mesh) {
2633 auto add_parent_field_bdy = [&](
auto fe,
auto op,
auto field) {
2634 return setParentDofs(
2638 boost::shared_ptr<ForcesAndSourcesCore> fe_parent(
2647 boost::make_shared<PostProcEleBdyCont>(mField, post_proc_mesh);
2648 post_proc_fe->exeTestHook = [](
FEMethod *fe_ptr) {
2657 boost::shared_ptr<ForcesAndSourcesCore> fe_parent(
2666 OpGetNormal(boost::shared_ptr<VectorDouble> l_ptr,
2667 boost::shared_ptr<MatrixDouble> n_ptr)
2675 auto t_n_fe = getFTensor1NormalsAtGaussPts();
2676 ptrNormal->resize(getGaussPts().size2(),
SPACE_DIM,
false);
2677 auto t_n = getFTensor1FromMat<SPACE_DIM>(*ptrNormal);
2678 for (
auto gg = 0; gg != getGaussPts().size2(); ++gg) {
2679 t_n(
i) = t_n_fe(
i) * t_l / std::sqrt(t_n_fe(
i) * t_n_fe(
i));
2688 boost::shared_ptr<VectorDouble> ptrL;
2689 boost::shared_ptr<MatrixDouble> ptrNormal;
2692 auto u_ptr = boost::make_shared<MatrixDouble>();
2693 auto p_ptr = boost::make_shared<VectorDouble>();
2694 auto lambda_ptr = boost::make_shared<VectorDouble>();
2695 auto normal_l_ptr = boost::make_shared<MatrixDouble>();
2697 CHKERR add_parent_field_bdy(post_proc_fe, UDO::OPCOL,
"U");
2698 post_proc_fe->getOpPtrVector().push_back(
2701 CHKERR add_parent_field_bdy(post_proc_fe, UDO::OPCOL,
"L");
2702 post_proc_fe->getOpPtrVector().push_back(
2704 post_proc_fe->getOpPtrVector().push_back(
2705 new OpGetNormal(lambda_ptr, normal_l_ptr));
2707 CHKERR add_parent_field_bdy(post_proc_fe, UDO::OPCOL,
"P");
2708 post_proc_fe->getOpPtrVector().push_back(
2712 op_ptr->doWorkRhsHook = [&](
DataOperator *base_op_ptr,
int side,
2721 post_proc_fe->getOpPtrVector().push_back(
2723 new OpPPMap(post_proc_fe->getPostProcMesh(),
2724 post_proc_fe->getMapGaussPts(),
2738 return post_proc_fe;
2741 auto get_lift_fe = [&]() {
2742 auto add_parent_field_bdy = [&](
auto fe,
auto op,
auto field) {
2743 return setParentDofs(
2747 boost::shared_ptr<ForcesAndSourcesCore> fe_parent(
2755 auto fe = boost::make_shared<BoundaryEle>(mField);
2756 fe->exeTestHook = [](
FEMethod *fe_ptr) {
2761 auto lift_ptr = boost::make_shared<VectorDouble>();
2762 auto p_ptr = boost::make_shared<VectorDouble>();
2763 auto ents_ptr = boost::make_shared<Range>();
2769 boost::shared_ptr<ForcesAndSourcesCore> fe_parent(
2776 std::vector<const CubitMeshSets *> vec_ptr;
2778 std::regex(
"LIFT"), vec_ptr);
2779 for (
auto m_ptr : vec_ptr) {
2784 ents_ptr->merge(ents);
2787 MOFEM_LOG(
"FS", Sev::noisy) <<
"Lift ents " << (*ents_ptr);
2788 CHKERR add_parent_field_bdy(fe, UDO::OPROW,
"L");
2789 CHKERR add_parent_field_bdy(fe, UDO::OPCOL,
"L");
2790 fe->getOpPtrVector().push_back(
2792 fe->getOpPtrVector().push_back(
2795 return std::make_pair(fe, lift_ptr);
2798 auto set_post_proc_monitor = [&](
auto ts) {
2802 boost::shared_ptr<FEMethod> null_fe;
2803 auto post_proc_mesh = boost::make_shared<moab::Core>();
2804 auto monitor_ptr = boost::make_shared<Monitor>(
2806 get_fe_post_proc(post_proc_mesh), get_bdy_post_proc_fe(post_proc_mesh),
2809 null_fe, monitor_ptr);
2813 auto dm =
simple->getDM();
2817 auto ts_pre_post_proc = boost::make_shared<TSPrePostProc>();
2822 ptr->fsRawPtr =
this;
2823 ptr->solverSubDM = create_solver_dm(
simple->getDM());
2827 CHKERR VecAssemblyBegin(ptr->globSol);
2828 CHKERR VecAssemblyEnd(ptr->globSol);
2830 auto sub_ts = pip_mng->createTSIM(ptr->solverSubDM);
2832 CHKERR set_post_proc_monitor(sub_ts);
2835 CHKERR TSSetFromOptions(ts);
2839 auto print_fields_in_section = [&]() {
2842 simple->getProblemName());
2843 PetscInt num_fields;
2844 CHKERR PetscSectionGetNumFields(section, &num_fields);
2845 for (
int f = 0;
f < num_fields; ++
f) {
2849 <<
"Field " <<
f <<
" " << std::string(
field_name);
2854 CHKERR print_fields_in_section();
2856 CHKERR TSSolve(ts, ptr->globSol);
2881#ifdef PYTHON_INIT_SURFACE
2886 const char param_file[] =
"param_file.petsc";
2890 auto core_log = logging::core::get();
2898 DMType dm_name =
"DMMOFEM";
2903 moab::Core mb_instance;
2904 moab::Interface &moab = mb_instance;
2921#ifdef PYTHON_INIT_SURFACE
2922 if (Py_FinalizeEx() < 0) {
2938 "can not get vertices on bit 0");
2943 Range plus_range, minus_range;
2944 std::vector<EntityHandle> plus, minus;
2947 for (
auto p = vertices.pair_begin(); p != vertices.pair_end(); ++p) {
2949 const auto f = p->first;
2950 const auto s = p->second;
2955 auto it = dofs_mi.lower_bound(lo_uid);
2956 const auto hi_it = dofs_mi.upper_bound(hi_uid);
2960 plus.reserve(std::distance(it, hi_it));
2961 minus.reserve(std::distance(it, hi_it));
2963 for (; it != hi_it; ++it) {
2964 const auto v = (*it)->getFieldData();
2966 plus.push_back((*it)->getEnt());
2968 minus.push_back((*it)->getEnt());
2971 plus_range.insert_list(plus.begin(), plus.end());
2972 minus_range.insert_list(minus.begin(), minus.end());
2977 <<
"Plus range " << plus_range << endl;
2979 <<
"Minus range " << minus_range << endl;
2982 auto get_elems = [&](
auto &ents,
auto bit,
auto mask) {
2985 moab::Interface::UNION),
2986 "can not get adjacencies");
2988 "can not filter elements with bit 0");
2992 CHKERR comm_mng->synchroniseEntities(plus_range);
2993 CHKERR comm_mng->synchroniseEntities(minus_range);
2996 ele_plus[0] = get_elems(plus_range,
bit(0),
BitRefLevel().set());
2997 ele_minus[0] = get_elems(minus_range,
bit(0),
BitRefLevel().set());
2998 auto common = intersect(ele_plus[0], ele_minus[0]);
2999 ele_plus[0] = subtract(ele_plus[0], common);
3000 ele_minus[0] = subtract(ele_minus[0], common);
3002 auto get_children = [&](
auto &p,
auto &
c) {
3004 CHKERR bit_mng->updateRangeByChildren(p,
c);
3016 auto get_level = [&](
auto &p,
auto &
m,
auto z,
auto bit,
auto mask) {
3019 bit_mng->getEntitiesByDimAndRefLevel(
bit, mask,
SPACE_DIM,
l),
3020 "can not get vertices on bit");
3023 for (
auto f = 0; f != z; ++f) {
3027 l = get_elems(conn,
bit, mask);
3032 std::vector<Range> vec_levels(
nb_levels);
3034 vec_levels[
l] = get_level(ele_plus[
l], ele_minus[
l], 2 * overlap,
bit(
l),
3038 if constexpr (
debug) {
3041 std::string name = (boost::format(
"out_r%d.h5m") %
l).str();
3058 start_mask[s] =
true;
3064 Range prev_level_skin;
3068 CHKERR bit_mng->lambdaBitRefLevel(
3075 auto set_levels = [&](
auto &&
3085 auto get_adj = [&](
auto ents) {
3091 ents.subset_by_dimension(
SPACE_DIM), d,
false, conn,
3092 moab::Interface::UNION),
3106 CHKERR bit_mng->updateRangeByParent(vec_levels[
l], parents);
3109 level_prev = subtract(level_prev, parents);
3111 level_prev.merge(vec_levels[
l]);
3119 CHKERR bit_mng->getEntitiesByDimAndRefLevel(
3121 level = get_adj(level);
3130 auto set_skins = [&]() {
3134 ParallelComm *pcomm =
3143 "can't get bit level");
3150 auto get_level_skin = [&]() {
3156 CHKERR pcomm->filter_pstatus(skin_level_mesh,
3157 PSTATUS_SHARED | PSTATUS_MULTISHARED,
3158 PSTATUS_NOT, -1,
nullptr);
3161 skin_level = subtract(skin_level,
3165 Range skin_level_verts;
3168 skin_level.merge(skin_level_verts);
3171 bit_prev.set(
l - 1);
3175 skin.merge(subtract(skin_level, level_prev));
3181 auto resolve_shared = [&](
auto &&skin) {
3182 Range tmp_skin = skin;
3184 map<int, Range> map_procs;
3186 tmp_skin, &map_procs);
3188 Range from_other_procs;
3189 for (
auto &
m : map_procs) {
3191 from_other_procs.merge(
m.second);
3195 auto common = intersect(
3196 skin, from_other_procs);
3197 skin.merge(from_other_procs);
3201 if (!common.empty()) {
3203 skin = subtract(skin, common);
3210 auto get_parent_level_skin = [&](
auto skin) {
3212 CHKERR bit_mng->updateRangeByParent(
3213 skin.subset_by_dimension(
SPACE_DIM - 1), skin_parents);
3214 Range skin_parent_verts;
3217 skin_parents.merge(skin_parent_verts);
3220 return skin_parents;
3223 auto child_skin = resolve_shared(get_level_skin());
3224 auto parent_skin = get_parent_level_skin(child_skin);
3226 child_skin = subtract(child_skin, parent_skin);
3234 auto set_current = [&]() {
3243 last_level = subtract(last_level, skin_child);
3255 if constexpr (
debug) {
3258 std::string name = (boost::format(
"out_level%d.h5m") %
l).str();
3261 "PARALLEL=WRITE_PART");
3265 "MOAB",
"PARALLEL=WRITE_PART");
3268 "MOAB",
"PARALLEL=WRITE_PART");
3272 "MOAB",
"PARALLEL=WRITE_PART");
3275 "MOAB",
"PARALLEL=WRITE_PART");
3283 boost::shared_ptr<FEMethod> fe_top, std::string
field_name,
3286 boost::function<boost::shared_ptr<ForcesAndSourcesCore>()> get_elem,
3293 boost::function<void(boost::shared_ptr<ForcesAndSourcesCore>,
int)>
3295 [&](boost::shared_ptr<ForcesAndSourcesCore> parent_fe_pt,
int level) {
3300 auto fe_ptr_current = get_elem();
3304 boost::dynamic_pointer_cast<ForcesAndSourcesCore>(
3312 parent_fe_pt->getOpPtrVector().push_back(
3316 H1, op, fe_ptr_current,
3327 parent_fe_pt->getOpPtrVector().push_back(
3342 add_parent_level(boost::dynamic_pointer_cast<ForcesAndSourcesCore>(fe_top),
3357 auto cut_off_dofs = [&]() {
3360 auto &m_field = ptr->fsRawPtr->mField;
3362 Range current_verts;
3367 auto cut_off_verts = [&](boost::shared_ptr<FieldEntity> ent_ptr) {
3369 for (
auto &
h : ent_ptr->getEntFieldData()) {
3375 auto field_blas = m_field.getInterface<
FieldBlas>();
3385 MOFEM_LOG(
"FS", Sev::inform) <<
"Run step pre proc";
3387 auto &m_field = ptr->fsRawPtr->mField;
3391 auto get_norm = [&](
auto x) {
3393 CHKERR VecNorm(x, NORM_2, &nrm);
3398 auto refine_problem = [&]() {
3400 MOFEM_LOG(
"FS", Sev::inform) <<
"Refine problem";
3402 CHKERR ptr->fsRawPtr->projectData();
3408 auto set_jacobian_operators = [&]() {
3411 CHKERR KSPReset(ptr->subKSP);
3416 auto set_solution = [&]() {
3418 MOFEM_LOG(
"FS", Sev::inform) <<
"Set solution";
3420 PetscObjectState state;
3431 INSERT_VALUES, SCATTER_FORWARD);
3434 <<
"Set solution, vector norm " << get_norm(ptr->globSol);
3439 PetscObjectTypeCompare((PetscObject)ts, TSTHETA, &is_theta);
3443 CHKERR set_jacobian_operators();
3448 "Sorry, only TSTheta handling is implemented");
3453 PetscBarrier((PetscObject)ts);
3465 auto &m_field = ptr->fsRawPtr->mField;
3477 auto sub_u = ptr->getSubVector();
3480 auto scatter = ptr->getScatter(sub_u, u,
R);
3482 auto apply_scatter_and_update = [&](
auto x,
auto sub_x) {
3484 CHKERR VecScatterBegin(scatter, x, sub_x, INSERT_VALUES, SCATTER_REVERSE);
3485 CHKERR VecScatterEnd(scatter, x, sub_x, INSERT_VALUES, SCATTER_REVERSE);
3486 CHKERR VecGhostUpdateBegin(sub_x, INSERT_VALUES, SCATTER_FORWARD);
3487 CHKERR VecGhostUpdateEnd(sub_x, INSERT_VALUES, SCATTER_FORWARD);
3491 CHKERR apply_scatter_and_update(u, sub_u);
3492 CHKERR apply_scatter_and_update(u_t, sub_u_t);
3495 CHKERR VecScatterBegin(scatter, sub_f,
f, INSERT_VALUES, SCATTER_FORWARD);
3496 CHKERR VecScatterEnd(scatter, sub_f,
f, INSERT_VALUES, SCATTER_FORWARD);
3502 PetscReal
a, Mat
A, Mat
B,
3506 auto sub_u = ptr->getSubVector();
3508 auto scatter = ptr->getScatter(sub_u, u,
R);
3510 auto apply_scatter_and_update = [&](
auto x,
auto sub_x) {
3512 CHKERR VecScatterBegin(scatter, x, sub_x, INSERT_VALUES, SCATTER_REVERSE);
3513 CHKERR VecScatterEnd(scatter, x, sub_x, INSERT_VALUES, SCATTER_REVERSE);
3514 CHKERR VecGhostUpdateBegin(sub_x, INSERT_VALUES, SCATTER_FORWARD);
3515 CHKERR VecGhostUpdateEnd(sub_x, INSERT_VALUES, SCATTER_FORWARD);
3519 CHKERR apply_scatter_and_update(u, sub_u);
3520 CHKERR apply_scatter_and_update(u_t, sub_u_t);
3523 ptr->tsCtxPtr.get());
3532 auto get_norm = [&](
auto x) {
3534 CHKERR VecNorm(x, NORM_2, &nrm);
3538 auto sub_u = ptr->getSubVector();
3539 auto scatter = ptr->getScatter(sub_u, u,
R);
3540 CHKERR VecScatterBegin(scatter, u, sub_u, INSERT_VALUES, SCATTER_REVERSE);
3541 CHKERR VecScatterEnd(scatter, u, sub_u, INSERT_VALUES, SCATTER_REVERSE);
3542 CHKERR VecGhostUpdateBegin(sub_u, INSERT_VALUES, SCATTER_FORWARD);
3543 CHKERR VecGhostUpdateEnd(sub_u, INSERT_VALUES, SCATTER_FORWARD);
3546 <<
"u norm " << get_norm(u) <<
" u sub nom " << get_norm(sub_u);
3556 MOFEM_LOG(
"FS", Sev::verbose) <<
"SetUP sub PC";
3557 ptr->subKSP =
createKSP(ptr->fsRawPtr->mField.get_comm());
3558 CHKERR KSPSetFromOptions(ptr->subKSP);
3566 auto sub_x = ptr->getSubVector();
3568 auto scatter = ptr->getScatter(sub_x, pc_x,
R);
3569 CHKERR VecScatterBegin(scatter, pc_f, sub_f, INSERT_VALUES,
3571 CHKERR VecScatterEnd(scatter, pc_f, sub_f, INSERT_VALUES, SCATTER_REVERSE);
3572 CHKERR KSPSetOperators(ptr->subKSP, ptr->subB, ptr->subB);
3573 MOFEM_LOG(
"FS", Sev::verbose) <<
"PCShell solve";
3574 CHKERR KSPSolve(ptr->subKSP, sub_f, sub_x);
3575 MOFEM_LOG(
"FS", Sev::verbose) <<
"PCShell solve <- done";
3576 CHKERR VecScatterBegin(scatter, sub_x, pc_x, INSERT_VALUES,
3578 CHKERR VecScatterEnd(scatter, sub_x, pc_x, INSERT_VALUES, SCATTER_FORWARD);
3585 auto prb_ptr = ptr->fsRawPtr->mField.get_problem(
"SUB_SOLVER");
3586 if (
auto sub_data = prb_ptr->getSubData()) {
3587 auto is = sub_data->getSmartColIs();
3622 CHKERR TSGetSNES(ts, &snes);
3625 auto set_section_monitor = [&](
auto snes) {
3627 CHKERR SNESMonitorSet(snes,
3630 (
void *)(snes_ctx_ptr.get()),
nullptr);
3634 CHKERR set_section_monitor(snes);
3636 auto ksp =
createKSP(m_field.get_comm());
3637 CHKERR KSPSetType(ksp, KSPPREONLY);
3639 CHKERR PCSetType(sub_pc, PCSHELL);
3642 CHKERR KSPSetPC(ksp, sub_pc);
3643 CHKERR SNESSetKSP(snes, ksp);
3657 PetscInt test_nb = 0;
3658 PetscBool test_flg = PETSC_FALSE;
3659 double regression_value = 0.0;
3669 CHKERR VecNorm(T, NORM_2, &nrm2);
3670 MOFEM_LOG(
"FS", Sev::verbose) <<
"Regression norm " << nrm2;
3678 if (fabs(nrm2 - regression_value) > 1e-2)
3680 "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₃
OpDomainMassH OpDomainMassP
FormsIntegrators< DomainEleOp >::Assembly< A >::LinearForm< I >::OpBaseTimesVector< BASE_DIM, SPACE_DIM, SPACE_DIM > OpDomainAssembleVector
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)
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.
static auto getFTensor0FromVec(V &data)
Get tensor rank 0 (scalar) form data vector.
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 MatrixDouble 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, ScalarDataPtr > DataMapVec
std::map< std::string, boost::shared_ptr< MatrixDouble > > DataMapMat
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