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
3ebbed23
Commit
3ebbed23
authored
7 years ago
by
alkaemper
Browse files
Options
Downloads
Patches
Plain Diff
add estimate closure for a uniformly refined mesh (multiple of d times
parent
91513036
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
utils/bisection-compatibility/estimate-closure.cc
+61
-13
61 additions, 13 deletions
utils/bisection-compatibility/estimate-closure.cc
with
61 additions
and
13 deletions
utils/bisection-compatibility/estimate-closure.cc
+
61
−
13
View file @
3ebbed23
...
...
@@ -15,18 +15,37 @@
template
<
class
GridType
>
void
estimateClosure
(
GridType
&
grid
)
void
estimateClosure
(
GridType
&
grid
,
int
level
=
0
)
{
const
std
::
size_t
macroSize
=
grid
.
levelGridView
(
0
).
size
(
0
);
//refine up to level
for
(
int
i
=
0
;
i
<
level
;
++
i
)
{
for
(
const
auto
&
entity
:
Dune
::
elements
(
grid
.
leafGridView
(
)
)
)
{
if
(
entity
.
level
()
<
level
)
{
grid
.
mark
(
1
,
entity
);
}
else
if
(
entity
.
level
()
>
level
)
{
grid
.
mark
(
-
1
,
entity
);
}
}
grid
.
preAdapt
();
grid
.
adapt
();
grid
.
postAdapt
();
}
const
size_t
macroSize
=
grid
.
leafGridView
().
size
(
0
);
const
size_t
nElements
=
grid
.
levelGridView
(
level
).
size
(
0
);
typedef
typename
GridType
::
LevelIndexSet
Level
IndexSetType
;
typedef
typename
Level
IndexSetType
::
I
ndex
Type
IdType
;
typedef
typename
GridType
::
GlobalIdSet
IndexSetType
;
typedef
typename
IndexSetType
::
I
d
Type
IdType
;
const
Level
IndexSetType
&
macroIdSet
=
grid
.
levelIndex
Set
(
0
);
const
IndexSetType
&
macroIdSet
=
grid
.
globalId
Set
();
std
::
map
<
IdType
,
size_t
>
elementClosure
;
typedef
typename
GridType
::
LeafGridView
LeafGridViewType
;
Dune
::
VTKSequenceWriter
<
LeafGridViewType
>
vtkout
(
grid
.
leafGridView
(),
"solution"
,
"./"
,
"."
,
Dune
::
VTK
::
nonconforming
);
Dune
::
VTKSequenceWriter
<
LeafGridViewType
>
vtkout
(
grid
.
leafGridView
(),
"solution"
+
level
,
"./"
,
"."
,
Dune
::
VTK
::
nonconforming
);
std
::
shared_ptr
<
VolumeData
<
LeafGridViewType
>
>
ptr
(
new
VolumeData
<
LeafGridViewType
>
(
)
);
vtkout
.
addCellData
(
ptr
);
...
...
@@ -35,10 +54,14 @@ void estimateClosure ( GridType &grid )
size_t
maxClosure
=
0
;
//loop over all macro elements.
for
(
const
auto
&
macroEntity
:
Dune
::
elements
(
grid
.
levelGridView
(
0
)
)
)
for
(
const
auto
&
macroEntity
:
Dune
::
elements
(
grid
.
levelGridView
(
level
)
)
)
{
//if elementClosure calculated - continue
const
IdType
macroId
=
macroIdSet
.
index
(
macroEntity
);
const
IdType
macroId
=
macroIdSet
.
id
(
macroEntity
);
if
(
elementClosure
.
find
(
macroId
)
!=
elementClosure
.
end
()
)
{
continue
;
}
//mark for refinement
grid
.
mark
(
1
,
macroEntity
);
//adapt
...
...
@@ -47,25 +70,49 @@ void estimateClosure ( GridType &grid )
grid
.
postAdapt
();
//loop over macro elements
size_t
closure
=
grid
.
leafGridView
().
size
(
0
)
-
macroSize
;
for
(
const
auto
&
entity
:
Dune
::
elements
(
grid
.
levelGridView
(
level
)
)
)
{
const
auto
id
=
macroIdSet
.
id
(
entity
);
if
(
!
entity
.
isLeaf
()
)
{
elementClosure
[
id
]
=
elementClosure
[
id
]
==
0
?
closure
:
std
::
min
(
closure
,
elementClosure
[
id
]
);
}
}
elementClosure
[
macroId
]
=
closure
;
if
(
closure
>
maxClosure
)
{
maxClosure
=
closure
;
std
::
cout
<<
"New maximum: "
<<
maxClosure
<<
std
::
endl
;
vtkout
.
write
(
double
(
closure
)
);
}
while
(
grid
.
leafGridView
().
size
(
0
)
!=
macroSize
)
std
::
cout
<<
"Before: "
<<
grid
.
leafGridView
().
size
(
0
)
<<
", after: "
;
//refine up to level
for
(
int
i
=
0
;
i
<
closure
*
(
level
+
1
);
++
i
)
{
if
(
grid
.
leafGridView
().
size
(
0
)
==
macroSize
)
break
;
for
(
const
auto
&
entity
:
Dune
::
elements
(
grid
.
leafGridView
(
)
)
)
{
grid
.
mark
(
-
1
,
entity
);
}
grid
.
preAdapt
();
grid
.
adapt
();
grid
.
postAdapt
();
}
//refine up to level
for
(
int
i
=
0
;
i
<
level
;
++
i
)
{
for
(
const
auto
&
entity
:
Dune
::
elements
(
grid
.
leafGridView
()
)
)
for
(
const
auto
&
entity
:
Dune
::
elements
(
grid
.
leafGridView
(
)
)
)
{
if
(
entity
.
level
()
>
0
)
if
(
entity
.
level
()
<
level
)
{
grid
.
mark
(
-
1
,
entity
);
grid
.
mark
(
1
,
entity
);
}
}
grid
.
preAdapt
();
grid
.
adapt
();
grid
.
postAdapt
();
}
std
::
cout
<<
grid
.
leafGridView
().
size
(
0
)
<<
std
::
endl
;
}
size_t
minClosure
=
1e10
;
...
...
@@ -77,7 +124,7 @@ void estimateClosure ( GridType &grid )
minClosure
=
std
::
min
(
closure
.
second
,
minClosure
);
avgClosure
+=
closure
.
second
;
}
avgClosure
/=
macroSize
;
avgClosure
/=
nElements
;
std
::
cout
<<
"Closure (min, max, avg): "
<<
minClosure
<<
" "
<<
maxClosure
<<
" "
<<
avgClosure
<<
std
::
endl
<<
std
::
endl
;
}
...
...
@@ -96,6 +143,7 @@ int main (int argc , char **argv) {
GridType
&
grid
=
*
gridPtr
;
grid
.
loadBalance
();
estimateClosure
(
grid
);
estimateClosure
(
grid
,
3
);
}
}
catch
(
Dune
::
Exception
&
e
)
...
...
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