Compare commits

..

3 Commits

Author SHA1 Message Date
e65dc2d578 BUG: integratedNonUniformTable: correct offsets (fixes #2614) 2022-11-01 14:55:59 +00:00
37db8ccd20 ENH: support direct calculation of finiteArea edgeNormals (#2592)
- with geometryOrder=1, calculate the edge normals from the adjacent
  faces (area-weighted, inverse distance squared) and also
  use that for the Le() calculation.

  Includes the contributions from processor edge neighbours, so it
  should be consistent on both sides.

  This new method (consider as 'beta') contrasts with the current
  standard method that first calculates area-weighted point normals
  and uses the average of them for the edge normal.

  Enable for testing either with a controlDict OptimisationSwitch entry
  "fa:geometryOrder", or on the command-line:

      solverName -opt-switch=fa:geometryOrder=1
2022-09-28 17:47:18 +02:00
a5d6c8ced0 ENH: use fallback value if calculated Le() is degenerate (#2592)
- the Le vector is calculated from (edgeVec ^ edgeNorm)
  and should be oriented in direction (faceCentre -> edgeCentre).

  If, however, the edgeNorm value is bad for any reason, the
  cross-product falls apart and Le vector is calculated as a zero
  vector!

  For these cases, revert to using (faceCentre -> edgeCentre)
  as a better approximation than a zero vector.

  In the future, will very likely switch calculating the edge normals
  directly from the attached faces, instead of from the attached
  points as is currently done, which should improve robustness.

ENH: expose fa:geometryOrder as a registered OptimisationSwitch

ENN: reuse polyMesh data (eg, faceCentres) if possible in faMesh

STYLE: add code lambdas and static functions to isolate logic
2022-09-28 17:47:17 +02:00
967 changed files with 10446 additions and 23760 deletions

View File

@ -35,7 +35,7 @@
( (
solidRegions[i], solidRegions[i],
thermos[i], thermos[i],
coordinateSystem::typeName coordinateSystem::typeName_()
) )
); );

View File

@ -15,7 +15,7 @@ if (!thermo.isotropic())
( (
mesh, mesh,
thermo, thermo,
coordinateSystem::typeName coordinateSystem::typeName_()
); );
tmp<volVectorField> tkappaByCp = thermo.Kappa()/thermo.Cp(); tmp<volVectorField> tkappaByCp = thermo.Kappa()/thermo.Cp();

View File

@ -157,7 +157,12 @@ void Foam::radiation::laserDTRM::initialiseReflection()
); );
} }
reflectionSwitch_ = returnReduceOr(reflections_.size()); if (reflections_.size())
{
reflectionSwitch_ = true;
}
reflectionSwitch_ = returnReduce(reflectionSwitch_, orOp<bool>());
} }
} }
@ -294,12 +299,14 @@ void Foam::radiation::laserDTRM::initialise()
DTRMCloud_.addParticle(pPtr); DTRMCloud_.addParticle(pPtr);
} }
if (nMissed < 10 && returnReduceAnd(cellI < 0)) if (returnReduce(cellI, maxOp<label>()) == -1)
{ {
++nMissed; if (++nMissed <= 10)
WarningInFunction {
<< "Cannot find owner cell for focalPoint at " WarningInFunction
<< p0 << endl; << "Cannot find owner cell for focalPoint at "
<< p0 << endl;
}
} }
} }
} }

View File

@ -28,6 +28,11 @@ License
#include "DirLister.H" #include "DirLister.H"
#include <dirent.h> #include <dirent.h>
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
static const Foam::word extgz("gz");
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * // // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
bool Foam::DirLister::const_iterator::open(const fileName& dir) bool Foam::DirLister::const_iterator::open(const fileName& dir)
@ -105,9 +110,9 @@ Foam::word Foam::DirLister::next(DIR* dirPtr) const
if (ok) if (ok)
{ {
if (fType == fileName::FILE && stripgz_ && name.has_ext("gz")) if (fType == fileName::FILE && stripgz_ && name.hasExt(extgz))
{ {
name.remove_ext(); name = name.lessExt();
} }
if (!name.empty() && accept(name)) if (!name.empty() && accept(name))

View File

@ -113,6 +113,7 @@ int main(int argc, char *argv[])
label coarseSize = max(addr)+1; label coarseSize = max(addr)+1;
Info<< "Level : " << level << endl Info<< "Level : " << level << endl
<< returnReduce(addr.size(), sumOp<label>()) << endl
<< " current size : " << " current size : "
<< returnReduce(addr.size(), sumOp<label>()) << endl << returnReduce(addr.size(), sumOp<label>()) << endl
<< " agglomerated size : " << " agglomerated size : "

View File

@ -90,7 +90,7 @@ void writeAndRead
const IOobject& io, const IOobject& io,
const label sz, const label sz,
const word& writeType, const word& writeType,
IOobjectOption::readOption rOpt, const IOobject::readOption rOpt,
const word& readType const word& readType
) )
{ {
@ -208,8 +208,7 @@ int main(int argc, char *argv[])
runTime.timeName(), runTime.timeName(),
mesh, mesh,
IOobject::NO_READ, IOobject::NO_READ,
IOobject::NO_WRITE, IOobject::NO_WRITE
IOobject::NO_REGISTER
); );
{ {
@ -244,7 +243,9 @@ int main(int argc, char *argv[])
args.executable(), args.executable(),
"constant", "constant",
runTime, runTime,
IOobject::NO_REGISTER // implicit convert to IOobjectOption IOobject::NO_READ,
IOobject::NO_WRITE,
false
); );
labelList ints(identity(200)); labelList ints(identity(200));

View File

@ -182,7 +182,7 @@ int main(int argc, char *argv[])
// MPI barrier // MPI barrier
bool barrier = true; bool barrier = true;
Pstream::broadcast(barrier); Pstream::scatter(barrier);
} }

View File

@ -83,9 +83,9 @@ int main(int argc, char *argv[])
{ {
IOstreamOption streamOpt; IOstreamOption streamOpt;
if (outputName.has_ext("gz")) if (outputName.hasExt("gz"))
{ {
outputName.remove_ext(); outputName.removeExt();
streamOpt.compression(IOstreamOption::COMPRESSED); streamOpt.compression(IOstreamOption::COMPRESSED);
} }

View File

@ -138,8 +138,8 @@ int main()
maxFirstEqOp<label>()(maxIndexed, item); maxFirstEqOp<label>()(maxIndexed, item);
} }
Pstream::combineReduce(minIndexed, minFirstEqOp<label>()); Pstream::combineAllGather(minIndexed, minFirstEqOp<label>());
Pstream::combineReduce(maxIndexed, maxFirstEqOp<label>()); Pstream::combineAllGather(maxIndexed, maxFirstEqOp<label>());
Info<< "Min indexed: " << minIndexed << nl Info<< "Min indexed: " << minIndexed << nl
<< "Max indexed: " << maxIndexed << nl; << "Max indexed: " << maxIndexed << nl;
@ -156,8 +156,8 @@ int main()
maxIndexed = maxFirstOp<label>()(maxIndexed, item); maxIndexed = maxFirstOp<label>()(maxIndexed, item);
} }
Pstream::combineReduce(minIndexed, minFirstEqOp<label>()); Pstream::combineAllGather(minIndexed, minFirstEqOp<label>());
Pstream::combineReduce(maxIndexed, maxFirstEqOp<label>()); Pstream::combineAllGather(maxIndexed, maxFirstEqOp<label>());
Info<< "Min indexed: " << minIndexed << nl Info<< "Min indexed: " << minIndexed << nl
<< "Max indexed: " << maxIndexed << nl; << "Max indexed: " << maxIndexed << nl;

View File

@ -1,2 +1,7 @@
/* EXE_INC = */ EXE_INC = \
/* EXE_LIBS = */ -I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude
EXE_LIBS = \
-lfiniteVolume \
-lmeshTools

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com \\ / A nd | www.openfoam.com
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2016-2022 OpenCFD Ltd. Copyright (C) 2016-2018 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -31,8 +31,7 @@ Description
#include "argList.H" #include "argList.H"
#include "Time.H" #include "Time.H"
#include "polyMesh.H" #include "polyMesh.H"
#include "line.H" #include "boundBox.H"
#include "Random.H"
#include "treeBoundBox.H" #include "treeBoundBox.H"
#include "cellModel.H" #include "cellModel.H"
#include "bitSet.H" #include "bitSet.H"
@ -85,20 +84,7 @@ int main(int argc, char *argv[])
else else
{ {
bb = cube(0, 1); bb = cube(0, 1);
Info<< "starting box: " << bb << endl; Info<<"starting box: " << bb << endl;
Info<< "corner: " << bb.hexCorner<0>() << nl
<< "corner: " << bb.hexCorner<7>() << nl
<< "corner: " << bb.hexCorner<6>() << endl;
linePoints ln1(bb.max(), bb.centre());
Info<< "line: " << ln1 << " box: " << ln1.box() << endl;
Info<< "box: " << boundBox(ln1.box()) << endl;
Info<< "corner: " << bb.hexCorner<0>() << nl
<< "corner: " << bb.hexCorner<7>() << nl
<< "corner: " << bb.hexCorner<6>() << endl;
point pt(Zero); point pt(Zero);
bb.add(pt); bb.add(pt);
@ -161,25 +147,6 @@ int main(int argc, char *argv[])
Info<< "box is now => " << box1 << endl; Info<< "box is now => " << box1 << endl;
} }
List<boundBox> boxes(12);
{
Random rndGen(12345);
for (auto& bb : boxes)
{
bb = cube
(
rndGen.position<scalar>(-10, 10),
rndGen.position<scalar>(0, 5)
);
}
Info<< "boxes: " << boxes << endl;
Foam::sort(boxes);
Info<< "sorted: " << boxes << endl;
}
return 0; return 0;
} }

View File

