Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
dune-alugrid
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
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
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
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
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ag-ohlberger
dune-community
dune-alugrid
Commits
aef8a822
Commit
aef8a822
authored
9 years ago
by
Robert K
Browse files
Options
Downloads
Patches
Plain Diff
[bugfix][SFC] insert elements following the SFC ordering.
parent
7bea69bf
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
dune/alugrid/common/hsfc.hh
+29
-26
29 additions, 26 deletions
dune/alugrid/common/hsfc.hh
dune/alugrid/common/structuredgridfactory.hh
+29
-3
29 additions, 3 deletions
dune/alugrid/common/structuredgridfactory.hh
with
58 additions
and
29 deletions
dune/alugrid/common/hsfc.hh
+
29
−
26
View file @
aef8a822
...
@@ -90,7 +90,7 @@ namespace ALUGridSFC {
...
@@ -90,7 +90,7 @@ namespace ALUGridSFC {
#endif // if HAVE_ZOLTAN
#endif // if HAVE_ZOLTAN
template
<
class
GridView
>
template
<
class
GridView
>
void
printSpaceFillingCurve
(
const
GridView
&
view
,
std
::
string
name
=
"sfc"
)
void
printSpaceFillingCurve
(
const
GridView
&
view
,
std
::
string
name
=
"sfc"
,
const
bool
vtk
=
false
)
{
{
typedef
typename
GridView
::
template
Codim
<
0
>
::
Iterator
Iterator
;
typedef
typename
GridView
::
template
Codim
<
0
>
::
Iterator
Iterator
;
typedef
typename
Iterator
::
Entity
::
Geometry
::
GlobalCoordinate
GlobalCoordinate
;
typedef
typename
Iterator
::
Entity
::
Geometry
::
GlobalCoordinate
GlobalCoordinate
;
...
@@ -120,35 +120,38 @@ namespace ALUGridSFC {
...
@@ -120,35 +120,38 @@ namespace ALUGridSFC {
gnuFile
.
close
();
gnuFile
.
close
();
}
}
std
::
stringstream
vtkfilename
;
if
(
vtk
)
vtkfilename
<<
name
<<
".vtk"
;
if
(
view
.
grid
().
comm
().
size
()
>
1
)
vtkfilename
<<
"."
<<
view
.
grid
().
comm
().
rank
();
std
::
ofstream
vtkFile
(
vtkfilename
.
str
()
);
if
(
vtkFile
)
{
{
vtkFile
<<
"# vtk DataFile Version 1.0"
<<
std
::
endl
;
std
::
stringstream
vtkfilename
;
vtk
F
ile
<<
"Line representation of vtk"
<<
std
::
endl
;
vtk
f
ile
name
<<
name
<<
".vtk"
;
vtkFile
<<
"ASCII"
<<
std
::
endl
;
if
(
view
.
grid
().
comm
().
size
()
>
1
)
vtk
F
ile
<<
"
DATASET POLYDATA"
<<
std
::
endl
;
vtk
f
ile
name
<<
"
."
<<
view
.
grid
().
comm
().
rank
()
;
vtkFile
<<
"POINTS "
<<
vertices
.
size
()
<<
" FLOAT"
<<
std
::
endl
;
std
::
ofstream
vtkFile
(
vtkfilename
.
str
()
)
;
for
(
size_t
i
=
0
;
i
<
vertices
.
size
();
++
i
)
if
(
vtkFile
)
{
{
vtkFile
<<
vertices
[
i
];
vtkFile
<<
"# vtk DataFile Version 1.0"
<<
std
::
endl
;
for
(
int
d
=
GlobalCoordinate
::
dimension
;
d
<
3
;
++
d
)
vtkFile
<<
"Line representation of vtk"
<<
std
::
endl
;
vtkFile
<<
" 0"
;
vtkFile
<<
"ASCII"
<<
std
::
endl
;
vtkFile
<<
std
::
endl
;
vtkFile
<<
"DATASET POLYDATA"
<<
std
::
endl
;
vtkFile
<<
"POINTS "
<<
vertices
.
size
()
<<
" FLOAT"
<<
std
::
endl
;
for
(
size_t
i
=
0
;
i
<
vertices
.
size
();
++
i
)
{
vtkFile
<<
vertices
[
i
];
for
(
int
d
=
GlobalCoordinate
::
dimension
;
d
<
3
;
++
d
)
vtkFile
<<
" 0"
;
vtkFile
<<
std
::
endl
;
}
// lines, #lines, #entries
vtkFile
<<
"LINES "
<<
vertices
.
size
()
-
1
<<
" "
<<
(
vertices
.
size
()
-
1
)
*
3
<<
std
::
endl
;
for
(
size_t
i
=
0
;
i
<
vertices
.
size
()
-
1
;
++
i
)
vtkFile
<<
"2 "
<<
i
<<
" "
<<
i
+
1
<<
std
::
endl
;
vtkFile
.
close
();
}
}
// lines, #lines, #entries
vtkFile
<<
"LINES "
<<
vertices
.
size
()
-
1
<<
" "
<<
(
vertices
.
size
()
-
1
)
*
3
<<
std
::
endl
;
for
(
size_t
i
=
0
;
i
<
vertices
.
size
()
-
1
;
++
i
)
vtkFile
<<
"2 "
<<
i
<<
" "
<<
i
+
1
<<
std
::
endl
;
vtkFile
.
close
();
}
}
}
}
...
...
This diff is collapsed.
Click to expand it.
dune/alugrid/common/structuredgridfactory.hh
+
29
−
3
View file @
aef8a822
...
@@ -102,6 +102,20 @@ namespace Dune
...
@@ -102,6 +102,20 @@ namespace Dune
}
}
public
:
public
:
template
<
class
Entity
>
double
index
(
const
Entity
&
entity
)
const
{
alugrid_assert
(
Entity
::
codimension
==
0
);
#ifdef USE_ALUGRID_SFC_ORDERING
// get center of entity's geometry
VertexType
center
=
entity
.
geometry
().
center
();
// get hilbert index in [0,1]
return
sfc_
.
index
(
center
);
#else
return
double
(
indexSet_
.
index
(
entity
));
#endif
}
template
<
class
Entity
>
template
<
class
Entity
>
int
rank
(
const
Entity
&
entity
)
const
int
rank
(
const
Entity
&
entity
)
const
{
{
...
@@ -131,7 +145,6 @@ namespace Dune
...
@@ -131,7 +145,6 @@ namespace Dune
return
pSize_
-
1
;
return
pSize_
-
1
;
}
}
protected
:
void
calculateElementCuts
()
void
calculateElementCuts
()
{
{
const
size_t
nElements
=
indexSet_
.
size
(
0
);
const
size_t
nElements
=
indexSet_
.
size
(
0
);
...
@@ -196,7 +209,7 @@ namespace Dune
...
@@ -196,7 +209,7 @@ namespace Dune
std
::
vector
<
long
int
>
elementCuts_
;
std
::
vector
<
long
int
>
elementCuts_
;
#ifdef USE_ALUGRID_SFC_ORDERING
#ifdef USE_ALUGRID_SFC_ORDERING
// get element to hilbert index mapping
// get element to hilbert
(or Z)
index mapping
SpaceFillingCurveOrdering
<
VertexType
>
sfc_
;
SpaceFillingCurveOrdering
<
VertexType
>
sfc_
;
#endif
#endif
const
double
maxIndex_
;
const
double
maxIndex_
;
...
@@ -371,19 +384,31 @@ namespace Dune
...
@@ -371,19 +384,31 @@ namespace Dune
// map global vertex ids to local ones
// map global vertex ids to local ones
std
::
map
<
IndexType
,
unsigned
int
>
vtxMap
;
std
::
map
<
IndexType
,
unsigned
int
>
vtxMap
;
std
::
map
<
double
,
const
Entity
>
sortedElementList
;
const
int
numVertices
=
(
1
<<
dim
);
const
int
numVertices
=
(
1
<<
dim
);
std
::
vector
<
unsigned
int
>
vertices
(
numVertices
);
std
::
vector
<
unsigned
int
>
vertices
(
numVertices
);
int
nextElementIndex
=
0
;
const
ElementIterator
end
=
gridView
.
template
end
<
0
>();
const
ElementIterator
end
=
gridView
.
template
end
<
0
>();
for
(
ElementIterator
it
=
gridView
.
template
begin
<
0
>();
it
!=
end
;
++
it
)
for
(
ElementIterator
it
=
gridView
.
template
begin
<
0
>();
it
!=
end
;
++
it
)
{
{
const
Entity
&
entity
=
*
it
;
const
Entity
&
entity
=
*
it
;
// if the element does not belong to our partition, continue
// if the element does not belong to our partition, continue
if
(
partitioner
.
rank
(
entity
)
!=
myrank
)
if
(
partitioner
.
rank
(
entity
)
!=
myrank
)
continue
;
continue
;
const
double
elIndex
=
partitioner
.
index
(
entity
);
assert
(
sortedElementList
.
find
(
elIndex
)
==
sortedElementList
.
end
()
);
sortedElementList
.
insert
(
std
::
make_pair
(
elIndex
,
entity
)
);
}
int
nextElementIndex
=
0
;
const
auto
endSorted
=
sortedElementList
.
end
();
for
(
auto
it
=
sortedElementList
.
begin
();
it
!=
endSorted
;
++
it
)
{
const
Entity
&
entity
=
(
*
it
).
second
;
// insert vertices and element
// insert vertices and element
const
typename
Entity
::
Geometry
geo
=
entity
.
geometry
();
const
typename
Entity
::
Geometry
geo
=
entity
.
geometry
();
alugrid_assert
(
numVertices
==
geo
.
corners
()
);
alugrid_assert
(
numVertices
==
geo
.
corners
()
);
...
@@ -397,6 +422,7 @@ namespace Dune
...
@@ -397,6 +422,7 @@ namespace Dune
factory
.
insertVertex
(
geo
.
corner
(
i
),
vtxId
);
factory
.
insertVertex
(
geo
.
corner
(
i
),
vtxId
);
vertices
[
i
]
=
result
.
first
->
second
;
vertices
[
i
]
=
result
.
first
->
second
;
}
}
factory
.
insertElement
(
entity
.
type
(),
vertices
);
factory
.
insertElement
(
entity
.
type
(),
vertices
);
const
int
elementIndex
=
nextElementIndex
++
;
const
int
elementIndex
=
nextElementIndex
++
;
...
...
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