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
d944db65
Commit
d944db65
authored
6 years ago
by
Timo Koch
Browse files
Options
Downloads
Patches
Plain Diff
[md] Add multidomain wrapper for grid geometry
parent
6a383aab
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!1350
Multidomain wrappers to easier write main files
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
dumux/multidomain/fvgridgeometry.hh
+125
-0
125 additions, 0 deletions
dumux/multidomain/fvgridgeometry.hh
with
125 additions
and
0 deletions
dumux/multidomain/fvgridgeometry.hh
0 → 100644
+
125
−
0
View file @
d944db65
// -*- mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
// vi: set et ts=4 sw=4 sts=4:
/*****************************************************************************
* See the file COPYING for full copying permissions. *
* *
* This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation, either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
*****************************************************************************/
/*!
* \file
* \ingroup MultiDomain
* \brief Multidomain wrapper for multiple grid geometries
*/
#ifndef DUMUX_MULTIDOMAIN_FVGRIDGEOMETRY_HH
#define DUMUX_MULTIDOMAIN_FVGRIDGEOMETRY_HH
#include
<tuple>
#include
<memory>
#include
<utility>
#include
<dune/common/hybridutilities.hh>
#include
<dune/common/indices.hh>
namespace
Dumux
{
/*!
* \ingroup MultiDomain
* \brief A multidomain wrapper for multiple grid geometries
* \tparam MDTraits The multidomain traits
*/
template
<
class
MDTraits
>
class
MultiDomainFVGridGeometry
{
static
constexpr
std
::
size_t
numSubDomains
=
MDTraits
::
numSubDomains
;
public:
//! export base types of the stored type
template
<
std
::
size_t
i
>
using
Type
=
typename
MDTraits
::
template
SubDomain
<
i
>
::
FVGridGeometry
;
//! export pointer types the stored type
template
<
std
::
size_t
i
>
using
PtrType
=
std
::
shared_ptr
<
Type
<
i
>>
;
//! export type of tuple of pointers
using
TupleType
=
typename
MDTraits
::
template
Tuple
<
PtrType
>;
/*!
* \brief The default constructor
*/
MultiDomainFVGridGeometry
()
=
default
;
/*!
* \brief Contruct the problem
* \param gridViews a tuple of gridViews
*/
template
<
class
GridViews
>
MultiDomainFVGridGeometry
(
GridViews
&&
gridViews
)
{
using
namespace
Dune
::
Hybrid
;
forEach
(
std
::
make_index_sequence
<
numSubDomains
>
{},
[
&
](
auto
&&
id
)
{
constexpr
auto
i
=
std
::
decay_t
<
decltype
(
id
)
>::
value
;
elementAt
(
gridGeometries_
,
id
)
=
std
::
make_shared
<
Type
<
i
>>
(
std
::
get
<
i
>
(
gridViews
));
});
}
/*!
* \brief Update all grid geometries (do this again after grid adaption)
*/
void
update
()
{
using
namespace
Dune
::
Hybrid
;
forEach
(
std
::
make_index_sequence
<
numSubDomains
>
{},
[
&
](
auto
&&
id
)
{
elementAt
(
gridGeometries_
,
id
)
->
update
();
});
}
//! return the grid geometry for domain with index i
template
<
std
::
size_t
i
>
const
Type
<
i
>&
operator
[]
(
Dune
::
index_constant
<
i
>
id
)
const
{
return
*
Dune
::
Hybrid
::
elementAt
(
gridGeometries_
,
id
);
}
//! return the grid geometry for domain with index i
template
<
std
::
size_t
i
>
Type
<
i
>&
operator
[]
(
Dune
::
index_constant
<
i
>
id
)
{
return
*
Dune
::
Hybrid
::
elementAt
(
gridGeometries_
,
id
);
}
///! return the grid geometry pointer for domain with index i
template
<
std
::
size_t
i
>
PtrType
<
i
>
get
(
Dune
::
index_constant
<
i
>
id
=
Dune
::
index_constant
<
i
>
{})
{
return
Dune
::
Hybrid
::
elementAt
(
gridGeometries_
,
id
);
}
//! set the pointer for sub domain i
template
<
std
::
size_t
i
>
void
set
(
PtrType
<
i
>
p
,
Dune
::
index_constant
<
i
>
id
=
Dune
::
index_constant
<
i
>
{})
{
Dune
::
Hybrid
::
elementAt
(
gridGeometries_
,
Dune
::
index_constant
<
i
>
{})
=
p
;
}
/*!
* \brief return the grid variables tuple we are wrapping
* \note the copy is not expensive since it is a tuple of shared pointers
*/
TupleType
getTuple
()
{
return
gridGeometries_
;
}
private
:
//! a tuple of pointes to all grid variables
TupleType
gridGeometries_
;
};
}
// end namespace Dumux
#endif
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