v0.10.0
NodalForce.hpp
Go to the documentation of this file.
1 /** \file NodalForce.hpp
2  \ingroup mofem_static_boundary_conditions
3 */
4 
5 /* This file is part of MoFEM.
6  * MoFEM is free software: you can redistribute it and/or modify it under
7  * the terms of the GNU Lesser General Public License as published by the
8  * Free Software Foundation, either version 3 of the License, or (at your
9  * option) any later version.
10  *
11  * MoFEM is distributed in the hope that it will be useful, but WITHOUT
12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
14  * License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with MoFEM. If not, see <http://www.gnu.org/licenses/>. */
18 
19 #ifndef __NODAL_FORCES_HPP__
20 #define __NODAL_FORCES_HPP__
21 
22 /** \brief Force applied to nodes
23  * \ingroup mofem_static_boundary_conditions
24  */
25 struct NodalForce {
26 
28  NodalForce(MoFEM::Interface &m_field) : mField(m_field), fe(m_field) {}
29 
31  MyFE(MoFEM::Interface &m_field);
32  };
33 
35  MyFE &getLoopFe() { return fe; }
36 
37  struct bCForce {
38  ForceCubitBcData data;
39  Range nOdes;
40  };
41  std::map<int, bCForce> mapForce;
42 
43  boost::ptr_vector<MethodForForceScaling> methodsOp;
44 
45  /// \brief Operator to assemble nodal force into right hand side vector
46  struct OpNodalForce
48 
49  Vec F;
50  bool useSnesF;
52  boost::ptr_vector<MethodForForceScaling> &methodsOp;
53 
54  OpNodalForce(const std::string field_name, Vec _F, bCForce &data,
55  boost::ptr_vector<MethodForForceScaling> &methods_op,
56  bool use_snes_f = false);
57 
59 
60  /** Executed for each entity on element, i.e. in this case Vertex element
61  has only one entity, that is vertex
62  */
63  MoFEMErrorCode doWork(int side, EntityType type,
65  };
66 
67  MoFEMErrorCode addForce(const std::string field_name, Vec F, int ms_id,
68  bool use_snes_f = false);
69 };
70 
72 
73  /** \brief Scale force based on tag value "_LoadFactor_Scale_"
74 
75  This is obsolete, is kept to have back compatibility with fracture code.
76 
77  */
80  double *sCale;
81  Tag thScale;
82 
85  };
86 
87  /**
88  * \brief Scale force based on some DOF value
89  *
90  * That dof usually will be associated with dof used for arc-length control
91  *
92  */
94  boost::shared_ptr<DofEntity> dOf;
95  DofForceScale(boost::shared_ptr<DofEntity> dof) : dOf(dof) {}
98  Nf *= dOf->getFieldData();
100  }
101  };
102 
103  /// Add element taking information from NODESET
105  const std::string field_name,
106  Range *intersect_ptr = NULL) {
108  CHKERR m_field.add_finite_element("FORCE_FE", MF_ZERO);
109  CHKERR m_field.modify_finite_element_add_field_row("FORCE_FE", field_name);
110  CHKERR m_field.modify_finite_element_add_field_col("FORCE_FE", field_name);
111  CHKERR m_field.modify_finite_element_add_field_data("FORCE_FE", field_name);
113  it)) {
114  Range tris;
115  CHKERR m_field.get_moab().get_entities_by_type(it->meshset, MBTRI, tris,
116  true);
117  Range edges;
118  CHKERR m_field.get_moab().get_entities_by_type(it->meshset, MBEDGE, edges,
119  true);
120  Range tris_nodes;
121  CHKERR m_field.get_moab().get_connectivity(tris, tris_nodes);
122  Range edges_nodes;
123  CHKERR m_field.get_moab().get_connectivity(edges, edges_nodes);
124  Range nodes;
125  CHKERR m_field.get_moab().get_entities_by_type(it->meshset, MBVERTEX,
126  nodes, true);
127  nodes = subtract(nodes, tris_nodes);
128  nodes = subtract(nodes, edges_nodes);
129  if (intersect_ptr) {
130  nodes = intersect(nodes, *intersect_ptr);
131  }
132  CHKERR m_field.add_ents_to_finite_element_by_type(nodes, MBVERTEX,
133  "FORCE_FE");
134  }
136  }
137 
138  /// Set integration point operators
139  static MoFEMErrorCode
141  boost::ptr_map<std::string, NodalForce> &nodal_forces, Vec F,
142  const std::string field_name) {
144  string fe_name = "FORCE_FE";
145  nodal_forces.insert(fe_name, new NodalForce(m_field));
147  it)) {
148  CHKERR nodal_forces.at(fe_name).addForce(field_name, F,
149  it->getMeshsetId());
150  }
152  }
153 };
154 
155 #endif //__NODAL_FORCES_HPP__
boost::ptr_vector< MethodForForceScaling > & methodsOp
Definition: NodalForce.hpp:52
virtual MoFEMErrorCode modify_finite_element_add_field_col(const std::string &fe_name, const std::string &name_row)=0
set field col which finite element use
virtual MoFEMErrorCode add_ents_to_finite_element_by_type(const EntityHandle entities, const EntityType type, const std::string &name, const bool recursive=true)=0
add entities to finite element
Deprecated interface functions.
MoFEMErrorCode addForce(const std::string field_name, Vec F, int ms_id, bool use_snes_f=false)
Definition: NodeForce.cpp:80
MyFE(MoFEM::Interface &m_field)
Definition: NodeForce.cpp:27
MyFE & getLoopFe()
Definition: NodalForce.hpp:35
virtual moab::Interface & get_moab()=0
std::map< int, bCForce > mapForce
Definition: NodalForce.hpp:41
MoFEMErrorCode doWork(int side, EntityType type, DataForcesAndSourcesCore::EntData &data)
Definition: NodeForce.cpp:38
boost::shared_ptr< DofEntity > dOf
Definition: NodalForce.hpp:94
Class used to scale loads, f.e. in arc-length control.
NodalForce(MoFEM::Interface &m_field)
Definition: NodalForce.hpp:28
#define MoFEMFunctionBeginHot
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:509
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:485
DofForceScale(boost::shared_ptr< DofEntity > dof)
Definition: NodalForce.hpp:95
MoFEM::Interface & mField
Definition: NodalForce.hpp:27
Scale force based on tag value "_LoadFactor_Scale_".
Definition: NodalForce.hpp:78
Vertex finite elementUser is implementing own operator at Gauss points level, by own object derived f...
boost::ptr_vector< MethodForForceScaling > methodsOp
Definition: NodalForce.hpp:43
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:516
MoFEMErrorCode scaleNf(const FEMethod *fe, VectorDouble &Nf)
Definition: NodeForce.cpp:119
static MoFEMErrorCode setOperators(MoFEM::Interface &m_field, boost::ptr_map< std::string, NodalForce > &nodal_forces, Vec F, const std::string field_name)
Set integration point operators.
Definition: NodalForce.hpp:140
TagForceScale(MoFEM::Interface &m_field)
Definition: NodeForce.cpp:96
ForceCubitBcData data
Definition: NodalForce.hpp:38
DataForcesAndSourcesCore::EntData EntData
PetscErrorCode MoFEMErrorCode
MoFEM/PETSc error code.
Definition: Exceptions.hpp:67
#define _IT_CUBITMESHSETS_BY_BCDATA_TYPE_FOR_LOOP_(MESHSET_MANAGER, CUBITBCTYPE, IT)
Iterator that loops over a specific Cubit MeshSet in a moFEM field.
static MoFEMErrorCode addElement(MoFEM::Interface &m_field, const std::string field_name, Range *intersect_ptr=NULL)
Add element taking information from NODESET.
Definition: NodalForce.hpp:104
MoFEMErrorCode scaleNf(const FEMethod *fe, VectorDouble &Nf)
Definition: NodalForce.hpp:96
Force applied to nodes.
Definition: NodalForce.hpp:25
virtual MoFEMErrorCode add_finite_element(const std::string &fe_name, enum MoFEMTypes bh=MF_EXCL, int verb=DEFAULT_VERBOSITY)=0
add finite element
#define CHKERR
Inline error check.
Definition: definitions.h:604
virtual MoFEMErrorCode modify_finite_element_add_field_data(const std::string &fe_name, const std::string &name_filed)=0
set finite element field data
OpNodalForce(const std::string field_name, Vec _F, bCForce &data, boost::ptr_vector< MethodForForceScaling > &methods_op, bool use_snes_f=false)
Definition: NodeForce.cpp:30
Scale force based on some DOF value.
Definition: NodalForce.hpp:93
virtual MoFEMErrorCode modify_finite_element_add_field_row(const std::string &fe_name, const std::string &name_row)=0
set field row which finite element use
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:415
Operator to assemble nodal force into right hand side vector.
Definition: NodalForce.hpp:46
ublas::vector< double, DoubleAllocator > VectorDouble
Definition: Types.hpp:74
#define _F(n)
Definition: quad.c:25
MoFEM::Interface & mField
Definition: NodalForce.hpp:79