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
e444a2c6
Commit
e444a2c6
authored
2 years ago
by
Christoph Lehmann
Browse files
Options
Downloads
Patches
Plain Diff
[T] Added further tests for point in element detection
parent
311954db
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/TestPntInElement.cpp
+96
-0
96 additions, 0 deletions
Tests/MeshLib/TestPntInElement.cpp
with
96 additions
and
0 deletions
Tests/MeshLib/TestPntInElement.cpp
+
96
−
0
View file @
e444a2c6
...
...
@@ -15,7 +15,10 @@
#include
"GeoLib/Point.h"
#include
"MeshLib/Elements/Elements.h"
#include
"MeshLib/Elements/Utils.h"
#include
"MeshLib/Mesh.h"
#include
"Tests/NumLib/ReferenceElementUtils.h"
#include
"Tests/VectorUtils.h"
std
::
vector
<
MeshLib
::
Node
*>
createNodes
()
{
...
...
@@ -151,3 +154,96 @@ TEST(IsPntInElement, Hex)
ASSERT_TRUE
(
hex
.
isPntInElement
(
pnt
,
0.02
));
deleteNodes
(
nodes
);
}
template
<
typename
MeshElementType
>
class
MeshLibIsPntInElementTest
:
public
::
testing
::
Test
{
ReferenceElementUtils
::
ReferenceElement
<
MeshElementType
>
reference_element
;
protected:
MeshElementType
const
&
bulk_element
=
reference_element
.
element
;
};
using
MeshElementTypes
=
ConvertListType_t
<
MeshLib
::
AllElementTypes
,
::
testing
::
Types
>
;
TYPED_TEST_SUITE
(
MeshLibIsPntInElementTest
,
MeshElementTypes
);
TYPED_TEST
(
MeshLibIsPntInElementTest
,
BarycenterIsInElement
)
{
auto
const
&
e
=
this
->
bulk_element
;
auto
const
barycenter
=
getCenterOfGravity
(
e
);
ASSERT_TRUE
(
e
.
isPntInElement
(
barycenter
));
}
TYPED_TEST
(
MeshLibIsPntInElementTest
,
LargeCoordsAreDefinitelyOutsideTheElement_Random
)
{
/* This test uses reference elements. All of their node coordinates have
* absolute values <= 1. Since all element types are convex polytopes,
* points that have any coordinate with absolute value > 1 must be outside
* the reference element.
*/
auto
const
&
e
=
this
->
bulk_element
;
std
::
array
<
double
,
3
>
coords
;
// comp is the coordinate that is close to, but outside the element range.
// I.e., this coordinate will be +/- (1 + eps).
for
(
unsigned
comp
=
0
;
comp
<
3
;
++
comp
)
{
for
(
int
pm
:
{
-
1
,
1
})
{
double
const
eps
=
1e-6
;
unsigned
const
n_repetitions
=
100
;
for
(
unsigned
i
=
0
;
i
<
n_repetitions
;
++
i
)
{
fillVectorRandomly
(
coords
);
coords
[
comp
]
=
pm
*
(
1
+
eps
);
MathLib
::
Point3d
pt
(
coords
);
EXPECT_FALSE
(
e
.
isPntInElement
(
pt
))
<<
"Point "
<<
pt
<<
" is inside the element "
<<
e
;
}
}
}
}
TYPED_TEST
(
MeshLibIsPntInElementTest
,
LargeCoordsAreDefinitelyOutsideTheElement_Zeroes
)
{
/* This test uses reference elements. All of their node coordinates have
* absolute values <= 1. Since all element types are convex polytopes,
* points that have any coordinate with absolute value > 1 must be outside
* the reference element.
*/
auto
const
&
e
=
this
->
bulk_element
;
double
const
eps
=
1e-6
;
// comp is the coordinate that is close to, but outside the element range.
// I.e., this coordinate will be +/- (1 + eps).
for
(
unsigned
comp
=
0
;
comp
<
3
;
++
comp
)
{
for
(
int
pm
:
{
-
1
,
1
})
{
std
::
array
<
double
,
3
>
coords
{};
coords
[
comp
]
=
pm
*
(
1
+
eps
);
for
(
unsigned
c
=
0
;
c
<
3
;
++
c
)
{
// all coordinates except comp will be zero.
ASSERT_TRUE
(
c
==
comp
||
coords
[
c
]
==
0
);
}
MathLib
::
Point3d
pt
(
coords
);
EXPECT_FALSE
(
e
.
isPntInElement
(
pt
))
<<
"Point "
<<
pt
<<
" is inside the element "
<<
e
;
}
}
}
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