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
a2eecb6d
Commit
a2eecb6d
authored
1 year ago
by
Stéphane Del Pino
Browse files
Options
Downloads
Patches
Plain Diff
Add tests for situation that enlightened normal calculation issue
parent
2ea389cb
No related branches found
No related tags found
1 merge request
!174
Issue/normal calculation
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
tests/test_MeshFlatNodeBoundary.cpp
+205
-0
205 additions, 0 deletions
tests/test_MeshFlatNodeBoundary.cpp
with
205 additions
and
0 deletions
tests/test_MeshFlatNodeBoundary.cpp
+
205
−
0
View file @
a2eecb6d
...
@@ -1133,6 +1133,211 @@ TEST_CASE("MeshFlatNodeBoundary", "[mesh]")
...
@@ -1133,6 +1133,211 @@ TEST_CASE("MeshFlatNodeBoundary", "[mesh]")
}
}
}
}
SECTION
(
"rotated diamond"
)
{
SECTION
(
"2D"
)
{
static
constexpr
size_t
Dimension
=
2
;
using
ConnectivityType
=
Connectivity
<
Dimension
>
;
using
MeshType
=
Mesh
<
ConnectivityType
>
;
using
R2
=
TinyVector
<
2
>
;
auto
T
=
[](
const
R2
&
x
)
->
R2
{
return
R2
{
x
[
0
]
+
0.1
*
x
[
1
],
x
[
1
]
+
0.1
*
x
[
0
]};
};
SECTION
(
"cartesian 2d"
)
{
std
::
shared_ptr
p_mesh
=
MeshDataBaseForTests
::
get
().
cartesian2DMesh
();
const
ConnectivityType
&
connectivity
=
p_mesh
->
connectivity
();
auto
xr
=
p_mesh
->
xr
();
NodeValue
<
R2
>
rotated_xr
{
connectivity
};
parallel_for
(
connectivity
.
numberOfNodes
(),
PUGS_LAMBDA
(
const
NodeId
node_id
)
{
rotated_xr
[
node_id
]
=
T
(
xr
[
node_id
]);
});
MeshType
mesh
{
p_mesh
->
shared_connectivity
(),
rotated_xr
};
{
const
std
::
set
<
size_t
>
tag_set
=
{
0
,
1
,
2
,
3
};
for
(
auto
tag
:
tag_set
)
{
NumberedBoundaryDescriptor
numbered_boundary_descriptor
(
tag
);
const
auto
&
node_boundary
=
getMeshFlatNodeBoundary
(
mesh
,
numbered_boundary_descriptor
);
auto
node_list
=
get_node_list_from_tag
(
tag
,
connectivity
);
REQUIRE
(
is_same
(
node_boundary
.
nodeList
(),
node_list
));
R2
normal
=
zero
;
switch
(
tag
)
{
case
0
:
{
normal
=
1.
/
std
::
sqrt
(
1.01
)
*
R2
{
-
1
,
0.1
};
break
;
}
case
1
:
{
normal
=
1.
/
std
::
sqrt
(
1.01
)
*
R2
{
1
,
-
0.1
};
break
;
}
case
2
:
{
normal
=
1.
/
std
::
sqrt
(
1.01
)
*
R2
{
0.1
,
-
1
};
break
;
}
case
3
:
{
normal
=
1.
/
std
::
sqrt
(
1.01
)
*
R2
{
-
0.1
,
1
};
break
;
}
default
:
{
FAIL
(
"unexpected tag number"
);
}
}
REQUIRE
(
l2Norm
(
node_boundary
.
outgoingNormal
()
-
normal
)
==
Catch
::
Approx
(
0
).
margin
(
1E-13
));
}
}
{
const
std
::
set
<
std
::
string
>
name_set
=
{
"XMIN"
,
"XMAX"
,
"YMIN"
,
"YMAX"
};
for
(
const
auto
&
name
:
name_set
)
{
NamedBoundaryDescriptor
named_boundary_descriptor
(
name
);
const
auto
&
node_boundary
=
getMeshFlatNodeBoundary
(
mesh
,
named_boundary_descriptor
);
auto
node_list
=
get_node_list_from_name
(
name
,
connectivity
);
REQUIRE
(
is_same
(
node_boundary
.
nodeList
(),
node_list
));
R2
normal
=
zero
;
if
(
name
==
"XMIN"
)
{
normal
=
1.
/
std
::
sqrt
(
1.01
)
*
R2
{
-
1
,
0.1
};
}
else
if
(
name
==
"XMAX"
)
{
normal
=
1.
/
std
::
sqrt
(
1.01
)
*
R2
{
1
,
-
0.1
};
}
else
if
(
name
==
"YMIN"
)
{
normal
=
1.
/
std
::
sqrt
(
1.01
)
*
R2
{
0.1
,
-
1
};
}
else
if
(
name
==
"YMAX"
)
{
normal
=
1.
/
std
::
sqrt
(
1.01
)
*
R2
{
-
0.1
,
1
};
}
else
{
FAIL
(
"unexpected name: "
+
name
);
}
REQUIRE
(
l2Norm
(
node_boundary
.
outgoingNormal
()
-
normal
)
==
Catch
::
Approx
(
0
).
margin
(
1E-13
));
}
}
}
}
SECTION
(
"3D"
)
{
static
constexpr
size_t
Dimension
=
3
;
using
ConnectivityType
=
Connectivity
<
Dimension
>
;
using
MeshType
=
Mesh
<
ConnectivityType
>
;
using
R3
=
TinyVector
<
3
>
;
auto
T
=
[](
const
R3
&
x
)
->
R3
{
return
R3
{
x
[
0
]
+
0.1
*
x
[
1
]
+
0.2
*
x
[
2
],
x
[
1
]
+
0.1
*
x
[
0
]
+
0.1
*
x
[
2
],
x
[
2
]
+
0.1
*
x
[
0
]};
};
SECTION
(
"cartesian 3d"
)
{
std
::
shared_ptr
p_mesh
=
MeshDataBaseForTests
::
get
().
cartesian3DMesh
();
const
ConnectivityType
&
connectivity
=
p_mesh
->
connectivity
();
auto
xr
=
p_mesh
->
xr
();
NodeValue
<
R3
>
rotated_xr
{
connectivity
};
parallel_for
(
connectivity
.
numberOfNodes
(),
PUGS_LAMBDA
(
const
NodeId
node_id
)
{
rotated_xr
[
node_id
]
=
T
(
xr
[
node_id
]);
});
MeshType
mesh
{
p_mesh
->
shared_connectivity
(),
rotated_xr
};
{
const
std
::
set
<
size_t
>
tag_set
=
{
0
,
1
,
2
,
3
,
4
,
5
};
for
(
auto
tag
:
tag_set
)
{
NumberedBoundaryDescriptor
numbered_boundary_descriptor
(
tag
);
const
auto
&
node_boundary
=
getMeshFlatNodeBoundary
(
mesh
,
numbered_boundary_descriptor
);
auto
node_list
=
get_node_list_from_tag
(
tag
,
connectivity
);
REQUIRE
(
is_same
(
node_boundary
.
nodeList
(),
node_list
));
R3
normal
=
zero
;
switch
(
tag
)
{
case
0
:
{
normal
=
R3
{
-
0.977717523265611
,
0.0977717523265611
,
0.185766329420466
};
break
;
}
case
1
:
{
normal
=
R3
{
0.977717523265611
,
-
0.0977717523265612
,
-
0.185766329420466
};
break
;
}
case
2
:
{
normal
=
R3
{
0.0911512175788074
,
-
0.992535480302569
,
0.0810233045144955
};
break
;
}
case
3
:
{
normal
=
R3
{
-
0.0911512175788074
,
0.992535480302569
,
-
0.0810233045144955
};
break
;
}
case
4
:
{
normal
=
R3
{
0.100493631166705
,
-
0.0100493631166705
,
-
0.994886948550377
};
break
;
}
case
5
:
{
normal
=
R3
{
-
0.100493631166705
,
0.0100493631166705
,
0.994886948550377
};
break
;
}
default
:
{
FAIL
(
"unexpected tag number"
);
}
}
REQUIRE
(
l2Norm
(
node_boundary
.
outgoingNormal
()
-
normal
)
==
Catch
::
Approx
(
0
).
margin
(
1E-13
));
}
}
{
const
std
::
set
<
std
::
string
>
name_set
=
{
"XMIN"
,
"XMAX"
,
"YMIN"
,
"YMAX"
,
"ZMIN"
,
"ZMAX"
};
for
(
const
auto
&
name
:
name_set
)
{
NamedBoundaryDescriptor
named_boundary_descriptor
(
name
);
const
auto
&
node_boundary
=
getMeshFlatNodeBoundary
(
mesh
,
named_boundary_descriptor
);
auto
node_list
=
get_node_list_from_name
(
name
,
connectivity
);
REQUIRE
(
is_same
(
node_boundary
.
nodeList
(),
node_list
));
R3
normal
=
zero
;
if
(
name
==
"XMIN"
)
{
normal
=
R3
{
-
0.977717523265611
,
0.0977717523265611
,
0.185766329420466
};
}
else
if
(
name
==
"XMAX"
)
{
normal
=
R3
{
0.977717523265611
,
-
0.0977717523265612
,
-
0.185766329420466
};
}
else
if
(
name
==
"YMIN"
)
{
normal
=
R3
{
0.0911512175788074
,
-
0.992535480302569
,
0.0810233045144955
};
}
else
if
(
name
==
"YMAX"
)
{
normal
=
R3
{
-
0.0911512175788074
,
0.992535480302569
,
-
0.0810233045144955
};
}
else
if
(
name
==
"ZMIN"
)
{
normal
=
R3
{
0.100493631166705
,
-
0.0100493631166705
,
-
0.994886948550377
};
}
else
if
(
name
==
"ZMAX"
)
{
normal
=
R3
{
-
0.100493631166705
,
0.0100493631166705
,
0.994886948550377
};
}
else
{
FAIL
(
"unexpected name: "
+
name
);
}
REQUIRE
(
l2Norm
(
node_boundary
.
outgoingNormal
()
-
normal
)
==
Catch
::
Approx
(
0
).
margin
(
1E-13
));
}
}
}
}
}
SECTION
(
"curved mesh"
)
SECTION
(
"curved mesh"
)
{
{
SECTION
(
"2D"
)
SECTION
(
"2D"
)
...
...
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