Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
dune-gfe
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
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
Sander, Oliver
dune-gfe
Commits
a008c5bf
Commit
a008c5bf
authored
4 years ago
by
Lisa Julia Nebel
Browse files
Options
Downloads
Patches
Plain Diff
Move the function reading input data to a filereader.hh
parent
6fdc34d0
No related branches found
No related tags found
1 merge request
!73
Feature/stress plot
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
dune/gfe/filereader.hh
+43
-0
43 additions, 0 deletions
dune/gfe/filereader.hh
with
43 additions
and
0 deletions
dune/gfe/filereader.hh
0 → 100644
+
43
−
0
View file @
a008c5bf
#ifndef DUNE_GFE_FILEREADER_HH
#define DUNE_GFE_FILEREADER_HH
#include
<iostream>
#include
<fstream>
#include
<dune/common/fvector.hh>
// This is a custom file format parser which reads in a grid deformation file
// The file must contain lines of the format <grid vertex>:<displacement or rotation>
// !!! THIS IS A TEMPORARY SOLUTION AND WILL BE REPLACED BY THE Dune::VtkReader in dune-vtk/dune/vtk/vtkreader.hh !!!
namespace
Dune
{
namespace
GFE
{
// Convert the pairs {grid vertex, vector of dimension d} in the given file to a map
template
<
int
d
>
static
std
::
unordered_map
<
std
::
string
,
FieldVector
<
double
,
d
>>
transformFileToMap
(
std
::
string
pathToFile
)
{
std
::
unordered_map
<
std
::
string
,
FieldVector
<
double
,
d
>>
map
;
std
::
string
line
,
displacement
,
entry
;
std
::
ifstream
file
(
pathToFile
,
std
::
ios
::
in
);
if
(
file
.
is_open
())
{
while
(
std
::
getline
(
file
,
line
))
{
size_t
j
=
0
;
size_t
pos
=
line
.
find
(
":"
);
displacement
=
line
.
substr
(
pos
+
1
);
line
.
erase
(
pos
);
std
::
stringstream
entries
(
displacement
);
FieldVector
<
double
,
d
>
vector
(
0
);
while
(
entries
>>
entry
)
vector
[
j
++
]
=
std
::
stod
(
entry
);
map
.
insert
({
line
,
vector
});
}
file
.
close
();
}
else
{
DUNE_THROW
(
Exception
,
"Error: Could not open the file "
+
pathToFile
+
" !"
);
}
return
map
;
}
}
}
#endif
\ No newline at end of file
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