Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
O
ogs
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Dmitri Naumov
ogs
Commits
51e1df58
Commit
51e1df58
authored
7 years ago
by
Dmitri Naumov
Browse files
Options
Downloads
Patches
Plain Diff
[MaL] Rename kelvinVectorToTensor().
Also specify all of the template arguments as needed for the MSVC compiler.
parent
e169d832
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
MathLib/KelvinVector.cpp
+4
-4
4 additions, 4 deletions
MathLib/KelvinVector.cpp
MathLib/KelvinVector.h
+6
-2
6 additions, 2 deletions
MathLib/KelvinVector.h
Tests/MaterialLib/KelvinVector.cpp
+8
-8
8 additions, 8 deletions
Tests/MaterialLib/KelvinVector.cpp
with
18 additions
and
14 deletions
MathLib/KelvinVector.cpp
+
4
−
4
View file @
51e1df58
...
...
@@ -58,8 +58,8 @@ Eigen::Matrix<double, 6, 1, Eigen::ColMajor, 6, 1> inverse(
}
template
<
>
Eigen
::
Matrix
<
double
,
3
,
3
>
kelvinToTensor
(
Eigen
::
Matrix
<
double
,
4
,
1
,
Eigen
::
ColMajor
>
const
&
v
)
Eigen
::
Matrix
<
double
,
3
,
3
>
kelvin
Vector
ToTensor
(
Eigen
::
Matrix
<
double
,
4
,
1
,
Eigen
::
ColMajor
,
4
,
1
>
const
&
v
)
{
Eigen
::
Matrix
<
double
,
3
,
3
>
m
;
m
<<
v
[
0
],
v
[
3
]
/
std
::
sqrt
(
2.
),
0
,
v
[
3
]
/
std
::
sqrt
(
2.
),
v
[
1
],
0
,
0
,
0
,
...
...
@@ -68,8 +68,8 @@ Eigen::Matrix<double, 3, 3> kelvinToTensor(
}
template
<
>
Eigen
::
Matrix
<
double
,
3
,
3
>
kelvinToTensor
(
Eigen
::
Matrix
<
double
,
6
,
1
,
Eigen
::
ColMajor
>
const
&
v
)
Eigen
::
Matrix
<
double
,
3
,
3
>
kelvin
Vector
ToTensor
(
Eigen
::
Matrix
<
double
,
6
,
1
,
Eigen
::
ColMajor
,
6
,
1
>
const
&
v
)
{
Eigen
::
Matrix
<
double
,
3
,
3
>
m
;
m
<<
v
[
0
],
v
[
3
]
/
std
::
sqrt
(
2.
),
v
[
5
]
/
std
::
sqrt
(
2.
),
v
[
3
]
/
std
::
sqrt
(
2.
),
...
...
This diff is collapsed.
Click to expand it.
MathLib/KelvinVector.h
+
6
−
2
View file @
51e1df58
...
...
@@ -118,8 +118,12 @@ inverse(Eigen::Matrix<double,
/// Conversion of a Kelvin vector to a 3x3 matrix
/// Only implementations for KelvinVectorSize 4 and 6 are provided.
template
<
int
KelvinVectorSize
>
Eigen
::
Matrix
<
double
,
3
,
3
>
kelvinToTensor
(
Eigen
::
Matrix
<
double
,
KelvinVectorSize
,
1
,
Eigen
::
ColMajor
>
const
&
v
);
Eigen
::
Matrix
<
double
,
3
,
3
>
kelvinVectorToTensor
(
Eigen
::
Matrix
<
double
,
KelvinVectorSize
,
1
,
Eigen
::
ColMajor
,
KelvinVectorSize
,
1
>
const
&
v
);
}
// namespace KelvinVector
}
// namespace MathLib
...
...
This diff is collapsed.
Click to expand it.
Tests/MaterialLib/KelvinVector.cpp
+
8
−
8
View file @
51e1df58
...
...
@@ -72,7 +72,7 @@ struct MaterialLibSolidsKelvinVector6 : public ::testing::Test
TEST_F
(
MaterialLibSolidsKelvinVector4
,
SelfTestMappingKelvinToTensor
)
{
auto
f
=
[](
KelvinVector
<
4
>
const
&
v
)
{
return
(
v
-
tensorToKelvin
<
4
>
(
kelvinToTensor
(
v
))).
norm
()
<=
return
(
v
-
tensorToKelvin
<
4
>
(
kelvin
Vector
ToTensor
(
v
))).
norm
()
<=
2
*
std
::
numeric_limits
<
double
>::
epsilon
()
*
v
.
norm
();
};
...
...
@@ -83,7 +83,7 @@ TEST_F(MaterialLibSolidsKelvinVector4, SelfTestMappingKelvinToTensor)
TEST_F
(
MaterialLibSolidsKelvinVector6
,
SelfTestMappingKelvinToTensor
)
{
auto
f
=
[](
KelvinVector
<
6
>
const
&
v
)
{
return
(
v
-
tensorToKelvin
<
6
>
(
kelvinToTensor
(
v
))).
norm
()
<=
return
(
v
-
tensorToKelvin
<
6
>
(
kelvin
Vector
ToTensor
(
v
))).
norm
()
<=
1.5
*
std
::
numeric_limits
<
double
>::
epsilon
()
*
v
.
norm
();
};
...
...
@@ -99,7 +99,7 @@ TEST_F(MaterialLibSolidsKelvinVector4, Determinant)
{
auto
f
=
[](
KelvinVector
<
4
>
const
&
v
)
{
return
std
::
abs
(
Invariants
<
4
>::
determinant
(
v
)
-
kelvinToTensor
(
v
).
determinant
())
<=
kelvin
Vector
ToTensor
(
v
).
determinant
())
<=
std
::
numeric_limits
<
double
>::
epsilon
()
*
std
::
pow
(
v
.
norm
(),
3.07
);
};
...
...
@@ -112,7 +112,7 @@ TEST_F(MaterialLibSolidsKelvinVector6, Determinant)
{
auto
f
=
[](
KelvinVector
<
6
>
const
&
v
)
{
return
std
::
abs
(
Invariants
<
6
>::
determinant
(
v
)
-
kelvinToTensor
(
v
).
determinant
())
<=
kelvin
Vector
ToTensor
(
v
).
determinant
())
<=
std
::
numeric_limits
<
double
>::
epsilon
()
*
std
::
pow
(
v
.
norm
(),
3.07
);
};
...
...
@@ -129,7 +129,7 @@ TEST_F(MaterialLibSolidsKelvinVector4, Inverse)
{
auto
f
=
[](
KelvinVector
<
4
>
const
&
v
)
{
auto
const
error
=
(
inverse
(
v
)
-
tensorToKelvin
<
4
>
(
kelvinToTensor
(
v
).
inverse
()))
(
inverse
(
v
)
-
tensorToKelvin
<
4
>
(
kelvin
Vector
ToTensor
(
v
).
inverse
()))
.
norm
();
// The error is only weekly depending on the input vector norm.
return
error
<
1e-6
&&
error
<
1e-8
*
std
::
pow
(
v
.
norm
(),
1.4
);
...
...
@@ -140,7 +140,7 @@ TEST_F(MaterialLibSolidsKelvinVector4, Inverse)
ac
::
make_arbitrary
(
kelvinVectorGenerator
)
.
discard_if
([](
KelvinVector
<
4
>
const
&
v
)
{
// only invertable matrices
return
(
std
::
abs
(
kelvinToTensor
(
v
).
determinant
())
==
0
);
return
(
std
::
abs
(
kelvin
Vector
ToTensor
(
v
).
determinant
())
==
0
);
}),
gtest_reporter
);
}
...
...
@@ -149,7 +149,7 @@ TEST_F(MaterialLibSolidsKelvinVector6, Inverse)
{
auto
f
=
[](
KelvinVector
<
6
>
const
&
v
)
{
auto
const
error
=
(
inverse
(
v
)
-
tensorToKelvin
<
6
>
(
kelvinToTensor
(
v
).
inverse
()))
(
inverse
(
v
)
-
tensorToKelvin
<
6
>
(
kelvin
Vector
ToTensor
(
v
).
inverse
()))
.
norm
();
// The error is only weekly depending on the input vector norm.
return
error
<
1e-6
&&
error
<
1e-8
*
std
::
pow
(
v
.
norm
(),
1.4
);
...
...
@@ -160,7 +160,7 @@ TEST_F(MaterialLibSolidsKelvinVector6, Inverse)
ac
::
make_arbitrary
(
kelvinVectorGenerator
)
.
discard_if
([](
KelvinVector
<
6
>
const
&
v
)
{
// only invertable matrices
return
(
std
::
abs
(
kelvinToTensor
(
v
).
determinant
())
==
0
);
return
(
std
::
abs
(
kelvin
Vector
ToTensor
(
v
).
determinant
())
==
0
);
}),
gtest_reporter
);
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment