v0.16.3
Loading...
Searching...
No Matches
DGProjectionInterface.hpp
Go to the documentation of this file.
1/** \file DGProjectionInterface.hpp
2 * \brief Project fields between mesh bit levels using an application DM.
3 */
4#ifndef MOFEM_DG_PROJECTION_INTERFACE_HPP
5#define MOFEM_DG_PROJECTION_INTERFACE_HPP
6
8
9namespace MoFEM {
10
11struct ForcesAndSourcesCore;
12
13/** L2 projection in one Core database using one sub-DM of a caller-owned DM.
14 * Source fields are H1/L2 and targets are L2 on affine triangles/tetrahedra.
15 * Integration-point tags use field-free L2 operators. Each target point is
16 * sampled from a source cell available locally; uncovered points take
17 * the empty value. Standard quadrature does not exactly integrate DG jumps
18 * cutting a target element. Components are Cartesian values (1 through 9);
19 * physical history/frame updates are separate. The caller supplies suitable
20 * entity support, geometry and quadrature. Field maps use caller-owned fields;
21 * tag maps use field-free L2 operators on the supplied finite element. One
22 * request projects several fields or tags at once.
23 */
29
30 /// Same signatures as ForcesAndSourcesCore::getRuleHook and setRuleHook.
31 using RuleHook =
32 boost::function<int(int order_row, int order_col, int order_data)>;
34 boost::function<MoFEMErrorCode(ForcesAndSourcesCore *fe_raw_ptr,
35 int order_row, int order_col,
36 int order_data)>;
38 RuleHook ruleHook; ///< Order of a standard rule.
39 SetRuleHook setRuleHook; ///< Explicit points and weights; takes precedence.
40 };
41
42 /// Pairs of source and target field names, projected together.
43 using FieldMap = std::vector<std::pair<std::string, std::string>>;
44 /// Pairs of source and target tag names, and the L2 order of reconstruction
45 /// and projection shared by all pairs. A missing target tag is created from
46 /// its source tag. Tags store the components of each integration point,
47 /// point-major; the number of components, 1 through 9, is the source tag
48 /// length divided by the number of source rule points.
49 using TagMap =
50 std::tuple<std::vector<std::pair<std::string, std::string>>, int>;
51
52 struct Options {
53 int quadratureOrder = -1; ///< Required for nonempty local targets.
54 double emptyValue = 0.; ///< Uncovered points; tags use their default.
55 IntegrationRule sourceRule; ///< Tags: rule that wrote the source values.
56 IntegrationRule targetRule; ///< Tags: rule of the stored target values.
57 std::string optionsPrefix =
58 "dg_projection_"; ///< Reserved for later H1 KSPs.
59 };
60 /// Source cells needed by local targets must be present locally, including
61 /// caller-provided ghosts with up-to-date field or tag data.
62 template <typename MAP> struct Request {
63 DM dm = nullptr; ///< Caller-owned MoFEM DM spanning both mesh levels.
64 std::string elementName; ///< Caller-owned finite element used for projection.
66 MAP maps;
68 };
69
70 struct FieldReport {
71 std::string targetField;
72 double relativeMassResidual = 0.; ///< Algebraic, not quadrature error.
73 };
74 struct TagReport {
75 std::string targetTag;
76 double relativeMassResidual = 0.; ///< Target local solves.
77 double sourceRelativeMassResidual = 0.; ///< Source reconstruction.
78 unsigned long long sourceElementsWithoutData = 0;
79 };
80 template <typename ITEM> struct Report {
81 unsigned long long targetElements = 0; ///< Local selected count.
82 unsigned long long sampledPoints = 0; ///< Target quadrature queries.
83 unsigned long long missingPoints = 0; ///< Took the empty value.
84 std::vector<ITEM> items;
85 };
86
87 /// Collective on the supplied DM communicator; ranks use the same element,
88 /// mesh levels and field maps. Each rank processes locally available cells.
89 /// An empty local target selection returns an empty report after sub-DM setup.
90 /// Store each element's projected coefficients and release the sub-DM.
91 /// An error during the element loop may leave earlier elements updated.
92 /// Existing application vectors are not updated; the result is field data.
95
96 /// Reconstruct source tags in element-local coefficient buffers, project
97 /// them and store target tags at the target rule; published if every map
98 /// succeeds. Collective on the supplied DM communicator; ranks use the same
99 /// element, mesh levels and tag maps.
100 virtual MoFEMErrorCode project(const Request<TagMap> &request,
102};
103
104template <>
106
107} // namespace MoFEM
108#endif
Report & report
MoFEM interface.
PetscErrorCode MoFEMErrorCode
MoFEM/PETSc error code.
std::bitset< BITREFLEVEL_SIZE > BitRefLevel
Bit structure attached to each entity identifying to what mesh entity is attached.
Definition Types.hpp:40
implementation of Data Operators for Forces and Sources
Definition Common.hpp:10
DGProjectionInterface * createInterface< DGProjectionInterface >(const Core &core)
Core (interface) class.
Definition Core.hpp:83
double relativeMassResidual
Algebraic, not quadrature error.
SetRuleHook setRuleHook
Explicit points and weights; takes precedence.
std::string optionsPrefix
Reserved for later H1 KSPs.
IntegrationRule targetRule
Tags: rule of the stored target values.
IntegrationRule sourceRule
Tags: rule that wrote the source values.
int quadratureOrder
Required for nonempty local targets.
double emptyValue
Uncovered points; tags use their default.
unsigned long long missingPoints
Took the empty value.
unsigned long long targetElements
Local selected count.
unsigned long long sampledPoints
Target quadrature queries.
DM dm
Caller-owned MoFEM DM spanning both mesh levels.
std::string elementName
Caller-owned finite element used for projection.
double sourceRelativeMassResidual
Source reconstruction.
std::tuple< std::vector< std::pair< std::string, std::string > >, int > TagMap
virtual MoFEMErrorCode project(const Request< FieldMap > &request, Report< FieldReport > &report)=0
boost::function< MoFEMErrorCode(ForcesAndSourcesCore *fe_raw_ptr, int order_row, int order_col, int order_data)> SetRuleHook
virtual MoFEMErrorCode project(const Request< TagMap > &request, Report< TagReport > &report)=0
boost::function< int(int order_row, int order_col, int order_data)> RuleHook
Same signatures as ForcesAndSourcesCore::getRuleHook and setRuleHook.
std::vector< std::pair< std::string, std::string > > FieldMap
Pairs of source and target field names, projected together.
structure to get information from mofem into EntitiesFieldData
base class for all interface classes