v0.9.0
Public Member Functions | Private Member Functions | Private Attributes | List of all members
OpS Struct Reference

Inherits UserDataOperator.

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, DataForcesAndSourcesCore::EntData &row_data, DataForcesAndSourcesCore::EntData &col_data)
 Do calculations for give operator. More...
 

Private Member Functions

MoFEMErrorCode iNtegrate (DataForcesAndSourcesCore::EntData &row_data, DataForcesAndSourcesCore::EntData &col_data)
 Integrate grad-grad operator. More...
 
MoFEMErrorCode aSsemble (DataForcesAndSourcesCore::EntData &row_data, DataForcesAndSourcesCore::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 85 of file analytical_poisson_field_split.cpp.

Constructor & Destructor Documentation

◆ OpS()

OpS::OpS ( const bool  beta = 1)
Examples
analytical_poisson_field_split.cpp.

Definition at line 87 of file analytical_poisson_field_split.cpp.

89  true),
90  bEta(beta) {}
const double bEta
error code
ForcesAndSourcesCore::UserDataOperator UserDataOperator

Member Function Documentation

◆ aSsemble()

MoFEMErrorCode OpS::aSsemble ( DataForcesAndSourcesCore::EntData row_data,
DataForcesAndSourcesCore::EntData col_data 
)
private

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 196 of file analytical_poisson_field_split.cpp.

197  {
199  // get pointer to first global index on row
200  const int *row_indices = &*row_data.getIndices().data().begin();
201  // get pointer to first global index on column
202  const int *col_indices = &*col_data.getIndices().data().begin();
203  Mat B = getFEMethod()->ksp_B != PETSC_NULL ? getFEMethod()->ksp_B
204  : getFEMethod()->snes_B;
205  // assemble local matrix
206  CHKERR MatSetValues(B, nbRows, row_indices, nbCols, col_indices,
207  &*locMat.data().begin(), ADD_VALUES);
208  if (!isDiag) {
209  // if not diagonal term and since global matrix is symmetric assemble
210  // transpose term.
211  locMat = trans(locMat);
212  CHKERR MatSetValues(B, nbCols, col_indices, nbRows, row_indices,
213  &*locMat.data().begin(), ADD_VALUES);
214  }
216  }
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:477
int nbCols
number if dof on column
MatrixDouble locMat
local entity block matrix
const VectorInt & getIndices() const
Get global indices of dofs on entity.
bool isDiag
true if this block is on diagonal
MoFEMErrorCode MatSetValues(Mat M, const DataForcesAndSourcesCore::EntData &row_data, const DataForcesAndSourcesCore::EntData &col_data, const double *ptr, InsertMode iora)
Assemble PETSc matrix.
#define CHKERR
Inline error check.
Definition: definitions.h:596
int nbRows
number of dofs on rows
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:407

◆ doWork()

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

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 102 of file analytical_poisson_field_split.cpp.

105  {
107  // get number of dofs on row
108  nbRows = row_data.getIndices().size();
109  // if no dofs on row, exit that work, nothing to do here
110  if (!nbRows)
112  // get number of dofs on column
113  nbCols = col_data.getIndices().size();
114  // if no dofs on Columbia, exit nothing to do here
115  if (!nbCols)
117  // get number of integration points
118  nbIntegrationPts = getGaussPts().size2();
119  // check if entity block is on matrix diagonal
120  if (row_side == col_side && row_type == col_type) {
121  isDiag = true; // yes, it is
122  } else {
123  isDiag = false;
124  }
125  // integrate local matrix for entity block
126  CHKERR iNtegrate(row_data, col_data);
127  // assemble local matrix
128  CHKERR aSsemble(row_data, col_data);
130  }
int nbIntegrationPts
number of integration points
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:477
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:508
int nbCols
number if dof on column
const VectorInt & getIndices() const
Get global indices of dofs on entity.
bool isDiag
true if this block is on diagonal
#define CHKERR
Inline error check.
Definition: definitions.h:596
MoFEMErrorCode iNtegrate(DataForcesAndSourcesCore::EntData &row_data, DataForcesAndSourcesCore::EntData &col_data)
Integrate grad-grad operator.
int nbRows
number of dofs on rows
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:407
MoFEMErrorCode aSsemble(DataForcesAndSourcesCore::EntData &row_data, DataForcesAndSourcesCore::EntData &col_data)
Assemble local entity block matrix.

◆ iNtegrate()

MoFEMErrorCode OpS::iNtegrate ( DataForcesAndSourcesCore::EntData row_data,
DataForcesAndSourcesCore::EntData col_data 
)
private

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 151 of file analytical_poisson_field_split.cpp.

152  {
154  // set size of local entity bock
155  locMat.resize(nbRows, nbCols, false);
156  // clear matrix
157  locMat.clear();
158  // get element area
159  double area = getArea() * bEta;
160  // get integration weights
161  auto t_w = getFTensor0IntegrationWeight();
162  // get base function gradient on rows
163  auto t_row_base = row_data.getFTensor0N();
164  // loop over integration points
165  for (int gg = 0; gg != nbIntegrationPts; gg++) {
166  // take into account Jacobean
167  const double alpha = t_w * area;
168  // take fist element to local matrix
170  &*locMat.data().begin());
171  // loop over rows base functions
172  for (int rr = 0; rr != nbRows; rr++) {
173  // get column base functions gradient at gauss point gg
174  auto t_col_base = col_data.getFTensor0N(gg, 0);
175  // loop over columns
176  for (int cc = 0; cc != nbCols; cc++) {
177  // calculate element of local matrix
178  a += alpha * t_row_base * t_col_base;
179  ++t_col_base; // move to another gradient of base function on column
180  ++a; // move to another element of local matrix in column
181  }
182  ++t_row_base; // move to another element of gradient of base function on
183  // row
184  }
185  ++t_w; // move to another integration weight
186  }
188  }
int nbIntegrationPts
number of integration points
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:477
const double bEta
error code
int nbCols
number if dof on column
MatrixDouble locMat
local entity block matrix
int nbRows
number of dofs on rows
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:407
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 133 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 140 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 143 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 138 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 139 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 137 of file analytical_poisson_field_split.cpp.


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