MAST
multilayer_1d_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 Multilayer1DSectionProperty {
29 
30  class LayerOffset: public MAST::FieldFunction<Real> {
31  public:
32  LayerOffset(const Real base,
33  unsigned int layer_num,
34  const std::vector<const MAST::FieldFunction<Real>*>& layer_hz):
35  MAST::FieldFunction<Real>("hz_offset"),
36  _base(base),
37  _layer_num(layer_num),
38  _layer_hz(layer_hz) {
39  for (unsigned int i=0; i < _layer_hz.size(); i++)
40  _functions.insert(_layer_hz[i]);
41  }
42 
43  virtual ~LayerOffset() {
44  // delete all the layer functions
45  for (unsigned int i=0; i<_layer_hz.size(); i++)
46  delete _layer_hz[i];
47  }
48 
49  virtual void operator() (const libMesh::Point& p,
50  const Real t,
51  Real& m) const {
52  Real val = 0.;
53  m = 0.;
54  for (unsigned int i=0; i<_layer_num; i++) {
55  (*_layer_hz[i])(p, t, val);
56  m += val; // currently the offset is chosen from h=0;
57  }
58  // finally, add half of the current layer thickness
59  (*_layer_hz[_layer_num])(p, t, val);
60  m += 0.5*val;
61 
62  // now add the base offset
63  for (unsigned int i=0; i<_layer_hz.size(); i++) {
64  (*_layer_hz[i])(p, t, val);
65  m -= 0.5*(1.+_base)*val; // currently the offset is chosen from h=0;
66  }
67  }
68 
69 
70  virtual void derivative ( const MAST::FunctionBase& f,
71  const libMesh::Point& p,
72  const Real t,
73  Real& m) const {
74  Real val = 0.;
75  m = 0.;
76  for (unsigned int i=0; i<_layer_num; i++) {
77  _layer_hz[i]->derivative( f, p, t, val);
78  m += val; // currently the offset is chosen from h=0;
79  }
80  // finally, add half of the current layer thickness
81  _layer_hz[_layer_num]->derivative( f, p, t, val);
82  m += 0.5*val;
83 
84  // now add the base offset
85  for (unsigned int i=0; i<_layer_hz.size(); i++) {
86  _layer_hz[i]->derivative( f, p, t, val);
87  m -= 0.5*(1.+_base)*val; // currently the offset is chosen from h=0;
88  }
89  }
90 
91  protected:
92 
93  const Real _base;
94  const unsigned int _layer_num;
95  const std::vector<const MAST::FieldFunction<Real>*> _layer_hz;
96  };
97 
98 
99 
100 
101 
102  class Matrix: public MAST::FieldFunction<RealMatrixX> {
103  public:
104  Matrix(std::vector<MAST::FieldFunction<RealMatrixX>*>& layer_mats):
105  MAST::FieldFunction<RealMatrixX>("Matrix1D"),
106  _layer_mats(layer_mats) {
107  for (unsigned int i=0; i < _layer_mats.size(); i++) {
108  _functions.insert(_layer_mats[i]);
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  for (unsigned int i=0; i<_layer_mats.size(); i++) {
142  _layer_mats[i]->derivative( f, p, t, mi);
143  // use the size of the layer matrix to resize the output
144  // all other layers should return the same sized matrices
145  if (i==0)
146  m = RealMatrixX::Zero(mi.rows(), mi.cols());
147 
148  m += mi;
149  }
150  }
151 
152 
153  protected:
154 
155  std::vector<MAST::FieldFunction<RealMatrixX>*> _layer_mats;
156  };
157  }
158 }
159 
160 
161 
162 
164 
165  // delete the layer offset functions
166  for (unsigned int i=0; i<_layer_offsets.size(); i++)
167  delete _layer_offsets[i];
168 }
169 
170 
171 
172 void
174 set_layers(const Real base,
175  std::vector<MAST::Solid1DSectionElementPropertyCard*>& layers) {
176 
177  // make sure that this has not been already set
178  libmesh_assert(_layers.size() == 0);
179 
180  // now create the vector of offsets for each later
181  const unsigned n_layers = (unsigned int)layers.size();
182  _layers = layers;
183  _layer_offsets.resize(n_layers);
184 
185 
186  for (unsigned int i=0; i<n_layers; i++) {
187 
188  // offsets to be provided as functions to each layer
189  std::vector<const MAST::FieldFunction<Real>*> layer_hz(n_layers);
190  for (unsigned int j=0; j<n_layers; j++)
191  layer_hz[j] =
192  &(_layers[j]->get<MAST::FieldFunction<Real> >("hz"));
193 
194  // create the offset function
195  _layer_offsets[i] =
197  (base, i, layer_hz);
198  // tell the layer about the offset
199  _layers[i]->add(*_layer_offsets[i]);
200  }
201 }
202 
203 
204 
205 
206 const std::vector<MAST::Solid1DSectionElementPropertyCard*>&
208  // make sure they have been set
209  libmesh_assert(_layers.size() > 0);
210  return _layers;
211 }
212 
213 
214 
215 
216 bool
218  return false;
219 }
220 
221 
222 
223 
224 
225 bool
227 
228  // ask each layer for the dependence
229  for (unsigned int i=0; i<_layers.size(); i++)
230  if (_layers[i]->depends_on(f))
231  return true;
232 
233  // ask each offset for the dependence
234  for (unsigned int i=0; i<_layer_offsets.size(); i++)
235  if (_layer_offsets[i]->depends_on(f))
236  return true;
237 
238  // if it gets here, then there is no dependence
239  return false;
240 }
241 
242 
243 
244 std::unique_ptr<MAST::FieldFunction<RealMatrixX> >
247 
248  // prepare vector of matrix functions from each layer
249  std::vector<MAST::FieldFunction<RealMatrixX>*> layer_mats(_layers.size());
250  for (unsigned int i=0; i<_layers.size(); i++)
251  layer_mats[i] = _layers[i]->stiffness_A_matrix(e).release();
252 
253  // now create the integrated object
254  std::unique_ptr<MAST::FieldFunction<RealMatrixX> > rval
256  (layer_mats));
257 
258  return rval;
259 }
260 
261 
262 
263 std::unique_ptr<MAST::FieldFunction<RealMatrixX> >
266 
267  // prepare vector of matrix functions from each layer
268  std::vector<MAST::FieldFunction<RealMatrixX>*> layer_mats(_layers.size());
269  for (unsigned int i=0; i<_layers.size(); i++)
270  layer_mats[i] = _layers[i]->stiffness_B_matrix(e).release();
271 
272  // now create the integrated object
273  std::unique_ptr<MAST::FieldFunction<RealMatrixX> > rval
275  (layer_mats));
276 
277  return rval;
278 }
279 
280 
281 
282 std::unique_ptr<MAST::FieldFunction<RealMatrixX> >
285 
286  // prepare vector of matrix functions from each layer
287  std::vector<MAST::FieldFunction<RealMatrixX>*> layer_mats(_layers.size());
288  for (unsigned int i=0; i<_layers.size(); i++)
289  layer_mats[i] = _layers[i]->stiffness_D_matrix(e).release();
290 
291  // now create the integrated object
292  std::unique_ptr<MAST::FieldFunction<RealMatrixX> > rval
294  (layer_mats));
295 
296  return rval;
297 }
298 
299 
300 
301 std::unique_ptr<MAST::FieldFunction<RealMatrixX> >
304 
305  // prepare vector of matrix functions from each layer
306  std::vector<MAST::FieldFunction<RealMatrixX>*> layer_mats(_layers.size());
307  for (unsigned int i=0; i<_layers.size(); i++)
308  layer_mats[i] = _layers[i]->damping_matrix(e).release();
309 
310  // now create the integrated object
311  std::unique_ptr<MAST::FieldFunction<RealMatrixX> > rval
313  (layer_mats));
314 
315  return rval;
316 }
317 
318 
319 
320 std::unique_ptr<MAST::FieldFunction<RealMatrixX> >
323 
324  // prepare vector of matrix functions from each layer
325  std::vector<MAST::FieldFunction<RealMatrixX>*> layer_mats(_layers.size());
326  for (unsigned int i=0; i<_layers.size(); i++)
327  layer_mats[i] = _layers[i]->inertia_matrix(e).release();
328 
329  // now create the integrated object
330  std::unique_ptr<MAST::FieldFunction<RealMatrixX> > rval
332  (layer_mats));
333 
334  return rval;
335 }
336 
337 
338 
339 std::unique_ptr<MAST::FieldFunction<RealMatrixX> >
342 
343  // prepare vector of matrix functions from each layer
344  std::vector<MAST::FieldFunction<RealMatrixX>*> layer_mats(_layers.size());
345  for (unsigned int i=0; i<_layers.size(); i++)
346  layer_mats[i] = _layers[i]->thermal_expansion_A_matrix(e).release();
347 
348  // now create the integrated object
349  std::unique_ptr<MAST::FieldFunction<RealMatrixX> > rval
351  (layer_mats));
352 
353  return rval;
354 }
355 
356 
357 
358 std::unique_ptr<MAST::FieldFunction<RealMatrixX> >
361 
362  // prepare vector of matrix functions from each layer
363  std::vector<MAST::FieldFunction<RealMatrixX>*> layer_mats(_layers.size());
364  for (unsigned int i=0; i<_layers.size(); i++)
365  layer_mats[i] = _layers[i]->thermal_expansion_B_matrix(e).release();
366 
367  // now create the integrated object
368  std::unique_ptr<MAST::FieldFunction<RealMatrixX> > rval
370  (layer_mats));
371 
372  return rval;
373 }
374 
375 
376 
377 std::unique_ptr<MAST::FieldFunction<RealMatrixX> >
380 
381  // prepare vector of matrix functions from each layer
382  std::vector<MAST::FieldFunction<RealMatrixX>*> layer_mats(_layers.size());
383  for (unsigned int i=0; i<_layers.size(); i++)
384  layer_mats[i] = _layers[i]->transverse_shear_stiffness_matrix(e).release();
385 
386  // now create the integrated object
387  std::unique_ptr<MAST::FieldFunction<RealMatrixX> > rval
389  (layer_mats));
390 
391  return rval;
392 }
393 
394 
395 
396 std::unique_ptr<MAST::FieldFunction<RealMatrixX> >
399 
400  // prepare vector of matrix functions from each layer
401  std::vector<MAST::FieldFunction<RealMatrixX>*> layer_mats(_layers.size());
402  for (unsigned int i=0; i<_layers.size(); i++)
403  layer_mats[i] = _layers[i]->prestress_A_matrix(e).release();
404 
405  // now create the integrated object
406  std::unique_ptr<MAST::FieldFunction<RealMatrixX> > rval
408  (layer_mats));
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  (layer_mats));
428 
429  return rval;
430 }
431 
432 
433 
434 
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 > > damping_matrix(const MAST::ElementBase &e)
virtual bool if_isotropic() const
return true if the property is isotropic
virtual std::unique_ptr< MAST::FieldFunction< RealMatrixX > > stiffness_D_matrix(const MAST::ElementBase &e)
LayerOffset(const Real base, unsigned int layer_num, const std::vector< const MAST::FieldFunction< Real > * > &layer_hz)
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 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 std::unique_ptr< MAST::FieldFunction< RealMatrixX > > inertia_matrix(const MAST::ElementBase &e)
std::set< const MAST::FunctionBase * > _functions
set of functions that this function depends on
const std::vector< const MAST::FieldFunction< Real > * > _layer_hz
libMesh::Real Real
Matrix(std::vector< MAST::FieldFunction< RealMatrixX > * > &layer_mats)
Matrix< Real, Dynamic, Dynamic > RealMatrixX
std::vector< MAST::FieldFunction< RealMatrixX > * > _layer_mats
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.
virtual std::unique_ptr< MAST::FieldFunction< RealMatrixX > > prestress_A_matrix(MAST::ElementBase &e)
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...
virtual std::unique_ptr< MAST::FieldFunction< RealMatrixX > > thermal_expansion_A_matrix(const MAST::ElementBase &e)
virtual std::unique_ptr< MAST::FieldFunction< RealMatrixX > > stiffness_B_matrix(const MAST::ElementBase &e)
const std::vector< MAST::Solid1DSectionElementPropertyCard * > & get_layers() const
returns the layers of this section
virtual std::unique_ptr< MAST::FieldFunction< RealMatrixX > > prestress_B_matrix(MAST::ElementBase &e)
virtual std::unique_ptr< MAST::FieldFunction< RealMatrixX > > transverse_shear_stiffness_matrix(const MAST::ElementBase &e)
void set_layers(const Real base, std::vector< MAST::Solid1DSectionElementPropertyCard * > &layers)
sets the layers of this section.
virtual std::unique_ptr< MAST::FieldFunction< RealMatrixX > > stiffness_A_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