23#ifndef EXECUTABLE_DIMENSION
24 #define EXECUTABLE_DIMENSION 2
49 GAUSS>::OpGradSymTensorGrad<1, SPACE_DIM, SPACE_DIM, 0>;
63 GAUSS>::OpGradTensorGrad<1, SPACE_DIM, SPACE_DIM, 1>;
94 GAUSS>::OpMixDivTimesScalar<SPACE_DIM>;
108 GAUSS>::OpBaseTimesVector<3, 3, 1>;
112 GAUSS>::OpBaseTimesVector<1, SPACE_DIM, 0>;
119 GAUSS>::OpMixDivTimesU<3, 1, SPACE_DIM>;
127 GAUSS>::OpBaseTimesScalarField<1>;
161 GAUSS>::OpEssentialRhs<HeatFluxCubitBcData, 3, SPACE_DIM>;
164 GAUSS>::OpEssentialLhs<HeatFluxCubitBcData, 3, SPACE_DIM>;
185auto save_range = [](moab::Interface &moab,
const std::string name,
189 CHKERR moab.add_entities(*out_meshset, r);
190 CHKERR moab.write_file(name.c_str(),
"VTK",
"", out_meshset->get_ptr(), 1);
223 boost::shared_ptr<MatrixDouble>
mDPtr;
226 :
public boost::enable_shared_from_this<BlockedParameters> {
235 return boost::shared_ptr<MatrixDouble>(shared_from_this(), &
mD);
243 return boost::shared_ptr<double>(shared_from_this(), &
biotConstant);
247 return boost::shared_ptr<double>(shared_from_this(), &
storageConstant);
251 return boost::shared_ptr<double>(shared_from_this(), &
fluidDensity);
255 return boost::shared_ptr<double>(shared_from_this(), &
matDensity);
260 boost::ptr_deque<ForcesAndSourcesCore::UserDataOperator> &pipeline,
261 std::string block_elastic_name, std::string block_thermal_name,
262 boost::shared_ptr<BlockedParameters> blockedParamsPtr,
Sev sev);
266 boost::ptr_deque<ForcesAndSourcesCore::UserDataOperator> &pipeline,
267 std::string block_elastic_name, std::string block_thermal_name,
268 boost::shared_ptr<BlockedParameters> blockedParamsPtr,
Sev sev) {
272 OpMatElasticBlocks(boost::shared_ptr<MatrixDouble>
m,
double bulk_modulus_K,
275 std::vector<const CubitMeshSets *> meshset_vec_ptr)
280 "Can not get data from block");
287 for (
auto &b : blockData) {
289 if (b.blockEnts.find(getFEEntityHandle()) != b.blockEnts.end()) {
290 CHKERR getMatDPtr(matDPtr, b.bulkModulusK, b.shearModulusG);
295 CHKERR getMatDPtr(matDPtr, bulkModulusKDefault, shearModulusGDefault);
300 boost::shared_ptr<MatrixDouble> matDPtr;
304 double shearModulusG;
308 double bulkModulusKDefault;
309 double shearModulusGDefault;
310 std::vector<BlockData> blockData;
314 std::vector<const CubitMeshSets *> meshset_vec_ptr,
318 for (
auto m : meshset_vec_ptr) {
320 std::vector<double> block_data;
321 CHKERR m->getAttributes(block_data);
322 if (block_data.size() < 2) {
324 "Expected that block has two attributes");
326 auto get_block_ents = [&]() {
329 m_field.
get_moab().get_entities_by_handle(
m->meshset, ents,
true);
349 MoFEMErrorCode getMatDPtr(boost::shared_ptr<MatrixDouble> mat_D_ptr,
353 auto set_material_stiffness = [&]() {
364 auto t_D = getFTensor4DdgFromMat<SPACE_DIM, SPACE_DIM, 0>(*mat_D_ptr);
373 set_material_stiffness();
378 double default_bulk_modulus_K =
380 double default_shear_modulus_G =
383 pipeline.push_back(
new OpMatElasticBlocks(
384 blockedParamsPtr->getDPtr(), default_bulk_modulus_K,
385 default_shear_modulus_G,
mField, sev,
390 (boost::format(
"%s(.*)") % block_elastic_name).str()
397 OpMatFluidBlocks(boost::shared_ptr<double> conductivity_ptr,
398 boost::shared_ptr<double> biot_constant_ptr,
399 boost::shared_ptr<double> fluid_density_ptr,
400 boost::shared_ptr<double> mat_density_ptr,
401 boost::shared_ptr<double> storage_constant_ptr,
403 std::vector<const CubitMeshSets *> meshset_vec_ptr)
405 conductivityPtr(conductivity_ptr), biotConstantPtr(biot_constant_ptr),
406 fluidDensityPtr(fluid_density_ptr), matDensityPtr(mat_density_ptr),
407 storageConstantPtr(storage_constant_ptr) {
409 "Can not get data from block");
416 for (
auto &b : blockData) {
418 if (b.blockEnts.find(getFEEntityHandle()) != b.blockEnts.end()) {
419 *conductivityPtr = b.conductivity;
420 *biotConstantPtr = b.biot_constant;
421 *fluidDensityPtr = b.fluid_density;
422 *matDensityPtr = b.mat_density;
423 *storageConstantPtr = b.storage;
440 double biot_constant;
443 double fluid_density;
447 std::vector<BlockData> blockData;
451 std::vector<const CubitMeshSets *> meshset_vec_ptr,
455 for (
auto m : meshset_vec_ptr) {
457 std::vector<double> block_data;
458 CHKERR m->getAttributes(block_data);
459 if (block_data.size() < 5) {
461 "Expected that block has five attributes");
463 auto get_block_ents = [&]() {
466 m_field.
get_moab().get_entities_by_handle(
m->meshset, ents,
true);
471 <<
m->getName() <<
": conductivity = " << block_data[0]
472 <<
", biot_constant = " << block_data[1]
473 <<
", storage = " << block_data[2]
474 <<
", mat_density = " << block_data[3]
475 <<
", fluid_density = " << block_data[4];
477 blockData.push_back({block_data[0], block_data[1], block_data[2],
478 block_data[3], block_data[4], get_block_ents()});
484 boost::shared_ptr<double> expansionPtr;
485 boost::shared_ptr<double> conductivityPtr;
486 boost::shared_ptr<double> biotConstantPtr;
487 boost::shared_ptr<double> fluidDensityPtr;
488 boost::shared_ptr<double> matDensityPtr;
489 boost::shared_ptr<double> storageConstantPtr;
490 boost::shared_ptr<double> capacityPtr;
493 pipeline.push_back(
new OpMatFluidBlocks(
494 blockedParamsPtr->getConductivityPtr(),
495 blockedParamsPtr->getBiotConstantPtr(),
496 blockedParamsPtr->getFluidDensityPtr(),
497 blockedParamsPtr->getMatDensityPtr(),
498 blockedParamsPtr->getStorageConstantPtr(),
mField, sev,
503 (boost::format(
"%s(.*)") % block_thermal_name).str()
566 mDPtr = boost::make_shared<MatrixDouble>();
576 auto no_rule = [](int, int, int) {
return -1; };
579 field_eval_fe_ptr->getRuleHook = no_rule;
581 auto block_params = boost::make_shared<BlockedParameters>();
582 mDPtr = block_params->getDPtr();
585 "MAT_FLUID", block_params, Sev::verbose);
588 field_eval_fe_ptr->getOpPtrVector(), {H1, HDIV});
590 field_eval_fe_ptr->getOpPtrVector().push_back(
592 field_eval_fe_ptr->getOpPtrVector().push_back(
594 field_eval_fe_ptr->getOpPtrVector().push_back(
596 field_eval_fe_ptr->getOpPtrVector().push_back(
599 field_eval_fe_ptr->getOpPtrVector().push_back(
601 field_eval_fe_ptr->getOpPtrVector().push_back(
614 auto get_command_line_parameters = [&]() {
648 CHKERR get_command_line_parameters();
665 simple->getProblemName(),
"U");
667 simple->getProblemName(),
"FLUX",
false);
669 auto get_skin = [&]() {
674 CHKERR skin.find_skin(0, body_ents,
false, skin_ents);
678 auto filter_flux_blocks = [&](
auto skin) {
679 auto remove_cubit_blocks = [&](
auto c) {
689 skin = subtract(skin, ents);
694 auto remove_named_blocks = [&](
auto n) {
699 (boost::format(
"%s(.*)") %
n).str()
707 skin = subtract(skin, ents);
713 "remove_cubit_blocks");
715 "remove_cubit_blocks");
724 ParallelComm *pcomm =
726 CHKERR pcomm->filter_pstatus(skin, PSTATUS_SHARED | PSTATUS_MULTISHARED,
727 PSTATUS_NOT, -1, &boundary_ents);
728 return boundary_ents;
736 MOFEM_LOG(
"SYNC", Sev::noisy) << remove_flux_ents << endl;
749 simple->getProblemName(),
"FLUX", remove_flux_ents);
762 auto boundary_marker =
763 bc_mng->getMergedBlocksMarker(vector<string>{
"FLUIDFLUX"});
765 auto u_grad_ptr = boost::make_shared<MatrixDouble>();
766 auto dot_u_grad_ptr = boost::make_shared<MatrixDouble>();
767 auto trace_dot_u_grad_ptr = boost::make_shared<VectorDouble>();
768 auto p_ptr = boost::make_shared<VectorDouble>();
769 auto dot_p_ptr = boost::make_shared<VectorDouble>();
770 auto flux_ptr = boost::make_shared<MatrixDouble>();
771 auto div_flux_ptr = boost::make_shared<VectorDouble>();
772 auto strain_ptr = boost::make_shared<MatrixDouble>();
773 auto stress_ptr = boost::make_shared<MatrixDouble>();
775 auto time_scale = boost::make_shared<TimeScale>();
777 auto block_params = boost::make_shared<BlockedParameters>();
778 auto mDPtr = block_params->getDPtr();
779 auto conductivity_ptr = block_params->getConductivityPtr();
780 auto biot_constant_ptr = block_params->getBiotConstantPtr();
781 auto mat_density_ptr = block_params->getMatDensityPtr();
782 auto fluid_density_ptr = block_params->getFluidDensityPtr();
783 auto storage_constant_ptr = block_params->getStorageConstantPtr();
794 auto add_domain_base_ops = [&](
auto &pip) {
805 "U", dot_u_grad_ptr));
807 trace_dot_u_grad_ptr));
813 "FLUX", div_flux_ptr));
819 auto add_domain_ops_lhs_mechanical = [&](
auto &pip) {
823 return -*biot_constant_ptr;
827 pip.push_back(
new OpBaseDivU(
"P",
"U", biot,
true,
true));
833 auto add_domain_ops_rhs_mechanical = [&](
auto &pip) {
837 pip,
mField,
"U", {time_scale},
"BODY_FORCE", Sev::inform);
839 return *biot_constant_ptr;
841 auto mat_density = [mat_density_ptr](
const double,
const double,
843 return *mat_density_ptr;
847 strain_ptr, stress_ptr,
mDPtr));
858 auto add_domain_ops_lhs_seepage = [&](
auto &pip,
auto &fe) {
860 auto resistance = [conductivity_ptr](
const double,
const double,
862 return (1. / *(conductivity_ptr));
865 return *biot_constant_ptr;
867 auto storage = [storage_constant_ptr](
const double,
const double,
869 return -*storage_constant_ptr;
871 auto minus_one = []()
constexpr {
return -1; };
873 pip.push_back(
new OpSetBc(
"FLUX",
true, boundary_marker));
875 pip.push_back(
new OpHdivHdiv(
"FLUX",
"FLUX", resistance));
876 pip.push_back(
new OpHdivQ(
"FLUX",
"P", minus_one,
true));
878 auto op_domain_mass =
new OpDomainMass(
"P",
"P", storage);
879 op_domain_mass->feScalingFun = [](
const FEMethod *fe_ptr) {
882 pip.push_back(op_domain_mass);
884 auto op_base_div_u =
new OpBaseDivU(
"P",
"U", biot,
false,
false);
885 op_base_div_u->feScalingFun = [](
const FEMethod *fe_ptr) {
888 pip.push_back(op_base_div_u);
897 auto add_domain_ops_rhs_seepage = [&](
auto &pip) {
900 return (1. / (*conductivity_ptr));
904 return *biot_constant_ptr;
907 auto storage = [storage_constant_ptr](
const double,
const double,
909 return -*storage_constant_ptr;
912 auto fluid_density = [fluid_density_ptr](
const double,
const double,
914 return *fluid_density_ptr;
917 auto dot_p_at_gauss_pts = boost::make_shared<VectorDouble>();
920 pip.push_back(
new OpSetBc(
"FLUX",
true, boundary_marker));
922 pip.push_back(
new OpHdivFlux(
"FLUX", flux_ptr, resistance));
923 pip.push_back(
new OpHDivH(
"FLUX", p_ptr, minus_one));
926 pip.push_back(
new OpBaseDotH(
"P", trace_dot_u_grad_ptr, biot));
927 pip.push_back(
new OpBaseDivFlux(
"P", div_flux_ptr, minus_one));
935 auto add_boundary_rhs_ops = [&](
auto &pip) {
940 pip.push_back(
new OpSetBc(
"FLUX",
true, boundary_marker));
943 pipeline_mng->getOpBoundaryRhsPipeline(),
mField,
"U", {time_scale},
944 "FORCE", Sev::inform);
947 pipeline_mng->getOpBoundaryRhsPipeline(),
mField,
"FLUX", {time_scale},
948 "PRESSURE", Sev::inform);
952 auto mat_flux_ptr = boost::make_shared<MatrixDouble>();
957 mField, pip,
simple->getProblemName(),
"FLUX", mat_flux_ptr,
963 auto add_boundary_lhs_ops = [&](
auto &pip) {
977 CHKERR add_domain_base_ops(pipeline_mng->getOpDomainLhsPipeline());
978 CHKERR add_domain_ops_lhs_mechanical(pipeline_mng->getOpDomainLhsPipeline());
979 CHKERR add_domain_ops_lhs_seepage(pipeline_mng->getOpDomainLhsPipeline(),
980 pipeline_mng->getDomainLhsFE());
983 CHKERR add_domain_base_ops(pipeline_mng->getOpDomainRhsPipeline());
984 CHKERR add_domain_ops_rhs_mechanical(pipeline_mng->getOpDomainRhsPipeline());
985 CHKERR add_domain_ops_rhs_seepage(pipeline_mng->getOpDomainRhsPipeline());
987 CHKERR add_boundary_rhs_ops(pipeline_mng->getOpBoundaryRhsPipeline());
988 CHKERR add_boundary_lhs_ops(pipeline_mng->getOpBoundaryLhsPipeline());
1001 auto dm =
simple->getDM();
1005 auto set_section_monitor = [&](
auto solver) {
1008 CHKERR TSGetSNES(solver, &snes);
1009 CHKERR SNESMonitorSet(snes,
1012 (
void *)(snes_ctx_ptr.get()),
nullptr);
1016 auto create_post_process_element = [&]() {
1017 auto post_proc_fe = boost::make_shared<PostProcEle>(
mField);
1019 auto block_params = boost::make_shared<BlockedParameters>();
1020 auto mD_ptr = block_params->getDPtr();
1022 "MAT_FLUID", block_params, Sev::verbose);
1024 post_proc_fe->getOpPtrVector(), {H1, HDIV});
1026 auto mat_grad_ptr = boost::make_shared<MatrixDouble>();
1027 auto mat_strain_ptr = boost::make_shared<MatrixDouble>();
1028 auto mat_stress_ptr = boost::make_shared<MatrixDouble>();
1030 auto p_ptr = boost::make_shared<VectorDouble>();
1031 auto mat_flux_ptr = boost::make_shared<MatrixDouble>();
1033 post_proc_fe->getOpPtrVector().push_back(
1035 post_proc_fe->getOpPtrVector().push_back(
1038 auto u_ptr = boost::make_shared<MatrixDouble>();
1039 post_proc_fe->getOpPtrVector().push_back(
1041 post_proc_fe->getOpPtrVector().push_back(
1044 post_proc_fe->getOpPtrVector().push_back(
1046 post_proc_fe->getOpPtrVector().push_back(
1048 mat_strain_ptr, mat_stress_ptr, mD_ptr));
1052 post_proc_fe->getOpPtrVector().push_back(
1056 post_proc_fe->getPostProcMesh(), post_proc_fe->getMapGaussPts(),
1060 {{
"U", u_ptr}, {
"FLUX", mat_flux_ptr}},
1064 {{
"STRAIN", mat_strain_ptr}, {
"STRESS", mat_stress_ptr}}
1070 return post_proc_fe;
1073 auto create_creaction_fe = [&]() {
1074 auto fe_ptr = boost::make_shared<DomainEle>(mField);
1075 fe_ptr->getRuleHook = [](int, int,
int o) {
return 2 * o; };
1077 auto &pip = fe_ptr->getOpPtrVector();
1079 auto block_params = boost::make_shared<BlockedParameters>();
1080 auto mD_ptr = block_params->getDPtr();
1085 auto u_grad_ptr = boost::make_shared<MatrixDouble>();
1086 auto strain_ptr = boost::make_shared<MatrixDouble>();
1087 auto stress_ptr = boost::make_shared<MatrixDouble>();
1095 strain_ptr, stress_ptr, mD_ptr));
1098 fe_ptr->postProcessHook =
1104 auto monitor_ptr = boost::make_shared<FEMethod>();
1105 auto post_proc_fe = create_post_process_element();
1107 auto rections_fe = create_creaction_fe();
1109 auto set_time_monitor = [&](
auto dm,
auto solver) {
1111 monitor_ptr->preProcessHook = [&]() {
1118 monitor_ptr->getCacheWeakPtr());
1119 CHKERR post_proc_fe->writeFile(
1120 "out_" + boost::lexical_cast<std::string>(monitor_ptr->ts_step) +
1124 rections_fe->f = res;
1127 monitor_ptr->getCacheWeakPtr());
1129 CHKERR VecAssemblyBegin(res);
1130 CHKERR VecAssemblyEnd(res);
1132 CHKERR VecNorm(res, NORM_2, &nrm);
1134 <<
"Residual norm " << nrm <<
" at time step "
1135 << monitor_ptr->ts_step;
1137 struct AtomTestResult {
1139 std::string msg =
"";
1142 AtomTestResult atom_test_result;
1144 auto fail_atom_test = [&atom_test_result](
const std::string &msg) {
1145 if (!atom_test_result.fail) {
1146 atom_test_result.fail =
true;
1147 atom_test_result.msg = msg;
1152 struct AtomTestData {
1153 double expected = 0.0;
1161 ->evalFEAtThePoint<SPACE_DIM>(
1162 fieldEvalCoords.data(), 1e-12,
simple->getProblemName(),
1163 simple->getDomainFEName(), fieldEvalData,
1164 mField.get_comm_rank(), mField.get_comm_rank(),
nullptr,
1170 CHKERR VecZeroEntries(eval_num_vec);
1171 if (pressureFieldPtr->size()) {
1172 CHKERR VecSetValue(eval_num_vec, 0, 1, ADD_VALUES);
1174 CHKERR VecAssemblyBegin(eval_num_vec);
1175 CHKERR VecAssemblyEnd(eval_num_vec);
1178 CHKERR VecSum(eval_num_vec, &eval_num);
1179 if (!(
int)eval_num) {
1181 "did not find elements to evaluate the field, check the "
1186 if (
atom_test && fabs(monitor_ptr->ts_t - 0.1) < 1e-12 &&
1187 pressureFieldPtr && !pressureFieldPtr->empty()) {
1190 <<
"Rank " << mField.get_comm_rank();
1192 <<
"Eval point P: " << t_pressure;
1193 double pressure = 0.0;
1196 auto t_flux = getFTensor1FromMat<SPACE_DIM>(*fluxFieldPtr);
1197 auto flux_mag = sqrt(t_flux(
i) * t_flux(
i));
1199 <<
"Eval point FLUX magnitude: " << flux_mag;
1202 auto t_disp = getFTensor1FromMat<SPACE_DIM>(*dispFieldPtr);
1203 auto disp_mag = sqrt(t_disp(
i) * t_disp(
i));
1205 <<
"Eval point U magnitude: " << disp_mag;
1208 auto t_strain = getFTensor2SymmetricFromMat<SPACE_DIM>(*strainFieldPtr);
1209 auto t_strain_trace = t_strain(
i,
i);
1211 <<
"Eval point trace of strain: " << t_strain_trace;
1212 double strain = 0.0;
1214 double von_mises_stress;
1215 auto getVonMisesStress = [&](
auto t_stress) {
1217 von_mises_stress = std::sqrt(
1219 ((t_stress(0, 0) - t_stress(1, 1)) *
1220 (t_stress(0, 0) - t_stress(1, 1)) +
1221 (
SPACE_DIM == 3 ? (t_stress(1, 1) - t_stress(2, 2)) *
1222 (t_stress(1, 1) - t_stress(2, 2))
1224 (
SPACE_DIM == 3 ? (t_stress(2, 2) - t_stress(0, 0)) *
1225 (t_stress(2, 2) - t_stress(0, 0))
1227 6 * (t_stress(0, 1) * t_stress(0, 1) +
1228 (
SPACE_DIM == 3 ? t_stress(1, 2) * t_stress(1, 2) : 0) +
1229 (
SPACE_DIM == 3 ? t_stress(2, 0) * t_stress(2, 0) : 0))));
1233 getFTensor2SymmetricFromMat<SPACE_DIM>(*stressFieldPtr);
1234 CHKERR getVonMisesStress(t_stress);
1236 <<
"Eval point von Mises Stress: " << von_mises_stress;
1237 double stress = 0.0;
1241 pressure = 0.0002681;
1249 pressure = 0.0063046;
1265 fail_atom_test(
"unknown atom test number");
1267 if (fabs(t_pressure + pressure) > 1e-4) {
1268 fail_atom_test(
"wrong pressure value");
1270 if (fabs(flux_mag - flux) > 1e-6) {
1271 fail_atom_test(
"wrong flux value");
1273 if (fabs(disp_mag - disp) > 1e-2) {
1274 fail_atom_test(
"wrong displacement value");
1276 if (fabs(t_strain_trace + strain) > 1e-3) {
1277 fail_atom_test(
"wrong strain value");
1279 if (fabs(von_mises_stress - stress) > 1e-2) {
1280 fail_atom_test(
"wrong stress value");
1284 auto current_time_step = monitor_ptr->ts_step;
1285 PetscReal current_time;
1286 CHKERR TSGetTime(solver, ¤t_time);
1288 if (pressureFieldPtr && !pressureFieldPtr->empty()) {
1291 <<
"Eval point displacement: " << *dispFieldPtr;
1293 <<
"Eval point strain: " << *strainFieldPtr;
1295 <<
"Eval point symmetric stress tensor: " << *stressFieldPtr;
1297 <<
"Eval point pore pressure: " << *pressureFieldPtr;
1299 <<
"Eval point flux: " << *fluxFieldPtr;
1301 <<
"Eval point elasticity matrix: " << *mDPtr;
1306 int fail_flag = atom_test_result.fail ? 1 : 0;
1307 MPI_Allreduce(MPI_IN_PLACE, &fail_flag, 1, MPI_INT, MPI_MAX, mField.get_comm());
1311 const int MAX_MSG = 512;
1313 char msg_buf[MAX_MSG];
1316 if (atom_test_result.fail) {
1317 std::snprintf(msg_buf, MAX_MSG,
"%s", atom_test_result.msg.c_str());
1319 int my_rank = mField.get_comm_rank();
1320 int send_rank = atom_test_result.fail ? my_rank : INT_MAX;
1321 MPI_Allreduce(MPI_IN_PLACE, &send_rank, 1, MPI_INT, MPI_MIN, mField.get_comm());
1322 MPI_Bcast(msg_buf, MAX_MSG, MPI_CHAR, send_rank, mField.get_comm());
1324 if (my_rank == root) {
1326 "atom test %d failed: %s",
atom_test, msg_buf);
1330 "Atom test failed");
1336 auto null = boost::shared_ptr<FEMethod>();
1342 auto set_fieldsplit_preconditioner = [&](
auto solver) {
1346 CHKERR TSGetSNES(solver, &snes);
1348 CHKERR SNESGetKSP(snes, &ksp);
1350 CHKERR KSPGetPC(ksp, &pc);
1351 PetscBool is_pcfs = PETSC_FALSE;
1352 PetscObjectTypeCompare((PetscObject)pc, PCFIELDSPLIT, &is_pcfs);
1355 if (is_pcfs == PETSC_TRUE) {
1356 auto bc_mng = mField.getInterface<
BcManager>();
1358 auto name_prb =
simple->getProblemName();
1361 CHKERR is_mng->isCreateProblemFieldAndRank(name_prb,
ROW,
"U", 0,
1364 CHKERR is_mng->isCreateProblemFieldAndRank(name_prb,
ROW,
"FLUX", 0, 0,
1367 CHKERR is_mng->isCreateProblemFieldAndRank(name_prb,
ROW,
"P", 0, 0,
1370 CHKERR ISExpand(is_P, is_flux, &is_tmp);
1373 auto is_all_bc = bc_mng->getBlockIS(name_prb,
"FLUIDFLUX",
"FLUX", 0, 0);
1375 CHKERR ISGetSize(is_all_bc, &is_all_bc_size);
1377 <<
"Field split block size " << is_all_bc_size;
1378 if (is_all_bc_size) {
1380 CHKERR ISDifference(is_Flux, is_all_bc, &is_tmp2);
1382 CHKERR PCFieldSplitSetIS(pc, PETSC_NULLPTR,
1388 CHKERR PCFieldSplitSetIS(pc, PETSC_NULLPTR, is_Flux);
1389 CHKERR PCFieldSplitSetIS(pc, PETSC_NULLPTR, is_u);
1395 auto pre_proc_ptr = boost::make_shared<FEMethod>();
1396 auto post_proc_rhs_ptr = boost::make_shared<FEMethod>();
1397 auto post_proc_lhs_ptr = boost::make_shared<FEMethod>();
1398 auto time_scale = boost::make_shared<TimeScale>();
1400 auto get_bc_hook_rhs = [
this, pre_proc_ptr, time_scale]() {
1402 {time_scale},
false);
1406 auto get_post_proc_hook_rhs = [
this, post_proc_rhs_ptr]() {
1409 mField, post_proc_rhs_ptr,
nullptr, Sev::verbose)();
1411 mField, post_proc_rhs_ptr, 1.)();
1414 auto get_post_proc_hook_lhs = [
this, post_proc_lhs_ptr]() {
1416 post_proc_lhs_ptr, 1.);
1419 pre_proc_ptr->preProcessHook = get_bc_hook_rhs();
1420 post_proc_rhs_ptr->postProcessHook = get_post_proc_hook_rhs;
1421 post_proc_lhs_ptr->postProcessHook = get_post_proc_hook_lhs();
1424 ts_ctx_ptr->getPreProcessIFunction().push_front(pre_proc_ptr);
1425 ts_ctx_ptr->getPreProcessIJacobian().push_front(pre_proc_ptr);
1426 ts_ctx_ptr->getPostProcessIFunction().push_back(post_proc_rhs_ptr);
1427 ts_ctx_ptr->getPostProcessIJacobian().push_back(post_proc_lhs_ptr);
1430 CHKERR TSSetIJacobian(solver,
B,
B, PETSC_NULLPTR, PETSC_NULLPTR);
1432 CHKERR TSSetSolution(solver,
D);
1433 CHKERR TSSetFromOptions(solver);
1435 CHKERR set_section_monitor(solver);
1436 CHKERR set_fieldsplit_preconditioner(solver);
1437 CHKERR set_time_monitor(dm, solver);
1440 CHKERR TSSolve(solver, NULL);
1451 const char param_file[] =
"param_file.petsc";
1455 auto core_log = logging::core::get();
1468 DMType dm_name =
"DMMOFEM";
1473 moab::Core mb_instance;
1474 moab::Interface &moab = mb_instance;
static auto filter_true_skin(MoFEM::Interface &m_field, Range &&skin)
#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)
DomainEle::UserDataOperator DomainEleOp
Finire element operator type.
ElementsAndOps< SPACE_DIM >::DomainEle DomainEle
FormsIntegrators< DomainEleOp >::Assembly< PETSC >::BiLinearForm< GAUSS >::OpMass< 1, FIELD_DIM > OpDomainMass
ElementsAndOps< SPACE_DIM >::BoundaryEle BoundaryEle
Kronecker Delta class symmetric.
#define CATCH_ERRORS
Catch errors.
FieldApproximationBase
approximation base
@ AINSWORTH_LEGENDRE_BASE
Ainsworth Cole (Legendre) approx. base .
#define CHK_THROW_MESSAGE(err, msg)
Check and throw MoFEM exception.
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return()
@ L2
field with C-1 continuity
@ HCURL
field with continuous tangents
@ HDIV
field with continuous normal traction
#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 ...
@ 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.
#define MoFEMFunctionBeginHot
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
FormsIntegrators< DomainEleOp >::Assembly< PETSC >::LinearForm< GAUSS >::OpBaseTimesVector< 1, SPACE_DIM, 1 > OpInertiaForce
FormsIntegrators< DomainEleOp >::Assembly< A >::BiLinearForm< I >::OpMixScalarTimesDiv< SPACE_DIM, COORD_TYPE > OpMixScalarTimesDiv
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)
Get smart vector from DM.
auto createDMMatrix(DM dm)
Get smart matrix from DM.
SmartPetscObj< TS > createTSIM(SmartPetscObj< DM > dm=nullptr)
Create TS (time) implicit solver.
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 getCubitMeshsetPtr(const int ms_id, const CubitBCType cubit_bc_type, const CubitMeshSets **cubit_meshset_ptr) const
get cubit meshset
FTensor::Index< 'i', SPACE_DIM > i
const double c
speed of light (cm/ns)
const double n
refractive index of diffusive medium
FTensor::Index< 'l', 3 > l
FTensor::Index< 'j', 3 > j
FTensor::Index< 'k', 3 > k
PetscErrorCode MoFEMErrorCode
MoFEM/PETSc error code.
implementation of Data Operators for Forces and Sources
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.
auto getDMTsCtx(DM dm)
Get TS context data structure used by DM.
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 PetscOptionsGetBool(PetscOptions *, const char pre[], const char name[], PetscBool *bval, PetscBool *set)
PetscErrorCode PetscOptionsGetScalar(PetscOptions *, const char pre[], const char name[], PetscScalar *dval, PetscBool *set)
PetscErrorCode PetscOptionsGetRealArray(PetscOptions *, const char pre[], const char name[], PetscReal dval[], PetscInt *nmax, PetscBool *set)
auto createVectorMPI(MPI_Comm comm, PetscInt n, PetscInt N)
Create MPI Vector.
static auto getFTensor0FromVec(ublas::vector< T, A > &data)
Get tensor rank 0 (scalar) form data vector.
OpCalculateScalarFieldValuesFromPetscVecImpl< PetscData::CTX_SET_X_T > OpCalculateScalarFieldValuesDot
auto get_temp_meshset_ptr(moab::Interface &moab)
Create smart pointer to temporary meshset.
auto getDMSnesCtx(DM dm)
Get SNES context data structure used by DM.
MoFEMErrorCode addMatBlockOps(MoFEM::Interface &m_field, std::string block_name, Pip &pip, boost::shared_ptr< MatrixDouble > mat_D_Ptr, boost::shared_ptr< CommonData::BlockParams > mat_params_ptr, double scale_value, Sev sev)
OpPostProcMapInMoab< SPACE_DIM, SPACE_DIM > OpPPMap
static constexpr int approx_order
OpBaseImpl< PETSC, EdgeEleOp > OpBase
FormsIntegrators< DomainEleOp >::Assembly< PETSC >::LinearForm< GAUSS >::OpGradTimesTensor< 1, SPACE_DIM, SPACE_DIM > OpInternalForcePiola
FormsIntegrators< DomainEleOp >::Assembly< PETSC >::BiLinearForm< GAUSS >::OpGradTensorGrad< 1, SPACE_DIM, SPACE_DIM, 1 > OpKPiola
[Only used for dynamics]
double default_conductivity
OpBaseDotH OpBaseDivFlux
Integrate Rhs base of temperature times divergent of flux (T)
FormsIntegrators< DomainEleOp >::Assembly< PETSC >::BiLinearForm< GAUSS >::OpMass< 1, 1 > OpDomainMass
static char help[]
[Solve]
FormsIntegrators< DomainEleOp >::Assembly< PETSC >::BiLinearForm< GAUSS >::OpMass< 1, SPACE_DIM > OpMass
[Only used with Hooke equation (linear material model)]
PetscBool is_plane_strain
double default_fluid_density
FormsIntegrators< DomainEleOp >::Assembly< PETSC >::LinearForm< GAUSS >::OpBaseTimesScalar< 1 > OpDomainTimesScalarField
FormsIntegrators< DomainEleOp >::Assembly< PETSC >::LinearForm< GAUSS >::OpGradTimesSymTensor< 1, SPACE_DIM, SPACE_DIM > OpInternalForceCauchy
#define EXECUTABLE_DIMENSION
FormsIntegrators< DomainEleOp >::Assembly< PETSC >::BiLinearForm< GAUSS >::OpMixScalarTimesDiv< SPACE_DIM > OpBaseDivU
[Essential boundary conditions]
FormsIntegrators< DomainEleOp >::Assembly< PETSC >::LinearForm< GAUSS >::OpMixDivTimesU< 3, 1, SPACE_DIM > OpHDivH
Integrate Rhs div flux base times temperature (T)
FormsIntegrators< DomainEleOp >::Assembly< PETSC >::LinearForm< GAUSS >::OpBaseTimesVector< 3, 3, 1 > OpHdivFlux
Integrating Rhs flux base (1/k) flux (FLUX)
double scale
[Essential boundary conditions (Least square approach)]
double default_young_modulus
FormsIntegrators< BoundaryEleOp >::Assembly< PETSC >::LinearForm< GAUSS >::OpBaseTimesVector< 1, SPACE_DIM, 0 > OpBoundaryVec
FormsIntegrators< DomainEleOp >::Assembly< PETSC >::BiLinearForm< GAUSS >::OpMixDivTimesScalar< SPACE_DIM > OpHdivQ
Integrate Lhs div of base of flux time base of temperature (FLUX x T) and transpose of it,...
FormsIntegrators< DomainEleOp >::Assembly< PETSC >::BiLinearForm< GAUSS >::OpMass< 1, 1 > OpCapacity
Integrate Lhs base of temperature times (heat capacity) times base of temperature (T x T)
double default_mat_density
FormsIntegrators< DomainEleOp >::Assembly< PETSC >::BiLinearForm< GAUSS >::OpMass< 3, 3 > OpHdivHdiv
Integrate Lhs base of flux (1/k) base of flux (FLUX x FLUX)
FormsIntegrators< DomainEleOp >::Assembly< PETSC >::BiLinearForm< GAUSS >::OpGradSymTensorGrad< 1, SPACE_DIM, SPACE_DIM, 0 > OpKCauchy
[Only used with Hooke equation (linear material model)]
FormsIntegrators< BoundaryEleOp >::Assembly< PETSC >::LinearForm< GAUSS >::OpBaseTimesVector< 1, SPACE_DIM, 1 > OpBoundaryInternal
FormsIntegrators< BoundaryEleOp >::Assembly< PETSC >::BiLinearForm< GAUSS >::OpMass< 1, SPACE_DIM > OpBoundaryMass
[Only used with Hencky/nonlinear material]
FormsIntegrators< DomainEleOp >::Assembly< PETSC >::LinearForm< GAUSS >::OpBaseTimesScalarField< 1 > OpBaseDotH
Integrate Rhs base of temperature time heat capacity times heat rate (T)
double default_poisson_ratio
FormsIntegrators< DomainEleOp >::Assembly< PETSC >::LinearForm< GAUSS >::OpBaseTimesVector< 1, SPACE_DIM, 0 > OpBaseFlux
FTensor::Index< 'm', 3 > m
Add operators pushing bases from local to physical configuration.
Boundary condition manager for finite element problem setup.
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.
Deprecated interface functions.
Definition of the displacement bc data structure.
Data on single entity (This is passed as argument to DataOperator::doWork)
Essential boundary conditions.
Class (Function) to enforce essential constrains on the left hand side diagonal.
Class (Function) to enforce essential constrains on the right hand side diagonal.
Class (Function) to calculate residual side diagonal.
Class (Function) to enforce essential constrains.
Structure for user loop methods on finite elements.
Field evaluator interface.
Definition of the heat flux bc data structure.
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.
static boost::shared_ptr< std::ostream > getStrmSync()
Get the strm sync object.
Interface for managing meshsets containing materials and boundary conditions.
Get vector field for H-div approximation.
Calculate divergence of vector field.
Specialization for double precision scalar field values calculation.
Operator for calculating the trace of matrices at integration points.
Get field gradients time derivative at integration pts for scalar field rank 0, i....
Get field gradients at integration pts for scalar field rank 0, i.e. vector field.
Specialization for double precision vector field values calculation.
Enforce essential constrains on lhs.
Enforce essential constrains on rhs.
Post post-proc data at points from hash maps.
Set indices on entities on finite element.
Operator for symmetrizing tensor fields.
Unset indices on entities on finite element.
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 addDomainField(const std::string name, const FieldSpace space, const FieldApproximationBase base, const FieldCoefficientsNumber nb_of_coefficients, const TagType tag_type=MB_TAG_SPARSE, const enum MoFEMTypes bh=MF_ZERO, int verb=-1)
Add field on domain.
MoFEMErrorCode getOptions()
get options
intrusive_ptr for managing petsc objects
MoFEMErrorCode getInterface(IFACE *&iface) const
Get interface reference to pointer of interface.
auto getFluidDensityPtr()
auto getStorageConstantPtr()
auto getBiotConstantPtr()
auto getConductivityPtr()
Seepage(MoFEM::Interface &m_field)
MoFEMErrorCode setupProblem()
[Run problem]
std::array< double, 3 > fieldEvalCoords
boost::shared_ptr< VectorDouble > pressureFieldPtr
MoFEMErrorCode createCommonData()
[Set up problem]
MoFEMErrorCode bC()
[Create common data]
std::tuple< SmartPetscObj< Vec >, SmartPetscObj< VecScatter > > uZScatter
std::tuple< SmartPetscObj< Vec >, SmartPetscObj< VecScatter > > uXScatter
MoFEMErrorCode runProblem()
[Run problem]
boost::shared_ptr< FieldEvaluatorInterface::SetPtsData > fieldEvalData
boost::shared_ptr< MatrixDouble > dispFieldPtr
boost::shared_ptr< MatrixDouble > fluxFieldPtr
MoFEMErrorCode OPs()
[Boundary condition]
boost::shared_ptr< MatrixDouble > mDPtr
boost::shared_ptr< MatrixDouble > stressFieldPtr
boost::shared_ptr< MatrixDouble > strainFieldPtr
std::tuple< SmartPetscObj< Vec >, SmartPetscObj< VecScatter > > uYScatter
MoFEM::Interface & mField
MoFEMErrorCode addMatBlockOps(boost::ptr_deque< ForcesAndSourcesCore::UserDataOperator > &pipeline, std::string block_elastic_name, std::string block_thermal_name, boost::shared_ptr< BlockedParameters > blockedParamsPtr, Sev sev)
MoFEMErrorCode tsSolve()
[Solve]
boost::shared_ptr< MatrixDouble > dispGradPtr
double young_modulus
Young modulus.
double poisson_ratio
Poisson ratio.