v0.15.0
Loading...
Searching...
No Matches
PoissonExample::OpC Struct Reference

Calculate constrains matrix. More...

#include "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.
 
MoFEMErrorCode aSsemble (EntitiesFieldData::EntData &row_data, EntitiesFieldData::EntData &col_data)
 integrate local constrains matrix
 

Private Attributes

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

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

Constructor & Destructor Documentation

◆ OpC()

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

Definition at line 307 of file PoissonOperators.hpp.

308 : FaceElementForcesAndSourcesCore::UserDataOperator("L", "U", OPROWCOL,
309 false),
310 assembleTranspose(assemble_transpose) {}
const bool assembleTranspose
assemble transpose, i.e. CT if set to true

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

389 {
391 // get indices on row
392 const int *row_indices = &*row_data.getIndices().data().begin();
393 // get indices on column
394 const int *col_indices = &*col_data.getIndices().data().begin();
395 Mat B = getFEMethod()->ksp_B != PETSC_NULLPTR ? getFEMethod()->ksp_B
396 : getFEMethod()->snes_B;
397 // assemble local matrix
398 CHKERR MatSetValues(B, nbRows, row_indices, nbCols, col_indices,
399 &*locMat.data().begin(), ADD_VALUES);
400 // cerr << locMat << endl;
401 if (assembleTranspose) {
402 // assemble transpose of local matrix
403 locMat = trans(locMat);
404 CHKERR MatSetValues(B, nbCols, col_indices, nbRows, row_indices,
405 &*locMat.data().begin(), ADD_VALUES);
406 }
408 }
#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.
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.
MatrixDouble locMat
local constrains matrix
int nbCols
number of dofs on column

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

315 {
317 // get number of dofs on row
318 nbRows = row_data.getIndices().size();
319 // exit here if no dofs on row, nothing to do
320 if (!nbRows)
322 // get number of dofs on column,
323 nbCols = col_data.getIndices().size();
324 // exit here if no dofs on roe, nothing to do
325 if (!nbCols)
327 // get number of integration points
328 nbIntegrationPts = getGaussPts().size2();
329 // integrate local constrains matrix
330 CHKERR iNtegrate(row_data, col_data);
331 // assemble local constrains matrix
332 CHKERR aSsemble(row_data, col_data);
334 }
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return()
MoFEMErrorCode aSsemble(EntitiesFieldData::EntData &row_data, EntitiesFieldData::EntData &col_data)
integrate local constrains matrix
MoFEMErrorCode iNtegrate(EntitiesFieldData::EntData &row_data, EntitiesFieldData::EntData &col_data)
Integrate local constrains matrix.
int nbIntegrationPts
number of integration points

◆ iNtegrate()

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

Integrate local constrains matrix.

Examples
PoissonOperators.hpp.

Definition at line 348 of file PoissonOperators.hpp.

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

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

◆ locMat

MatrixDouble PoissonExample::OpC::locMat
private

local constrains matrix

Examples
PoissonOperators.hpp.

Definition at line 344 of file PoissonOperators.hpp.

◆ nbCols

int PoissonExample::OpC::nbCols
private

number of dofs on column

Examples
PoissonOperators.hpp.

Definition at line 340 of file PoissonOperators.hpp.

◆ nbIntegrationPts

int PoissonExample::OpC::nbIntegrationPts
private

number of integration points

Examples
PoissonOperators.hpp.

Definition at line 341 of file PoissonOperators.hpp.

◆ nbRows

int PoissonExample::OpC::nbRows
private

< error code

number of dofs on row

Examples
PoissonOperators.hpp.

Definition at line 339 of file PoissonOperators.hpp.


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