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
Chaofan Chen
ogs
Commits
7b7da21b
Commit
7b7da21b
authored
2 years ago
by
Christoph Lehmann
Committed by
Dmitri Naumov
2 years ago
Browse files
Options
Downloads
Patches
Plain Diff
[T] Added IP data setter unit tests
parent
6b13fe64
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Tests/ProcessLib/TestIPDataAccess.cpp
+65
-1
65 additions, 1 deletion
Tests/ProcessLib/TestIPDataAccess.cpp
with
65 additions
and
1 deletion
Tests/ProcessLib/TestIPDataAccess.cpp
+
65
−
1
View file @
7b7da21b
...
@@ -34,7 +34,7 @@ struct ProcessLib_IPDataAccess : ::testing::Test
...
@@ -34,7 +34,7 @@ struct ProcessLib_IPDataAccess : ::testing::Test
constexpr
int
off_diag_size
=
dim
==
2
?
1
:
3
;
constexpr
int
off_diag_size
=
dim
==
2
?
1
:
3
;
static
constexpr
std
::
size_t
num_int_pts
=
10
;
constexpr
std
::
size_t
num_int_pts
=
10
;
std
::
vector
<
IPData
<
dim
>>
ip_data
(
num_int_pts
);
std
::
vector
<
IPData
<
dim
>>
ip_data
(
num_int_pts
);
...
@@ -52,6 +52,24 @@ struct ProcessLib_IPDataAccess : ::testing::Test
...
@@ -52,6 +52,24 @@ struct ProcessLib_IPDataAccess : ::testing::Test
return
ip_data
;
return
ip_data
;
}
}
static
std
::
vector
<
IPData
<
Dim
::
value
>>
getIPDataNaNs
()
{
using
KV
=
typename
IPData
<
dim
>::
KV
;
constexpr
std
::
size_t
num_int_pts
=
10
;
constexpr
double
nan
=
std
::
numeric_limits
<
double
>::
quiet_NaN
();
std
::
vector
<
IPData
<
dim
>>
ip_data
(
num_int_pts
);
for
(
std
::
size_t
i
=
0
;
i
<
num_int_pts
;
++
i
)
{
ip_data
[
i
].
kelvin
=
KV
::
Constant
(
nan
);
ip_data
[
i
].
scalar
=
nan
;
}
return
ip_data
;
}
static
std
::
vector
<
double
>
getScalarData
()
static
std
::
vector
<
double
>
getScalarData
()
{
{
return
{
100
,
101
,
102
,
103
,
104
,
105
,
106
,
107
,
108
,
109
};
return
{
100
,
101
,
102
,
103
,
104
,
105
,
106
,
107
,
108
,
109
};
...
@@ -162,3 +180,49 @@ TYPED_TEST(ProcessLib_IPDataAccess, GetKelvinVectorDataTransposedOrder)
...
@@ -162,3 +180,49 @@ TYPED_TEST(ProcessLib_IPDataAccess, GetKelvinVectorDataTransposedOrder)
testing
::
Pointwise
(
testing
::
DoubleEq
(),
testing
::
Pointwise
(
testing
::
DoubleEq
(),
this
->
getKVDataTransposedOrder
()));
this
->
getKVDataTransposedOrder
()));
}
}
TYPED_TEST
(
ProcessLib_IPDataAccess
,
SetScalarData
)
{
constexpr
int
dim
=
TypeParam
::
value
;
auto
ip_data
=
this
->
getIPDataNaNs
();
auto
const
cache
=
this
->
getScalarData
();
auto
const
num_read
=
ProcessLib
::
setIntegrationPointScalarData
(
&
cache
[
0
],
ip_data
,
&
IPData
<
dim
>::
scalar
);
ASSERT_EQ
(
ip_data
.
size
(),
num_read
);
auto
const
ip_data_expected
=
this
->
getIPData
();
for
(
std
::
size_t
i
=
0
;
i
<
ip_data_expected
.
size
();
++
i
)
{
EXPECT_DOUBLE_EQ
(
ip_data_expected
[
i
].
scalar
,
ip_data
[
i
].
scalar
)
<<
"Values at integration point "
<<
i
<<
" differ."
;
}
}
TYPED_TEST
(
ProcessLib_IPDataAccess
,
SetKelvinVectorData
)
{
constexpr
int
dim
=
TypeParam
::
value
;
auto
ip_data
=
this
->
getIPDataNaNs
();
auto
const
cache
=
this
->
getKVDataTransposedOrder
();
auto
const
num_read
=
ProcessLib
::
setIntegrationPointKelvinVectorData
<
dim
>
(
&
cache
[
0
],
ip_data
,
&
IPData
<
dim
>::
kelvin
);
ASSERT_EQ
(
ip_data
.
size
(),
num_read
);
auto
const
ip_data_expected
=
this
->
getIPData
();
for
(
std
::
size_t
i
=
0
;
i
<
ip_data_expected
.
size
();
++
i
)
{
EXPECT_THAT
(
ip_data
[
i
].
kelvin
,
testing
::
Pointwise
(
testing
::
DoubleEq
(),
ip_data_expected
[
i
].
kelvin
))
<<
"Values at integration point "
<<
i
<<
" differ."
;
}
}
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