v0.14.0
Public Member Functions | Private Attributes | List of all members
Poisson2DiscontGalerkinOperators::OpL2LhsPenalty Struct Reference

Operator the left hand side matrix. More...

#include <tutorials/scl-11/src/PoissonDiscontinousGalerkin.hpp>

Inheritance diagram for Poisson2DiscontGalerkinOperators::OpL2LhsPenalty:
[legend]
Collaboration diagram for Poisson2DiscontGalerkinOperators::OpL2LhsPenalty:
[legend]

Public Member Functions

 OpL2LhsPenalty (boost::shared_ptr< FaceSideEle > side_fe_ptr)
 Construct a new OpL2LhsPenalty. More...
 
MoFEMErrorCode doWork (int side, EntityType type, EntitiesFieldData::EntData &data)
 

Private Attributes

boost::shared_ptr< FaceSideElesideFEPtr
 pointer to element to get data on edge/face sides More...
 
MatrixDouble locMat
 local operator matrix More...
 

Detailed Description

Operator the left hand side matrix.

Examples
poisson_2d_dis_galerkin.cpp.

Definition at line 115 of file PoissonDiscontinousGalerkin.hpp.

Constructor & Destructor Documentation

◆ OpL2LhsPenalty()

Poisson2DiscontGalerkinOperators::OpL2LhsPenalty::OpL2LhsPenalty ( boost::shared_ptr< FaceSideEle side_fe_ptr)
inline

Construct a new OpL2LhsPenalty.

Parameters
side_fe_ptrpointer to FE to evaluate side elements
Examples
PoissonDiscontinousGalerkin.hpp.

Definition at line 123 of file PoissonDiscontinousGalerkin.hpp.

124  : BoundaryEleOp(NOSPACE, BoundaryEleOp::OPSPACE), sideFEPtr(side_fe_ptr) {}

Member Function Documentation

◆ doWork()

MoFEMErrorCode Poisson2DiscontGalerkinOperators::OpL2LhsPenalty::doWork ( int  side,
EntityType  type,
EntitiesFieldData::EntData data 
)
inline
Examples
PoissonDiscontinousGalerkin.hpp.

Definition at line 126 of file PoissonDiscontinousGalerkin.hpp.

