3D Beam Finite Element Code
1.0
|
This project requires CMake to compile the code. If not installed, install CMake before continuing. If you intend on building the GUI, Qt must be installed and the path to the Qt5WidgetsConfig.cmake file must be set when invoking CMake. Currently, the following method of building the GUI works on Mac and Linux. If running on Windows, open the fea_gui.pro file with QtCreator (included with the Qt installation) and run. Alternatively, I can package pre-built binaries if there is interest.
threed-beam-fea
directorybuild
build
directorycmake ..
-DCMAKE_BUILD_TYPE=debug
if you would like to build the code for debugging purposes. By default the make files will be configured for the release build.cmake .. -DFEA_BUILD_GUI=ON -DCMAKE_PREFIX_PATH="/path/to/Qt"
-DFEA_BUILD_GUI=ON
tells cmake to add the ../gui
subdirectory and adds fea_gui
to the targets.-DCMAKE_PREFIX_PATH="/path/to/Qt"
should be the path to the Qt root directory. make
in the terminal from the build directory to build all the targets. On Windows the solution file will be located in the build directory. Open the solution file in Visual Studio and compile.This contains a C++ implementation of 3D Euler-Bernoulli beam element formulation. An analysis can be formulated in C++, through a command line interface via a config file, or using the graphical user interface.
An analysis consists of the fea::Job
as well as any boundary conditions (fea::BC
), prescribed nodal forces (fea::Force
), and ties (fea::Tie
). The latter of which ties to nodes together via a linear springs between all translational and rotational degrees of freedom. The fea::Options
struct can be used to request results of the analysis be written to disk as well as modify various aspect of the analysis.
The job defines the nodal coordinates in \((x, y, z)\) space, the nodes that are connected to form beam elements, and the elemental properties. The nodal coordinates are formed as a vector of fea::Node
's where each node simply contains the \((x, y, z)\) coordinates of the point. An element contains the 2 nodal indices that are connected to form the element as well as the associated properties of the element. The properties must define the extensional stiffness, \(EA\), bending stiffness parallel to the local z-axis \(EI_{z}\), bending stiffness parallel to the local y-axis \(EI_{y}\), the torsional stiffness, \(GJ\), and a vector pointing along the beam elements local y-axis. An example forming a simple job with a single element is shown below.
Boundary conditions are applied by specifying the index of the node, the degree of freedom, and the prescribed value. The index of the node is simply the index the node occurs in the node list. The degree of freedom can be defined using the fea::DOF
enum or by specifying the integer associated with the degree of freedom explicitly. There are 6 degrees of freedom per node meaning valid integers associated with degrees of freedom are between 0 and 5. The associations for degrees of freedom are defined as
Continuing the example from above, we can fix all degrees of freedom of the node at the origin using the following code:
Nodal forces are assigned in the same manner as boundary conditions, i.e. using the node number, degree of freedom, and value. We can load our cantilever at the tip with the following:
By default submitting an analysis to the fea::solve
function will not save the results. The outputs must be requested using the fea::Options
struct. Using the appropriate member variables nodal displacements, nodal forces, and the forces associated with ties can be saved to a CSV file. The name of the file the output is saved to is also set in the options as well as the delimiter used when writing the data to disk. Additionally, the fea::Options
struct has the ability to set the epsilon value on nodal forces and displacements. After the analysis if the magnitude of the displacement is below the epsilon value, it will be set to 0.0. The default is 1.0e-14
. A summary of the analysis can be saved to a text file using the save_report
and report_filename
member variables of fea::Options
. If the verbose
member is set to true
informational messages regarding the current step and time taken on previous steps of the analysis will be written to std::cout
. An example of customizing the analysis with the options struct is shown below:
Once the analysis has been setup, it can be solved using the fea::solve
function. This functions takes as input the job, boundary conditions, prescribed nodal forces, ties (discussed below), and options. fea::solve
will solve the analysis, save the requested files, and return a summary of the analysis. The fea::Summary
object can return a report of the analysis in the form of a string using the fea::Summary::fullReport()
function, and member variables fea::Summary::nodal_forces
, fea::Summary::nodal_displacements
, and fea::Summary::tie_forces
contain the results of the analysis.
Ties are enforced by placing linear springs between all degrees of freedom for 2 nodes. To form a tie specify the 2 nodes that will be linked as well as the spring constants for translational and rotational degrees of freedom. All translational degrees of freedom will be assigned the same spring constant. The same is true for rotational degrees of freedom, although the spring constant does not have to be the same as that used for the translational DOFs. Commonly, ties are used to model non-rigid joints. To form a joint between 2 elements, introduce a redundant node at that location and use a tie to link the to nodes together. This essentially places a spring element between the two points of the specified stiffness.
After using CMake to build the targets, an executable will be created that provide a command line interface (CLI) to the beam element code. Once in the build directory, navigate to the bin
folder containing fea_cmd. running ./fea_cmd -h
from the terminal will show the help documentation for the program. The CLI expects the -c
flag to be set and point to the config file for the current analysis. A config file is a JSON document that contains key, value pairs pointing to the nodes, elements, properties, and other analysis options. An example is shown below.
The use of a JSON document avoids the need to set each of these options using command line options, which can become tedious when running multiple jobs. The "nodes", "elems", and "props" keys are required. Keys "bcs", "forces", and "ties" are optional–if not provided the analysis will assume none were prescribed. If the "options" key is not provided the analysis will run with the default options. Any of all of the "options" keys presented above can be used to customize the analysis. If a key is not provided the default value is used in its place. See the Formatting CSV Files section below for how the CSV files should be created.
A simple graphical user interface can be used to set up an analysis. Internally, the GUI creates the JSON file used by the CLI (see above) without the need to write the file by hand. The program then saves a temporary configuration file and submits it to the command line application. This requires that the command line application has been compiled and is located in the same directory as the GUI. To open the GUI navigate to the build folder and open the fea_gui executable located in the bin
directory. The first set of buttons allows the path to the CSV files to be set, and the second set of controls customizes the options. Once the files and options have been configured, clicking the submit button will run the analysis.
All CSV file must be comma delimited with no spaces between values, i.e. one row of the nodal coordinates file might resemble 1.0,2.0,3.0
. The file indicated by the value of "nodes" should be in the format:
where each entry is a double and every line must have 3 entries for the x,y,z
position. The "elems" file contains (only) the node indices:
where each entry is an integer and must have 2 nodal indices defining the connectivity of the element. Elemental properties are defined in the "props" file as:
where each entry is a double and each line has 7 entries. The "bcs" and "forces" CSV files have the same format. Each line specifies the node number, degree of freedom, and value:
where the node number is the index of the node in the node list (integer), the DOF is the degree of freedom constrained (integer between 0 and 5), and value is the value to hold the degree of freedom at relative to the starting position (double). The "ties" CSV file is specified using the format:
where lmult
is the spring constant for the translational degrees of freedom and rmult
is the spring constant for the rotational degrees of freedom.