mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
Merge branch 'develop' of develop.openfoam.com:Development/OpenFOAM-plus into develop
This commit is contained in:
@ -1,6 +1,6 @@
|
|||||||
#include "stream.h"
|
#include "stream.h"
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <stdlib.h>
|
#include <cstdlib>
|
||||||
|
|
||||||
main()
|
main()
|
||||||
{
|
{
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
#include <stdlib.h>
|
#include <cstdlib>
|
||||||
|
|
||||||
class Int
|
class Int
|
||||||
{
|
{
|
||||||
|
|||||||
@ -30,6 +30,8 @@ Description
|
|||||||
|
|
||||||
#include "argList.H"
|
#include "argList.H"
|
||||||
#include "complexFields.H"
|
#include "complexFields.H"
|
||||||
|
#include "ops.H"
|
||||||
|
#include "ListOps.H"
|
||||||
|
|
||||||
using namespace Foam;
|
using namespace Foam;
|
||||||
|
|
||||||
@ -97,9 +99,6 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Info<< "sum = " << sum(fld1) << nl;
|
|
||||||
// Not yet Info<< "min = " << min(fld1) << nl;
|
|
||||||
|
|
||||||
fld1 *= 10;
|
fld1 *= 10;
|
||||||
Info<< "scalar multiply: " << flatOutput(fld1) << nl;
|
Info<< "scalar multiply: " << flatOutput(fld1) << nl;
|
||||||
|
|
||||||
@ -120,6 +119,36 @@ int main(int argc, char *argv[])
|
|||||||
// Info<< "pow(2) : " << pow(fld1, 2) << nl;
|
// Info<< "pow(2) : " << pow(fld1, 2) << nl;
|
||||||
|
|
||||||
|
|
||||||
|
// Make some changes
|
||||||
|
{
|
||||||
|
label i = 1;
|
||||||
|
for (complex& c : fld1)
|
||||||
|
{
|
||||||
|
c.Re() += i;
|
||||||
|
c.Im() -= 10 - i;
|
||||||
|
++i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Info<< nl
|
||||||
|
<< "field = " << fld1 << nl;
|
||||||
|
|
||||||
|
Info<< "magSqr = "
|
||||||
|
<< ListOps::create<scalar>
|
||||||
|
(
|
||||||
|
fld1,
|
||||||
|
[](const complex& c) { return magSqr(c); }
|
||||||
|
)
|
||||||
|
<< nl;
|
||||||
|
|
||||||
|
Info
|
||||||
|
<< "sum = " << sum(fld1) << nl
|
||||||
|
<< "min = " << min(fld1) << nl
|
||||||
|
<< "max = " << max(fld1) << nl;
|
||||||
|
|
||||||
|
// MinMax fails since there is no less comparison operator
|
||||||
|
// Info<< "min/max = " << MinMax<complex>(fld1) << nl;
|
||||||
|
|
||||||
Info<< "\nEnd\n" << endl;
|
Info<< "\nEnd\n" << endl;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
3
applications/test/fileNameOS/Make/files
Normal file
3
applications/test/fileNameOS/Make/files
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
Test-fileNameOS.C
|
||||||
|
|
||||||
|
EXE = $(FOAM_USER_APPBIN)/Test-fileNameOS
|
||||||
2
applications/test/fileNameOS/Make/options
Normal file
2
applications/test/fileNameOS/Make/options
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
/* EXE_INC = */
|
||||||
|
/* EXE_LIBS = */
|
||||||
106
applications/test/fileNameOS/Test-fileNameOS.C
Normal file
106
applications/test/fileNameOS/Test-fileNameOS.C
Normal file
@ -0,0 +1,106 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2019 OpenCFD Ltd.
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||||
|
under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
Application
|
||||||
|
Test-fileNameOS
|
||||||
|
|
||||||
|
Description
|
||||||
|
Test fileName behaviour, potential OS capabilities etc.
|
||||||
|
|
||||||
|
In the distant future could possibly replace parts with C++ filesystem
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#include "argList.H"
|
||||||
|
#include "fileName.H"
|
||||||
|
#include "OSspecific.H"
|
||||||
|
#include "Switch.H"
|
||||||
|
|
||||||
|
#include <csignal>
|
||||||
|
#include <cstdlib>
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
|
|
||||||
|
using namespace Foam;
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
void testDirname(const std::string& rawInput)
|
||||||
|
{
|
||||||
|
fileName input(fileName::validate(rawInput));
|
||||||
|
|
||||||
|
Info<< nl
|
||||||
|
<< "input: " << rawInput << nl
|
||||||
|
<< "fileName:" << input << nl
|
||||||
|
<< " path:" << input.path()
|
||||||
|
<< " name:\"" << input.name() << '"'
|
||||||
|
<< " ext:\"" << input.ext() << '"'
|
||||||
|
<< " components: " << flatOutput(input.components()) << nl;
|
||||||
|
|
||||||
|
if (rawInput.size() != input.size())
|
||||||
|
{
|
||||||
|
Info<< " This would be Fatal with debug > 1" << nl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
// Main program:
|
||||||
|
|
||||||
|
int main(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
argList::noParallel();
|
||||||
|
argList::addBoolOption("no-space", "allowSpaceInFileName = false");
|
||||||
|
argList::addBoolOption("with-space", "set allowSpaceInFileName = true");
|
||||||
|
|
||||||
|
#include "setRootCase.H"
|
||||||
|
|
||||||
|
if (args.found("with-space"))
|
||||||
|
{
|
||||||
|
fileName::allowSpaceInFileName = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (args.found("no-space"))
|
||||||
|
{
|
||||||
|
fileName::allowSpaceInFileName = false;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Info<<"fileName with spaces? : "
|
||||||
|
<< Switch(bool(fileName::allowSpaceInFileName)) << nl << nl;
|
||||||
|
|
||||||
|
|
||||||
|
{
|
||||||
|
testDirname("/abc");
|
||||||
|
testDirname("/abc/with space/name");
|
||||||
|
testDirname("/abc/with space/more space");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Info<< "\nEnd\n" << endl;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -1,5 +1,6 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <stdlib.h>
|
#include <cstdlib>
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
|
|||||||
@ -32,6 +32,7 @@ Description
|
|||||||
#include "HashOps.H"
|
#include "HashOps.H"
|
||||||
#include "ListOps.H"
|
#include "ListOps.H"
|
||||||
#include "scalarField.H"
|
#include "scalarField.H"
|
||||||
|
#include "complexField.H"
|
||||||
#include "MinMax.H"
|
#include "MinMax.H"
|
||||||
#include "dimensionedScalar.H"
|
#include "dimensionedScalar.H"
|
||||||
|
|
||||||
@ -47,6 +48,19 @@ Ostream& printInfo(const MinMax<T>& range)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
void testUniformField(const T& val)
|
||||||
|
{
|
||||||
|
constexpr label N = 10;
|
||||||
|
|
||||||
|
// Field<T> fld(N, val);
|
||||||
|
List<T> fld(N, val);
|
||||||
|
|
||||||
|
Info<< "field: " << fld << nl
|
||||||
|
<< "min/max: " << minMaxMag(fld) << nl;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
// Main program:
|
// Main program:
|
||||||
|
|
||||||
@ -225,6 +239,15 @@ int main(int argc, char *argv[])
|
|||||||
Info<< "filtered: " << hashed << nl;
|
Info<< "filtered: " << hashed << nl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Min/max of uniform fields
|
||||||
|
{
|
||||||
|
testUniformField<scalar>(100);
|
||||||
|
// testUniformField<complex>(complex(100, 0));
|
||||||
|
}
|
||||||
|
|
||||||
|
Info<< "\nEnd\n" << nl;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
3
applications/test/readDir/Make/files
Normal file
3
applications/test/readDir/Make/files
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
Test-readDir.C
|
||||||
|
|
||||||
|
EXE = $(FOAM_USER_APPBIN)/Test-readDir
|
||||||
2
applications/test/readDir/Make/options
Normal file
2
applications/test/readDir/Make/options
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
/* EXE_INC = -I$(LIB_SRC)/finiteVolume/lnInclude */
|
||||||
|
/* EXE_LIBS = -lfiniteVolume */
|
||||||
74
applications/test/readDir/Test-readDir.C
Normal file
74
applications/test/readDir/Test-readDir.C
Normal file
@ -0,0 +1,74 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2019 OpenCFD Ltd.
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||||
|
under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
Description
|
||||||
|
Test functionality of Foam::readDir
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#include "argList.H"
|
||||||
|
#include "OSspecific.H"
|
||||||
|
#include "fileNameList.H"
|
||||||
|
|
||||||
|
using namespace Foam;
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
// Main program:
|
||||||
|
|
||||||
|
int main(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
argList::noBanner();
|
||||||
|
argList::noParallel();
|
||||||
|
argList::addBoolOption("dir", "list directories instead of files");
|
||||||
|
|
||||||
|
#include "setRootCase.H"
|
||||||
|
|
||||||
|
fileName::Type listType = fileName::FILE;
|
||||||
|
|
||||||
|
if (args.found("dir"))
|
||||||
|
{
|
||||||
|
Info<< "Listing directories" << nl;
|
||||||
|
listType = fileName::DIRECTORY;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Info<< "Listing files" << nl;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
{
|
||||||
|
Info<< nl;
|
||||||
|
for (const word& item : readDir(".", listType))
|
||||||
|
{
|
||||||
|
Info<< " " << item << nl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Info<< "\nEnd\n" << endl;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -2,7 +2,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) 2018 OpenCFD Ltd.
|
\\ / A nd | Copyright (C) 2018-2019 OpenCFD Ltd.
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -31,6 +31,7 @@ Description
|
|||||||
|
|
||||||
#include "vector.H"
|
#include "vector.H"
|
||||||
#include "IOstreams.H"
|
#include "IOstreams.H"
|
||||||
|
#include <algorithm>
|
||||||
|
|
||||||
using namespace Foam;
|
using namespace Foam;
|
||||||
|
|
||||||
@ -74,6 +75,18 @@ void doTest(vector& vec1, vector& vec2)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class VecSpace>
|
||||||
|
void testIterator(const VecSpace& vs)
|
||||||
|
{
|
||||||
|
Info<< "size: " << vs.size() << " for:";
|
||||||
|
for (const auto& val : vs)
|
||||||
|
{
|
||||||
|
Info<< " " << val;
|
||||||
|
}
|
||||||
|
Info<< nl;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
// Main program:
|
// Main program:
|
||||||
|
|
||||||
@ -89,8 +102,21 @@ int main(int argc, char *argv[])
|
|||||||
vector vec2(0.5, 0.51, -0.5);
|
vector vec2(0.5, 0.51, -0.5);
|
||||||
|
|
||||||
doTest(vec1, vec2);
|
doTest(vec1, vec2);
|
||||||
|
|
||||||
|
testIterator(vec1);
|
||||||
|
testIterator(vec2);
|
||||||
|
|
||||||
|
// Use STL algorithm(s)
|
||||||
|
|
||||||
|
std::sort(vec2.begin(), vec2.end());
|
||||||
|
Info<< "sorted: " << vec2 << nl;
|
||||||
|
|
||||||
|
std::random_shuffle(vec2.begin(), vec2.end());
|
||||||
|
Info<< "shuffled: " << vec2 << nl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Info<< "\nEnd\n" << nl;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
10
applications/test/wmake1/Make/files
Normal file
10
applications/test/wmake1/Make/files
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
Test-wmake1.C
|
||||||
|
|
||||||
|
/* #if OPENFOAM == 1812 */
|
||||||
|
#if OPENFOAM > 1812
|
||||||
|
newStub.C
|
||||||
|
#else
|
||||||
|
oldStub.C
|
||||||
|
#endif
|
||||||
|
|
||||||
|
EXE = $(FOAM_APPBIN)/Test-wmake1
|
||||||
2
applications/test/wmake1/Make/options
Normal file
2
applications/test/wmake1/Make/options
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
EXE_INC =
|
||||||
|
EXE_LIBS =
|
||||||
56
applications/test/wmake1/Test-wmake1.C
Normal file
56
applications/test/wmake1/Test-wmake1.C
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2019 OpenCFD Ltd.
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||||
|
under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
Application
|
||||||
|
Test-wmake1
|
||||||
|
|
||||||
|
Description
|
||||||
|
Some tests for wmake features.
|
||||||
|
For example, testing how robust or fragile version-dependent conditional
|
||||||
|
compilation works.
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#include "argList.H"
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
void printTest();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
using namespace Foam;
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
int main(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
printTest();
|
||||||
|
|
||||||
|
Info<< "\nEnd\n" << nl;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
13
applications/test/wmake1/newStub.C
Normal file
13
applications/test/wmake1/newStub.C
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
// Some test code
|
||||||
|
|
||||||
|
#include "foamVersion.H"
|
||||||
|
#include "IOstreams.H"
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
void printTest()
|
||||||
|
{
|
||||||
|
Info<< nl;
|
||||||
|
foamVersion::printBuildInfo();
|
||||||
|
}
|
||||||
|
}
|
||||||
17
applications/test/wmake1/oldStub.C
Normal file
17
applications/test/wmake1/oldStub.C
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
// Some test code
|
||||||
|
|
||||||
|
#include "IOstreams.H"
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
void printTest()
|
||||||
|
{
|
||||||
|
Info<< nl << "Using old stub" << nl;
|
||||||
|
|
||||||
|
#if OPENFOAM
|
||||||
|
Info<< "OPENFOAM=" << OPENFOAM << nl;
|
||||||
|
#else
|
||||||
|
Info<< "OPENFOAM is undefined" << nl;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -121,14 +121,14 @@ void usage()
|
|||||||
std::cout
|
std::cout
|
||||||
<< "usage: addr2line [-e filename|--exe=filename]"
|
<< "usage: addr2line [-e filename|--exe=filename]"
|
||||||
" address [address...]\n" << std::endl;
|
" address [address...]\n" << std::endl;
|
||||||
::exit(1);
|
std::exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void version()
|
void version()
|
||||||
{
|
{
|
||||||
std::cout<< "OpenFOAM addr2line emulator\n" << std::endl;
|
std::cout<< "OpenFOAM addr2line emulator\n" << std::endl;
|
||||||
::exit(0);
|
std::exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -64,6 +64,9 @@ InfoSwitches
|
|||||||
|
|
||||||
// Allow case-supplied C++ code (#codeStream, codedFixedValue)
|
// Allow case-supplied C++ code (#codeStream, codedFixedValue)
|
||||||
allowSystemOperations 1;
|
allowSystemOperations 1;
|
||||||
|
|
||||||
|
// Allow space character in fileName (use with caution)
|
||||||
|
allowSpaceInFileName 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -1,18 +1,20 @@
|
|||||||
|
clockTime/clockTime.C
|
||||||
|
clockValue/clockValue.C
|
||||||
|
cpuInfo/cpuInfo.C
|
||||||
|
cpuTime/cpuTime.C
|
||||||
|
memInfo/memInfo.C
|
||||||
|
|
||||||
signals/sigFpe.C
|
signals/sigFpe.C
|
||||||
signals/sigSegv.C
|
signals/sigSegv.C
|
||||||
signals/sigInt.C
|
signals/sigInt.C
|
||||||
signals/sigQuit.C
|
signals/sigQuit.C
|
||||||
signals/sigStopAtWriteNow.C
|
signals/sigStopAtWriteNow.C
|
||||||
signals/sigWriteNow.C
|
signals/sigWriteNow.C
|
||||||
|
signals/timer.C
|
||||||
|
|
||||||
regExpPosix.C
|
regExpPosix.C
|
||||||
timer.C
|
|
||||||
fileStat.C
|
fileStat.C
|
||||||
POSIX.C
|
POSIX.C
|
||||||
cpuTime/cpuTime.C
|
|
||||||
clockTime/clockTime.C
|
|
||||||
clockValue/clockValue.C
|
|
||||||
cpuInfo/cpuInfo.C
|
|
||||||
memInfo/memInfo.C
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Note: fileMonitor assumes inotify by default. Compile with -DFOAM_USE_STAT
|
* Note: fileMonitor assumes inotify by default. Compile with -DFOAM_USE_STAT
|
||||||
|
|||||||
@ -2,7 +2,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) 2016-2018 OpenCFD Ltd.
|
\\ / A nd | Copyright (C) 2016-2019 OpenCFD Ltd.
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
| Copyright (C) 2011-2017 OpenFOAM Foundation
|
| Copyright (C) 2011-2017 OpenFOAM Foundation
|
||||||
@ -34,14 +34,11 @@ Description
|
|||||||
|
|
||||||
#include "OSspecific.H"
|
#include "OSspecific.H"
|
||||||
#include "POSIX.H"
|
#include "POSIX.H"
|
||||||
#include "foamVersion.H"
|
|
||||||
#include "fileName.H"
|
#include "fileName.H"
|
||||||
#include "fileStat.H"
|
#include "fileStat.H"
|
||||||
#include "timer.H"
|
#include "timer.H"
|
||||||
#include "IFstream.H"
|
|
||||||
#include "DynamicList.H"
|
#include "DynamicList.H"
|
||||||
#include "CStringList.H"
|
#include "CStringList.H"
|
||||||
#include "SubList.H"
|
|
||||||
#include "IOstreams.H"
|
#include "IOstreams.H"
|
||||||
#include "Pstream.H"
|
#include "Pstream.H"
|
||||||
|
|
||||||
@ -49,7 +46,7 @@ Description
|
|||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <cctype>
|
#include <cctype>
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <cstdio>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <dirent.h>
|
#include <dirent.h>
|
||||||
#include <pwd.h>
|
#include <pwd.h>
|
||||||
@ -87,44 +84,6 @@ static bool cwdPreference_(Foam::debug::optimisationSwitch("cwd", 0));
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * * Local Functions * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Local Functions * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
// Like fileName "/" global operator, but retain any invalid characters
|
|
||||||
static inline Foam::fileName fileNameConcat
|
|
||||||
(
|
|
||||||
const std::string& a,
|
|
||||||
const std::string& b
|
|
||||||
)
|
|
||||||
{
|
|
||||||
if (a.size())
|
|
||||||
{
|
|
||||||
if (b.size())
|
|
||||||
{
|
|
||||||
// Two non-empty strings: can concatenate
|
|
||||||
|
|
||||||
if (a.back() == '/' || b.front() == '/')
|
|
||||||
{
|
|
||||||
return Foam::fileName(a + b, false);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return Foam::fileName(a + '/' + b, false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// The second string was empty
|
|
||||||
return Foam::fileName(a, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (b.size())
|
|
||||||
{
|
|
||||||
// The first string is empty
|
|
||||||
return Foam::fileName(b, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Both strings are empty
|
|
||||||
return Foam::fileName();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// After a fork in system(), before the exec() do the following
|
// After a fork in system(), before the exec() do the following
|
||||||
// - close stdin when executing in background (daemon-like)
|
// - close stdin when executing in background (daemon-like)
|
||||||
// - redirect stdout to stderr when infoDetailLevel == 0
|
// - redirect stdout to stderr when infoDetailLevel == 0
|
||||||
@ -145,6 +104,141 @@ static inline void redirects(const bool bg)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * Local Classes * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
namespace POSIX
|
||||||
|
{
|
||||||
|
|
||||||
|
//- A simple directory contents iterator
|
||||||
|
class directoryIterator
|
||||||
|
{
|
||||||
|
DIR* dirptr_;
|
||||||
|
|
||||||
|
bool exists_;
|
||||||
|
|
||||||
|
bool hidden_;
|
||||||
|
|
||||||
|
std::string item_;
|
||||||
|
|
||||||
|
//- Accept file/dir name
|
||||||
|
inline bool accept() const
|
||||||
|
{
|
||||||
|
return
|
||||||
|
(
|
||||||
|
item_.size() && item_ != "." && item_ != ".."
|
||||||
|
&& (hidden_ || item_[0] != '.')
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
// Constructors
|
||||||
|
|
||||||
|
//- Construct for dirName, optionally allowing hidden files/dirs
|
||||||
|
directoryIterator(const fileName& dirName, bool allowHidden = false)
|
||||||
|
:
|
||||||
|
dirptr_(nullptr),
|
||||||
|
exists_(false),
|
||||||
|
hidden_(allowHidden),
|
||||||
|
item_()
|
||||||
|
{
|
||||||
|
if (!dirName.empty())
|
||||||
|
{
|
||||||
|
dirptr_ = ::opendir(dirName.c_str());
|
||||||
|
exists_ = (dirptr_ != nullptr);
|
||||||
|
next(); // Move to first element
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//- Destructor
|
||||||
|
~directoryIterator()
|
||||||
|
{
|
||||||
|
close();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Member Functions
|
||||||
|
|
||||||
|
//- Directory open succeeded
|
||||||
|
bool exists() const
|
||||||
|
{
|
||||||
|
return exists_;
|
||||||
|
}
|
||||||
|
|
||||||
|
//- Directory pointer is valid
|
||||||
|
bool good() const
|
||||||
|
{
|
||||||
|
return dirptr_;
|
||||||
|
}
|
||||||
|
|
||||||
|
//- Close directory
|
||||||
|
void close()
|
||||||
|
{
|
||||||
|
if (dirptr_)
|
||||||
|
{
|
||||||
|
::closedir(dirptr_);
|
||||||
|
dirptr_ = nullptr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//- The current item
|
||||||
|
const std::string& val() const
|
||||||
|
{
|
||||||
|
return item_;
|
||||||
|
}
|
||||||
|
|
||||||
|
//- Read next item, always ignoring "." and ".." entries.
|
||||||
|
// Normally also ignore hidden files/dirs (beginning with '.')
|
||||||
|
// Automatically close when there are no more items
|
||||||
|
bool next()
|
||||||
|
{
|
||||||
|
struct dirent *list;
|
||||||
|
|
||||||
|
while (dirptr_ && (list = ::readdir(dirptr_)) != nullptr)
|
||||||
|
{
|
||||||
|
item_ = list->d_name;
|
||||||
|
|
||||||
|
if (accept())
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
close(); // No more items
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Member Operators
|
||||||
|
|
||||||
|
//- Same as good()
|
||||||
|
operator bool() const
|
||||||
|
{
|
||||||
|
return good();
|
||||||
|
}
|
||||||
|
|
||||||
|
//- Same as val()
|
||||||
|
const std::string& operator*() const
|
||||||
|
{
|
||||||
|
return val();
|
||||||
|
}
|
||||||
|
|
||||||
|
//- Same as next()
|
||||||
|
directoryIterator& operator++()
|
||||||
|
{
|
||||||
|
next();
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
} // End namespace POSIX
|
||||||
|
} // End namespace Foam
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
pid_t Foam::pid()
|
pid_t Foam::pid()
|
||||||
@ -455,135 +549,122 @@ bool Foam::mkDir(const fileName& pathName, mode_t mode)
|
|||||||
// Directory made OK so return true
|
// Directory made OK so return true
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
|
switch (errno)
|
||||||
{
|
{
|
||||||
switch (errno)
|
case EPERM:
|
||||||
{
|
{
|
||||||
case EPERM:
|
FatalErrorInFunction
|
||||||
{
|
<< "The filesystem containing " << pathName
|
||||||
FatalErrorInFunction
|
<< " does not support the creation of directories."
|
||||||
<< "The filesystem containing " << pathName
|
<< exit(FatalError);
|
||||||
<< " does not support the creation of directories."
|
break;
|
||||||
<< exit(FatalError);
|
}
|
||||||
|
|
||||||
return false;
|
case EEXIST:
|
||||||
|
{
|
||||||
|
// Directory already exists so simply return true
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
case EFAULT:
|
||||||
|
{
|
||||||
|
FatalErrorInFunction
|
||||||
|
<< "" << pathName
|
||||||
|
<< " points outside your accessible address space."
|
||||||
|
<< exit(FatalError);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case EACCES:
|
||||||
|
{
|
||||||
|
FatalErrorInFunction
|
||||||
|
<< "The parent directory does not allow write "
|
||||||
|
"permission to the process,"<< nl
|
||||||
|
<< " or one of the directories in " << pathName
|
||||||
|
<< " did not allow search (execute) permission."
|
||||||
|
<< exit(FatalError);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case ENAMETOOLONG:
|
||||||
|
{
|
||||||
|
FatalErrorInFunction
|
||||||
|
<< "" << pathName << " is too long."
|
||||||
|
<< exit(FatalError);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case ENOENT:
|
||||||
|
{
|
||||||
|
// Part of the path does not exist so try to create it
|
||||||
|
if (pathName.path().size() && mkDir(pathName.path(), mode))
|
||||||
|
{
|
||||||
|
return mkDir(pathName, mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
case EEXIST:
|
FatalErrorInFunction
|
||||||
{
|
<< "Couldn't create directory " << pathName
|
||||||
// Directory already exists so simply return true
|
<< exit(FatalError);
|
||||||
return true;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case EFAULT:
|
case ENOTDIR:
|
||||||
{
|
{
|
||||||
FatalErrorInFunction
|
FatalErrorInFunction
|
||||||
<< "" << pathName
|
<< "A component used as a directory in " << pathName
|
||||||
<< " points outside your accessible address space."
|
<< " is not, in fact, a directory."
|
||||||
<< exit(FatalError);
|
<< exit(FatalError);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
case ENOMEM:
|
||||||
}
|
{
|
||||||
|
FatalErrorInFunction
|
||||||
|
<< "Insufficient kernel memory was available to make directory "
|
||||||
|
<< pathName << '.'
|
||||||
|
<< exit(FatalError);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case EACCES:
|
case EROFS:
|
||||||
{
|
{
|
||||||
FatalErrorInFunction
|
FatalErrorInFunction
|
||||||
<< "The parent directory does not allow write "
|
<< "" << pathName
|
||||||
"permission to the process,"<< nl
|
<< " refers to a file on a read-only filesystem."
|
||||||
<< "or one of the directories in " << pathName
|
<< exit(FatalError);
|
||||||
<< " did not allow search (execute) permission."
|
break;
|
||||||
<< exit(FatalError);
|
}
|
||||||
|
|
||||||
return false;
|
case ELOOP:
|
||||||
}
|
{
|
||||||
|
FatalErrorInFunction
|
||||||
|
<< "Too many symbolic links were encountered in resolving "
|
||||||
|
<< pathName << '.'
|
||||||
|
<< exit(FatalError);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case ENAMETOOLONG:
|
case ENOSPC:
|
||||||
{
|
{
|
||||||
FatalErrorInFunction
|
FatalErrorInFunction
|
||||||
<< "" << pathName << " is too long."
|
<< "The device containing " << pathName
|
||||||
<< exit(FatalError);
|
<< " has no room for the new directory or "
|
||||||
|
<< "the user's disk quota is exhausted."
|
||||||
|
<< exit(FatalError);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
default:
|
||||||
}
|
{
|
||||||
|
FatalErrorInFunction
|
||||||
case ENOENT:
|
<< "Couldn't create directory " << pathName
|
||||||
{
|
<< exit(FatalError);
|
||||||
// Part of the path does not exist so try to create it
|
break;
|
||||||
if (pathName.path().size() && mkDir(pathName.path(), mode))
|
|
||||||
{
|
|
||||||
return mkDir(pathName, mode);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
FatalErrorInFunction
|
|
||||||
<< "Couldn't create directory " << pathName
|
|
||||||
<< exit(FatalError);
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
case ENOTDIR:
|
|
||||||
{
|
|
||||||
FatalErrorInFunction
|
|
||||||
<< "A component used as a directory in " << pathName
|
|
||||||
<< " is not, in fact, a directory."
|
|
||||||
<< exit(FatalError);
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
case ENOMEM:
|
|
||||||
{
|
|
||||||
FatalErrorInFunction
|
|
||||||
<< "Insufficient kernel memory was available to make "
|
|
||||||
"directory " << pathName << '.'
|
|
||||||
<< exit(FatalError);
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
case EROFS:
|
|
||||||
{
|
|
||||||
FatalErrorInFunction
|
|
||||||
<< "" << pathName
|
|
||||||
<< " refers to a file on a read-only filesystem."
|
|
||||||
<< exit(FatalError);
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
case ELOOP:
|
|
||||||
{
|
|
||||||
FatalErrorInFunction
|
|
||||||
<< "Too many symbolic links were encountered in resolving "
|
|
||||||
<< pathName << '.'
|
|
||||||
<< exit(FatalError);
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
case ENOSPC:
|
|
||||||
{
|
|
||||||
FatalErrorInFunction
|
|
||||||
<< "The device containing " << pathName
|
|
||||||
<< " has no room for the new directory or "
|
|
||||||
<< "the user's disk quota is exhausted."
|
|
||||||
<< exit(FatalError);
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
default:
|
|
||||||
{
|
|
||||||
FatalErrorInFunction
|
|
||||||
<< "Couldn't create directory " << pathName
|
|
||||||
<< exit(FatalError);
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -797,7 +878,7 @@ Foam::fileNameList Foam::readDir
|
|||||||
)
|
)
|
||||||
{
|
{
|
||||||
// Initial filename list size and the increment when resizing the list
|
// Initial filename list size and the increment when resizing the list
|
||||||
static const int maxNnames = 100;
|
constexpr int maxNnames = 100;
|
||||||
|
|
||||||
// Basic sanity: cannot strip '.gz' from directory names
|
// Basic sanity: cannot strip '.gz' from directory names
|
||||||
const bool stripgz = filtergz && (type != fileName::DIRECTORY);
|
const bool stripgz = filtergz && (type != fileName::DIRECTORY);
|
||||||
@ -805,14 +886,10 @@ Foam::fileNameList Foam::readDir
|
|||||||
|
|
||||||
fileNameList dirEntries;
|
fileNameList dirEntries;
|
||||||
|
|
||||||
// Open directory and set the structure pointer
|
// Iterate contents (ignores an empty directory name)
|
||||||
// Do not attempt to open an empty directory name
|
|
||||||
DIR *source;
|
POSIX::directoryIterator dirIter(directory);
|
||||||
if
|
if (!dirIter.exists())
|
||||||
(
|
|
||||||
directory.empty()
|
|
||||||
|| (source = ::opendir(directory.c_str())) == nullptr
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
if (POSIX::debug)
|
if (POSIX::debug)
|
||||||
{
|
{
|
||||||
@ -835,19 +912,12 @@ Foam::fileNameList Foam::readDir
|
|||||||
|
|
||||||
label nFailed = 0; // Entries with invalid characters
|
label nFailed = 0; // Entries with invalid characters
|
||||||
label nEntries = 0; // Number of selected entries
|
label nEntries = 0; // Number of selected entries
|
||||||
dirEntries.setSize(maxNnames);
|
dirEntries.resize(maxNnames);
|
||||||
|
|
||||||
// Read and parse all the entries in the directory
|
// Process the directory entries
|
||||||
for (struct dirent *list; (list = ::readdir(source)) != nullptr; /*nil*/)
|
for (/*nil*/; dirIter; ++dirIter)
|
||||||
{
|
{
|
||||||
const std::string item(list->d_name);
|
const std::string& item = *dirIter;
|
||||||
|
|
||||||
// Ignore files/directories beginning with "."
|
|
||||||
// These are the ".", ".." directories and any hidden files/dirs
|
|
||||||
if (item.empty() || item[0] == '.')
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Validate filename without spaces, quotes, etc in the name.
|
// Validate filename without spaces, quotes, etc in the name.
|
||||||
// No duplicate slashes to strip - dirent will not have them anyhow.
|
// No duplicate slashes to strip - dirent will not have them anyhow.
|
||||||
@ -867,7 +937,7 @@ Foam::fileNameList Foam::readDir
|
|||||||
{
|
{
|
||||||
if (nEntries >= dirEntries.size())
|
if (nEntries >= dirEntries.size())
|
||||||
{
|
{
|
||||||
dirEntries.setSize(dirEntries.size() + maxNnames);
|
dirEntries.resize(dirEntries.size() + maxNnames);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (stripgz && name.hasExt(extgz))
|
if (stripgz && name.hasExt(extgz))
|
||||||
@ -881,10 +951,9 @@ Foam::fileNameList Foam::readDir
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
::closedir(source);
|
|
||||||
|
|
||||||
// Finalize the length of the entries list
|
// Finalize the length of the entries list
|
||||||
dirEntries.setSize(nEntries);
|
dirEntries.resize(nEntries);
|
||||||
|
|
||||||
if (nFailed && POSIX::debug)
|
if (nFailed && POSIX::debug)
|
||||||
{
|
{
|
||||||
@ -934,14 +1003,14 @@ bool Foam::cp(const fileName& src, const fileName& dest, const bool followLink)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Open and check streams.
|
// Open and check streams. Enforce binary for extra safety
|
||||||
std::ifstream srcStream(src);
|
std::ifstream srcStream(src, ios_base::in | ios_base::binary);
|
||||||
if (!srcStream)
|
if (!srcStream)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::ofstream destStream(destFile);
|
std::ofstream destStream(destFile, ios_base::out | ios_base::binary);
|
||||||
if (!destStream)
|
if (!destStream)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
@ -1141,12 +1210,10 @@ bool Foam::mv(const fileName& src, const fileName& dst, const bool followLink)
|
|||||||
{
|
{
|
||||||
const fileName dstName(dst/src.name());
|
const fileName dstName(dst/src.name());
|
||||||
|
|
||||||
return ::rename(src.c_str(), dstName.c_str()) == 0;
|
return (0 == ::rename(src.c_str(), dstName.c_str()));
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return ::rename(src.c_str(), dst.c_str()) == 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return (0 == ::rename(src.c_str(), dst.c_str()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1187,7 +1254,7 @@ bool Foam::mvBak(const fileName& src, const std::string& ext)
|
|||||||
// possible index where we have no choice
|
// possible index where we have no choice
|
||||||
if (!exists(dstName, false) || n == maxIndex)
|
if (!exists(dstName, false) || n == maxIndex)
|
||||||
{
|
{
|
||||||
return ::rename(src.c_str(), dstName.c_str()) == 0;
|
return (0 == ::rename(src.c_str(), dstName.c_str()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1215,28 +1282,23 @@ bool Foam::rm(const fileName& file)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Try returning plain file name; if not there, try with .gz
|
// If removal of plain file name fails, try with .gz
|
||||||
if (::remove(file.c_str()) == 0)
|
|
||||||
{
|
return
|
||||||
return true;
|
(
|
||||||
}
|
0 == ::remove(file.c_str())
|
||||||
else
|
|| 0 == ::remove((file + ".gz").c_str())
|
||||||
{
|
);
|
||||||
return ::remove(string(file + ".gz").c_str()) == 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool Foam::rmDir(const fileName& directory, const bool silent)
|
bool Foam::rmDir(const fileName& directory, const bool silent)
|
||||||
{
|
{
|
||||||
// Open directory and set the structure pointer
|
// Iterate contents (ignores an empty directory name)
|
||||||
// Do not attempt to open an empty directory name
|
// Also retain hidden files/dirs for removal
|
||||||
DIR *source;
|
|
||||||
if
|
POSIX::directoryIterator dirIter(directory, true);
|
||||||
(
|
if (!dirIter.exists())
|
||||||
directory.empty()
|
|
||||||
|| (source = ::opendir(directory.c_str())) == nullptr
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
if (!silent)
|
if (!silent)
|
||||||
{
|
{
|
||||||
@ -1259,21 +1321,16 @@ bool Foam::rmDir(const fileName& directory, const bool silent)
|
|||||||
|
|
||||||
// Process each directory entry, counting any errors encountered
|
// Process each directory entry, counting any errors encountered
|
||||||
label nErrors = 0;
|
label nErrors = 0;
|
||||||
for (struct dirent *list; (list = ::readdir(source)) != nullptr; /*nil*/)
|
|
||||||
{
|
|
||||||
const std::string item(list->d_name);
|
|
||||||
|
|
||||||
// Ignore "." and ".." directories
|
for (/*nil*/; dirIter; ++dirIter)
|
||||||
if (item.empty() || item == "." || item == "..")
|
{
|
||||||
{
|
const std::string& item = *dirIter;
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Allow invalid characters (spaces, quotes, etc),
|
// Allow invalid characters (spaces, quotes, etc),
|
||||||
// otherwise we cannot subdirs with these types of names.
|
// otherwise we cannot remove subdirs with these types of names.
|
||||||
// -> const fileName path = directory/name; <-
|
// -> const fileName path = directory/name; <-
|
||||||
|
|
||||||
const fileName path(fileNameConcat(directory, item));
|
const fileName path(fileName::concat(directory, item));
|
||||||
|
|
||||||
if (path.type(false) == fileName::DIRECTORY)
|
if (path.type(false) == fileName::DIRECTORY)
|
||||||
{
|
{
|
||||||
@ -1314,7 +1371,6 @@ bool Foam::rmDir(const fileName& directory, const bool silent)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// clean up
|
// clean up
|
||||||
::closedir(source);
|
|
||||||
return !nErrors;
|
return !nErrors;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -51,8 +51,8 @@ namespace POSIX
|
|||||||
//- Declare namespace and its debug switch
|
//- Declare namespace and its debug switch
|
||||||
NamespaceName("POSIX");
|
NamespaceName("POSIX");
|
||||||
|
|
||||||
const label pathLengthChunk = 256;
|
constexpr label pathLengthChunk = 256;
|
||||||
const label pathLengthMax = 4096;
|
constexpr label pathLengthMax = 4096;
|
||||||
}
|
}
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|||||||
@ -41,7 +41,7 @@ SourceFiles
|
|||||||
#define cpuTime_H
|
#define cpuTime_H
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <time.h>
|
#include <ctime>
|
||||||
#include <sys/times.h>
|
#include <sys/times.h>
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd |
|
\\ / A nd | Copyright (C) 2018 OpenCFD Ltd.
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
| Copyright (C) 2011-2016 OpenFOAM Foundation
|
| Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd |
|
\\ / A nd | Copyright (C) 2017-2018 OpenCFD Ltd.
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
| Copyright (C) 2011-2015 OpenFOAM Foundation
|
| Copyright (C) 2011-2015 OpenFOAM Foundation
|
||||||
@ -54,6 +54,7 @@ SourceFiles
|
|||||||
namespace Foam
|
namespace Foam
|
||||||
{
|
{
|
||||||
|
|
||||||
|
// Forward Declarations
|
||||||
class fileMonitor;
|
class fileMonitor;
|
||||||
class fileMonitorWatcher;
|
class fileMonitorWatcher;
|
||||||
|
|
||||||
@ -63,7 +64,6 @@ class fileMonitorWatcher;
|
|||||||
|
|
||||||
class fileMonitor
|
class fileMonitor
|
||||||
{
|
{
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
// Public data types
|
// Public data types
|
||||||
@ -79,6 +79,7 @@ public:
|
|||||||
static const Enum<fileState> fileStateNames_;
|
static const Enum<fileState> fileStateNames_;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
// Private data
|
// Private data
|
||||||
|
|
||||||
//- Whether to use inotify (requires -DFOAM_USE_INOTIFY, see above)
|
//- Whether to use inotify (requires -DFOAM_USE_INOTIFY, see above)
|
||||||
@ -120,7 +121,7 @@ public:
|
|||||||
// Constructors
|
// Constructors
|
||||||
|
|
||||||
//- Construct null
|
//- Construct null
|
||||||
fileMonitor(const bool useInotify);
|
explicit fileMonitor(const bool useInotify);
|
||||||
|
|
||||||
|
|
||||||
//- Destructor
|
//- Destructor
|
||||||
|
|||||||
@ -29,7 +29,6 @@ License
|
|||||||
#include "IOstreams.H"
|
#include "IOstreams.H"
|
||||||
#include "timer.H"
|
#include "timer.H"
|
||||||
|
|
||||||
#include <signal.h>
|
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#ifndef darwin
|
#ifndef darwin
|
||||||
#include <sys/sysmacros.h>
|
#include <sys/sysmacros.h>
|
||||||
|
|||||||
@ -111,7 +111,7 @@ public:
|
|||||||
);
|
);
|
||||||
|
|
||||||
//- Construct from Istream
|
//- Construct from Istream
|
||||||
fileStat(Istream& is);
|
explicit fileStat(Istream& is);
|
||||||
|
|
||||||
|
|
||||||
// Member Functions
|
// Member Functions
|
||||||
|
|||||||
@ -2,7 +2,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) 2016-2018 OpenCFD Ltd.
|
\\ / A nd | Copyright (C) 2016-2019 OpenCFD Ltd.
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
| Copyright (C) 2011-2015 OpenFOAM Foundation
|
| Copyright (C) 2011-2015 OpenFOAM Foundation
|
||||||
@ -33,6 +33,8 @@ License
|
|||||||
#include "Switch.H"
|
#include "Switch.H"
|
||||||
#include "UList.H"
|
#include "UList.H"
|
||||||
|
|
||||||
|
#include <limits>
|
||||||
|
|
||||||
#if defined(__linux__) && defined(__GNUC__)
|
#if defined(__linux__) && defined(__GNUC__)
|
||||||
#ifndef __USE_GNU
|
#ifndef __USE_GNU
|
||||||
#define __USE_GNU // To use feenableexcept()
|
#define __USE_GNU // To use feenableexcept()
|
||||||
@ -47,7 +49,9 @@ License
|
|||||||
#include "feexceptErsatz.H"
|
#include "feexceptErsatz.H"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <limits>
|
// File-local functions
|
||||||
|
#include "signalMacros.C"
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||||
|
|
||||||
@ -57,8 +61,6 @@ bool Foam::sigFpe::switchNan_(Foam::debug::optimisationSwitch("setNaN", 0));
|
|||||||
bool Foam::sigFpe::sigActive_ = false;
|
bool Foam::sigFpe::sigActive_ = false;
|
||||||
bool Foam::sigFpe::nanActive_ = false;
|
bool Foam::sigFpe::nanActive_ = false;
|
||||||
|
|
||||||
struct sigaction Foam::sigFpe::oldAction_;
|
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * Local Functions * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Local Functions * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
@ -123,17 +125,11 @@ void Foam::sigFpe::sigHandler(int)
|
|||||||
{
|
{
|
||||||
#if (defined(__linux__) && defined(__GNUC__)) || defined(darwin)
|
#if (defined(__linux__) && defined(__GNUC__)) || defined(darwin)
|
||||||
|
|
||||||
// Reset old handling
|
resetHandler("SIGFPE", SIGFPE);
|
||||||
if (sigaction(SIGFPE, &oldAction_, nullptr) < 0)
|
|
||||||
{
|
|
||||||
FatalErrorInFunction
|
|
||||||
<< "Cannot reset SIGFPE trapping"
|
|
||||||
<< abort(FatalError);
|
|
||||||
}
|
|
||||||
|
|
||||||
jobInfo.signalEnd(); // Update jobInfo file
|
jobInfo.signalEnd(); // Update jobInfo file
|
||||||
error::printStack(Perr);
|
error::printStack(Perr);
|
||||||
raise(SIGFPE); // Throw signal (to old handler)
|
::raise(SIGFPE); // Throw signal (to old handler)
|
||||||
|
|
||||||
#endif // (__linux__ && __GNUC__) || darwin
|
#endif // (__linux__ && __GNUC__) || darwin
|
||||||
}
|
}
|
||||||
@ -203,17 +199,7 @@ void Foam::sigFpe::set(bool verbose)
|
|||||||
| FE_OVERFLOW
|
| FE_OVERFLOW
|
||||||
);
|
);
|
||||||
|
|
||||||
struct sigaction newAction;
|
setHandler("SIGFPE", SIGFPE, sigHandler);
|
||||||
newAction.sa_handler = sigHandler;
|
|
||||||
newAction.sa_flags = SA_NODEFER;
|
|
||||||
sigemptyset(&newAction.sa_mask);
|
|
||||||
|
|
||||||
if (sigaction(SIGFPE, &newAction, &oldAction_) < 0)
|
|
||||||
{
|
|
||||||
FatalErrorInFunction
|
|
||||||
<< "Cannot set SIGFPE trapping"
|
|
||||||
<< abort(FatalError);
|
|
||||||
}
|
|
||||||
|
|
||||||
sigActive_ = true;
|
sigActive_ = true;
|
||||||
|
|
||||||
@ -293,12 +279,7 @@ void Foam::sigFpe::unset(bool verbose)
|
|||||||
<< endl;
|
<< endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sigaction(SIGFPE, &oldAction_, nullptr) < 0)
|
resetHandler("SIGFPE", SIGFPE);
|
||||||
{
|
|
||||||
FatalErrorInFunction
|
|
||||||
<< "Cannot reset SIGFPE trapping"
|
|
||||||
<< abort(FatalError);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Reset exception raising
|
// Reset exception raising
|
||||||
const int oldExcept = fedisableexcept
|
const int oldExcept = fedisableexcept
|
||||||
|
|||||||
@ -2,7 +2,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) 2018 OpenCFD Ltd.
|
\\ / A nd | Copyright (C) 2018-2019 OpenCFD Ltd.
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
| Copyright (C) 2011-2016 OpenFOAM Foundation
|
| Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||||
@ -56,7 +56,6 @@ SourceFiles
|
|||||||
#ifndef sigFpe_H
|
#ifndef sigFpe_H
|
||||||
#define sigFpe_H
|
#define sigFpe_H
|
||||||
|
|
||||||
#include <signal.h>
|
|
||||||
#include "scalar.H"
|
#include "scalar.H"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
@ -64,7 +63,7 @@ SourceFiles
|
|||||||
namespace Foam
|
namespace Foam
|
||||||
{
|
{
|
||||||
|
|
||||||
// Forward declarations
|
// Forward Declarations
|
||||||
template<class T> class UList;
|
template<class T> class UList;
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------*\
|
/*---------------------------------------------------------------------------*\
|
||||||
@ -73,7 +72,7 @@ template<class T> class UList;
|
|||||||
|
|
||||||
class sigFpe
|
class sigFpe
|
||||||
{
|
{
|
||||||
// Private data
|
// Private Data
|
||||||
|
|
||||||
//- Flag that floating point trapping should be used.
|
//- Flag that floating point trapping should be used.
|
||||||
// Can override with FOAM_SIGFPE env variable
|
// Can override with FOAM_SIGFPE env variable
|
||||||
@ -83,20 +82,16 @@ class sigFpe
|
|||||||
// Can override with FOAM_SETNAN env variable
|
// Can override with FOAM_SETNAN env variable
|
||||||
static bool switchNan_;
|
static bool switchNan_;
|
||||||
|
|
||||||
//- Flag to indicate floating point trapping is currently active
|
//- Floating point trapping currently active?
|
||||||
static bool sigActive_;
|
static bool sigActive_;
|
||||||
|
|
||||||
//- Flag to indicate mallocNan is currently active
|
//- Flag to indicate mallocNan is currently active
|
||||||
static bool nanActive_;
|
static bool nanActive_;
|
||||||
|
|
||||||
//- Saved old signal trapping setting
|
|
||||||
static struct sigaction oldAction_;
|
|
||||||
|
|
||||||
|
|
||||||
// Private Member Functions
|
// Private Member Functions
|
||||||
|
|
||||||
//- Handler for caught signals.
|
//- Handler for caught signals - ends job and prints stack
|
||||||
// Ends job and prints stack
|
|
||||||
static void sigHandler(int);
|
static void sigHandler(int);
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd |
|
\\ / A nd | Copyright (C) 2018-2019 OpenCFD Ltd.
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
| Copyright (C) 2011-2015 OpenFOAM Foundation
|
| Copyright (C) 2011-2015 OpenFOAM Foundation
|
||||||
@ -30,9 +30,11 @@ License
|
|||||||
#include "JobInfo.H"
|
#include "JobInfo.H"
|
||||||
#include "IOstreams.H"
|
#include "IOstreams.H"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
// File-local functions
|
||||||
|
#include "signalMacros.C"
|
||||||
|
|
||||||
struct sigaction Foam::sigInt::oldAction_;
|
|
||||||
|
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||||
|
|
||||||
bool Foam::sigInt::sigActive_ = false;
|
bool Foam::sigInt::sigActive_ = false;
|
||||||
|
|
||||||
@ -41,16 +43,10 @@ bool Foam::sigInt::sigActive_ = false;
|
|||||||
|
|
||||||
void Foam::sigInt::sigHandler(int)
|
void Foam::sigInt::sigHandler(int)
|
||||||
{
|
{
|
||||||
// Reset old handling
|
resetHandler("SIGINT", SIGINT);
|
||||||
if (sigaction(SIGINT, &oldAction_, nullptr) < 0)
|
|
||||||
{
|
|
||||||
FatalErrorInFunction
|
|
||||||
<< "Cannot reset SIGINT trapping"
|
|
||||||
<< abort(FatalError);
|
|
||||||
}
|
|
||||||
|
|
||||||
jobInfo.signalEnd(); // Update jobInfo file
|
jobInfo.signalEnd(); // Update jobInfo file
|
||||||
raise(SIGINT); // Throw signal (to old handler)
|
::raise(SIGINT); // Throw signal (to old handler)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -74,35 +70,25 @@ Foam::sigInt::~sigInt()
|
|||||||
|
|
||||||
void Foam::sigInt::set(bool)
|
void Foam::sigInt::set(bool)
|
||||||
{
|
{
|
||||||
if (!sigActive_)
|
if (sigActive_)
|
||||||
{
|
{
|
||||||
struct sigaction newAction;
|
return;
|
||||||
newAction.sa_handler = sigHandler;
|
|
||||||
newAction.sa_flags = SA_NODEFER;
|
|
||||||
sigemptyset(&newAction.sa_mask);
|
|
||||||
if (sigaction(SIGINT, &newAction, &oldAction_) < 0)
|
|
||||||
{
|
|
||||||
FatalErrorInFunction
|
|
||||||
<< "Cannot call sigInt::set() more than once"
|
|
||||||
<< abort(FatalError);
|
|
||||||
}
|
|
||||||
sigActive_ = true;
|
|
||||||
}
|
}
|
||||||
|
sigActive_ = true;
|
||||||
|
|
||||||
|
setHandler("SIGINT", SIGINT, sigHandler);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Foam::sigInt::unset(bool)
|
void Foam::sigInt::unset(bool)
|
||||||
{
|
{
|
||||||
if (sigActive_)
|
if (!sigActive_)
|
||||||
{
|
{
|
||||||
if (sigaction(SIGINT, &oldAction_, nullptr) < 0)
|
return;
|
||||||
{
|
|
||||||
FatalErrorInFunction
|
|
||||||
<< "Cannot set SIGINT trapping"
|
|
||||||
<< abort(FatalError);
|
|
||||||
}
|
|
||||||
sigActive_ = false;
|
|
||||||
}
|
}
|
||||||
|
sigActive_ = false;
|
||||||
|
|
||||||
|
resetHandler("SIGINT", SIGINT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd |
|
\\ / A nd | Copyright (C) 2018-2019 OpenCFD Ltd.
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
| Copyright (C) 2011-2016 OpenFOAM Foundation
|
| Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||||
@ -47,8 +47,6 @@ SourceFiles
|
|||||||
#ifndef sigInt_H
|
#ifndef sigInt_H
|
||||||
#define sigInt_H
|
#define sigInt_H
|
||||||
|
|
||||||
#include <signal.h>
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
namespace Foam
|
namespace Foam
|
||||||
@ -62,10 +60,7 @@ class sigInt
|
|||||||
{
|
{
|
||||||
// Private data
|
// Private data
|
||||||
|
|
||||||
//- Saved old signal trapping setting
|
//- Signal trapping enabled?
|
||||||
static struct sigaction oldAction_;
|
|
||||||
|
|
||||||
//- Flag to indicate signal trapping is enabled
|
|
||||||
static bool sigActive_;
|
static bool sigActive_;
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd |
|
\\ / A nd | Copyright (C) 2017-2019 OpenCFD Ltd.
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
| Copyright (C) 2011-2015 OpenFOAM Foundation
|
| Copyright (C) 2011-2015 OpenFOAM Foundation
|
||||||
@ -30,9 +30,11 @@ License
|
|||||||
#include "JobInfo.H"
|
#include "JobInfo.H"
|
||||||
#include "IOstreams.H"
|
#include "IOstreams.H"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
// File-local functions
|
||||||
|
#include "signalMacros.C"
|
||||||
|
|
||||||
struct sigaction Foam::sigQuit::oldAction_;
|
|
||||||
|
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||||
|
|
||||||
bool Foam::sigQuit::sigActive_ = false;
|
bool Foam::sigQuit::sigActive_ = false;
|
||||||
|
|
||||||
@ -41,17 +43,11 @@ bool Foam::sigQuit::sigActive_ = false;
|
|||||||
|
|
||||||
void Foam::sigQuit::sigHandler(int)
|
void Foam::sigQuit::sigHandler(int)
|
||||||
{
|
{
|
||||||
// Reset old handling
|
resetHandler("SIGQUIT", SIGQUIT);
|
||||||
if (sigaction(SIGQUIT, &oldAction_, nullptr) < 0)
|
|
||||||
{
|
|
||||||
FatalErrorInFunction
|
|
||||||
<< "Cannot reset SIGQUIT trapping"
|
|
||||||
<< abort(FatalError);
|
|
||||||
}
|
|
||||||
|
|
||||||
jobInfo.signalEnd(); // Update jobInfo file
|
jobInfo.signalEnd(); // Update jobInfo file
|
||||||
error::printStack(Perr);
|
error::printStack(Perr);
|
||||||
raise(SIGQUIT); // Throw signal (to old handler)
|
::raise(SIGQUIT); // Throw signal (to old handler)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -75,35 +71,25 @@ Foam::sigQuit::~sigQuit()
|
|||||||
|
|
||||||
void Foam::sigQuit::set(bool)
|
void Foam::sigQuit::set(bool)
|
||||||
{
|
{
|
||||||
if (!sigActive_)
|
if (sigActive_)
|
||||||
{
|
{
|
||||||
struct sigaction newAction;
|
return;
|
||||||
newAction.sa_handler = sigHandler;
|
|
||||||
newAction.sa_flags = SA_NODEFER;
|
|
||||||
sigemptyset(&newAction.sa_mask);
|
|
||||||
if (sigaction(SIGQUIT, &newAction, &oldAction_) < 0)
|
|
||||||
{
|
|
||||||
FatalErrorInFunction
|
|
||||||
<< "Cannot call more than once"
|
|
||||||
<< abort(FatalError);
|
|
||||||
}
|
|
||||||
sigActive_ = true;
|
|
||||||
}
|
}
|
||||||
|
sigActive_ = true;
|
||||||
|
|
||||||
|
setHandler("SIGQUIT", SIGQUIT, sigHandler);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Foam::sigQuit::unset(bool)
|
void Foam::sigQuit::unset(bool)
|
||||||
{
|
{
|
||||||
if (sigActive_)
|
if (!sigActive_)
|
||||||
{
|
{
|
||||||
if (sigaction(SIGQUIT, &oldAction_, nullptr) < 0)
|
return;
|
||||||
{
|
|
||||||
FatalErrorInFunction
|
|
||||||
<< "Cannot unset SIGQUIT trapping"
|
|
||||||
<< abort(FatalError);
|
|
||||||
}
|
|
||||||
sigActive_ = false;
|
|
||||||
}
|
}
|
||||||
|
sigActive_ = false;
|
||||||
|
|
||||||
|
resetHandler("SIGQUIT", SIGQUIT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd |
|
\\ / A nd | Copyright (C) 2017-2019 OpenCFD Ltd.
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
| Copyright (C) 2011-2016 OpenFOAM Foundation
|
| Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||||
@ -46,8 +46,6 @@ SourceFiles
|
|||||||
#ifndef sigQuit_H
|
#ifndef sigQuit_H
|
||||||
#define sigQuit_H
|
#define sigQuit_H
|
||||||
|
|
||||||
#include <signal.h>
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
namespace Foam
|
namespace Foam
|
||||||
@ -59,12 +57,9 @@ namespace Foam
|
|||||||
|
|
||||||
class sigQuit
|
class sigQuit
|
||||||
{
|
{
|
||||||
// Private data
|
// Private Data
|
||||||
|
|
||||||
//- Saved old signal trapping setting
|
//- Signal trapping enabled?
|
||||||
static struct sigaction oldAction_;
|
|
||||||
|
|
||||||
//- Flag to indicate signal trapping is enabled
|
|
||||||
static bool sigActive_;
|
static bool sigActive_;
|
||||||
|
|
||||||
|
|
||||||
@ -86,7 +81,7 @@ public:
|
|||||||
~sigQuit();
|
~sigQuit();
|
||||||
|
|
||||||
|
|
||||||
// Member functions
|
// Member Functions
|
||||||
|
|
||||||
//- Activate SIGQUIT signal handler
|
//- Activate SIGQUIT signal handler
|
||||||
static void set(bool verbose=false);
|
static void set(bool verbose=false);
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd |
|
\\ / A nd | Copyright (C) 2018-2019 OpenCFD Ltd.
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
| Copyright (C) 2011-2015 OpenFOAM Foundation
|
| Copyright (C) 2011-2015 OpenFOAM Foundation
|
||||||
@ -30,9 +30,11 @@ License
|
|||||||
#include "JobInfo.H"
|
#include "JobInfo.H"
|
||||||
#include "IOstreams.H"
|
#include "IOstreams.H"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
// File-local functions
|
||||||
|
#include "signalMacros.C"
|
||||||
|
|
||||||
struct sigaction Foam::sigSegv::oldAction_;
|
|
||||||
|
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||||
|
|
||||||
bool Foam::sigSegv::sigActive_ = false;
|
bool Foam::sigSegv::sigActive_ = false;
|
||||||
|
|
||||||
@ -41,17 +43,11 @@ bool Foam::sigSegv::sigActive_ = false;
|
|||||||
|
|
||||||
void Foam::sigSegv::sigHandler(int)
|
void Foam::sigSegv::sigHandler(int)
|
||||||
{
|
{
|
||||||
// Reset old handling
|
resetHandler("SIGSEGV", SIGSEGV);
|
||||||
if (sigaction(SIGSEGV, &oldAction_, nullptr) < 0)
|
|
||||||
{
|
|
||||||
FatalErrorInFunction
|
|
||||||
<< "Cannot reset SIGSEGV trapping"
|
|
||||||
<< abort(FatalError);
|
|
||||||
}
|
|
||||||
|
|
||||||
jobInfo.signalEnd(); // Update jobInfo file
|
jobInfo.signalEnd(); // Update jobInfo file
|
||||||
error::printStack(Perr);
|
error::printStack(Perr);
|
||||||
raise(SIGSEGV); // Throw signal (to old handler)
|
::raise(SIGSEGV); // Throw signal (to old handler)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -75,35 +71,25 @@ Foam::sigSegv::~sigSegv()
|
|||||||
|
|
||||||
void Foam::sigSegv::set(bool)
|
void Foam::sigSegv::set(bool)
|
||||||
{
|
{
|
||||||
if (!sigActive_)
|
if (sigActive_)
|
||||||
{
|
{
|
||||||
struct sigaction newAction;
|
return;
|
||||||
newAction.sa_handler = sigHandler;
|
|
||||||
newAction.sa_flags = SA_NODEFER;
|
|
||||||
sigemptyset(&newAction.sa_mask);
|
|
||||||
if (sigaction(SIGSEGV, &newAction, &oldAction_) < 0)
|
|
||||||
{
|
|
||||||
FatalErrorInFunction
|
|
||||||
<< "Cannot call more than once"
|
|
||||||
<< abort(FatalError);
|
|
||||||
}
|
|
||||||
sigActive_ = true;
|
|
||||||
}
|
}
|
||||||
|
sigActive_ = true;
|
||||||
|
|
||||||
|
setHandler("SIGSEGV", SIGSEGV, sigHandler);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Foam::sigSegv::unset(bool)
|
void Foam::sigSegv::unset(bool)
|
||||||
{
|
{
|
||||||
if (sigActive_)
|
if (!sigActive_)
|
||||||
{
|
{
|
||||||
if (sigaction(SIGSEGV, &oldAction_, nullptr) < 0)
|
return;
|
||||||
{
|
|
||||||
FatalErrorInFunction
|
|
||||||
<< "Cannot unset SIGSEGV trapping"
|
|
||||||
<< abort(FatalError);
|
|
||||||
}
|
|
||||||
sigActive_ = false;
|
|
||||||
}
|
}
|
||||||
|
sigActive_ = false;
|
||||||
|
|
||||||
|
resetHandler("SIGSEGV", SIGSEGV);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd |
|
\\ / A nd | Copyright (C) 2018-2019 OpenCFD Ltd.
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
| Copyright (C) 2011-2016 OpenFOAM Foundation
|
| Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||||
@ -46,8 +46,6 @@ SourceFiles
|
|||||||
#ifndef sigSegv_H
|
#ifndef sigSegv_H
|
||||||
#define sigSegv_H
|
#define sigSegv_H
|
||||||
|
|
||||||
#include <signal.h>
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
namespace Foam
|
namespace Foam
|
||||||
@ -59,12 +57,9 @@ namespace Foam
|
|||||||
|
|
||||||
class sigSegv
|
class sigSegv
|
||||||
{
|
{
|
||||||
// Private data
|
// Private Data
|
||||||
|
|
||||||
//- Saved old signal trapping setting
|
//- Signal trapping enabled?
|
||||||
static struct sigaction oldAction_;
|
|
||||||
|
|
||||||
//- Flag to indicate signal trapping is enabled
|
|
||||||
static bool sigActive_;
|
static bool sigActive_;
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd |
|
\\ / A nd | Copyright (C) 2016-2019 OpenCFD Ltd.
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
| Copyright (C) 2011-2016 OpenFOAM Foundation
|
| Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||||
@ -25,12 +25,17 @@ License
|
|||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#include "sigWriteNow.H"
|
||||||
#include "sigStopAtWriteNow.H"
|
#include "sigStopAtWriteNow.H"
|
||||||
#include "error.H"
|
#include "error.H"
|
||||||
#include "JobInfo.H"
|
#include "JobInfo.H"
|
||||||
#include "IOstreams.H"
|
#include "IOstreams.H"
|
||||||
#include "Time.H"
|
#include "Time.H"
|
||||||
|
|
||||||
|
// File-local functions
|
||||||
|
#include "signalMacros.C"
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||||
|
|
||||||
// Signal number to catch
|
// Signal number to catch
|
||||||
@ -39,21 +44,19 @@ int Foam::sigStopAtWriteNow::signal_
|
|||||||
Foam::debug::optimisationSwitch("stopAtWriteNowSignal", -1)
|
Foam::debug::optimisationSwitch("stopAtWriteNowSignal", -1)
|
||||||
);
|
);
|
||||||
|
|
||||||
Foam::Time const* Foam::sigStopAtWriteNow::runTimePtr_ = nullptr;
|
// Pointer to Time (file-local variable)
|
||||||
|
static Foam::Time const* runTimePtr_ = nullptr;
|
||||||
|
|
||||||
struct sigaction Foam::sigStopAtWriteNow::oldAction_;
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * Local Classes * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
namespace Foam
|
namespace Foam
|
||||||
{
|
{
|
||||||
// Register re-reader
|
// Register re-reader
|
||||||
class addstopAtWriteNowSignalToOpt
|
struct addstopAtWriteNowSignalToOpt
|
||||||
:
|
:
|
||||||
public ::Foam::simpleRegIOobject
|
public ::Foam::simpleRegIOobject
|
||||||
{
|
{
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
addstopAtWriteNowSignalToOpt(const char* name)
|
addstopAtWriteNowSignalToOpt(const char* name)
|
||||||
:
|
:
|
||||||
::Foam::simpleRegIOobject(Foam::debug::addOptimisationObject, name)
|
::Foam::simpleRegIOobject(Foam::debug::addOptimisationObject, name)
|
||||||
@ -85,15 +88,9 @@ addstopAtWriteNowSignalToOpt addstopAtWriteNowSignalToOpt_
|
|||||||
|
|
||||||
void Foam::sigStopAtWriteNow::sigHandler(int)
|
void Foam::sigStopAtWriteNow::sigHandler(int)
|
||||||
{
|
{
|
||||||
// Reset old handling
|
resetHandler("stopAtWriteNow", signal_);
|
||||||
if (sigaction(signal_, &oldAction_, nullptr) < 0)
|
|
||||||
{
|
|
||||||
FatalErrorInFunction
|
|
||||||
<< "Cannot reset " << signal_ << " trapping"
|
|
||||||
<< abort(FatalError);
|
|
||||||
}
|
|
||||||
|
|
||||||
jobInfo.signalEnd(); // Update jobInfo file
|
jobInfo.signalEnd(); // Update jobInfo file
|
||||||
|
|
||||||
if (runTimePtr_)
|
if (runTimePtr_)
|
||||||
{
|
{
|
||||||
@ -113,7 +110,7 @@ Foam::sigStopAtWriteNow::sigStopAtWriteNow()
|
|||||||
|
|
||||||
Foam::sigStopAtWriteNow::sigStopAtWriteNow(const Time& runTime, bool verbose)
|
Foam::sigStopAtWriteNow::sigStopAtWriteNow(const Time& runTime, bool verbose)
|
||||||
{
|
{
|
||||||
runTimePtr_ = &runTime; // Store runTime
|
runTimePtr_ = &runTime; // Store runTime
|
||||||
set(verbose);
|
set(verbose);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -122,61 +119,55 @@ Foam::sigStopAtWriteNow::sigStopAtWriteNow(const Time& runTime, bool verbose)
|
|||||||
|
|
||||||
Foam::sigStopAtWriteNow::~sigStopAtWriteNow()
|
Foam::sigStopAtWriteNow::~sigStopAtWriteNow()
|
||||||
{
|
{
|
||||||
// Reset old handling
|
if (!active())
|
||||||
if (signal_ > 0)
|
|
||||||
{
|
{
|
||||||
if (sigaction(signal_, &oldAction_, nullptr) < 0)
|
return;
|
||||||
{
|
|
||||||
FatalErrorInFunction
|
|
||||||
<< "Cannot reset " << signal_ << " trapping"
|
|
||||||
<< abort(FatalError);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
resetHandler("stopAtWriteNow", signal_);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
void Foam::sigStopAtWriteNow::set(bool verbose)
|
bool Foam::sigStopAtWriteNow::active()
|
||||||
{
|
|
||||||
if (signal_ > 0)
|
|
||||||
{
|
|
||||||
// Check that the signal is different from the writeNowSignal
|
|
||||||
if (sigWriteNow::signal_ == signal_)
|
|
||||||
{
|
|
||||||
FatalErrorInFunction
|
|
||||||
<< "stopAtWriteNowSignal : " << signal_
|
|
||||||
<< " cannot be the same as the writeNowSignal."
|
|
||||||
<< " Please change this in the etc/controlDict."
|
|
||||||
<< exit(FatalError);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
struct sigaction newAction;
|
|
||||||
newAction.sa_handler = sigHandler;
|
|
||||||
newAction.sa_flags = SA_NODEFER;
|
|
||||||
sigemptyset(&newAction.sa_mask);
|
|
||||||
if (sigaction(signal_, &newAction, &oldAction_) < 0)
|
|
||||||
{
|
|
||||||
FatalErrorInFunction
|
|
||||||
<< "Cannot set " << signal_ << " trapping"
|
|
||||||
<< abort(FatalError);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (verbose)
|
|
||||||
{
|
|
||||||
Info<< "sigStopAtWriteNow :"
|
|
||||||
<< " Enabling writing and stopping upon signal " << signal_
|
|
||||||
<< endl;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool Foam::sigStopAtWriteNow::active() const
|
|
||||||
{
|
{
|
||||||
return signal_ > 0;
|
return signal_ > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int Foam::sigStopAtWriteNow::signalNumber()
|
||||||
|
{
|
||||||
|
return signal_;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Foam::sigStopAtWriteNow::set(bool verbose)
|
||||||
|
{
|
||||||
|
if (!active())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check that the signal is different from the writeNowSignal
|
||||||
|
if (sigWriteNow::signalNumber() == signal_)
|
||||||
|
{
|
||||||
|
FatalErrorInFunction
|
||||||
|
<< "stopAtWriteNowSignal : " << signal_
|
||||||
|
<< " cannot be the same as the writeNowSignal."
|
||||||
|
<< " Please change this in the etc/controlDict."
|
||||||
|
<< exit(FatalError);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (verbose)
|
||||||
|
{
|
||||||
|
Info<< "sigStopAtWriteNow :"
|
||||||
|
<< " Enabling writing and stopping upon signal " << signal_
|
||||||
|
<< endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
setHandler("stopAtWriteNow", signal_, sigHandler);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// ************************************************************************* //
|
// ************************************************************************* //
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd |
|
\\ / A nd | Copyright (C) 2016-2019 OpenCFD Ltd.
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
| Copyright (C) 2011-2016 OpenFOAM Foundation
|
| Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||||
@ -27,10 +27,8 @@ Class
|
|||||||
Foam::sigStopAtWriteNow
|
Foam::sigStopAtWriteNow
|
||||||
|
|
||||||
Description
|
Description
|
||||||
Signal handler for interupt defined by
|
Signal handler to write and stop the job.
|
||||||
OptimisationSwitches::stopAtWriteNowSignal
|
The interrupt is defined by OptimisationSwitches::stopAtWriteNowSignal
|
||||||
|
|
||||||
Write and stop the job.
|
|
||||||
|
|
||||||
SourceFiles
|
SourceFiles
|
||||||
sigStopAtWriteNow.C
|
sigStopAtWriteNow.C
|
||||||
@ -40,32 +38,25 @@ SourceFiles
|
|||||||
#ifndef sigStopAtWriteNow_H
|
#ifndef sigStopAtWriteNow_H
|
||||||
#define sigStopAtWriteNow_H
|
#define sigStopAtWriteNow_H
|
||||||
|
|
||||||
#include <signal.h>
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
namespace Foam
|
namespace Foam
|
||||||
{
|
{
|
||||||
|
|
||||||
|
// Forward Declarations
|
||||||
class Time;
|
class Time;
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------*\
|
/*---------------------------------------------------------------------------*\
|
||||||
Class sigStopAtWriteNow Declaration
|
Class sigStopAtWriteNow Declaration
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
class sigStopAtWriteNow
|
class sigStopAtWriteNow
|
||||||
{
|
{
|
||||||
// Private data
|
// Private Data
|
||||||
|
|
||||||
//- Number of signal to use
|
//- Signal number to use
|
||||||
static int signal_;
|
static int signal_;
|
||||||
|
|
||||||
//- Pointer to Time
|
|
||||||
static Time const* runTimePtr_;
|
|
||||||
|
|
||||||
//- Saved old signal trapping setting
|
|
||||||
static struct sigaction oldAction_;
|
|
||||||
|
|
||||||
|
|
||||||
// Private Member Functions
|
// Private Member Functions
|
||||||
|
|
||||||
@ -92,13 +83,16 @@ public:
|
|||||||
~sigStopAtWriteNow();
|
~sigStopAtWriteNow();
|
||||||
|
|
||||||
|
|
||||||
// Member functions
|
// Member Functions
|
||||||
|
|
||||||
//- (re)set signal catcher
|
|
||||||
static void set(bool verbose=false);
|
|
||||||
|
|
||||||
//- Is active?
|
//- Is active?
|
||||||
bool active() const;
|
static bool active();
|
||||||
|
|
||||||
|
//- Signal number being used
|
||||||
|
static int signalNumber();
|
||||||
|
|
||||||
|
//- Set/reset signal handler
|
||||||
|
static void set(bool verbose=false);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd |
|
\\ / A nd | Copyright (C) 2016-2019 OpenCFD Ltd.
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
| Copyright (C) 2011-2016 OpenFOAM Foundation
|
| Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||||
@ -31,6 +31,10 @@ License
|
|||||||
#include "IOstreams.H"
|
#include "IOstreams.H"
|
||||||
#include "Time.H"
|
#include "Time.H"
|
||||||
|
|
||||||
|
// File-local functions
|
||||||
|
#include "signalMacros.C"
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||||
|
|
||||||
// Signal number to catch
|
// Signal number to catch
|
||||||
@ -39,22 +43,20 @@ int Foam::sigWriteNow::signal_
|
|||||||
Foam::debug::optimisationSwitch("writeNowSignal", -1)
|
Foam::debug::optimisationSwitch("writeNowSignal", -1)
|
||||||
);
|
);
|
||||||
|
|
||||||
Foam::Time* Foam::sigWriteNow::runTimePtr_ = nullptr;
|
// Pointer to Time (file-local variable)
|
||||||
|
static Foam::Time* runTimePtr_ = nullptr;
|
||||||
|
|
||||||
struct sigaction Foam::sigWriteNow::oldAction_;
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * Local Classes * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
namespace Foam
|
namespace Foam
|
||||||
{
|
{
|
||||||
|
|
||||||
// Register re-reader
|
// Register re-reader
|
||||||
class addwriteNowSignalToOpt
|
struct addwriteNowSignalToOpt
|
||||||
:
|
:
|
||||||
public ::Foam::simpleRegIOobject
|
public ::Foam::simpleRegIOobject
|
||||||
{
|
{
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
addwriteNowSignalToOpt(const char* name)
|
addwriteNowSignalToOpt(const char* name)
|
||||||
:
|
:
|
||||||
::Foam::simpleRegIOobject(Foam::debug::addOptimisationObject, name)
|
::Foam::simpleRegIOobject(Foam::debug::addOptimisationObject, name)
|
||||||
@ -100,7 +102,7 @@ Foam::sigWriteNow::sigWriteNow()
|
|||||||
|
|
||||||
Foam::sigWriteNow::sigWriteNow(Time& runTime, bool verbose)
|
Foam::sigWriteNow::sigWriteNow(Time& runTime, bool verbose)
|
||||||
{
|
{
|
||||||
runTimePtr_ = &runTime; // Store runTime
|
runTimePtr_ = &runTime; // Store runTime
|
||||||
set(verbose);
|
set(verbose);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -109,50 +111,44 @@ Foam::sigWriteNow::sigWriteNow(Time& runTime, bool verbose)
|
|||||||
|
|
||||||
Foam::sigWriteNow::~sigWriteNow()
|
Foam::sigWriteNow::~sigWriteNow()
|
||||||
{
|
{
|
||||||
// Reset old handling
|
if (!active())
|
||||||
if (signal_ > 0)
|
|
||||||
{
|
{
|
||||||
if (sigaction(signal_, &oldAction_, nullptr) < 0)
|
return;
|
||||||
{
|
|
||||||
FatalErrorInFunction
|
|
||||||
<< "Cannot reset " << signal_ << " trapping"
|
|
||||||
<< abort(FatalError);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
resetHandler("writeNow", signal_);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
void Foam::sigWriteNow::set(bool verbose)
|
bool Foam::sigWriteNow::active()
|
||||||
{
|
|
||||||
if (signal_ >= 0)
|
|
||||||
{
|
|
||||||
struct sigaction newAction;
|
|
||||||
newAction.sa_handler = sigHandler;
|
|
||||||
newAction.sa_flags = SA_NODEFER;
|
|
||||||
sigemptyset(&newAction.sa_mask);
|
|
||||||
if (sigaction(signal_, &newAction, &oldAction_) < 0)
|
|
||||||
{
|
|
||||||
FatalErrorInFunction
|
|
||||||
<< "Cannot set " << signal_ << " trapping"
|
|
||||||
<< abort(FatalError);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (verbose)
|
|
||||||
{
|
|
||||||
Info<< "sigWriteNow :"
|
|
||||||
<< " Enabling writing upon signal " << signal_
|
|
||||||
<< endl;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool Foam::sigWriteNow::active() const
|
|
||||||
{
|
{
|
||||||
return signal_ > 0;
|
return signal_ > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int Foam::sigWriteNow::signalNumber()
|
||||||
|
{
|
||||||
|
return signal_;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Foam::sigWriteNow::set(bool verbose)
|
||||||
|
{
|
||||||
|
if (!active())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (verbose)
|
||||||
|
{
|
||||||
|
Info<< "sigWriteNow :"
|
||||||
|
<< " Enabling writing upon signal " << signal_ << nl;
|
||||||
|
}
|
||||||
|
|
||||||
|
setHandler("writeNow", signal_, sigHandler);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// ************************************************************************* //
|
// ************************************************************************* //
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd |
|
\\ / A nd | Copyright (C) 2016-2019 OpenCFD Ltd.
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
| Copyright (C) 2011-2016 OpenFOAM Foundation
|
| Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||||
@ -27,9 +27,8 @@ Class
|
|||||||
Foam::sigWriteNow
|
Foam::sigWriteNow
|
||||||
|
|
||||||
Description
|
Description
|
||||||
Signal handler for interupt defined by OptimisationSwitches::writeNowSignal
|
Signal handler to write once and continue.
|
||||||
|
The interrupt is defined by OptimisationSwitches::writeNowSignal
|
||||||
Write once and continue.
|
|
||||||
|
|
||||||
SourceFiles
|
SourceFiles
|
||||||
sigWriteNow.C
|
sigWriteNow.C
|
||||||
@ -39,32 +38,25 @@ SourceFiles
|
|||||||
#ifndef sigWriteNow_H
|
#ifndef sigWriteNow_H
|
||||||
#define sigWriteNow_H
|
#define sigWriteNow_H
|
||||||
|
|
||||||
#include <signal.h>
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
namespace Foam
|
namespace Foam
|
||||||
{
|
{
|
||||||
|
|
||||||
|
// Forward Declarations
|
||||||
class Time;
|
class Time;
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------*\
|
/*---------------------------------------------------------------------------*\
|
||||||
Class sigWriteNow Declaration
|
Class sigWriteNow Declaration
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
class sigWriteNow
|
class sigWriteNow
|
||||||
{
|
{
|
||||||
// Private data
|
// Private Data
|
||||||
|
|
||||||
//- Number of signal to use
|
//- Signal number to use
|
||||||
static int signal_;
|
static int signal_;
|
||||||
|
|
||||||
//- Pointer to Time
|
|
||||||
static Time* runTimePtr_;
|
|
||||||
|
|
||||||
//- Saved old signal trapping setting
|
|
||||||
static struct sigaction oldAction_;
|
|
||||||
|
|
||||||
|
|
||||||
// Private Member Functions
|
// Private Member Functions
|
||||||
|
|
||||||
@ -74,8 +66,6 @@ class sigWriteNow
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
friend class sigStopAtWriteNow;
|
|
||||||
|
|
||||||
//- Allow setter access to signal_
|
//- Allow setter access to signal_
|
||||||
friend class addwriteNowSignalToOpt;
|
friend class addwriteNowSignalToOpt;
|
||||||
|
|
||||||
@ -96,9 +86,12 @@ public:
|
|||||||
// Member Functions
|
// Member Functions
|
||||||
|
|
||||||
//- Is active?
|
//- Is active?
|
||||||
bool active() const;
|
static bool active();
|
||||||
|
|
||||||
//- (re)set signal catcher
|
//- The signal number being used
|
||||||
|
static int signalNumber();
|
||||||
|
|
||||||
|
//- Set/reset signal handler
|
||||||
static void set(bool verbose=false);
|
static void set(bool verbose=false);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|||||||
74
src/OSspecific/POSIX/signals/signalMacros.C
Normal file
74
src/OSspecific/POSIX/signals/signalMacros.C
Normal file
@ -0,0 +1,74 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2019 OpenCFD Ltd.
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||||
|
under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
Description
|
||||||
|
File-local code for setting/resetting signal handlers.
|
||||||
|
|
||||||
|
SourceFiles
|
||||||
|
signalMacros.C
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#include "error.H"
|
||||||
|
#include <csignal>
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * Local Functions * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
|
||||||
|
// Saved old signal trapping setting (file-local variable)
|
||||||
|
static struct sigaction oldAction_;
|
||||||
|
|
||||||
|
|
||||||
|
static void resetHandler(const char *what, int sigNum)
|
||||||
|
{
|
||||||
|
if (sigaction(sigNum, &oldAction_, nullptr) < 0)
|
||||||
|
{
|
||||||
|
FatalError
|
||||||
|
<< "Cannot unset " << what << " signal (" << sigNum
|
||||||
|
<< ") trapping" << endl
|
||||||
|
<< abort(FatalError);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void setHandler(const char *what, int sigNum, void (*handler)(int))
|
||||||
|
{
|
||||||
|
struct sigaction newAction;
|
||||||
|
newAction.sa_handler = handler;
|
||||||
|
newAction.sa_flags = SA_NODEFER;
|
||||||
|
sigemptyset(&newAction.sa_mask);
|
||||||
|
if (sigaction(sigNum, &newAction, &oldAction_) < 0)
|
||||||
|
{
|
||||||
|
FatalError
|
||||||
|
<< "Could not set " << what << " signal (" << sigNum
|
||||||
|
<< ") trapping" << endl
|
||||||
|
<< abort(FatalError);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} // End namespace Foam
|
||||||
|
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
114
src/OSspecific/POSIX/signals/timer.C
Normal file
114
src/OSspecific/POSIX/signals/timer.C
Normal file
@ -0,0 +1,114 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2004-2010, 2019 OpenCFD Ltd.
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
| Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||||
|
under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#include "error.H"
|
||||||
|
#include "timer.H"
|
||||||
|
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
// File-local functions
|
||||||
|
#include "signalMacros.C"
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
defineTypeNameAndDebug(timer, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
jmp_buf Foam::timer::envAlarm;
|
||||||
|
|
||||||
|
unsigned int Foam::timer::oldTimeOut_ = 0;
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||||
|
|
||||||
|
void Foam::timer::sigHandler(int)
|
||||||
|
{
|
||||||
|
DebugInFunction<< "Timed out. Jumping." << endl;
|
||||||
|
|
||||||
|
longjmp(envAlarm, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
Foam::timer::timer(unsigned int seconds)
|
||||||
|
:
|
||||||
|
timeOut_(seconds)
|
||||||
|
{
|
||||||
|
if (!timeOut_)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Singleton since handler is static function
|
||||||
|
if (oldTimeOut_)
|
||||||
|
{
|
||||||
|
FatalErrorInFunction
|
||||||
|
<< "timer already used."
|
||||||
|
<< abort(FatalError);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set alarm signal handler
|
||||||
|
// - do not block any signals while in it
|
||||||
|
// - clear list of signals to mask
|
||||||
|
|
||||||
|
setHandler("SIGALRM", SIGALRM, sigHandler);
|
||||||
|
|
||||||
|
// Set alarm timer
|
||||||
|
oldTimeOut_ = ::alarm(timeOut_);
|
||||||
|
|
||||||
|
DebugInFunction
|
||||||
|
<< "Installing timeout " << int(timeOut_) << " seconds"
|
||||||
|
<< " (overriding old timeout " << int(oldTimeOut_) << ")." << endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
Foam::timer::~timer()
|
||||||
|
{
|
||||||
|
if (!timeOut_)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
DebugInFunction
|
||||||
|
<< "timeOut=" << int(timeOut_)
|
||||||
|
<< " : resetting timeOut to " << int(oldTimeOut_) << endl;
|
||||||
|
|
||||||
|
// Reset alarm timer
|
||||||
|
::alarm(oldTimeOut_);
|
||||||
|
oldTimeOut_ = 0;
|
||||||
|
|
||||||
|
resetHandler("SIGALRM", SIGALRM);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd |
|
\\ / A nd | Copyright (C) 2019 OpenCFD Ltd.
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
| Copyright (C) 2011-2015 OpenFOAM Foundation
|
| Copyright (C) 2011-2015 OpenFOAM Foundation
|
||||||
@ -46,14 +46,15 @@ Description
|
|||||||
Constructor set signal handler on sigalarm and alarm(). Destructor
|
Constructor set signal handler on sigalarm and alarm(). Destructor
|
||||||
clears these.
|
clears these.
|
||||||
|
|
||||||
timedOut is macro because setjmp can't be in member function of timer.
|
|
||||||
?something to do with stack frames.
|
|
||||||
|
|
||||||
Warning
|
Warning
|
||||||
The setjmp restores complete register state so including local vars
|
The setjmp restores complete register state so including local vars
|
||||||
held in regs. So if in blocking part something gets calced in a stack
|
held in regs. So if in blocking part something gets calced in a stack
|
||||||
based variable make sure it is declared 'volatile'.
|
based variable make sure it is declared 'volatile'.
|
||||||
|
|
||||||
|
Note
|
||||||
|
timedOut is macro because setjmp can't be in member function of timer.
|
||||||
|
?something to do with stack frames.
|
||||||
|
|
||||||
SourceFiles
|
SourceFiles
|
||||||
timer.C
|
timer.C
|
||||||
|
|
||||||
@ -63,16 +64,14 @@ SourceFiles
|
|||||||
#define timer_H
|
#define timer_H
|
||||||
|
|
||||||
#include "className.H"
|
#include "className.H"
|
||||||
|
#include <csetjmp>
|
||||||
#include <signal.h>
|
|
||||||
#include <setjmp.h>
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
//- Check it a timeout has occured
|
//- Check if timeout has occurred
|
||||||
// keep setjmp in same stack frame so no function calls
|
// keep setjmp in same stack frame so no function calls
|
||||||
#define timedOut(x) \
|
#define timedOut(x) \
|
||||||
(((x).newTimeOut_ > 0) ? setjmp(Foam::timer::envAlarm) : false)
|
((x).timeOut_ ? setjmp(Foam::timer::envAlarm) : false)
|
||||||
|
|
||||||
namespace Foam
|
namespace Foam
|
||||||
{
|
{
|
||||||
@ -83,10 +82,7 @@ namespace Foam
|
|||||||
|
|
||||||
class timer
|
class timer
|
||||||
{
|
{
|
||||||
// Private data
|
// Private Data
|
||||||
|
|
||||||
//- Old signal masks
|
|
||||||
static struct sigaction oldAction_;
|
|
||||||
|
|
||||||
//- Old alarm() value
|
//- Old alarm() value
|
||||||
static unsigned int oldTimeOut_;
|
static unsigned int oldTimeOut_;
|
||||||
@ -95,18 +91,18 @@ class timer
|
|||||||
// Private Member Functions
|
// Private Member Functions
|
||||||
|
|
||||||
//- Alarm handler
|
//- Alarm handler
|
||||||
static void signalHandler(int);
|
static void sigHandler(int);
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
// Public data
|
// Public Data
|
||||||
|
|
||||||
//- Declare name of the class and its debug switch
|
//- Declare name of the class and its debug switch
|
||||||
ClassName("timer");
|
ClassName("timer");
|
||||||
|
|
||||||
//- Current time out value. Needed by macro timedOut
|
//- The time-out value (seconds). Needed by macro timedOut
|
||||||
unsigned int newTimeOut_;
|
unsigned int timeOut_;
|
||||||
|
|
||||||
//- State for setjmp. Needed by macro timedOut
|
//- State for setjmp. Needed by macro timedOut
|
||||||
static jmp_buf envAlarm;
|
static jmp_buf envAlarm;
|
||||||
@ -114,12 +110,11 @@ public:
|
|||||||
|
|
||||||
// Constructors
|
// Constructors
|
||||||
|
|
||||||
//- Construct from components.
|
//- Construct with specified time-out, a value of 0 makes it a no-op.
|
||||||
// newTimeOut=0 makes it do nothing.
|
explicit timer(unsigned int seconds);
|
||||||
timer(const unsigned int newTimeOut);
|
|
||||||
|
|
||||||
|
|
||||||
//- Destructor
|
//- Destructor. Restores the alarm and signal handler as required.
|
||||||
~timer();
|
~timer();
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -1,133 +0,0 @@
|
|||||||
/*---------------------------------------------------------------------------*\
|
|
||||||
========= |
|
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
|
||||||
\\ / O peration |
|
|
||||||
\\ / A nd |
|
|
||||||
\\/ M anipulation |
|
|
||||||
-------------------------------------------------------------------------------
|
|
||||||
| Copyright (C) 2011-2016 OpenFOAM Foundation
|
|
||||||
-------------------------------------------------------------------------------
|
|
||||||
License
|
|
||||||
This file is part of OpenFOAM.
|
|
||||||
|
|
||||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
|
||||||
under the terms of the GNU General Public License as published by
|
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
|
||||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
||||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
||||||
for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
|
||||||
|
|
||||||
#include <unistd.h>
|
|
||||||
|
|
||||||
#include "error.H"
|
|
||||||
#include "timer.H"
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
namespace Foam
|
|
||||||
{
|
|
||||||
defineTypeNameAndDebug(timer, 0);
|
|
||||||
|
|
||||||
jmp_buf timer::envAlarm;
|
|
||||||
|
|
||||||
struct sigaction timer::oldAction_;
|
|
||||||
|
|
||||||
unsigned int timer::oldTimeOut_ = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
void Foam::timer::signalHandler(int)
|
|
||||||
{
|
|
||||||
if (debug)
|
|
||||||
{
|
|
||||||
InfoInFunction<< "Timed out. Jumping."
|
|
||||||
<< endl;
|
|
||||||
}
|
|
||||||
longjmp(envAlarm, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
Foam::timer::timer(const unsigned int newTimeOut)
|
|
||||||
:
|
|
||||||
newTimeOut_(newTimeOut)
|
|
||||||
{
|
|
||||||
|
|
||||||
if (newTimeOut > 0)
|
|
||||||
{
|
|
||||||
// Is singleton since handler is static function
|
|
||||||
if (oldTimeOut_ != 0)
|
|
||||||
{
|
|
||||||
FatalErrorInFunction
|
|
||||||
<< "timer already used."
|
|
||||||
<< abort(FatalError);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Install alarm signal handler:
|
|
||||||
// - do not block any signals while in it
|
|
||||||
// - clear list of signals to mask
|
|
||||||
struct sigaction newAction;
|
|
||||||
newAction.sa_handler = timer::signalHandler;
|
|
||||||
newAction.sa_flags = SA_NODEFER;
|
|
||||||
sigemptyset(&newAction.sa_mask);
|
|
||||||
|
|
||||||
if (sigaction(SIGALRM, &newAction, &oldAction_) < 0)
|
|
||||||
{
|
|
||||||
FatalErrorInFunction
|
|
||||||
<< "sigaction(SIGALRM) error"
|
|
||||||
<< abort(FatalError);
|
|
||||||
}
|
|
||||||
|
|
||||||
oldTimeOut_ = ::alarm(newTimeOut);
|
|
||||||
|
|
||||||
if (debug)
|
|
||||||
{
|
|
||||||
InfoInFunction
|
|
||||||
<< "Installing timeout " << int(newTimeOut_)
|
|
||||||
<< " seconds"
|
|
||||||
<< " (overriding old timeout " << int(oldTimeOut_)
|
|
||||||
<< ")." << endl;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
Foam::timer::~timer()
|
|
||||||
{
|
|
||||||
if (newTimeOut_ > 0)
|
|
||||||
{
|
|
||||||
if (debug)
|
|
||||||
{
|
|
||||||
InfoInFunction
|
|
||||||
<< "timeOut=" << int(newTimeOut_)
|
|
||||||
<< " : resetting timeOut to " << int(oldTimeOut_) << endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Reset timer
|
|
||||||
::alarm(oldTimeOut_);
|
|
||||||
oldTimeOut_ = 0;
|
|
||||||
|
|
||||||
// Restore signal handler
|
|
||||||
if (sigaction(SIGALRM, &oldAction_, nullptr) < 0)
|
|
||||||
{
|
|
||||||
FatalErrorInFunction
|
|
||||||
<< "sigaction(SIGALRM) error"
|
|
||||||
<< abort(FatalError);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// ************************************************************************* //
|
|
||||||
@ -2,7 +2,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) 2017 OpenCFD Ltd.
|
\\ / A nd | Copyright (C) 2017-2019 OpenCFD Ltd.
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
| Copyright (C) 2011-2016 OpenFOAM Foundation
|
| Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||||
@ -52,7 +52,9 @@ Foam::Detail::IFstreamAllocator::IFstreamAllocator(const fileName& pathname)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
allocatedPtr_ = new std::ifstream(pathname);
|
const std::ios_base::openmode mode(std::ios_base::in|std::ios_base::binary);
|
||||||
|
|
||||||
|
allocatedPtr_ = new std::ifstream(pathname, mode);
|
||||||
|
|
||||||
// If the file is compressed, decompress it before reading.
|
// If the file is compressed, decompress it before reading.
|
||||||
if (!allocatedPtr_->good() && isFile(pathname + ".gz", false))
|
if (!allocatedPtr_->good() && isFile(pathname + ".gz", false))
|
||||||
@ -63,7 +65,7 @@ Foam::Detail::IFstreamAllocator::IFstreamAllocator(const fileName& pathname)
|
|||||||
}
|
}
|
||||||
|
|
||||||
delete allocatedPtr_;
|
delete allocatedPtr_;
|
||||||
allocatedPtr_ = new igzstream((pathname + ".gz").c_str());
|
allocatedPtr_ = new igzstream((pathname + ".gz").c_str(), mode);
|
||||||
|
|
||||||
if (allocatedPtr_->good())
|
if (allocatedPtr_->good())
|
||||||
{
|
{
|
||||||
|
|||||||
@ -2,7 +2,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) 2017-2018 OpenCFD Ltd.
|
\\ / A nd | Copyright (C) 2017-2019 OpenCFD Ltd.
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
| Copyright (C) 2011-2017 OpenFOAM Foundation
|
| Copyright (C) 2011-2017 OpenFOAM Foundation
|
||||||
@ -55,7 +55,7 @@ Foam::Detail::OFstreamAllocator::OFstreamAllocator
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::ios_base::openmode mode(std::ios_base::out);
|
std::ios_base::openmode mode(std::ios_base::out|std::ios_base::binary);
|
||||||
if (append)
|
if (append)
|
||||||
{
|
{
|
||||||
mode |= std::ios_base::app;
|
mode |= std::ios_base::app;
|
||||||
|
|||||||
@ -272,7 +272,7 @@ void Foam::dictionary::checkITstream
|
|||||||
<< " at line " << is.lineNumber() << '.' << nl
|
<< " at line " << is.lineNumber() << '.' << nl
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
|
|
||||||
::exit(1);
|
std::exit(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (!is.size())
|
else if (!is.size())
|
||||||
@ -305,7 +305,7 @@ void Foam::dictionary::checkITstream
|
|||||||
<< " at line " << is.lineNumber() << '.' << nl
|
<< " at line " << is.lineNumber() << '.' << nl
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
|
|
||||||
::exit(1);
|
std::exit(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -116,7 +116,7 @@ void Foam::entry::checkITstream(const ITstream& is) const
|
|||||||
<< " at line " << is.lineNumber() << '.' << nl
|
<< " at line " << is.lineNumber() << '.' << nl
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
|
|
||||||
::exit(1);
|
std::exit(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (!is.size())
|
else if (!is.size())
|
||||||
@ -149,7 +149,7 @@ void Foam::entry::checkITstream(const ITstream& is) const
|
|||||||
<< " at line " << is.lineNumber() << '.' << nl
|
<< " at line " << is.lineNumber() << '.' << nl
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
|
|
||||||
::exit(1);
|
std::exit(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -153,7 +153,7 @@ void Foam::IOerror::SafeFatalIOError
|
|||||||
<< " in file " << sourceFileName
|
<< " in file " << sourceFileName
|
||||||
<< " at line " << sourceFileLineNumber << '.'
|
<< " at line " << sourceFileLineNumber << '.'
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
::exit(1);
|
std::exit(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -210,7 +210,7 @@ void Foam::IOerror::exit(const int)
|
|||||||
{
|
{
|
||||||
Perr<< endl << *this << endl
|
Perr<< endl << *this << endl
|
||||||
<< "\nFOAM exiting\n" << endl;
|
<< "\nFOAM exiting\n" << endl;
|
||||||
::exit(1);
|
std::exit(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -229,7 +229,7 @@ void Foam::IOerror::abort()
|
|||||||
Perr<< endl << *this << endl
|
Perr<< endl << *this << endl
|
||||||
<< "\nFOAM aborting (FOAM_ABORT set)\n" << endl;
|
<< "\nFOAM aborting (FOAM_ABORT set)\n" << endl;
|
||||||
printStack(Perr);
|
printStack(Perr);
|
||||||
::abort();
|
std::abort();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Pstream::parRun())
|
if (Pstream::parRun())
|
||||||
@ -256,7 +256,7 @@ void Foam::IOerror::abort()
|
|||||||
Perr<< endl << *this << endl
|
Perr<< endl << *this << endl
|
||||||
<< "\nFOAM aborting\n" << endl;
|
<< "\nFOAM aborting\n" << endl;
|
||||||
printStack(Perr);
|
printStack(Perr);
|
||||||
::abort();
|
std::abort();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -244,7 +244,7 @@ void Foam::error::exit(const int errNo)
|
|||||||
{
|
{
|
||||||
Perr<< endl << *this << endl
|
Perr<< endl << *this << endl
|
||||||
<< "\nFOAM exiting\n" << endl;
|
<< "\nFOAM exiting\n" << endl;
|
||||||
::exit(errNo);
|
std::exit(errNo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -262,7 +262,7 @@ void Foam::error::abort()
|
|||||||
Perr<< endl << *this << endl
|
Perr<< endl << *this << endl
|
||||||
<< "\nFOAM aborting (FOAM_ABORT set)\n" << endl;
|
<< "\nFOAM aborting (FOAM_ABORT set)\n" << endl;
|
||||||
printStack(Perr);
|
printStack(Perr);
|
||||||
::abort();
|
std::abort();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (throwExceptions_)
|
if (throwExceptions_)
|
||||||
@ -287,7 +287,7 @@ void Foam::error::abort()
|
|||||||
Perr<< endl << *this << endl
|
Perr<< endl << *this << endl
|
||||||
<< "\nFOAM aborting\n" << endl;
|
<< "\nFOAM aborting\n" << endl;
|
||||||
printStack(Perr);
|
printStack(Perr);
|
||||||
::abort();
|
std::abort();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -887,7 +887,7 @@ bool Foam::functionObjectList::read()
|
|||||||
catch (const Foam::IOerror& ioErr)
|
catch (const Foam::IOerror& ioErr)
|
||||||
{
|
{
|
||||||
Info<< ioErr << nl << endl;
|
Info<< ioErr << nl << endl;
|
||||||
::exit(1);
|
std::exit(1);
|
||||||
}
|
}
|
||||||
catch (const Foam::error& err)
|
catch (const Foam::error& err)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -648,7 +648,7 @@ void Foam::argList::setCasePaths()
|
|||||||
|
|
||||||
if (optIter.found())
|
if (optIter.found())
|
||||||
{
|
{
|
||||||
caseDir = optIter.val();
|
caseDir = fileName::validate(optIter.val());
|
||||||
caseDir.clean();
|
caseDir.clean();
|
||||||
|
|
||||||
if (caseDir.empty() || caseDir == ".")
|
if (caseDir.empty() || caseDir == ".")
|
||||||
@ -906,7 +906,7 @@ void Foam::argList::parse
|
|||||||
|
|
||||||
if (quickExit)
|
if (quickExit)
|
||||||
{
|
{
|
||||||
::exit(0);
|
std::exit(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -147,7 +147,7 @@ Foam::dictionary& Foam::debug::switchSet
|
|||||||
<< controlDict().name().c_str()
|
<< controlDict().name().c_str()
|
||||||
<< std::endl << std::endl;
|
<< std::endl << std::endl;
|
||||||
|
|
||||||
::exit(1);
|
std::exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
subDictPtr = &(eptr->dict());
|
subDictPtr = &(eptr->dict());
|
||||||
|
|||||||
@ -82,7 +82,7 @@ static inline void errorMandatoryNotFound
|
|||||||
<< locationToString(location) << ")\n '"
|
<< locationToString(location) << ")\n '"
|
||||||
<< name << "'\n"
|
<< name << "'\n"
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
::exit(1);
|
std::exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -46,7 +46,7 @@ void newError()
|
|||||||
"by e.g. bad use of pointers or an out of date shared library"
|
"by e.g. bad use of pointers or an out of date shared library"
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
|
|
||||||
::abort();
|
std::abort();
|
||||||
}
|
}
|
||||||
|
|
||||||
void (*old_new_handler)() = std::set_new_handler(newError);
|
void (*old_new_handler)() = std::set_new_handler(newError);
|
||||||
|
|||||||
@ -63,7 +63,7 @@ public:
|
|||||||
// Member constants
|
// Member constants
|
||||||
|
|
||||||
//- Rank of Barycentric is 1
|
//- Rank of Barycentric is 1
|
||||||
static const direction rank = 1;
|
static constexpr direction rank = 1;
|
||||||
|
|
||||||
|
|
||||||
//- Component labeling enumeration
|
//- Component labeling enumeration
|
||||||
|
|||||||
@ -67,7 +67,7 @@ public:
|
|||||||
// Member constants
|
// Member constants
|
||||||
|
|
||||||
//- Rank of BarycentricTensor is 2
|
//- Rank of BarycentricTensor is 2
|
||||||
static const direction rank = 2;
|
static constexpr direction rank = 2;
|
||||||
|
|
||||||
|
|
||||||
//- Component labeling enumeration
|
//- Component labeling enumeration
|
||||||
|
|||||||
@ -63,7 +63,7 @@ public:
|
|||||||
// Member constants
|
// Member constants
|
||||||
|
|
||||||
//- Rank of Barycentric2D is 1
|
//- Rank of Barycentric2D is 1
|
||||||
static const direction rank = 1;
|
static constexpr direction rank = 1;
|
||||||
|
|
||||||
|
|
||||||
//- Component labeling enumeration
|
//- Component labeling enumeration
|
||||||
|
|||||||
@ -67,7 +67,7 @@ public:
|
|||||||
// Member constants
|
// Member constants
|
||||||
|
|
||||||
//- Rank of DiagTensor is 2
|
//- Rank of DiagTensor is 2
|
||||||
static const direction rank = 2;
|
static constexpr direction rank = 2;
|
||||||
|
|
||||||
|
|
||||||
//- Component labeling enumeration
|
//- Component labeling enumeration
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd |
|
\\ / A nd | Copyright (C) 2019 OpenCFD Ltd.
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
| Copyright (C) 2016 OpenFOAM Foundation
|
| Copyright (C) 2016 OpenFOAM Foundation
|
||||||
@ -68,20 +68,20 @@ public:
|
|||||||
|
|
||||||
// Member constants
|
// Member constants
|
||||||
|
|
||||||
static const direction mRows = Mrows;
|
static constexpr direction mRows = Mrows;
|
||||||
static const direction nCols = Ncols;
|
static constexpr direction nCols = Ncols;
|
||||||
|
|
||||||
|
|
||||||
// Static member functions
|
// Static member functions
|
||||||
|
|
||||||
//- Return the number of rows
|
//- Return the number of rows
|
||||||
static direction m()
|
static direction m() noexcept
|
||||||
{
|
{
|
||||||
return Mrows;
|
return Mrows;
|
||||||
}
|
}
|
||||||
|
|
||||||
//- Return the number of columns
|
//- Return the number of columns
|
||||||
static direction n()
|
static direction n() noexcept
|
||||||
{
|
{
|
||||||
return Ncols;
|
return Ncols;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -345,7 +345,7 @@ inline const Cmpt& Foam::MatrixSpace<Form, Cmpt, Mrows, Ncols>::operator()
|
|||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
#ifdef FULLDEBUG
|
#ifdef FULLDEBUG
|
||||||
if (i > Mrows-1 || j > Ncols-1)
|
if (i >= Mrows || j >= Ncols)
|
||||||
{
|
{
|
||||||
FatalErrorInFunction
|
FatalErrorInFunction
|
||||||
<< "indices out of range"
|
<< "indices out of range"
|
||||||
@ -365,7 +365,7 @@ inline Cmpt& Foam::MatrixSpace<Form, Cmpt, Mrows, Ncols>::operator()
|
|||||||
)
|
)
|
||||||
{
|
{
|
||||||
#ifdef FULLDEBUG
|
#ifdef FULLDEBUG
|
||||||
if (i > Mrows-1 || j > Ncols-1)
|
if (i >= Mrows || j >= Ncols)
|
||||||
{
|
{
|
||||||
FatalErrorInFunction
|
FatalErrorInFunction
|
||||||
<< "indices out of range"
|
<< "indices out of range"
|
||||||
|
|||||||
@ -59,13 +59,13 @@ public:
|
|||||||
// Member constants
|
// Member constants
|
||||||
|
|
||||||
//- Dimensionality of space
|
//- Dimensionality of space
|
||||||
static const direction dim = 3;
|
static constexpr direction dim = 3;
|
||||||
|
|
||||||
//- Rank of Scalar is 0
|
//- Rank of Scalar is 0
|
||||||
static const direction rank = 0;
|
static constexpr direction rank = 0;
|
||||||
|
|
||||||
//- Number of components in Scalar is 1
|
//- Number of components in Scalar is 1
|
||||||
static const direction nComponents = 1;
|
static constexpr direction nComponents = 1;
|
||||||
|
|
||||||
|
|
||||||
// Static data members
|
// Static data members
|
||||||
|
|||||||
@ -65,7 +65,7 @@ public:
|
|||||||
// Member constants
|
// Member constants
|
||||||
|
|
||||||
//- Rank of SphericalTensor is 2
|
//- Rank of SphericalTensor is 2
|
||||||
static const direction rank = 2;
|
static constexpr direction rank = 2;
|
||||||
|
|
||||||
|
|
||||||
// Static data members
|
// Static data members
|
||||||
|
|||||||
@ -61,7 +61,7 @@ public:
|
|||||||
// Member constants
|
// Member constants
|
||||||
|
|
||||||
//- Rank of SphericalTensor2D is 2
|
//- Rank of SphericalTensor2D is 2
|
||||||
static const direction rank = 2;
|
static constexpr direction rank = 2;
|
||||||
|
|
||||||
|
|
||||||
// Static data members
|
// Static data members
|
||||||
|
|||||||
@ -67,7 +67,7 @@ public:
|
|||||||
// Member constants
|
// Member constants
|
||||||
|
|
||||||
//- Rank of SymmTensor is 2
|
//- Rank of SymmTensor is 2
|
||||||
static const direction rank = 2;
|
static constexpr direction rank = 2;
|
||||||
|
|
||||||
|
|
||||||
// Static data members
|
// Static data members
|
||||||
|
|||||||
@ -67,7 +67,7 @@ public:
|
|||||||
// Member constants
|
// Member constants
|
||||||
|
|
||||||
//- Rank of SymmTensor2D is 2
|
//- Rank of SymmTensor2D is 2
|
||||||
static const direction rank = 2;
|
static constexpr direction rank = 2;
|
||||||
|
|
||||||
|
|
||||||
// Static data members
|
// Static data members
|
||||||
|
|||||||
@ -53,8 +53,9 @@ See also
|
|||||||
namespace Foam
|
namespace Foam
|
||||||
{
|
{
|
||||||
|
|
||||||
template<class Cmpt>
|
// Forward Declarations
|
||||||
class SymmTensor;
|
template<class Cmpt> class SymmTensor;
|
||||||
|
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------*\
|
/*---------------------------------------------------------------------------*\
|
||||||
Class Tensor Declaration
|
Class Tensor Declaration
|
||||||
@ -75,7 +76,7 @@ public:
|
|||||||
// Member constants
|
// Member constants
|
||||||
|
|
||||||
//- Rank of Tensor is 2
|
//- Rank of Tensor is 2
|
||||||
static const direction rank = 2;
|
static constexpr direction rank = 2;
|
||||||
|
|
||||||
|
|
||||||
// Static data members
|
// Static data members
|
||||||
|
|||||||
@ -70,7 +70,7 @@ public:
|
|||||||
// Member constants
|
// Member constants
|
||||||
|
|
||||||
//- Rank of Tensor2D is 2
|
//- Rank of Tensor2D is 2
|
||||||
static const direction rank = 2;
|
static constexpr direction rank = 2;
|
||||||
|
|
||||||
|
|
||||||
// Static data members
|
// Static data members
|
||||||
|
|||||||
@ -72,7 +72,7 @@ public:
|
|||||||
// Member constants
|
// Member constants
|
||||||
|
|
||||||
//- Rank of Vector is 1
|
//- Rank of Vector is 1
|
||||||
static const direction rank = 1;
|
static constexpr direction rank = 1;
|
||||||
|
|
||||||
|
|
||||||
//- Component labeling enumeration
|
//- Component labeling enumeration
|
||||||
|
|||||||
@ -65,7 +65,7 @@ public:
|
|||||||
// Member constants
|
// Member constants
|
||||||
|
|
||||||
//- Rank of Vector2D is 1
|
//- Rank of Vector2D is 1
|
||||||
static const direction rank = 1;
|
static constexpr direction rank = 1;
|
||||||
|
|
||||||
|
|
||||||
//- Component labeling enumeration
|
//- Component labeling enumeration
|
||||||
|
|||||||
@ -38,18 +38,15 @@ Foam::VectorSpace<Form, Cmpt, Ncmpts>::VectorSpace
|
|||||||
Istream& is
|
Istream& is
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
// Read beginning of VectorSpace<Cmpt>
|
is.readBegin("VectorSpace");
|
||||||
is.readBegin("VectorSpace<Form, Cmpt, Ncmpts>");
|
|
||||||
|
|
||||||
for (direction i=0; i<Ncmpts; i++)
|
for (direction i=0; i<Ncmpts; i++)
|
||||||
{
|
{
|
||||||
is >> v_[i];
|
is >> v_[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
// Read end of VectorSpace<Cmpt>
|
is.readEnd("VectorSpace");
|
||||||
is.readEnd("VectorSpace<Form, Cmpt, Ncmpts>");
|
|
||||||
|
|
||||||
// Check state of Istream
|
|
||||||
is.check(FUNCTION_NAME);
|
is.check(FUNCTION_NAME);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -64,7 +61,7 @@ Foam::word Foam::name
|
|||||||
|
|
||||||
buf << '(' << vs.v_[0];
|
buf << '(' << vs.v_[0];
|
||||||
|
|
||||||
for (direction i=1; i<Ncmpts; i++)
|
for (direction i=1; i<Ncmpts; ++i)
|
||||||
{
|
{
|
||||||
buf << ',' << vs.v_[i];
|
buf << ',' << vs.v_[i];
|
||||||
}
|
}
|
||||||
@ -84,18 +81,15 @@ Foam::Istream& Foam::operator>>
|
|||||||
VectorSpace<Form, Cmpt, Ncmpts>& vs
|
VectorSpace<Form, Cmpt, Ncmpts>& vs
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
// Read beginning of VectorSpace<Cmpt, Ncmpts>
|
is.readBegin("VectorSpace");
|
||||||
is.readBegin("VectorSpace<Form, Cmpt, Ncmpts>");
|
|
||||||
|
|
||||||
for (direction i=0; i<Ncmpts; i++)
|
for (direction i=0; i<Ncmpts; i++)
|
||||||
{
|
{
|
||||||
is >> vs.v_[i];
|
is >> vs.v_[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
// Read end of VectorSpace<Cmpt, Ncmpts>
|
is.readEnd("VectorSpace");
|
||||||
is.readEnd("VectorSpace<Form, Cmpt, Ncmpts>");
|
|
||||||
|
|
||||||
// Check state of Istream
|
|
||||||
is.check(FUNCTION_NAME);
|
is.check(FUNCTION_NAME);
|
||||||
|
|
||||||
return is;
|
return is;
|
||||||
@ -111,7 +105,7 @@ Foam::Ostream& Foam::operator<<
|
|||||||
{
|
{
|
||||||
os << token::BEGIN_LIST << vs.v_[0];
|
os << token::BEGIN_LIST << vs.v_[0];
|
||||||
|
|
||||||
for (direction i=1; i<Ncmpts; i++)
|
for (direction i=1; i<Ncmpts; ++i)
|
||||||
{
|
{
|
||||||
os << token::SPACE << vs.v_[i];
|
os << token::SPACE << vs.v_[i];
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd |
|
\\ / A nd | Copyright (C) 2019 OpenCFD Ltd.
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
| Copyright (C) 2011-2016 OpenFOAM Foundation
|
| Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||||
@ -89,23 +89,23 @@ public:
|
|||||||
typedef Cmpt cmptType;
|
typedef Cmpt cmptType;
|
||||||
|
|
||||||
|
|
||||||
// Static constants
|
// Static Constants
|
||||||
|
|
||||||
//- Dimensionality of space
|
//- Dimensionality of space
|
||||||
static const direction dim = 3;
|
static constexpr direction dim = 3;
|
||||||
|
|
||||||
//- Number of components in this vector space
|
//- Number of components in this vector space
|
||||||
static const direction nComponents = Ncmpts;
|
static constexpr direction nComponents = Ncmpts;
|
||||||
|
|
||||||
|
|
||||||
// VectorSpace currently defaults to a column-vector
|
// VectorSpace currently defaults to a column-vector
|
||||||
// This will be removed when column-vector is introduced
|
// This will be removed when column-vector is introduced
|
||||||
// as a specialization
|
// as a specialization
|
||||||
static const direction mRows = Ncmpts;
|
static constexpr direction mRows = Ncmpts;
|
||||||
static const direction nCols = 1;
|
static constexpr direction nCols = 1;
|
||||||
|
|
||||||
|
|
||||||
// Static data members
|
// Static Data Members
|
||||||
|
|
||||||
static const char* const typeName;
|
static const char* const typeName;
|
||||||
static const char* const componentNames[];
|
static const char* const componentNames[];
|
||||||
@ -120,11 +120,7 @@ public:
|
|||||||
// Sub-Block Classes
|
// Sub-Block Classes
|
||||||
|
|
||||||
//- Const sub-block type
|
//- Const sub-block type
|
||||||
template
|
template<class SubVector, direction BStart>
|
||||||
<
|
|
||||||
class SubVector,
|
|
||||||
direction BStart
|
|
||||||
>
|
|
||||||
class ConstBlock
|
class ConstBlock
|
||||||
{
|
{
|
||||||
const vsType& vs_;
|
const vsType& vs_;
|
||||||
@ -158,12 +154,12 @@ public:
|
|||||||
inline VectorSpace(const Foam::zero);
|
inline VectorSpace(const Foam::zero);
|
||||||
|
|
||||||
//- Construct from Istream
|
//- Construct from Istream
|
||||||
VectorSpace(Istream&);
|
VectorSpace(Istream& is);
|
||||||
|
|
||||||
//- Construct as copy
|
//- Copy construct
|
||||||
inline VectorSpace(const VectorSpace<Form, Cmpt, Ncmpts>&);
|
inline VectorSpace(const VectorSpace<Form, Cmpt, Ncmpts>& vs);
|
||||||
|
|
||||||
//- Construct as copy of a VectorSpace with the same size
|
//- Copy construct of a VectorSpace with the same size
|
||||||
template<class Form2, class Cmpt2>
|
template<class Form2, class Cmpt2>
|
||||||
inline explicit VectorSpace(const VectorSpace<Form2, Cmpt2, Ncmpts>&);
|
inline explicit VectorSpace(const VectorSpace<Form2, Cmpt2, Ncmpts>&);
|
||||||
|
|
||||||
@ -171,7 +167,7 @@ public:
|
|||||||
// Member Functions
|
// Member Functions
|
||||||
|
|
||||||
//- Return the number of elements in the VectorSpace = Ncmpts.
|
//- Return the number of elements in the VectorSpace = Ncmpts.
|
||||||
inline static direction size();
|
inline static constexpr direction size();
|
||||||
|
|
||||||
inline const Cmpt& component(const direction) const;
|
inline const Cmpt& component(const direction) const;
|
||||||
inline Cmpt& component(const direction);
|
inline Cmpt& component(const direction);
|
||||||
@ -200,6 +196,39 @@ public:
|
|||||||
inline void operator/=(const scalar);
|
inline void operator/=(const scalar);
|
||||||
|
|
||||||
|
|
||||||
|
// Iterators
|
||||||
|
|
||||||
|
//- Random access iterator for traversing VectorSpace
|
||||||
|
typedef Cmpt* iterator;
|
||||||
|
|
||||||
|
//- Random access iterator for traversing VectorSpace
|
||||||
|
typedef const Cmpt* const_iterator;
|
||||||
|
|
||||||
|
|
||||||
|
// Random access iterator (non-const)
|
||||||
|
|
||||||
|
//- Return an iterator to begin of VectorSpace
|
||||||
|
inline iterator begin();
|
||||||
|
|
||||||
|
//- Return an iterator to end of UListVectorSpace
|
||||||
|
inline iterator end();
|
||||||
|
|
||||||
|
|
||||||
|
// Random access iterator (const)
|
||||||
|
|
||||||
|
//- Return const_iterator to begin of VectorSpace
|
||||||
|
inline const_iterator cbegin() const;
|
||||||
|
|
||||||
|
//- Return const_iterator to end of VectorSpace
|
||||||
|
inline const_iterator cend() const;
|
||||||
|
|
||||||
|
//- Return const_iterator to begin of VectorSpace
|
||||||
|
inline const_iterator begin() const;
|
||||||
|
|
||||||
|
//- Return const_iterator to end of VectorSpace
|
||||||
|
inline const_iterator end() const;
|
||||||
|
|
||||||
|
|
||||||
// IOstream Operators
|
// IOstream Operators
|
||||||
|
|
||||||
friend Istream& operator>> <Form, Cmpt, Ncmpts>
|
friend Istream& operator>> <Form, Cmpt, Ncmpts>
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd |
|
\\ / A nd | Copyright (C) 2019 OpenCFD Ltd.
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
| Copyright (C) 2011-2016 OpenFOAM Foundation
|
| Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||||
@ -31,27 +31,23 @@ License
|
|||||||
#include "ops.H"
|
#include "ops.H"
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
namespace Foam
|
|
||||||
{
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
template<class Form, class Cmpt, direction Ncmpts>
|
template<class Form, class Cmpt, Foam::direction Ncmpts>
|
||||||
inline VectorSpace<Form, Cmpt, Ncmpts>::VectorSpace()
|
inline Foam::VectorSpace<Form, Cmpt, Ncmpts>::VectorSpace()
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
||||||
template<class Form, class Cmpt, direction Ncmpts>
|
template<class Form, class Cmpt, Foam::direction Ncmpts>
|
||||||
inline VectorSpace<Form, Cmpt, Ncmpts>::VectorSpace(const Foam::zero)
|
inline Foam::VectorSpace<Form, Cmpt, Ncmpts>::VectorSpace(const Foam::zero)
|
||||||
{
|
{
|
||||||
VectorSpaceOps<Ncmpts,0>::eqOpS(*this, Zero, eqOp<Cmpt>());
|
VectorSpaceOps<Ncmpts,0>::eqOpS(*this, Zero, eqOp<Cmpt>());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class Form, class Cmpt, direction Ncmpts>
|
template<class Form, class Cmpt, Foam::direction Ncmpts>
|
||||||
inline VectorSpace<Form, Cmpt, Ncmpts>::VectorSpace
|
inline Foam::VectorSpace<Form, Cmpt, Ncmpts>::VectorSpace
|
||||||
(
|
(
|
||||||
const VectorSpace<Form, Cmpt, Ncmpts>& vs
|
const VectorSpace<Form, Cmpt, Ncmpts>& vs
|
||||||
)
|
)
|
||||||
@ -60,9 +56,9 @@ inline VectorSpace<Form, Cmpt, Ncmpts>::VectorSpace
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class Form, class Cmpt, direction Ncmpts>
|
template<class Form, class Cmpt, Foam::direction Ncmpts>
|
||||||
template<class Form2, class Cmpt2>
|
template<class Form2, class Cmpt2>
|
||||||
inline VectorSpace<Form, Cmpt, Ncmpts>::VectorSpace
|
inline Foam::VectorSpace<Form, Cmpt, Ncmpts>::VectorSpace
|
||||||
(
|
(
|
||||||
const VectorSpace<Form2, Cmpt2, Ncmpts>& vs
|
const VectorSpace<Form2, Cmpt2, Ncmpts>& vs
|
||||||
)
|
)
|
||||||
@ -71,10 +67,10 @@ inline VectorSpace<Form, Cmpt, Ncmpts>::VectorSpace
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class Form, class Cmpt, direction Ncmpts>
|
template<class Form, class Cmpt, Foam::direction Ncmpts>
|
||||||
template<class SubVector, direction BStart>
|
template<class SubVector, Foam::direction BStart>
|
||||||
inline
|
inline Foam::VectorSpace<Form, Cmpt, Ncmpts>::ConstBlock<SubVector, BStart>
|
||||||
VectorSpace<Form, Cmpt, Ncmpts>::ConstBlock<SubVector, BStart>::ConstBlock
|
::ConstBlock
|
||||||
(
|
(
|
||||||
const vsType& vs
|
const vsType& vs
|
||||||
)
|
)
|
||||||
@ -91,15 +87,15 @@ VectorSpace<Form, Cmpt, Ncmpts>::ConstBlock<SubVector, BStart>::ConstBlock
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
template<class Form, class Cmpt, direction Ncmpts>
|
template<class Form, class Cmpt, Foam::direction Ncmpts>
|
||||||
inline direction VectorSpace<Form, Cmpt, Ncmpts>::size()
|
inline constexpr Foam::direction Foam::VectorSpace<Form, Cmpt, Ncmpts>::size()
|
||||||
{
|
{
|
||||||
return Ncmpts;
|
return Ncmpts;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class Form, class Cmpt, direction Ncmpts>
|
template<class Form, class Cmpt, Foam::direction Ncmpts>
|
||||||
inline const Cmpt& VectorSpace<Form, Cmpt, Ncmpts>::component
|
inline const Cmpt& Foam::VectorSpace<Form, Cmpt, Ncmpts>::component
|
||||||
(
|
(
|
||||||
const direction d
|
const direction d
|
||||||
) const
|
) const
|
||||||
@ -117,8 +113,8 @@ inline const Cmpt& VectorSpace<Form, Cmpt, Ncmpts>::component
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class Form, class Cmpt, direction Ncmpts>
|
template<class Form, class Cmpt, Foam::direction Ncmpts>
|
||||||
inline Cmpt& VectorSpace<Form, Cmpt, Ncmpts>::component
|
inline Cmpt& Foam::VectorSpace<Form, Cmpt, Ncmpts>::component
|
||||||
(
|
(
|
||||||
const direction d
|
const direction d
|
||||||
)
|
)
|
||||||
@ -136,8 +132,8 @@ inline Cmpt& VectorSpace<Form, Cmpt, Ncmpts>::component
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class Form, class Cmpt, direction Ncmpts>
|
template<class Form, class Cmpt, Foam::direction Ncmpts>
|
||||||
inline void VectorSpace<Form, Cmpt, Ncmpts>::component
|
inline void Foam::VectorSpace<Form, Cmpt, Ncmpts>::component
|
||||||
(
|
(
|
||||||
Cmpt& c,
|
Cmpt& c,
|
||||||
const direction d
|
const direction d
|
||||||
@ -156,8 +152,8 @@ inline void VectorSpace<Form, Cmpt, Ncmpts>::component
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class Form, class Cmpt, direction Ncmpts>
|
template<class Form, class Cmpt, Foam::direction Ncmpts>
|
||||||
inline void VectorSpace<Form, Cmpt, Ncmpts>::replace
|
inline void Foam::VectorSpace<Form, Cmpt, Ncmpts>::replace
|
||||||
(
|
(
|
||||||
const direction d,
|
const direction d,
|
||||||
const Cmpt& c
|
const Cmpt& c
|
||||||
@ -176,8 +172,8 @@ inline void VectorSpace<Form, Cmpt, Ncmpts>::replace
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class Form, class Cmpt, direction Ncmpts>
|
template<class Form, class Cmpt, Foam::direction Ncmpts>
|
||||||
inline Form VectorSpace<Form, Cmpt, Ncmpts>::uniform(const Cmpt& s)
|
inline Form Foam::VectorSpace<Form, Cmpt, Ncmpts>::uniform(const Cmpt& s)
|
||||||
{
|
{
|
||||||
Form v;
|
Form v;
|
||||||
VectorSpaceOps<Ncmpts,0>::eqOpS(v, s, eqOp<Cmpt>());
|
VectorSpaceOps<Ncmpts,0>::eqOpS(v, s, eqOp<Cmpt>());
|
||||||
@ -185,20 +181,64 @@ inline Form VectorSpace<Form, Cmpt, Ncmpts>::uniform(const Cmpt& s)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class Form, class Cmpt, direction Ncmpts>
|
template<class Form, class Cmpt, Foam::direction Ncmpts>
|
||||||
template<class SubVector, direction BStart>
|
template<class SubVector, Foam::direction BStart>
|
||||||
inline const typename VectorSpace<Form, Cmpt, Ncmpts>::template
|
inline const typename Foam::VectorSpace<Form, Cmpt, Ncmpts>::template
|
||||||
ConstBlock<SubVector, BStart>
|
ConstBlock<SubVector, BStart>
|
||||||
VectorSpace<Form, Cmpt, Ncmpts>::block() const
|
Foam::VectorSpace<Form, Cmpt, Ncmpts>::block() const
|
||||||
{
|
{
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * Iterator * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
template<class Form, class Cmpt, Foam::direction Ncmpts>
|
||||||
|
inline Cmpt* Foam::VectorSpace<Form, Cmpt, Ncmpts>::begin()
|
||||||
|
{
|
||||||
|
return v_;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class Form, class Cmpt, Foam::direction Ncmpts>
|
||||||
|
inline Cmpt* Foam::VectorSpace<Form, Cmpt, Ncmpts>::end()
|
||||||
|
{
|
||||||
|
return (v_ + Ncmpts);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class Form, class Cmpt, Foam::direction Ncmpts>
|
||||||
|
inline const Cmpt* Foam::VectorSpace<Form, Cmpt, Ncmpts>::cbegin() const
|
||||||
|
{
|
||||||
|
return v_;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class Form, class Cmpt, Foam::direction Ncmpts>
|
||||||
|
inline const Cmpt* Foam::VectorSpace<Form, Cmpt, Ncmpts>::cend() const
|
||||||
|
{
|
||||||
|
return (v_ + Ncmpts);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class Form, class Cmpt, Foam::direction Ncmpts>
|
||||||
|
inline const Cmpt* Foam::VectorSpace<Form, Cmpt, Ncmpts>::begin() const
|
||||||
|
{
|
||||||
|
return v_;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class Form, class Cmpt, Foam::direction Ncmpts>
|
||||||
|
inline const Cmpt* Foam::VectorSpace<Form, Cmpt, Ncmpts>::end() const
|
||||||
|
{
|
||||||
|
return (v_ + Ncmpts);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
|
||||||
|
|
||||||
template<class Form, class Cmpt, direction Ncmpts>
|
template<class Form, class Cmpt, Foam::direction Ncmpts>
|
||||||
inline const Cmpt& VectorSpace<Form, Cmpt, Ncmpts>::operator[]
|
inline const Cmpt& Foam::VectorSpace<Form, Cmpt, Ncmpts>::operator[]
|
||||||
(
|
(
|
||||||
const direction d
|
const direction d
|
||||||
) const
|
) const
|
||||||
@ -216,8 +256,8 @@ inline const Cmpt& VectorSpace<Form, Cmpt, Ncmpts>::operator[]
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class Form, class Cmpt, direction Ncmpts>
|
template<class Form, class Cmpt, Foam::direction Ncmpts>
|
||||||
inline Cmpt& VectorSpace<Form, Cmpt, Ncmpts>::operator[]
|
inline Cmpt& Foam::VectorSpace<Form, Cmpt, Ncmpts>::operator[]
|
||||||
(
|
(
|
||||||
const direction d
|
const direction d
|
||||||
)
|
)
|
||||||
@ -235,10 +275,10 @@ inline Cmpt& VectorSpace<Form, Cmpt, Ncmpts>::operator[]
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class Form, class Cmpt, direction Ncmpts>
|
template<class Form, class Cmpt, Foam::direction Ncmpts>
|
||||||
template<class SubVector, direction BStart>
|
template<class SubVector, Foam::direction BStart>
|
||||||
inline const Cmpt&
|
inline const Cmpt&
|
||||||
VectorSpace<Form, Cmpt, Ncmpts>::
|
Foam::VectorSpace<Form, Cmpt, Ncmpts>::
|
||||||
ConstBlock<SubVector, BStart>::operator[]
|
ConstBlock<SubVector, BStart>::operator[]
|
||||||
(
|
(
|
||||||
const direction d
|
const direction d
|
||||||
@ -257,10 +297,10 @@ ConstBlock<SubVector, BStart>::operator[]
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class Form, class Cmpt, direction Ncmpts>
|
template<class Form, class Cmpt, Foam::direction Ncmpts>
|
||||||
template<class SubVector, direction BStart>
|
template<class SubVector, Foam::direction BStart>
|
||||||
inline const Cmpt&
|
inline const Cmpt&
|
||||||
VectorSpace<Form, Cmpt, Ncmpts>::
|
Foam::VectorSpace<Form, Cmpt, Ncmpts>::
|
||||||
ConstBlock<SubVector, BStart>::operator()
|
ConstBlock<SubVector, BStart>::operator()
|
||||||
(
|
(
|
||||||
const direction i,
|
const direction i,
|
||||||
@ -275,7 +315,7 @@ ConstBlock<SubVector, BStart>::operator()
|
|||||||
<< abort(FatalError);
|
<< abort(FatalError);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (j != 0)
|
if (j)
|
||||||
{
|
{
|
||||||
FatalErrorInFunction
|
FatalErrorInFunction
|
||||||
<< "index " << j << " != 0"
|
<< "index " << j << " != 0"
|
||||||
@ -287,8 +327,8 @@ ConstBlock<SubVector, BStart>::operator()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class Form, class Cmpt, direction Ncmpts>
|
template<class Form, class Cmpt, Foam::direction Ncmpts>
|
||||||
inline void VectorSpace<Form, Cmpt, Ncmpts>::operator=
|
inline void Foam::VectorSpace<Form, Cmpt, Ncmpts>::operator=
|
||||||
(
|
(
|
||||||
const VectorSpace<Form, Cmpt, Ncmpts>& vs
|
const VectorSpace<Form, Cmpt, Ncmpts>& vs
|
||||||
)
|
)
|
||||||
@ -297,8 +337,8 @@ inline void VectorSpace<Form, Cmpt, Ncmpts>::operator=
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class Form, class Cmpt, direction Ncmpts>
|
template<class Form, class Cmpt, Foam::direction Ncmpts>
|
||||||
inline void VectorSpace<Form, Cmpt, Ncmpts>::operator+=
|
inline void Foam::VectorSpace<Form, Cmpt, Ncmpts>::operator+=
|
||||||
(
|
(
|
||||||
const VectorSpace<Form, Cmpt, Ncmpts>& vs
|
const VectorSpace<Form, Cmpt, Ncmpts>& vs
|
||||||
)
|
)
|
||||||
@ -307,8 +347,8 @@ inline void VectorSpace<Form, Cmpt, Ncmpts>::operator+=
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class Form, class Cmpt, direction Ncmpts>
|
template<class Form, class Cmpt, Foam::direction Ncmpts>
|
||||||
inline void VectorSpace<Form, Cmpt, Ncmpts>::operator-=
|
inline void Foam::VectorSpace<Form, Cmpt, Ncmpts>::operator-=
|
||||||
(
|
(
|
||||||
const VectorSpace<Form, Cmpt, Ncmpts>& vs
|
const VectorSpace<Form, Cmpt, Ncmpts>& vs
|
||||||
)
|
)
|
||||||
@ -317,15 +357,15 @@ inline void VectorSpace<Form, Cmpt, Ncmpts>::operator-=
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class Form, class Cmpt, direction Ncmpts>
|
template<class Form, class Cmpt, Foam::direction Ncmpts>
|
||||||
inline void VectorSpace<Form, Cmpt, Ncmpts>::operator=(const Foam::zero)
|
inline void Foam::VectorSpace<Form, Cmpt, Ncmpts>::operator=(const Foam::zero)
|
||||||
{
|
{
|
||||||
VectorSpaceOps<Ncmpts,0>::eqOpS(*this, 0, eqOp<Cmpt>());
|
VectorSpaceOps<Ncmpts,0>::eqOpS(*this, 0, eqOp<Cmpt>());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class Form, class Cmpt, direction Ncmpts>
|
template<class Form, class Cmpt, Foam::direction Ncmpts>
|
||||||
inline void VectorSpace<Form, Cmpt, Ncmpts>::operator*=
|
inline void Foam::VectorSpace<Form, Cmpt, Ncmpts>::operator*=
|
||||||
(
|
(
|
||||||
const scalar s
|
const scalar s
|
||||||
)
|
)
|
||||||
@ -334,8 +374,8 @@ inline void VectorSpace<Form, Cmpt, Ncmpts>::operator*=
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class Form, class Cmpt, direction Ncmpts>
|
template<class Form, class Cmpt, Foam::direction Ncmpts>
|
||||||
inline void VectorSpace<Form, Cmpt, Ncmpts>::operator/=
|
inline void Foam::VectorSpace<Form, Cmpt, Ncmpts>::operator/=
|
||||||
(
|
(
|
||||||
const scalar s
|
const scalar s
|
||||||
)
|
)
|
||||||
@ -344,6 +384,11 @@ inline void VectorSpace<Form, Cmpt, Ncmpts>::operator/=
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
template<class Form, class Cmpt, direction Ncmpts>
|
template<class Form, class Cmpt, direction Ncmpts>
|
||||||
|
|||||||
@ -77,13 +77,13 @@ public:
|
|||||||
// Member constants
|
// Member constants
|
||||||
|
|
||||||
//- Dimensionality of space
|
//- Dimensionality of space
|
||||||
static const direction dim = 3;
|
static constexpr direction dim = 3;
|
||||||
|
|
||||||
//- Rank of bool is 0
|
//- Rank of bool is 0
|
||||||
static const direction rank = 0;
|
static constexpr direction rank = 0;
|
||||||
|
|
||||||
//- Number of components in bool is 1
|
//- Number of components in bool is 1
|
||||||
static const direction nComponents = 1;
|
static constexpr direction nComponents = 1;
|
||||||
|
|
||||||
|
|
||||||
// Static data members
|
// Static data members
|
||||||
|
|||||||
@ -47,11 +47,19 @@ class Ostream;
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
char readChar(Istream&);
|
//- Read single character
|
||||||
Istream& operator>>(Istream&, char&);
|
char readChar(Istream& is);
|
||||||
Ostream& operator<<(Ostream&, const char);
|
|
||||||
Ostream& operator<<(Ostream&, const char*);
|
|
||||||
|
|
||||||
|
//- Read single character
|
||||||
|
Istream& operator>>(Istream& is, char& c);
|
||||||
|
|
||||||
|
//- Write single character
|
||||||
|
Ostream& operator<<(Ostream& os, const char c);
|
||||||
|
|
||||||
|
//- Write a nul-terminated C-string
|
||||||
|
Ostream& operator<<(Ostream& os, const char* str);
|
||||||
|
|
||||||
|
//- Test for \em horizontal whitespace
|
||||||
inline bool isspace(char c)
|
inline bool isspace(char c)
|
||||||
{
|
{
|
||||||
return
|
return
|
||||||
@ -63,6 +71,7 @@ inline bool isspace(char c)
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
} // End namespace Foam
|
} // End namespace Foam
|
||||||
|
|||||||
@ -32,9 +32,9 @@ License
|
|||||||
|
|
||||||
char Foam::readChar(Istream& is)
|
char Foam::readChar(Istream& is)
|
||||||
{
|
{
|
||||||
char c;
|
char c;
|
||||||
is.read(c);
|
is.read(c);
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -54,9 +54,9 @@ Foam::Ostream& Foam::operator<<(Ostream& os, const char c)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Foam::Ostream& Foam::operator<<(Ostream& os, const char* s)
|
Foam::Ostream& Foam::operator<<(Ostream& os, const char* str)
|
||||||
{
|
{
|
||||||
os.write(s);
|
os.write(str);
|
||||||
os.check(FUNCTION_NAME);
|
os.check(FUNCTION_NAME);
|
||||||
return os;
|
return os;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -35,6 +35,41 @@ const Foam::complex Foam::complex::zero(0, 0);
|
|||||||
const Foam::complex Foam::complex::one(1, 0);
|
const Foam::complex Foam::complex::one(1, 0);
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
const char* const Foam::pTraits<Foam::complex>::typeName = "complex";
|
||||||
|
const char* const Foam::pTraits<Foam::complex>::componentNames[] = {"re", "im"};
|
||||||
|
|
||||||
|
const Foam::complex Foam::pTraits<Foam::complex>::zero(0, 0);
|
||||||
|
const Foam::complex Foam::pTraits<Foam::complex>::one(1, 0);
|
||||||
|
|
||||||
|
const Foam::complex Foam::pTraits<Foam::complex>::min(-VGREAT, -VGREAT);
|
||||||
|
const Foam::complex Foam::pTraits<Foam::complex>::max(VGREAT, VGREAT);
|
||||||
|
|
||||||
|
const Foam::complex Foam::pTraits<Foam::complex>::rootMin
|
||||||
|
(
|
||||||
|
-ROOTVGREAT, -ROOTVGREAT
|
||||||
|
);
|
||||||
|
|
||||||
|
const Foam::complex Foam::pTraits<Foam::complex>::rootMax
|
||||||
|
(
|
||||||
|
ROOTVGREAT, ROOTVGREAT
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
Foam::pTraits<Foam::complex>::pTraits(const complex& val)
|
||||||
|
:
|
||||||
|
p_(val)
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
Foam::pTraits<Foam::complex>::pTraits(Istream& is)
|
||||||
|
{
|
||||||
|
is >> p_;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
Foam::complex::complex(Istream& is)
|
Foam::complex::complex(Istream& is)
|
||||||
|
|||||||
@ -232,6 +232,70 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// Template specialisation for pTraits<complex>
|
||||||
|
template<>
|
||||||
|
class pTraits<complex>
|
||||||
|
{
|
||||||
|
complex p_;
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
//- Component type
|
||||||
|
typedef complex cmptType;
|
||||||
|
|
||||||
|
//- Equivalent type of labels used for valid component indexing
|
||||||
|
typedef label labelType;
|
||||||
|
|
||||||
|
|
||||||
|
// Member constants
|
||||||
|
|
||||||
|
//- Dimensionality of space
|
||||||
|
static constexpr direction dim = 3;
|
||||||
|
|
||||||
|
//- Rank of complex is 0
|
||||||
|
static constexpr direction rank = 0;
|
||||||
|
|
||||||
|
//- Number of components in complex is 2
|
||||||
|
static constexpr direction nComponents = 2;
|
||||||
|
|
||||||
|
|
||||||
|
// Static Data Members
|
||||||
|
|
||||||
|
static const char* const typeName;
|
||||||
|
static const char* const componentNames[];
|
||||||
|
static const complex zero;
|
||||||
|
static const complex one;
|
||||||
|
static const complex max;
|
||||||
|
static const complex min;
|
||||||
|
static const complex rootMax;
|
||||||
|
static const complex rootMin;
|
||||||
|
|
||||||
|
|
||||||
|
// Constructors
|
||||||
|
|
||||||
|
//- Construct from primitive
|
||||||
|
explicit pTraits(const complex& val);
|
||||||
|
|
||||||
|
//- Construct from Istream
|
||||||
|
pTraits(Istream& is);
|
||||||
|
|
||||||
|
|
||||||
|
// Member Functions
|
||||||
|
|
||||||
|
//- Access to the value
|
||||||
|
operator complex() const
|
||||||
|
{
|
||||||
|
return p_;
|
||||||
|
}
|
||||||
|
|
||||||
|
//- Access to the value
|
||||||
|
operator complex&()
|
||||||
|
{
|
||||||
|
return p_;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * Global Operators * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Global Operators * * * * * * * * * * * * * //
|
||||||
|
|
||||||
Istream& operator>>(Istream& is, complex& c);
|
Istream& operator>>(Istream& is, complex& c);
|
||||||
|
|||||||
@ -350,6 +350,7 @@ inline complex operator/(const scalar s, const complex& c)
|
|||||||
return complex(s/c.re, s/c.im);
|
return complex(s/c.re, s/c.im);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
} // End namespace Foam
|
} // End namespace Foam
|
||||||
|
|||||||
@ -142,13 +142,13 @@ public:
|
|||||||
// Member constants
|
// Member constants
|
||||||
|
|
||||||
//- Dimensionality of space
|
//- Dimensionality of space
|
||||||
static const direction dim = 3;
|
static constexpr direction dim = 3;
|
||||||
|
|
||||||
//- Rank of int32_t is 0
|
//- Rank of int32_t is 0
|
||||||
static const direction rank = 0;
|
static constexpr direction rank = 0;
|
||||||
|
|
||||||
//- Number of components in int32_t is 1
|
//- Number of components in int32_t is 1
|
||||||
static const direction nComponents = 1;
|
static constexpr direction nComponents = 1;
|
||||||
|
|
||||||
|
|
||||||
// Static data members
|
// Static data members
|
||||||
|
|||||||
@ -143,13 +143,13 @@ public:
|
|||||||
// Member constants
|
// Member constants
|
||||||
|
|
||||||
//- Dimensionality of space
|
//- Dimensionality of space
|
||||||
static const direction dim = 3;
|
static constexpr direction dim = 3;
|
||||||
|
|
||||||
//- Rank of int64_t is 0
|
//- Rank of int64_t is 0
|
||||||
static const direction rank = 0;
|
static constexpr direction rank = 0;
|
||||||
|
|
||||||
//- Number of components in int64_t is 1
|
//- Number of components in int64_t is 1
|
||||||
static const direction nComponents = 1;
|
static constexpr direction nComponents = 1;
|
||||||
|
|
||||||
|
|
||||||
// Static data members
|
// Static data members
|
||||||
|
|||||||
@ -133,13 +133,13 @@ public:
|
|||||||
// Member constants
|
// Member constants
|
||||||
|
|
||||||
//- Dimensionality of space
|
//- Dimensionality of space
|
||||||
static const direction dim = 3;
|
static constexpr direction dim = 3;
|
||||||
|
|
||||||
//- Rank of uint32_t is 0
|
//- Rank of uint32_t is 0
|
||||||
static const direction rank = 0;
|
static constexpr direction rank = 0;
|
||||||
|
|
||||||
//- Number of components in uint32_t is 1
|
//- Number of components in uint32_t is 1
|
||||||
static const direction nComponents = 1;
|
static constexpr direction nComponents = 1;
|
||||||
|
|
||||||
|
|
||||||
// Static data members
|
// Static data members
|
||||||
|
|||||||
@ -141,13 +141,13 @@ public:
|
|||||||
// Member constants
|
// Member constants
|
||||||
|
|
||||||
//- Dimensionality of space
|
//- Dimensionality of space
|
||||||
static const direction dim = 3;
|
static constexpr direction dim = 3;
|
||||||
|
|
||||||
//- Rank of uint64_t is 0
|
//- Rank of uint64_t is 0
|
||||||
static const direction rank = 0;
|
static constexpr direction rank = 0;
|
||||||
|
|
||||||
//- Number of components in uint64_t is 1
|
//- Number of components in uint64_t is 1
|
||||||
static const direction nComponents = 1;
|
static constexpr direction nComponents = 1;
|
||||||
|
|
||||||
|
|
||||||
// Static data members
|
// Static data members
|
||||||
|
|||||||
@ -110,7 +110,7 @@ public:
|
|||||||
// Member constants
|
// Member constants
|
||||||
|
|
||||||
//- Rank of quaternion is 1
|
//- Rank of quaternion is 1
|
||||||
static const direction rank = 1;
|
static constexpr direction rank = 1;
|
||||||
|
|
||||||
|
|
||||||
// Static data members
|
// Static data members
|
||||||
|
|||||||
@ -74,7 +74,7 @@ public:
|
|||||||
// Member constants
|
// Member constants
|
||||||
|
|
||||||
//- Rank of Tensor is 2
|
//- Rank of Tensor is 2
|
||||||
static const direction rank = 2;
|
static constexpr direction rank = 2;
|
||||||
|
|
||||||
|
|
||||||
// Static data members
|
// Static data members
|
||||||
|
|||||||
@ -2,7 +2,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) 2016-2018 OpenCFD Ltd.
|
\\ / A nd | Copyright (C) 2016-2019 OpenCFD Ltd.
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
| Copyright (C) 2011-2017 OpenFOAM Foundation
|
| Copyright (C) 2011-2017 OpenFOAM Foundation
|
||||||
@ -36,7 +36,11 @@ License
|
|||||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||||
|
|
||||||
const char* const Foam::fileName::typeName = "fileName";
|
const char* const Foam::fileName::typeName = "fileName";
|
||||||
int Foam::fileName::debug(debug::debugSwitch(fileName::typeName, 0));
|
int Foam::fileName::debug(Foam::debug::debugSwitch(fileName::typeName, 0));
|
||||||
|
int Foam::fileName::allowSpaceInFileName
|
||||||
|
(
|
||||||
|
Foam::debug::infoSwitch("allowSpaceInFileName", 0)
|
||||||
|
);
|
||||||
const Foam::fileName Foam::fileName::null;
|
const Foam::fileName Foam::fileName::null;
|
||||||
|
|
||||||
|
|
||||||
@ -48,16 +52,27 @@ Foam::fileName Foam::fileName::validate
|
|||||||
const bool doClean
|
const bool doClean
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
fileName out;
|
// The logic is very similar to stripInvalid,
|
||||||
out.resize(s.size());
|
// but silently removes bad characters
|
||||||
|
|
||||||
|
fileName out;
|
||||||
|
out.resize(s.length());
|
||||||
|
|
||||||
char prev = 0;
|
|
||||||
std::string::size_type len = 0;
|
std::string::size_type len = 0;
|
||||||
|
|
||||||
// Largely as per stripInvalid
|
char prev = 0;
|
||||||
for (auto iter = s.cbegin(); iter != s.cend(); ++iter)
|
for (auto iter = s.cbegin(); iter != s.cend(); ++iter)
|
||||||
{
|
{
|
||||||
const char c = *iter;
|
char c = *iter;
|
||||||
|
|
||||||
|
// Treat raw backslash like a path separator. There is no "normal"
|
||||||
|
// way for these to be there (except for an OS that uses them), but
|
||||||
|
// could also cause issues when writing strings, shell commands etc.
|
||||||
|
|
||||||
|
if (c == '\\')
|
||||||
|
{
|
||||||
|
c = '/';
|
||||||
|
}
|
||||||
|
|
||||||
if (fileName::valid(c))
|
if (fileName::valid(c))
|
||||||
{
|
{
|
||||||
@ -84,6 +99,33 @@ Foam::fileName Foam::fileName::validate
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Foam::fileName Foam::fileName::concat
|
||||||
|
(
|
||||||
|
const std::string& s1,
|
||||||
|
const std::string& s2
|
||||||
|
)
|
||||||
|
{
|
||||||
|
const auto n1 = s1.length();
|
||||||
|
const auto n2 = s2.length();
|
||||||
|
|
||||||
|
fileName out;
|
||||||
|
out.reserve(n1 + n2 + 1);
|
||||||
|
|
||||||
|
out += s1;
|
||||||
|
|
||||||
|
if (n1 && n2 && s1.back() != '/' && s2.front() != '/')
|
||||||
|
{
|
||||||
|
// Add separator
|
||||||
|
out += '/';
|
||||||
|
}
|
||||||
|
|
||||||
|
out += s2;
|
||||||
|
|
||||||
|
// Could also remove trailing '/', if desired.
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
bool Foam::fileName::equals(const std::string& s1, const std::string& s2)
|
bool Foam::fileName::equals(const std::string& s1, const std::string& s2)
|
||||||
{
|
{
|
||||||
// Do not use (s1 == s2) or s1.compare(s2) first since this would
|
// Do not use (s1 == s2) or s1.compare(s2) first since this would
|
||||||
@ -92,8 +134,8 @@ bool Foam::fileName::equals(const std::string& s1, const std::string& s2)
|
|||||||
std::string::size_type i1 = 0;
|
std::string::size_type i1 = 0;
|
||||||
std::string::size_type i2 = 0;
|
std::string::size_type i2 = 0;
|
||||||
|
|
||||||
const auto n1 = s1.size();
|
const auto n1 = s1.length();
|
||||||
const auto n2 = s2.size();
|
const auto n2 = s2.length();
|
||||||
|
|
||||||
//Info<< "compare " << s1 << " == " << s2 << endl;
|
//Info<< "compare " << s1 << " == " << s2 << endl;
|
||||||
while (i1 < n1 && i2 < n2)
|
while (i1 < n1 && i2 < n2)
|
||||||
@ -249,7 +291,7 @@ bool Foam::fileName::clean(std::string& str)
|
|||||||
// Number of output characters
|
// Number of output characters
|
||||||
auto nChar = top+1;
|
auto nChar = top+1;
|
||||||
|
|
||||||
const auto maxLen = str.size();
|
const auto maxLen = str.length();
|
||||||
|
|
||||||
for (auto src = nChar; src < maxLen; /*nil*/)
|
for (auto src = nChar; src < maxLen; /*nil*/)
|
||||||
{
|
{
|
||||||
@ -462,7 +504,7 @@ Foam::fileName& Foam::fileName::operator/=(const string& other)
|
|||||||
s += '/';
|
s += '/';
|
||||||
}
|
}
|
||||||
|
|
||||||
s.append(other);
|
s += other;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (other.size())
|
else if (other.size())
|
||||||
@ -477,32 +519,32 @@ Foam::fileName& Foam::fileName::operator/=(const string& other)
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * * Global Operators * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Global Operators * * * * * * * * * * * * * //
|
||||||
|
|
||||||
Foam::fileName Foam::operator/(const string& a, const string& b)
|
Foam::fileName Foam::operator/(const string& s1, const string& s2)
|
||||||
{
|
{
|
||||||
if (a.size())
|
if (s1.length())
|
||||||
{
|
{
|
||||||
if (b.size())
|
if (s2.length())
|
||||||
{
|
{
|
||||||
// Two non-empty strings: can concatenate
|
// Two non-empty strings: can concatenate
|
||||||
|
|
||||||
if (a.back() == '/' || b.front() == '/')
|
if (s1.back() == '/' || s2.front() == '/')
|
||||||
{
|
{
|
||||||
return fileName(a + b);
|
return fileName(s1 + s2);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return fileName(a + '/' + b);
|
return fileName(s1 + '/' + s2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// The second string was empty
|
// The second string was empty
|
||||||
return a;
|
return s1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (b.size())
|
if (s2.length())
|
||||||
{
|
{
|
||||||
// The first string is empty
|
// The first string is empty
|
||||||
return b;
|
return s2;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Both strings are empty
|
// Both strings are empty
|
||||||
|
|||||||
@ -82,7 +82,7 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
// Static data members
|
// Static Data Members
|
||||||
|
|
||||||
//- The typeName
|
//- The typeName
|
||||||
static const char* const typeName;
|
static const char* const typeName;
|
||||||
@ -90,6 +90,9 @@ public:
|
|||||||
//- Debugging
|
//- Debugging
|
||||||
static int debug;
|
static int debug;
|
||||||
|
|
||||||
|
//- Allow space character in fileName. To be used with caution.
|
||||||
|
static int allowSpaceInFileName;
|
||||||
|
|
||||||
//- An empty fileName
|
//- An empty fileName
|
||||||
static const fileName null;
|
static const fileName null;
|
||||||
|
|
||||||
@ -141,14 +144,16 @@ public:
|
|||||||
//- Is this character valid for a fileName?
|
//- Is this character valid for a fileName?
|
||||||
inline static bool valid(char c);
|
inline static bool valid(char c);
|
||||||
|
|
||||||
//- Construct validated fileName (no invalid characters).
|
//- Construct fileName with no invalid characters, possibly applying
|
||||||
// Optionally perform some additional cleanup such as removing
|
//- other transformations such as changing the path separator,
|
||||||
// duplicate or trailing slashes.
|
//- removing duplicate or trailing slashes, etc.
|
||||||
static fileName validate
|
static fileName validate(const std::string& s, const bool doClean=true);
|
||||||
(
|
|
||||||
const std::string& s,
|
//- Join two strings with '/' as a path separator.
|
||||||
const bool doClean=false
|
// No '/' separator is added if either argument is an empty string or
|
||||||
);
|
// if the arguments already had the path separator at the junction.
|
||||||
|
// Invalid characters are \em not stripped (ie, retained).
|
||||||
|
static fileName concat(const std::string& s1, const std::string& s2);
|
||||||
|
|
||||||
//- This is a specialized (possibly slower) version of compare()
|
//- This is a specialized (possibly slower) version of compare()
|
||||||
//- that ignores duplicate or trailing slashes.
|
//- that ignores duplicate or trailing slashes.
|
||||||
@ -403,7 +408,7 @@ Ostream& operator<<(Ostream& os, const fileName& val);
|
|||||||
|
|
||||||
//- Assemble words and fileNames as pathnames by adding a '/' separator.
|
//- Assemble words and fileNames as pathnames by adding a '/' separator.
|
||||||
// No '/' separator is added if either argument is an empty string.
|
// No '/' separator is added if either argument is an empty string.
|
||||||
fileName operator/(const string& a, const string& b);
|
fileName operator/(const string& s1, const string& s2);
|
||||||
|
|
||||||
|
|
||||||
//- Recursively search the given directory for the file
|
//- Recursively search the given directory for the file
|
||||||
|
|||||||
@ -102,9 +102,9 @@ inline bool Foam::fileName::valid(char c)
|
|||||||
{
|
{
|
||||||
return
|
return
|
||||||
(
|
(
|
||||||
!isspace(c)
|
c != '"' // string quote
|
||||||
&& c != '"' // string quote
|
&& c != '\'' // string quote
|
||||||
&& c != '\'' // string quote
|
&& (!isspace(c) || (allowSpaceInFileName && c == ' '))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -134,7 +134,10 @@ inline void Foam::fileName::stripInvalid()
|
|||||||
|
|
||||||
inline bool Foam::fileName::isAbsolute(const std::string& str)
|
inline bool Foam::fileName::isAbsolute(const std::string& str)
|
||||||
{
|
{
|
||||||
return !str.empty() && str[0] == '/';
|
return
|
||||||
|
(
|
||||||
|
!str.empty() && str[0] == '/'
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -58,14 +58,14 @@ bool Foam::UPstream::init(int& argc, char**& argv, const bool needsThread)
|
|||||||
void Foam::UPstream::exit(int errnum)
|
void Foam::UPstream::exit(int errnum)
|
||||||
{
|
{
|
||||||
// No MPI - just exit
|
// No MPI - just exit
|
||||||
::exit(errnum);
|
std::exit(errnum);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Foam::UPstream::abort()
|
void Foam::UPstream::abort()
|
||||||
{
|
{
|
||||||
// No MPI - just abort
|
// No MPI - just abort
|
||||||
::abort();
|
std::abort();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -213,7 +213,7 @@ void Foam::UPstream::exit(int errnum)
|
|||||||
if (!flag)
|
if (!flag)
|
||||||
{
|
{
|
||||||
// Not initialized - just exit
|
// Not initialized - just exit
|
||||||
::exit(errnum);
|
std::exit(errnum);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -224,7 +224,7 @@ void Foam::UPstream::exit(int errnum)
|
|||||||
WarningInFunction
|
WarningInFunction
|
||||||
<< "MPI was already finalized (perhaps by a connected program)"
|
<< "MPI was already finalized (perhaps by a connected program)"
|
||||||
<< endl;
|
<< endl;
|
||||||
::exit(1);
|
std::exit(1);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -271,7 +271,7 @@ void Foam::UPstream::exit(int errnum)
|
|||||||
if (errnum == 0)
|
if (errnum == 0)
|
||||||
{
|
{
|
||||||
MPI_Finalize();
|
MPI_Finalize();
|
||||||
::exit(errnum);
|
std::exit(errnum);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
@ -118,7 +118,7 @@ bool Foam::ccm::ccmGlobalState::assertNoError
|
|||||||
<< "\n libccmio reports -> " << errorMsg(err) << " <-\n"
|
<< "\n libccmio reports -> " << errorMsg(err) << " <-\n"
|
||||||
<< endl;
|
<< endl;
|
||||||
|
|
||||||
::exit(1);
|
std::exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (err == kCCMIONoErr);
|
return (err == kCCMIONoErr);
|
||||||
|
|||||||
@ -96,7 +96,7 @@ public:
|
|||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//- Destructor
|
//- Destructor
|
||||||
virtual ~gravity() = default;
|
virtual ~gravity() = default;
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd |
|
\\ / A nd | Copyright (C) 2019 OpenCFD Ltd.
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
| Copyright (C) 2011-2016 OpenFOAM Foundation
|
| Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||||
@ -59,19 +59,20 @@ Foam::genericFaPatchField<Type>::genericFaPatchField
|
|||||||
actualTypeName_(dict.get<word>("type")),
|
actualTypeName_(dict.get<word>("type")),
|
||||||
dict_(dict)
|
dict_(dict)
|
||||||
{
|
{
|
||||||
|
const label patchSize = this->size();
|
||||||
|
|
||||||
if (!dict.found("value"))
|
if (!dict.found("value"))
|
||||||
{
|
{
|
||||||
FatalIOErrorInFunction(dict)
|
FatalIOErrorInFunction(dict)
|
||||||
<< "\n Cannot find 'value' entry"
|
<< nl << " Cannot find 'value' entry"
|
||||||
<< " on patch " << this->patch().name()
|
<< " on patch " << this->patch().name()
|
||||||
<< " of field " << this->internalField().name()
|
<< " of field " << this->internalField().name()
|
||||||
<< " in file " << this->internalField().objectPath()
|
<< " in file " << this->internalField().objectPath() << nl
|
||||||
<< nl
|
|
||||||
<< " which is required to set the"
|
<< " which is required to set the"
|
||||||
" values of the generic patch field." << nl
|
" values of the generic patch field." << nl
|
||||||
<< " (Actual type " << actualTypeName_ << ")" << nl
|
<< " (Actual type " << actualTypeName_ << ')' << nl << nl
|
||||||
<< "\n Please add the 'value' entry to the write function "
|
<< " Please add the 'value' entry to the write function"
|
||||||
"of the user-defined boundary-condition\n"
|
" of the user-defined boundary-condition" << nl
|
||||||
<< exit(FatalIOError);
|
<< exit(FatalIOError);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -79,338 +80,329 @@ Foam::genericFaPatchField<Type>::genericFaPatchField
|
|||||||
{
|
{
|
||||||
const keyType& key = dEntry.keyword();
|
const keyType& key = dEntry.keyword();
|
||||||
|
|
||||||
if (key != "type" && key != "value")
|
if
|
||||||
|
(
|
||||||
|
key == "type"
|
||||||
|
|| key == "value"
|
||||||
|
|| !dEntry.isStream() || dEntry.stream().empty()
|
||||||
|
)
|
||||||
{
|
{
|
||||||
if
|
continue;
|
||||||
(
|
}
|
||||||
dEntry.isStream()
|
|
||||||
&& dEntry.stream().size()
|
|
||||||
)
|
ITstream& is = dEntry.stream();
|
||||||
|
|
||||||
|
// Read first token
|
||||||
|
token firstToken(is);
|
||||||
|
|
||||||
|
if
|
||||||
|
(
|
||||||
|
firstToken.isWord()
|
||||||
|
&& firstToken.wordToken() == "nonuniform"
|
||||||
|
)
|
||||||
|
{
|
||||||
|
token fieldToken(is);
|
||||||
|
|
||||||
|
if (!fieldToken.isCompound())
|
||||||
{
|
{
|
||||||
ITstream& is = dEntry.stream();
|
|
||||||
|
|
||||||
// Read first token
|
|
||||||
token firstToken(is);
|
|
||||||
|
|
||||||
if
|
if
|
||||||
(
|
(
|
||||||
firstToken.isWord()
|
fieldToken.isLabel()
|
||||||
&& firstToken.wordToken() == "nonuniform"
|
&& fieldToken.labelToken() == 0
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
token fieldToken(is);
|
scalarFields_.insert(key, autoPtr<scalarField>::New());
|
||||||
|
|
||||||
if (!fieldToken.isCompound())
|
|
||||||
{
|
|
||||||
if
|
|
||||||
(
|
|
||||||
fieldToken.isLabel()
|
|
||||||
&& fieldToken.labelToken() == 0
|
|
||||||
)
|
|
||||||
{
|
|
||||||
scalarFields_.insert
|
|
||||||
(
|
|
||||||
key,
|
|
||||||
autoPtr<scalarField>::New()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
FatalIOErrorInFunction(dict)
|
|
||||||
<< "\n token following 'nonuniform' "
|
|
||||||
"is not a compound"
|
|
||||||
<< "\n on patch " << this->patch().name()
|
|
||||||
<< " of field "
|
|
||||||
<< this->internalField().name()
|
|
||||||
<< " in file "
|
|
||||||
<< this->internalField().objectPath()
|
|
||||||
<< exit(FatalIOError);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if
|
|
||||||
(
|
|
||||||
fieldToken.compoundToken().type()
|
|
||||||
== token::Compound<List<scalar>>::typeName
|
|
||||||
)
|
|
||||||
{
|
|
||||||
auto fPtr = autoPtr<scalarField>::New();
|
|
||||||
|
|
||||||
fPtr->transfer
|
|
||||||
(
|
|
||||||
dynamicCast<token::Compound<List<scalar>>>
|
|
||||||
(
|
|
||||||
fieldToken.transferCompoundToken(is)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
if (fPtr->size() != this->size())
|
|
||||||
{
|
|
||||||
FatalIOErrorInFunction(dict)
|
|
||||||
<< "\n size of field " << key
|
|
||||||
<< " (" << fPtr->size() << ')'
|
|
||||||
<< " is not the same size as the patch ("
|
|
||||||
<< this->size() << ')'
|
|
||||||
<< "\n on patch " << this->patch().name()
|
|
||||||
<< " of field "
|
|
||||||
<< this->internalField().name()
|
|
||||||
<< " in file "
|
|
||||||
<< this->internalField().objectPath()
|
|
||||||
<< exit(FatalIOError);
|
|
||||||
}
|
|
||||||
|
|
||||||
scalarFields_.insert(key, fPtr);
|
|
||||||
}
|
|
||||||
else if
|
|
||||||
(
|
|
||||||
fieldToken.compoundToken().type()
|
|
||||||
== token::Compound<List<vector>>::typeName
|
|
||||||
)
|
|
||||||
{
|
|
||||||
auto fPtr = autoPtr<vectorField>::New();
|
|
||||||
|
|
||||||
fPtr->transfer
|
|
||||||
(
|
|
||||||
dynamicCast<token::Compound<List<vector>>>
|
|
||||||
(
|
|
||||||
fieldToken.transferCompoundToken(is)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
if (fPtr->size() != this->size())
|
|
||||||
{
|
|
||||||
FatalIOErrorInFunction(dict)
|
|
||||||
<< "\n size of field " << key
|
|
||||||
<< " (" << fPtr->size() << ')'
|
|
||||||
<< " is not the same size as the patch ("
|
|
||||||
<< this->size() << ')'
|
|
||||||
<< "\n on patch " << this->patch().name()
|
|
||||||
<< " of field "
|
|
||||||
<< this->internalField().name()
|
|
||||||
<< " in file "
|
|
||||||
<< this->internalField().objectPath()
|
|
||||||
<< exit(FatalIOError);
|
|
||||||
}
|
|
||||||
|
|
||||||
vectorFields_.insert(key, fPtr);
|
|
||||||
}
|
|
||||||
else if
|
|
||||||
(
|
|
||||||
fieldToken.compoundToken().type()
|
|
||||||
== token::Compound<List<sphericalTensor>>::typeName
|
|
||||||
)
|
|
||||||
{
|
|
||||||
auto fPtr = autoPtr<sphericalTensorField>::New();
|
|
||||||
|
|
||||||
fPtr->transfer
|
|
||||||
(
|
|
||||||
dynamicCast
|
|
||||||
<
|
|
||||||
token::Compound<List<sphericalTensor>>
|
|
||||||
>
|
|
||||||
(
|
|
||||||
fieldToken.transferCompoundToken(is)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
if (fPtr->size() != this->size())
|
|
||||||
{
|
|
||||||
FatalIOErrorInFunction(dict)
|
|
||||||
<< "\n size of field " << key
|
|
||||||
<< " (" << fPtr->size() << ')'
|
|
||||||
<< " is not the same size as the patch ("
|
|
||||||
<< this->size() << ')'
|
|
||||||
<< "\n on patch " << this->patch().name()
|
|
||||||
<< " of field "
|
|
||||||
<< this->internalField().name()
|
|
||||||
<< " in file "
|
|
||||||
<< this->internalField().objectPath()
|
|
||||||
<< exit(FatalIOError);
|
|
||||||
}
|
|
||||||
|
|
||||||
sphTensorFields_.insert(key, fPtr);
|
|
||||||
}
|
|
||||||
else if
|
|
||||||
(
|
|
||||||
fieldToken.compoundToken().type()
|
|
||||||
== token::Compound<List<symmTensor>>::typeName
|
|
||||||
)
|
|
||||||
{
|
|
||||||
auto fPtr = autoPtr<symmTensorField>::New();
|
|
||||||
|
|
||||||
fPtr->transfer
|
|
||||||
(
|
|
||||||
dynamicCast
|
|
||||||
<
|
|
||||||
token::Compound<List<symmTensor>>
|
|
||||||
>
|
|
||||||
(
|
|
||||||
fieldToken.transferCompoundToken(is)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
if (fPtr->size() != this->size())
|
|
||||||
{
|
|
||||||
FatalIOErrorInFunction(dict)
|
|
||||||
<< "\n size of field " << key
|
|
||||||
<< " (" << fPtr->size() << ')'
|
|
||||||
<< " is not the same size as the patch ("
|
|
||||||
<< this->size() << ')'
|
|
||||||
<< "\n on patch " << this->patch().name()
|
|
||||||
<< " of field "
|
|
||||||
<< this->internalField().name()
|
|
||||||
<< " in file "
|
|
||||||
<< this->internalField().objectPath()
|
|
||||||
<< exit(FatalIOError);
|
|
||||||
}
|
|
||||||
|
|
||||||
symmTensorFields_.insert(key, fPtr);
|
|
||||||
}
|
|
||||||
else if
|
|
||||||
(
|
|
||||||
fieldToken.compoundToken().type()
|
|
||||||
== token::Compound<List<tensor>>::typeName
|
|
||||||
)
|
|
||||||
{
|
|
||||||
auto fPtr = autoPtr<tensorField>::New();
|
|
||||||
|
|
||||||
fPtr->transfer
|
|
||||||
(
|
|
||||||
dynamicCast<token::Compound<List<tensor>>>
|
|
||||||
(
|
|
||||||
fieldToken.transferCompoundToken(is)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
if (fPtr->size() != this->size())
|
|
||||||
{
|
|
||||||
FatalIOErrorInFunction(dict)
|
|
||||||
<< "\n size of field " << key
|
|
||||||
<< " (" << fPtr->size() << ')'
|
|
||||||
<< " is not the same size as the patch ("
|
|
||||||
<< this->size() << ')'
|
|
||||||
<< "\n on patch " << this->patch().name()
|
|
||||||
<< " of field "
|
|
||||||
<< this->internalField().name()
|
|
||||||
<< " in file "
|
|
||||||
<< this->internalField().objectPath()
|
|
||||||
<< exit(FatalIOError);
|
|
||||||
}
|
|
||||||
|
|
||||||
tensorFields_.insert(key, fPtr);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
FatalIOErrorInFunction(dict)
|
|
||||||
<< "\n compound " << fieldToken.compoundToken()
|
|
||||||
<< " not supported"
|
|
||||||
<< "\n on patch " << this->patch().name()
|
|
||||||
<< " of field "
|
|
||||||
<< this->internalField().name()
|
|
||||||
<< " in file "
|
|
||||||
<< this->internalField().objectPath()
|
|
||||||
<< exit(FatalIOError);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else if
|
else
|
||||||
(
|
|
||||||
firstToken.isWord()
|
|
||||||
&& firstToken.wordToken() == "uniform"
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
token fieldToken(is);
|
FatalIOErrorInFunction(dict)
|
||||||
|
<< "\n token following 'nonuniform' "
|
||||||
|
"is not a compound"
|
||||||
|
<< "\n on patch " << this->patch().name()
|
||||||
|
<< " of field "
|
||||||
|
<< this->internalField().name()
|
||||||
|
<< " in file "
|
||||||
|
<< this->internalField().objectPath() << nl
|
||||||
|
<< exit(FatalIOError);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if
|
||||||
|
(
|
||||||
|
fieldToken.compoundToken().type()
|
||||||
|
== token::Compound<List<scalar>>::typeName
|
||||||
|
)
|
||||||
|
{
|
||||||
|
auto fPtr = autoPtr<scalarField>::New();
|
||||||
|
|
||||||
if (!fieldToken.isPunctuation())
|
fPtr->transfer
|
||||||
{
|
(
|
||||||
scalarFields_.insert
|
dynamicCast<token::Compound<List<scalar>>>
|
||||||
|
(
|
||||||
|
fieldToken.transferCompoundToken(is)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
if (fPtr->size() != patchSize)
|
||||||
|
{
|
||||||
|
FatalIOErrorInFunction(dict)
|
||||||
|
<< "\n size of field " << key
|
||||||
|
<< " (" << fPtr->size() << ')'
|
||||||
|
<< " is not the same size as the patch ("
|
||||||
|
<< patchSize << ')'
|
||||||
|
<< "\n on patch " << this->patch().name()
|
||||||
|
<< " of field "
|
||||||
|
<< this->internalField().name()
|
||||||
|
<< " in file "
|
||||||
|
<< this->internalField().objectPath() << nl
|
||||||
|
<< exit(FatalIOError);
|
||||||
|
}
|
||||||
|
|
||||||
|
scalarFields_.insert(key, fPtr);
|
||||||
|
}
|
||||||
|
else if
|
||||||
|
(
|
||||||
|
fieldToken.compoundToken().type()
|
||||||
|
== token::Compound<List<vector>>::typeName
|
||||||
|
)
|
||||||
|
{
|
||||||
|
auto fPtr = autoPtr<vectorField>::New();
|
||||||
|
|
||||||
|
fPtr->transfer
|
||||||
|
(
|
||||||
|
dynamicCast<token::Compound<List<vector>>>
|
||||||
|
(
|
||||||
|
fieldToken.transferCompoundToken(is)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
if (fPtr->size() != patchSize)
|
||||||
|
{
|
||||||
|
FatalIOErrorInFunction(dict)
|
||||||
|
<< "\n size of field " << key
|
||||||
|
<< " (" << fPtr->size() << ')'
|
||||||
|
<< " is not the same size as the patch ("
|
||||||
|
<< patchSize << ')'
|
||||||
|
<< "\n on patch " << this->patch().name()
|
||||||
|
<< " of field "
|
||||||
|
<< this->internalField().name()
|
||||||
|
<< " in file "
|
||||||
|
<< this->internalField().objectPath() << nl
|
||||||
|
<< exit(FatalIOError);
|
||||||
|
}
|
||||||
|
|
||||||
|
vectorFields_.insert(key, fPtr);
|
||||||
|
}
|
||||||
|
else if
|
||||||
|
(
|
||||||
|
fieldToken.compoundToken().type()
|
||||||
|
== token::Compound<List<sphericalTensor>>::typeName
|
||||||
|
)
|
||||||
|
{
|
||||||
|
auto fPtr = autoPtr<sphericalTensorField>::New();
|
||||||
|
|
||||||
|
fPtr->transfer
|
||||||
|
(
|
||||||
|
dynamicCast<token::Compound<List<sphericalTensor>>>
|
||||||
|
(
|
||||||
|
fieldToken.transferCompoundToken(is)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
if (fPtr->size() != patchSize)
|
||||||
|
{
|
||||||
|
FatalIOErrorInFunction(dict)
|
||||||
|
<< "\n size of field " << key
|
||||||
|
<< " (" << fPtr->size() << ')'
|
||||||
|
<< " is not the same size as the patch ("
|
||||||
|
<< patchSize << ')'
|
||||||
|
<< "\n on patch " << this->patch().name()
|
||||||
|
<< " of field "
|
||||||
|
<< this->internalField().name()
|
||||||
|
<< " in file "
|
||||||
|
<< this->internalField().objectPath() << nl
|
||||||
|
<< exit(FatalIOError);
|
||||||
|
}
|
||||||
|
|
||||||
|
sphTensorFields_.insert(key, fPtr);
|
||||||
|
}
|
||||||
|
else if
|
||||||
|
(
|
||||||
|
fieldToken.compoundToken().type()
|
||||||
|
== token::Compound<List<symmTensor>>::typeName
|
||||||
|
)
|
||||||
|
{
|
||||||
|
auto fPtr = autoPtr<symmTensorField>::New();
|
||||||
|
|
||||||
|
fPtr->transfer
|
||||||
|
(
|
||||||
|
dynamicCast<token::Compound<List<symmTensor>>>
|
||||||
|
(
|
||||||
|
fieldToken.transferCompoundToken(is)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
if (fPtr->size() != patchSize)
|
||||||
|
{
|
||||||
|
FatalIOErrorInFunction(dict)
|
||||||
|
<< "\n size of field " << key
|
||||||
|
<< " (" << fPtr->size() << ')'
|
||||||
|
<< " is not the same size as the patch ("
|
||||||
|
<< patchSize << ')'
|
||||||
|
<< "\n on patch " << this->patch().name()
|
||||||
|
<< " of field "
|
||||||
|
<< this->internalField().name()
|
||||||
|
<< " in file "
|
||||||
|
<< this->internalField().objectPath() << nl
|
||||||
|
<< exit(FatalIOError);
|
||||||
|
}
|
||||||
|
|
||||||
|
symmTensorFields_.insert(key, fPtr);
|
||||||
|
}
|
||||||
|
else if
|
||||||
|
(
|
||||||
|
fieldToken.compoundToken().type()
|
||||||
|
== token::Compound<List<tensor>>::typeName
|
||||||
|
)
|
||||||
|
{
|
||||||
|
auto fPtr = autoPtr<tensorField>::New();
|
||||||
|
|
||||||
|
fPtr->transfer
|
||||||
|
(
|
||||||
|
dynamicCast<token::Compound<List<tensor>>>
|
||||||
|
(
|
||||||
|
fieldToken.transferCompoundToken(is)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
if (fPtr->size() != patchSize)
|
||||||
|
{
|
||||||
|
FatalIOErrorInFunction(dict)
|
||||||
|
<< "\n size of field " << key
|
||||||
|
<< " (" << fPtr->size() << ')'
|
||||||
|
<< " is not the same size as the patch ("
|
||||||
|
<< patchSize << ')'
|
||||||
|
<< "\n on patch " << this->patch().name()
|
||||||
|
<< " of field "
|
||||||
|
<< this->internalField().name()
|
||||||
|
<< " in file "
|
||||||
|
<< this->internalField().objectPath() << nl
|
||||||
|
<< exit(FatalIOError);
|
||||||
|
}
|
||||||
|
|
||||||
|
tensorFields_.insert(key, fPtr);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
FatalIOErrorInFunction(dict)
|
||||||
|
<< "\n compound " << fieldToken.compoundToken()
|
||||||
|
<< " not supported"
|
||||||
|
<< "\n on patch " << this->patch().name()
|
||||||
|
<< " of field "
|
||||||
|
<< this->internalField().name()
|
||||||
|
<< " in file "
|
||||||
|
<< this->internalField().objectPath() << nl
|
||||||
|
<< exit(FatalIOError);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if
|
||||||
|
(
|
||||||
|
firstToken.isWord()
|
||||||
|
&& firstToken.wordToken() == "uniform"
|
||||||
|
)
|
||||||
|
{
|
||||||
|
token fieldToken(is);
|
||||||
|
|
||||||
|
if (!fieldToken.isPunctuation())
|
||||||
|
{
|
||||||
|
scalarFields_.insert
|
||||||
|
(
|
||||||
|
key,
|
||||||
|
autoPtr<scalarField>::New
|
||||||
|
(
|
||||||
|
patchSize,
|
||||||
|
fieldToken.number()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Read as scalarList.
|
||||||
|
is.putBack(fieldToken);
|
||||||
|
|
||||||
|
scalarList l(is);
|
||||||
|
|
||||||
|
if (l.size() == vector::nComponents)
|
||||||
|
{
|
||||||
|
vector vs(l[0], l[1], l[2]);
|
||||||
|
|
||||||
|
vectorFields_.insert
|
||||||
|
(
|
||||||
|
key,
|
||||||
|
autoPtr<vectorField>::New
|
||||||
(
|
(
|
||||||
key,
|
patchSize,
|
||||||
autoPtr<scalarField>::New
|
vs
|
||||||
(
|
)
|
||||||
this->size(),
|
);
|
||||||
fieldToken.number()
|
}
|
||||||
)
|
else if (l.size() == sphericalTensor::nComponents)
|
||||||
);
|
{
|
||||||
}
|
sphericalTensor vs(l[0]);
|
||||||
else
|
|
||||||
{
|
|
||||||
// Read as scalarList.
|
|
||||||
is.putBack(fieldToken);
|
|
||||||
|
|
||||||
scalarList l(is);
|
sphTensorFields_.insert
|
||||||
|
(
|
||||||
|
key,
|
||||||
|
autoPtr<sphericalTensorField>::New
|
||||||
|
(
|
||||||
|
patchSize,
|
||||||
|
vs
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
else if (l.size() == symmTensor::nComponents)
|
||||||
|
{
|
||||||
|
symmTensor vs(l[0], l[1], l[2], l[3], l[4], l[5]);
|
||||||
|
|
||||||
if (l.size() == vector::nComponents)
|
symmTensorFields_.insert
|
||||||
{
|
(
|
||||||
vector vs(l[0], l[1], l[2]);
|
key,
|
||||||
|
autoPtr<symmTensorField>::New
|
||||||
|
(
|
||||||
|
patchSize,
|
||||||
|
vs
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
else if (l.size() == tensor::nComponents)
|
||||||
|
{
|
||||||
|
tensor vs
|
||||||
|
(
|
||||||
|
l[0], l[1], l[2],
|
||||||
|
l[3], l[4], l[5],
|
||||||
|
l[6], l[7], l[8]
|
||||||
|
);
|
||||||
|
|
||||||
vectorFields_.insert
|
tensorFields_.insert
|
||||||
(
|
(
|
||||||
key,
|
key,
|
||||||
autoPtr<vectorField>::New
|
autoPtr<tensorField>::New
|
||||||
(
|
(
|
||||||
this->size(),
|
patchSize,
|
||||||
vs
|
vs
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
else if (l.size() == sphericalTensor::nComponents)
|
else
|
||||||
{
|
{
|
||||||
sphericalTensor vs(l[0]);
|
FatalIOErrorInFunction(dict)
|
||||||
|
<< "\n unrecognised native type " << l
|
||||||
sphTensorFields_.insert
|
<< "\n on patch " << this->patch().name()
|
||||||
(
|
<< " of field "
|
||||||
key,
|
<< this->internalField().name()
|
||||||
autoPtr<sphericalTensorField>::New
|
<< " in file "
|
||||||
(
|
<< this->internalField().objectPath() << nl
|
||||||
this->size(),
|
<< exit(FatalIOError);
|
||||||
vs
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
else if (l.size() == symmTensor::nComponents)
|
|
||||||
{
|
|
||||||
symmTensor vs(l[0], l[1], l[2], l[3], l[4], l[5]);
|
|
||||||
|
|
||||||
symmTensorFields_.insert
|
|
||||||
(
|
|
||||||
key,
|
|
||||||
autoPtr<symmTensorField>::New
|
|
||||||
(
|
|
||||||
this->size(),
|
|
||||||
vs
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
else if (l.size() == tensor::nComponents)
|
|
||||||
{
|
|
||||||
tensor vs
|
|
||||||
(
|
|
||||||
l[0], l[1], l[2],
|
|
||||||
l[3], l[4], l[5],
|
|
||||||
l[6], l[7], l[8]
|
|
||||||
);
|
|
||||||
|
|
||||||
tensorFields_.insert
|
|
||||||
(
|
|
||||||
key,
|
|
||||||
autoPtr<tensorField>::New
|
|
||||||
(
|
|
||||||
this->size(),
|
|
||||||
vs
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
FatalIOErrorInFunction(dict)
|
|
||||||
<< "\n unrecognised native type " << l
|
|
||||||
<< "\n on patch " << this->patch().name()
|
|
||||||
<< " of field "
|
|
||||||
<< this->internalField().name()
|
|
||||||
<< " in file "
|
|
||||||
<< this->internalField().objectPath()
|
|
||||||
<< exit(FatalIOError);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -707,46 +699,42 @@ void Foam::genericFaPatchField<Type>::write(Ostream& os) const
|
|||||||
{
|
{
|
||||||
const keyType& key = dEntry.keyword();
|
const keyType& key = dEntry.keyword();
|
||||||
|
|
||||||
if (key != "type" && key != "value")
|
if (key == "type" || key == "value")
|
||||||
{
|
{
|
||||||
if
|
continue;
|
||||||
(
|
}
|
||||||
dEntry.isStream()
|
else if
|
||||||
&& dEntry.stream().size()
|
(
|
||||||
&& dEntry.stream()[0].isWord()
|
dEntry.isStream()
|
||||||
&& dEntry.stream()[0].wordToken() == "nonuniform"
|
&& dEntry.stream().size()
|
||||||
)
|
&& dEntry.stream()[0].isWord()
|
||||||
|
&& dEntry.stream()[0].wordToken() == "nonuniform"
|
||||||
|
)
|
||||||
|
{
|
||||||
|
if (scalarFields_.found(key))
|
||||||
{
|
{
|
||||||
if (scalarFields_.found(key))
|
scalarFields_.cfind(key)()->writeEntry(key, os);
|
||||||
{
|
|
||||||
scalarFields_.find(key)()
|
|
||||||
->writeEntry(key, os);
|
|
||||||
}
|
|
||||||
else if (vectorFields_.found(key))
|
|
||||||
{
|
|
||||||
vectorFields_.find(key)()
|
|
||||||
->writeEntry(key, os);
|
|
||||||
}
|
|
||||||
else if (sphTensorFields_.found(key))
|
|
||||||
{
|
|
||||||
sphTensorFields_.find(key)()
|
|
||||||
->writeEntry(key, os);
|
|
||||||
}
|
|
||||||
else if (symmTensorFields_.found(key))
|
|
||||||
{
|
|
||||||
symmTensorFields_.find(key)()
|
|
||||||
->writeEntry(key, os);
|
|
||||||
}
|
|
||||||
else if (tensorFields_.found(key))
|
|
||||||
{
|
|
||||||
tensorFields_.find(key)()
|
|
||||||
->writeEntry(key, os);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else if (vectorFields_.found(key))
|
||||||
{
|
{
|
||||||
dEntry.write(os);
|
vectorFields_.cfind(key)()->writeEntry(key, os);
|
||||||
}
|
}
|
||||||
|
else if (sphTensorFields_.found(key))
|
||||||
|
{
|
||||||
|
sphTensorFields_.cfind(key)()->writeEntry(key, os);
|
||||||
|
}
|
||||||
|
else if (symmTensorFields_.found(key))
|
||||||
|
{
|
||||||
|
symmTensorFields_.cfind(key)()->writeEntry(key, os);
|
||||||
|
}
|
||||||
|
else if (tensorFields_.found(key))
|
||||||
|
{
|
||||||
|
tensorFields_.cfind(key)()->writeEntry(key, os);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
dEntry.write(os);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd |
|
\\ / A nd | Copyright (C) 2019 OpenCFD Ltd.
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
| Copyright (C) 2011-2016 OpenFOAM Foundation
|
| Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||||
@ -56,22 +56,23 @@ Foam::genericFvPatchField<Type>::genericFvPatchField
|
|||||||
)
|
)
|
||||||
:
|
:
|
||||||
calculatedFvPatchField<Type>(p, iF, dict),
|
calculatedFvPatchField<Type>(p, iF, dict),
|
||||||
actualTypeName_(dict.lookup("type")),
|
actualTypeName_(dict.get<word>("type")),
|
||||||
dict_(dict)
|
dict_(dict)
|
||||||
{
|
{
|
||||||
|
const label patchSize = this->size();
|
||||||
|
|
||||||
if (!dict.found("value"))
|
if (!dict.found("value"))
|
||||||
{
|
{
|
||||||
FatalIOErrorInFunction(dict)
|
FatalIOErrorInFunction(dict)
|
||||||
<< "\n Cannot find 'value' entry"
|
<< nl << " Cannot find 'value' entry"
|
||||||
<< " on patch " << this->patch().name()
|
<< " on patch " << this->patch().name()
|
||||||
<< " of field " << this->internalField().name()
|
<< " of field " << this->internalField().name()
|
||||||
<< " in file " << this->internalField().objectPath()
|
<< " in file " << this->internalField().objectPath() << nl
|
||||||
<< nl
|
|
||||||
<< " which is required to set the"
|
<< " which is required to set the"
|
||||||
" values of the generic patch field." << nl
|
" values of the generic patch field." << nl
|
||||||
<< " (Actual type " << actualTypeName_ << ")" << nl
|
<< " (Actual type " << actualTypeName_ << ')' << nl << nl
|
||||||
<< "\n Please add the 'value' entry to the write function "
|
<< " Please add the 'value' entry to the write function"
|
||||||
"of the user-defined boundary-condition\n"
|
" of the user-defined boundary-condition" << nl
|
||||||
<< exit(FatalIOError);
|
<< exit(FatalIOError);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -79,338 +80,329 @@ Foam::genericFvPatchField<Type>::genericFvPatchField
|
|||||||
{
|
{
|
||||||
const keyType& key = dEntry.keyword();
|
const keyType& key = dEntry.keyword();
|
||||||
|
|
||||||
if (key != "type" && key != "value")
|
if
|
||||||
|
(
|
||||||
|
key == "type"
|
||||||
|
|| key == "value"
|
||||||
|
|| !dEntry.isStream() || dEntry.stream().empty()
|
||||||
|
)
|
||||||
{
|
{
|
||||||
if
|
continue;
|
||||||
(
|
}
|
||||||
dEntry.isStream()
|
|
||||||
&& dEntry.stream().size()
|
|
||||||
)
|
ITstream& is = dEntry.stream();
|
||||||
|
|
||||||
|
// Read first token
|
||||||
|
token firstToken(is);
|
||||||
|
|
||||||
|
if
|
||||||
|
(
|
||||||
|
firstToken.isWord()
|
||||||
|
&& firstToken.wordToken() == "nonuniform"
|
||||||
|
)
|
||||||
|
{
|
||||||
|
token fieldToken(is);
|
||||||
|
|
||||||
|
if (!fieldToken.isCompound())
|
||||||
{
|
{
|
||||||
ITstream& is = dEntry.stream();
|
|
||||||
|
|
||||||
// Read first token
|
|
||||||
token firstToken(is);
|
|
||||||
|
|
||||||
if
|
if
|
||||||
(
|
(
|
||||||
firstToken.isWord()
|
fieldToken.isLabel()
|
||||||
&& firstToken.wordToken() == "nonuniform"
|
&& fieldToken.labelToken() == 0
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
token fieldToken(is);
|
scalarFields_.insert(key, autoPtr<scalarField>::New());
|
||||||
|
|
||||||
if (!fieldToken.isCompound())
|
|
||||||
{
|
|
||||||
if
|
|
||||||
(
|
|
||||||
fieldToken.isLabel()
|
|
||||||
&& fieldToken.labelToken() == 0
|
|
||||||
)
|
|
||||||
{
|
|
||||||
scalarFields_.insert
|
|
||||||
(
|
|
||||||
dEntry.keyword(),
|
|
||||||
autoPtr<scalarField>::New()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
FatalIOErrorInFunction(dict)
|
|
||||||
<< "\n token following 'nonuniform' "
|
|
||||||
"is not a compound"
|
|
||||||
<< "\n on patch " << this->patch().name()
|
|
||||||
<< " of field "
|
|
||||||
<< this->internalField().name()
|
|
||||||
<< " in file "
|
|
||||||
<< this->internalField().objectPath()
|
|
||||||
<< exit(FatalIOError);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if
|
|
||||||
(
|
|
||||||
fieldToken.compoundToken().type()
|
|
||||||
== token::Compound<List<scalar>>::typeName
|
|
||||||
)
|
|
||||||
{
|
|
||||||
auto fPtr = autoPtr<scalarField>::New();
|
|
||||||
|
|
||||||
fPtr->transfer
|
|
||||||
(
|
|
||||||
dynamicCast<token::Compound<List<scalar>>>
|
|
||||||
(
|
|
||||||
fieldToken.transferCompoundToken(is)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
if (fPtr->size() != this->size())
|
|
||||||
{
|
|
||||||
FatalIOErrorInFunction(dict)
|
|
||||||
<< "\n size of field " << key
|
|
||||||
<< " (" << fPtr->size() << ')'
|
|
||||||
<< " is not the same size as the patch ("
|
|
||||||
<< this->size() << ')'
|
|
||||||
<< "\n on patch " << this->patch().name()
|
|
||||||
<< " of field "
|
|
||||||
<< this->internalField().name()
|
|
||||||
<< " in file "
|
|
||||||
<< this->internalField().objectPath()
|
|
||||||
<< exit(FatalIOError);
|
|
||||||
}
|
|
||||||
|
|
||||||
scalarFields_.insert(key, fPtr);
|
|
||||||
}
|
|
||||||
else if
|
|
||||||
(
|
|
||||||
fieldToken.compoundToken().type()
|
|
||||||
== token::Compound<List<vector>>::typeName
|
|
||||||
)
|
|
||||||
{
|
|
||||||
auto fPtr = autoPtr<vectorField>::New();
|
|
||||||
|
|
||||||
fPtr->transfer
|
|
||||||
(
|
|
||||||
dynamicCast<token::Compound<List<vector>>>
|
|
||||||
(
|
|
||||||
fieldToken.transferCompoundToken(is)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
if (fPtr->size() != this->size())
|
|
||||||
{
|
|
||||||
FatalIOErrorInFunction(dict)
|
|
||||||
<< "\n size of field " << key
|
|
||||||
<< " (" << fPtr->size() << ')'
|
|
||||||
<< " is not the same size as the patch ("
|
|
||||||
<< this->size() << ')'
|
|
||||||
<< "\n on patch " << this->patch().name()
|
|
||||||
<< " of field "
|
|
||||||
<< this->internalField().name()
|
|
||||||
<< " in file "
|
|
||||||
<< this->internalField().objectPath()
|
|
||||||
<< exit(FatalIOError);
|
|
||||||
}
|
|
||||||
|
|
||||||
vectorFields_.insert(key, fPtr);
|
|
||||||
}
|
|
||||||
else if
|
|
||||||
(
|
|
||||||
fieldToken.compoundToken().type()
|
|
||||||
== token::Compound<List<sphericalTensor>>::typeName
|
|
||||||
)
|
|
||||||
{
|
|
||||||
auto fPtr = autoPtr<sphericalTensorField>::New();
|
|
||||||
|
|
||||||
fPtr->transfer
|
|
||||||
(
|
|
||||||
dynamicCast
|
|
||||||
<
|
|
||||||
token::Compound<List<sphericalTensor>>
|
|
||||||
>
|
|
||||||
(
|
|
||||||
fieldToken.transferCompoundToken(is)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
if (fPtr->size() != this->size())
|
|
||||||
{
|
|
||||||
FatalIOErrorInFunction(dict)
|
|
||||||
<< "\n size of field " << key
|
|
||||||
<< " (" << fPtr->size() << ')'
|
|
||||||
<< " is not the same size as the patch ("
|
|
||||||
<< this->size() << ')'
|
|
||||||
<< "\n on patch " << this->patch().name()
|
|
||||||
<< " of field "
|
|
||||||
<< this->internalField().name()
|
|
||||||
<< " in file "
|
|
||||||
<< this->internalField().objectPath()
|
|
||||||
<< exit(FatalIOError);
|
|
||||||
}
|
|
||||||
|
|
||||||
sphTensorFields_.insert(key, fPtr);
|
|
||||||
}
|
|
||||||
else if
|
|
||||||
(
|
|
||||||
fieldToken.compoundToken().type()
|
|
||||||
== token::Compound<List<symmTensor>>::typeName
|
|
||||||
)
|
|
||||||
{
|
|
||||||
auto fPtr = autoPtr<symmTensorField>::New();
|
|
||||||
|
|
||||||
fPtr->transfer
|
|
||||||
(
|
|
||||||
dynamicCast
|
|
||||||
<
|
|
||||||
token::Compound<List<symmTensor>>
|
|
||||||
>
|
|
||||||
(
|
|
||||||
fieldToken.transferCompoundToken(is)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
if (fPtr->size() != this->size())
|
|
||||||
{
|
|
||||||
FatalIOErrorInFunction(dict)
|
|
||||||
<< "\n size of field " << key
|
|
||||||
<< " (" << fPtr->size() << ')'
|
|
||||||
<< " is not the same size as the patch ("
|
|
||||||
<< this->size() << ')'
|
|
||||||
<< "\n on patch " << this->patch().name()
|
|
||||||
<< " of field "
|
|
||||||
<< this->internalField().name()
|
|
||||||
<< " in file "
|
|
||||||
<< this->internalField().objectPath()
|
|
||||||
<< exit(FatalIOError);
|
|
||||||
}
|
|
||||||
|
|
||||||
symmTensorFields_.insert(key, fPtr);
|
|
||||||
}
|
|
||||||
else if
|
|
||||||
(
|
|
||||||
fieldToken.compoundToken().type()
|
|
||||||
== token::Compound<List<tensor>>::typeName
|
|
||||||
)
|
|
||||||
{
|
|
||||||
auto fPtr = autoPtr<tensorField>::New();
|
|
||||||
|
|
||||||
fPtr->transfer
|
|
||||||
(
|
|
||||||
dynamicCast<token::Compound<List<tensor>>>
|
|
||||||
(
|
|
||||||
fieldToken.transferCompoundToken(is)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
if (fPtr->size() != this->size())
|
|
||||||
{
|
|
||||||
FatalIOErrorInFunction(dict)
|
|
||||||
<< "\n size of field " << key
|
|
||||||
<< " (" << fPtr->size() << ')'
|
|
||||||
<< " is not the same size as the patch ("
|
|
||||||
<< this->size() << ')'
|
|
||||||
<< "\n on patch " << this->patch().name()
|
|
||||||
<< " of field "
|
|
||||||
<< this->internalField().name()
|
|
||||||
<< " in file "
|
|
||||||
<< this->internalField().objectPath()
|
|
||||||
<< exit(FatalIOError);
|
|
||||||
}
|
|
||||||
|
|
||||||
tensorFields_.insert(key, fPtr);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
FatalIOErrorInFunction(dict)
|
|
||||||
<< "\n compound " << fieldToken.compoundToken()
|
|
||||||
<< " not supported"
|
|
||||||
<< "\n on patch " << this->patch().name()
|
|
||||||
<< " of field "
|
|
||||||
<< this->internalField().name()
|
|
||||||
<< " in file "
|
|
||||||
<< this->internalField().objectPath()
|
|
||||||
<< exit(FatalIOError);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else if
|
else
|
||||||
(
|
|
||||||
firstToken.isWord()
|
|
||||||
&& firstToken.wordToken() == "uniform"
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
token fieldToken(is);
|
FatalIOErrorInFunction(dict)
|
||||||
|
<< "\n token following 'nonuniform' "
|
||||||
|
"is not a compound"
|
||||||
|
<< "\n on patch " << this->patch().name()
|
||||||
|
<< " of field "
|
||||||
|
<< this->internalField().name()
|
||||||
|
<< " in file "
|
||||||
|
<< this->internalField().objectPath() << nl
|
||||||
|
<< exit(FatalIOError);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if
|
||||||
|
(
|
||||||
|
fieldToken.compoundToken().type()
|
||||||
|
== token::Compound<List<scalar>>::typeName
|
||||||
|
)
|
||||||
|
{
|
||||||
|
auto fPtr = autoPtr<scalarField>::New();
|
||||||
|
|
||||||
if (!fieldToken.isPunctuation())
|
fPtr->transfer
|
||||||
{
|
(
|
||||||
scalarFields_.insert
|
dynamicCast<token::Compound<List<scalar>>>
|
||||||
|
(
|
||||||
|
fieldToken.transferCompoundToken(is)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
if (fPtr->size() != patchSize)
|
||||||
|
{
|
||||||
|
FatalIOErrorInFunction(dict)
|
||||||
|
<< "\n size of field " << key
|
||||||
|
<< " (" << fPtr->size() << ')'
|
||||||
|
<< " is not the same size as the patch ("
|
||||||
|
<< patchSize << ')'
|
||||||
|
<< "\n on patch " << this->patch().name()
|
||||||
|
<< " of field "
|
||||||
|
<< this->internalField().name()
|
||||||
|
<< " in file "
|
||||||
|
<< this->internalField().objectPath() << nl
|
||||||
|
<< exit(FatalIOError);
|
||||||
|
}
|
||||||
|
|
||||||
|
scalarFields_.insert(key, fPtr);
|
||||||
|
}
|
||||||
|
else if
|
||||||
|
(
|
||||||
|
fieldToken.compoundToken().type()
|
||||||
|
== token::Compound<List<vector>>::typeName
|
||||||
|
)
|
||||||
|
{
|
||||||
|
auto fPtr = autoPtr<vectorField>::New();
|
||||||
|
|
||||||
|
fPtr->transfer
|
||||||
|
(
|
||||||
|
dynamicCast<token::Compound<List<vector>>>
|
||||||
|
(
|
||||||
|
fieldToken.transferCompoundToken(is)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
if (fPtr->size() != patchSize)
|
||||||
|
{
|
||||||
|
FatalIOErrorInFunction(dict)
|
||||||
|
<< "\n size of field " << key
|
||||||
|
<< " (" << fPtr->size() << ')'
|
||||||
|
<< " is not the same size as the patch ("
|
||||||
|
<< patchSize << ')'
|
||||||
|
<< "\n on patch " << this->patch().name()
|
||||||
|
<< " of field "
|
||||||
|
<< this->internalField().name()
|
||||||
|
<< " in file "
|
||||||
|
<< this->internalField().objectPath() << nl
|
||||||
|
<< exit(FatalIOError);
|
||||||
|
}
|
||||||
|
|
||||||
|
vectorFields_.insert(key, fPtr);
|
||||||
|
}
|
||||||
|
else if
|
||||||
|
(
|
||||||
|
fieldToken.compoundToken().type()
|
||||||
|
== token::Compound<List<sphericalTensor>>::typeName
|
||||||
|
)
|
||||||
|
{
|
||||||
|
auto fPtr = autoPtr<sphericalTensorField>::New();
|
||||||
|
|
||||||
|
fPtr->transfer
|
||||||
|
(
|
||||||
|
dynamicCast<token::Compound<List<sphericalTensor>>>
|
||||||
|
(
|
||||||
|
fieldToken.transferCompoundToken(is)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
if (fPtr->size() != patchSize)
|
||||||
|
{
|
||||||
|
FatalIOErrorInFunction(dict)
|
||||||
|
<< "\n size of field " << key
|
||||||
|
<< " (" << fPtr->size() << ')'
|
||||||
|
<< " is not the same size as the patch ("
|
||||||
|
<< patchSize << ')'
|
||||||
|
<< "\n on patch " << this->patch().name()
|
||||||
|
<< " of field "
|
||||||
|
<< this->internalField().name()
|
||||||
|
<< " in file "
|
||||||
|
<< this->internalField().objectPath() << nl
|
||||||
|
<< exit(FatalIOError);
|
||||||
|
}
|
||||||
|
|
||||||
|
sphTensorFields_.insert(key, fPtr);
|
||||||
|
}
|
||||||
|
else if
|
||||||
|
(
|
||||||
|
fieldToken.compoundToken().type()
|
||||||
|
== token::Compound<List<symmTensor>>::typeName
|
||||||
|
)
|
||||||
|
{
|
||||||
|
auto fPtr = autoPtr<symmTensorField>::New();
|
||||||
|
|
||||||
|
fPtr->transfer
|
||||||
|
(
|
||||||
|
dynamicCast<token::Compound<List<symmTensor>>>
|
||||||
|
(
|
||||||
|
fieldToken.transferCompoundToken(is)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
if (fPtr->size() != patchSize)
|
||||||
|
{
|
||||||
|
FatalIOErrorInFunction(dict)
|
||||||
|
<< "\n size of field " << key
|
||||||
|
<< " (" << fPtr->size() << ')'
|
||||||
|
<< " is not the same size as the patch ("
|
||||||
|
<< patchSize << ')'
|
||||||
|
<< "\n on patch " << this->patch().name()
|
||||||
|
<< " of field "
|
||||||
|
<< this->internalField().name()
|
||||||
|
<< " in file "
|
||||||
|
<< this->internalField().objectPath() << nl
|
||||||
|
<< exit(FatalIOError);
|
||||||
|
}
|
||||||
|
|
||||||
|
symmTensorFields_.insert(key, fPtr);
|
||||||
|
}
|
||||||
|
else if
|
||||||
|
(
|
||||||
|
fieldToken.compoundToken().type()
|
||||||
|
== token::Compound<List<tensor>>::typeName
|
||||||
|
)
|
||||||
|
{
|
||||||
|
auto fPtr = autoPtr<tensorField>::New();
|
||||||
|
|
||||||
|
fPtr->transfer
|
||||||
|
(
|
||||||
|
dynamicCast<token::Compound<List<tensor>>>
|
||||||
|
(
|
||||||
|
fieldToken.transferCompoundToken(is)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
if (fPtr->size() != patchSize)
|
||||||
|
{
|
||||||
|
FatalIOErrorInFunction(dict)
|
||||||
|
<< "\n size of field " << key
|
||||||
|
<< " (" << fPtr->size() << ')'
|
||||||
|
<< " is not the same size as the patch ("
|
||||||
|
<< patchSize << ')'
|
||||||
|
<< "\n on patch " << this->patch().name()
|
||||||
|
<< " of field "
|
||||||
|
<< this->internalField().name()
|
||||||
|
<< " in file "
|
||||||
|
<< this->internalField().objectPath() << nl
|
||||||
|
<< exit(FatalIOError);
|
||||||
|
}
|
||||||
|
|
||||||
|
tensorFields_.insert(key, fPtr);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
FatalIOErrorInFunction(dict)
|
||||||
|
<< "\n compound " << fieldToken.compoundToken()
|
||||||
|
<< " not supported"
|
||||||
|
<< "\n on patch " << this->patch().name()
|
||||||
|
<< " of field "
|
||||||
|
<< this->internalField().name()
|
||||||
|
<< " in file "
|
||||||
|
<< this->internalField().objectPath() << nl
|
||||||
|
<< exit(FatalIOError);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if
|
||||||
|
(
|
||||||
|
firstToken.isWord()
|
||||||
|
&& firstToken.wordToken() == "uniform"
|
||||||
|
)
|
||||||
|
{
|
||||||
|
token fieldToken(is);
|
||||||
|
|
||||||
|
if (!fieldToken.isPunctuation())
|
||||||
|
{
|
||||||
|
scalarFields_.insert
|
||||||
|
(
|
||||||
|
key,
|
||||||
|
autoPtr<scalarField>::New
|
||||||
|
(
|
||||||
|
patchSize,
|
||||||
|
fieldToken.number()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Read as scalarList.
|
||||||
|
is.putBack(fieldToken);
|
||||||
|
|
||||||
|
scalarList l(is);
|
||||||
|
|
||||||
|
if (l.size() == vector::nComponents)
|
||||||
|
{
|
||||||
|
vector vs(l[0], l[1], l[2]);
|
||||||
|
|
||||||
|
vectorFields_.insert
|
||||||
|
(
|
||||||
|
key,
|
||||||
|
autoPtr<vectorField>::New
|
||||||
(
|
(
|
||||||
key,
|
patchSize,
|
||||||
autoPtr<scalarField>::New
|
vs
|
||||||
(
|
)
|
||||||
this->size(),
|
);
|
||||||
fieldToken.number()
|
}
|
||||||
)
|
else if (l.size() == sphericalTensor::nComponents)
|
||||||
);
|
{
|
||||||
}
|
sphericalTensor vs(l[0]);
|
||||||
else
|
|
||||||
{
|
|
||||||
// Read as scalarList.
|
|
||||||
is.putBack(fieldToken);
|
|
||||||
|
|
||||||
scalarList l(is);
|
sphTensorFields_.insert
|
||||||
|
(
|
||||||
|
key,
|
||||||
|
autoPtr<sphericalTensorField>::New
|
||||||
|
(
|
||||||
|
patchSize,
|
||||||
|
vs
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
else if (l.size() == symmTensor::nComponents)
|
||||||
|
{
|
||||||
|
symmTensor vs(l[0], l[1], l[2], l[3], l[4], l[5]);
|
||||||
|
|
||||||
if (l.size() == vector::nComponents)
|
symmTensorFields_.insert
|
||||||
{
|
(
|
||||||
vector vs(l[0], l[1], l[2]);
|
key,
|
||||||
|
autoPtr<symmTensorField>::New
|
||||||
|
(
|
||||||
|
patchSize,
|
||||||
|
vs
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
else if (l.size() == tensor::nComponents)
|
||||||
|
{
|
||||||
|
tensor vs
|
||||||
|
(
|
||||||
|
l[0], l[1], l[2],
|
||||||
|
l[3], l[4], l[5],
|
||||||
|
l[6], l[7], l[8]
|
||||||
|
);
|
||||||
|
|
||||||
vectorFields_.insert
|
tensorFields_.insert
|
||||||
(
|
(
|
||||||
key,
|
key,
|
||||||
autoPtr<vectorField>::New
|
autoPtr<tensorField>::New
|
||||||
(
|
(
|
||||||
this->size(),
|
patchSize,
|
||||||
vs
|
vs
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
else if (l.size() == sphericalTensor::nComponents)
|
else
|
||||||
{
|
{
|
||||||
sphericalTensor vs(l[0]);
|
FatalIOErrorInFunction(dict)
|
||||||
|
<< "\n unrecognised native type " << l
|
||||||
sphTensorFields_.insert
|
<< "\n on patch " << this->patch().name()
|
||||||
(
|
<< " of field "
|
||||||
key,
|
<< this->internalField().name()
|
||||||
autoPtr<sphericalTensorField>::New
|
<< " in file "
|
||||||
(
|
<< this->internalField().objectPath() << nl
|
||||||
this->size(),
|
<< exit(FatalIOError);
|
||||||
vs
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
else if (l.size() == symmTensor::nComponents)
|
|
||||||
{
|
|
||||||
symmTensor vs(l[0], l[1], l[2], l[3], l[4], l[5]);
|
|
||||||
|
|
||||||
symmTensorFields_.insert
|
|
||||||
(
|
|
||||||
key,
|
|
||||||
autoPtr<symmTensorField>::New
|
|
||||||
(
|
|
||||||
this->size(),
|
|
||||||
vs
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
else if (l.size() == tensor::nComponents)
|
|
||||||
{
|
|
||||||
tensor vs
|
|
||||||
(
|
|
||||||
l[0], l[1], l[2],
|
|
||||||
l[3], l[4], l[5],
|
|
||||||
l[6], l[7], l[8]
|
|
||||||
);
|
|
||||||
|
|
||||||
tensorFields_.insert
|
|
||||||
(
|
|
||||||
key,
|
|
||||||
autoPtr<tensorField>::New
|
|
||||||
(
|
|
||||||
this->size(),
|
|
||||||
vs
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
FatalIOErrorInFunction(dict)
|
|
||||||
<< "\n unrecognised native type " << l
|
|
||||||
<< "\n on patch " << this->patch().name()
|
|
||||||
<< " of field "
|
|
||||||
<< this->internalField().name()
|
|
||||||
<< " in file "
|
|
||||||
<< this->internalField().objectPath()
|
|
||||||
<< exit(FatalIOError);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -707,46 +699,42 @@ void Foam::genericFvPatchField<Type>::write(Ostream& os) const
|
|||||||
{
|
{
|
||||||
const keyType& key = dEntry.keyword();
|
const keyType& key = dEntry.keyword();
|
||||||
|
|
||||||
if (key != "type" && key != "value")
|
if (key == "type" || key == "value")
|
||||||
{
|
{
|
||||||
if
|
continue;
|
||||||
(
|
}
|
||||||
dEntry.isStream()
|
else if
|
||||||
&& dEntry.stream().size()
|
(
|
||||||
&& dEntry.stream()[0].isWord()
|
dEntry.isStream()
|
||||||
&& dEntry.stream()[0].wordToken() == "nonuniform"
|
&& dEntry.stream().size()
|
||||||
)
|
&& dEntry.stream()[0].isWord()
|
||||||
|
&& dEntry.stream()[0].wordToken() == "nonuniform"
|
||||||
|
)
|
||||||
|
{
|
||||||
|
if (scalarFields_.found(key))
|
||||||
{
|
{
|
||||||
if (scalarFields_.found(key))
|
scalarFields_.cfind(key)()->writeEntry(key, os);
|
||||||
{
|
|
||||||
scalarFields_.find(key)()
|
|
||||||
->writeEntry(key, os);
|
|
||||||
}
|
|
||||||
else if (vectorFields_.found(key))
|
|
||||||
{
|
|
||||||
vectorFields_.find(key)()
|
|
||||||
->writeEntry(key, os);
|
|
||||||
}
|
|
||||||
else if (sphTensorFields_.found(key))
|
|
||||||
{
|
|
||||||
sphTensorFields_.find(key)()
|
|
||||||
->writeEntry(key, os);
|
|
||||||
}
|
|
||||||
else if (symmTensorFields_.found(key))
|
|
||||||
{
|
|
||||||
symmTensorFields_.find(key)()
|
|
||||||
->writeEntry(key, os);
|
|
||||||
}
|
|
||||||
else if (tensorFields_.found(key))
|
|
||||||
{
|
|
||||||
tensorFields_.find(key)()
|
|
||||||
->writeEntry(key, os);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else if (vectorFields_.found(key))
|
||||||
{
|
{
|
||||||
dEntry.write(os);
|
vectorFields_.cfind(key)()->writeEntry(key, os);
|
||||||
}
|
}
|
||||||
|
else if (sphTensorFields_.found(key))
|
||||||
|
{
|
||||||
|
sphTensorFields_.cfind(key)()->writeEntry(key, os);
|
||||||
|
}
|
||||||
|
else if (symmTensorFields_.found(key))
|
||||||
|
{
|
||||||
|
symmTensorFields_.cfind(key)()->writeEntry(key, os);
|
||||||
|
}
|
||||||
|
else if (tensorFields_.found(key))
|
||||||
|
{
|
||||||
|
tensorFields_.cfind(key)()->writeEntry(key, os);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
dEntry.write(os);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -54,22 +54,23 @@ Foam::genericFvsPatchField<Type>::genericFvsPatchField
|
|||||||
)
|
)
|
||||||
:
|
:
|
||||||
calculatedFvsPatchField<Type>(p, iF, dict),
|
calculatedFvsPatchField<Type>(p, iF, dict),
|
||||||
actualTypeName_(dict.lookup("type")),
|
actualTypeName_(dict.get<word>("type")),
|
||||||
dict_(dict)
|
dict_(dict)
|
||||||
{
|
{
|
||||||
|
const label patchSize = this->size();
|
||||||
|
|
||||||
if (!dict.found("value"))
|
if (!dict.found("value"))
|
||||||
{
|
{
|
||||||
FatalIOErrorInFunction(dict)
|
FatalIOErrorInFunction(dict)
|
||||||
<< "\n Cannot find 'value' entry"
|
<< nl << " Cannot find 'value' entry"
|
||||||
<< " on patch " << this->patch().name()
|
<< " on patch " << this->patch().name()
|
||||||
<< " of field " << this->internalField().name()
|
<< " of field " << this->internalField().name()
|
||||||
<< " in file " << this->internalField().objectPath()
|
<< " in file " << this->internalField().objectPath() << nl
|
||||||
<< nl
|
|
||||||
<< " which is required to set the"
|
<< " which is required to set the"
|
||||||
" values of the generic patch field." << nl
|
" values of the generic patch field." << nl
|
||||||
<< " (Actual type " << actualTypeName_ << ")" << nl
|
<< " (Actual type " << actualTypeName_ << ')' << nl << nl
|
||||||
<< "\n Please add the 'value' entry to the write function "
|
<< " Please add the 'value' entry to the write function"
|
||||||
"of the user-defined boundary-condition\n"
|
" of the user-defined boundary-condition" << nl
|
||||||
<< exit(FatalIOError);
|
<< exit(FatalIOError);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -77,338 +78,329 @@ Foam::genericFvsPatchField<Type>::genericFvsPatchField
|
|||||||
{
|
{
|
||||||
const keyType& key = dEntry.keyword();
|
const keyType& key = dEntry.keyword();
|
||||||
|
|
||||||
if (key != "type" && key != "value")
|
if
|
||||||
|
(
|
||||||
|
key == "type"
|
||||||
|
|| key == "value"
|
||||||
|
|| !dEntry.isStream() || dEntry.stream().empty()
|
||||||
|
)
|
||||||
{
|
{
|
||||||
if
|
continue;
|
||||||
(
|
}
|
||||||
dEntry.isStream()
|
|
||||||
&& dEntry.stream().size()
|
|
||||||
)
|
ITstream& is = dEntry.stream();
|
||||||
|
|
||||||
|
// Read first token
|
||||||
|
token firstToken(is);
|
||||||
|
|
||||||
|
if
|
||||||
|
(
|
||||||
|
firstToken.isWord()
|
||||||
|
&& firstToken.wordToken() == "nonuniform"
|
||||||
|
)
|
||||||
|
{
|
||||||
|
token fieldToken(is);
|
||||||
|
|
||||||
|
if (!fieldToken.isCompound())
|
||||||
{
|
{
|
||||||
ITstream& is = dEntry.stream();
|
|
||||||
|
|
||||||
// Read first token
|
|
||||||
token firstToken(is);
|
|
||||||
|
|
||||||
if
|
if
|
||||||
(
|
(
|
||||||
firstToken.isWord()
|
fieldToken.isLabel()
|
||||||
&& firstToken.wordToken() == "nonuniform"
|
&& fieldToken.labelToken() == 0
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
token fieldToken(is);
|
scalarFields_.insert(key, autoPtr<scalarField>::New());
|
||||||
|
|
||||||
if (!fieldToken.isCompound())
|
|
||||||
{
|
|
||||||
if
|
|
||||||
(
|
|
||||||
fieldToken.isLabel()
|
|
||||||
&& fieldToken.labelToken() == 0
|
|
||||||
)
|
|
||||||
{
|
|
||||||
scalarFields_.insert
|
|
||||||
(
|
|
||||||
dEntry.keyword(),
|
|
||||||
autoPtr<scalarField>::New()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
FatalIOErrorInFunction(dict)
|
|
||||||
<< "\n token following 'nonuniform' "
|
|
||||||
"is not a compound"
|
|
||||||
<< "\n on patch " << this->patch().name()
|
|
||||||
<< " of field "
|
|
||||||
<< this->internalField().name()
|
|
||||||
<< " in file "
|
|
||||||
<< this->internalField().objectPath()
|
|
||||||
<< exit(FatalIOError);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if
|
|
||||||
(
|
|
||||||
fieldToken.compoundToken().type()
|
|
||||||
== token::Compound<List<scalar>>::typeName
|
|
||||||
)
|
|
||||||
{
|
|
||||||
auto fPtr = autoPtr<scalarField>::New();
|
|
||||||
|
|
||||||
fPtr->transfer
|
|
||||||
(
|
|
||||||
dynamicCast<token::Compound<List<scalar>>>
|
|
||||||
(
|
|
||||||
fieldToken.transferCompoundToken(is)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
if (fPtr->size() != this->size())
|
|
||||||
{
|
|
||||||
FatalIOErrorInFunction(dict)
|
|
||||||
<< "\n size of field " << key
|
|
||||||
<< " (" << fPtr->size() << ')'
|
|
||||||
<< " is not the same size as the patch ("
|
|
||||||
<< this->size() << ')'
|
|
||||||
<< "\n on patch " << this->patch().name()
|
|
||||||
<< " of field "
|
|
||||||
<< this->internalField().name()
|
|
||||||
<< " in file "
|
|
||||||
<< this->internalField().objectPath()
|
|
||||||
<< exit(FatalIOError);
|
|
||||||
}
|
|
||||||
|
|
||||||
scalarFields_.insert(key, fPtr);
|
|
||||||
}
|
|
||||||
else if
|
|
||||||
(
|
|
||||||
fieldToken.compoundToken().type()
|
|
||||||
== token::Compound<List<vector>>::typeName
|
|
||||||
)
|
|
||||||
{
|
|
||||||
auto fPtr = autoPtr<vectorField>::New();
|
|
||||||
|
|
||||||
fPtr->transfer
|
|
||||||
(
|
|
||||||
dynamicCast<token::Compound<List<vector>>>
|
|
||||||
(
|
|
||||||
fieldToken.transferCompoundToken(is)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
if (fPtr->size() != this->size())
|
|
||||||
{
|
|
||||||
FatalIOErrorInFunction(dict)
|
|
||||||
<< "\n size of field " << key
|
|
||||||
<< " (" << fPtr->size() << ')'
|
|
||||||
<< " is not the same size as the patch ("
|
|
||||||
<< this->size() << ')'
|
|
||||||
<< "\n on patch " << this->patch().name()
|
|
||||||
<< " of field "
|
|
||||||
<< this->internalField().name()
|
|
||||||
<< " in file "
|
|
||||||
<< this->internalField().objectPath()
|
|
||||||
<< exit(FatalIOError);
|
|
||||||
}
|
|
||||||
|
|
||||||
vectorFields_.insert(key, fPtr);
|
|
||||||
}
|
|
||||||
else if
|
|
||||||
(
|
|
||||||
fieldToken.compoundToken().type()
|
|
||||||
== token::Compound<List<sphericalTensor>>::typeName
|
|
||||||
)
|
|
||||||
{
|
|
||||||
auto fPtr = autoPtr<sphericalTensorField>::New();
|
|
||||||
|
|
||||||
fPtr->transfer
|
|
||||||
(
|
|
||||||
dynamicCast
|
|
||||||
<
|
|
||||||
token::Compound<List<sphericalTensor>>
|
|
||||||
>
|
|
||||||
(
|
|
||||||
fieldToken.transferCompoundToken(is)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
if (fPtr->size() != this->size())
|
|
||||||
{
|
|
||||||
FatalIOErrorInFunction(dict)
|
|
||||||
<< "\n size of field " << key
|
|
||||||
<< " (" << fPtr->size() << ')'
|
|
||||||
<< " is not the same size as the patch ("
|
|
||||||
<< this->size() << ')'
|
|
||||||
<< "\n on patch " << this->patch().name()
|
|
||||||
<< " of field "
|
|
||||||
<< this->internalField().name()
|
|
||||||
<< " in file "
|
|
||||||
<< this->internalField().objectPath()
|
|
||||||
<< exit(FatalIOError);
|
|
||||||
}
|
|
||||||
|
|
||||||
sphTensorFields_.insert(key, fPtr);
|
|
||||||
}
|
|
||||||
else if
|
|
||||||
(
|
|
||||||
fieldToken.compoundToken().type()
|
|
||||||
== token::Compound<List<symmTensor>>::typeName
|
|
||||||
)
|
|
||||||
{
|
|
||||||
auto fPtr = autoPtr<symmTensorField>::New();
|
|
||||||
|
|
||||||
fPtr->transfer
|
|
||||||
(
|
|
||||||
dynamicCast
|
|
||||||
<
|
|
||||||
token::Compound<List<symmTensor>>
|
|
||||||
>
|
|
||||||
(
|
|
||||||
fieldToken.transferCompoundToken(is)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
if (fPtr->size() != this->size())
|
|
||||||
{
|
|
||||||
FatalIOErrorInFunction(dict)
|
|
||||||
<< "\n size of field " << key
|
|
||||||
<< " (" << fPtr->size() << ')'
|
|
||||||
<< " is not the same size as the patch ("
|
|
||||||
<< this->size() << ')'
|
|
||||||
<< "\n on patch " << this->patch().name()
|
|
||||||
<< " of field "
|
|
||||||
<< this->internalField().name()
|
|
||||||
<< " in file "
|
|
||||||
<< this->internalField().objectPath()
|
|
||||||
<< exit(FatalIOError);
|
|
||||||
}
|
|
||||||
|
|
||||||
symmTensorFields_.insert(key, fPtr);
|
|
||||||
}
|
|
||||||
else if
|
|
||||||
(
|
|
||||||
fieldToken.compoundToken().type()
|
|
||||||
== token::Compound<List<tensor>>::typeName
|
|
||||||
)
|
|
||||||
{
|
|
||||||
auto fPtr = autoPtr<tensorField>::New();
|
|
||||||
|
|
||||||
fPtr->transfer
|
|
||||||
(
|
|
||||||
dynamicCast<token::Compound<List<tensor>>>
|
|
||||||
(
|
|
||||||
fieldToken.transferCompoundToken(is)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
if (fPtr->size() != this->size())
|
|
||||||
{
|
|
||||||
FatalIOErrorInFunction(dict)
|
|
||||||
<< "\n size of field " << key
|
|
||||||
<< " (" << fPtr->size() << ')'
|
|
||||||
<< " is not the same size as the patch ("
|
|
||||||
<< this->size() << ')'
|
|
||||||
<< "\n on patch " << this->patch().name()
|
|
||||||
<< " of field "
|
|
||||||
<< this->internalField().name()
|
|
||||||
<< " in file "
|
|
||||||
<< this->internalField().objectPath()
|
|
||||||
<< exit(FatalIOError);
|
|
||||||
}
|
|
||||||
|
|
||||||
tensorFields_.insert(key, fPtr);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
FatalIOErrorInFunction(dict)
|
|
||||||
<< "\n compound " << fieldToken.compoundToken()
|
|
||||||
<< " not supported"
|
|
||||||
<< "\n on patch " << this->patch().name()
|
|
||||||
<< " of field "
|
|
||||||
<< this->internalField().name()
|
|
||||||
<< " in file "
|
|
||||||
<< this->internalField().objectPath()
|
|
||||||
<< exit(FatalIOError);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else if
|
else
|
||||||
(
|
|
||||||
firstToken.isWord()
|
|
||||||
&& firstToken.wordToken() == "uniform"
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
token fieldToken(is);
|
FatalIOErrorInFunction(dict)
|
||||||
|
<< "\n token following 'nonuniform' "
|
||||||
|
"is not a compound"
|
||||||
|
<< "\n on patch " << this->patch().name()
|
||||||
|
<< " of field "
|
||||||
|
<< this->internalField().name()
|
||||||
|
<< " in file "
|
||||||
|
<< this->internalField().objectPath() << nl
|
||||||
|
<< exit(FatalIOError);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if
|
||||||
|
(
|
||||||
|
fieldToken.compoundToken().type()
|
||||||
|
== token::Compound<List<scalar>>::typeName
|
||||||
|
)
|
||||||
|
{
|
||||||
|
auto fPtr = autoPtr<scalarField>::New();
|
||||||
|
|
||||||
if (!fieldToken.isPunctuation())
|
fPtr->transfer
|
||||||
{
|
(
|
||||||
scalarFields_.insert
|
dynamicCast<token::Compound<List<scalar>>>
|
||||||
|
(
|
||||||
|
fieldToken.transferCompoundToken(is)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
if (fPtr->size() != patchSize)
|
||||||
|
{
|
||||||
|
FatalIOErrorInFunction(dict)
|
||||||
|
<< "\n size of field " << key
|
||||||
|
<< " (" << fPtr->size() << ')'
|
||||||
|
<< " is not the same size as the patch ("
|
||||||
|
<< patchSize << ')'
|
||||||
|
<< "\n on patch " << this->patch().name()
|
||||||
|
<< " of field "
|
||||||
|
<< this->internalField().name()
|
||||||
|
<< " in file "
|
||||||
|
<< this->internalField().objectPath() << nl
|
||||||
|
<< exit(FatalIOError);
|
||||||
|
}
|
||||||
|
|
||||||
|
scalarFields_.insert(key, fPtr);
|
||||||
|
}
|
||||||
|
else if
|
||||||
|
(
|
||||||
|
fieldToken.compoundToken().type()
|
||||||
|
== token::Compound<List<vector>>::typeName
|
||||||
|
)
|
||||||
|
{
|
||||||
|
auto fPtr = autoPtr<vectorField>::New();
|
||||||
|
|
||||||
|
fPtr->transfer
|
||||||
|
(
|
||||||
|
dynamicCast<token::Compound<List<vector>>>
|
||||||
|
(
|
||||||
|
fieldToken.transferCompoundToken(is)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
if (fPtr->size() != patchSize)
|
||||||
|
{
|
||||||
|
FatalIOErrorInFunction(dict)
|
||||||
|
<< "\n size of field " << key
|
||||||
|
<< " (" << fPtr->size() << ')'
|
||||||
|
<< " is not the same size as the patch ("
|
||||||
|
<< patchSize << ')'
|
||||||
|
<< "\n on patch " << this->patch().name()
|
||||||
|
<< " of field "
|
||||||
|
<< this->internalField().name()
|
||||||
|
<< " in file "
|
||||||
|
<< this->internalField().objectPath() << nl
|
||||||
|
<< exit(FatalIOError);
|
||||||
|
}
|
||||||
|
|
||||||
|
vectorFields_.insert(key, fPtr);
|
||||||
|
}
|
||||||
|
else if
|
||||||
|
(
|
||||||
|
fieldToken.compoundToken().type()
|
||||||
|
== token::Compound<List<sphericalTensor>>::typeName
|
||||||
|
)
|
||||||
|
{
|
||||||
|
auto fPtr = autoPtr<sphericalTensorField>::New();
|
||||||
|
|
||||||
|
fPtr->transfer
|
||||||
|
(
|
||||||
|
dynamicCast<token::Compound<List<sphericalTensor>>>
|
||||||
|
(
|
||||||
|
fieldToken.transferCompoundToken(is)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
if (fPtr->size() != patchSize)
|
||||||
|
{
|
||||||
|
FatalIOErrorInFunction(dict)
|
||||||
|
<< "\n size of field " << key
|
||||||
|
<< " (" << fPtr->size() << ')'
|
||||||
|
<< " is not the same size as the patch ("
|
||||||
|
<< patchSize << ')'
|
||||||
|
<< "\n on patch " << this->patch().name()
|
||||||
|
<< " of field "
|
||||||
|
<< this->internalField().name()
|
||||||
|
<< " in file "
|
||||||
|
<< this->internalField().objectPath() << nl
|
||||||
|
<< exit(FatalIOError);
|
||||||
|
}
|
||||||
|
|
||||||
|
sphTensorFields_.insert(key, fPtr);
|
||||||
|
}
|
||||||
|
else if
|
||||||
|
(
|
||||||
|
fieldToken.compoundToken().type()
|
||||||
|
== token::Compound<List<symmTensor>>::typeName
|
||||||
|
)
|
||||||
|
{
|
||||||
|
auto fPtr = autoPtr<symmTensorField>::New();
|
||||||
|
|
||||||
|
fPtr->transfer
|
||||||
|
(
|
||||||
|
dynamicCast<token::Compound<List<symmTensor>>>
|
||||||
|
(
|
||||||
|
fieldToken.transferCompoundToken(is)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
if (fPtr->size() != patchSize)
|
||||||
|
{
|
||||||
|
FatalIOErrorInFunction(dict)
|
||||||
|
<< "\n size of field " << key
|
||||||
|
<< " (" << fPtr->size() << ')'
|
||||||
|
<< " is not the same size as the patch ("
|
||||||
|
<< patchSize << ')'
|
||||||
|
<< "\n on patch " << this->patch().name()
|
||||||
|
<< " of field "
|
||||||
|
<< this->internalField().name()
|
||||||
|
<< " in file "
|
||||||
|
<< this->internalField().objectPath() << nl
|
||||||
|
<< exit(FatalIOError);
|
||||||
|
}
|
||||||
|
|
||||||
|
symmTensorFields_.insert(key, fPtr);
|
||||||
|
}
|
||||||
|
else if
|
||||||
|
(
|
||||||
|
fieldToken.compoundToken().type()
|
||||||
|
== token::Compound<List<tensor>>::typeName
|
||||||
|
)
|
||||||
|
{
|
||||||
|
auto fPtr = autoPtr<tensorField>::New();
|
||||||
|
|
||||||
|
fPtr->transfer
|
||||||
|
(
|
||||||
|
dynamicCast<token::Compound<List<tensor>>>
|
||||||
|
(
|
||||||
|
fieldToken.transferCompoundToken(is)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
if (fPtr->size() != patchSize)
|
||||||
|
{
|
||||||
|
FatalIOErrorInFunction(dict)
|
||||||
|
<< "\n size of field " << key
|
||||||
|
<< " (" << fPtr->size() << ')'
|
||||||
|
<< " is not the same size as the patch ("
|
||||||
|
<< patchSize << ')'
|
||||||
|
<< "\n on patch " << this->patch().name()
|
||||||
|
<< " of field "
|
||||||
|
<< this->internalField().name()
|
||||||
|
<< " in file "
|
||||||
|
<< this->internalField().objectPath() << nl
|
||||||
|
<< exit(FatalIOError);
|
||||||
|
}
|
||||||
|
|
||||||
|
tensorFields_.insert(key, fPtr);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
FatalIOErrorInFunction(dict)
|
||||||
|
<< "\n compound " << fieldToken.compoundToken()
|
||||||
|
<< " not supported"
|
||||||
|
<< "\n on patch " << this->patch().name()
|
||||||
|
<< " of field "
|
||||||
|
<< this->internalField().name()
|
||||||
|
<< " in file "
|
||||||
|
<< this->internalField().objectPath() << nl
|
||||||
|
<< exit(FatalIOError);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if
|
||||||
|
(
|
||||||
|
firstToken.isWord()
|
||||||
|
&& firstToken.wordToken() == "uniform"
|
||||||
|
)
|
||||||
|
{
|
||||||
|
token fieldToken(is);
|
||||||
|
|
||||||
|
if (!fieldToken.isPunctuation())
|
||||||
|
{
|
||||||
|
scalarFields_.insert
|
||||||
|
(
|
||||||
|
key,
|
||||||
|
autoPtr<scalarField>::New
|
||||||
|
(
|
||||||
|
patchSize,
|
||||||
|
fieldToken.number()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Read as scalarList.
|
||||||
|
is.putBack(fieldToken);
|
||||||
|
|
||||||
|
scalarList l(is);
|
||||||
|
|
||||||
|
if (l.size() == vector::nComponents)
|
||||||
|
{
|
||||||
|
vector vs(l[0], l[1], l[2]);
|
||||||
|
|
||||||
|
vectorFields_.insert
|
||||||
|
(
|
||||||
|
key,
|
||||||
|
autoPtr<vectorField>::New
|
||||||
(
|
(
|
||||||
key,
|
patchSize,
|
||||||
autoPtr<scalarField>::New
|
vs
|
||||||
(
|
)
|
||||||
this->size(),
|
);
|
||||||
fieldToken.number()
|
}
|
||||||
)
|
else if (l.size() == sphericalTensor::nComponents)
|
||||||
);
|
{
|
||||||
}
|
sphericalTensor vs(l[0]);
|
||||||
else
|
|
||||||
{
|
|
||||||
// Read as scalarList.
|
|
||||||
is.putBack(fieldToken);
|
|
||||||
|
|
||||||
scalarList l(is);
|
sphTensorFields_.insert
|
||||||
|
(
|
||||||
|
key,
|
||||||
|
autoPtr<sphericalTensorField>::New
|
||||||
|
(
|
||||||
|
patchSize,
|
||||||
|
vs
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
else if (l.size() == symmTensor::nComponents)
|
||||||
|
{
|
||||||
|
symmTensor vs(l[0], l[1], l[2], l[3], l[4], l[5]);
|
||||||
|
|
||||||
if (l.size() == vector::nComponents)
|
symmTensorFields_.insert
|
||||||
{
|
(
|
||||||
vector vs(l[0], l[1], l[2]);
|
key,
|
||||||
|
autoPtr<symmTensorField>::New
|
||||||
|
(
|
||||||
|
patchSize,
|
||||||
|
vs
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
else if (l.size() == tensor::nComponents)
|
||||||
|
{
|
||||||
|
tensor vs
|
||||||
|
(
|
||||||
|
l[0], l[1], l[2],
|
||||||
|
l[3], l[4], l[5],
|
||||||
|
l[6], l[7], l[8]
|
||||||
|
);
|
||||||
|
|
||||||
vectorFields_.insert
|
tensorFields_.insert
|
||||||
(
|
(
|
||||||
key,
|
key,
|
||||||
autoPtr<vectorField>::New
|
autoPtr<tensorField>::New
|
||||||
(
|
(
|
||||||
this->size(),
|
patchSize,
|
||||||
vs
|
vs
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
else if (l.size() == sphericalTensor::nComponents)
|
else
|
||||||
{
|
{
|
||||||
sphericalTensor vs(l[0]);
|
FatalIOErrorInFunction(dict)
|
||||||
|
<< "\n unrecognised native type " << l
|
||||||
sphTensorFields_.insert
|
<< "\n on patch " << this->patch().name()
|
||||||
(
|
<< " of field "
|
||||||
key,
|
<< this->internalField().name()
|
||||||
autoPtr<sphericalTensorField>::New
|
<< " in file "
|
||||||
(
|
<< this->internalField().objectPath() << nl
|
||||||
this->size(),
|
<< exit(FatalIOError);
|
||||||
vs
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
else if (l.size() == symmTensor::nComponents)
|
|
||||||
{
|
|
||||||
symmTensor vs(l[0], l[1], l[2], l[3], l[4], l[5]);
|
|
||||||
|
|
||||||
symmTensorFields_.insert
|
|
||||||
(
|
|
||||||
key,
|
|
||||||
autoPtr<symmTensorField>::New
|
|
||||||
(
|
|
||||||
this->size(),
|
|
||||||
vs
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
else if (l.size() == tensor::nComponents)
|
|
||||||
{
|
|
||||||
tensor vs
|
|
||||||
(
|
|
||||||
l[0], l[1], l[2],
|
|
||||||
l[3], l[4], l[5],
|
|
||||||
l[6], l[7], l[8]
|
|
||||||
);
|
|
||||||
|
|
||||||
tensorFields_.insert
|
|
||||||
(
|
|
||||||
key,
|
|
||||||
autoPtr<tensorField>::New
|
|
||||||
(
|
|
||||||
this->size(),
|
|
||||||
vs
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
FatalIOErrorInFunction(dict)
|
|
||||||
<< "\n unrecognised native type " << l
|
|
||||||
<< "\n on patch " << this->patch().name()
|
|
||||||
<< " of field "
|
|
||||||
<< this->internalField().name()
|
|
||||||
<< " in file "
|
|
||||||
<< this->internalField().objectPath()
|
|
||||||
<< exit(FatalIOError);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -705,46 +697,42 @@ void Foam::genericFvsPatchField<Type>::write(Ostream& os) const
|
|||||||
{
|
{
|
||||||
const keyType& key = dEntry.keyword();
|
const keyType& key = dEntry.keyword();
|
||||||
|
|
||||||
if (key != "type" && key != "value")
|
if (key == "type" || key == "value")
|
||||||
{
|
{
|
||||||
if
|
continue;
|
||||||
(
|
}
|
||||||
dEntry.isStream()
|
else if
|
||||||
&& dEntry.stream().size()
|
(
|
||||||
&& dEntry.stream()[0].isWord()
|
dEntry.isStream()
|
||||||
&& dEntry.stream()[0].wordToken() == "nonuniform"
|
&& dEntry.stream().size()
|
||||||
)
|
&& dEntry.stream()[0].isWord()
|
||||||
|
&& dEntry.stream()[0].wordToken() == "nonuniform"
|
||||||
|
)
|
||||||
|
{
|
||||||
|
if (scalarFields_.found(key))
|
||||||
{
|
{
|
||||||
if (scalarFields_.found(key))
|
scalarFields_.cfind(key)()->writeEntry(key, os);
|
||||||
{
|
|
||||||
scalarFields_.find(key)()
|
|
||||||
->writeEntry(key, os);
|
|
||||||
}
|
|
||||||
else if (vectorFields_.found(key))
|
|
||||||
{
|
|
||||||
vectorFields_.find(key)()
|
|
||||||
->writeEntry(key, os);
|
|
||||||
}
|
|
||||||
else if (sphTensorFields_.found(key))
|
|
||||||
{
|
|
||||||
sphTensorFields_.find(key)()
|
|
||||||
->writeEntry(key, os);
|
|
||||||
}
|
|
||||||
else if (symmTensorFields_.found(key))
|
|
||||||
{
|
|
||||||
symmTensorFields_.find(key)()
|
|
||||||
->writeEntry(key, os);
|
|
||||||
}
|
|
||||||
else if (tensorFields_.found(key))
|
|
||||||
{
|
|
||||||
tensorFields_.find(key)()
|
|
||||||
->writeEntry(key, os);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else if (vectorFields_.found(key))
|
||||||
{
|
{
|
||||||
dEntry.write(os);
|
vectorFields_.cfind(key)()->writeEntry(key, os);
|
||||||
}
|
}
|
||||||
|
else if (sphTensorFields_.found(key))
|
||||||
|
{
|
||||||
|
sphTensorFields_.cfind(key)()->writeEntry(key, os);
|
||||||
|
}
|
||||||
|
else if (symmTensorFields_.found(key))
|
||||||
|
{
|
||||||
|
symmTensorFields_.cfind(key)()->writeEntry(key, os);
|
||||||
|
}
|
||||||
|
else if (tensorFields_.found(key))
|
||||||
|
{
|
||||||
|
tensorFields_.cfind(key)()->writeEntry(key, os);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
dEntry.write(os);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -2,7 +2,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) 2016 OpenCFD Ltd.
|
\\ / A nd | Copyright (C) 2016-2019 OpenCFD Ltd.
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
| Copyright (C) 2011-2016 OpenFOAM Foundation
|
| Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||||
@ -55,242 +55,234 @@ Foam::genericPointPatchField<Type>::genericPointPatchField
|
|||||||
actualTypeName_(dict.get<word>("type")),
|
actualTypeName_(dict.get<word>("type")),
|
||||||
dict_(dict)
|
dict_(dict)
|
||||||
{
|
{
|
||||||
|
const label patchSize = this->size();
|
||||||
|
|
||||||
for (const entry& dEntry : dict_)
|
for (const entry& dEntry : dict_)
|
||||||
{
|
{
|
||||||
const keyType& key = dEntry.keyword();
|
const keyType& key = dEntry.keyword();
|
||||||
|
|
||||||
if (key != "type")
|
if
|
||||||
|
(
|
||||||
|
key == "type"
|
||||||
|
|| !dEntry.isStream() || dEntry.stream().empty()
|
||||||
|
)
|
||||||
{
|
{
|
||||||
if
|
continue;
|
||||||
(
|
}
|
||||||
dEntry.isStream()
|
|
||||||
&& dEntry.stream().size()
|
|
||||||
)
|
ITstream& is = dEntry.stream();
|
||||||
|
|
||||||
|
// Read first token
|
||||||
|
token firstToken(is);
|
||||||
|
|
||||||
|
if
|
||||||
|
(
|
||||||
|
firstToken.isWord()
|
||||||
|
&& firstToken.wordToken() == "nonuniform"
|
||||||
|
)
|
||||||
|
{
|
||||||
|
token fieldToken(is);
|
||||||
|
|
||||||
|
if (!fieldToken.isCompound())
|
||||||
{
|
{
|
||||||
ITstream& is = dEntry.stream();
|
|
||||||
|
|
||||||
// Read first token
|
|
||||||
token firstToken(is);
|
|
||||||
|
|
||||||
if
|
if
|
||||||
(
|
(
|
||||||
firstToken.isWord()
|
fieldToken.isLabel()
|
||||||
&& firstToken.wordToken() == "nonuniform"
|
&& fieldToken.labelToken() == 0
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
token fieldToken(is);
|
scalarFields_.insert(key, autoPtr<scalarField>::New());
|
||||||
|
|
||||||
if (!fieldToken.isCompound())
|
|
||||||
{
|
|
||||||
if
|
|
||||||
(
|
|
||||||
fieldToken.isLabel()
|
|
||||||
&& fieldToken.labelToken() == 0
|
|
||||||
)
|
|
||||||
{
|
|
||||||
scalarFields_.insert
|
|
||||||
(
|
|
||||||
key,
|
|
||||||
autoPtr<scalarField>::New()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
FatalIOErrorInFunction(dict)
|
|
||||||
<< "\n token following 'nonuniform' "
|
|
||||||
"is not a compound"
|
|
||||||
<< "\n on patch " << this->patch().name()
|
|
||||||
<< " of field "
|
|
||||||
<< this->internalField().name()
|
|
||||||
<< " in file "
|
|
||||||
<< this->internalField().objectPath()
|
|
||||||
<< exit(FatalIOError);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if
|
|
||||||
(
|
|
||||||
fieldToken.compoundToken().type()
|
|
||||||
== token::Compound<List<scalar>>::typeName
|
|
||||||
)
|
|
||||||
{
|
|
||||||
auto fPtr = autoPtr<scalarField>::New();
|
|
||||||
|
|
||||||
fPtr->transfer
|
|
||||||
(
|
|
||||||
dynamicCast<token::Compound<List<scalar>>>
|
|
||||||
(
|
|
||||||
fieldToken.transferCompoundToken(is)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
if (fPtr->size() != this->size())
|
|
||||||
{
|
|
||||||
FatalIOErrorInFunction(dict)
|
|
||||||
<< "\n size of field " << key
|
|
||||||
<< " (" << fPtr->size() << ')'
|
|
||||||
<< " is not the same size as the patch ("
|
|
||||||
<< this->size() << ')'
|
|
||||||
<< "\n on patch " << this->patch().name()
|
|
||||||
<< " of field "
|
|
||||||
<< this->internalField().name()
|
|
||||||
<< " in file "
|
|
||||||
<< this->internalField().objectPath()
|
|
||||||
<< exit(FatalIOError);
|
|
||||||
}
|
|
||||||
|
|
||||||
scalarFields_.insert(key, fPtr);
|
|
||||||
}
|
|
||||||
else if
|
|
||||||
(
|
|
||||||
fieldToken.compoundToken().type()
|
|
||||||
== token::Compound<List<vector>>::typeName
|
|
||||||
)
|
|
||||||
{
|
|
||||||
auto fPtr = autoPtr<vectorField>::New();
|
|
||||||
|
|
||||||
fPtr->transfer
|
|
||||||
(
|
|
||||||
dynamicCast<token::Compound<List<vector>>>
|
|
||||||
(
|
|
||||||
fieldToken.transferCompoundToken(is)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
if (fPtr->size() != this->size())
|
|
||||||
{
|
|
||||||
FatalIOErrorInFunction(dict)
|
|
||||||
<< "\n size of field " << key
|
|
||||||
<< " (" << fPtr->size() << ')'
|
|
||||||
<< " is not the same size as the patch ("
|
|
||||||
<< this->size() << ')'
|
|
||||||
<< "\n on patch " << this->patch().name()
|
|
||||||
<< " of field "
|
|
||||||
<< this->internalField().name()
|
|
||||||
<< " in file "
|
|
||||||
<< this->internalField().objectPath()
|
|
||||||
<< exit(FatalIOError);
|
|
||||||
}
|
|
||||||
|
|
||||||
vectorFields_.insert(key, fPtr);
|
|
||||||
}
|
|
||||||
else if
|
|
||||||
(
|
|
||||||
fieldToken.compoundToken().type()
|
|
||||||
== token::Compound<List<sphericalTensor>>::typeName
|
|
||||||
)
|
|
||||||
{
|
|
||||||
auto fPtr = autoPtr<sphericalTensorField>::New();
|
|
||||||
|
|
||||||
fPtr->transfer
|
|
||||||
(
|
|
||||||
dynamicCast
|
|
||||||
<
|
|
||||||
token::Compound<List<sphericalTensor>>
|
|
||||||
>
|
|
||||||
(
|
|
||||||
fieldToken.transferCompoundToken(is)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
if (fPtr->size() != this->size())
|
|
||||||
{
|
|
||||||
FatalIOErrorInFunction(dict)
|
|
||||||
<< "\n size of field " << key
|
|
||||||
<< " (" << fPtr->size() << ')'
|
|
||||||
<< " is not the same size as the patch ("
|
|
||||||
<< this->size() << ')'
|
|
||||||
<< "\n on patch " << this->patch().name()
|
|
||||||
<< " of field "
|
|
||||||
<< this->internalField().name()
|
|
||||||
<< " in file "
|
|
||||||
<< this->internalField().objectPath()
|
|
||||||
<< exit(FatalIOError);
|
|
||||||
}
|
|
||||||
|
|
||||||
sphTensorFields_.insert(key, fPtr);
|
|
||||||
}
|
|
||||||
else if
|
|
||||||
(
|
|
||||||
fieldToken.compoundToken().type()
|
|
||||||
== token::Compound<List<symmTensor>>::typeName
|
|
||||||
)
|
|
||||||
{
|
|
||||||
auto fPtr = autoPtr<symmTensorField>::New();
|
|
||||||
|
|
||||||
fPtr->transfer
|
|
||||||
(
|
|
||||||
dynamicCast
|
|
||||||
<
|
|
||||||
token::Compound<List<symmTensor>>
|
|
||||||
>
|
|
||||||
(
|
|
||||||
fieldToken.transferCompoundToken(is)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
if (fPtr->size() != this->size())
|
|
||||||
{
|
|
||||||
FatalIOErrorInFunction(dict)
|
|
||||||
<< "\n size of field " << key
|
|
||||||
<< " (" << fPtr->size() << ')'
|
|
||||||
<< " is not the same size as the patch ("
|
|
||||||
<< this->size() << ')'
|
|
||||||
<< "\n on patch " << this->patch().name()
|
|
||||||
<< " of field "
|
|
||||||
<< this->internalField().name()
|
|
||||||
<< " in file "
|
|
||||||
<< this->internalField().objectPath()
|
|
||||||
<< exit(FatalIOError);
|
|
||||||
}
|
|
||||||
|
|
||||||
symmTensorFields_.insert(key, fPtr);
|
|
||||||
}
|
|
||||||
else if
|
|
||||||
(
|
|
||||||
fieldToken.compoundToken().type()
|
|
||||||
== token::Compound<List<tensor>>::typeName
|
|
||||||
)
|
|
||||||
{
|
|
||||||
auto fPtr = autoPtr<tensorField>::New();
|
|
||||||
|
|
||||||
fPtr->transfer
|
|
||||||
(
|
|
||||||
dynamicCast<token::Compound<List<tensor>>>
|
|
||||||
(
|
|
||||||
fieldToken.transferCompoundToken(is)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
if (fPtr->size() != this->size())
|
|
||||||
{
|
|
||||||
FatalIOErrorInFunction(dict)
|
|
||||||
<< "\n size of field " << key
|
|
||||||
<< " (" << fPtr->size() << ')'
|
|
||||||
<< " is not the same size as the patch ("
|
|
||||||
<< this->size() << ')'
|
|
||||||
<< "\n on patch " << this->patch().name()
|
|
||||||
<< " of field "
|
|
||||||
<< this->internalField().name()
|
|
||||||
<< " in file "
|
|
||||||
<< this->internalField().objectPath()
|
|
||||||
<< exit(FatalIOError);
|
|
||||||
}
|
|
||||||
|
|
||||||
tensorFields_.insert(key, fPtr);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
FatalIOErrorInFunction(dict)
|
|
||||||
<< "\n compound " << fieldToken.compoundToken()
|
|
||||||
<< " not supported"
|
|
||||||
<< "\n on patch " << this->patch().name()
|
|
||||||
<< " of field "
|
|
||||||
<< this->internalField().name()
|
|
||||||
<< " in file "
|
|
||||||
<< this->internalField().objectPath()
|
|
||||||
<< exit(FatalIOError);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
FatalIOErrorInFunction(dict)
|
||||||
|
<< "\n token following 'nonuniform' "
|
||||||
|
"is not a compound"
|
||||||
|
<< "\n on patch " << this->patch().name()
|
||||||
|
<< " of field "
|
||||||
|
<< this->internalField().name()
|
||||||
|
<< " in file "
|
||||||
|
<< this->internalField().objectPath() << nl
|
||||||
|
<< exit(FatalIOError);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if
|
||||||
|
(
|
||||||
|
fieldToken.compoundToken().type()
|
||||||
|
== token::Compound<List<scalar>>::typeName
|
||||||
|
)
|
||||||
|
{
|
||||||
|
auto fPtr = autoPtr<scalarField>::New();
|
||||||
|
|
||||||
|
fPtr->transfer
|
||||||
|
(
|
||||||
|
dynamicCast<token::Compound<List<scalar>>>
|
||||||
|
(
|
||||||
|
fieldToken.transferCompoundToken(is)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
if (fPtr->size() != patchSize)
|
||||||
|
{
|
||||||
|
FatalIOErrorInFunction(dict)
|
||||||
|
<< "\n size of field " << key
|
||||||
|
<< " (" << fPtr->size() << ')'
|
||||||
|
<< " is not the same size as the patch ("
|
||||||
|
<< patchSize << ')'
|
||||||
|
<< "\n on patch " << this->patch().name()
|
||||||
|
<< " of field "
|
||||||
|
<< this->internalField().name()
|
||||||
|
<< " in file "
|
||||||
|
<< this->internalField().objectPath() << nl
|
||||||
|
<< exit(FatalIOError);
|
||||||
|
}
|
||||||
|
|
||||||
|
scalarFields_.insert(key, fPtr);
|
||||||
|
}
|
||||||
|
else if
|
||||||
|
(
|
||||||
|
fieldToken.compoundToken().type()
|
||||||
|
== token::Compound<List<vector>>::typeName
|
||||||
|
)
|
||||||
|
{
|
||||||
|
auto fPtr = autoPtr<vectorField>::New();
|
||||||
|
|
||||||
|
fPtr->transfer
|
||||||
|
(
|
||||||
|
dynamicCast<token::Compound<List<vector>>>
|
||||||
|
(
|
||||||
|
fieldToken.transferCompoundToken(is)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
if (fPtr->size() != patchSize)
|
||||||
|
{
|
||||||
|
FatalIOErrorInFunction(dict)
|
||||||
|
<< "\n size of field " << key
|
||||||
|
<< " (" << fPtr->size() << ')'
|
||||||
|
<< " is not the same size as the patch ("
|
||||||
|
<< patchSize << ')'
|
||||||
|
<< "\n on patch " << this->patch().name()
|
||||||
|
<< " of field "
|
||||||
|
<< this->internalField().name()
|
||||||
|
<< " in file "
|
||||||
|
<< this->internalField().objectPath() << nl
|
||||||
|
<< exit(FatalIOError);
|
||||||
|
}
|
||||||
|
|
||||||
|
vectorFields_.insert(key, fPtr);
|
||||||
|
}
|
||||||
|
else if
|
||||||
|
(
|
||||||
|
fieldToken.compoundToken().type()
|
||||||
|
== token::Compound<List<sphericalTensor>>::typeName
|
||||||
|
)
|
||||||
|
{
|
||||||
|
auto fPtr = autoPtr<sphericalTensorField>::New();
|
||||||
|
|
||||||
|
fPtr->transfer
|
||||||
|
(
|
||||||
|
dynamicCast<token::Compound<List<sphericalTensor>>>
|
||||||
|
(
|
||||||
|
fieldToken.transferCompoundToken(is)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
if (fPtr->size() != patchSize)
|
||||||
|
{
|
||||||
|
FatalIOErrorInFunction(dict)
|
||||||
|
<< "\n size of field " << key
|
||||||
|
<< " (" << fPtr->size() << ')'
|
||||||
|
<< " is not the same size as the patch ("
|
||||||
|
<< patchSize << ')'
|
||||||
|
<< "\n on patch " << this->patch().name()
|
||||||
|
<< " of field "
|
||||||
|
<< this->internalField().name()
|
||||||
|
<< " in file "
|
||||||
|
<< this->internalField().objectPath() << nl
|
||||||
|
<< exit(FatalIOError);
|
||||||
|
}
|
||||||
|
|
||||||
|
sphTensorFields_.insert(key, fPtr);
|
||||||
|
}
|
||||||
|
else if
|
||||||
|
(
|
||||||
|
fieldToken.compoundToken().type()
|
||||||
|
== token::Compound<List<symmTensor>>::typeName
|
||||||
|
)
|
||||||
|
{
|
||||||
|
auto fPtr = autoPtr<symmTensorField>::New();
|
||||||
|
|
||||||
|
fPtr->transfer
|
||||||
|
(
|
||||||
|
dynamicCast<token::Compound<List<symmTensor>>>
|
||||||
|
(
|
||||||
|
fieldToken.transferCompoundToken(is)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
if (fPtr->size() != patchSize)
|
||||||
|
{
|
||||||
|
FatalIOErrorInFunction(dict)
|
||||||
|
<< "\n size of field " << key
|
||||||
|
<< " (" << fPtr->size() << ')'
|
||||||
|
<< " is not the same size as the patch ("
|
||||||
|
<< patchSize << ')'
|
||||||
|
<< "\n on patch " << this->patch().name()
|
||||||
|
<< " of field "
|
||||||
|
<< this->internalField().name()
|
||||||
|
<< " in file "
|
||||||
|
<< this->internalField().objectPath() << nl
|
||||||
|
<< exit(FatalIOError);
|
||||||
|
}
|
||||||
|
|
||||||
|
symmTensorFields_.insert(key, fPtr);
|
||||||
|
}
|
||||||
|
else if
|
||||||
|
(
|
||||||
|
fieldToken.compoundToken().type()
|
||||||
|
== token::Compound<List<tensor>>::typeName
|
||||||
|
)
|
||||||
|
{
|
||||||
|
auto fPtr = autoPtr<tensorField>::New();
|
||||||
|
|
||||||
|
fPtr->transfer
|
||||||
|
(
|
||||||
|
dynamicCast<token::Compound<List<tensor>>>
|
||||||
|
(
|
||||||
|
fieldToken.transferCompoundToken(is)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
if (fPtr->size() != patchSize)
|
||||||
|
{
|
||||||
|
FatalIOErrorInFunction(dict)
|
||||||
|
<< "\n size of field " << key
|
||||||
|
<< " (" << fPtr->size() << ')'
|
||||||
|
<< " is not the same size as the patch ("
|
||||||
|
<< patchSize << ')'
|
||||||
|
<< "\n on patch " << this->patch().name()
|
||||||
|
<< " of field "
|
||||||
|
<< this->internalField().name()
|
||||||
|
<< " in file "
|
||||||
|
<< this->internalField().objectPath() << nl
|
||||||
|
<< exit(FatalIOError);
|
||||||
|
}
|
||||||
|
|
||||||
|
tensorFields_.insert(key, fPtr);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
FatalIOErrorInFunction(dict)
|
||||||
|
<< "\n compound " << fieldToken.compoundToken()
|
||||||
|
<< " not supported"
|
||||||
|
<< "\n on patch " << this->patch().name()
|
||||||
|
<< " of field "
|
||||||
|
<< this->internalField().name()
|
||||||
|
<< " in file "
|
||||||
|
<< this->internalField().objectPath() << nl
|
||||||
|
<< exit(FatalIOError);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -488,41 +480,42 @@ void Foam::genericPointPatchField<Type>::write(Ostream& os) const
|
|||||||
{
|
{
|
||||||
const keyType& key = dEntry.keyword();
|
const keyType& key = dEntry.keyword();
|
||||||
|
|
||||||
if (key != "type")
|
if (key == "type" || key == "value")
|
||||||
{
|
{
|
||||||
if
|
continue;
|
||||||
(
|
}
|
||||||
dEntry.isStream()
|
else if
|
||||||
&& dEntry.stream().size()
|
(
|
||||||
&& dEntry.stream()[0].isWord()
|
dEntry.isStream()
|
||||||
&& dEntry.stream()[0].wordToken() == "nonuniform"
|
&& dEntry.stream().size()
|
||||||
)
|
&& dEntry.stream()[0].isWord()
|
||||||
|
&& dEntry.stream()[0].wordToken() == "nonuniform"
|
||||||
|
)
|
||||||
|
{
|
||||||
|
if (scalarFields_.found(key))
|
||||||
{
|
{
|
||||||
if (scalarFields_.found(key))
|
scalarFields_.cfind(key)()->writeEntry(key, os);
|
||||||
{
|
|
||||||
scalarFields_.find(key)()->writeEntry(key, os);
|
|
||||||
}
|
|
||||||
else if (vectorFields_.found(key))
|
|
||||||
{
|
|
||||||
vectorFields_.find(key)()->writeEntry(key, os);
|
|
||||||
}
|
|
||||||
else if (sphTensorFields_.found(key))
|
|
||||||
{
|
|
||||||
sphTensorFields_.find(key)()->writeEntry(key, os);
|
|
||||||
}
|
|
||||||
else if (symmTensorFields_.found(key))
|
|
||||||
{
|
|
||||||
symmTensorFields_.find(key)()->writeEntry(key, os);
|
|
||||||
}
|
|
||||||
else if (tensorFields_.found(key))
|
|
||||||
{
|
|
||||||
tensorFields_.find(key)()->writeEntry(key, os);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else if (vectorFields_.found(key))
|
||||||
{
|
{
|
||||||
dEntry.write(os);
|
vectorFields_.cfind(key)()->writeEntry(key, os);
|
||||||
}
|
}
|
||||||
|
else if (sphTensorFields_.found(key))
|
||||||
|
{
|
||||||
|
sphTensorFields_.cfind(key)()->writeEntry(key, os);
|
||||||
|
}
|
||||||
|
else if (symmTensorFields_.found(key))
|
||||||
|
{
|
||||||
|
symmTensorFields_.cfind(key)()->writeEntry(key, os);
|
||||||
|
}
|
||||||
|
else if (tensorFields_.found(key))
|
||||||
|
{
|
||||||
|
tensorFields_.cfind(key)()->writeEntry(key, os);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
dEntry.write(os);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -3916,7 +3916,7 @@ void Foam::snappyLayerDriver::addLayers
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
Perr<< "\nFOAM exiting\n" << endl;
|
Perr<< "\nFOAM exiting\n" << endl;
|
||||||
::exit(0);
|
std::exit(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -253,8 +253,17 @@ void Foam::PatchFunction1Types::ConstantField<Type>::writeData
|
|||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
PatchFunction1<Type>::writeData(os);
|
PatchFunction1<Type>::writeData(os);
|
||||||
//os << token::SPACE << value_ << token::END_STATEMENT << nl;
|
|
||||||
value_.writeEntry(this->name_, os);
|
if (isUniform_)
|
||||||
|
{
|
||||||
|
os.writeKeyword(this->name_)
|
||||||
|
<< "constant " << uniformValue_
|
||||||
|
<< token::END_STATEMENT << nl;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
value_.writeEntry(this->name_, os);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -41,7 +41,8 @@ wmakeLnInclude -u decompositionMethods
|
|||||||
if have_scotch
|
if have_scotch
|
||||||
then
|
then
|
||||||
wmake $targetType scotchDecomp
|
wmake $targetType scotchDecomp
|
||||||
if [ -d "$FOAM_LIBBIN/$FOAM_MPI" ]
|
|
||||||
|
if have_ptscotch
|
||||||
then
|
then
|
||||||
wmakeMpiLib "$SCOTCH_VERSION" ptscotchDecomp
|
wmakeMpiLib "$SCOTCH_VERSION" ptscotchDecomp
|
||||||
fi
|
fi
|
||||||
|
|||||||
@ -1,13 +1,12 @@
|
|||||||
/*
|
/*
|
||||||
* NB: mplib PINC must appear after the SCOTCH_ARCH_PATH/include/FOAM_MPI
|
* NB: mplib PINC must appear after PTSCOTCH_INC_DIR to ensure we
|
||||||
* to ensure we do not accidentally get a ptscotch header from the
|
* do not accidentally get a ptscotch header from the MPI distribution.
|
||||||
* mpi distribution.
|
|
||||||
*/
|
*/
|
||||||
sinclude $(GENERAL_RULES)/mplib$(WM_MPLIB)
|
sinclude $(GENERAL_RULES)/mplib$(WM_MPLIB)
|
||||||
sinclude $(DEFAULT_RULES)/mplib$(WM_MPLIB)
|
sinclude $(DEFAULT_RULES)/mplib$(WM_MPLIB)
|
||||||
|
|
||||||
EXE_INC = \
|
EXE_INC = \
|
||||||
-I$(SCOTCH_ARCH_PATH)/include/$(FOAM_MPI) \
|
-I$(PTSCOTCH_INC_DIR) \
|
||||||
-I$(SCOTCH_INC_DIR) \
|
-I$(SCOTCH_INC_DIR) \
|
||||||
$(PFLAGS) $(PINC) \
|
$(PFLAGS) $(PINC) \
|
||||||
-I../decompositionMethods/lnInclude
|
-I../decompositionMethods/lnInclude
|
||||||
@ -17,9 +16,8 @@ EXE_INC = \
|
|||||||
* ptscotch 6 requires scotch linked in, but does not declare the dependency
|
* ptscotch 6 requires scotch linked in, but does not declare the dependency
|
||||||
*/
|
*/
|
||||||
LIB_LIBS = \
|
LIB_LIBS = \
|
||||||
|
-L$(PTSCOTCH_LIB_DIR) \
|
||||||
-L$(SCOTCH_LIB_DIR) \
|
-L$(SCOTCH_LIB_DIR) \
|
||||||
-L$(FOAM_EXT_LIBBIN)/$(FOAM_MPI) \
|
|
||||||
-L$(FOAM_EXT_LIBBIN) \
|
|
||||||
-lptscotch -lptscotcherrexit \
|
-lptscotch -lptscotcherrexit \
|
||||||
-lscotch
|
-lscotch
|
||||||
|
|
||||||
|
|||||||
@ -384,9 +384,11 @@ bool Foam::surfaceWriter::expire()
|
|||||||
|
|
||||||
upToDate_ = false;
|
upToDate_ = false;
|
||||||
wroteGeom_ = false;
|
wroteGeom_ = false;
|
||||||
nFields_ = 0;
|
|
||||||
merged_.clear();
|
merged_.clear();
|
||||||
|
|
||||||
|
// Field count (nFields_) is a different type of accounting
|
||||||
|
// and is unaffected by geometry changes
|
||||||
|
|
||||||
return changed;
|
return changed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user