v0.15.0
Loading...
Searching...
No Matches
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.
 
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
 
MatrixDouble locMat
 local operator matrix
 

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) {}
BoundaryEle::UserDataOperator BoundaryEleOp
@ NOSPACE
Definition definitions.h:83
boost::shared_ptr< FaceSideEle > sideFEPtr
pointer to element to get data on edge/face sides

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 }
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return()
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
#define CHKERR
Inline error check.
#define MOFEM_LOG(channel, severity)
Log.
std::array< MatrixDouble, 2 > rowBaseSideMap
std::array< VectorInt, 2 > indicesColSideMap
indices on columns for left hand-side
std::array< MatrixDouble, 2 > colDiffBaseSideMap
std::array< MatrixDouble, 2 > colBaseSideMap
std::array< VectorInt, 2 > indicesRowSideMap
indices on rows for left hand-side
std::array< MatrixDouble, 2 > rowDiffBaseSideMap
static double nitsche
static double penalty
static double phi

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: