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
bd3dfe93
Commit
bd3dfe93
authored
19 years ago
by
Robert Klöfkorn
Browse files
Options
Downloads
Patches
Plain Diff
Interior and ghost iterators for leaf at the moment.
[[Imported from SVN: r2235]]
parent
9d175d82
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
grid/alu3dgrid/alu3dinclude.hh
+355
-46
355 additions, 46 deletions
grid/alu3dgrid/alu3dinclude.hh
with
355 additions
and
46 deletions
grid/alu3dgrid/alu3dinclude.hh
+
355
−
46
View file @
bd3dfe93
...
...
@@ -230,95 +230,404 @@ namespace ALU3dGridSpace {
};
template
<
int
codim
>
class
ALU3dGridLeafIteratorWrapper
;
template
<
class
val_t
>
class
IteratorWrapperInterface
{
public:
virtual
~
IteratorWrapperInterface
()
{}
virtual
int
size
()
=
0
;
virtual
void
next
()
=
0
;
virtual
void
first
()
=
0
;
virtual
int
done
()
=
0
;
virtual
val_t
&
item
()
=
0
;
};
typedef
Dune
::
PartitionIteratorType
PartitionIteratorType
;
template
<
int
codim
,
PartitionIteratorType
pitype
>
class
ALU3dGridLeafIteratorWrapper
;
typedef
pair
<
ALUHElementType
<
0
>::
ElementType
*
,
BNDFace3Type
*
>
LeafValType
;
typedef
IteratorWrapperInterface
<
LeafValType
>
IteratorWrapperInterfaceType
;
//**********************************************************
// LeafIterator Wrapper
//**********************************************************
template
<
>
class
ALU3dGridLeafIteratorWrapper
<
0
>
template
<
PartitionIteratorType
pitype
>
class
ALU3dGridLeafIteratorWrapper
<
0
,
pitype
>
:
public
IteratorWrapperInterface
<
LeafValType
>
{
typedef
ALUHElementType
<
0
>::
ElementType
ElType
;
typedef
Insert
<
AccessIterator
<
ElType
>::
Handle
,
TreeIterator
<
ElType
,
leaf_or_has_level
<
ElType
>
>
>
IteratorType
;
IteratorType
it_
;
typedef
IteratorType
::
val_t
val_t
;
//typedef IteratorType :: val_t val_t;
typedef
LeafValType
val_t
;
val_t
elem_
;
public:
template
<
class
GridImp
>
ALU3dGridLeafIteratorWrapper
(
const
GridImp
&
grid
,
int
level
)
:
it_
(
const_cast
<
GridImp
&>
(
grid
).
myGrid
().
container
(),
level
)
{}
ALU3dGridLeafIteratorWrapper
(
const
GridImp
&
grid
,
int
level
)
:
it_
(
const_cast
<
GridImp
&>
(
grid
).
myGrid
().
container
(),
level
)
{
elem_
.
first
=
0
;
elem_
.
second
=
0
;
}
int
size
()
{
return
it_
.
size
();
}
void
next
()
{
it_
.
next
();
}
void
first
()
{
it_
.
first
();
}
int
done
()
{
return
it_
.
done
();
}
val_t
&
item
()
{
return
it_
.
item
();
}
val_t
&
item
()
{
elem_
.
first
=
&
it_
.
item
();
return
elem_
;
}
};
template
<
>
class
ALU3dGridLeafIteratorWrapper
<
1
>
/*
template <>
class ALU3dGridLeafIteratorWrapper<1> : public IteratorWrapperInterface
{
typedef ALUHElementType<1>::ElementType ElType;
typedef Insert < AccessIterator < ElType >::Handle,
TreeIterator < ElType , leaf_or_has_level < ElType > > > IteratorType;
IteratorType it_;
typedef IteratorType :: val_t val_t;
public:
template <class GridImp>
ALU3dGridLeafIteratorWrapper (const GridImp & grid, int level )
: it_(const_cast<GridImp &> (grid).myGrid().container(),level) {}
int size () { return it_.size(); }
void next () { it_.next(); }
void first() { it_.first(); }
int done () { return it_.done(); }
val_t & item () { return it_.item(); }
};
template <>
class ALU3dGridLeafIteratorWrapper<2> : public IteratorWrapperInterface
{
typedef ALUHElementType<2>::ElementType ElType;
typedef Insert < AccessIterator < ElType >::Handle,
TreeIterator < ElType , leaf_or_has_level < ElType > > > IteratorType;
IteratorType it_;
typedef IteratorType :: val_t val_t;
public:
template <class GridImp>
ALU3dGridLeafIteratorWrapper (const GridImp & grid, int level )
: it_(const_cast<GridImp &> (grid).myGrid().container(),level) {}
int size () { return it_.size(); }
void next () { it_.next(); }
void first() { it_.first(); }
int done () { return it_.done(); }
val_t & item () { return it_.item(); }
};
template <>
class ALU3dGridLeafIteratorWrapper<3> : public IteratorWrapperInterface
{
typedef LeafIterator < GitterType::vertex_STI > IteratorType;
IteratorType it_;
typedef IteratorType :: val_t val_t;
public:
template <class GridImp>
ALU3dGridLeafIteratorWrapper (const GridImp & grid, int level )
: it_(const_cast<GridImp &> (grid).myGrid()) {}
int size () { return it_->size(); }
void next () { it_->next(); }
void first() { it_->first(); }
int done () { return it_->done(); }
val_t & item () { return it_->item(); }
};
*/
#ifdef _ALU3DGRID_PARALLEL_
class
LeafLevelIteratorTT
{
typedef
ALUHElementType
<
1
>::
ElementType
ElType
;
typedef
Insert
<
AccessIterator
<
ElType
>::
Handle
,
TreeIterator
<
ElType
,
leaf_or_has_level
<
ElType
>
>
>
IteratorType
;
IteratorType
it_
;
typedef
IteratorType
::
val_t
val_t
;
typedef
Insert
<
AccessIteratorTT
<
ElType
>
::
InnerHandle
,
TreeIterator
<
ElType
,
leaf_minus_one
<
ElType
>
>
>
InnerIteratorType
;
typedef
Insert
<
AccessIteratorTT
<
ElType
>
::
OuterHandle
,
TreeIterator
<
ElType
,
leaf_minus_one
<
ElType
>
>
>
OuterIteratorType
;
typedef
IteratorSTI
<
ElType
>
IteratorType
;
AccessIteratorTT
<
ElType
>
::
InnerHandle
mif_
;
AccessIteratorTT
<
ElType
>
::
OuterHandle
mof_
;
InnerIteratorType
wi_
;
OuterIteratorType
wo_
;
public:
template
<
class
GridImp
>
ALU3dGridLeafIteratorWrapper
(
const
GridImp
&
grid
,
int
level
)
:
it_
(
const_cast
<
GridImp
&>
(
grid
).
myGrid
().
container
(),
level
)
{}
int
size
()
{
return
it_
.
size
();
}
void
next
()
{
it_
.
next
();
}
void
first
()
{
it_
.
first
();
}
int
done
()
{
return
it_
.
done
();
}
val_t
&
item
()
{
return
it_
.
item
();
}
LeafLevelIteratorTT
(
GitterImplType
&
gitter
,
int
link
,
int
level
)
:
mif_
(
gitter
.
containerPll
(),
link
)
,
mof_
(
gitter
.
containerPll
(),
link
)
,
wi_
(
mif_
)
,
wo_
(
mof_
)
{
}
IteratorType
&
inner
()
{
return
wi_
;
}
IteratorType
&
outer
()
{
return
wo_
;
}
};
template
<
>
class
ALU3dGridLeafIteratorWrapper
<
2
>
class
ALU3dGridLeafIteratorWrapper
<
0
,
Dune
::
Ghost_Partition
>
:
public
IteratorWrapperInterface
<
LeafValType
>
{
typedef
ALUHElementType
<
2
>::
ElementType
ElType
;
typedef
Insert
<
AccessIterator
<
ElType
>::
Handle
,
TreeIterator
<
ElType
,
leaf_or_has_level
<
ElType
>
>
>
IteratorType
;
GitterImplType
&
gitter_
;
IteratorType
it_
;
typedef
IteratorType
::
val_t
val_t
;
typedef
ALUHElementType
<
1
>::
ElementType
ElType
;
private:
//typedef LeafIteratorTT < ElType > IteratorType;
typedef
LeafLevelIteratorTT
IteratorType
;
IteratorType
*
iterTT_
;
typedef
IteratorSTI
<
ElType
>
InnerIteratorType
;
InnerIteratorType
*
it_
;
//typedef InnerIteratorType :: val_t val_t;
typedef
LeafValType
val_t
;
// number of links
const
int
nl_
;
// current link
int
link_
;
const
int
levelMinusOne_
;
// the pair of elementand boundary face
val_t
elem_
;
public:
typedef
ElementPllXIF_t
ItemType
;
template
<
class
GridImp
>
ALU3dGridLeafIteratorWrapper
(
const
GridImp
&
grid
,
int
level
)
:
it_
(
const_cast
<
GridImp
&>
(
grid
).
myGrid
().
container
(),
level
)
{}
ALU3dGridLeafIteratorWrapper
(
const
GridImp
&
grid
,
int
level
,
const
int
nlinks
)
:
gitter_
(
const_cast
<
GridImp
&>
(
grid
).
myGrid
())
,
iterTT_
(
0
)
,
it_
(
0
),
nl_
(
nlinks
)
,
link_
(
0
)
,
levelMinusOne_
(
(
level
>
0
)
?
(
level
-
1
)
:
0
)
{
elem_
.
first
=
0
;
elem_
.
second
=
0
;
createIterator
();
}
int
size
()
{
return
it_
.
size
();
}
void
next
()
{
it_
.
next
();
}
void
first
()
{
it_
.
first
();
}
int
done
()
{
return
it_
.
done
();
}
val_t
&
item
()
{
return
it_
.
item
();
}
~
ALU3dGridLeafIteratorWrapper
()
{
if
(
iterTT_
)
delete
iterTT_
;
}
void
createIterator
()
{
if
(
link_
<
nl_
)
{
if
(
iterTT_
)
delete
iterTT_
;
iterTT_
=
0
;
iterTT_
=
new
IteratorType
(
gitter_
,
link_
,
levelMinusOne_
);
assert
(
iterTT_
);
checkInnerOuter
();
}
else
{
if
(
iterTT_
)
delete
iterTT_
;
iterTT_
=
0
;
it_
=
0
;
}
}
void
checkInnerOuter
()
{
assert
(
iterTT_
);
it_
=
&
(
iterTT_
->
inner
()
);
InnerIteratorType
&
it
=
iterTT_
->
inner
();
it
.
first
();
if
(
!
it
.
done
())
{
pair
<
ElementPllXIF_t
*
,
int
>
p
=
it
.
item
().
accessPllX
().
accessOuterPllX
()
;
pair
<
Gitter
::
helement_STI
*
,
Gitter
::
hbndseg_STI
*
>
elems
;
p
.
first
->
getAttachedElement
(
elems
);
assert
(
elems
.
first
||
elems
.
second
);
if
(
elems
.
second
)
{
return
;
}
}
InnerIteratorType
&
out
=
iterTT_
->
outer
();
out
.
first
();
if
(
!
out
.
done
())
{
pair
<
ElementPllXIF_t
*
,
int
>
p
=
out
.
item
().
accessPllX
().
accessOuterPllX
()
;
pair
<
Gitter
::
helement_STI
*
,
Gitter
::
hbndseg_STI
*
>
elems
;
p
.
first
->
getAttachedElement
(
elems
);
assert
(
elems
.
second
);
it_
=
&
out
;
return
;
}
assert
(
false
);
it_
=
0
;
}
int
size
()
{
if
(
!
it_
)
{
assert
(
false
);
return
0
;
}
return
it_
->
size
();
}
void
checkLevel
()
{
if
(
it_
)
{
if
(
!
it_
->
done
())
{
val_t
&
el
=
item
();
BNDFace3Type
*
face
=
el
.
second
;
assert
(
face
);
if
(
face
->
leaf
()
)
{
// if the ghost is not used, go to next ghost
if
(
face
->
ghostLevel
()
!=
face
->
level
()
)
next
()
;
}
else
{
BNDFace3Type
*
dwn
=
dynamic_cast
<
BNDFace3Type
*
>
(
face
->
down
());
assert
(
dwn
);
// if owr child is ok then we go to the children
if
(
dwn
->
ghostLevel
()
==
dwn
->
level
())
next
();
}
}
}
}
// go next ghost
void
next
()
{
if
(
it_
)
{
it_
->
next
();
}
if
(
it_
->
done
())
{
link_
++
;
createIterator
();
}
checkLevel
();
// if we still have iterator
}
void
first
()
{
link_
=
0
;
createIterator
();
if
(
it_
)
it_
->
first
();
checkLevel
();
}
int
done
()
{
if
(
link_
>=
nl_
)
return
1
;
return
((
it_
)
?
it_
->
done
()
:
1
);
}
val_t
&
item
()
{
assert
(
it_
);
pair
<
ElementPllXIF_t
*
,
int
>
p
=
it_
->
item
().
accessPllX
().
accessOuterPllX
()
;
pair
<
Gitter
::
helement_STI
*
,
Gitter
::
hbndseg_STI
*
>
p2
;
p
.
first
->
getAttachedElement
(
p2
);
assert
(
p2
.
second
);
elem_
.
second
=
dynamic_cast
<
BNDFace3Type
*
>
(
p2
.
second
);
return
elem_
;
}
};
// the all partition iterator
template
<
>
class
ALU3dGridLeafIteratorWrapper
<
3
>
class
ALU3dGridLeafIteratorWrapper
<
0
,
Dune
::
All_Partition
>
:
public
IteratorWrapperInterface
<
LeafValType
>
{
typedef
LeafIterator
<
GitterType
::
vertex_STI
>
IteratorType
;
IteratorType
it_
;
typedef
IteratorType
::
val_t
val_t
;
ALU3dGridLeafIteratorWrapper
<
0
,
Dune
::
InteriorBorder_Partition
>
interior_
;
ALU3dGridLeafIteratorWrapper
<
0
,
Dune
::
Ghost_Partition
>
ghosts_
;
typedef
LeafValType
val_t
;
bool
useInterior_
;
public:
typedef
ElementPllXIF_t
ItemType
;
template
<
class
GridImp
>
ALU3dGridLeafIteratorWrapper
(
const
GridImp
&
grid
,
int
level
)
:
it_
(
const_cast
<
GridImp
&>
(
grid
).
myGrid
())
{}
ALU3dGridLeafIteratorWrapper
(
const
GridImp
&
grid
,
int
level
,
const
int
nlinks
)
:
interior_
(
grid
,
level
)
,
ghosts_
(
grid
,
level
,
nlinks
)
,
useInterior_
(
true
)
{}
int
size
()
{
return
it_
->
size
();
}
void
next
()
{
it_
->
next
();
}
void
first
()
{
it_
->
first
();
}
int
done
()
{
return
it_
->
done
();
}
val_t
&
item
()
{
return
it_
->
item
();
}
int
size
()
{
return
interior_
.
size
()
+
ghosts_
.
size
();
}
void
next
()
{
if
(
useInterior_
)
{
interior_
.
next
();
if
(
interior_
.
done
())
{
useInterior_
=
false
;
ghosts_
.
first
();
}
}
else
{
ghosts_
.
next
();
}
}
void
first
()
{
useInterior_
=
true
;
interior_
.
first
();
}
int
done
()
{
if
(
useInterior_
)
return
0
;
return
ghosts_
.
done
();
}
val_t
&
item
()
{
if
(
useInterior_
)
return
interior_
.
item
();
else
return
ghosts_
.
item
();
}
};
#endif
//*************************************************************
typedef
LeafIterator
<
GitterType
::
helement_STI
>
BSLeafIteratorMaxLevel
;
...
...
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