v0.16.3
Loading...
Searching...
No Matches
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.
 
MoFEMErrorCode doWork (int side, EntityType type, EntitiesFieldData::EntData &data)
 

Private Attributes

boost::shared_ptr< FaceSideEle > sideFEPtr
 pointer to element to get data on edge/face sides
 
MatrixDouble locMat
 local operator matrix
 
boost::shared_ptr< MatrixDouble > dMatPtr
 

Detailed Description

Operator the left hand side matrix.

Examples
mofem/tutorials/vec-6_dg_kirchhoff_plate/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
mofem/tutorials/vec-6_dg_kirchhoff_plate/plate.cpp.

Definition at line 502 of file plate.cpp.

504 : BoundaryEleOp(NOSPACE, BoundaryEleOp::OPSPACE), sideFEPtr(side_fe_ptr),
505 dMatPtr(mat_d_ptr) {}
@ NOSPACE
Definition definitions.h:83
BoundaryEle::UserDataOperator BoundaryEleOp
Definition plate.cpp:32
boost::shared_ptr< MatrixDouble > dMatPtr
Definition plate.cpp:137
boost::shared_ptr< FaceSideEle > sideFEPtr
pointer to element to get data on edge/face sides
Definition plate.cpp:135

Member Function Documentation

◆ doWork()

MoFEMErrorCode OpH1LhsSkeleton::doWork ( int  side,
EntityType  type,
EntitiesFieldData::EntData &  data 
)
Examples
mofem/tutorials/vec-6_dg_kirchhoff_plate/plate.cpp.

Definition at line 507 of file plate.cpp.

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

Member Data Documentation

◆ dMatPtr

boost::shared_ptr<MatrixDouble> OpH1LhsSkeleton::dMatPtr
private

◆ locMat

MatrixDouble OpH1LhsSkeleton::locMat
private

local operator matrix

Examples
mofem/tutorials/vec-6_dg_kirchhoff_plate/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
mofem/tutorials/vec-6_dg_kirchhoff_plate/plate.cpp.

Definition at line 135 of file plate.cpp.


The documentation for this struct was generated from the following file: