71 enum bases { AINSWORTH, DEMKOWICZ, LASBASETOPT };
72 const char *list_bases[LASBASETOPT] = {
"ainsworth",
"demkowicz"};
73 PetscInt choice_base_value = AINSWORTH;
74 CHKERR PetscOptionsGetEList(PETSC_NULLPTR, NULL,
"-base", list_bases,
75 LASBASETOPT, &choice_base_value, PETSC_NULLPTR);
78 switch (choice_base_value) {
82 <<
"Set AINSWORTH_LEGENDRE_BASE for displacements";
87 <<
"Set DEMKOWICZ_JACOBI_BASE for displacements";
98 CHKERR PetscOptionsGetInt(PETSC_NULLPTR,
"",
"-order", &
order, PETSC_NULLPTR);
106 auto project_ho_geometry = [&]() {
107 Projection10NodeCoordsOnField ent_method(
mField,
"GEOMETRY");
110 CHKERR project_ho_geometry();
147 auto integration_rule_bc = [](int, int,
int approx_order) {
153 CHKERR pip->setBoundaryRhsIntegrationRule(integration_rule_bc);
154 CHKERR pip->setBoundaryLhsIntegrationRule(integration_rule_bc);
158 pip->getOpDomainLhsPipeline(), {H1},
"GEOMETRY");
160 pip->getOpDomainRhsPipeline(), {H1},
"GEOMETRY");
162 pip->getOpBoundaryRhsPipeline(), {NOSPACE},
"GEOMETRY");
164 pip->getOpBoundaryLhsPipeline(), {NOSPACE},
"GEOMETRY");
168 CHKERR HookeOps::opFactoryDomainLhs<SPACE_DIM, A, I, DomainEleOp>(
169 mField, pip->getOpDomainLhsPipeline(),
"U",
"MAT_ELASTIC", Sev::verbose);
173 CHKERR HookeOps::opFactoryDomainRhs<SPACE_DIM, A, I, DomainEleOp>(
174 mField, pip->getOpDomainRhsPipeline(),
"U",
"MAT_ELASTIC", Sev::verbose);
178 pip->getOpDomainRhsPipeline(),
mField,
"U", Sev::inform);
184 pip->getOpBoundaryRhsPipeline(),
mField,
"U", -1, Sev::inform);
187 pip->getOpBoundaryLhsPipeline(),
mField,
"U", Sev::verbose);
228 auto solver = pip->createKSP();
229 CHKERR KSPSetFromOptions(solver);
231 auto set_essential_bc = [
this]() {
235 auto dm =
simple->getDM();
236 auto ksp_ctx_ptr = getDMKspCtx(dm);
238 auto pre_proc_rhs = boost::make_shared<FEMethod>();
239 auto post_proc_rhs = boost::make_shared<FEMethod>();
240 auto post_proc_lhs = boost::make_shared<FEMethod>();
242 auto get_pre_proc_hook = [
this, pre_proc_rhs]() {
243 return EssentialPreProc<DisplacementCubitBcData>(
mField, pre_proc_rhs,
246 pre_proc_rhs->preProcessHook = get_pre_proc_hook();
248 auto get_post_proc_hook_rhs = [
this, post_proc_rhs]() {
251 CHKERR EssentialPostProcRhs<DisplacementCubitBcData>(
mField,
252 post_proc_rhs, 1.)();
256 auto get_post_proc_hook_lhs = [
this, post_proc_lhs]() {
259 CHKERR EssentialPostProcLhs<DisplacementCubitBcData>(
mField,
260 post_proc_lhs, 1.)();
264 post_proc_rhs->postProcessHook = get_post_proc_hook_rhs;
265 post_proc_lhs->postProcessHook = get_post_proc_hook_lhs;
267 ksp_ctx_ptr->getPreProcComputeRhs().push_front(pre_proc_rhs);
268 ksp_ctx_ptr->getPostProcComputeRhs().push_back(post_proc_rhs);
269 ksp_ctx_ptr->getPostProcSetOperators().push_back(post_proc_lhs);
273 auto evaluate_field_at_the_point = [&]() {
277 std::array<double, 3> field_eval_coords{0.0, 0.0, 0.0};
279 CHKERR PetscOptionsGetRealArray(NULL, NULL,
"-field_eval_coords",
280 field_eval_coords.data(), &coords_dim,
286 auto field_eval_data =
290 ->buildTree<SPACE_DIM>(field_eval_data,
simple->getDomainFEName());
292 field_eval_data->setEvalPoints(field_eval_coords.data(), 1);
293 auto no_rule = [](int, int, int) {
return -1; };
294 auto field_eval_fe_ptr = field_eval_data->feMethodPtr.lock();
295 field_eval_fe_ptr->getRuleHook = no_rule;
297 field_eval_fe_ptr->getOpPtrVector().push_back(
298 new OpCalculateVectorFieldValues<SPACE_DIM>(
"U",
vectorFieldPtr));
301 ->evalFEAtThePoint<SPACE_DIM>(
302 field_eval_coords.data(), 1e-12,
simple->getProblemName(),
303 simple->getDomainFEName(), field_eval_data,
311 <<
"U_X: " << t_disp(0) <<
" U_Y: " << t_disp(1);
314 <<
"U_X: " << t_disp(0) <<
" U_Y: " << t_disp(1)
315 <<
" U_Z: " << t_disp(2);
323 CHKERR set_essential_bc();
325 CHKERR evaluate_field_at_the_point();
348 pip->getDomainRhsFE().reset();
349 pip->getDomainLhsFE().reset();
350 pip->getBoundaryRhsFE().reset();
351 pip->getBoundaryLhsFE().reset();
353 auto integration_rule = [](int, int,
int p_data) {
return 2 * p_data + 1; };
358 pip->getOpDomainRhsPipeline(), {H1},
"GEOMETRY");
360 pip->getOpBoundaryRhsPipeline(), {},
"GEOMETRY");
363 CHKERR HookeOps::opFactoryDomainRhs<SPACE_DIM, A, I, DomainEleOp>(
364 mField, pip->getOpDomainRhsPipeline(),
"U",
"MAT_ELASTIC", Sev::verbose);
367 pip->getOpDomainRhsPipeline(),
mField,
"U", Sev::verbose);
370 pip->getOpBoundaryRhsPipeline(),
mField,
"U", -1, Sev::verbose);
372 auto dm =
simple->getDM();
373 auto res = createDMVector(dm);
374 CHKERR VecSetDM(res, PETSC_NULLPTR);
376 pip->getDomainRhsFE()->f = res;
377 pip->getBoundaryRhsFE()->f = res;
379 CHKERR VecZeroEntries(res);
381 CHKERR pip->loopFiniteElements();
384 CHKERR VecGhostUpdateBegin(res, ADD_VALUES, SCATTER_REVERSE);
385 CHKERR VecGhostUpdateEnd(res, ADD_VALUES, SCATTER_REVERSE);
386 CHKERR VecAssemblyBegin(res);
387 CHKERR VecAssemblyEnd(res);
389 auto zero_residual_at_constrains = [&]() {
391 auto fe_post_proc_ptr = boost::make_shared<FEMethod>();
392 auto get_post_proc_hook_rhs = [&]() {
394 CHKERR EssentialPreProcReaction<DisplacementCubitBcData>(
395 mField, fe_post_proc_ptr, res)();
396 CHKERR EssentialPostProcRhs<DisplacementCubitBcData>(
397 mField, fe_post_proc_ptr, 0, res)();
400 fe_post_proc_ptr->postProcessHook = get_post_proc_hook_rhs;
401 CHKERR DMoFEMPostProcessFiniteElements(dm, fe_post_proc_ptr.get());
405 CHKERR zero_residual_at_constrains();
408 CHKERR VecNorm(res, NORM_2, &nrm2);
410 MOFEM_LOG_C(
"WORLD", Sev::inform,
"residual = %3.4e\n", nrm2);
413 CHKERR PetscOptionsGetInt(PETSC_NULLPTR,
"",
"-test", &test, PETSC_NULLPTR);
415 auto post_proc_residual = [&](
auto dm,
auto f_res,
auto out_name) {
418 boost::make_shared<PostProcBrokenMeshInMoab<DomainEle>>(
mField);
419 using OpPPMap = OpPostProcMapInMoab<SPACE_DIM, SPACE_DIM>;
420 auto u_vec = boost::make_shared<MatrixDouble>();
421 post_proc_fe->getOpPtrVector().push_back(
422 new OpCalculateVectorFieldValues<SPACE_DIM>(
"U", u_vec, f_res));
423 post_proc_fe->getOpPtrVector().push_back(
427 post_proc_fe->getPostProcMesh(), post_proc_fe->getMapGaussPts(),
437 CHKERR DMoFEMLoopFiniteElements(dm,
simple->getDomainFEName(),
439 post_proc_fe->writeFile(out_name);
443 CHKERR post_proc_residual(
simple->getDM(), res,
"res.h5m");
445 constexpr double eps = 1e-8;
448 "Residual is not zero");
451 if (!vectorFieldPtr || vectorFieldPtr->size1() == 0) {
453 "atom test %d failed: Field Evaluator did not provide result",
456 auto t_disp = getFTensor1FromMat<SPACE_DIM>(*vectorFieldPtr);
457 double Ux_ref = 0.46;
458 double Uy_ref = -0.03;
459 constexpr double eps = 1e-8;
460 if (fabs(t_disp(0) - Ux_ref) >
eps || fabs(t_disp(1) - Uy_ref) >
eps) {
462 "atom test %d failed: Ux_ref = %3.6e, computed = %3.6e, Uy_ref "
463 "= %3.6e, computed = %3.6e",
464 test, Ux_ref, t_disp(0), Uy_ref, t_disp(1));
virtual MoFEMErrorCode loop_dofs(const Problem *problem_ptr, const std::string &field_name, RowColData rc, DofMethod &method, int lower_rank, int upper_rank, int verb=DEFAULT_VERBOSITY)=0
Make a loop over dofs.
MoFEMErrorCode postProcessElasticResults(MoFEM::Interface &mField, SmartPetscObj< DM > dm, const std::string &domain_fe_name, const std::string &out_file_name, SmartPetscObj< Vec > extra_vector=nullptr, const std::string &extra_vector_name="", const Sev hooke_ops_sev=Sev::verbose)
Post post-proc data at points from hash maps.
Boundary conditions in domain, i.e. body forces.