@ -59,11 +59,11 @@ void basicTests(const coordinateSystem& cs)
{ {
cs.writeEntry(cs.name(), Info); cs.writeEntry(cs.name(), Info);
if ((const auto* cartptr = isA<coordSystem::cartesian>(cs)) != nullptr) if (const auto* cartptr = isA<coordSystem::cartesian>(cs))
{ {
if (!cartptr->valid()) if (!cartptr->active())
{ {
Info<< "invalid cartesian = " << (*cartptr) Info<< "inactive cartesian = " << (*cartptr)
<< " with: " << (*cartptr).R() << nl; << " with: " << (*cartptr).R() << nl;
} }
} }
@ -106,7 +106,7 @@ void doTest(const dictionary& dict)
try try
{ {
auto cs1ptr = coordinateSystem::New(dict, word::null); auto cs1ptr = coordinateSystem::New(dict, "");
coordinateSystem& cs1 = *cs1ptr; coordinateSystem& cs1 = *cs1ptr;
cs1.rename(dict.dictName()); cs1.rename(dict.dictName());

View File

@ -51,8 +51,11 @@ cs4
{ {
type cylindrical; type cylindrical;
origin (0 3 5); origin (0 3 5);
rotation euler; rotation
angles (90 0 0); {
type euler;
angles (90 0 0);
}
} }
cyl cyl
@ -72,7 +75,10 @@ cyl
ident ident
{ {
origin (0 0 0); origin (0 0 0);
rotation none; rotation
{
type none;
}
} }
) )

View File

@ -26,7 +26,7 @@ rot_x90
rot_x90_axesRotation rot_x90_axesRotation
{ {
origin (0 0 0); origin (0 0 0);
rotation coordinateRotation
{ {
type axesRotation; type axesRotation;
e1 (1 0 0); e1 (1 0 0);
@ -37,7 +37,7 @@ rot_x90_axesRotation
rot_x90_axisAngle rot_x90_axisAngle
{ {
origin (0 0 0); origin (0 0 0);
rotation coordinateRotation
{ {
type axisAngle; type axisAngle;
axis (1 0 0); // non-unit also OK axis (1 0 0); // non-unit also OK
@ -48,7 +48,7 @@ rot_x90_axisAngle
rot_x90_euler rot_x90_euler
{ {
origin (0 0 0); origin (0 0 0);
rotation coordinateRotation
{ {
type euler; type euler;
angles (0 90 0); // z-x'-z'' angles (0 90 0); // z-x'-z''
@ -61,7 +61,7 @@ rot_x90_euler
rot_z45_axesRotation rot_z45_axesRotation
{ {
origin (0 0 0); origin (0 0 0);
rotation coordinateRotation
{ {
type axesRotation; type axesRotation;
e1 (1 1 0); e1 (1 1 0);
@ -72,7 +72,7 @@ rot_z45_axesRotation
rot_z45_axisAngle rot_z45_axisAngle
{ {
origin (0 0 0); origin (0 0 0);
rotation coordinateRotation
{ {
type axisAngle; type axisAngle;
axis (0 0 10); // non-unit also OK axis (0 0 10); // non-unit also OK
@ -83,7 +83,7 @@ rot_z45_axisAngle
rot_z45_euler rot_z45_euler
{ {
origin (0 0 0); origin (0 0 0);
rotation coordinateRotation
{ {
type euler; type euler;
angles (45 0 0); // z-x'-z'' angles (45 0 0); // z-x'-z''
@ -93,7 +93,7 @@ rot_z45_euler
rot_z45_starcd rot_z45_starcd
{ {
origin (0 0 0); origin (0 0 0);
rotation coordinateRotation
{ {
type starcd; type starcd;
angles (45 0 0); // z-x'-y'' angles (45 0 0); // z-x'-y''
@ -106,7 +106,7 @@ rot_z45_starcd
rot_zm45_axesRotation rot_zm45_axesRotation
{ {
origin (0 0 0); origin (0 0 0);
rotation coordinateRotation
{ {
type axesRotation; type axesRotation;
e1 (1 -1 0); e1 (1 -1 0);
@ -117,7 +117,7 @@ rot_zm45_axesRotation
rot_zm45_axisAngle rot_zm45_axisAngle
{ {
origin (0 0 0); origin (0 0 0);
rotation coordinateRotation
{ {
type axisAngle; type axisAngle;
axis (0 0 10); // non-unit also OK axis (0 0 10); // non-unit also OK
@ -128,7 +128,7 @@ rot_zm45_axisAngle
rot_zm45_euler rot_zm45_euler
{ {
origin (0 0 0); origin (0 0 0);
rotation coordinateRotation
{ {
type euler; type euler;
angles (-45 0 0); // z-x'-z'' angles (-45 0 0); // z-x'-z''
@ -141,7 +141,7 @@ rot_zm45_euler
null_axesRotation null_axesRotation
{ {
origin (0 0 0); origin (0 0 0);
rotation coordinateRotation
{ {
type axesRotation; type axesRotation;
e1 (1 0 0); e1 (1 0 0);
@ -152,7 +152,7 @@ null_axesRotation
null_axisAngle0 null_axisAngle0
{ {
origin (0 0 0); origin (0 0 0);
rotation coordinateRotation
{ {
type axisAngle; type axisAngle;
axis (0 0 0); // non-unit also OK axis (0 0 0); // non-unit also OK
@ -163,7 +163,7 @@ null_axisAngle0
null_axisAngle1 null_axisAngle1
{ {
origin (0 0 0); origin (0 0 0);
rotation coordinateRotation
{ {
type axisAngle; type axisAngle;
axis (1 1 1); // non-unit also OK axis (1 1 1); // non-unit also OK
@ -174,7 +174,7 @@ null_axisAngle1
null_euler null_euler
{ {
origin (0 0 0); origin (0 0 0);
rotation coordinateRotation
{ {
type euler; type euler;
angles (0 0 0); // z-x'-z'' angles (0 0 0); // z-x'-z''

View File

@ -60,7 +60,7 @@ int main(int argc, char *argv[])
Info<< "Reading " << file << nl << endl; Info<< "Reading " << file << nl << endl;
decomposedBlockData data decomposedBlockData data
( (
UPstream::worldComm, Pstream::worldComm,
IOobject IOobject
( (
file, file,
@ -79,6 +79,7 @@ int main(int argc, char *argv[])
( (
objPath, objPath,
IOstreamOption::BINARY, IOstreamOption::BINARY,
IOstreamOption::currentVersion,
runTime.writeCompression() runTime.writeCompression()
); );
if (!os.good()) if (!os.good())

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com \\ / A nd | www.openfoam.com
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2020-2022 OpenCFD Ltd. Copyright (C) 2020 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -65,7 +65,8 @@ int main(int argc, char *argv[])
"tensor", "tensor",
runTime.timeName(), runTime.timeName(),
mesh, mesh,
{ IOobject::READ_IF_PRESENT, IOobject::NO_REGISTER } IOobject::NO_READ,
IOobject::NO_WRITE
), ),
mesh, mesh,
dimensioned<tensor>(dimless, tensor(1,2,3,4,5,6,7,8,9)) dimensioned<tensor>(dimless, tensor(1,2,3,4,5,6,7,8,9))
@ -74,47 +75,6 @@ int main(int argc, char *argv[])
Info().beginBlock("transformed") Info().beginBlock("transformed")
<< tensorfld.T() << nl; << tensorfld.T() << nl;
Info().endBlock(); Info().endBlock();
{
auto tfld =
DimensionedField<scalar, volMesh>::New
(
tensorfld,
"scalar",
dimensioned<scalar>(14)
);
Info().beginBlock(tfld().type())
<< tfld << nl;
Info().endBlock();
}
{
auto tfld =
volScalarField::New
(
"scalar",
tensorfld.mesh(),
dimensioned<scalar>(5)
);
Info().beginBlock(tfld().type())
<< tfld() << nl;
Info().endBlock();
// From dissimilar types
auto tfld2 =
volVectorField::New
(
tfld(),
"vector",
dimensioned<vector>(Zero)
);
Info().beginBlock(tfld2().type())
<< tfld2() << nl;
Info().endBlock();
}
} }
#ifdef TEST_UINT8_FIELD #ifdef TEST_UINT8_FIELD

View File

@ -120,8 +120,7 @@ int main(int argc, char *argv[])
try try
{ {
// Should not trigger any errors // Should not trigger any errors
auto expr = expressions::exprString::toExpr(str, dict); expressions::exprString expr(str, dict, false);
Info<< "expr: " << expr << nl; Info<< "expr: " << expr << nl;
} }
catch (const Foam::error& err) catch (const Foam::error& err)

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2016-2022 OpenCFD Ltd. Copyright (C) 2016-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -48,14 +48,6 @@ Description
using namespace Foam; using namespace Foam;
// Create named file with some dummy content
void touchFileContent(const fileName& file)
{
std::ofstream os(file);
os << "file=<" << file << ">" << nl;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
unsigned testClean(std::initializer_list<Pair<std::string>> tests) unsigned testClean(std::initializer_list<Pair<std::string>> tests)
@ -268,7 +260,7 @@ int main(int argc, char *argv[])
"hello1", "hello1",
"hello2", "hello2",
"hello3", "hello3",
"hello4.ext" "hello4.hmm"
}; };
Info<< file1 << nl; Info<< file1 << nl;
@ -278,7 +270,7 @@ int main(int argc, char *argv[])
{ {
file1, file1,
"some", "some",
"more/things.ext" "more/things.hmm"
}; };
Info<< file2 << nl; Info<< file2 << nl;
@ -289,7 +281,7 @@ int main(int argc, char *argv[])
{ {
std::string("ffO"), std::string("ffO"),
"some", "some",
"more/things.ext" "more/things.hmm"
}; };
Info<< file3 << nl; Info<< file3 << nl;
@ -303,7 +295,7 @@ int main(int argc, char *argv[])
{ {
"some", "some",
file3, file3,
"more/things.ext", "more/things.hmm",
file1 file1
}; };
Info<< "All ==> " << file4 << nl; Info<< "All ==> " << file4 << nl;
@ -336,26 +328,26 @@ int main(int argc, char *argv[])
fileName input1("path.to/media/image.png"); fileName input1("path.to/media/image.png");
Info<<"File : " << input0 << " ext: " Info<<"File : " << input0 << " ext: "
<< Switch(input0.has_ext()) << Switch(input0.hasExt())
<< " = " << input0.ext() << nl; << " = " << input0.ext() << nl;
Info<<"File : " << input1 << " ext: " Info<<"File : " << input1 << " ext: "
<< Switch(input1.has_ext()) << Switch(input1.hasExt())
<< " = " << input1.ext() << nl; << " = " << input1.ext() << nl;
Info<<"File : " << endWithDot << " ext: " Info<<"File : " << endWithDot << " ext: "
<< Switch(endWithDot.has_ext()) << Switch(endWithDot.hasExt())
<< " = " << endWithDot.ext() << " <-- perhaps return false?" << nl; << " = " << endWithDot.ext() << " <-- perhaps return false?" << nl;
Info<<"File : " << endWithSlash << " ext: " Info<<"File : " << endWithSlash << " ext: "
<< Switch(endWithSlash.has_ext()) << Switch(endWithSlash.hasExt())
<< " = " << endWithSlash.ext() << nl; << " = " << endWithSlash.ext() << nl;
Info<<"Remove extension " << (input0.remove_ext()); Info<<"Remove extension " << (input0.removeExt());
Info<< " now: " << input0 << nl; Info<< " now: " << input0 << nl;
Info<<"Remove extension " << (input1.removeExt()); Info<<"Remove extension " << (input1.removeExt());
Info<< " now: " << input1 << nl; Info<< " now: " << input1 << nl;
Info<<"Remove extension " << (endWithSlash.remove_ext()); Info<<"Remove extension " << (endWithSlash.removeExt());
Info<< " now: " << endWithSlash << nl; Info<< " now: " << endWithSlash << nl;
wordList exts{ "jpg", "png", "txt", word::null }; wordList exts{ "jpg", "png", "txt", word::null };
@ -367,14 +359,14 @@ int main(int argc, char *argv[])
Info<< nl; Info<< nl;
Info<<"Test has_ext(word)" << nl Info<<"Test hasExt(word)" << nl
<<"~~~~~~~~~~~~~~~~~" << nl; <<"~~~~~~~~~~~~~~~~~" << nl;
Info<<"Has extension(s):" << nl Info<<"Has extension(s):" << nl
<< "input: " << input1 << nl; << "input: " << input1 << nl;
for (const word& e : exts) for (const word& e : exts)
{ {
Info<<" '" << e << "' -> " Info<<" '" << e << "' -> "
<< Switch(input1.has_ext(e)) << nl; << Switch(input1.hasExt(e)) << nl;
} }
Info<< nl; Info<< nl;
@ -383,12 +375,12 @@ int main(int argc, char *argv[])
for (const word& e : exts) for (const word& e : exts)
{ {
Info<<" '" << e << "' -> " Info<<" '" << e << "' -> "
<< Switch(endWithDot.has_ext(e)) << nl; << Switch(endWithDot.hasExt(e)) << nl;
} }
Info<< nl; Info<< nl;
Info<<"Test has_ext(wordRe)" << nl Info<<"Test hasExt(wordRe)" << nl
<<"~~~~~~~~~~~~~~~~~~~" << nl; <<"~~~~~~~~~~~~~~~~~~~" << nl;
// A regex with a zero length matcher doesn't work at all: // A regex with a zero length matcher doesn't work at all:
@ -401,25 +393,25 @@ int main(int argc, char *argv[])
Info<<"Has extension(s):" << nl Info<<"Has extension(s):" << nl
<< "input: " << endWithDot << nl; << "input: " << endWithDot << nl;
Info<<" " << matcher0 << " -> " Info<<" " << matcher0 << " -> "
<< Switch(endWithDot.has_ext(matcher0)) << nl; << Switch(endWithDot.hasExt(matcher0)) << nl;
Info<<" " << matcher1 << " -> " Info<<" " << matcher1 << " -> "
<< Switch(endWithDot.has_ext(matcher1)) << nl; << Switch(endWithDot.hasExt(matcher1)) << nl;
Info<<" " << matcher2 << " -> " Info<<" " << matcher2 << " -> "
<< Switch(endWithDot.has_ext(matcher2)) << nl; << Switch(endWithDot.hasExt(matcher2)) << nl;
Info<< "input: " << input1 << nl; Info<< "input: " << input1 << nl;
Info<<" " << matcher0 << " -> " Info<<" " << matcher0 << " -> "
<< Switch(input1.has_ext(matcher0)) << nl; << Switch(input1.hasExt(matcher0)) << nl;
Info<<" " << matcher1 << " -> " Info<<" " << matcher1 << " -> "
<< Switch(input1.has_ext(matcher1)) << nl; << Switch(input1.hasExt(matcher1)) << nl;
Info<<" " << matcher2 << " -> " Info<<" " << matcher2 << " -> "
<< Switch(input1.has_ext(matcher2)) << nl; << Switch(input1.hasExt(matcher2)) << nl;
Info<< nl; Info<< nl;
Info<<"Remove extension(s):" << nl << "input: " << input1 << nl; Info<<"Remove extension(s):" << nl << "input: " << input1 << nl;
while (!input1.empty()) while (!input1.empty())
{ {
if (input1.remove_ext()) if (input1.removeExt())
{ {
Info<< " -> " << input1 << nl; Info<< " -> " << input1 << nl;
} }
@ -595,54 +587,14 @@ int main(int argc, char *argv[])
if (args.found("system")) if (args.found("system"))
{ {
const fileName dirA("dirA"); const fileName dirA("dirA");
const fileName dirB("dirB");
const fileName dirC("dirC");
const fileName dirD("dirD");
const fileName lnA("lnA"); const fileName lnA("lnA");
const fileName lnB("lnB"); const fileName lnB("lnB");
const fileName dirB("dirB");
// Purge anything existing Foam::rmDir(dirA);
Foam::rmDir(dirA, true);
Foam::rmDir(dirB, true);
Foam::rmDir(dirC, true);
Foam::rmDir(dirD, true);
Foam::rm(lnA); Foam::rm(lnA);
Foam::rm(lnB); Foam::rm(lnB);
Foam::rmDir(dirB);
{
fileName name(dirA/dirB/dirC/"abc");
Foam::mkDir(name.path());
touchFileContent(name); // Create real file
Foam::mkDir(dirB/dirB/dirB/dirB);
Foam::ln("test", dirB/"linkB"); // Create dead link
Foam::mkDir(dirC);
Foam::ln("../dirD", dirC/"linkC"); // Create real link
Foam::mkDir(dirD);
for (const fileName& d : { dirA, dirB, dirC, dirD })
{
Info<< "Directory: " << d << " = "
<< readDir(d, fileName::UNDEFINED, false, false) << nl;
if (Foam::rmDir(d, false, true))
{
Info<< " Removed empty dir" << nl;
}
else
{
Info<< " Could not remove empty dir" << nl;
}
}
// Force removal before continuing
Foam::rmDir(dirA, true);
Foam::rmDir(dirB, true);
Foam::rmDir(dirC, true);
Foam::rmDir(dirD, true);
}
Info<< nl << "=========================" << nl Info<< nl << "=========================" << nl
<< "Test some copying and deletion" << endl; << "Test some copying and deletion" << endl;
@ -666,7 +618,9 @@ int main(int argc, char *argv[])
); );
Info<<" create: " << file << endl; Info<<" create: " << file << endl;
touchFileContent(file);
std::ofstream os(file);
os << "file=<" << file << ">" << nl;
} }
const int oldDebug = POSIX::debug; const int oldDebug = POSIX::debug;
@ -754,7 +708,7 @@ int main(int argc, char *argv[])
"hello1", "hello1",
"hello2", "hello2",
"hello3", "hello3",
"hello4.ext" "hello4.hmm"
}; };
fileName pathName(wrdList); fileName pathName(wrdList);
@ -764,28 +718,14 @@ int main(int argc, char *argv[])
<< "pathName.name() = >" << pathName.name() << "<\n" << "pathName.name() = >" << pathName.name() << "<\n"
<< "pathName.path() = " << pathName.path() << nl << "pathName.path() = " << pathName.path() << nl
<< "pathName.ext() = >" << pathName.ext() << "<\n" << "pathName.ext() = >" << pathName.ext() << "<\n"
<< "pathName.stem = >" << pathName.stem() << "<\n"; << "pathName.nameLessExt= >" << pathName.nameLessExt() << "<\n";
Info<< "pathName.components() = " << pathName.components() << nl Info<< "pathName.components() = " << pathName.components() << nl
<< "pathName.component(2) = " << pathName.component(2) << nl << "pathName.component(2) = " << pathName.component(2) << nl
<< endl; << endl;
pathName.replace_name("newName.ext"); Info<< "hasPath = " << Switch(pathName.hasPath()) << nl;
Info<< "new name = " << pathName << nl; pathName.removePath();
Info<< "has ext = " << Switch::name(pathName.has_ext()) << nl;
Info<< "has ext('') = " << Switch::name(pathName.has_ext("")) << nl;
Info<< "has ext(foo) = " << Switch::name(pathName.has_ext("foo")) << nl;
Info<< "has ext(ext) = " << Switch::name(pathName.has_ext("ext")) << nl;
pathName.replace_ext("png");
Info<< "new ext = " << pathName << nl;
pathName.replace_ext(""); // Same as remove_ext
Info<< "new ext = " << pathName << nl;
Info<< "has path = " << Switch::name(pathName.has_path()) << nl;
pathName.remove_path();
pathName.removePath(); // second type should be a no-op
Info<< "removed path = " << pathName << nl; Info<< "removed path = " << pathName << nl;
Info<< nl << nl; Info<< nl << nl;

View File

@ -64,8 +64,13 @@ int main(int argc, char *argv[])
// Slightly extended bb. Slightly off-centred just so on symmetric // Slightly extended bb. Slightly off-centred just so on symmetric
// geometry there are less face/edge aligned items. // geometry there are less face/edge aligned items.
treeBoundBox bb(efem.points()); treeBoundBox bb
bb.grow(ROOTVSMALL); (
efem.points()
);
bb.min() -= point::uniform(ROOTVSMALL);
bb.max() += point::uniform(ROOTVSMALL);
labelList allEdges(identity(efem.edges().size())); labelList allEdges(identity(efem.edges().size()));

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com \\ / A nd | www.openfoam.com
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2020-2022 OpenCFD Ltd. Copyright (C) 2020-2021 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.
@ -61,10 +61,10 @@ int main(int argc, char *argv[])
InfoErr<< "output: " << outputName; InfoErr<< "output: " << outputName;
IOstreamOption::compressionType comp(IOstreamOption::UNCOMPRESSED); IOstreamOption::compressionType comp(IOstreamOption::UNCOMPRESSED);
if (outputName.has_ext("gz")) if (outputName.hasExt("gz"))
{ {
comp = IOstreamOption::COMPRESSED; comp = IOstreamOption::COMPRESSED;
outputName.remove_ext(); outputName.removeExt();
InfoErr<< " [compress]"; InfoErr<< " [compress]";
} }

View File

@ -204,7 +204,7 @@ int main(int argc, char *argv[])
labelPair inOut; labelPair inOut;
pointField allCcs(globalNumbering.gather(mesh.cellCentres())); pointField allCcs(globalNumbering.gather(mesh.cellCentres()));
inOut[0] = allCcs.size(); inOut[0] = allCcs.size();
Pstream::broadcast(allCcs); Pstream::scatter(allCcs);
inOut[1] = allCcs.size(); inOut[1] = allCcs.size();
Pout<< " " << inOut << endl; Pout<< " " << inOut << endl;

View File

@ -41,8 +41,8 @@ void printInfo(const labelRange& range)
<< "last " << range.last() << nl << "last " << range.last() << nl
<< "min " << range.min() << nl << "min " << range.min() << nl
<< "max " << range.max() << nl << "max " << range.max() << nl
<< "end " << range.end_value() << nl << "after " << range.after() << nl
<< "begin/end " << *range.cbegin() << ' ' << *range.cend() << nl; << "begin end " << *range.cbegin() << ' ' << *range.cend() << nl;
// Info<< "rbegin rend " << *range.rbegin() << ' ' << *range.rend() << nl; // Info<< "rbegin rend " << *range.rbegin() << ' ' << *range.rend() << nl;
} }
@ -56,7 +56,7 @@ int main(int argc, char *argv[])
argList::noParallel(); argList::noParallel();
argList::noFunctionObjects(); argList::noFunctionObjects();
argList::addArgument("start size .. startN sizeN"); argList::addArgument("start size .. startN sizeN");
argList::addVerboseOption("enable labelRange::debug"); argList::addVerbose("enable labelRange::debug");
argList::addNote argList::addNote
( (
"The default is to add ranges, use 'add' and 'del' to toggle\n\n" "The default is to add ranges, use 'add' and 'del' to toggle\n\n"

View File

@ -44,7 +44,7 @@ using namespace Foam;
template<class T> template<class T>
Ostream& printInfo(const MinMax<T>& range) Ostream& printInfo(const MinMax<T>& range)
{ {
Info<< range << " good=" << range.good() << " span=" << range.span(); Info<< range << " valid=" << range.valid() << " span=" << range.span();
return Info; return Info;
} }
@ -234,7 +234,11 @@ int main(int argc, char *argv[])
Pout<< "hashed: " << hashed << nl; Pout<< "hashed: " << hashed << nl;
Pstream::mapCombineReduce(hashed, plusEqOp<scalarMinMax>()); Pstream::mapCombineGather
(
hashed,
plusEqOp<scalarMinMax>()
);
Info<< "reduced: " << hashed << nl; Info<< "reduced: " << hashed << nl;

View File

@ -44,7 +44,7 @@ using namespace Foam;
template<class T> template<class T>
Ostream& printInfo(const MinMax<T>& range) Ostream& printInfo(const MinMax<T>& range)
{ {
Info<< range << " good=" << range.good(); Info<< range << " valid=" << range.valid();
return Info; return Info;
} }

View File

@ -1,4 +1,4 @@
EXE_INC = $(COMP_OPENMP) EXE_INC = $(COMP_OPENMP) /* -UUSE_OMP */
/* Mostly do not need to explicitly link openmp libraries */ /* Mostly do not need to explicitly link openmp libraries */
/* EXE_LIBS = $(LINK_OPENMP) */ /* EXE_LIBS = $(LINK_OPENMP) */

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com \\ / A nd | www.openfoam.com
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2017-2022 OpenCFD Ltd. Copyright (C) 2017 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -41,6 +41,12 @@ Description
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
#if USE_OMP
std::cout << "USE_OMP defined (" << USE_OMP << ")\n";
#else
std::cout << "USE_OMP undefined\n";
#endif
#if _OPENMP #if _OPENMP
std::cout << "_OPENMP = " << _OPENMP << "\n\n"; std::cout << "_OPENMP = " << _OPENMP << "\n\n";

View File

@ -167,7 +167,7 @@ int main(int argc, char *argv[])
( (
localValue, localValue,
sumOp<scalar>(), sumOp<scalar>(),
UPstream::msgType(), Pstream::msgType(),
comm comm
); );
Pout<< "sum :" << sum << endl; Pout<< "sum :" << sum << endl;

View File

@ -125,13 +125,13 @@ int main(int argc, char *argv[])
scalar data1 = 1.0; scalar data1 = 1.0;
label request1 = -1; label request1 = -1;
{ {
Foam::reduce(data1, sumOp<scalar>(), UPstream::msgType(), request1); Foam::reduce(data1, sumOp<scalar>(), Pstream::msgType(), request1);
} }
scalar data2 = 0.1; scalar data2 = 0.1;
label request2 = -1; label request2 = -1;
{ {
Foam::reduce(data2, sumOp<scalar>(), UPstream::msgType(), request2); Foam::reduce(data2, sumOp<scalar>(), Pstream::msgType(), request2);
} }

View File

@ -232,7 +232,6 @@ int main(int argc, char *argv[])
const labelListList& edgeFaces = pp.edgeFaces(); const labelListList& edgeFaces = pp.edgeFaces();
const labelListList& faceEdges = pp.faceEdges(); const labelListList& faceEdges = pp.faceEdges();
Pout<< "box: " << pp.box() << endl;
checkFaceEdges(localFaces, edges, faceEdges); checkFaceEdges(localFaces, edges, faceEdges);

View File

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

View File

@ -1,9 +0,0 @@
EXE_INC = \
-I$(LIB_SRC)/fileFormats/lnInclude \
-I$(LIB_SRC)/surfMesh/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude
EXE_LIBS = \
-lfileFormats \
-lsurfMesh \
-lmeshTools

View File

@ -1,168 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Application
Test-rawIOField
Description
Reading rawIOField from disk
\*---------------------------------------------------------------------------*/
#include "argList.H"
#include "Time.H"
#include "Switch.H"
#include "primitiveFields.H"
#include "pointField.H"
#include "rawIOField.H"
#include "exprTraits.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
using namespace Foam;
#undef USE_ROOT_CASE
//#define USE_ROOT_CASE
template<class Type>
tmp<Field<Type>> readRawField
(
const IOobject& io,
IOobjectOption::readOption withAverage
)
{
rawIOField<Type> raw(io, withAverage);
Info<< "File: " << io.objectPath() << nl
<< "Read: " << raw.size()
<< ' ' << pTraits<Type>::typeName << " entries" << nl
<< "Average: " << Switch::name(raw.hasAverage())
<< " = " << raw.average() << endl;
return tmp<Field<Type>>::New(std::move(static_cast<Field<Type>&>(raw)));
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
int main(int argc, char *argv[])
{
argList::addNote
(
"Test behaviour of rawIOField reading (writing?)"
);
argList::noCheckProcessorDirectories();
argList::addBoolOption("scalar", "Read scalar field");
argList::addBoolOption("vector", "Read vector field");
argList::addBoolOption("point", "Read point field");
argList::addBoolOption("average", "Require averaged value entry");
argList::addBoolOption("try-average", "Optional averaged value entry");
argList::addArgument("fileName");
#ifdef USE_ROOT_CASE
#include "setRootCase.H"
#include "createTime.H"
#else
// Without root case, or time
argList args(argc, argv);
#endif
fileName inputName = args.get<fileName>(1);
IOobjectOption::readOption withAverage = IOobjectOption::NO_READ;
if (args.found("average"))
{
withAverage = IOobjectOption::MUST_READ;
}
else if (args.found("try-average"))
{
withAverage = IOobjectOption::READ_IF_PRESENT;
}
Info<< "Using case: " << argList::envGlobalPath() << nl
<< "Read file: " << inputName << nl
<< "with average: " << int(withAverage) << nl
<< endl;
refPtr<Time> timePtr;
#ifdef USE_ROOT_CASE
timePtr.cref(runTime);
#endif
// Fallback (eg, no runTime)
if (!timePtr.good())
{
timePtr.reset(Time::New(argList::envGlobalPath()));
}
const auto& tm = timePtr();
fileName resolvedName(inputName);
resolvedName.toAbsolute();
IOobject io
(
resolvedName, // absolute path
tm,
IOobject::MUST_READ,
IOobject::NO_WRITE,
IOobject::NO_REGISTER,
true // is global object (currently not used)
);
if (args.found("scalar"))
{
auto tfield = readRawField<scalar>(io, withAverage);
}
else if (args.found("point"))
{
auto tfield = readRawField<point>(io, withAverage);
}
else if (args.found("vector"))
{
auto tfield = readRawField<vector>(io, withAverage);
}
else
{
Info<< "no data type specified!\n";
}
Info<< nl << "End\n" << endl;
return 0;
}
// ************************************************************************* //

View File

@ -135,7 +135,6 @@ int main(int argc, char *argv[])
cout<<"string:" << sizeof(Foam::string) << nl; cout<<"string:" << sizeof(Foam::string) << nl;
} }
cout<<"IOobjectOption:" << sizeof(Foam::IOobjectOption) << nl;
cout<<"IOobject:" << sizeof(Foam::IOobject) << nl; cout<<"IOobject:" << sizeof(Foam::IOobject) << nl;
cout<<"IOstream:" << sizeof(Foam::IOstream) << nl; cout<<"IOstream:" << sizeof(Foam::IOstream) << nl;
cout<<"PstreamBuffers:" << sizeof(Foam::PstreamBuffers) << nl; cout<<"PstreamBuffers:" << sizeof(Foam::PstreamBuffers) << nl;

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com \\ / A nd | www.openfoam.com
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2018-2022 OpenCFD Ltd. Copyright (C) 2018-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -91,15 +91,15 @@ int main(int argc, char *argv[])
const auto importName = args.get<fileName>(1); const auto importName = args.get<fileName>(1);
word ext = word ext;
( if (!args.readIfPresent("ext", ext))
importName.has_ext("gz") {
? importName.stem().ext() ext = importName.ext();
: importName.ext() if (ext == "gz")
); {
ext = importName.lessExt().ext();
// Allow override of extension }
args.readIfPresent("ext", ext); }
args.readIfPresent("stl-parser", fileFormats::STLReader::parserType); args.readIfPresent("stl-parser", fileFormats::STLReader::parserType);

View File

@ -33,7 +33,6 @@ Description
#include "vectorField.H" #include "vectorField.H"
#include "IOstreams.H" #include "IOstreams.H"
#include "Random.H"
#include <algorithm> #include <algorithm>
#include <random> #include <random>
@ -75,12 +74,8 @@ void doTest(vector& vec1, vector& vec2)
printInfo(vec1); printInfo(vec1);
printInfo(vec2); printInfo(vec2);
Info<< "vector: " << vec1 << nl Info<< "min of " << vec1 << " and " << vec2 << " = "
<< "vector: " << vec2 << nl << min(vec1, vec2) << nl << nl;
<< " min: " << min(vec1, vec2) << nl
<< " dist: " << vec1.dist(vec2) << ' ' << mag(vec1 - vec2) << nl
<< "dist^2: " << vec1.distSqr(vec2) << ' ' << magSqr(vec1 - vec2) << nl
<< nl;
} }
@ -151,46 +146,6 @@ int main(int argc, char *argv[])
std::shuffle(vec2.begin(), vec2.end(), std::default_random_engine()); std::shuffle(vec2.begin(), vec2.end(), std::default_random_engine());
Info<< "shuffled: " << vec2 << nl; Info<< "shuffled: " << vec2 << nl;
// Vectors with some identical components
List<vector> vectors
({
{1.1, 2.2, 3.3 },
{2.2, 3.3, 4.4 },
{-1.1, 2.2, 3.3 },
{-2.2, 3.3, 4.4 },
{-1.1, -2.2, 3.3 },
{-2.2, -3.3, 4.4 },
{-1.1, -2.2, -3.3 },
{-2.2, -3.3, -4.4 },
{-3.3, 2.1, 12 },
{3.145, 1.6, 2 },
{0, 0, 0}
});
shuffle(vectors);
Info<< "initial vectors: ";
vectors.writeList(Info, 1) << nl;
Foam::sort(vectors);
Info<< "regular sort:";
vectors.writeList(Info, 1) << nl;
std::sort(vectors.begin(), vectors.end(), vector::less_xyz);
Info<< "sorted xyz:";
vectors.writeList(Info, 1) << nl;
std::sort(vectors.begin(), vectors.end(), vector::less_yzx);
Info<< "sorted yzx:";
vectors.writeList(Info, 1) << nl;
std::sort(vectors.begin(), vectors.end(), vector::less_zxy);
Info<< "sorted zxy:";
vectors.writeList(Info, 1) << nl;
} }
// Basic tests for fields // Basic tests for fields

View File

@ -585,7 +585,7 @@ void createBaffles
// Wrapper around find patch. Also makes sure same patch in parallel. // Wrapper around find patch. Also makes sure same patch in parallel.
label findPatch(const polyBoundaryMesh& patches, const word& patchName) label findPatch(const polyBoundaryMesh& patches, const word& patchName)
{ {
const label patchi = patches.findPatchID(patchName); label patchi = patches.findPatchID(patchName);
if (patchi == -1) if (patchi == -1)
{ {
@ -597,15 +597,16 @@ label findPatch(const polyBoundaryMesh& patches, const word& patchName)
// Check same patch for all procs // Check same patch for all procs
{ {
const label newPatchi = returnReduce(patchi, minOp<label>()); label newPatch = patchi;
reduce(newPatch, minOp<label>());
if (newPatchi != patchi) if (newPatch != patchi)
{ {
FatalErrorInFunction FatalErrorInFunction
<< "Patch " << patchName << "Patch " << patchName
<< " should have the same patch index on all processors." << nl << " should have the same patch index on all processors." << nl
<< "On my processor it has index " << patchi << "On my processor it has index " << patchi
<< " ; on some other processor it has index " << newPatchi << " ; on some other processor it has index " << newPatch
<< exit(FatalError); << exit(FatalError);
} }
} }

View File

@ -6,7 +6,6 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2022 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -397,11 +396,12 @@ int main(int argc, char *argv[])
meshSearch queryMesh(mesh); meshSearch queryMesh(mesh);
// Check all 'outside' points // Check all 'outside' points
for (const point& outsidePoint : outsidePts) forAll(outsidePts, outsideI)
{ {
const label celli = queryMesh.findCell(outsidePoint, -1, false); const point& outsidePoint = outsidePts[outsideI];
if (returnReduceAnd(celli < 0)) label celli = queryMesh.findCell(outsidePoint, -1, false);
if (returnReduce(celli, maxOp<label>()) == -1)
{ {
FatalErrorInFunction FatalErrorInFunction
<< "outsidePoint " << outsidePoint << "outsidePoint " << outsidePoint

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com \\ / A nd | www.openfoam.com
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2016-2022 OpenCFD Ltd. Copyright (C) 2016-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -175,7 +175,7 @@ int main(int argc, char *argv[])
// strip erroneous extension (.ccm, .ccmg, .ccmp) // strip erroneous extension (.ccm, .ccmg, .ccmp)
if (ext == "ccm" || ext == "ccmg" || ext == "ccmp") if (ext == "ccm" || ext == "ccmg" || ext == "ccmp")
{ {
exportName.remove_ext(); exportName = exportName.lessExt();
} }
} }
else if (args.found("export")) else if (args.found("export"))

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com \\ / A nd | www.openfoam.com
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2016-2022 OpenCFD Ltd. Copyright (C) 2016 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -137,7 +137,7 @@ int main(int argc, char *argv[])
// strip erroneous extension (.ccm, .ccmg, .ccmp) // strip erroneous extension (.ccm, .ccmg, .ccmp)
if (ext == "ccm" || ext == "ccmg" || ext == "ccmp") if (ext == "ccm" || ext == "ccmg" || ext == "ccmp")
{ {
exportName.remove_ext(); exportName = exportName.lessExt();
} }
} }
else if (args.found("case")) else if (args.found("case"))

View File

@ -1,4 +0,0 @@
ensightMeshReader.C
ensightToFoam.C
EXE = $(FOAM_APPBIN)/ensightToFoam

View File

@ -1,11 +0,0 @@
EXE_INC = \
-I$(LIB_SRC)/fileFormats/lnInclude \
-I$(LIB_SRC)/surfMesh/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude \
-I$(LIB_SRC)/conversion/lnInclude
EXE_LIBS = \
-lfileFormats \
-lsurfMesh \
-lmeshTools \
-lconversion

View File

@ -1,194 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class
Foam::fileFormats::ensightMeshReader
Description
Notes
SourceFiles
ensightMeshReader.C
\*---------------------------------------------------------------------------*/
#ifndef Foam_ensightMeshReader_H
#define Foam_ensightMeshReader_H
#include "meshReader.H"
//#include "ensightReadFile.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// Forward Declarations
class ensightReadFile;
namespace fileFormats
{
/*---------------------------------------------------------------------------*\
Class fileFormats::ensightMeshReader Declaration
\*---------------------------------------------------------------------------*/
class ensightMeshReader
:
public meshReader
{
// Private Data
//- Merge distance
const scalar mergeTol_;
//- Check and correct handedness
const bool setHandedness_;
protected:
// Protected Data
//- mesh point to original node_id
labelList nodeIds_;
//- mesh cell to original element_id
labelList elementIds_;
// Protected Member Functions
//- Rotate face so lowest vertex is first
const face& rotateFace
(
const face& f,
face& rotatedFace
) const;
//- Read set of vertices. Optional mapping
void readVerts
(
ensightReadFile& is,
const label nVerts,
const Map<label>& nodeIdToPoints,
DynamicList<label>& verts
) const;
//- Read set of element/node IDs
void readIDs
(
ensightReadFile& is,
const bool doRead,
const label nShapes,
labelList& foamToElem,
Map<label>& elemToFoam
) const;
//- Swap handedness of hex if needed
void setHandedness
(
const cellModel& model,
DynamicList<label>& verts,
const pointField& points
) const;
//- Read a single part until eof (return true) or until start of next
// part (return false)
bool readGoldPart
(
ensightReadFile& is,
const bool read_node_ids,
const bool read_elem_ids,
pointField& points,
labelList& pointToNodeIds,
Map<label>& nodeIdToPoints,
// 3D-elems : cells (cell-to-faces)
faceListList& cellFaces,
labelList& cellToElemIds,
Map<label>& elemIdToCells,
// 2D-elems : faces
faceList& faces,
labelList& faceToElemIDs,
Map<label>& elemIdToFaces
) const;
//- Read the mesh from the file(s)
virtual bool readGeometry(const scalar scaleFactor = 1.0);
public:
//- Runtime type information
TypeName("ensightMeshReader");
// Constructors
//- Construct from case name
ensightMeshReader
(
const fileName& geomFile,
const objectRegistry& registry,
const scalar mergeTol = SMALL,
const scalar scaleFactor = 1.0,
const bool setHandedness = true
);
//- Destructor
virtual ~ensightMeshReader() = default;
// Access
//- Original node id (if supplied) or -1
const labelList& nodeIds() const noexcept
{
return nodeIds_;
}
//- Original element id (if supplied) or -1
const labelList& elementIds() const noexcept
{
return elementIds_;
}
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace fileFormats
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -1,118 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Application
ensightToFoam
Group
grpMeshConversionUtilities
Description
Convert an Ensight Gold mesh into OpenFOAM format.
Usage
\b ensightToFoam [OPTION] \<ensightGeometryFile\>
Options:
- \par -mergeTol \<factor\>
Specify an alternative merging tolerance as a fraction of
the bounding box of the points.
- \par -scale \<factor\>
Specify an optional geometry scaling factor.
- \par -keepHandedness
Do not automatically flip negative volume cells
See also
Foam::meshReader and Foam::fileFormats::STARCDMeshReader
\*---------------------------------------------------------------------------*/
#include "argList.H"
#include "Time.H"
#include "ensightMeshReader.H"
using namespace Foam;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
int main(int argc, char *argv[])
{
argList::addNote
(
"Convert Ensight mesh to OpenFOAM"
);
argList::noParallel();
argList::addArgument(".geo file", "The file containing the geometry");
argList::addOption
(
"mergeTol",
"factor",
"Merge tolerance as a fraction of bounding box - 0 to disable merging"
);
argList::addOption
(
"scale",
"factor",
"Geometry scaling factor - default is 1"
);
argList::addBoolOption
(
"keepHandedness",
"Do not automatically flip inverted cells"
" (default is to do a geometric test)"
);
argList args(argc, argv);
Time runTime(args.rootPath(), args.caseName());
// Increase the precision of the points data
IOstream::defaultPrecision(max(10u, IOstream::defaultPrecision()));
const fileName geomFile(args.get<fileName>(1));
{
fileFormats::ensightMeshReader reader
(
geomFile,
runTime,
args.getOrDefault<scalar>("mergeTol", 1e-10),
args.getOrDefault<scalar>("scale", 1.0),
args.found("keepHandedness")
);
autoPtr<polyMesh> mesh = reader.mesh(runTime);
mesh().setInstance(runTime.constant());
mesh().write();
}
Info<< "\nEnd\n" << endl;
return 0;
}
// ************************************************************************* //

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2020-2022 OpenCFD Ltd. Copyright (C) 2020-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -87,8 +87,8 @@ int main(int argc, char *argv[])
const scalar scaleFactor = args.getOrDefault<scalar>("scale", 0); const scalar scaleFactor = args.getOrDefault<scalar>("scale", 0);
const bool doTriangulate = args.found("tri"); const bool doTriangulate = args.found("tri");
const fileName exportBase = exportName.lessExt(); fileName exportBase = exportName.lessExt();
const word exportExt = exportName.ext(); word exportExt = exportName.ext();
if (!meshedSurface::canWriteType(exportExt, true)) if (!meshedSurface::canWriteType(exportExt, true))
{ {

View File

@ -538,11 +538,8 @@ int main(int argc, char *argv[])
// Add any patches. // Add any patches.
const label nAdded = returnReduce label nAdded = nPatches - mesh.boundaryMesh().size();
( reduce(nAdded, sumOp<label>());
nPatches - mesh.boundaryMesh().size(),
sumOp<label>()
);
Info<< "Adding overall " << nAdded << " processor patches." << endl; Info<< "Adding overall " << nAdded << " processor patches." << endl;
@ -949,8 +946,9 @@ int main(int argc, char *argv[])
// Put all modifications into meshMod // Put all modifications into meshMod
bool anyChange = collapser.setRefinement(allPointInfo, meshMod); bool anyChange = collapser.setRefinement(allPointInfo, meshMod);
reduce(anyChange, orOp<bool>());
if (returnReduceOr(anyChange)) if (anyChange)
{ {
// Construct new mesh from polyTopoChange. // Construct new mesh from polyTopoChange.
autoPtr<mapPolyMesh> map = meshMod.changeMesh(mesh, false); autoPtr<mapPolyMesh> map = meshMod.changeMesh(mesh, false);
@ -1120,7 +1118,8 @@ int main(int argc, char *argv[])
processorMeshes::removeFiles(mesh); processorMeshes::removeFiles(mesh);
// Need writing cellSet // Need writing cellSet
if (returnReduceOr(addedCellsSet.size())) label nAdded = returnReduce(addedCellsSet.size(), sumOp<label>());
if (nAdded > 0)
{ {
cellSet addedCells(mesh, "addedCells", addedCellsSet); cellSet addedCells(mesh, "addedCells", addedCellsSet);
Info<< "Writing added cells to cellSet " << addedCells.name() Info<< "Writing added cells to cellSet " << addedCells.name()

View File

@ -345,7 +345,7 @@ void deleteEmptyPatches(fvMesh& mesh)
else else
{ {
// Common patch. // Common patch.
if (returnReduceAnd(patches[patchi].empty())) if (returnReduce(patches[patchi].empty(), andOp<bool>()))
{ {
Pout<< "Deleting patch " << patchi Pout<< "Deleting patch " << patchi
<< " name:" << patches[patchi].name() << " name:" << patches[patchi].name()
@ -661,8 +661,8 @@ void countExtrudePatches
} }
// Synchronise decision. Actual numbers are not important, just make // Synchronise decision. Actual numbers are not important, just make
// sure that they're > 0 on all processors. // sure that they're > 0 on all processors.
Pstream::listCombineReduce(zoneSidePatch, plusEqOp<label>()); Pstream::listCombineAllGather(zoneSidePatch, plusEqOp<label>());
Pstream::listCombineReduce(zoneZonePatch, plusEqOp<label>()); Pstream::listCombineAllGather(zoneZonePatch, plusEqOp<label>());
} }
@ -1848,7 +1848,7 @@ int main(int argc, char *argv[])
const primitiveFacePatch extrudePatch(std::move(zoneFaces), mesh.points()); const primitiveFacePatch extrudePatch(std::move(zoneFaces), mesh.points());
Pstream::listCombineReduce(isInternal, orEqOp<bool>()); Pstream::listCombineAllGather(isInternal, orEqOp<bool>());
// Check zone either all internal or all external faces // Check zone either all internal or all external faces
checkZoneInside(mesh, zoneNames, zoneID, extrudeMeshFaces, isInternal); checkZoneInside(mesh, zoneNames, zoneID, extrudeMeshFaces, isInternal);
@ -2309,7 +2309,7 @@ int main(int argc, char *argv[])
} }
// Reduce // Reduce
Pstream::mapCombineReduce(globalSum, plusEqOp<point>()); Pstream::mapCombineAllGather(globalSum, plusEqOp<point>());
forAll(localToGlobalRegion, localRegionI) forAll(localToGlobalRegion, localRegionI)
{ {

View File

@ -588,8 +588,9 @@ Foam::label Foam::DistributedDelaunayMesh<Triangulation>::referVertices
reduce(preInsertionSize, sumOp<label>()); reduce(preInsertionSize, sumOp<label>());
reduce(postInsertionSize, sumOp<label>()); reduce(postInsertionSize, sumOp<label>());
label nTotalToInsert = label nTotalToInsert = referredVertices.size();
returnReduce(referredVertices.size(), sumOp<label>());
reduce(nTotalToInsert, sumOp<label>());
if (preInsertionSize + nTotalToInsert != postInsertionSize) if (preInsertionSize + nTotalToInsert != postInsertionSize)
{ {

View File

@ -167,7 +167,14 @@ void Foam::backgroundMeshDecomposition::initialRefinement()
{ {
if (volumeStatus[celli] == volumeType::UNKNOWN) if (volumeStatus[celli] == volumeType::UNKNOWN)
{ {
treeBoundBox cellBb(mesh_.cells()[celli].box(mesh_)); treeBoundBox cellBb
(
mesh_.cells()[celli].points
(
mesh_.faces(),
mesh_.points()
)
);
if (geometry.overlaps(cellBb)) if (geometry.overlaps(cellBb))
{ {
@ -217,7 +224,7 @@ void Foam::backgroundMeshDecomposition::initialRefinement()
); );
} }
if (returnReduceAnd(newCellsToRefine.empty())) if (returnReduce(newCellsToRefine.size(), sumOp<label>()) == 0)
{ {
break; break;
} }
@ -279,7 +286,14 @@ void Foam::backgroundMeshDecomposition::initialRefinement()
{ {
if (volumeStatus[celli] == volumeType::UNKNOWN) if (volumeStatus[celli] == volumeType::UNKNOWN)
{ {
treeBoundBox cellBb(mesh_.cells()[celli].box(mesh_)); treeBoundBox cellBb
(
mesh_.cells()[celli].points
(
mesh_.faces(),
mesh_.points()
)
);
if (geometry.overlaps(cellBb)) if (geometry.overlaps(cellBb))
{ {
@ -498,7 +512,14 @@ bool Foam::backgroundMeshDecomposition::refineCell
// const conformationSurfaces& geometry = geometryToConformTo_; // const conformationSurfaces& geometry = geometryToConformTo_;
treeBoundBox cellBb(mesh_.cells()[celli].box(mesh_)); treeBoundBox cellBb
(
mesh_.cells()[celli].points
(
mesh_.faces(),
mesh_.points()
)
);
weightEstimate = 1.0; weightEstimate = 1.0;
@ -878,7 +899,7 @@ Foam::backgroundMeshDecomposition::distribute
} }
} }
if (returnReduceAnd(cellsToRefine.empty())) if (returnReduce(cellsToRefine.size(), sumOp<label>()) == 0)
{ {
break; break;
} }

View File

@ -153,7 +153,7 @@ public:
return name_; return name_;
} }
Switch forceInitialPointInsertion() const noexcept const Switch& forceInitialPointInsertion() const
{ {
return forceInitialPointInsertion_; return forceInitialPointInsertion_;
} }

View File

@ -92,7 +92,9 @@ bool Foam::controlMeshRefinement::detectEdge
magSqr(a - b) < tolSqr magSqr(a - b) < tolSqr
) )
{ {
pointFound.hitPoint(midPoint); pointFound.setPoint(midPoint);
pointFound.setHit();
return true; return true;
} }
@ -262,7 +264,7 @@ void Foam::controlMeshRefinement::initialMeshPopulation
const cellSizeAndAlignmentControl& controlFunction = const cellSizeAndAlignmentControl& controlFunction =
controlFunctions[fI]; controlFunctions[fI];
const Switch forceInsertion = const Switch& forceInsertion =
controlFunction.forceInitialPointInsertion(); controlFunction.forceInitialPointInsertion();
Info<< "Inserting points from " << controlFunction.name() Info<< "Inserting points from " << controlFunction.name()
@ -448,7 +450,7 @@ void Foam::controlMeshRefinement::initialMeshPopulation
const cellSizeAndAlignmentControl& controlFunction = const cellSizeAndAlignmentControl& controlFunction =
controlFunctions[fI]; controlFunctions[fI];
const Switch forceInsertion = const Switch& forceInsertion =
controlFunction.forceInitialPointInsertion(); controlFunction.forceInitialPointInsertion();
Info<< "Inserting points from " << controlFunction.name() Info<< "Inserting points from " << controlFunction.name()

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2012-2017 OpenFOAM Foundation Copyright (C) 2012-2017 OpenFOAM Foundation
Copyright (C) 2016-2022 OpenCFD Ltd. Copyright (C) 2016-2020 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -298,7 +298,7 @@ Foam::tmp<Foam::triSurfacePointScalarField> Foam::automatic::load()
( (
surface_.searchableSurface::time().constant() surface_.searchableSurface::time().constant()
/ "triSurface" / "triSurface"
/ surfaceName_.stem() + "_cellSize" / surfaceName_.nameLessExt() + "_cellSize"
) )
); );

View File

@ -38,7 +38,6 @@ Description
#if defined(CGAL_VERSION_NR) && (CGAL_VERSION_NR < 1050211000) #if defined(CGAL_VERSION_NR) && (CGAL_VERSION_NR < 1050211000)
#define BOOST_BIND_GLOBAL_PLACEHOLDERS #define BOOST_BIND_GLOBAL_PLACEHOLDERS
#endif #endif
#pragma clang diagnostic ignored "-Wbitwise-instead-of-logical"
// ------------------------------------------------------------------------- // // ------------------------------------------------------------------------- //

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2012-2016 OpenFOAM Foundation Copyright (C) 2012-2016 OpenFOAM Foundation
Copyright (C) 2020-2022 OpenCFD Ltd. Copyright (C) 2020-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -87,17 +87,23 @@ void Foam::conformalVoronoiMesh::cellSizeMeshOverlapsBackground() const
boundBox cellSizeMeshBb = cellSizeMesh.bounds(); boundBox cellSizeMeshBb = cellSizeMesh.bounds();
bool fullyContained = cellSizeMeshBb.contains(bb); bool fullyContained = true;
if (!fullyContained) if (!cellSizeMeshBb.contains(bb))
{ {
Pout<< "Triangulation not fully contained in cell size mesh." << endl Pout<< "Triangulation not fully contained in cell size mesh."
<< "Cell Size Mesh Bounds = " << cellSizeMeshBb << endl << endl;
<< "foamyHexMesh Bounds = " << bb << endl;
Pout<< "Cell Size Mesh Bounds = " << cellSizeMesh.bounds() << endl;
Pout<< "foamyHexMesh Bounds = " << bb << endl;
fullyContained = false;
} }
reduce(fullyContained, andOp<unsigned int>());
Info<< "Triangulation is " Info<< "Triangulation is "
<< (returnReduceAnd(fullyContained) ? "fully" : "not fully") << (fullyContained ? "fully" : "not fully")
<< " contained in the cell size mesh" << " contained in the cell size mesh"
<< endl; << endl;
} }
@ -109,7 +115,12 @@ void Foam::conformalVoronoiMesh::insertInternalPoints
bool distribute bool distribute
) )
{ {
const label nPoints = returnReduce(points.size(), sumOp<label>()); label nPoints = points.size();
if (Pstream::parRun())
{
reduce(nPoints, sumOp<label>());
}
Info<< " " << nPoints << " points to insert..." << endl; Info<< " " << nPoints << " points to insert..." << endl;
@ -134,15 +145,16 @@ void Foam::conformalVoronoiMesh::insertInternalPoints
map().distribute(points); map().distribute(points);
} }
label preReinsertionSize(number_of_vertices()); label nVert = number_of_vertices();
insert(points.begin(), points.end()); insert(points.begin(), points.end());
const label nInserted = returnReduce label nInserted(number_of_vertices() - nVert);
(
label(number_of_vertices()) - preReinsertionSize, if (Pstream::parRun())
sumOp<label>() {
); reduce(nInserted, sumOp<label>());
}
Info<< " " << nInserted << " points inserted" Info<< " " << nInserted << " points inserted"
<< ", failed to insert " << nPoints - nInserted << ", failed to insert " << nPoints - nInserted

View File

@ -753,7 +753,7 @@ Foam::conformalVoronoiMesh::createPolyMeshFromPoints
forAll(patches, p) forAll(patches, p)
{ {
label nPatchFaces = patchDicts[p].get<label>("nFaces"); label totalPatchSize = patchDicts[p].get<label>("nFaces");
if if
( (
@ -762,7 +762,7 @@ Foam::conformalVoronoiMesh::createPolyMeshFromPoints
) )
{ {
// Do not create empty processor patches // Do not create empty processor patches
if (nPatchFaces) if (totalPatchSize > 0)
{ {
patchDicts[p].set("transform", "coincidentFullMatch"); patchDicts[p].set("transform", "coincidentFullMatch");
@ -781,8 +781,9 @@ Foam::conformalVoronoiMesh::createPolyMeshFromPoints
else else
{ {
// Check that the patch is not empty on every processor // Check that the patch is not empty on every processor
reduce(totalPatchSize, sumOp<label>());
if (returnReduceOr(nPatchFaces)) if (totalPatchSize > 0)
{ {
patches[nValidPatches] = polyPatch::New patches[nValidPatches] = polyPatch::New
( (

View File

@ -729,7 +729,7 @@ Foam::label Foam::conformalVoronoiMesh::synchroniseSurfaceTrees
} }
} }
Pstream::listCombineReduce(hits, plusEqOp<labelHashSet>()); Pstream::listCombineAllGather(hits, plusEqOp<labelHashSet>());
forAll(surfaceHits, eI) forAll(surfaceHits, eI)
{ {
@ -816,7 +816,7 @@ Foam::label Foam::conformalVoronoiMesh::synchroniseEdgeTrees
} }
} }
Pstream::listCombineReduce(hits, plusEqOp<labelHashSet>()); Pstream::listCombineAllGather(hits, plusEqOp<labelHashSet>());
forAll(featureEdgeHits, eI) forAll(featureEdgeHits, eI)
{ {

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2012-2017 OpenFOAM Foundation Copyright (C) 2012-2017 OpenFOAM Foundation
Copyright (C) 2015-2022 OpenCFD Ltd. Copyright (C) 2015-2018 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -707,7 +707,9 @@ void Foam::conformalVoronoiMesh::reorderProcessorPatches
Info<< incrIndent << indent << "Faces matched." << endl; Info<< incrIndent << indent << "Faces matched." << endl;
if (returnReduceOr(anyChanged)) reduce(anyChanged, orOp<bool>());
if (anyChanged)
{ {
label nReorderedFaces = 0; label nReorderedFaces = 0;

View File

@ -44,7 +44,6 @@ SourceFiles
#if defined(CGAL_VERSION_NR) && (CGAL_VERSION_NR < 1050211000) #if defined(CGAL_VERSION_NR) && (CGAL_VERSION_NR < 1050211000)
#define BOOST_BIND_GLOBAL_PLACEHOLDERS #define BOOST_BIND_GLOBAL_PLACEHOLDERS
#endif #endif
#pragma clang diagnostic ignored "-Wbitwise-instead-of-logical"
// ------------------------------------------------------------------------- // // ------------------------------------------------------------------------- //

View File

@ -45,7 +45,6 @@ SourceFiles
#if defined(CGAL_VERSION_NR) && (CGAL_VERSION_NR < 1050211000) #if defined(CGAL_VERSION_NR) && (CGAL_VERSION_NR < 1050211000)
#define BOOST_BIND_GLOBAL_PLACEHOLDERS #define BOOST_BIND_GLOBAL_PLACEHOLDERS
#endif #endif
#pragma clang diagnostic ignored "-Wbitwise-instead-of-logical"
// ------------------------------------------------------------------------- // // ------------------------------------------------------------------------- //

View File

@ -605,7 +605,7 @@ Foam::conformationSurfaces::conformationSurfaces
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
bool Foam::conformationSurfaces::overlaps(const boundBox& bb) const bool Foam::conformationSurfaces::overlaps(const treeBoundBox& bb) const
{ {
forAll(surfaces_, s) forAll(surfaces_, s)
{ {

View File

@ -188,7 +188,7 @@ public:
//- Check if the supplied bound box overlaps any part of any of //- Check if the supplied bound box overlaps any part of any of
// the surfaces // the surfaces
bool overlaps(const boundBox& bb) const; bool overlaps(const treeBoundBox& bb) const;
//- Check if points are inside surfaces to conform to //- Check if points are inside surfaces to conform to
Field<bool> inside(const pointField& samplePts) const; Field<bool> inside(const pointField& samplePts) const;

View File

@ -84,12 +84,16 @@ Foam::searchableBoxFeatures::features() const
autoPtr<extendedFeatureEdgeMesh> features; autoPtr<extendedFeatureEdgeMesh> features;
List<vector> faceNormalsList(treeBoundBox::faceNormals); List<vector> faceNormalsList(treeBoundBox::faceNormals);
vectorField faceNormals(std::move(faceNormalsList)); vectorField faceNormals(faceNormalsList);
vectorField edgeDirections(12); vectorField edgeDirections(12);
labelListList normalDirections(12, labelList(2, Zero)); labelListList normalDirections(12);
labelListList edgeNormals(12, labelList(2, Zero));
labelListList edgeNormals(12);
forAll(edgeNormals, eI)
{
edgeNormals[eI].setSize(2, 0);
}
edgeNormals[0][0] = 2; edgeNormals[0][1] = 4; edgeNormals[0][0] = 2; edgeNormals[0][1] = 4;
edgeNormals[1][0] = 1; edgeNormals[1][1] = 4; edgeNormals[1][0] = 1; edgeNormals[1][1] = 4;
edgeNormals[2][0] = 3; edgeNormals[2][1] = 4; edgeNormals[2][0] = 3; edgeNormals[2][1] = 4;
@ -112,6 +116,7 @@ Foam::searchableBoxFeatures::features() const
surfacePoints[treeBoundBox::edges[eI].end()] surfacePoints[treeBoundBox::edges[eI].end()]
- surfacePoints[treeBoundBox::edges[eI].start()]; - surfacePoints[treeBoundBox::edges[eI].start()];
normalDirections[eI] = labelList(2, Zero);
for (label j = 0; j < 2; ++j) for (label j = 0; j < 2; ++j)
{ {
const vector cross = const vector cross =
@ -133,12 +138,12 @@ Foam::searchableBoxFeatures::features() const
} }
} }
labelListList featurePointNormals(8, labelList(3, Zero)); labelListList featurePointNormals(8);
labelListList featurePointEdges(8, labelList(3, Zero)); labelListList featurePointEdges(8);
forAll(featurePointNormals, pI) forAll(featurePointNormals, pI)
{ {
labelList& ftPtEdges = featurePointEdges[pI]; labelList& ftPtEdges = featurePointEdges[pI];
ftPtEdges.setSize(3, 0);
label edgeI = 0; label edgeI = 0;
forAll(treeBoundBox::edges, eI) forAll(treeBoundBox::edges, eI)
@ -156,6 +161,7 @@ Foam::searchableBoxFeatures::features() const
} }
labelList& ftPtNormals = featurePointNormals[pI]; labelList& ftPtNormals = featurePointNormals[pI];
ftPtNormals.setSize(3, 0);
ftPtNormals[0] = edgeNormals[ftPtEdges[0]][0]; ftPtNormals[0] = edgeNormals[ftPtEdges[0]][0];
ftPtNormals[1] = edgeNormals[ftPtEdges[0]][1]; ftPtNormals[1] = edgeNormals[ftPtEdges[0]][1];

View File

@ -727,12 +727,14 @@ int main(int argc, char *argv[])
pointField mergedPoints; pointField mergedPoints;
faceList mergedFaces; faceList mergedFaces;
labelList pointMergeMap;
PatchTools::gatherAndMerge PatchTools::gatherAndMerge
( (
tolDim, tolDim,
primitivePatch(SubList<face>(isoFaces), isoPoints), primitivePatch(SubList<face>(isoFaces), isoPoints),
mergedPoints, mergedPoints,
mergedFaces mergedFaces,
pointMergeMap
); );
if (Pstream::master()) if (Pstream::master())

View File

@ -38,7 +38,6 @@ Description
#if defined(CGAL_VERSION_NR) && (CGAL_VERSION_NR < 1050211000) #if defined(CGAL_VERSION_NR) && (CGAL_VERSION_NR < 1050211000)
#define BOOST_BIND_GLOBAL_PLACEHOLDERS #define BOOST_BIND_GLOBAL_PLACEHOLDERS
#endif #endif
#pragma clang diagnostic ignored "-Wbitwise-instead-of-logical"
// ------------------------------------------------------------------------- // // ------------------------------------------------------------------------- //

View File

@ -40,7 +40,6 @@ Description
#if defined(CGAL_VERSION_NR) && (CGAL_VERSION_NR < 1050211000) #if defined(CGAL_VERSION_NR) && (CGAL_VERSION_NR < 1050211000)
#define BOOST_BIND_GLOBAL_PLACEHOLDERS #define BOOST_BIND_GLOBAL_PLACEHOLDERS
#endif #endif
#pragma clang diagnostic ignored "-Wbitwise-instead-of-logical"
// ------------------------------------------------------------------------- // // ------------------------------------------------------------------------- //

View File

@ -416,12 +416,10 @@ void extractSurface
// Allocate zone/patch for all patches // Allocate zone/patch for all patches
HashTable<label> compactZoneID(1024); HashTable<label> compactZoneID(1024);
if (Pstream::master()) forAllConstIters(patchSize, iter)
{ {
forAllConstIters(patchSize, iter) label sz = compactZoneID.size();
{ compactZoneID.insert(iter.key(), sz);
compactZoneID.insert(iter.key(), compactZoneID.size());
}
} }
Pstream::broadcast(compactZoneID); Pstream::broadcast(compactZoneID);
@ -433,7 +431,7 @@ void extractSurface
label patchi = bMesh.findPatchID(iter.key()); label patchi = bMesh.findPatchID(iter.key());
if (patchi != -1) if (patchi != -1)
{ {
patchToCompactZone[patchi] = iter.val(); patchToCompactZone[patchi] = iter();
} }
} }
@ -665,7 +663,7 @@ void removeZeroSizedPatches(fvMesh& mesh)
if if
( (
isA<coupledPolyPatch>(pp) isA<coupledPolyPatch>(pp)
|| returnReduceOr(pp.size()) || returnReduce(pp.size(), sumOp<label>())
) )
{ {
// Coupled (and unknown size) or uncoupled and used // Coupled (and unknown size) or uncoupled and used
@ -1891,8 +1889,11 @@ int main(int argc, char *argv[])
); );
// Use the maxLocalCells from the refinement parameters // Use the maxLocalCells from the refinement parameters
const bool preBalance = bool preBalance = returnReduce
returnReduceOr(mesh.nCells() >= refineParams.maxLocalCells()); (
(mesh.nCells() >= refineParams.maxLocalCells()),
orOp<bool>()
);
if (!overwrite && !debugLevel) if (!overwrite && !debugLevel)

View File

@ -104,6 +104,9 @@ void Foam::checkPatch
// << endl; // << endl;
} }
//DebugVar(globalEdgeFaces);
// Synchronise across coupled edges. // Synchronise across coupled edges.
syncTools::syncEdgeList syncTools::syncEdgeList
( (
@ -113,6 +116,7 @@ void Foam::checkPatch
labelList() // null value labelList() // null value
); );
//DebugVar(globalEdgeFaces);
label labelTyp = TopoType::MANIFOLD; label labelTyp = TopoType::MANIFOLD;
forAll(meshEdges, edgei) forAll(meshEdges, edgei)
@ -187,7 +191,7 @@ void Foam::checkPatch
{ {
const labelList& mp = pp.meshPoints(); const labelList& mp = pp.meshPoints();
if (returnReduceOr(mp.size())) if (returnReduce(mp.size(), sumOp<label>()) > 0)
{ {
boundBox bb(pp.points(), mp, true); // reduce boundBox bb(pp.points(), mp, true); // reduce
Info<< ' ' << bb; Info<< ' ' << bb;
@ -196,35 +200,6 @@ void Foam::checkPatch
} }
template<class Zone>
Foam::label Foam::checkZones
(
const polyMesh& mesh,
const ZoneMesh<Zone, polyMesh>& zones,
topoSet& set
)
{
labelList zoneID(set.maxSize(mesh), -1);
for (const auto& zone : zones)
{
for (const label elem : zone)
{
if
(
zoneID[elem] != -1
&& zoneID[elem] != zone.index()
)
{
set.insert(elem);
}
zoneID[elem] = zone.index();
}
}
return returnReduce(set.size(), sumOp<label>());
}
Foam::label Foam::checkTopology Foam::label Foam::checkTopology
( (
const polyMesh& mesh, const polyMesh& mesh,
@ -252,10 +227,10 @@ Foam::label Foam::checkTopology
} }
} }
reduce(nEmpty, sumOp<label>()); reduce(nEmpty, sumOp<label>());
const label nCells = returnReduce(mesh.cells().size(), sumOp<label>()); label nTotCells = returnReduce(mesh.cells().size(), sumOp<label>());
// These are actually warnings, not errors. // These are actually warnings, not errors.
if (nCells && (nEmpty % nCells)) if (nTotCells && (nEmpty % nTotCells))
{ {
Info<< " ***Total number of faces on empty patches" Info<< " ***Total number of faces on empty patches"
<< " is not divisible by the number of cells in the mesh." << " is not divisible by the number of cells in the mesh."
@ -335,7 +310,7 @@ Foam::label Foam::checkTopology
{ {
noFailedChecks++; noFailedChecks++;
const label nPoints = returnReduce(points.size(), sumOp<label>()); label nPoints = returnReduce(points.size(), sumOp<label>());
Info<< " <<Writing " << nPoints Info<< " <<Writing " << nPoints
<< " unused points to set " << points.name() << endl; << " unused points to set " << points.name() << endl;
@ -472,7 +447,7 @@ Foam::label Foam::checkTopology
} }
} }
const label nOneCells = returnReduce(oneCells.size(), sumOp<label>()); label nOneCells = returnReduce(oneCells.size(), sumOp<label>());
if (nOneCells > 0) if (nOneCells > 0)
{ {
@ -488,7 +463,7 @@ Foam::label Foam::checkTopology
} }
} }
const label nTwoCells = returnReduce(twoCells.size(), sumOp<label>()); label nTwoCells = returnReduce(twoCells.size(), sumOp<label>());
if (nTwoCells > 0) if (nTwoCells > 0)
{ {
@ -588,7 +563,11 @@ Foam::label Foam::checkTopology
} }
} }
Pstream::listCombineReduce(regionDisconnected, andEqOp<bool>()); Pstream::listCombineAllGather
(
regionDisconnected,
andEqOp<bool>()
);
} }
@ -635,7 +614,7 @@ Foam::label Foam::checkTopology
cellRegions[i].write(); cellRegions[i].write();
} }
const label nPoints = returnReduce(points.size(), sumOp<label>()); label nPoints = returnReduce(points.size(), sumOp<label>());
if (nPoints) if (nPoints)
{ {
Info<< " <<Writing " << nPoints Info<< " <<Writing " << nPoints
@ -735,25 +714,6 @@ Foam::label Foam::checkTopology
); );
Info<< endl; Info<< endl;
} }
// Check for duplicates
if (allTopology)
{
faceSet mzFaces(mesh, "multiZoneFaces", mesh.nFaces()/100);
const label nMulti = checkZones(mesh, faceZones, mzFaces);
if (nMulti)
{
Info<< " <<Writing " << nMulti
<< " faces that are in multiple zones"
<< " to set " << mzFaces.name() << endl;
mzFaces.instance() = mesh.pointsInstance();
mzFaces.write();
if (surfWriter && surfWriter->enabled())
{
mergeAndWrite(*surfWriter, mzFaces);
}
}
}
} }
else else
{ {
@ -831,26 +791,6 @@ Foam::label Foam::checkTopology
<< returnReduce(v, sumOp<scalar>()) << returnReduce(v, sumOp<scalar>())
<< ' ' << bb << endl; << ' ' << bb << endl;
} }
// Check for duplicates
if (allTopology)
{
cellSet mzCells(mesh, "multiZoneCells", mesh.nCells()/100);
const label nMulti = checkZones(mesh, cellZones, mzCells);
if (nMulti)
{
Info<< " <<Writing " << nMulti
<< " cells that are in multiple zones"
<< " to set " << mzCells.name() << endl;
mzCells.instance() = mesh.pointsInstance();
mzCells.write();
if (surfWriter && surfWriter->enabled())
{
mergeAndWrite(*surfWriter, mzCells);
}
}
}
} }
else else
{ {
@ -858,65 +798,6 @@ Foam::label Foam::checkTopology
} }
} }
{
Info<< "\nChecking basic pointZone addressing..." << endl;
Pout.setf(ios_base::left);
const pointZoneMesh& pointZones = mesh.pointZones();
if (pointZones.size())
{
Info<< " "
<< setw(20) << "PointZone"
<< setw(8) << "Points"
<< "BoundingBox" << endl;
for (const auto& zone : pointZones)
{
boundBox bb;
for (const label pointi : zone)
{
bb.add(mesh.points()[pointi]);
}
bb.reduce(); // Global min/max
Info<< " "
<< setw(20) << zone.name()
<< setw(8)
<< returnReduce(zone.size(), sumOp<label>())
<< bb << endl;
}
// Check for duplicates
if (allTopology)
{
pointSet mzPoints(mesh, "multiZonePoints", mesh.nPoints()/100);
const label nMulti = checkZones(mesh, pointZones, mzPoints);
if (nMulti)
{
Info<< " <<Writing " << nMulti
<< " points that are in multiple zones"
<< " to set " << mzPoints.name() << endl;
mzPoints.instance() = mesh.pointsInstance();
mzPoints.write();
if (setWriter && setWriter->enabled())
{
mergeAndWrite(*setWriter, mzPoints);
}
}
}
}
else
{
Info<< " No pointZones found."<<endl;
}
}
// Force creation of all addressing if requested. // Force creation of all addressing if requested.
// Errors will be reported as required // Errors will be reported as required
if (allTopology) if (allTopology)

View File

@ -1,7 +1,5 @@
#include "labelList.H" #include "labelList.H"
#include "autoPtr.H" #include "autoPtr.H"
#include "ZoneMesh.H"
#include "topoSet.H"
namespace Foam namespace Foam
{ {
@ -23,14 +21,6 @@ namespace Foam
pointSet& points pointSet& points
); );
template<class Zone>
label checkZones
(
const polyMesh& mesh,
const ZoneMesh<Zone, polyMesh>& zones,
topoSet& set
);
label checkTopology label checkTopology
( (
const polyMesh& mesh, const polyMesh& mesh,

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2016-2022 OpenCFD Ltd. Copyright (C) 2016-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -138,7 +138,7 @@ void filterPatches(fvMesh& mesh, const wordHashSet& addedPatchNames)
if if
( (
isA<coupledPolyPatch>(pp) isA<coupledPolyPatch>(pp)
|| returnReduceOr(pp.size()) || returnReduce(pp.size(), sumOp<label>())
|| addedPatchNames.found(pp.name()) || addedPatchNames.found(pp.name())
) )
{ {

View File

@ -686,7 +686,7 @@ void syncPoints
//- Note: hasTransformation is only used for warning messages so //- Note: hasTransformation is only used for warning messages so
// reduction not strictly necessary. // reduction not strictly necessary.
//Pstream::reduceOr(hasTransformation); //reduce(hasTransformation, orOp<bool>());
// Synchronize multiple shared points. // Synchronize multiple shared points.
const globalMeshData& pd = mesh.globalData(); const globalMeshData& pd = mesh.globalData();
@ -714,7 +714,7 @@ void syncPoints
} }
// Combine - globally consistent // Combine - globally consistent
Pstream::listCombineReduce(sharedPts, cop); Pstream::listCombineAllGather(sharedPts, cop);
// Now we will all have the same information. Merge it back with // Now we will all have the same information. Merge it back with
// my local information. // my local information.

View File

@ -6,7 +6,6 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2013-2016 OpenFOAM Foundation Copyright (C) 2013-2016 OpenFOAM Foundation
Copyright (C) 2022 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -273,7 +272,7 @@ int main(int argc, char *argv[])
} }
if (returnReduceAnd(changedEdges.empty())) if (returnReduce(changedEdges.size(), sumOp<label>()) == 0)
{ {
break; break;
} }

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2016-2022 OpenCFD Ltd. Copyright (C) 2016-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -1103,7 +1103,9 @@ int main(int argc, char *argv[])
// Update proc maps // Update proc maps
if (cellProcAddressing.headerOk()) if (cellProcAddressing.headerOk())
{ {
if (returnReduceAnd(cellProcAddressing.size() == mesh.nCells())) bool localOk = (cellProcAddressing.size() == mesh.nCells());
if (returnReduce(localOk, andOp<bool>()))
{ {
Info<< "Renumbering processor cell decomposition map " Info<< "Renumbering processor cell decomposition map "
<< cellProcAddressing.name() << endl; << cellProcAddressing.name() << endl;
@ -1127,7 +1129,9 @@ int main(int argc, char *argv[])
if (faceProcAddressing.headerOk()) if (faceProcAddressing.headerOk())
{ {
if (returnReduceAnd(faceProcAddressing.size() == mesh.nFaces())) bool localOk = (faceProcAddressing.size() == mesh.nFaces());
if (returnReduce(localOk, andOp<bool>()))
{ {
Info<< "Renumbering processor face decomposition map " Info<< "Renumbering processor face decomposition map "
<< faceProcAddressing.name() << endl; << faceProcAddressing.name() << endl;
@ -1167,7 +1171,9 @@ int main(int argc, char *argv[])
if (pointProcAddressing.headerOk()) if (pointProcAddressing.headerOk())
{ {
if (returnReduceAnd(pointProcAddressing.size() == mesh.nPoints())) bool localOk = (pointProcAddressing.size() == mesh.nPoints());
if (returnReduce(localOk, andOp<bool>()))
{ {
Info<< "Renumbering processor point decomposition map " Info<< "Renumbering processor point decomposition map "
<< pointProcAddressing.name() << endl; << pointProcAddressing.name() << endl;
@ -1191,13 +1197,12 @@ int main(int argc, char *argv[])
if (boundaryProcAddressing.headerOk()) if (boundaryProcAddressing.headerOk())
{ {
if bool localOk =
( (
returnReduceAnd boundaryProcAddressing.size()
( == mesh.boundaryMesh().size()
boundaryProcAddressing.size() == mesh.boundaryMesh().size() );
) if (returnReduce(localOk, andOp<bool>()))
)
{ {
// No renumbering needed // No renumbering needed
} }

View File

@ -847,7 +847,7 @@ void createAndWriteRegion
if (!isA<processorPolyPatch>(pp)) if (!isA<processorPolyPatch>(pp))
{ {
if (returnReduceOr(pp.size())) if (returnReduce(pp.size(), sumOp<label>()) > 0)
{ {
oldToNew[patchi] = newI; oldToNew[patchi] = newI;
if (!addedPatches.found(patchi)) if (!addedPatches.found(patchi))
@ -1114,7 +1114,7 @@ label findCorrespondingRegion
} }
} }
Pstream::listCombineReduce(cellsInZone, plusEqOp<label>()); Pstream::listCombineAllGather(cellsInZone, plusEqOp<label>());
// Pick region with largest overlap of zoneI // Pick region with largest overlap of zoneI
label regionI = findMax(cellsInZone); label regionI = findMax(cellsInZone);

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2016-2017 OpenFOAM Foundation Copyright (C) 2016-2017 OpenFOAM Foundation
Copyright (C) 2017-2022 OpenCFD Ltd. Copyright (C) 2017-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -144,7 +144,11 @@ using namespace Foam;
// but leave anything with '/' delimiters untouched // but leave anything with '/' delimiters untouched
bool upgradeScope(word& entryName) bool upgradeScope(word& entryName)
{ {
if (!entryName.contains('/') && entryName.contains(':')) if
(
entryName.find('/') == string::npos
&& entryName.find(':') != string::npos
)
{ {
const wordList names(fileName(entryName).components(':')); const wordList names(fileName(entryName).components(':'));

View File

@ -223,7 +223,7 @@ bool writeOptionalMeshObject
// Make sure all know if there is a valid class name // Make sure all know if there is a valid class name
wordList classNames(1, io.headerClassName()); wordList classNames(1, io.headerClassName());
Pstream::combineReduce(classNames, uniqueEqOp<word>()); Pstream::combineAllGather(classNames, uniqueEqOp<word>());
// Check for correct type // Check for correct type
if (classNames[0] == T::typeName) if (classNames[0] == T::typeName)
@ -429,7 +429,7 @@ int main(int argc, char *argv[])
) )
); );
Pstream::combineReduce(lagrangianDirs, uniqueEqOp<fileName>()); Pstream::combineAllGather(lagrangianDirs, uniqueEqOp<fileName>());
if (!lagrangianDirs.empty()) if (!lagrangianDirs.empty())
{ {
@ -466,7 +466,7 @@ int main(int argc, char *argv[])
) )
); );
Pstream::combineReduce(cloudDirs, uniqueEqOp<fileName>()); Pstream::combineAllGather(cloudDirs, uniqueEqOp<fileName>());
forAll(cloudDirs, i) forAll(cloudDirs, i)
{ {
@ -492,7 +492,7 @@ int main(int argc, char *argv[])
); );
// Combine with all other cloud objects // Combine with all other cloud objects
Pstream::combineReduce(cloudFields, uniqueEqOp<word>()); Pstream::combineAllGather(cloudFields, uniqueEqOp<word>());
for (const word& name : cloudFields) for (const word& name : cloudFields)
{ {

View File

@ -252,7 +252,7 @@ autoPtr<mapPolyMesh> mergeSharedPoints
Info<< "mergeSharedPoints : detected " << pointToMaster.size() Info<< "mergeSharedPoints : detected " << pointToMaster.size()
<< " points that are to be merged." << endl; << " points that are to be merged." << endl;
if (returnReduceAnd(pointToMaster.empty())) if (returnReduce(pointToMaster.size(), sumOp<label>()) == 0)
{ {
return nullptr; return nullptr;
} }

View File

@ -69,7 +69,7 @@ Foam::boolList Foam::haveMeshFile
void Foam::removeProcAddressing(const faMesh& mesh) void Foam::removeProcAddressing(const faMesh& mesh)
{ {
IOobject io IOobject ioAddr
( (
"procAddressing", "procAddressing",
mesh.facesInstance(), mesh.facesInstance(),
@ -79,9 +79,9 @@ void Foam::removeProcAddressing(const faMesh& mesh)
for (const auto prefix : {"boundary", "edge", "face", "point"}) for (const auto prefix : {"boundary", "edge", "face", "point"})
{ {
io.rename(prefix + word("ProcAddressing")); ioAddr.rename(prefix + word("ProcAddressing"));
const fileName procFile(io.objectPath()); const fileName procFile(ioAddr.objectPath());
Foam::rm(procFile); Foam::rm(procFile);
} }
} }
@ -89,7 +89,7 @@ void Foam::removeProcAddressing(const faMesh& mesh)
void Foam::removeProcAddressing(const polyMesh& mesh) void Foam::removeProcAddressing(const polyMesh& mesh)
{ {
IOobject io IOobject ioAddr
( (
"procAddressing", "procAddressing",
mesh.facesInstance(), mesh.facesInstance(),
@ -99,18 +99,89 @@ void Foam::removeProcAddressing(const polyMesh& mesh)
for (const auto prefix : {"boundary", "cell", "face", "point"}) for (const auto prefix : {"boundary", "cell", "face", "point"})
{ {
io.rename(prefix + word("ProcAddressing")); ioAddr.rename(prefix + word("ProcAddressing"));
const fileName procFile(io.objectPath()); const fileName procFile(ioAddr.objectPath());
Foam::rm(procFile); Foam::rm(procFile);
} }
} }
void Foam::removeEmptyDir(const fileName& path) bool Foam::removeEmptyDir(const fileName& path)
{ {
// Remove directory: silent, emptyOnly // Return true if empty directory. Note bypass of fileHandler to be
Foam::rmDir(path, true, true); // consistent with polyMesh.removeFiles for now.
{
fileNameList files
(
Foam::readDir
(
path,
fileName::FILE,
false, // filterGz
false // followLink
)
);
if (files.size())
{
return false;
}
}
{
fileNameList dirs
(
Foam::readDir
(
path,
fileName::DIRECTORY,
false, // filterGz
false // followLink
)
);
if (dirs.size())
{
return false;
}
}
{
fileNameList links
(
Foam::readDir
(
path,
fileName::SYMLINK,
false, // filterGz
false // followLink
)
);
if (links.size())
{
return false;
}
}
{
fileNameList other
(
Foam::readDir
(
path,
fileName::UNDEFINED,
false, // filterGz
false // followLink
)
);
if (other.size())
{
return false;
}
}
// Avoid checking success of deletion since initial path might not
// exist (e.g. contain 'region0'). Will stop when trying to delete
// parent directory anyway since now not empty.
Foam::rm(path);
return true;
} }

View File

@ -64,8 +64,8 @@ void removeProcAddressing(const faMesh& mesh);
//- Remove procAddressing //- Remove procAddressing
void removeProcAddressing(const polyMesh& mesh); void removeProcAddressing(const polyMesh& mesh);
//- Remove empty directory //- Remove empty directory. Return true if removed.
void removeEmptyDir(const fileName& path); bool removeEmptyDir(const fileName& path);
//- Remove empty directories from bottom up //- Remove empty directories from bottom up
void removeEmptyDirs(const fileName& path); void removeEmptyDirs(const fileName& path);

View File

@ -224,7 +224,7 @@ Foam::parFvFieldDistributor::distributeField
} }
// Map all faces // Map all faces
primitiveField = Field<Type>(flatFld, mapper, fld.is_oriented()); primitiveField = Field<Type>(flatFld, mapper, fld.oriented()());
// Trim to internal faces (note: could also have special mapper) // Trim to internal faces (note: could also have special mapper)
primitiveField.resize primitiveField.resize

View File

@ -89,11 +89,10 @@ void Foam::parLagrangianDistributor::findClouds
} }
// Synchronise cloud names // Synchronise cloud names
Pstream::combineReduce(cloudNames, ListOps::uniqueEqOp<word>()); Pstream::combineGather(cloudNames, ListOps::uniqueEqOp<word>());
Foam::sort(cloudNames); // Consistent order Pstream::broadcast(cloudNames);
objectNames.clear(); objectNames.setSize(cloudNames.size());
objectNames.resize(cloudNames.size());
for (const fileName& localCloudName : localCloudDirs) for (const fileName& localCloudName : localCloudDirs)
{ {
@ -125,11 +124,11 @@ void Foam::parLagrangianDistributor::findClouds
} }
} }
// Synchronise objectNames (per cloud) // Synchronise objectNames
for (wordList& objNames : objectNames) forAll(objectNames, i)
{ {
Pstream::combineReduce(objNames, ListOps::uniqueEqOp<word>()); Pstream::combineGather(objectNames[i], ListOps::uniqueEqOp<word>());
Foam::sort(objNames); // Consistent order Pstream::broadcast(objectNames[i]);
} }
} }
@ -292,7 +291,7 @@ Foam::parLagrangianDistributor::distributeLagrangianPositions
nsTransPs[sendProcI] = subMap[sendProcI].size(); nsTransPs[sendProcI] = subMap[sendProcI].size();
} }
// Send sizes across. Note: blocks. // Send sizes across. Note: blocks.
Pstream::combineReduce(sizes, Pstream::listEq()); Pstream::combineAllGather(sizes, Pstream::listEq());
labelListList constructMap(Pstream::nProcs()); labelListList constructMap(Pstream::nProcs());
label constructSize = 0; label constructSize = 0;

View File

@ -51,9 +51,14 @@ Foam::wordList Foam::parLagrangianDistributor::filterObjects
: objects.names<Container>(selectedFields) : objects.names<Container>(selectedFields)
); );
// Parallel synchronise - combine names from all processors // Parallel synchronise
Pstream::combineReduce(fieldNames, ListOps::uniqueEqOp<word>()); // - Combine names from all processors
Foam::sort(fieldNames); // Consistent order
Pstream::combineGather(fieldNames, ListOps::uniqueEqOp<word>());
Pstream::broadcast(fieldNames);
// Sort for consistent order on all processors
Foam::sort(fieldNames);
return fieldNames; return fieldNames;
} }
@ -88,8 +93,11 @@ Foam::label Foam::parLagrangianDistributor::distributeFields
if (!nFields) if (!nFields)
{ {
// Performing an all-to-one (reconstruct)? // Performing an all-to-one (reconstruct)?
reconstruct = reconstruct = returnReduce
returnReduceAnd(!map.constructSize() || Pstream::master()); (
(!map.constructSize() || Pstream::master()),
andOp<bool>()
);
} }
if (verbose_) if (verbose_)
@ -192,8 +200,11 @@ Foam::label Foam::parLagrangianDistributor::distributeFieldFields
if (!nFields) if (!nFields)
{ {
// Performing an all-to-one (reconstruct)? // Performing an all-to-one (reconstruct)?
reconstruct = reconstruct = returnReduce
returnReduceAnd(!map.constructSize() || Pstream::master()); (
(!map.constructSize() || Pstream::master()),
andOp<bool>()
);
} }
if (verbose_) if (verbose_)
@ -338,8 +349,11 @@ Foam::label Foam::parLagrangianDistributor::distributeStoredFields
if (!nFields) if (!nFields)
{ {
// Performing an all-to-one (reconstruct)? // Performing an all-to-one (reconstruct)?
reconstruct = reconstruct = returnReduce
returnReduceAnd(!map.constructSize() || Pstream::master()); (
(!map.constructSize() || Pstream::master()),
andOp<bool>()
);
} }
if (verbose_) if (verbose_)

View File

@ -132,7 +132,7 @@ void createTimeDirs(const fileName& path)
//Pstream::parRun(oldParRun); // Restore parallel state //Pstream::parRun(oldParRun); // Restore parallel state
masterTimeDirs = localTimeDirs; masterTimeDirs = localTimeDirs;
} }
Pstream::broadcast(masterTimeDirs); Pstream::scatter(masterTimeDirs);
//DebugVar(masterTimeDirs); //DebugVar(masterTimeDirs);
//DebugVar(localTimeDirs); //DebugVar(localTimeDirs);
@ -1168,7 +1168,7 @@ int main(int argc, char *argv[])
bool nfs = true; bool nfs = true;
{ {
List<fileName> roots(1, args.rootPath()); List<fileName> roots(1, args.rootPath());
Pstream::combineReduce(roots, ListOps::uniqueEqOp<fileName>()); Pstream::combineAllGather(roots, ListOps::uniqueEqOp<fileName>());
nfs = (roots.size() == 1); nfs = (roots.size() == 1);
} }
@ -1187,8 +1187,7 @@ int main(int argc, char *argv[])
{ {
if (decompose) if (decompose)
{ {
Info<< "Removing existing processor directory:" Info<< "Removing existing processor directory" << procDir << endl;
<< args.relativePath(procDir) << endl;
fileHandler().rmDir(procDir); fileHandler().rmDir(procDir);
} }
} }
@ -1203,7 +1202,7 @@ int main(int argc, char *argv[])
} }
} }
// If master changed to decompose mode make sure all nodes know about it // If master changed to decompose mode make sure all nodes know about it
Pstream::broadcast(decompose); Pstream::scatter(decompose);
// If running distributed we have problem of new processors not finding // If running distributed we have problem of new processors not finding
@ -1288,7 +1287,7 @@ int main(int argc, char *argv[])
// use the times list from the master processor // use the times list from the master processor
// and select a subset based on the command-line options // and select a subset based on the command-line options
instantList timeDirs = timeSelector::select(runTime.times(), args); instantList timeDirs = timeSelector::select(runTime.times(), args);
Pstream::broadcast(timeDirs); Pstream::scatter(timeDirs);
if (timeDirs.empty()) if (timeDirs.empty())
{ {
@ -1547,7 +1546,7 @@ int main(int argc, char *argv[])
if if
( (
!volMeshHaveUndecomposed !volMeshHaveUndecomposed
|| !returnReduceAnd(haveVolAddressing) || !returnReduce(haveVolAddressing, andOp<bool>())
) )
{ {
Info<< "No undecomposed mesh. Creating from: " Info<< "No undecomposed mesh. Creating from: "
@ -1615,7 +1614,7 @@ int main(int argc, char *argv[])
&& &&
( (
!areaMeshHaveUndecomposed !areaMeshHaveUndecomposed
|| !returnReduceAnd(haveAreaAddressing) || !returnReduce(haveAreaAddressing, andOp<bool>())
) )
) )
{ {
@ -2067,7 +2066,7 @@ int main(int argc, char *argv[])
args args
)[0].value(); )[0].value();
} }
Pstream::broadcast(masterTime); Pstream::scatter(masterTime);
Info<< "Setting time to that of master or undecomposed case : " Info<< "Setting time to that of master or undecomposed case : "
<< masterTime << endl; << masterTime << endl;
runTime.setTime(masterTime, 0); runTime.setTime(masterTime, 0);
@ -2349,8 +2348,6 @@ int main(int argc, char *argv[])
// Remove any left-over empty processor directories created // Remove any left-over empty processor directories created
// by loadOrCreateMesh to get around the collated start-up // by loadOrCreateMesh to get around the collated start-up
// problems // problems
Info<< "Removing left-over empty processor directories" << nl;
if (Pstream::master()) //fileHandler().comm())) if (Pstream::master()) //fileHandler().comm()))
{ {
const auto myProci = UPstream::myProcNo(); //comm() const auto myProci = UPstream::myProcNo(); //comm()
@ -2367,7 +2364,9 @@ int main(int argc, char *argv[])
&& volMeshDir[proci] != volMeshDir[myProci] && volMeshDir[proci] != volMeshDir[myProci]
) )
{ {
Foam::rmDir(volMeshDir[proci], true); // silent Info<< "Deleting mesh dir:"
<< volMeshDir[proci] << endl;
Foam::rmDir(volMeshDir[proci]);
} }
if if
@ -2376,18 +2375,9 @@ int main(int argc, char *argv[])
&& areaMeshDir[proci] != areaMeshDir[myProci] && areaMeshDir[proci] != areaMeshDir[myProci]
) )
{ {
Foam::rmDir(areaMeshDir[proci], true); // silent Info<< "Deleting mesh dir:"
} << areaMeshDir[proci] << endl;
Foam::rmDir(areaMeshDir[proci]);
// Remove empty processor directories
// Eg, <path-name>/processorN/constant/polyMesh
// to <path-name>/processorN
if (proci != myProci)
{
removeEmptyDir
(
volMeshDir[proci].path().path()
);
} }
} }
@ -2451,8 +2441,7 @@ int main(int argc, char *argv[])
// Remove dummy mesh created by loadOrCreateMesh // Remove dummy mesh created by loadOrCreateMesh
const bool oldParRun = Pstream::parRun(false); const bool oldParRun = Pstream::parRun(false);
mesh.removeFiles(); mesh.removeFiles();
// Silent rmdir Foam::rmDir(mesh.objectRegistry::objectPath());
Foam::rmDir(mesh.objectRegistry::objectPath(), true);
Pstream::parRun(oldParRun); // Restore parallel state Pstream::parRun(oldParRun); // Restore parallel state
} }
} }

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com \\ / A nd | www.openfoam.com
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2021-2022 OpenCFD Ltd. Copyright (C) 2021 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.
@ -78,6 +78,6 @@ if (timeDirs.size() > 1)
} }
// Ensure consistency // Ensure consistency
Pstream::reduceOr(hasMovingMesh); reduce(hasMovingMesh, orOp<bool>());
// ************************************************************************* // // ************************************************************************* //

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com \\ / A nd | www.openfoam.com
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2018-2022 OpenCFD Ltd. Copyright (C) 2018-2021 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.
@ -38,7 +38,7 @@ if (doLagrangian)
Info<< "Cloud " << cloudName << " ("; Info<< "Cloud " << cloudName << " (";
const bool cloudExists = const bool cloudExists =
returnReduceOr(currentCloudDirs.found(cloudName)); returnReduce(currentCloudDirs.found(cloudName), orOp<bool>());
{ {
autoPtr<ensightFile> os = ensCase.newCloud(cloudName); autoPtr<ensightFile> os = ensCase.newCloud(cloudName);
@ -82,7 +82,7 @@ if (doLagrangian)
const bool oldParRun = Pstream::parRun(false); const bool oldParRun = Pstream::parRun(false);
fieldExists = fieldObject.typeHeaderOk<IOField<scalar>>(false); fieldExists = fieldObject.typeHeaderOk<IOField<scalar>>(false);
Pstream::parRun(oldParRun); // Restore parallel state Pstream::parRun(oldParRun); // Restore parallel state
Pstream::reduceOr(fieldExists); reduce(fieldExists, orOp<bool>());
} }
bool wrote = false; bool wrote = false;

View File

@ -101,7 +101,7 @@ if (timeDirs.size() && doLagrangian)
{ {
for (auto& cloudFields : regionCloudFields) for (auto& cloudFields : regionCloudFields)
{ {
Pstream::mapCombineReduce Pstream::mapCombineAllGather
( (
cloudFields, cloudFields,
HashTableOps::plusEqOp<word>() HashTableOps::plusEqOp<word>()

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com \\ / A nd | www.openfoam.com
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2018-2022 OpenCFD Ltd. Copyright (C) 2018 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -64,7 +64,9 @@ Foam::label Foam::checkData
} }
} }
if (returnReduceAnd(good)) reduce(good, andOp<bool>());
if (good)
{ {
goodFields.insert(fieldName); goodFields.insert(fieldName);
} }

View File

@ -46,9 +46,11 @@ if (doLagrangian)
if (Pstream::parRun()) if (Pstream::parRun())
{ {
// Synchronise cloud names // Synchronise cloud names
Pstream::combineReduce(cloudNames, ListOps::uniqueEqOp<word>()); Pstream::combineGather(cloudNames, ListOps::uniqueEqOp<word>());
Pstream::broadcast(cloudNames);
} }
Foam::sort(cloudNames); // Consistent order // Consistent order
Foam::sort(cloudNames);
for (const word& cloudName : cloudNames) for (const word& cloudName : cloudNames)
{ {
@ -64,7 +66,7 @@ if (doLagrangian)
isCloud = true; isCloud = true;
} }
if (!returnReduceOr(isCloud)) if (!returnReduce(isCloud, orOp<bool>()))
{ {
continue; continue;
} }
@ -76,7 +78,7 @@ if (doLagrangian)
); );
// Are there cloud fields (globally)? // Are there cloud fields (globally)?
if (returnReduceAnd(cloudObjs.empty())) if (returnReduce(cloudObjs.empty(), andOp<bool>()))
{ {
continue; continue;
} }

View File

@ -186,7 +186,7 @@ int main(int argc, char *argv[])
const label maxNProcs = returnReduce(maxIds.size(), maxOp<label>()); const label maxNProcs = returnReduce(maxIds.size(), maxOp<label>());
maxIds.resize(maxNProcs, -1); maxIds.resize(maxNProcs, -1);
Pstream::listCombineReduce(maxIds, maxEqOp<label>()); Pstream::listCombineAllGather(maxIds, maxEqOp<label>());
// From ids to count // From ids to count
const labelList numIds = maxIds + 1; const labelList numIds = maxIds + 1;

View File

@ -77,7 +77,8 @@ Foam::label Foam::particleTracksSampler::setTrackFields
if (Pstream::parRun()) if (Pstream::parRun())
{ {
Pstream::combineReduce(fieldNames, ListOps::uniqueEqOp<word>()); Pstream::combineGather(fieldNames, ListOps::uniqueEqOp<word>());
Pstream::broadcast(fieldNames);
} }
for (const word& fieldName : fieldNames) for (const word& fieldName : fieldNames)

View File

@ -15,5 +15,10 @@ wordRes acceptFields(propsDict.get<wordRes>("fields"));
wordRes excludeFields; wordRes excludeFields;
propsDict.readIfPresent("exclude", excludeFields); propsDict.readIfPresent("exclude", excludeFields);
const dictionary formatOptions
(
propsDict.subOrEmptyDict("formatOptions", keyType::LITERAL)
);
// ************************************************************************* // // ************************************************************************* //

View File

@ -6,7 +6,6 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2022 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -69,7 +68,7 @@ void Foam::channelIndex::walkOppositeFaces
blockedFace[facei] = true; blockedFace[facei] = true;
} }
while (returnReduceOr(frontFaces.size())) while (returnReduce(frontFaces.size(), sumOp<label>()) > 0)
{ {
// Transfer across. // Transfer across.
boolList isFrontBndFace(nBnd, false); boolList isFrontBndFace(nBnd, false);

View File

@ -40,7 +40,7 @@ Foam::Field<T> Foam::channelIndex::regionSum(const Field<T>& cellField) const
} }
// Global sum // Global sum
Pstream::listCombineReduce(regionField, plusEqOp<T>()); Pstream::listCombineAllGather(regionField, plusEqOp<T>());
return regionField; return regionField;
} }

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2015 OpenFOAM Foundation Copyright (C) 2011-2015 OpenFOAM Foundation
Copyright (C) 2016-2022 OpenCFD Ltd. Copyright (C) 2016-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -127,7 +127,7 @@ int main(int argc, char *argv[])
IOdictionary dict(dictIO); IOdictionary dict(dictIO);
autoPtr<noiseModel> model(noiseModel::New(dict, runTime)); autoPtr<noiseModel> model(noiseModel::New(dict));
model->calculate(); model->calculate();
Info<< nl << "End\n" << endl; Info<< nl << "End\n" << endl;

View File

@ -193,14 +193,14 @@ int main(int argc, char* argv[])
const labelRange origBlocks(0, obstacles.size()); const labelRange origBlocks(0, obstacles.size());
// Intersection blockage // Intersection blockage
labelRange interBlocks(origBlocks.end_value(), 0); labelRange interBlocks(origBlocks.after(), 0);
scalar volSubtract = 0; scalar volSubtract = 0;
// Do binary intersections between blocks and cylinders (or diag-beam) // Do binary intersections between blocks and cylinders (or diag-beam)
// by creating -ve blocks at the overlap // by creating -ve blocks at the overlap
labelRange int1Blocks(origBlocks.end_value(), 0); labelRange int1Blocks(origBlocks.after(), 0);
if (pars.overlaps % 2 > 0) if (pars.overlaps % 2 > 0)
{ {
@ -219,7 +219,7 @@ int main(int argc, char* argv[])
// Do binary intersections between blocks // Do binary intersections between blocks
// by creating -ve blocks at the overlap // by creating -ve blocks at the overlap
labelRange int2Blocks(int1Blocks.end_value(), 0); labelRange int2Blocks(int1Blocks.after(), 0);
if (pars.overlaps % 4 > 1) if (pars.overlaps % 4 > 1)
{ {
Info<< " block/block intersections" << endl; Info<< " block/block intersections" << endl;
@ -237,7 +237,7 @@ int main(int argc, char* argv[])
// Correct for triple intersections // Correct for triple intersections
// by looking for overlaps between the -ve blocks just created // by looking for overlaps between the -ve blocks just created
labelRange int3Blocks(int2Blocks.end_value(), 0); labelRange int3Blocks(int2Blocks.after(), 0);
if (pars.overlaps % 8 > 3) if (pars.overlaps % 8 > 3)
{ {
Info<< " triple intersections" << endl; Info<< " triple intersections" << endl;

View File

@ -223,7 +223,7 @@ void Foam::solverTemplate::setRegionProperties
fieldDimensions_[regionI].set fieldDimensions_[regionI].set
( (
i, i,
new dimensionSet("dimensions", dict) new dimensionSet(dict, "dimensions")
); );
} }
} }

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2019-2022 OpenCFD Ltd. Copyright (C) 2019-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -238,7 +238,7 @@ void rewriteBoundary
patches.reorder(oldToNew); patches.reorder(oldToNew);
if (returnReduceOr(nOldCyclics)) if (returnReduce(nOldCyclics, sumOp<label>()) > 0)
{ {
if (dryrun) if (dryrun)
{ {
@ -299,7 +299,7 @@ void rewriteField
dictionary& boundaryField = fieldDict.subDict("boundaryField"); dictionary& boundaryField = fieldDict.subDict("boundaryField");
bool hasChange = false; label nChanged = 0;
forAllConstIters(thisNames, iter) forAllConstIters(thisNames, iter)
{ {
@ -337,13 +337,13 @@ void rewriteField
); );
Info<< " Adding entry " << nbrNames[patchName] << endl; Info<< " Adding entry " << nbrNames[patchName] << endl;
hasChange = true; nChanged++;
} }
} }
//Info<< "New boundaryField:" << boundaryField << endl; //Info<< "New boundaryField:" << boundaryField << endl;
if (returnReduceOr(hasChange)) if (returnReduce(nChanged, sumOp<label>()) > 0)
{ {
if (dryrun) if (dryrun)
{ {

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2018-2022 OpenCFD Ltd. Copyright (C) 2018-2019 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -113,9 +113,10 @@ void mapLagrangian(const meshToMesh& interp)
if if
( (
returnReduceOr returnReduce
( (
objects.found("coordinates") || objects.found("positions") (objects.found("coordinates") || objects.found("positions")),
orOp<bool>()
) )
) )
{ {

View File

@ -60,16 +60,18 @@ int main(int argc, char *argv[])
) )
).subDict("volumetricBSplinesMotionSolverCoeffs") ).subDict("volumetricBSplinesMotionSolverCoeffs")
); );
// Read box names and allocate size
wordList controlBoxes(NURBSdict.toc());
for (const entry& dEntry : NURBSdict) for (const word& boxName : controlBoxes)
{ {
if (dEntry.isDict()) if (NURBSdict.isDict(boxName))
{ {
// Creating an object writes the control points in the // Creating an object writes the control points in the
// constructor // constructor
(void) NURBS3DVolume::New NURBS3DVolume::New
( (
dEntry.dict(), NURBSdict.subDict(boxName),
mesh, mesh,
false // do not compute parametric coordinates false // do not compute parametric coordinates
); );

View File

@ -232,7 +232,15 @@ int main(int argc, char *argv[])
dictionary& patchDict = boundaryFieldDict.subDict(patchName); dictionary& patchDict = boundaryFieldDict.subDict(patchName);
expressions::exprString valueExpr_("expression", currDict); auto valueExpr_
(
expressions::exprString::getEntry
(
"expression",
currDict,
true // strip comments
)
);
Info<< "Set boundaryField/" << patchName << '/' Info<< "Set boundaryField/" << patchName << '/'
<< targetName << nl << targetName << nl

View File

@ -560,6 +560,7 @@ int main(int argc, char *argv[])
" (command-line operation)", " (command-line operation)",
true // Advanced option true // Advanced option
); );
argList::addOptionCompat("dimensions", {"dimension", 2012});
argList::addBoolOption argList::addBoolOption
( (
@ -770,7 +771,11 @@ int main(int argc, char *argv[])
ctrl.streamOpt.format(IOstreamOption::ASCII); ctrl.streamOpt.format(IOstreamOption::ASCII);
} }
expressions::exprString valueExpr_(args["expression"]); expressions::exprString valueExpr_
(
args["expression"],
dictionary::null
);
expressions::exprString maskExpr_; expressions::exprString maskExpr_;
args.readIfPresent("field-mask", maskExpr_); args.readIfPresent("field-mask", maskExpr_);
@ -855,7 +860,14 @@ int main(int argc, char *argv[])
const word fieldName(dict.get<word>("field")); const word fieldName(dict.get<word>("field"));
expressions::exprString valueExpr_("expression", dict); auto valueExpr_
(
expressions::exprString::getEntry
(
"expression",
dict
)
);
expressions::exprString maskExpr_; expressions::exprString maskExpr_;
{ {
@ -872,11 +884,18 @@ int main(int argc, char *argv[])
} }
} }
// Optional: "dimensions"
dimensionSet dims; dimensionSet dims;
if (dims.readEntry("dimensions", dict, false))
{ {
ctrl.hasDimensions = true; const entry* dimPtr = dict.findCompat
(
"dimensions", {{"dimension", 2012}},
keyType::LITERAL
);
if (dimPtr)
{
dimPtr->stream() >> dims;
}
ctrl.hasDimensions = bool(dimPtr);
} }
if (args.verbose() && !timei) if (args.verbose() && !timei)

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