127  {
129 
130  // Collect data from side domian elements
131  CHKERR loopSideFaces("dFE", *sideFEPtr);
132  const auto in_the_loop =
133  sideFEPtr->nInTheLoop; // return number of elements on the side
134 
135 #ifndef NDEBUG
136  const std::array<std::string, 2> ele_type_name = {"BOUNDARY", "SKELETON"};
137  MOFEM_LOG("SELF", Sev::noisy)
138  << "OpL2LhsPenalty inTheLoop " << ele_type_name[in_the_loop];
139  MOFEM_LOG("SELF", Sev::noisy)
140  << "OpL2LhsPenalty sense " << senseMap[0] << " " << senseMap[1];
141 #endif
142 
143  // calculate penalty
144  const double s = getMeasure() / (areaMap[0] + areaMap[1]);
145  const double p = penalty * s;
146 
147  // get normal of the face or edge
148  auto t_normal = getFTensor1Normal();
149  t_normal.normalize();
150 
151  // get number of integration points on face
152  const size_t nb_integration_pts = getGaussPts().size2();
153 
154  // beta paramter is zero, when penalty method is used, also, takes value 1,
155  // when boundary edge/face is evaluated, and 2 when is skeleton edge/face.
156  const double beta = static_cast<double>(nitsche) / (in_the_loop + 1);
157 
158  // iterate the sides rows
159  for (auto s0 : {LEFT_SIDE, RIGHT_SIDE}) {
160 
161  // gent number of DOFs on the right side.
162  const auto nb_rows = indicesRowSideMap[s0].size();
163 
164  if (nb_rows) {
165 
166  // get orientation of the local element edge
167  const auto sense_row = senseMap[s0];
168 
169  // iterate the side cols
170  const auto nb_row_base_functions = rowBaseSideMap[s0].size2();
171  for (auto s1 : {LEFT_SIDE, RIGHT_SIDE}) {
172 
173  // get orientation of the edge
174  const auto sense_col = senseMap[s1];
175 
176  // number of dofs, for homogenous approximation this value is
177  // constant.
178  const auto nb_cols = indicesColSideMap[s1].size();
179 
180  // resize local element matrix
181  locMat.resize(nb_rows, nb_cols, false);
182  locMat.clear();
183 
184  // get base functions, and integration weights
185  auto t_row_base = get_ntensor(rowBaseSideMap[s0]);
186  auto t_diff_row_base = get_diff_ntensor(rowDiffBaseSideMap[s0]);
187  auto t_w = getFTensor0IntegrationWeight();
188 
189  // iterate integration points on face/edge
190  for (size_t gg = 0; gg != nb_integration_pts; ++gg) {
191 
192  // t_w is integration weight, and measure is element area, or
193  // volume, depending if problem is in 2d/3d.
194  const double alpha = getMeasure() * t_w;
195  auto t_mat = locMat.data().begin();
196 
197  // iterate rows
198  size_t rr = 0;
199  for (; rr != nb_rows; ++rr) {
200 
201  // calculate tetting function
203  t_vn_plus(i) = beta * (phi * t_diff_row_base(i) / p);
205  t_vn(i) = t_row_base * t_normal(i) * sense_row - t_vn_plus(i);
206 
207  // get base functions on columns
208  auto t_col_base = get_ntensor(colBaseSideMap[s1], gg, 0);
209  auto t_diff_col_base =
211 
212  // iterate columns
213  for (size_t cc = 0; cc != nb_cols; ++cc) {
214 
215  // calculate variance of tested function
217  t_un(i) = -p * (t_col_base * t_normal(i) * sense_col -
218  beta * t_diff_col_base(i) / p);
219 
220  // assemble matrix
221  *t_mat -= alpha * (t_vn(i) * t_un(i));
222  *t_mat -= alpha * (t_vn_plus(i) * (beta * t_diff_col_base(i)));
223 
224  // move to next column base and element of matrix
225  ++t_col_base;
226  ++t_diff_col_base;
227  ++t_mat;
228  }
229 
230  // move to next row base
231  ++t_row_base;
232  ++t_diff_row_base;
233  }
234 
235  // this is obsolete for this particular example, we keep it for
236  // generality. in case of multi-physics problems different fields can
237  // chare hierarchical base but use different approx. order, so is
238  // possible to have more base functions than DOFs on element.
239  for (; rr < nb_row_base_functions; ++rr) {
240  ++t_row_base;
241  ++t_diff_row_base;
242  }
243 
244  ++t_w;
245  }
246 
247  // assemble system
248  CHKERR ::MatSetValues(getKSPB(), indicesRowSideMap[s0].size(),
249  &*indicesRowSideMap[s0].begin(),
250  indicesColSideMap[s1].size(),
251  &*indicesColSideMap[s1].begin(),
252  &*locMat.data().begin(), ADD_VALUES);
253 
254  // stop of boundary element
255  if (!in_the_loop)
257  }
258  }
259  }
260 
262  }

Member Data Documentation

◆ locMat

MatrixDouble Poisson2DiscontGalerkinOperators::OpL2LhsPenalty::locMat
private

local operator matrix

Examples
PoissonDiscontinousGalerkin.hpp.

Definition at line 267 of file PoissonDiscontinousGalerkin.hpp.

◆ sideFEPtr

boost::shared_ptr<FaceSideEle> Poisson2DiscontGalerkinOperators::OpL2LhsPenalty::sideFEPtr
private

pointer to element to get data on edge/face sides

Examples
PoissonDiscontinousGalerkin.hpp.

Definition at line 266 of file PoissonDiscontinousGalerkin.hpp.


