MAST
multilayer_2d_section_element_property_card.cpp
Go to the documentation of this file.
1 /*
2  * MAST: Multidisciplinary-design Adaptation and Sensitivity Toolkit
3  * Copyright (C) 2013-2019 Manav Bhatia
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 // MAST includes
25 
26 
27 namespace MAST {
28  namespace Multilayer2DSectionProperty {
29 
30 
31  class LayerOffset: public MAST::FieldFunction<Real> {
32  public:
33  LayerOffset(const Real base,
34  unsigned int layer_num,
35  const std::vector<const MAST::FieldFunction<Real>*>& layer_h):
36  MAST::FieldFunction<Real>("off"),
37  _base(base),
38  _layer_num(layer_num),
39  _layer_h(layer_h) {
40  for (unsigned int i=0; i < _layer_h.size(); i++)
41  _functions.insert(_layer_h[i]);
42  }
43 
44 
45  virtual ~LayerOffset() {
46  // delete all the layer functions
47  for (unsigned int i=0; i<_layer_h.size(); i++)
48  delete _layer_h[i];
49  }
50 
51  virtual void operator() (const libMesh::Point& p,
52  const Real t,
53  Real& m) const {
54  Real val = 0.;
55  m = 0.;
56  for (unsigned int i=0; i<_layer_num; i++) {
57  (*_layer_h[i])(p, t, val);
58  m += val; // this calculates offset from h=0, and then it is modified for base
59  }
60  // finally, add half of the current layer thickness
61  (*_layer_h[_layer_num])(p, t, val);
62  m += 0.5*val;
63 
64  // now add the base offset
65  for (unsigned int i=0; i<_layer_h.size(); i++) {
66  (*_layer_h[i])(p, t, val);
67  m -= 0.5*(1.+_base)*val; // currently the offset is chosen from h=0;
68  }
69  }
70 
71 
72  virtual void derivative ( const MAST::FunctionBase& f,
73  const libMesh::Point& p,
74  const Real t,
75  Real& m) const {
76  Real val = 0.;
77  m = 0.;
78  for (unsigned int i=0; i<_layer_num; i++) {
79  _layer_h[i]->derivative( f, p, t, val);
80  m += val; // this calculates offset from h=0, and then it is modified for base
81  }
82  // finally, add half of the current layer thickness
83  _layer_h[_layer_num]->derivative( f, p, t, val);
84  m += 0.5*val;
85 
86  // now add the base offset
87  for (unsigned int i=0; i<_layer_h.size(); i++) {
88  _layer_h[i]->derivative( f, p, t, val);
89  m -= 0.5*(1.+_base)*val; // currently the offset is chosen from h=0;
90  }
91  }
92 
93  protected:
94 
95  const Real _base;
96  const unsigned int _layer_num;
97  const std::vector<const MAST::FieldFunction<Real>*> _layer_h;
98  };
99 
100 
101  class Matrix: public MAST::FieldFunction<RealMatrixX> {
102  public:
103  Matrix(std::vector<MAST::FieldFunction<RealMatrixX>*>& layer_mats):
104  MAST::FieldFunction<RealMatrixX>("Matrix2D"),
105  _layer_mats(layer_mats) {
106  for (unsigned int i=0; i < _layer_mats.size(); i++) {
107  _functions.insert(_layer_mats[i]);
108  }
109  }
110 
111 
112  virtual ~Matrix() {
113  // delete all the layer functions
114  for (unsigned int i=0; i<_layer_mats.size(); i++)
115  delete _layer_mats[i];
116  }
117 
118  virtual void operator() (const libMesh::Point& p,
119  const Real t,
120  RealMatrixX& m) const {
121  // add the values of each matrix to get the integrated value
122  RealMatrixX mi;
123  for (unsigned int i=0; i<_layer_mats.size(); i++) {
124  (*_layer_mats[i])(p, t, mi);
125  // use the size of the layer matrix to resize the output
126  // all other layers should return the same sized matrices
127  if (i==0)
128  m = RealMatrixX::Zero(mi.rows(), mi.cols());
129 
130  m += mi;
131  }
132  }
133 
134 
135  virtual void derivative ( const MAST::FunctionBase& f,
136  const libMesh::Point& p,
137  const Real t,
138  RealMatrixX& m) const {
139  // add the values of each matrix to get the integrated value
140  RealMatrixX mi;
141  m = RealMatrixX::Zero(2,2);
142  for (unsigned int i=0; i<_layer_mats.size(); i++) {
143  _layer_mats[i]->derivative( f, p, t, mi);
144  // use the size of the layer matrix to resize the output
145  // all other layers should return the same sized matrices
146  if (i==0)
147  m = RealMatrixX::Zero(mi.rows(), mi.cols());
148 
149  m += mi;
150  }
151  }
152 
153 
154  protected:
155 
156  std::vector<MAST::FieldFunction<RealMatrixX>*> _layer_mats;
157  };
158 
159 
160  }
161 
162 }
163 
164 
165 
166 
168  // delete the layer offset functions
169  for (unsigned int i=0; i<_layer_offsets.size(); i++)
170  delete _layer_offsets[i];
171 }
172 
173 
174 
175 unsigned int
177  return 2;
178 }
179 
180 
181 
182 
183 void
185 set_layers(const Real base,
186  std::vector<MAST::Solid2DSectionElementPropertyCard*>& layers) {
187 
188  // make sure that this has not been already set
189  libmesh_assert(_layers.size() == 0);
190 
191  // now create the vector of offsets for each later
192  const unsigned n_layers = (unsigned int)layers.size();
193  _layers = layers;
194  _layer_offsets.resize(n_layers);
195 
196 
197  for (unsigned int i=0; i<n_layers; i++) {
198 
199  // offsets to be provided as functions to each layer
200  std::vector<const MAST::FieldFunction<Real>*> layer_h(n_layers);
201  for (unsigned int j=0; j<n_layers; j++)
202  layer_h[j] = &(_layers[j]->get<MAST::FieldFunction<Real> >("h"));
203 
204  // create the offset function
205  _layer_offsets[i] =
207  (base, i, layer_h);
208  // tell the layer about the offset
209  _layers[i]->add(*_layer_offsets[i]);
210  }
211 }
212 
213 
214 
215 const std::vector<MAST::Solid2DSectionElementPropertyCard*>&
217  // make sure they have been set
218  libmesh_assert(_layers.size() > 0);
219  return _layers;
220 }
221 
222 
223 
224 bool
226  return false;
227 }
228 
229 
230 
231 
232 
233 bool
235  // ask each layer for the dependence
236  for (unsigned int i=0; i<_layers.size(); i++)
237  if (_layers[i]->depends_on(f))
238  return true;
239 
240  // ask each offset for the dependence
241  for (unsigned int i=0; i<_layer_offsets.size(); i++)
242  if (_layer_offsets[i]->depends_on(f))
243  return true;
244 
245  // if it gets here, then there is no dependence
246  return false;
247 }
248 
249 
250 
251 std::unique_ptr<MAST::FieldFunction<RealMatrixX> >
254 
255  // prepare vector of matrix functions from each layer
256  std::vector<MAST::FieldFunction<RealMatrixX>*> layer_mats(_layers.size());
257  for (unsigned int i=0; i<_layers.size(); i++)
258  layer_mats[i] = _layers[i]->stiffness_A_matrix(e).release();
259 
260  // now create the integrated object
261  std::unique_ptr<MAST::FieldFunction<RealMatrixX> > rval
263 
264  return rval;
265 }
266 
267 
268 
269 std::unique_ptr<MAST::FieldFunction<RealMatrixX> >
272 
273  // prepare vector of matrix functions from each layer
274  std::vector<MAST::FieldFunction<RealMatrixX>*> layer_mats(_layers.size());
275  for (unsigned int i=0; i<_layers.size(); i++)
276  layer_mats[i] = _layers[i]->stiffness_B_matrix(e).release();
277 
278  // now create the integrated object
279  std::unique_ptr<MAST::FieldFunction<RealMatrixX> > rval
281 
282  return rval;
283 }
284 
285 
286 
287 
288 std::unique_ptr<MAST::FieldFunction<RealMatrixX> >
291 
292  // prepare vector of matrix functions from each layer
293  std::vector<MAST::FieldFunction<RealMatrixX>*> layer_mats(_layers.size());
294  for (unsigned int i=0; i<_layers.size(); i++)
295  layer_mats[i] = _layers[i]->stiffness_D_matrix(e).release();
296 
297  // now create the integrated object
298  std::unique_ptr<MAST::FieldFunction<RealMatrixX> > rval
300 
301  return rval;
302 }
303 
304 
305 
306 std::unique_ptr<MAST::FieldFunction<RealMatrixX> >
309 
310  // prepare vector of matrix functions from each layer
311  std::vector<MAST::FieldFunction<RealMatrixX>*> layer_mats(_layers.size());
312  for (unsigned int i=0; i<_layers.size(); i++)
313  layer_mats[i] = _layers[i]->damping_matrix(e).release();
314 
315  // now create the integrated object
316  std::unique_ptr<MAST::FieldFunction<RealMatrixX> > rval
318 
319  return rval;
320 }
321 
322 
323 
324 std::unique_ptr<MAST::FieldFunction<RealMatrixX> >
327 
328  // prepare vector of matrix functions from each layer
329  std::vector<MAST::FieldFunction<RealMatrixX>*> layer_mats(_layers.size());
330  for (unsigned int i=0; i<_layers.size(); i++)
331  layer_mats[i] = _layers[i]->inertia_matrix(e).release();
332 
333  // now create the integrated object
334  std::unique_ptr<MAST::FieldFunction<RealMatrixX> > rval
336 
337  return rval;
338 }
339 
340 
341 
342 std::unique_ptr<MAST::FieldFunction<RealMatrixX> >
345 
346  // prepare vector of matrix functions from each layer
347  std::vector<MAST::FieldFunction<RealMatrixX>*> layer_mats(_layers.size());
348  for (unsigned int i=0; i<_layers.size(); i++)
349  layer_mats[i] = _layers[i]->thermal_expansion_A_matrix(e).release();
350 
351  // now create the integrated object
352  std::unique_ptr<MAST::FieldFunction<RealMatrixX> > rval
354 
355  return rval;
356 }
357 
358 
359 
360 std::unique_ptr<MAST::FieldFunction<RealMatrixX> >
363 
364  // prepare vector of matrix functions from each layer
365  std::vector<MAST::FieldFunction<RealMatrixX>*> layer_mats(_layers.size());
366  for (unsigned int i=0; i<_layers.size(); i++)
367  layer_mats[i] = _layers[i]->thermal_expansion_B_matrix(e).release();
368 
369  // now create the integrated object
370  std::unique_ptr<MAST::FieldFunction<RealMatrixX> > rval
372 
373  return rval;
374 }
375 
376 
377 
378 std::unique_ptr<MAST::FieldFunction<RealMatrixX> >
381 
382  // prepare vector of matrix functions from each layer
383  std::vector<MAST::FieldFunction<RealMatrixX>*> layer_mats(_layers.size());
384  for (unsigned int i=0; i<_layers.size(); i++)
385  layer_mats[i] = _layers[i]->transverse_shear_stiffness_matrix(e).release();
386 
387  // now create the integrated object
388  std::unique_ptr<MAST::FieldFunction<RealMatrixX> > rval
390 
391  return rval;
392 }
393 
394 
395 
396 
397 std::unique_ptr<MAST::FieldFunction<RealMatrixX> >
400 
401  // prepare vector of matrix functions from each layer
402  std::vector<MAST::FieldFunction<RealMatrixX>*> layer_mats(_layers.size());
403  for (unsigned int i=0; i<_layers.size(); i++)
404  layer_mats[i] = _layers[i]->prestress_A_matrix(e).release();
405 
406  // now create the integrated object
407  std::unique_ptr<MAST::FieldFunction<RealMatrixX> > rval
409 
410  return rval;
411 }
412 
413 
414 
415 std::unique_ptr<MAST::FieldFunction<RealMatrixX> >
418 
419  // prepare vector of matrix functions from each layer
420  std::vector<MAST::FieldFunction<RealMatrixX>*> layer_mats(_layers.size());
421  for (unsigned int i=0; i<_layers.size(); i++)
422  layer_mats[i] = _layers[i]->prestress_B_matrix(e).release();
423 
424  // now create the integrated object
425  std::unique_ptr<MAST::FieldFunction<RealMatrixX> > rval
427 
428  return rval;
429 }
430 
431 
432 
LayerOffset(const Real base, unsigned int layer_num, const std::vector< const MAST::FieldFunction< Real > * > &layer_h)
virtual bool if_isotropic() const
return true if the property is isotropic
const std::vector< MAST::Solid2DSectionElementPropertyCard * > & get_layers() const
returns the layers of this section
std::vector< MAST::FieldFunction< RealMatrixX > * > _layer_mats
virtual std::unique_ptr< MAST::FieldFunction< RealMatrixX > > damping_matrix(const MAST::ElementBase &e)
virtual void operator()(const libMesh::Point &p, const Real t, Real &m) const
calculates the value of the function at the specified point, p, and time, t, and returns it in v...
virtual void derivative(const MAST::FunctionBase &f, const libMesh::Point &p, const Real t, Real &m) const
calculates the value of the derivative of function with respect to the function f at the specified po...
std::set< const MAST::FunctionBase * > _functions
set of functions that this function depends on
Matrix(std::vector< MAST::FieldFunction< RealMatrixX > * > &layer_mats)
virtual unsigned int dim() const
dimension of the element for which this property is defined
void set_layers(const Real base, std::vector< MAST::Solid2DSectionElementPropertyCard * > &layers)
sets the layers of this section.
virtual std::unique_ptr< MAST::FieldFunction< RealMatrixX > > prestress_A_matrix(MAST::ElementBase &e)
libMesh::Real Real
virtual std::unique_ptr< MAST::FieldFunction< RealMatrixX > > thermal_expansion_A_matrix(const MAST::ElementBase &e)
virtual std::unique_ptr< MAST::FieldFunction< RealMatrixX > > prestress_B_matrix(MAST::ElementBase &e)
Matrix< Real, Dynamic, Dynamic > RealMatrixX
virtual bool depends_on(const MAST::FunctionBase &f) const
returns true if the function depends on the provided value
Definition: function_base.h:68
This creates the base class for functions that have a saptial and temporal dependence, and provide sensitivity operations with respect to the functions and parameters.
const std::vector< const MAST::FieldFunction< Real > * > _layer_h
virtual bool depends_on(const MAST::FunctionBase &f) const
returns true if the property card depends on the function f
virtual std::unique_ptr< MAST::FieldFunction< RealMatrixX > > thermal_expansion_B_matrix(const MAST::ElementBase &e)
virtual std::unique_ptr< MAST::FieldFunction< RealMatrixX > > stiffness_D_matrix(const MAST::ElementBase &e)
virtual void derivative(const MAST::FunctionBase &f, const libMesh::Point &p, const Real t, RealMatrixX &m) const
calculates the value of the derivative of function with respect to the function f at the specified po...
virtual std::unique_ptr< MAST::FieldFunction< RealMatrixX > > inertia_matrix(const MAST::ElementBase &e)
virtual std::unique_ptr< MAST::FieldFunction< RealMatrixX > > transverse_shear_stiffness_matrix(const MAST::ElementBase &e)
virtual std::unique_ptr< MAST::FieldFunction< RealMatrixX > > stiffness_A_matrix(const MAST::ElementBase &e)
virtual std::unique_ptr< MAST::FieldFunction< RealMatrixX > > stiffness_B_matrix(const MAST::ElementBase &e)
This is the base class for elements that implement calculation of finite element quantities over the ...
Definition: elem_base.h:72