Compare commits

..

1 Commits

Author SHA1 Message Date
bc5a55f7e6 ENH: regIOobject: factory method from IO.
- compiles
- deepClone (not needed at the moment)
- objectRegistry::subRegistry with fileName
- Time::null object so IOobject can be constructed
  without objectRegistry
2024-01-11 15:15:34 +01:00
1447 changed files with 13815 additions and 39150 deletions

View File

@ -49,7 +49,7 @@
<!--
Providing details of your set-up can help us identify any issues, e.g.
OpenFOAM version : v2112|v2106|v2012|v2006|v1912|v1906 etc
OpenFOAM version : v1806|v1812|v1906|v1912|v2006|v2012|v2106 etc
Operating system : ubuntu|openSUSE|centos etc
Hardware info : any info that may help?
Compiler : gcc|intel|clang etc

View File

@ -1,2 +1,2 @@
api=2109
api=2108
patch=0

View File

@ -40,9 +40,9 @@ Violations of the Trademark are monitored, and will be duly prosecuted.
If OpenFOAM has already been compiled on your system, simply source
the appropriate `etc/bashrc` or `etc/cshrc` file and get started.
For example, for the OpenFOAM-v2112 version:
For example, for the OpenFOAM-v2106 version:
```
source /installation/path/OpenFOAM-v2112/etc/bashrc
source /installation/path/OpenFOAM-v2106/etc/bashrc
```
## Compiling OpenFOAM
@ -127,8 +127,8 @@ These 3rd-party sources are normally located in a directory parallel
to the OpenFOAM directory. For example,
```
/path/parent
|-- OpenFOAM-v2112
\-- ThirdParty-v2112
|-- OpenFOAM-v2106
\-- ThirdParty-v2106
```
There are, however, many cases where this simple convention is inadequate:
@ -136,7 +136,7 @@ There are, however, many cases where this simple convention is inadequate:
operating system or cluster installation provides it)
* When we have changed the OpenFOAM directory name to some arbitrary
directory name, e.g. openfoam-sandbox2112, etc..
directory name, e.g. openfoam-sandbox2106, etc..
* When we would like any additional 3rd party software to be located
inside of the OpenFOAM directory to ensure that the installation is
@ -156,9 +156,9 @@ when locating the ThirdParty directory with the following precedence:
2. PREFIX/ThirdParty-VERSION
* this corresponds to the traditional approach
3. PREFIX/ThirdParty-vAPI
* allows for an updated value of VERSION, *eg*, `v2112-myCustom`,
* allows for an updated value of VERSION, *eg*, `v2106-myCustom`,
without requiring a renamed ThirdParty. The API value would still
be `2112` and the original `ThirdParty-v2112/` would be found.
be `2106` and the original `ThirdParty-v2106/` would be found.
4. PREFIX/ThirdParty-API
* same as the previous example, but using an unadorned API value.
5. PREFIX/ThirdParty-common

View File

@ -138,6 +138,13 @@ public:
const surfaceScalarField& phi
);
//- Return a clone
virtual refPtr<regIOobject> deepClone() const
{
NotImplemented;
return nullptr;
}
//- Destructor
virtual ~PDRDragModel();

View File

@ -49,7 +49,7 @@
);
}
// Update the boundary values of the reciprocal time-step
// Update tho boundary values of the reciprocal time-step
rDeltaT.correctBoundaryConditions();
Info<< "Flow time scale min/max = "

View File

@ -1,5 +1,3 @@
#include "createRDeltaT.H"
Info<< "Reading field p\n" << endl;
volScalarField p
(

View File

@ -81,8 +81,6 @@ Note
#include "pimpleControl.H"
#include "CorrectPhi.H"
#include "fvOptions.H"
#include "localEulerDdtScheme.H"
#include "fvcSmooth.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -109,12 +107,6 @@ int main(int argc, char *argv[])
turbulence->validate();
if (!LTS)
{
#include "CourantNo.H"
#include "setInitialDeltaT.H"
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
Info<< "\nStarting time loop\n" << endl;
@ -122,16 +114,8 @@ int main(int argc, char *argv[])
while (runTime.run())
{
#include "readDyMControls.H"
if (LTS)
{
#include "setRDeltaT.H"
}
else
{
#include "CourantNo.H"
#include "setDeltaT.H"
}
#include "CourantNo.H"
#include "setDeltaT.H"
++runTime;

View File

@ -1,69 +0,0 @@
{
volScalarField& rDeltaT = trDeltaT.ref();
const dictionary& pimpleDict = pimple.dict();
scalar maxCo
(
pimpleDict.getOrDefault<scalar>("maxCo", 0.8)
);
scalar rDeltaTSmoothingCoeff
(
pimpleDict.getOrDefault<scalar>("rDeltaTSmoothingCoeff", 0.02)
);
scalar rDeltaTDampingCoeff
(
pimpleDict.getOrDefault<scalar>("rDeltaTDampingCoeff", 1.0)
);
scalar maxDeltaT
(
pimpleDict.getOrDefault<scalar>("maxDeltaT", GREAT)
);
volScalarField rDeltaT0("rDeltaT0", rDeltaT);
// Set the reciprocal time-step from the local Courant number
rDeltaT.ref() = max
(
1/dimensionedScalar("maxDeltaT", dimTime, maxDeltaT),
fvc::surfaceSum(mag(phi))()()
/((2*maxCo)*mesh.V())
);
// Update the boundary values of the reciprocal time-step
rDeltaT.correctBoundaryConditions();
Info<< "Flow time scale min/max = "
<< gMin(1/rDeltaT.primitiveField())
<< ", " << gMax(1/rDeltaT.primitiveField()) << endl;
if (rDeltaTSmoothingCoeff < 1.0)
{
fvc::smooth(rDeltaT, rDeltaTSmoothingCoeff);
}
Info<< "Smoothed flow time scale min/max = "
<< gMin(1/rDeltaT.primitiveField())
<< ", " << gMax(1/rDeltaT.primitiveField()) << endl;
// Limit rate of change of time scale
// - reduce as much as required
// - only increase at a fraction of old time scale
if
(
rDeltaTDampingCoeff < 1.0
&& runTime.timeIndex() > runTime.startTimeIndex() + 1
)
{
rDeltaT =
rDeltaT0
*max(rDeltaT/rDeltaT0, scalar(1) - rDeltaTDampingCoeff);
Info<< "Damped flow time scale min/max = "
<< gMin(1/rDeltaT.primitiveField())
<< ", " << gMax(1/rDeltaT.primitiveField()) << endl;
}
}

View File

@ -123,7 +123,7 @@ Foam::fv::VoFSolidificationMeltingSource::VoFSolidificationMeltingSource
)
:
fv::cellSetOption(sourceName, modelType, dict, mesh),
alphaSolidT_(Function1<scalar>::New("alphaSolidT", coeffs_, &mesh)),
alphaSolidT_(Function1<scalar>::New("alphaSolidT", coeffs_)),
L_("L", dimEnergy/dimMass, coeffs_),
relax_(coeffs_.getOrDefault("relax", 0.9)),
Cu_(coeffs_.getOrDefault<scalar>("Cu", 100000)),

View File

@ -33,7 +33,7 @@ bool Foam::fv::VoFSolidificationMeltingSource::read(const dictionary& dict)
{
if (fv::cellSetOption::read(dict))
{
alphaSolidT_ = Function1<scalar>::New("alphaSolidT", coeffs_, &mesh_);
alphaSolidT_ = Function1<scalar>::New("alphaSolidT", coeffs_);
coeffs_.readEntry("L", L_);
coeffs_.readIfPresent("relax", relax_);
coeffs_.readIfPresent("Cu", Cu_);

View File

@ -11,6 +11,7 @@ EXE_INC = \
-I$(LIB_SRC)/transportModels/compressible/lnInclude \
-I$(LIB_SRC)/TurbulenceModels/turbulenceModels/lnInclude \
-I$(LIB_SRC)/TurbulenceModels/compressible/lnInclude \
-I$(LIB_SRC)/transportModels/interfaceProperties/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/radiation/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/basic/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/specie/lnInclude \

View File

@ -343,12 +343,12 @@ Foam::radiation::laserDTRM::laserDTRM(const volScalarField& T)
focalLaserPosition_
(
Function1<point>::New("focalLaserPosition", *this, &mesh_)
Function1<point>::New("focalLaserPosition", *this)
),
laserDirection_
(
Function1<vector>::New("laserDirection", *this, &mesh_)
Function1<vector>::New("laserDirection", *this)
),
focalLaserRadius_(get<scalar>("focalLaserRadius")),
@ -359,7 +359,7 @@ Foam::radiation::laserDTRM::laserDTRM(const volScalarField& T)
sigma_(0),
I0_(0),
laserPower_(Function1<scalar>::New("laserPower", *this, &mesh_)),
laserPower_(Function1<scalar>::New("laserPower", *this)),
powerDistribution_(),
reflectionSwitch_(false),
@ -441,11 +441,11 @@ Foam::radiation::laserDTRM::laserDTRM
focalLaserPosition_
(
Function1<point>::New("focalLaserPosition", *this, &mesh_)
Function1<point>::New("focalLaserPosition", *this)
),
laserDirection_
(
Function1<vector>::New("laserDirection", *this, &mesh_)
Function1<vector>::New("laserDirection", *this)
),
focalLaserRadius_(get<scalar>("focalLaserRadius")),
@ -456,7 +456,7 @@ Foam::radiation::laserDTRM::laserDTRM
sigma_(0),
I0_(0),
laserPower_(Function1<scalar>::New("laserPower", *this, &mesh_)),
laserPower_(Function1<scalar>::New("laserPower", *this)),
powerDistribution_(),
reflectionSwitch_(false),

View File

@ -1,7 +1,7 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v2112 |
| \\ / O peration | Version: v2106 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
@ -138,53 +138,4 @@ cosine6
}
expr1
{
type expression;
functions<scalar>
{
func1 constant 21;
func2 constant 15;
sin constant -5;
}
functions<vector>
{
vfunc3 constant (1 2 3);
vfunc4 constant (3 2 1);
}
expression
#{
100 * fn:vfunc3() & fn:vfunc4() * (vector::z) .z()
* (fn:sin(arg()) + fn:func1(fn:func2()))
#};
}
expr2
{
type expression;
functions<scalar>
{
func1 constant 21;
func2 constant 15;
sin constant -5;
}
functions<vector>
{
vfunc3 constant (1 2 3);
vfunc4 constant (3 2 1);
}
expression
#{
(fn:vfunc3() & vector::z) * arg()
#};
}
// ************************************************************************* //

View File

@ -121,9 +121,6 @@ int main(int argc, char *argv[])
argList::addArgument("label");
argList::noMandatoryArgs();
argList::addDryRunOption("Just for testing");
argList::addVerboseOption("Increase verbosity");
#include "setRootCase.H"
Pout<< "command-line ("
@ -136,10 +133,6 @@ int main(int argc, char *argv[])
<< "globalPath: " << args.globalPath() << nl
<< nl;
Pout<< "dry-run: " << args.dryRun()
<< " verbose: " << args.verbose() << nl;
if (args.found("relative"))
{
Pout<< "input path: " << args["relative"] << nl

View File

@ -57,8 +57,9 @@ int main(int argc, char *argv[])
#include "addAllRegionOptions.H"
argList::addVerboseOption
argList::addBoolOption
(
"verbose",
"more information about decomposition"
);
@ -70,6 +71,7 @@ int main(int argc, char *argv[])
#include "setRootCase.H"
const auto decompFile = args.get<fileName>(1);
const bool verbose = args.found("verbose");
// Set time from database
#include "createTime.H"
@ -144,7 +146,7 @@ int main(int argc, char *argv[])
nDomains
);
if (args.verbose())
if (verbose)
{
info.printDetails(Info);
Info<< nl;

View File

@ -18,8 +18,6 @@ FoamFile
#sinclude "$FOAM_CASE/someUnknownFile"
#includeIfPresent "$FOAM_CASE/someUnknownFile-$FOAM_CASENAME"
zeroVelocity uniform (0 0 0);
internalField uniform 1;
// supply defaults
@ -50,7 +48,7 @@ x 5;
varName x;
// Indirection for keys
//Indirection for keys
key inlet_9;
@ -69,17 +67,13 @@ boundaryField
inlet_5 { $inactive }
inlet_6a { $...inactive } // Relative scoping - fairly horrible to use
inlet_6b { $^inactive } // Absolute scoping
inlet_6c { key ${/key}; } // Absolute scoping
inlet_7 { ${inactive}} // Test variable expansion
inlet_8 { $inactive }
// Variable expansion for a keyword
${key} { $inactive }
#include "testDictInc"
outletBase
outlet
{
type inletOutlet;
inletValue $internalField;
@ -89,36 +83,16 @@ boundaryField
y 6;
}
outlet
{
$outletBase
}
Default_Boundary_Region
{
valueOut $zeroVelocity;
}
// this should have no effect (not in scope)
// this should have no effect
#remove inactive
// But this should work to remove things in different scopes
#remove "/zeroVelocity"
inlet_7 { ${inactive} } // Test variable expansion
inlet_8 { $inactive }
inlet_7a { ${${varType}} } // Test indirection/recursive expansion
inlet_7b { ${${varType}} } // Test indirection/recursive expansion
inlet_7 { ${${varType}}} // Test indirection/recursive expansion
inlet_8 { $active }
#overwrite inlet_8 { type none; }
}
// No patterns with scoped removal
// #remove "/boundaryField/outletB.*"
#remove "/boundaryField/outletBase"
#include "testDict2"
verbatim #{
@ -149,25 +123,10 @@ baz
$active
}
// This should work
#remove x
// this should work
#remove active
// This should work too
// this should work too
#remove ( bar baz )
// Remove a sub-dictionary entry
#remove "/anynumber.*/value"
// Removal does not auto-vivify
#remove "/nonExistentDict/value"
// Add into existing dictionary
"/anynumber.*/someValue" 100;
// Auto-vivify
// - but currently cannot auto-vivify entries with dictionary patterns
"/abd/someValue" 100;
"/def/'someValue.*" 100;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -1,3 +0,0 @@
Test-exprTraits.C
EXE = $(FOAM_USER_APPBIN)/Test-exprTraits

View File

@ -1,2 +0,0 @@
/* EXE_INC = */
/* EXE_LIBS = */

View File

@ -1,108 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
Description
Basic tests of expression traits
\*---------------------------------------------------------------------------*/
#include "IOstreams.H"
#include "ITstream.H"
#include "exprTraits.H"
#include "uLabel.H"
#include "error.H"
#include "stringList.H"
#include "exprScanToken.H"
using namespace Foam;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
template<class T>
void printTraits()
{
const auto typeCode = exprTypeTraits<T>::value;
Info<< "type " << pTraits<T>::typeName
<< " code:" << int(typeCode)
<< " name:" << exprTypeTraits<T>::name;
if (pTraits<T>::typeName != word(exprTypeTraits<T>::name))
{
Info<< " (UNSUPPORTED)";
}
Info << endl;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
int main()
{
Info<< nl << "Traits:" << nl;
printTraits<word>();
printTraits<string>();
printTraits<bool>();
printTraits<label>();
printTraits<scalar>();
printTraits<vector>();
printTraits<tensor>();
printTraits<symmTensor>();
printTraits<sphericalTensor>();
const auto getName = nameOp<expressions::valueTypeCode>();
Info<< nl;
Info<< "Name of typeCode: "
<< Foam::name(expressions::valueTypeCode::type_scalar) << nl;
Info<< "Name of typeCode: "
<< getName(expressions::valueTypeCode::type_bool) << nl;
{
expressions::scanToken tok;
expressions::scanToken tok2;
Info<< nl << "sizeof(scanToken): "
<< sizeof(tok) << nl;
Info<< " type:" << int(tok.type_) << nl;
Info<< " ptr:" << Foam::name(tok.name_) << nl;
Info<< " type:" << int(tok2.type_) << nl;
Info<< " ptr:" << Foam::name(tok2.name_) << nl;
tok.setWord("hello");
Info<< " type:" << int(tok.type_) << nl;
Info<< " ptr:" << Foam::name(tok.name_) << nl;
tok2 = tok;
Info<< " type:" << int(tok2.type_) << nl;
Info<< " ptr:" << Foam::name(tok2.name_) << nl;
tok2.destroy();
Info<< " type:" << int(tok2.type_) << nl;
Info<< " ptr:" << Foam::name(tok2.name_) << nl;
}
Info<< nl << "Done" << nl;
return 0;
}
// ************************************************************************* //

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011 OpenFOAM Foundation
Copyright (C) 2017-2021 OpenCFD Ltd.
Copyright (C) 2017-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -56,7 +56,7 @@ int main(int argc, char *argv[])
argList::noParallel();
argList::noFunctionObjects();
argList::addArgument("start size .. startN sizeN");
argList::addVerbose("enable labelRange::debug");
argList::addOption("verbose");
argList::addNote
(
"The default is to add ranges, use 'add' and 'del' to toggle\n\n"
@ -65,7 +65,7 @@ int main(int argc, char *argv[])
argList args(argc, argv, false, true);
if (args.verbose())
if (args.found("verbose"))
{
labelRange::debug = 1;
}

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2016-2021 OpenCFD Ltd.
Copyright (C) 2016-2018 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -146,9 +146,6 @@ int main(int argc, char *argv[])
const objectRegistry& db = (optMesh ? mesh.thisDb() : runTime);
Info<<"## start ##" << nl;
Info<< "db isTime:" << db.isTimeDb() << " addr:" << Foam::name(&db)
<< " time: " << Foam::name(&(db.time())) << nl;
printRegistry(Info, db);
Info<< nl;

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2019-2021 OpenCFD Ltd.
Copyright (C) 2019 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -124,13 +124,16 @@ int main(int argc, char *argv[])
"(vector angle)",
"Rotate about the <vector> by <angle> degrees - eg, '((1 0 0) 45)'"
);
argList::addVerboseOption
argList::addBoolOption
(
"Report euler angles"
"verbose",
"Additional verbosity"
);
argList args(argc, argv);
const bool verbose = args.found("verbose");
vector rotVector;
@ -324,7 +327,7 @@ int main(int argc, char *argv[])
tensor rotQ(quaternion(order, angles).R());
tensor rotE(euler::rotation(order, angles, false));
if (args.verbose())
if (verbose)
{
Info<< "euler " << orderName << angles << nl;
printRotation(rotE);

View File

@ -32,22 +32,14 @@ struct myScalarField : public scalarField
template<class T>
void printInfo(const refPtr<T>& item, const bool verbose = false)
{
Info<< "refPtr good:" << Switch::name(item.good())
Info<< "refPtr valid:" << Switch::name(item.valid())
<< " pointer:" << Switch::name(item.is_pointer())
<< " addr: " << Foam::name(item.get())
<< " addr: " << name(item.get())
<< " movable:" << Switch(item.movable());
Info<< " move-constructible:"
<< std::is_move_constructible<refPtr<T>>::value
<< " move-assignable:"
<< std::is_move_assignable<refPtr<T>>::value
<< " nothrow:"
<< std::is_nothrow_move_assignable<refPtr<T>>::value
<< " trivially:"
<< std::is_trivially_move_assignable<refPtr<T>>::value
<< nl;
Info<< nl;
if (verbose && item)
if (verbose && item.valid())
{
Info<< "content: " << item() << nl;
}

View File

@ -252,16 +252,12 @@ void testExpressions(const UList<regexTest>& tests)
}
else if (re.search(str))
{
Info<< "partial";
Info<< "partial match";
}
else
{
Info<< "false";
}
if (re.negated())
{
Info<< " (negated)";
}
Info<< endl;
}
catch (const Foam::error& err)
@ -333,15 +329,6 @@ int main(int argc, char *argv[])
}
#endif
Info<< "sizeof std::regex: " << sizeof(std::regex) << nl;
Info<< "sizeof regex C++11: " << sizeof(regExpCxx) << nl;
#ifndef _WIN32
Info<< "sizeof regex POSIX: " << sizeof(regExpPosix) << nl;
#endif
Info<< "sizeof word: " << sizeof(Foam::word) << nl;
Info<< "sizeof wordRe: " << sizeof(Foam::wordRe) << nl;
Info<< "sizeof keyType: " << sizeof(Foam::keyType) << nl;
if (!args.count({"cxx", "posix"}))
{
args.setOption("cxx");

View File

@ -1,7 +1,7 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v2112 |
| \\ / O peration | Version: v2106 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
@ -12,8 +12,6 @@
(
( true "(U|k|epsilon)" "U" )
( false "(U|k|epsilon)" "alpha" )
( true "(?!)(U|k|epsilon)" "alpha" )
( true "(?! *&)(U|k|epsilon)" "alpha" ) // Ignore unknown content
( true "ab.*" "abc" )
( true ".*" "abc" )

View File

@ -39,7 +39,6 @@ Description
#include "argList.H"
#include "Time.H"
#include "IOobject.H"
#include "scalarField.H"
namespace Foam
{
@ -140,8 +139,6 @@ int main(int argc, char *argv[])
cout<<"PstreamBuffers:" << sizeof(Foam::PstreamBuffers) << nl;
cout<<"Time:" << sizeof(Foam::Time) << nl;
cout<<"tmp<>:" << sizeof(tmp<scalarField>) << nl;
Info << "---\nEnd\n" << endl;
return 0;

View File

@ -32,26 +32,18 @@ struct myScalarField : public scalarField
template<class T>
void printInfo(const tmp<T>& item, const bool verbose = false)
{
Info<< "tmp good:" << Switch::name(item.good())
Info<< "tmp valid:" << Switch::name(item.valid())
<< " pointer:" << Switch::name(item.is_pointer())
<< " addr: " << Foam::name(item.get())
<< " addr: " << name(item.get())
<< " movable:" << Switch(item.movable());
if (item)
if (item.valid())
{
Info<< " refCount:" << item->count();
}
Info<< nl;
Info<< " move-constructible:"
<< std::is_move_constructible<tmp<T>>::value
<< " move-assignable:"
<< std::is_move_assignable<tmp<T>>::value
<< " nothrow:"
<< std::is_nothrow_move_assignable<tmp<T>>::value
<< " trivially:"
<< std::is_trivially_move_assignable<tmp<T>>::value
<< nl;
if (verbose && item)
if (verbose && item.valid())
{
Info<< "content: " << item() << nl;
}

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011 OpenFOAM Foundation
Copyright (C) 2020-2021 OpenCFD Ltd.
Copyright (C) 2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -50,16 +50,18 @@ int main(int argc, char *argv[])
argList::addArgument("string .. stringN");
argList::addOption("file", "name");
argList::addOption("repeat", "count");
argList::addVerboseOption("report each repeat");
argList::addBoolOption("verbose", "report for each repeat");
argList args(argc, argv, false, true);
const label repeat = args.getOrDefault<label>("repeat", 1);
const bool optVerbose = args.found("verbose");
cpuTime timer;
for (label count = 0; count < repeat; ++count)
{
const bool verbose = (args.verbose() || count == 0);
const bool verbose = (optVerbose || count == 0);
for (label argI=1; argI < args.size(); ++argI)
{
@ -118,7 +120,7 @@ int main(int argc, char *argv[])
for (label count = 0; count < repeat; ++count)
{
const bool verbose = (args.verbose() || count == 0);
const bool verbose = (optVerbose || count == 0);
label nTokens = 0;
if (count)

View File

@ -11,11 +11,11 @@ License
This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
Description
Write proc addressing and decompose area fields (parallel only).
Decompose area fields, when mesh was generated in parallel
\*---------------------------------------------------------------------------*/
if (doDecompose && Pstream::parRun())
if (Pstream::parRun())
{
faMeshReconstructor reconstructor(aMesh);
reconstructor.writeAddressing();
@ -43,42 +43,24 @@ if (doDecompose && Pstream::parRun())
reconstructor.writeMesh();
if (doDecompFields)
const bool oldDistributed = fileHandler().distributed();
auto oldHandler = fileHandler(fileOperation::NewUncollated());
fileHandler().distributed(true);
IOobjectList objects(fullMesh.time(), runTime.timeName());
faFieldDecomposer::readFields(fullMesh, objects, areaScalarFields);
faFieldDecomposer::readFields(fullMesh, objects, areaVectorFields);
faFieldDecomposer::readFields(fullMesh, objects, areaSphTensorFields);
faFieldDecomposer::readFields(fullMesh, objects, areaSymmTensorFields);
faFieldDecomposer::readFields(fullMesh, objects, areaTensorFields);
// Restore old settings
if (oldHandler)
{
const bool oldDistributed = fileHandler().distributed();
auto oldHandler = fileHandler(fileOperation::NewUncollated());
fileHandler().distributed(true);
IOobjectList objects(fullMesh.time(), runTime.timeName());
faFieldDecomposer::readFields
(
fullMesh, objects, areaScalarFields
);
faFieldDecomposer::readFields
(
fullMesh, objects, areaVectorFields
);
faFieldDecomposer::readFields
(
fullMesh, objects, areaSphTensorFields
);
faFieldDecomposer::readFields
(
fullMesh, objects, areaSymmTensorFields
);
faFieldDecomposer::readFields
(
fullMesh, objects, areaTensorFields
);
// Restore old settings
if (oldHandler)
{
fileHandler(std::move(oldHandler));
}
fileHandler().distributed(oldDistributed);
fileHandler(std::move(oldHandler));
}
fileHandler().distributed(oldDistributed);
}
const label nAreaFields =
@ -142,5 +124,4 @@ if (doDecompose && Pstream::parRun())
}
}
// ************************************************************************* //

View File

@ -71,23 +71,12 @@ int main(int argc, char *argv[])
);
argList::addOption("dict", "file", "Alternative faMeshDefinition");
argList::addDryRunOption
argList::addBoolOption
(
"dry-run",
"Create but do not write"
);
argList::addBoolOption
(
"no-decompose",
"Suppress procAddressing creation and field decomposition"
" (parallel)"
);
argList::addBoolOption
(
"no-fields",
"Suppress field decomposition"
" (parallel)"
);
argList::addBoolOption
(
"write-vtk",
"Write mesh as a vtp (vtk) file for display or debugging"
@ -104,17 +93,7 @@ int main(int argc, char *argv[])
#include "createTime.H"
#include "createNamedPolyMesh.H"
const bool doDecompose = !args.found("no-decompose");
const bool doDecompFields = !args.found("no-fields");
if (!doDecompose)
{
Info<< "Skip decompose of finiteArea mesh/fields" << nl;
}
else if (!doDecompFields)
{
Info<< "Skip decompose of finiteArea fields" << nl;
}
const bool dryrun = args.found("dry-run");
// Reading faMeshDefinition dictionary
#include "findMeshDefinitionDict.H"
@ -143,7 +122,7 @@ int main(int argc, char *argv[])
#include "faMeshWriteVTK.H"
}
if (args.dryRun())
if (dryrun)
{
Info<< "\ndry-run: not writing mesh or decomposing fields\n" << nl;
}

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2016-2021 OpenCFD Ltd.
Copyright (C) 2016-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -75,7 +75,6 @@ Usage
#include "blockMesh.H"
#include "foamVtkInternalMeshWriter.H"
#include "foamVtkSurfaceWriter.H"
#include "attachPolyTopoChanger.H"
#include "polyTopoChange.H"
#include "cyclicPolyPatch.H"
@ -97,24 +96,23 @@ int main(int argc, char *argv[])
argList::addNote
(
"Block mesh generator.\n"
" \n"
" The ordering of vertex and face labels within a block as shown "
"below.\n"
" For the local vertex numbering in the sequence 0 to 7:\n"
" Faces 0, 1 (x-direction) are left, right.\n"
" Faces 2, 3 (y-direction) are front, back.\n"
" Faces 4, 5 (z-direction) are bottom, top.\n"
" \n"
"\n"
" 7 ---- 6\n"
" f5 |\\ :\\ f3\n"
" f5 |\\ |\\ f3\n"
" | | 4 ---- 5 \\\n"
" | 3.|....2 | \\\n"
" | 3 |--- 2 | \\\n"
" | \\| \\| f2\n"
" f4 0 ---- 1\n"
" Y Z\n"
" \\ | f0 ------ f1\n"
" \\|\n"
" o--- X\n"
" O--- X\n"
);
argList::noParallel();
@ -131,11 +129,7 @@ int main(int argc, char *argv[])
argList::addBoolOption
(
"write-vtk",
"Write topology as VTU file and exit"
);
argList::addVerboseOption
(
"Force verbose output. (Can be used multiple times)"
"Write topology as VTK file and exit"
);
argList::addBoolOption
@ -176,12 +170,12 @@ int main(int argc, char *argv[])
const bool writeCellSets = args.found("sets");
// Default merge (topology), unless otherwise specified
const blockMesh::mergeStrategy strategy =
(
args.found("merge-points")
? blockMesh::MERGE_POINTS
: blockMesh::DEFAULT_MERGE
);
blockMesh::mergeStrategy strategy(blockMesh::DEFAULT_MERGE);
if (args.found("merge-points"))
{
strategy = blockMesh::MERGE_POINTS;
}
word regionName(polyMesh::defaultRegion);
word regionPath;
@ -222,7 +216,7 @@ int main(int argc, char *argv[])
// Locate appropriate blockMeshDict
#include "findBlockMeshDict.H"
blockMesh blocks(meshDict, regionName, strategy, args.verbose());
blockMesh blocks(meshDict, regionName, strategy);
if (!blocks.valid())
{

View File

@ -13,25 +13,22 @@ License
Description
VTK output of blockMesh topology blocks
Always write in ASCII since the mesh is small and we want easily
readable output for inspection.
\*---------------------------------------------------------------------------*/
// Common
refPtr<polyMesh> topoMeshPtr(blocks.topology(true));
const polyMesh& topoMesh = topoMeshPtr();
// Internal mesh - ie, the blocks
{
const vtk::vtuCells topoCells(topoMesh, vtk::formatType::INLINE_ASCII);
// Non-legacy and ASCII (mesh is small, want readable output)
const vtk::outputOptions writeOpts = vtk::formatType::INLINE_ASCII;
refPtr<polyMesh> topoMeshPtr(blocks.topology(true));
const polyMesh& topoMesh = topoMeshPtr();
const vtk::vtuCells topoCells(topoMesh, writeOpts);
vtk::internalMeshWriter writer
(
topoMesh,
topoCells,
vtk::formatType::INLINE_ASCII,
writeOpts,
runTime.path()/"blockTopology"
);
@ -102,64 +99,4 @@ const polyMesh& topoMesh = topoMeshPtr();
}
// Block boundary faces
{
const label nIntFaces = topoMesh.nInternalFaces();
const label nBndFaces = topoMesh.nBoundaryFaces();
faceList bndFaces
(
faceList::subList(topoMesh.faces(), nBndFaces, nIntFaces)
);
vtk::surfaceWriter writer
(
topoMesh.points(),
bndFaces,
vtk::formatType::INLINE_ASCII,
runTime.path()/"blockFaces"
);
labelList blockIds(nBndFaces, -1);
labelList cellFaceIds(nBndFaces, -1);
labelList patchIds(nBndFaces, -1);
{
const labelList& own = topoMesh.faceOwner();
const cellList& cells = topoMesh.cells();
const polyPatchList& patches = topoMesh.boundaryMesh();
for (const polyPatch& pp : patches)
{
label bndFacei = pp.start() - nIntFaces;
label meshFacei = pp.start();
forAll(pp, bfacei)
{
const label celli = own[meshFacei];
const label cellFacei = cells[celli].find(meshFacei);
blockIds[bndFacei] = celli;
cellFaceIds[bndFacei] = cellFacei;
patchIds[bndFacei] = pp.index();
++bndFacei;
++meshFacei;
}
}
}
Info<< "Writing block boundary faces in vtk format: "
<< args.relativePath(writer.output()).c_str() << endl;
writer.writeGeometry();
writer.beginCellData();
writer.writeCellData("block", blockIds);
writer.writeCellData("face", cellFaceIds);
writer.writeCellData("patch", patchIds);
}
// ************************************************************************* //

View File

@ -125,8 +125,6 @@ int main(int argc, char *argv[])
// ------------------------------------------------------------------------
#include "createNamedMeshes.H"
forAll(regionNames, regioni)
{
const word& regionName = regionNames[regioni];
@ -168,6 +166,8 @@ int main(int argc, char *argv[])
instantList timeDirs = timeSelector::select0(runTime, args);
#include "createNamedMeshes.H"
forAll(timeDirs, timei)
{
runTime.setTime(timeDirs[timei], timei);

View File

@ -78,8 +78,9 @@ int main(int argc, char *argv[])
"detail",
"Additional detail"
);
argList::addVerboseOption
argList::addBoolOption
(
"verbose",
"Additional verbosity"
);
@ -93,6 +94,7 @@ int main(int argc, char *argv[])
const bool testOr = args.found("or");
const bool detail = args.found("detail");
const bool verbose = args.found("verbose");
label ngood = 0;
label nbad = 0;
@ -125,7 +127,7 @@ int main(int argc, char *argv[])
{
++ngood;
if (args.verbose())
if (verbose)
{
const word addr(Foam::name(ptr));

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2016-2021 OpenCFD Ltd.
Copyright (C) 2016-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -101,8 +101,9 @@ int main(int argc, char *argv[])
"rm",
"Remove selected time directories"
);
argList::addVerboseOption
argList::addBoolOption
(
"verbose",
"Report progress of -rm option"
);
profiling::disable(); // Disable profiling (and its output)
@ -110,7 +111,7 @@ int main(int argc, char *argv[])
#include "setRootCase.H"
const bool removeFiles(args.found("rm"));
bool verbose(args.verbose());
bool verbose(args.found("verbose"));
// Get times list from the master processor and subset based on

View File

@ -232,8 +232,9 @@ int main(int argc, char *argv[])
(
"Report action without moving/renaming"
);
argList::addVerboseOption
argList::addBoolOption
(
"verbose",
"Additional verbosity"
);
@ -246,7 +247,7 @@ int main(int argc, char *argv[])
#include "setRootCase.H"
dryrun = args.dryRun();
verbose = args.verbose();
verbose = args.found("verbose");
// Construct time

View File

@ -141,15 +141,11 @@ Usage
\*---------------------------------------------------------------------------*/
#include "argList.H"
#include "timeSelector.H"
#include "OSspecific.H"
#include "fvCFD.H"
#include "IOobjectList.H"
#include "decompositionModel.H"
#include "domainDecomposition.H"
#include "domainDecompositionDryRun.H"
#include "labelIOField.H"
#include "labelFieldIOField.H"
#include "scalarIOField.H"
@ -169,7 +165,9 @@ Usage
#include "fvFieldDecomposer.H"
#include "pointFieldDecomposer.H"
#include "lagrangianFieldDecomposer.H"
#include "decompositionModel.H"
#include "faCFD.H"
#include "emptyFaPatch.H"
#include "faMeshDecomposition.H"
#include "faFieldDecomposer.H"
@ -308,8 +306,6 @@ void decomposeUniform
} // End namespace Foam
using namespace Foam;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
int main(int argc, char *argv[])
@ -334,8 +330,9 @@ int main(int argc, char *argv[])
"Test without writing the decomposition. "
"Changes -cellDist to only write VTK output."
);
argList::addVerboseOption
argList::addBoolOption
(
"verbose",
"Additional verbosity"
);
argList::addOption
@ -388,11 +385,6 @@ int main(int argc, char *argv[])
"fields",
"Use existing geometry decomposition and convert fields only"
);
argList::addBoolOption
(
"no-fields",
"Suppress conversion of fields (volume, finite-area, lagrangian)"
);
argList::addBoolOption
(
@ -417,7 +409,9 @@ int main(int argc, char *argv[])
#include "setRootCase.H"
const bool dryrun = args.dryRun();
const bool writeCellDist = args.found("cellDist");
const bool verbose = args.found("verbose");
// Most of these are ignored for dry-run (not triggered anywhere)
const bool copyZero = args.found("copyZero");
@ -426,7 +420,6 @@ int main(int argc, char *argv[])
const bool decomposeIfRequired = args.found("ifRequired");
const bool doDecompFields = !args.found("no-fields");
const bool doFiniteArea = !args.found("no-finite-area");
const bool doLagrangian = !args.found("no-lagrangian");
@ -439,25 +432,13 @@ int main(int argc, char *argv[])
// Allow override of time (unless dry-run)
instantList times;
if (args.dryRun())
if (dryrun)
{
Info<< "\ndry-run: ignoring -copy*, -fields, -force, time selection"
<< nl;
}
else
{
if (decomposeFieldsOnly && !doDecompFields)
{
FatalErrorIn(args.executable())
<< "Options -fields and -no-fields are mutually exclusive"
<< " ... giving up" << nl
<< exit(FatalError);
}
if (!doDecompFields)
{
Info<< "Skip decompose of all fields" << nl;
}
if (!doFiniteArea)
{
Info<< "Skip decompose of finiteArea mesh/fields" << nl;
@ -470,7 +451,6 @@ int main(int argc, char *argv[])
times = timeSelector::selectIfPresent(runTime, args);
}
// Allow override of decomposeParDict location
fileName decompDictFile(args.get<fileName>("decomposeParDict", ""));
if (!decompDictFile.empty() && !decompDictFile.isAbsolute())
@ -497,7 +477,7 @@ int main(int argc, char *argv[])
regionName == polyMesh::defaultRegion ? word::null : regionName
);
if (args.dryRun())
if (dryrun)
{
Info<< "dry-run: decomposing mesh " << regionName << nl << nl
<< "Create mesh..." << flush;
@ -518,7 +498,7 @@ int main(int argc, char *argv[])
args.getOrDefault<word>("method", word::null)
);
decompTest.execute(writeCellDist, args.verbose());
decompTest.execute(writeCellDist, verbose);
continue;
}
@ -530,8 +510,7 @@ int main(int argc, char *argv[])
Info<< nl << endl;
// Determine the existing processor count directly
const label nProcsOld =
fileHandler().nProcs(runTime.path(), regionDir);
label nProcs = fileHandler().nProcs(runTime.path(), regionDir);
// Get requested numberOfSubdomains directly from the dictionary.
// Note: have no mesh yet so cannot use decompositionModel::New
@ -562,22 +541,22 @@ int main(int argc, char *argv[])
if (decomposeFieldsOnly)
{
// Sanity check on previously decomposed case
if (nProcsOld != nDomains)
if (nProcs != nDomains)
{
FatalErrorIn(args.executable())
FatalErrorInFunction
<< "Specified -fields, but the case was decomposed with "
<< nProcsOld << " domains"
<< nProcs << " domains"
<< nl
<< "instead of " << nDomains
<< " domains as specified in decomposeParDict" << nl
<< exit(FatalError);
}
}
else if (nProcsOld)
else if (nProcs)
{
bool procDirsProblem = true;
if (decomposeIfRequired && nProcsOld == nDomains)
if (decomposeIfRequired && nProcs == nDomains)
{
// We can reuse the decomposition
decomposeFieldsOnly = true;
@ -595,7 +574,7 @@ int main(int argc, char *argv[])
if (forceOverwrite)
{
Info<< "Removing " << nProcsOld
Info<< "Removing " << nProcs
<< " existing processor directories" << endl;
// Remove existing processors directory
@ -638,8 +617,8 @@ int main(int argc, char *argv[])
if (procDirsProblem)
{
FatalErrorIn(args.executable())
<< "Case is already decomposed with " << nProcsOld
FatalErrorInFunction
<< "Case is already decomposed with " << nProcs
<< " domains, use the -force option or manually" << nl
<< "remove processor directories before decomposing. e.g.,"
<< nl
@ -668,6 +647,7 @@ int main(int argc, char *argv[])
if (!decomposeFieldsOnly)
{
mesh.decomposeMesh();
mesh.writeDecomposition(decomposeSets);
if (writeCellDist)
@ -770,7 +750,7 @@ int main(int argc, char *argv[])
}
else
{
// Decompose field files, lagrangian, finite-area
// Decompose the field files
// Cached processor meshes and maps. These are only preserved if
// running with multiple times.
@ -779,9 +759,8 @@ int main(int argc, char *argv[])
PtrList<labelIOList> faceProcAddressingList(mesh.nProcs());
PtrList<labelIOList> cellProcAddressingList(mesh.nProcs());
PtrList<labelIOList> boundaryProcAddressingList(mesh.nProcs());
PtrList<labelIOList> pointProcAddressingList(mesh.nProcs());
PtrList<fvFieldDecomposer> fieldDecomposerList(mesh.nProcs());
PtrList<labelIOList> pointProcAddressingList(mesh.nProcs());
PtrList<pointFieldDecomposer> pointFieldDecomposerList
(
mesh.nProcs()
@ -789,139 +768,83 @@ int main(int argc, char *argv[])
// Loop over all times
forAll(times, timei)
forAll(times, timeI)
{
runTime.setTime(times[timei], timei);
runTime.setTime(times[timeI], timeI);
Info<< "Time = " << runTime.timeName() << endl;
// Field objects at this time
IOobjectList objects;
if (doDecompFields)
{
objects = IOobjectList(mesh, runTime.timeName());
// Ignore generated fields: (cellDist)
objects.remove("cellDist");
}
// Finite area handling
autoPtr<faMeshDecomposition> faMeshDecompPtr;
if (doFiniteArea)
{
IOobject io
(
"faBoundary",
mesh.time().findInstance
(
mesh.dbDir()/polyMesh::meshSubDir,
"boundary"
),
faMesh::meshSubDir,
mesh,
IOobject::READ_IF_PRESENT,
IOobject::NO_WRITE,
false // not registered
);
if (io.typeHeaderOk<faBoundaryMesh>(true))
{
// Always based on the volume decomposition!
faMeshDecompPtr.reset
(
new faMeshDecomposition
(
mesh,
mesh.nProcs(),
mesh.model()
)
);
}
}
// Search for list of objects for this time
IOobjectList objects(mesh, runTime.timeName());
// Vol fields
// ~~~~~~~~~~
// Construct the vol fields
// ~~~~~~~~~~~~~~~~~~~~~~~~
PtrList<volScalarField> volScalarFields;
readFields(mesh, objects, volScalarFields, false);
PtrList<volVectorField> volVectorFields;
PtrList<volSphericalTensorField> volSphTensorFields;
readFields(mesh, objects, volVectorFields, false);
PtrList<volSphericalTensorField> volSphericalTensorFields;
readFields(mesh, objects, volSphericalTensorFields, false);
PtrList<volSymmTensorField> volSymmTensorFields;
readFields(mesh, objects, volSymmTensorFields, false);
PtrList<volTensorField> volTensorFields;
readFields(mesh, objects, volTensorFields, false);
if (doDecompFields)
{
readFields(mesh, objects, volScalarFields, false);
readFields(mesh, objects, volVectorFields, false);
readFields(mesh, objects, volSphTensorFields, false);
readFields(mesh, objects, volSymmTensorFields, false);
readFields(mesh, objects, volTensorFields, false);
}
// Internal fields
// ~~~~~~~~~~~~~~~
// Construct the dimensioned fields
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
PtrList<DimensionedField<scalar, volMesh>> dimScalarFields;
readFields(mesh, objects, dimScalarFields);
PtrList<DimensionedField<vector, volMesh>> dimVectorFields;
readFields(mesh, objects, dimVectorFields);
PtrList<DimensionedField<sphericalTensor, volMesh>>
dimSphTensorFields;
dimSphericalTensorFields;
readFields(mesh, objects, dimSphericalTensorFields);
PtrList<DimensionedField<symmTensor, volMesh>>
dimSymmTensorFields;
readFields(mesh, objects, dimSymmTensorFields);
PtrList<DimensionedField<tensor, volMesh>> dimTensorFields;
readFields(mesh, objects, dimTensorFields);
if (doDecompFields)
{
readFields(mesh, objects, dimScalarFields);
readFields(mesh, objects, dimVectorFields);
readFields(mesh, objects, dimSphTensorFields);
readFields(mesh, objects, dimSymmTensorFields);
readFields(mesh, objects, dimTensorFields);
}
// Surface fields
// ~~~~~~~~~~~~~~
// Construct the surface fields
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
PtrList<surfaceScalarField> surfaceScalarFields;
readFields(mesh, objects, surfaceScalarFields, false);
PtrList<surfaceVectorField> surfaceVectorFields;
readFields(mesh, objects, surfaceVectorFields, false);
PtrList<surfaceSphericalTensorField>
surfaceSphTensorFields;
surfaceSphericalTensorFields;
readFields(mesh, objects, surfaceSphericalTensorFields, false);
PtrList<surfaceSymmTensorField> surfaceSymmTensorFields;
readFields(mesh, objects, surfaceSymmTensorFields, false);
PtrList<surfaceTensorField> surfaceTensorFields;
if (doDecompFields)
{
readFields(mesh, objects, surfaceScalarFields, false);
readFields(mesh, objects, surfaceVectorFields, false);
readFields(mesh, objects, surfaceSphTensorFields, false);
readFields(mesh, objects, surfaceSymmTensorFields, false);
readFields(mesh, objects, surfaceTensorFields, false);
}
readFields(mesh, objects, surfaceTensorFields, false);
// Point fields
// ~~~~~~~~~~~~
// Construct the point fields
// ~~~~~~~~~~~~~~~~~~~~~~~~~~
const pointMesh& pMesh = pointMesh::New(mesh);
PtrList<pointScalarField> pointScalarFields;
readFields(pMesh, objects, pointScalarFields, false);
PtrList<pointVectorField> pointVectorFields;
PtrList<pointSphericalTensorField> pointSphTensorFields;
readFields(pMesh, objects, pointVectorFields, false);
PtrList<pointSphericalTensorField> pointSphericalTensorFields;
readFields(pMesh, objects, pointSphericalTensorFields, false);
PtrList<pointSymmTensorField> pointSymmTensorFields;
readFields(pMesh, objects, pointSymmTensorFields, false);
PtrList<pointTensorField> pointTensorFields;
if (doDecompFields)
{
readFields(pMesh, objects, pointScalarFields, false);
readFields(pMesh, objects, pointVectorFields, false);
readFields(pMesh, objects, pointSphTensorFields, false);
readFields(pMesh, objects, pointSymmTensorFields, false);
readFields(pMesh, objects, pointTensorFields, false);
}
readFields(pMesh, objects, pointTensorFields, false);
// Lagrangian fields
// ~~~~~~~~~~~~~~~~~
// Construct the Lagrangian fields
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
fileNameList cloudDirs;
if (doDecompFields && doLagrangian)
if (doLagrangian)
{
cloudDirs = fileHandler().readDir
(
@ -969,17 +892,13 @@ int main(int argc, char *argv[])
cloudDirs.size()
);
PtrList<PtrList<sphericalTensorIOField>>
lagrangianSphTensorFields
lagrangianSphericalTensorFields
(
cloudDirs.size()
);
PtrList<PtrList<sphericalTensorFieldCompactIOField>>
lagrangianSphTensorFieldFields
(
cloudDirs.size()
);
PtrList<PtrList<symmTensorIOField>>
lagrangianSymmTensorFields
lagrangianSphericalTensorFieldFields(cloudDirs.size());
PtrList<PtrList<symmTensorIOField>> lagrangianSymmTensorFields
(
cloudDirs.size()
);
@ -998,7 +917,6 @@ int main(int argc, char *argv[])
cloudDirs.size()
);
label cloudI = 0;
for (const fileName& cloudDir : cloudDirs)
@ -1062,7 +980,7 @@ int main(int argc, char *argv[])
// Check
if (celli < 0 || celli >= mesh.nCells())
{
FatalErrorIn(args.executable())
FatalErrorInFunction
<< "Illegal cell number " << celli
<< " for particle with index "
<< p.index()
@ -1144,14 +1062,14 @@ int main(int argc, char *argv[])
(
cloudI,
lagrangianObjects,
lagrangianSphTensorFields
lagrangianSphericalTensorFields
);
lagrangianFieldDecomposer::readFieldFields
(
cloudI,
lagrangianObjects,
lagrangianSphTensorFieldFields
lagrangianSphericalTensorFieldFields
);
lagrangianFieldDecomposer::readFields
@ -1182,34 +1100,29 @@ int main(int argc, char *argv[])
lagrangianTensorFieldFields
);
++cloudI;
cloudI++;
}
}
lagrangianPositions.resize(cloudI);
cellParticles.resize(cloudI);
lagrangianLabelFields.resize(cloudI);
lagrangianLabelFieldFields.resize(cloudI);
lagrangianScalarFields.resize(cloudI);
lagrangianScalarFieldFields.resize(cloudI);
lagrangianVectorFields.resize(cloudI);
lagrangianVectorFieldFields.resize(cloudI);
lagrangianSphTensorFields.resize(cloudI);
lagrangianSphTensorFieldFields.resize(cloudI);
lagrangianSymmTensorFields.resize(cloudI);
lagrangianSymmTensorFieldFields.resize(cloudI);
lagrangianTensorFields.resize(cloudI);
lagrangianTensorFieldFields.resize(cloudI);
lagrangianPositions.setSize(cloudI);
cellParticles.setSize(cloudI);
lagrangianLabelFields.setSize(cloudI);
lagrangianLabelFieldFields.setSize(cloudI);
lagrangianScalarFields.setSize(cloudI);
lagrangianScalarFieldFields.setSize(cloudI);
lagrangianVectorFields.setSize(cloudI);
lagrangianVectorFieldFields.setSize(cloudI);
lagrangianSphericalTensorFields.setSize(cloudI);
lagrangianSphericalTensorFieldFields.setSize(cloudI);
lagrangianSymmTensorFields.setSize(cloudI);
lagrangianSymmTensorFieldFields.setSize(cloudI);
lagrangianTensorFields.setSize(cloudI);
lagrangianTensorFieldFields.setSize(cloudI);
Info<< endl;
// split the fields over processors
for
(
label proci = 0;
doDecompFields && proci < mesh.nProcs();
++proci
)
for (label proci = 0; proci < mesh.nProcs(); ++proci)
{
Info<< "Processor " << proci << ": field transfer" << endl;
@ -1297,19 +1210,22 @@ int main(int argc, char *argv[])
const fvFieldDecomposer& fieldDecomposer =
fieldDecomposerList[proci];
// Vol fields
// vol fields
fieldDecomposer.decomposeFields(volScalarFields);
fieldDecomposer.decomposeFields(volVectorFields);
fieldDecomposer.decomposeFields(volSphTensorFields);
fieldDecomposer.decomposeFields
(
volSphericalTensorFields
);
fieldDecomposer.decomposeFields(volSymmTensorFields);
fieldDecomposer.decomposeFields(volTensorFields);
// Surface fields
// surface fields
fieldDecomposer.decomposeFields(surfaceScalarFields);
fieldDecomposer.decomposeFields(surfaceVectorFields);
fieldDecomposer.decomposeFields
(
surfaceSphTensorFields
surfaceSphericalTensorFields
);
fieldDecomposer.decomposeFields
(
@ -1320,7 +1236,7 @@ int main(int argc, char *argv[])
// internal fields
fieldDecomposer.decomposeFields(dimScalarFields);
fieldDecomposer.decomposeFields(dimVectorFields);
fieldDecomposer.decomposeFields(dimSphTensorFields);
fieldDecomposer.decomposeFields(dimSphericalTensorFields);
fieldDecomposer.decomposeFields(dimSymmTensorFields);
fieldDecomposer.decomposeFields(dimTensorFields);
@ -1337,7 +1253,7 @@ int main(int argc, char *argv[])
(
pointScalarFields.size()
|| pointVectorFields.size()
|| pointSphTensorFields.size()
|| pointSphericalTensorFields.size()
|| pointSymmTensorFields.size()
|| pointTensorFields.size()
)
@ -1371,7 +1287,10 @@ int main(int argc, char *argv[])
pointDecomposer.decomposeFields(pointScalarFields);
pointDecomposer.decomposeFields(pointVectorFields);
pointDecomposer.decomposeFields(pointSphTensorFields);
pointDecomposer.decomposeFields
(
pointSphericalTensorFields
);
pointDecomposer.decomposeFields(pointSymmTensorFields);
pointDecomposer.decomposeFields(pointTensorFields);
@ -1435,12 +1354,12 @@ int main(int argc, char *argv[])
fieldDecomposer.decomposeFields
(
cloudDirs[cloudI],
lagrangianSphTensorFields[cloudI]
lagrangianSphericalTensorFields[cloudI]
);
fieldDecomposer.decomposeFieldFields
(
cloudDirs[cloudI],
lagrangianSphTensorFieldFields[cloudI]
lagrangianSphericalTensorFieldFields[cloudI]
);
fieldDecomposer.decomposeFields
(
@ -1466,24 +1385,17 @@ int main(int argc, char *argv[])
}
}
if (doDecompFields)
// Decompose the "uniform" directory in the time region
// directory
decomposeUniform(copyUniform, mesh, processorDb, regionDir);
// For a multi-region case, also decompose the "uniform"
// directory in the time directory
if (regionNames.size() > 1 && regioni == 0)
{
// Decompose "uniform" directory in the time region
// directory
decomposeUniform
(
copyUniform, mesh, processorDb, regionDir
);
// For a multi-region case, also decompose "uniform"
// directory in the time directory
if (regionNames.size() > 1 && regioni == 0)
{
decomposeUniform(copyUniform, mesh, processorDb);
}
decomposeUniform(copyUniform, mesh, processorDb);
}
// We have cached all the constant mesh data for the current
// processor. This is only important if running with
// multiple times, otherwise it is just extra storage.
@ -1497,46 +1409,72 @@ int main(int argc, char *argv[])
}
}
// Finite area mesh and field decomposition
if (faMeshDecompPtr)
IOobject faMeshBoundaryIOobj
(
"faBoundary",
mesh.time().findInstance
(
mesh.dbDir()/polyMesh::meshSubDir,
"boundary"
),
faMesh::meshSubDir,
mesh,
IOobject::READ_IF_PRESENT,
IOobject::NO_WRITE,
false // not registered
);
if
(
doFiniteArea
&& faMeshBoundaryIOobj.typeHeaderOk<faBoundaryMesh>(true)
)
{
Info<< "\nFinite area mesh decomposition" << endl;
faMeshDecomposition& aMesh = faMeshDecompPtr();
// Always based on the volume decomposition!
faMeshDecomposition aMesh
(
mesh,
mesh.nProcs(),
mesh.model()
);
aMesh.decomposeMesh();
aMesh.writeDecomposition();
// Area fields
// ~~~~~~~~~~~
// Construct the area fields
// ~~~~~~~~~~~~~~~~~~~~~~~~
PtrList<areaScalarField> areaScalarFields;
readFields(aMesh, objects, areaScalarFields);
PtrList<areaVectorField> areaVectorFields;
PtrList<areaSphericalTensorField> areaSphTensorFields;
readFields(aMesh, objects, areaVectorFields);
PtrList<areaSphericalTensorField> areaSphericalTensorFields;
readFields(aMesh, objects, areaSphericalTensorFields);
PtrList<areaSymmTensorField> areaSymmTensorFields;
readFields(aMesh, objects, areaSymmTensorFields);
PtrList<areaTensorField> areaTensorFields;
readFields(aMesh, objects, areaTensorFields);
// Edge fields (limited number of types)
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Construct the edge fields
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
PtrList<edgeScalarField> edgeScalarFields;
if (doDecompFields)
{
readFields(aMesh, objects, areaScalarFields);
readFields(aMesh, objects, areaVectorFields);
readFields(aMesh, objects, areaSphTensorFields);
readFields(aMesh, objects, areaSymmTensorFields);
readFields(aMesh, objects, areaTensorFields);
readFields(aMesh, objects, edgeScalarFields);
}
readFields(aMesh, objects, edgeScalarFields);
const label nAreaFields =
(
areaScalarFields.size()
+ areaVectorFields.size()
+ areaSphTensorFields.size()
+ areaSphericalTensorFields.size()
+ areaSymmTensorFields.size()
+ areaTensorFields.size()
+ edgeScalarFields.size()
@ -1639,7 +1577,10 @@ int main(int argc, char *argv[])
fieldDecomposer.decomposeFields(areaScalarFields);
fieldDecomposer.decomposeFields(areaVectorFields);
fieldDecomposer.decomposeFields(areaSphTensorFields);
fieldDecomposer.decomposeFields
(
areaSphericalTensorFields
);
fieldDecomposer.decomposeFields(areaSymmTensorFields);
fieldDecomposer.decomposeFields(areaTensorFields);

View File

@ -52,7 +52,7 @@ void Foam::domainDecomposition::writeVolField
false
),
this->mesh(),
dimensionedScalar("cellDist", dimless, -1),
dimensionedScalar(dimless, Zero),
zeroGradientFvPatchScalarField::typeName
);

View File

@ -44,6 +44,13 @@ void Foam::readFields
// Search list of objects for fields of type GeoField
IOobjectList fieldObjects(objects.lookupClass<GeoField>());
// Remove the cellDist field
auto iter = fieldObjects.find("cellDist");
if (iter.found())
{
fieldObjects.erase(iter);
}
// Use sorted set of names
// (different processors might read objects in different order)
const wordList masterNames(fieldObjects.sortedNames());

View File

@ -147,7 +147,7 @@ void createTimeDirs(const fileName& path)
// Just to make sure remove all state and re-scan
fileHandler().flush();
(void)Time::findTimes(path, "constant");
(void)fileHandler().findTimes(path, "constant");
}
@ -2665,11 +2665,9 @@ int main(int argc, char *argv[])
// e.g. latestTime will pick up a different time (which causes createTime.H
// to abort). So for now make sure to have master times on all
// processors
if (!reconstruct)
{
Info<< "Creating time directories on all processors" << nl << endl;
createTimeDirs(args.path());
}
Info<< "Creating time directories on all processors" << nl << endl;
createTimeDirs(args.path());
// Construct time
// ~~~~~~~~~~~~~~
@ -2934,10 +2932,6 @@ int main(int argc, char *argv[])
}
}
// Make sure all is finished writing until re-reading in pass2
// below
fileHandler().flush();
// Pass2 : read mesh and addressing and reconstruct fields
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

View File

@ -15,12 +15,4 @@ const label sampleFrequency(propsDict.get<label>("sampleFrequency"));
const label maxPositions(propsDict.get<label>("maxPositions"));
const label maxTracks(propsDict.getOrDefault<label>("maxTracks", -1));
const word setFormat(propsDict.getOrDefault<word>("setFormat", "vtk"));
const wordRes fieldNames(propsDict.getOrDefault<wordRes>("fields", wordRes()));
const word UName(propsDict.getOrDefault<word>("U", "U"));
const dictionary formatOptions = propsDict.subOrEmptyDict("formatOptions");

View File

@ -6,7 +6,6 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -31,8 +30,8 @@ Group
grpPostProcessingUtilities
Description
Generate particle tracks for cases that were computed using a
tracked-parcel-type cloud.
Generate a legacy VTK file of particle tracks for cases that were
computed using a tracked-parcel-type cloud.
\*---------------------------------------------------------------------------*/
@ -45,206 +44,16 @@ Description
#include "OFstream.H"
#include "passiveParticleCloud.H"
#include "writer.H"
#include "ListOps.H"
#define createTrack(field, trackValues) \
createTrackField \
( \
field, \
sampleFrequency, \
maxPositions, \
startIds, \
allOrigProcs, \
allOrigIds, \
trackValues \
);
#define setFields(fields, fieldNames) \
setTrackFields \
( \
obr, \
fields, \
fieldNames, \
nTracks, \
startIds, \
allOrigProcs, \
allOrigIds, \
maxPositions, \
sampleFrequency \
);
#define writeFields(fields, fieldNames, tracks, times, dirs) \
writeTrackFields \
( \
fields, \
fieldNames, \
tracks, \
times, \
dirs, \
setFormat, \
formatOptions, \
cloudName \
);
using namespace Foam;
template<class Type>
void createTrackField
(
const Field<Type>& values,
const label sampleFrequency,
const label maxPositions,
const labelList& startIds,
const List<labelField>& allOrigProcs,
const List<labelField>& allOrigIds,
List<DynamicList<Type>>& trackValues
)
{
List<Field<Type>> procField(Pstream::nProcs());
procField[Pstream::myProcNo()] = values;
Pstream::gatherList(procField);
if (!Pstream::master())
{
return;
}
const label nTracks = trackValues.size();
forAll(procField, proci)
{
forAll(procField[proci], i)
{
const label globalId =
startIds[allOrigProcs[proci][i]] + allOrigIds[proci][i];
if (globalId % sampleFrequency == 0)
{
const label trackId = globalId/sampleFrequency;
if
(
trackId < nTracks
&& trackValues[trackId].size() < maxPositions
)
{
trackValues[trackId].append(procField[proci][i]);
}
}
}
}
}
template<class Type>
void writeTrackFields
(
List<List<DynamicList<Type>>>& fieldValues,
const wordList& fieldNames,
const PtrList<coordSet>& tracks,
const List<scalarField>& times,
const List<vectorField>& dirs,
const word& setFormat,
const dictionary& formatOptions,
const word& cloudName
)
{
if (fieldValues.empty())
{
return;
}
auto writerPtr = writer<Type>::New(setFormat, formatOptions);
const fileName outFile(writerPtr().getFileName(tracks[0], wordList(0)));
const fileName outPath
(
functionObject::outputPrefix/cloud::prefix/cloudName/"particleTracks"
);
mkDir(outPath);
OFstream os(outPath/(pTraits<Type>::typeName & "tracks." + outFile.ext()));
Info<< "Writing " << pTraits<Type>::typeName << " particle tracks in "
<< setFormat << " format to " << os.name() << endl;
List<List<Field<Type>>> fields(fieldValues.size());
forAll(fields, fieldi)
{
fields[fieldi].setSize(fieldValues[fieldi].size());
forAll(fields[fieldi], tracki)
{
fields[fieldi][tracki].transfer(fieldValues[fieldi][tracki]);
}
}
writerPtr().write(true, times, tracks, fieldNames, fields, os);
}
template<class Type>
Foam::label setTrackFields
(
const objectRegistry& obr,
List<List<DynamicList<Type>>>& fields,
List<word>& fieldNames,
const label nTracks,
const labelList& startIds,
const List<labelField>& allOrigProcs,
const List<labelField>& allOrigIds,
const label maxPositions,
const label sampleFrequency
)
{
const auto availableFieldPtrs = obr.lookupClass<IOField<Type>>();
fieldNames = availableFieldPtrs.toc();
if (Pstream::parRun())
{
Pstream::combineGather(fieldNames, ListOps::uniqueEqOp<word>());
Pstream::combineScatter(fieldNames);
Foam::sort(fieldNames);
}
const label nFields = fieldNames.size();
if (fields.empty())
{
fields.setSize(nFields);
fieldNames.setSize(nFields);
forAll(fields, i)
{
fields[i].setSize(nTracks);
}
}
forAll(fieldNames, fieldi)
{
const word& fieldName = fieldNames[fieldi];
const auto* fldPtr = obr.cfindObject<IOField<Type>>(fieldName);
createTrack
(
fldPtr ? static_cast<const Field<Type>>(*fldPtr) : Field<Type>(),
fields[fieldi]
);
}
return nFields;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
int main(int argc, char *argv[])
{
argList::addNote
(
"Generate a file of particle tracks for cases that were"
"Generate a legacy VTK file of particle tracks for cases that were"
" computed using a tracked-parcel-type cloud"
);
@ -267,9 +76,9 @@ int main(int argc, char *argv[])
<< nl << endl;
labelList maxIds(Pstream::nProcs(), -1);
forAll(timeDirs, timei)
forAll(timeDirs, timeI)
{
runTime.setTime(timeDirs[timei], timei);
runTime.setTime(timeDirs[timeI], timeI);
Info<< "Time = " << runTime.timeName() << endl;
Info<< " Reading particle positions" << endl;
@ -283,8 +92,6 @@ int main(int argc, char *argv[])
const label origId = p.origId();
const label origProc = p.origProc();
// Handle case where we are processing particle data generated in
// parallel using more cores than when running this application.
if (origProc >= maxIds.size())
{
maxIds.setSize(origProc+1, -1);
@ -317,7 +124,7 @@ int main(int argc, char *argv[])
// Calculate starting ids for particles on each processor
labelList startIds(numIds.size(), Zero);
for (label i = 0; i < numIds.size()-1; ++i)
for (label i = 0; i < numIds.size()-1; i++)
{
startIds[i+1] += startIds[i] + numIds[i];
}
@ -325,135 +132,130 @@ int main(int argc, char *argv[])
// Number of tracks to generate
const label nTracks =
maxTracks > 0
? min(nParticle/sampleFrequency, maxTracks)
: nParticle/sampleFrequency;
label nTracks = nParticle/sampleFrequency;
// Storage for all particle tracks
List<DynamicList<vector>> allTracks(nTracks);
List<DynamicList<scalar>> allTrackTimes(nTracks);
// Lists of field, tracki, trackValues
//List<List<DynamicList<label>>> labelFields;
List<List<DynamicList<scalar>>> scalarFields;
List<List<DynamicList<vector>>> vectorFields;
List<List<DynamicList<sphericalTensor>>> sphTensorFields;
List<List<DynamicList<symmTensor>>> symTensorFields;
List<List<DynamicList<tensor>>> tensorFields;
//List<word> labelFieldNames;
List<word> scalarFieldNames;
List<word> vectorFieldNames;
List<word> sphTensorFieldNames;
List<word> symTensorFieldNames;
List<word> tensorFieldNames;
Info<< "\nGenerating " << nTracks << " particle tracks for cloud "
<< cloudName << nl << endl;
forAll(timeDirs, timei)
forAll(timeDirs, timeI)
{
runTime.setTime(timeDirs[timei], timei);
runTime.setTime(timeDirs[timeI], timeI);
Info<< "Time = " << runTime.timeName() << endl;
List<pointField> allPositions(Pstream::nProcs());
List<labelField> allOrigIds(Pstream::nProcs());
List<labelField> allOrigProcs(Pstream::nProcs());
// Read particles. Will be size 0 if no particles.
Info<< " Reading particle positions" << endl;
passiveParticleCloud myCloud(mesh, cloudName);
pointField localPositions(myCloud.size(), Zero);
scalarField localTimes(myCloud.size(), Zero);
List<labelField> allOrigIds(Pstream::nProcs());
List<labelField> allOrigProcs(Pstream::nProcs());
// Collect the track data on all processors that have positions
allPositions[Pstream::myProcNo()].setSize
(
myCloud.size(),
point::zero
);
allOrigIds[Pstream::myProcNo()].setSize(myCloud.size(), Zero);
allOrigProcs[Pstream::myProcNo()].setSize(myCloud.size(), Zero);
label i = 0;
for (const passiveParticle& p : myCloud)
{
allPositions[Pstream::myProcNo()][i] = p.position();
allOrigIds[Pstream::myProcNo()][i] = p.origId();
allOrigProcs[Pstream::myProcNo()][i] = p.origProc();
localPositions[i] = p.position();
localTimes[i] = runTime.value();
++i;
}
// Collect the track data on the master processor
Pstream::gatherList(allPositions);
Pstream::gatherList(allOrigIds);
Pstream::gatherList(allOrigProcs);
objectRegistry obr
(
IOobject
(
"cloudFields",
runTime.timeName(),
runTime
)
);
Info<< " Constructing tracks" << nl << endl;
if (Pstream::master())
{
forAll(allPositions, proci)
{
forAll(allPositions[proci], i)
{
label globalId =
startIds[allOrigProcs[proci][i]]
+ allOrigIds[proci][i];
myCloud.readFromFiles(obr, fieldNames);
// Create track positions and track time fields
// (not registered as IOFields)
// Note: createTrack is a local #define to reduce arg count...
createTrack(localPositions, allTracks);
createTrack(localTimes, allTrackTimes);
// Create the track fields
// Note: setFields is a local #define to reduce arg count...
//setFields(labelFields, labelFieldNames);
setFields(scalarFields, scalarFieldNames);
setFields(vectorFields, vectorFieldNames);
setFields(sphTensorFields, sphTensorFieldNames);
setFields(symTensorFields, symTensorFieldNames);
setFields(tensorFields, tensorFieldNames);
if (globalId % sampleFrequency == 0)
{
label trackId = globalId/sampleFrequency;
if (allTracks[trackId].size() < maxPositions)
{
allTracks[trackId].append
(
allPositions[proci][i]
);
}
}
}
}
}
}
if (Pstream::master())
{
PtrList<coordSet> tracks(allTracks.size());
List<scalarField> times(tracks.size());
forAll(tracks, tracki)
forAll(allTracks, trackI)
{
tracks.set
(
tracki,
new coordSet("track" + Foam::name(tracki), "distance")
trackI,
new coordSet
(
"track" + Foam::name(trackI),
"distance"
)
);
tracks[tracki].transfer(allTracks[tracki]);
times[tracki].transfer(allTrackTimes[tracki]);
tracks[trackI].transfer(allTracks[trackI]);
}
Info<< nl;
autoPtr<writer<scalar>> scalarFormatterPtr = writer<scalar>::New
(
setFormat
);
const label Uid = vectorFieldNames.find(UName);
List<vectorField> dirs(nTracks);
//OFstream vtkTracks(vtkPath/"particleTracks.vtk");
fileName vtkFile
(
scalarFormatterPtr().getFileName
(
tracks[0],
wordList(0)
)
);
if (Uid != -1)
{
const auto& UTracks = vectorFields[Uid];
forAll(UTracks, tracki)
{
const auto& U = UTracks[tracki];
dirs[tracki] = U/(mag(U) + ROOTVSMALL);
}
}
OFstream vtkTracks
(
vtkPath/("particleTracks." + vtkFile.ext())
);
// Write track fields
// Note: writeFields is a local #define to reduce arg count...
//writeFields(allLabelFields, labelFieldNames, tracks);
writeFields(scalarFields, scalarFieldNames, tracks, times, dirs);
writeFields(vectorFields, vectorFieldNames, tracks, times, dirs);
writeFields(sphTensorFields, sphTensorFieldNames, tracks, times, dirs);
writeFields(symTensorFields, symTensorFieldNames, tracks, times, dirs);
writeFields(tensorFields, tensorFieldNames, tracks, times, dirs);
Info<< "\nWriting particle tracks in " << setFormat
<< " format to " << vtkTracks.name()
<< nl << endl;
scalarFormatterPtr().write
(
true,
tracks,
wordList(0),
List<List<scalarField>>(0),
vtkTracks
);
}
Info<< nl << "End\n" << endl;
Info<< "End\n" << endl;
return 0;
}

View File

@ -27,7 +27,7 @@ Application
steadyParticleTracks
Group
grpPostProcessingUtilities
grpPostProcessingUtilitie
Description
Generate a legacy VTK file of particle tracks for cases that were

View File

@ -72,19 +72,24 @@ int main(int argc, char *argv[])
"Suppress calculation/display of point interpolators"
);
argList::addVerboseOption
argList::addBoolOption
(
"verbose",
"Additional verbosity"
);
#include "addRegionOption.H"
#include "setRootCase.H"
#include "createTime.H"
const bool noInterpolate = args.found("no-interpolate");
// const bool verbose = args.found("verbose");
args.readIfPresent("visual-length", lumpedPointState::visLength);
#include "createTime.H"
if (args.dryRun())
{
// Create without a mesh

View File

@ -203,8 +203,7 @@ static inline scalar averageSurrounding
template<class Type>
static inline Ostream& putUniform(Ostream& os, const word& key, const Type& val)
{
os.writeKeyword(key)
<< word("uniform") << token::SPACE
os.writeKeyword(key) << word("uniform") << token::SPACE
<< val << token::END_STATEMENT << nl;
return os;
}

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2019-2021 OpenCFD Ltd.
Copyright (C) 2019-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -54,7 +54,7 @@ void Foam::PDRparams::readDefaults(const dictionary& dict)
outer_orthog = dict.found("outer_orthog");
dict.readIfPresent("debug.level", debugLevel);
dict.readIfPresent("debugLevel", debugLevel);
dict.readIfPresent("nFacesToBlockC", nFacesToBlockC);
dict.readIfPresent("nPairsToBlockC", nPairsToBlockC);
dict.readIfPresent("overlaps", overlaps);

View File

@ -16,7 +16,7 @@ const vector L(dict.get<vector>("L"));
const Vector<label> N(dict.get<Vector<label>>("N"));
// Wave number vs energy profile
autoPtr<Function1<scalar>> Ek(Function1<scalar>::New("Ek", dict, &runTime));
autoPtr<Function1<scalar>> Ek(Function1<scalar>::New("Ek", dict));
// Number of modes
const label nModes = dict.get<label>("nModes");

View File

@ -137,7 +137,7 @@ composedFunctionImplicitFunction
{
FatalIOErrorInFunction(funcDict)
<< "Entry " << key << " is not a dictionary" << endl
<< exit(FatalIOError);
<< exit(FatalError);
}
const dictionary& subdict = dEntry.dict();

View File

@ -231,21 +231,18 @@ int main(int argc, char *argv[])
dictionary& patchDict = boundaryFieldDict.subDict(patchName);
auto valueExpr_
expressions::exprString expr
(
expressions::exprString::getEntry
(
"expression",
currDict,
true // strip comments
)
currDict.get<string>("expression"),
currDict,
true // strip comments
);
Info<< "Set boundaryField/" << patchName << '/'
<< targetName << nl
<< "with expression" << nl
<< "<<<<" << nl
<< valueExpr_.c_str() << nl
<< expr.c_str() << nl
<< ">>>>" << nl;
expressions::patchExprDriver driver(currDict, mesh);
@ -258,7 +255,7 @@ int main(int argc, char *argv[])
);
driver.clearVariables();
driver.parse(valueExpr_);
driver.parse(expr);
// Serializing via Field::writeEntry etc
OStringStream serialize;

View File

@ -53,17 +53,18 @@ Note
using namespace Foam;
using FieldAssociation = expressions::FieldAssociation;
using FieldAssociation = expressions::volumeExpr::FieldAssociation;
word fieldGeoType(const FieldAssociation geoType)
{
switch (geoType)
{
case FieldAssociation::POINT_DATA : return "points"; break;
case FieldAssociation::FACE_DATA : return "faces"; break;
case FieldAssociation::VOLUME_DATA : return "cells"; break;
case FieldAssociation::SURFACE_DATA : return "faces"; break;
case FieldAssociation::POINT_DATA : return "points"; break;
default: break;
}
return "unknown";
}
@ -74,7 +75,7 @@ struct setExprFieldsControl
bool dryRun;
bool debugParsing;
bool cacheVariables;
bool hasDimensions;
bool useDimensions;
bool createNew;
bool keepPatches;
bool correctPatches;
@ -122,12 +123,13 @@ void doCorrectBoundaryConditions
{}
template<class GeoField>
bool setField
template<class GeoField, class Mesh>
void setField
(
const word& fieldName,
const GeoField& evaluated,
const boolField& fieldMask,
const Mesh& mesh,
const GeoField& result,
const scalarField& cond,
const dimensionSet& dims,
const wordList& valuePatches,
@ -137,8 +139,6 @@ bool setField
Info<< "setField(" << fieldName << "): "
<< pTraits<GeoField>::typeName << endl;
const auto& mesh = evaluated.mesh();
tmp<GeoField> toutput;
if (ctrl.createNew)
@ -171,57 +171,55 @@ bool setField
auto& output = toutput.ref();
label numValuesChanged = 0;
label setCells = 0;
// Internal field
if (fieldMask.empty())
if (cond.empty())
{
// No field-mask - set entire internal field
numValuesChanged = output.size();
// No condition - set all
output = result;
output.primitiveFieldRef() = evaluated;
setCells = output.size();
}
else
{
auto& internal = output.primitiveFieldRef();
forAll(internal, idx)
forAll(output, celli)
{
if (fieldMask[idx])
if (expressions::boolOp<scalar>()(cond[celli]))
{
internal[idx] = evaluated[idx];
++numValuesChanged;
output[celli] = result[celli];
++setCells;
}
}
}
// Boundary fields
forAll(evaluated.boundaryField(), patchi)
const label totalCells = returnReduce(output.size(), plusOp<label>());
reduce(setCells, plusOp<label>());
forAll(result.boundaryField(), patchi)
{
auto& pf = output.boundaryFieldRef()[patchi];
if (pf.patch().coupled())
{
pf == evaluated.boundaryField()[patchi];
pf == result.boundaryField()[patchi];
}
}
doCorrectBoundaryConditions(ctrl.correctBCs, output);
const label numTotal = returnReduce(output.size(), plusOp<label>());
reduce(numValuesChanged, plusOp<label>());
if (numValuesChanged == numTotal)
if (setCells == totalCells)
{
Info<< "Set all ";
}
else
{
Info<< "Set " << numValuesChanged << " of ";
Info<< "Set " << setCells << " of ";
}
Info<< numTotal << " values" << endl;
Info<< totalCells << " cells" << endl;
if (ctrl.hasDimensions)
doCorrectBoundaryConditions(ctrl.correctBCs, output);
if (ctrl.useDimensions)
{
Info<< "Setting dimensions to " << dims << endl;
output.dimensions().reset(dims);
@ -236,8 +234,6 @@ bool setField
Info<< "Writing to " << output.name() << nl;
output.writeObject(ctrl.streamOpt, true);
}
return true;
}
@ -245,8 +241,8 @@ void evaluate
(
const fvMesh& mesh,
const word& fieldName,
const expressions::exprString& valueExpr_,
const expressions::exprString& maskExpr_,
const expressions::exprString& expression,
const expressions::exprString& condition,
const dictionary& dict,
const dimensionSet& dims,
const wordList& valuePatches,
@ -277,8 +273,10 @@ void evaluate
if (oldFieldType == IOobject::typeName)
{
FatalErrorInFunction
<< "Field " << fieldName << "(type: " << oldFieldType
<< ") seems to be missing. Use 'create'" << nl
<< "Field " << fieldName << " is "
<< oldFieldType
<< ". Seems that it does not exist. Use 'create'"
<< nl
<< exit(FatalError);
}
@ -286,21 +284,17 @@ void evaluate
<< " (type " << oldFieldType << ')';
}
Info<< " time=" << mesh.thisDb().time().timeName() << nl
<< "Expression:" << nl
<< ">>>>" << nl
<< valueExpr_.c_str() << nl
<< expression.c_str() << nl
<< "<<<<" << nl;
bool evalFieldMask =
(maskExpr_.size() && maskExpr_ != "true" && maskExpr_ != "1");
if (evalFieldMask)
if (condition.size() && condition != "true")
{
Info<< "field-mask:" << nl
Info<< "Condition:" << nl
<< ">>>>" << nl
<< maskExpr_.c_str() << nl
<< condition.c_str() << nl
<< "<<<<" << nl;
}
@ -324,95 +318,128 @@ void evaluate
if (ctrl.debugParsing)
{
Info<< "Parsing expression: " << valueExpr_ << "\nand field-mask "
<< maskExpr_ << nl << endl;
Info<< "Parsing expression: " << expression << "\nand condition "
<< condition << nl << endl;
driver.setDebugging(true, true);
}
driver.clearVariables();
scalarField conditionField;
// Handle "field-mask" evaluation
bool evaluatedCondition = false;
boolField fieldMask;
FieldAssociation maskFieldAssoc(FieldAssociation::NO_DATA);
FieldAssociation conditionDataType(FieldAssociation::VOLUME_DATA);
if (evalFieldMask)
if (condition.size() && condition != "true")
{
if (ctrl.debugParsing)
{
Info<< "Parsing field-mask:" << maskExpr_ << endl;
Info<< "Parsing condition:" << condition << endl;
}
driver.parse(maskExpr_);
driver.parse(condition);
if (ctrl.debugParsing)
{
Info<< "Parsed field-mask" << endl;
Info<< "Parsed condition" << endl;
}
if (driver.isLogical())
// Process any/all scalar fields. May help with diagnosis
bool goodCond = true;
while (goodCond)
{
auto& result = driver.result();
if (result.is_bool())
// volScalarField
{
fieldMask = result.getResult<bool>();
maskFieldAssoc = driver.fieldAssociation();
const auto* ptr = driver.isResultType<volScalarField>();
if (ptr)
{
conditionField = ptr->internalField();
break;
}
}
// surfaceScalarField
{
const auto* ptr = driver.isResultType<surfaceScalarField>();
if (ptr)
{
conditionField = ptr->internalField();
conditionDataType = FieldAssociation::SURFACE_DATA;
break;
}
}
// pointScalarField
{
const auto* ptr = driver.isResultType<pointScalarField>();
if (ptr)
{
conditionField = ptr->internalField();
conditionDataType = FieldAssociation::POINT_DATA;
break;
}
}
// No matching field types
goodCond = false;
}
// Slightly pedantic...
driver.clearField();
driver.clearResult();
// Verify that it also logical
goodCond = goodCond && driver.isLogical();
evalFieldMask = (maskFieldAssoc != FieldAssociation::NO_DATA);
if (!evalFieldMask)
if (!goodCond)
{
FatalErrorInFunction
<< " mask: " << maskExpr_
<< " condition: " << condition
<< " does not evaluate to a logical expression: "
<< driver.resultType() << nl
#ifdef FULLDEBUG
<< "contents: " << fieldMask
<< "contents: " << conditionField
#endif
<< exit(FatalError);
}
if (ctrl.debugParsing)
{
Info<< "Field-mask evaluates to "
<< fieldMask << nl;
Info<< "Condition evaluates to "
<< conditionField << nl;
}
evaluatedCondition = true;
}
if (ctrl.debugParsing)
{
Info<< "Parsing expression:" << valueExpr_ << endl;
Info<< "Parsing expression:" << expression << endl;
}
driver.parse(valueExpr_);
driver.parse(expression);
if (ctrl.debugParsing)
{
Info<< "Parsed expression" << endl;
}
if (evalFieldMask && maskFieldAssoc != driver.fieldAssociation())
if (evaluatedCondition)
{
FatalErrorInFunction
<< "Mismatch between field-mask geometric type ("
<< fieldGeoType(maskFieldAssoc) << ") and" << nl
<< "expression geometric type ("
<< fieldGeoType(driver.fieldAssociation()) << ')' << nl
<< nl
<< "expression: " << valueExpr_ << nl
<< "field-mask: " << maskExpr_ << nl
<< nl
<< exit(FatalError);
if (conditionDataType != driver.fieldAssociation())
{
FatalErrorInFunction
<< "Mismatch between condition geometric type ("
<< fieldGeoType(conditionDataType) << ") and" << nl
<< "expression geometric type ("
<< fieldGeoType(driver.fieldAssociation()) << ')' << nl
<< nl
<< "Expression: " << expression << nl
<< "Condition: " << condition << nl
<< nl
<< exit(FatalError);
}
}
if (!oldFieldType.empty() && driver.resultType() != oldFieldType)
if (!ctrl.createNew && driver.resultType() != oldFieldType)
{
FatalErrorInFunction
<< "Inconsistent types: " << fieldName << " is "
@ -424,69 +451,81 @@ void evaluate
Info<< "Dispatch ... " << driver.resultType() << nl;
#undef setFieldDispatch
#define setFieldDispatch(FieldType) \
{ \
/* FieldType */ \
const auto* ptr = driver.isResultType<FieldType>(); \
if (ptr) \
{ \
/* driver.getResult<FieldType>(correctPatches), */ \
\
setField \
( \
fieldName, \
mesh, \
*ptr, \
conditionField, \
dims, \
valuePatches, \
ctrl \
); \
return; \
} \
} \
bool applied = false;
switch (driver.fieldAssociation())
{
#undef doLocalCode
#define doLocalCode(GeoField) \
{ \
const auto* ptr = driver.isResultType<GeoField>(); \
if (ptr) \
{ \
applied = setField \
( \
fieldName, \
*ptr, \
fieldMask, \
dims, \
valuePatches, \
ctrl \
); \
break; \
} \
}
case FieldAssociation::VOLUME_DATA:
{
doLocalCode(volScalarField);
doLocalCode(volVectorField);
doLocalCode(volTensorField);
doLocalCode(volSymmTensorField);
doLocalCode(volSphericalTensorField);
break;
}
case FieldAssociation::FACE_DATA:
{
doLocalCode(surfaceScalarField);
doLocalCode(surfaceVectorField);
doLocalCode(surfaceTensorField);
doLocalCode(surfaceSymmTensorField);
doLocalCode(surfaceSphericalTensorField);
break;
}
case FieldAssociation::POINT_DATA:
{
doLocalCode(pointScalarField);
doLocalCode(pointVectorField);
doLocalCode(pointTensorField);
doLocalCode(pointSymmTensorField);
doLocalCode(pointSphericalTensorField);
break;
}
setFieldDispatch(volScalarField);
setFieldDispatch(volVectorField);
setFieldDispatch(volTensorField);
setFieldDispatch(volSymmTensorField);
setFieldDispatch(volSphericalTensorField);
default: break;
#undef doLocalCode
}
setFieldDispatch(surfaceScalarField);
setFieldDispatch(surfaceVectorField);
setFieldDispatch(surfaceTensorField);
setFieldDispatch(surfaceSymmTensorField);
setFieldDispatch(surfaceSphericalTensorField);
if (!applied)
{
FatalErrorInFunction
<< "Expression evaluates to an unsupported type: "
<< driver.resultType() << nl << nl
<< "Expression " << valueExpr_ << nl << endl
<< exit(FatalError);
}
#undef setFieldDispatch
#define setFieldDispatch(FieldType) \
{ \
/* FieldType */ \
const auto* ptr = driver.isResultType<FieldType>(); \
\
if (ptr) \
{ \
/* driver.getResult<FieldType>(correctPatches), */ \
\
setField \
( \
fieldName, \
pointMesh::New(mesh), \
*ptr, \
conditionField, \
dims, \
valuePatches, \
ctrl \
); \
return; \
} \
} \
setFieldDispatch(pointScalarField);
setFieldDispatch(pointVectorField);
setFieldDispatch(pointTensorField);
setFieldDispatch(pointSymmTensorField);
setFieldDispatch(pointSphericalTensorField);
#undef setFieldDispatch
// Nothing dispatched?
FatalErrorInFunction
<< "Expression evaluates to an unsupported type: "
<< driver.resultType() << nl << nl
<< "Expression " << expression << nl << endl
<< exit(FatalError);
}
@ -514,8 +553,9 @@ int main(int argc, char *argv[])
(
"Evaluate but do not write"
);
argList::addVerboseOption
argList::addBoolOption
(
"verbose",
"Additional verbosity",
true // Advanced option
);
@ -544,13 +584,12 @@ int main(int argc, char *argv[])
);
argList::addOption
(
"field-mask",
"condition",
"logic",
"The field mask (logical condition) when to apply the expression"
"The logical condition when to apply the expression"
" (command-line operation)",
true // Advanced option
);
argList::addOptionCompat("field-mask", {"condition", 2106});
argList::addOption
(
"dimensions",
@ -623,6 +662,9 @@ int main(int argc, char *argv[])
#include "createTime.H"
const bool dryrun = args.dryRun();
const bool verbose = args.found("verbose");
const word dictName("setExprFieldsDict");
instantList times = timeSelector::select0(runTime, args);
@ -687,7 +729,7 @@ int main(int argc, char *argv[])
wordHashSet badOptions
({
"create", "keepPatches", "value-patches",
"field-mask", "expression", "dimensions"
"condition", "expression", "dimensions"
});
badOptions.retain(args.options());
@ -755,7 +797,7 @@ int main(int argc, char *argv[])
setExprFieldsControl ctrl;
ctrl.dryRun = args.dryRun();
ctrl.dryRun = dryrun;
ctrl.debugParsing = args.found("debug-parser");
ctrl.cacheVariables = !args.found("no-variable-caching");
@ -763,24 +805,25 @@ int main(int argc, char *argv[])
ctrl.keepPatches = args.found("keepPatches");
ctrl.correctPatches = !args.found("noCorrectPatches");
ctrl.correctBCs = args.found("correctResultBoundaryFields");
ctrl.hasDimensions = args.found("dimensions");
ctrl.useDimensions = args.found("dimensions");
ctrl.streamOpt.format(runTime.writeFormat());
if (args.found("ascii"))
{
ctrl.streamOpt.format(IOstream::ASCII);
}
expressions::exprString valueExpr_
(
args["expression"],
dictionary::null
);
expressions::exprString
expression
(
args["expression"],
dictionary::null
);
expressions::exprString maskExpr_;
args.readIfPresent("field-mask", maskExpr_);
expressions::exprString condition;
args.readIfPresent("condition", condition);
dimensionSet dims;
if (ctrl.hasDimensions)
if (ctrl.useDimensions)
{
ITstream is(args.lookup("dimensions"));
is >> dims;
@ -790,8 +833,8 @@ int main(int argc, char *argv[])
(
mesh,
fieldName,
valueExpr_,
maskExpr_,
expression,
condition,
dictionary::null,
dims,
args.getList<word>("value-patches", false),
@ -826,7 +869,7 @@ int main(int argc, char *argv[])
setExprFieldsControl ctrl;
ctrl.dryRun = args.dryRun();
ctrl.dryRun = dryrun;
ctrl.debugParsing = args.found("debug-parser");
ctrl.cacheVariables = !args.found("no-variable-caching");
@ -859,28 +902,22 @@ int main(int argc, char *argv[])
const word fieldName(dict.get<word>("field"));
auto valueExpr_
expressions::exprString expression
(
expressions::exprString::getEntry
(
"expression",
dict
)
dict.get<string>("expression"),
dict
);
expressions::exprString maskExpr_;
{
const entry* eptr = dict.findCompat
(
"fieldMask", {{"condition", 2106}},
keyType::LITERAL
);
expressions::exprString condition;
if (eptr)
{
maskExpr_.readEntry(eptr->keyword(), dict);
maskExpr_.trim();
}
if (dict.found("condition"))
{
condition =
expressions::exprString
(
dict.get<string>("condition"),
dict
);
}
dimensionSet dims;
@ -894,10 +931,10 @@ int main(int argc, char *argv[])
{
dimPtr->stream() >> dims;
}
ctrl.hasDimensions = bool(dimPtr);
ctrl.useDimensions = bool(dimPtr);
}
if (args.verbose() && !timei)
if (verbose && !timei)
{
// Report once
Info<< "Processing" << dict << nl;
@ -907,8 +944,8 @@ int main(int argc, char *argv[])
(
mesh,
fieldName,
valueExpr_,
maskExpr_,
expression,
condition,
dict,
dims,
dict.getOrDefault<wordList>("valuePatches", wordList()),

View File

@ -1,7 +1,7 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v2112 |
| \\ / O peration | Version: v2106 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
@ -31,7 +31,7 @@ expressions
"radius = 0.1"
);
fieldMask
condition
#{
// Within the radius
(mag(pos() - $[(vector)constants.centre]) < radius)

View File

@ -308,8 +308,9 @@ int main(int argc, char *argv[])
"Split surface along non-manifold edges "
"(default split is fully disconnected)"
);
argList::addVerboseOption
argList::addBoolOption
(
"verbose",
"Additional verbosity"
);
argList::addBoolOption

View File

@ -46,9 +46,6 @@
# The '-show-api' and '-show-patch' options extract values from
# the "META-INFO/api-info" file
#
# The '-show-build' options extract values from
# the "META-INFO/build-info" file
#
# SeeAlso
# META-INFO/README.md for other routines that also use META-INFO.
#
@ -74,7 +71,6 @@ options:
-etc=[DIR] set/unset FOAM_CONFIG_ETC for alternative etc directory
-show-api Print META-INFO api value and exit
-show-patch Print META-INFO patch value and exit
-show-build Print META-INFO build value and exit
-with-api=NUM Specify alternative api value to search with
-quiet (-q) Suppress all normal output
-silent (-s) Suppress stderr, except -csh-verbose, -sh-verbose output
@ -159,14 +155,6 @@ getApiInfo()
}
# Get 'build' from META-INFO/build-info
getBuildValue()
{
value="$(sed -ne 's@^build *= *\([^ ]*\).*@\1@p' "$projectDir"/META-INFO/build-info 2>/dev/null)"
echo "$value"
}
#-------------------------------------------------------------------------------
unset shellOutput verboseOutput
unset optAll optConfig optList projectApi
@ -189,10 +177,6 @@ do
getApiInfo patch
exit $?
;;
-show-build) # Show build information and exit
getBuildValue
exit $?
;;
-with-api=*)
projectApi="${1#*=}"
;;

View File

@ -123,7 +123,7 @@ cleanCase()
rm -rf system/machines
# Possible blockMesh output
rm -f blockTopology.vtu blockFaces.vtp blockTopology.obj blockCentres.obj
rm -f blockTopology.vtu blockTopology.obj blockCentres.obj
# From mpirunDebug
rm -f gdbCommands mpirun.schema

View File

@ -5,7 +5,7 @@
# \\ / A nd | www.openfoam.com
# \\/ M anipulation |
#------------------------------------------------------------------------------
# Copyright (C) 2019-2021 OpenCFD Ltd.
# Copyright (C) 2019-2020 OpenCFD Ltd.
#------------------------------------------------------------------------------
# License
# This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
@ -39,18 +39,16 @@ fi
#------------------------------------------------------------------------------
_com_openfoam_projectDir="$projectDir"
if [ -d "$_com_openfoam_projectDir" ]
if [ -d "$projectDir" ]
then
_com_openfoam_bashrcFile="${_com_openfoam_projectDir}/etc/bashrc"
_foamSourceBashEnv="$projectDir/etc/bashrc"
else
unset _com_openfoam_bashrcFile
unset _foamSourceBashEnv
fi
# Source the user bashrc first. Improbable they use the following variables:
# * _com_openfoam_bashrcFile
# * _com_openfoam_projectDir
# Source the user bashrc first.
# Simply hope that they don't unset/reset _foamSourceBashEnv !!
if [ -f "$HOME/.bashrc" ]
then
@ -60,90 +58,40 @@ fi
# Source the OpenFOAM etc/bashrc
if [ -f "$_com_openfoam_bashrcFile" ]
if [ -f "$_foamSourceBashEnv" ]
then
. "$_com_openfoam_bashrcFile" $FOAM_SETTINGS
. "$_foamSourceBashEnv" $FOAM_SETTINGS
# Avoid further inheritance
unset FOAM_SETTINGS
else
echo "Missing OpenFOAM etc/bashrc in '${_com_openfoam_projectDir}'" 1>&2
fi
unset _com_openfoam_bashrcFile _com_openfoam_projectDir
# Welcome banner - format somewhat like Ubuntu welcome
#----
## Welcome to Ubuntu VER (GNU/Linux ... x86_64)
##
## * Documentation: ...
#----
if [ -n "$PS1" ] ## Interactive
then
if [ -d "$WM_PROJECT_DIR" ]
# Some feedback
if [ -n "$PS1" ] && [ -d "$WM_PROJECT_DIR" ]
then
_foam_api="$("$WM_PROJECT_DIR"/bin/foamEtcFile -show-api 2>/dev/null)"
_foam_patch="$("$WM_PROJECT_DIR"/bin/foamEtcFile -show-patch 2>/dev/null)"
_foam_build="$("$WM_PROJECT_DIR"/bin/foamEtcFile -show-build 2>/dev/null)"
info="$("$WM_PROJECT_DIR"/bin/foamEtcFile -show-patch 2>/dev/null)"
unset _foam_arch1
case "$WM_OPTIONS" in # Or WM_LABEL_SIZE?
(*Int32*) _foam_arch1="label=32" ;;
(*Int64*) _foam_arch1="label=64" ;;
esac
# echo "Using: OpenFOAM-$WM_PROJECT_VERSION ($FOAM_API${info:+ patch=$info}) - visit www.openfoam.com" 1>&2
echo "Using: OpenFOAM-$WM_PROJECT_VERSION${info:+ (patch=$info)} - visit www.openfoam.com" 1>&2
echo "Arch: $WM_OPTIONS (mpi=$FOAM_MPI)" 1>&2
unset _foam_arch2
case "$WM_OPTIONS" in # Or WM_PRECISION_OPTION?
(*SPDPInt*) _foam_arch2="scalar=32;solveScalar=64" ;;
(*SPInt*) _foam_arch2="scalar=32" ;;
(*DPInt*) _foam_arch2="scalar=64" ;;
esac
if [ "${_foam_patch:-0}" = 0 ]
then
unset _foam_patch
fi
if [ -n "$_foam_build" ]
then
# Everything there - format like binary -help output
_foam_build="${_foam_build}${_foam_patch:+ (patch=${_foam_patch})}"
_foam_verinfo="${_foam_api}"
else
# Missing build info - combine api and patch info together
_foam_verinfo="${_foam_api}${_foam_patch:+ patch=${_foam_patch}}"
fi
echo "openfoam = $WM_PROJECT_DIR" 1>&2
echo 1>&2
echo " * Using: OpenFOAM-$WM_PROJECT_VERSION (${_foam_verinfo}) - visit www.openfoam.com" 1>&2
if [ -n "$_foam_build" ]
then
echo " * Build: ${_foam_build}" 1>&2
fi
# Arch: LSB;label=32;scalar=64
echo " * Arch: $_foam_arch1;$_foam_arch2" 1>&2
echo " * Platform: $WM_OPTIONS (mpi=$FOAM_MPI)" 1>&2
echo 1>&2
## echo "$WM_PROJECT_DIR" 1>&2
## echo 1>&2
# Set prompt as reminder that this is a shell session
# Chalmers likes this one:
# PS1="openfoam${_foam_api}:"'$(foamPwd)\n\u\$ '
# PS1="OpenFOAM${FOAM_API:+-$FOAM_API}:"'$(foamPwd)\n\u\$ '
PS1="openfoam${_foam_api}:"'\w/\n\u\$ '
unset _foam_arch1 _foam_arch2
unset _foam_api _foam_patch _foam_build _foam_verinfo
else
# Adjust prompt if not found - reminder that it is a shell session
PS1="openfoam(not-found):"'\w/\n\u\$ '
PS1="OpenFOAM${FOAM_API:+-$FOAM_API}:"'\w/\n\u\$ '
fi
echo "OpenFOAM shell session - use 'exit' to quit" 1>&2
echo 1>&2
else
echo "Could not locate OpenFOAM etc/bashrc in '$projectDir'" 1>&2
fi
echo "OpenFOAM shell session - use exit to quit" 1>&2
echo 1>&2
# Cleanup variables (done as final statement for a clean exit code)
unset projectDir
unset _foamSourceBashEnv projectDir
#------------------------------------------------------------------------------

View File

@ -1,4 +1,4 @@
## Known Build Issues (v2012, v2106, v2112)
## Known Build Issues (v2012, v2106)
### Windows cross-compilation

View File

@ -1,7 +1,7 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v2112 |
| \\ / O peration | Version: v2106 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
@ -34,7 +34,7 @@ expressions
"radius = 0.1"
);
fieldMask
condition
#{
// Within the radius
(mag(pos() - $[(vector)constants.centre]) < radius)

View File

@ -1,7 +1,7 @@
/*--------------------------------*- C++ -*----------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Version: v2112
\\ / O peration | Version: v2106
\\ / A nd | Website: www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
@ -15,12 +15,11 @@ Description
\*---------------------------------------------------------------------------*/
type dsmcFields;
libs ("liblagrangianFunctionObjects.so");
type dsmcFields;
libs ("liblagrangianFunctionObjects.so");
// Names for reference purposes only
fields ( rhoNMean rhoMMean momentumMean linearKEMean internalEMean
iDofMean fDMean );
fields (rhoNMean rhoMMean momentumMean linearKEMean internalEMean
iDofMean fDMean);
executeControl writeTime;
writeControl writeTime;

View File

@ -78,7 +78,7 @@ CONSTRUCT
scalarData_(dict.get<scalar>("scalarData")),
data_(dict.get<TYPE>("data")),
fieldData_("fieldData", dict, p.size()),
timeVsData_(Function1<TYPE>::New("timeVsData", dict, &this->db())),
timeVsData_(Function1<TYPE>::New("timeVsData", dict)),
wordData_(dict.getOrDefault<word>("wordName", "wordDefault")),
labelData_(-1),
boolData_(false)

View File

@ -1,121 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2021 OpenCFD Ltd.
Copyright (C) YEAR AUTHOR,AFFILIATION
-------------------------------------------------------------------------------
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 "codedFunction1Template.H"
#include "addToRunTimeSelectionTable.H"
#include "unitConversion.H"
//{{{ begin codeInclude
${codeInclude}
//}}} end codeInclude
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * Local Functions * * * * * * * * * * * * * * //
//{{{ begin localCode
${localCode}
//}}} end localCode
// * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * //
// dynamicCode:
// SHA1 = ${SHA1sum}
//
// unique function name that can be checked if the correct library version
// has been loaded
extern "C" void ${typeName}_${SHA1sum}(bool load)
{
if (load)
{
// Code that can be explicitly executed after loading
}
else
{
// Code that can be explicitly executed before unloading
}
}
namespace Function1Types
{
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
//makeFunction1(${typeName}Function1, ${TemplateType});
defineTypeNameAndDebug
(
${typeName}Function1_${TemplateType},
0
);
Function1<${TemplateType}>::addRemovabledictionaryConstructorToTable
<${typeName}Function1_${TemplateType}>
addRemovable${typeName}Function1_${TemplateType}ConstructorToTable_;
} // namespace Function1Types
} // namespace Foam
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::Function1Types::
${typeName}Function1_${TemplateType}::
${typeName}Function1_${TemplateType}
(
const word& entryName,
const dictionary& dict,
const objectRegistry* obrPtr
)
:
Function1<${TemplateType}>(entryName, dict, obrPtr)
{
if (${verbose:-false})
{
printMessage("Construct ${typeName} Function1 from dictionary");
}
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
Foam::${TemplateType}
Foam::Function1Types::${typeName}Function1_${TemplateType}::value
(
const scalar x
) const
{
//{{{ begin code
${code}
//}}} end code
}
// ************************************************************************* //

View File

@ -1,119 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
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
Template for use with dynamic code generation of a Function1
SourceFiles
codedFunction1Template.C
\*---------------------------------------------------------------------------*/
#ifndef dynamicCode_codedFunction1_${typeName}_${TemplateType}_H
#define dynamicCode_codedFunction1_${typeName}_${TemplateType}_H
#include "Function1.H"
#include "dictionaryContent.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
namespace Function1Types
{
/*---------------------------------------------------------------------------*\
A coded version Function1
\*---------------------------------------------------------------------------*/
class ${typeName}Function1_${TemplateType}
:
public Function1<${TemplateType}>,
public dictionaryContent
{
// Private Member Functions
//- Report a message with the SHA1sum
inline static void printMessage(const char* message)
{
Info<< message << " sha1: " << SHA1sum << '\n';
}
public:
//- SHA1 representation of the code content
static constexpr const char* const SHA1sum = "${SHA1sum}";
//- Runtime type information
TypeName("${typeName}");
// Constructors
//- Construct from entry name, dictionary and registry
${typeName}Function1_${TemplateType}
(
const word& entryName,
const dictionary& dict,
const objectRegistry* obrPtr = nullptr
);
//- Copy construct
${typeName}Function1_${TemplateType}
(
const ${typeName}Function1_${TemplateType}& rhs
) = default;
//- Construct and return a clone
virtual tmp<Function1<${TemplateType}>> clone() const
{
return tmp<Function1<${TemplateType}>>
(
new ${typeName}Function1_${TemplateType}(*this)
);
}
//- Destructor
virtual ~${typeName}Function1_${TemplateType}() = default;
// Member Functions
//- Return value as a function of (scalar) independent variable
virtual ${TemplateType} value(const scalar x) const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Function1Types
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -83,13 +83,9 @@ addRemovableToRunTimeSelectionTable
dictionary
);
} // End namespace fv
} // End namespace Foam
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::fv::
${typeName}FvOption${SourceType}::
${typeName}FvOption${SourceType}
(
@ -110,7 +106,6 @@ ${typeName}FvOption${SourceType}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::fv::
${typeName}FvOption${SourceType}::
~${typeName}FvOption${SourceType}()
{
@ -124,7 +119,6 @@ ${typeName}FvOption${SourceType}::
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void
Foam::fv::
${typeName}FvOption${SourceType}::correct
(
GeometricField<${TemplateType}, fvPatchField, volMesh>& fld
@ -142,7 +136,6 @@ ${typeName}FvOption${SourceType}::correct
void
Foam::fv::
${typeName}FvOption${SourceType}::addSup
(
fvMatrix<${TemplateType}>& eqn,
@ -154,14 +147,13 @@ ${typeName}FvOption${SourceType}::addSup
Info<< "${typeName}FvOption${SourceType}::addSup()\n";
}
//{{{ begin code - warn/fatal if not implemented?
//{{{ begin code
${codeAddSup}
//}}} end code
}
void
Foam::fv::
${typeName}FvOption${SourceType}::addSup
(
const volScalarField& rho,
@ -171,17 +163,16 @@ ${typeName}FvOption${SourceType}::addSup
{
if (${verbose:-false})
{
Info<< "${typeName}FvOption${SourceType}::addSup(rho)\n";
Info<< "${typeName}FvOption${SourceType}::addSup()\n";
}
//{{{ begin code - warn/fatal if not implemented?
${codeAddSupRho}
//{{{ begin code
${codeAddSup}
//}}} end code
}
void
Foam::fv::
${typeName}FvOption${SourceType}::constrain
(
fvMatrix<${TemplateType}>& eqn,
@ -199,4 +190,9 @@ ${typeName}FvOption${SourceType}::constrain
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace fv
} // End namespace Foam
// ************************************************************************* //

View File

@ -35,14 +35,7 @@ Description
codeAddSup
(
fvMatrix<Type>& eqn,
const label fieldi
)
codeAddSupRho
(
const volScalarField& rho,
fvMatrix<Type>& eqn,
fvMatrix<Type}>& eqn,
const label fieldi
)
@ -163,7 +156,7 @@ public:
// Member Functions
//- Code context as a dictionary
const dictionary& codeContext() const noexcept
const dictionary& codeContext() const
{
return dictionaryContent::dict();
}

View File

@ -80,17 +80,14 @@ defineTypeNameAndDebug
${typeName}PatchFunction1${FieldType},
0
);
PatchFunction1<${TemplateType}>::addRemovabledictionaryConstructorToTable
PatchFunction1<${TemplateType}>::adddictionaryConstructorToTable
<${typeName}PatchFunction1${FieldType}>
addRemovable${typeName}PatchFunction1${FieldType}ConstructorToTable_;
add${typeName}PatchFunction1${FieldType}ConstructorToTable_;
} // namespace PatchFunction1Types
} // namespace Foam
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::PatchFunction1Types::
${typeName}PatchFunction1${FieldType}::
${typeName}PatchFunction1${FieldType}
(
@ -110,7 +107,6 @@ ${typeName}PatchFunction1${FieldType}
}
Foam::PatchFunction1Types::
${typeName}PatchFunction1${FieldType}::
${typeName}PatchFunction1${FieldType}
(
@ -125,7 +121,7 @@ ${typeName}PatchFunction1${FieldType}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
Foam::tmp<Foam::Field<Foam::${TemplateType}>>
Foam::PatchFunction1Types::${typeName}PatchFunction1${FieldType}::value
${typeName}PatchFunction1${FieldType}::value
(
const scalar x
) const
@ -136,4 +132,10 @@ Foam::PatchFunction1Types::${typeName}PatchFunction1${FieldType}::value
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace PatchFunction1Types
} // End namespace Foam
// ************************************************************************* //

View File

@ -31,8 +31,8 @@ SourceFiles
\*---------------------------------------------------------------------------*/
#ifndef dynamicCode_codedPatchFunction1_${typeName}_${FieldType}_H
#define dynamicCode_codedPatchFunction1_${typeName}_${FieldType}_H
#ifndef codedPatchFunction1Template${FieldType}_H
#define codedPatchFunction1Template${FieldType}_H
#include "PatchFunction1.H"
#include "dictionaryContent.H"
@ -126,11 +126,20 @@ public:
// Member Functions
//- Is value uniform (i.e. independent of coordinate)
virtual bool uniform() const { return false; }
//- Return value as a function of (scalar) independent variable
virtual tmp<Field<${TemplateType}>> value(const scalar x) const;
//- Is value constant (i.e. independent of x)
virtual bool constant() const
{
return false;
}
//- Is value uniform (i.e. independent of coordinate)
virtual bool uniform() const
{
return false;
}
};

View File

@ -75,14 +75,10 @@ extern "C" void ${typeName}_${SHA1sum}(bool load)
${localCode}
//}}} end localCode
} // End namespace Foam
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::
${typeName}Points0MotionSolver::
${typeName}Points0MotionSolver
${typeName}Points0MotionSolver::${typeName}Points0MotionSolver
(
const polyMesh& mesh,
const IOdictionary& dict
@ -94,16 +90,13 @@ ${typeName}Points0MotionSolver
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::
${typeName}Points0MotionSolver::
~${typeName}Points0MotionSolver()
${typeName}Points0MotionSolver::~${typeName}Points0MotionSolver()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
Foam::tmp<Foam::pointField>
Foam::${typeName}Points0MotionSolver::curPoints() const
tmp<pointField> ${typeName}Points0MotionSolver::curPoints() const
{
if (${verbose:-false})
{
@ -116,4 +109,8 @@ Foam::${typeName}Points0MotionSolver::curPoints() const
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //

View File

@ -103,7 +103,7 @@ public:
// Member Functions
//- Code context as a dictionary
const dictionary& codeContext() const noexcept
const dictionary& codeContext() const
{
return dictionaryContent::dict();
}

View File

@ -78,12 +78,9 @@ makeRemovablePatchTypeField
${typeName}FixedValueFvPatch${FieldType}
);
} // End namespace Foam
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::
${typeName}FixedValueFvPatch${FieldType}::
${typeName}FixedValueFvPatch${FieldType}
(
@ -100,7 +97,6 @@ ${typeName}FixedValueFvPatch${FieldType}
}
Foam::
${typeName}FixedValueFvPatch${FieldType}::
${typeName}FixedValueFvPatch${FieldType}
(
@ -119,7 +115,6 @@ ${typeName}FixedValueFvPatch${FieldType}
}
Foam::
${typeName}FixedValueFvPatch${FieldType}::
${typeName}FixedValueFvPatch${FieldType}
(
@ -137,7 +132,6 @@ ${typeName}FixedValueFvPatch${FieldType}
}
Foam::
${typeName}FixedValueFvPatch${FieldType}::
${typeName}FixedValueFvPatch${FieldType}
(
@ -153,7 +147,6 @@ ${typeName}FixedValueFvPatch${FieldType}
}
Foam::
${typeName}FixedValueFvPatch${FieldType}::
${typeName}FixedValueFvPatch${FieldType}
(
@ -172,7 +165,6 @@ ${typeName}FixedValueFvPatch${FieldType}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::
${typeName}FixedValueFvPatch${FieldType}::
~${typeName}FixedValueFvPatch${FieldType}()
{
@ -186,7 +178,6 @@ ${typeName}FixedValueFvPatch${FieldType}::
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void
Foam::
${typeName}FixedValueFvPatch${FieldType}::updateCoeffs()
{
if (this->updated())
@ -207,4 +198,8 @@ ${typeName}FixedValueFvPatch${FieldType}::updateCoeffs()
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //

View File

@ -143,7 +143,7 @@ public:
// Member Functions
//- Code context as a dictionary
const dictionary& codeContext() const noexcept
const dictionary& codeContext() const
{
return dictionaryContent::dict();
}

View File

@ -77,12 +77,9 @@ makePointPatchTypeField
${typeName}FixedValuePointPatch${FieldType}
);
} // End namespace Foam
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::
${typeName}FixedValuePointPatch${FieldType}::
${typeName}FixedValuePointPatch${FieldType}
(
@ -99,7 +96,6 @@ ${typeName}FixedValuePointPatch${FieldType}
}
Foam::
${typeName}FixedValuePointPatch${FieldType}::
${typeName}FixedValuePointPatch${FieldType}
(
@ -118,7 +114,6 @@ ${typeName}FixedValuePointPatch${FieldType}
}
Foam::
${typeName}FixedValuePointPatch${FieldType}::
${typeName}FixedValuePointPatch${FieldType}
(
@ -137,7 +132,6 @@ ${typeName}FixedValuePointPatch${FieldType}
}
Foam::
${typeName}FixedValuePointPatch${FieldType}::
${typeName}FixedValuePointPatch${FieldType}
(
@ -153,7 +147,6 @@ ${typeName}FixedValuePointPatch${FieldType}
}
Foam::
${typeName}FixedValuePointPatch${FieldType}::
${typeName}FixedValuePointPatch${FieldType}
(
@ -172,7 +165,6 @@ ${typeName}FixedValuePointPatch${FieldType}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::
${typeName}FixedValuePointPatch${FieldType}::
~${typeName}FixedValuePointPatch${FieldType}()
{
@ -186,7 +178,6 @@ ${typeName}FixedValuePointPatch${FieldType}::
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void
Foam::
${typeName}FixedValuePointPatch${FieldType}::updateCoeffs()
{
if (this->updated())
@ -207,4 +198,8 @@ ${typeName}FixedValuePointPatch${FieldType}::updateCoeffs()
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //

View File

@ -144,7 +144,7 @@ public:
// Member Functions
//- Code context as a dictionary
const dictionary& codeContext() const noexcept
const dictionary& codeContext() const
{
return dictionaryContent::dict();
}

View File

@ -75,13 +75,10 @@ extern "C" void ${typeName}_${SHA1sum}(bool load)
${localCode}
//}}} end localCode
} // End namespace Foam
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
const Foam::fvMesh&
Foam::${typeName}FunctionObject::mesh() const
const fvMesh& ${typeName}FunctionObject::mesh() const
{
return refCast<const fvMesh>(obr_);
}
@ -89,9 +86,7 @@ Foam::${typeName}FunctionObject::mesh() const
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::
${typeName}FunctionObject::
${typeName}FunctionObject
${typeName}FunctionObject::${typeName}FunctionObject
(
const word& name,
const Time& runTime,
@ -106,16 +101,13 @@ ${typeName}FunctionObject
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::
${typeName}FunctionObject::
~${typeName}FunctionObject()
${typeName}FunctionObject::~${typeName}FunctionObject()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
bool
Foam::
${typeName}FunctionObject::read(const dictionary& dict)
{
if (${verbose:-false})
@ -132,7 +124,6 @@ ${typeName}FunctionObject::read(const dictionary& dict)
bool
Foam::
${typeName}FunctionObject::execute()
{
if (${verbose:-false})
@ -149,7 +140,6 @@ ${typeName}FunctionObject::execute()
bool
Foam::
${typeName}FunctionObject::write()
{
if (${verbose:-false})
@ -166,7 +156,6 @@ ${typeName}FunctionObject::write()
bool
Foam::
${typeName}FunctionObject::end()
{
if (${verbose:-false})
@ -182,4 +171,8 @@ ${typeName}FunctionObject::end()
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //

View File

@ -32,8 +32,8 @@ SourceFiles
\*---------------------------------------------------------------------------*/
#ifndef coded_functionObjectTemplate_H
#define coded_functionObjectTemplate_H
#ifndef functionObjectTemplate_H
#define functionObjectTemplate_H
#include "regionFunctionObject.H"
#include "dictionaryContent.H"
@ -116,7 +116,7 @@ public:
// Member Functions
//- Code context as a dictionary
const dictionary& codeContext() const noexcept
const dictionary& codeContext() const
{
return dictionaryContent::dict();
}

View File

@ -77,12 +77,9 @@ makeRemovablePatchTypeField
${typeName}MixedValueFvPatch${FieldType}
);
} // End namespace Foam
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::
${typeName}MixedValueFvPatch${FieldType}::
${typeName}MixedValueFvPatch${FieldType}
(
@ -99,7 +96,6 @@ ${typeName}MixedValueFvPatch${FieldType}
}
Foam::
${typeName}MixedValueFvPatch${FieldType}::
${typeName}MixedValueFvPatch${FieldType}
(
@ -118,7 +114,6 @@ ${typeName}MixedValueFvPatch${FieldType}
}
Foam::
${typeName}MixedValueFvPatch${FieldType}::
${typeName}MixedValueFvPatch${FieldType}
(
@ -136,7 +131,6 @@ ${typeName}MixedValueFvPatch${FieldType}
}
Foam::
${typeName}MixedValueFvPatch${FieldType}::
${typeName}MixedValueFvPatch${FieldType}
(
@ -152,7 +146,6 @@ ${typeName}MixedValueFvPatch${FieldType}
}
Foam::
${typeName}MixedValueFvPatch${FieldType}::
${typeName}MixedValueFvPatch${FieldType}
(
@ -171,7 +164,6 @@ ${typeName}MixedValueFvPatch${FieldType}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::
${typeName}MixedValueFvPatch${FieldType}::
~${typeName}MixedValueFvPatch${FieldType}()
{
@ -185,7 +177,6 @@ ${typeName}MixedValueFvPatch${FieldType}::
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void
Foam::
${typeName}MixedValueFvPatch${FieldType}::updateCoeffs()
{
if (this->updated())
@ -206,4 +197,8 @@ ${typeName}MixedValueFvPatch${FieldType}::updateCoeffs()
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //

View File

@ -143,7 +143,7 @@ public:
// Member Functions
//- Code context as a dictionary
const dictionary& codeContext() const noexcept
const dictionary& codeContext() const
{
return dictionaryContent::dict();
}

View File

@ -437,10 +437,10 @@ case SGIMPI:
# ----
# Also support any ending (eg, INTELMPI_custom) to allow custom wmake rules
case intelmpi:
case intelmpi-[1-9]*:
case INTELMPI*: ## Also includes (INTELMPI | INTELMPI-[1-9]*)
case INTELMPI:
case INTELMPI-[1-9]*:
setenv FOAM_MPI intelmpi
## Add version embedded in the naming

View File

@ -99,7 +99,7 @@ case "none":
breaksw
case "system":
# Obtain (major.minor) from `paraview --version`
# Obtain major.minor from `paraview --version`
set pv_api=`paraview --version | sed -ne 's/^[^0-9]*\([0-9][0-9]*\.[0-9][0-9]*\).*$/\1/p'`
if ("${pv_api}" == "") then
@ -183,7 +183,7 @@ default:
set pvLibDir="${libDir}/paraview-${pv_api}"
if ( -d "${ParaView_DIR}/${pvLibDir}" ) then
switch ("$pv_api")
case 5.[0-4]:
case 5.[0-4]*:
set libDir="$pvLibDir" # Needs lib/paraview-X.X (not lib)
breaksw
endsw
@ -203,8 +203,8 @@ default:
# Any extra library directories
if ( "$pv_libdirs" != "" ) then
switch ("$WM_ARCH")
if ( -n "$pv_libdirs" != "" ) then
switch "WM_ARCH" in
case darwin*:
setenv DYLD_LIBRARY_PATH "${pv_libdirs}:$DYLD_LIBRARY_PATH"
breaksw

View File

@ -106,11 +106,6 @@ unsetenv FOAM_USER_APPBIN
unsetenv FOAM_USER_LIBBIN
unsetenv FOAM_UTILITIES
# Build related
unsetenv FOAM_BUILDROOT
unsetenv FOAM_THIRD_PARTY_BUILDROOT
unsetenv FOAM_THIRD_PARTY_SOURCES
# Older, unused variables
# Before 1812

View File

@ -442,9 +442,8 @@ SGIMPI)
# ----
# Also support any ending (eg, INTELMPI_custom) to allow custom wmake rules
intelmpi | intelmpi-[1-9]* |\
INTELMPI*) # Also includes (INTELMPI | INTELMPI-[1-9]*)
INTELMPI | INTELMPI-[1-9]* )
export FOAM_MPI=intelmpi
_foamMpiEmbedVersion intelmpi INTELMPI

View File

@ -118,7 +118,7 @@ case "$ParaView_VERSION" in
;;
([0-9]*)
# Extract API (major.minor) from VERSION
# Extract API from VERSION
pv_api=$(echo "$ParaView_VERSION" | \
sed -ne 's/^[^0-9]*\([0-9][0-9]*\.[0-9][0-9]*\).*$/\1/p')
;;
@ -162,7 +162,7 @@ case "$ParaView_VERSION" in
if [ -d "$ParaView_DIR/$pvLibDir" ]
then
case "$pv_api" in
(5.[0-4])
(5.[0-4]*)
libDir="$pvLibDir" # Needs lib/paraview-X.X (not lib)
;;
esac

View File

@ -264,7 +264,7 @@ GCC_NOT_FOUND
if [ -n "$FOAM_VERBOSE" ] && [ -n "$PS1" ]
then
echo "Using ThirdParty compiler"
echo " ${gccDir##*/} (${gmpDir##*/} ${mpfrDir##*/} ${mpcDir##*/})"
echo " ${gccDir##*/} (${gmpDir##*/} $${mpfrDir##*/} ${mpcDir##*/})"
fi
;;

View File

@ -130,19 +130,22 @@ then
;;
(*=)
# name= -> unset name
_foamEcho "unset ${foamVar_eval%=}"
[ -n "$FOAM_VERBOSE" ] && [ -n "$PS1" ] \
&& echo "unset ${foamVar_eval%=}" 1>&2
eval "unset ${foamVar_eval%=}"
;;
(*=*)
# name=value -> export name=value
_foamEcho "export $foamVar_eval"
[ -n "$FOAM_VERBOSE" ] && [ -n "$PS1" ] \
&& echo "export $foamVar_eval" 1>&2
eval "export $foamVar_eval"
;;
(*)
# Filename: source it
if [ -f "$foamVar_eval" ]
then
_foamEcho "Use file: $foamVar_eval"
[ -n "$FOAM_VERBOSE" ] && [ -n "$PS1" ] \
&& echo "Using: $foamVar_eval" 1>&2
. "$foamVar_eval"
elif [ -n "$foamVar_eval" ]
then
@ -226,7 +229,7 @@ then
_foamAddMan "$WM_PROJECT_DIR/doc"
fi
# Interactive shell
# Interactive shell (use PS1, not tty)
if [ -n "$PS1" ]
then
_foamEtc -config aliases

View File

@ -95,11 +95,6 @@ unset FOAM_USER_APPBIN
unset FOAM_USER_LIBBIN
unset FOAM_UTILITIES
# Build related
unset FOAM_BUILDROOT
unset FOAM_THIRD_PARTY_BUILDROOT
unset FOAM_THIRD_PARTY_SOURCES
# Older, unused variables
# Before 1812

View File

@ -107,8 +107,7 @@ getApiInfo()
# - No inheritance of FOAM_SETTINGS
# - No default verbosity (only as command-line option)
unset FOAM_CONFIG_ETC FOAM_SETTINGS FOAM_VERBOSE
unset _foam_config_etc _foam_bashrcFile
unset _foamSettings _foamScriptCommand
unset _foamEtcDir _foamSettings _foamScriptCommand _foamSourceBashEnv
unset optTestTut
# Parse options
@ -163,14 +162,9 @@ do
_foamSettings="$_foamSettings${_foamSettings:+ }WM_LABEL_SIZE=${1#-int}"
;;
#TDB: -etc-*)
#TDB: # Define FOAM_CONFIG_ETC for finding files
#TDB: _foam_config_etc="${1#*-}"
#TDB: ;;
-etc=*)
# Define FOAM_CONFIG_ETC for finding files
_foam_config_etc="${1#*=}"
_foamEtcDir="${1#*=}"
;;
-prefix=*)
@ -178,7 +172,7 @@ do
;;
-init=*)
_foam_bashrcFile="${1#*=}"
_foamSourceBashEnv="${1#*=}"
;;
-verbose)
@ -233,48 +227,28 @@ then
interactive=true
fi
if [ -z "$_foam_bashrcFile" ]
if [ -z "$_foamSourceBashEnv" ]
then
if [ -n "$interactive" ]
then
# Interactive shell, chain off via a file
_foam_bashrcFile="$projectDir/bin/tools/source-bashrc"
_foamSourceBashEnv="$projectDir/bin/tools/source-bashrc"
else
# Default: OPENFOAM etc/bashrc
_foam_bashrcFile="$projectDir/etc/bashrc"
_foamSourceBashEnv="$projectDir/etc/bashrc"
fi
fi
[ -f "$_foam_bashrcFile" ] || {
echo "Error: file not found: $_foam_bashrcFile" 1>&2
[ -f "$_foamSourceBashEnv" ] || {
echo "Error: file not found: $_foamSourceBashEnv" 1>&2
exit 2
}
# FOAM_CONFIG_ETC: additional etc directory
case "$_foam_config_etc" in
('') # Empty - ignore
;;
(/*) # Absolute
[ -d "$_foam_config_etc" ] || unset _foam_config_etc
;;
(*) # Relative
if [ -d "$_foam_config_etc" ]
then
# Qualify local dir
_foam_config_etc="$PWD/$_foam_config_etc"
else
[ -d "$projectDir/$_foam_config_etc" ] || unset _foam_config_etc
fi
;;
esac
if [ -n "$_foam_config_etc" ]
if [ -n "$_foamEtcDir" ] && [ -d "$_foamEtcDir" ]
then
export FOAM_CONFIG_ETC="$_foam_config_etc"
# Additional etc directory
export FOAM_CONFIG_ETC="$_foamEtcDir"
fi
if [ -n "$interactive" ]
@ -292,10 +266,10 @@ then
export FOAM_SETTINGS="$_foamSettings"
fi
## echo "Source with $_foam_bashrcFile with '$FOAM_SETTINGS'" 1>&2
## echo "Source with $_foamSourceBashEnv with '$FOAM_SETTINGS'" 1>&2
# Newer bash can use --init-file instead of --rcfile
exec bash --rcfile "$_foam_bashrcFile" -i
exec bash --rcfile "$_foamSourceBashEnv" -i
exit $? # Safety
fi
@ -307,7 +281,7 @@ fi
# Suppresses aliases as a side-effect, but non-interactive anyhow.
sourceBashrc()
{
. "$_foam_bashrcFile" $_foamSettings
. "$_foamSourceBashEnv" $_foamSettings
}

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2018-2021 OpenCFD Ltd.
Copyright (C) 2018 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -49,98 +49,16 @@ static inline bool fullMatch(const regmatch_t& m, const regoff_t len)
} // End anonymous namespace
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
bool Foam::regExpPosix::set_pattern
(
const char* pattern,
size_t len,
bool ignoreCase
)
{
clear(); // Also sets ctrl_ = 0
const char* pat = pattern;
bool doNegate = false;
// Handle known embedded prefixes
if (len > 2 && pat[0] == '(' && pat[1] == '?')
{
pat += 2;
len -= 2;
for (bool done = false; !done && len; ++pat, --len)
{
switch (*pat)
{
case '!':
{
// Negated (inverted) match
doNegate = true;
break;
}
case 'i':
{
// Ignore-case
ignoreCase = true;
break;
}
case ')':
{
// End of prefix parsing
done = true;
break;
}
}
}
}
// Avoid zero-length patterns
if (len)
{
int flags = REG_EXTENDED;
if (ignoreCase)
{
flags |= REG_ICASE;
}
{
preg_ = new regex_t;
int err = regcomp(preg_, pat, flags);
if (err == 0)
{
ctrl_ = (doNegate ? ctrlType::NEGATED : ctrlType::NORMAL);
return true;
}
else
{
char errbuf[200];
regerror(err, preg_, errbuf, sizeof(errbuf));
FatalErrorInFunction
<< "Failed to compile regular expression '"
<< pattern << "'\n" << errbuf
<< exit(FatalError);
}
}
}
return false;
}
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
bool Foam::regExpPosix::clear()
{
ctrl_ = 0;
if (preg_)
{
regfree(preg_);
delete preg_;
preg_ = nullptr;
return true;
}
@ -148,40 +66,71 @@ bool Foam::regExpPosix::clear()
}
bool Foam::regExpPosix::set(const char* pattern, bool ignoreCase)
{
clear();
// Avoid nullptr and zero-length patterns
if (pattern && *pattern)
{
int cflags = REG_EXTENDED;
if (ignoreCase)
{
cflags |= REG_ICASE;
}
const char* pat = pattern;
// Check for embedded prefix for ignore-case
// this is the only embedded prefix we support
// - a simple check is sufficient
if (!strncmp(pattern, "(?i)", 4))
{
cflags |= REG_ICASE;
pat += 4;
// avoid zero-length patterns
if (!*pat)
{
return false;
}
}
preg_ = new regex_t;
int err = regcomp(preg_, pat, cflags);
if (err != 0)
{
char errbuf[200];
regerror(err, preg_, errbuf, sizeof(errbuf));
FatalErrorInFunction
<< "Failed to compile regular expression '" << pattern << "'"
<< nl << errbuf
<< exit(FatalError);
}
return true;
}
return false; // Was cleared and nothing was set
}
bool Foam::regExpPosix::set(const std::string& pattern, bool ignoreCase)
{
return set(pattern.c_str(), ignoreCase);
}
std::string::size_type Foam::regExpPosix::find(const std::string& text) const
{
// Find with negated is probably not very reliable...
if (!preg_ || !ctrl_)
{
// Undefined: never matches
return std::string::npos;
}
else if (text.empty())
{
if (ctrl_ == ctrlType::NEGATED)
{
return 0; // No match - pretend it starts at position 0
}
else
{
return std::string::npos;
}
}
else
if (preg_ && !text.empty())
{
const size_t nmatch = 1;
regmatch_t pmatch[1];
const bool ok = (regexec(preg_, text.c_str(), nmatch, pmatch, 0) == 0);
if (ctrl_ == ctrlType::NEGATED)
{
if (!ok)
{
return 0; // No match - claim that is starts at position 0
}
}
else if (ok)
if (regexec(preg_, text.c_str(), nmatch, pmatch, 0) == 0)
{
return pmatch[0].rm_so;
}
@ -193,31 +142,23 @@ std::string::size_type Foam::regExpPosix::find(const std::string& text) const
bool Foam::regExpPosix::match(const std::string& text) const
{
bool ok = false;
const auto len = text.size();
if (!preg_ || !ctrl_)
{
// Undefined: never matches
return false;
}
const auto len = text.length();
if (len)
if (preg_ && len)
{
const size_t nmatch = 1;
regmatch_t pmatch[1];
// Verify that the entire string was matched
// - [0] is the entire match result
ok =
return
(
regexec(preg_, text.c_str(), nmatch, pmatch, 0) == 0
&& fullMatch(pmatch[0], len)
);
}
return (ctrl_ == ctrlType::NEGATED ? !ok : ok);
return false;
}
@ -229,12 +170,6 @@ bool Foam::regExpPosix::match
{
matches.clear();
// Probably does not make sense for negated pattern...
if (negated())
{
return match(text);
}
const auto len = text.size();
if (preg_ && len)
{

View File

@ -28,20 +28,10 @@ Class
Foam::regExpPosix
Description
Wrapper around POSIX extended regular expressions
with some additional prefix-handling. The prefix-handling is
loosely oriented on PCRE regular expressions and provides a
simple means of tuning the expressions.
Wrapper around POSIX extended regular expressions.
The prefixes are detected as \c (?...) at the beginning of
the regular expression. Any unknown/unsupported prefixes are silently
ignored.
- "(?!i)" :
one or more embedded pattern-match modifiers for the entire pattern.
- the \c 'i' indicates ignore-case
- the \c '!' (exclamation) indicates negated (inverted) matching
.
The PCRE '(?i)' extension is provided to compile the regular expression
as being case-insensitive.
SeeAlso
The manpage regex(7) for more information about POSIX regular expressions.
@ -59,8 +49,8 @@ Warning
for regular expressions continues to improve.
SourceFiles
regExpPosix.C
regExpPosixI.H
regExpPosix.C
\*---------------------------------------------------------------------------*/
@ -84,27 +74,11 @@ template<class StringType> class SubStrings;
class regExpPosix
{
// Data Types
//- Simple control types
enum ctrlType { EMPTY = 0, NORMAL = 1, NEGATED = 2 };
// Private Data
//- Compiled regular expression
regex_t* preg_;
//- Track if input pattern is non-empty, negated etc.
unsigned char ctrl_;
// Private Member Functions
//- Assign pattern
bool set_pattern(const char* pattern, size_t len, bool ignoreCase);
public:
// Public Types
@ -184,14 +158,7 @@ public:
//- Return true if a precompiled expression exists
inline bool exists() const noexcept;
//- True if pattern matching is negated
inline bool negated() const noexcept;
//- Change pattern negation, return previous value
inline bool negate(bool on) noexcept;
//- The number of capture groups for a non-empty,
//- non-negated expressions
//- The number of capture groups for a non-empty expression
inline unsigned ngroups() const;
@ -206,19 +173,17 @@ public:
//- Compile pattern into a regular expression, optionally ignore case.
// \return True if the pattern was compiled
inline bool set(const char* pattern, bool ignoreCase=false);
bool set(const char* pattern, bool ignoreCase=false);
//- Compile pattern into a regular expression, optionally ignore case.
// \return True if the pattern was compiled
inline bool set(const std::string& pattern, bool ignoreCase=false);
bool set(const std::string& pattern, bool ignoreCase=false);
// Matching/Searching
//- Find position within the text.
// \return The index where it begins or string::npos if not found
//
// \note does not properly work with negated regex!
std::string::size_type find(const std::string& text) const;
//- True if the regex matches the entire text.
@ -228,8 +193,6 @@ public:
//- True if the regex matches the text, set the matches.
// The first group starts at index 1 (0 is the entire match).
// The begin-of-line (^) and end-of-line ($) anchors are implicit
//
// \note does not properly work with negated regex!
bool match(const std::string& text, results_type& matches) const;
//- Return true if the regex was found within the text

View File

@ -31,18 +31,15 @@ License
inline Foam::regExpPosix::regExpPosix() noexcept
:
preg_(nullptr),
ctrl_(0)
preg_(nullptr)
{}
inline Foam::regExpPosix::regExpPosix(regExpPosix&& rgx) noexcept
:
preg_(rgx.preg_),
ctrl_(rgx.ctrl_)
preg_(rgx.preg_)
{
rgx.preg_ = nullptr;
rgx.ctrl_ = 0;
}
@ -52,8 +49,7 @@ inline Foam::regExpPosix::regExpPosix
const bool ignoreCase
)
:
preg_(nullptr),
ctrl_(0)
preg_(nullptr)
{
set(pattern, ignoreCase);
}
@ -65,8 +61,7 @@ inline Foam::regExpPosix::regExpPosix
const bool ignoreCase
)
:
preg_(nullptr),
ctrl_(0)
preg_(nullptr)
{
set(pattern, ignoreCase);
}
@ -94,72 +89,14 @@ inline bool Foam::regExpPosix::exists() const noexcept
}
inline bool Foam::regExpPosix::negated() const noexcept
{
return (ctrl_ == ctrlType::NEGATED);
}
inline bool Foam::regExpPosix::negate(bool on) noexcept
{
bool old(ctrl_ == ctrlType::NEGATED);
if (on)
{
if (ctrl_)
{
ctrl_ = ctrlType::NEGATED;
}
}
else if (old)
{
ctrl_ = ctrlType::NORMAL;
}
return old;
}
inline unsigned Foam::regExpPosix::ngroups() const
{
return (preg_ && ctrl_ == ctrlType::NORMAL) ? preg_->re_nsub : 0;
}
inline bool Foam::regExpPosix::set(const char* pattern, bool ignoreCase)
{
// Silently handle nullptr
return set_pattern
(
pattern,
(pattern ? std::char_traits<char>::length(pattern) : 0),
ignoreCase
);
}
inline bool Foam::regExpPosix::set(const std::string& pattern, bool ignoreCase)
{
return set_pattern
(
pattern.data(),
pattern.length(),
ignoreCase
);
return preg_ ? preg_->re_nsub : 0;
}
inline bool Foam::regExpPosix::search(const std::string& text) const
{
if (!ctrl_)
{
return false;
}
else if (text.empty())
{
return (ctrl_ == ctrlType::NEGATED);
}
return std::string::npos != find(text);
}
@ -170,7 +107,6 @@ inline void Foam::regExpPosix::swap(regExpPosix& rgx)
{
// Self-swap is a no-op
std::swap(preg_, rgx.preg_);
std::swap(ctrl_, rgx.ctrl_);
}
}

View File

@ -162,13 +162,9 @@ $(expr)/exprResult/exprResultStored.C
$(expr)/exprResult/exprResultStoredStack.C
$(expr)/exprString/exprString.C
$(expr)/exprTools/exprTools.C
$(expr)/scanToken/exprScanToken.C
$(expr)/traits/exprTraits.C
$(expr)/exprDriver/exprDriver.C
$(expr)/exprDriver/exprDriverFields.C
$(expr)/exprDriver/exprDriverFunctions.C
$(expr)/exprDriver/exprDriverIO.C
fieldExpr = $(expr)/fields
@ -305,15 +301,13 @@ $(functionEntries)/calcEntry/calcEntry.C
$(functionEntries)/codeStream/codeStream.C
$(functionEntries)/evalEntry/evalEntry.C
$(functionEntries)/functionEntry/functionEntry.C
$(functionEntries)/ifEntry/ifEntry.C
$(functionEntries)/ifeqEntry/ifeqEntry.C
$(functionEntries)/includeEntry/includeEntry.C
$(functionEntries)/includeEtcEntry/includeEtcEntry.C
$(functionEntries)/includeFuncEntry/includeFuncEntry.C
$(functionEntries)/inputMode/inputMode.C
$(functionEntries)/message/messageDirective.C
$(functionEntries)/removeEntry/removeEntry.C
$(functionEntries)/word/wordDirective.C
$(functionEntries)/ifeqEntry/ifeqEntry.C
$(functionEntries)/ifEntry/ifEntry.C
IOdictionary = db/IOobjects/IOdictionary
$(IOdictionary)/baseIOdictionary.C
@ -356,7 +350,6 @@ $(dll)/codedBase/codedBase.C
funcObjs = db/functionObjects
$(funcObjs)/functionObject/functionObject.C
$(funcObjs)/functionObjectProperties/functionObjectProperties.C
$(funcObjs)/functionObjectList/functionObjectList.C
$(funcObjs)/stateFunctionObject/stateFunctionObject.C
$(funcObjs)/timeFunctionObject/timeFunctionObject.C
@ -458,8 +451,6 @@ $(GAMGInterfaces)/GAMGInterface/GAMGInterfaceNew.C
$(GAMGInterfaces)/processorGAMGInterface/processorGAMGInterface.C
$(GAMGInterfaces)/processorCyclicGAMGInterface/processorCyclicGAMGInterface.C
$(GAMGInterfaces)/cyclicGAMGInterface/cyclicGAMGInterface.C
$(GAMGInterfaces)/primitiveGAMGInterface/primitiveGAMGInterface.C
GAMGInterfaceFields = $(GAMG)/interfaceFields
$(GAMGInterfaceFields)/GAMGInterfaceField/GAMGInterfaceField.C

View File

@ -52,7 +52,7 @@ Typedef
Foam::wordHashSet
Description
A HashSet with word keys and string hasher.
A HashSet with (the default) word keys.
Typedef
Foam::labelHashSet
@ -75,22 +75,12 @@ namespace Foam
// Forward Declarations
template<class T> class MinMax;
template<class Key, class Hash> class HashSet;
// Common hash-set types
//- A HashSet of words, uses string hasher.
typedef HashSet<word, Hash<word>> wordHashSet;
//- A HashSet of labels, uses label hasher.
typedef HashSet<label, Hash<label>> labelHashSet;
/*---------------------------------------------------------------------------*\
Class HashSet Declaration
\*---------------------------------------------------------------------------*/
template<class Key, class Hash=Foam::Hash<Key>>
template<class Key=word, class Hash=Foam::Hash<Key>>
class HashSet
:
public HashTable<zero::null, Key, Hash>
@ -411,7 +401,14 @@ public:
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Typedefs
//- A HashSet with word keys.
typedef HashSet<word> wordHashSet;
//- A HashSet with label keys and label hasher.
typedef HashSet<label, Hash<label>> labelHashSet;
// Global Functions

View File

@ -39,10 +39,9 @@ Description
namespace Foam
{
template<class Key, class Hash> class HashSet;
template<class T, class Key, class Hash> class HashTable;
template<class T, class Key, class Hash> class HashPtrTable;
template<class Key, class Hash> class HashSet;
template<class T> class Map;
template<class T> class PtrMap;

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2015-2021 OpenCFD Ltd.
Copyright (C) 2015-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -327,7 +327,7 @@ Foam::labelList Foam::sortedOrder
const UList<T>& input
)
{
labelList order;
labelList order(input.size());
sortedOrder(input, order, typename UList<T>::less(input));
return order;
}
@ -352,8 +352,15 @@ void Foam::sortedOrder
const ListComparePredicate& comp
)
{
// List lengths must be identical. Old content is overwritten
order.resize_nocopy(input.size());
const label len = input.size();
// List lengths must be identical
if (order.size() != len)
{
// Avoid copying elements, they are overwritten anyhow
order.clear();
order.resize(len);
}
ListOps::identity(order);
@ -367,7 +374,7 @@ Foam::labelList Foam::duplicateOrder
const UList<T>& input
)
{
labelList order;
labelList order(input.size());
duplicateOrder(input, order, typename UList<T>::less(input));
return order;
}
@ -420,7 +427,7 @@ Foam::labelList Foam::uniqueOrder
const UList<T>& input
)
{
labelList order;
labelList order(input.size());
uniqueOrder(input, order, typename UList<T>::less(input));
return order;
}

View File

@ -35,7 +35,7 @@ Foam::labelList Foam::sortedOrder
const UPtrList<T>& input
)
{
labelList order;
labelList order(input.size());
sortedOrder(input, order, typename PtrListOps::less<T>(input));
return order;
}
@ -60,8 +60,15 @@ void Foam::sortedOrder
const ListComparePredicate& comp
)
{
// List lengths must be identical. Old content is overwritten
order.resize_nocopy(input.size());
const label len = input.size();
// List lengths must be identical
if (order.size() != len)
{
// Avoid copying elements, they are overwritten anyhow
order.clear();
order.resize(len);
}
ListOps::identity(order);
@ -72,7 +79,7 @@ void Foam::sortedOrder
template<class T>
void Foam::sort(UPtrList<T>& list)
{
labelList order;
labelList order(list.size());
sortedOrder(list, order);
list.sortOrder(order, false); // false = allow nullptr
}
@ -81,7 +88,7 @@ void Foam::sort(UPtrList<T>& list)
template<class T, class Compare>
void Foam::sort(UPtrList<T>& list, const Compare& comp)
{
labelList order;
labelList order(list.size());
sortedOrder(list, order, comp);
list.sortOrder(order, false); // false = allow nullptr
}

View File

@ -314,12 +314,9 @@ public:
static word member(const word& name);
//- Create scope:name or scope_name string
// An empty scope is ignored.
static inline word scopedName
(
const std::string& scope,
const word& name
);
// An empty scope or name is ignored.
template<class StringType>
static inline word scopedName(StringType scope, const word& name);
//- Return the IOobject, but also consider an alternative file name.
//

View File

@ -43,13 +43,18 @@ inline Foam::word Foam::IOobject::groupName
}
template<class StringType>
inline Foam::word Foam::IOobject::scopedName
(
const std::string& scope,
StringType scope,
const word& name
)
{
if (scope.empty())
if (name.empty())
{
return scope;
}
else if (scope.empty())
{
return name;
}

View File

@ -106,6 +106,12 @@ public:
//- Construct by transferring the Field contents
CompactIOField(const IOobject& io, Field<T>&& content);
//- Return a clone
virtual refPtr<regIOobject> deepClone() const
{
return regIOobject::DeepClone(*this);
}
//- Destructor
virtual ~CompactIOField() = default;

Some files were not shown because too many files have changed in this diff Show More