v0.14.0
Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | List of all members
OpK Struct Reference
Inheritance diagram for OpK:
[legend]
Collaboration diagram for OpK:
[legend]

Public Member Functions

 OpK (bool symm=true)
 
MoFEMErrorCode doWork (int row_side, int col_side, EntityType row_type, EntityType col_type, EntitiesFieldData::EntData &row_data, EntitiesFieldData::EntData &col_data)
 Do calculations for give operator. More...
 
- Public Member Functions inherited from MoFEM::VolumeElementForcesAndSourcesCore::UserDataOperator
int getNumNodes ()
 get element number of nodes More...
 
const EntityHandlegetConn ()
 get element connectivity More...
 
double getVolume () const
 element volume (linear geometry) More...
 
doublegetVolume ()
 element volume (linear geometry) More...
 
FTensor::Tensor2< double *, 3, 3 > & getJac ()
 get element Jacobian More...
 
FTensor::Tensor2< double *, 3, 3 > & getInvJac ()
 get element inverse Jacobian More...
 
VectorDoublegetCoords ()
 nodal coordinates More...
 
VolumeElementForcesAndSourcesCoregetVolumeFE () const
 return pointer to Generic Volume Finite Element object More...
 
- 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...
 

Public Attributes

MatrixDouble K
 
FTensor::Ddg< double, 3, 3 > tD
 
double yOung
 
double pOisson
 
- 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...
 

Protected Member Functions

MoFEMErrorCode iNtegrate (EntitiesFieldData::EntData &row_data, EntitiesFieldData::EntData &col_data)
 Integrate B^T D B operator. More...
 
MoFEMErrorCode aSsemble (EntitiesFieldData::EntData &row_data, EntitiesFieldData::EntData &col_data)
 Assemble local entity block matrix. More...
 
- Protected Member Functions inherited from MoFEM::VolumeElementForcesAndSourcesCore::UserDataOperator
MoFEMErrorCode setPtrFE (ForcesAndSourcesCore *ptr)
 

Protected Attributes

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...
 
- Protected Attributes inherited from MoFEM::ForcesAndSourcesCore::UserDataOperator
ForcesAndSourcesCoreptrFE
 

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)>
 
- Static Public Attributes inherited from MoFEM::ForcesAndSourcesCore::UserDataOperator
static const char *const OpTypeNames []
 

Detailed Description

Examples
eigen_elastic.cpp, PoissonOperators.hpp, and simple_elasticity.cpp.

Definition at line 16 of file simple_elasticity.cpp.

Constructor & Destructor Documentation

◆ OpK()

OpK::OpK ( bool  symm = true)
inline

Definition at line 29 of file simple_elasticity.cpp.

31  symm) {
32 
33  // Evaluation of the elastic stiffness tensor, D
34 
35  // hardcoded choice of elastic parameters
36  pOisson = 0.1;
37  yOung = 10;
38 
39  // coefficient used in intermediate calculation
40  const double coefficient = yOung / ((1 + pOisson) * (1 - 2 * pOisson));
41 
46 
47  tD(i, j, k, l) = 0.;
48 
49  tD(0, 0, 0, 0) = 1 - pOisson;
50  tD(1, 1, 1, 1) = 1 - pOisson;
51  tD(2, 2, 2, 2) = 1 - pOisson;
52 
53  tD(0, 1, 0, 1) = 0.5 * (1 - 2 * pOisson);
54  tD(0, 2, 0, 2) = 0.5 * (1 - 2 * pOisson);
55  tD(1, 2, 1, 2) = 0.5 * (1 - 2 * pOisson);
56 
57  tD(0, 0, 1, 1) = pOisson;
58  tD(1, 1, 0, 0) = pOisson;
59  tD(0, 0, 2, 2) = pOisson;
60  tD(2, 2, 0, 0) = pOisson;
61  tD(1, 1, 2, 2) = pOisson;
62  tD(2, 2, 1, 1) = pOisson;
63 
64  tD(i, j, k, l) *= coefficient;
65  }

Member Function Documentation

◆ aSsemble()

MoFEMErrorCode OpK::aSsemble ( EntitiesFieldData::EntData row_data,
EntitiesFieldData::EntData col_data 
)
inlineprotected

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

Definition at line 205 of file simple_elasticity.cpp.

206  {
208  // get pointer to first global index on row
209  const int *row_indices = &*row_data.getIndices().data().begin();
210  // get pointer to first global index on column
211  const int *col_indices = &*col_data.getIndices().data().begin();
212  Mat B = getFEMethod()->ksp_B != PETSC_NULL ? getFEMethod()->ksp_B
213  : getFEMethod()->snes_B;
214  // assemble local matrix
215  CHKERR MatSetValues(B, nbRows, row_indices, nbCols, col_indices,
216  &*K.data().begin(), ADD_VALUES);
217 
218  if (!isDiag && sYmm) {
219  // if not diagonal term and since global matrix is symmetric assemble
220  // transpose term.
221  K = trans(K);
222  CHKERR MatSetValues(B, nbCols, col_indices, nbRows, row_indices,
223  &*K.data().begin(), ADD_VALUES);
224  }
226  }

