-
Notifications
You must be signed in to change notification settings - Fork 238
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'MFrontUpdatesForLargeDeformations' into 'master'
MFront update in preparation for LargeDeformation process See merge request ogs/ogs!4794
- Loading branch information
Showing
8 changed files
with
255 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/* | ||
* \file | ||
* \copyright | ||
* Copyright (c) 2012-2023, OpenGeoSys Community (http://www.opengeosys.org) | ||
* Distributed under a Modified BSD License. | ||
* See accompanying file LICENSE.txt or | ||
* http://www.opengeosys.org/project/license | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include <Eigen/Core> | ||
|
||
#include "MaterialLib/MPL/Property.h" | ||
|
||
namespace MaterialPropertyLib | ||
{ | ||
/// See Tensor type for details. | ||
constexpr int tensorSize(int dim) | ||
{ | ||
if (dim == 1) | ||
{ | ||
return 3; // Diagonal entries. | ||
} | ||
if (dim == 2) | ||
{ | ||
return 5; // 2x2 matrix and the 3rd diagonal entry. | ||
} | ||
if (dim == 3) | ||
{ | ||
return 9; // Full 3x3 matrix. | ||
} | ||
OGS_FATAL("Tensor size for dimension {} is not defined.", dim); | ||
} | ||
|
||
/// The tensor's components in 3D case are ordered in the usual way: | ||
/// (1,1), (1,2), (1,3) | ||
/// (2,1), (2,2), (2,3) | ||
/// (3,1), (3,2), (3,3). | ||
/// | ||
/// For the 2D case the 2x2 block is as usual and is followed by the (3,3) | ||
/// component: | ||
/// (1,1), (1,2), | ||
/// (2,1), (2,2), | ||
/// (3,3). | ||
/// | ||
/// For the 1D case only the diagonal is stored: | ||
/// (1,1), | ||
/// (2,2), | ||
/// (3,3). | ||
template <int Dim> | ||
using Tensor = Eigen::Matrix<double, tensorSize(Dim), 1>; | ||
|
||
} // namespace MaterialPropertyLib |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/** | ||
* \file | ||
* \copyright | ||
* Copyright (c) 2012-2023, OpenGeoSys Community (http://www.opengeosys.org) | ||
* Distributed under a Modified BSD License. | ||
* See accompanying file LICENSE.txt or | ||
* http://www.opengeosys.org/project/license | ||
*/ | ||
|
||
#ifdef OGS_USE_MFRONT | ||
|
||
#include <gmock/gmock-matchers.h> | ||
#include <gtest/gtest.h> | ||
|
||
#include "MaterialLib/SolidModels/MFront/MFrontGeneric.h" | ||
#include "Tests/TestTools.h" | ||
|
||
namespace MPL = MaterialPropertyLib; | ||
namespace MSM = MaterialLib::Solids::MFront; | ||
|
||
TEST(MaterialLib_OgsToMFrontConversion, Tensor3D) | ||
{ | ||
MPL::Tensor<3> ogs_tensor; | ||
ogs_tensor << 11, 12, 13, 21, 22, 23, 31, 32, 33; | ||
|
||
EXPECT_THAT(MSM::ogsTensorToMFrontTensor<3>(ogs_tensor).eval(), | ||
testing::Pointwise(testing::DoubleEq(), | ||
{11, 22, 33, 12, 21, 13, 31, 23, 32})); | ||
} | ||
|
||
TEST(MaterialLib_OgsToMFrontConversion, Tensor2D) | ||
{ | ||
MPL::Tensor<2> ogs_tensor; | ||
ogs_tensor << 11, 12, 21, 22, 33; | ||
|
||
EXPECT_THAT(MSM::ogsTensorToMFrontTensor<2>(ogs_tensor).eval(), | ||
testing::Pointwise(testing::DoubleEq(), {11, 22, 33, 12, 21})); | ||
} | ||
|
||
#endif |
Oops, something went wrong.