v0.9.0
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
HookeElement::OpAssemble Struct Reference

#include <users_modules/basic_finite_elements/src/HookeElement.hpp>

Inheritance diagram for HookeElement::OpAssemble:
[legend]
Collaboration diagram for HookeElement::OpAssemble:
[legend]

Public Member Functions

 OpAssemble (const std::string row_field, const std::string col_field, boost::shared_ptr< DataAtIntegrationPts > &data_at_pts, const char type, bool symm=false)
 
MoFEMErrorCode doWork (int row_side, int col_side, EntityType row_type, EntityType col_type, EntData &row_data, EntData &col_data)
 Do calculations for give operator. More...
 
MoFEMErrorCode doWork (int row_side, EntityType row_type, EntData &row_data)
 Operator for linear form, usually to calculate values on right hand side. More...
 
- Public Member Functions inherited from MoFEM::VolumeElementForcesAndSourcesCoreBase::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...
 
double getMeasure () const
 get measure of element More...
 
doublegetMeasure ()
 get measure of element More...
 
VectorDoublegetCoords ()
 nodal coordinates More...
 
MatrixDoublegetCoordsAtGaussPts ()
 Gauss points and weight, matrix (nb. of points x 3) More...
 
MatrixDoublegetHoCoordsAtGaussPts ()
 coordinate at Gauss points (if hierarchical approximation of element geometry) More...
 
MatrixDoublegetHoGaussPtsJac ()
 
MatrixDoublegetHoGaussPtsInvJac ()
 
VectorDoublegetHoGaussPtsDetJac ()
 
auto getFTenosr0HoMeasure ()
 
auto getFTensor1CoordsAtGaussPts ()
 Get coordinates at integration points assuming linear geometry. More...
 
auto getFTensor1HoCoordsAtGaussPts ()
 Get coordinates at integration points taking geometry from field. More...
 
auto getFTensor2HoGaussPtsJac ()
 
auto getFTensor2HoGaussPtsInvJac ()
 
VolumeElementForcesAndSourcesCoreBasegetVolumeFE () const
 return pointer to Generic Volume Finite Element object More...
 
MoFEMErrorCode getDivergenceOfHDivBaseFunctions (int side, EntityType type, DataForcesAndSourcesCore::EntData &data, int gg, VectorDouble &div)
 Get divergence of base functions at integration point. More...
 
MoFEMErrorCode getCurlOfHCurlBaseFunctions (int side, EntityType type, DataForcesAndSourcesCore::EntData &data, int gg, MatrixDouble &curl)
 Get curl of base functions at integration point. More...
 
