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
fa05944b
Commit
fa05944b
authored
6 years ago
by
Bernd Flemisch
Committed by
Timo Koch
6 years ago
Browse files
Options
Downloads
Patches
Plain Diff
[io][vtk] read from parallel Vtk file into a solution vector with state
parent
d82bca6e
No related branches found
No related tags found
1 merge request
!1039
Feature/restart from vtk
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
dumux/io/loadsolution.hh
+54
-6
54 additions, 6 deletions
dumux/io/loadsolution.hh
with
54 additions
and
6 deletions
dumux/io/loadsolution.hh
+
54
−
6
View file @
fa05944b
...
@@ -146,11 +146,6 @@ auto loadSolutionFromParallelVtkFile(const std::string fileName,
...
@@ -146,11 +146,6 @@ auto loadSolutionFromParallelVtkFile(const std::string fileName,
{
{
const
auto
pvName
=
pvNamesFunc
(
pvIdx
);
const
auto
pvName
=
pvNamesFunc
(
pvIdx
);
auto
vec
=
vtu
.
readData
<
std
::
vector
<
Scalar
>>
(
pvName
,
dataType
);
auto
vec
=
vtu
.
readData
<
std
::
vector
<
Scalar
>>
(
pvName
,
dataType
);
if
(
vec
.
size
()
!=
sol
.
size
()
&&
fvGridGeometry
.
gridView
().
comm
().
size
()
==
1
)
{
DUNE_THROW
(
Dune
::
IOError
,
"Size mismatch between solution vector and read data ("
<<
sol
.
size
()
<<
" != "
<<
vec
.
size
()
<<
")"
);
}
std
::
vector
<
bool
>
visited
;
std
::
vector
<
bool
>
visited
;
if
(
dataType
==
VTKReader
::
DataType
::
pointData
)
if
(
dataType
==
VTKReader
::
DataType
::
pointData
)
...
@@ -239,7 +234,60 @@ auto loadSolutionFromParallelVtkFile(const std::string fileName,
...
@@ -239,7 +234,60 @@ auto loadSolutionFromParallelVtkFile(const std::string fileName,
const
FVGridGeometry
&
fvGridGeometry
)
const
FVGridGeometry
&
fvGridGeometry
)
->
typename
std
::
enable_if_t
<
decltype
(
isValid
(
Detail
::
hasState
())(
sol
[
0
]))
::
value
,
void
>
->
typename
std
::
enable_if_t
<
decltype
(
isValid
(
Detail
::
hasState
())(
sol
[
0
]))
::
value
,
void
>
{
{
DUNE_THROW
(
Dune
::
NotImplemented
,
"reading solution with state from a parallel Vtk file"
);
VTKReader
vtu
(
fileName
);
// get states at dof locations
const
auto
stateAtDof
=
vtu
.
readData
<
std
::
vector
<
int
>>
(
"phase presence"
,
dataType
);
// determine which states are present
std
::
unordered_set
<
int
>
states
;
for
(
size_t
i
=
0
;
i
<
sol
.
size
();
++
i
)
states
.
insert
(
stateAtDof
[
i
]);
// declare a vector to determine which vertices have been visited already
std
::
vector
<
bool
>
visited
;
using
GridView
=
typename
FVGridGeometry
::
GridView
;
static
constexpr
auto
dim
=
GridView
::
dimension
;
if
(
dataType
==
VTKReader
::
DataType
::
pointData
)
visited
.
resize
(
fvGridGeometry
.
gridView
().
size
(
dim
));
using
PrimaryVariables
=
typename
SolutionVector
::
block_type
;
using
Scalar
=
typename
PrimaryVariables
::
field_type
;
for
(
size_t
pvIdx
=
0
;
pvIdx
<
PrimaryVariables
::
dimension
;
++
pvIdx
)
{
std
::
unordered_map
<
int
,
std
::
vector
<
Scalar
>>
switchedPvsSol
;
for
(
const
auto
&
state
:
states
)
switchedPvsSol
[
state
]
=
vtu
.
readData
<
std
::
vector
<
Scalar
>>
(
pvNamesFunc
(
pvIdx
,
state
),
dataType
);
std
::
fill
(
visited
.
begin
(),
visited
.
end
(),
false
);
std
::
size_t
i
=
0
;
for
(
const
auto
&
element
:
elements
(
fvGridGeometry
.
gridView
(),
Dune
::
Partitions
::
interior
))
{
if
(
dataType
==
VTKReader
::
DataType
::
cellData
)
{
auto
eIdx
=
fvGridGeometry
.
elementMapper
().
index
(
element
);
auto
state
=
stateAtDof
[
i
];
sol
[
eIdx
].
setState
(
state
);
sol
[
eIdx
][
pvIdx
]
=
switchedPvsSol
[
state
][
i
];
++
i
;
}
else
{
for
(
int
vIdxLocal
=
0
;
vIdxLocal
<
element
.
subEntities
(
dim
);
++
vIdxLocal
)
{
auto
vIdxGlobal
=
fvGridGeometry
.
vertexMapper
().
subIndex
(
element
,
vIdxLocal
,
dim
);
if
(
!
visited
[
vIdxGlobal
])
{
auto
state
=
stateAtDof
[
i
];
sol
[
vIdxGlobal
].
setState
(
state
);
sol
[
vIdxGlobal
][
pvIdx
]
=
switchedPvsSol
[
state
][
i
];
visited
[
vIdxGlobal
]
=
true
;
++
i
;
}
}
}
}
}
}
}
/*!
/*!
...
...
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