v0.15.0
Loading...
Searching...
No Matches
OpAssemble Struct Reference

#include "users_modules/basic_finite_elements/src/HookeElement.hpp"

Inheritance diagram for OpAssemble:
[legend]
Collaboration diagram for 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.
 
MoFEMErrorCode doWork (int row_side, EntityType row_type, EntData &row_data)
 Operator for linear form, usually to calculate values on right hand side.
 
- Public Member Functions inherited from MoFEM::VolumeElementForcesAndSourcesCore::UserDataOperator
int getNumNodes ()
 get element number of nodes
 
const EntityHandlegetConn ()
 get element connectivity
 
double getVolume () const
 element volume (linear geometry)
 
doublegetVolume ()
 element volume (linear geometry)
 
FTensor::Tensor2< double *, 3, 3 > & getJac ()
 get element Jacobian
 
FTensor::Tensor2< double *, 3, 3 > & getInvJac ()
 get element inverse Jacobian
 
VectorDoublegetCoords ()
 nodal coordinates
 
VolumeElementForcesAndSourcesCoregetVolumeFE () const
 return pointer to Generic Volume Finite Element object
 
- 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.
 
EntityHandle getFEEntityHandle () const
 Return finite element entity handle.
 
int getFEDim () const
 Get dimension of finite element.
 
EntityType getFEType () const
 Get dimension of finite element.
 
boost::weak_ptr< SideNumbergetSideNumberPtr (const int side_number, const EntityType type)
 Get the side number pointer.
 
EntityHandle getSideEntity (const int side_number, const EntityType type)
 Get the side entity.
 
int getNumberOfNodesOnElement () const
 Get the number of nodes on finite element.
 
MoFEMErrorCode getProblemRowIndices (const std::string filed_name, const EntityType type, const int side, VectorInt &indices) const
 Get row indices.
 
MoFEMErrorCode getProblemColIndices (const std::string filed_name, const EntityType type, const int side, VectorInt &indices) const
 Get col indices.
 
const FEMethodgetFEMethod () const
 Return raw pointer to Finite Element Method object.
 
int getOpType () const
 Get operator types.
 
void setOpType (const OpType type)
 Set operator type.
 
void addOpType (const OpType type)
 Add operator type.
 
int getNinTheLoop () const
 get number of finite element in the loop
 
int getLoopSize () const
 get size of elements in the loop
 
std::string getFEName () const
 Get name of the element.
 
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
 
auto getFTensor0IntegrationWeight ()
 Get integration weights.
 
MatrixDoublegetCoordsAtGaussPts ()
 Gauss points and weight, matrix (nb. of points x 3)
 
auto getFTensor1CoordsAtGaussPts ()
 Get coordinates at integration points assuming linear geometry.
 
double getMeasure () const
 get measure of element
 
doublegetMeasure ()
 get measure of element
 
MoFEMErrorCode loopSide (const string &fe_name, ForcesAndSourcesCore *side_fe, const size_t dim, const EntityHandle ent_for_side=0, boost::shared_ptr< Range > fe_range=nullptr, 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.
 
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.
 
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.
 
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.
 
MoFEMErrorCode loopRange (const string &fe_name, ForcesAndSourcesCore *range_fe, boost::shared_ptr< Range > fe_range, const int verb=QUIET, const LogManager::SeverityLevel sev=Sev::noisy)
 Iterate over range of elements.
 
- 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 opRhs (EntitiesFieldData &data, const bool error_if_no_base=false)
 
bool getSymm () const
 Get if operator uses symmetry of DOFs or not.
 
void setSymm ()
 set if operator is executed taking in account symmetry
 
void unSetSymm ()
 unset if operator is executed for non symmetric problem
 

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.
 
MoFEMErrorCode aSsemble (EntData &row_data)
 Assemble local entity right-hand vector.
 
- Protected Member Functions inherited from MoFEM::VolumeElementForcesAndSourcesCore::UserDataOperator
MoFEMErrorCode setPtrFE (ForcesAndSourcesCore *ptr)
 
- Protected Member Functions inherited from MoFEM::ForcesAndSourcesCore::UserDataOperator

Protected Attributes

MatrixDouble K
 
MatrixDouble transK
 
VectorDouble nF
 
boost::shared_ptr< DataAtIntegrationPtsdataAtPts
 
VectorInt rowIndices
 
VectorInt colIndices
 
int nbRows
 number of dofs on rows
 
int nbCols
 number if dof on column
 
int nbIntegrationPts
 number of integration points
 
bool isDiag
 true if this block is on diagonal
 
- 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
 
- Public Types inherited from MoFEM::DataOperator
using DoWorkLhsHookFunType
 
using DoWorkRhsHookFunType
 
- 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.
 
std::array< bool, MBMAXTYPE > doEntities
 If true operator is executed for entity.
 
booldoVertices
 \deprectaed If false skip vertices
 
booldoEdges
 \deprectaed If false skip edges
 
booldoQuads
 \deprectaed
 
booldoTris
 \deprectaed
 
booldoTets
 \deprectaed
 
booldoPrisms
 \deprectaed
 
- Static Public Attributes inherited from MoFEM::ForcesAndSourcesCore::UserDataOperator
static const char *const OpTypeNames []
 

Detailed Description

Examples
HookeElement.cpp, and HookeElement.hpp.

Definition at line 340 of file HookeElement.hpp.

Constructor & Destructor Documentation

◆ OpAssemble()

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 )

