v0.10.0
Public Member Functions | Protected Attributes | List of all members
MoFEM::OpCalculateVectorFieldValuesFromPetscVecImpl< Tensor_Dim, CTX > Struct Template Reference

Approximate field valuse for given petsc vector. More...

#include <src/finite_elements/UserDataOperators.hpp>

Inheritance diagram for MoFEM::OpCalculateVectorFieldValuesFromPetscVecImpl< Tensor_Dim, CTX >:
[legend]
Collaboration diagram for MoFEM::OpCalculateVectorFieldValuesFromPetscVecImpl< Tensor_Dim, CTX >:
[legend]

Public Member Functions

 OpCalculateVectorFieldValuesFromPetscVecImpl (const std::string field_name, boost::shared_ptr< MatrixDouble > data_ptr, const EntityType zero_at_type=MBVERTEX)
 
MoFEMErrorCode doWork (int side, EntityType type, DataForcesAndSourcesCore::EntData &data)
 Operator for linear form, usually to calculate values on right hand side. 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
 
double getTSaa () 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 doWork (int row_side, int col_side, EntityType row_type, EntityType col_type, DataForcesAndSourcesCore::EntData &row_data, DataForcesAndSourcesCore::EntData &col_data)
 Operator for bi-linear form, usually to calculate values on left hand side. More...
 
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 Attributes

boost::shared_ptr< MatrixDoubledataPtr
 
const EntityHandle zeroAtType
 
VectorDouble dotVector
 
- 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...
 
- Protected Member Functions inherited from MoFEM::ForcesAndSourcesCore::UserDataOperator
virtual MoFEMErrorCode setPtrFE (ForcesAndSourcesCore *ptr)
 
ForcesAndSourcesCoregetPtrFE () const
 
ForcesAndSourcesCoregetSidePtrFE () const
 

Detailed Description

template<int Tensor_Dim, PetscData::DataContext CTX>
struct MoFEM::OpCalculateVectorFieldValuesFromPetscVecImpl< Tensor_Dim, CTX >

Approximate field valuse for given petsc vector.

Note
Look at PetscData to see what vectors could be extarcted with that user data opetaor.

Definition at line 354 of file UserDataOperators.hpp.

Constructor & Destructor Documentation

◆ OpCalculateVectorFieldValuesFromPetscVecImpl()

template<int Tensor_Dim, PetscData::DataContext CTX>
MoFEM::OpCalculateVectorFieldValuesFromPetscVecImpl< Tensor_Dim, CTX >::OpCalculateVectorFieldValuesFromPetscVecImpl ( const std::string  field_name,
boost::shared_ptr< MatrixDouble data_ptr,
const EntityType  zero_at_type = MBVERTEX 
)

Definition at line 357 of file UserDataOperators.hpp.

362  dataPtr(data_ptr), zeroAtType(zero_at_type) {
363  if (!dataPtr)
364  THROW_MESSAGE("Pointer is not set");
365  }
#define THROW_MESSAGE(a)
Throw MoFEM exception.
Definition: definitions.h:628

Member Function Documentation

◆ doWork()

template<int Tensor_Dim, PetscData::DataContext CTX>
MoFEMErrorCode MoFEM::OpCalculateVectorFieldValuesFromPetscVecImpl< Tensor_Dim, CTX >::doWork ( int  side,
EntityType  type,
DataForcesAndSourcesCore::EntData data 
)
virtual

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

Reimplemented from MoFEM::DataOperator.

Definition at line 367 of file UserDataOperators.hpp.

