v0.16.0
Loading...
Searching...
No Matches
BasicPostProc.hpp
Go to the documentation of this file.
1/** \file BasicPostProc.hpp
2 * \brief Helpers for post-processing basic finite element fields.
3 */
4
5#ifndef __BASIC_POST_PROC_HPP__
6#define __BASIC_POST_PROC_HPP__
7
8/**
9 * \brief Core broken-mesh post-processor adapted to the fat-prism element.
10 *
11 * FatPrismElementForcesAndSourcesCore builds its integration points as a
12 * Cartesian product of points on a triangle and points through the prism
13 * thickness. The core post-processor stores the same points as one reference
14 * prism. This adapter exposes that reference-prism point set in the form
15 * expected by the fat-prism element and keeps the point-to-vertex map in the
16 * resulting Cartesian-product order.
17 */
20 FatPrismElementForcesAndSourcesCore> {
21
22 using Base =
24 using Base::Base;
25
26 int getRuleTrianglesOnly(int) override { return -1; }
27 int getRuleThroughThickness(int) override { return -1; }
28
29 MoFEMErrorCode setGaussPtsTrianglesOnly(int order) override {
31
32 CHKERR Base::setGaussPts(order);
33
34 constexpr double eps = 100 * std::numeric_limits<double>::epsilon();
35 std::vector<std::array<double, 2>> triangle_points;
36 std::vector<double> thickness_points;
37
38 auto same = [eps](const double a, const double b) {
39 return std::abs(a - b) <= eps;
40 };
41 auto has_triangle_point = [&](const double ksi, const double eta) {
42 return std::find_if(
43 triangle_points.begin(), triangle_points.end(),
44 [&](const auto &p) {
45 return same(p[0], ksi) && same(p[1], eta);
46 }) != triangle_points.end();
47 };
48 auto has_thickness_point = [&](const double zeta) {
49 return std::find_if(thickness_points.begin(), thickness_points.end(),
50 [&](const double z) { return same(z, zeta); }) !=
51 thickness_points.end();
52 };
53
54 const auto reference_points = this->gaussPts;
55 const auto original_map = this->mapGaussPts;
56 for (size_t gg = 0; gg != reference_points.size2(); ++gg) {
57 const double ksi = reference_points(0, gg);
58 const double eta = reference_points(1, gg);
59 const double zeta = reference_points(2, gg);
60 if (!has_triangle_point(ksi, eta))
61 triangle_points.push_back({ksi, eta});
62 if (!has_thickness_point(zeta))
63 thickness_points.push_back(zeta);
64 }
65
66 const size_t expected_points =
67 triangle_points.size() * thickness_points.size();
68 if (expected_points != reference_points.size2())
69 SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
70 "Reference prism points do not form a Cartesian product");
71
72 this->gaussPtsTrianglesOnly.resize(3, triangle_points.size(), false);
73 this->gaussPtsTrianglesOnly.clear();
74 for (size_t tt = 0; tt != triangle_points.size(); ++tt) {
75 this->gaussPtsTrianglesOnly(0, tt) = triangle_points[tt][0];
76 this->gaussPtsTrianglesOnly(1, tt) = triangle_points[tt][1];
77 }
78
79 this->gaussPtsThroughThickness.resize(2, thickness_points.size(), false);
80 this->gaussPtsThroughThickness.clear();
81 for (size_t zz = 0; zz != thickness_points.size(); ++zz)
82 this->gaussPtsThroughThickness(0, zz) = thickness_points[zz];
83
84 this->mapGaussPts.clear();
85 this->mapGaussPts.reserve(expected_points);
86 for (const auto &p : triangle_points) {
87 for (const double zeta : thickness_points) {
88 auto gg = size_t{0};
89 for (; gg != reference_points.size2(); ++gg) {
90 if (same(reference_points(0, gg), p[0]) &&
91 same(reference_points(1, gg), p[1]) &&
92 same(reference_points(2, gg), zeta))
93 break;
94 }
95 if (gg == reference_points.size2())
96 SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
97 "Could not map a fat-prism post-processing point");
98 this->mapGaussPts.push_back(original_map[gg]);
99 }
100 }
101
103 }
104
105 MoFEMErrorCode setGaussPtsThroughThickness(int) override {
107 if (!this->gaussPtsThroughThickness.size2())
108 SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
109 "Fat-prism post-processing points are not initialised");
111 }
112};
113
114#endif // __BASIC_POST_PROC_HPP__
constexpr double a
static const double eps
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
@ MOFEM_DATA_INCONSISTENCY
Definition definitions.h:31
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
#define CHKERR
Inline error check.
constexpr int order
double eta
Core broken-mesh post-processor adapted to the fat-prism element.
int getRuleThroughThickness(int) override
MoFEMErrorCode setGaussPtsTrianglesOnly(int order) override
MoFEMErrorCode setGaussPtsThroughThickness(int) override
PostProcBrokenMeshInMoabBase< FatPrismElementForcesAndSourcesCore > Base
int getRuleTrianglesOnly(int) override
double zeta
Viscous hardening.
Definition plastic.cpp:131