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
88703a1a
Commit
88703a1a
authored
6 years ago
by
Timo Koch
Browse files
Options
Downloads
Patches
Plain Diff
[io][gridmanager] Add support for dune-spgrid
parent
179cbd53
No related branches found
No related tags found
1 merge request
!1097
Feature/periodic boundaries
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
dumux/io/grid/gridmanager.hh
+69
-0
69 additions, 0 deletions
dumux/io/grid/gridmanager.hh
with
69 additions
and
0 deletions
dumux/io/grid/gridmanager.hh
+
69
−
0
View file @
88703a1a
...
@@ -67,6 +67,12 @@
...
@@ -67,6 +67,12 @@
#include
<dune/foamgrid/dgffoam.hh>
#include
<dune/foamgrid/dgffoam.hh>
#endif
#endif
// SPGrid specific includes
#if HAVE_DUNE_SPGRID
#include
<dune/grid/spgrid.hh>
#include
<dune/grid/spgrid/dgfparser.hh>
#endif
#include
<dumux/common/parameters.hh>
#include
<dumux/common/parameters.hh>
#include
<dumux/discretization/methods.hh>
#include
<dumux/discretization/methods.hh>
...
@@ -1281,6 +1287,69 @@ public:
...
@@ -1281,6 +1287,69 @@ public:
#endif // HAVE_DUNE_FOAMGRID
#endif // HAVE_DUNE_FOAMGRID
#if HAVE_DUNE_SPGRID
/*!
* \brief Provides a grid manager for SPGrid
*
* The following keys are recognized:
* - File : A DGF or gmsh file to load from, type detection by file extension
*
*/
template
<
class
ct
,
int
dim
,
template
<
int
>
class
Ref
,
class
Comm
>
class
GridManager
<
Dune
::
SPGrid
<
ct
,
dim
,
Ref
,
Comm
>>
:
public
GridManagerBase
<
Dune
::
SPGrid
<
ct
,
dim
,
Ref
,
Comm
>>
{
public:
using
Grid
=
Dune
::
SPGrid
<
ct
,
dim
,
Ref
,
Comm
>
;
using
ParentType
=
GridManagerBase
<
Grid
>
;
/*!
* \brief Make the grid. This is implemented by specializations of this method.
*/
void
init
(
const
std
::
string
&
paramGroup
=
""
)
{
// try to create it from file
if
(
hasParamInGroup
(
paramGroup
,
"Grid.File"
))
{
ParentType
::
makeGridFromDgfFile
(
getParamFromGroup
<
std
::
string
>
(
paramGroup
,
"Grid.File"
));
ParentType
::
maybeRefineGrid
(
paramGroup
);
ParentType
::
loadBalance
();
return
;
}
// Didn't find a way to construct the grid
else
if
(
hasParamInGroup
(
paramGroup
,
"Grid.UpperRight"
))
{
using
GlobalPosition
=
Dune
::
FieldVector
<
ct
,
dim
>
;
const
auto
lowerLeft
=
getParamFromGroup
<
GlobalPosition
>
(
paramGroup
,
"Grid.LowerLeft"
,
GlobalPosition
(
0.0
));
const
auto
upperRight
=
getParamFromGroup
<
GlobalPosition
>
(
paramGroup
,
"Grid.UpperRight"
);
using
IntArray
=
std
::
array
<
int
,
dim
>
;
IntArray
cells
;
cells
.
fill
(
1
);
cells
=
getParamFromGroup
<
IntArray
>
(
paramGroup
,
"Grid.Cells"
,
cells
);
const
auto
periodic
=
getParamFromGroup
<
std
::
bitset
<
dim
>>
(
paramGroup
,
"Grid.Periodic"
,
std
::
bitset
<
dim
>
{});
const
auto
overlap
=
getParamFromGroup
<
int
>
(
paramGroup
,
"Grid.Overlap"
,
1
);
IntArray
spOverlap
;
spOverlap
.
fill
(
overlap
);
using
Domain
=
typename
Grid
::
Domain
;
std
::
vector
<
typename
Domain
::
Cube
>
cubes
;
cubes
.
push_back
(
typename
Domain
::
Cube
(
lowerLeft
,
upperRight
)
);
Domain
domain
(
cubes
,
typename
Domain
::
Topology
(
static_cast
<
unsigned
int
>
(
periodic
.
to_ulong
())
)
);
ParentType
::
gridPtr
()
=
std
::
make_shared
<
Grid
>
(
domain
,
cells
,
spOverlap
);
ParentType
::
maybeRefineGrid
(
paramGroup
);
ParentType
::
loadBalance
();
}
else
{
const
auto
prefix
=
paramGroup
==
""
?
paramGroup
:
paramGroup
+
"."
;
DUNE_THROW
(
ParameterException
,
"Please supply a grid file in "
<<
prefix
<<
"Grid.File or "
<<
prefix
<<
"Grid.UpperRight/Cells."
);
}
}
};
#endif // HAVE_DUNE_SPGRID
}
// end namespace Dumux
}
// end namespace Dumux
#endif
#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