The documentation for this struct was generated from the following file:
NOSPACE
@ NOSPACE
Definition: definitions.h:83
MoFEMFunctionReturnHot
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:460
Poisson2DiscontGalerkinOperators::indicesRowSideMap
std::array< VectorInt, 2 > indicesRowSideMap
indices on rows for left hand-side
Definition: PoissonDiscontinousGalerkin.hpp:23
MoFEM::MatSetValues
MoFEMErrorCode MatSetValues(Mat M, const EntitiesFieldData::EntData &row_data, const EntitiesFieldData::EntData &col_data, const double *ptr, InsertMode iora)
Assemble PETSc matrix.
Definition: EntitiesFieldData.hpp:1644
FTensor::Tensor1
Definition: Tensor1_value.hpp:8
Poisson2DiscontGalerkinOperators::LEFT_SIDE
@ LEFT_SIDE
Definition: PoissonDiscontinousGalerkin.hpp:20
phi
static double phi
Definition: poisson_2d_dis_galerkin.cpp:30
Poisson2DiscontGalerkinOperators::i
FTensor::Index< 'i', SPACE_DIM > i
Definition: PoissonDiscontinousGalerkin.hpp:18
Poisson2DiscontGalerkinOperators::rowBaseSideMap
std::array< MatrixDouble, 2 > rowBaseSideMap
Definition: PoissonDiscontinousGalerkin.hpp:26
Poisson2DiscontGalerkinOperators::get_diff_ntensor
auto get_diff_ntensor(T &base_mat)
Definition: PoissonDiscontinousGalerkin.hpp:100
Poisson2DiscontGalerkinOperators::colDiffBaseSideMap
std::array< MatrixDouble, 2 > colDiffBaseSideMap
Definition: PoissonDiscontinousGalerkin.hpp:29
CHKERR
#define CHKERR
Inline error check.
Definition: definitions.h:548
Poisson2DiscontGalerkinOperators::OpL2LhsPenalty::sideFEPtr
boost::shared_ptr< FaceSideEle > sideFEPtr
pointer to element to get data on edge/face sides
Definition: PoissonDiscontinousGalerkin.hpp:266
BoundaryEleOp
BoundaryEle::UserDataOperator BoundaryEleOp
Definition: child_and_parent.cpp:40
Poisson2DiscontGalerkinOperators::get_ntensor
auto get_ntensor(T &base_mat)
Definition: PoissonDiscontinousGalerkin.hpp:90
nitsche
static double nitsche
Definition: poisson_2d_dis_galerkin.cpp:32
Poisson2DiscontGalerkinOperators::rowDiffBaseSideMap
std::array< MatrixDouble, 2 > rowDiffBaseSideMap
Definition: PoissonDiscontinousGalerkin.hpp:28
penalty
constexpr double penalty
Definition: shallow_wave.cpp:75
MOFEM_LOG
#define MOFEM_LOG(channel, severity)
Log.
Definition: LogManager.hpp:308
Poisson2DiscontGalerkinOperators::areaMap
std::array< double, 2 > areaMap
Definition: PoissonDiscontinousGalerkin.hpp:30
Poisson2DiscontGalerkinOperators::colBaseSideMap
std::array< MatrixDouble, 2 > colBaseSideMap
Definition: PoissonDiscontinousGalerkin.hpp:27
Poisson2DiscontGalerkinOperators::OpL2LhsPenalty::locMat
MatrixDouble locMat
local operator matrix
Definition: PoissonDiscontinousGalerkin.hpp:267
Poisson2DiscontGalerkinOperators::RIGHT_SIDE
@ RIGHT_SIDE
Definition: PoissonDiscontinousGalerkin.hpp:20
Poisson2DiscontGalerkinOperators::indicesColSideMap
std::array< VectorInt, 2 > indicesColSideMap
indices on columns for left hand-side
Definition: PoissonDiscontinousGalerkin.hpp:25
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
Poisson2DiscontGalerkinOperators::senseMap
std::array< int, 2 > senseMap
Definition: PoissonDiscontinousGalerkin.hpp:31