Definition at line 169 of file HookeElement.cpp.

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

Member Function Documentation

◆ aSsemble() [1/2]

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

315 {
317
318 // get pointer to first global index on row
319 const int *row_indices = &*row_data.getIndices().data().begin();
320
321 auto &data = *dataAtPts;
322 if (!data.forcesOnlyOnEntitiesRow.empty()) {
323 rowIndices.resize(nbRows, false);
324 noalias(rowIndices) = row_data.getIndices();
325 row_indices = &rowIndices[0];
326 VectorDofs &dofs = row_data.getFieldDofs();
327 VectorDofs::iterator dit = dofs.begin();
328 for (int ii = 0; dit != dofs.end(); dit++, ii++) {
329 if (data.forcesOnlyOnEntitiesRow.find((*dit)->getEnt()) ==
330 data.forcesOnlyOnEntitiesRow.end()) {
331 rowIndices[ii] = -1;
332 }
333 }
334 }
335
336 Vec F = getFEMethod()->snes_f;
337 // assemble local matrix
338 CHKERR VecSetValues(F, nbRows, row_indices, &*nF.data().begin(), ADD_VALUES);
340}
#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.
@ F
ublas::vector< FEDofEntity *, DofsAllocator > VectorDofs
MoFEMErrorCode VecSetValues(Vec V, const EntitiesFieldData::EntData &data, const double *ptr, InsertMode iora)
Assemble PETSc vector.
const VectorDofs & getFieldDofs() const
get dofs data stature FEDofEntity
const VectorInt & getIndices() const
Get global indices of dofs on entity.
const FEMethod * getFEMethod() const
Return raw pointer to Finite Element Method object.
Vec & snes_f
residual
VectorDouble nF
int nbRows
number of dofs on rows
VectorInt rowIndices

◆ aSsemble() [2/2]

MoFEMErrorCode 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

Definition at line 260 of file HookeElement.cpp.

261 {
263
264 // get pointer to first global index on row
265 const int *row_indices = &*row_data.getIndices().data().begin();
266 // get pointer to first global index on column
267 const int *col_indices = &*col_data.getIndices().data().begin();
268
269 auto &data = *dataAtPts;
270 if (!data.forcesOnlyOnEntitiesRow.empty()) {
271 rowIndices.resize(nbRows, false);
272 noalias(rowIndices) = row_data.getIndices();
273 row_indices = &rowIndices[0];
274 VectorDofs &dofs = row_data.getFieldDofs();
275 VectorDofs::iterator dit = dofs.begin();
276 for (int ii = 0; dit != dofs.end(); dit++, ii++) {
277 if (data.forcesOnlyOnEntitiesRow.find((*dit)->getEnt()) ==
278 data.forcesOnlyOnEntitiesRow.end()) {
279 rowIndices[ii] = -1;
280 }
281 }
282 }
283
284 if (!data.forcesOnlyOnEntitiesCol.empty()) {
285 colIndices.resize(nbCols, false);
286 noalias(colIndices) = col_data.getIndices();
287 col_indices = &colIndices[0];
288 VectorDofs &dofs = col_data.getFieldDofs();
289 VectorDofs::iterator dit = dofs.begin();
290 for (int ii = 0; dit != dofs.end(); dit++, ii++) {
291 if (data.forcesOnlyOnEntitiesCol.find((*dit)->getEnt()) ==
292 data.forcesOnlyOnEntitiesCol.end()) {
293 colIndices[ii] = -1;
294 }
295 }
296 }
297
298 Mat B = getFEMethod()->ksp_B != PETSC_NULLPTR ? getFEMethod()->ksp_B
299 : getFEMethod()->snes_B;
300 // assemble local matrix
301 CHKERR MatSetValues(B, nbRows, row_indices, nbCols, col_indices,
302 &*K.data().begin(), ADD_VALUES);
303
304 if (!isDiag && sYmm) {
305 // if not diagonal term and since global matrix is symmetric assemble
306 // transpose term.
307 transK.resize(K.size2(), K.size1(), false);
308 noalias(transK) = trans(K);
309 CHKERR MatSetValues(B, nbCols, col_indices, nbRows, row_indices,
310 &*transK.data().begin(), ADD_VALUES);
311 }
313}
MoFEMErrorCode MatSetValues(Mat M, const EntitiesFieldData::EntData &row_data, const EntitiesFieldData::EntData &col_data, const double *ptr, InsertMode iora)
Assemble PETSc matrix.
bool sYmm
If true assume that matrix is symmetric structure.
Mat & snes_B
preconditioner of jacobian matrix
int nbCols
number if dof on column
bool isDiag
true if this block is on diagonal
MatrixDouble transK
VectorInt colIndices
MatrixDouble K

