v0.14.0
Loading...
Searching...
No Matches
Public Member Functions | Private Member Functions | Private Attributes | List of all members
OpS Struct Reference
Inheritance diagram for OpS:
[legend]
Collaboration diagram for OpS:
[legend]

Public Member Functions

 OpS (const bool beta=1)
 
MoFEMErrorCode doWork (int row_side, int col_side, EntityType row_type, EntityType col_type, EntitiesFieldData::EntData &row_data, EntitiesFieldData::EntData &col_data)
 Do calculations for give operator. More...
 

Private Member Functions

MoFEMErrorCode iNtegrate (EntitiesFieldData::EntData &row_data, EntitiesFieldData::EntData &col_data)
 Integrate grad-grad operator. More...
 
MoFEMErrorCode aSsemble (EntitiesFieldData::EntData &row_data, EntitiesFieldData::EntData &col_data)
 Assemble local entity block matrix. More...
 

Private Attributes

const double bEta
 error code More...
 
int nbRows
 number of dofs on rows More...
 
int nbCols
 number if dof on column More...
 
int nbIntegrationPts
 number of integration points More...
 
bool isDiag
 true if this block is on diagonal More...
 
FTensor::Index< 'i', 3 > i
 summit Index More...
 
MatrixDouble locMat
 local entity block matrix More...
 

Detailed Description

Examples
analytical_poisson_field_split.cpp.

Definition at line 73 of file analytical_poisson_field_split.cpp.

Constructor & Destructor Documentation

◆ OpS()

OpS::OpS ( const bool  beta = 1)
inline

Definition at line 75 of file analytical_poisson_field_split.cpp.

76 : FaceElementForcesAndSourcesCore::UserDataOperator("U", "U", OPROWCOL,
77 true),
78 bEta(beta) {}
const double bEta
error code

Member Function Documentation

◆ aSsemble()

MoFEMErrorCode OpS::aSsemble ( EntitiesFieldData::EntData row_data,
EntitiesFieldData::EntData col_data 
)
inlineprivate

Assemble local entity block matrix.

Parameters
row_datarow data (consist base functions on row entity)
col_datacolumn data (consist base functions on column entity)
Returns
error code
Examples
analytical_poisson_field_split.cpp.

Definition at line 184 of file analytical_poisson_field_split.cpp.

185 {
187 // get pointer to first global index on row
188 const int *row_indices = &*row_data.getIndices().data().begin();
189 // get pointer to first global index on column
190 const int *col_indices = &*col_data.getIndices().data().begin();
191 Mat B = getFEMethod()->ksp_B != PETSC_NULL ? getFEMethod()->ksp_B
192 : getFEMethod()->snes_B;
193 // assemble local matrix
194 CHKERR MatSetValues(B, nbRows, row_indices, nbCols, col_indices,
195 &*locMat.data().begin(), ADD_VALUES);
196 if (!isDiag) {
197 // if not diagonal term and since global matrix is symmetric assemble
198 // transpose term.
199 locMat = trans(locMat);
200 CHKERR MatSetValues(B, nbCols, col_indices, nbRows, row_indices,
201 &*locMat.data().begin(), ADD_VALUES);
202 }
204 }
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:346
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:416
#define CHKERR
Inline error check.
Definition: definitions.h:535
MoFEMErrorCode MatSetValues(Mat M, const EntitiesFieldData::EntData &row_data, const EntitiesFieldData::EntData &col_data, const double *ptr, InsertMode iora)
Assemble PETSc matrix.
const VectorInt & getIndices() const
Get global indices of dofs on entity.
int nbRows
number of dofs on rows
int nbCols
number if dof on column
MatrixDouble locMat
local entity block matrix
bool isDiag
true if this block is on diagonal

◆ doWork()

MoFEMErrorCode OpS::doWork ( int  row_side,
int  col_side,
EntityType  row_type,
EntityType  col_type,
EntitiesFieldData::EntData row_data,
EntitiesFieldData::EntData col_data 
)
inline

Do calculations for give operator.

Parameters
row_siderow side number (local number) of entity on element
col_sidecolumn side number (local number) of entity on element
row_typetype of row entity MBVERTEX, MBEDGE, MBTRI or MBTET
col_typetype of column entity MBVERTEX, MBEDGE, MBTRI or MBTET
row_datadata for row
col_datadata for column
Returns
error code
Examples
analytical_poisson_field_split.cpp.

