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
e3cc1c30
Commit
e3cc1c30
authored
6 years ago
by
Dennis Gläser
Committed by
Timo Koch
6 years ago
Browse files
Options
Downloads
Patches
Plain Diff
[geometryisection] add test for 1d-2d isection
parent
0048f088
No related branches found
No related tags found
1 merge request
!1523
Feature/improve box facet fluxes
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_1d2d_intersection.cc
+110
-0
110 additions, 0 deletions
test/common/geometry/test_1d2d_intersection.cc
with
111 additions
and
0 deletions
test/common/geometry/CMakeLists.txt
+
1
−
0
View file @
e3cc1c30
dune_add_test
(
SOURCES test_1d3d_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
)
dune_add_test
(
SOURCES test_2d3d_intersection.cc LABELS unit
)
dune_add_test
(
SOURCES test_graham_convex_hull.cc LABELS unit
)
dune_add_test
(
SOURCES test_graham_convex_hull.cc LABELS unit
)
dune_add_test
(
SOURCES test_makegeometry.cc LABELS unit
)
dune_add_test
(
SOURCES test_makegeometry.cc LABELS unit
)
This diff is collapsed.
Click to expand it.
test/common/geometry/test_1d2d_intersection.cc
0 → 100644
+
110
−
0
View file @
e3cc1c30
#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
<dune/geometry/multilineargeometry.hh>
#include
<dumux/common/geometry/geometryintersection.hh>
#ifndef DOXYGEN
template
<
int
dimworld
=
2
>
Dune
::
MultiLinearGeometry
<
double
,
1
,
dimworld
>
makeLine
(
std
::
initializer_list
<
Dune
::
FieldVector
<
double
,
dimworld
>>&&
c
)
{
return
{
Dune
::
GeometryTypes
::
line
,
c
};
}
template
<
int
dimworld
=
2
>
bool
testIntersection
(
const
Dune
::
MultiLinearGeometry
<
double
,
dimworld
,
dimworld
>&
polygon
,
const
Dune
::
MultiLinearGeometry
<
double
,
1
,
dimworld
>&
line
,
bool
foundExpected
=
true
)
{
using
Test
=
Dumux
::
GeometryIntersection
<
Dune
::
MultiLinearGeometry
<
double
,
dimworld
,
dimworld
>
,
Dune
::
MultiLinearGeometry
<
double
,
1
,
dimworld
>
>
;
typename
Test
::
IntersectionType
intersection
;
bool
found
=
Test
::
intersection
(
polygon
,
line
,
intersection
);
if
(
!
found
&&
foundExpected
)
std
::
cerr
<<
"Failed detecting intersection with "
<<
line
.
corner
(
0
)
<<
" "
<<
line
.
corner
(
1
)
<<
std
::
endl
;
else
if
(
found
&&
foundExpected
)
std
::
cout
<<
"Found intersection with "
<<
line
.
corner
(
0
)
<<
" "
<<
line
.
corner
(
1
)
<<
std
::
endl
;
else
if
(
found
&&
!
foundExpected
)
std
::
cerr
<<
"Found false positive: intersection with "
<<
line
.
corner
(
0
)
<<
" "
<<
line
.
corner
(
1
)
<<
std
::
endl
;
else
if
(
!
found
&&
!
foundExpected
)
std
::
cout
<<
"No intersection with "
<<
line
.
corner
(
0
)
<<
" "
<<
line
.
corner
(
1
)
<<
std
::
endl
;
return
(
found
==
foundExpected
);
}
#endif
int
main
(
int
argc
,
char
*
argv
[])
try
{
// maybe initialize mpi
Dune
::
MPIHelper
::
instance
(
argc
,
argv
);
constexpr
int
dimworld
=
2
;
constexpr
int
dim
=
2
;
// we test quadrilateral-line & triangle-line intersections
using
CornerStorage
=
std
::
vector
<
Dune
::
FieldVector
<
double
,
dimworld
>>
;
CornerStorage
quadCorners
({
{
0.0
,
0.0
},
{
1.0
,
0.0
},
{
0.0
,
1.0
},
{
1.0
,
1.0
}
});
CornerStorage
triaCorners
({
{
0.0
,
0.0
},
{
1.0
,
0.0
},
{
0.0
,
1.0
}
});
using
Geometry
=
Dune
::
MultiLinearGeometry
<
double
,
dim
,
dimworld
>
;
Geometry
quad
(
Dune
::
GeometryTypes
::
cube
(
dimworld
),
quadCorners
);
Geometry
triangle
(
Dune
::
GeometryTypes
::
simplex
(
dimworld
),
triaCorners
);
// collect returns to determine exit code
std
::
vector
<
bool
>
returns
;
// the tests
returns
.
push_back
(
testIntersection
(
quad
,
makeLine
({
{
0.0
,
0.0
},
{
1.0
,
0.0
}
})));
returns
.
push_back
(
testIntersection
(
quad
,
makeLine
({
{
0.0
,
0.0
},
{
0.0
,
1.0
}
})));
returns
.
push_back
(
testIntersection
(
quad
,
makeLine
({
{
0.0
,
0.0
},
{
1.0
,
1.0
}
})));
returns
.
push_back
(
testIntersection
(
quad
,
makeLine
({
{
1.0
,
0.0
},
{
1.0
,
1.0
}
})));
returns
.
push_back
(
testIntersection
(
quad
,
makeLine
({
{
1.0
,
1.0
},
{
0.0
,
1.0
}
})));
returns
.
push_back
(
testIntersection
(
quad
,
makeLine
({
{
0.5
,
0.0
},
{
0.5
,
1.0
}
})));
returns
.
push_back
(
testIntersection
(
quad
,
makeLine
({
{
0.0
,
0.5
},
{
1.0
,
0.5
}
})));
returns
.
push_back
(
testIntersection
(
quad
,
makeLine
({
{
0.5
,
0.5
},
{
0.5
,
2.0
}
})));
returns
.
push_back
(
testIntersection
(
quad
,
makeLine
({
{
0.5
,
0.5
},
{
0.5
,
-
2.0
}
})));
returns
.
push_back
(
testIntersection
(
quad
,
makeLine
({
{
0.5
,
0.5
},
{
-
2.0
,
0.5
}
})));
returns
.
push_back
(
testIntersection
(
quad
,
makeLine
({
{
0.5
,
0.5
},
{
2.0
,
0.5
}
})));
returns
.
push_back
(
testIntersection
(
quad
,
makeLine
({
{
0.5
,
0.0
},
{
0.5
,
-
2.0
}
}),
false
));
returns
.
push_back
(
testIntersection
(
quad
,
makeLine
({
{
0.5
,
1.0
},
{
0.5
,
2.0
}
}),
false
));
returns
.
push_back
(
testIntersection
(
triangle
,
makeLine
({
{
0.0
,
0.0
},
{
1.0
,
0.0
}
})));
returns
.
push_back
(
testIntersection
(
triangle
,
makeLine
({
{
0.0
,
0.0
},
{
0.0
,
1.0
}
})));
returns
.
push_back
(
testIntersection
(
triangle
,
makeLine
({
{
0.0
,
0.0
},
{
1.0
,
1.0
}
})));
returns
.
push_back
(
testIntersection
(
triangle
,
makeLine
({
{
0.5
,
0.0
},
{
0.5
,
1.0
}
})));
returns
.
push_back
(
testIntersection
(
triangle
,
makeLine
({
{
0.0
,
0.5
},
{
1.0
,
0.5
}
})));
returns
.
push_back
(
testIntersection
(
triangle
,
makeLine
({
{
0.5
,
0.5
},
{
0.0
,
0.0
}
})));
returns
.
push_back
(
testIntersection
(
triangle
,
makeLine
({
{
0.0
,
0.0
},
{
0.5
,
0.5
}
})));
returns
.
push_back
(
testIntersection
(
triangle
,
makeLine
({
{
0.5
,
0.5
},
{
-
2.0
,
0.5
}
})));
returns
.
push_back
(
testIntersection
(
triangle
,
makeLine
({
{
0.5
,
0.5
},
{
0.5
,
-
2.0
}
})));
returns
.
push_back
(
testIntersection
(
triangle
,
makeLine
({
{
1.0
,
1.0
},
{
0.0
,
1.0
}
}),
false
));
returns
.
push_back
(
testIntersection
(
triangle
,
makeLine
({
{
1.0
,
0.0
},
{
1.0
,
1.0
}
}),
false
));
// 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