OpenBeam
C++ library for static analysis of mechanical structures
Classes | Public Types | Protected Types | Protected Member Functions | Protected Attributes | List of all members
openbeam::CFiniteElementProblem Class Reference

#include <CFiniteElementProblem.h>

Inheritance diagram for openbeam::CFiniteElementProblem:
Inheritance graph
[legend]

Classes

struct  node_used_t
 
struct  TNodeElementConnection
 
struct  TProblemDOFIndicesForNode
 

Public Types

using constraint_list_t = std::map< size_t, num_t >
 
using load_list_t = std::map< size_t, num_t >
 

Public Member Functions

High-level management
virtual void clear ()
 
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)
 
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)
 
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
 
bool saveAsImagePNG (const std::string &file, const DrawStructureOptions &options, const StaticSolveProblemInfo *solver_info=nullptr, const MeshOutputInfo *meshing_info=nullptr, ImageSaveOutputInfo *out_img_info=nullptr) const
 
bool saveAsImage (const std::string &file, const bool is_svg, const DrawStructureOptions &options, const StaticSolveProblemInfo *solver_info=nullptr, const MeshOutputInfo *meshing_info=nullptr, ImageSaveOutputInfo *out_img_info=nullptr) const
 
bool renderToCairoContext (void *_cairo_context, const RenderInitData &ri, const DrawStructureOptions &options, const StaticSolveProblemInfo *solver_info, const MeshOutputInfo *meshing_info) const
 
mrpt::viz::CSetOfObjects::Ptr getVisualization (const DrawStructureOptions &options, const StaticSolveProblemInfo &solver_info, const MeshOutputInfo *meshing_info=nullptr, const StressInfo *stressInfo=nullptr) const
 
Problem elements
size_t insertElement (CElement::Ptr el)
 
template<typename ElementClass , typename... _Args>
size_t createElement (_Args &&... __args)
 
CElement::ConstPtr getElement (size_t i) const
 
const CElement::Ptr & getElement (size_t i)
 
size_t getNumberOfElements () const
 
Problem constraints
void insertConstraint (const size_t dof_index, const num_t value=0)
 
const constraint_list_t & getAllConstraints () const
 
bool addNodeConstraint (node_index_t node, DoF_index dof, num_t value=0)
 
const std::map< std::pair< node_index_t, DoF_index >, num_t > & getNodeConstraintRequests () const
 Constraints as requested with addNodeConstraint()
 
void setLoadAtDOF (const size_t dof_index, const num_t f)
 
void addLoadAtDOF (const size_t dof_index, const num_t f)
 
const load_list_t & getOverallLoadsOnDOFs () const
 
Problem nodes and their reference 3D pose (to this, one must add

the displacement obtained as solution to the problem).

void setNumberOfNodes (size_t N)
 
size_t getNumberOfNodes () const
 
node_index_t insertNode (const TRotationTrans3D &p)
 
void setNodePose (size_t idx, const TRotationTrans3D &p)
 
void setNodePose (size_t idx, const num_t x, const num_t y, const num_t z)
 
TRotationTrans3D & getNodePose (size_t i)
 
const TRotationTrans3D & getNodePose (size_t i) const
 
void getNodeDeformedPosition (size_t i, Vector3 &out_final_point, const StaticSolveProblemInfo &solver_info, const num_t exageration_factor=1) const
 
num_t getMaximumDeformedDisplacement (const StaticSolveProblemInfo &solver_info) const
 
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
 
Problem solving
virtual void updateAll ()
 
void assembleProblem (BuildProblemInfo &out_info)
 
void solveStatic (StaticSolveProblemInfo &out_info, const StaticSolverOptions &opts=StaticSolverOptions())
 
void postProcCalcStress (StressInfo &out_stress, const StaticSolveProblemInfo &solver_info)
 
std::string getNodeLabel (const size_t idx) const
 "N%i" or custom label
 

Protected Types

using TNodeConnections = std::map< element_index_t, TNodeElementConnection >
 

Protected Member Functions

virtual void internalComputeStressAndEquivalentLoads ()
 
