OGS
Tensor.h
Go to the documentation of this file.
1/*
2 * \file
3 * \copyright
4 * Copyright (c) 2012-2024, OpenGeoSys Community (http://www.opengeosys.org)
5 * Distributed under a Modified BSD License.
6 * See accompanying file LICENSE.txt or
7 * http://www.opengeosys.org/project/license
8 */
9
10#pragma once
11
12#include <Eigen/Core>
13
15
16namespace MaterialPropertyLib
17{
19constexpr int tensorSize(int dim)
20{
21 if (dim == 1)
22 {
23 return 3; // Diagonal entries.
24 }
25 if (dim == 2)
26 {
27 return 5; // 2x2 matrix and the 3rd diagonal entry.
28 }
29 if (dim == 3)
30 {
31 return 9; // Full 3x3 matrix.
32 }
33 OGS_FATAL("Tensor size for dimension {} is not defined.", dim);
34}
35
51template <int Dim>
52using Tensor = Eigen::Matrix<double, tensorSize(Dim), 1>;
53
54} // namespace MaterialPropertyLib
#define OGS_FATAL(...)
Definition Error.h:26
Eigen::Matrix< double, tensorSize(Dim), 1 > Tensor
Definition Tensor.h:52
constexpr int tensorSize(int dim)
See Tensor type for details.
Definition Tensor.h:19