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/opengl/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 
83  std::vector<TStiffnessSubmatrix>& outSubMats) const = 0;
84 
86  virtual void getLocalDoFs(std::vector<used_DoFs_t>& dofs) const = 0;
87 
90  void getGlobalDoFs(std::vector<used_DoFs_t>& dofs) const;
91 
97  std::vector<TStiffnessSubmatrix>& outSubMats) const;
98 
99  void setGlobalOrientation(const TRotation3D& new_orientation)
100  {
101  m_global_orientation = new_orientation;
102  }
103  const TRotation3D& getGlobalOrientation() const
104  {
105  return m_global_orientation;
106  }
107 
112 
118  {
120  }
121 
122  void setParent(CFiniteElementProblem* parent) { m_parent = parent; }
123 
128  virtual void loadParamsFromSet(
129  const mrpt::containers::yaml& p, const EvaluationContext& ctx) = 0;
130 
132  void loadParamsFromSet(const mrpt::containers::yaml& p)
133  {
134  EvaluationContext def;
135  loadParamsFromSet(p, def);
136  }
137 
139  CFiniteElementProblem* getParent() const { return m_parent; }
140 
144  virtual void drawSVG(
145  void* _cairo_context, const DrawStructureOptions& options,
146  const RenderInitData& ri, const DrawElementExtraParams& draw_el_params,
147  const MeshOutputInfo* meshing_info) const = 0;
148 
149  virtual mrpt::opengl::CSetOfObjects::Ptr getVisualization(
150  const DrawStructureOptions& options,
151  const DrawElementExtraParams& draw_el_params,
152  const MeshOutputInfo* meshing_info) const = 0;
153 
155  virtual void do_mesh(
156  const size_t my_idx, CStructureProblem& out_fem,
157  MeshOutputInfo& out_info, const MeshParams& params) = 0;
158 
159  protected:
160  CElement(unsigned char nEdges);
162  unsigned char nEdges, const size_t from_node_id,
163  const size_t to_node_id);
165 
166  const unsigned char m_nEdges;
167  CFiniteElementProblem* m_parent;
168 
171 
174 };
175 } // 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:170
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:117
unsigned char getNumberEdges() const
Definition: CElement.h:73
CFiniteElementProblem * getParent() const
Definition: CElement.h:139
void loadParamsFromSet(const mrpt::containers::yaml &p)
Definition: CElement.h:132
TRotation3D m_global_orientation
Orientation of the element wrt global coords.
Definition: CElement.h:173
Definition: CFiniteElementProblem.h:196
Definition: CStructureProblem.h:36
Definition: DrawStructureOptions.h:103
Definition: DrawStructureOptions.h:34
Definition: types.h:161
Definition: CFiniteElementProblem.h:138
Definition: CFiniteElementProblem.h:128
Definition: DrawStructureOptions.h:115
Definition: types.h:187
Definition: CElement.h:38