Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
iwr
dune-vtk
Commits
1334467e
Commit
1334467e
authored
Aug 17, 2020
by
Praetorius, Simon
Browse files
rename Vtk::path to Vtk::path and use camelCase function names
parent
6b0d1620
Changes
9
Hide whitespace changes
Inline
Side-by-side
dune/vtk/pvdwriter.impl.hh
View file @
1334467e
...
...
@@ -12,13 +12,13 @@ template <class W>
void
PvdWriter
<
W
>
::
writeTimestep
(
double
time
,
std
::
string
const
&
fn
,
std
::
optional
<
std
::
string
>
dir
,
bool
writeCollection
)
const
{
auto
p
=
Vtk
::
p
ath
(
fn
);
auto
p
=
Vtk
::
P
ath
(
fn
);
auto
name
=
p
.
stem
();
p
.
remove_filename
();
Vtk
::
p
ath
fn_dir
=
p
;
Vtk
::
p
ath
data_dir
=
dir
?
Vtk
::
p
ath
(
*
dir
)
:
fn_dir
;
Vtk
::
p
ath
rel_dir
=
Vtk
::
relative
(
data_dir
,
fn_dir
);
Vtk
::
P
ath
fn_dir
=
p
;
Vtk
::
P
ath
data_dir
=
dir
?
Vtk
::
P
ath
(
*
dir
)
:
fn_dir
;
Vtk
::
P
ath
rel_dir
=
Vtk
::
relative
(
data_dir
,
fn_dir
);
std
::
string
pvd_fn
=
fn_dir
.
string
()
+
'/'
+
name
.
string
();
std
::
string
seq_fn
=
data_dir
.
string
()
+
'/'
+
name
.
string
()
+
"_t"
+
std
::
to_string
(
timesteps_
.
size
());
...
...
@@ -52,7 +52,7 @@ template <class W>
std
::
string
PvdWriter
<
W
>
::
write
(
std
::
string
const
&
fn
,
std
::
optional
<
std
::
string
>
/*dir*/
)
const
{
auto
p
=
Vtk
::
p
ath
(
fn
);
auto
p
=
Vtk
::
P
ath
(
fn
);
auto
name
=
p
.
stem
();
p
.
remove_filename
();
p
/=
name
.
string
();
...
...
dune/vtk/reader.impl.hh
View file @
1334467e
...
...
@@ -25,7 +25,7 @@ void VtkReader<Grid,Creator>::read (std::string const& filename, bool fillCreato
std
::
ifstream
input
(
filename
,
std
::
ios_base
::
in
|
std
::
ios_base
::
binary
);
assert
(
input
.
is_open
());
std
::
string
ext
=
Vtk
::
p
ath
(
filename
).
extension
().
string
();
std
::
string
ext
=
Vtk
::
P
ath
(
filename
).
extension
().
string
();
if
(
ext
==
".vtu"
)
{
readSerialFileFromStream
(
input
,
fillCreator
);
pieces_
.
push_back
(
filename
);
...
...
dune/vtk/timeserieswriter.hh
View file @
1334467e
...
...
@@ -47,7 +47,7 @@ namespace Dune
std
::
srand
(
std
::
time
(
nullptr
));
// put temporary file to /tmp directory
tmpDir_
=
Vtk
::
p
ath
(
"/tmp/vtktimeserieswriter_"
+
Vtk
::
uid
(
10
)
+
"/"
);
tmpDir_
=
Vtk
::
P
ath
(
"/tmp/vtktimeserieswriter_"
+
Vtk
::
uid
(
10
)
+
"/"
);
}
/// Remove all written intermediate files and remove temporary directory
...
...
@@ -98,7 +98,7 @@ namespace Dune
protected:
VtkWriter
vtkWriter_
;
Vtk
::
p
ath
tmpDir_
;
Vtk
::
P
ath
tmpDir_
;
mutable
bool
initialized_
=
false
;
...
...
dune/vtk/timeserieswriter.impl.hh
View file @
1334467e
...
...
@@ -41,8 +41,8 @@ template <class W>
void
VtkTimeseriesWriter
<
W
>
::
writeTimestep
(
double
time
,
std
::
string
const
&
fn
,
std
::
optional
<
std
::
string
>
tmpDir
,
bool
writeCollection
)
const
{
auto
name
=
Vtk
::
p
ath
(
fn
).
stem
();
auto
tmpBase
=
tmpDir
?
Vtk
::
p
ath
(
*
tmpDir
)
:
tmpDir_
;
auto
name
=
Vtk
::
P
ath
(
fn
).
stem
();
auto
tmpBase
=
tmpDir
?
Vtk
::
P
ath
(
*
tmpDir
)
:
tmpDir_
;
auto
tmp
=
tmpBase
;
tmp
/=
name
.
string
();
...
...
@@ -79,13 +79,13 @@ std::string VtkTimeseriesWriter<W>
{
assert
(
initialized_
);
auto
p
=
Vtk
::
p
ath
(
fn
);
auto
p
=
Vtk
::
P
ath
(
fn
);
auto
name
=
p
.
stem
();
p
.
remove_filename
();
Vtk
::
p
ath
fn_dir
=
p
;
Vtk
::
p
ath
data_dir
=
dir
?
Vtk
::
p
ath
(
*
dir
)
:
fn_dir
;
Vtk
::
p
ath
rel_dir
=
Vtk
::
relative
(
data_dir
,
fn_dir
);
Vtk
::
P
ath
fn_dir
=
p
;
Vtk
::
P
ath
data_dir
=
dir
?
Vtk
::
P
ath
(
*
dir
)
:
fn_dir
;
Vtk
::
P
ath
rel_dir
=
Vtk
::
relative
(
data_dir
,
fn_dir
);
std
::
string
serial_fn
=
fn_dir
.
string
()
+
'/'
+
name
.
string
()
+
"_ts"
;
std
::
string
parallel_fn
=
data_dir
.
string
()
+
'/'
+
name
.
string
()
+
"_ts"
;
...
...
dune/vtk/utility/filesystem.cc
View file @
1334467e
...
...
@@ -21,9 +21,10 @@
template
<
class
...
Args
>
void
inline
_ignore_
(
Args
&&
...)
{}
namespace
Dune
{
namespace
Vtk
{
namespace
Dune
{
namespace
Vtk
{
std
::
string
p
ath
::
string
()
const
std
::
string
P
ath
::
string
()
const
{
if
(
empty
())
return
"."
;
...
...
@@ -31,12 +32,12 @@ std::string path::string() const
auto
it
=
begin
();
auto
result
=
*
it
;
for
(
++
it
;
it
!=
end
();
++
it
)
result
+=
preferred
_s
eparator
+
*
it
;
result
+=
preferred
S
eparator
+
*
it
;
return
result
;
}
void
p
ath
::
split
(
std
::
string
p
)
void
P
ath
::
split
(
std
::
string
p
)
{
std
::
string
separators
=
"/
\\
"
;
bool
relative
=
true
;
...
...
@@ -62,7 +63,7 @@ void path::split(std::string p)
}
p
ath
p
ath
::
stem
()
const
P
ath
P
ath
::
stem
()
const
{
auto
f
=
filename
().
string
();
auto
pos
=
f
.
find_last_of
(
'.'
);
...
...
@@ -73,7 +74,7 @@ path path::stem() const
}
p
ath
p
ath
::
extension
()
const
P
ath
P
ath
::
extension
()
const
{
auto
f
=
filename
().
string
();
auto
pos
=
f
.
find_last_of
(
'.'
);
...
...
@@ -84,7 +85,7 @@ path path::extension() const
}
bool
p
ath
::
is
_a
bsolute
(
std
::
string
p
)
bool
P
ath
::
is
A
bsolute
(
std
::
string
p
)
{
if
(
p
[
0
]
==
'/'
)
return
true
;
...
...
@@ -97,15 +98,15 @@ bool path::is_absolute(std::string p)
}
p
ath
&
p
ath
::
operator
/=
(
p
ath
const
&
p
)
P
ath
&
P
ath
::
operator
/=
(
P
ath
const
&
p
)
{
insert
(
end
(),
p
.
begin
(),
p
.
end
());
original
+=
preferred
_s
eparator
+
p
.
original
;
original
+=
preferred
S
eparator
+
p
.
original
;
return
*
this
;
}
bool
p
ath
::
is
_f
ile
()
const
bool
P
ath
::
is
F
ile
()
const
{
std
::
string
p
=
this
->
string
();
struct
stat
info
;
...
...
@@ -113,7 +114,7 @@ bool path::is_file() const
}
bool
p
ath
::
is
_d
irectory
()
const
bool
P
ath
::
is
D
irectory
()
const
{
std
::
string
p
=
this
->
string
();
struct
stat
info
;
...
...
@@ -121,7 +122,7 @@ bool path::is_directory() const
}
p
ath
current
_p
ath
()
P
ath
current
P
ath
()
{
char
cwd_
[
FILENAME_MAX
];
_ignore_
(
GET_CURRENT_DIR
(
cwd_
,
sizeof
(
cwd_
)));
...
...
@@ -130,20 +131,20 @@ path current_path()
}
bool
exists
(
p
ath
const
&
p
)
bool
exists
(
P
ath
const
&
p
)
{
return
p
.
is
_f
ile
()
||
p
.
is
_d
irectory
();
return
p
.
is
F
ile
()
||
p
.
is
D
irectory
();
}
bool
create
_d
irectories
(
p
ath
const
&
p
)
bool
create
D
irectories
(
P
ath
const
&
p
)
{
if
(
p
.
is
_d
irectory
())
if
(
p
.
is
D
irectory
())
return
true
;
auto
parent
=
p
.
parent
_p
ath
();
if
(
!
parent
.
empty
()
&&
!
parent
.
is
_d
irectory
())
create
_d
irectories
(
parent
);
auto
parent
=
p
.
parent
P
ath
();
if
(
!
parent
.
empty
()
&&
!
parent
.
is
D
irectory
())
create
D
irectories
(
parent
);
#ifdef _WIN32
int
ret
=
_mkdir
(
p
.
string
().
c_str
());
...
...
@@ -169,7 +170,7 @@ bool create_directories(path const& p)
}
}
p
ath
relative
(
p
ath
const
&
a
,
p
ath
const
&
b
)
P
ath
relative
(
P
ath
const
&
a
,
P
ath
const
&
b
)
{
// find common base path
auto
a_it
=
a
.
begin
();
...
...
@@ -180,7 +181,7 @@ path relative(path const& a, path const& b)
}
// combine remaining parts of a to result path
p
ath
rel
(
"."
);
P
ath
rel
(
"."
);
for
(;
a_it
!=
a
.
end
();
++
a_it
)
rel
/=
*
a_it
;
...
...
dune/vtk/utility/filesystem.hh
View file @
1334467e
...
...
@@ -9,9 +9,8 @@ namespace Dune
{
namespace
Vtk
{
// A minimalistic filesystem class
class
p
ath
class
P
ath
:
public
std
::
vector
<
std
::
string
>
{
using
Super
=
std
::
vector
<
std
::
string
>
;
...
...
@@ -20,58 +19,58 @@ namespace Dune
public:
#ifdef _WIN32
static
constexpr
char
preferred
_s
eparator
=
'\\'
;
static
constexpr
char
preferred
S
eparator
=
'\\'
;
#else
static
constexpr
char
preferred
_s
eparator
=
'/'
;
static
constexpr
char
preferred
S
eparator
=
'/'
;
#endif
public:
p
ath
()
=
default
;
P
ath
()
=
default
;
// NOTE: implicit conversion is allowed here
template
<
class
String
>
p
ath
(
String
const
&
p
)
P
ath
(
String
const
&
p
)
:
original
(
p
)
{
split
(
p
);
}
template
<
class
InputIt
>
p
ath
(
InputIt
it
,
InputIt
end_it
)
P
ath
(
InputIt
it
,
InputIt
end_it
)
:
Super
(
it
,
end_it
)
{
original
=
this
->
string
();
}
template
<
class
String
>
p
ath
(
std
::
initializer_list
<
String
>
const
&
list
)
:
p
ath
(
list
.
begin
(),
list
.
end
())
P
ath
(
std
::
initializer_list
<
String
>
const
&
list
)
:
P
ath
(
list
.
begin
(),
list
.
end
())
{}
/// Removes filename path component
p
ath
&
remove
_f
ilename
()
P
ath
&
remove
F
ilename
()
{
this
->
pop_back
();
return
*
this
;
}
/// Returns the path of the parent path
p
ath
parent
_p
ath
()
const
P
ath
parent
P
ath
()
const
{
return
empty
()
?
p
ath
()
:
p
ath
(
begin
(),
--
end
());
return
empty
()
?
P
ath
()
:
P
ath
(
begin
(),
--
end
());
}
/// Returns filename path component
p
ath
filename
()
const
P
ath
filename
()
const
{
return
empty
()
?
p
ath
()
:
p
ath
(
back
());
return
empty
()
?
P
ath
()
:
P
ath
(
back
());
}
/// Returns the stem path component
p
ath
stem
()
const
;
P
ath
stem
()
const
;
/// Returns the file extension path component
p
ath
extension
()
const
;
P
ath
extension
()
const
;
/// Return the path as string
std
::
string
string
()
const
;
...
...
@@ -80,30 +79,30 @@ namespace Dune
/** In Linux, test whether the path starts with `/`, in Windows whether it starts
* with `[a-z]:\\`.
**/
static
bool
is
_a
bsolute
(
std
::
string
p
);
static
bool
is
A
bsolute
(
std
::
string
p
);
bool
is
_a
bsolute
()
const
{
return
is
_a
bsolute
(
original
);
}
bool
is
A
bsolute
()
const
{
return
is
A
bsolute
(
original
);
}
bool
is
_r
elative
()
const
{
return
!
is
_a
bsolute
();
}
bool
is
R
elative
()
const
{
return
!
is
A
bsolute
();
}
/// Check whether path is a regular file
bool
is
_f
ile
()
const
;
bool
is
F
ile
()
const
;
/// Check whether path is a regular file
bool
is
_d
irectory
()
const
;
bool
is
D
irectory
()
const
;
/// Lexicographically compares two paths
bool
operator
==
(
p
ath
const
&
p
)
bool
operator
==
(
P
ath
const
&
p
)
{
return
this
->
string
()
==
p
.
string
();
}
/// Appends elements to the path
p
ath
&
operator
/=
(
p
ath
const
&
p
);
P
ath
&
operator
/=
(
P
ath
const
&
p
);
/// output of the path
template
<
class
CharT
,
class
Traits
>
friend
std
::
basic_ostream
<
CharT
,
Traits
>&
operator
<<
(
std
::
basic_ostream
<
CharT
,
Traits
>&
out
,
p
ath
const
&
p
)
friend
std
::
basic_ostream
<
CharT
,
Traits
>&
operator
<<
(
std
::
basic_ostream
<
CharT
,
Traits
>&
out
,
P
ath
const
&
p
)
{
out
<<
'"'
<<
p
.
string
()
<<
'"'
;
return
out
;
...
...
@@ -120,16 +119,16 @@ namespace Dune
};
/// Test whether the path is a valid (existing and accessible) file / directory
bool
exists
(
p
ath
const
&
);
bool
exists
(
P
ath
const
&
);
/// Create directory and non existing parent directories.
bool
create
_d
irectories
(
p
ath
const
&
);
bool
create
D
irectories
(
P
ath
const
&
);
/// Returns the current path
p
ath
current
_p
ath
();
P
ath
current
P
ath
();
/// Find the path of `a` relative to directory of `b`
p
ath
relative
(
p
ath
const
&
a
,
p
ath
const
&
b
);
P
ath
relative
(
P
ath
const
&
a
,
P
ath
const
&
b
);
}
// end namespace Vtk
}
// end namespace Dune
dune/vtk/writerinterface.impl.hh
View file @
1334467e
...
...
@@ -28,13 +28,13 @@ std::string VtkWriterInterface<GV,DC>
{
dataCollector_
->
update
();
auto
p
=
Vtk
::
p
ath
(
fn
);
auto
p
=
Vtk
::
P
ath
(
fn
);
auto
name
=
p
.
stem
();
p
.
remove_filename
();
Vtk
::
p
ath
fn_dir
=
p
;
Vtk
::
p
ath
data_dir
=
dir
?
Vtk
::
p
ath
(
*
dir
)
:
fn_dir
;
Vtk
::
p
ath
rel_dir
=
Vtk
::
relative
(
data_dir
,
fn_dir
);
Vtk
::
P
ath
fn_dir
=
p
;
Vtk
::
P
ath
data_dir
=
dir
?
Vtk
::
P
ath
(
*
dir
)
:
fn_dir
;
Vtk
::
P
ath
rel_dir
=
Vtk
::
relative
(
data_dir
,
fn_dir
);
std
::
string
serial_fn
=
data_dir
.
string
()
+
'/'
+
name
.
string
();
std
::
string
parallel_fn
=
fn_dir
.
string
()
+
'/'
+
name
.
string
();
...
...
src/test/parallel_reader_writer_test.cc
View file @
1334467e
...
...
@@ -79,7 +79,7 @@ using HasParallelGridFactory = Std::is_detected<HasParallelGridFactoryImpl, Grid
template
<
class
Test
>
void
compare
(
Test
&
test
,
Vtk
::
p
ath
const
&
dir
,
Vtk
::
p
ath
const
&
name
)
void
compare
(
Test
&
test
,
Vtk
::
P
ath
const
&
dir
,
Vtk
::
P
ath
const
&
name
)
{
test
.
check
(
compare_files
(
dir
.
string
()
+
'/'
+
name
.
string
()
+
".vtu"
,
dir
.
string
()
+
'/'
+
name
.
string
()
+
"_2.vtu"
));
...
...
src/test/reader_writer_test.cc
View file @
1334467e
...
...
@@ -80,7 +80,7 @@ static TestCases test_cases = {
};
template
<
class
Test
>
void
compare
(
Test
&
test
,
Vtk
::
p
ath
const
&
dir
,
Vtk
::
p
ath
const
&
name
)
void
compare
(
Test
&
test
,
Vtk
::
P
ath
const
&
dir
,
Vtk
::
P
ath
const
&
name
)
{
test
.
check
(
compare_files
(
dir
.
string
()
+
'/'
+
name
.
string
()
+
".vtu"
,
dir
.
string
()
+
'/'
+
name
.
string
()
+
"_2.vtu"
));
...
...
Write
Preview
Supports
Markdown
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