v0.9.1
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...
 
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
 
DEPRECATED Vec getSnesF () const
 
DEPRECATED Vec getSnesX () const
 
DEPRECATED Mat getSnesA () const
 
DEPRECATED 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 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)
 
virtual ~DataOperator ()=default
 
virtual MoFEMErrorCode opLhs (DataForcesAndSourcesCore &row_data, DataForcesAndSourcesCore &col_data)
 
virtual MoFEMErrorCode opRhs (DataForcesAndSourcesCore &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...
 

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::VolumeElementForcesAndSourcesCoreBase::UserDataOperator
MoFEMErrorCode setPtrFE (ForcesAndSourcesCore *ptr)
 
- Protected Member Functions inherited from MoFEM::ForcesAndSourcesCore::UserDataOperator
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...
 
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...
 

Detailed Description

Definition at line 229 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 192 of file HookeElement.cpp.

196  : VolUserDataOperator(row_field, col_field, type, symm),
197  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 283 of file HookeElement.cpp.

284  {
286 
287  // get pointer to first global index on row
288  const int *row_indices = &*row_data.getIndices().data().begin();
289  // get pointer to first global index on column
290  const int *col_indices = &*col_data.getIndices().data().begin();
291 
292  auto &data = *dataAtPts;
293  if (!data.forcesOnlyOnEntitiesRow.empty()) {
294  rowIndices.resize(nbRows, false);
295  noalias(rowIndices) = row_data.getIndices();
296  row_indices = &rowIndices[0];
297  VectorDofs &dofs = row_data.getFieldDofs();
298  VectorDofs::iterator dit = dofs.begin();
299  for (int ii = 0; dit != dofs.end(); dit++, ii++) {
300  if (data.forcesOnlyOnEntitiesRow.find((*dit)->getEnt()) ==
301  data.forcesOnlyOnEntitiesRow.end()) {
302  rowIndices[ii] = -1;
303  }
304  }
305  }
306 
307  if (!data.forcesOnlyOnEntitiesCol.empty()) {
308  colIndices.resize(nbCols, false);
309  noalias(colIndices) = col_data.getIndices();
310  col_indices = &colIndices[0];
311  VectorDofs &dofs = col_data.getFieldDofs();
312  VectorDofs::iterator dit = dofs.begin();
313  for (int ii = 0; dit != dofs.end(); dit++, ii++) {
314  if (data.forcesOnlyOnEntitiesCol.find((*dit)->getEnt()) ==
315  data.forcesOnlyOnEntitiesCol.end()) {
316  colIndices[ii] = -1;
317  }
318  }
319  }
320 
321  Mat B = getFEMethod()->ksp_B != PETSC_NULL ? getFEMethod()->ksp_B
322  : getFEMethod()->snes_B;
323  // assemble local matrix
324  CHKERR MatSetValues(B, nbRows, row_indices, nbCols, col_indices,
325  &*K.data().begin(), ADD_VALUES);
326 
327  if (!isDiag && sYmm) {
328  // if not diagonal term and since global matrix is symmetric assemble
329  // transpose term.
330  transK.resize(K.size2(), K.size1(), false);
331  noalias(transK) = trans(K);
332  CHKERR MatSetValues(B, nbCols, col_indices, nbRows, row_indices,
333  &*transK.data().begin(), ADD_VALUES);
334  }
336 }
int nbRows
number of dofs on rows
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:482
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.
Mat & snes_B
preconditioner of jacobian matrix
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:601
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
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:412
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 338 of file HookeElement.cpp.

338  {
340 
341  // get pointer to first global index on row
342  const int *row_indices = &*row_data.getIndices().data().begin();
343 
344  auto &data = *dataAtPts;
345  if (!data.forcesOnlyOnEntitiesRow.empty()) {
346  rowIndices.resize(nbRows, false);
347  noalias(rowIndices) = row_data.getIndices();
348  row_indices = &rowIndices[0];
349  VectorDofs &dofs = row_data.getFieldDofs();
350  VectorDofs::iterator dit = dofs.begin();
351  for (int ii = 0; dit != dofs.end(); dit++, ii++) {
352  if (data.forcesOnlyOnEntitiesRow.find((*dit)->getEnt()) ==
353  data.forcesOnlyOnEntitiesRow.end()) {
354  rowIndices[ii] = -1;
355  }
356  }
357  }
358 
359  Vec F = getFEMethod()->snes_f;
360  // assemble local matrix
361  CHKERR VecSetValues(F, nbRows, row_indices, &*nF.data().begin(), ADD_VALUES);
363 }
int nbRows
number of dofs on rows
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:482
Vec & snes_f
residual
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:601
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:412
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 199 of file HookeElement.cpp.

203  {
204 
206 
207  // get number of dofs on row
208  nbRows = row_data.getIndices().size();
209  // if no dofs on row, exit that work, nothing to do here
210  if (!nbRows)
212 
213  // get number of dofs on column
214  nbCols = col_data.getIndices().size();
215  // if no dofs on Columbia, exit nothing to do here
216  if (!nbCols)
218 
219  // K_ij matrix will have 3 times the number of degrees of freedom of the
220  // i-th entity set (nbRows)
221  // and 3 times the number of degrees of freedom of the j-th entity set
222  // (nbCols)
223  K.resize(nbRows, nbCols, false);
224  K.clear();
225 
226  // get number of integration points
227  nbIntegrationPts = getGaussPts().size2();
228  // check if entity block is on matrix diagonal
229  if (row_side == col_side && row_type == col_type) {
230  isDiag = true;
231  } else {
232  isDiag = false;
233  }
234 
235  // integrate local matrix for entity block
236  CHKERR iNtegrate(row_data, col_data);
237 
238  // assemble local matrix
239  CHKERR aSsemble(row_data, col_data);
240 
242 }
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:482
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:513
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:601
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:412
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 244 of file HookeElement.cpp.

246  {
248 
249  // get number of dofs on row
250  nbRows = row_data.getIndices().size();
251  // if no dofs on row, exit that work, nothing to do here
252  if (!nbRows)
254 
255  nF.resize(nbRows, false);
256  nF.clear();
257 
258  // get number of integration points
259  nbIntegrationPts = getGaussPts().size2();
260 
261  // integrate local matrix for entity block
262  CHKERR iNtegrate(row_data);
263 
264  // assemble local matrix
265  CHKERR aSsemble(row_data);
266 
268 }
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:482
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:513
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:601
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:412

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

271  {
273  SETERRQ(PETSC_COMM_SELF, MOFEM_NOT_IMPLEMENTED, "Not implemented");
275 };
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:482
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:412

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

277  {
279  SETERRQ(PETSC_COMM_SELF, MOFEM_NOT_IMPLEMENTED, "Not implemented");
281 };
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:482
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:412

Member Data Documentation

◆ colIndices

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

Definition at line 260 of file HookeElement.hpp.

◆ dataAtPts

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

Definition at line 257 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 265 of file HookeElement.hpp.

◆ K

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

Definition at line 253 of file HookeElement.hpp.

◆ nbCols

int HookeElement::OpAssemble::nbCols
protected

number if dof on column

Examples
HookeElement.cpp, and HookeElement.hpp.

Definition at line 263 of file HookeElement.hpp.

◆ nbIntegrationPts

int HookeElement::OpAssemble::nbIntegrationPts
protected

number of integration points

Examples
HookeElement.cpp, and HookeElement.hpp.

Definition at line 264 of file HookeElement.hpp.

◆ nbRows

int HookeElement::OpAssemble::nbRows
protected

number of dofs on rows

Examples
HookeElement.cpp, and HookeElement.hpp.

Definition at line 262 of file HookeElement.hpp.

◆ nF

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

Definition at line 255 of file HookeElement.hpp.

◆ rowIndices

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

Definition at line 259 of file HookeElement.hpp.

◆ transK

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

Definition at line 254 of file HookeElement.hpp.


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