v0.13.2
Loading...
Searching...
No Matches
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
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
45 VectorDouble Nf;
46
47 MoFEMErrorCode doWork(int side, EntityType type,
48 EntitiesFieldData::EntData &data) {
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
110private:
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 */
DEPRECATED typedef BodyForceConstantField BodyFroceConstantField
USe BodyForceConstantField.
Definition: BodyForce.hpp:115
ForcesAndSourcesCore::UserDataOperator UserDataOperator
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:447
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:346
@ BLOCKSET
Definition: definitions.h:148
#define DEPRECATED
Definition: definitions.h:17
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:416
#define CHKERR
Inline error check.
Definition: definitions.h:535
@ F
implementation of Data Operators for Forces and Sources
Definition: Common.hpp:10
constexpr auto field_name
#define _F(n)
Definition: quad.c:25
MyVolumeFE(MoFEM::Interface &m_field)
Definition: BodyForce.hpp:17
OpBodyForce(const std::string field_name, Block_BodyForces &data, Range block_tets)
Definition: BodyForce.hpp:39
MoFEMErrorCode doWork(int side, EntityType type, EntitiesFieldData::EntData &data)
Definition: BodyForce.hpp:47
OpBodyForce(const std::string field_name, Vec _F, Block_BodyForces &data, Range block_tets)
Definition: BodyForce.hpp:34
Body forces elements.
Definition: BodyForce.hpp:12
MyVolumeFE & getLoopFe()
Definition: BodyForce.hpp:23
MoFEM::Interface & mField
Definition: BodyForce.hpp:14
std::map< int, Block_BodyForces > mapData
Definition: BodyForce.hpp:111
BodyForceConstantField(MoFEM::Interface &m_field)
Definition: BodyForce.hpp:25
MoFEMErrorCode addBlock(const std::string field_name, Vec F, int ms_id)
Definition: BodyForce.hpp:94
virtual moab::Interface & get_moab()=0
Deprecated interface functions.
boost::shared_ptr< const NumeredEntFiniteElement > getNumeredEntFiniteElementPtr() const
Return raw pointer to NumeredEntFiniteElement.
@ OPROW
operator doWork function is executed on FE rows
MatrixDouble & getGaussPts()
matrix of integration (Gauss) points for Volume Element
boost::ptr_deque< UserDataOperator > & getOpPtrVector()
Use to push back operator for row operator.
MoFEMErrorCode getInterface(IFACE *&iface) const
Get interface refernce to pointer of interface.
VolumeElementForcesAndSourcesCore(Interface &m_field, const EntityType type=MBTET)