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);
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 snes,
"free surface initial condition");
1362 CHKERR VecGhostUpdateBegin(
D, INSERT_VALUES, SCATTER_FORWARD);
1363 CHKERR VecGhostUpdateEnd(
D, INSERT_VALUES, SCATTER_FORWARD);
1374 for (
auto f : {
"U",
"P",
"H",
"G",
"L"}) {
1385 pip_mng->getOpDomainRhsPipeline().clear();
1386 pip_mng->getOpDomainLhsPipeline().clear();
1389 CHKERR bc_mng->removeBlockDOFsOnEntities(
simple->getProblemName(),
"SYM_X",
1391 CHKERR bc_mng->removeBlockDOFsOnEntities(
simple->getProblemName(),
"SYM_X",
1393 CHKERR bc_mng->removeBlockDOFsOnEntities(
simple->getProblemName(),
"SYM_Y",
1395 CHKERR bc_mng->removeBlockDOFsOnEntities(
simple->getProblemName(),
"SYM_Y",
1397 CHKERR bc_mng->removeBlockDOFsOnEntities(
simple->getProblemName(),
"FIX",
"U",
1399 CHKERR bc_mng->removeBlockDOFsOnEntities(
simple->getProblemName(),
"FIX",
"L",
1401 CHKERR bc_mng->removeBlockDOFsOnEntities(
simple->getProblemName(),
"ZERO",
1423 auto fe_domain_lhs = pip_mng->getDomainLhsFE();
1424 auto fe_domain_rhs = pip_mng->getDomainRhsFE();
1425 auto fe_bdy_lhs = pip_mng->getBoundaryLhsFE();
1426 auto fe_bdy_rhs = pip_mng->getBoundaryRhsFE();
1428 pip_mng->getDomainLhsFE().reset();
1429 pip_mng->getDomainRhsFE().reset();
1430 pip_mng->getBoundaryLhsFE().reset();
1431 pip_mng->getBoundaryRhsFE().reset();
1436 auto add_parent_field_domain = [&](
auto fe,
auto op,
auto field,
auto bit) {
1441 boost::shared_ptr<ForcesAndSourcesCore> fe_parent(
1450 auto add_parent_field_bdy = [&](
auto fe,
auto op,
auto field,
auto bit) {
1455 boost::shared_ptr<ForcesAndSourcesCore> fe_parent(
1465 auto create_run_parent_op = [&](
auto parent_fe_ptr,
auto this_fe_ptr,
1467 auto parent_mask = fe_bit;
1475 auto get_parents_vel_fe_ptr = [&](
auto this_fe_ptr,
auto fe_bit) {
1476 std::vector<boost::shared_ptr<DomainParentEle>> parents_elems_ptr_vec;
1478 parents_elems_ptr_vec.emplace_back(
1479 boost::make_shared<DomainParentEle>(
mField));
1481 parents_elems_ptr_vec[
l - 1]->getOpPtrVector().push_back(
1482 create_run_parent_op(parents_elems_ptr_vec[
l], this_fe_ptr, fe_bit));
1484 return parents_elems_ptr_vec[0];
1488 auto solve_projection = [&](
auto exe_test) {
1491 auto set_domain_rhs = [&](
auto fe) {
1493 auto &pip = fe->getOpPtrVector();
1495 auto u_ptr = boost::make_shared<MatrixDouble>();
1496 auto p_ptr = boost::make_shared<VectorDouble>();
1497 auto h_ptr = boost::make_shared<VectorDouble>();
1498 auto g_ptr = boost::make_shared<VectorDouble>();
1500 auto eval_fe_ptr = boost::make_shared<DomainParentEle>(
mField);
1502 auto &pip = eval_fe_ptr->getOpPtrVector();
1508 boost::shared_ptr<ForcesAndSourcesCore> fe_parent(
1516 CHKERR add_parent_field_domain(eval_fe_ptr, UDO::OPCOL,
"U",
1519 CHKERR add_parent_field_domain(eval_fe_ptr, UDO::OPCOL,
"P",
1522 CHKERR add_parent_field_domain(eval_fe_ptr, UDO::OPCOL,
"H",
1525 CHKERR add_parent_field_domain(eval_fe_ptr, UDO::OPCOL,
"G",
1529 auto parent_eval_fe_ptr =
1531 pip.push_back(create_run_parent_op(parent_eval_fe_ptr, eval_fe_ptr,
1534 auto assemble_fe_ptr = boost::make_shared<DomainParentEle>(
mField);
1536 auto &pip = assemble_fe_ptr->getOpPtrVector();
1542 boost::shared_ptr<ForcesAndSourcesCore> fe_parent(
1548 CHKERR add_parent_field_domain(assemble_fe_ptr, UDO::OPROW,
"U",
1551 CHKERR add_parent_field_domain(assemble_fe_ptr, UDO::OPROW,
"P",
1554 CHKERR add_parent_field_domain(assemble_fe_ptr, UDO::OPROW,
"H",
1557 CHKERR add_parent_field_domain(assemble_fe_ptr, UDO::OPROW,
"G",
1561 auto parent_assemble_fe_ptr =
1563 pip.push_back(create_run_parent_op(
1569 auto set_domain_lhs = [&](
auto fe) {
1572 auto &pip = fe->getOpPtrVector();
1580 boost::shared_ptr<ForcesAndSourcesCore> fe_parent(
1589 CHKERR add_parent_field_domain(fe, UDO::OPROW,
"U",
1591 CHKERR add_parent_field_domain(fe, UDO::OPCOL,
"U",
1594 CHKERR add_parent_field_domain(fe, UDO::OPROW,
"P",
1596 CHKERR add_parent_field_domain(fe, UDO::OPCOL,
"P",
1599 CHKERR add_parent_field_domain(fe, UDO::OPROW,
"H",
1601 CHKERR add_parent_field_domain(fe, UDO::OPCOL,
"H",
1604 CHKERR add_parent_field_domain(fe, UDO::OPROW,
"G",
1606 CHKERR add_parent_field_domain(fe, UDO::OPCOL,
"G",
1613 auto set_bdy_rhs = [&](
auto fe) {
1615 auto &pip = fe->getOpPtrVector();
1617 auto l_ptr = boost::make_shared<VectorDouble>();
1619 auto eval_fe_ptr = boost::make_shared<BoundaryParentEle>(
mField);
1621 auto &pip = eval_fe_ptr->getOpPtrVector();
1626 boost::shared_ptr<ForcesAndSourcesCore> fe_parent(
1634 CHKERR add_parent_field_bdy(eval_fe_ptr, UDO::OPCOL,
"L",
1638 auto parent_eval_fe_ptr =
1640 pip.push_back(create_run_parent_op(parent_eval_fe_ptr, eval_fe_ptr,
1643 auto assemble_fe_ptr = boost::make_shared<BoundaryParentEle>(
mField);
1645 auto &pip = assemble_fe_ptr->getOpPtrVector();
1650 boost::shared_ptr<ForcesAndSourcesCore> fe_parent(
1658 OpLSize(boost::shared_ptr<VectorDouble> l_ptr)
1662 if (lPtr->size() != getGaussPts().size2()) {
1663 lPtr->resize(getGaussPts().size2());
1670 boost::shared_ptr<VectorDouble> lPtr;
1673 pip.push_back(
new OpLSize(l_ptr));
1675 CHKERR add_parent_field_bdy(assemble_fe_ptr, UDO::OPROW,
"L",
1679 auto parent_assemble_fe_ptr =
1681 pip.push_back(create_run_parent_op(
1687 auto set_bdy_lhs = [&](
auto fe) {
1690 auto &pip = fe->getOpPtrVector();
1696 boost::shared_ptr<ForcesAndSourcesCore> fe_parent(
1705 CHKERR add_parent_field_bdy(fe, UDO::OPROW,
"L",
1707 CHKERR add_parent_field_bdy(fe, UDO::OPCOL,
"L",
1715 auto level_ents_ptr = boost::make_shared<Range>();
1719 auto get_prj_ents = [&]() {
1724 auto common_ents = intersect(prj_mesh, *level_ents_ptr);
1725 prj_mesh = subtract(unite(*level_ents_ptr, prj_mesh), common_ents)
1731 auto prj_ents = get_prj_ents();
1735 auto rebuild = [&]() {
1739 std::vector<std::string> fields{
"U",
"P",
"H",
"G",
"L"};
1740 std::map<std::string, boost::shared_ptr<Range>> range_maps{
1742 {
"U", level_ents_ptr},
1743 {
"P", level_ents_ptr},
1744 {
"H", level_ents_ptr},
1745 {
"G", level_ents_ptr},
1746 {
"L", level_ents_ptr}
1751 simple->getProblemName(), PETSC_TRUE,
1752 &range_maps, &range_maps);
1755 CHKERR prb_mng->partitionFiniteElements(
"SUB_SOLVER",
true, 0,
1758 CHKERR prb_mng->partitionGhostDofsOnDistributedMesh(
"SUB_SOLVER");
1763 MOFEM_LOG(
"FS", Sev::verbose) <<
"Create projection problem";
1767 auto dm =
simple->getDM();
1770 CHKERR DMSetType(subdm,
"DMMOFEM");
1775 MOFEM_LOG(
"FS", Sev::inform) <<
"Nothing to project";
1780 auto create_dummy_dm = [&]() {
1783 simple->getProblemName().c_str(),
1789 auto subdm = create_subdm();
1792 pip_mng->getDomainRhsFE().reset();
1793 pip_mng->getDomainLhsFE().reset();
1794 pip_mng->getBoundaryRhsFE().reset();
1795 pip_mng->getBoundaryLhsFE().reset();
1800 pip_mng->getDomainLhsFE()->exeTestHook = exe_test;
1801 pip_mng->getDomainRhsFE()->exeTestHook = [](
FEMethod *fe_ptr) {
1804 pip_mng->getBoundaryLhsFE()->exeTestHook = exe_test;
1805 pip_mng->getBoundaryRhsFE()->exeTestHook = [](
FEMethod *fe_ptr) {
1809 CHKERR set_domain_rhs(pip_mng->getCastDomainRhsFE());
1810 CHKERR set_domain_lhs(pip_mng->getCastDomainLhsFE());
1811 CHKERR set_bdy_rhs(pip_mng->getCastBoundaryRhsFE());
1812 CHKERR set_bdy_lhs(pip_mng->getCastBoundaryLhsFE());
1817 auto ksp = pip_mng->createKSP(subdm);
1822 auto get_norm = [&](
auto x) {
1824 CHKERR VecNorm(x, NORM_2, &nrm);
1831 auto zero_dofs = [](boost::shared_ptr<FieldEntity> ent_ptr) {
1833 for (
auto &
v : ent_ptr->getEntFieldData()) {
1839 auto solve = [&](
auto S) {
1841 CHKERR VecZeroEntries(S);
1843 CHKERR VecGhostUpdateBegin(
F, INSERT_VALUES, SCATTER_FORWARD);
1844 CHKERR VecGhostUpdateEnd(
F, INSERT_VALUES, SCATTER_FORWARD);
1847 ksp,
"free surface projection");
1848 CHKERR VecGhostUpdateBegin(S, INSERT_VALUES, SCATTER_FORWARD);
1849 CHKERR VecGhostUpdateEnd(S, INSERT_VALUES, SCATTER_FORWARD);
1856 MOFEM_LOG(
"FS", Sev::inform) <<
"Solve projection";
1861 auto dummy_dm = create_dummy_dm();
1866 auto apply_restrict = [&]() {
1867 auto get_is = [](
auto v) {
1869 auto create = [&]() {
1873 CHKERR VecGetOwnershipRange(
v, &ystart, NULL);
1874 CHKERR ISCreateStride(PETSC_COMM_SELF,
n, ystart, 1, &iy);
1881 auto iy = get_is(glob_x);
1885 DMSubDomainRestrict(
simple->getDM(), s, PETSC_NULLPTR, dummy_dm),
1891 DMGetNamedGlobalVector(dummy_dm,
"TSTheta_Xdot", &Xdot),
1894 auto forward_ghost = [](
auto g) {
1896 CHKERR VecGhostUpdateBegin(
g, INSERT_VALUES, SCATTER_FORWARD);
1897 CHKERR VecGhostUpdateEnd(
g, INSERT_VALUES, SCATTER_FORWARD);
1904 if constexpr (
debug) {
1906 <<
"Reverse restrict: X0 " << get_norm(X0) <<
" Xdot "
1910 return std::vector<Vec>{X0, Xdot};
1913 auto ts_solver_vecs = apply_restrict();
1915 if (ts_solver_vecs.size()) {
1917 for (
auto v : ts_solver_vecs) {
1918 MOFEM_LOG(
"FS", Sev::inform) <<
"Solve projection vector";
1924 for (
auto f : {
"U",
"P",
"H",
"G",
"L"}) {
1925 MOFEM_LOG(
"WORLD", Sev::verbose) <<
"Zero field " << f;
1926 CHKERR field_blas->fieldLambdaOnEntities(zero_dofs, f);
1934 MOFEM_LOG(
"FS", Sev::inform) <<
"Norm V " << get_norm(
v);
1937 CHKERR DMRestoreNamedGlobalVector(dummy_dm,
"TSTheta_X0",
1938 &ts_solver_vecs[0]);
1939 CHKERR DMRestoreNamedGlobalVector(dummy_dm,
"TSTheta_Xdot",
1940 &ts_solver_vecs[1]);
1943 for (
auto f : {
"U",
"P",
"H",
"G",
"L"}) {
1944 MOFEM_LOG(
"WORLD", Sev::verbose) <<
"Zero field " << f;
1945 CHKERR field_blas->fieldLambdaOnEntities(zero_dofs, f);
1954 auto post_proc = [&](
auto exe_test) {
1956 auto post_proc_fe = boost::make_shared<PostProcEleDomain>(
mField);
1957 auto &pip = post_proc_fe->getOpPtrVector();
1958 post_proc_fe->exeTestHook = exe_test;
1966 boost::shared_ptr<ForcesAndSourcesCore> fe_parent(
1969 fe_parent->getOpPtrVector(), {H1});
1977 auto u_ptr = boost::make_shared<MatrixDouble>();
1978 auto p_ptr = boost::make_shared<VectorDouble>();
1979 auto h_ptr = boost::make_shared<VectorDouble>();
1980 auto g_ptr = boost::make_shared<VectorDouble>();
1982 CHKERR add_parent_field_domain(post_proc_fe, UDO::OPCOL,
"U",
1985 CHKERR add_parent_field_domain(post_proc_fe, UDO::OPCOL,
"P",
1988 CHKERR add_parent_field_domain(post_proc_fe, UDO::OPCOL,
"H",
1991 CHKERR add_parent_field_domain(post_proc_fe, UDO::OPCOL,
"G",
1995 post_proc_fe->getOpPtrVector().push_back(
1997 new OpPPMap(post_proc_fe->getPostProcMesh(),
1998 post_proc_fe->getMapGaussPts(),
2000 {{
"P", p_ptr}, {
"H", h_ptr}, {
"G", g_ptr}},
2012 auto dm =
simple->getDM();
2014 CHKERR post_proc_fe->writeFile(
"out_projection.h5m");
2023 if constexpr (
debug) {
2029 fe_domain_lhs.swap(pip_mng->getDomainLhsFE());
2030 fe_domain_rhs.swap(pip_mng->getDomainRhsFE());
2031 fe_bdy_lhs.swap(pip_mng->getBoundaryLhsFE());
2032 fe_bdy_rhs.swap(pip_mng->getBoundaryRhsFE());
2045 auto add_parent_field_domain = [&](
auto fe,
auto op,
auto field) {
2050 boost::shared_ptr<ForcesAndSourcesCore> fe_parent(
2058 auto add_parent_field_bdy = [&](
auto fe,
auto op,
auto field) {
2063 boost::shared_ptr<ForcesAndSourcesCore> fe_parent(
2076 auto dot_u_ptr = boost::make_shared<MatrixDouble>();
2077 auto u_ptr = boost::make_shared<MatrixDouble>();
2078 auto grad_u_ptr = boost::make_shared<MatrixDouble>();
2079 auto dot_h_ptr = boost::make_shared<VectorDouble>();
2080 auto h_ptr = boost::make_shared<VectorDouble>();
2081 auto grad_h_ptr = boost::make_shared<MatrixDouble>();
2082 auto g_ptr = boost::make_shared<VectorDouble>();
2083 auto grad_g_ptr = boost::make_shared<MatrixDouble>();
2084 auto lambda_ptr = boost::make_shared<VectorDouble>();
2085 auto p_ptr = boost::make_shared<VectorDouble>();
2086 auto div_u_ptr = boost::make_shared<VectorDouble>();
2090 auto set_domain_general = [&](
auto fe) {
2092 auto &pip = fe->getOpPtrVector();
2100 boost::shared_ptr<ForcesAndSourcesCore> fe_parent(
2103 fe_parent->getOpPtrVector(), {H1});
2109 CHKERR add_parent_field_domain(fe, UDO::OPROW,
"U");
2110 CHKERR add_parent_field_domain(fe, UDO::OPCOL,
"U");
2130 "Coordinate system not implemented");
2133 CHKERR add_parent_field_domain(fe, UDO::OPCOL,
"H");
2139 CHKERR add_parent_field_domain(fe, UDO::OPCOL,
"G");
2144 CHKERR add_parent_field_domain(fe, UDO::OPCOL,
"P");
2149 auto set_domain_rhs = [&](
auto fe) {
2151 auto &pip = fe->getOpPtrVector();
2153 CHKERR set_domain_general(fe);
2155 CHKERR add_parent_field_domain(fe, UDO::OPROW,
"U");
2156 pip.push_back(
new OpRhsU(
"U", dot_u_ptr, u_ptr, grad_u_ptr, h_ptr,
2157 grad_h_ptr, g_ptr, p_ptr));
2159 CHKERR add_parent_field_domain(fe, UDO::OPROW,
"H");
2160 pip.push_back(
new OpRhsH<false>(
"H", u_ptr, dot_h_ptr, h_ptr, grad_h_ptr,
2163 CHKERR add_parent_field_domain(fe, UDO::OPROW,
"G");
2164 pip.push_back(
new OpRhsG<false>(
"G", h_ptr, grad_h_ptr, g_ptr));
2166 CHKERR add_parent_field_domain(fe, UDO::OPROW,
"P");
2168 "P", div_u_ptr, [](
const double r,
const double,
const double) {
2172 "P", p_ptr, [](
const double r,
const double,
const double) {
2178 auto set_domain_lhs = [&](
auto fe) {
2180 auto &pip = fe->getOpPtrVector();
2182 CHKERR set_domain_general(fe);
2184 CHKERR add_parent_field_domain(fe, UDO::OPROW,
"U");
2186 CHKERR add_parent_field_domain(fe, UDO::OPCOL,
"U");
2187 pip.push_back(
new OpLhsU_dU(
"U", u_ptr, grad_u_ptr, h_ptr));
2188 CHKERR add_parent_field_domain(fe, UDO::OPCOL,
"H");
2190 new OpLhsU_dH(
"U",
"H", dot_u_ptr, u_ptr, grad_u_ptr, h_ptr, g_ptr));
2192 CHKERR add_parent_field_domain(fe, UDO::OPCOL,
"G");
2193 pip.push_back(
new OpLhsU_dG(
"U",
"G", grad_h_ptr));
2196 CHKERR add_parent_field_domain(fe, UDO::OPROW,
"H");
2198 CHKERR add_parent_field_domain(fe, UDO::OPCOL,
"U");
2199 pip.push_back(
new OpLhsH_dU(
"H",
"U", grad_h_ptr));
2200 CHKERR add_parent_field_domain(fe, UDO::OPCOL,
"H");
2202 CHKERR add_parent_field_domain(fe, UDO::OPCOL,
"G");
2206 CHKERR add_parent_field_domain(fe, UDO::OPROW,
"G");
2208 CHKERR add_parent_field_domain(fe, UDO::OPCOL,
"H");
2210 CHKERR add_parent_field_domain(fe, UDO::OPCOL,
"G");
2214 CHKERR add_parent_field_domain(fe, UDO::OPROW,
"P");
2216 CHKERR add_parent_field_domain(fe, UDO::OPCOL,
"U");
2222 [](
const double r,
const double,
const double) {
2230 [](
const double r,
const double,
const double) {
2237 "Coordinate system not implemented");
2240 CHKERR add_parent_field_domain(fe, UDO::OPCOL,
"P");
2241 pip.push_back(
new OpDomainMassP(
"P",
"P", [](
double r,
double,
double) {
2249 auto get_block_name = [](
auto name) {
2250 return boost::format(
"%s(.*)") %
"WETTING_ANGLE";
2253 auto get_blocks = [&](
auto &&
name) {
2255 std::regex(
name.str()));
2258 auto set_boundary_rhs = [&](
auto fe) {
2260 auto &pip = fe->getOpPtrVector();
2266 boost::shared_ptr<ForcesAndSourcesCore> fe_parent(
2273 CHKERR add_parent_field_bdy(fe, UDO::OPCOL,
"U");
2276 CHKERR add_parent_field_bdy(fe, UDO::OPCOL,
"L");
2281 pip,
mField,
"L", {},
"INFLUX",
2284 CHKERR add_parent_field_bdy(fe, UDO::OPROW,
"U");
2287 auto wetting_block = get_blocks(get_block_name(
"WETTING_ANGLE"));
2288 if (wetting_block.size()) {
2295 op_bdy_side->getOpPtrVector(), {H1});
2298 op_bdy_side->getSideFEPtr(),
"", UDO::OPSPACE,
2302 boost::shared_ptr<ForcesAndSourcesCore> fe_parent(
2305 fe_parent->getOpPtrVector(), {H1});
2311 CHKERR add_parent_field_domain(op_bdy_side->getSideFEPtr(), UDO::OPCOL,
2313 op_bdy_side->getOpPtrVector().push_back(
2316 pip.push_back(op_bdy_side);
2319 for (
auto &b : wetting_block) {
2321 std::vector<double> attr_vec;
2322 CHKERR b->getMeshsetIdEntitiesByDimension(
2324 b->getAttributes(attr_vec);
2325 if (attr_vec.size() != 1)
2327 "Should be one attribute");
2328 MOFEM_LOG(
"FS", Sev::inform) <<
"Wetting angle: " << attr_vec.front();
2330 CHKERR add_parent_field_bdy(fe, UDO::OPROW,
"G");
2331 CHKERR add_parent_field_bdy(fe, UDO::OPCOL,
"G");
2333 "G", grad_h_ptr, boost::make_shared<Range>(force_edges),
2341 auto set_boundary_lhs = [&](
auto fe) {
2343 auto &pip = fe->getOpPtrVector();
2349 boost::shared_ptr<ForcesAndSourcesCore> fe_parent(
2356 CHKERR add_parent_field_bdy(fe, UDO::OPROW,
"L");
2357 CHKERR add_parent_field_bdy(fe, UDO::OPCOL,
"U");
2360 auto wetting_block = get_blocks(get_block_name(
"WETTING_ANGLE"));
2361 if (wetting_block.size()) {
2362 auto col_ind_ptr = boost::make_shared<std::vector<VectorInt>>();
2363 auto col_diff_base_ptr = boost::make_shared<std::vector<MatrixDouble>>();
2371 op_bdy_side->getOpPtrVector(), {H1});
2374 op_bdy_side->getSideFEPtr(),
"", UDO::OPSPACE,
2378 boost::shared_ptr<ForcesAndSourcesCore> fe_parent(
2381 fe_parent->getOpPtrVector(), {H1});
2387 CHKERR add_parent_field_domain(op_bdy_side->getSideFEPtr(), UDO::OPROW,
2389 CHKERR add_parent_field_domain(op_bdy_side->getSideFEPtr(), UDO::OPCOL,
2391 op_bdy_side->getOpPtrVector().push_back(
2393 op_bdy_side->getOpPtrVector().push_back(
2397 pip.push_back(op_bdy_side);
2400 for (
auto &b : wetting_block) {
2402 std::vector<double> attr_vec;
2403 CHKERR b->getMeshsetIdEntitiesByDimension(
2405 b->getAttributes(attr_vec);
2406 if (attr_vec.size() != 1)
2408 "Should be one attribute");
2410 <<
"wetting angle edges size " << force_edges.size();
2412 CHKERR add_parent_field_bdy(fe, UDO::OPROW,
"G");
2413 CHKERR add_parent_field_bdy(fe, UDO::OPCOL,
"G");
2415 "G", grad_h_ptr, col_ind_ptr, col_diff_base_ptr,
2416 boost::make_shared<Range>(force_edges), attr_vec.front()));
2425 CHKERR set_domain_rhs(pip_mng->getCastDomainRhsFE());
2426 CHKERR set_domain_lhs(pip_mng->getCastDomainLhsFE());
2427 CHKERR set_boundary_rhs(pip_mng->getCastBoundaryRhsFE());
2428 CHKERR set_boundary_lhs(pip_mng->getCastBoundaryLhsFE());
2452 boost::shared_ptr<PostProcEleDomainCont> post_proc,
2453 boost::shared_ptr<PostProcEleBdyCont> post_proc_edge,
2454 std::pair<boost::shared_ptr<BoundaryEle>, boost::shared_ptr<VectorDouble>>
2461 MOFEM_LOG(
"FS", Sev::verbose) <<
"Monitor";
2466 MOFEM_LOG(
"FS", Sev::verbose) <<
"Mesh pre proc";
2469 auto post_proc_begin =
2470 boost::make_shared<PostProcBrokenMeshInMoabBaseBegin>(*m_field_ptr,
2472 auto post_proc_end = boost::make_shared<PostProcBrokenMeshInMoabBaseEnd>(
2480 CHKERR post_proc_end->writeFile(
2481 "out_step_" + boost::lexical_cast<std::string>(
ts_step) +
".h5m");
2482 MOFEM_LOG(
"FS", Sev::verbose) <<
"Mesh pre proc done";
2488 MPI_Allreduce(MPI_IN_PLACE, &(*
liftVec)[0],
SPACE_DIM, MPI_DOUBLE, MPI_SUM,
2492 <<
" lift vec x: " << (*liftVec)[0] <<
" y: " << (*liftVec)[1];
2518 auto setup_subdm = [&](
auto dm) {
2522 auto dm =
simple->getDM();
2523 auto level_ents_ptr = boost::make_shared<Range>();
2524 CHKERR bit_mng->getEntitiesByRefLevel(
2527 CHKERR DMSetType(subdm,
"DMMOFEM");
2533 for (
auto f : {
"U",
"P",
"H",
"G",
"L"}) {
2546 auto get_fe_post_proc = [&](
auto post_proc_mesh) {
2547 auto add_parent_field_domain = [&](
auto fe,
auto op,
auto field) {
2552 boost::shared_ptr<ForcesAndSourcesCore> fe_parent(
2561 boost::make_shared<PostProcEleDomainCont>(
mField, post_proc_mesh);
2562 post_proc_fe->exeTestHook = [](
FEMethod *fe_ptr) {
2567 auto u_ptr = boost::make_shared<MatrixDouble>();
2568 auto grad_u_ptr = boost::make_shared<MatrixDouble>();
2569 auto h_ptr = boost::make_shared<VectorDouble>();
2570 auto grad_h_ptr = boost::make_shared<MatrixDouble>();
2571 auto p_ptr = boost::make_shared<VectorDouble>();
2572 auto g_ptr = boost::make_shared<VectorDouble>();
2573 auto grad_g_ptr = boost::make_shared<MatrixDouble>();
2576 post_proc_fe->getOpPtrVector(), {H1});
2582 boost::shared_ptr<ForcesAndSourcesCore> fe_parent(
2585 fe_parent->getOpPtrVector(), {H1});
2591 CHKERR add_parent_field_domain(post_proc_fe, UDO::OPCOL,
"U");
2592 post_proc_fe->getOpPtrVector().push_back(
2594 post_proc_fe->getOpPtrVector().push_back(
2598 CHKERR add_parent_field_domain(post_proc_fe, UDO::OPCOL,
"H");
2599 post_proc_fe->getOpPtrVector().push_back(
2601 post_proc_fe->getOpPtrVector().push_back(
2604 CHKERR add_parent_field_domain(post_proc_fe, UDO::OPCOL,
"P");
2605 post_proc_fe->getOpPtrVector().push_back(
2608 CHKERR add_parent_field_domain(post_proc_fe, UDO::OPCOL,
"G");
2609 post_proc_fe->getOpPtrVector().push_back(
2611 post_proc_fe->getOpPtrVector().push_back(
2616 post_proc_fe->getOpPtrVector().push_back(
2619 post_proc_fe->getPostProcMesh(), post_proc_fe->getMapGaussPts(),
2621 {{
"H", h_ptr}, {
"P", p_ptr}, {
"G", g_ptr}},
2623 {{
"U", u_ptr}, {
"H_GRAD", grad_h_ptr}, {
"G_GRAD", grad_g_ptr}},
2625 {{
"GRAD_U", grad_u_ptr}},
2633 return post_proc_fe;
2636 auto get_bdy_post_proc_fe = [&](
auto post_proc_mesh) {
2637 auto add_parent_field_bdy = [&](
auto fe,
auto op,
auto field) {
2638 return setParentDofs(
2642 boost::shared_ptr<ForcesAndSourcesCore> fe_parent(
2651 boost::make_shared<PostProcEleBdyCont>(mField, post_proc_mesh);
2652 post_proc_fe->exeTestHook = [](
FEMethod *fe_ptr) {
2661 boost::shared_ptr<ForcesAndSourcesCore> fe_parent(
2670 OpGetNormal(boost::shared_ptr<VectorDouble> l_ptr,
2671 boost::shared_ptr<MatrixDouble> n_ptr)
2679 auto t_n_fe = getFTensor1NormalsAtGaussPts();
2680 ptrNormal->resize(getGaussPts().size2(),
SPACE_DIM,
false);
2681 auto t_n = getFTensor1FromMat<SPACE_DIM>(*ptrNormal);
2682 for (
auto gg = 0; gg != getGaussPts().size2(); ++gg) {
2683 t_n(
i) = t_n_fe(
i) * t_l / std::sqrt(t_n_fe(
i) * t_n_fe(
i));
2692 boost::shared_ptr<VectorDouble> ptrL;
2693 boost::shared_ptr<MatrixDouble> ptrNormal;
2696 auto u_ptr = boost::make_shared<MatrixDouble>();
2697 auto p_ptr = boost::make_shared<VectorDouble>();
2698 auto lambda_ptr = boost::make_shared<VectorDouble>();
2699 auto normal_l_ptr = boost::make_shared<MatrixDouble>();
2701 CHKERR add_parent_field_bdy(post_proc_fe, UDO::OPCOL,
"U");
2702 post_proc_fe->getOpPtrVector().push_back(
2705 CHKERR add_parent_field_bdy(post_proc_fe, UDO::OPCOL,
"L");
2706 post_proc_fe->getOpPtrVector().push_back(
2708 post_proc_fe->getOpPtrVector().push_back(
2709 new OpGetNormal(lambda_ptr, normal_l_ptr));
2711 CHKERR add_parent_field_bdy(post_proc_fe, UDO::OPCOL,
"P");
2712 post_proc_fe->getOpPtrVector().push_back(
2716 op_ptr->doWorkRhsHook = [&](
DataOperator *base_op_ptr,
int side,
2725 post_proc_fe->getOpPtrVector().push_back(
2727 new OpPPMap(post_proc_fe->getPostProcMesh(),
2728 post_proc_fe->getMapGaussPts(),
2742 return post_proc_fe;
2745 auto get_lift_fe = [&]() {
2746 auto add_parent_field_bdy = [&](
auto fe,
auto op,
auto field) {
2747 return setParentDofs(
2751 boost::shared_ptr<ForcesAndSourcesCore> fe_parent(
2759 auto fe = boost::make_shared<BoundaryEle>(mField);
2760 fe->exeTestHook = [](
FEMethod *fe_ptr) {
2765 auto lift_ptr = boost::make_shared<VectorDouble>();
2766 auto p_ptr = boost::make_shared<VectorDouble>();
2767 auto ents_ptr = boost::make_shared<Range>();
2773 boost::shared_ptr<ForcesAndSourcesCore> fe_parent(
2780 std::vector<const CubitMeshSets *> vec_ptr;
2782 std::regex(
"LIFT"), vec_ptr);
2783 for (
auto m_ptr : vec_ptr) {
2788 ents_ptr->merge(ents);
2791 MOFEM_LOG(
"FS", Sev::noisy) <<
"Lift ents " << (*ents_ptr);
2792 CHKERR add_parent_field_bdy(fe, UDO::OPROW,
"L");
2793 CHKERR add_parent_field_bdy(fe, UDO::OPCOL,
"L");
2794 fe->getOpPtrVector().push_back(
2796 fe->getOpPtrVector().push_back(
2799 return std::make_pair(fe, lift_ptr);
2802 auto set_post_proc_monitor = [&](
auto ts) {
2806 boost::shared_ptr<FEMethod> null_fe;
2807 auto post_proc_mesh = boost::make_shared<moab::Core>();
2808 auto monitor_ptr = boost::make_shared<Monitor>(
2810 get_fe_post_proc(post_proc_mesh), get_bdy_post_proc_fe(post_proc_mesh),
2813 null_fe, monitor_ptr);
2817 auto dm =
simple->getDM();
2821 auto ts_pre_post_proc = boost::make_shared<TSPrePostProc>();
2826 ptr->fsRawPtr =
this;
2827 ptr->solverSubDM = create_solver_dm(
simple->getDM());
2831 CHKERR VecAssemblyBegin(ptr->globSol);
2832 CHKERR VecAssemblyEnd(ptr->globSol);
2834 auto sub_ts = pip_mng->createTSIM(ptr->solverSubDM);
2836 CHKERR set_post_proc_monitor(sub_ts);
2839 CHKERR TSSetFromOptions(ts);
2843 auto print_fields_in_section = [&]() {
2846 simple->getProblemName());
2847 PetscInt num_fields;
2848 CHKERR PetscSectionGetNumFields(section, &num_fields);
2849 for (
int f = 0;
f < num_fields; ++
f) {
2853 <<
"Field " <<
f <<
" " << std::string(
field_name);
2858 CHKERR print_fields_in_section();
2860 CHKERR TSSolve(ts, ptr->globSol);
2865 PetscReal expected_time;
2866 CHKERR TSGetTime(ts, &expected_time);
2868 ts, expected_time, {1e-12, 1e-12},
"free surface");
2894#ifdef PYTHON_INIT_SURFACE
2899 const char param_file[] =
"param_file.petsc";
2903 auto core_log = logging::core::get();
2911 DMType dm_name =
"DMMOFEM";
2916 moab::Core mb_instance;
2917 moab::Interface &moab = mb_instance;
2934#ifdef PYTHON_INIT_SURFACE
2935 if (Py_FinalizeEx() < 0) {
2951 "can not get vertices on bit 0");
2956 Range plus_range, minus_range;
2957 std::vector<EntityHandle> plus, minus;
2960 for (
auto p = vertices.pair_begin(); p != vertices.pair_end(); ++p) {
2962 const auto f = p->first;
2963 const auto s = p->second;
2968 auto it = dofs_mi.lower_bound(lo_uid);
2969 const auto hi_it = dofs_mi.upper_bound(hi_uid);
2973 plus.reserve(std::distance(it, hi_it));
2974 minus.reserve(std::distance(it, hi_it));
2976 for (; it != hi_it; ++it) {
2977 const auto v = (*it)->getFieldData();
2979 plus.push_back((*it)->getEnt());
2981 minus.push_back((*it)->getEnt());
2984 plus_range.insert_list(plus.begin(), plus.end());
2985 minus_range.insert_list(minus.begin(), minus.end());
2990 <<
"Plus range " << plus_range << endl;
2992 <<
"Minus range " << minus_range << endl;
2995 auto get_elems = [&](
auto &ents,
auto bit,
auto mask) {
2998 moab::Interface::UNION),
2999 "can not get adjacencies");
3001 "can not filter elements with bit 0");
3005 CHKERR comm_mng->synchroniseEntities(plus_range);
3006 CHKERR comm_mng->synchroniseEntities(minus_range);
3009 ele_plus[0] = get_elems(plus_range,
bit(0),
BitRefLevel().set());
3010 ele_minus[0] = get_elems(minus_range,
bit(0),
BitRefLevel().set());
3011 auto common = intersect(ele_plus[0], ele_minus[0]);
3012 ele_plus[0] = subtract(ele_plus[0], common);
3013 ele_minus[0] = subtract(ele_minus[0], common);
3015 auto get_children = [&](
auto &p,
auto &
c) {
3017 CHKERR bit_mng->updateRangeByChildren(p,
c);
3029 auto get_level = [&](
auto &p,
auto &
m,
auto z,
auto bit,
auto mask) {
3032 bit_mng->getEntitiesByDimAndRefLevel(
bit, mask,
SPACE_DIM,
l),
3033 "can not get vertices on bit");
3036 for (
auto f = 0; f != z; ++f) {
3040 l = get_elems(conn,
bit, mask);
3045 std::vector<Range> vec_levels(
nb_levels);
3047 vec_levels[
l] = get_level(ele_plus[
l], ele_minus[
l], 2 * overlap,
bit(
l),
3051 if constexpr (
debug) {
3054 std::string
name = (boost::format(
"out_r%d.h5m") %
l).str();
3071 start_mask[s] =
true;
3077 Range prev_level_skin;
3081 CHKERR bit_mng->lambdaBitRefLevel(
3088 auto set_levels = [&](
auto &&
3098 auto get_adj = [&](
auto ents) {
3104 ents.subset_by_dimension(
SPACE_DIM), d,
false, conn,
3105 moab::Interface::UNION),
3119 CHKERR bit_mng->updateRangeByParent(vec_levels[
l], parents);
3122 level_prev = subtract(level_prev, parents);
3124 level_prev.merge(vec_levels[
l]);
3132 CHKERR bit_mng->getEntitiesByDimAndRefLevel(
3134 level = get_adj(level);
3143 auto set_skins = [&]() {
3147 ParallelComm *pcomm =
3156 "can't get bit level");
3163 auto get_level_skin = [&]() {
3169 CHKERR pcomm->filter_pstatus(skin_level_mesh,
3170 PSTATUS_SHARED | PSTATUS_MULTISHARED,
3171 PSTATUS_NOT, -1,
nullptr);
3174 skin_level = subtract(skin_level,
3178 Range skin_level_verts;
3181 skin_level.merge(skin_level_verts);
3184 bit_prev.set(
l - 1);
3188 skin.merge(subtract(skin_level, level_prev));
3194 auto resolve_shared = [&](
auto &&skin) {
3195 Range tmp_skin = skin;
3197 map<int, Range> map_procs;
3199 tmp_skin, &map_procs);
3201 Range from_other_procs;
3202 for (
auto &
m : map_procs) {
3204 from_other_procs.merge(
m.second);
3208 auto common = intersect(
3209 skin, from_other_procs);
3210 skin.merge(from_other_procs);
3214 if (!common.empty()) {
3216 skin = subtract(skin, common);
3223 auto get_parent_level_skin = [&](
auto skin) {
3225 CHKERR bit_mng->updateRangeByParent(
3226 skin.subset_by_dimension(
SPACE_DIM - 1), skin_parents);
3227 Range skin_parent_verts;
3230 skin_parents.merge(skin_parent_verts);
3233 return skin_parents;
3236 auto child_skin = resolve_shared(get_level_skin());
3237 auto parent_skin = get_parent_level_skin(child_skin);
3239 child_skin = subtract(child_skin, parent_skin);
3247 auto set_current = [&]() {
3256 last_level = subtract(last_level, skin_child);
3268 if constexpr (
debug) {
3271 std::string
name = (boost::format(
"out_level%d.h5m") %
l).str();
3274 "PARALLEL=WRITE_PART");
3278 "MOAB",
"PARALLEL=WRITE_PART");
3281 "MOAB",
"PARALLEL=WRITE_PART");
3285 "MOAB",
"PARALLEL=WRITE_PART");
3288 "MOAB",
"PARALLEL=WRITE_PART");
3296 boost::shared_ptr<FEMethod> fe_top, std::string
field_name,
3299 boost::function<boost::shared_ptr<ForcesAndSourcesCore>()> get_elem,
3306 boost::function<void(boost::shared_ptr<ForcesAndSourcesCore>,
int)>
3308 [&](boost::shared_ptr<ForcesAndSourcesCore> parent_fe_pt,
int level) {
3313 auto fe_ptr_current = get_elem();
3317 boost::dynamic_pointer_cast<ForcesAndSourcesCore>(
3325 parent_fe_pt->getOpPtrVector().push_back(
3329 H1, op, fe_ptr_current,
3340 parent_fe_pt->getOpPtrVector().push_back(
3355 add_parent_level(boost::dynamic_pointer_cast<ForcesAndSourcesCore>(fe_top),
3370 auto cut_off_dofs = [&]() {
3373 auto &m_field = ptr->fsRawPtr->mField;
3375 Range current_verts;
3380 auto cut_off_verts = [&](boost::shared_ptr<FieldEntity> ent_ptr) {
3382 for (
auto &
h : ent_ptr->getEntFieldData()) {
3388 auto field_blas = m_field.getInterface<
FieldBlas>();
3398 MOFEM_LOG(
"FS", Sev::inform) <<
"Run step pre proc";
3400 auto &m_field = ptr->fsRawPtr->mField;
3404 auto get_norm = [&](
auto x) {
3406 CHKERR VecNorm(x, NORM_2, &nrm);
3411 auto refine_problem = [&]() {
3413 MOFEM_LOG(
"FS", Sev::inform) <<
"Refine problem";
3415 CHKERR ptr->fsRawPtr->projectData();
3421 auto set_jacobian_operators = [&]() {
3424 CHKERR KSPReset(ptr->subKSP);
3429 auto set_solution = [&]() {
3431 MOFEM_LOG(
"FS", Sev::inform) <<
"Set solution";
3433 PetscObjectState state;
3444 INSERT_VALUES, SCATTER_FORWARD);
3447 <<
"Set solution, vector norm " << get_norm(ptr->globSol);
3452 PetscObjectTypeCompare((PetscObject)ts, TSTHETA, &is_theta);
3456 CHKERR set_jacobian_operators();
3461 "Sorry, only TSTheta handling is implemented");
3466 PetscBarrier((PetscObject)ts);
3478 auto &m_field = ptr->fsRawPtr->mField;
3490 auto sub_u = ptr->getSubVector();
3493 auto scatter = ptr->getScatter(sub_u, u,
R);
3495 auto apply_scatter_and_update = [&](
auto x,
auto sub_x) {
3497 CHKERR VecScatterBegin(scatter, x, sub_x, INSERT_VALUES, SCATTER_REVERSE);
3498 CHKERR VecScatterEnd(scatter, x, sub_x, INSERT_VALUES, SCATTER_REVERSE);
3499 CHKERR VecGhostUpdateBegin(sub_x, INSERT_VALUES, SCATTER_FORWARD);
3500 CHKERR VecGhostUpdateEnd(sub_x, INSERT_VALUES, SCATTER_FORWARD);
3504 CHKERR apply_scatter_and_update(u, sub_u);
3505 CHKERR apply_scatter_and_update(u_t, sub_u_t);
3508 CHKERR VecScatterBegin(scatter, sub_f, f, INSERT_VALUES, SCATTER_FORWARD);
3509 CHKERR VecScatterEnd(scatter, sub_f, f, INSERT_VALUES, SCATTER_FORWARD);
3515 PetscReal
a, Mat
A, Mat
B,
3519 auto sub_u = ptr->getSubVector();
3521 auto scatter = ptr->getScatter(sub_u, u,
R);
3523 auto apply_scatter_and_update = [&](
auto x,
auto sub_x) {
3525 CHKERR VecScatterBegin(scatter, x, sub_x, INSERT_VALUES, SCATTER_REVERSE);
3526 CHKERR VecScatterEnd(scatter, x, sub_x, INSERT_VALUES, SCATTER_REVERSE);
3527 CHKERR VecGhostUpdateBegin(sub_x, INSERT_VALUES, SCATTER_FORWARD);
3528 CHKERR VecGhostUpdateEnd(sub_x, INSERT_VALUES, SCATTER_FORWARD);
3532 CHKERR apply_scatter_and_update(u, sub_u);
3533 CHKERR apply_scatter_and_update(u_t, sub_u_t);
3536 ptr->tsCtxPtr.get());
3545 auto get_norm = [&](
auto x) {
3547 CHKERR VecNorm(x, NORM_2, &nrm);
3551 auto sub_u = ptr->getSubVector();
3552 auto scatter = ptr->getScatter(sub_u, u,
R);
3553 CHKERR VecScatterBegin(scatter, u, sub_u, INSERT_VALUES, SCATTER_REVERSE);
3554 CHKERR VecScatterEnd(scatter, u, sub_u, INSERT_VALUES, SCATTER_REVERSE);
3555 CHKERR VecGhostUpdateBegin(sub_u, INSERT_VALUES, SCATTER_FORWARD);
3556 CHKERR VecGhostUpdateEnd(sub_u, INSERT_VALUES, SCATTER_FORWARD);
3559 <<
"u norm " << get_norm(u) <<
" u sub nom " << get_norm(sub_u);
3569 MOFEM_LOG(
"FS", Sev::verbose) <<
"SetUP sub PC";
3570 ptr->subKSP =
createKSP(ptr->fsRawPtr->mField.get_comm());
3571 CHKERR KSPSetFromOptions(ptr->subKSP);
3579 auto sub_x = ptr->getSubVector();
3581 auto scatter = ptr->getScatter(sub_x, pc_x,
R);
3582 CHKERR VecScatterBegin(scatter, pc_f, sub_f, INSERT_VALUES,
3584 CHKERR VecScatterEnd(scatter, pc_f, sub_f, INSERT_VALUES, SCATTER_REVERSE);
3585 CHKERR KSPSetOperators(ptr->subKSP, ptr->subB, ptr->subB);
3586 MOFEM_LOG(
"FS", Sev::verbose) <<
"PCShell solve";
3587 CHKERR KSPSolve(ptr->subKSP, sub_f, sub_x);
3588 MOFEM_LOG(
"FS", Sev::verbose) <<
"PCShell solve <- done";
3589 CHKERR VecScatterBegin(scatter, sub_x, pc_x, INSERT_VALUES,
3591 CHKERR VecScatterEnd(scatter, sub_x, pc_x, INSERT_VALUES, SCATTER_FORWARD);
3598 auto prb_ptr = ptr->fsRawPtr->mField.get_problem(
"SUB_SOLVER");
3599 if (
auto sub_data = prb_ptr->getSubData()) {
3600 auto is = sub_data->getSmartColIs();
3635 CHKERR TSGetSNES(ts, &snes);
3638 auto set_section_monitor = [&](
auto snes) {
3640 CHKERR SNESMonitorSet(snes,
3643 (
void *)(snes_ctx_ptr.get()),
nullptr);
3647 CHKERR set_section_monitor(snes);
3652 CHKERR PCSetType(sub_pc, PCSHELL);
3670 PetscInt test_nb = 0;
3671 PetscBool test_flg = PETSC_FALSE;
3672 double regression_value = 0.0;
3682 CHKERR VecNorm(T, NORM_2, &nrm2);
3683 MOFEM_LOG(
"FS", Sev::verbose) <<
"Regression norm " << nrm2;
3691 if (fabs(nrm2 - regression_value) > 1e-2)
3693 "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
ElementsAndOps< SPACE_DIM >::SideEle SideEle
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