v0.14.0
Public Member Functions | Private Member Functions | Private Attributes | List of all members
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)
 Operator for bi-linear form, usually to calculate values on left hand side. More...
 
- Public Member Functions inherited from MoFEM::FaceElementForcesAndSourcesCore::UserDataOperator
double getArea ()
 get area of face More...
 
VectorDoublegetNormal ()
 get triangle normal More...
 
VectorDoublegetTangent1 ()
 get triangle tangent 1 More...
 
VectorDoublegetTangent2 ()
 get triangle tangent 2 More...
 
auto getFTensor1Normal ()
 get normal as tensor More...
 
auto getFTensor1Tangent1 ()
 get tangentOne as tensor More...
 
auto getFTensor1Tangent2 ()
 get tangentTwo as tensor More...
 
int getNumNodes ()
 get element number of nodes More...
 
const EntityHandlegetConn ()
 get element connectivity More...
 
VectorDoublegetCoords ()
 get triangle coordinates More...
 
auto getFTensor1Coords ()
 get get coords at gauss points More...
 
MatrixDoublegetNormalsAtGaussPts ()
 if higher order geometry return normals at Gauss pts. More...
 
ublas::matrix_row< MatrixDoublegetNormalsAtGaussPts (const int gg)
 if higher order geometry return normals at Gauss pts. More...
 
MatrixDoublegetTangent1AtGaussPts ()
 if higher order geometry return tangent vector to triangle at Gauss pts. More...
 
MatrixDoublegetTangent2AtGaussPts ()
 if higher order geometry return tangent vector to triangle at Gauss pts. More...
 
auto getFTensor1NormalsAtGaussPts ()
 get normal at integration points More...
 
auto getFTensor1Tangent1AtGaussPts ()
 get tangent 1 at integration points More...
 
auto getFTensor1Tangent2AtGaussPts ()
 get tangent 2 at integration points More...
 
FaceElementForcesAndSourcesCoregetFaceFE ()
 return pointer to Generic Triangle Finite Element object More...
 
MoFEMErrorCode loopSideVolumes (const string fe_name, VolumeElementForcesAndSourcesCoreOnSide &fe_method)
 
- Public Member Functions inherited from MoFEM::ForcesAndSourcesCore::UserDataOperator
 UserDataOperator (const FieldSpace space, const char type=OPSPACE, const bool symm=true)
 
 UserDataOperator (const std::string field_name, const char type, const bool symm=true)
 
 UserDataOperator (const std::string row_field_name, const std::string col_field_name, const char type, const bool symm=true)
 
boost::shared_ptr< const NumeredEntFiniteElementgetNumeredEntFiniteElementPtr () const
 Return raw pointer to NumeredEntFiniteElement. More...
 
EntityHandle getFEEntityHandle () const
 Return finite element entity handle. More...
 
int getFEDim () const
 Get dimension of finite element. More...
 
EntityType getFEType () const
 Get dimension of finite element. More...
 
boost::weak_ptr< SideNumbergetSideNumberPtr (const int side_number, const EntityType type)
 Get the side number pointer. More...
 
EntityHandle getSideEntity (const int side_number, const EntityType type)
 Get the side entity. More...
 
int getNumberOfNodesOnElement () const
 Get the number of nodes on finite element. More...
 
MoFEMErrorCode getProblemRowIndices (const std::string filed_name, const EntityType type, const int side, VectorInt &indices) const
 Get row indices. More...
 
MoFEMErrorCode getProblemColIndices (const std::string filed_name, const EntityType type, const int side, VectorInt &indices) const
 Get col indices. More...
 
const FEMethodgetFEMethod () const
 Return raw pointer to Finite Element Method object. More...
 
int getOpType () const
 Get operator types. More...
 
void setOpType (const OpType type)
 Set operator type. More...
 
void addOpType (const OpType type)
 Add operator type. More...
 
int getNinTheLoop () const
 get number of finite element in the loop More...
 
int getLoopSize () const
 get size of elements in the loop More...
 
std::string getFEName () const
 Get name of the element. More...
 
ForcesAndSourcesCoregetPtrFE () const
 
ForcesAndSourcesCoregetSidePtrFE () const
 
ForcesAndSourcesCoregetRefinePtrFE () const
 
const PetscData::SwitchesgetDataCtx () const
 
const KspMethod::KSPContext getKSPCtx () const
 
const SnesMethod::SNESContext getSNESCtx () const
 
const TSMethod::TSContext getTSCtx () const
 
Vec getKSPf () const
 
Mat getKSPA () const
 
Mat getKSPB () const
 
Vec getSNESf () const
 
Vec getSNESx () const
 
Mat getSNESA () const
 
Mat getSNESB () const
 
Vec getTSu () const
 
