Compare commits
17 Commits
ami-cache-
...
develop
| Author | SHA1 | Date | |
|---|---|---|---|
| 6b3e65d17d | |||
| 572fa22bae | |||
| e100e4d084 | |||
| f186b0098b | |||
| b0066fc550 | |||
| 7fb4e77583 | |||
| 78cf2ce5db | |||
| f2793f2ac8 | |||
| 013dbb8248 | |||
| e9fcd75ec4 | |||
| ac34d9fd29 | |||
| 14bece937b | |||
| 2396828a60 | |||
| 9223d238bd | |||
| 4b92bb6533 | |||
| 55c81bce1b | |||
| 1cb0b7b6c9 |
@ -200,7 +200,7 @@ void printTypeName()
|
|||||||
|
|
||||||
|
|
||||||
template<class Type, bool UseTypeName = true>
|
template<class Type, bool UseTypeName = true>
|
||||||
void printPstreamTraits(const std::string_view name = std::string_view())
|
void printPstreamTraits(std::string_view name = std::string_view())
|
||||||
{
|
{
|
||||||
Info<< "========" << nl;
|
Info<< "========" << nl;
|
||||||
Info<< "type: ";
|
Info<< "type: ";
|
||||||
@ -299,6 +299,9 @@ void printPstreamTraits(const std::string_view name = std::string_view())
|
|||||||
// Use element or component type (or byte-wise) for data type
|
// Use element or component type (or byte-wise) for data type
|
||||||
using base = typename UPstream_dataType<Type>::base;
|
using base = typename UPstream_dataType<Type>::base;
|
||||||
|
|
||||||
|
// The sizing factor is constexpr
|
||||||
|
constexpr std::streamsize count = UPstream_dataType<Type>::size(1);
|
||||||
|
|
||||||
Info<< " : ";
|
Info<< " : ";
|
||||||
if constexpr (UseTypeName)
|
if constexpr (UseTypeName)
|
||||||
{
|
{
|
||||||
@ -311,8 +314,7 @@ void printPstreamTraits(const std::string_view name = std::string_view())
|
|||||||
|
|
||||||
Info<< " cmpt-type=";
|
Info<< " cmpt-type=";
|
||||||
printDataTypeId(UPstream_dataType<Type>::datatype_id);
|
printDataTypeId(UPstream_dataType<Type>::datatype_id);
|
||||||
Info<< " count=" << UPstream_dataType<Type>::size(1);
|
Info<< " count=" << count << nl;
|
||||||
Info<< nl;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -362,6 +364,24 @@ void print_data_opType(BinaryOp bop, std::string_view name)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
template<class Type>
|
||||||
|
int check_simple(std::string_view name = std::string_view())
|
||||||
|
{
|
||||||
|
// The sizing factor is constexpr
|
||||||
|
constexpr std::streamsize count = UPstream_dataType<Type>::size(1);
|
||||||
|
|
||||||
|
static_assert
|
||||||
|
(
|
||||||
|
(count == 1),
|
||||||
|
"Code does not (yet) work with aggregate types"
|
||||||
|
);
|
||||||
|
|
||||||
|
Info<< "check_simple: " << name << ": " << count << nl;
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
// Main program:
|
// Main program:
|
||||||
|
|
||||||
@ -389,6 +409,8 @@ int main()
|
|||||||
printPstreamTraits<const float>();
|
printPstreamTraits<const float>();
|
||||||
printPstreamTraits<floatVector>();
|
printPstreamTraits<floatVector>();
|
||||||
|
|
||||||
|
check_simple<floatVector>("vector<float>");
|
||||||
|
|
||||||
printPstreamTraits<scalar>();
|
printPstreamTraits<scalar>();
|
||||||
printPstreamTraits<double>();
|
printPstreamTraits<double>();
|
||||||
printPstreamTraits<doubleVector>();
|
printPstreamTraits<doubleVector>();
|
||||||
|
|||||||
5
applications/test/expressionTemplates/Make/files
Normal file
5
applications/test/expressionTemplates/Make/files
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
Test-expressionTemplates-volFields.C
|
||||||
|
/* Test-expressionTemplates-pointFields.C */
|
||||||
|
/* Test-expressionTemplates-Fields.C */
|
||||||
|
|
||||||
|
EXE = $(FOAM_USER_APPBIN)/Test-expressionTemplates
|
||||||
11
applications/test/expressionTemplates/Make/options
Normal file
11
applications/test/expressionTemplates/Make/options
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
EXE_INC = \
|
||||||
|
-O0 \
|
||||||
|
-I$(FOAM_SRC)/meshTools/lnInclude \
|
||||||
|
-I$(FOAM_SRC)/finiteVolume/lnInclude \
|
||||||
|
|
||||||
|
EXE_LIBS = \
|
||||||
|
/* -rpath /Volumes/case_sensitive/OpenFOAM/work/feature-et/platforms */ \
|
||||||
|
/* -rpath /Volumes/case_sensitive/OpenFOAM/work/feature-et/platforms/darwin64GccDPInt32Opt/lib */ \
|
||||||
|
/* -rpath /Volumes/case_sensitive/OpenFOAM/work/feature-et/platforms/darwin64GccDPInt32Opt/lib/$(FOAM_MPI) */\
|
||||||
|
-L/Volumes/case_sensitive/OpenFOAM/work/feature-et/platforms/darwin64GccDPInt32Opt/lib \
|
||||||
|
-lfiniteVolume
|
||||||
@ -0,0 +1,126 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | www.openfoam.com
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
Copyright (C) 2025 M. Janssens
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||||
|
under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
Application
|
||||||
|
Test-expressionTemplates
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#include "Time.H"
|
||||||
|
#include "argList.H"
|
||||||
|
#include "polyMesh.H"
|
||||||
|
#include "pointMesh.H"
|
||||||
|
#include "pointFields.H"
|
||||||
|
|
||||||
|
using namespace Foam;
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
int main(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
#include "setRootCase.H"
|
||||||
|
|
||||||
|
#include "createTime.H"
|
||||||
|
#include "createPolyMesh.H"
|
||||||
|
|
||||||
|
{
|
||||||
|
scalarField vals0({1.0, 2.0, 3.0});
|
||||||
|
const Expression::ListConstRefWrap<scalar> wvals0(vals0);
|
||||||
|
|
||||||
|
scalarField vals1;
|
||||||
|
Expression::ListRefWrap<scalar> wvals1(vals1.size(), vals1);
|
||||||
|
wvals1 = wvals0;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
const pointMesh& pMesh = pointMesh::New(mesh);
|
||||||
|
|
||||||
|
// Field, dimensionedScalar as List expression
|
||||||
|
{
|
||||||
|
scalarField vals({1.0, 2.0, 3.0});
|
||||||
|
dimensionedScalar d(dimless, 4.0);
|
||||||
|
|
||||||
|
scalarField result(d.expr(vals.size())*vals.expr());
|
||||||
|
|
||||||
|
Pout<< "result:" << result << endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
Info<< "Reading field p\n" << endl;
|
||||||
|
pointScalarField p
|
||||||
|
(
|
||||||
|
IOobject
|
||||||
|
(
|
||||||
|
"pointDisplacement",
|
||||||
|
runTime.timeName(),
|
||||||
|
pMesh.thisDb(),
|
||||||
|
IOobject::MUST_READ,
|
||||||
|
IOobject::AUTO_WRITE
|
||||||
|
),
|
||||||
|
pMesh
|
||||||
|
);
|
||||||
|
|
||||||
|
pointScalarField result
|
||||||
|
(
|
||||||
|
IOobject
|
||||||
|
(
|
||||||
|
"result",
|
||||||
|
runTime.timeName(),
|
||||||
|
pMesh.thisDb(),
|
||||||
|
IOobject::NO_READ,
|
||||||
|
IOobject::NO_WRITE,
|
||||||
|
IOobject::NO_REGISTER
|
||||||
|
),
|
||||||
|
pMesh,
|
||||||
|
dimensionedScalar("zero", Foam::sqr(p().dimensions()), 0)
|
||||||
|
);
|
||||||
|
|
||||||
|
// Construct value + dimensions with correct sizing
|
||||||
|
const auto oneField(dimensionedScalar(dimless, 1.0).expr(p));
|
||||||
|
|
||||||
|
// Make expression
|
||||||
|
auto expression = oneField * p.expr() + p.expr();
|
||||||
|
|
||||||
|
// Combine expressions
|
||||||
|
auto newExpression = sqr(expression);
|
||||||
|
|
||||||
|
// Assign values
|
||||||
|
result = newExpression;
|
||||||
|
|
||||||
|
DebugVar(result);
|
||||||
|
|
||||||
|
|
||||||
|
// Construct from expression
|
||||||
|
pointScalarField result2("result2", pMesh, sqrt(p.expr()));
|
||||||
|
|
||||||
|
DebugVar(result2);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -0,0 +1,451 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | www.openfoam.com
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||||
|
under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
Application
|
||||||
|
volPointInterpolationTest
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#include "Time.H"
|
||||||
|
#include "argList.H"
|
||||||
|
#include "fvMesh.H"
|
||||||
|
#include "ListExpression.H"
|
||||||
|
#include "GeometricFieldExpression.H"
|
||||||
|
#include "fvCFD.H"
|
||||||
|
#include "fvMatrixExpression.H"
|
||||||
|
#include <ratio>
|
||||||
|
#include <chrono>
|
||||||
|
|
||||||
|
using namespace Foam;
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
tmp<volScalarField> someFunction(const volScalarField& fld)
|
||||||
|
{
|
||||||
|
return fld*1.0001;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class Type>
|
||||||
|
void fusedGaussFvmLaplacian
|
||||||
|
(
|
||||||
|
fvMatrix<Type>& fvm,
|
||||||
|
const surfaceInterpolationScheme<scalar>& interpGammaScheme,
|
||||||
|
const fv::snGradScheme<Type>& snGradScheme,
|
||||||
|
const GeometricField<scalar, fvPatchField, volMesh>& gamma,
|
||||||
|
const GeometricField<Type, fvPatchField, volMesh>& vf
|
||||||
|
)
|
||||||
|
{
|
||||||
|
// Replacement for gaussLaplacianScheme::fvmLaplacian with scalar gamma
|
||||||
|
typedef GeometricField<Type, fvsPatchField, surfaceMesh> surfaceType;
|
||||||
|
|
||||||
|
const auto& mesh = vf.mesh();
|
||||||
|
|
||||||
|
// Expression for weights
|
||||||
|
const auto weights = interpGammaScheme.weights(gamma).expr();
|
||||||
|
|
||||||
|
// Expression for gamma_face * magSf
|
||||||
|
const auto gammaMagSf =
|
||||||
|
Expression::interpolate(gamma.expr(), weights, mesh)
|
||||||
|
* mesh.magSf().expr();
|
||||||
|
|
||||||
|
// Expression for deltaCoeffs
|
||||||
|
const auto deltaCoeffs = snGradScheme.deltaCoeffs(vf).expr();
|
||||||
|
|
||||||
|
// Construct matrix
|
||||||
|
Expression::fvmLaplacianUncorrected(fvm, gammaMagSf, deltaCoeffs);
|
||||||
|
|
||||||
|
if (snGradScheme.corrected())
|
||||||
|
{
|
||||||
|
// Wrap correction
|
||||||
|
const auto corr(snGradScheme.correction(vf).expr());
|
||||||
|
const auto V = mesh.V().expr();
|
||||||
|
|
||||||
|
if (mesh.fluxRequired(vf.name()))
|
||||||
|
{
|
||||||
|
fvm.faceFluxCorrectionPtr() = std::make_unique<surfaceType>
|
||||||
|
(
|
||||||
|
IOobject
|
||||||
|
(
|
||||||
|
"faceFluxCorr",
|
||||||
|
mesh.time().timeName(),
|
||||||
|
mesh,
|
||||||
|
IOobject::NO_READ,
|
||||||
|
IOobject::NO_WRITE,
|
||||||
|
IOobject::NO_REGISTER
|
||||||
|
),
|
||||||
|
mesh,
|
||||||
|
gamma.dimensions()
|
||||||
|
*mesh.magSf().dimensions()
|
||||||
|
*corr.data().dimensions()
|
||||||
|
);
|
||||||
|
auto& faceFluxCorr = *fvm.faceFluxCorrectionPtr();
|
||||||
|
faceFluxCorr = gammaMagSf*corr;
|
||||||
|
|
||||||
|
fvm.source() =
|
||||||
|
fvm.source().expr()
|
||||||
|
- (
|
||||||
|
V * fvc::div
|
||||||
|
(
|
||||||
|
faceFluxCorr
|
||||||
|
)().primitiveField().expr()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Temporary field
|
||||||
|
surfaceType faceFluxCorr
|
||||||
|
(
|
||||||
|
IOobject
|
||||||
|
(
|
||||||
|
"faceFluxCorr",
|
||||||
|
mesh.time().timeName(),
|
||||||
|
mesh,
|
||||||
|
IOobject::NO_READ,
|
||||||
|
IOobject::NO_WRITE,
|
||||||
|
IOobject::NO_REGISTER
|
||||||
|
),
|
||||||
|
mesh,
|
||||||
|
gamma.dimensions()
|
||||||
|
*mesh.magSf().dimensions()
|
||||||
|
*corr.data().dimensions()
|
||||||
|
);
|
||||||
|
faceFluxCorr = gammaMagSf*corr;
|
||||||
|
|
||||||
|
fvm.source() =
|
||||||
|
fvm.source().expr()
|
||||||
|
- (
|
||||||
|
V * fvc::div
|
||||||
|
(
|
||||||
|
faceFluxCorr
|
||||||
|
)().primitiveField().expr()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
using namespace std::chrono;
|
||||||
|
|
||||||
|
int main(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
#include "setRootCase.H"
|
||||||
|
#include "createTime.H"
|
||||||
|
#include "createMesh.H"
|
||||||
|
|
||||||
|
Info<< "Reading field p\n" << endl;
|
||||||
|
volScalarField p
|
||||||
|
(
|
||||||
|
IOobject
|
||||||
|
(
|
||||||
|
"p",
|
||||||
|
runTime.timeName(),
|
||||||
|
mesh.thisDb(),
|
||||||
|
IOobject::MUST_READ,
|
||||||
|
IOobject::AUTO_WRITE
|
||||||
|
),
|
||||||
|
mesh
|
||||||
|
);
|
||||||
|
|
||||||
|
{
|
||||||
|
volScalarField p2("p2", p);
|
||||||
|
DebugVar(p2.boundaryFieldRef());
|
||||||
|
|
||||||
|
for (auto& pf : p.boundaryFieldRef())
|
||||||
|
{
|
||||||
|
scalarField newVals(pf.size());
|
||||||
|
forAll(pf, i)
|
||||||
|
{
|
||||||
|
newVals[i] = scalar(i);
|
||||||
|
}
|
||||||
|
pf == newVals;
|
||||||
|
}
|
||||||
|
|
||||||
|
//std::vector<const scalarField*> ptrs;
|
||||||
|
// List<const scalarField*> ptrs;
|
||||||
|
// for (const auto& pp : p.boundaryField())
|
||||||
|
// {
|
||||||
|
// ptrs.push_back(&pp);
|
||||||
|
// }
|
||||||
|
DebugVar(sizeof(long));
|
||||||
|
DebugVar(p.boundaryField());
|
||||||
|
Expression::ListsConstRefWrap<scalarField> expr(p.boundaryField());
|
||||||
|
|
||||||
|
const auto twoA = expr + expr;
|
||||||
|
Expression::ListsRefWrap<scalarField> expr2(p2.boundaryFieldRef());
|
||||||
|
Pout<< "**before assignment twoA:" << twoA.size()
|
||||||
|
<< " expr2:" << expr2.size() << endl;
|
||||||
|
expr2 = twoA;
|
||||||
|
Pout<< "**after assignment twoA:" << twoA.size()
|
||||||
|
<< " expr2:" << expr2.size() << endl;
|
||||||
|
DebugVar(p2.boundaryField());
|
||||||
|
// forAll(expr, i)
|
||||||
|
// {
|
||||||
|
// Pout<< "i:" << i
|
||||||
|
// //<< " expr:" << expr[i]
|
||||||
|
// //<< " twoA:" << twoA[i]
|
||||||
|
// << " expr2:" << expr2[i]
|
||||||
|
// << endl;
|
||||||
|
// }
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
//DebugVar(linearInterpolate(p));
|
||||||
|
//auto tweights = linear<scalar>(mesh).weights(p);
|
||||||
|
//DebugVar(tweights);
|
||||||
|
|
||||||
|
surfaceScalarField result
|
||||||
|
(
|
||||||
|
IOobject
|
||||||
|
(
|
||||||
|
"result",
|
||||||
|
runTime.timeName(),
|
||||||
|
mesh.thisDb(),
|
||||||
|
IOobject::NO_READ,
|
||||||
|
IOobject::NO_WRITE,
|
||||||
|
IOobject::NO_REGISTER
|
||||||
|
),
|
||||||
|
mesh,
|
||||||
|
dimensionedScalar(p.dimensions(), 0)
|
||||||
|
);
|
||||||
|
//result = Expression::interpolate
|
||||||
|
//(
|
||||||
|
// p.expr(),
|
||||||
|
// tweights().expr(),
|
||||||
|
// mesh
|
||||||
|
//);
|
||||||
|
|
||||||
|
result = Expression::linearInterpolate(p.expr(), mesh);
|
||||||
|
|
||||||
|
|
||||||
|
DebugVar(result);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
volScalarField p2
|
||||||
|
(
|
||||||
|
IOobject
|
||||||
|
(
|
||||||
|
"p",
|
||||||
|
runTime.timeName(),
|
||||||
|
mesh.thisDb(),
|
||||||
|
IOobject::MUST_READ,
|
||||||
|
IOobject::AUTO_WRITE,
|
||||||
|
IOobject::NO_REGISTER
|
||||||
|
),
|
||||||
|
mesh
|
||||||
|
);
|
||||||
|
|
||||||
|
// Expresions of volFields
|
||||||
|
{
|
||||||
|
volScalarField result
|
||||||
|
(
|
||||||
|
IOobject
|
||||||
|
(
|
||||||
|
"result",
|
||||||
|
runTime.timeName(),
|
||||||
|
mesh.thisDb(),
|
||||||
|
IOobject::NO_READ,
|
||||||
|
IOobject::NO_WRITE,
|
||||||
|
IOobject::NO_REGISTER
|
||||||
|
),
|
||||||
|
mesh,
|
||||||
|
dimensionedScalar(p.dimensions(), 0)
|
||||||
|
);
|
||||||
|
|
||||||
|
{
|
||||||
|
Pout<< "No expression templates:" << endl;
|
||||||
|
const high_resolution_clock::time_point t1 =
|
||||||
|
high_resolution_clock::now();
|
||||||
|
result = p + p2;
|
||||||
|
const high_resolution_clock::time_point t2 =
|
||||||
|
high_resolution_clock::now();
|
||||||
|
const duration<double> time_span = t2 - t1;
|
||||||
|
Pout<< "Operation time:" << time_span.count() << endl;
|
||||||
|
}
|
||||||
|
{
|
||||||
|
Pout<< "With expression templates:" << endl;
|
||||||
|
const high_resolution_clock::time_point t1 =
|
||||||
|
high_resolution_clock::now();
|
||||||
|
result = p.expr() + p2.expr();
|
||||||
|
const high_resolution_clock::time_point t2 =
|
||||||
|
high_resolution_clock::now();
|
||||||
|
const duration<double> time_span = t2 - t1;
|
||||||
|
Pout<< "Operation time:" << time_span.count() << endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
// const auto oldDimensions = p.dimensions();
|
||||||
|
// p.dimensions().reset(dimless);
|
||||||
|
// p2.dimensions().reset(dimless);
|
||||||
|
// result.dimensions().reset(dimless);
|
||||||
|
// {
|
||||||
|
//
|
||||||
|
// Pout<< "Complex expression : No expression templates:" << endl;
|
||||||
|
// const high_resolution_clock::time_point t1 =
|
||||||
|
// high_resolution_clock::now();
|
||||||
|
// result = cos(p + 0.5*sqrt(p2-sin(p)));
|
||||||
|
// const high_resolution_clock::time_point t2 =
|
||||||
|
// high_resolution_clock::now();
|
||||||
|
// const duration<double> time_span = t2 - t1;
|
||||||
|
// Pout<< "Operation time:" << time_span.count() << endl;
|
||||||
|
// }
|
||||||
|
// {
|
||||||
|
// Pout<< "Complex expression : With expression templates:" << endl;
|
||||||
|
// const high_resolution_clock::time_point t1 =
|
||||||
|
// high_resolution_clock::now();
|
||||||
|
// const auto zeroDotFive
|
||||||
|
// (
|
||||||
|
// dimensionedScalar(dimless, 0.5).expr(p)
|
||||||
|
// );
|
||||||
|
// result = cos(p.expr() + zeroDotFive*sqrt(p2.expr()-sin(p.expr())));
|
||||||
|
// const high_resolution_clock::time_point t2 =
|
||||||
|
// high_resolution_clock::now();
|
||||||
|
// const duration<double> time_span = t2 - t1;
|
||||||
|
// Pout<< "Operation time:" << time_span.count() << endl;
|
||||||
|
// }
|
||||||
|
// p.dimensions().reset(oldDimensions);
|
||||||
|
// p2.dimensions().reset(oldDimensions);
|
||||||
|
// result.dimensions().reset(oldDimensions);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
// auto expression = someFunction(p).expr() + someFunction(p).expr();
|
||||||
|
// result = expression;
|
||||||
|
// DebugVar(result);
|
||||||
|
}
|
||||||
|
{
|
||||||
|
volScalarField result
|
||||||
|
(
|
||||||
|
IOobject
|
||||||
|
(
|
||||||
|
"result",
|
||||||
|
runTime.timeName(),
|
||||||
|
mesh.thisDb(),
|
||||||
|
IOobject::NO_READ,
|
||||||
|
IOobject::NO_WRITE,
|
||||||
|
IOobject::NO_REGISTER
|
||||||
|
),
|
||||||
|
mesh,
|
||||||
|
dimensionedScalar(p.dimensions(), 0)
|
||||||
|
);
|
||||||
|
auto expression = someFunction(p).expr() + someFunction(p).expr();
|
||||||
|
result = expression;
|
||||||
|
DebugVar(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Expresions of volFields
|
||||||
|
{
|
||||||
|
volScalarField result
|
||||||
|
(
|
||||||
|
"result",
|
||||||
|
mesh,
|
||||||
|
sqr(p.expr() + p.expr())
|
||||||
|
);
|
||||||
|
DebugVar(result);
|
||||||
|
}
|
||||||
|
{
|
||||||
|
// Fill p with some values
|
||||||
|
forAll(p, celli)
|
||||||
|
{
|
||||||
|
p[celli] = celli;
|
||||||
|
}
|
||||||
|
p.correctBoundaryConditions();
|
||||||
|
|
||||||
|
// Interpolate to surface field
|
||||||
|
surfaceScalarField result
|
||||||
|
(
|
||||||
|
"result",
|
||||||
|
mesh,
|
||||||
|
Expression::interpolate //<volExpr, surfaceExpr>
|
||||||
|
(
|
||||||
|
p.expr(),
|
||||||
|
mesh.surfaceInterpolation::weights().expr(),
|
||||||
|
mesh
|
||||||
|
)
|
||||||
|
);
|
||||||
|
DebugVar(result);
|
||||||
|
}
|
||||||
|
{
|
||||||
|
// For testing as a replacement of laplacian weights
|
||||||
|
const volScalarField gamma
|
||||||
|
(
|
||||||
|
IOobject
|
||||||
|
(
|
||||||
|
"gamma",
|
||||||
|
runTime.timeName(),
|
||||||
|
mesh,
|
||||||
|
IOobject::NO_READ,
|
||||||
|
IOobject::NO_WRITE,
|
||||||
|
IOobject::NO_REGISTER
|
||||||
|
),
|
||||||
|
mesh,
|
||||||
|
dimensionedScalar(dimless, 1.0)
|
||||||
|
);
|
||||||
|
|
||||||
|
fvMatrix<scalar> fvm
|
||||||
|
(
|
||||||
|
p,
|
||||||
|
gamma.dimensions()*mesh.magSf().dimensions()*p.dimensions()
|
||||||
|
);
|
||||||
|
|
||||||
|
const linear<scalar> interpGammaScheme(mesh);
|
||||||
|
const fv::correctedSnGrad<scalar> snGradScheme(mesh);
|
||||||
|
|
||||||
|
fusedGaussFvmLaplacian
|
||||||
|
(
|
||||||
|
fvm,
|
||||||
|
interpGammaScheme,
|
||||||
|
snGradScheme,
|
||||||
|
gamma,
|
||||||
|
p
|
||||||
|
);
|
||||||
|
|
||||||
|
DebugVar(fvm.source());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// Expressions of fvMatrix
|
||||||
|
{
|
||||||
|
tmp<fvMatrix<scalar>> tm0(fvm::laplacian(p));
|
||||||
|
const fvMatrix<scalar>& m0 = tm0();
|
||||||
|
DebugVar(m0.dimensions());
|
||||||
|
|
||||||
|
tmp<fvMatrix<scalar>> tm1(fvm::laplacian(p));
|
||||||
|
const fvMatrix<scalar>& m1 = tm1();
|
||||||
|
DebugVar(m1.dimensions());
|
||||||
|
|
||||||
|
fvMatrix<scalar> m2(p, m0.expr() + m1.expr());
|
||||||
|
DebugVar(m2.dimensions());
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -296,7 +296,7 @@ int main(int argc, char *argv[])
|
|||||||
(
|
(
|
||||||
strings,
|
strings,
|
||||||
order,
|
order,
|
||||||
stringOps::natural_sort::less<string>(strings)
|
stringOps::natural_sort::list_less(strings)
|
||||||
);
|
);
|
||||||
Info<< "natural sortedOrder: " << flatOutput(order) << endl;
|
Info<< "natural sortedOrder: " << flatOutput(order) << endl;
|
||||||
}
|
}
|
||||||
@ -321,7 +321,7 @@ int main(int argc, char *argv[])
|
|||||||
/// sortable = hashed.toc();
|
/// sortable = hashed.toc();
|
||||||
/// sortable.sort
|
/// sortable.sort
|
||||||
/// (
|
/// (
|
||||||
/// stringOps::natural_sort::less<string>(sortable)
|
/// stringOps::natural_sort::list_less(sortable)
|
||||||
/// );
|
/// );
|
||||||
/// Info<< nl << "natural:" << sortable << endl;
|
/// Info<< nl << "natural:" << sortable << endl;
|
||||||
|
|
||||||
@ -329,7 +329,7 @@ int main(int argc, char *argv[])
|
|||||||
/// sortable = hashed.toc();
|
/// sortable = hashed.toc();
|
||||||
/// sortable.sort
|
/// sortable.sort
|
||||||
/// (
|
/// (
|
||||||
/// stringOps::natural_sort::greater<string>(sortable)
|
/// stringOps::natural_sort::list_greater(sortable)
|
||||||
/// );
|
/// );
|
||||||
/// Info<< nl << "natural:" << sortable << endl;
|
/// Info<< nl << "natural:" << sortable << endl;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -59,11 +59,6 @@ int main(int argc, char *argv[])
|
|||||||
<< " type: " << typeid(cstr).name() << " len:" << len << nl;
|
<< " type: " << typeid(cstr).name() << " len:" << len << nl;
|
||||||
|
|
||||||
Info<< " view: " << std::string_view(cstr) << nl;
|
Info<< " view: " << std::string_view(cstr) << nl;
|
||||||
|
|
||||||
Info<< " span: "
|
|
||||||
<< stdFoam::span<const char>(cstr, len) << nl;
|
|
||||||
Info<< " span: "
|
|
||||||
<< stdFoam::span<char>(const_cast<char*>(cstr), len) << nl;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
mydebugSurfaceWriter.C
|
mydebugSurfaceWriter.cxx
|
||||||
Test-surface-sampling.C
|
Test-surface-sampling.cxx
|
||||||
|
|
||||||
EXE = $(FOAM_USER_APPBIN)/Test-surface-sampling
|
EXE = $(FOAM_USER_APPBIN)/Test-surface-sampling
|
||||||
|
|||||||
@ -5,7 +5,7 @@
|
|||||||
\\ / A nd | www.openfoam.com
|
\\ / A nd | www.openfoam.com
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2022-2023 OpenCFD Ltd.
|
Copyright (C) 2022-2025 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -83,12 +83,10 @@ template<> struct narrowType<SymmTensor<double>>
|
|||||||
typedef SymmTensor<float> type;
|
typedef SymmTensor<float> type;
|
||||||
};
|
};
|
||||||
|
|
||||||
// FIXME: Not sure why this one seems to be broken...
|
template<> struct narrowType<Tensor<double>>
|
||||||
//
|
{
|
||||||
// template<> struct narrowType<Tensor<double>>
|
typedef Tensor<float> type;
|
||||||
// {
|
};
|
||||||
// typedef Tensor<float> type;
|
|
||||||
// };
|
|
||||||
|
|
||||||
} // End namespace Foam
|
} // End namespace Foam
|
||||||
|
|
||||||
@ -104,12 +102,18 @@ Foam::surfaceWriters::mydebugWriter::mergeField
|
|||||||
{
|
{
|
||||||
addProfiling(merge, "debugWriter::merge-field");
|
addProfiling(merge, "debugWriter::merge-field");
|
||||||
|
|
||||||
// This is largely identical to surfaceWriter::mergeField()
|
// Identical to surfaceWriter::mergeField()
|
||||||
// but with narrowing for communication
|
// but with narrowing for communication
|
||||||
if (narrowTransfer_ && parallel_ && UPstream::parRun())
|
|
||||||
|
if constexpr (std::is_same_v<Tensor<double>, Type>)
|
||||||
|
{
|
||||||
|
// Cannot narrow tensor. Does not compile since MatrixSpace
|
||||||
|
// does not (yet) allow assigments from different Cmpt types.
|
||||||
|
}
|
||||||
|
else if (narrowTransfer_ && parallel_ && UPstream::parRun())
|
||||||
{
|
{
|
||||||
// The narrowed type
|
// The narrowed type
|
||||||
typedef typename narrowType<Type>::type narrowedType;
|
using narrowedType = typename narrowType<Type>::type;
|
||||||
|
|
||||||
// Ensure geometry is also merged
|
// Ensure geometry is also merged
|
||||||
merge();
|
merge();
|
||||||
@ -130,14 +134,29 @@ Foam::surfaceWriters::mydebugWriter::mergeField
|
|||||||
ConstPrecisionAdaptor<narrowedType, Type> input(fld);
|
ConstPrecisionAdaptor<narrowedType, Type> input(fld);
|
||||||
PrecisionAdaptor<narrowedType, Type> output(allFld);
|
PrecisionAdaptor<narrowedType, Type> output(allFld);
|
||||||
|
|
||||||
globIndex.gather
|
if (gatherv_)
|
||||||
(
|
{
|
||||||
input.cref(), // fld,
|
globIndex.mpiGather
|
||||||
output.ref(), // allFld,
|
(
|
||||||
UPstream::msgType(),
|
input.cref(), // fld
|
||||||
commType_,
|
output.ref(), // allFld
|
||||||
UPstream::worldComm
|
UPstream::worldComm,
|
||||||
);
|
// For fallback:
|
||||||
|
commType_,
|
||||||
|
UPstream::msgType()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
globIndex.gather
|
||||||
|
(
|
||||||
|
input.cref(), // fld
|
||||||
|
output.ref(), // allFld
|
||||||
|
UPstream::msgType(),
|
||||||
|
commType_,
|
||||||
|
UPstream::worldComm
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
// Commit adapted content changes
|
// Commit adapted content changes
|
||||||
input.commit();
|
input.commit();
|
||||||
@ -193,8 +212,19 @@ Foam::surfaceWriters::mydebugWriter::mydebugWriter
|
|||||||
{
|
{
|
||||||
Info<< "Using debug surface writer ("
|
Info<< "Using debug surface writer ("
|
||||||
<< (this->isPointData() ? "point" : "face") << " data):"
|
<< (this->isPointData() ? "point" : "face") << " data):"
|
||||||
<< " commsType=" << UPstream::commsTypeNames[commType_]
|
<< " commsType=";
|
||||||
<< " merge=" << Switch::name(enableMerge_)
|
|
||||||
|
if (UPstream::parRun())
|
||||||
|
{
|
||||||
|
if (gatherv_) Info<< "gatherv+";
|
||||||
|
Info<< UPstream::commsTypeNames[commType_];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Info<< "serial";
|
||||||
|
}
|
||||||
|
|
||||||
|
Info<< " merge=" << Switch::name(enableMerge_)
|
||||||
<< " write=" << Switch::name(enableWrite_)
|
<< " write=" << Switch::name(enableWrite_)
|
||||||
<< " narrow=" << Switch::name(narrowTransfer_)
|
<< " narrow=" << Switch::name(narrowTransfer_)
|
||||||
<< endl;
|
<< endl;
|
||||||
@ -30,7 +30,8 @@ Group
|
|||||||
grpPostProcessingUtilities
|
grpPostProcessingUtilities
|
||||||
|
|
||||||
Description
|
Description
|
||||||
List regions from constant/regionProperties.
|
List volume regions from constant/regionProperties
|
||||||
|
or area regions from constant/finite-area/regionProperties
|
||||||
|
|
||||||
Usage
|
Usage
|
||||||
\b foamListRegions [OPTION]
|
\b foamListRegions [OPTION]
|
||||||
@ -72,6 +73,12 @@ int main(int argc, char *argv[])
|
|||||||
"List constant/finite-area/regionProperties (if available)"
|
"List constant/finite-area/regionProperties (if available)"
|
||||||
);
|
);
|
||||||
|
|
||||||
|
argList::addBoolOption
|
||||||
|
(
|
||||||
|
"optional",
|
||||||
|
"A missing regionProperties is not treated as an error"
|
||||||
|
);
|
||||||
|
|
||||||
argList::addDryRunOption
|
argList::addDryRunOption
|
||||||
(
|
(
|
||||||
"Make reading optional and add verbosity"
|
"Make reading optional and add verbosity"
|
||||||
@ -92,14 +99,20 @@ int main(int argc, char *argv[])
|
|||||||
++optVerbose;
|
++optVerbose;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// File is optional, not an error
|
||||||
|
const bool isOptional = args.found("optional");
|
||||||
|
|
||||||
// Use finite-area regions
|
// Use finite-area regions
|
||||||
const bool doFiniteArea = args.found("finite-area");
|
const bool doFiniteArea = args.found("finite-area");
|
||||||
|
|
||||||
|
// The number of optional region filters to apply
|
||||||
|
const label nFilters = (args.size()-1);
|
||||||
|
|
||||||
IOobjectOption::readOption readOpt(IOobjectOption::MUST_READ);
|
IOobjectOption::readOption readOpt(IOobjectOption::MUST_READ);
|
||||||
|
|
||||||
if (dryRun || doFiniteArea)
|
if (dryRun || isOptional || doFiniteArea)
|
||||||
{
|
{
|
||||||
// Always treat finite-area regionProperties as optional
|
// The finite-area regionProperties are also considered optional
|
||||||
readOpt = IOobjectOption::READ_IF_PRESENT;
|
readOpt = IOobjectOption::READ_IF_PRESENT;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -116,58 +129,70 @@ int main(int argc, char *argv[])
|
|||||||
if (doFiniteArea)
|
if (doFiniteArea)
|
||||||
{
|
{
|
||||||
regionProps = regionProperties(runTime, faMeshPrefix, readOpt);
|
regionProps = regionProperties(runTime, faMeshPrefix, readOpt);
|
||||||
|
|
||||||
if (regionProps.empty())
|
|
||||||
{
|
|
||||||
InfoErr<< "No finite-area region types" << nl;
|
|
||||||
}
|
|
||||||
else if (optVerbose)
|
|
||||||
{
|
|
||||||
InfoErr
|
|
||||||
<< "Have " << regionProps.size()
|
|
||||||
<< " finite-area region types, "
|
|
||||||
<< regionProps.count() << " regions" << nl << nl;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
regionProps = regionProperties(runTime, readOpt);
|
regionProps = regionProperties(runTime, readOpt);
|
||||||
|
|
||||||
if (regionProps.empty())
|
|
||||||
{
|
|
||||||
// Probably only occurs with -dry-run option
|
|
||||||
InfoErr<< "No region types" << nl;
|
|
||||||
}
|
|
||||||
else if (optVerbose)
|
|
||||||
{
|
|
||||||
InfoErr
|
|
||||||
<< "Have " << regionProps.size() << " region types, "
|
|
||||||
<< regionProps.count() << " regions" << nl << nl;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// We now handle checking args and general sanity etc.
|
// Some reporting...
|
||||||
wordList regionTypes;
|
if (regionProps.empty())
|
||||||
|
|
||||||
if (args.size() > 1)
|
|
||||||
{
|
{
|
||||||
regionTypes.resize(args.size()-1);
|
if (doFiniteArea)
|
||||||
|
{
|
||||||
|
InfoErr<< "No finite-area region types" << nl;
|
||||||
|
}
|
||||||
|
else if (isOptional)
|
||||||
|
{
|
||||||
|
InfoErr<< "No region types" << nl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (optVerbose)
|
||||||
|
{
|
||||||
|
InfoErr << "Have " << regionProps.size();
|
||||||
|
|
||||||
// No duplicates
|
if (doFiniteArea)
|
||||||
|
{
|
||||||
|
InfoErr<< " finite-area";
|
||||||
|
}
|
||||||
|
InfoErr
|
||||||
|
<< " region types, "
|
||||||
|
<< regionProps.count() << " regions" << nl << nl;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// We now handle checking args and general sanity etc.
|
||||||
|
|
||||||
|
DynamicList<word> regionTypes;
|
||||||
|
|
||||||
|
if (isOptional && regionProps.empty())
|
||||||
|
{
|
||||||
|
// Nothing to do...
|
||||||
|
}
|
||||||
|
else if (nFilters > 0)
|
||||||
|
{
|
||||||
|
// Apply region filters
|
||||||
|
|
||||||
|
regionTypes.reserve_exact
|
||||||
|
(
|
||||||
|
Foam::min(nFilters, regionProps.size())
|
||||||
|
);
|
||||||
|
|
||||||
|
// No duplicates, and no duplicate warnings
|
||||||
wordHashSet uniq;
|
wordHashSet uniq;
|
||||||
|
|
||||||
label nTypes = 0;
|
|
||||||
for (label argi = 1; argi < args.size(); ++argi)
|
for (label argi = 1; argi < args.size(); ++argi)
|
||||||
{
|
{
|
||||||
regionTypes[nTypes] = args[argi];
|
word regType(args[argi]);
|
||||||
|
|
||||||
const word& regType = regionTypes[nTypes];
|
|
||||||
|
|
||||||
if (uniq.insert(regType))
|
if (uniq.insert(regType))
|
||||||
{
|
{
|
||||||
if (regionProps.contains(regType))
|
if (regionProps.contains(regType))
|
||||||
{
|
{
|
||||||
++nTypes;
|
if (!regionTypes.contains(regType))
|
||||||
|
{
|
||||||
|
regionTypes.push_back(std::move(regType));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -175,22 +200,22 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
regionTypes.resize(nTypes);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
// Take all regions
|
||||||
regionTypes = regionProps.sortedToc();
|
regionTypes = regionProps.sortedToc();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
for (const word& regionType : regionTypes)
|
for (const word& regionType : regionTypes)
|
||||||
{
|
{
|
||||||
const wordList& regionNames = regionProps[regionType];
|
if (const auto iter = regionProps.cfind(regionType); iter.good())
|
||||||
|
|
||||||
for (const word& regionName : regionNames)
|
|
||||||
{
|
{
|
||||||
Info<< regionName << nl;
|
for (const word& regionName : iter.val())
|
||||||
|
{
|
||||||
|
Info<< regionName << nl;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -418,8 +418,14 @@ int main(int argc, char *argv[])
|
|||||||
// Allow explicit -constant, have zero from time range
|
// Allow explicit -constant, have zero from time range
|
||||||
timeSelector::addOptions(true, false); // constant(true), zero(false)
|
timeSelector::addOptions(true, false); // constant(true), zero(false)
|
||||||
|
|
||||||
|
// Prevent volume BCs from triggering finite-area
|
||||||
|
regionModels::allowFaModels(false);
|
||||||
|
|
||||||
#include "setRootCase.H"
|
#include "setRootCase.H"
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------
|
||||||
|
// Configuration
|
||||||
|
|
||||||
const bool writeCellDist = args.found("cellDist");
|
const bool writeCellDist = args.found("cellDist");
|
||||||
|
|
||||||
// Most of these are ignored for dry-run (not triggered anywhere)
|
// Most of these are ignored for dry-run (not triggered anywhere)
|
||||||
|
|||||||
@ -135,9 +135,14 @@ int main(int argc, char *argv[])
|
|||||||
"Only reconstruct new times (i.e. that do not exist already)"
|
"Only reconstruct new times (i.e. that do not exist already)"
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// Prevent volume BCs from triggering finite-area
|
||||||
|
regionModels::allowFaModels(false);
|
||||||
|
|
||||||
#include "setRootCase.H"
|
#include "setRootCase.H"
|
||||||
#include "createTime.H"
|
#include "createTime.H"
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------
|
||||||
|
// Configuration
|
||||||
|
|
||||||
const bool doFields = !args.found("no-fields");
|
const bool doFields = !args.found("no-fields");
|
||||||
wordRes selectedFields;
|
wordRes selectedFields;
|
||||||
|
|||||||
@ -780,11 +780,17 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
#include "addAllRegionOptions.H"
|
#include "addAllRegionOptions.H"
|
||||||
|
|
||||||
|
// Prevent volume BCs from triggering finite-area
|
||||||
|
regionModels::allowFaModels(false);
|
||||||
|
|
||||||
#include "setRootCase.H"
|
#include "setRootCase.H"
|
||||||
#include "createTime.H"
|
#include "createTime.H"
|
||||||
|
|
||||||
printWarning();
|
printWarning();
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------
|
||||||
|
// Configuration
|
||||||
|
|
||||||
const bool fullMatch = args.found("fullMatch");
|
const bool fullMatch = args.found("fullMatch");
|
||||||
const bool procMatch = args.found("procMatch");
|
const bool procMatch = args.found("procMatch");
|
||||||
const bool writeCellDist = args.found("cellDist");
|
const bool writeCellDist = args.found("cellDist");
|
||||||
|
|||||||
@ -1257,6 +1257,8 @@ int main(int argc, char *argv[])
|
|||||||
true // Advanced option
|
true // Advanced option
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// Prevent volume BCs from triggering finite-area
|
||||||
|
regionModels::allowFaModels(false);
|
||||||
|
|
||||||
//- Disable caching of times/processor dirs etc. Cause massive parallel
|
//- Disable caching of times/processor dirs etc. Cause massive parallel
|
||||||
// problems when e.g decomposing.
|
// problems when e.g decomposing.
|
||||||
@ -1269,6 +1271,7 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
argList args(argc, argv);
|
argList args(argc, argv);
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------
|
||||||
|
|
||||||
// As much as possible avoid synchronised operation. To be looked at more
|
// As much as possible avoid synchronised operation. To be looked at more
|
||||||
// closely for the three scenarios:
|
// closely for the three scenarios:
|
||||||
|
|||||||
@ -323,6 +323,9 @@ int main(int argc, char *argv[])
|
|||||||
);
|
);
|
||||||
argList::addOptionCompat("cellZones", {"cellZone", 1912});
|
argList::addOptionCompat("cellZones", {"cellZone", 1912});
|
||||||
|
|
||||||
|
// Prevent volume BCs from triggering finite-area
|
||||||
|
regionModels::allowFaModels(false);
|
||||||
|
|
||||||
#include "setRootCase.H"
|
#include "setRootCase.H"
|
||||||
|
|
||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
|
|||||||
@ -479,8 +479,14 @@ int main(int argc, char *argv[])
|
|||||||
"Directory name for VTK output (default: 'VTK')"
|
"Directory name for VTK output (default: 'VTK')"
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// Prevent volume BCs from triggering finite-area
|
||||||
|
regionModels::allowFaModels(false);
|
||||||
|
|
||||||
#include "setRootCase.H"
|
#include "setRootCase.H"
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------
|
||||||
|
// Configuration
|
||||||
|
|
||||||
/// const int optVerbose = args.verbose();
|
/// const int optVerbose = args.verbose();
|
||||||
const bool decomposePoly = args.found("poly-decomp");
|
const bool decomposePoly = args.found("poly-decomp");
|
||||||
const bool doBoundary = !args.found("no-boundary");
|
const bool doBoundary = !args.found("no-boundary");
|
||||||
|
|||||||
138
bin/foamCleanFaMesh
Executable file
138
bin/foamCleanFaMesh
Executable file
@ -0,0 +1,138 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
#------------------------------------------------------------------------------
|
||||||
|
# ========= |
|
||||||
|
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
# \\ / O peration |
|
||||||
|
# \\ / A nd | www.openfoam.com
|
||||||
|
# \\/ M anipulation |
|
||||||
|
#-------------------------------------------------------------------------------
|
||||||
|
# Copyright (C) 2011 OpenFOAM Foundation
|
||||||
|
# Copyright (C) 2025 OpenCFD Ltd.
|
||||||
|
#------------------------------------------------------------------------------
|
||||||
|
# License
|
||||||
|
# This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
|
||||||
|
#
|
||||||
|
# Script
|
||||||
|
# foamCleanFaMesh
|
||||||
|
#
|
||||||
|
# Description
|
||||||
|
# Remove the contents of the constant/finite-area/faMesh directory
|
||||||
|
# as per the Foam::faMesh::removeFiles() method.
|
||||||
|
#
|
||||||
|
#------------------------------------------------------------------------------
|
||||||
|
usage() {
|
||||||
|
exec 1>&2
|
||||||
|
while [ "$#" -ge 1 ]; do echo "$1"; shift; done
|
||||||
|
cat <<USAGE
|
||||||
|
|
||||||
|
Usage: ${0##*/} [OPTION]
|
||||||
|
options:
|
||||||
|
-case <dir> case directory, default is the cwd
|
||||||
|
-area-region <name> area-mesh region
|
||||||
|
-dry-run | -n report actions but do not remove
|
||||||
|
-help print the usage
|
||||||
|
|
||||||
|
Remove the contents of the constant/finite-area/faMesh directory as per the
|
||||||
|
Foam::faMesh::removeFiles() method.
|
||||||
|
|
||||||
|
USAGE
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
#------------------------------------------------------------------------------
|
||||||
|
# Parse options
|
||||||
|
unset caseDir areaRegion optDryRun
|
||||||
|
|
||||||
|
while [ "$#" -gt 0 ]
|
||||||
|
do
|
||||||
|
case "$1" in
|
||||||
|
-h | -help*)
|
||||||
|
usage
|
||||||
|
;;
|
||||||
|
-dry-run | -n)
|
||||||
|
optDryRun="(dry-run) "
|
||||||
|
;;
|
||||||
|
|
||||||
|
-case=*)
|
||||||
|
caseDir="${1#*=}"
|
||||||
|
;;
|
||||||
|
|
||||||
|
-case)
|
||||||
|
[ "$#" -ge 2 ] || usage "'$1' option requires an argument"
|
||||||
|
cd "$2" 2>/dev/null || usage "directory does not exist: '$2'"
|
||||||
|
caseDir=$2
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
|
||||||
|
-area-region)
|
||||||
|
[ "$#" -ge 2 ] || usage "'$1' option requires an argument"
|
||||||
|
areaRegion=$2
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
|
||||||
|
(*)
|
||||||
|
usage "unknown option/argument: '$*'"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
shift
|
||||||
|
done
|
||||||
|
|
||||||
|
#------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
# Remove files (mesh etc)
|
||||||
|
# also remove .gz versions of the same files
|
||||||
|
|
||||||
|
removeFiles()
|
||||||
|
{
|
||||||
|
local directory="$1"
|
||||||
|
|
||||||
|
for i in \
|
||||||
|
faceLabels \
|
||||||
|
faBoundary \
|
||||||
|
;
|
||||||
|
do
|
||||||
|
if [ -n "$optDryRun" ]
|
||||||
|
then
|
||||||
|
echo "${optDryRun} rm -rf $directory/{$i,$i.gz}"
|
||||||
|
else
|
||||||
|
rm -rf -- "$directory/$i" "$directory/$i.gz"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
#------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
meshDir="constant/finite-area/${areaRegion}${areaRegion:+/}faMesh"
|
||||||
|
|
||||||
|
if [ -d "$meshDir" ]
|
||||||
|
then
|
||||||
|
# [OK] has constant/finite-areaRegion/<region>/faMesh
|
||||||
|
:
|
||||||
|
|
||||||
|
elif [ -n "$caseDir" ]
|
||||||
|
then
|
||||||
|
# Specified -case, so no extra magic...
|
||||||
|
echo "Error: no <$meshDir> in $caseDir" 1>&2
|
||||||
|
exit 1
|
||||||
|
|
||||||
|
else
|
||||||
|
# Try some other combinations
|
||||||
|
other="${meshDir#constant/}"
|
||||||
|
|
||||||
|
if [ -d "$other" ]
|
||||||
|
then
|
||||||
|
# Probably already within constant/
|
||||||
|
meshDir="$other}"
|
||||||
|
elif [ "${PWD##*/}" = faMesh ] && [ -z "$areaRegion" ]
|
||||||
|
then
|
||||||
|
# Apparently already within faMesh/
|
||||||
|
meshDir=.
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
echo "Cleaning ${caseDir:-.}/$meshDir" 1>&2
|
||||||
|
|
||||||
|
removeFiles "$meshDir"
|
||||||
|
|
||||||
|
#------------------------------------------------------------------------------
|
||||||
@ -7,7 +7,7 @@
|
|||||||
# \\/ M anipulation |
|
# \\/ M anipulation |
|
||||||
#-------------------------------------------------------------------------------
|
#-------------------------------------------------------------------------------
|
||||||
# Copyright (C) 2011-2016 OpenFOAM Foundation
|
# Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||||
# Copyright (C) 2022 OpenCFD Ltd.
|
# Copyright (C) 2022,2025 OpenCFD Ltd.
|
||||||
#------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------
|
||||||
# License
|
# License
|
||||||
# This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
|
# This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
|
||||||
@ -27,9 +27,10 @@ usage() {
|
|||||||
|
|
||||||
Usage: ${0##*/} [OPTION]
|
Usage: ${0##*/} [OPTION]
|
||||||
options:
|
options:
|
||||||
-case <dir> specify alternative case directory, default is the cwd
|
-case <dir> case directory, default is the cwd
|
||||||
-region <name> specify alternative mesh region
|
-region <name> mesh region
|
||||||
-help print the usage
|
-dry-run | -n report actions but do not remove
|
||||||
|
-help print the usage
|
||||||
|
|
||||||
Remove the contents of the constant/polyMesh directory as per the
|
Remove the contents of the constant/polyMesh directory as per the
|
||||||
Foam::polyMesh::removeFiles() method.
|
Foam::polyMesh::removeFiles() method.
|
||||||
@ -38,58 +39,101 @@ USAGE
|
|||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
unset caseDir regionName
|
#------------------------------------------------------------------------------
|
||||||
|
# Parse options
|
||||||
|
unset caseDir regionName optDryRun
|
||||||
|
|
||||||
# Parse a single option
|
|
||||||
while [ "$#" -gt 0 ]
|
while [ "$#" -gt 0 ]
|
||||||
do
|
do
|
||||||
case "$1" in
|
case "$1" in
|
||||||
-h | -help*)
|
-h | -help*)
|
||||||
usage
|
usage
|
||||||
;;
|
;;
|
||||||
|
-dry-run | -n)
|
||||||
|
optDryRun="(dry-run) "
|
||||||
|
;;
|
||||||
|
|
||||||
|
-case=*)
|
||||||
|
caseDir="${1#*=}"
|
||||||
|
;;
|
||||||
|
|
||||||
-case)
|
-case)
|
||||||
|
caseDir="$2"
|
||||||
[ "$#" -ge 2 ] || usage "'$1' option requires an argument"
|
[ "$#" -ge 2 ] || usage "'$1' option requires an argument"
|
||||||
cd "$2" 2>/dev/null || usage "directory does not exist: '$2'"
|
cd "$2" 2>/dev/null || usage "directory does not exist: '$2'"
|
||||||
caseDir=$2
|
caseDir=$2
|
||||||
shift 2
|
shift
|
||||||
;;
|
;;
|
||||||
|
|
||||||
-region)
|
-region)
|
||||||
[ "$#" -ge 2 ] || usage "'$1' option requires an argument"
|
[ "$#" -ge 2 ] || usage "'$1' option requires an argument"
|
||||||
regionName=$2
|
regionName="$2"
|
||||||
shift 2
|
shift
|
||||||
;;
|
;;
|
||||||
*)
|
|
||||||
|
(*)
|
||||||
usage "unknown option/argument: '$*'"
|
usage "unknown option/argument: '$*'"
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
shift
|
||||||
done
|
done
|
||||||
|
|
||||||
meshDir=polyMesh
|
#------------------------------------------------------------------------------
|
||||||
if [ -n "$regionName" ]
|
|
||||||
then
|
|
||||||
meshDir="$regionName/$meshDir"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# If -case was specified: insist upon 'constant/polyMesh'
|
# Remove files (mesh itself, modifiers, snappyHexMesh ones) and subdirectories
|
||||||
if [ -n "$caseDir" ]
|
# also remove .gz versions of the same files
|
||||||
|
|
||||||
|
removeFiles()
|
||||||
|
{
|
||||||
|
local directory="$1"
|
||||||
|
|
||||||
|
for i in \
|
||||||
|
points faces \
|
||||||
|
owner neighbour \
|
||||||
|
boundary \
|
||||||
|
cells \
|
||||||
|
cellZones faceZones pointZones \
|
||||||
|
meshModifiers \
|
||||||
|
parallelData \
|
||||||
|
sets \
|
||||||
|
cellLevel pointLevel \
|
||||||
|
level0Edge \
|
||||||
|
refinementHistory \
|
||||||
|
surfaceIndex \
|
||||||
|
;
|
||||||
|
do
|
||||||
|
if [ -n "$optDryRun" ]
|
||||||
|
then
|
||||||
|
echo "${optDryRun} rm -rf $directory/{$i,$i.gz}"
|
||||||
|
else
|
||||||
|
rm -rf -- "$directory/$i" "$directory/$i.gz"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
#------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
meshDir="constant/${regionName}${regionName:+/}polyMesh"
|
||||||
|
|
||||||
|
if [ -d "$meshDir" ]
|
||||||
then
|
then
|
||||||
if [ -d constant/"$meshDir" ]
|
# [OK] has constant/<region>/polyMesh
|
||||||
then
|
:
|
||||||
# Use constant/polyMesh
|
|
||||||
meshDir=constant/"$meshDir"
|
elif [ -n "$caseDir" ]
|
||||||
else
|
then
|
||||||
echo "Error: no 'constant/$meshDir' in $caseDir" 1>&2
|
# Specified -case, so no extra magic...
|
||||||
exit 1
|
echo "Error: no <$meshDir> in $caseDir" 1>&2
|
||||||
fi
|
exit 1
|
||||||
|
|
||||||
else
|
else
|
||||||
if [ -d constant/"$meshDir" ]
|
# Try some other combinations
|
||||||
|
other="${meshDir#constant/}"
|
||||||
|
|
||||||
|
if [ -d "$other" ]
|
||||||
then
|
then
|
||||||
# Use constant/polyMesh
|
# Probably already within constant/
|
||||||
meshDir=constant/"$meshDir"
|
meshDir="$other}"
|
||||||
elif [ -d "$meshDir" ]
|
|
||||||
then
|
|
||||||
# Likely already in constant/ - do not adjust anything
|
|
||||||
:
|
|
||||||
elif [ "${PWD##*/}" = polyMesh ] && [ -z "$regionName" ]
|
elif [ "${PWD##*/}" = polyMesh ] && [ -z "$regionName" ]
|
||||||
then
|
then
|
||||||
# Apparently already within polyMesh/
|
# Apparently already within polyMesh/
|
||||||
@ -98,31 +142,8 @@ else
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
# Remove files (mesh itself, modifiers, snappyHexMesh ones) and subdirectories
|
|
||||||
# also remove .gz versions of the same files
|
|
||||||
echo "Cleaning ${caseDir:-.}/$meshDir" 1>&2
|
echo "Cleaning ${caseDir:-.}/$meshDir" 1>&2
|
||||||
|
|
||||||
for i in \
|
removeFiles "$meshDir"
|
||||||
points \
|
|
||||||
faces \
|
|
||||||
owner \
|
|
||||||
neighbour \
|
|
||||||
cells \
|
|
||||||
boundary \
|
|
||||||
pointZones \
|
|
||||||
faceZones \
|
|
||||||
cellZones \
|
|
||||||
meshModifiers \
|
|
||||||
parallelData \
|
|
||||||
sets \
|
|
||||||
cellLevel \
|
|
||||||
pointLevel \
|
|
||||||
level0Edge \
|
|
||||||
refinementHistory \
|
|
||||||
surfaceIndex \
|
|
||||||
;
|
|
||||||
do
|
|
||||||
rm -rf "$meshDir/$i" "$meshDir/$i.gz"
|
|
||||||
done
|
|
||||||
|
|
||||||
#------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------
|
||||||
|
|||||||
@ -108,54 +108,116 @@ cleanPostProcessing()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
# ---------------
|
||||||
|
# Remove constant/finite-area/faMesh or constant/finite-area/{region}/faMesh
|
||||||
|
#
|
||||||
|
# Accepts following options:
|
||||||
|
# -region <name> The region name
|
||||||
|
# -- End of options
|
||||||
|
# ---------------
|
||||||
cleanFaMesh()
|
cleanFaMesh()
|
||||||
{
|
{
|
||||||
if [ -e constant/finite-area/faMesh ]
|
local region
|
||||||
|
|
||||||
|
# Parse options
|
||||||
|
while [ "$#" -gt 0 ]
|
||||||
|
do
|
||||||
|
case "$1" in
|
||||||
|
('') ;; # Ignore empty option
|
||||||
|
(--) shift; break ;; # Stop option parsing
|
||||||
|
|
||||||
|
(-region) region="$2"; shift ;;
|
||||||
|
(*) break ;;
|
||||||
|
esac
|
||||||
|
shift
|
||||||
|
done
|
||||||
|
|
||||||
|
# safety
|
||||||
|
if [ "$region" = "--" ]; then unset region; fi
|
||||||
|
|
||||||
|
local meshDir="constant/finite-area/${region}${region:+/}faMesh"
|
||||||
|
|
||||||
|
if [ -e "$meshDir" ]
|
||||||
then
|
then
|
||||||
rm -rf constant/finite-area/faMesh
|
[ -n "$region" ] && echo "Clearing $meshDir" 1>&2
|
||||||
|
rm -rf -- "$meshDir"
|
||||||
fi
|
fi
|
||||||
if [ -e constant/faMesh ]
|
|
||||||
|
# Legacy location <constant/faMesh>
|
||||||
|
# - may still have remnant <constant/faMesh/faMeshDefinition>
|
||||||
|
|
||||||
|
meshDir="constant/faMesh"
|
||||||
|
if [ -e "$meshDir" ] && [ -z "$region" ]
|
||||||
then
|
then
|
||||||
if [ -e constant/faMesh/faMeshDefinition ]
|
if [ -e "$meshDir"/faMeshDefinition ]
|
||||||
then
|
then
|
||||||
# Old constant/faMesh location for faMeshDefinition still in use:
|
# VERY OLD LOCATION
|
||||||
# - warn but don't remove anything
|
|
||||||
echo
|
echo
|
||||||
echo "Warning: not removing constant/faMesh/"
|
echo "WARNING: not removing $meshDir/"
|
||||||
echo " It contains a 'faMeshDefinition' file"
|
echo " It contains a 'faMeshDefinition' file"
|
||||||
echo " Please relocate file(s) to system/ !!"
|
echo " Please relocate file(s) to system/finite-area/ !!"
|
||||||
echo
|
echo
|
||||||
else
|
else
|
||||||
# Can remove constant/faMesh/ entirely (no faMeshDefinition)
|
# Can remove constant/faMesh/ entirely (no faMeshDefinition)
|
||||||
rm -rf constant/faMesh
|
echo "Clearing $meshDir" 1>&2
|
||||||
|
rm -rf -- "$meshDir"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
# ---------------
|
||||||
|
# Remove constant/polyMesh or constant/<region>/polyMesh
|
||||||
|
#
|
||||||
|
# Accepts following options:
|
||||||
|
# -region <name> The region name
|
||||||
|
# -- End of options
|
||||||
|
# ---------------
|
||||||
cleanPolyMesh()
|
cleanPolyMesh()
|
||||||
{
|
{
|
||||||
if [ -e constant/polyMesh ]
|
local region
|
||||||
|
|
||||||
|
# Parse options
|
||||||
|
while [ "$#" -gt 0 ]
|
||||||
|
do
|
||||||
|
case "$1" in
|
||||||
|
('') ;; # Ignore empty option
|
||||||
|
(--) shift; break ;; # Stop option parsing
|
||||||
|
|
||||||
|
(-region) region="$2"; shift ;;
|
||||||
|
(*) break ;;
|
||||||
|
esac
|
||||||
|
shift
|
||||||
|
done
|
||||||
|
|
||||||
|
# safety
|
||||||
|
if [ "$region" = "--" ]; then unset region; fi
|
||||||
|
|
||||||
|
local meshDir="constant/${region}${region:+/}polyMesh"
|
||||||
|
|
||||||
|
if [ -e "$meshDir" ]
|
||||||
then
|
then
|
||||||
if [ -e constant/polyMesh/blockMeshDict ] \
|
[ -n "$region" ] && echo "Clearing $meshDir" 1>&2
|
||||||
|| [ -e constant/polyMesh/blockMeshDict.m4 ]
|
|
||||||
|
if [ -e "$meshDir"/blockMeshDict ] \
|
||||||
|
|| [ -e "$meshDir"/blockMeshDict.m4 ]
|
||||||
then
|
then
|
||||||
# Old constant/polyMesh location for blockMeshDict still in use:
|
# VERY OLD LOCATION
|
||||||
# - warn but don't remove anything
|
|
||||||
echo
|
echo
|
||||||
echo "Warning: not removing constant/polyMesh/"
|
echo "WARNING: not removing $meshDir/"
|
||||||
echo " It contains a 'blockMeshDict' or 'blockMeshDict.m4' file"
|
echo " It contains a 'blockMeshDict' or 'blockMeshDict.m4' file"
|
||||||
echo " Please relocate file(s) to system/ !!"
|
echo " Please relocate file(s) to system/ !!"
|
||||||
echo
|
echo
|
||||||
else
|
else
|
||||||
# Can remove constant/polyMesh/ entirely (no blockMeshDict)
|
# Can remove constant/polyMesh/ entirely (no blockMeshDict)
|
||||||
rm -rf constant/polyMesh
|
rm -rf -- "$meshDir"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -e system/blockMeshDict.m4 ]
|
meshDir="system${region:+/}${region}"
|
||||||
|
if [ -e "$meshDir"/blockMeshDict.m4 ]
|
||||||
then
|
then
|
||||||
rm -f system/blockMeshDict
|
rm -f -- "$meshDir"/blockMeshDict
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -212,7 +274,7 @@ cleanCase0()
|
|||||||
removeCase()
|
removeCase()
|
||||||
{
|
{
|
||||||
echo "Removing case ${1:-unknown}"
|
echo "Removing case ${1:-unknown}"
|
||||||
[ "$#" -ge 1 ] && rm -rf "$1"
|
[ "$#" -ge 1 ] && rm -rf -- "$1"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -517,9 +517,11 @@ cloneParallelCase()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
# ---------------
|
||||||
# If 0.orig/ exists, copy (overwrite) into 0/ [ie, serial case]
|
# If 0.orig/ exists, copy (overwrite) into 0/ [ie, serial case]
|
||||||
# * -processor : copy into processor directories instead
|
# * -processor : copy into processor directories instead
|
||||||
# * -all : copy into serial and processor directories
|
# * -all : copy into serial and processor directories
|
||||||
|
# ---------------
|
||||||
restore0Dir()
|
restore0Dir()
|
||||||
{
|
{
|
||||||
if [ ! -d 0.orig ]
|
if [ ! -d 0.orig ]
|
||||||
@ -553,4 +555,61 @@ restore0Dir()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
# ---------------
|
||||||
|
# Helper routine to remove specified fields from the 0/ directory.
|
||||||
|
# Often used in combination with foamListRegions.
|
||||||
|
#
|
||||||
|
# Accepts following options:
|
||||||
|
# -region <name> The region name
|
||||||
|
# -- End of options
|
||||||
|
#
|
||||||
|
# any remaining parameters are taken to be fields names
|
||||||
|
# ---------------
|
||||||
|
remove0DirFields()
|
||||||
|
{
|
||||||
|
local region
|
||||||
|
|
||||||
|
# Parse options
|
||||||
|
while [ "$#" -gt 0 ]
|
||||||
|
do
|
||||||
|
case "$1" in
|
||||||
|
('') ;; # Ignore empty option
|
||||||
|
(--) shift; break ;; # Stop option parsing
|
||||||
|
|
||||||
|
(-region) region="$2"; shift ;;
|
||||||
|
(*) break ;;
|
||||||
|
esac
|
||||||
|
shift
|
||||||
|
done
|
||||||
|
|
||||||
|
# safety
|
||||||
|
if [ "$region" = "--" ]; then unset region; fi
|
||||||
|
|
||||||
|
if [ "$#" -eq 0 ]
|
||||||
|
then
|
||||||
|
echo "No fields specified for ${region:+region=$region }" 1>&2
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Remove 0/ fields${region:+ [$region]} : $@" 1>&2
|
||||||
|
|
||||||
|
local subdir
|
||||||
|
for subdir in 0/"$region" processor*/0/"$region"
|
||||||
|
do
|
||||||
|
if [ -d "$subdir" ]
|
||||||
|
then
|
||||||
|
for field in $@ ## unquoted for IFS splitting [SIC]
|
||||||
|
do
|
||||||
|
# Cautious with removal
|
||||||
|
if [ -f "$subdir/$field" ]
|
||||||
|
then
|
||||||
|
rm -f -- "$subdir/$field"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------
|
||||||
|
|||||||
@ -140,6 +140,11 @@ _of_complete_()
|
|||||||
# Could use "foamListTimes -withZero", but still doesn't address ranges
|
# Could use "foamListTimes -withZero", but still doesn't address ranges
|
||||||
COMPREPLY=($(compgen -d -X '![-0-9]*' -- ${cur}))
|
COMPREPLY=($(compgen -d -X '![-0-9]*' -- ${cur}))
|
||||||
;;
|
;;
|
||||||
|
-area-region)
|
||||||
|
# Or: $(find system/finite-area -mindepth 1 -maxdepth 1 -type d 2>/dev/null | sed -e 's%.*/%%')
|
||||||
|
choices=$(\ls -d system/finite-area/*/ 2>/dev/null | sed -e 's%/$%%; s%^.*/%%')
|
||||||
|
COMPREPLY=($(compgen -W "$choices" -- ${cur}))
|
||||||
|
;;
|
||||||
-region)
|
-region)
|
||||||
# Or: $(find system -mindepth 1 -maxdepth 1 -type d 2>/dev/null | sed -e 's%.*/%%')
|
# Or: $(find system -mindepth 1 -maxdepth 1 -type d 2>/dev/null | sed -e 's%.*/%%')
|
||||||
choices=$(\ls -d system/*/ 2>/dev/null | sed -e 's%/$%%; s%^.*/%%')
|
choices=$(\ls -d system/*/ 2>/dev/null | sed -e 's%/$%%; s%^.*/%%')
|
||||||
|
|||||||
@ -55,8 +55,6 @@ wmake $targetType fileFormats
|
|||||||
wmake $targetType surfMesh
|
wmake $targetType surfMesh
|
||||||
wmake $targetType meshTools
|
wmake $targetType meshTools
|
||||||
|
|
||||||
#------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
wmake $targetType finiteArea
|
wmake $targetType finiteArea
|
||||||
wmake $targetType finiteVolume
|
wmake $targetType finiteVolume
|
||||||
wmake $targetType fused/finiteVolume
|
wmake $targetType fused/finiteVolume
|
||||||
|
|||||||
@ -45,6 +45,7 @@ SourceFiles
|
|||||||
|
|
||||||
#include "autoPtr.H"
|
#include "autoPtr.H"
|
||||||
#include "UList.H"
|
#include "UList.H"
|
||||||
|
#include "SLListFwd.H"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
@ -65,7 +66,6 @@ typedef List<bool> boolList; //!< A List of bools
|
|||||||
typedef List<char> charList; //!< A List of chars
|
typedef List<char> charList; //!< A List of chars
|
||||||
typedef List<label> labelList; //!< A List of labels
|
typedef List<label> labelList; //!< A List of labels
|
||||||
|
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------*\
|
/*---------------------------------------------------------------------------*\
|
||||||
Class List Declaration
|
Class List Declaration
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
@ -395,6 +395,37 @@ public:
|
|||||||
|
|
||||||
//- Alias for resize()
|
//- Alias for resize()
|
||||||
void setSize(label n, const T& val) { this->resize(n, val); }
|
void setSize(label n, const T& val) { this->resize(n, val); }
|
||||||
|
|
||||||
|
|
||||||
|
// Expression templates
|
||||||
|
|
||||||
|
//- Construct from value expression
|
||||||
|
template<typename E>
|
||||||
|
explicit List
|
||||||
|
(
|
||||||
|
const Expression::ListExpression
|
||||||
|
<
|
||||||
|
E,
|
||||||
|
typename E::value_type
|
||||||
|
>& expr
|
||||||
|
)
|
||||||
|
{
|
||||||
|
expr.evaluate(*this);
|
||||||
|
}
|
||||||
|
|
||||||
|
//- Assign values from expression
|
||||||
|
template<typename E>
|
||||||
|
void operator=
|
||||||
|
(
|
||||||
|
const Expression::ListExpression
|
||||||
|
<
|
||||||
|
E,
|
||||||
|
typename E::value_type
|
||||||
|
>& expr
|
||||||
|
)
|
||||||
|
{
|
||||||
|
expr.evaluate(*this);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -80,6 +80,11 @@ typedef UList<bool> boolUList; //!< A UList of bools
|
|||||||
typedef UList<char> charUList; //!< A UList of chars
|
typedef UList<char> charUList; //!< A UList of chars
|
||||||
typedef UList<label> labelUList; //!< A UList of labels
|
typedef UList<label> labelUList; //!< A UList of labels
|
||||||
|
|
||||||
|
namespace Expression
|
||||||
|
{
|
||||||
|
template<class E, typename ValType> class ListExpression;
|
||||||
|
template<class T> class ListConstRefWrap;
|
||||||
|
}
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------*\
|
/*---------------------------------------------------------------------------*\
|
||||||
Class UList Declaration
|
Class UList Declaration
|
||||||
@ -697,6 +702,39 @@ public:
|
|||||||
{
|
{
|
||||||
return this->contains(val, pos);
|
return this->contains(val, pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Expression templates
|
||||||
|
|
||||||
|
//- Have unique tag
|
||||||
|
using is_List = void;
|
||||||
|
|
||||||
|
//- Wrap value as expression
|
||||||
|
auto expr() const
|
||||||
|
{
|
||||||
|
return Expression::ListConstRefWrap<T>
|
||||||
|
(
|
||||||
|
reinterpret_cast<const List<T>&>(*this)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
//- Assign values from expression
|
||||||
|
template<typename E>
|
||||||
|
void operator=
|
||||||
|
(
|
||||||
|
const Expression::ListExpression
|
||||||
|
<
|
||||||
|
E,
|
||||||
|
typename E::value_type
|
||||||
|
>& expr
|
||||||
|
)
|
||||||
|
{
|
||||||
|
// bypass expr.evaluate to avoid resize ...
|
||||||
|
for (label i = 0; i < expr.size(); ++i)
|
||||||
|
{
|
||||||
|
operator[](i) = expr[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -341,22 +341,6 @@ inline Ostream& operator<<(Ostream& os, std::string_view s)
|
|||||||
return os;
|
return os;
|
||||||
}
|
}
|
||||||
|
|
||||||
//- Write operator for character span. Output like string data
|
|
||||||
inline Ostream& operator<<(Ostream& os, stdFoam::span<char> s)
|
|
||||||
{
|
|
||||||
os.writeQuoted(s.data(), s.size(), true); // quoted
|
|
||||||
os.check("Foam::operator<<(Ostream&, stdFoam::span<char>)");
|
|
||||||
return os;
|
|
||||||
}
|
|
||||||
|
|
||||||
//- Write operator for const character span. Output like string data
|
|
||||||
inline Ostream& operator<<(Ostream& os, stdFoam::span<const char> s)
|
|
||||||
{
|
|
||||||
os.writeQuoted(s.data(), s.size(), true); // quoted
|
|
||||||
os.check("Foam::operator<<(Ostream&, stdFoam::span<const char>)");
|
|
||||||
return os;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------*\
|
/*---------------------------------------------------------------------------*\
|
||||||
Manipulators (without arguments)
|
Manipulators (without arguments)
|
||||||
|
|||||||
@ -343,11 +343,22 @@ void Foam::UPstream::mpiGatherv
|
|||||||
}
|
}
|
||||||
// Nothing further to do
|
// Nothing further to do
|
||||||
}
|
}
|
||||||
else if constexpr (UPstream_basic_dataType<Type>::value)
|
else if constexpr (UPstream_dataType<Type>::value)
|
||||||
{
|
{
|
||||||
// Restrict to basic (or aliased) MPI types to avoid recalculating
|
// Restrict to basic (or aliased) MPI types to avoid recalculating
|
||||||
// the list of counts/offsets.
|
// the list of counts/offsets.
|
||||||
|
|
||||||
|
// The sizing factor (constexpr) must be 1 otherwise
|
||||||
|
// [recvCounts,recvOffsets] are likely incorrect
|
||||||
|
|
||||||
|
constexpr std::streamsize count = UPstream_dataType<Type>::size(1);
|
||||||
|
|
||||||
|
static_assert
|
||||||
|
(
|
||||||
|
(count == 1),
|
||||||
|
"Code does not (yet) work with aggregate types"
|
||||||
|
);
|
||||||
|
|
||||||
UPstream::mpi_gatherv
|
UPstream::mpi_gatherv
|
||||||
(
|
(
|
||||||
sendData,
|
sendData,
|
||||||
@ -356,7 +367,7 @@ void Foam::UPstream::mpiGatherv
|
|||||||
recvCounts,
|
recvCounts,
|
||||||
recvOffsets,
|
recvOffsets,
|
||||||
|
|
||||||
UPstream_basic_dataType<Type>::datatype_id,
|
UPstream_dataType<Type>::datatype_id,
|
||||||
communicator
|
communicator
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -364,7 +375,8 @@ void Foam::UPstream::mpiGatherv
|
|||||||
{
|
{
|
||||||
static_assert
|
static_assert
|
||||||
(
|
(
|
||||||
stdFoam::dependent_false_v<Type>, "Only basic MPI data types"
|
stdFoam::dependent_false_v<Type>,
|
||||||
|
"Only basic and user data types"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -392,11 +404,22 @@ void Foam::UPstream::mpiScatterv
|
|||||||
}
|
}
|
||||||
// Nothing further to do
|
// Nothing further to do
|
||||||
}
|
}
|
||||||
else if constexpr (UPstream_basic_dataType<Type>::value)
|
else if constexpr (UPstream_dataType<Type>::value)
|
||||||
{
|
{
|
||||||
// Restrict to basic (or aliased) MPI types to avoid recalculating
|
// Restrict to basic (or aliased) MPI types to avoid recalculating
|
||||||
// the list of counts/offsets.
|
// the list of counts/offsets.
|
||||||
|
|
||||||
|
// The sizing factor (constexpr) must be 1 otherwise
|
||||||
|
// [sendCounts,sendOffsets] are likely incorrect
|
||||||
|
|
||||||
|
constexpr std::streamsize count = UPstream_dataType<Type>::size(1);
|
||||||
|
|
||||||
|
static_assert
|
||||||
|
(
|
||||||
|
(count == 1),
|
||||||
|
"Code does not (yet) work with aggregate types"
|
||||||
|
);
|
||||||
|
|
||||||
UPstream::mpi_scatterv
|
UPstream::mpi_scatterv
|
||||||
(
|
(
|
||||||
sendData,
|
sendData,
|
||||||
@ -405,7 +428,7 @@ void Foam::UPstream::mpiScatterv
|
|||||||
recvData,
|
recvData,
|
||||||
recvCount,
|
recvCount,
|
||||||
|
|
||||||
UPstream_basic_dataType<Type>::datatype_id,
|
UPstream_dataType<Type>::datatype_id,
|
||||||
communicator
|
communicator
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -413,7 +436,8 @@ void Foam::UPstream::mpiScatterv
|
|||||||
{
|
{
|
||||||
static_assert
|
static_assert
|
||||||
(
|
(
|
||||||
stdFoam::dependent_false_v<Type>, "Only basic MPI data types"
|
stdFoam::dependent_false_v<Type>,
|
||||||
|
"Only basic and user data types"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -354,7 +354,7 @@ struct UPstream_basic_dataType
|
|||||||
UPstream_alias_dataType<base>::datatype_id;
|
UPstream_alias_dataType<base>::datatype_id;
|
||||||
|
|
||||||
//- The size in terms of the number of underlying data elements
|
//- The size in terms of the number of underlying data elements
|
||||||
static std::streamsize size(std::streamsize n) noexcept
|
static constexpr std::streamsize size(std::streamsize n) noexcept
|
||||||
{
|
{
|
||||||
if constexpr (UPstream_alias_dataType<T>::value)
|
if constexpr (UPstream_alias_dataType<T>::value)
|
||||||
{
|
{
|
||||||
@ -373,7 +373,10 @@ struct UPstream_basic_dataType
|
|||||||
template<> struct UPstream_basic_dataType<void> : UPstream_mpi_dataType<void>
|
template<> struct UPstream_basic_dataType<void> : UPstream_mpi_dataType<void>
|
||||||
{
|
{
|
||||||
using base = void;
|
using base = void;
|
||||||
static std::streamsize size(std::streamsize n) noexcept { return n; }
|
static constexpr std::streamsize size(std::streamsize n) noexcept
|
||||||
|
{
|
||||||
|
return n;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -410,7 +413,7 @@ struct UPstream_dataType
|
|||||||
UPstream_any_dataType<base>::datatype_id;
|
UPstream_any_dataType<base>::datatype_id;
|
||||||
|
|
||||||
//- The size in terms of the number of base data elements
|
//- The size in terms of the number of base data elements
|
||||||
static std::streamsize size(std::streamsize n) noexcept
|
static constexpr std::streamsize size(std::streamsize n) noexcept
|
||||||
{
|
{
|
||||||
if constexpr (UPstream_any_dataType<T>::value)
|
if constexpr (UPstream_any_dataType<T>::value)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -95,10 +95,12 @@ Foam::tokenList Foam::ITstream::parse_chars
|
|||||||
IOstreamOption streamOpt
|
IOstreamOption streamOpt
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
ISpanStream is(s, nbytes, streamOpt);
|
|
||||||
|
|
||||||
tokenList tokens;
|
tokenList tokens;
|
||||||
parseStream(is, tokens);
|
if (s && nbytes > 0) // extra safety
|
||||||
|
{
|
||||||
|
ISpanStream is(s, nbytes, streamOpt);
|
||||||
|
parseStream(is, tokens);
|
||||||
|
}
|
||||||
return tokens;
|
return tokens;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -107,10 +109,19 @@ Foam::tokenList Foam::ITstream::parse_chars
|
|||||||
|
|
||||||
void Foam::ITstream::reset(const char* input, size_t nbytes)
|
void Foam::ITstream::reset(const char* input, size_t nbytes)
|
||||||
{
|
{
|
||||||
ISpanStream is(input, nbytes, static_cast<IOstreamOption>(*this));
|
tokenList tokens;
|
||||||
|
if (input && nbytes > 0) // extra safety
|
||||||
|
{
|
||||||
|
ISpanStream is(input, nbytes, static_cast<IOstreamOption>(*this));
|
||||||
|
|
||||||
parseStream(is, static_cast<tokenList&>(*this));
|
parseStream(is, static_cast<tokenList&>(*this));
|
||||||
ITstream::seek(0); // rewind() bypassing virtual
|
ITstream::seek(0); // rewind() bypassing virtual
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ITstream::seek(0); // rewind() bypassing virtual
|
||||||
|
tokenList::clear();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -248,7 +259,10 @@ Foam::ITstream::ITstream
|
|||||||
:
|
:
|
||||||
ITstream(streamOpt, name)
|
ITstream(streamOpt, name)
|
||||||
{
|
{
|
||||||
reset(input, strlen(input));
|
if (input)
|
||||||
|
{
|
||||||
|
reset(input, strlen(input));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -77,7 +77,8 @@ class ITstream
|
|||||||
// but leave any excess capacity (ie, like reserve).
|
// but leave any excess capacity (ie, like reserve).
|
||||||
void reserveCapacity(const label newCapacity);
|
void reserveCapacity(const label newCapacity);
|
||||||
|
|
||||||
//- Convert input sequence into a list of tokens,
|
//- Convert input sequence into a list of tokens.
|
||||||
|
// Includes nullptr guard
|
||||||
static tokenList parse_chars
|
static tokenList parse_chars
|
||||||
(
|
(
|
||||||
const char* s,
|
const char* s,
|
||||||
@ -87,6 +88,7 @@ class ITstream
|
|||||||
|
|
||||||
//- Convert input sequence into a list of tokens,
|
//- Convert input sequence into a list of tokens,
|
||||||
//- using the existing stream format. Rewinds the stream
|
//- using the existing stream format. Rewinds the stream
|
||||||
|
// Includes nullptr guard
|
||||||
void reset(const char* input, size_t nbytes);
|
void reset(const char* input, size_t nbytes);
|
||||||
|
|
||||||
//- Failsafe read-access to token at specified location
|
//- Failsafe read-access to token at specified location
|
||||||
@ -175,32 +177,6 @@ public:
|
|||||||
reset(s.data(), s.size());
|
reset(s.data(), s.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
//- Construct token list by parsing the input character sequence
|
|
||||||
// Uses static parse function internally.
|
|
||||||
explicit ITstream
|
|
||||||
(
|
|
||||||
stdFoam::span<char> s,
|
|
||||||
IOstreamOption streamOpt = IOstreamOption()
|
|
||||||
)
|
|
||||||
:
|
|
||||||
ITstream(streamOpt)
|
|
||||||
{
|
|
||||||
reset(s.data(), s.size());
|
|
||||||
}
|
|
||||||
|
|
||||||
//- Construct token list by parsing the input character sequence
|
|
||||||
// Uses static parse function internally.
|
|
||||||
explicit ITstream
|
|
||||||
(
|
|
||||||
stdFoam::span<const char> s,
|
|
||||||
IOstreamOption streamOpt = IOstreamOption()
|
|
||||||
)
|
|
||||||
:
|
|
||||||
ITstream(streamOpt)
|
|
||||||
{
|
|
||||||
reset(s.data(), s.size());
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Additional constructors
|
// Additional constructors
|
||||||
|
|
||||||
@ -255,17 +231,6 @@ public:
|
|||||||
return parse_chars(input.cdata(), input.size(), streamOpt);
|
return parse_chars(input.cdata(), input.size(), streamOpt);
|
||||||
}
|
}
|
||||||
|
|
||||||
//- Create token list by parsing the input string
|
|
||||||
//- until no good tokens remain.
|
|
||||||
static tokenList parse
|
|
||||||
(
|
|
||||||
const std::string& input,
|
|
||||||
IOstreamOption streamOpt = IOstreamOption()
|
|
||||||
)
|
|
||||||
{
|
|
||||||
return parse_chars(input.data(), input.size(), streamOpt);
|
|
||||||
}
|
|
||||||
|
|
||||||
//- Create token list by parsing the input character sequence
|
//- Create token list by parsing the input character sequence
|
||||||
//- until no good tokens remain.
|
//- until no good tokens remain.
|
||||||
static tokenList parse
|
static tokenList parse
|
||||||
@ -274,7 +239,14 @@ public:
|
|||||||
IOstreamOption streamOpt = IOstreamOption()
|
IOstreamOption streamOpt = IOstreamOption()
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
return parse_chars(input, strlen(input), streamOpt);
|
if (input)
|
||||||
|
{
|
||||||
|
return parse_chars(input, strlen(input), streamOpt);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return tokenList();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//- Create token list by parsing the input character sequence
|
//- Create token list by parsing the input character sequence
|
||||||
@ -288,28 +260,6 @@ public:
|
|||||||
return parse_chars(s.data(), s.size(), streamOpt);
|
return parse_chars(s.data(), s.size(), streamOpt);
|
||||||
}
|
}
|
||||||
|
|
||||||
//- Create token list by parsing the input character sequence
|
|
||||||
//- until no good tokens remain.
|
|
||||||
static tokenList parse
|
|
||||||
(
|
|
||||||
stdFoam::span<char> s,
|
|
||||||
IOstreamOption streamOpt = IOstreamOption()
|
|
||||||
)
|
|
||||||
{
|
|
||||||
return parse_chars(s.data(), s.size(), streamOpt);
|
|
||||||
}
|
|
||||||
|
|
||||||
//- Create token list by parsing the input character sequence
|
|
||||||
//- until no good tokens remain.
|
|
||||||
static tokenList parse
|
|
||||||
(
|
|
||||||
stdFoam::span<const char> s,
|
|
||||||
IOstreamOption streamOpt = IOstreamOption()
|
|
||||||
)
|
|
||||||
{
|
|
||||||
return parse_chars(s.data(), s.size(), streamOpt);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Member Functions
|
// Member Functions
|
||||||
|
|
||||||
@ -387,7 +337,7 @@ public:
|
|||||||
label& tokenIndex() noexcept { return tokenIndex_; }
|
label& tokenIndex() noexcept { return tokenIndex_; }
|
||||||
|
|
||||||
//- Set the token index (no checks). \return the previous value
|
//- Set the token index (no checks). \return the previous value
|
||||||
label tokenIndex(const label num) noexcept
|
label tokenIndex(label num) noexcept
|
||||||
{
|
{
|
||||||
label old(tokenIndex_);
|
label old(tokenIndex_);
|
||||||
tokenIndex_ = num;
|
tokenIndex_ = num;
|
||||||
|
|||||||
@ -123,20 +123,6 @@ public:
|
|||||||
stream_type(static_cast<buffer_type*>(this))
|
stream_type(static_cast<buffer_type*>(this))
|
||||||
{}
|
{}
|
||||||
|
|
||||||
//- Construct (shallow copy) from span character content
|
|
||||||
explicit ispanstream(stdFoam::span<char> s)
|
|
||||||
:
|
|
||||||
buffer_type(const_cast<char*>(s.data()), s.size()),
|
|
||||||
stream_type(static_cast<buffer_type*>(this))
|
|
||||||
{}
|
|
||||||
|
|
||||||
//- Construct (shallow copy) from span character content
|
|
||||||
explicit ispanstream(stdFoam::span<const char> s)
|
|
||||||
:
|
|
||||||
buffer_type(const_cast<char*>(s.data()), s.size()),
|
|
||||||
stream_type(static_cast<buffer_type*>(this))
|
|
||||||
{}
|
|
||||||
|
|
||||||
|
|
||||||
// Member Functions
|
// Member Functions
|
||||||
|
|
||||||
@ -325,26 +311,6 @@ public:
|
|||||||
ISpanStream(buffer.cdata(), buffer.size(), streamOpt)
|
ISpanStream(buffer.cdata(), buffer.size(), streamOpt)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
//- Construct (shallow copy) from span character content
|
|
||||||
explicit ISpanStream
|
|
||||||
(
|
|
||||||
stdFoam::span<const char> s,
|
|
||||||
IOstreamOption streamOpt = IOstreamOption()
|
|
||||||
)
|
|
||||||
:
|
|
||||||
ISpanStream(s.data(), s.size(), streamOpt)
|
|
||||||
{}
|
|
||||||
|
|
||||||
//- Construct (shallow copy) from span character content
|
|
||||||
explicit ISpanStream
|
|
||||||
(
|
|
||||||
stdFoam::span<char> s,
|
|
||||||
IOstreamOption streamOpt = IOstreamOption()
|
|
||||||
)
|
|
||||||
:
|
|
||||||
ISpanStream(s.data(), s.size(), streamOpt)
|
|
||||||
{}
|
|
||||||
|
|
||||||
|
|
||||||
// Member Functions
|
// Member Functions
|
||||||
|
|
||||||
@ -402,20 +368,6 @@ public:
|
|||||||
syncState();
|
syncState();
|
||||||
}
|
}
|
||||||
|
|
||||||
//- Reset input area to use data from span character content
|
|
||||||
void reset(stdFoam::span<char> s)
|
|
||||||
{
|
|
||||||
stream_.reset(s.data(), s.size());
|
|
||||||
syncState();
|
|
||||||
}
|
|
||||||
|
|
||||||
//- Reset input area to use data from span character content
|
|
||||||
void reset(stdFoam::span<const char> s)
|
|
||||||
{
|
|
||||||
stream_.reset(s.data(), s.size());
|
|
||||||
syncState();
|
|
||||||
}
|
|
||||||
|
|
||||||
//- Rewind the stream, clearing any old errors
|
//- Rewind the stream, clearing any old errors
|
||||||
virtual void rewind() override
|
virtual void rewind() override
|
||||||
{
|
{
|
||||||
|
|||||||
@ -38,6 +38,7 @@ Description
|
|||||||
#include "DynamicList.H"
|
#include "DynamicList.H"
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
#include <string_view>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
|
|
||||||
|
|||||||
@ -113,6 +113,7 @@ SeeAlso
|
|||||||
#include "label.H"
|
#include "label.H"
|
||||||
#include "scalar.H"
|
#include "scalar.H"
|
||||||
#include "regExpFwd.H"
|
#include "regExpFwd.H"
|
||||||
|
#include "Switch.H"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
|||||||
@ -55,6 +55,8 @@ SourceFiles
|
|||||||
|
|
||||||
#include "label.H"
|
#include "label.H"
|
||||||
#include "word.H"
|
#include "word.H"
|
||||||
|
|
||||||
|
#include <string_view>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
|
|||||||
@ -60,6 +60,12 @@ template<class Type> class dimensioned;
|
|||||||
template<class Type>
|
template<class Type>
|
||||||
Istream& operator>>(Istream& is, dimensioned<Type>& dt);
|
Istream& operator>>(Istream& is, dimensioned<Type>& dt);
|
||||||
|
|
||||||
|
namespace Expression
|
||||||
|
{
|
||||||
|
template<class T> class UniformListWrap;
|
||||||
|
template<class GeoField> class UniformGeometricFieldWrap;
|
||||||
|
}
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------*\
|
/*---------------------------------------------------------------------------*\
|
||||||
Class dimensioned Declaration
|
Class dimensioned Declaration
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
@ -449,6 +455,28 @@ public:
|
|||||||
{
|
{
|
||||||
return getOrAddToDict(name, dict, deflt);
|
return getOrAddToDict(name, dict, deflt);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Expression templates
|
||||||
|
|
||||||
|
//- Wrap value as constant-value List expression
|
||||||
|
auto expr(const label size) const
|
||||||
|
{
|
||||||
|
return Expression::UniformListWrap<Type>(size, value_);
|
||||||
|
}
|
||||||
|
|
||||||
|
//- Wrap value as constant-value GeometricField expression. Supplied
|
||||||
|
// fields is used for sizing only and needs to be valid at time of
|
||||||
|
// evaluation.
|
||||||
|
template<class GeoField>
|
||||||
|
auto expr(const GeoField& fld) const
|
||||||
|
{
|
||||||
|
return Expression::UniformGeometricFieldWrap<GeoField>
|
||||||
|
(
|
||||||
|
fld,
|
||||||
|
*this
|
||||||
|
);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
252
src/OpenFOAM/expressionTemplates/GenericExpression.H
Normal file
252
src/OpenFOAM/expressionTemplates/GenericExpression.H
Normal file
@ -0,0 +1,252 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | www.openfoam.com
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
Copyright (C) 2025 M. Janssens
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
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/>.
|
||||||
|
|
||||||
|
Namespace
|
||||||
|
Foam::GenericExpression
|
||||||
|
|
||||||
|
Description
|
||||||
|
Expression templates.
|
||||||
|
|
||||||
|
SourceFiles
|
||||||
|
GenericExpression.H
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#ifndef Foam_GenericExpression_H
|
||||||
|
#define Foam_GenericExpression_H
|
||||||
|
|
||||||
|
#include <cassert>
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
namespace Expression
|
||||||
|
{
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
Class GenericExpression Declarations
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
template<typename E>
|
||||||
|
class GenericExpression
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
static constexpr bool is_leaf = false;
|
||||||
|
|
||||||
|
auto evaluate() const
|
||||||
|
{
|
||||||
|
// Delegation to the actual expression type. This avoids dynamic
|
||||||
|
// polymorphism (a.k.a. virtual functions in C++)
|
||||||
|
return static_cast<E const&>(*this).evaluate();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// Macros
|
||||||
|
// ~~~~~~
|
||||||
|
|
||||||
|
#define EXPRESSION_FUNCTION1(BaseClass, Func, BaseFunc, OpFunc) \
|
||||||
|
template<typename E1> \
|
||||||
|
class OpFunc \
|
||||||
|
: \
|
||||||
|
public BaseClass<OpFunc<E1>> \
|
||||||
|
{ \
|
||||||
|
typename std::conditional<E1::is_leaf, const E1&, const E1>::type u_; \
|
||||||
|
\
|
||||||
|
public: \
|
||||||
|
static constexpr bool is_leaf = false; \
|
||||||
|
\
|
||||||
|
OpFunc(const E1& u) \
|
||||||
|
: \
|
||||||
|
u_(u) \
|
||||||
|
{} \
|
||||||
|
\
|
||||||
|
auto evaluate() const \
|
||||||
|
{ \
|
||||||
|
return BaseFunc(u_.evaluate()); \
|
||||||
|
} \
|
||||||
|
}; \
|
||||||
|
template<typename E1> \
|
||||||
|
OpFunc<E1> Func \
|
||||||
|
( \
|
||||||
|
const BaseClass<E1>& u \
|
||||||
|
) \
|
||||||
|
{ \
|
||||||
|
return OpFunc<E1>(static_cast<const E1&>(u)); \
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#define EXPRESSION_FUNCTION2(BaseClass, Func, BaseFunc, OpFunc) \
|
||||||
|
template<typename E1, typename E2> \
|
||||||
|
class OpFunc \
|
||||||
|
: \
|
||||||
|
public BaseClass<OpFunc<E1, E2>> \
|
||||||
|
{ \
|
||||||
|
typename std::conditional<E1::is_leaf, const E1&, const E1>::type u_; \
|
||||||
|
typename std::conditional<E2::is_leaf, const E2&, const E2>::type v_; \
|
||||||
|
\
|
||||||
|
public: \
|
||||||
|
static constexpr bool is_leaf = false; \
|
||||||
|
\
|
||||||
|
OpFunc(const E1& u, const E2& v) \
|
||||||
|
: \
|
||||||
|
u_(u), v_(v) \
|
||||||
|
{} \
|
||||||
|
auto evaluate() const \
|
||||||
|
{ \
|
||||||
|
return BaseFunc(u_.evaluate(), v_.evaluate()); \
|
||||||
|
} \
|
||||||
|
}; \
|
||||||
|
template<typename E1, typename E2> \
|
||||||
|
OpFunc<E1, E2> Func \
|
||||||
|
( \
|
||||||
|
const BaseClass<E1>& u, \
|
||||||
|
const BaseClass<E2>& v \
|
||||||
|
) \
|
||||||
|
{ \
|
||||||
|
return OpFunc<E1, E2> \
|
||||||
|
( \
|
||||||
|
static_cast<const E1&>(u), \
|
||||||
|
static_cast<const E2&>(v) \
|
||||||
|
); \
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#define EXPRESSION_OPERATOR(BaseClass, Op, BaseOp, OpFunc) \
|
||||||
|
template<typename E1, typename E2> \
|
||||||
|
class OpFunc \
|
||||||
|
: \
|
||||||
|
public BaseClass \
|
||||||
|
< \
|
||||||
|
OpFunc<E1, E2> \
|
||||||
|
> \
|
||||||
|
{ \
|
||||||
|
/* cref if leaf, copy otherwise */ \
|
||||||
|
typename std::conditional<E1::is_leaf, const E1&, const E1>::type u_; \
|
||||||
|
typename std::conditional<E2::is_leaf, const E2&, const E2>::type v_; \
|
||||||
|
\
|
||||||
|
public: \
|
||||||
|
static constexpr bool is_leaf = false; \
|
||||||
|
\
|
||||||
|
OpFunc(const E1& u, const E2& v) \
|
||||||
|
: \
|
||||||
|
u_(u), v_(v) \
|
||||||
|
{} \
|
||||||
|
auto evaluate() const \
|
||||||
|
{ \
|
||||||
|
return u_.evaluate() BaseOp v_.evaluate(); \
|
||||||
|
} \
|
||||||
|
}; \
|
||||||
|
template<typename E1, typename E2> \
|
||||||
|
OpFunc<E1, E2> \
|
||||||
|
operator Op \
|
||||||
|
( \
|
||||||
|
BaseClass<E1> const& u, \
|
||||||
|
BaseClass<E2> const& v \
|
||||||
|
) \
|
||||||
|
{ \
|
||||||
|
return OpFunc<E1, E2> \
|
||||||
|
( \
|
||||||
|
static_cast<const E1&>(u), \
|
||||||
|
static_cast<const E2&>(v) \
|
||||||
|
); \
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Do '-' separately until we work out macro expansion...
|
||||||
|
template<typename E1>
|
||||||
|
class g_negate
|
||||||
|
:
|
||||||
|
public GenericExpression
|
||||||
|
<
|
||||||
|
g_negate<E1>
|
||||||
|
>
|
||||||
|
{
|
||||||
|
typename std::conditional<E1::is_leaf, const E1&, const E1>::type u_;
|
||||||
|
|
||||||
|
public:
|
||||||
|
static constexpr bool is_leaf = false;
|
||||||
|
|
||||||
|
g_negate(const E1& u)
|
||||||
|
:
|
||||||
|
u_(u)
|
||||||
|
{}
|
||||||
|
|
||||||
|
auto evaluate() const
|
||||||
|
{
|
||||||
|
return -u_.evaluate();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
template<typename E1>
|
||||||
|
g_negate<E1> operator-
|
||||||
|
(
|
||||||
|
const GenericExpression<E1>& u
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return g_negate<E1>(static_cast<const E1&>(u));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
EXPRESSION_FUNCTION1(GenericExpression, sqr, Foam::sqr, g_sqr)
|
||||||
|
EXPRESSION_FUNCTION1(GenericExpression, sqrt, Foam::sqrt, g_sqrt)
|
||||||
|
EXPRESSION_FUNCTION1(GenericExpression, magSqr, Foam::magSqr, g_magSqr)
|
||||||
|
EXPRESSION_FUNCTION1(GenericExpression, symm, Foam::symm, g_symm)
|
||||||
|
EXPRESSION_FUNCTION1(GenericExpression, pow2, Foam::pow2, g_pow2)
|
||||||
|
EXPRESSION_FUNCTION1(GenericExpression, pow3, Foam::pow3, g_pow3)
|
||||||
|
EXPRESSION_FUNCTION1(GenericExpression, pow4, Foam::pow4, g_pow4)
|
||||||
|
EXPRESSION_FUNCTION1(GenericExpression, operator~, Foam::operator~, g_compl)
|
||||||
|
|
||||||
|
//TBD. Parse problem
|
||||||
|
//EXPRESSION_FUNCTION1(GenericExpression, operator!, Foam::operator!, g_not)
|
||||||
|
|
||||||
|
#undef EXPRESSION_FUNCTION1
|
||||||
|
|
||||||
|
EXPRESSION_FUNCTION2(GenericExpression, operator+, Foam::operator+, g_add);
|
||||||
|
EXPRESSION_FUNCTION2(GenericExpression, operator-, Foam::operator-, g_subtract);
|
||||||
|
EXPRESSION_FUNCTION2(GenericExpression, operator*, Foam::operator*, g_multiply);
|
||||||
|
EXPRESSION_FUNCTION2(GenericExpression, operator/, Foam::operator/, g_divide);
|
||||||
|
|
||||||
|
#undef EXPRESSION_FUNCTION2
|
||||||
|
|
||||||
|
EXPRESSION_OPERATOR(GenericExpression, ||, ||, g_or)
|
||||||
|
EXPRESSION_OPERATOR(GenericExpression, &&, &&, g_and)
|
||||||
|
EXPRESSION_OPERATOR(GenericExpression, &, &, g_bitand)
|
||||||
|
EXPRESSION_OPERATOR(GenericExpression, |, |, g_bitor)
|
||||||
|
EXPRESSION_OPERATOR(GenericExpression, ^, ^, g_xor)
|
||||||
|
|
||||||
|
#undef EXPRESSION_OPERATOR
|
||||||
|
|
||||||
|
} // End namespace Expression
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
} // End namespace Foam
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
1879
src/OpenFOAM/expressionTemplates/GeometricFieldExpression.H
Normal file
1879
src/OpenFOAM/expressionTemplates/GeometricFieldExpression.H
Normal file
File diff suppressed because it is too large
Load Diff
2416
src/OpenFOAM/expressionTemplates/ListExpression.H
Normal file
2416
src/OpenFOAM/expressionTemplates/ListExpression.H
Normal file
File diff suppressed because it is too large
Load Diff
145
src/OpenFOAM/expressionTemplates/boolExpression.H
Normal file
145
src/OpenFOAM/expressionTemplates/boolExpression.H
Normal file
@ -0,0 +1,145 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | www.openfoam.com
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
Copyright (C) 2025 M. Janssens
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
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/>.
|
||||||
|
|
||||||
|
Namespace
|
||||||
|
Foam::boolExpression
|
||||||
|
|
||||||
|
Description
|
||||||
|
Expression templates for bool
|
||||||
|
|
||||||
|
SourceFiles
|
||||||
|
boolExpression.H
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#ifndef Foam_boolExpression_H
|
||||||
|
#define Foam_boolExpression_H
|
||||||
|
|
||||||
|
#include "GenericExpression.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
namespace Expression
|
||||||
|
{
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
Namespace Expression Declarations
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
// Wrap of non-const bool
|
||||||
|
// ~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
class boolWrap
|
||||||
|
:
|
||||||
|
public GenericExpression<boolWrap>
|
||||||
|
{
|
||||||
|
bool elems_;
|
||||||
|
|
||||||
|
public:
|
||||||
|
static constexpr bool is_leaf = false; //true;
|
||||||
|
|
||||||
|
//- Construct from components
|
||||||
|
boolWrap(const bool elems)
|
||||||
|
:
|
||||||
|
elems_(elems)
|
||||||
|
{}
|
||||||
|
|
||||||
|
// Construct from GenericExpression, forcing its evaluation.
|
||||||
|
template<typename E>
|
||||||
|
boolWrap
|
||||||
|
(
|
||||||
|
const GenericExpression<E>& expr
|
||||||
|
)
|
||||||
|
:
|
||||||
|
elems_(expr.evaluate())
|
||||||
|
{}
|
||||||
|
|
||||||
|
auto evaluate() const
|
||||||
|
{
|
||||||
|
return elems_;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename E>
|
||||||
|
auto evaluate
|
||||||
|
(
|
||||||
|
const GenericExpression<E>& expr
|
||||||
|
)
|
||||||
|
{
|
||||||
|
elems_ = expr.evaluate();
|
||||||
|
return elems_;
|
||||||
|
}
|
||||||
|
|
||||||
|
//- Assignment
|
||||||
|
template<typename E>
|
||||||
|
void operator=
|
||||||
|
(
|
||||||
|
const GenericExpression<E>& expr
|
||||||
|
)
|
||||||
|
{
|
||||||
|
elems_ = expr.evaluate();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// Wrap of const bool
|
||||||
|
// ~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
class boolConstWrap
|
||||||
|
:
|
||||||
|
public GenericExpression<boolConstWrap>
|
||||||
|
{
|
||||||
|
const bool elems_;
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
// ! Store as copy (since holds reference)
|
||||||
|
static constexpr bool is_leaf = false;
|
||||||
|
|
||||||
|
// construct from components
|
||||||
|
boolConstWrap(const bool elems)
|
||||||
|
:
|
||||||
|
elems_(elems)
|
||||||
|
{}
|
||||||
|
|
||||||
|
auto evaluate() const
|
||||||
|
{
|
||||||
|
return elems_;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
} // End namespace Expression
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
} // End namespace Foam
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
148
src/OpenFOAM/expressionTemplates/dimensionSetExpression.H
Normal file
148
src/OpenFOAM/expressionTemplates/dimensionSetExpression.H
Normal file
@ -0,0 +1,148 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | www.openfoam.com
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
Copyright (C) 2025 M. Janssens
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
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/>.
|
||||||
|
|
||||||
|
Namespace
|
||||||
|
Foam::dimensionSetExpression
|
||||||
|
|
||||||
|
Description
|
||||||
|
Expression templates for dimensionSet
|
||||||
|
|
||||||
|
SourceFiles
|
||||||
|
dimensionSetExpression.H
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#ifndef Foam_dimensionSetExpression_H
|
||||||
|
#define Foam_dimensionSetExpression_H
|
||||||
|
|
||||||
|
#include "GenericExpression.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
namespace Expression
|
||||||
|
{
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
Namespace Expression Declarations
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
// Wrap of non-const reference to dimensionSet
|
||||||
|
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
class dimensionSetRefWrap
|
||||||
|
:
|
||||||
|
public GenericExpression<dimensionSetRefWrap>
|
||||||
|
{
|
||||||
|
dimensionSet& elems_;
|
||||||
|
|
||||||
|
public:
|
||||||
|
static constexpr bool is_leaf = false; //true;
|
||||||
|
|
||||||
|
//- Construct from components
|
||||||
|
dimensionSetRefWrap(dimensionSet& elems)
|
||||||
|
:
|
||||||
|
elems_(elems)
|
||||||
|
{}
|
||||||
|
|
||||||
|
// Construct from GenericExpression, forcing its evaluation.
|
||||||
|
template<typename E>
|
||||||
|
dimensionSetRefWrap
|
||||||
|
(
|
||||||
|
dimensionSet& elems,
|
||||||
|
const GenericExpression<E>& expr
|
||||||
|
)
|
||||||
|
:
|
||||||
|
elems_(elems)
|
||||||
|
{
|
||||||
|
elems_ = expr.evaluate();
|
||||||
|
}
|
||||||
|
|
||||||
|
auto evaluate() const
|
||||||
|
{
|
||||||
|
return elems_;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename E>
|
||||||
|
auto& evaluate
|
||||||
|
(
|
||||||
|
const GenericExpression<E>& expr
|
||||||
|
)
|
||||||
|
{
|
||||||
|
elems_ = expr.evaluate();
|
||||||
|
return elems_;
|
||||||
|
}
|
||||||
|
|
||||||
|
//- Assignment
|
||||||
|
template<typename E>
|
||||||
|
void operator=
|
||||||
|
(
|
||||||
|
const GenericExpression<E>& expr
|
||||||
|
)
|
||||||
|
{
|
||||||
|
elems_ = expr.evaluate();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// Wrap of const reference to dimensionSet
|
||||||
|
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
class dimensionSetConstRefWrap
|
||||||
|
:
|
||||||
|
public GenericExpression<dimensionSetConstRefWrap>
|
||||||
|
{
|
||||||
|
const dimensionSet& elems_;
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
// ! Store as copy (since holds reference)
|
||||||
|
static constexpr bool is_leaf = false;
|
||||||
|
|
||||||
|
// construct from components
|
||||||
|
dimensionSetConstRefWrap(const dimensionSet& elems)
|
||||||
|
:
|
||||||
|
elems_(elems)
|
||||||
|
{}
|
||||||
|
|
||||||
|
auto evaluate() const
|
||||||
|
{
|
||||||
|
return elems_;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
} // End namespace Expression
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
} // End namespace Foam
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -582,6 +582,37 @@ public:
|
|||||||
|
|
||||||
friend Ostream& operator<< <Type>
|
friend Ostream& operator<< <Type>
|
||||||
(Ostream&, const tmp<Field<Type>>&);
|
(Ostream&, const tmp<Field<Type>>&);
|
||||||
|
|
||||||
|
|
||||||
|
// Expression templates
|
||||||
|
|
||||||
|
//- Construct from value expression
|
||||||
|
template<typename E>
|
||||||
|
explicit Field
|
||||||
|
(
|
||||||
|
const Expression::ListExpression
|
||||||
|
<
|
||||||
|
E,
|
||||||
|
typename E::value_type
|
||||||
|
>& expr
|
||||||
|
)
|
||||||
|
{
|
||||||
|
expr.evaluate(*this);
|
||||||
|
}
|
||||||
|
|
||||||
|
//- Assign values from expression
|
||||||
|
template<typename E>
|
||||||
|
void operator=
|
||||||
|
(
|
||||||
|
const Expression::ListExpression
|
||||||
|
<
|
||||||
|
E,
|
||||||
|
typename E::value_type
|
||||||
|
>& expr
|
||||||
|
)
|
||||||
|
{
|
||||||
|
expr.evaluate(*this);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -1675,6 +1675,124 @@ Foam::Ostream& Foam::operator<<
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * Expression Templates * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
template<class Type, template<class> class PatchField, class GeoMesh>
|
||||||
|
template<typename E>
|
||||||
|
Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricField
|
||||||
|
(
|
||||||
|
const IOobject& io,
|
||||||
|
const Mesh& mesh,
|
||||||
|
const Expression::GeometricFieldExpression
|
||||||
|
<
|
||||||
|
E,
|
||||||
|
typename E::IntExpr,
|
||||||
|
typename E::UncoupledPatchExpr,
|
||||||
|
typename E::CoupledPatchExpr,
|
||||||
|
typename E::value_type
|
||||||
|
>& expr
|
||||||
|
)
|
||||||
|
:
|
||||||
|
Internal(io, mesh, expr.dimensions(), false),
|
||||||
|
timeIndex_(this->time().timeIndex()),
|
||||||
|
boundaryField_(mesh.boundary(), *this, PatchField<Type>::calculatedType())
|
||||||
|
{
|
||||||
|
DebugInFunction
|
||||||
|
<< "Creating from expression " << nl << this->info() << endl;
|
||||||
|
|
||||||
|
bool hasRead = readIfPresent();
|
||||||
|
if (!hasRead)
|
||||||
|
{
|
||||||
|
expr.evaluate(*this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class Type, template<class> class PatchField, class GeoMesh>
|
||||||
|
template<typename E>
|
||||||
|
Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricField
|
||||||
|
(
|
||||||
|
const word& name,
|
||||||
|
const Mesh& mesh,
|
||||||
|
const Expression::GeometricFieldExpression
|
||||||
|
<
|
||||||
|
E,
|
||||||
|
typename E::IntExpr,
|
||||||
|
typename E::UncoupledPatchExpr,
|
||||||
|
typename E::CoupledPatchExpr,
|
||||||
|
typename E::value_type
|
||||||
|
>& expr
|
||||||
|
)
|
||||||
|
:
|
||||||
|
Internal
|
||||||
|
(
|
||||||
|
IOobject
|
||||||
|
(
|
||||||
|
name,
|
||||||
|
mesh.time().timeName(),
|
||||||
|
mesh.thisDb()
|
||||||
|
),
|
||||||
|
mesh,
|
||||||
|
expr.dimensions(),
|
||||||
|
false
|
||||||
|
),
|
||||||
|
timeIndex_(this->time().timeIndex()),
|
||||||
|
boundaryField_(mesh.boundary(), *this, PatchField<Type>::calculatedType())
|
||||||
|
{
|
||||||
|
DebugInFunction
|
||||||
|
<< "Creating from expression " << nl << this->info() << endl;
|
||||||
|
|
||||||
|
expr.evaluate(*this);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class Type, template<class> class PatchField, class GeoMesh>
|
||||||
|
Foam::Expression::GeometricFieldConstRefWrap
|
||||||
|
<
|
||||||
|
Foam::GeometricField<Type, PatchField, GeoMesh>
|
||||||
|
>
|
||||||
|
Foam::GeometricField<Type, PatchField, GeoMesh>::expr() const
|
||||||
|
{
|
||||||
|
return Expression::GeometricFieldConstRefWrap<this_type>(*this);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class Type, template<class> class PatchField, class GeoMesh>
|
||||||
|
template<typename E>
|
||||||
|
void Foam::GeometricField<Type, PatchField, GeoMesh>::operator=
|
||||||
|
(
|
||||||
|
const Expression::GeometricFieldExpression
|
||||||
|
<
|
||||||
|
E,
|
||||||
|
typename E::IntExpr,
|
||||||
|
typename E::UncoupledPatchExpr,
|
||||||
|
typename E::CoupledPatchExpr,
|
||||||
|
typename E::value_type
|
||||||
|
>& expr
|
||||||
|
)
|
||||||
|
{
|
||||||
|
Expression::GeometricFieldRefWrap<this_type>(*this, expr);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class Type, template<class> class PatchField, class GeoMesh>
|
||||||
|
template<typename E>
|
||||||
|
void Foam::GeometricField<Type, PatchField, GeoMesh>::operator==
|
||||||
|
(
|
||||||
|
const Expression::GeometricFieldExpression
|
||||||
|
<
|
||||||
|
E,
|
||||||
|
typename E::IntExpr,
|
||||||
|
typename E::UncoupledPatchExpr,
|
||||||
|
typename E::CoupledPatchExpr,
|
||||||
|
typename E::value_type
|
||||||
|
>& expr
|
||||||
|
)
|
||||||
|
{
|
||||||
|
expr.evaluate(*this, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
#undef checkField
|
#undef checkField
|
||||||
|
|||||||
@ -42,6 +42,7 @@ SourceFiles
|
|||||||
#define Foam_GeometricField_H
|
#define Foam_GeometricField_H
|
||||||
|
|
||||||
#include "GeometricBoundaryField.H"
|
#include "GeometricBoundaryField.H"
|
||||||
|
#include "GeometricFieldExpression.H"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
@ -1142,6 +1143,79 @@ public:
|
|||||||
{
|
{
|
||||||
return this->clamp_range(lo.value(), hi.value());
|
return this->clamp_range(lo.value(), hi.value());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Expression templates
|
||||||
|
|
||||||
|
//- Have unique tag
|
||||||
|
using is_GeometricField = void;
|
||||||
|
|
||||||
|
//- Construct from IOobject and value expression. Supports
|
||||||
|
// read_if_present
|
||||||
|
template<typename E>
|
||||||
|
GeometricField
|
||||||
|
(
|
||||||
|
const IOobject& io,
|
||||||
|
const Mesh& mesh,
|
||||||
|
const Expression::GeometricFieldExpression
|
||||||
|
<
|
||||||
|
E,
|
||||||
|
typename E::IntExpr,
|
||||||
|
typename E::UncoupledPatchExpr,
|
||||||
|
typename E::CoupledPatchExpr,
|
||||||
|
typename E::value_type
|
||||||
|
>& expr
|
||||||
|
);
|
||||||
|
|
||||||
|
//- Construct from name, mesh and value expression.
|
||||||
|
template<typename E>
|
||||||
|
GeometricField
|
||||||
|
(
|
||||||
|
const word& name,
|
||||||
|
const Mesh& mesh,
|
||||||
|
const Expression::GeometricFieldExpression
|
||||||
|
<
|
||||||
|
E,
|
||||||
|
typename E::IntExpr,
|
||||||
|
typename E::UncoupledPatchExpr,
|
||||||
|
typename E::CoupledPatchExpr,
|
||||||
|
typename E::value_type
|
||||||
|
>& expr
|
||||||
|
);
|
||||||
|
|
||||||
|
//- Wrap value as expression
|
||||||
|
typename Expression::GeometricFieldConstRefWrap
|
||||||
|
<
|
||||||
|
this_type
|
||||||
|
> expr() const;
|
||||||
|
|
||||||
|
//- Assign values from expression
|
||||||
|
template<typename E>
|
||||||
|
void operator=
|
||||||
|
(
|
||||||
|
const Expression::GeometricFieldExpression
|
||||||
|
<
|
||||||
|
E,
|
||||||
|
typename E::IntExpr,
|
||||||
|
typename E::UncoupledPatchExpr,
|
||||||
|
typename E::CoupledPatchExpr,
|
||||||
|
typename E::value_type
|
||||||
|
>& expr
|
||||||
|
);
|
||||||
|
|
||||||
|
//- Assign values from expression. Override asssignable.
|
||||||
|
template<typename E>
|
||||||
|
void operator==
|
||||||
|
(
|
||||||
|
const Expression::GeometricFieldExpression
|
||||||
|
<
|
||||||
|
E,
|
||||||
|
typename E::IntExpr,
|
||||||
|
typename E::UncoupledPatchExpr,
|
||||||
|
typename E::CoupledPatchExpr,
|
||||||
|
typename E::value_type
|
||||||
|
>& expr
|
||||||
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -40,6 +40,7 @@ SourceFiles
|
|||||||
|
|
||||||
#include "Dictionary.H"
|
#include "Dictionary.H"
|
||||||
#include "simpleRegIOobject.H"
|
#include "simpleRegIOobject.H"
|
||||||
|
#include <string_view>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|||||||
@ -333,7 +333,7 @@ Foam::fileMonitor& Foam::fileOperation::monitor() const
|
|||||||
|
|
||||||
void Foam::fileOperation::mergeTimes
|
void Foam::fileOperation::mergeTimes
|
||||||
(
|
(
|
||||||
const instantList& extraTimes,
|
const UList<instant>& extraTimes,
|
||||||
const word& constantName,
|
const word& constantName,
|
||||||
instantList& times
|
instantList& times
|
||||||
)
|
)
|
||||||
|
|||||||
@ -198,8 +198,10 @@ protected:
|
|||||||
//- Merge two times
|
//- Merge two times
|
||||||
static void mergeTimes
|
static void mergeTimes
|
||||||
(
|
(
|
||||||
const instantList& extraTimes,
|
const UList<instant>& extraTimes,
|
||||||
|
//! The "constant" name
|
||||||
const word& constantName,
|
const word& constantName,
|
||||||
|
//! [in,out] Updated with any extra times
|
||||||
instantList& times
|
instantList& times
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -870,7 +872,13 @@ public:
|
|||||||
) const;
|
) const;
|
||||||
|
|
||||||
//- Get sorted list of times
|
//- Get sorted list of times
|
||||||
virtual instantList findTimes(const fileName&, const word&) const;
|
virtual instantList findTimes
|
||||||
|
(
|
||||||
|
//! The directory to search
|
||||||
|
const fileName& directory,
|
||||||
|
//! The "constant" name
|
||||||
|
const word& constantName = "constant"
|
||||||
|
) const;
|
||||||
|
|
||||||
//- Find time instance where IOobject is located.
|
//- Find time instance where IOobject is located.
|
||||||
//- The name of the IOobject can be empty, in which case only the
|
//- The name of the IOobject can be empty, in which case only the
|
||||||
|
|||||||
@ -748,7 +748,13 @@ public:
|
|||||||
// Other
|
// Other
|
||||||
|
|
||||||
//- Get sorted list of times
|
//- Get sorted list of times
|
||||||
virtual instantList findTimes(const fileName&, const word&) const;
|
virtual instantList findTimes
|
||||||
|
(
|
||||||
|
//! The directory to search
|
||||||
|
const fileName& directory,
|
||||||
|
//! The "constant" name
|
||||||
|
const word& constantName = "constant"
|
||||||
|
) const;
|
||||||
|
|
||||||
//- Find time instance where IOobject is located.
|
//- Find time instance where IOobject is located.
|
||||||
//- The name of the IOobject can be empty, in which case only the
|
//- The name of the IOobject can be empty, in which case only the
|
||||||
|
|||||||
@ -11,7 +11,10 @@ License
|
|||||||
This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
|
This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
|
||||||
|
|
||||||
Description
|
Description
|
||||||
Add multi-region command-line options: -allRegions, -regions, -region
|
Add multi-region command-line options:
|
||||||
|
-allRegions | -all-regions
|
||||||
|
-regions
|
||||||
|
-region
|
||||||
|
|
||||||
Required Classes
|
Required Classes
|
||||||
- Foam::argList
|
- Foam::argList
|
||||||
@ -24,10 +27,10 @@ See Also
|
|||||||
{
|
{
|
||||||
Foam::argList::addBoolOption
|
Foam::argList::addBoolOption
|
||||||
(
|
(
|
||||||
"all-regions",
|
"allRegions",
|
||||||
"Use all regions in regionProperties"
|
"Use all regions in regionProperties"
|
||||||
);
|
);
|
||||||
Foam::argList::addOptionCompat("all-regions", { "allRegions", -2506 });
|
Foam::argList::addOptionCompat("allRegions", { "all-regions", 0 });
|
||||||
|
|
||||||
Foam::argList::addOption
|
Foam::argList::addOption
|
||||||
(
|
(
|
||||||
|
|||||||
@ -45,12 +45,19 @@ See Also
|
|||||||
|
|
||||||
wordList regionNames;
|
wordList regionNames;
|
||||||
{
|
{
|
||||||
// Local alias
|
|
||||||
auto& names = regionNames;
|
|
||||||
// Exit or fallback if nothing matches
|
// Exit or fallback if nothing matches
|
||||||
constexpr bool exitOnNoMatches = true;
|
constexpr bool exitOnNoMatches = true;
|
||||||
|
|
||||||
if (args.found("all-regions"))
|
// Local aliases
|
||||||
|
auto& names = regionNames;
|
||||||
|
const auto& fallback = Foam::polyMesh::defaultRegion;
|
||||||
|
|
||||||
|
if
|
||||||
|
(
|
||||||
|
// Handle both here (independent of which is an alias)
|
||||||
|
args.found("all-regions")
|
||||||
|
|| args.found("allRegions")
|
||||||
|
)
|
||||||
{
|
{
|
||||||
names =
|
names =
|
||||||
(
|
(
|
||||||
@ -81,11 +88,11 @@ wordList regionNames;
|
|||||||
{
|
{
|
||||||
select.uniq(); // Normally a no-op
|
select.uniq(); // Normally a no-op
|
||||||
|
|
||||||
if (select.size() == 1 && select.front().isLiteral())
|
if (select.size() == 1 && select[0].isLiteral())
|
||||||
{
|
{
|
||||||
// Identical to -region NAME
|
// Identical to -region NAME
|
||||||
names.resize(1);
|
names.resize(1);
|
||||||
names.front() = select.front();
|
names[0] = select[0];
|
||||||
}
|
}
|
||||||
else if (select.size())
|
else if (select.size())
|
||||||
{
|
{
|
||||||
@ -116,12 +123,12 @@ wordList regionNames;
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
InfoErr<< "... ignoring and using default region"
|
InfoErr
|
||||||
|
<< "... ignoring and using default region"
|
||||||
<< nl << endl;
|
<< nl << endl;
|
||||||
|
|
||||||
// Arbitrary fallback, but can handle this further on
|
|
||||||
names.resize(1);
|
names.resize(1);
|
||||||
names.front() = Foam::polyMesh::defaultRegion;
|
names[0] = fallback;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -160,7 +167,7 @@ wordList regionNames;
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
names.resize(1);
|
names.resize(1);
|
||||||
names.front() = Foam::polyMesh::defaultRegion;
|
names[0] = fallback;
|
||||||
|
|
||||||
InfoErr
|
InfoErr
|
||||||
<< "Warning: No regionProperties, "
|
<< "Warning: No regionProperties, "
|
||||||
@ -169,17 +176,30 @@ wordList regionNames;
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (args.found("region"))
|
else
|
||||||
{
|
{
|
||||||
|
// Single region option or fallback
|
||||||
names.resize(1);
|
names.resize(1);
|
||||||
names.front() = args.get<word>("region");
|
auto& name = names[0];
|
||||||
|
|
||||||
|
if
|
||||||
|
(
|
||||||
|
!args.readIfPresent("region", name)
|
||||||
|
)
|
||||||
|
{
|
||||||
|
name = fallback;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fallback to defaultRegion
|
// Final sanity checks and/or fallback
|
||||||
if (names.empty())
|
if (names.empty())
|
||||||
{
|
{
|
||||||
names.resize(1);
|
names.resize(1);
|
||||||
names.front() = Foam::polyMesh::defaultRegion;
|
names[0] = fallback;
|
||||||
|
}
|
||||||
|
else if (names.size() == 1 && names[0].empty())
|
||||||
|
{
|
||||||
|
names[0] = fallback;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -221,9 +221,14 @@ Foam::tmp<Foam::labelField> Foam::pairGAMGAgglomeration::agglomerate
|
|||||||
auto tcoarseCellMap = tmp<labelField>::New(nFineCells, -1);
|
auto tcoarseCellMap = tmp<labelField>::New(nFineCells, -1);
|
||||||
auto& coarseCellMap = tcoarseCellMap.ref();
|
auto& coarseCellMap = tcoarseCellMap.ref();
|
||||||
|
|
||||||
|
// Small tolerance to account for faces potentially having slightly
|
||||||
|
// different truncation error in their weights from run to run
|
||||||
|
// (e.g. due to offloading). If all the largest faces per cell are
|
||||||
|
// within this tolerance use the first one. This guarantees repeatability.
|
||||||
|
const scalar tol = 1E-10;
|
||||||
|
|
||||||
nCoarseCells = 0;
|
nCoarseCells = 0;
|
||||||
label celli;
|
label celli;
|
||||||
|
|
||||||
for (label cellfi=0; cellfi<nFineCells; cellfi++)
|
for (label cellfi=0; cellfi<nFineCells; cellfi++)
|
||||||
{
|
{
|
||||||
// Change cell ordering depending on direction for this level
|
// Change cell ordering depending on direction for this level
|
||||||
@ -250,7 +255,7 @@ Foam::tmp<Foam::labelField> Foam::pairGAMGAgglomeration::agglomerate
|
|||||||
(
|
(
|
||||||
coarseCellMap[upperAddr[facei]] < 0
|
coarseCellMap[upperAddr[facei]] < 0
|
||||||
&& coarseCellMap[lowerAddr[facei]] < 0
|
&& coarseCellMap[lowerAddr[facei]] < 0
|
||||||
&& faceWeights[facei] > maxFaceWeight
|
&& faceWeights[facei] > maxFaceWeight*(1.0 + tol)
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
// Match found. Pick up all the necessary data
|
// Match found. Pick up all the necessary data
|
||||||
@ -282,7 +287,7 @@ Foam::tmp<Foam::labelField> Foam::pairGAMGAgglomeration::agglomerate
|
|||||||
{
|
{
|
||||||
label facei = cellFaces[faceOs];
|
label facei = cellFaces[faceOs];
|
||||||
|
|
||||||
if (faceWeights[facei] > clusterMaxFaceCoeff)
|
if (faceWeights[facei] > clusterMaxFaceCoeff*(1.0 + tol))
|
||||||
{
|
{
|
||||||
clusterMatchFaceNo = facei;
|
clusterMatchFaceNo = facei;
|
||||||
clusterMaxFaceCoeff = faceWeights[facei];
|
clusterMaxFaceCoeff = faceWeights[facei];
|
||||||
|
|||||||
@ -59,8 +59,17 @@ See also
|
|||||||
namespace Foam
|
namespace Foam
|
||||||
{
|
{
|
||||||
|
|
||||||
|
namespace Expression
|
||||||
|
{
|
||||||
|
template<class GeoField> class GeometricFieldConstTmpWrap;
|
||||||
|
template<class T> class ListConstTmpWrap;
|
||||||
|
}
|
||||||
|
|
||||||
// Forward Declarations
|
// Forward Declarations
|
||||||
template<class T> class refPtr;
|
template<class T> class refPtr;
|
||||||
|
template<class T> class tmp;
|
||||||
|
template<class Type, template<class> class PatchField, class GeoMesh>
|
||||||
|
class GeometricField;
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------*\
|
/*---------------------------------------------------------------------------*\
|
||||||
Class tmp Declaration
|
Class tmp Declaration
|
||||||
@ -352,6 +361,33 @@ public:
|
|||||||
// \deprecated(2020-07) - use bool operator
|
// \deprecated(2020-07) - use bool operator
|
||||||
FOAM_DEPRECATED_FOR(2020-07, "bool operator")
|
FOAM_DEPRECATED_FOR(2020-07, "bool operator")
|
||||||
bool empty() const noexcept { return !ptr_; }
|
bool empty() const noexcept { return !ptr_; }
|
||||||
|
|
||||||
|
|
||||||
|
// Expression templates
|
||||||
|
|
||||||
|
//- Wrap value as expression
|
||||||
|
auto expr() const
|
||||||
|
{
|
||||||
|
// Add 'using is_GeometricField = void' to GeometricField
|
||||||
|
// Add 'using is_List = void' to List
|
||||||
|
|
||||||
|
if constexpr
|
||||||
|
(
|
||||||
|
std::is_void_v<typename T::is_GeometricField>
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return Expression::GeometricFieldConstTmpWrap<T>(*this);
|
||||||
|
}
|
||||||
|
else //if constexpr (std::is_void_v<T::is_List>)
|
||||||
|
{
|
||||||
|
return Expression::ListConstTmpWrap<T>(*this);
|
||||||
|
}
|
||||||
|
//else
|
||||||
|
//{
|
||||||
|
// //static_assert("XXX",YYY);
|
||||||
|
// return;
|
||||||
|
//}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -131,7 +131,7 @@ inline Foam::tmp<T>::tmp(const tmp<T>& rhs)
|
|||||||
if (ptr_)
|
if (ptr_)
|
||||||
{
|
{
|
||||||
ptr_->refCount::operator++();
|
ptr_->refCount::operator++();
|
||||||
this->checkUseCount();
|
//this->checkUseCount();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -162,7 +162,7 @@ inline Foam::tmp<T>::tmp(const tmp<T>& rhs, bool reuse)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
ptr_->refCount::operator++();
|
ptr_->refCount::operator++();
|
||||||
this->checkUseCount();
|
//this->checkUseCount();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
@ -27,6 +27,7 @@ License
|
|||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#include "globalIndex.H"
|
#include "globalIndex.H"
|
||||||
|
#include <functional>
|
||||||
|
|
||||||
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
|
||||||
|
|
||||||
@ -696,159 +697,94 @@ void Foam::globalIndex::mpiGather
|
|||||||
const UList<Type>& sendData,
|
const UList<Type>& sendData,
|
||||||
OutputContainer& allData,
|
OutputContainer& allData,
|
||||||
const label comm,
|
const label comm,
|
||||||
UPstream::commsTypes commsType,
|
[[maybe_unused]] UPstream::commsTypes commsType,
|
||||||
const int tag
|
[[maybe_unused]] const int tag
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
if (!UPstream::parRun())
|
if (!UPstream::is_parallel(comm))
|
||||||
{
|
{
|
||||||
// Serial: direct copy
|
// Serial: direct copy
|
||||||
allData = sendData;
|
allData = sendData;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// MPI_Gatherv requires contiguous data, but a byte-wise transfer can
|
if (UPstream::master(comm))
|
||||||
// quickly exceed the 'int' limits used for MPI sizes/offsets.
|
|
||||||
// Thus gather label/scalar components when possible to increase the
|
|
||||||
// effective size limit.
|
|
||||||
//
|
|
||||||
// Note: cannot rely on pTraits (cmptType, nComponents) since this method
|
|
||||||
// needs to compile (and work) even with things like strings etc.
|
|
||||||
|
|
||||||
// Single char ad hoc "enum":
|
|
||||||
// - b(yte): gather bytes
|
|
||||||
// - f(loat): gather scalars components
|
|
||||||
// - i(nt): gather label components
|
|
||||||
// - 0: gather with Pstream read/write etc.
|
|
||||||
|
|
||||||
List<int> recvCounts;
|
|
||||||
List<int> recvOffsets;
|
|
||||||
|
|
||||||
char dataMode(0);
|
|
||||||
int nCmpts(0);
|
|
||||||
|
|
||||||
if constexpr (is_contiguous_v<Type>)
|
|
||||||
{
|
{
|
||||||
if constexpr (is_contiguous_scalar<Type>::value)
|
allData.resize_nocopy(offsets_.back()); // == totalSize()
|
||||||
{
|
}
|
||||||
dataMode = 'f';
|
else
|
||||||
nCmpts = static_cast<int>(sizeof(Type)/sizeof(scalar));
|
{
|
||||||
}
|
allData.clear(); // zero-size on non-master
|
||||||
else if constexpr (is_contiguous_label<Type>::value)
|
}
|
||||||
{
|
|
||||||
dataMode = 'i';
|
if constexpr (UPstream_dataType<Type>::value)
|
||||||
nCmpts = static_cast<int>(sizeof(Type)/sizeof(label));
|
{
|
||||||
}
|
// Restrict to basic (or aliased) MPI types
|
||||||
else
|
// - simplifies calculating counts/offsets
|
||||||
{
|
// and can call UPstream::mpiGatherv directly
|
||||||
dataMode = 'b';
|
|
||||||
nCmpts = static_cast<int>(sizeof(Type));
|
// The sizing factor is constexpr
|
||||||
}
|
constexpr std::streamsize count = UPstream_dataType<Type>::size(1);
|
||||||
|
|
||||||
|
static_assert
|
||||||
|
(
|
||||||
|
(count == 1),
|
||||||
|
"Code does not (yet) work with aggregate types"
|
||||||
|
);
|
||||||
|
|
||||||
|
List<int> recvCounts;
|
||||||
|
List<int> recvOffsets;
|
||||||
|
|
||||||
// Offsets must fit into int
|
|
||||||
if (UPstream::master(comm))
|
if (UPstream::master(comm))
|
||||||
{
|
{
|
||||||
const globalIndex& globalAddr = *this;
|
// Must be same as Pstream::nProcs(comm), at least on master!
|
||||||
|
// if (UPstream::nProcs(comm) != this->nProcs()) ...
|
||||||
|
|
||||||
if (globalAddr.totalSize() > (INT_MAX/nCmpts))
|
recvCounts.resize(offsets_.size()-1);
|
||||||
{
|
recvOffsets.resize(offsets_.size());
|
||||||
// Offsets do not fit into int - revert to manual.
|
|
||||||
dataMode = 0;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// Must be same as Pstream::nProcs(comm), at least on master!
|
|
||||||
const label nproc = globalAddr.nProcs();
|
|
||||||
|
|
||||||
allData.resize_nocopy(globalAddr.totalSize());
|
// Copy offsets
|
||||||
|
std::copy(offsets_.begin(), offsets_.end(), recvOffsets.begin());
|
||||||
|
|
||||||
recvCounts.resize(nproc);
|
// Calculate sizes. Currently without std::minus <functional>
|
||||||
recvOffsets.resize(nproc+1);
|
std::transform
|
||||||
|
(
|
||||||
|
offsets_.begin()+1, offsets_.end(),
|
||||||
|
offsets_.begin(), recvCounts.begin(),
|
||||||
|
std::minus<>{}
|
||||||
|
);
|
||||||
|
|
||||||
for (label proci = 0; proci < nproc; ++proci)
|
// FUTURE .. fix sizes and offsets by the element factor...
|
||||||
{
|
// if constexpr (UPstream_basic_dataType<Type>::size(1) > 1)
|
||||||
recvCounts[proci] = globalAddr.localSize(proci)*nCmpts;
|
|
||||||
recvOffsets[proci] = globalAddr.localStart(proci)*nCmpts;
|
|
||||||
}
|
|
||||||
recvOffsets[nproc] = globalAddr.totalSize()*nCmpts;
|
|
||||||
|
|
||||||
// Assign local data directly
|
|
||||||
|
|
||||||
recvCounts[0] = 0; // ie, ignore for MPI_Gatherv
|
|
||||||
SubList<Type>(allData, globalAddr.range(0)) =
|
|
||||||
SubList<Type>(sendData, globalAddr.range(0));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Consistent information for everyone
|
int sendSize = static_cast<int>(sendData.size());
|
||||||
UPstream::broadcast(&dataMode, 1, comm);
|
|
||||||
|
// Note we let MPI_Gatherv copy back the local data as well...
|
||||||
|
|
||||||
|
UPstream::mpiGatherv
|
||||||
|
(
|
||||||
|
sendData.cdata(),
|
||||||
|
sendSize,
|
||||||
|
allData.data(),
|
||||||
|
recvCounts,
|
||||||
|
recvOffsets,
|
||||||
|
comm
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
// Dispatch
|
|
||||||
switch (dataMode)
|
|
||||||
{
|
{
|
||||||
case 'b': // Byte-wise
|
// Regular (manual) gathering
|
||||||
{
|
globalIndex::gather
|
||||||
UPstream::mpiGatherv
|
(
|
||||||
(
|
offsets_, // needed on master only
|
||||||
sendData.cdata_bytes(),
|
comm,
|
||||||
sendData.size_bytes(),
|
UPstream::allProcs(comm), // All communicator ranks
|
||||||
allData.data_bytes(),
|
sendData,
|
||||||
recvCounts,
|
allData,
|
||||||
recvOffsets,
|
tag,
|
||||||
comm
|
commsType
|
||||||
);
|
);
|
||||||
break;
|
|
||||||
}
|
|
||||||
case 'f': // Float (scalar) components
|
|
||||||
{
|
|
||||||
typedef scalar cmptType;
|
|
||||||
|
|
||||||
UPstream::mpiGatherv
|
|
||||||
(
|
|
||||||
reinterpret_cast<const cmptType*>(sendData.cdata()),
|
|
||||||
(sendData.size()*nCmpts),
|
|
||||||
reinterpret_cast<cmptType*>(allData.data()),
|
|
||||||
recvCounts,
|
|
||||||
recvOffsets,
|
|
||||||
comm
|
|
||||||
);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case 'i': // Int (label) components
|
|
||||||
{
|
|
||||||
typedef label cmptType;
|
|
||||||
|
|
||||||
UPstream::mpiGatherv
|
|
||||||
(
|
|
||||||
reinterpret_cast<const cmptType*>(sendData.cdata()),
|
|
||||||
(sendData.size()*nCmpts),
|
|
||||||
reinterpret_cast<cmptType*>(allData.data()),
|
|
||||||
recvCounts,
|
|
||||||
recvOffsets,
|
|
||||||
comm
|
|
||||||
);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
default: // Regular (manual) gathering
|
|
||||||
{
|
|
||||||
globalIndex::gather
|
|
||||||
(
|
|
||||||
offsets_, // needed on master only
|
|
||||||
comm,
|
|
||||||
UPstream::allProcs(comm), // All communicator ranks
|
|
||||||
sendData,
|
|
||||||
allData,
|
|
||||||
tag,
|
|
||||||
commsType
|
|
||||||
);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!UPstream::master(comm))
|
|
||||||
{
|
|
||||||
allData.clear(); // safety: zero-size on non-master
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -43,6 +43,9 @@ SourceFiles
|
|||||||
#include "bool.H"
|
#include "bool.H"
|
||||||
#include "stdFoam.H"
|
#include "stdFoam.H"
|
||||||
|
|
||||||
|
#include <string_view>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
// Avoid any pre-processor conflicts with enum names
|
// Avoid any pre-processor conflicts with enum names
|
||||||
#undef FALSE
|
#undef FALSE
|
||||||
#undef TRUE
|
#undef TRUE
|
||||||
|
|||||||
@ -58,6 +58,9 @@ Description
|
|||||||
|
|
||||||
#include <algorithm> // std::copy
|
#include <algorithm> // std::copy
|
||||||
#include <utility> // std::initializer_list
|
#include <utility> // std::initializer_list
|
||||||
|
#include <vector>
|
||||||
|
#include <string_view>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
@ -93,6 +96,11 @@ class CStringList
|
|||||||
// \return location one-past end of dest (ie, the next destination)
|
// \return location one-past end of dest (ie, the next destination)
|
||||||
static inline char* stringCopy(char* dest, const char* src);
|
static inline char* stringCopy(char* dest, const char* src);
|
||||||
|
|
||||||
|
//- Copy string characters into dest as NUL-terminated string.
|
||||||
|
//
|
||||||
|
// \return location one-past end of dest (ie, the next destination)
|
||||||
|
static inline char* stringCopy(char *dest, std::string_view src);
|
||||||
|
|
||||||
//- Copy string characters into dest as NUL-terminated string.
|
//- Copy string characters into dest as NUL-terminated string.
|
||||||
// Forces conversion of std::sub_match to string form
|
// Forces conversion of std::sub_match to string form
|
||||||
//
|
//
|
||||||
@ -133,9 +141,17 @@ public:
|
|||||||
template<class StringType>
|
template<class StringType>
|
||||||
inline explicit CStringList(const UList<StringType>& input);
|
inline explicit CStringList(const UList<StringType>& input);
|
||||||
|
|
||||||
|
//- Copy construct from a list of string_views
|
||||||
|
// Copies the input characters.
|
||||||
|
inline explicit CStringList(const UList<std::string_view>& input);
|
||||||
|
|
||||||
|
//- Copy construct from a list of string_views
|
||||||
|
// Copies the input characters.
|
||||||
|
inline explicit CStringList(const std::vector<std::string_view>& input);
|
||||||
|
|
||||||
//- Copy construct from a list of sub-string references
|
//- Copy construct from a list of sub-string references
|
||||||
// Copies the input characters.
|
// Copies the input characters.
|
||||||
explicit CStringList(const SubStrings& input);
|
inline explicit CStringList(const SubStrings& input);
|
||||||
|
|
||||||
|
|
||||||
//- Destructor. Invokes clear() to free memory.
|
//- Destructor. Invokes clear() to free memory.
|
||||||
@ -157,6 +173,9 @@ public:
|
|||||||
//- Return the number of C-strings (ie, argc)
|
//- Return the number of C-strings (ie, argc)
|
||||||
int size() const noexcept { return argc_; }
|
int size() const noexcept { return argc_; }
|
||||||
|
|
||||||
|
//- The flattened character content, with interspersed nul-chars
|
||||||
|
inline std::string_view view() const;
|
||||||
|
|
||||||
//- The flattened character content, with interspersed nul-chars
|
//- The flattened character content, with interspersed nul-chars
|
||||||
const char* cdata_bytes() const noexcept { return data_; }
|
const char* cdata_bytes() const noexcept { return data_; }
|
||||||
|
|
||||||
|
|||||||
@ -28,16 +28,6 @@ License
|
|||||||
#include "CStringList.H"
|
#include "CStringList.H"
|
||||||
#include "Ostream.H"
|
#include "Ostream.H"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
Foam::CStringList::CStringList(const SubStrings& input)
|
|
||||||
:
|
|
||||||
CStringList()
|
|
||||||
{
|
|
||||||
resetContent(input);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
// Largely identical to resetContent() except with 'c-string'
|
// Largely identical to resetContent() except with 'c-string'
|
||||||
|
|||||||
@ -5,7 +5,7 @@
|
|||||||
\\ / A nd | www.openfoam.com
|
\\ / A nd | www.openfoam.com
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2016-2024 OpenCFD Ltd.
|
Copyright (C) 2016-2025 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -35,6 +35,14 @@ inline char* Foam::CStringList::stringCopy(char* dest, const char* src)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline char* Foam::CStringList::stringCopy(char *dest, std::string_view src)
|
||||||
|
{
|
||||||
|
dest = std::copy_n(src.data(), src.size(), dest);
|
||||||
|
*(dest++) = '\0';
|
||||||
|
return dest;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
inline char* Foam::CStringList::stringCopy(char *dest, const std::string& src)
|
inline char* Foam::CStringList::stringCopy(char *dest, const std::string& src)
|
||||||
{
|
{
|
||||||
dest = std::copy_n(src.data(), src.size(), dest);
|
dest = std::copy_n(src.data(), src.size(), dest);
|
||||||
@ -90,6 +98,33 @@ inline Foam::CStringList::CStringList(const UList<StringType>& input)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline Foam::CStringList::CStringList(const UList<std::string_view>& input)
|
||||||
|
:
|
||||||
|
CStringList()
|
||||||
|
{
|
||||||
|
resetContent(input);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline Foam::CStringList::CStringList
|
||||||
|
(
|
||||||
|
const std::vector<std::string_view>& input
|
||||||
|
)
|
||||||
|
:
|
||||||
|
CStringList()
|
||||||
|
{
|
||||||
|
resetContent(input);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline Foam::CStringList::CStringList(const SubStrings& input)
|
||||||
|
:
|
||||||
|
CStringList()
|
||||||
|
{
|
||||||
|
resetContent(input);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
inline Foam::CStringList::~CStringList()
|
inline Foam::CStringList::~CStringList()
|
||||||
@ -100,6 +135,12 @@ inline Foam::CStringList::~CStringList()
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
inline std::string_view Foam::CStringList::view() const
|
||||||
|
{
|
||||||
|
return std::string_view(data_, nbytes_);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
inline void Foam::CStringList::clear()
|
inline void Foam::CStringList::clear()
|
||||||
{
|
{
|
||||||
argc_ = 0;
|
argc_ = 0;
|
||||||
|
|||||||
@ -37,6 +37,7 @@ Description
|
|||||||
|
|
||||||
#include <regex> // For std::ssub_match
|
#include <regex> // For std::ssub_match
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
#include <string_view>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
|||||||
@ -69,6 +69,7 @@ SourceFiles
|
|||||||
#define Foam_regExpCxx_H
|
#define Foam_regExpCxx_H
|
||||||
|
|
||||||
#include <regex>
|
#include <regex>
|
||||||
|
#include <string_view>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|||||||
@ -54,6 +54,7 @@ SourceFiles
|
|||||||
#include "Hasher.H"
|
#include "Hasher.H"
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
#include <string_view>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|||||||
@ -5,7 +5,7 @@
|
|||||||
\\ / A nd | www.openfoam.com
|
\\ / A nd | www.openfoam.com
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2017 OpenCFD Ltd.
|
Copyright (C) 2017-2025 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -46,85 +46,106 @@ namespace Foam
|
|||||||
namespace stringOps
|
namespace stringOps
|
||||||
{
|
{
|
||||||
|
|
||||||
//- 'Natural' compare for C-strings
|
//- 'Natural' compare for C-strings
|
||||||
// Uses algorithm and code from Jan-Marten Spit <jmspit@euronet.nl>
|
// Uses algorithm and code from Jan-Marten Spit <jmspit@euronet.nl>
|
||||||
//
|
//
|
||||||
// In the 'natural' comparison, strings are compared alphabetically
|
// In the 'natural' comparison, strings are compared alphabetically
|
||||||
// and numerically. Thus 'file010.txt' sorts after 'file2.txt'
|
// and numerically. Thus 'file010.txt' sorts after 'file2.txt'
|
||||||
//
|
//
|
||||||
// \param s1 left string
|
// \param s1 left string
|
||||||
// \param s2 right string
|
// \param s2 right string
|
||||||
|
// \return -1 when s1 < s2, 0 when s1 == s2, 1 when s1 > s2
|
||||||
|
int natstrcmp(const char* s1, const char* s2);
|
||||||
|
|
||||||
|
|
||||||
|
//- Encapsulation of natural order sorting for algorithms
|
||||||
|
struct natural_sort
|
||||||
|
{
|
||||||
|
//- Natural compare for std::string
|
||||||
// \return -1 when s1 < s2, 0 when s1 == s2, 1 when s1 > s2
|
// \return -1 when s1 < s2, 0 when s1 == s2, 1 when s1 > s2
|
||||||
int natstrcmp(const char* s1, const char* s2);
|
static inline int compare
|
||||||
|
(
|
||||||
|
const std::string& s1,
|
||||||
//- Encapsulation of natural order sorting for algorithms
|
const std::string& s2
|
||||||
struct natural_sort
|
)
|
||||||
{
|
{
|
||||||
//- Natural compare for std::string
|
return stringOps::natstrcmp(s1.data(), s2.data());
|
||||||
// \return -1 when s1 < s2, 0 when s1 == s2, 1 when s1 > s2
|
}
|
||||||
static inline int compare
|
|
||||||
(
|
|
||||||
const std::string& s1,
|
|
||||||
const std::string& s2
|
|
||||||
)
|
|
||||||
{
|
|
||||||
return natstrcmp(s1.data(), s2.data());
|
|
||||||
}
|
|
||||||
|
|
||||||
//- Default (forward) natural sorting
|
//- Natural compare two strings for a less-than relationship
|
||||||
|
static inline bool less
|
||||||
|
(
|
||||||
|
const std::string& s1,
|
||||||
|
const std::string& s2
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return (natural_sort::compare(s1, s2) < 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
//- Natural compare two strings for a greater-than relationship
|
||||||
|
static inline bool greater
|
||||||
|
(
|
||||||
|
const std::string& s1,
|
||||||
|
const std::string& s2
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return (natural_sort::compare(s1, s2) > 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
//- Default (forward) natural sorting
|
||||||
|
bool operator()(const std::string& s1, const std::string& s2) const
|
||||||
|
{
|
||||||
|
return (natural_sort::compare(s1, s2) < 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
//- Reverse natural sorting
|
||||||
|
struct reverse
|
||||||
|
{
|
||||||
|
//- Reverse natural sorting
|
||||||
bool operator()(const std::string& s1, const std::string& s2) const
|
bool operator()(const std::string& s1, const std::string& s2) const
|
||||||
{
|
{
|
||||||
return natural_sort::compare(s1, s2) < 0;
|
return (natural_sort::compare(s1, s2) > 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
//- Reverse natural sorting
|
|
||||||
struct reverse
|
|
||||||
{
|
|
||||||
//- Reverse natural sorting
|
|
||||||
bool operator()(const std::string& s1, const std::string& s2) const
|
|
||||||
{
|
|
||||||
return natural_sort::compare(s1, s2) > 0;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
//- A list compare binary predicate for natural sort
|
|
||||||
template<class T>
|
|
||||||
struct less
|
|
||||||
{
|
|
||||||
const UList<T>& values;
|
|
||||||
|
|
||||||
less(const UList<T>& list)
|
|
||||||
:
|
|
||||||
values(list)
|
|
||||||
{}
|
|
||||||
|
|
||||||
bool operator()(const label a, const label b) const
|
|
||||||
{
|
|
||||||
return natural_sort::compare(values[a], values[b]) < 0;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
//- A list compare binary predicate for reverse natural sort
|
|
||||||
template<class T>
|
|
||||||
struct greater
|
|
||||||
{
|
|
||||||
const UList<T>& values;
|
|
||||||
|
|
||||||
greater(const UList<T>& list)
|
|
||||||
:
|
|
||||||
values(list)
|
|
||||||
{}
|
|
||||||
|
|
||||||
bool operator()(const label a, const label b) const
|
|
||||||
{
|
|
||||||
return natural_sort::compare(values[a], values[b]) > 0;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
//- A UList compare binary predicate for natural sort
|
||||||
|
template<class T>
|
||||||
|
struct list_less
|
||||||
|
{
|
||||||
|
const UList<T>& values;
|
||||||
|
|
||||||
|
list_less(const UList<T>& list) noexcept
|
||||||
|
:
|
||||||
|
values(list)
|
||||||
|
{}
|
||||||
|
|
||||||
|
bool operator()(label a, label b) const
|
||||||
|
{
|
||||||
|
return (natural_sort::compare(values[a], values[b]) < 0);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
//- A Ulist compare binary predicate for reverse natural sort
|
||||||
|
template<class T>
|
||||||
|
struct list_greater
|
||||||
|
{
|
||||||
|
const UList<T>& values;
|
||||||
|
|
||||||
|
list_greater(const UList<T>& list) noexcept
|
||||||
|
:
|
||||||
|
values(list)
|
||||||
|
{}
|
||||||
|
|
||||||
|
bool operator()(label a, label b) const
|
||||||
|
{
|
||||||
|
return (natural_sort::compare(values[a], values[b]) > 0);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
} // End namespace stringOps
|
} // End namespace stringOps
|
||||||
} // End namespace Foam
|
} // End namespace Foam
|
||||||
|
|
||||||
|
|||||||
@ -28,33 +28,45 @@ License
|
|||||||
#include "Pstream.H"
|
#include "Pstream.H"
|
||||||
#include "PstreamGlobals.H"
|
#include "PstreamGlobals.H"
|
||||||
#include "UPstreamWrapping.H"
|
#include "UPstreamWrapping.H"
|
||||||
|
#include "vector.H" // for debugging
|
||||||
|
|
||||||
|
#undef STRINGIFY
|
||||||
|
#undef STRING_QUOTE
|
||||||
|
|
||||||
|
#define STRINGIFY(content) #content
|
||||||
|
#define STRING_QUOTE(input) STRINGIFY(input)
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * Local Functions * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Local Functions * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
static inline bool is_basic_dataType(Foam::UPstream::dataTypes id) noexcept
|
namespace
|
||||||
|
{
|
||||||
|
|
||||||
|
inline bool is_nonAggregate(Foam::UPstream::dataTypes id) noexcept
|
||||||
{
|
{
|
||||||
return
|
return
|
||||||
(
|
(
|
||||||
int(id) >= int(Foam::UPstream::dataTypes::Basic_begin)
|
int(id) >= int(Foam::UPstream::dataTypes::Basic_begin)
|
||||||
&& int(id) < int(Foam::UPstream::dataTypes::Basic_end)
|
&& int(id) < int(Foam::UPstream::dataTypes::Basic_end)
|
||||||
|
)
|
||||||
|
||
|
||||||
|
(
|
||||||
|
int(id) >= int(Foam::UPstream::dataTypes::User_begin)
|
||||||
|
&& int(id) < int(Foam::UPstream::dataTypes::User_end)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace
|
|
||||||
{
|
|
||||||
|
|
||||||
using namespace Foam;
|
|
||||||
|
|
||||||
// Local function to print some error information
|
// Local function to print some error information
|
||||||
inline void printErrorNonIntrinsic
|
inline void printErrorNonIntrinsic
|
||||||
(
|
(
|
||||||
const char* context,
|
const char* context,
|
||||||
UPstream::dataTypes dataTypeId
|
Foam::UPstream::dataTypes dataTypeId
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
using namespace Foam;
|
||||||
|
|
||||||
FatalError
|
FatalError
|
||||||
<< "Bad input for " << context << ": likely a programming problem\n"
|
<< "Bad input for " << context << ": likely a programming problem\n"
|
||||||
<< " Non-intrinsic data (" << int(dataTypeId) << ")\n"
|
<< " Non-intrinsic/non-user data (type:" << int(dataTypeId) << ")\n"
|
||||||
<< Foam::endl;
|
<< Foam::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -214,19 +226,37 @@ void Foam::UPstream::mpi_gatherv
|
|||||||
{
|
{
|
||||||
MPI_Datatype datatype = PstreamGlobals::getDataType(dataTypeId);
|
MPI_Datatype datatype = PstreamGlobals::getDataType(dataTypeId);
|
||||||
|
|
||||||
if
|
// Runtime assert that we are not using aggregated data types
|
||||||
(
|
if (FOAM_UNLIKELY(!is_nonAggregate(dataTypeId)))
|
||||||
FOAM_UNLIKELY
|
|
||||||
(
|
|
||||||
!is_basic_dataType(dataTypeId)
|
|
||||||
)
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
FatalErrorInFunction;
|
FatalErrorInFunction;
|
||||||
printErrorNonIntrinsic("MPI_Gatherv()", dataTypeId);
|
printErrorNonIntrinsic("MPI_Gatherv()", dataTypeId);
|
||||||
FatalError << Foam::abort(FatalError);
|
FatalError << Foam::abort(FatalError);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const label np = UPstream::nProcs(communicator);
|
||||||
|
|
||||||
|
// For total-size calculation,
|
||||||
|
// don't rely on recvOffsets being (np+1)
|
||||||
|
const int totalSize =
|
||||||
|
(
|
||||||
|
(UPstream::master(communicator) && np > 1)
|
||||||
|
? (recvOffsets[np-1] + recvCounts[np-1])
|
||||||
|
: 0
|
||||||
|
);
|
||||||
|
|
||||||
|
if (FOAM_UNLIKELY(UPstream::debug))
|
||||||
|
{
|
||||||
|
Perr<< "[mpi_gatherv] :"
|
||||||
|
<< " type:" << int(dataTypeId)
|
||||||
|
<< " count:" << sendCount
|
||||||
|
<< " total:" << totalSize
|
||||||
|
<< " comm:" << communicator
|
||||||
|
<< " recvCounts:" << flatOutput(recvCounts)
|
||||||
|
<< " recvOffsets:" << flatOutput(recvOffsets)
|
||||||
|
<< Foam::endl;
|
||||||
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
PstreamDetail::gatherv
|
PstreamDetail::gatherv
|
||||||
(
|
(
|
||||||
@ -235,6 +265,48 @@ void Foam::UPstream::mpi_gatherv
|
|||||||
datatype, communicator
|
datatype, communicator
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Extended debugging. Limit to master:
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
if (FOAM_UNLIKELY(UPstream::debug))
|
||||||
|
{
|
||||||
|
if (UPstream::master(communicator))
|
||||||
|
{
|
||||||
|
switch (dataTypeId)
|
||||||
|
{
|
||||||
|
#undef dataPrinter
|
||||||
|
#define dataPrinter(enumType, nativeType) \
|
||||||
|
case UPstream::dataTypes::enumType : \
|
||||||
|
{ \
|
||||||
|
UList<nativeType> combined \
|
||||||
|
( \
|
||||||
|
static_cast<nativeType*>(recvData), \
|
||||||
|
totalSize \
|
||||||
|
); \
|
||||||
|
\
|
||||||
|
Info<< "[mpi_gatherv] => " \
|
||||||
|
"List<" STRING_QUOTE(nativeType) "> "; \
|
||||||
|
combined.writeList(Info) << Foam::endl; \
|
||||||
|
\
|
||||||
|
break; \
|
||||||
|
}
|
||||||
|
|
||||||
|
// Some common types
|
||||||
|
dataPrinter(type_int32, int32_t);
|
||||||
|
dataPrinter(type_int64, int64_t);
|
||||||
|
dataPrinter(type_float, float);
|
||||||
|
dataPrinter(type_double, double);
|
||||||
|
dataPrinter(type_3float, floatVector);
|
||||||
|
dataPrinter(type_3double, doubleVector);
|
||||||
|
|
||||||
|
// Some other type
|
||||||
|
default: break;
|
||||||
|
#undef dataPrinter
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -255,13 +327,8 @@ void Foam::UPstream::mpi_scatterv
|
|||||||
{
|
{
|
||||||
MPI_Datatype datatype = PstreamGlobals::getDataType(dataTypeId);
|
MPI_Datatype datatype = PstreamGlobals::getDataType(dataTypeId);
|
||||||
|
|
||||||
if
|
// Runtime assert that we are not using aggregated data types
|
||||||
(
|
if (FOAM_UNLIKELY(!is_nonAggregate(dataTypeId)))
|
||||||
FOAM_UNLIKELY
|
|
||||||
(
|
|
||||||
!is_basic_dataType(dataTypeId)
|
|
||||||
)
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
FatalErrorInFunction;
|
FatalErrorInFunction;
|
||||||
printErrorNonIntrinsic("MPI_Scatterv()", dataTypeId);
|
printErrorNonIntrinsic("MPI_Scatterv()", dataTypeId);
|
||||||
|
|||||||
@ -855,7 +855,7 @@ bool Foam::UPstream::finishedRequest(const label i)
|
|||||||
// This allows MPI to progress behind the scenes if it wishes.
|
// This allows MPI to progress behind the scenes if it wishes.
|
||||||
|
|
||||||
int flag = 0;
|
int flag = 0;
|
||||||
if (i < 0 || i >= PstreamGlobals::outstandingRequests_.size())
|
if (i >= 0 && i < PstreamGlobals::outstandingRequests_.size())
|
||||||
{
|
{
|
||||||
auto& request = PstreamGlobals::outstandingRequests_[i];
|
auto& request = PstreamGlobals::outstandingRequests_[i];
|
||||||
|
|
||||||
|
|||||||
@ -218,9 +218,11 @@ tmp<vectorField> atmBoundaryLayer::U(const vectorField& pCf) const
|
|||||||
const scalar groundMin = zDir() & ppMin_;
|
const scalar groundMin = zDir() & ppMin_;
|
||||||
|
|
||||||
// (YGCJ:Table 1, RH:Eq. 6, HW:Eq. 5)
|
// (YGCJ:Table 1, RH:Eq. 6, HW:Eq. 5)
|
||||||
|
scalarField zEff(max((zDir() & pCf) - groundMin - d + z0, z0));
|
||||||
|
|
||||||
scalarField Un
|
scalarField Un
|
||||||
(
|
(
|
||||||
(Ustar(z0)/kappa_)*log(((zDir() & pCf) - groundMin - d + z0)/z0)
|
(Ustar(z0)/kappa_)*log(zEff/z0)
|
||||||
);
|
);
|
||||||
|
|
||||||
return flowDir()*Un;
|
return flowDir()*Un;
|
||||||
@ -235,9 +237,9 @@ tmp<scalarField> atmBoundaryLayer::k(const vectorField& pCf) const
|
|||||||
const scalar groundMin = zDir() & ppMin_;
|
const scalar groundMin = zDir() & ppMin_;
|
||||||
|
|
||||||
// (YGCJ:Eq. 21; RH:Eq. 7, HW:Eq. 6 when C1=0 and C2=1)
|
// (YGCJ:Eq. 21; RH:Eq. 7, HW:Eq. 6 when C1=0 and C2=1)
|
||||||
return
|
scalarField zEff(max((zDir() & pCf) - groundMin - d + z0, z0));
|
||||||
sqr(Ustar(z0))/sqrt(Cmu_)
|
|
||||||
*sqrt(C1_*log(((zDir() & pCf) - groundMin - d + z0)/z0) + C2_);
|
return sqr(Ustar(z0))/sqrt(Cmu_)*sqrt(C1_*log(zEff/z0) + C2_);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -249,9 +251,9 @@ tmp<scalarField> atmBoundaryLayer::epsilon(const vectorField& pCf) const
|
|||||||
const scalar groundMin = zDir() & ppMin_;
|
const scalar groundMin = zDir() & ppMin_;
|
||||||
|
|
||||||
// (YGCJ:Eq. 22; RH:Eq. 8, HW:Eq. 7 when C1=0 and C2=1)
|
// (YGCJ:Eq. 22; RH:Eq. 8, HW:Eq. 7 when C1=0 and C2=1)
|
||||||
return
|
scalarField zEff(max((zDir() & pCf) - groundMin - d + z0, z0));
|
||||||
pow3(Ustar(z0))/(kappa_*((zDir() & pCf) - groundMin - d + z0))
|
|
||||||
*sqrt(C1_*log(((zDir() & pCf) - groundMin - d + z0)/z0) + C2_);
|
return pow3(Ustar(z0))/(kappa_*zEff)*sqrt(C1_*log(zEff/z0) + C2_);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -263,7 +265,9 @@ tmp<scalarField> atmBoundaryLayer::omega(const vectorField& pCf) const
|
|||||||
const scalar groundMin = zDir() & ppMin_;
|
const scalar groundMin = zDir() & ppMin_;
|
||||||
|
|
||||||
// (YGJ:Eq. 13)
|
// (YGJ:Eq. 13)
|
||||||
return Ustar(z0)/(kappa_*sqrt(Cmu_)*((zDir() & pCf) - groundMin - d + z0));
|
scalarField zEff(max((zDir() & pCf) - groundMin - d + z0, z0));
|
||||||
|
|
||||||
|
return Ustar(z0)/(kappa_*sqrt(Cmu_)*zEff);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -16,6 +16,6 @@ starcd/STARCDMeshWriter.C
|
|||||||
|
|
||||||
polyDualMesh/polyDualMesh.C
|
polyDualMesh/polyDualMesh.C
|
||||||
|
|
||||||
vtk/output/foamVtkSurfaceFieldWriter.C
|
vtk/output/foamVtkSurfaceFieldWriter.cxx
|
||||||
|
|
||||||
LIB = $(FOAM_LIBBIN)/libconversion
|
LIB = $(FOAM_LIBBIN)/libconversion
|
||||||
|
|||||||
@ -98,7 +98,7 @@ bool writeAreaField
|
|||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
#ifdef NoRepository
|
#ifdef NoRepository
|
||||||
#include "ensightOutputAreaFieldTemplates.C"
|
#include "ensightOutputAreaField.txx"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@ -177,7 +177,7 @@ bool writePointField
|
|||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
#ifdef NoRepository
|
#ifdef NoRepository
|
||||||
#include "ensightOutputVolFieldTemplates.C"
|
#include "ensightOutputVolField.txx"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@ -39,7 +39,7 @@ Note
|
|||||||
|
|
||||||
SourceFiles
|
SourceFiles
|
||||||
foamVtkToolsI.H
|
foamVtkToolsI.H
|
||||||
foamVtkToolsTemplates.C
|
foamVtkTools.txx
|
||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
@ -358,7 +358,7 @@ void Foam::vtk::Tools::remapTuple<Foam::symmTensor>(double data[])
|
|||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
#ifdef NoRepository
|
#ifdef NoRepository
|
||||||
#include "foamVtkToolsTemplates.C"
|
#include "foamVtkTools.txx"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|||||||
@ -39,7 +39,7 @@ Note
|
|||||||
|
|
||||||
SourceFiles
|
SourceFiles
|
||||||
foamVtkVtuAdaptorI.H
|
foamVtkVtuAdaptorI.H
|
||||||
foamVtkVtuAdaptorTemplates.C
|
foamVtkVtuAdaptor.txx
|
||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
@ -156,7 +156,7 @@ public:
|
|||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
#ifdef NoRepository
|
#ifdef NoRepository
|
||||||
#include "foamVtkVtuAdaptorTemplates.C"
|
#include "foamVtkVtuAdaptor.txx"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|||||||
@ -32,7 +32,7 @@ Description
|
|||||||
Caution, currently only works properly for indirect patches.
|
Caution, currently only works properly for indirect patches.
|
||||||
|
|
||||||
SourceFiles
|
SourceFiles
|
||||||
foamVtkGenericPatchGeoFieldsWriter.C
|
foamVtkGenericPatchGeoFieldsWriter.txx
|
||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
@ -117,7 +117,7 @@ public:
|
|||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
#ifdef NoRepository
|
#ifdef NoRepository
|
||||||
#include "foamVtkGenericPatchGeoFieldsWriter.C"
|
#include "foamVtkGenericPatchGeoFieldsWriter.txx"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -44,7 +44,7 @@ See Also
|
|||||||
Foam::vtk::internalMeshWriter
|
Foam::vtk::internalMeshWriter
|
||||||
|
|
||||||
SourceFiles
|
SourceFiles
|
||||||
foamVtkInternalWriterTemplates.C
|
foamVtkInternalWriter.txx
|
||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
@ -183,7 +183,7 @@ public:
|
|||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
#ifdef NoRepository
|
#ifdef NoRepository
|
||||||
#include "foamVtkInternalWriterTemplates.C"
|
#include "foamVtkInternalWriter.txx"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|||||||
@ -43,7 +43,7 @@ See Also
|
|||||||
Foam::vtk::patchMeshWriter
|
Foam::vtk::patchMeshWriter
|
||||||
|
|
||||||
SourceFiles
|
SourceFiles
|
||||||
foamVtkPatchWriterTemplates.C
|
foamVtkPatchWriter.txx
|
||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
@ -202,7 +202,7 @@ public:
|
|||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
#ifdef NoRepository
|
#ifdef NoRepository
|
||||||
#include "foamVtkPatchWriterTemplates.C"
|
#include "foamVtkPatchWriter.txx"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|||||||
@ -47,7 +47,7 @@ Note
|
|||||||
may be addressed using ghost points.
|
may be addressed using ghost points.
|
||||||
|
|
||||||
SourceFiles
|
SourceFiles
|
||||||
surfaceFieldWriter.C
|
foamVtkSurfaceFieldWriter.cxx
|
||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
|||||||
@ -34,7 +34,7 @@ SourceFiles
|
|||||||
ensightCase.C
|
ensightCase.C
|
||||||
ensightCaseI.H
|
ensightCaseI.H
|
||||||
ensightCaseOptions.C
|
ensightCaseOptions.C
|
||||||
ensightCaseTemplates.C
|
ensightCase.txx
|
||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
@ -548,7 +548,7 @@ public:
|
|||||||
#include "ensightCaseI.H"
|
#include "ensightCaseI.H"
|
||||||
|
|
||||||
#ifdef NoRepository
|
#ifdef NoRepository
|
||||||
#include "ensightCaseTemplates.C"
|
#include "ensightCase.txx"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@ -394,7 +394,7 @@ public:
|
|||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
#ifdef NoRepository
|
#ifdef NoRepository
|
||||||
#include "ensightFileTemplates.C"
|
#include "ensightFile.txx"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|||||||
@ -31,7 +31,7 @@ Description
|
|||||||
|
|
||||||
SourceFiles
|
SourceFiles
|
||||||
ensightOutput.C
|
ensightOutput.C
|
||||||
ensightOutputTemplates.C
|
ensightOutput.txx
|
||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
@ -557,7 +557,7 @@ bool writeFaceLocalField
|
|||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
#ifdef NoRepository
|
#ifdef NoRepository
|
||||||
#include "ensightOutputTemplates.C"
|
#include "ensightOutput.txx"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|||||||
@ -38,7 +38,7 @@ Note
|
|||||||
|
|
||||||
SourceFiles
|
SourceFiles
|
||||||
ensightOutputSurface.C
|
ensightOutputSurface.C
|
||||||
ensightOutputSurfaceTemplates.C
|
ensightOutputSurface.txx
|
||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
@ -136,7 +136,7 @@ public:
|
|||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
#ifdef NoRepository
|
#ifdef NoRepository
|
||||||
#include "ensightOutputSurfaceTemplates.C"
|
#include "ensightOutputSurface.txx"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|||||||
@ -42,8 +42,8 @@ Description
|
|||||||
|
|
||||||
SourceFiles
|
SourceFiles
|
||||||
foamVtkFileWriter.C
|
foamVtkFileWriter.C
|
||||||
|
foamVtkFileWriter.txx
|
||||||
foamVtkFileWriterI.H
|
foamVtkFileWriterI.H
|
||||||
foamVtkFileWriterTemplates.C
|
|
||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
@ -350,7 +350,7 @@ public:
|
|||||||
#include "foamVtkFileWriterI.H"
|
#include "foamVtkFileWriterI.H"
|
||||||
|
|
||||||
#ifdef NoRepository
|
#ifdef NoRepository
|
||||||
#include "foamVtkFileWriterTemplates.C"
|
#include "foamVtkFileWriter.txx"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|||||||
@ -5,7 +5,7 @@
|
|||||||
\\ / A nd | www.openfoam.com
|
\\ / A nd | www.openfoam.com
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2018-2023 OpenCFD Ltd.
|
Copyright (C) 2018-2025 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -64,13 +64,17 @@ namespace Foam
|
|||||||
// 2. natural sort (name)
|
// 2. natural sort (name)
|
||||||
struct seriesLess
|
struct seriesLess
|
||||||
{
|
{
|
||||||
bool operator()(const fileNameInstant a, const fileNameInstant b) const
|
template<class StringType>
|
||||||
|
bool operator()
|
||||||
|
(
|
||||||
|
const Instant<StringType>& a,
|
||||||
|
const Instant<StringType>& b
|
||||||
|
) const
|
||||||
{
|
{
|
||||||
scalar val = compareOp<scalar>()(a.value(), b.value());
|
scalar val = compareOp<scalar>()(a.value(), b.value());
|
||||||
if (val == 0)
|
if (val == 0)
|
||||||
{
|
{
|
||||||
return
|
return stringOps::natural_sort::less(a.name(), b.name());
|
||||||
stringOps::natural_sort::compare(a.name(), b.name()) < 0;
|
|
||||||
}
|
}
|
||||||
return val < 0;
|
return val < 0;
|
||||||
}
|
}
|
||||||
@ -78,7 +82,7 @@ namespace Foam
|
|||||||
|
|
||||||
|
|
||||||
// Check if value is less than upper, with some tolerance.
|
// Check if value is less than upper, with some tolerance.
|
||||||
static inline bool lessThan(const scalar& val, const scalar& upper)
|
static inline bool lessThan(scalar val, scalar upper)
|
||||||
{
|
{
|
||||||
return (val < upper && Foam::mag(val - upper) > ROOTVSMALL);
|
return (val < upper && Foam::mag(val - upper) > ROOTVSMALL);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -34,7 +34,8 @@ Description
|
|||||||
|
|
||||||
SourceFiles
|
SourceFiles
|
||||||
foamVtkFormatter.C
|
foamVtkFormatter.C
|
||||||
foamVtkFormatterTemplates.C
|
foamVtkFormatter.txx
|
||||||
|
foamVtkFormatterI.H
|
||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
@ -560,7 +561,7 @@ inline uint64_t sizeofData(label count)
|
|||||||
#include "foamVtkFormatterI.H"
|
#include "foamVtkFormatterI.H"
|
||||||
|
|
||||||
#ifdef NoRepository
|
#ifdef NoRepository
|
||||||
#include "foamVtkFormatterTemplates.C"
|
#include "foamVtkFormatter.txx"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|||||||
@ -38,7 +38,8 @@ Description
|
|||||||
|
|
||||||
SourceFiles
|
SourceFiles
|
||||||
foamVtkOutput.C
|
foamVtkOutput.C
|
||||||
foamVtkOutputTemplates.C
|
foamVtkOutput.txx
|
||||||
|
foamVtkOutputI.H
|
||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
@ -352,7 +353,7 @@ namespace legacy
|
|||||||
#include "foamVtkOutputI.H"
|
#include "foamVtkOutputI.H"
|
||||||
|
|
||||||
#ifdef NoRepository
|
#ifdef NoRepository
|
||||||
#include "foamVtkOutputTemplates.C"
|
#include "foamVtkOutput.txx"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|||||||
@ -358,7 +358,7 @@ public:
|
|||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
#ifdef NoRepository
|
#ifdef NoRepository
|
||||||
#include "vtkUnstructuredReaderTemplates.C"
|
#include "vtkUnstructuredReader.txx"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -42,7 +42,7 @@ Note
|
|||||||
|
|
||||||
SourceFiles
|
SourceFiles
|
||||||
foamVtkPolyWriter.C
|
foamVtkPolyWriter.C
|
||||||
foamVtkPolyWriterTemplates.C
|
foamVtkPolyWriter.txx
|
||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
@ -253,7 +253,7 @@ public:
|
|||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
#ifdef NoRepository
|
#ifdef NoRepository
|
||||||
#include "foamVtkPolyWriterTemplates.C"
|
#include "foamVtkPolyWriter.txx"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user