MAST
Multidisciplinary-design Adaptation and Sensitivity Toolkit (MAST)
mast_structural_element_2d.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_2D_H
21 #define MAST_MAST_STRUCTURAL_ELEMENT_2D_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.
42  // Section properties.
46  // Field functions to distribution parameters throughout model.
56  // Material and property cards.
59  // Data associated with finite element system/assembly and discipline.
60  libMesh::EquationSystems equation_systems;
62  libMesh::FEType fetype;
66  // Data for actual structural element.
68  std::unique_ptr<MAST::StructuralElementBase> elem_base;
70  // Quick reference to element degree of freedom IDs.
71  std::vector<libMesh::dof_id_type> dof_indices;
72  uint n_dofs;
73  // Element states.
76  // Storage for element residual & Jacobian for zero solution.
83 
84  TestStructuralSingleElement2D(libMesh::ElemType e_type, RealMatrixX& coordinates):
85  TestMeshSingleElement(e_type, coordinates),
86  // Initialize material properties to some default values.
87  E("E_param", 72.0e9),
88  nu("nu_param", 0.33),
89  rho("rho_param", 1420.5),
90  alpha("alpha_param", 5.43e-05),
91  cp("cp_param", 908.0),
92  k("k_param", 237.0),
93  // Initialize section properties to some default values.
94  thickness("th_param", 0.06),
95  offset("off_param", 0.03),
96  kappa("kappa_param", 5.0/6.0),
97  // Initialize field functions using parameters.
98  E_f("E", E),
99  nu_f("nu", nu),
100  rho_f("rho", rho),
101  alpha_f("alpha_expansion", alpha),
102  cp_f("cp", cp),
103  k_f("k_th", k),
104  thickness_f("h", thickness),
105  offset_f("off", offset),
106  kappa_f("kappa", kappa),
107  // Initialize system/discipline/etc.
108  equation_systems(mesh),
109  system(equation_systems.add_system<MAST::NonlinearSystem>("structural")),
110  fetype(libMesh::FIRST, libMesh::LAGRANGE),
111  structural_system(system, system.name(), fetype),
112  discipline(equation_systems)
113  {
114  // Configure material card.
115  material.add(E_f);
116  material.add(nu_f);
117  material.add(rho_f);
118  material.add(alpha_f);
119  material.add(k_f);
120  material.add(cp_f);
121 
122  // Configure section property card.
123  section.add(thickness_f);
124  section.add(offset_f);
125  section.add(kappa_f);
126  section.set_material(material);
127  discipline.set_property_for_subdomain(0, section);
128 
129  // Setup finite element system and discipline.
130  equation_systems.init();
131  assembly.set_discipline_and_system(discipline, structural_system);
132 
133  // Create the MAST element from the libMesh reference element.
134  geom_elem.init(*reference_elem, structural_system);
135  elem_base = MAST::build_structural_element(structural_system, geom_elem, section);
136  elem = (dynamic_cast<MAST::StructuralElement2D*>(elem_base.get()));
137 
138  // Get element DOFs for easy reference in tests.
139  const libMesh::DofMap& dof_map = assembly.system().get_dof_map();
140  dof_map.dof_indices (reference_elem, dof_indices);
141  n_dofs = uint(dof_indices.size());
142 
143  // Set element's initial solution and solution sensitivity to zero.
144  elem_solution = RealVectorX::Zero(n_dofs);
145  elem->set_solution(elem_solution);
146  elem->set_solution(elem_solution, true);
147 
148  // Set element's initial acceleration and acceleration sensitivity to zero.
149  elem_accel = RealVectorX::Zero(n_dofs);
150  elem->set_acceleration(elem_accel);
151  elem->set_acceleration(elem_accel, true);
152 
153  // Calculate residual and jacobian
154  residual = RealVectorX::Zero(n_dofs);
155  jacobian0 = RealMatrixX::Zero(n_dofs, n_dofs);
156  jacobian_xdot0 = RealMatrixX::Zero(n_dofs, n_dofs);
157  jacobian_xddot0 = RealMatrixX::Zero(n_dofs, n_dofs);
158  jacobian = RealMatrixX::Zero(n_dofs, n_dofs);
159  jacobian_fd = RealMatrixX::Zero(n_dofs, n_dofs);
160  }
161  void update_residual_and_jacobian0() {elem->internal_residual(true, residual, jacobian0);}
162  void update_residual_and_jacobian() {elem->internal_residual(true, residual, jacobian);}
163  void update_inertial_residual_and_jacobian0() {elem->inertial_residual(true, residual, jacobian_xddot0, jacobian_xdot0, jacobian0);}
164  };
165 
166 }
167 
168 #endif //MAST_MAST_STRUCTURAL_ELEMENT_2D_H
MAST::Parameter k
Thermal conductivity.
MAST::Parameter offset
Section offset.
const MAST::NonlinearSystem & system() const
RealVectorX residual
Vector storage for element&#39;s residual vector.
RealMatrixX jacobian
Matrix storage for Jacobian of the element in a perturbed/modified state.
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
RealMatrixX jacobian_xddot0
Matrix storage for acceleration Jacobian of baseline/undeformed element.
Storage class for a mesh consisting of a single element used in testing.
Definition: mast_mesh.h:46
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...
MAST::Parameter cp
Specific heat capacity.
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
MAST::StructuralSystemInitialization structural_system
virtual bool inertial_residual(bool request_jacobian, RealVectorX &f, RealMatrixX &jac_xddot, RealMatrixX &jac_xdot, RealMatrixX &jac)
inertial force contribution to system residual
MAST::Solid2DSectionElementPropertyCard section
RealMatrixX jacobian_xdot0
Matrix storage for velocity Jacobian of baseline/undeformed element.
MAST::Parameter thickness
Section thickness.
MAST::NonlinearImplicitAssembly assembly
MAST::Parameter E
Modulus of Elasticity.
void add(MAST::FunctionBase &f)
adds the function to this card and returns a reference to it.
virtual bool internal_residual(bool request_jacobian, RealVectorX &f, RealMatrixX &jac)
Calculates the internal residual vector and Jacobian due to strain energy.
libMesh::LibMeshInit * p_global_init
Definition: init_catch2.cpp:26
Definition: mast_mesh.h:39
MAST::Parameter nu
Poisson&#39;s ratio.
std::unique_ptr< MAST::StructuralElementBase > elem_base
Matrix< Real, Dynamic, Dynamic > RealMatrixX
TestStructuralSingleElement2D(libMesh::ElemType e_type, RealMatrixX &coordinates)
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...
RealMatrixX jacobian0
Matrix storage for Jacobian of baseline/undeformed element.
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
This class acts as a wrapper around libMesh::Elem for the purpose of providing a uniform interface fo...
Definition: geom_elem.h:59
MAST::Parameter alpha
Coefficient of thermal expansion.
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
MAST::Parameter kappa
Shear coefficient.
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 void set_material(MAST::MaterialPropertyCardBase &mat)
sets the material card
std::vector< libMesh::dof_id_type > dof_indices
RealMatrixX jacobian_fd
Matrix storage for element Jacobian approximated by finite difference.
MAST::IsotropicMaterialPropertyCard material