v0.9.0
Public Member Functions | Private Member Functions | Private Attributes | List of all members
PoissonExample::OpC Struct Reference

Calculate constrains matrix. More...

#include <users_modules/basic_finite_elements/poisson/src/PoissonOperators.hpp>

Inherits UserDataOperator.

Collaboration diagram for PoissonExample::OpC:
[legend]

Public Member Functions

 OpC (const bool assemble_transpose)
 
MoFEMErrorCode doWork (int row_side, int col_side, EntityType row_type, EntityType col_type, DataForcesAndSourcesCore::EntData &row_data, DataForcesAndSourcesCore::EntData &col_data)
 

Private Member Functions

MoFEMErrorCode iNtegrate (DataForcesAndSourcesCore::EntData &row_data, DataForcesAndSourcesCore::EntData &col_data)
 Integrate local constrains matrix. More...
 
MoFEMErrorCode aSsemble (DataForcesAndSourcesCore::EntData &row_data, DataForcesAndSourcesCore::EntData &col_data)
 integrate local constrains matrix More...
 

Private Attributes

int nbRows
 < error code More...
 
int nbCols
 number of dofs on column More...
 
int nbIntegrationPts
 number of integration points More...
 
const bool assembleTranspose
 assemble transpose, i.e. CT if set to true More...
 
MatrixDouble locMat
 local constrains matrix More...
 

Detailed Description

Calculate constrains matrix.

\[ \mathbf{C} = \int_{\partial\Omega} \boldsymbol\psi \boldsymbol\phi \textrm{d}\partial\Omega \]

where \(\lambda \) is base function on boundary

Definition at line 315 of file PoissonOperators.hpp.

Constructor & Destructor Documentation

◆ OpC()

PoissonExample::OpC::OpC ( const bool  assemble_transpose)
Examples
PoissonOperators.hpp.

Definition at line 317 of file PoissonOperators.hpp.

319  false),
320  assembleTranspose(assemble_transpose) {}
const bool assembleTranspose
assemble transpose, i.e. CT if set to true
ForcesAndSourcesCore::UserDataOperator UserDataOperator

Member Function Documentation

◆ aSsemble()

MoFEMErrorCode PoissonExample::OpC::aSsemble ( DataForcesAndSourcesCore::EntData row_data,
DataForcesAndSourcesCore::EntData col_data 
)
private

integrate local constrains matrix

Examples
PoissonOperators.hpp.

Definition at line 398 of file PoissonOperators.hpp.

399  {
401  // get indices on row
402  const int *row_indices = &*row_data.getIndices().data().begin();
403  // get indices on column
404  const int *col_indices = &*col_data.getIndices().data().begin();
405  Mat B = getFEMethod()->ksp_B != PETSC_NULL ? getFEMethod()->ksp_B
406  : getFEMethod()->snes_B;
407  // assemble local matrix
408  CHKERR MatSetValues(B, nbRows, row_indices, nbCols, col_indices,
409  &*locMat.data().begin(), ADD_VALUES);
410  // cerr << locMat << endl;
411  if (assembleTranspose) {
412  // assemble transpose of local matrix
413  locMat = trans(locMat);
414  CHKERR MatSetValues(B, nbCols, col_indices, nbRows, row_indices,
415  &*locMat.data().begin(), ADD_VALUES);
416  }
418  }
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:477
int nbRows
< error code
const bool assembleTranspose
assemble transpose, i.e. CT if set to true
MatrixDouble locMat
local constrains matrix
int nbCols
number of dofs on column
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
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:407

◆ doWork()

MoFEMErrorCode PoissonExample::OpC::doWork ( int  row_side,
int  col_side,
EntityType  row_type,
EntityType  col_type,
DataForcesAndSourcesCore::EntData row_data,
DataForcesAndSourcesCore::EntData col_data 
)
Examples
PoissonOperators.hpp.

Definition at line 322 of file PoissonOperators.hpp.

