ug4
math_tensor_functions.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2014-2015: G-CSC, Goethe University Frankfurt
3  * Author: Raphael Prohl
4  *
5  * This file is part of UG4.
6  *
7  * UG4 is free software: you can redistribute it and/or modify it under the
8  * terms of the GNU Lesser General Public License version 3 (as published by the
9  * Free Software Foundation) with the following additional attribution
10  * requirements (according to LGPL/GPL v3 §7):
11  *
12  * (1) The following notice must be displayed in the Appropriate Legal Notices
13  * of covered and combined works: "Based on UG4 (www.ug4.org/license)".
14  *
15  * (2) The following notice must be displayed at a prominent place in the
16  * terminal output of covered works: "Based on UG4 (www.ug4.org/license)".
17  *
18  * (3) The following bibliography is recommended for citation and must be
19  * preserved in all covered files:
20  * "Reiter, S., Vogel, A., Heppner, I., Rupp, M., and Wittum, G. A massively
21  * parallel geometric multigrid solver on hierarchically distributed grids.
22  * Computing and visualization in science 16, 4 (2013), 151-164"
23  * "Vogel, A., Reiter, S., Rupp, M., Nägel, A., and Wittum, G. UG4 -- a novel
24  * flexible software system for simulating pde based models on high performance
25  * computers. Computing and visualization in science 16, 4 (2013), 165-179"
26  *
27  * This program is distributed in the hope that it will be useful,
28  * but WITHOUT ANY WARRANTY; without even the implied warranty of
29  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
30  * GNU Lesser General Public License for more details.
31  */
32 
33 #ifndef __H__UG__COMMON__MATH_TENSOR_FUNCTIONS__
34 #define __H__UG__COMMON__MATH_TENSOR_FUNCTIONS__
35 
36 #include "math_tensor.h"
37 
40 
41 namespace ug{
42 
45 
47 template <std::size_t TDim, std::size_t TDimSQ>
48 void
49 Tens2ToVec(DenseVector<FixedArray1<number, TDimSQ> > &vec, const MathMatrix<TDim, TDim>& tens2);
50 
52 template <std::size_t TDim, std::size_t TDimSQ>
53 void
54 VecToTens2(MathMatrix<TDim, TDim>& tens2, const DenseVector<FixedArray1<number, TDimSQ> > &vec);
55 
58 template <std::size_t TDim, std::size_t TDimSQ>
59 void
60 Tens4ToMat(DenseMatrix<FixedArray2<number, TDimSQ, TDimSQ> > &mat, const MathTensor4<TDim, TDim, TDim, TDim>& tens4);
61 
64 template <std::size_t TDim, std::size_t TDimSQ>
65 void
66 MatToTens4(MathTensor4<TDim, TDim, TDim, TDim>& tens4, const DenseMatrixInverse<FixedArray2<number, TDimSQ, TDimSQ> > &mat);
67 
68 
69 
72 template <std::size_t TDim>
73 void
74 Tens4Add(MathTensor4<TDim, TDim, TDim, TDim>& tens4_out,
75  const MathTensor4<TDim, TDim, TDim, TDim>& tens4a,
76  const MathTensor4<TDim, TDim, TDim, TDim>& tens4b);
77 
80 template <std::size_t TDim>
81 void
82 Tens4Subtract(MathTensor4<TDim, TDim, TDim, TDim>& tens4_out,
83  const MathTensor4<TDim, TDim, TDim, TDim>& tens4a,
84  const MathTensor4<TDim, TDim, TDim, TDim>& tens4b);
85 
86 
87 
90 template <std::size_t TDim>
91 void
92 TransTens4(MathTensor4<TDim, TDim, TDim, TDim>& tens4_out,
93  const MathTensor4<TDim, TDim, TDim, TDim>& tens4);
94 
95 
96 
99 template <std::size_t TDim>
100 void
101 InvertTensor4(MathTensor4<TDim, TDim, TDim, TDim>& tens4_out,
102  const MathTensor4<TDim, TDim, TDim, TDim>& tens4);
103 
108 template <std::size_t TDim>
109 void
110 SolveTensorMatrixEquation(MathMatrix<TDim, TDim>& X,
111  const MathTensor4<TDim, TDim, TDim, TDim>& A,
112  const MathMatrix<TDim, TDim>& rhs);
113 
114 
115 
118 template <std::size_t TDim>
119 void
120 Tens4Contract(MathMatrix<TDim, TDim>& tens2_out,
121  const MathTensor4<TDim, TDim, TDim, TDim>& tens4,
122  const MathMatrix<TDim, TDim>& tens2);
123 
126 template <std::size_t TDim>
127 void
128 Tens4Contract(MathTensor4<TDim, TDim, TDim, TDim>& tens4_out,
129  const MathTensor4<TDim, TDim, TDim, TDim>& tens4a,
130  const MathTensor4<TDim, TDim, TDim, TDim>& tens4b);
131 
134 template <std::size_t TDim>
135 void
136 Tens4Contract(MathTensor4<TDim, TDim, TDim, TDim>& tens4_out,
137  const MathTensor4<TDim, TDim, TDim, TDim>& tens4a,
138  const MathTensor4<TDim, TDim, TDim, TDim>& tens4b,
139  const MathTensor4<TDim, TDim, TDim, TDim>& tens4c);
140 
141 
142 
143 template <std::size_t TDim>
144 void
145 Tens4Zero(MathTensor4<TDim, TDim, TDim, TDim>& tensOut);
146 
148 template <std::size_t TDim>
149 void
150 Tens4Identity(MathTensor4<TDim, TDim, TDim, TDim>& Ident);
151 
153 template <std::size_t TDim>
154 void
155 Tens4IdentitySym(MathTensor4<TDim, TDim, TDim, TDim>& Ident);
156 
157 
158 // end group math_tensor
160 
161 } //end of namespace
162 
163 // include a general, but not very fast implementation of the declared methods above.
165 
166 #endif /* __H__UG__COMMON__MATH_TENSOR_FUNCTIONS__ */
void MatToTens4(MathTensor4< TDim, TDim, TDim, TDim > &tens4, const DenseMatrixInverse< FixedArray2< number, TDimSQ, TDimSQ > > &mat)
Definition: math_tensor_functions_common_impl.hpp:109
void Tens4Contract(MathMatrix< TDim, TDim > &tens2_out, const MathTensor4< TDim, TDim, TDim, TDim > &tens4, const MathMatrix< TDim, TDim > &tens2)
Definition: math_tensor_functions_common_impl.hpp:278
void VecToTens2(MathMatrix< TDim, TDim > &tens2, const DenseVector< FixedArray1< number, TDimSQ > > &vec)
transformation of a vector (R^(dim^2)) into a tensor of rank 2 (R^dim x R^dim)
Definition: math_tensor_functions_common_impl.hpp:70
void Tens4Zero(MathTensor4< TDim, TDim, TDim, TDim > &tensOut)
Definition: math_tensor_functions_common_impl.hpp:364
void Tens4Identity(MathTensor4< TDim, TDim, TDim, TDim > &Ident)
this function computes the 4th order identity tensor
Definition: math_tensor_functions_common_impl.hpp:379
void TransTens4(MathTensor4< TDim, TDim, TDim, TDim > &tens4_out, const MathTensor4< TDim, TDim, TDim, TDim > &tens4)
Definition: math_tensor_functions_common_impl.hpp:183
void InvertTensor4(MathTensor4< TDim, TDim, TDim, TDim > &tens4_out, const MathTensor4< TDim, TDim, TDim, TDim > &tens4)
Definition: math_tensor_functions_common_impl.hpp:205
void SolveTensorMatrixEquation(MathMatrix< TDim, TDim > &X, const MathTensor4< TDim, TDim, TDim, TDim > &A, const MathMatrix< TDim, TDim > &rhs)
Definition: math_tensor_functions_common_impl.hpp:243
void Tens4Add(MathTensor4< TDim, TDim, TDim, TDim > &tens4_out, const MathTensor4< TDim, TDim, TDim, TDim > &tens4a, const MathTensor4< TDim, TDim, TDim, TDim > &tens4b)
Definition: math_tensor_functions_common_impl.hpp:134
void Tens4IdentitySym(MathTensor4< TDim, TDim, TDim, TDim > &Ident)
this function computes the symmetric 4th order identity tensor
Definition: math_tensor_functions_common_impl.hpp:396
void Tens4Subtract(MathTensor4< TDim, TDim, TDim, TDim > &tens4_out, const MathTensor4< TDim, TDim, TDim, TDim > &tens4a, const MathTensor4< TDim, TDim, TDim, TDim > &tens4b)
Definition: math_tensor_functions_common_impl.hpp:158
void Tens4ToMat(DenseMatrix< FixedArray2< number, TDimSQ, TDimSQ > > &mat, const MathTensor4< TDim, TDim, TDim, TDim > &tens4)
Definition: math_tensor_functions_common_impl.hpp:88
void Tens2ToVec(DenseVector< FixedArray1< number, TDimSQ > > &vec, const MathMatrix< TDim, TDim > &tens2)
transformation of a tensor of rank 2 (R^dim x R^dim) into a vector (R^(dim^2))
Definition: math_tensor_functions_common_impl.hpp:53
the ug namespace