Definition at line 90 of file analytical_poisson_field_split.cpp.

93 {
95 // get number of dofs on row
96 nbRows = row_data.getIndices().size();
97 // if no dofs on row, exit that work, nothing to do here
98 if (!nbRows)
100 // get number of dofs on column
101 nbCols = col_data.getIndices().size();
102 // if no dofs on Columbia, exit nothing to do here
103 if (!nbCols)
105 // get number of integration points
106 nbIntegrationPts = getGaussPts().size2();
107 // check if entity block is on matrix diagonal
108 if (row_side == col_side && row_type == col_type) {
109 isDiag = true; // yes, it is
110 } else {
111 isDiag = false;
112 }
113 // integrate local matrix for entity block
114 CHKERR iNtegrate(row_data, col_data);
115 // assemble local matrix
116 CHKERR aSsemble(row_data, col_data);
118 }
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:447
int nbIntegrationPts
number of integration points
MoFEMErrorCode iNtegrate(EntitiesFieldData::EntData &row_data, EntitiesFieldData::EntData &col_data)
Integrate grad-grad operator.
MoFEMErrorCode aSsemble(EntitiesFieldData::EntData &row_data, EntitiesFieldData::EntData &col_data)
Assemble local entity block matrix.

◆ iNtegrate()

MoFEMErrorCode OpS::iNtegrate ( EntitiesFieldData::EntData row_data,
EntitiesFieldData::EntData col_data 
)
inlineprivate

Integrate grad-grad operator.

Parameters
row_datarow data (consist base functions on row entity)
col_datacolumn data (consist base functions on column entity)
Returns
error code
Examples
analytical_poisson_field_split.cpp.

Definition at line 139 of file analytical_poisson_field_split.cpp.

140 {
142 // set size of local entity bock
143 locMat.resize(nbRows, nbCols, false);
144 // clear matrix
145 locMat.clear();
146 // get element area
147 double area = getArea() * bEta;
148 // get integration weights
149 auto t_w = getFTensor0IntegrationWeight();
150 // get base function gradient on rows
151 auto t_row_base = row_data.getFTensor0N();
152 // loop over integration points
153 for (int gg = 0; gg != nbIntegrationPts; gg++) {
154 // take into account Jacobean
155 const double alpha = t_w * area;
156 // take fist element to local matrix
158 &*locMat.data().begin());
159 // loop over rows base functions
160 for (int rr = 0; rr != nbRows; rr++) {
161 // get column base functions gradient at gauss point gg
162 auto t_col_base = col_data.getFTensor0N(gg, 0);
163 // loop over columns
164 for (int cc = 0; cc != nbCols; cc++) {
165 // calculate element of local matrix
166 a += alpha * t_row_base * t_col_base;
167 ++t_col_base; // move to another gradient of base function on column
168 ++a; // move to another element of local matrix in column
169 }
170 ++t_row_base; // move to another element of gradient of base function on
171 // row
172 }
173 ++t_w; // move to another integration weight
174 }
176 }
constexpr double a
FTensor::Tensor0< FTensor::PackPtr< double *, 1 > > getFTensor0N(const FieldApproximationBase base)
Get base function as Tensor0.

Member Data Documentation

◆ bEta

const double OpS::bEta
private

error code

Examples
analytical_poisson_field_split.cpp.

Definition at line 121 of file analytical_poisson_field_split.cpp.

◆ i

FTensor::Index<'i', 3> OpS::i
private

◆ isDiag

bool OpS::isDiag
private

true if this block is on diagonal

Examples
analytical_poisson_field_split.cpp.

Definition at line 128 of file analytical_poisson_field_split.cpp.

◆ locMat

MatrixDouble OpS::locMat
private

local entity block matrix

Examples
analytical_poisson_field_split.cpp.

Definition at line 131 of file analytical_poisson_field_split.cpp.

◆ nbCols

int OpS::nbCols
private

number if dof on column

Examples
analytical_poisson_field_split.cpp.

Definition at line 126 of file analytical_poisson_field_split.cpp.

◆ nbIntegrationPts

int OpS::nbIntegrationPts
private

number of integration points

Examples
analytical_poisson_field_split.cpp.

Definition at line 127 of file analytical_poisson_field_split.cpp.

◆ nbRows

int OpS::nbRows
private

number of dofs on rows

Examples
analytical_poisson_field_split.cpp.

Definition at line 125 of file analytical_poisson_field_split.cpp.


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