MAST
Multidisciplinary-design Adaptation and Sensitivity Toolkit (MAST)
beam_bending_evaluation.cpp
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 
21 // BOOST includes
22 #include <boost/test/unit_test.hpp>
23 
24 
25 // MAST includes
26 #include "examples/structural/beam_bending/beam_bending.h"
27 #include "tests/base/check_sensitivity.h"
28 #include "base/nonlinear_system.h"
29 
30 
31 BOOST_FIXTURE_TEST_SUITE (Structural1DBeamBending,
32  MAST::BeamBending)
33 
34 BOOST_AUTO_TEST_CASE (BeamBendingSolution) {
35 
36  const Real
37  tol = 1.e-2;
38 
39  this->init(libMesh::EDGE2, false);
40  this->solve();
41 
42  // check the solution
43  // iterate over each node, and compare the nodal solution with the
44  // expected anlaytical value
45  unsigned int
46  dof_num = 0;
47  libMesh::MeshBase::const_node_iterator
48  it = _mesh->local_nodes_begin(),
49  end = _mesh->local_nodes_end();
50 
51  Real
52  press = (*_press)(),
53  th_y = (*_thy)(),
54  th_z = (*_thz)(),
55  Izz = th_z*pow(th_y,3)/12.,
56  x = 0.,
57  xi = 0.,
58  eta = 0.,
59  Eval = (*_E)(),
60  analytical = 0.,
61  numerical = 0.;
62 
63  // analytical solution to the simply supported problem is
64  // w(x) = p/EI ( x^4/24 - L x^3/12 + L^2 x^2/24)
65  // dwdx(x) = p/EI ( x^3/6 - L x^2/4 + L^2 x/12)
66 
67  for ( ; it!=end; it++) {
68  const libMesh::Node* node = *it;
69  x = (*node)(0);
70 
71  // v-displacement
72  analytical = -press/Eval/Izz*(pow(x,4)/24. -
73  _length*pow(x,3)/12. +
74  pow(_length,2)*pow(x,2)/24.);
75 
76  dof_num = node->dof_number(_sys->number(),
77  _structural_sys->vars()[1], // v-displ.
78  0);
79  numerical = _sys->solution->el(dof_num);
80 
81  BOOST_CHECK(MAST::compare_value(analytical, numerical, tol));
82 
83  // theta-z rotation
84  analytical = -press/Eval/Izz*(pow(x,3)/6. -
85  _length*pow(x,2)/4. +
86  pow(_length,2)*x/12.);
87 
88  dof_num = node->dof_number(_sys->number(),
89  _structural_sys->vars()[5], // tz-rotation
90  0);
91  numerical = _sys->solution->el(dof_num);
92  BOOST_CHECK(MAST::compare_value(analytical, numerical, tol));
93 
94  }
95 
96 
97  // make sure that each stress object has a single stored value
98  for (unsigned int i=0; i<_outputs.size(); i++) {
99  BOOST_CHECK(_outputs[i]->n_elem_in_storage() == 1);
100  }
101 
102  // now check the stress value in each element, which should be the same as
103  // the pressure value specified for the problem
104  for (unsigned int i=0; i<_outputs.size(); i++) {
105 
106  // get the element and the nodes to evaluate the stress
107  const libMesh::Elem& e = **(_outputs[i]->get_elem_subset().begin());
108 
109  const std::vector<MAST::StressStrainOutputBase::Data*>&
110  data = _outputs[i]->get_stress_strain_data_for_elem(&e);
111 
112  // find the location of quadrature point
113  for (unsigned int j=0; j<data.size(); j++) {
114 
115  // logitudinal strain for this location
116  numerical = data[j]->stress()(0);
117 
118  xi = data[j]->point_location_in_element_coordinate()(0);
119  eta = data[j]->point_location_in_element_coordinate()(1);
120 
121  // assuming linear Lagrange interpolation for elements
122  x = e.point(0)(0) * (1.-xi)/2. + e.point(1)(0) * (1.+xi)/2.;
123  // this gives the rotation at this point.
124  analytical = -press/Eval/Izz*(pow(x,2)/2. -
125  _length*x/2. +
126  pow(_length,2)/12.);
127  // use this to evaluate the stress. The stress at both upper and
128  // lower skins is same, but in opposite sign.
129  analytical *= -Eval*th_y*eta/2.;
130 
131  BOOST_CHECK(MAST::compare_value(analytical, numerical, tol));
132  }
133  }
134 
135 }
136 
137 
138 BOOST_AUTO_TEST_CASE (BeamBendingSensitivity) {
139 
140 
141  this->init(libMesh::EDGE2, false);
143 }
144 
145 
146 BOOST_AUTO_TEST_SUITE_END()
147 
BOOST_FIXTURE_TEST_SUITE(Structural1DBeamBending, MAST::BeamBending) BOOST_AUTO_TEST_CASE(BeamBendingSolution)
void check_sensitivity(ValType &v)
BOOST_AUTO_TEST_CASE(BeamBendingSensitivity)
libMesh::Real Real
bool compare_value(const Real v0, const Real v, const Real tol)