Vec getTSu_t () const
 
Vec getTSu_tt () const
 
Vec getTSf () const
 
Mat getTSA () const
 
Mat getTSB () const
 
int getTSstep () const
 
double getTStime () const
 
double getTStimeStep () const
 
double getTSa () const
 
double getTSaa () const
 
MatrixDoublegetGaussPts ()
 matrix of integration (Gauss) points for Volume Element More...
 
auto getFTensor0IntegrationWeight ()
 Get integration weights. More...
 
MatrixDoublegetCoordsAtGaussPts ()
 Gauss points and weight, matrix (nb. of points x 3) More...
 
auto getFTensor1CoordsAtGaussPts ()
 Get coordinates at integration points assuming linear geometry. More...
 
double getMeasure () const
 get measure of element More...
 
doublegetMeasure ()
 get measure of element More...
 
MoFEMErrorCode loopSide (const string &fe_name, ForcesAndSourcesCore *side_fe, const size_t dim, const EntityHandle ent_for_side=0, const int verb=QUIET, const LogManager::SeverityLevel sev=Sev::noisy, AdjCache *adj_cache=nullptr)
 User calls this function to loop over elements on the side of face. This function calls finite element with its operator to do calculations. More...
 
MoFEMErrorCode loopThis (const string &fe_name, ForcesAndSourcesCore *this_fe, const int verb=QUIET, const LogManager::SeverityLevel sev=Sev::noisy)
 User calls this function to loop over the same element using a different set of integration points. This function calls finite element with its operator to do calculations. More...
 
MoFEMErrorCode loopParent (const string &fe_name, ForcesAndSourcesCore *parent_fe, const int verb=QUIET, const LogManager::SeverityLevel sev=Sev::noisy)
 User calls this function to loop over parent elements. This function calls finite element with its operator to do calculations. More...
 
MoFEMErrorCode loopChildren (const string &fe_name, ForcesAndSourcesCore *child_fe, const int verb=QUIET, const LogManager::SeverityLevel sev=Sev::noisy)
 User calls this function to loop over parent elements. This function calls finite element with its operator to do calculations. More...
 
- Public Member Functions inherited from MoFEM::DataOperator
 DataOperator (const bool symm=true)
 
virtual ~DataOperator ()=default
 
virtual MoFEMErrorCode opLhs (EntitiesFieldData &row_data, EntitiesFieldData &col_data)
 
virtual MoFEMErrorCode doWork (int side, EntityType type, EntitiesFieldData::EntData &data)
 Operator for linear form, usually to calculate values on right hand side. More...
 
virtual MoFEMErrorCode opRhs (EntitiesFieldData &data, const bool error_if_no_base=false)
 
bool getSymm () const
 Get if operator uses symmetry of DOFs or not. More...
 
void setSymm ()
 set if operator is executed taking in account symmetry More...
 
void unSetSymm ()
 unset if operator is executed for non symmetric problem More...
 

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...
 

Additional Inherited Members

- Public Types inherited from MoFEM::ForcesAndSourcesCore::UserDataOperator
enum  OpType {
  OPROW = 1 << 0, OPCOL = 1 << 1, OPROWCOL = 1 << 2, OPSPACE = 1 << 3,
  OPLAST = 1 << 3
}
 Controls loop over entities on element. More...
 
using AdjCache = std::map< EntityHandle, std::vector< boost::weak_ptr< NumeredEntFiniteElement > >>
 
- Public Types inherited from MoFEM::DataOperator
using DoWorkLhsHookFunType = boost::function< MoFEMErrorCode(DataOperator *op_ptr, int row_side, int col_side, EntityType row_type, EntityType col_type, EntitiesFieldData::EntData &row_data, EntitiesFieldData::EntData &col_data)>
 
using DoWorkRhsHookFunType = boost::function< MoFEMErrorCode(DataOperator *op_ptr, int side, EntityType type, EntitiesFieldData::EntData &data)>
 
- Public Attributes inherited from MoFEM::ForcesAndSourcesCore::UserDataOperator
char opType
 
std::string rowFieldName
 
std::string colFieldName
 
FieldSpace sPace
 
- Public Attributes inherited from MoFEM::DataOperator
DoWorkLhsHookFunType doWorkLhsHook
 
DoWorkRhsHookFunType doWorkRhsHook
 
bool sYmm
 If true assume that matrix is symmetric structure. More...
 
std::array< bool, MBMAXTYPE > doEntities
 If true operator is executed for entity. More...
 
booldoVertices
 \deprectaed If false skip vertices More...
 
booldoEdges
 \deprectaed If false skip edges More...
 
booldoQuads
 \deprectaed More...
 
booldoTris
 \deprectaed More...
 
booldoTets
 \deprectaed More...
 
