Reference documentation for deal.II version 9.3.3
\(\newcommand{\dealvcentcolon}{\mathrel{\mathop{:}}}\) \(\newcommand{\dealcoloneq}{\dealvcentcolon\mathrel{\mkern-1.2mu}=}\) \(\newcommand{\jump}[1]{\left[\!\left[ #1 \right]\!\right]}\) \(\newcommand{\average}[1]{\left\{\!\left\{ #1 \right\}\!\right\}}\)
transformations.h
Go to the documentation of this file.
1// ---------------------------------------------------------------------
2//
3// Copyright (C) 2016 - 2021 by the deal.II authors
4//
5// This file is part of the deal.II library.
6//
7// The deal.II library is free software; you can use it, redistribute
8// it, and/or modify it under the terms of the GNU Lesser General
9// Public License as published by the Free Software Foundation; either
10// version 2.1 of the License, or (at your option) any later version.
11// The full text of the license can be found in the file LICENSE.md at
12// the top level directory of deal.II.
13//
14// ---------------------------------------------------------------------
15
16#ifndef dealii_transformations_h
17#define dealii_transformations_h
18
19#include <deal.II/base/config.h>
20
21#include <deal.II/base/point.h>
23#include <deal.II/base/tensor.h>
24
26
27
28namespace Physics
29{
30 namespace Transformations
31 {
36 namespace Rotations
37 {
42
58 template <typename Number>
60 rotation_matrix_2d(const Number &angle);
61
62
91 template <typename Number>
93 rotation_matrix_3d(const Point<3, Number> &axis, const Number &angle);
94
96
97 } // namespace Rotations
98
115 namespace Contravariant
116 {
121
135 template <int dim, typename Number>
139
154 template <int dim, typename Number>
158
174 template <int dim, typename Number>
177 const Tensor<2, dim, Number> & F);
178
193 template <int dim, typename Number>
197
213 template <int dim, typename Number>
216 const Tensor<2, dim, Number> & F);
217
219
224
238 template <int dim, typename Number>
242
257 template <int dim, typename Number>
261
276 template <int dim, typename Number>
279 const Tensor<2, dim, Number> & F);
280
295 template <int dim, typename Number>
299
314 template <int dim, typename Number>
317 const Tensor<2, dim, Number> & F);
318
320 } // namespace Contravariant
321
340 namespace Covariant
341 {
346
360 template <int dim, typename Number>
364
379 template <int dim, typename Number>
383
399 template <int dim, typename Number>
402 const Tensor<2, dim, Number> & F);
403
418 template <int dim, typename Number>
422
438 template <int dim, typename Number>
441 const Tensor<2, dim, Number> & F);
442
444
449
463 template <int dim, typename Number>
467
482 template <int dim, typename Number>
486
501 template <int dim, typename Number>
504 const Tensor<2, dim, Number> & F);
505
520 template <int dim, typename Number>
524
539 template <int dim, typename Number>
542 const Tensor<2, dim, Number> & F);
543
545 } // namespace Covariant
546
552 namespace Piola
553 {
558
574 template <int dim, typename Number>
578
594 template <int dim, typename Number>
598
615 template <int dim, typename Number>
618 const Tensor<2, dim, Number> & F);
619
636 template <int dim, typename Number>
640
658 template <int dim, typename Number>
661 const Tensor<2, dim, Number> & F);
662
664
669
685 template <int dim, typename Number>
689
705 template <int dim, typename Number>
709
725 template <int dim, typename Number>
728 const Tensor<2, dim, Number> & F);
729
746 template <int dim, typename Number>
750
767 template <int dim, typename Number>
770 const Tensor<2, dim, Number> & F);
771
773 } // namespace Piola
774
779
802 template <int dim, typename Number>
806
808
813
824 template <int dim, typename Number>
827 const Tensor<2, dim, Number> &B);
828
840 template <int dim, typename Number>
843 const Tensor<2, dim, Number> &B);
844
856 template <int dim, typename Number>
859 const Tensor<2, dim, Number> & B);
860
871 template <int dim, typename Number>
874 const Tensor<2, dim, Number> &B);
875
887 template <int dim, typename Number>
890 const Tensor<2, dim, Number> & B);
891
893
894 } // namespace Transformations
895} // namespace Physics
896
897
898
899#ifndef DOXYGEN
900
901
902
903template <typename Number>
906{
907 const Number rotation[2][2] = {{std::cos(angle), -std::sin(angle)},
909 return Tensor<2, 2>(rotation);
910}
911
912
913
914template <typename Number>
917 const Point<3, Number> &axis,
918 const Number & angle)
919{
920 Assert(std::abs(axis.norm() - 1.0) < 1e-9,
921 ExcMessage("The supplied axial vector is not a unit vector."));
922 const Number c = std::cos(angle);
923 const Number s = std::sin(angle);
924 const Number t = 1. - c;
925 const Number rotation[3][3] = {{t * axis[0] * axis[0] + c,
926 t * axis[0] * axis[1] - s * axis[2],
927 t * axis[0] * axis[2] + s * axis[1]},
928 {t * axis[0] * axis[1] + s * axis[2],
929 t * axis[1] * axis[1] + c,
930 t * axis[1] * axis[2] - s * axis[0]},
931 {t * axis[0] * axis[2] - s * axis[1],
932 t * axis[1] * axis[2] + s * axis[0],
933 t * axis[2] * axis[2] + c}};
934 return Tensor<2, 3, Number>(rotation);
935}
936
937
938
939template <int dim, typename Number>
944{
946}
947
948
949
950template <int dim, typename Number>
955{
957}
958
959
960
961template <int dim, typename Number>
966{
968}
969
970
971
972template <int dim, typename Number>
975 const Tensor<4, dim, Number> &H,
977{
979}
980
981
982
983template <int dim, typename Number>
988{
990}
991
992
993
994template <int dim, typename Number>
997 const Tensor<1, dim, Number> &v,
999{
1001}
1002
1003
1004
1005template <int dim, typename Number>
1008 const Tensor<2, dim, Number> &t,
1010{
1012}
1013
1014
1015
1016template <int dim, typename Number>
1020 const Tensor<2, dim, Number> & F)
1021{
1023}
1024
1025
1026
1027template <int dim, typename Number>
1030 const Tensor<4, dim, Number> &h,
1032{
1034}
1035
1036
1037
1038template <int dim, typename Number>
1042 const Tensor<2, dim, Number> & F)
1043{
1045}
1046
1047
1048
1049template <int dim, typename Number>
1054{
1056 transpose(invert(F)));
1057}
1058
1059
1060
1061template <int dim, typename Number>
1066{
1068 transpose(invert(F)));
1069}
1070
1071
1072
1073template <int dim, typename Number>
1077 const Tensor<2, dim, Number> & F)
1078{
1080 transpose(invert(F)));
1081}
1082
1083
1084
1085template <int dim, typename Number>
1088 const Tensor<4, dim, Number> &H,
1090{
1092 transpose(invert(F)));
1093}
1094
1095
1096
1097template <int dim, typename Number>
1101 const Tensor<2, dim, Number> & F)
1102{
1104 transpose(invert(F)));
1105}
1106
1107
1108
1109template <int dim, typename Number>
1113{
1115}
1116
1117
1118
1119template <int dim, typename Number>
1123{
1125}
1126
1127
1128
1129template <int dim, typename Number>
1133 const Tensor<2, dim, Number> & F)
1134{
1136}
1137
1138
1139
1140template <int dim, typename Number>
1144{
1146}
1147
1148
1149
1150template <int dim, typename Number>
1154 const Tensor<2, dim, Number> & F)
1155{
1157}
1158
1159
1160
1161template <int dim, typename Number>
1165{
1166 return Number(1.0 / determinant(F)) * Contravariant::push_forward(V, F);
1167}
1168
1169
1170
1171template <int dim, typename Number>
1175{
1176 return Number(1.0 / determinant(F)) * Contravariant::push_forward(T, F);
1177}
1178
1179
1180
1181template <int dim, typename Number>
1185 const Tensor<2, dim, Number> & F)
1186{
1187 return Number(1.0 / determinant(F)) * Contravariant::push_forward(T, F);
1188}
1189
1190
1191
1192template <int dim, typename Number>
1196{
1197 return Number(1.0 / determinant(F)) * Contravariant::push_forward(H, F);
1198}
1199
1200
1201
1202template <int dim, typename Number>
1206 const Tensor<2, dim, Number> & F)
1207{
1208 return Number(1.0 / determinant(F)) * Contravariant::push_forward(H, F);
1209}
1210
1211
1212
1213template <int dim, typename Number>
1217{
1218 return Number(determinant(F)) * Contravariant::pull_back(v, F);
1219}
1220
1221
1222
1223template <int dim, typename Number>
1227{
1228 return Number(determinant(F)) * Contravariant::pull_back(t, F);
1229}
1230
1231
1232
1233template <int dim, typename Number>
1237 const Tensor<2, dim, Number> & F)
1238{
1239 return Number(determinant(F)) * Contravariant::pull_back(t, F);
1240}
1241
1242
1243
1244template <int dim, typename Number>
1248{
1249 return Number(determinant(F)) * Contravariant::pull_back(h, F);
1250}
1251
1252
1253
1254template <int dim, typename Number>
1258 const Tensor<2, dim, Number> & F)
1259{
1260 return Number(determinant(F)) * Contravariant::pull_back(h, F);
1261}
1262
1263
1264
1265template <int dim, typename Number>
1269{
1270 return cofactor(F) * N;
1271}
1272
1273
1274template <int dim, typename Number>
1277 const Tensor<2, dim, Number> &B)
1278{
1279 return contract<1, 0>(B, V);
1280}
1281
1282
1283
1284template <int dim, typename Number>
1287 const Tensor<2, dim, Number> &B)
1288{
1289 return contract<1, 0>(B, contract<1, 1>(T, B));
1290}
1291
1292
1293
1294template <int dim, typename Number>
1298 const Tensor<2, dim, Number> & B)
1299{
1301 for (unsigned int i = 0; i < dim; ++i)
1302 for (unsigned int J = 0; J < dim; ++J)
1303 // Loop over I but complex.h defines a macro I, so use I_ instead
1304 for (unsigned int I_ = 0; I_ < dim; ++I_)
1305 tmp_1[i][J] += B[i][I_] * T[I_][J];
1306
1308 for (unsigned int i = 0; i < dim; ++i)
1309 for (unsigned int j = i; j < dim; ++j)
1310 for (unsigned int J = 0; J < dim; ++J)
1311 out[i][j] += B[j][J] * tmp_1[i][J];
1312
1313 return out;
1314}
1315
1316
1317
1318template <int dim, typename Number>
1321 const Tensor<2, dim, Number> &B)
1322{
1323 // This contraction order and indexing might look a bit dubious, so a
1324 // quick explanation as to what's going on is probably in order:
1325 //
1326 // When the contract() function operates on the inner indices, the
1327 // result has the inner index and outer index transposed, i.e.
1328 // contract<2,1>(H,F) implies
1329 // T_{IJLk} = (H_{IJMN} F_{mM}) \delta_{mL} \delta_{Nk}
1330 // rather than T_{IJkL} (the desired result).
1331 // So, in effect, contraction of the 3rd (inner) index with F as the
1332 // second argument results in its transposition with respect to its
1333 // adjacent neighbor. This is due to the position of the argument F,
1334 // leading to the free index being on the right hand side of the result.
1335 // However, given that we can do two transformations from the LHS of H
1336 // and two from the right we can undo the otherwise erroneous
1337 // swapping of the outer indices upon application of the second
1338 // sets of contractions.
1339 //
1340 // Note: Its significantly quicker (in 3d) to push forward
1341 // each index individually
1342 return contract<1, 1>(
1343 B, contract<1, 1>(B, contract<2, 1>(contract<2, 1>(H, B), B)));
1344}
1345
1346
1347
1348template <int dim, typename Number>
1352 const Tensor<2, dim, Number> & B)
1353{
1354 // The first and last transformation operations respectively
1355 // break and recover the symmetry properties of the tensors.
1356 // We also want to perform a minimal number of operations here
1357 // and avoid some complications related to the transposition of
1358 // tensor indices when contracting inner indices using the contract()
1359 // function. (For an explanation of the contraction operations,
1360 // please see the note in the equivalent function for standard
1361 // Tensors.) So what we'll do here is manually perform the first
1362 // and last contractions that break/recover the tensor symmetries
1363 // on the inner indices, and use the contract() function only on
1364 // the outer indices.
1365 //
1366 // Note: Its significantly quicker (in 3d) to push forward
1367 // each index individually
1368
1369 // Push forward (inner) index 1
1371 // Loop over I but complex.h defines a macro I, so use I_ instead
1372 for (unsigned int I_ = 0; I_ < dim; ++I_)
1373 for (unsigned int j = 0; j < dim; ++j)
1374 for (unsigned int K = 0; K < dim; ++K)
1375 for (unsigned int L = 0; L < dim; ++L)
1376 for (unsigned int J = 0; J < dim; ++J)
1377 tmp[I_][j][K][L] += B[j][J] * H[I_][J][K][L];
1378
1379 // Push forward (outer) indices 0 and 3
1380 tmp = contract<1, 0>(B, contract<3, 1>(tmp, B));
1381
1382 // Push forward (inner) index 2
1384 for (unsigned int i = 0; i < dim; ++i)
1385 for (unsigned int j = i; j < dim; ++j)
1386 for (unsigned int k = 0; k < dim; ++k)
1387 for (unsigned int l = k; l < dim; ++l)
1388 for (unsigned int K = 0; K < dim; ++K)
1389 out[i][j][k][l] += B[k][K] * tmp[i][j][K][l];
1390
1391 return out;
1392}
1393
1394#endif // DOXYGEN
1395
1397
1398#endif
DerivativeForm< 1, spacedim, dim, Number > transpose(const DerivativeForm< 1, dim, spacedim, Number > &DF)
Definition: point.h:111
constexpr SymmetricTensor< 2, dim, Number > invert(const SymmetricTensor< 2, dim, Number > &t)
constexpr Number determinant(const SymmetricTensor< 2, dim, Number > &t)
Definition: tensor.h:472
constexpr Tensor< 2, dim, Number > cofactor(const Tensor< 2, dim, Number > &t)
Definition: tensor.h:2830
numbers::NumberTraits< Number >::real_type norm() const
#define DEAL_II_NAMESPACE_OPEN
Definition: config.h:402
#define DEAL_II_NAMESPACE_CLOSE
Definition: config.h:403
const double angle
#define Assert(cond, exc)
Definition: exceptions.h:1465
static ::ExceptionBase & ExcMessage(std::string arg1)
static const char L
static const char T
static const char N
static const char V
SymmetricTensor< 2, dim, Number > e(const Tensor< 2, dim, Number > &F)
Tensor< 2, dim, Number > l(const Tensor< 2, dim, Number > &F, const Tensor< 2, dim, Number > &dF_dt)
Tensor< 2, dim, Number > F(const Tensor< 2, dim, Number > &Grad_u)
Tensor< 1, dim, Number > pull_back(const Tensor< 1, dim, Number > &v, const Tensor< 2, dim, Number > &F)
Tensor< 1, dim, Number > push_forward(const Tensor< 1, dim, Number > &V, const Tensor< 2, dim, Number > &F)
Tensor< 1, dim, Number > push_forward(const Tensor< 1, dim, Number > &V, const Tensor< 2, dim, Number > &F)
Tensor< 1, dim, Number > pull_back(const Tensor< 1, dim, Number > &v, const Tensor< 2, dim, Number > &F)
SymmetricTensor< 4, dim, Number > pull_back(const SymmetricTensor< 4, dim, Number > &h, const Tensor< 2, dim, Number > &F)
SymmetricTensor< 4, dim, Number > push_forward(const SymmetricTensor< 4, dim, Number > &H, const Tensor< 2, dim, Number > &F)
Tensor< 1, dim, Number > push_forward(const Tensor< 1, dim, Number > &V, const Tensor< 2, dim, Number > &F)
Tensor< 1, dim, Number > pull_back(const Tensor< 1, dim, Number > &v, const Tensor< 2, dim, Number > &F)
Tensor< 2, 3, Number > rotation_matrix_3d(const Point< 3, Number > &axis, const Number &angle)
Tensor< 2, 2, Number > rotation_matrix_2d(const Number &angle)
Tensor< 1, dim, Number > nansons_formula(const Tensor< 1, dim, Number > &N, const Tensor< 2, dim, Number > &F)
Tensor< 1, dim, Number > basis_transformation(const Tensor< 1, dim, Number > &V, const Tensor< 2, dim, Number > &B)
::VectorizedArray< Number, width > cos(const ::VectorizedArray< Number, width > &)
::VectorizedArray< Number, width > sin(const ::VectorizedArray< Number, width > &)
::VectorizedArray< Number, width > abs(const ::VectorizedArray< Number, width > &)