Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
dumux
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
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
dumux-repositories
dumux
Commits
d55bf37c
Commit
d55bf37c
authored
6 years ago
by
Kilian Weishaupt
Committed by
Timo Koch
6 years ago
Browse files
Options
Downloads
Patches
Plain Diff
[md][couplingmanager] Store tuple of problem weak ptrs in the base class
parent
a57fcfc7
No related branches found
No related tags found
1 merge request
!1179
[md][bugfix] Fix memory leak due to cyclic shared_ptr dependency couplingmanager<->problem
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
dumux/multidomain/couplingmanager.hh
+44
-2
44 additions, 2 deletions
dumux/multidomain/couplingmanager.hh
with
44 additions
and
2 deletions
dumux/multidomain/couplingmanager.hh
+
44
−
2
View file @
d55bf37c
...
...
@@ -25,11 +25,14 @@
#ifndef DUMUX_MULTIDOMAIN_COUPLING_MANAGER_HH
#define DUMUX_MULTIDOMAIN_COUPLING_MANAGER_HH
#include
<memory>
#include
<tuple>
#include
<vector>
#include
<dune/common/indices.hh>
#include
<dune/common/exceptions.hh>
#include
<du
mux
/common/
typetraits/typetrait
s.hh>
#include
<du
ne
/common/
indice
s.hh>
#include
<dumux/assembly/numericepsilon.hh>
#include
<dumux/common/properties.hh>
#include
<dumux/common/typetraits/typetraits.hh>
namespace
Dumux
{
...
...
@@ -45,6 +48,9 @@ class CouplingManager
template
<
std
::
size_t
id
>
using
PrimaryVariables
=
typename
GET_PROP_TYPE
(
SubDomainTypeTag
<
id
>
,
PrimaryVariables
);
template
<
std
::
size_t
id
>
using
GridView
=
typename
GET_PROP_TYPE
(
SubDomainTypeTag
<
id
>
,
FVGridGeometry
)
::
GridView
;
template
<
std
::
size_t
id
>
using
Element
=
typename
GridView
<
id
>::
template
Codim
<
0
>
::
Entity
;
template
<
std
::
size_t
id
>
using
Problem
=
typename
GET_PROP_TYPE
(
SubDomainTypeTag
<
id
>
,
Problem
);
template
<
std
::
size_t
id
>
using
ProblemWeakPtr
=
std
::
weak_ptr
<
const
Problem
<
id
>>
;
using
Problems
=
typename
Traits
::
template
MakeTuple
<
ProblemWeakPtr
>;
public:
//! default type used for coupling element stencils
...
...
@@ -231,6 +237,36 @@ public:
return
NumericEpsilon
<
typename
Traits
::
Scalar
,
numEq
>
(
paramGroup
);
}
/*!
* \brief set the pointers to the sub problems
* \param problems A tuple of shared pointers to the sub problems
*/
template
<
typename
...
SubProblems
>
void
setSubProblems
(
const
std
::
tuple
<
std
::
shared_ptr
<
SubProblems
>
...
>&
problems
)
{
problems_
=
problems
;
}
/*!
* \brief set a pointer to one of the sub problems
* \param problem a pointer to the sub problem
* \param domainIdx the domain index of the sub problem
*/
template
<
class
SubProblem
,
std
::
size_t
i
>
void
setSubProblem
(
std
::
shared_ptr
<
SubProblem
>
problem
,
Dune
::
index_constant
<
i
>
domainIdx
)
{
std
::
get
<
i
>
(
problems_
)
=
problem
;
}
/*!
* \brief Return a reference to the sub problem
* \param domainIdx The domain index
*/
template
<
std
::
size_t
i
>
const
Problem
<
i
>&
problem
(
Dune
::
index_constant
<
i
>
domainIdx
)
const
{
if
(
!
std
::
get
<
i
>
(
problems_
).
expired
())
return
*
std
::
get
<
i
>
(
problems_
).
lock
();
else
DUNE_THROW
(
Dune
::
InvalidStateException
,
"The problem pointer was not set or has already expired. Use setSubProblems() before calling this function"
);
}
protected
:
/*!
...
...
@@ -254,6 +290,12 @@ private:
*/
SolutionVector
curSol_
;
/*!
* \brief A tuple of std::weak_ptrs to the sub problems
* \note these are weak pointers and not shared pointers to break the cyclic dependency between coupling manager and problems
*/
Problems
problems_
;
};
}
//end namespace Dumux
...
...
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