11 using namespace MoFEM;
13 static char help[] =
"...\n\n";
48 GAUSS>::OpGradGradSymTensorGradGrad<1, 1, SPACE_DIM, 0>;
57 constexpr
double mu = 1;
58 constexpr
double t = 1;
72 return cos(2 * x * M_PI) * sin(2 * y * M_PI);
81 auto mat_D_ptr = boost::make_shared<MatrixDouble>(
a *
a, 1);
82 auto t_D = getFTensor4DdgFromMat<2, 2, 0>(*(mat_D_ptr));
83 constexpr
double t3 =
t *
t *
t;
84 constexpr
double A =
mu * t3 / 12;
85 constexpr
double B =
lambda * t3 / 12;
95 std::array<std::vector<VectorInt>, 2>
97 std::array<std::vector<MatrixDouble>, 2>
99 std::array<std::vector<MatrixDouble>, 2>
128 boost::shared_ptr<MatrixDouble> d_mat_ptr);
134 boost::shared_ptr<FaceSideEle>
203 auto get_skin = [&]() {
206 mField.get_moab().get_entities_by_dimension(0,
SPACE_DIM, body_ents));
207 Skinner skin(&mField.get_moab());
209 MOAB_THROW(skin.find_skin(0, body_ents,
false, skin_ents));
211 MOAB_THROW(mField.get_moab().get_connectivity(skin_ents, verts,
true));
212 skin_ents.merge(verts);
217 auto remove_dofs_from_problem = [&](
Range &&skin) {
221 CHKERR problem_mng->removeDofsOnEntities(
simple->getProblemName(),
"U",
227 CHKERR remove_dofs_from_problem(get_skin());
239 auto rule_lhs = [](
int,
int,
int p) ->
int {
return 2 * p; };
240 auto rule_rhs = [](
int,
int,
int p) ->
int {
return 2 * p; };
243 CHKERR pipeline_mng->setDomainLhsIntegrationRule(rule_lhs);
244 CHKERR pipeline_mng->setDomainRhsIntegrationRule(rule_rhs);
246 CHKERR pipeline_mng->setSkeletonLhsIntegrationRule(rule_2);
247 CHKERR pipeline_mng->setSkeletonRhsIntegrationRule(rule_2);
248 CHKERR pipeline_mng->setBoundaryLhsIntegrationRule(rule_2);
249 CHKERR pipeline_mng->setBoundaryRhsIntegrationRule(rule_2);
251 auto det_ptr = boost::make_shared<VectorDouble>();
252 auto jac_ptr = boost::make_shared<MatrixDouble>();
253 auto inv_jac_ptr = boost::make_shared<MatrixDouble>();
254 auto base_mass_ptr = boost::make_shared<MatrixDouble>();
255 auto data_l2_ptr = boost::make_shared<EntitiesFieldData>(MBENTITYSET);
259 auto push_ho_direcatives = [&](
auto &pipeline) {
263 BaseDerivatives::SecondDerivative, base_mass_ptr, data_l2_ptr,
271 auto push_jacobian = [&](
auto &pipeline) {
282 push_ho_direcatives(pipeline_mng->getOpDomainLhsPipeline());
283 push_jacobian(pipeline_mng->getOpDomainLhsPipeline());
285 pipeline_mng->getOpDomainLhsPipeline().push_back(
290 pipeline_mng->getOpDomainRhsPipeline().push_back(
294 auto side_fe_ptr = boost::make_shared<FaceSideEle>(mField);
295 push_ho_direcatives(side_fe_ptr->getOpPtrVector());
296 push_jacobian(side_fe_ptr->getOpPtrVector());
300 pipeline_mng->getOpSkeletonLhsPipeline().push_back(
314 auto ksp_solver = pipeline_mng->createKSP();
315 CHKERR KSPSetFromOptions(ksp_solver);
316 CHKERR KSPSetUp(ksp_solver);
319 auto dm =
simple->getDM();
326 CHKERR VecGhostUpdateBegin(
D, INSERT_VALUES, SCATTER_FORWARD);
327 CHKERR VecGhostUpdateEnd(
D, INSERT_VALUES, SCATTER_FORWARD);
340 pipeline_mng->getSkeletonRhsFE().reset();
341 pipeline_mng->getSkeletonLhsFE().reset();
342 pipeline_mng->getBoundaryRhsFE().reset();
343 pipeline_mng->getBoundaryLhsFE().reset();
345 auto post_proc_fe = boost::make_shared<PostProcEle>(mField);
347 auto u_ptr = boost::make_shared<VectorDouble>();
348 post_proc_fe->getOpPtrVector().push_back(
353 post_proc_fe->getOpPtrVector().push_back(
355 new OpPPMap(post_proc_fe->getPostProcMesh(),
356 post_proc_fe->getMapGaussPts(),
366 pipeline_mng->getDomainRhsFE() = post_proc_fe;
367 CHKERR pipeline_mng->loopFiniteElements();
368 CHKERR post_proc_fe->writeFile(
"out_result.h5m");
390 int main(
int argc,
char *argv[]) {
393 const char param_file[] =
"param_file.petsc";
397 auto core_log = logging::core::get();
398 core_log->add_sink(LogManager::createSink(LogManager::getStrmWorld(),
"PL"));
399 LogManager::setLog(
"PL");
405 DMType dm_name =
"DMMOFEM";
430 std::string col_field_name)
437 const auto nb_in_loop = getFEMethod()->nInTheLoop;
439 auto clear = [](
auto nb) {
445 if (
type == MBVERTEX) {
446 areaMap[nb_in_loop] = getMeasure();
447 senseMap[nb_in_loop] = getEdgeSense();
456 const auto nb_dofs = data.
getIndices().size();
460 data.
getN(BaseDerivatives::FirstDerivative));
462 data.
getN(BaseDerivatives::SecondDerivative));
470 &*base_mat.data().begin());
473 template <
typename T>
inline auto get_ntensor(T &base_mat,
int gg,
int bb) {
474 double *ptr = &base_mat(gg, bb);
479 double *ptr = &*base_mat.data().begin();
480 return getFTensor1FromPtr<2>(ptr);
483 template <
typename T>
485 double *ptr = &base_mat(gg, 2 * bb);
486 return getFTensor1FromPtr<2>(ptr);
490 double *ptr = &*base_mat.data().begin();
494 template <
typename T>
496 double *ptr = &base_mat(gg, 4 * bb);
506 boost::shared_ptr<MatrixDouble> mat_d_ptr)
508 dMatPtr(mat_d_ptr) {}
516 const auto in_the_loop =
524 auto t_normal = getFTensor1Normal();
525 t_normal.normalize();
529 auto t_D = getFTensor4DdgFromMat<SPACE_DIM, SPACE_DIM, 0>(*
dMatPtr);
532 const size_t nb_integration_pts = getGaussPts().size2();
536 const double beta =
static_cast<double>(
nitsche) / (in_the_loop + 1);
538 auto integrate = [&](
auto sense_row,
auto &row_ind,
auto &row_diff,
539 auto &row_diff2,
auto sense_col,
auto &col_ind,
540 auto &col_diff,
auto &col_diff2) {
545 const auto nb_rows = row_ind.size();
546 const auto nb_cols = col_ind.size();
548 const auto nb_row_base_functions = row_diff.size2() /
SPACE_DIM;
553 locMat.resize(nb_rows, nb_cols,
false);
560 auto t_w = getFTensor0IntegrationWeight();
563 for (
size_t gg = 0; gg != nb_integration_pts; ++gg) {
567 const double alpha = getMeasure() * t_w;
568 auto t_mat =
locMat.data().begin();
572 for (; rr != nb_rows; ++rr) {
575 t_mv(
i,
j) = t_D(
i,
j,
k,
l) * t_diff2_row_base(
k,
l);
579 t_vn_plus(
i,
j) = beta * (
phi * t_mv(
i,
j) / p);
581 t_vn(
i,
j) = (t_diff_row_base(
j) * (t_normal(
i) * sense_row)) -
589 for (
size_t cc = 0; cc != nb_cols; ++cc) {
592 t_mu(
i,
j) = t_D(
i,
j,
k,
l) * t_diff2_col_base(
k,
l);
596 t_un(
i,
j) = -p * ((t_diff_col_base(
j) * (t_normal(
i) * sense_col) -
597 beta * t_mu(
i,
j) / p));
600 *t_mat -= alpha * (t_vn(
i,
j) * t_un(
i,
j));
601 *t_mat -= alpha * (t_vn_plus(
i,
j) * (beta * t_mu(
i,
j)));
619 for (; rr < nb_row_base_functions; ++rr) {
629 col_ind.size(), &*col_ind.begin(),
630 &*
locMat.data().begin(), ADD_VALUES);
639 const auto sense_row =
senseMap[s0];
644 const auto sense_col =
senseMap[s1];