11 using namespace MoFEM;
13 static char help[] =
"...\n\n";
49 GAUSS>::OpGradGradSymTensorGradGrad<1, 1, SPACE_DIM, 0>;
58 constexpr
double mu = 1;
59 constexpr
double t = 1;
73 return cos(2 * x * M_PI) * sin(2 * y * M_PI);
82 auto mat_D_ptr = boost::make_shared<MatrixDouble>(
a *
a, 1);
83 auto t_D = getFTensor4DdgFromMat<2, 2, 0>(*(mat_D_ptr));
84 constexpr
double t3 =
t *
t *
t;
85 constexpr
double A =
mu * t3 / 12;
86 constexpr
double B =
lambda * t3 / 12;
96 std::array<std::vector<VectorInt>, 2>
98 std::array<std::vector<MatrixDouble>, 2>
100 std::array<std::vector<MatrixDouble>, 2>
129 boost::shared_ptr<MatrixDouble> d_mat_ptr);
135 boost::shared_ptr<FaceSideEle>
204 auto get_skin = [&]() {
207 mField.get_moab().get_entities_by_dimension(0,
SPACE_DIM, body_ents));
208 Skinner skin(&mField.get_moab());
210 MOAB_THROW(skin.find_skin(0, body_ents,
false, skin_ents));
212 MOAB_THROW(mField.get_moab().get_connectivity(skin_ents, verts,
true));
213 skin_ents.merge(verts);
218 auto remove_dofs_from_problem = [&](
Range &&skin) {
222 CHKERR problem_mng->removeDofsOnEntities(
simple->getProblemName(),
"U",
228 CHKERR remove_dofs_from_problem(get_skin());
240 auto rule_lhs = [](
int,
int,
int p) ->
int {
return 2 * p; };
241 auto rule_rhs = [](
int,
int,
int p) ->
int {
return 2 * p; };
244 CHKERR pipeline_mng->setDomainLhsIntegrationRule(rule_lhs);
245 CHKERR pipeline_mng->setDomainRhsIntegrationRule(rule_rhs);
247 CHKERR pipeline_mng->setSkeletonLhsIntegrationRule(rule_2);
248 CHKERR pipeline_mng->setSkeletonRhsIntegrationRule(rule_2);
249 CHKERR pipeline_mng->setBoundaryLhsIntegrationRule(rule_2);
250 CHKERR pipeline_mng->setBoundaryRhsIntegrationRule(rule_2);
252 auto det_ptr = boost::make_shared<VectorDouble>();
253 auto jac_ptr = boost::make_shared<MatrixDouble>();
254 auto inv_jac_ptr = boost::make_shared<MatrixDouble>();
255 auto base_mass_ptr = boost::make_shared<MatrixDouble>();
256 auto data_l2_ptr = boost::make_shared<EntitiesFieldData>(MBENTITYSET);
260 auto push_ho_direcatives = [&](
auto &pipeline) {
264 BaseDerivatives::SecondDerivative, base_mass_ptr, data_l2_ptr,
272 auto push_jacobian = [&](
auto &pipeline) {
283 push_ho_direcatives(pipeline_mng->getOpDomainLhsPipeline());
284 push_jacobian(pipeline_mng->getOpDomainLhsPipeline());
286 pipeline_mng->getOpDomainLhsPipeline().push_back(
291 pipeline_mng->getOpDomainRhsPipeline().push_back(
295 auto side_fe_ptr = boost::make_shared<FaceSideEle>(mField);
296 push_ho_direcatives(side_fe_ptr->getOpPtrVector());
297 push_jacobian(side_fe_ptr->getOpPtrVector());
301 pipeline_mng->getOpSkeletonLhsPipeline().push_back(
315 auto ksp_solver = pipeline_mng->createKSP();
316 CHKERR KSPSetFromOptions(ksp_solver);
317 CHKERR KSPSetUp(ksp_solver);
320 auto dm =
simple->getDM();
327 CHKERR VecGhostUpdateBegin(
D, INSERT_VALUES, SCATTER_FORWARD);
328 CHKERR VecGhostUpdateEnd(
D, INSERT_VALUES, SCATTER_FORWARD);
341 pipeline_mng->getSkeletonRhsFE().reset();
342 pipeline_mng->getSkeletonLhsFE().reset();
343 pipeline_mng->getBoundaryRhsFE().reset();
344 pipeline_mng->getBoundaryLhsFE().reset();
346 auto post_proc_fe = boost::make_shared<PostProcEle>(mField);
348 auto u_ptr = boost::make_shared<VectorDouble>();
349 post_proc_fe->getOpPtrVector().push_back(
354 post_proc_fe->getOpPtrVector().push_back(
356 new OpPPMap(post_proc_fe->getPostProcMesh(),
357 post_proc_fe->getMapGaussPts(),
367 pipeline_mng->getDomainRhsFE() = post_proc_fe;
368 CHKERR pipeline_mng->loopFiniteElements();
369 CHKERR post_proc_fe->writeFile(
"out_result.h5m");
391 int main(
int argc,
char *argv[]) {
394 const char param_file[] =
"param_file.petsc";
398 auto core_log = logging::core::get();
399 core_log->add_sink(LogManager::createSink(LogManager::getStrmWorld(),
"PL"));
400 LogManager::setLog(
"PL");
406 DMType dm_name =
"DMMOFEM";
431 std::string col_field_name)
438 const auto nb_in_loop = getFEMethod()->nInTheLoop;
440 auto clear = [](
auto nb) {
446 if (
type == MBVERTEX) {
447 areaMap[nb_in_loop] = getMeasure();
448 senseMap[nb_in_loop] = getEdgeSense();
457 const auto nb_dofs = data.
getIndices().size();
461 data.
getN(BaseDerivatives::FirstDerivative));
463 data.
getN(BaseDerivatives::SecondDerivative));
471 &*base_mat.data().begin());
474 template <
typename T>
inline auto get_ntensor(T &base_mat,
int gg,
int bb) {
475 double *ptr = &base_mat(gg, bb);
480 double *ptr = &*base_mat.data().begin();
481 return getFTensor1FromPtr<2>(ptr);
484 template <
typename T>
486 double *ptr = &base_mat(gg, 2 * bb);
487 return getFTensor1FromPtr<2>(ptr);
491 double *ptr = &*base_mat.data().begin();
495 template <
typename T>
497 double *ptr = &base_mat(gg, 4 * bb);
507 boost::shared_ptr<MatrixDouble> mat_d_ptr)
509 dMatPtr(mat_d_ptr) {}
517 const auto in_the_loop =
525 auto t_normal = getFTensor1Normal();
526 t_normal.normalize();
530 auto t_D = getFTensor4DdgFromMat<SPACE_DIM, SPACE_DIM, 0>(*
dMatPtr);
533 const size_t nb_integration_pts = getGaussPts().size2();
537 const double beta =
static_cast<double>(
nitsche) / (in_the_loop + 1);
539 auto integrate = [&](
auto sense_row,
auto &row_ind,
auto &row_diff,
540 auto &row_diff2,
auto sense_col,
auto &col_ind,
541 auto &col_diff,
auto &col_diff2) {
546 const auto nb_rows = row_ind.size();
547 const auto nb_cols = col_ind.size();
549 const auto nb_row_base_functions = row_diff.size2() /
SPACE_DIM;
554 locMat.resize(nb_rows, nb_cols,
false);
561 auto t_w = getFTensor0IntegrationWeight();
564 for (
size_t gg = 0; gg != nb_integration_pts; ++gg) {
568 const double alpha = getMeasure() * t_w;
569 auto t_mat =
locMat.data().begin();
573 for (; rr != nb_rows; ++rr) {
576 t_mv(
i,
j) = t_D(
i,
j,
k,
l) * t_diff2_row_base(
k,
l);
580 t_vn_plus(
i,
j) = beta * (
phi * t_mv(
i,
j) / p);
582 t_vn(
i,
j) = (t_diff_row_base(
j) * (t_normal(
i) * sense_row)) -
590 for (
size_t cc = 0; cc != nb_cols; ++cc) {
593 t_mu(
i,
j) = t_D(
i,
j,
k,
l) * t_diff2_col_base(
k,
l);
597 t_un(
i,
j) = -p * ((t_diff_col_base(
j) * (t_normal(
i) * sense_col) -
598 beta * t_mu(
i,
j) / p));
601 *t_mat -= alpha * (t_vn(
i,
j) * t_un(
i,
j));
602 *t_mat -= alpha * (t_vn_plus(
i,
j) * (beta * t_mu(
i,
j)));
620 for (; rr < nb_row_base_functions; ++rr) {
630 col_ind.size(), &*col_ind.begin(),
631 &*
locMat.data().begin(), ADD_VALUES);
640 const auto sense_row =
senseMap[s0];
645 const auto sense_col =
senseMap[s1];