MAST
Multidisciplinary-design Adaptation and Sensitivity Toolkit (MAST)
mast_structural_element_1d.h
Go to the documentation of this file.
1 /*
2  * MAST: Multidisciplinary-design Adaptation and Sensitivity Toolkit
3  * Copyright (C) 2013-2020 Manav Bhatia and MAST authors
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18  */
19 
20 #ifndef MAST_MAST_STRUCTURAL_ELEMENT_1D_H
21 #define MAST_MAST_STRUCTURAL_ELEMENT_1D_H
22 
23 // Test includes
24 #include "base/mast_mesh.h"
25 
26 extern libMesh::LibMeshInit* p_global_init;
27 
28 namespace TEST {
29 
34  public:
35  // Material properties.
36  MAST::Parameter E; // Modulus of Elasticity
37  MAST::Parameter nu; // Poisson's ratio
38  MAST::Parameter rho; // Density
39  MAST::Parameter alpha; // Coefficient of thermal expansion
40  MAST::Parameter cp; // Specific Heat Capacity
41  MAST::Parameter k; // Thermal Conductivity
42  // Section properties.
43  MAST::Parameter thickness_y; // Section thickness in y-direction
44  MAST::Parameter thickness_z; // Section thickness in z-direction
45  MAST::Parameter offset_y; // Section offset in y-direction
46  MAST::Parameter offset_z; // Section offset in z-direction
47  MAST::Parameter kappa_yy; // Shear coefficient
48  MAST::Parameter kappa_zz; // Shear coefficient
49  // Field functions to distribution parameters throughout model.
62  // Material and property cards.
65  // Data associated with finite element system/assembly and discipline.
66  libMesh::EquationSystems equation_systems;
68  libMesh::FEType fetype;
72  // Data for actual structural element.
74  std::unique_ptr<MAST::StructuralElementBase> elem_base;
76  // Quick reference to element degree of freedom IDs.
77  std::vector<libMesh::dof_id_type> dof_indices;
78  uint n_dofs;
79  // Element states.
82  // Storage for element residual & Jacobian for zero solution.
89 
90  TestStructuralSingleElement1D(libMesh::ElemType e_type, RealMatrixX& coordinates):
91  TestMeshSingleElement(e_type, coordinates),
92  // Initialize material properties to some default values.
93  E("E_param", 72.0e9),
94  nu("nu_param", 0.33),
95  rho("rho_param", 1420.5),
96  alpha("alpha_param", 5.43e-05),
97  cp("cp_param", 908.0),
98  k("k_param", 237.0),
99  // Initialize section properties to some default values.
100  thickness_y("thy_param", 0.06), // Section thickness in y-direction
101  thickness_z("thz_param", 0.04), // Section thickness in z-direction
102  offset_y("offy_param", 0.035), // Section offset in y-direction
103  offset_z("offz_param", 0.026), // Section offset in z-direction
104  kappa_yy("kappa_yy", 5.0/6.0), // Shear coefficient
105  kappa_zz("kappa_zz", 5.0/6.0), // Shear coefficient
106  // Initialize field functions using parameters.
107  E_f("E", E),
108  nu_f("nu", nu),
109  rho_f("rho", rho),
110  alpha_f("alpha_expansion", alpha),
111  cp_f("cp", cp),
112  k_f("k_th", k),
113  thicknessy_f("hy", thickness_y),
114  thicknessz_f("hz", thickness_z),
115  offsety_f("hy_off", offset_y),
116  offsetz_f("hz_off", offset_z),
117  kappa_yy_f("Kappayy", kappa_yy),
118  kappa_zz_f("Kappazz", kappa_zz),
119  // Initialize system/discipline/etc.
120  equation_systems(mesh),
121  system(equation_systems.add_system<MAST::NonlinearSystem>("structural")),
122  fetype(libMesh::FIRST, libMesh::LAGRANGE),
123  structural_system(system, system.name(), fetype),
124  discipline(equation_systems)
125  {
126  // Configure material card.
127  material.add(E_f);
128  material.add(nu_f);
129  material.add(rho_f);
130  material.add(alpha_f);
131  material.add(k_f);
132  material.add(cp_f);
133 
134  // Configure section property card.
135  section.add(thicknessy_f);
136  section.add(offsety_f);
137  section.add(thicknessz_f);
138  section.add(offsetz_f);
139  section.add(kappa_yy_f);
140  section.add(kappa_zz_f);
141  section.set_material(material);
142  RealVectorX orientation = RealVectorX::Zero(3);
143  orientation(1) = 1.0;
144  section.y_vector() = orientation;
145  section.init();
146  discipline.set_property_for_subdomain(0, section);
147 
148  // Setup finite element system and discipline.
149  equation_systems.init();
150  assembly.set_discipline_and_system(discipline, structural_system);
151 
152  // Create the MAST element from the libMesh reference element.
153  geom_elem.init(*reference_elem, structural_system);
154  elem_base = MAST::build_structural_element(structural_system, geom_elem, section);
155  elem = (dynamic_cast<MAST::StructuralElement1D*>(elem_base.get()));
156 
157  // Get element DOFs for easy reference in tests.
158  const libMesh::DofMap& dof_map = assembly.system().get_dof_map();
159  dof_map.dof_indices (reference_elem, dof_indices);
160  n_dofs = uint(dof_indices.size());
161 
162  // Set element's initial solution and solution sensitivity to zero.
163  elem_solution = RealVectorX::Zero(n_dofs);
164  elem->set_solution(elem_solution);
165  elem->set_solution(elem_solution, true);
166 
167  // Set element's initial acceleration and acceleration sensitivity to zero.
168  elem_accel = RealVectorX::Zero(n_dofs);
169  elem->set_acceleration(elem_accel);
170  elem->set_acceleration(elem_accel, true);
171 
172  // Calculate residual and jacobian
173  residual = RealVectorX::Zero(n_dofs);
174  jacobian0 = RealMatrixX::Zero(n_dofs, n_dofs);
175  jacobian_xdot0 = RealMatrixX::Zero(n_dofs, n_dofs);
176  jacobian_xddot0 = RealMatrixX::Zero(n_dofs, n_dofs);
177  jacobian = RealMatrixX::Zero(n_dofs, n_dofs);
178  jacobian_fd = RealMatrixX::Zero(n_dofs, n_dofs);
179 
180  };
181  void update_residual_and_jacobian0() {elem->internal_residual(true, residual, jacobian0);}
182  void update_residual_and_jacobian() {elem->internal_residual(true, residual, jacobian);}
183  void update_inertial_residual_and_jacobian0() {elem->inertial_residual(true, residual, jacobian_xddot0, jacobian_xdot0, jacobian0);}
184 // void update_thermal_residual_and_jacobian0(MAST::BoundaryConditionBase temperature_load)
185 // {
186 // elem->thermal_residual(true, residual, jacobian0, temperature_load);
187 // }
188 
189  };
190 }
191 
192 #endif // MAST_MAST_STRUCTURAL_ELEMENT_1D_H
RealMatrixX jacobian
Matrix storage for Jacobian of the element in a perturbed/modified state.
TestStructuralSingleElement1D(libMesh::ElemType e_type, RealMatrixX &coordinates)
const MAST::NonlinearSystem & system() const
RealMatrixX jacobian_xddot0
Matrix storage for acceleration Jacobian of baseline/undeformed element.
MAST::NonlinearImplicitAssembly assembly
This class implements a system for solution of nonlinear systems.
libMesh::Elem * reference_elem
Pointer to the actual libMesh element object.
Definition: mast_mesh.h:51
Storage class for a mesh consisting of a single element used in testing.
Definition: mast_mesh.h:46
virtual void set_material(MAST::MaterialPropertyCardBase &mat)
sets the material card
virtual void set_acceleration(const RealVectorX &vec, bool if_sens=false)
stores vec as acceleration for element level calculations, or its sensitivity if if_sens is true...
RealVectorX & y_vector()
returns value of the property val.
MAST::Solid1DSectionElementPropertyCard section
This is a scalar function whose value can be changed and one that can be used as a design variable in...
Definition: parameter.h:35
virtual bool inertial_residual(bool request_jacobian, RealVectorX &f, RealMatrixX &jac_xddot, RealMatrixX &jac_xdot, RealMatrixX &jac)
inertial force contribution to system residual
MAST::IsotropicMaterialPropertyCard material
RealMatrixX jacobian_xdot0
Matrix storage for velocity Jacobian of baseline/undeformed element.
void add(MAST::FunctionBase &f)
adds the function to this card and returns a reference to it.
libMesh::LibMeshInit * p_global_init
Definition: init_catch2.cpp:26
RealMatrixX jacobian0
Matrix storage for Jacobian of baseline/undeformed element.
Definition: mast_mesh.h:39
Matrix< Real, Dynamic, Dynamic > RealMatrixX
RealMatrixX jacobian_fd
Matrix storage for element Jacobian approximated by finite difference.
RealVectorX residual
Vector storage for element&#39;s residual vector.
virtual void set_solution(const RealVectorX &vec, bool if_sens=false)
stores vec as solution for element level calculations, or its sensitivity if if_sens is true...
Matrix< Real, Dynamic, 1 > RealVectorX
std::unique_ptr< MAST::StructuralElementBase > build_structural_element(MAST::SystemInitialization &sys, const MAST::GeomElem &elem, const MAST::ElementPropertyCardBase &p)
builds the structural element for the specified element type
MAST::StructuralSystemInitialization structural_system
This class acts as a wrapper around libMesh::Elem for the purpose of providing a uniform interface fo...
Definition: geom_elem.h:59
void set_property_for_subdomain(const libMesh::subdomain_id_type sid, const MAST::ElementPropertyCardBase &prop)
sets the same property for all elements in the specified subdomain
std::vector< libMesh::dof_id_type > dof_indices
virtual void set_discipline_and_system(MAST::PhysicsDisciplineBase &discipline, MAST::SystemInitialization &system)
attaches a system to this discipline
virtual void init(const libMesh::Elem &elem, const MAST::SystemInitialization &sys_init)
initialize the object for the specified reference elem.
Definition: geom_elem.cpp:134
libMesh::ReplicatedMesh mesh
The actual libMesh mesh object.
Definition: mast_mesh.h:52
virtual bool internal_residual(bool request_jacobian, RealVectorX &f, RealMatrixX &jac)
Calculates the internal force vector and Jacobian due to strain energy.
std::unique_ptr< MAST::StructuralElementBase > elem_base