OGS
Tensor.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright (c) OpenGeoSys Community (opengeosys.org)
2// SPDX-License-Identifier: BSD-3-Clause
3
4#pragma once
5
6#include <Eigen/Core>
7
9
10namespace MaterialPropertyLib
11{
13constexpr int tensorSize(int dim)
14{
15 if (dim == 1)
16 {
17 return 3; // Diagonal entries.
18 }
19 if (dim == 2)
20 {
21 return 5; // 2x2 matrix and the 3rd diagonal entry.
22 }
23 if (dim == 3)
24 {
25 return 9; // Full 3x3 matrix.
26 }
27 OGS_FATAL("Tensor size for dimension {} is not defined.", dim);
28}
29
45template <int Dim>
46using Tensor = Eigen::Matrix<double, tensorSize(Dim), 1>;
47
48} // namespace MaterialPropertyLib
#define OGS_FATAL(...)
Definition Error.h:19
Eigen::Matrix< double, tensorSize(Dim), 1 > Tensor
Definition Tensor.h:46
constexpr int tensorSize(int dim)
See Tensor type for details.
Definition Tensor.h:13