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

Calculate constrains matrix. More...

#include <users_modules/tutorials/cor-2to5/src/PoissonOperators.hpp>

Inheritance diagram for PoissonExample::OpC:
[legend]
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, EntitiesFieldData::EntData &row_data, EntitiesFieldData::EntData &col_data)
 

Private Member Functions

MoFEMErrorCode iNtegrate (EntitiesFieldData::EntData &row_data, EntitiesFieldData::EntData &col_data)
 Integrate local constrains matrix. More...
 
MoFEMErrorCode aSsemble (EntitiesFieldData::EntData &row_data, EntitiesFieldData::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 302 of file PoissonOperators.hpp.

Constructor & Destructor Documentation

◆ OpC()

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

Definition at line 304 of file PoissonOperators.hpp.

306  false),
307  assembleTranspose(assemble_transpose) {}

Member Function Documentation

◆ aSsemble()

MoFEMErrorCode PoissonExample::OpC::aSsemble ( EntitiesFieldData::EntData row_data,
EntitiesFieldData::EntData col_data 
)
inlineprivate

integrate local constrains matrix

Examples
PoissonOperators.hpp.

Definition at line 385 of file PoissonOperators.hpp.

386  {
388  // get indices on row
389  const int *row_indices = &*row_data.getIndices().data().begin();
390  // get indices on column
391  const int *col_indices = &*col_data.getIndices().data().begin();
392  Mat B = getFEMethod()->ksp_B != PETSC_NULL ? getFEMethod()->ksp_B
393  : getFEMethod()->snes_B;
394  // assemble local matrix
395  CHKERR MatSetValues(B, nbRows, row_indices, nbCols, col_indices,
396  &*locMat.data().begin(), ADD_VALUES);
397  // cerr << locMat << endl;
398  if (assembleTranspose) {
399  // assemble transpose of local matrix
400  locMat = trans(locMat);
401  CHKERR MatSetValues(B, nbCols, col_indices, nbRows, row_indices,
402  &*locMat.data().begin(), ADD_VALUES);
403  }
405  }

◆ doWork()

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

Definition at line 309 of file PoissonOperators.hpp.

312  {
314  // get number of dofs on row
315  nbRows = row_data.getIndices().size();
316  // exit here if no dofs on row, nothing to do
317  if (!nbRows)
319  // get number of dofs on column,
320  nbCols = col_data.getIndices().size();
321  // exit here if no dofs on roe, nothing to do
322  if (!nbCols)
324  // get number of integration points
325  nbIntegrationPts = getGaussPts().size2();
326  // integrate local constrains matrix
327  CHKERR iNtegrate(row_data, col_data);
328  // assemble local constrains matrix
329  CHKERR aSsemble(row_data, col_data);
331  }

◆ iNtegrate()

MoFEMErrorCode PoissonExample::OpC::iNtegrate ( EntitiesFieldData::EntData row_data,
EntitiesFieldData::EntData col_data 
)
inlineprivate

Integrate local constrains matrix.

Examples
PoissonOperators.hpp.

Definition at line 345 of file PoissonOperators.hpp.

346  {
348  // set size of local constrains matrix
349  locMat.resize(nbRows, nbCols, false);
350  // clear matrix
351  locMat.clear();
352  // get area of element
353  const double area = getArea();
354  // get integration weights
355  auto t_w = getFTensor0IntegrationWeight();
356  // get base functions on entity
357  auto t_row = row_data.getFTensor0N();
358  // run over integration points
359  for (int gg = 0; gg != nbIntegrationPts; gg++) {
360  const double alpha = area * t_w;
361  // get element of local matrix
363  &*locMat.data().begin());
364  // run over base functions on rows
365  for (int rr = 0; rr != nbRows; rr++) {
366  // get first base functions on column for integration point gg
367  auto t_col = col_data.getFTensor0N(gg, 0);
368  // run over base function on column
369  for (int cc = 0; cc != nbCols; cc++) {
370  // integrate element of constrains matrix
371  c += alpha * t_row * t_col;
372  ++t_col; // move to next base function on column
373  ++c; // move to next element of local matrix
374  }
375  ++t_row; // move to next base function on row
376  }
377  ++t_w; // move to next integrate weight
378  }
380  }

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 339 of file PoissonOperators.hpp.

◆ locMat

MatrixDouble PoissonExample::OpC::locMat
private

local constrains matrix

Examples
PoissonOperators.hpp.

Definition at line 341 of file PoissonOperators.hpp.

◆ nbCols

int PoissonExample::OpC::nbCols
private

number of dofs on column

Examples
PoissonOperators.hpp.

Definition at line 337 of file PoissonOperators.hpp.

◆ nbIntegrationPts

int PoissonExample::OpC::nbIntegrationPts
private

number of integration points

Examples
PoissonOperators.hpp.

Definition at line 338 of file PoissonOperators.hpp.

◆ nbRows

int PoissonExample::OpC::nbRows
private

< error code

number of dofs on row

Examples
PoissonOperators.hpp.

Definition at line 336 of file PoissonOperators.hpp.


The documentation for this struct was generated from the following file:
MoFEMFunctionReturnHot
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:447
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:1631
PoissonExample::OpC::locMat
MatrixDouble locMat
local constrains matrix
Definition: PoissonOperators.hpp:341
PoissonExample::OpC::iNtegrate
MoFEMErrorCode iNtegrate(EntitiesFieldData::EntData &row_data, EntitiesFieldData::EntData &col_data)
Integrate local constrains matrix.
Definition: PoissonOperators.hpp:345
PoissonExample::OpC::nbIntegrationPts
int nbIntegrationPts
number of integration points
Definition: PoissonOperators.hpp:338
PoissonExample::OpC::aSsemble
MoFEMErrorCode aSsemble(EntitiesFieldData::EntData &row_data, EntitiesFieldData::EntData &col_data)
integrate local constrains matrix
Definition: PoissonOperators.hpp:385
PoissonExample::OpC::nbRows
int nbRows
< error code
Definition: PoissonOperators.hpp:336
PoissonExample::OpC::nbCols
int nbCols
number of dofs on column
Definition: PoissonOperators.hpp:337
c
const double c
speed of light (cm/ns)
Definition: initial_diffusion.cpp:39
CHKERR
#define CHKERR
Inline error check.
Definition: definitions.h:535
FTensor::Tensor0
Definition: Tensor0.hpp:16
UserDataOperator
ForcesAndSourcesCore::UserDataOperator UserDataOperator
Definition: HookeElement.hpp:75
PoissonExample::OpC::assembleTranspose
const bool assembleTranspose
assemble transpose, i.e. CT if set to true
Definition: PoissonOperators.hpp:339
MoFEMFunctionReturn
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:416
MoFEMFunctionBegin
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:346