bool internal_loadFromYaml (const mrpt::containers::yaml &f, const mrpt::optional_ref< vector_string_t > &errMsg, const mrpt::optional_ref< vector_string_t > &warnMsg)
 
void internal_parser1_Parameters (const mrpt::containers::yaml &f, EvaluationContext &ctx) const
 
void internal_parser2_BeamSections (const mrpt::containers::yaml &f, EvaluationContext &ctx) const
 
void internal_parser3_nodes (const mrpt::containers::yaml &f, EvaluationContext &ctx)
 
void internal_parser4_elements (const mrpt::containers::yaml &f, EvaluationContext &ctx)
 
void internal_parser5_constraints (const mrpt::containers::yaml &f, EvaluationContext &ctx)
 
void internal_parser6_node_loads (const mrpt::containers::yaml &f, EvaluationContext &ctx)
 
void internal_parser7_element_loads (const mrpt::containers::yaml &f, EvaluationContext &ctx)
 
void updateListDoFs ()
 
void updateNodeConnections ()
 
void updateElementsOrientation ()
 
void updateNodesMainOrientation ()
 
std::string describeSingularStiffness (const DynMatrix &Kff, const std::vector< size_t > &free_dof_indices) const
 
void internal_getVisualization_nodeLoads (mrpt::viz::CSetOfObjects &gl, const DrawStructureOptions &options, const StaticSolveProblemInfo &solver_info, const MeshOutputInfo *meshing_info, num_t DEFORMED_SCALE_FACTOR) const
 
void internal_getVisualization_constraints (mrpt::viz::CSetOfObjects &gl, const DrawStructureOptions &options, const StaticSolveProblemInfo &solver_info, const MeshOutputInfo *meshing_info, num_t DEFORMED_SCALE_FACTOR) const
 
void internal_getVisualization_distributedLoads (const CStructureProblem &str, mrpt::viz::CSetOfObjects &gl, const DrawStructureOptions &options, const StaticSolveProblemInfo &solver_info, const MeshOutputInfo *meshing_info, num_t DEFORMED_SCALE_FACTOR) const
 
void internal_getVisualization_stressDiagrams (mrpt::viz::CSetOfObjects &gl, const DrawStructureOptions &options, const StaticSolveProblemInfo &solverInfo, const MeshOutputInfo *meshingInfo, num_t DEFORMED_SCALE_FACTOR, const StressInfo &stressInfo) const
 

Protected Attributes

std::vector< NodeDoF > m_problem_DoFs
 
std::vector< TProblemDOFIndicesForNode > m_problem_DoFs_inverse_list
 
std::vector< TNodeConnections > m_node_connections
 
std::vector< TRotation3D > m_nodeMainDirection
 
Main data
std::deque< node_used_t > m_node_defined
 
std::deque< TRotationTrans3D > m_node_poses
 
std::vector< std::string > m_node_labels
 node custom label
 
std::deque< CElement::Ptr > m_elements
 
constraint_list_t m_DoF_constraints
 
std::map< std::pair< node_index_t, DoF_index >, num_t > m_node_constraint_requests
 See addNodeConstraint()
 
load_list_t m_loads_at_each_dof
 
load_list_t m_loads_at_each_dof_equivs
 
std::map< size_t, ElementStress > m_extra_stress_for_each_element
 

Problem DOFs (abstract list of DoF, doesn't have quantitative

displacement values)

const std::vector< NodeDoF > & getProblemDoFs ()
 
std::string getProblemDoFsDescription ()
 
size_t getDOFIndex (const size_t nNode, const DoF_index n) const
 
static std::vector< size_t > complementaryDoFs (const std::vector< size_t > &ds, const size_t nTotalDOFs)
 

Detailed Description

A complete problem of finite elements. It contains:

See also
CFiniteElementProblem

Member Typedef Documentation

◆ TNodeConnections

using openbeam::CFiniteElementProblem::TNodeConnections = std::map<element_index_t, TNodeElementConnection>
protected

For each node, this map has the list of connected elements and the type of the connection.

Member Function Documentation

◆ addLoadAtDOF()

void openbeam::CFiniteElementProblem::addLoadAtDOF ( const size_t  dof_index,
const num_t  f 
)