325  {
327  // get number of dofs on row
328  nbRows = row_data.getIndices().size();
329  // exit here if no dofs on row, nothing to do
330  if (!nbRows)
332  // get number of dofs on column,
333  nbCols = col_data.getIndices().size();
334  // exit here if no dofs on roe, nothing to do
335  if (!nbCols)
337  // get number of integration points
338  nbIntegrationPts = getGaussPts().size2();
339  // integrate local constrains matrix
340  CHKERR iNtegrate(row_data, col_data);
341  // assemble local constrains matrix
342  CHKERR aSsemble(row_data, col_data);
344  }
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:477
int nbRows
< error code
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:508
int nbIntegrationPts
number of integration points
int nbCols
number of dofs on column
MoFEMErrorCode aSsemble(DataForcesAndSourcesCore::EntData &row_data, DataForcesAndSourcesCore::EntData &col_data)
integrate local constrains matrix
#define CHKERR
Inline error check.
Definition: definitions.h:596
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:407
MoFEMErrorCode iNtegrate(DataForcesAndSourcesCore::EntData &row_data, DataForcesAndSourcesCore::EntData &col_data)
Integrate local constrains matrix.

◆ iNtegrate()

MoFEMErrorCode PoissonExample::OpC::iNtegrate ( DataForcesAndSourcesCore::EntData row_data,
DataForcesAndSourcesCore::EntData col_data 
)
private

Integrate local constrains matrix.

Examples
PoissonOperators.hpp.

Definition at line 358 of file PoissonOperators.hpp.

359  {
361  // set size of local constrains matrix
362  locMat.resize(nbRows, nbCols, false);
363  // clear matrix
364  locMat.clear();
365  // get area of element
366  const double area = getArea();
367  // get integration weights
368  auto t_w = getFTensor0IntegrationWeight();
369  // get base functions on entity
370  auto t_row = row_data.getFTensor0N();
371  // run over integration points
372  for (int gg = 0; gg != nbIntegrationPts; gg++) {
373  const double alpha = area * t_w;
374  // get element of local matrix
376  &*locMat.data().begin());
377  // run over base functions on rows
378  for (int rr = 0; rr != nbRows; rr++) {
379  // get first base functions on column for integration point gg
380  auto t_col = col_data.getFTensor0N(gg, 0);
381  // run over base function on column
382  for (int cc = 0; cc != nbCols; cc++) {
383  // integrate element of constrains matrix
384  c += alpha * t_row * t_col;
385  ++t_col; // move to next base function on column
386  ++c; // move to next element of local matrix
387  }
388  ++t_row; // move to next base function on row
389  }
390  ++t_w; // move to next integrate weight
391  }
393  }
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:477
int nbRows
< error code
int nbIntegrationPts
number of integration points
MatrixDouble locMat
local constrains matrix
int nbCols
number of dofs on column
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:407

Member Data Documentation

◆ assembleTranspose

const bool PoissonExample::OpC::assembleTranspose
private

assemble transpose, i.e. CT if set to true

Examples
PoissonOperators.hpp.

Definition at line 352 of file PoissonOperators.hpp.

◆ locMat

MatrixDouble PoissonExample::OpC::locMat
private

local constrains matrix

Examples
PoissonOperators.hpp.

Definition at line 354 of file PoissonOperators.hpp.

◆ nbCols

int PoissonExample::OpC::nbCols
private

number of dofs on column

Examples
PoissonOperators.hpp.

Definition at line 350 of file PoissonOperators.hpp.

◆ nbIntegrationPts

int PoissonExample::OpC::nbIntegrationPts
private

number of integration points

Examples
PoissonOperators.hpp.

Definition at line 351 of file PoissonOperators.hpp.

◆ nbRows

int PoissonExample::OpC::nbRows
private

< error code

number of dofs on row

Examples
PoissonOperators.hpp.

Definition at line 349 of file PoissonOperators.hpp.


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