Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
dumux
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
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
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
dumux-repositories
dumux
Commits
822e5357
Commit
822e5357
authored
5 years ago
by
Dennis Gläser
Browse files
Options
Downloads
Patches
Plain Diff
[test] add test for 0d-1d intersections
parent
fb822cab
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!1541
[geometryisection] introduce policy classes for intersections
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
test/common/geometry/CMakeLists.txt
+1
-0
1 addition, 0 deletions
test/common/geometry/CMakeLists.txt
test/common/geometry/test_0d1d_intersection.cc
+91
-0
91 additions, 0 deletions
test/common/geometry/test_0d1d_intersection.cc
with
92 additions
and
0 deletions
test/common/geometry/CMakeLists.txt
+
1
−
0
View file @
822e5357
dune_add_test
(
SOURCES test_0d1d_intersection.cc LABELS unit
)
dune_add_test
(
SOURCES test_1d3d_intersection.cc LABELS unit
)
dune_add_test
(
SOURCES test_1d2d_intersection.cc LABELS unit
)
dune_add_test
(
SOURCES test_2d3d_intersection.cc LABELS unit
)
...
...
This diff is collapsed.
Click to expand it.
test/common/geometry/test_0d1d_intersection.cc
0 → 100644
+
91
−
0
View file @
822e5357
#include
<config.h>
#include
<iostream>
#include
<algorithm>
#include
<initializer_list>
#include
<dune/common/exceptions.hh>
#include
<dune/common/parallel/mpihelper.hh>
#include
<dune/common/fvector.hh>
#include
<dumux/common/geometry/intersectspointgeometry.hh>
#ifndef DOXYGEN
template
<
int
dimworld
=
3
>
bool
testIntersection
(
const
Dune
::
FieldVector
<
double
,
dimworld
>&
a
,
const
Dune
::
FieldVector
<
double
,
dimworld
>&
b
,
const
Dune
::
FieldVector
<
double
,
dimworld
>&
p
,
bool
foundExpected
=
false
)
{
bool
found
=
Dumux
::
intersectsPointSimplex
(
p
,
a
,
b
);
if
(
!
found
&&
foundExpected
)
std
::
cerr
<<
"Failed detecting intersection with "
<<
p
<<
std
::
endl
;
else
if
(
found
&&
foundExpected
)
std
::
cout
<<
"Found intersection with "
<<
p
<<
std
::
endl
;
else
if
(
found
&&
!
foundExpected
)
std
::
cerr
<<
"Found false positive: intersection with "
<<
p
<<
std
::
endl
;
else
if
(
!
found
&&
!
foundExpected
)
std
::
cout
<<
"No intersection with "
<<
p
<<
std
::
endl
;
return
(
found
==
foundExpected
);
}
template
<
int
dimWorld
>
void
testIntersections
(
std
::
vector
<
bool
>&
returns
)
{
// test if points lie on 3d segments
using
GlobalPosition
=
Dune
::
FieldVector
<
double
,
dimWorld
>
;
for
(
auto
scaling
:
{
1.0
,
1e3
,
1e12
,
1e-12
})
{
const
GlobalPosition
a
(
0.0
);
auto
b
=
a
;
b
[
dimWorld
-
1
]
=
1.0
*
scaling
;
GlobalPosition
p1
=
a
;
GlobalPosition
p2
=
b
;
GlobalPosition
p3
=
a
+
b
;
p3
/=
2.0
;
GlobalPosition
p4
=
b
+
(
b
-
a
);
GlobalPosition
p5
=
a
-
(
b
-
a
);
GlobalPosition
p6
(
0.5
*
scaling
);
returns
.
push_back
(
testIntersection
(
a
,
b
,
p1
,
true
));
returns
.
push_back
(
testIntersection
(
a
,
b
,
p2
,
true
));
returns
.
push_back
(
testIntersection
(
a
,
b
,
p3
,
true
));
returns
.
push_back
(
testIntersection
(
a
,
b
,
p4
));
returns
.
push_back
(
testIntersection
(
a
,
b
,
p5
));
returns
.
push_back
(
testIntersection
(
a
,
b
,
p6
));
}
}
#endif
int
main
(
int
argc
,
char
*
argv
[])
try
{
// maybe initialize mpi
Dune
::
MPIHelper
::
instance
(
argc
,
argv
);
// collect returns to determine exit code
std
::
vector
<
bool
>
returns
;
// test for dimWorld = 2
testIntersections
<
2
>
(
returns
);
// test for dimWorld = 3
testIntersections
<
3
>
(
returns
);
// determine the exit code
if
(
std
::
any_of
(
returns
.
begin
(),
returns
.
end
(),
[](
bool
i
){
return
!
i
;
}))
return
1
;
std
::
cout
<<
"All tests passed!"
<<
std
::
endl
;
return
0
;
}
// //////////////////////////////////
// Error handler
// /////////////////////////////////
catch
(
const
Dune
::
Exception
&
e
)
{
std
::
cout
<<
e
<<
std
::
endl
;
return
1
;
}
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