Adds a load (force or moment) to a given DOF, accumulating to previously existing values if any.

See also
setLoadAtDOF

◆ addNodeConstraint()

bool openbeam::CFiniteElementProblem::addNodeConstraint ( node_index_t  node,
DoF_index  dof,
num_t  value = 0 
)

Constrains a DoF of a node (in nodal coordinates) to a given displacement. The request is remembered even if no element uses that DoF (which is then left out of the problem), so it is applied again if the problem DoFs change, e.g. when meshing.

Returns
false if the DoF is not part of the problem right now.

◆ assembleProblem()

void openbeam::CFiniteElementProblem::assembleProblem ( BuildProblemInfo &  out_info)

For any partitioning of the DoFs into fixed (restricted, boundary conditions) and the rest (the free variables free_dof_indices), where DoF indices refer to m_problem_DoFs, computes three sparse matrices: K_{FF} (free-free), K_{BB} (boundary-boundary) and K_{BF} (boundary-free) which define the stiffness matrix of the problem.

Note
The free vs constrained DoF's are automatically determined from m_DoF_constraints
See also
solveStatic

◆ clear()

virtual void openbeam::CFiniteElementProblem::clear ( )
virtual

Delete all elements, nodes and constraints in this problem, completely emptying it.

Reimplemented in openbeam::CStructureProblem.

◆ complementaryDoFs()

static std::vector<size_t> openbeam::CFiniteElementProblem::complementaryDoFs ( const std::vector< size_t > &  ds,
const size_t  nTotalDOFs 
)
static

Return the complementary list of DOFs, such as "return \CUP ds = 1:N" and "return \CAP ds = \empty".

◆ createElement()

template<typename ElementClass , typename... _Args>
size_t openbeam::CFiniteElementProblem::createElement ( _Args &&...  __args)
inline

Insert a new element in the problem

Returns
The element index

◆ describeSingularStiffness()

std::string openbeam::CFiniteElementProblem::describeSingularStiffness ( const DynMatrix &  Kff,
const std::vector< size_t > &  free_dof_indices 
) const
protected

Explains why a free-free stiffness matrix could not be factorized: lists the DoFs that can move freely (a mechanism), if any.

◆ getBoundingBox()

void openbeam::CFiniteElementProblem::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

Computes the bounding box of all existing nodes

◆ getDOFIndex()

size_t openbeam::CFiniteElementProblem::getDOFIndex ( const size_t  nNode,
const DoF_index  n 
) const

Returns the 0-based index of the n'th DOF (0-5) of node "nNode" in the list of DOFs to consider in the problem. Callable only after buildAll(). Returns string::npos if the DOF is NOT considered in the problem.

◆ getElement() [1/2]

const CElement::Ptr& openbeam::CFiniteElementProblem::getElement ( size_t  i)

Return a pointer to the i'th element in the problem.

◆ getElement() [2/2]

CElement::ConstPtr openbeam::CFiniteElementProblem::getElement ( size_t  i) const

Return a constant pointer to the i'th element in the problem.

◆ getMaximumDeformedDisplacement()

num_t openbeam::CFiniteElementProblem::getMaximumDeformedDisplacement ( const StaticSolveProblemInfo &  solver_info) const

Returns the maximum absolute value translation in any X,Y,Z directions for a static problem solution

◆ getNodeDeformedPosition()

void openbeam::CFiniteElementProblem::getNodeDeformedPosition ( size_t  i,
Vector3 &  out_final_point,
const StaticSolveProblemInfo &  solver_info,
const num_t  exageration_factor = 1 
) const

Returns the 3D location of the final deformed state after solving the problem

◆ getNodePose() [1/2]

TRotationTrans3D& openbeam::CFiniteElementProblem::getNodePose ( size_t  i)
inline

The 3D location of a node; its orientation (if different than global coordinates) serves as a local frame for constraints.

◆ getNodePose() [2/2]

const TRotationTrans3D& openbeam::CFiniteElementProblem::getNodePose ( size_t  i) const
inline

The 3D location of a node; its orientation (if different than global coordinates) serves as a local frame for constraints.

