Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
pugs
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
code
pugs
Commits
661a4bbe
Commit
661a4bbe
authored
Apr 14, 2022
by
Stéphane Del Pino
Browse files
Options
Downloads
Patches
Plain Diff
Add tests for MeshNodeBoundary
parent
86a40d4d
No related branches found
No related tags found
1 merge request
!140
Change referenced item list policy
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
tests/CMakeLists.txt
+1
-0
1 addition, 0 deletions
tests/CMakeLists.txt
tests/test_MeshNodeBoundary.cpp
+353
-0
353 additions, 0 deletions
tests/test_MeshNodeBoundary.cpp
with
354 additions
and
0 deletions
tests/CMakeLists.txt
+
1
−
0
View file @
661a4bbe
...
@@ -177,6 +177,7 @@ add_executable (mpi_unit_tests
...
@@ -177,6 +177,7 @@ add_executable (mpi_unit_tests
test_ItemValueUtils.cpp
test_ItemValueUtils.cpp
test_MeshFaceBoundary.cpp
test_MeshFaceBoundary.cpp
test_MeshFlatFaceBoundary.cpp
test_MeshFlatFaceBoundary.cpp
test_MeshNodeBoundary.cpp
test_Messenger.cpp
test_Messenger.cpp
test_OFStream.cpp
test_OFStream.cpp
test_Partitioner.cpp
test_Partitioner.cpp
...
...
This diff is collapsed.
Click to expand it.
tests/test_MeshNodeBoundary.cpp
0 → 100644
+
353
−
0
View file @
661a4bbe
#include
<catch2/catch_test_macros.hpp>
#include
<catch2/matchers/catch_matchers_all.hpp>
#include
<MeshDataBaseForTests.hpp>
#include
<mesh/Connectivity.hpp>
#include
<mesh/Mesh.hpp>
#include
<mesh/MeshNodeBoundary.hpp>
#include
<mesh/NamedBoundaryDescriptor.hpp>
#include
<mesh/NumberedBoundaryDescriptor.hpp>
// clazy:excludeall=non-pod-global-static
TEST_CASE
(
"MeshNodeBoundary"
,
"[mesh]"
)
{
auto
is_same
=
[](
const
auto
&
a
,
const
auto
&
b
)
->
bool
{
if
(
a
.
size
()
>
0
and
b
.
size
()
>
0
)
{
return
(
a
.
size
()
==
b
.
size
())
and
(
&
(
a
[
0
])
==
&
(
b
[
0
]));
}
else
{
return
(
a
.
size
()
==
b
.
size
());
}
};
auto
get_node_list_from_tag
=
[](
const
size_t
tag
,
const
auto
&
connectivity
)
->
Array
<
const
NodeId
>
{
for
(
size_t
i
=
0
;
i
<
connectivity
.
template
numberOfRefItemList
<
ItemType
::
node
>();
++
i
)
{
const
auto
&
ref_node_list
=
connectivity
.
template
refItemList
<
ItemType
::
node
>(
i
);
const
RefId
ref_id
=
ref_node_list
.
refId
();
if
(
ref_id
.
tagNumber
()
==
tag
)
{
return
ref_node_list
.
list
();
}
}
return
{};
};
auto
get_node_list_from_name
=
[](
const
std
::
string
&
name
,
const
auto
&
connectivity
)
->
Array
<
const
NodeId
>
{
for
(
size_t
i
=
0
;
i
<
connectivity
.
template
numberOfRefItemList
<
ItemType
::
node
>();
++
i
)
{
const
auto
&
ref_node_list
=
connectivity
.
template
refItemList
<
ItemType
::
node
>(
i
);
const
RefId
ref_id
=
ref_node_list
.
refId
();
if
(
ref_id
.
tagName
()
==
name
)
{
return
ref_node_list
.
list
();
}
}
return
{};
};
SECTION
(
"1D"
)
{
static
constexpr
size_t
Dimension
=
1
;
using
ConnectivityType
=
Connectivity
<
Dimension
>
;
using
MeshType
=
Mesh
<
ConnectivityType
>
;
SECTION
(
"cartesian 1d"
)
{
std
::
shared_ptr
p_mesh
=
MeshDataBaseForTests
::
get
().
cartesian1DMesh
();
const
MeshType
&
mesh
=
*
p_mesh
;
const
ConnectivityType
&
connectivity
=
mesh
.
connectivity
();
{
const
std
::
set
<
size_t
>
tag_set
=
{
0
,
1
};
for
(
auto
tag
:
tag_set
)
{
NumberedBoundaryDescriptor
numbered_boundary_descriptor
(
tag
);
const
auto
&
node_boundary
=
getMeshNodeBoundary
(
mesh
,
numbered_boundary_descriptor
);
auto
node_list
=
get_node_list_from_tag
(
tag
,
connectivity
);
REQUIRE
(
is_same
(
node_boundary
.
nodeList
(),
node_list
));
}
}
{
const
std
::
set
<
std
::
string
>
name_set
=
{
"XMIN"
,
"XMAX"
};
for
(
auto
name
:
name_set
)
{
NamedBoundaryDescriptor
named_boundary_descriptor
(
name
);
const
auto
&
node_boundary
=
getMeshNodeBoundary
(
mesh
,
named_boundary_descriptor
);
auto
node_list
=
get_node_list_from_name
(
name
,
connectivity
);
REQUIRE
(
is_same
(
node_boundary
.
nodeList
(),
node_list
));
}
}
}
SECTION
(
"unordered 1d"
)
{
std
::
shared_ptr
p_mesh
=
MeshDataBaseForTests
::
get
().
unordered1DMesh
();
const
MeshType
&
mesh
=
*
p_mesh
;
const
ConnectivityType
&
connectivity
=
mesh
.
connectivity
();
{
const
std
::
set
<
size_t
>
tag_set
=
{
1
,
2
};
for
(
auto
tag
:
tag_set
)
{
NumberedBoundaryDescriptor
numbered_boundary_descriptor
(
tag
);
const
auto
&
node_boundary
=
getMeshNodeBoundary
(
mesh
,
numbered_boundary_descriptor
);
auto
node_list
=
get_node_list_from_tag
(
tag
,
connectivity
);
REQUIRE
(
is_same
(
node_boundary
.
nodeList
(),
node_list
));
}
}
{
const
std
::
set
<
std
::
string
>
name_set
=
{
"XMIN"
,
"XMAX"
};
for
(
auto
name
:
name_set
)
{
NamedBoundaryDescriptor
named_boundary_descriptor
(
name
);
const
auto
&
node_boundary
=
getMeshNodeBoundary
(
mesh
,
named_boundary_descriptor
);
auto
node_list
=
get_node_list_from_name
(
name
,
connectivity
);
REQUIRE
(
is_same
(
node_boundary
.
nodeList
(),
node_list
));
}
}
}
}
SECTION
(
"2D"
)
{
static
constexpr
size_t
Dimension
=
2
;
using
ConnectivityType
=
Connectivity
<
Dimension
>
;
using
MeshType
=
Mesh
<
ConnectivityType
>
;
SECTION
(
"cartesian 2d"
)
{
std
::
shared_ptr
p_mesh
=
MeshDataBaseForTests
::
get
().
cartesian2DMesh
();
const
MeshType
&
mesh
=
*
p_mesh
;
const
ConnectivityType
&
connectivity
=
mesh
.
connectivity
();
{
const
std
::
set
<
size_t
>
tag_set
=
{
0
,
1
,
2
,
3
,
10
,
11
,
12
,
13
};
for
(
auto
tag
:
tag_set
)
{
NumberedBoundaryDescriptor
numbered_boundary_descriptor
(
tag
);
const
auto
&
node_boundary
=
getMeshNodeBoundary
(
mesh
,
numbered_boundary_descriptor
);
auto
node_list
=
get_node_list_from_tag
(
tag
,
connectivity
);
REQUIRE
(
is_same
(
node_boundary
.
nodeList
(),
node_list
));
}
}
{
const
std
::
set
<
std
::
string
>
name_set
=
{
"XMIN"
,
"XMAX"
,
"YMIN"
,
"YMAX"
,
"XMINYMIN"
,
"XMINYMAX"
,
"XMAXYMIN"
,
"XMAXYMAX"
};
for
(
auto
name
:
name_set
)
{
NamedBoundaryDescriptor
numbered_boundary_descriptor
(
name
);
const
auto
&
node_boundary
=
getMeshNodeBoundary
(
mesh
,
numbered_boundary_descriptor
);
auto
node_list
=
get_node_list_from_name
(
name
,
connectivity
);
REQUIRE
(
is_same
(
node_boundary
.
nodeList
(),
node_list
));
}
}
}
SECTION
(
"hybrid 2d"
)
{
std
::
shared_ptr
p_mesh
=
MeshDataBaseForTests
::
get
().
hybrid2DMesh
();
const
MeshType
&
mesh
=
*
p_mesh
;
const
ConnectivityType
&
connectivity
=
mesh
.
connectivity
();
{
const
std
::
set
<
size_t
>
tag_set
=
{
1
,
2
,
3
,
4
,
8
,
9
,
10
,
11
};
for
(
auto
tag
:
tag_set
)
{
NumberedBoundaryDescriptor
numbered_boundary_descriptor
(
tag
);
const
auto
&
node_boundary
=
getMeshNodeBoundary
(
mesh
,
numbered_boundary_descriptor
);
auto
node_list
=
get_node_list_from_tag
(
tag
,
connectivity
);
REQUIRE
(
is_same
(
node_boundary
.
nodeList
(),
node_list
));
}
}
{
const
std
::
set
<
std
::
string
>
name_set
=
{
"XMIN"
,
"YMIN"
,
"XMAX"
,
"YMIN"
,
"XMINYMIN"
,
"XMINYMAX"
,
"XMAXYMIN"
,
"XMAXYMAX"
};
for
(
auto
name
:
name_set
)
{
NamedBoundaryDescriptor
numbered_boundary_descriptor
(
name
);
const
auto
&
node_boundary
=
getMeshNodeBoundary
(
mesh
,
numbered_boundary_descriptor
);
auto
node_list
=
get_node_list_from_name
(
name
,
connectivity
);
REQUIRE
(
is_same
(
node_boundary
.
nodeList
(),
node_list
));
}
}
}
}
SECTION
(
"3D"
)
{
static
constexpr
size_t
Dimension
=
3
;
using
ConnectivityType
=
Connectivity
<
Dimension
>
;
using
MeshType
=
Mesh
<
ConnectivityType
>
;
SECTION
(
"cartesian 3d"
)
{
std
::
shared_ptr
p_mesh
=
MeshDataBaseForTests
::
get
().
cartesian3DMesh
();
const
MeshType
&
mesh
=
*
p_mesh
;
const
ConnectivityType
&
connectivity
=
mesh
.
connectivity
();
{
const
std
::
set
<
size_t
>
tag_set
=
{
0
,
1
,
2
,
3
,
4
,
5
,
10
,
11
,
12
,
13
,
14
,
15
,
16
,
17
,
20
,
21
,
22
,
23
,
24
,
25
,
26
,
27
,
28
,
29
,
30
,
31
};
for
(
auto
tag
:
tag_set
)
{
NumberedBoundaryDescriptor
numbered_boundary_descriptor
(
tag
);
const
auto
&
node_boundary
=
getMeshNodeBoundary
(
mesh
,
numbered_boundary_descriptor
);
auto
node_list
=
get_node_list_from_tag
(
tag
,
connectivity
);
REQUIRE
(
is_same
(
node_boundary
.
nodeList
(),
node_list
));
}
}
{
const
std
::
set
<
std
::
string
>
name_set
=
{
// faces
"XMIN"
,
"XMAX"
,
"YMIN"
,
"YMAX"
,
"ZMIN"
,
"ZMAX"
,
// ridges
"XMINYMIN"
,
"XMINYMAX"
,
"XMINZMIN"
,
"XMINZMAX"
,
"XMAXYMIN"
,
"XMAXYMAX"
,
"XMAXZMIN"
,
"XMAXZMAX"
,
"YMINZMIN"
,
"YMINZMAX"
,
"YMAXZMIN"
,
"YMAXZMAX"
,
// corners
"XMINYMINZMIN"
,
"XMINYMINZMAX"
,
"XMINYMAXZMIN"
,
"XMINYMAXZMAX"
,
"XMAXYMINZMIN"
,
"XMAXYMINZMAX"
,
"XMAXYMAXZMIN"
,
"XMAXYMAXZMAX"
};
for
(
auto
name
:
name_set
)
{
NamedBoundaryDescriptor
numbered_boundary_descriptor
(
name
);
const
auto
&
node_boundary
=
getMeshNodeBoundary
(
mesh
,
numbered_boundary_descriptor
);
auto
node_list
=
get_node_list_from_name
(
name
,
connectivity
);
REQUIRE
(
is_same
(
node_boundary
.
nodeList
(),
node_list
));
}
}
}
SECTION
(
"hybrid 3d"
)
{
std
::
shared_ptr
p_mesh
=
MeshDataBaseForTests
::
get
().
hybrid3DMesh
();
const
MeshType
&
mesh
=
*
p_mesh
;
const
ConnectivityType
&
connectivity
=
mesh
.
connectivity
();
{
const
std
::
set
<
size_t
>
tag_set
=
{
22
,
23
,
24
,
25
,
26
,
27
,
28
,
29
,
30
,
31
,
32
,
33
,
34
,
35
,
36
,
37
,
38
,
39
,
40
,
41
,
42
,
43
,
44
,
45
,
47
,
51
};
for
(
auto
tag
:
tag_set
)
{
NumberedBoundaryDescriptor
numbered_boundary_descriptor
(
tag
);
const
auto
&
node_boundary
=
getMeshNodeBoundary
(
mesh
,
numbered_boundary_descriptor
);
auto
node_list
=
get_node_list_from_tag
(
tag
,
connectivity
);
REQUIRE
(
is_same
(
node_boundary
.
nodeList
(),
node_list
));
}
}
{
const
std
::
set
<
std
::
string
>
name_set
=
{
// faces
"XMIN"
,
"XMAX"
,
"YMIN"
,
"YMAX"
,
"ZMIN"
,
"ZMAX"
,
// ridges
"XMINYMIN"
,
"XMINYMAX"
,
"XMINZMIN"
,
"XMINZMAX"
,
"XMAXYMIN"
,
"XMAXYMAX"
,
"XMAXZMIN"
,
"XMAXZMAX"
,
"YMINZMIN"
,
"YMINZMAX"
,
"YMAXZMIN"
,
"YMAXZMAX"
,
// corners
"XMINYMINZMIN"
,
"XMINYMINZMAX"
,
"XMINYMAXZMIN"
,
"XMINYMAXZMAX"
,
"XMAXYMINZMIN"
,
"XMAXYMINZMAX"
,
"XMAXYMAXZMIN"
,
"XMAXYMAXZMAX"
};
for
(
auto
name
:
name_set
)
{
NamedBoundaryDescriptor
numbered_boundary_descriptor
(
name
);
const
auto
&
node_boundary
=
getMeshNodeBoundary
(
mesh
,
numbered_boundary_descriptor
);
auto
node_list
=
get_node_list_from_name
(
name
,
connectivity
);
REQUIRE
(
is_same
(
node_boundary
.
nodeList
(),
node_list
));
}
}
}
}
SECTION
(
"errors"
)
{
SECTION
(
"cannot find boundary"
)
{
static
constexpr
size_t
Dimension
=
3
;
using
ConnectivityType
=
Connectivity
<
Dimension
>
;
using
MeshType
=
Mesh
<
ConnectivityType
>
;
std
::
shared_ptr
p_mesh
=
MeshDataBaseForTests
::
get
().
hybrid3DMesh
();
const
MeshType
&
mesh
=
*
p_mesh
;
NamedBoundaryDescriptor
named_boundary_descriptor
(
"invalid_boundary"
);
REQUIRE_THROWS_WITH
(
getMeshNodeBoundary
(
mesh
,
named_boundary_descriptor
),
"error: cannot find node list with name
\"
invalid_boundary
\"
"
);
}
SECTION
(
"surface is inside"
)
{
SECTION
(
"1D"
)
{
static
constexpr
size_t
Dimension
=
1
;
using
ConnectivityType
=
Connectivity
<
Dimension
>
;
using
MeshType
=
Mesh
<
ConnectivityType
>
;
std
::
shared_ptr
p_mesh
=
MeshDataBaseForTests
::
get
().
unordered1DMesh
();
const
MeshType
&
mesh
=
*
p_mesh
;
NamedBoundaryDescriptor
named_boundary_descriptor
(
"INTERFACE"
);
REQUIRE_THROWS_WITH
(
getMeshNodeBoundary
(
mesh
,
named_boundary_descriptor
),
"error: invalid boundary
\"
INTERFACE
\"
: inner nodes cannot be used to define mesh "
"boundaries"
);
}
SECTION
(
"2D"
)
{
static
constexpr
size_t
Dimension
=
2
;
using
ConnectivityType
=
Connectivity
<
Dimension
>
;
using
MeshType
=
Mesh
<
ConnectivityType
>
;
std
::
shared_ptr
p_mesh
=
MeshDataBaseForTests
::
get
().
hybrid2DMesh
();
const
MeshType
&
mesh
=
*
p_mesh
;
NamedBoundaryDescriptor
named_boundary_descriptor
(
"INTERFACE"
);
REQUIRE_THROWS_WITH
(
getMeshNodeBoundary
(
mesh
,
named_boundary_descriptor
),
"error: invalid boundary
\"
INTERFACE
\"
: inner edges cannot be used to define mesh "
"boundaries"
);
}
SECTION
(
"3D"
)
{
static
constexpr
size_t
Dimension
=
3
;
using
ConnectivityType
=
Connectivity
<
Dimension
>
;
using
MeshType
=
Mesh
<
ConnectivityType
>
;
std
::
shared_ptr
p_mesh
=
MeshDataBaseForTests
::
get
().
hybrid3DMesh
();
const
MeshType
&
mesh
=
*
p_mesh
;
NamedBoundaryDescriptor
named_boundary_descriptor
(
"INTERFACE1"
);
REQUIRE_THROWS_WITH
(
getMeshNodeBoundary
(
mesh
,
named_boundary_descriptor
),
"error: invalid boundary
\"
INTERFACE1
\"
: inner faces cannot be used to define mesh "
"boundaries"
);
}
}
}
}
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