368  {
370  auto &local_indices = data.getLocalIndices();
371  const int nb_dofs = local_indices.size();
372  if (!nb_dofs && type == zeroAtType) {
373  dataPtr->resize(Tensor_Dim, 0, false);
375  }
376  if (!nb_dofs)
378 
379  const double *array;
380 
381  auto get_array = [&](const auto ctx, auto vec) {
383  if ((getFEMethod()->data_ctx & ctx).none())
384  SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY, "Vector not set");
385  CHKERR VecGetArrayRead(vec, &array);
387  };
388 
389  auto restore_array = [&](auto vec) {
390  return VecRestoreArrayRead(vec, &array);
391  };
392 
393  switch (CTX) {
395  CHKERR get_array(PetscData::CtxSetX, getFEMethod()->ts_u);
396  break;
398  CHKERR get_array(PetscData::CtxSetX_T, getFEMethod()->ts_u_t);
399  break;
401  CHKERR get_array(PetscData::CtxSetX_TT, getFEMethod()->ts_u_tt);
402  break;
403  default:
404  SETERRQ(PETSC_COMM_SELF, MOFEM_NOT_IMPLEMENTED,
405  "That case is not implemented");
406  }
407 
408  dotVector.resize(local_indices.size());
409  for (int i = 0; i != local_indices.size(); ++i)
410  if (local_indices[i] != -1)
411  dotVector[i] = array[local_indices[i]];
412  else
413  dotVector[i] = 0;
414 
415  switch (CTX) {
417  CHKERR restore_array(getFEMethod()->ts_u);
418  break;
420  CHKERR restore_array(getFEMethod()->ts_u_t);
421  break;
423  CHKERR restore_array(getFEMethod()->ts_u_tt);
424  break;
425  default:
426  SETERRQ(PETSC_COMM_SELF, MOFEM_NOT_IMPLEMENTED,
427  "That case is not implemented");
428  }
429 
430  const size_t nb_gauss_pts = data.getN().size1();
431  const size_t nb_base_functions = data.getN().size2();
432  MatrixDouble &mat = *dataPtr;
433  if (type == zeroAtType) {
434  mat.resize(Tensor_Dim, nb_gauss_pts, false);
435  mat.clear();
436  }
437  auto base_function = data.getFTensor0N();
438  auto values_at_gauss_pts = getFTensor1FromMat<Tensor_Dim>(mat);
440  const size_t size = nb_dofs / Tensor_Dim;
441  if (nb_dofs % Tensor_Dim) {
442  SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY, "Data inconsistency");
443  }
444  for (size_t gg = 0; gg != nb_gauss_pts; ++gg) {
445  auto field_data = getFTensor1FromArray<Tensor_Dim, Tensor_Dim>(dotVector);
446  size_t bb = 0;
447  for (; bb != size; ++bb) {
448  values_at_gauss_pts(I) += field_data(I) * base_function;
449  ++field_data;
450  ++base_function;
451  }
452  // Number of dofs can be smaller than number of Tensor_Dim x base
453  // functions
454  for (; bb != nb_base_functions; ++bb)
455  ++base_function;
456  ++values_at_gauss_pts;
457  }
459  }
static Index< 'I', 3 > I
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:516
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:415
@ MOFEM_DATA_INCONSISTENCY
Definition: definitions.h:123
@ MOFEM_NOT_IMPLEMENTED
Definition: definitions.h:124
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:485
#define CHKERR
Inline error check.
Definition: definitions.h:604
FTensor::Index< 'i', 3 > i
ublas::matrix< double, ublas::row_major, DoubleAllocator > MatrixDouble
Definition: Types.hpp:76
const FEMethod * getFEMethod() const
Return raw pointer to Finite Element Method object.
static constexpr Switches CtxSetX
Definition: LoopMethods.hpp:65
static constexpr Switches CtxSetX_TT
Definition: LoopMethods.hpp:67
static constexpr Switches CtxSetX_T
Definition: LoopMethods.hpp:66

Member Data Documentation

◆ dataPtr

template<int Tensor_Dim, PetscData::DataContext CTX>
boost::shared_ptr<MatrixDouble> MoFEM::OpCalculateVectorFieldValuesFromPetscVecImpl< Tensor_Dim, CTX >::dataPtr
protected

Definition at line 462 of file UserDataOperators.hpp.

◆ dotVector

template<int Tensor_Dim, PetscData::DataContext CTX>
VectorDouble MoFEM::OpCalculateVectorFieldValuesFromPetscVecImpl< Tensor_Dim, CTX >::dotVector
protected

Definition at line 464 of file UserDataOperators.hpp.

◆ zeroAtType

template<int Tensor_Dim, PetscData::DataContext CTX>
const EntityHandle MoFEM::OpCalculateVectorFieldValuesFromPetscVecImpl< Tensor_Dim, CTX >::zeroAtType
protected

Definition at line 463 of file UserDataOperators.hpp.


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