Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
dune-fufem
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
Container registry
Model registry
Operate
Environments
Monitor
Incidents
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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Ansgar Burchardt
dune-fufem
Commits
771e9b6c
Commit
771e9b6c
authored
Apr 26, 2017
by
Max Kahnt
Browse files
Options
Downloads
Patches
Plain Diff
Add GridConstructionTest.
parent
a65d3ab2
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
dune/fufem/test/CMakeLists.txt
+1
-0
1 addition, 0 deletions
dune/fufem/test/CMakeLists.txt
dune/fufem/test/gridconstructiontest.cc
+164
-0
164 additions, 0 deletions
dune/fufem/test/gridconstructiontest.cc
with
165 additions
and
0 deletions
dune/fufem/test/CMakeLists.txt
+
1
−
0
View file @
771e9b6c
...
@@ -13,6 +13,7 @@ set(GRID_BASED_TESTS
...
@@ -13,6 +13,7 @@ set(GRID_BASED_TESTS
functionspacebasistest
functionspacebasistest
generalizedlaplaceassemblertest
generalizedlaplaceassemblertest
gradientassemblertest
gradientassemblertest
gridconstructiontest
gridfunctiontest
gridfunctiontest
gridfunctionadaptortest
gridfunctionadaptortest
h1functionalassemblertest
h1functionalassemblertest
...
...
This diff is collapsed.
Click to expand it.
dune/fufem/test/gridconstructiontest.cc
0 → 100644
+
164
−
0
View file @
771e9b6c
#include
<config.h>
#include
<iostream>
#include
<dune/common/parametertree.hh>
#include
<dune/common/parallel/mpihelper.hh>
#include
<dune/fufem/utilities/gridconstruction.hh>
#include
<dune/grid/onedgrid.hh>
#if HAVE_UG
#include
<dune/grid/uggrid.hh>
#endif // HAVE_UG
#if HAVE_DUNE_ALUGRID
#include
<dune/alugrid/grid.hh>
template
<
size_t
dim
>
using
SN_ALUGrid
=
Dune
::
ALUGrid
<
dim
,
dim
,
Dune
::
ALUGridElementType
::
simplex
,
Dune
::
ALUGridRefinementType
::
nonconforming
>
;
#endif // HAVE_DUNE_ALUGRID
struct
GridConstructionTest
{
template
<
class
Grid
>
bool
test1D
()
const
{
using
C
=
Dune
::
GridConstruction
<
Grid
,
1
>
;
return
test
([
this
]()
{
Grid
*
interval
=
C
::
createGrid
(
getIntervalConfig
());
delete
(
interval
);
});
}
template
<
class
Grid
>
bool
test2D
()
const
{
using
C
=
Dune
::
GridConstruction
<
Grid
,
2
>
;
return
test
([
this
]()
{
Grid
*
rectangle
=
C
::
createGrid
(
getRectangleConfig
());
delete
(
rectangle
);
Grid
*
circle
=
C
::
createGrid
(
getCircleConfig
());
delete
(
circle
);
});
}
template
<
class
Grid
>
bool
test3D
()
const
{
using
C
=
Dune
::
GridConstruction
<
Grid
,
3
>
;
return
test
([
this
]()
{
Grid
*
tubeSegment
=
C
::
createGrid
(
getTubeSegmentConfig
());
delete
(
tubeSegment
);
Grid
*
sphere
=
C
::
createGrid
(
getSphereConfig
());
delete
(
sphere
);
Grid
*
cuboid
=
C
::
createGrid
(
getCuboidConfig
());
delete
(
cuboid
);
});
}
private
:
template
<
class
T
>
bool
test
(
T
&&
t
)
const
{
try
{
t
();
}
catch
(
const
Dune
::
Exception
&
e
)
{
std
::
cout
<<
"Exception caught:"
<<
e
<<
std
::
endl
;
return
false
;
}
catch
(...)
{
std
::
cout
<<
"Unkonwn exception caught."
<<
std
::
endl
;
return
false
;
}
return
true
;
// no exception was caught
}
using
Config
=
Dune
::
ParameterTree
;
Config
getIntervalConfig
()
const
{
Config
config
;
config
[
"type"
]
=
"interval"
;
config
[
"lowerCorner"
]
=
"0.0"
;
config
[
"upperCorner"
]
=
"1.0"
;
config
[
"elements"
]
=
"3"
;
return
config
;
}
Config
getRectangleConfig
()
const
{
Config
config
;
config
[
"type"
]
=
"rectangle"
;
config
[
"lowerCorner"
]
=
"0.0 0.0"
;
config
[
"upperCorner"
]
=
"1.0 1.0"
;
config
[
"elements"
]
=
"3 3"
;
config
[
"tetrahedral"
]
=
"1"
;
return
config
;
}
Config
getCircleConfig
()
const
{
Config
config
;
config
[
"type"
]
=
"circle"
;
config
[
"center"
]
=
"0.0 0.0"
;
config
[
"radius"
]
=
"1.0"
;
return
config
;
}
Config
getTubeSegmentConfig
()
const
{
Config
config
;
config
[
"type"
]
=
"tubeSegment"
;
config
[
"center"
]
=
"0.0 0.0 0.0"
;
config
[
"thickness"
]
=
"0.2"
;
config
[
"length"
]
=
"2.0"
;
config
[
"innerRadius"
]
=
"1.0"
;
config
[
"fromAngle"
]
=
"0.0"
;
config
[
"toAngle"
]
=
"10.0"
;
config
[
"nElementRing"
]
=
"10"
;
config
[
"nElementLength"
]
=
"5"
;
config
[
"closeTube"
]
=
"0"
;
config
[
"axis"
]
=
"0"
;
config
[
"tetrahedra"
]
=
"1"
;
config
[
"parameterizedBoundary"
]
=
"0"
;
return
config
;
}
Config
getSphereConfig
()
const
{
Config
config
;
config
[
"type"
]
=
"sphere"
;
config
[
"center"
]
=
"0.0 0.0 0.0"
;
config
[
"radius"
]
=
"1.0"
;
return
config
;
}
Config
getCuboidConfig
()
const
{
Config
config
;
config
[
"type"
]
=
"cuboid"
;
config
[
"lowerCorner"
]
=
"0.0 0.0 0.0"
;
config
[
"upperCorner"
]
=
"1.0 1.0 1.0"
;
config
[
"elements"
]
=
"4 5 4"
;
config
[
"tetrahedral"
]
=
"1"
;
return
config
;
}
};
int
main
(
int
argc
,
char
**
argv
)
{
bool
passed
=
true
;
Dune
::
MPIHelper
::
instance
(
argc
,
argv
);
std
::
cout
<<
"This is GridConstructionTest v0.01"
<<
std
::
endl
;
GridConstructionTest
test
;
std
::
cout
<<
"Testing OneD grid construction."
<<
std
::
endl
;
passed
=
passed
&&
test
.
test1D
<
Dune
::
OneDGrid
>
();
#if HAVE_UG
std
::
cout
<<
"Testing UG grid construction."
<<
std
::
endl
;
passed
=
passed
&&
test
.
test2D
<
Dune
::
UGGrid
<
2
>>
();
passed
=
passed
&&
test
.
test3D
<
Dune
::
UGGrid
<
3
>>
();
#else // HAVE_UG
std
::
cout
<<
"No UG Grid available."
<<
std
::
endl
;
#endif // HAVE_UG
#if HAVE_DUNE_ALUGRID
std
::
cout
<<
"Testing ALU grid construction."
<<
std
::
endl
;
passed
=
passed
&&
test
.
test2D
<
SN_ALUGrid
<
2
>>
();
// passed = passed && test.test3D<SN_ALUGrid<3>>(); // makeSphere not compatible
#else // HAVE_DUNE_ALUGRID
std
::
cout
<<
"No ALU Grid available."
<<
std
::
endl
;
#endif // HAVE_DUNE_ALUGRID
return
passed
?
0
:
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