Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
dorie
dorie
Commits
c7124e06
Commit
c7124e06
authored
Feb 13, 2019
by
Lukas Riedel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Build interpolator in H5 initial condition directly from config
parent
6ff38911
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
56 deletions
+7
-56
dune/dorie/common/initial_condition/h5.hh
dune/dorie/common/initial_condition/h5.hh
+7
-56
No files found.
dune/dorie/common/initial_condition/h5.hh
View file @
c7124e06
...
...
@@ -41,60 +41,11 @@ public:
InitialConditionH5
(
const
GV
&
grid_view
,
const
Dune
::
ParameterTree
&
config
,
std
::
shared_ptr
<
spdlog
::
logger
>
log
)
:
Base
(
grid_view
)
{
// open the H5 file
const
auto
datafile
=
config
.
template
get
<
std
::
string
>(
"initial.datafile"
);
const
auto
dataset
=
config
.
template
get
<
std
::
string
>(
"initial.dataset"
);
H5File
h5file
(
datafile
,
log
);
// read the dataset
std
::
vector
<
RF
>
data
;
std
::
vector
<
size_t
>
shape
;
h5file
.
read_dataset
(
dataset
,
H5T_NATIVE_DOUBLE
,
data
,
shape
);
std
::
reverse
(
std
::
begin
(
shape
),
std
::
end
(
shape
));
/// retrieve extensions and offset from grid extensions
const
auto
level_gv
=
grid_view
.
grid
().
levelGridView
(
0
);
const
auto
[
off
,
upper_right
]
=
get_grid_extensions
(
level_gv
);
const
auto
ext
=
upper_right
-
off
;
if
(
shape
.
size
()
!=
dim
)
{
log
->
error
(
"Expected {}-dimensional dataset. File: {}, "
"Dataset: {}, Dimensions: {}"
,
dim
,
datafile
,
dataset
,
shape
.
size
());
DUNE_THROW
(
Dune
::
IOError
,
"Invalid dataset for interpolator"
);
}
if
(
ext
.
size
()
!=
dim
)
{
log
->
error
(
"Expected {}-dimensional sequence as 'extensions'"
,
dim
);
DUNE_THROW
(
Dune
::
IOError
,
"Invalid interpolator input"
);
}
if
(
off
.
size
()
!=
dim
)
{
log
->
error
(
"Expected {}-dimensional sequence as 'offset'"
,
dim
);
DUNE_THROW
(
Dune
::
IOError
,
"Invalid interpolator input"
);
}
// copy into correct data structure
Domain
extensions
;
std
::
copy
(
std
::
begin
(
ext
),
std
::
end
(
ext
),
std
::
begin
(
extensions
));
Domain
offset
;
std
::
copy
(
std
::
begin
(
off
),
std
::
end
(
off
),
std
::
begin
(
offset
));
// build interpolator
_interpolator
=
InterpolatorFactory
<
T
>::
create
(
config
.
template
get
<
std
::
string
>(
"initial.interpolation"
),
data
,
shape
,
extensions
,
offset
,
log
);
}
:
Base
(
grid_view
),
_interpolator
(
InterpolatorFactory
<
T
>::
create
(
config
.
sub
(
"initial"
),
grid_view
,
log
))
{
}
/// Evaluate the initial condition at certain position
/** \param y
...
...
@@ -110,10 +61,10 @@ public:
}
private:
std
::
shared_ptr
<
Interpolator
<
RF
,
T
>>
_interpolator
;
std
::
shared_ptr
<
Interpolator
<
RF
,
T
>>
_interpolator
;
};
}
// namespace Dorie
}
// namespace Dune
#endif // DUNE_DORIE_INITIAL_CONDITION_H5_HH
\ No newline at end of file
#endif // DUNE_DORIE_INITIAL_CONDITION_H5_HH
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment