v0.14.0
DGProjection.cpp
Go to the documentation of this file.
1 /**
2  * @file DGProjection.cpp
3  */
4 
5 namespace 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 
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,
40  const LogManager::SeverityLevel sev)
41  : OpBaseDerivativesBase(mass_ptr, data_l2, b, s, VERBOSE, sev),
42  dataPtr(data_ptr), coeffsPtr(coeffs_ptr) {}
43 
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);
67  auto t_w = getFTensor0IntegrationWeight();
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,
97  const LogManager::SeverityLevel sev)
98  : OpDGProjectionCoefficients(data_ptr, coeffs_ptr,
99  boost::make_shared<MatrixDouble>(), data_l2, b,
100  s, sev) {}
101 
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
UBlasMatrix< double >
MoFEM::OpBaseDerivativesBase::calculateBase
MoFEMErrorCode calculateBase(GetOrderFun get_order)
Definition: BaseDerivativesDataOperators.cpp:20
MoFEM::OpBaseDerivativesBase::base
FieldApproximationBase base
Definition: BaseDerivativesDataOperators.hpp:21
MoFEM::EntitiesFieldData::EntData
Data on single entity (This is passed as argument to DataOperator::doWork)
Definition: EntitiesFieldData.hpp:128
MoFEM::OpDGProjectionMassMatrix::doWork
MoFEMErrorCode doWork(int side, EntityType type, EntitiesFieldData::EntData &data)
Operator for linear form, usually to calculate values on right hand side.
Definition: DGProjection.cpp:15
MoFEM::OpDGProjectionEvaluation::doWork
MoFEMErrorCode doWork(int side, EntityType type, EntitiesFieldData::EntData &data)
Operator for linear form, usually to calculate values on right hand side.
Definition: DGProjection.cpp:103
MoFEM::ForcesAndSourcesCore::UserDataOperator::getFEType
EntityType getFEType() const
Get dimension of finite element.
Definition: ForcesAndSourcesCore.hpp:1012
MoFEM::OpBaseDerivativesBase::baseMassPtr
boost::shared_ptr< MatrixDouble > baseMassPtr
Definition: BaseDerivativesDataOperators.hpp:25
L2
@ L2
field with C-1 continuity
Definition: definitions.h:88
MoFEM::Exceptions::MoFEMErrorCode
PetscErrorCode MoFEMErrorCode
MoFEM/PETSc error code.
Definition: Exceptions.hpp:56
MoFEM::OpDGProjectionCoefficients
Definition: DGProjection.hpp:119
MoFEM::OpBaseDerivativesBase::dataL2
boost::shared_ptr< EntitiesFieldData > dataL2
Definition: BaseDerivativesDataOperators.hpp:26
order
constexpr int order
Definition: dg_projection.cpp:18
MoFEM::ForcesAndSourcesCore::UserDataOperator::getFTensor0IntegrationWeight
auto getFTensor0IntegrationWeight()
Get integration weights.
Definition: ForcesAndSourcesCore.hpp:1240
MoFEM::ForcesAndSourcesCore::UserDataOperator::getGaussPts
MatrixDouble & getGaussPts()
matrix of integration (Gauss) points for Volume Element
Definition: ForcesAndSourcesCore.hpp:1236
FieldSpace
FieldSpace
approximation spaces
Definition: definitions.h:82
MoFEM::OpBaseDerivativesBase::calculateMass
MoFEMErrorCode calculateMass()
Definition: BaseDerivativesDataOperators.cpp:54
VERBOSE
@ VERBOSE
Definition: definitions.h:222
CHKERR
#define CHKERR
Inline error check.
Definition: definitions.h:548
MoFEM::OpDGProjectionCoefficients::coeffsPtr
boost::shared_ptr< MatrixDouble > coeffsPtr
Definition: DGProjection.hpp:133
MoFEM
implementation of Data Operators for Forces and Sources
Definition: Common.hpp:10
MoFEM::OpDGProjectionCoefficients::dataPtr
boost::shared_ptr< MatrixDouble > dataPtr
Definition: DGProjection.hpp:132
convert.type
type
Definition: convert.py:64
MoFEM::LogManager::SeverityLevel
SeverityLevel
Severity levels.
Definition: LogManager.hpp:33
MoFEM::OpBaseDerivativesBase
Definition: BaseDerivativesDataOperators.hpp:13
MoFEM::OpDGProjectionEvaluation::OpDGProjectionEvaluation
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)
Definition: DGProjection.cpp:92
FTensor::Tensor0
Definition: Tensor0.hpp:16
MoFEM::OpDGProjectionMassMatrix::OpDGProjectionMassMatrix
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)
Definition: DGProjection.cpp:7
MOFEM_DATA_INCONSISTENCY
@ MOFEM_DATA_INCONSISTENCY
Definition: definitions.h:31
cholesky_solve
void cholesky_solve(const TRIA &L, VEC &x, ublas::lower)
solve system L L^T x = b inplace
Definition: cholesky.hpp:221
MoFEM::ForcesAndSourcesCore::UserDataOperator::sPace
FieldSpace sPace
Definition: ForcesAndSourcesCore.hpp:579
FieldApproximationBase
FieldApproximationBase
approximation base
Definition: definitions.h:58
MoFEM::OpDGProjectionMassMatrix::baseOrder
int baseOrder
Definition: DGProjection.hpp:116
MoFEM::OpDGProjectionCoefficients::OpDGProjectionCoefficients
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)
Definition: DGProjection.cpp:34
MoFEM::OpDGProjectionCoefficients::doWork
MoFEMErrorCode doWork(int side, EntityType type, EntitiesFieldData::EntData &data)
Operator for linear form, usually to calculate values on right hand side.
Definition: DGProjection.cpp:45
MoFEMFunctionReturn
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:429
MoFEMFunctionBegin
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:359