booldoPrisms
 \deprectaed More...
 
- Static Public Attributes inherited from MoFEM::ForcesAndSourcesCore::UserDataOperator
static const char *const OpTypeNames []
 
- Protected Attributes inherited from MoFEM::ForcesAndSourcesCore::UserDataOperator
ForcesAndSourcesCoreptrFE
 

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

Definition at line 307 of file PoissonOperators.hpp.

309  false),
310  assembleTranspose(assemble_transpose) {}

Member Function Documentation

◆ aSsemble()

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

integrate local constrains matrix

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_NULL ? 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  }

◆ 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 
)
inlinevirtual

Operator for bi-linear form, usually to calculate values on left hand side.

Reimplemented from MoFEM::DataOperator.

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  }

◆ iNtegrate()

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

Integrate local constrains matrix.

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  }

Member Data Documentation

◆ assembleTranspose

const bool PoissonExample::OpC::assembleTranspose
private

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

Definition at line 342 of file PoissonOperators.hpp.

◆ locMat

MatrixDouble PoissonExample::OpC::locMat
private

local constrains matrix

Definition at line 344 of file PoissonOperators.hpp.

◆ nbCols

int PoissonExample::OpC::nbCols
private

number of dofs on column

Definition at line 340 of file PoissonOperators.hpp.

◆ nbIntegrationPts

int PoissonExample::OpC::nbIntegrationPts
private

number of integration points

Definition at line 341 of file PoissonOperators.hpp.

◆ nbRows

int PoissonExample::OpC::nbRows
private

< error code

number of dofs on row

Definition at line 339 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:460
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:1644
MoFEM::KspMethod::ksp_B
Mat & ksp_B
Definition: LoopMethods.hpp:91
PoissonExample::OpC::locMat
MatrixDouble locMat
local constrains matrix
Definition: PoissonOperators.hpp:344
MoFEM::SnesMethod::snes_B
Mat & snes_B
preconditioner of jacobian matrix
Definition: LoopMethods.hpp:124
PoissonExample::OpC::iNtegrate
MoFEMErrorCode iNtegrate(EntitiesFieldData::EntData &row_data, EntitiesFieldData::EntData &col_data)
Integrate local constrains matrix.
Definition: PoissonOperators.hpp:348
PoissonExample::OpC::nbIntegrationPts
int nbIntegrationPts
number of integration points
Definition: PoissonOperators.hpp:341
PoissonExample::OpC::aSsemble
MoFEMErrorCode aSsemble(EntitiesFieldData::EntData &row_data, EntitiesFieldData::EntData &col_data)
integrate local constrains matrix
Definition: PoissonOperators.hpp:388
MoFEM::ForcesAndSourcesCore::UserDataOperator::OPROWCOL
@ OPROWCOL
operator doWork is executed on FE rows &columns
Definition: ForcesAndSourcesCore.hpp:569
PoissonExample::OpC::nbRows
int nbRows
< error code
Definition: PoissonOperators.hpp:339
MoFEM::ForcesAndSourcesCore::UserDataOperator::getFTensor0IntegrationWeight
auto getFTensor0IntegrationWeight()
Get integration weights.
Definition: ForcesAndSourcesCore.hpp:1240
PoissonExample::OpC::nbCols
int nbCols
number of dofs on column
Definition: PoissonOperators.hpp:340
MoFEM::ForcesAndSourcesCore::UserDataOperator::getGaussPts
MatrixDouble & getGaussPts()
matrix of integration (Gauss) points for Volume Element
Definition: ForcesAndSourcesCore.hpp:1236
MoFEM::EntitiesFieldData::EntData::getFTensor0N
FTensor::Tensor0< FTensor::PackPtr< double *, 1 > > getFTensor0N(const FieldApproximationBase base)
Get base function as Tensor0.
Definition: EntitiesFieldData.hpp:1502
c
const double c
speed of light (cm/ns)
Definition: initial_diffusion.cpp:39
CHKERR
#define CHKERR
Inline error check.
Definition: definitions.h:548
MoFEM::EntitiesFieldData::EntData::getIndices
const VectorInt & getIndices() const
Get global indices of dofs on entity.
Definition: EntitiesFieldData.hpp:1214
MoFEM::ForcesAndSourcesCore::UserDataOperator::getFEMethod
const FEMethod * getFEMethod() const
Return raw pointer to Finite Element Method object.
Definition: ForcesAndSourcesCore.hpp:1042
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:342
MoFEM::FaceElementForcesAndSourcesCore::UserDataOperator::getArea
double getArea()
get area of face
Definition: FaceElementForcesAndSourcesCore.hpp:239
MoFEMFunctionReturn
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:429
MoFEMFunctionBegin
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:359