◆ doWork()

MoFEMErrorCode OpK::doWork ( int  row_side,
int  col_side,
EntityType  row_type,
EntityType  col_type,
EntitiesFieldData::EntData row_data,
EntitiesFieldData::EntData col_data 
)
inlinevirtual

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

Reimplemented from MoFEM::DataOperator.

Definition at line 77 of file simple_elasticity.cpp.

80  {
81 
83 
84  // get number of dofs on row
85  nbRows = row_data.getIndices().size();
86  // if no dofs on row, exit that work, nothing to do here
87  if (!nbRows)
89 
90  // get number of dofs on column
91  nbCols = col_data.getIndices().size();
92  // if no dofs on Columbia, exit nothing to do here
93  if (!nbCols)
95 
96  // K_ij matrix will have 3 times the number of degrees of freedom of the
97  // i-th entity set (nbRows)
98  // and 3 times the number of degrees of freedom of the j-th entity set
99  // (nbCols)
100  K.resize(nbRows, nbCols, false);
101  K.clear();
102 
103  // get number of integration points
104  nbIntegrationPts = getGaussPts().size2();
105  // check if entity block is on matrix diagonal
106  if (row_side == col_side && row_type == col_type) {
107  isDiag = true;
108  } else {
109  isDiag = false;
110  }
111 
112  // integrate local matrix for entity block
113  CHKERR iNtegrate(row_data, col_data);
114 
115  // assemble local matrix
116  CHKERR aSsemble(row_data, col_data);
117 
119  }

◆ iNtegrate()

MoFEMErrorCode OpK::iNtegrate ( EntitiesFieldData::EntData row_data,
EntitiesFieldData::EntData col_data 
)
inlineprotected

Integrate B^T D B operator.

Parameters
row_datarow data (consist base functions on row entity)
col_datacolumn data (consist base functions on column entity)
Returns
error code

Definition at line 133 of file simple_elasticity.cpp.

134  {
136 
137  // get sub-block (3x3) of local stiffens matrix, here represented by second
138  // order tensor
139  auto get_tensor2 = [](MatrixDouble &m, const int r, const int c) {
141  &m(r + 0, c + 0), &m(r + 0, c + 1), &m(r + 0, c + 2),
142  &m(r + 1, c + 0), &m(r + 1, c + 1), &m(r + 1, c + 2),
143  &m(r + 2, c + 0), &m(r + 2, c + 1), &m(r + 2, c + 2));
144  };
145 
150 
151  // get element volume
152  double vol = getVolume();
153 
154  // get intergration weights
155  auto t_w = getFTensor0IntegrationWeight();
156 
157  // get derivatives of base functions on rows
158  auto t_row_diff_base = row_data.getFTensor1DiffN<3>();
159  // iterate over integration points
160  for (int gg = 0; gg != nbIntegrationPts; ++gg) {
161 
162  // calculate scalar weight times element volume
163  const double a = t_w * vol;
164 
165  // iterate over row base functions
166  for (int rr = 0; rr != nbRows / 3; ++rr) {
167 
168  // get sub matrix for the row
169  auto t_m = get_tensor2(K, 3 * rr, 0);
170 
171  // get derivatives of base functions for columns
172  auto t_col_diff_base = col_data.getFTensor1DiffN<3>(gg, 0);
173 
174  // iterate column base functions
175  for (int cc = 0; cc != nbCols / 3; ++cc) {
176 
177  // integrate block local stiffens matrix
178  t_m(i, k) +=
179  a * (tD(i, j, k, l) * (t_row_diff_base(j) * t_col_diff_base(l)));
180 
181  // move to next column base function
182  ++t_col_diff_base;
183 
184  // move to next block of local stiffens matrix
185  ++t_m;
186  }
187 
188  // move to next row base function
189  ++t_row_diff_base;
190  }
191 
192  // move to next integration weight
193  ++t_w;
194  }
195 
197  }

Member Data Documentation

◆ isDiag

bool OpK::isDiag
protected

true if this block is on diagonal

Definition at line 125 of file simple_elasticity.cpp.

◆ K

MatrixDouble OpK::K

Definition at line 19 of file simple_elasticity.cpp.

◆ nbCols

int OpK::nbCols
protected

number if dof on column

Definition at line 123 of file simple_elasticity.cpp.

◆ nbIntegrationPts

int OpK::nbIntegrationPts
protected

number of integration points

Definition at line 124 of file simple_elasticity.cpp.

◆ nbRows

int OpK::nbRows
protected

number of dofs on rows

Definition at line 122 of file simple_elasticity.cpp.

