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
da51ad8a
Commit
da51ad8a
authored
2 years ago
by
wenqing
Browse files
Options
Downloads
Patches
Plain Diff
[Unitest] Added a test for pyramid element type in createQuadraticOrderMesh
parent
7fbce04c
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Tests/MeshLib/TestQuadraticMesh.cpp
+55
-0
55 additions, 0 deletions
Tests/MeshLib/TestQuadraticMesh.cpp
with
55 additions
and
0 deletions
Tests/MeshLib/TestQuadraticMesh.cpp
+
55
−
0
View file @
da51ad8a
...
...
@@ -9,12 +9,14 @@
#include
<gtest/gtest.h>
#include
<limits>
#include
<memory>
#include
"GeoLib/Polyline.h"
#include
"GeoLib/PolylineVec.h"
#include
"MeshGeoToolsLib/AppendLinesAlongPolyline.h"
#include
"MeshLib/Elements/Element.h"
#include
"MeshLib/Elements/Pyramid.h"
#include
"MeshLib/Mesh.h"
#include
"MeshLib/MeshGenerators/MeshGenerator.h"
#include
"MeshLib/MeshGenerators/QuadraticMeshGenerator.h"
...
...
@@ -330,3 +332,56 @@ TEST(MeshLib, QuadraticOrderMesh_LineQuad)
(
connections
[
n
->
getID
()].
size
()
==
13
);
}));
}
TEST
(
MeshLib
,
QuadraticOrderMesh_Pyramid
)
{
// Note the memory allocated for nodes and elements are released in the
// destructor of Mesh.
std
::
vector
<
MeshLib
::
Node
*>
nodes
{
// nodes on base
new
MeshLib
::
Node
(
0.0
,
0.0
,
0.5
),
new
MeshLib
::
Node
(
0.0
,
0.0
,
0.0
),
new
MeshLib
::
Node
(
0.0
,
0.5
,
0.0
),
new
MeshLib
::
Node
(
0.0
,
0.5
,
0.5
),
// node at the top
new
MeshLib
::
Node
(
0.25
,
0.25
,
0.25
)};
// Element(Node* nodes, ...) deletes nodes. Copy nodes entries to
// std::array<MeshLib::Node*> to call Element(std::array<MeshLib::Node*>,
// ...).
std
::
array
<
MeshLib
::
Node
*
,
5
>
pyramid_element_nodes
;
std
::
copy_n
(
nodes
.
begin
(),
5
,
pyramid_element_nodes
.
begin
());
std
::
vector
<
MeshLib
::
Element
*>
elements
{
new
MeshLib
::
Pyramid
(
pyramid_element_nodes
)};
MeshLib
::
Mesh
mesh
(
"test_mesh"
,
nodes
,
elements
);
auto
const
quadratic_mesh
=
MeshLib
::
createQuadraticOrderMesh
(
mesh
,
false
/* add centre node*/
);
auto
const
quadratic_element
=
quadratic_mesh
->
getElement
(
0
);
double
const
tol
=
std
::
numeric_limits
<
double
>::
epsilon
();
// Compare vertex nodes
for
(
std
::
size_t
i
=
0
;
i
<
nodes
.
size
();
i
++
)
{
auto
const
x
=
nodes
[
i
]
->
data
();
auto
const
x_q
=
quadratic_element
->
getNode
(
i
)
->
data
();
for
(
int
j
=
0
;
j
<
3
;
j
++
)
{
ASSERT_NEAR
(
x
[
j
],
x_q
[
j
],
tol
);
}
}
// Compare edge nodes:
auto
const
nodes_q
=
quadratic_element
->
getNodes
();
for
(
int
i
=
0
;
i
<
8
;
i
++
)
{
auto
const
edge_node_ids
=
MeshLib
::
PyramidRule13
::
edge_nodes
[
i
];
auto
const
x_vertex_a
=
nodes
[
edge_node_ids
[
0
]]
->
data
();
auto
const
x_vertex_b
=
nodes
[
edge_node_ids
[
1
]]
->
data
();
auto
const
x_edge
=
nodes_q
[
edge_node_ids
[
2
]]
->
data
();
for
(
int
j
=
0
;
j
<
3
;
j
++
)
{
ASSERT_NEAR
(
0.5
*
(
x_vertex_a
[
j
]
+
x_vertex_b
[
j
]),
x_edge
[
j
],
tol
);
}
}
}
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