MAST
coordinate_base.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 // MAST includes
22 
23 
24 MAST::CoordinateBase::CoordinateBase(const std::string& nm):
26 
27 }
28 
29 
30 
31 void
34  RealMatrixX &mat) const {
35 
36  mat.setZero(6,6);
37 
38  std::vector<std::pair<unsigned int, unsigned int> > ids(6);
39  ids[0] = std::pair<unsigned int, unsigned int>(0,0);
40  ids[1] = std::pair<unsigned int, unsigned int>(1,1);
41  ids[2] = std::pair<unsigned int, unsigned int>(2,2);
42  ids[3] = std::pair<unsigned int, unsigned int>(0,1);
43  ids[4] = std::pair<unsigned int, unsigned int>(1,2);
44  ids[5] = std::pair<unsigned int, unsigned int>(2,0);
45 
46  for (unsigned int i=0; i<6; i++)
47  for (unsigned int j=0; j<3; j++) {
48  // the first three columns of the matrix
49  mat(i,j) =
50  T(ids[j].first, ids[i].first) * T(ids[j].second, ids[i].second);
51  // libMesh::out
52  // << "( " << i << ", " << j << " ): "
53  // << ids[j].first+1 << ids[i].first+1 << " x "
54  // << ids[j].second+1 << ids[i].second+1 << std::endl;
55 
56  // last three columns of the matrix
57  mat(i,j+3) =
58  T(ids[j+3].first, ids[i].first) * T(ids[j+3].second, ids[i].second) +
59  T(ids[j+3].first, ids[i].second) * T(ids[j+3].second, ids[i].first);
60 
61  // libMesh::out
62  // << "( " << i << ", " << j+3 << " ): "
63  // << ids[j+3].first+1 << ids[i].first+1 << " x "
64  // << ids[j+3].second+1 << ids[i].second+1
65  // << " + " << ids[j+3].first+1 << ids[i].second+1 << " x "
66  // << ids[j+3].second+1 << ids[i].first+1 << std::endl;
67  }
68 }
69 
70 
71 
72 void
75  const RealMatrixX& dT,
76  RealMatrixX &mat) const {
77 
78  mat.setZero(6,6);
79 
80  std::vector<std::pair<unsigned int, unsigned int> > ids(6);
81  ids[0] = std::pair<unsigned int, unsigned int>(0,0);
82  ids[1] = std::pair<unsigned int, unsigned int>(1,1);
83  ids[2] = std::pair<unsigned int, unsigned int>(2,2);
84  ids[3] = std::pair<unsigned int, unsigned int>(0,1);
85  ids[4] = std::pair<unsigned int, unsigned int>(1,2);
86  ids[5] = std::pair<unsigned int, unsigned int>(2,0);
87 
88  for (unsigned int i=0; i<6; i++)
89  for (unsigned int j=0; j<3; j++) {
90  // the first three columns of the matrix
91  mat(i,j) =
92  dT(ids[j].first, ids[i].first) * T(ids[j].second, ids[i].second) +
93  T (ids[j].first, ids[i].first) * dT(ids[j].second, ids[i].second);
94 
95  // last three columns of the matrix
96  mat(i,j+3) =
97  dT(ids[j+3].first, ids[i].first) * T(ids[j+3].second, ids[i].second) +
98  T (ids[j+3].first, ids[i].first) * dT(ids[j+3].second, ids[i].second) +
99  dT(ids[j+3].first, ids[i].second) * T(ids[j+3].second, ids[i].first) +
100  T (ids[j+3].first, ids[i].second) * dT(ids[j+3].second, ids[i].first);
101  }
102 }
103 
104 
Matrix< Real, Dynamic, Dynamic > RealMatrixX
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.
void stress_strain_transformation_matrix(const RealMatrixX &T, RealMatrixX &mat) const
prepares the matrix mat that transforms stress and strain tensors represented in a 6x1 vector from th...
void stress_strain_transformation_matrix_sens(const RealMatrixX &T, const RealMatrixX &dT, RealMatrixX &mat) const
CoordinateBase(const std::string &nm)