Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
amdis-core
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
External wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Analyze
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
amdis
amdis-core
Commits
e1c34812
Commit
e1c34812
authored
5 years ago
by
Praetorius, Simon
Browse files
Options
Downloads
Patches
Plain Diff
Add attach function with callback to GridTransfer
parent
7e46647e
No related branches found
Branches containing commit
No related tags found
1 merge request
!97
Add attach function with callback to GridTransfer
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/amdis/GridTransfer.hpp
+20
-4
20 additions, 4 deletions
src/amdis/GridTransfer.hpp
src/amdis/GridTransferManager.hpp
+7
-2
7 additions, 2 deletions
src/amdis/GridTransferManager.hpp
with
27 additions
and
6 deletions
src/amdis/GridTransfer.hpp
+
20
−
4
View file @
e1c34812
...
...
@@ -86,16 +86,21 @@ namespace AMDiS
REQUIRES
(
Concepts
::
UpdateData
<
Data
>)
>
void
attach
(
Data
&
data
)
{
a
uto
it
=
updateCallbacks_
.
emplace
(
Key
(
&
data
),
UpdateCallback
{
[
&
data
]()
->
void
{
data
.
update
(
data
.
gridView
());
}});
a
ttach
(
data
,
[
&
data
]()
->
void
{
data
.
update
(
data
.
gridView
());
});
}
/// Register callback to GridTransfer
template
<
class
Data
,
class
Callback
>
void
attach
(
Data
const
&
data
,
Callback
&&
callback
)
{
auto
it
=
updateCallbacks_
.
emplace
(
Key
(
&
data
),
UpdateCallback
{
FWD
(
callback
)});
it
.
first
->
second
.
count
++
;
}
/// Unregister data from GridTransfer. Data is identified by its address.
template
<
class
Data
,
REQUIRES
(
Concepts
::
InterpolateData
<
Data
>)
>
void
detach
(
Data
&
data
)
void
detach
(
Data
const
&
data
)
{
eraseCallback
(
interpolateCallbacks_
,
Key
(
&
data
));
}
...
...
@@ -103,7 +108,7 @@ namespace AMDiS
/// Unregister data from GridTransfer. Data is identified by its address.
template
<
class
Data
,
REQUIRES
(
Concepts
::
UpdateData
<
Data
>)
>
void
detach
(
Data
&
data
)
void
detach
(
Data
const
&
data
)
{
eraseCallback
(
updateCallbacks_
,
Key
(
&
data
));
}
...
...
@@ -113,9 +118,14 @@ namespace AMDiS
bool
preAdapt
()
override
{
assert
(
bound
());
Dune
::
Timer
t
;
mightCoarsen_
=
grid_
->
preAdapt
();
Dune
::
MPIHelper
::
getCollectiveCommunication
().
max
(
&
mightCoarsen_
,
1
);
for
(
auto
&&
data
:
interpolateCallbacks_
)
data
.
second
.
preAdapt
(
mightCoarsen_
);
info
(
2
,
"preAdapt needed {} seconds"
,
t
.
elapsed
());
return
mightCoarsen_
;
}
...
...
@@ -124,7 +134,11 @@ namespace AMDiS
bool
adapt
()
override
{
assert
(
bound
());
Dune
::
Timer
t
;
refined_
=
grid_
->
adapt
();
Dune
::
MPIHelper
::
getCollectiveCommunication
().
max
(
&
refined_
,
1
);
info
(
2
,
"adapt needed {} seconds"
,
t
.
elapsed
());
return
refined_
;
}
...
...
@@ -133,6 +147,7 @@ namespace AMDiS
void
postAdapt
()
override
{
assert
(
bound
());
Dune
::
Timer
t
;
if
(
mightCoarsen_
||
refined_
)
{
for
(
auto
&&
data
:
updateCallbacks_
)
data
.
second
.
update
();
...
...
@@ -142,6 +157,7 @@ namespace AMDiS
grid_
->
postAdapt
();
changeIndex_
++
;
info
(
2
,
"postAdapt needed {} seconds"
,
t
.
elapsed
());
}
/// Returns the grid change index, see \ref changeIndex.
...
...
This diff is collapsed.
Click to expand it.
src/amdis/GridTransferManager.hpp
+
7
−
2
View file @
e1c34812
...
...
@@ -65,14 +65,19 @@ namespace AMDiS
get
(
grid
)
->
attach
(
data
);
}
template
<
class
Grid
,
class
Data
,
class
Callback
>
static
void
attach
(
Grid
const
&
grid
,
Data
const
&
data
,
Callback
&&
callback
)
{
get
(
grid
)
->
attach
(
data
,
FWD
(
callback
));
}
template
<
class
Grid
,
class
Data
>
static
void
detach
(
Grid
const
&
grid
,
Data
&
data
)
static
void
detach
(
Grid
const
&
grid
,
Data
const
&
data
)
{
get
(
grid
)
->
detach
(
data
);
}
private
:
/// \brief Returns the GridTransfer class, used for attaching and detaching Data
/**
* NOTE: The returned GridTransfer is not yet bound to a grid, since a
...
...
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