◆ getNumberOfElements()

size_t openbeam::CFiniteElementProblem::getNumberOfElements ( ) const
inline

Get the number of elements in the problem

◆ getNumberOfNodes()

size_t openbeam::CFiniteElementProblem::getNumberOfNodes ( ) const
inline

Number of DoF's?

◆ getProblemDoFs()

const std::vector<NodeDoF>& openbeam::CFiniteElementProblem::getProblemDoFs ( )
inline

Return the list of all DoF in the problem .

See also
getProblemDoFsDescription

◆ getProblemDoFsDescription()

std::string openbeam::CFiniteElementProblem::getProblemDoFsDescription ( )

Make a list with all DoF in the problem sorted by nodes.

See also
getProblemDoFs

◆ insertConstraint()

void openbeam::CFiniteElementProblem::insertConstraint ( const size_t  dof_index,
const num_t  value = 0 
)

Adds a new displacement constraint to the problem, at the DoF dof_index (indices wrt list returned by getProblemDoFs() ).

◆ insertElement()

size_t openbeam::CFiniteElementProblem::insertElement ( CElement::Ptr  el)

Insert a new element in the problem

Returns
The element index

◆ insertNode()

node_index_t openbeam::CFiniteElementProblem::insertNode ( const TRotationTrans3D &  p)

Insert a new node to the problem with the given 6D pose, in global coordinates.

Returns
The index of this new node

◆ internal_loadFromYaml()

bool openbeam::CFiniteElementProblem::internal_loadFromYaml ( const mrpt::containers::yaml &  f,
const mrpt::optional_ref< vector_string_t > &  errMsg,
const mrpt::optional_ref< vector_string_t > &  warnMsg 
)
protected

Internal common implementation of loadFrom*() methods()

◆ internalComputeStressAndEquivalentLoads()

virtual void openbeam::CFiniteElementProblem::internalComputeStressAndEquivalentLoads ( )
inlineprotectedvirtual

In base classes, process loads on elements and populate the m_loads_at_each_dof_equivs and m_extra_stress_for_each_element

◆ loadFromFile()

bool openbeam::CFiniteElementProblem::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 
)

Discard the current problem and loads it by parsing the given text file. The expected format of the file is described in XXXX.

Parameters
[in]isThe input stream.
[out]errMsgThe error messages found while parsing the text.
[out]warnMsgThe warning messages found while parsing the text.
Returns
true on Success

◆ loadFromStream()

bool openbeam::CFiniteElementProblem::loadFromStream ( std::istream &  is,
const mrpt::optional_ref< vector_string_t > &  errMsg = std::nullopt,
const mrpt::optional_ref< vector_string_t > &  warnMsg = std::nullopt 
)

Discard the current problem and loads it by parsing the given text input stream. The expected format of the file is described in XXXX.

Parameters
[in]isThe input stream.
[out]errMsgThe error messages found while parsing the text.
[out]warnMsgThe warning messages found while parsing the text.
Returns
true on Success

◆ postProcCalcStress()

void openbeam::CFiniteElementProblem::postProcCalcStress ( StressInfo &  out_stress,
const StaticSolveProblemInfo &  solver_info 
)

After solving the problem with solveStatic, you can optionally call this post-processing method to evaluate the stress of all the elements.

See also
solveStatic

◆ saveAsImageSVG()

bool openbeam::CFiniteElementProblem::saveAsImageSVG ( const std::string &  file,
const DrawStructureOptions &  options,
const StaticSolveProblemInfo *  solver_info = nullptr,
const MeshOutputInfo *  meshing_info = nullptr,
ImageSaveOutputInfo *  out_img_info = nullptr 
) const

Saves a representation of the problem to a SVG file.

Parameters
optionsMany parameters and switches to control what will be drawn and hiden.
Returns
true on success

◆ setLoadAtDOF()

void openbeam::CFiniteElementProblem::setLoadAtDOF ( const size_t  dof_index,
const num_t  f 
)

Sets the load (force or moment) applied to a given DOF

See also
addLoadAtDOF

◆ setNodePose() [1/2]

