25 #include <mrpt/containers/yaml.h>
26 #include <mrpt/core/optional_ref.h>
27 #include <mrpt/opengl/CSetOfObjects.h>
28 #include <mrpt/system/CTimeLogger.h>
29 #include <openbeam/CElement.h>
30 #include <openbeam/types.h>
32 #include <Eigen/Sparse>
39 struct RenderInitData;
43 enum class DoF_index : uint8_t
55 NodeDoF(node_index_t _node_id, DoF_index _dof) : nodeId(_node_id),
dof(_dof)
58 NodeDoF(node_index_t _node_id, uint8_t _dof)
59 : nodeId(_node_id),
dof(
static_cast<DoF_index
>(_dof))
66 uint8_t dofAsInt()
const {
return static_cast<uint8_t
>(
dof); }
69 enum class StaticSolverAlgorithm : uint8_t
86 Eigen::SparseMatrix<num_t> K_bb;
87 Eigen::SparseMatrix<num_t> K_ff;
88 Eigen::SparseMatrix<num_t> K_bf;
90 std::vector<size_t> free_dof_indices;
91 std::vector<size_t> bounded_dof_indices;
92 std::vector<TDoFType> dof_types;
97 Eigen::Matrix<num_t, Eigen::Dynamic, 1>
U_b;
101 Eigen::Matrix<num_t, Eigen::Dynamic, 1>
F_f;
112 Eigen::Matrix<num_t, Eigen::Dynamic, 1>
F_b;
116 Eigen::Matrix<num_t, Eigen::Dynamic, 1>
U_f;
119 Eigen::Matrix<num_t, Eigen::Dynamic, 1>
F;
122 Eigen::Matrix<num_t, Eigen::Dynamic, 1>
U;
161 unsigned int img_width = 0, img_height = 0;
169 StaticSolverAlgorithm algorithm = StaticSolverAlgorithm::Dense_LLT;
170 bool nonLinearIterative =
false;
198 using constraint_list_t = std::map<size_t, num_t>;
199 using load_list_t = std::map<size_t, num_t>;
222 const mrpt::optional_ref<vector_string_t>& errMsg = std::nullopt,
223 const mrpt::optional_ref<vector_string_t>& warnMsg = std::nullopt);
235 const std::string& file,
236 const mrpt::optional_ref<vector_string_t>& errMsg = std::nullopt,
237 const mrpt::optional_ref<vector_string_t>& warnMsg = std::nullopt);
254 const std::string& file,
const bool is_svg,
260 bool renderToCairoContext(
266 mrpt::opengl::CSetOfObjects::Ptr getVisualization(
270 const StressInfo* stressInfo =
nullptr)
const;
283 template <
typename ElementClass,
typename... _Args>
287 std::make_shared<ElementClass>(std::forward<_Args>(__args)...));
309 const constraint_list_t& getAllConstraints()
const
322 const load_list_t& getOverallLoadsOnDOFs()
const
347 void setNodePose(
size_t idx,
const num_t x,
const num_t y,
const num_t z);
353 ASSERT_(i < m_node_poses.size());
354 return m_node_poses[i];
360 ASSERT_(i < m_node_poses.size());
361 return m_node_poses[i];
367 size_t i, Vector3& out_final_point,
369 const num_t exageration_factor = 1)
const;
378 num_t& min_x, num_t& max_x, num_t& min_y, num_t& max_y,
379 bool deformed =
false,
381 num_t deformed_scale_factor = 1.0)
const;
405 const std::vector<size_t>& ds,
const size_t nTotalDOFs);
457 const size_t idx)
const;
472 std::deque<node_used_t> m_node_defined;
473 std::deque<TRotationTrans3D> m_node_poses;
475 std::deque<CElement::Ptr> m_elements;
509 const mrpt::containers::yaml& f,
510 const mrpt::optional_ref<vector_string_t>& errMsg,
511 const mrpt::optional_ref<vector_string_t>& warnMsg);
513 void internal_parser1_Parameters(
516 void internal_parser2_BeamSections(
519 void internal_parser3_nodes(
521 void internal_parser4_elements(
523 void internal_parser5_constraints(
526 void internal_parser6_node_loads(
528 void internal_parser7_element_loads(
553 std::array<int, 6>
dof_index = {-1, -1, -1, -1, -1, -1};
590 void internal_getVisualization_nodeLoads(
593 const MeshOutputInfo* meshing_info, num_t DEFORMED_SCALE_FACTOR)
const;
595 void internal_getVisualization_constraints(
598 const MeshOutputInfo* meshing_info, num_t DEFORMED_SCALE_FACTOR)
const;
600 void internal_getVisualization_distributedLoads(
604 const MeshOutputInfo* meshing_info, num_t DEFORMED_SCALE_FACTOR)
const;
606 void internal_getVisualization_stressDiagrams(
Definition: CFiniteElementProblem.h:196
void getNodeDeformedPosition(size_t i, Vector3 &out_final_point, const StaticSolveProblemInfo &solver_info, const num_t exageration_factor=1) const
std::vector< TRotation3D > m_nodeMainDirection
Definition: CFiniteElementProblem.h:587
std::vector< NodeDoF > m_problem_DoFs
Definition: CFiniteElementProblem.h:560
size_t getNumberOfElements() const
Definition: CFiniteElementProblem.h:297
std::string getNodeLabel(const size_t idx) const
"N%i" or custom label
std::vector< TProblemDOFIndicesForNode > m_problem_DoFs_inverse_list
Definition: CFiniteElementProblem.h:566
TRotationTrans3D & getNodePose(size_t i)
Definition: CFiniteElementProblem.h:351
bool internal_loadFromYaml(const mrpt::containers::yaml &f, const mrpt::optional_ref< vector_string_t > &errMsg, const mrpt::optional_ref< vector_string_t > &warnMsg)
std::vector< std::string > m_node_labels
node custom label
Definition: CFiniteElementProblem.h:474
void solveStatic(StaticSolveProblemInfo &out_info, const StaticSolverOptions &opts=StaticSolverOptions())
load_list_t m_loads_at_each_dof_equivs
Definition: CFiniteElementProblem.h:492
static std::vector< size_t > complementaryDoFs(const std::vector< size_t > &ds, const size_t nTotalDOFs)
virtual void internalComputeStressAndEquivalentLoads()
Definition: CFiniteElementProblem.h:505
constraint_list_t m_DoF_constraints
Definition: CFiniteElementProblem.h:482
size_t createElement(_Args &&... __args)
Definition: CFiniteElementProblem.h:284
void insertConstraint(const size_t dof_index, const num_t value=0)
bool saveAsImageSVG(const std::string &file, const DrawStructureOptions &options, const StaticSolveProblemInfo *solver_info=nullptr, const MeshOutputInfo *meshing_info=nullptr, ImageSaveOutputInfo *out_img_info=nullptr) const
node_index_t insertNode(const TRotationTrans3D &p)
num_t getMaximumDeformedDisplacement(const StaticSolveProblemInfo &solver_info) const
std::map< element_index_t, TNodeElementConnection > TNodeConnections
Definition: CFiniteElementProblem.h:576
const std::vector< NodeDoF > & getProblemDoFs()
Definition: CFiniteElementProblem.h:391
bool loadFromStream(std::istream &is, const mrpt::optional_ref< vector_string_t > &errMsg=std::nullopt, const mrpt::optional_ref< vector_string_t > &warnMsg=std::nullopt)
size_t getDOFIndex(const size_t nNode, const DoF_index n) const
size_t getNumberOfNodes() const
Definition: CFiniteElementProblem.h:337
std::string getProblemDoFsDescription()
void addLoadAtDOF(const size_t dof_index, const num_t f)
void updateElementsOrientation()
size_t insertElement(CElement::Ptr el)
void getBoundingBox(num_t &min_x, num_t &max_x, num_t &min_y, num_t &max_y, bool deformed=false, const StaticSolveProblemInfo *solver_info=nullptr, num_t deformed_scale_factor=1.0) const
CElement::ConstPtr getElement(size_t i) const
void setNodePose(size_t idx, const num_t x, const num_t y, const num_t z)
const TRotationTrans3D & getNodePose(size_t i) const
Definition: CFiniteElementProblem.h:358
void setNumberOfNodes(size_t N)
std::vector< TNodeConnections > m_node_connections
Definition: CFiniteElementProblem.h:582
bool loadFromFile(const std::string &file, const mrpt::optional_ref< vector_string_t > &errMsg=std::nullopt, const mrpt::optional_ref< vector_string_t > &warnMsg=std::nullopt)
void updateNodeConnections()
void updateNodesMainOrientation()
void postProcCalcStress(StressInfo &out_stress, const StaticSolveProblemInfo &solver_info)
void assembleProblem(BuildProblemInfo &out_info)
std::map< size_t, ElementStress > m_extra_stress_for_each_element
Definition: CFiniteElementProblem.h:498
load_list_t m_loads_at_each_dof
Definition: CFiniteElementProblem.h:486
const CElement::Ptr & getElement(size_t i)
void setNodePose(size_t idx, const TRotationTrans3D &p)
void setLoadAtDOF(const size_t dof_index, const num_t f)
Definition: CStructureProblem.h:36
Definition: CFiniteElementProblem.h:79
size_t free_index
Definition: CFiniteElementProblem.h:82
size_t bounded_index
Definition: CFiniteElementProblem.h:80
Definition: CFiniteElementProblem.h:77
Eigen::Matrix< num_t, Eigen::Dynamic, 1 > U_b
Definition: CFiniteElementProblem.h:97
Eigen::Matrix< num_t, Eigen::Dynamic, 1 > F_f
Definition: CFiniteElementProblem.h:101
Definition: CFiniteElementProblem.h:569
unsigned char elementFaceId
To which face in that element.
Definition: CFiniteElementProblem.h:570
used_DoFs_t dofs
DoFs used by that face in that element.
Definition: CFiniteElementProblem.h:571
Definition: CFiniteElementProblem.h:548
std::array< int, 6 > dof_index
Definition: CFiniteElementProblem.h:553
Definition: CFiniteElementProblem.h:466
Definition: DrawStructureOptions.h:34
Definition: CFiniteElementProblem.h:158
Definition: CFiniteElementProblem.h:138
std::deque< std::vector< element_index_t > > element2elements
List of smaller element IDs resulting from meshing the element [i].
Definition: CFiniteElementProblem.h:154
std::deque< std::vector< node_index_t > > element2nodes
Definition: CFiniteElementProblem.h:151
size_t num_original_elements
Definition: CFiniteElementProblem.h:147
size_t num_original_nodes
Definition: CFiniteElementProblem.h:143
Definition: CFiniteElementProblem.h:128
double max_element_length
In meters (m)
Definition: CFiniteElementProblem.h:131
Definition: CFiniteElementProblem.h:54
DoF_index dof
In the range [0-5].
Definition: CFiniteElementProblem.h:64
Definition: DrawStructureOptions.h:115
Definition: CFiniteElementProblem.h:106
Eigen::Matrix< num_t, Eigen::Dynamic, 1 > U_f
Definition: CFiniteElementProblem.h:116
Eigen::Matrix< num_t, Eigen::Dynamic, 1 > F_b
Definition: CFiniteElementProblem.h:112
BuildProblemInfo build_info
Information from the assembly of the problem.
Definition: CFiniteElementProblem.h:108
Eigen::Matrix< num_t, Eigen::Dynamic, 1 > F
The full F vector (bounded+free DOFs)
Definition: CFiniteElementProblem.h:119
Eigen::Matrix< num_t, Eigen::Dynamic, 1 > U
The full U vector (bounded+free DOFs)
Definition: CFiniteElementProblem.h:122
Definition: CFiniteElementProblem.h:166
Definition: CFiniteElementProblem.h:174
std::vector< ElementStress > element_stress
Definition: CFiniteElementProblem.h:182