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
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
Yuhao Liu
ogs
Commits
a14fd28c
Commit
a14fd28c
authored
4 years ago
by
Tom Fischer
Browse files
Options
Downloads
Patches
Plain Diff
[T/MeL] Tests for pyramid quality criteria.
parent
a98df6ba
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/MeshLib/TestPyramidQualityCriteria.cpp
+134
-0
134 additions, 0 deletions
Tests/MeshLib/TestPyramidQualityCriteria.cpp
with
134 additions
and
0 deletions
Tests/MeshLib/TestPyramidQualityCriteria.cpp
0 → 100644
+
134
−
0
View file @
a14fd28c
/**
* \file
* \copyright
* Copyright (c) 2012-2020, OpenGeoSys Community (http://www.opengeosys.org)
* Distributed under a Modified BSD License.
* See accompanying file LICENSE.txt or
* http://www.opengeosys.org/project/license
*/
#include
<memory>
#include
<numeric>
#include
<random>
#include
"MeshLib/Elements/Element.h"
#include
"MeshLib/Mesh.h"
#include
"MeshLib/MeshGenerators/MeshGenerator.h"
#include
"MeshLib/MeshQuality/ElementQualityInterface.h"
#include
"MeshLib/Node.h"
#include
"gtest/gtest.h"
class
PyramidElementQuality
:
public
::
testing
::
Test
{
public:
PyramidElementQuality
()
{
std
::
random_device
rd
;
std
::
mt19937
gen
(
rd
());
std
::
uniform_int_distribution
<>
distrib
(
1
,
10
);
lengths
=
{
1.0
,
1.0
,
1.0
};
n_subdivisions
=
{
distrib
(
gen
),
distrib
(
gen
),
distrib
(
gen
)};
}
std
::
vector
<
double
>
getElementQualityVectorFromRegularPyramidMesh
(
MeshLib
::
MeshQualityType
const
type
)
{
std
::
vector
<
std
::
unique_ptr
<
BaseLib
::
ISubdivision
>>
vec_div
;
for
(
int
i
=
0
;
i
<
3
;
++
i
)
{
vec_div
.
emplace_back
(
new
BaseLib
::
UniformSubdivision
(
lengths
[
i
],
n_subdivisions
[
i
]));
}
std
::
unique_ptr
<
MeshLib
::
Mesh
>
mesh
(
MeshLib
::
MeshGenerator
::
generateRegularPyramidMesh
(
*
vec_div
[
0
],
*
vec_div
[
1
],
*
vec_div
[
2
]));
MeshLib
::
ElementQualityInterface
element_quality
(
*
mesh
,
type
);
return
element_quality
.
getQualityVector
();
}
std
::
array
<
double
,
3
>
lengths
;
std
::
array
<
int
,
3
>
n_subdivisions
;
};
TEST_F
(
PyramidElementQuality
,
ElementSize
)
{
auto
const
type
=
MeshLib
::
MeshQualityType
::
ELEMENTSIZE
;
auto
const
element_quality_vector
=
getElementQualityVectorFromRegularPyramidMesh
(
type
);
auto
const
expected_value
=
(
1.0
/
6
)
/
std
::
accumulate
(
n_subdivisions
.
begin
(),
n_subdivisions
.
end
(),
1
,
std
::
multiplies
<
int
>
());
for
(
auto
const
element_quality
:
element_quality_vector
)
{
ASSERT_NEAR
(
expected_value
,
element_quality
,
std
::
numeric_limits
<
double
>::
epsilon
());
}
}
TEST_F
(
PyramidElementQuality
,
SizeDifference
)
{
auto
const
type
=
MeshLib
::
MeshQualityType
::
SIZEDIFFERENCE
;
auto
const
element_quality_vector
=
getElementQualityVectorFromRegularPyramidMesh
(
type
);
// all elements have the same size, the quality value has to be 1.0
auto
constexpr
expected_value
=
1.0
;
for
(
auto
const
element_quality
:
element_quality_vector
)
{
ASSERT_NEAR
(
expected_value
,
element_quality
,
12
*
std
::
numeric_limits
<
double
>::
epsilon
());
}
}
TEST_F
(
PyramidElementQuality
,
EdgeRatio
)
{
auto
const
type
=
MeshLib
::
MeshQualityType
::
EDGERATIO
;
auto
const
element_quality_vector
=
getElementQualityVectorFromRegularPyramidMesh
(
type
);
std
::
array
const
dx
=
{
1.0
/
n_subdivisions
[
0
],
1.0
/
n_subdivisions
[
1
],
1.0
/
n_subdivisions
[
2
]};
std
::
array
const
edge_lengths_top_bottom
=
{
dx
[
0
],
dx
[
1
],
std
::
sqrt
(
std
::
pow
(
dx
[
0
]
/
2
,
2
)
+
std
::
pow
(
dx
[
1
]
/
2
,
2
)
+
std
::
pow
(
dx
[
2
]
/
2
,
2
))};
auto
const
&
min_max_top_bottom
=
std
::
minmax_element
(
edge_lengths_top_bottom
.
begin
(),
edge_lengths_top_bottom
.
end
());
auto
const
expected_value_top_bottom
=
*
min_max_top_bottom
.
first
/
*
min_max_top_bottom
.
second
;
std
::
array
const
edge_lengths_left_right
=
{
dx
[
1
],
dx
[
2
],
std
::
sqrt
(
std
::
pow
(
dx
[
0
]
/
2
,
2
)
+
std
::
pow
(
dx
[
1
]
/
2
,
2
)
+
std
::
pow
(
dx
[
2
]
/
2
,
2
))};
auto
const
&
min_max_left_right
=
std
::
minmax_element
(
edge_lengths_left_right
.
begin
(),
edge_lengths_left_right
.
end
());
auto
const
expected_value_left_right
=
*
min_max_left_right
.
first
/
*
min_max_left_right
.
second
;
std
::
array
const
edge_lengths_front_back
=
{
dx
[
0
],
dx
[
2
],
std
::
sqrt
(
std
::
pow
(
dx
[
0
]
/
2
,
2
)
+
std
::
pow
(
dx
[
1
]
/
2
,
2
)
+
std
::
pow
(
dx
[
2
]
/
2
,
2
))};
auto
const
&
min_max_front_back
=
std
::
minmax_element
(
edge_lengths_front_back
.
begin
(),
edge_lengths_front_back
.
end
());
auto
const
expected_value_front_back
=
*
min_max_front_back
.
first
/
*
min_max_front_back
.
second
;
for
(
int
i
=
0
;
i
<
element_quality_vector
.
size
();
i
=
i
+
6
)
{
ASSERT_NEAR
(
expected_value_top_bottom
,
element_quality_vector
[
i
],
10
*
std
::
numeric_limits
<
double
>::
epsilon
());
ASSERT_NEAR
(
expected_value_top_bottom
,
element_quality_vector
[
i
+
1
],
10
*
std
::
numeric_limits
<
double
>::
epsilon
());
ASSERT_NEAR
(
expected_value_left_right
,
element_quality_vector
[
i
+
2
],
10
*
std
::
numeric_limits
<
double
>::
epsilon
());
ASSERT_NEAR
(
expected_value_left_right
,
element_quality_vector
[
i
+
3
],
10
*
std
::
numeric_limits
<
double
>::
epsilon
());
ASSERT_NEAR
(
expected_value_front_back
,
element_quality_vector
[
i
+
4
],
10
*
std
::
numeric_limits
<
double
>::
epsilon
());
ASSERT_NEAR
(
expected_value_front_back
,
element_quality_vector
[
i
+
5
],
10
*
std
::
numeric_limits
<
double
>::
epsilon
());
}
}
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