void openbeam::CFiniteElementProblem::setNodePose ( size_t  idx,
const num_t  x,
const num_t  y,
const num_t  z 
)

Set the reference 3D pose of a node, in global coordinates

◆ setNodePose() [2/2]

void openbeam::CFiniteElementProblem::setNodePose ( size_t  idx,
const TRotationTrans3D &  p 
)

Set the reference 6D pose of a node, in global coordinates

◆ setNumberOfNodes()

void openbeam::CFiniteElementProblem::setNumberOfNodes ( size_t  N)

Set the number of nodes in the problem

◆ solveStatic()

void openbeam::CFiniteElementProblem::solveStatic ( StaticSolveProblemInfo &  out_info,
const StaticSolverOptions &  opts = StaticSolverOptions() 
)

Solve the static FE problem, returning the resulting displacements and reaction forces.

Note
This method internally calls assembleProblem()
See also
assembleProblem, postProcCalcStress

◆ updateAll()

virtual void openbeam::CFiniteElementProblem::updateAll ( )
virtual

Update all internal lists after changing the problem. This actually calls:

Reimplemented in openbeam::CStructureProblem.

◆ updateElementsOrientation()

void openbeam::CFiniteElementProblem::updateElementsOrientation ( )
protected

Call the "updateOrientationFromNodePositions" in each element

◆ updateListDoFs()

void openbeam::CFiniteElementProblem::updateListDoFs ( )
protected

From the list of elements and their properties and connections, build the list of DoFs relevant to the problem.

◆ updateNodeConnections()

void openbeam::CFiniteElementProblem::updateNodeConnections ( )
protected

From the list of elements, update m_node_connections

◆ updateNodesMainOrientation()

void openbeam::CFiniteElementProblem::updateNodesMainOrientation ( )
protected

Fills up m_nodeMainDirection

Member Data Documentation

◆ m_DoF_constraints

constraint_list_t openbeam::CFiniteElementProblem::m_DoF_constraints
protected

List of constrainsts for each "fixed/constrained" DoF. Map key are indices in m_problem_DoFs. Map values are displacement in that DoF wrt the current node pose. Units are SI (meters or radians).

See also
getProblemDoFs

◆ m_extra_stress_for_each_element

std::map<size_t, ElementStress> openbeam::CFiniteElementProblem::m_extra_stress_for_each_element
protected

The extra stress to add up to each element as computed by internalComputeStressAndEquivalentLoads map: element index -> vector for each "port" -> vector of 6 stresses values.

◆ m_loads_at_each_dof

load_list_t openbeam::CFiniteElementProblem::m_loads_at_each_dof
protected

The vector of overall external loads (F_L) - Map keys are indices of m_problem_DoFs

◆ m_loads_at_each_dof_equivs

load_list_t openbeam::CFiniteElementProblem::m_loads_at_each_dof_equivs
protected

The vector of overall loads (F_L') on each DoF due to distributed forces - Map keys are indices of m_problem_DoFs Updated by assembleProblem() via internalComputeStressAndEquivalentLoads()

◆ m_node_connections

std::vector<TNodeConnections> openbeam::CFiniteElementProblem::m_node_connections
protected

A vector with an item for each node (list in m_node_poses) Each item is a map from element_id -> TNodeElementConnection Length=number of nodes.

◆ m_nodeMainDirection

std::vector<TRotation3D> openbeam::CFiniteElementProblem::m_nodeMainDirection
protected

For each node, the +X direction of the first element touching that node. Filled by updateNodesMainOrientation()

◆ m_problem_DoFs

std::vector<NodeDoF> openbeam::CFiniteElementProblem::m_problem_DoFs
protected

The list of DoFs variables of my problem. Built by updateListDoFs()

See also
m_problem_DoFs_inverse_list

◆ m_problem_DoFs_inverse_list

std::vector<TProblemDOFIndicesForNode> openbeam::CFiniteElementProblem::m_problem_DoFs_inverse_list
protected

Built together with m_problem_DoFs by updateListDoFs , holds the mapping from node index -> 6 numbers, with the index of that global DOF in the list of problem DOFs, or -1 if the DOF is not considered.


The documentation for this class was generated from the following file: