v0.15.0
Loading...
Searching...
No Matches
DGProjection.cpp
Go to the documentation of this file.
1/**
2 * @file DGProjection.cpp
3 */
4
5namespace MoFEM {
6
8 int order, boost::shared_ptr<MatrixDouble> mass_ptr,
9 boost::shared_ptr<EntitiesFieldData> data_l2,
10 const FieldApproximationBase b, const FieldSpace s, int verb, Sev sev)
11 : OpBaseDerivativesBase(mass_ptr, data_l2, b, s, verb, sev),
12 baseOrder(order) {}
13
15OpDGProjectionMassMatrix::doWork(int side, EntityType type,
18
19 if (sPace != L2) {
20 SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
21 "Space should be set to L2");
22 }
23
25
26 [this]() { return this->baseOrder; }
27
28 );
30
32}
33
35 boost::shared_ptr<MatrixDouble> data_ptr,
36 boost::shared_ptr<MatrixDouble> coeffs_ptr,
37 boost::shared_ptr<MatrixDouble> mass_ptr,
38 boost::shared_ptr<EntitiesFieldData> data_l2,
39 const FieldApproximationBase b, const FieldSpace s,
41 : OpBaseDerivativesBase(mass_ptr, data_l2, b, s, VERBOSE, sev),
42 dataPtr(data_ptr), coeffsPtr(coeffs_ptr) {}
43
45OpDGProjectionCoefficients::doWork(int side, EntityType type,
48 auto nb_integration_pts = getGaussPts().size2();
49
50 const auto fe_type = getFEType();
51 constexpr auto side_number = 0;
52 auto &ent_data = dataL2->dataOnEntities[fe_type][side_number];
53 auto nb_base_functions = ent_data.getN(base).size2();
54
55 auto nb_data_coeffs = dataPtr->size1();
56 auto &rhs = *coeffsPtr;
57 auto &data = *dataPtr;
58
59 rhs.resize(nb_base_functions, nb_data_coeffs, false);
60 rhs.clear();
61
63 MatrixDouble trans_data = trans(data);
64
65 // assemble rhs
66 auto t_base = ent_data.getFTensor0N(base, 0, 0);
68 for (auto gg = 0; gg != nb_integration_pts; ++gg) {
69 Tensor0 t_rhs(&*rhs.data().begin());
70 for (auto bb = 0; bb != nb_base_functions; ++bb) {
71 double alpha = t_w * t_base;
72 Tensor0 t_data(&trans_data(gg, 0));
73 for (auto cc = 0; cc != nb_data_coeffs; ++cc) {
74 t_rhs += alpha * t_data;
75 ++t_data;
76 ++t_rhs;
77 }
78 ++t_base;
79 }
80 ++t_w;
81 }
82
83 // solve for coefficients
84 for (auto cc = 0; cc != nb_data_coeffs; ++cc) {
85 ublas::matrix_column<MatrixDouble> mc(rhs, cc);
86 cholesky_solve(*baseMassPtr, mc, ublas::lower());
87 }
88
90}
91
93 boost::shared_ptr<MatrixDouble> data_ptr,
94 boost::shared_ptr<MatrixDouble> coeffs_ptr,
95 boost::shared_ptr<EntitiesFieldData> data_l2,
96 const FieldApproximationBase b, const FieldSpace s,
98 : OpDGProjectionCoefficients(data_ptr, coeffs_ptr,
99 boost::make_shared<MatrixDouble>(), data_l2, b,
100 s, sev) {}
101
103OpDGProjectionEvaluation::doWork(int side, EntityType type,
105
107
108 if (sPace != L2) {
109 SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
110 "Space should be set to L2");
111 }
112
113 auto fe_type = getFEType();
114 constexpr auto side_number = 0;
115 auto order = dataL2->dataOnEntities[fe_type][side_number].getOrder();
117
118 [order]() { return order; }
119
120 );
121
122 auto &ent_data = dataL2->dataOnEntities[fe_type][side_number];
123 const auto nb_base_functions = ent_data.getN(base).size2();
124 auto nb_data_coeffs = dataPtr->size1();
125 if (!nb_data_coeffs) {
126 SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
127 "Number of data coefficients should be set");
128 }
129 auto &data = *dataPtr;
130 auto &coeffs = *coeffsPtr;
131
132 auto nb_integration_pts = getGaussPts().size2();
133 data.resize(nb_integration_pts, nb_data_coeffs);
134 data.clear();
135
137
138 auto t_base = ent_data.getFTensor0N(base, 0, 0);
139 for (auto gg = 0; gg != nb_integration_pts; ++gg) {
140 Tensor0 t_coeffs(&*coeffs.data().begin());
141 for (auto bb = 0; bb != nb_base_functions; ++bb) {
142 double alpha = t_base;
143 Tensor0 t_data(&data(gg, 0));
144 for (auto cc = 0; cc != nb_data_coeffs; ++cc) {
145 t_data += alpha * t_coeffs;
146 ++t_data;
147 ++t_coeffs;
148 }
149 ++t_base;
150 }
151 }
152
153 *dataPtr = trans(*dataPtr);
154
156}
157} // namespace MoFEM
void cholesky_solve(const TRIA &L, VEC &x, ublas::lower)
solve system L L^T x = b inplace
Definition cholesky.hpp:221
@ VERBOSE
FieldApproximationBase
approximation base
Definition definitions.h:58
FieldSpace
approximation spaces
Definition definitions.h:82
@ L2
field with C-1 continuity
Definition definitions.h:88
#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
SeverityLevel
Severity levels.
PetscErrorCode MoFEMErrorCode
MoFEM/PETSc error code.
implementation of Data Operators for Forces and Sources
Definition Common.hpp:10
Data on single entity (This is passed as argument to DataOperator::doWork)
EntityType getFEType() const
Get dimension of finite element.
auto getFTensor0IntegrationWeight()
Get integration weights.
MatrixDouble & getGaussPts()
matrix of integration (Gauss) points for Volume Element
boost::shared_ptr< EntitiesFieldData > dataL2
MoFEMErrorCode calculateBase(GetOrderFun get_order)
boost::shared_ptr< MatrixDouble > baseMassPtr
boost::shared_ptr< MatrixDouble > coeffsPtr
boost::shared_ptr< MatrixDouble > dataPtr
MoFEMErrorCode doWork(int side, EntityType type, EntitiesFieldData::EntData &data)
Operator for linear form, usually to calculate values on right hand side.
OpDGProjectionCoefficients(boost::shared_ptr< MatrixDouble > data_ptr, boost::shared_ptr< MatrixDouble > coeffs_ptr, boost::shared_ptr< MatrixDouble > mass_ptr, boost::shared_ptr< EntitiesFieldData > data_l2, const FieldApproximationBase b, const FieldSpace s, const LogManager::SeverityLevel sev=Sev::noisy)
MoFEMErrorCode doWork(int side, EntityType type, EntitiesFieldData::EntData &data)
Operator for linear form, usually to calculate values on right hand side.
OpDGProjectionEvaluation(boost::shared_ptr< MatrixDouble > data_ptr, boost::shared_ptr< MatrixDouble > coeffs_ptr, boost::shared_ptr< EntitiesFieldData > data_l2, const FieldApproximationBase b, const FieldSpace s, const LogManager::SeverityLevel sev=Sev::noisy)
MoFEMErrorCode doWork(int side, EntityType type, EntitiesFieldData::EntData &data)
Operator for linear form, usually to calculate values on right hand side.
OpDGProjectionMassMatrix(int order, boost::shared_ptr< MatrixDouble > mass_ptr, boost::shared_ptr< EntitiesFieldData > data_l2, const FieldApproximationBase b, const FieldSpace s, int verb=QUIET, Sev sev=Sev::verbose)