Skip to content
Snippets Groups Projects
Commit 49c7b377 authored by Mark Olesen's avatar Mark Olesen
Browse files

BUG: 'processor' in directory name causes issues (issue #199)

- previously just detected the presence of "processor" in the case
  path name. Restrict to checking the final portion.
  Does not solve all problems, but solves ones like this:

      test-new-processor-generation/....
parent 526ecfec
No related branches found
No related tags found
No related merge requests found
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
...@@ -26,6 +26,38 @@ License ...@@ -26,6 +26,38 @@ License
#include "TimePaths.H" #include "TimePaths.H"
#include "IOstreams.H" #include "IOstreams.H"
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
bool Foam::TimePaths::detectProcessorCase()
{
if (processorCase_)
{
return processorCase_;
}
// Look for "processor", but should really check for following digits too
const std::string::size_type sep = globalCaseName_.rfind('/');
const std::string::size_type pos = globalCaseName_.find
(
"processor",
(sep == string::npos ? 0 : sep)
);
if (pos == 0)
{
globalCaseName_ = ".";
processorCase_ = true;
}
else if (pos != string::npos && sep != string::npos && sep == pos-1)
{
globalCaseName_.resize(sep);
processorCase_ = true;
}
return processorCase_;
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::TimePaths::TimePaths Foam::TimePaths::TimePaths
...@@ -38,29 +70,13 @@ Foam::TimePaths::TimePaths ...@@ -38,29 +70,13 @@ Foam::TimePaths::TimePaths
: :
processorCase_(false), processorCase_(false),
rootPath_(rootPath), rootPath_(rootPath),
globalCaseName_(caseName),
case_(caseName), case_(caseName),
system_(systemName), system_(systemName),
constant_(constantName) constant_(constantName)
{ {
// Find out from case name whether a processor directory // Find out from case name whether a processor directory
std::string::size_type pos = caseName.find("processor"); detectProcessorCase();
if (pos != string::npos)
{
processorCase_ = true;
if (pos == 0)
{
globalCaseName_ = ".";
}
else
{
globalCaseName_ = caseName(pos-1);
}
}
else
{
globalCaseName_ = caseName;
}
} }
...@@ -81,27 +97,10 @@ Foam::TimePaths::TimePaths ...@@ -81,27 +97,10 @@ Foam::TimePaths::TimePaths
system_(systemName), system_(systemName),
constant_(constantName) constant_(constantName)
{ {
if (!processorCase) // For convenience: find out from case name whether it is a
{ // processor directory and set processorCase flag so file searching
// For convenience: find out from case name whether it is a // goes up one level.
// processor directory and set processorCase flag so file searching detectProcessorCase();
// goes up one level.
std::string::size_type pos = caseName.find("processor");
if (pos != string::npos)
{
processorCase_ = true;
if (pos == 0)
{
globalCaseName_ = ".";
}
else
{
globalCaseName_ = caseName(pos-1);
}
}
}
} }
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2014 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2014 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
...@@ -59,6 +59,12 @@ class TimePaths ...@@ -59,6 +59,12 @@ class TimePaths
const word constant_; const word constant_;
// Private Member functions
//- Determine from case name whether it is a processor directory
bool detectProcessorCase();
public: public:
// Constructors // Constructors
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment