Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
dune-common
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
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
Timo Koch
dune-common
Commits
9859b77b
Commit
9859b77b
authored
19 years ago
by
Oliver Sander
Browse files
Options
Downloads
Patches
Plain Diff
test element data
[[Imported from SVN: r4133]]
parent
8282ab86
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
grid/common/test/mcmgmappertest.cc
+68
-64
68 additions, 64 deletions
grid/common/test/mcmgmappertest.cc
with
68 additions
and
64 deletions
grid/common/test/mcmgmappertest.cc
+
68
−
64
View file @
9859b77b
...
...
@@ -17,34 +17,37 @@
using
namespace
Dune
;
#if 0
template <class GridType, class HostIndexSet>
void checkMapper(const PanTypeIndexSet<GridType,HostIndexSet>& panTypeIndexSet,
const HostIndexSet& hostIndexSet)
// Parameter for mapper class
template
<
int
dim
>
struct
ElementDataLayout
{
// //////////////////////////////////////////////////////////////
// Check whether the size methods give the correct result
// //////////////////////////////////////////////////////////////
for (int codim=0; codim<=GridType::dimension; codim++) {
assert(panTypeIndexSet.geomTypes(codim) == hostIndexSet.geomTypes(codim));
assert(panTypeIndexSet.size(codim) == hostIndexSet.size(codim));
for (size_t i=0; i<panTypeIndexSet.geomTypes(codim).size(); i++) {
NewGeometryType type = panTypeIndexSet.geomTypes(codim)[i];
assert(panTypeIndexSet.size(codim,type) == hostIndexSet.size(codim,type));
}
bool
contains
(
int
codim
,
Dune
::
GeometryType
gt
)
{
return
codim
==
0
;
}
};
template
<
int
dim
>
struct
FaceDataLayout
{
bool
contains
(
int
codim
,
Dune
::
GeometryType
gt
)
{
return
codim
==
1
;
}
};
// ///////////////////////////////////////////////////////////////////////////
// Check whether the index for codim 0 is consecutive and zero starting
// ///////////////////////////////////////////////////////////////////////////
typedef typename PanTypeIndexSet<GridType,HostIndexSet>::template Codim<0>::template Partition<All_Partition>::Iterator Iterator;
// /////////////////////////////////////////////////////////////////////////////////
// Check whether the index created for element data is unique, consecutive
// and starting from zero.
// /////////////////////////////////////////////////////////////////////////////////
template
<
class
Mapper
,
class
IndexSet
>
void
checkElementDataMapper
(
const
Mapper
&
mapper
,
const
IndexSet
&
indexSet
)
{
typedef
typename
IndexSet
::
template
Codim
<
0
>
::
template
Partition
<
All_Partition
>
::
Iterator
Iterator
;
Iterator eIt =
panTypeI
ndexSet.template begin<0,All_Partition>();
Iterator eEndIt =
panTypeI
ndexSet.template end<0,All_Partition>();
Iterator
eIt
=
i
ndexSet
.
template
begin
<
0
,
All_Partition
>();
Iterator
eEndIt
=
i
ndexSet
.
template
end
<
0
,
All_Partition
>();
int
min
=
1
;
int
max
=
0
;
...
...
@@ -52,7 +55,7 @@ void checkMapper(const PanTypeIndexSet<GridType,HostIndexSet>& panTypeIndexSet,
for
(;
eIt
!=
eEndIt
;
++
eIt
)
{
int index =
panTypeIndexSet.template index<0>
(*eIt);
int
index
=
mapper
.
map
(
*
eIt
);
min
=
std
::
min
(
min
,
index
);
max
=
std
::
max
(
max
,
index
);
...
...
@@ -60,30 +63,35 @@ void checkMapper(const PanTypeIndexSet<GridType,HostIndexSet>& panTypeIndexSet,
std
::
pair
<
std
::
set
<
int
>::
iterator
,
bool
>
status
=
indices
.
insert
(
index
);
if
(
!
status
.
second
)
// not inserted because already existing
DUNE_THROW(GridError, "
PanTypeI
ndex is not unique!");
DUNE_THROW
(
GridError
,
"
Mapper element i
ndex is not unique!"
);
}
if
(
min
!=
0
)
DUNE_THROW(GridError, "
PanTypeI
ndex is not starting from zero!");
DUNE_THROW
(
GridError
,
"
Mapper element i
ndex is not starting from zero!"
);
if (max!=
panTypeI
ndexSet.size(0)-1)
DUNE_THROW(GridError, "
PanTypeI
ndex is not consecutive!");
if
(
max
!=
i
ndexSet
.
size
(
0
)
-
1
)
DUNE_THROW
(
GridError
,
"
Mapper element i
ndex is not consecutive!"
);
}
// ///////////////////////////////////////////////////////////////////////////
// Check whether the index for codim 1 is consecutive and zero starting
// ///////////////////////////////////////////////////////////////////////////
// /////////////////////////////////////////////////////////////////////////////////
// Check whether the index created for face data is unique, consecutive
// and starting from zero.
// /////////////////////////////////////////////////////////////////////////////////
template
<
class
Mapper
,
class
IndexSet
>
void
checkFaceDataMapper
(
const
Mapper
&
mapper
,
const
IndexSet
&
indexSet
)
{
#if 0
typedef typename IndexSet::template Codim<0>::template Partition<All_Partition>::Iterator Iterator;
eIt = panTypeIndexSet.template begin<0,All_Partition>();
Iterator eIt = indexSet.template begin<0,All_Partition>();
Iterator eEndIt = indexSet.template end<0,All_Partition>();
// Reset the counting variables
min = 1;
max = 0;
int
min = 1;
int
max = 0;
indices.clear();
// Currently there are no iterators over codim-1 entities. Therefore we have to
// simulate them with an element iterator and an intersection iterator.
for (; eIt!=eEndIt; ++eIt) {
typedef typename GridType::template Codim<0>::Entity::IntersectionIterator IntersectionIterator;
...
...
@@ -93,13 +101,15 @@ void checkMapper(const PanTypeIndexSet<GridType,HostIndexSet>& panTypeIndexSet,
for (; iIt!=iEndIt; ++iIt) {
#if 0
// The correctness of the pan-type index for codim 0 has been checked above.
// So now we can use it.
if (iIt.neighbor()
&& panTypeIndexSet.template index<0>(*eIt) > panTypeIndexSet.template index<0>(*iIt.outside()))
continue;
#endif
int index =
panTypeIndexSet.template subIndex<1>
(*eIt, iIt.numberInSelf());
int index =
mapper.map
(*eIt, iIt.numberInSelf());
// std::cout << hostIndexSet.template subIndex<1>(*eIt, iIt.numberInSelf())
// << " Index: " << index << " type: " << eIt->geometry().type() << std::endl;
...
...
@@ -109,36 +119,32 @@ void checkMapper(const PanTypeIndexSet<GridType,HostIndexSet>& panTypeIndexSet,
std::pair<std::set<int>::iterator, bool> status = indices.insert(index);
if (!status.second) // not inserted because already existing
DUNE_THROW(GridError, "
PanTypeI
ndex is not unique!");
DUNE_THROW(GridError, "
Mapper i
ndex is not unique!");
}
}
if (min!=0)
DUNE_THROW(GridError, "
PanTypeI
ndex for codim 1 is not starting from zero!");
DUNE_THROW(GridError, "
Mapper i
ndex for codim 1 is not starting from zero!");
if (max!=
panTypeI
ndexSet.size(1)
-1
)
DUNE_THROW(GridError, "
PanTypeI
ndex for codim 1 is not consecutive!");
if (max!=
i
ndexSet.size(1))
DUNE_THROW(GridError, "
Mapper i
ndex for codim 1 is not consecutive!");
}
#endif
}
/*
PanTypeIndexSets only do something helpful on grids with more than one
element type. So far only UGGrids do this, so we use them to test
the index set.
The MultipleGeometryMultipleCodimMapper only does something helpful on grids with more
than one element type. So far only UGGrids do this, so we use them to test the mapper.
*/
int
main
()
try
{
#if 0
// ////////////////////////////////////////////////////////////////////////
// Do the
standard grid
test for a 2d UGGrid
// Do the test for a 2d UGGrid
// ////////////////////////////////////////////////////////////////////////
// extra-environment to check destruction
{
typedef
UGGrid
<
2
,
2
>
GridType
;
typedef
GridType
::
Traits
::
LeafIndexSet
LeafIndexSetType
;
...
...
@@ -152,18 +158,17 @@ int main () try
grid
.
adapt
();
grid
.
globalRefine
(
1
);
// PanTypeIndexSet<GridType, LeafIndexSetType> panTypeLeafIndexSet(grid, grid.leafIndexSet()
);
// checkPanTypeIndexSet(panTypeLeafIndexSet
, grid.leafIndexSet());
LeafMultipleCodimMultipleGeomTypeMapper
<
GridType
,
ElementDataLayout
>
leafMCMGMapper
(
grid
);
checkElementDataMapper
(
leafMCMGMapper
,
grid
.
leafIndexSet
());
for
(
int
i
=
2
;
i
<=
grid
.
maxLevel
();
i
++
)
{
PanTypeIndexSet<GridType, LevelIndexSetType> panTypeLevelIndexSet(grid, grid.levelIndexSet(i)
);
check
PanTypeIndexSet(panTypeLevelIndexSet
, grid.levelIndexSet(i));
LevelMultipleCodimMultipleGeomTypeMapper
<
GridType
,
ElementDataLayout
>
levelMCMGMapper
(
grid
,
i
);
check
ElementDataMapper
(
levelMCMGMapper
,
grid
.
levelIndexSet
(
i
));
}
}
// ////////////////////////////////////////////////////////////////////////
// Do the
standard grid
test for a 3d UGGrid
// Do the test for a 3d UGGrid
// ////////////////////////////////////////////////////////////////////////
{
typedef
UGGrid
<
3
,
3
>
GridType
;
...
...
@@ -178,16 +183,15 @@ int main () try
grid
.
adapt
();
grid
.
globalRefine
(
1
);
PanTypeIndexSet<GridType, LeafIndexSetType> panTypeLeafIndexSet(grid, grid.leafIndexSet()
);
check
PanTypeIndexSet(panTypeLeafIndexSet
, grid.leafIndexSet());
LeafMultipleCodimMultipleGeomTypeMapper
<
GridType
,
ElementDataLayout
>
leafMCMGMapper
(
grid
);
check
ElementDataMapper
(
leafMCMGMapper
,
grid
.
leafIndexSet
());
for (int i=
0
; i<=grid.maxLevel(); i++) {
PanTypeIndexSet<GridType, LevelIndexSetType> panTypeLevelIndexSet(grid, grid.levelIndexSet(i)
);
check
PanTypeIndexSet(panTypeLevelIndexSet
, grid.levelIndexSet(i));
for
(
int
i
=
2
;
i
<=
grid
.
maxLevel
();
i
++
)
{
LevelMultipleCodimMultipleGeomTypeMapper
<
GridType
,
ElementDataLayout
>
levelMCMGMapper
(
grid
,
i
);
check
ElementDataMapper
(
levelMCMGMapper
,
grid
.
levelIndexSet
(
i
));
}
}
#endif
return
0
;
}
...
...
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