Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
O
ogs-feliks
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
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
Feliks Kiszkurno
ogs-feliks
Commits
6a610bdd
Commit
6a610bdd
authored
8 years ago
by
Christoph Lehmann
Committed by
GitHub
8 years ago
Browse files
Options
Downloads
Plain Diff
Merge pull request #1331 from chleh/fix-dot-path
Fix dots in VTU file names
parents
1478df67
558e8bbc
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
BaseLib/FileTools.cpp
+15
-9
15 additions, 9 deletions
BaseLib/FileTools.cpp
MeshLib/IO/VtkIO/VtuInterface.cpp
+9
-4
9 additions, 4 deletions
MeshLib/IO/VtkIO/VtuInterface.cpp
Tests/BaseLib/TestFilePathStringManipulation.cpp
+5
-4
5 additions, 4 deletions
Tests/BaseLib/TestFilePathStringManipulation.cpp
with
29 additions
and
17 deletions
BaseLib/FileTools.cpp
+
15
−
9
View file @
6a610bdd
...
...
@@ -141,11 +141,11 @@ std::string extractPath(std::string const& pathname)
return
""
;
return
pathname
.
substr
(
0
,
pos
+
1
);
}
static
const
char
*
pathSeparator
=
static
const
char
pathSeparator
=
#ifdef _WIN32
"
\\
"
;
'
\\
'
;
#else
"/"
;
'/'
;
#endif
std
::
string
appendPathSeparator
(
std
::
string
const
&
path
)
...
...
@@ -157,12 +157,18 @@ std::string appendPathSeparator(std::string const& path)
std
::
string
joinPaths
(
std
::
string
const
&
pathA
,
std
::
string
const
&
pathB
)
{
std
::
string
tmpB
(
pathB
);
if
(
tmpB
.
substr
(
0
,
1
)
==
"."
)
tmpB
=
tmpB
.
substr
(
1
);
if
(
tmpB
.
substr
(
0
,
1
)
==
pathSeparator
)
tmpB
=
tmpB
.
substr
(
1
);
return
appendPathSeparator
(
pathA
)
+
tmpB
;
if
(
pathA
.
empty
())
return
pathB
;
if
(
pathB
.
empty
())
return
pathA
;
if
(
pathB
.
front
()
==
pathSeparator
)
{
auto
const
tmpB
=
pathB
.
substr
(
1
);
return
appendPathSeparator
(
pathA
)
+
tmpB
;
}
else
{
return
appendPathSeparator
(
pathA
)
+
pathB
;
}
}
}
// end namespace BaseLib
This diff is collapsed.
Click to expand it.
MeshLib/IO/VtkIO/VtuInterface.cpp
+
9
−
4
View file @
6a610bdd
...
...
@@ -77,12 +77,17 @@ bool VtuInterface::writeToFile(std::string const &file_name)
// and PETSC_COMM_WORLD should be replaced with the argument.
int
mpi_rank
;
MPI_Comm_rank
(
PETSC_COMM_WORLD
,
&
mpi_rank
);
std
::
string
file_name_base
=
boost
::
erase_last_copy
(
file_name
,
".vtu"
);
auto
const
file_name_base
=
boost
::
erase_last_copy
(
file_name
,
".vtu"
);
auto
const
dirname
=
BaseLib
::
extractPath
(
file_name_base
);
auto
basename
=
BaseLib
::
extractBaseName
(
file_name_base
);
// Since the pvtu writing function drops all letters from the letter of '.'.
std
::
replace
(
file_name_base
.
begin
(),
file_name_base
.
end
(),
'.'
,
'_'
);
std
::
replace
(
basename
.
begin
(),
basename
.
end
(),
'.'
,
'_'
);
auto
const
vtu_file_name
=
BaseLib
::
joinPaths
(
dirname
,
basename
);
const
std
::
string
file_name_rank
=
file_name
_base
+
"_"
const
std
::
string
file_name_rank
=
vtu_
file_name
+
"_"
+
std
::
to_string
(
mpi_rank
)
+
".vtu"
;
bool
vtu_status_i
=
writeVTU
<
vtkXMLUnstructuredGridWriter
>
(
file_name_rank
);
bool
vtu_status
=
false
;
...
...
@@ -93,7 +98,7 @@ bool VtuInterface::writeToFile(std::string const &file_name)
bool
pvtu_status
=
false
;
if
(
mpi_rank
==
0
)
{
pvtu_status
=
writeVTU
<
vtkXMLPUnstructuredGridWriter
>
(
file_name
_base
+
".pvtu"
,
mpi_size
);
pvtu_status
=
writeVTU
<
vtkXMLPUnstructuredGridWriter
>
(
vtu_
file_name
+
".pvtu"
,
mpi_size
);
}
MPI_Bcast
(
&
pvtu_status
,
1
,
MPI_C_BOOL
,
0
,
PETSC_COMM_WORLD
);
...
...
This diff is collapsed.
Click to expand it.
Tests/BaseLib/TestFilePathStringManipulation.cpp
+
5
−
4
View file @
6a610bdd
...
...
@@ -391,12 +391,13 @@ TEST(BaseLib, ExtractPathUnix)
TEST
(
BaseLib
,
JoinPaths
)
{
#if _WIN32
ASSERT_EQ
(
"
\\
path
\\
path"
,
BaseLib
::
joinPaths
(
"
\\
path"
,
"path"
)
);
ASSERT_EQ
(
"
\\
path
\\
path"
,
BaseLib
::
joinPaths
(
"
\\
path"
,
"
\\
path"
)
);
ASSERT_EQ
(
"
\\
path
\\
path"
,
BaseLib
::
joinPaths
(
"
\\
path"
,
".
\\
path"
)
);
ASSERT_EQ
(
"
\\
path
\\
path"
,
BaseLib
::
joinPaths
(
"
\\
path
\\
"
,
"
\\
path"
)
);
ASSERT_EQ
(
"
\\
path
\\
.
\\
path"
,
BaseLib
::
joinPaths
(
"
\\
path"
,
".
\\
path"
)
);
#else
ASSERT_EQ
(
"/path/path"
,
BaseLib
::
joinPaths
(
"/path"
,
"path"
)
);
ASSERT_EQ
(
"/path/path"
,
BaseLib
::
joinPaths
(
"/path"
,
"/path"
)
);
ASSERT_EQ
(
"/path/path"
,
BaseLib
::
joinPaths
(
"/path"
,
"./path"
)
);
ASSERT_EQ
(
"/path/path"
,
BaseLib
::
joinPaths
(
"/path/"
,
"/path"
)
);
ASSERT_EQ
(
"/path/./path"
,
BaseLib
::
joinPaths
(
"/path"
,
"./path"
)
);
ASSERT_EQ
(
"/path"
,
BaseLib
::
joinPaths
(
"/"
,
"path"
)
);
#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