v0.14.0
Public Member Functions | Private Attributes | List of all members
OpH1LhsSkeleton Struct Reference

Operator the left hand side matrix. More...

Inheritance diagram for OpH1LhsSkeleton:
[legend]
Collaboration diagram for OpH1LhsSkeleton:
[legend]

Public Member Functions

 OpH1LhsSkeleton (boost::shared_ptr< FaceSideEle > side_fe_ptr, boost::shared_ptr< MatrixDouble > d_mat_ptr)
 Construct a new OpH1LhsSkeleton. 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...
 
boost::shared_ptr< MatrixDouble > dMatPtr
 

Detailed Description

Operator the left hand side matrix.

Examples
plate.cpp.

Definition at line 120 of file plate.cpp.

Constructor & Destructor Documentation

◆ OpH1LhsSkeleton()

OpH1LhsSkeleton::OpH1LhsSkeleton ( boost::shared_ptr< FaceSideEle side_fe_ptr,
boost::shared_ptr< MatrixDouble >  mat_d_ptr 
)

Construct a new OpH1LhsSkeleton.

Parameters
side_fe_ptrpointer to FE to evaluate side elements
Examples
plate.cpp.

Definition at line 505 of file plate.cpp.

507  : BoundaryEleOp(NOSPACE, BoundaryEleOp::OPSPACE), sideFEPtr(side_fe_ptr),
508  dMatPtr(mat_d_ptr) {}

Member Function Documentation

◆ doWork()

MoFEMErrorCode OpH1LhsSkeleton::doWork ( int  side,
EntityType  type,
EntitiesFieldData::EntData data 
)
Examples
plate.cpp.

Definition at line 510 of file plate.cpp.

511  {
513 
514  // Collect data from side domian elements
515  CHKERR loopSideFaces("dFE", *sideFEPtr);
516  const auto in_the_loop =
517  sideFEPtr->nInTheLoop; // return number of elements on the side
518 
519  // calculate penalty
520  const double s = getMeasure() / (areaMap[0] + areaMap[1]);
521  const double p = penalty * s;
522 
523  // get normal of the face or edge
524  auto t_normal = getFTensor1Normal();
525  t_normal.normalize();
526 
527  // Elastic stiffness tensor (4th rank tensor with minor and major
528  // symmetry)
529  auto t_D = getFTensor4DdgFromMat<SPACE_DIM, SPACE_DIM, 0>(*dMatPtr);
530 
531  // get number of integration points on face
532  const size_t nb_integration_pts = getGaussPts().size2();
533 
534  // beta paramter is zero, when penalty method is used, also, takes value 1,
535  // when boundary edge/face is evaluated, and 2 when is skeleton edge/face.
536  const double beta = static_cast<double>(nitsche) / (in_the_loop + 1);
537 
538  auto integrate = [&](auto sense_row, auto &row_ind, auto &row_diff,
539  auto &row_diff2, auto sense_col, auto &col_ind,
540  auto &col_diff, auto &col_diff2) {
542 
543  // number of dofs, for homogenous approximation this value is
544  // constant.
545  const auto nb_rows = row_ind.size();
546  const auto nb_cols = col_ind.size();
547 
548  const auto nb_row_base_functions = row_diff.size2() / SPACE_DIM;
549 
550  if (nb_cols) {
551 
552  // resize local element matrix
553  locMat.resize(nb_rows, nb_cols, false);
554  locMat.clear();
555 
556  // get base functions, and integration weights
557  auto t_diff_row_base = get_diff_ntensor(row_diff);
558  auto t_diff2_row_base = get_diff2_ntensor(row_diff2);
559 
560  auto t_w = getFTensor0IntegrationWeight();
561 
562  // iterate integration points on face/edge
563  for (size_t gg = 0; gg != nb_integration_pts; ++gg) {
564 
565  // t_w is integration weight, and measure is element area, or
566  // volume, depending if problem is in 2d/3d.
567  const double alpha = getMeasure() * t_w;
568  auto t_mat = locMat.data().begin();
569 
570  // iterate rows
571  size_t rr = 0;
572  for (; rr != nb_rows; ++rr) {
573 
575  t_mv(i, j) = t_D(i, j, k, l) * t_diff2_row_base(k, l);
576 
577  // calculate tetting function
579  t_vn_plus(i, j) = beta * (phi * t_mv(i, j) / p);
581  t_vn(i, j) = (t_diff_row_base(j) * (t_normal(i) * sense_row)) -
582  t_vn_plus(i, j);
583 
584  // get base functions on columns
585  auto t_diff_col_base = get_diff_ntensor(col_diff, gg, 0);
586  auto t_diff2_col_base = get_diff2_ntensor(col_diff2, gg, 0);
587 
588  // iterate columns
589  for (size_t cc = 0; cc != nb_cols; ++cc) {
590 
592  t_mu(i, j) = t_D(i, j, k, l) * t_diff2_col_base(k, l);
593 
594  // // calculate variance of tested function
596  t_un(i, j) = -p * ((t_diff_col_base(j) * (t_normal(i) * sense_col) -
597  beta * t_mu(i, j) / p));
598 
599  // assemble matrix
600  *t_mat -= alpha * (t_vn(i, j) * t_un(i, j));
601  *t_mat -= alpha * (t_vn_plus(i, j) * (beta * t_mu(i, j)));
602 
603  // move to next column base and element of matrix
604  ++t_diff_col_base;
605  ++t_diff2_col_base;
606  ++t_mat;
607  }
608 
609  // move to next row base
610  ++t_diff_row_base;
611  ++t_diff2_row_base;
612  }
613 
614  // this is obsolete for this particular example, we keep it for
615  // generality. in case of multi-physcis problems diffrent fields
616  // can chare hierarchical base but use diffrent approx. order,
617  // so is possible to have more base functions than DOFs on
618  // element.
619  for (; rr < nb_row_base_functions; ++rr) {
620  ++t_diff_row_base;
621  ++t_diff2_row_base;
622  }
623 
624  ++t_w;
625  }
626 
627  // assemble system
628  CHKERR ::MatSetValues(getKSPB(), nb_rows, &*row_ind.begin(),
629  col_ind.size(), &*col_ind.begin(),
630  &*locMat.data().begin(), ADD_VALUES);
631  }
632 
634  };
635 
636  // iterate the sides rows
637  for (auto s0 : {LEFT_SIDE, RIGHT_SIDE}) {
638 
639  const auto sense_row = senseMap[s0];
640 
641  for (auto x0 = 0; x0 != indicesSideMap[s0].size(); ++x0) {
642 
643  for (auto s1 : {LEFT_SIDE, RIGHT_SIDE}) {
644  const auto sense_col = senseMap[s1];
645 
646  for (auto x1 = 0; x1 != indicesSideMap[s1].size(); ++x1) {
647 
648  CHKERR integrate(sense_row, indicesSideMap[s0][x0],
649  diffBaseSideMap[s0][x0], diff2BaseSideMap[s0][x0],
650 
651  sense_col, indicesSideMap[s1][x1],
652  diffBaseSideMap[s1][x1], diff2BaseSideMap[s1][x1]
653 
654  );
655  }
656  }
657  }
658  }
659 
661 }

Member Data Documentation

◆ dMatPtr

boost::shared_ptr<MatrixDouble> OpH1LhsSkeleton::dMatPtr
private
Examples
plate.cpp.

Definition at line 137 of file plate.cpp.

◆ locMat

MatrixDouble OpH1LhsSkeleton::locMat
private

local operator matrix

Examples
plate.cpp.

Definition at line 136 of file plate.cpp.

◆ sideFEPtr

boost::shared_ptr<FaceSideEle> OpH1LhsSkeleton::sideFEPtr
private

pointer to element to get data on edge/face sides

Examples
plate.cpp.

Definition at line 135 of file plate.cpp.


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
senseMap
std::array< int, 2 > senseMap
Definition: plate.cpp:102
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
OpH1LhsSkeleton::sideFEPtr
boost::shared_ptr< FaceSideEle > sideFEPtr
pointer to element to get data on edge/face sides
Definition: plate.cpp:135
k
FTensor::Index< 'k', SPACE_DIM > k
Definition: plate.cpp:62
SPACE_DIM
constexpr int SPACE_DIM
dimension of space
Definition: plate.cpp:17
l
FTensor::Index< 'l', SPACE_DIM > l
Definition: plate.cpp:63
nitsche
static double nitsche
Definition: plate.cpp:68
FTensor::Tensor2_symmetric
Definition: Tensor2_symmetric_value.hpp:13
diff2BaseSideMap
std::array< std::vector< MatrixDouble >, 2 > diff2BaseSideMap
Definition: plate.cpp:100
RIGHT_SIDE
@ RIGHT_SIDE
Definition: plate.cpp:92
get_diff_ntensor
auto get_diff_ntensor(T &base_mat)
Definition: plate.cpp:478
FTensor::Tensor2
Definition: Tensor2_value.hpp:16
indicesSideMap
std::array< std::vector< VectorInt >, 2 > indicesSideMap
indices on rows for left hand-side
Definition: plate.cpp:96
CHKERR
#define CHKERR
Inline error check.
Definition: definitions.h:548
OpH1LhsSkeleton::locMat
MatrixDouble locMat
local operator matrix
Definition: plate.cpp:136
i
FTensor::Index< 'i', SPACE_DIM > i
Definition: plate.cpp:60
areaMap
std::array< double, 2 > areaMap
Definition: plate.cpp:101
OpH1LhsSkeleton::dMatPtr
boost::shared_ptr< MatrixDouble > dMatPtr
Definition: plate.cpp:137
penalty
static double penalty
Definition: plate.cpp:65
diffBaseSideMap
std::array< std::vector< MatrixDouble >, 2 > diffBaseSideMap
Definition: plate.cpp:98
get_diff2_ntensor
auto get_diff2_ntensor(T &base_mat)
Definition: plate.cpp:489
LEFT_SIDE
@ LEFT_SIDE
Definition: plate.cpp:92
j
FTensor::Index< 'j', SPACE_DIM > j
Definition: plate.cpp:61
MoFEMFunctionBeginHot
#define MoFEMFunctionBeginHot
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:453
MoFEMFunctionReturn
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:429
BoundaryEleOp
BoundaryEle::UserDataOperator BoundaryEleOp
Definition: plate.cpp:32
MoFEMFunctionBegin
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:359
phi
static double phi
Definition: plate.cpp:66