◆ pOisson

double OpK::pOisson

Definition at line 27 of file simple_elasticity.cpp.

◆ tD

FTensor::Ddg<double, 3, 3> OpK::tD

Definition at line 22 of file simple_elasticity.cpp.

◆ yOung

double OpK::yOung

Definition at line 25 of file simple_elasticity.cpp.


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
OpK::nbCols
int nbCols
number if dof on column
Definition: simple_elasticity.cpp:123
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
MoFEM::KspMethod::ksp_B
Mat & ksp_B
Definition: LoopMethods.hpp:91
MoFEM::Types::MatrixDouble
UBlasMatrix< double > MatrixDouble
Definition: Types.hpp:77
MoFEM::SnesMethod::snes_B
Mat & snes_B
preconditioner of jacobian matrix
Definition: LoopMethods.hpp:124
OpK::isDiag
bool isDiag
true if this block is on diagonal
Definition: simple_elasticity.cpp:125
MoFEM::VolumeElementForcesAndSourcesCore::UserDataOperator::getVolume
double getVolume() const
element volume (linear geometry)
Definition: VolumeElementForcesAndSourcesCore.hpp:161
MoFEM::ForcesAndSourcesCore::UserDataOperator::OPROWCOL
@ OPROWCOL
operator doWork is executed on FE rows &columns
Definition: ForcesAndSourcesCore.hpp:569
sdf.r
int r
Definition: sdf.py:8
FTensor::Tensor2
Definition: Tensor2_value.hpp:16
MoFEM::ForcesAndSourcesCore::UserDataOperator::getFTensor0IntegrationWeight
auto getFTensor0IntegrationWeight()
Get integration weights.
Definition: ForcesAndSourcesCore.hpp:1239
MoFEM::ForcesAndSourcesCore::UserDataOperator::getGaussPts
MatrixDouble & getGaussPts()
matrix of integration (Gauss) points for Volume Element
Definition: ForcesAndSourcesCore.hpp:1235
OpK::pOisson
double pOisson
Definition: simple_elasticity.cpp:27
c
const double c
speed of light (cm/ns)
Definition: initial_diffusion.cpp:39
CHKERR
#define CHKERR
Inline error check.
Definition: definitions.h:535
a
constexpr double a
Definition: approx_sphere.cpp:30
MoFEM::EntitiesFieldData::EntData::getIndices
const VectorInt & getIndices() const
Get global indices of dofs on entity.
Definition: EntitiesFieldData.hpp:1201
OpK::iNtegrate
MoFEMErrorCode iNtegrate(EntitiesFieldData::EntData &row_data, EntitiesFieldData::EntData &col_data)
Integrate B^T D B operator.
Definition: simple_elasticity.cpp:133
i
FTensor::Index< 'i', SPACE_DIM > i
Definition: hcurl_divergence_operator_2d.cpp:27
FTensor::Index< 'i', 3 >
MoFEM::ForcesAndSourcesCore::UserDataOperator::getFEMethod
const FEMethod * getFEMethod() const
Return raw pointer to Finite Element Method object.
Definition: ForcesAndSourcesCore.hpp:1041
OpK::nbIntegrationPts
int nbIntegrationPts
number of integration points
Definition: simple_elasticity.cpp:124
OpK::K
MatrixDouble K
Definition: simple_elasticity.cpp:19
MoFEM::EntitiesFieldData::EntData::getFTensor1DiffN
FTensor::Tensor1< FTensor::PackPtr< double *, Tensor_Dim >, Tensor_Dim > getFTensor1DiffN(const FieldApproximationBase base)
Get derivatives of base functions.
Definition: EntitiesFieldData.cpp:526
OpK::yOung
double yOung
Definition: simple_elasticity.cpp:25
UserDataOperator
ForcesAndSourcesCore::UserDataOperator UserDataOperator
Definition: HookeElement.hpp:75
j
FTensor::Index< 'j', 3 > j
Definition: matrix_function.cpp:19
OpK::nbRows
int nbRows
number of dofs on rows
Definition: simple_elasticity.cpp:122
OpK::aSsemble
MoFEMErrorCode aSsemble(EntitiesFieldData::EntData &row_data, EntitiesFieldData::EntData &col_data)
Assemble local entity block matrix.
Definition: simple_elasticity.cpp:205
m
FTensor::Index< 'm', 3 > m
Definition: shallow_wave.cpp:80
OpK::tD
FTensor::Ddg< double, 3, 3 > tD
Definition: simple_elasticity.cpp:22
k
FTensor::Index< 'k', 3 > k
Definition: matrix_function.cpp:20
MoFEM::DataOperator::sYmm
bool sYmm
If true assume that matrix is symmetric structure.
Definition: DataOperators.hpp:82
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
l
FTensor::Index< 'l', 3 > l
Definition: matrix_function.cpp:21