- Public Member Functions inherited from MoFEM::ForcesAndSourcesCore::UserDataOperator
 UserDataOperator (const FieldSpace space, const char type=OPLAST, 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...
 
boost::weak_ptr< SideNumber > getSideNumberPtr (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 ()
 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...
 
const std::string & getFEName () const
 Get name of the element. More...
 
Vec getSnesF () const
 
Vec getSnesX () const
 
Mat getSnesA () const
 
Mat getSnesB () const
 
Vec getTSu () const
 
Vec getTSu_t () const
 
Vec getTSf () const
 
Mat getTSA () const
 
Mat getTSB () const
 
int getTSstep () const
 
double getTStime () const
 
double getTSa () const
 
MatrixDoublegetGaussPts ()
 matrix of integration (Gauss) points for Volume Element More...
 
auto getFTensor0IntegrationWeight ()
 Get integration weights. More...
 
DEPRECATED MoFEMErrorCode getPorblemRowIndices (const std::string filed_name, const EntityType type, const int side, VectorInt &indices) const
 
- Public Member Functions inherited from MoFEM::DataOperator
 DataOperator (const bool symm=true, const bool do_vertices=true, const bool do_edges=true, const bool do_quads=true, const bool do_tris=true, const bool do_tets=true, const bool do_prisms=true)
 
virtual ~DataOperator ()
 
virtual MoFEMErrorCode opLhs (DataForcesAndSourcesCore &row_data, DataForcesAndSourcesCore &col_data, bool symm=true)
 
virtual MoFEMErrorCode opLhs (DataForcesAndSourcesCore &row_data, DataForcesAndSourcesCore &col_data)
 
virtual MoFEMErrorCode opRhs (DataForcesAndSourcesCore &data, const bool do_vertices, const bool do_edges, const bool do_quads, const bool do_tris, const bool do_tets, const bool do_prisms, const bool error_if_no_base=true)
 
virtual MoFEMErrorCode opRhs (DataForcesAndSourcesCore &data, const bool error_if_no_base=true)
 
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...
 

Protected Member Functions

virtual MoFEMErrorCode iNtegrate (EntData &row_data, EntData &col_data)
 
virtual MoFEMErrorCode iNtegrate (EntData &row_data)
 
MoFEMErrorCode aSsemble (EntData &row_data, EntData &col_data)
 Assemble local entity block matrix. More...
 
MoFEMErrorCode aSsemble (EntData &row_data)
 Assemble local entity right-hand vector. More...
 
- Protected Member Functions inherited from MoFEM::ForcesAndSourcesCore::UserDataOperator
MoFEMErrorCode setPtrFE (ForcesAndSourcesCore *ptr)
 
ForcesAndSourcesCoregetPtrFE () const
 
ForcesAndSourcesCoregetSidePtrFE () const
 

Protected Attributes

MatrixDouble K
 
MatrixDouble transK
 
VectorDouble nF
 
boost::shared_ptr< DataAtIntegrationPtsdataAtPts
 
VectorInt rowIndices
 
VectorInt colIndices
 
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, OPLAST = 1 << 3 }
 Controls loop over entities on element. More...
 
- Public Attributes inherited from MoFEM::ForcesAndSourcesCore::UserDataOperator
char opType
 
std::string rowFieldName
 
std::string colFieldName
 
FieldSpace sPace
 
- Public Attributes inherited from MoFEM::DataOperator
bool sYmm
 If true assume that matrix is symmetric structure. More...
 
bool doVertices
 If false skip vertices. More...
 
bool doEdges
 If false skip edges. More...
 
bool doQuads
 
bool doTris
 
bool doTets
 
bool doPrisms
 

Detailed Description

Definition at line 230 of file HookeElement.hpp.

Constructor & Destructor Documentation

◆ OpAssemble()

HookeElement::OpAssemble::OpAssemble ( const std::string  row_field,
const std::string  col_field,
boost::shared_ptr< DataAtIntegrationPts > &  data_at_pts,
const char  type,
bool  symm = false 
)
Examples
HookeElement.cpp, and HookeElement.hpp.

Definition at line 204 of file HookeElement.cpp.

208  : VolUserDataOperator(row_field, col_field, type, symm),
209  dataAtPts(data_at_pts) {}
boost::shared_ptr< DataAtIntegrationPts > dataAtPts
VolumeElementForcesAndSourcesCore::UserDataOperator VolUserDataOperator

Member Function Documentation

◆ aSsemble() [1/2]

MoFEMErrorCode HookeElement::OpAssemble::aSsemble ( EntData row_data,
EntData col_data 
)
protected

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
Examples
HookeElement.cpp, and HookeElement.hpp.

Definition at line 295 of file HookeElement.cpp.

296  {
298 
299  // get pointer to first global index on row
300  const int *row_indices = &*row_data.getIndices().data().begin();
301  // get pointer to first global index on column
302  const int *col_indices = &*col_data.getIndices().data().begin();
303 
304  auto &data = *dataAtPts;
305  if (!data.forcesOnlyOnEntitiesRow.empty()) {
306  rowIndices.resize(nbRows, false);
307  noalias(rowIndices) = row_data.getIndices();
308  row_indices = &rowIndices[0];
309  VectorDofs &dofs = row_data.getFieldDofs();
310  VectorDofs::iterator dit = dofs.begin();
311  for (int ii = 0; dit != dofs.end(); dit++, ii++) {
312  if (data.forcesOnlyOnEntitiesRow.find((*dit)->getEnt()) ==
313  data.forcesOnlyOnEntitiesRow.end()) {
314  rowIndices[ii] = -1;
315  }
316  }
317  }
318 
319  if (!data.forcesOnlyOnEntitiesCol.empty()) {
320  colIndices.resize(nbCols, false);
321  noalias(colIndices) = col_data.getIndices();
322  col_indices = &colIndices[0];
323  VectorDofs &dofs = col_data.getFieldDofs();
324  VectorDofs::iterator dit = dofs.begin();
325  for (int ii = 0; dit != dofs.end(); dit++, ii++) {
326  if (data.forcesOnlyOnEntitiesCol.find((*dit)->getEnt()) ==
327  data.forcesOnlyOnEntitiesCol.end()) {
328  colIndices[ii] = -1;
329  }
330  }
331  }
332 
333  Mat B = getFEMethod()->ksp_B != PETSC_NULL ? getFEMethod()->ksp_B
334  : getFEMethod()->snes_B;
335  // assemble local matrix
336  CHKERR MatSetValues(B, nbRows, row_indices, nbCols, col_indices,
337  &*K.data().begin(), ADD_VALUES);
338 
339  if (!isDiag && sYmm) {
340  // if not diagonal term and since global matrix is symmetric assemble
341  // transpose term.
342  transK.resize(K.size2(), K.size1(), false);
343  noalias(transK) = trans(K);
344  CHKERR MatSetValues(B, nbCols, col_indices, nbRows, row_indices,
345  &*transK.data().begin(), ADD_VALUES);
346  }
348 }
int nbRows
number of dofs on rows
Mat ksp_B
preconditioner matrix
Definition: LoopMethods.hpp:94
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:477
const FEMethod * getFEMethod() const
Return raw pointer to Finite Element Method object.
const VectorInt & getIndices() const
Get global indices of dofs on entity.
bool sYmm
If true assume that matrix is symmetric structure.
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
ublas::vector< boost::shared_ptr< const FEDofEntity >, DofsAllocator > VectorDofs
const VectorDofs & getFieldDofs() const
get dofs data stature FEDofEntity
int nbCols
number if dof on column
Mat snes_B
preconditioner of jacobian matrix
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:407
bool isDiag
true if this block is on diagonal
boost::shared_ptr< DataAtIntegrationPts > dataAtPts

◆ aSsemble() [2/2]

MoFEMErrorCode HookeElement::OpAssemble::aSsemble ( EntData row_data)
protected

Assemble local entity right-hand vector.

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 350 of file HookeElement.cpp.

350  {
352 
353  // get pointer to first global index on row
354  const int *row_indices = &*row_data.getIndices().data().begin();
355 
356  auto &data = *dataAtPts;
357  if (!data.forcesOnlyOnEntitiesRow.empty()) {
358  rowIndices.resize(nbRows, false);
359  noalias(rowIndices) = row_data.getIndices();
360  row_indices = &rowIndices[0];
361  VectorDofs &dofs = row_data.getFieldDofs();
362  VectorDofs::iterator dit = dofs.begin();
363  for (int ii = 0; dit != dofs.end(); dit++, ii++) {
364  if (data.forcesOnlyOnEntitiesRow.find((*dit)->getEnt()) ==
365  data.forcesOnlyOnEntitiesRow.end()) {
366  rowIndices[ii] = -1;
367  }
368  }
369  }
370 
371  Vec F = getFEMethod()->snes_f;
372  // assemble local matrix
373  CHKERR VecSetValues(F, nbRows, row_indices, &*nF.data().begin(), ADD_VALUES);
375 }
int nbRows
number of dofs on rows
Vec snes_f
residual
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:477
const FEMethod * getFEMethod() const
Return raw pointer to Finite Element Method object.
const VectorInt & getIndices() const
Get global indices of dofs on entity.
MoFEMErrorCode VecSetValues(Vec V, const DataForcesAndSourcesCore::EntData &data, const double *ptr, InsertMode iora)
Assemble PETSc vector.
#define CHKERR
Inline error check.
Definition: definitions.h:596
ublas::vector< boost::shared_ptr< const FEDofEntity >, DofsAllocator > VectorDofs
const VectorDofs & getFieldDofs() const
get dofs data stature FEDofEntity
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:407
boost::shared_ptr< DataAtIntegrationPts > dataAtPts

◆ doWork() [1/2]

MoFEMErrorCode HookeElement::OpAssemble::doWork ( int  row_side,
int  col_side,
EntityType  row_type,
EntityType  col_type,
EntData row_data,
EntData col_data 
)
virtual

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.

Examples
HookeElement.cpp, and HookeElement.hpp.

Definition at line 211 of file HookeElement.cpp.

215  {
216 
218 
219  // get number of dofs on row
220  nbRows = row_data.getIndices().size();
221  // if no dofs on row, exit that work, nothing to do here
222  if (!nbRows)
224 
225  // get number of dofs on column
226  nbCols = col_data.getIndices().size();
227  // if no dofs on Columbia, exit nothing to do here
228  if (!nbCols)
230 
231  // K_ij matrix will have 3 times the number of degrees of freedom of the
232  // i-th entity set (nbRows)
233  // and 3 times the number of degrees of freedom of the j-th entity set
234  // (nbCols)
235  K.resize(nbRows, nbCols, false);
236  K.clear();
237 
238  // get number of integration points
239  nbIntegrationPts = getGaussPts().size2();
240  // check if entity block is on matrix diagonal
241  if (row_side == col_side && row_type == col_type) {
242  isDiag = true;
243  } else {
244  isDiag = false;
245  }
246 
247  // integrate local matrix for entity block
248  CHKERR iNtegrate(row_data, col_data);
249 
250  // assemble local matrix
251  CHKERR aSsemble(row_data, col_data);
252 
254 }
int nbRows
number of dofs on rows
MatrixDouble & getGaussPts()
matrix of integration (Gauss) points for Volume Element
virtual MoFEMErrorCode iNtegrate(EntData &row_data, EntData &col_data)
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:477
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:508
const VectorInt & getIndices() const
Get global indices of dofs on entity.
MoFEMErrorCode aSsemble(EntData &row_data, EntData &col_data)
Assemble local entity block matrix.
int nbIntegrationPts
number of integration points
#define CHKERR
Inline error check.
Definition: definitions.h:596
int nbCols
number if dof on column
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:407
bool isDiag
true if this block is on diagonal

◆ doWork() [2/2]

MoFEMErrorCode HookeElement::OpAssemble::doWork ( int  side,
EntityType  type,
EntData data 
)
virtual

Operator for linear form, usually to calculate values on right hand side.

Reimplemented from MoFEM::DataOperator.

Definition at line 256 of file HookeElement.cpp.

258  {
260 
261  // get number of dofs on row
262  nbRows = row_data.getIndices().size();
263  // if no dofs on row, exit that work, nothing to do here
264  if (!nbRows)
266 
267  nF.resize(nbRows, false);
268  nF.clear();
269 
270  // get number of integration points
271  nbIntegrationPts = getGaussPts().size2();
272 
273  // integrate local matrix for entity block
274  CHKERR iNtegrate(row_data);
275 
276  // assemble local matrix
277  CHKERR aSsemble(row_data);
278 
280 }
int nbRows
number of dofs on rows
MatrixDouble & getGaussPts()
matrix of integration (Gauss) points for Volume Element
virtual MoFEMErrorCode iNtegrate(EntData &row_data, EntData &col_data)
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:477
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:508
MoFEMErrorCode aSsemble(EntData &row_data, EntData &col_data)
Assemble local entity block matrix.
int nbIntegrationPts
number of integration points
#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

◆ iNtegrate() [1/2]

MoFEMErrorCode HookeElement::OpAssemble::iNtegrate ( EntData row_data,
EntData col_data 
)
protectedvirtual

Reimplemented in HookeElement::OpAleLhs_dX_dx, HookeElement::OpAleLhs_dX_dX< S >, HookeElement::OpAleLhsWithDensity_dX_dX, HookeElement::OpAleLhsWithDensity_dx_dX, HookeElement::OpAleLhs_dx_dX< S >, HookeElement::OpAleLhs_dx_dx< S >, and HookeElement::OpLhs_dx_dx< S >.

Examples
HookeElement.cpp, and HookeElement.hpp.

Definition at line 282 of file HookeElement.cpp.

283  {
285  SETERRQ(PETSC_COMM_SELF, MOFEM_NOT_IMPLEMENTED, "Not implemented");
287 };
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:477
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:407

◆ iNtegrate() [2/2]

MoFEMErrorCode HookeElement::OpAssemble::iNtegrate ( EntData row_data)
protectedvirtual

Reimplemented in HookeElement::OpAleRhs_dX, HookeElement::OpAleRhs_dx, and HookeElement::OpRhs_dx.

Definition at line 289 of file HookeElement.cpp.

289  {
291  SETERRQ(PETSC_COMM_SELF, MOFEM_NOT_IMPLEMENTED, "Not implemented");
293 };
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:477
#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

◆ colIndices

VectorInt HookeElement::OpAssemble::colIndices
protected
Examples
HookeElement.hpp.

Definition at line 261 of file HookeElement.hpp.

◆ dataAtPts

boost::shared_ptr<DataAtIntegrationPts> HookeElement::OpAssemble::dataAtPts
protected
Examples
HookeElement.cpp, and HookeElement.hpp.

Definition at line 258 of file HookeElement.hpp.

◆ isDiag

bool HookeElement::OpAssemble::isDiag
protected

true if this block is on diagonal

Examples
HookeElement.cpp, and HookeElement.hpp.

Definition at line 266 of file HookeElement.hpp.

◆ K

MatrixDouble HookeElement::OpAssemble::K
protected
Examples
HookeElement.cpp, and HookeElement.hpp.

Definition at line 254 of file HookeElement.hpp.

◆ nbCols

int HookeElement::OpAssemble::nbCols
protected

number if dof on column

Examples
HookeElement.cpp, and HookeElement.hpp.

Definition at line 264 of file HookeElement.hpp.

◆ nbIntegrationPts

int HookeElement::OpAssemble::nbIntegrationPts
protected

number of integration points

Examples
HookeElement.cpp, and HookeElement.hpp.

Definition at line 265 of file HookeElement.hpp.

◆ nbRows

int HookeElement::OpAssemble::nbRows
protected

number of dofs on rows

Examples
HookeElement.cpp, and HookeElement.hpp.

Definition at line 263 of file HookeElement.hpp.

◆ nF

VectorDouble HookeElement::OpAssemble::nF
protected
Examples
HookeElement.cpp, and HookeElement.hpp.

Definition at line 256 of file HookeElement.hpp.

◆ rowIndices

VectorInt HookeElement::OpAssemble::rowIndices
protected
Examples
HookeElement.hpp.

Definition at line 260 of file HookeElement.hpp.

◆ transK

MatrixDouble HookeElement::OpAssemble::transK
protected
Examples
HookeElement.hpp.

Definition at line 255 of file HookeElement.hpp.


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