/*! * \file containers.h * * \author Ryan Latture * \date 8-12-15 * * Contains the structs used to organize the job, BCs, and ties for 3D beam FEA. */ // Copyright 2015. All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are met: // // * Redistributions of source code must retain the above copyright notice, // this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright notice, // this list of conditions and the following disclaimer in the documentation // and/or other materials provided with the distribution. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE // POSSIBILITY OF SUCH DAMAGE. // // Author: ryan.latture@gmail.com (Ryan Latture) #ifndef FEA_CONTAINERS_H #define FEA_CONTAINERS_H #include #include namespace fea { /** * @brief A node that describes a mesh. Uses Eigen's predefined Vector class for added functionality. * @details See the Eigen documentation on the Vector3d class for more options of what can be done with `Nodes`. \n * Examples of constucting a `Node` at \f$(x, y, z)=(0,1,2)\f$: * @code * // specify values on constuction * fea::Node n1(1.0, 2.0, 3.0); * * // construct a Node then insert values * fea::Node n2; * n2 << 0.0, 1.0, 2.0; * @endcode */ typedef Eigen::Vector3d Node; /** * @brief A boundary condition to enforce. * @details Set by specifying the node to constrain, which degree of freedom, and the value to hold the node at. * * @code * // define the node number to constrain * unsigned int nn1 = 0; * // define the value to hold the nodal DOF at * double value = 0.0; * fea::BC bc(nn1, fea::DOF::DISPLACEMENT_X, value); * @endcode */ struct BC { unsigned int node;/** normal_vec = {0.0, 0.0, 1.0}; * fea::Props props(EA, EIz, EIy, GJ, normal_vec); * @endcode */ struct Props { double EA;/**. Vector normal to element (`normal_vec.size()==3`). Direction should be parallel to the beam element's local y-axis. */ Props(double _EA, double _EIz, double _EIy, double _GJ, const std::vector &_normal_vec) : EA(_EA), EIz(_EIz), EIy(_EIy), GJ(_GJ) { normal_vec << _normal_vec[0], _normal_vec[1], _normal_vec[2]; }; }; /** * @brief Places linear springs between all degrees of freedom of 2 nodes. * @details 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. * @code * // create the tie between node2 and node3 * unsigned int nn1 = 1; // i.e. the second node in the node list * unsigned int nn2 = 2; // i.e. the third node in the node list * * // define the spring constant for x, y, and z translational DOFs * double lmult = 100.0; * * // define the spring constant for x, y, and z rotational DOFs * double rmult = 100.0; * * // form the tie * fea::Tie tie1(nn1, nn2, lmult, rmult); * @endcode */ struct Tie { unsigned int node_number_1;/** terms;/**`. A list of terms that sum to zero.k */ Equation(const std::vector &_terms) : terms(_terms) {}; }; /** * @brief An element of the mesh. Contains the indices of the two `fea::Node`'s that form the element as well * as the properties of the element given by the `fea::Props` struct. */ struct Elem { Eigen::Vector2i node_numbers;/** nodes;/** elems;/** props;/**. The node list that defines the mesh. * @param[in] elems std::vector. The elements that define the mesh. * An element is defined by the connectivity list and the associated properties. */ Job(const std::vector &_nodes, const std::vector _elems) : nodes(_nodes) { unsigned int num_elems = _elems.size(); elems.reserve(num_elems); props.reserve(num_elems); for (unsigned int i = 0; i < num_elems; i++) { elems.push_back(_elems[i].node_numbers); props.push_back(_elems[i].props); } }; }; /** * @brief Convenience enumerator for specifying the active degree of freedom in a constraint. */ enum DOF { /** * Displacement along the global x-axis. */ DISPLACEMENT_X, /** * Displacement along the global y-axis. */ DISPLACEMENT_Y, /** * Displacement along the global z-axis. */ DISPLACEMENT_Z, /** * Rotation about the global x-axis. */ ROTATION_X, /** * Rotation about the global y-axis. */ ROTATION_Y, /** * Rotation about the global z-axis. */ ROTATION_Z, /** * Number of degrees of freedom per node. */ NUM_DOFS }; } // namespace fea #endif // FEA_CONTAINERS_H