v0.15.0
Loading...
Searching...
No Matches
NodeForce.cpp
Go to the documentation of this file.
1/** \file NodeForce.cpp
2 \ingroup mofem_static_boundary_conditions
3*/
4
5
6
7#include <MoFEM.hpp>
8using namespace MoFEM;
9#include <MethodForForceScaling.hpp>
10#include <SurfacePressure.hpp>
11#include <NodalForce.hpp>
12
13using namespace boost::numeric;
14
17
19 const std::string field_name, Vec _F, bCForce &data,
20 boost::ptr_vector<MethodForForceScaling> &methods_op, bool use_snes_f)
23 F(_F), useSnesF(use_snes_f), dAta(data), methodsOp(methods_op) {}
24
26NodalForce::OpNodalForce::doWork(int side, EntityType type,
29
30 if (data.getIndices().size() == 0)
32 EntityHandle ent = getNumeredEntFiniteElementPtr()->getEnt();
33 if (dAta.nOdes.find(ent) == dAta.nOdes.end())
35
36 const auto &dof_ptr = data.getFieldDofs()[0];
37 int rank = dof_ptr->getNbOfCoeffs();
38
39 if (data.getIndices().size() != (unsigned int)rank) {
40 SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY, "data inconsistency");
41 }
42
43 Nf.resize(3);
44 for (int rr = 0; rr != rank; ++rr) {
45 if (rr == 0) {
46 Nf[0] = dAta.data.data.value3 * dAta.data.data.value1;
47 } else if (rr == 1) {
48 Nf[1] = dAta.data.data.value4 * dAta.data.data.value1;
49 } else if (rr == 2) {
50 Nf[2] = dAta.data.data.value5 * dAta.data.data.value1;
51 } else {
52 SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY, "data inconsistency");
53 }
54 }
55
57
58 Vec myF = F;
59 if (useSnesF || F == PETSC_NULLPTR)
60 myF = getKSPf();
61
62 CHKERR VecSetValues(myF, data.getIndices().size(), &data.getIndices()[0],
63 &Nf[0], ADD_VALUES);
64
66}
67
69 int ms_id, bool use_snes_f) {
70
71 const CubitMeshSets *cubit_meshset_ptr;
72 MeshsetsManager *mmanager_ptr;
74 CHKERR mField.getInterface(mmanager_ptr);
75 CHKERR mmanager_ptr->getCubitMeshsetPtr(ms_id, NODESET, &cubit_meshset_ptr);
76 CHKERR cubit_meshset_ptr->getBcDataStructure(mapForce[ms_id].data);
77 CHKERR mField.get_moab().get_entities_by_type(
78 cubit_meshset_ptr->meshset, MBVERTEX, mapForce[ms_id].nOdes, true);
79 fe.getOpPtrVector().push_back(
80 new OpNodalForce(field_name, F, mapForce[ms_id], methodsOp, use_snes_f));
82}
83
85 : mField(m_field) {
86
87 double def_scale = 1.;
88 const EntityHandle root_meshset = mField.get_moab().get_root_set();
89 rval = mField.get_moab().tag_get_handle(
90 "_LoadFactor_Scale_", 1, MB_TYPE_DOUBLE, thScale,
91 MB_TAG_CREAT | MB_TAG_EXCL | MB_TAG_MESH, &def_scale);
92 if (rval == MB_ALREADY_ALLOCATED) {
93 rval = mField.get_moab().tag_get_by_ptr(thScale, &root_meshset, 1,
94 (const void **)&sCale);
96 } else {
98 rval =
99 mField.get_moab().tag_set_data(thScale, &root_meshset, 1, &def_scale);
101 rval = mField.get_moab().tag_get_by_ptr(thScale, &root_meshset, 1,
102 (const void **)&sCale);
104 }
105}
106
108 VectorDouble &Nf) {
110 Nf *= *sCale;
112}
ForcesAndSourcesCore::UserDataOperator UserDataOperator
#define MOAB_THROW(err)
Check error code of MoAB function and throw MoFEM exception.
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return()
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
@ NODESET
@ MOFEM_DATA_INCONSISTENCY
Definition definitions.h:31
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
#define CHKERR
Inline error check.
#define MoFEMFunctionBeginHot
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
@ F
MoFEMErrorCode getCubitMeshsetPtr(const int ms_id, const CubitBCType cubit_bc_type, const CubitMeshSets **cubit_meshset_ptr) const
get cubit meshset
static MoFEMErrorCodeGeneric< moab::ErrorCode > rval
PetscErrorCode MoFEMErrorCode
MoFEM/PETSc error code.
implementation of Data Operators for Forces and Sources
Definition Common.hpp:10
MoFEMErrorCode VecSetValues(Vec V, const EntitiesFieldData::EntData &data, const double *ptr, InsertMode iora)
Assemble PETSc vector.
constexpr auto field_name
#define _F(n)
Definition quad.c:25
TagForceScale(MoFEM::Interface &m_field)
Definition NodeForce.cpp:84
MoFEMErrorCode scaleNf(const FEMethod *fe, VectorDouble &Nf)
static MoFEMErrorCode applyScale(const FEMethod *fe, boost::ptr_vector< MethodForForceScaling > &methods_op, VectorDouble &nf)
virtual moab::Interface & get_moab()=0
this struct keeps basic methods for moab meshset about material and boundary conditions
MoFEMErrorCode getBcDataStructure(CUBIT_BC_DATA_TYPE &data) const
Deprecated interface functions.
Data on single entity (This is passed as argument to DataOperator::doWork)
const VectorDofs & getFieldDofs() const
get dofs data stature FEDofEntity
const VectorInt & getIndices() const
Get global indices of dofs on entity.
structure for User Loop Methods on finite elements
structure to get information form mofem into EntitiesFieldData
boost::ptr_deque< UserDataOperator > & getOpPtrVector()
Use to push back operator for row operator.
Interface for managing meshsets containing materials and boundary conditions.
MoFEMErrorCode getInterface(IFACE *&iface) const
Get interface reference to pointer of interface.
MyFE(MoFEM::Interface &m_field)
Definition NodeForce.cpp:15
Operator to assemble nodal force into right hand side vector.
OpNodalForce(const std::string field_name, Vec _F, bCForce &data, boost::ptr_vector< MethodForForceScaling > &methods_op, bool use_snes_f=false)
Definition NodeForce.cpp:18
MoFEMErrorCode doWork(int side, EntityType type, EntitiesFieldData::EntData &data)
Definition NodeForce.cpp:26
MoFEM::Interface & mField
MoFEMErrorCode addForce(const std::string field_name, Vec F, int ms_id, bool use_snes_f=false)
Definition NodeForce.cpp:68
boost::ptr_vector< MethodForForceScaling > methodsOp
std::map< int, bCForce > mapForce