OpenBeam
C++ library for static analysis of mechanical structures
CElement.h
1 /* +---------------------------------------------------------------------------+
2  | OpenBeam - C++ Finite Element Analysis library |
3  | |
4  | Copyright (C) 2010-2021 Jose Luis Blanco Claraco |
5  | University of Malaga |
6  | |
7  | OpenBeam is free software: you can redistribute it and/or modify |
8  | it under the terms of the GNU General Public License as published by |
9  | the Free Software Foundation, either version 3 of the License, or |
10  | (at your option) any later version. |
11  | |
12  | OpenBeam is distributed in the hope that it will be useful, |
13  | but WITHOUT ANY WARRANTY; without even the implied warranty of |
14  | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15  | GNU General Public License for more details. |
16  | |
17  | You should have received a copy of the GNU General Public License |
18  | along with OpenBeam. If not, see <http://www.gnu.org/licenses/>. |
19  | |
20  +---------------------------------------------------------------------------+
21  */
22 
23 #pragma once
24 
25 #include <mrpt/viz/CSetOfObjects.h>
26 #include <openbeam/types.h>
27 
28 #include <memory>
29 
30 namespace openbeam
31 {
32 class CFiniteElementProblem;
33 struct MeshParams;
34 struct MeshOutputInfo;
35 class CStructureProblem;
36 
38 {
39  size_t edge_in, edge_out;
40  Matrix66 matrix;
41 };
42 
44 using used_DoFs_t = std::array<bool, 6>;
45 
48 class CElement
49 {
50  public:
51  using Ptr = std::shared_ptr<CElement>;
52  using ConstPtr = std::shared_ptr<const CElement>;
53 
63  static Ptr createElementByName(const std::string& sName);
64 
68  std::vector<size_t> conected_nodes_ids;
69 
73  unsigned char getNumberEdges() const { return m_nEdges; }
74 
75  virtual std::string asString() const { return ""; }
76 
82  virtual void getLocalStiffnessMatrices(std::vector<TStiffnessSubmatrix>& outSubMats) const = 0;
83 
85  virtual void getLocalDoFs(std::vector<used_DoFs_t>& dofs) const = 0;
86 
89  void getGlobalDoFs(std::vector<used_DoFs_t>& dofs) const;
90 
95  virtual void getGlobalStiffnessMatrices(std::vector<TStiffnessSubmatrix>& outSubMats) const;
96 
97  void setGlobalOrientation(const TRotation3D& new_orientation)
98  {
99  m_global_orientation = new_orientation;
100  }
101  const TRotation3D& getGlobalOrientation() const { return m_global_orientation; }
102 
107 
113 
114  void setParent(CFiniteElementProblem* parent) { m_parent = parent; }
115 
120  virtual void loadParamsFromSet(const mrpt::containers::yaml& p, const EvaluationContext& ctx) = 0;
121 
123  void loadParamsFromSet(const mrpt::containers::yaml& p)
124  {
125  EvaluationContext def;
126  loadParamsFromSet(p, def);
127  }
128 
130  CFiniteElementProblem* getParent() const { return m_parent; }
131 
135  virtual void drawSVG(
136  void* _cairo_context,
137  const DrawStructureOptions& options,
138  const RenderInitData& ri,
139  const DrawElementExtraParams& draw_el_params,
140  const MeshOutputInfo* meshing_info) const = 0;
141 
142  virtual mrpt::viz::CSetOfObjects::Ptr getVisualization(
143  const DrawStructureOptions& options,
144  const DrawElementExtraParams& draw_el_params,
145  const MeshOutputInfo* meshing_info) const = 0;
146 
148  virtual void do_mesh(
149  const size_t my_idx,
150  CStructureProblem& out_fem,
151  MeshOutputInfo& out_info,
152  const MeshParams& params) = 0;
153 
154  protected:
155  CElement(unsigned char nEdges);
157  unsigned char nEdges,
158  const size_t from_node_id,
159  const size_t to_node_id);
161 
162  const unsigned char m_nEdges;
163  CFiniteElementProblem* m_parent;
164 
167 
170 };
171 } // namespace openbeam
Definition: CElement.h:49
void getGlobalDoFs(std::vector< used_DoFs_t > &dofs) const
virtual void getLocalDoFs(std::vector< used_DoFs_t > &dofs) const =0
num_t m_design_rotation_around_linear_axis
For linear elements, the rotation around +X(local)
Definition: CElement.h:166
virtual void getLocalStiffnessMatrices(std::vector< TStiffnessSubmatrix > &outSubMats) const =0
virtual void updateOrientationFromNodePositions()
virtual void drawSVG(void *_cairo_context, const DrawStructureOptions &options, const RenderInitData &ri, const DrawElementExtraParams &draw_el_params, const MeshOutputInfo *meshing_info) const =0
virtual void loadParamsFromSet(const mrpt::containers::yaml &p, const EvaluationContext &ctx)=0
CElement(unsigned char nEdges, const size_t from_node_id, const size_t to_node_id)
virtual void do_mesh(const size_t my_idx, CStructureProblem &out_fem, MeshOutputInfo &out_info, const MeshParams &params)=0
static Ptr createElementByName(const std::string &sName)
virtual void getGlobalStiffnessMatrices(std::vector< TStiffnessSubmatrix > &outSubMats) const
std::vector< size_t > conected_nodes_ids
Definition: CElement.h:68
void setDesignRotationAroundLinearAxis(num_t ang)
Definition: CElement.h:112
unsigned char getNumberEdges() const
Definition: CElement.h:73
CFiniteElementProblem * getParent() const
Definition: CElement.h:130
void loadParamsFromSet(const mrpt::containers::yaml &p)
Definition: CElement.h:123
TRotation3D m_global_orientation
Orientation of the element wrt global coords.
Definition: CElement.h:169
Definition: CFiniteElementProblem.h:212
Definition: CStructureProblem.h:36
Definition: DrawStructureOptions.h:102
Definition: DrawStructureOptions.h:34
Definition: types.h:160
Definition: CFiniteElementProblem.h:152
Definition: CFiniteElementProblem.h:142
Definition: DrawStructureOptions.h:114
Definition: types.h:191
Definition: CElement.h:38