◆ doWork() [1/2]

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

223 {
225
226 // get number of dofs on row
227 nbRows = row_data.getIndices().size();
228 // if no dofs on row, exit that work, nothing to do here
229 if (!nbRows)
231
232 nF.resize(nbRows, false);
233 nF.clear();
234
235 // get number of integration points
236 nbIntegrationPts = getGaussPts().size2();
237
238 // integrate local matrix for entity block
239 CHKERR iNtegrate(row_data);
240
241 // assemble local matrix
242 CHKERR aSsemble(row_data);
243
245}
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return()
MatrixDouble & getGaussPts()
matrix of integration (Gauss) points for Volume Element
virtual MoFEMErrorCode iNtegrate(EntData &row_data, EntData &col_data)
MoFEMErrorCode aSsemble(EntData &row_data, EntData &col_data)
Assemble local entity block matrix.
int nbIntegrationPts
number of integration points

◆ doWork() [2/2]

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

Definition at line 176 of file HookeElement.cpp.

180 {
181
183
184 // get number of dofs on row
185 nbRows = row_data.getIndices().size();
186 // if no dofs on row, exit that work, nothing to do here
187 if (!nbRows)
189
190 // get number of dofs on column
191 nbCols = col_data.getIndices().size();
192 // if no dofs on Columbia, exit nothing to do here
193 if (!nbCols)
195
196 // K_ij matrix will have 3 times the number of degrees of freedom of the
197 // i-th entity set (nbRows)
198 // and 3 times the number of degrees of freedom of the j-th entity set
199 // (nbCols)
200 K.resize(nbRows, nbCols, false);
201 K.clear();
202
203 // get number of integration points
204 nbIntegrationPts = getGaussPts().size2();
205 // check if entity block is on matrix diagonal
206 if (row_side == col_side && row_type == col_type) {
207 isDiag = true;
208 } else {
209 isDiag = false;
210 }
211
212 // integrate local matrix for entity block
213 CHKERR iNtegrate(row_data, col_data);
214
215 // assemble local matrix
216 CHKERR aSsemble(row_data, col_data);
217
219}

◆ iNtegrate() [1/2]

MoFEMErrorCode OpAssemble::iNtegrate ( EntData & row_data)
protectedvirtual

Reimplemented in OpAleRhs_dX, OpAleRhs_dx, OpAnalyticalInternalAleStrain_dX< S >, OpAnalyticalInternalAleStrain_dx< S >, OpAnalyticalInternalStrain_dx< S >, and OpRhs_dx.

Definition at line 254 of file HookeElement.cpp.

254 {
256 SETERRQ(PETSC_COMM_SELF, MOFEM_NOT_IMPLEMENTED, "Not implemented");
258};
@ MOFEM_NOT_IMPLEMENTED
Definition definitions.h:32

◆ iNtegrate() [2/2]

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

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

Definition at line 247 of file HookeElement.cpp.

248 {
250 SETERRQ(PETSC_COMM_SELF, MOFEM_NOT_IMPLEMENTED, "Not implemented");
252};

Member Data Documentation

◆ colIndices

VectorInt OpAssemble::colIndices
protected

Definition at line 371 of file HookeElement.hpp.

◆ dataAtPts

boost::shared_ptr<DataAtIntegrationPts> OpAssemble::dataAtPts
protected

Definition at line 368 of file HookeElement.hpp.

◆ isDiag

bool OpAssemble::isDiag
protected

true if this block is on diagonal

Definition at line 376 of file HookeElement.hpp.

◆ K

MatrixDouble OpAssemble::K
protected

Definition at line 364 of file HookeElement.hpp.

◆ nbCols

int OpAssemble::nbCols
protected

number if dof on column

Definition at line 374 of file HookeElement.hpp.

◆ nbIntegrationPts

int OpAssemble::nbIntegrationPts
protected

number of integration points

Definition at line 375 of file HookeElement.hpp.

◆ nbRows

int OpAssemble::nbRows
protected

number of dofs on rows

Definition at line 373 of file HookeElement.hpp.

◆ nF

VectorDouble OpAssemble::nF
protected

Definition at line 366 of file HookeElement.hpp.

◆ rowIndices

VectorInt OpAssemble::rowIndices
protected

Definition at line 370 of file HookeElement.hpp.

◆ transK

MatrixDouble OpAssemble::transK
protected

Definition at line 365 of file HookeElement.hpp.


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