v0.14.0
BodyForce.hpp
Go to the documentation of this file.
1 /** \file BodyForce.hpp
2  */
3 
4 
5 
6 #ifndef __BODY_FORCE_HPP
7 #define __BODY_FORCE_HPP
8 
9 /** \brief Body forces elements
10  * \ingroup mofem_body_forces
11  */
13 
15 
19  int getRule(int order) { return order; };
20  };
21 
23  MyVolumeFE &getLoopFe() { return fe; }
24 
26  : mField(m_field), fe(m_field) {}
27 
28  struct OpBodyForce
30 
31  Vec F;
32  Block_BodyForces &dAta;
34  OpBodyForce(const std::string field_name, Vec _F, Block_BodyForces &data,
35  Range block_tets)
36  : MoFEM::VolumeElementForcesAndSourcesCore::UserDataOperator(
38  F(_F), dAta(data), blockTets(block_tets) {}
39  OpBodyForce(const std::string field_name, Block_BodyForces &data,
40  Range block_tets)
41  : MoFEM::VolumeElementForcesAndSourcesCore::UserDataOperator(
43  dAta(data), blockTets(block_tets) {}
44 
46 
47  MoFEMErrorCode doWork(int side, EntityType type,
50 
51  if (data.getIndices().size() == 0)
53  if (blockTets.find(getNumeredEntFiniteElementPtr()->getEnt()) ==
54  blockTets.end())
56 
57  const auto &dof_ptr = data.getFieldDofs()[0];
58  int rank = dof_ptr->getNbOfCoeffs();
59  int nb_row_dofs = data.getIndices().size() / rank;
60 
61  Nf.resize(data.getIndices().size());
62  bzero(&*Nf.data().begin(), data.getIndices().size() * sizeof(FieldData));
63 
64  for (unsigned int gg = 0; gg < data.getN().size1(); gg++) {
65  double val = getVolume() * getGaussPts()(3, gg);
66  for (int rr = 0; rr < rank; rr++) {
67 
68  double acc;
69  if (rr == 0) {
70  acc = -dAta.data.acceleration_x;
71  } else if (rr == 1) {
72  acc = -dAta.data.acceleration_y;
73  } else if (rr == 2) {
74  acc = -dAta.data.acceleration_z;
75  } else {
76  SETERRQ(PETSC_COMM_SELF, 1, "data inconsistency");
77  }
78  acc *= dAta.data.density;
79  cblas_daxpy(nb_row_dofs, val * acc, &data.getN()(gg, 0), 1, &Nf[rr],
80  rank);
81  }
82  }
83 
84  if (F == PETSC_NULL)
85  F = getKSPf();
86 
87  CHKERR VecSetValues(F, data.getIndices().size(), &data.getIndices()[0],
88  &Nf[0], ADD_VALUES);
89 
91  }
92  };
93 
94  MoFEMErrorCode addBlock(const std::string field_name, Vec F, int ms_id) {
95  const CubitMeshSets *cubit_meshset_ptr;
96  MeshsetsManager *mmanager_ptr;
98  CHKERR mField.getInterface(mmanager_ptr);
99  CHKERR mmanager_ptr->getCubitMeshsetPtr(ms_id, BLOCKSET,
100  &cubit_meshset_ptr);
101  CHKERR cubit_meshset_ptr->getAttributeDataStructure(mapData[ms_id]);
102  EntityHandle meshset = cubit_meshset_ptr->getMeshset();
103  Range tets;
104  CHKERR mField.get_moab().get_entities_by_type(meshset, MBTET, tets, true);
105  fe.getOpPtrVector().push_back(
106  new OpBodyForce(field_name, F, mapData[ms_id], tets));
108  }
109 
110 private:
111  std::map<int, Block_BodyForces> mapData;
112 };
113 
114 /// \brief USe BodyForceConstantField
116 
117 #endif //__BODY_FORCE_HPP
118 
119 /**
120  * \defgroup mofem_body_forces Body forces elements
121  * \ingroup user_modules
122  */
MoFEMFunctionReturnHot
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:460
MoFEM::UnknownInterface::getInterface
MoFEMErrorCode getInterface(IFACE *&iface) const
Get interface reference to pointer of interface.
Definition: UnknownInterface.hpp:93
MoFEM::ForcesAndSourcesCore::UserDataOperator::getKSPf
Vec getKSPf() const
Definition: ForcesAndSourcesCore.hpp:1088
MoFEM::VolumeElementForcesAndSourcesCore::VolumeElementForcesAndSourcesCore
VolumeElementForcesAndSourcesCore(Interface &m_field, const EntityType type=MBTET)
Definition: VolumeElementForcesAndSourcesCore.cpp:9
BodyForceConstantField::mField
MoFEM::Interface & mField
Definition: BodyForce.hpp:14
DEPRECATED
#define DEPRECATED
Definition: definitions.h:17
BodyForceConstantField::addBlock
MoFEMErrorCode addBlock(const std::string field_name, Vec F, int ms_id)
Definition: BodyForce.hpp:94
EntityHandle
BodyForceConstantField::OpBodyForce::OpBodyForce
OpBodyForce(const std::string field_name, Vec _F, Block_BodyForces &data, Range block_tets)
Definition: BodyForce.hpp:34
BodyForceConstantField::BodyForceConstantField
BodyForceConstantField(MoFEM::Interface &m_field)
Definition: BodyForce.hpp:25
BodyForceConstantField::MyVolumeFE::MyVolumeFE
MyVolumeFE(MoFEM::Interface &m_field)
Definition: BodyForce.hpp:17
_F
#define _F(n)
Definition: quad.c:25
MoFEM::Exceptions::MoFEMErrorCode
PetscErrorCode MoFEMErrorCode
MoFEM/PETSc error code.
Definition: Exceptions.hpp:56
OpBodyForce
DomainNaturalBCRhs::OpFlux< NaturalMeshsetType< BLOCKSET >, 1, SPACE_DIM > OpBodyForce
Definition: thermo_elastic.cpp:98
MoFEM::VolumeElementForcesAndSourcesCore::UserDataOperator::getVolume
double getVolume() const
element volume (linear geometry)
Definition: VolumeElementForcesAndSourcesCore.hpp:161
BodyForceConstantField::getLoopFe
MyVolumeFE & getLoopFe()
Definition: BodyForce.hpp:23
MoFEM::VecSetValues
MoFEMErrorCode VecSetValues(Vec V, const EntitiesFieldData::EntData &data, const double *ptr, InsertMode iora)
Assemble PETSc vector.
Definition: EntitiesFieldData.hpp:1589
order
constexpr int order
Definition: dg_projection.cpp:18
BodyForceConstantField::OpBodyForce::blockTets
Range blockTets
Definition: BodyForce.hpp:33
MoFEM::DeprecatedCoreInterface
Deprecated interface functions.
Definition: DeprecatedCoreInterface.hpp:16
MoFEM::ForcesAndSourcesCore::UserDataOperator::getGaussPts
MatrixDouble & getGaussPts()
matrix of integration (Gauss) points for Volume Element
Definition: ForcesAndSourcesCore.hpp:1236
CHKERR
#define CHKERR
Inline error check.
Definition: definitions.h:548
BodyForceConstantField::OpBodyForce::dAta
Block_BodyForces & dAta
Definition: BodyForce.hpp:32
BodyForceConstantField
Body forces elements.
Definition: BodyForce.hpp:12
MoFEM::CoreInterface::get_moab
virtual moab::Interface & get_moab()=0
MoFEM
implementation of Data Operators for Forces and Sources
Definition: Common.hpp:10
MoFEM::ForcesAndSourcesCore::UserDataOperator
Definition: ForcesAndSourcesCore.hpp:549
convert.type
type
Definition: convert.py:64
BodyForceConstantField::fe
MyVolumeFE fe
Definition: BodyForce.hpp:22
MoFEM::ForcesAndSourcesCore::UserDataOperator::getNumeredEntFiniteElementPtr
boost::shared_ptr< const NumeredEntFiniteElement > getNumeredEntFiniteElementPtr() const
Return raw pointer to NumeredEntFiniteElement.
Definition: ForcesAndSourcesCore.hpp:1000
BodyForceConstantField::OpBodyForce::doWork
MoFEMErrorCode doWork(int side, EntityType type, EntitiesFieldData::EntData &data)
Definition: BodyForce.hpp:47
BodyForceConstantField::OpBodyForce
Definition: BodyForce.hpp:28
BodyForceConstantField::OpBodyForce::Nf
VectorDouble Nf
Definition: BodyForce.hpp:45
MoFEM::VolumeElementForcesAndSourcesCore
Volume finite element base.
Definition: VolumeElementForcesAndSourcesCore.hpp:26
MoFEM::VolumeElementForcesAndSourcesCore::UserDataOperator
Definition: VolumeElementForcesAndSourcesCore.hpp:108
EntData
EntitiesFieldData::EntData EntData
Definition: child_and_parent.cpp:37
field_name
constexpr auto field_name
Definition: poisson_2d_homogeneous.cpp:13
BodyForceConstantField::MyVolumeFE::getRule
int getRule(int order)
Definition: BodyForce.hpp:19
Range
BodyFroceConstantField
DEPRECATED typedef BodyForceConstantField BodyFroceConstantField
USe BodyForceConstantField.
Definition: BodyForce.hpp:115
BLOCKSET
@ BLOCKSET
Definition: definitions.h:161
MoFEM::ForcesAndSourcesCore::getOpPtrVector
boost::ptr_deque< UserDataOperator > & getOpPtrVector()
Use to push back operator for row operator.
Definition: ForcesAndSourcesCore.hpp:83
MoFEM::Types::FieldData
double FieldData
Field data type.
Definition: Types.hpp:25
EigenMatrix::Vec
const FTensor::Tensor2< T, Dim, Dim > Vec
Definition: MatrixFunction.hpp:66
MoFEM::Types::VectorDouble
UBlasVector< double > VectorDouble
Definition: Types.hpp:68
BodyForceConstantField::MyVolumeFE
Definition: BodyForce.hpp:16
BodyForceConstantField::OpBodyForce::F
Vec F
Definition: BodyForce.hpp:31
MoFEMFunctionReturn
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:429
BodyForceConstantField::OpBodyForce::OpBodyForce
OpBodyForce(const std::string field_name, Block_BodyForces &data, Range block_tets)
Definition: BodyForce.hpp:39
BodyForceConstantField::mapData
std::map< int, Block_BodyForces > mapData
Definition: BodyForce.hpp:111
MoFEMFunctionBegin
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:359
F
@ F
Definition: free_surface.cpp:394
MoFEM::ForcesAndSourcesCore::UserDataOperator::OPROW
@ OPROW
operator doWork function is executed on FE rows
Definition: ForcesAndSourcesCore.hpp:567