Compare commits

..

28 Commits

Author SHA1 Message Date
c3aecfab81 WIP: fv fields 2023-03-09 17:55:32 +00:00
e655231e24 WIP ENH: base infrastructure for label point fields 2023-03-09 17:55:32 +00:00
7cf553ca00 WIP ENH: core-level definitions for geometric label fields
- this are to be used for bookkeeping purposes, not to solve on
2023-03-09 17:55:32 +00:00
64d1bd7488 WIP: edge field 2023-03-09 17:55:32 +00:00
ce602d340b WIP area fields 2023-03-09 17:55:32 +00:00
64e5b7f626 WIP: surface (fvs) fields 2023-03-09 17:55:32 +00:00
b36c9897b2 ...ENH: base support for volume label fields
- for bookkeeping purposes (not to solve on), and thus only basic
  types: (calculated empty processor symmetry zeroGradient)
2023-03-09 17:55:32 +00:00
e505abfb30 ENH: base support for point label fields
- for bookkeeping purposes (not to solve on), and thus only basic
  types: (calculated empty processor symmetry zeroGradient)
2023-03-09 17:55:32 +00:00
2ec8a44fad WIP: uniformMixed + finiteArea uniformFixedGradient 2023-03-09 17:55:32 +00:00
2ea26ffadf ENH: remove specialisations for scalar symmetry/transform patch fields
- previously used template specialisations, but now simply check
  pTrait<Type>::rank == 0. This aids for future extension to support
  other scalar-like fields.
2023-03-09 17:55:32 +00:00
20566a87f5 ENH: provide getter/setter interface to standard communicators
- similar to UPstream::parRun(), the setter returns the previous value.

  The accessors are prefixed with 'comm':
  Eg, commGlobal(), commWarn(), commWorld(), commSelf().
  This distinguishes them from any existing variables (eg, worldComm)
  and arguably more similar to MPI_COMM_WORLD etc...

  If demand-driven communicators are added in the future, the function
  call syntax can help encapsulate that.

  Previously:

      const label oldWarnComm = UPstream::warnComm;
      const label oldWorldComm = UPstream::worldComm;
      UPstream::warnComm = myComm;
      UPstream::worldComm = myComm;
      ...

      UPstream::warnComm = oldWarnComm;
      UPstream::worldComm = oldWorldComm;

  Now:
      const label oldWarnComm = UPstream::commWarn(myComm);
      const label oldWorldComm = UPstream::commWorld(myComm);
      ...

      UPstream::commWarn(oldWarnComm);
      UPstream::commWorld(oldWorldComm);

STYLE: check (warnComm >= 0) instead of (warnComm != -1)
2023-03-09 16:01:04 +00:00
06df44a588 COMP: protect against null tmp field (freestream BC) 2023-03-09 09:43:29 +00:00
b519a8e128 ENH: add finite-area uniformFixedValue
- deprecate timeVaryingUniformFixed (now redundant)
2023-03-08 15:32:34 +00:00
26400d7534 ENH: add finite-area extrapolatedCalculated BC 2023-03-08 15:31:01 +00:00
b17422ef1a ENH: use readValueEntry, readMixedEntries for simpler program control 2023-03-08 15:30:04 +00:00
42dba36832 ENH: consistent handling of "value" for faePatchField
- base level now explicity equivalent to LAZY_READ with overriding as
  required

- clearer documentation for reading of "value" for faPatchField
2023-03-08 12:02:41 +00:00
063227baed ENH: support readOption handling for patch fields (base level)
- constructing with valueRequired as a bool is still supported,
  but now also support more refined requirements
  (eg, NO_READ, MUST_READ, LAZY_READ)

- continue with LAZY_READ for finite-area fields
2023-03-07 17:24:28 +00:00
7e9b5dbc78 TUT: adjust height limiter and outflow BC for drippingChair 2023-03-03 20:55:10 +01:00
94df19a93a ENH: add finiteArea outletInlet patch type
STYLE: use readValueEntry and Field assign to simplify code
2023-03-03 18:53:58 +01:00
2ef89bf9d3 Merge branch 'primitiveMeshOptimization' into 'develop'
ENH: improved point-cell and cell-point topology methods (#2715)

See merge request Development/openfoam!597
2023-03-03 16:36:55 +00:00
074749a722 ENH: improved point-cell and cell-point topology methods (#2715) 2023-03-03 16:36:54 +00:00
820f93c3b4 ENH: simplify box mesh construction (PDRblockMesh)
ENH: construct or reset boundBox from zero_one for a 0-1 unit cube

ENH: add some testing timings (for !596 and #2715)
2023-03-03 16:23:42 +01:00
4dff2bfad1 STYLE: PtrList emplace_set for symmetry with HashPtrTable method naming 2023-03-03 12:17:25 +01:00
d5c0852de1 ENH: improve diagnostic fields for checkFaMesh -write-vtk
ENH: support VTK output of procIDs for point data for some writers

TUT: areaWrite for drippingChair
2023-03-02 20:50:52 +01:00
4284d02c99 CONFIG: accept -decompose-dict=xyz for Run functions and mpirunDebug
- interpret as '-decomposeParDict xyz' for simpler scripting:
  A empty value ("") as well as "none" or "false" values are ignored.

  Eg,
      unset decompDict
      if some_condition; then decompDict=decomposeParDict-12; fi

      runParallel -decompose-dict=$decompDict ...

ENH: more generous when scanning decomposeParDict for numberOfSubdomains

- assume file is in system/ directory if not otherwise found
2023-03-02 20:50:52 +01:00
82c0b360c6 ENH: support run-time PstreamBuffers algorithm selection (advanced option)
- this helps isolate selection of PEX vs NBX, for potential migration
  to a hybrid PEX
2023-03-02 20:50:48 +01:00
99bf27cbee STYLE: use PstreamBuffers allProcs() addressing in zoneDistribute
STYLE: more generous handling of procIDs on non-master (globalIndex)
2023-03-02 15:31:50 +01:00
d3867a2d34 SUBMODULE: minor updates for external-solver 2023-03-02 12:37:06 +01:00
372 changed files with 6045 additions and 2306 deletions

View File

@ -103,14 +103,7 @@ Foam::smoluchowskiJumpTFvPatchScalarField::smoluchowskiJumpTFvPatchScalarField
<< exit(FatalIOError);
}
if (dict.found("value"))
{
fvPatchField<scalar>::operator=
(
scalarField("value", dict, p.size())
);
}
else
if (!this->readValueEntry(dict))
{
fvPatchField<scalar>::operator=(patchInternalField());
}

View File

@ -105,18 +105,15 @@ Foam::maxwellSlipUFvPatchVectorField::maxwellSlipUFvPatchVectorField
<< exit(FatalIOError);
}
if (dict.found("value"))
if (this->readValueEntry(dict))
{
fvPatchField<vector>::operator=
(
vectorField("value", dict, p.size())
);
const auto* hasRefValue = dict.findEntry("refValue", keyType::LITERAL);
const auto* hasFrac = dict.findEntry("valueFraction", keyType::LITERAL);
if (dict.found("refValue") && dict.found("valueFraction"))
if (hasRefValue && hasFrac)
{
this->refValue() = vectorField("refValue", dict, p.size());
this->valueFraction() =
scalarField("valueFraction", dict, p.size());
this->refValue().assign(*hasRefValue, p.size());
this->valueFraction().assign(*hasFrac, p.size());
}
else
{

View File

@ -243,14 +243,12 @@ turbulentTemperatureTwoPhaseRadCoupledMixedFvPatchScalarField
<< exit(FatalError);
}
fvPatchScalarField::operator=(scalarField("value", dict, p.size()));
if (dict.found("refValue"))
this->readValueEntry(dict, IOobjectOption::MUST_READ);
if (this->readMixedEntries(dict))
{
// Full restart
refValue() = scalarField("refValue", dict, p.size());
refGrad() = scalarField("refGradient", dict, p.size());
valueFraction() = scalarField("valueFraction", dict, p.size());
}
else
{

View File

@ -143,7 +143,7 @@ int main(int argc, char *argv[])
{
#include "setRootCase.H"
treeBoundBox bb(cube(0, 1));
treeBoundBox bb(zero_one{});
treeBoundBox sub(cube(0.1, 0.8));
Info<< nl

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2022 OpenCFD Ltd.
Copyright (C) 2022-2023 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -51,7 +51,7 @@ void printInfo(const label comm)
<< " sub:" << UPstream::subProcs(comm) << nl;
if (UPstream::selfComm == comm)
if (UPstream::commSelf() == comm)
{
Pout<< "self all:" << UPstream::allProcs(comm)
<< " sub:" << UPstream::subProcs(comm) << nl;
@ -86,32 +86,32 @@ int main(int argc, char *argv[])
<< "nProcs = " << UPstream::nProcs()
<< " with " << UPstream::nComms() << " predefined comm(s)" << nl;
Info<< "worldComm : ";
printInfo(UPstream::worldComm);
Info<< "comm-world : ";
printInfo(UPstream::commWorld());
Info<< "selfComm : ";
printInfo(UPstream::selfComm);
Info<< "comm-self : ";
printInfo(UPstream::commSelf());
Info<< nl;
// Reductions (using MPI intrinsics)
{
label val = Pstream::myProcNo(UPstream::worldComm);
label val = Pstream::myProcNo(UPstream::commWorld());
label worldVal = returnReduce
(
val,
sumOp<label>(),
Pstream::msgType(),
UPstream::worldComm
UPstream::msgType(),
UPstream::commWorld()
);
label selfVal = returnReduce
(
val,
sumOp<label>(),
Pstream::msgType(),
UPstream::selfComm
UPstream::msgType(),
UPstream::commSelf()
);
Pout<< "value " << val
@ -123,8 +123,8 @@ int main(int argc, char *argv[])
{
Pair<label> val
(
Pstream::myProcNo(UPstream::worldComm),
Pstream::myProcNo(UPstream::worldComm)
Pstream::myProcNo(UPstream::commWorld()),
Pstream::myProcNo(UPstream::commWorld())
);
Pair<label> worldVal = val;
@ -133,8 +133,8 @@ int main(int argc, char *argv[])
(
worldVal,
minFirstEqOp<label>(),
Pstream::msgType(),
UPstream::worldComm
UPstream::msgType(),
UPstream::commWorld()
);
Pair<label> selfVal = val;
@ -143,8 +143,8 @@ int main(int argc, char *argv[])
(
worldVal,
minFirstEqOp<label>(),
Pstream::msgType(),
UPstream::selfComm
UPstream::msgType(),
UPstream::commSelf()
);
Pout<< "value " << val

View File

@ -150,11 +150,7 @@ int main(int argc, char *argv[])
Pout<< "localValue :" << localValue << endl;
label comm = Pstream::allocateCommunicator
(
UPstream::worldComm,
top
);
label comm = UPstream::allocateCommunicator(UPstream::worldComm, top);
Pout<< "allocated comm :" << comm << endl;
Pout<< "comm myproc :" << Pstream::myProcNo(comm)
@ -173,7 +169,7 @@ int main(int argc, char *argv[])
Pout<< "sum :" << sum << endl;
}
Pstream::freeCommunicator(comm);
UPstream::freeCommunicator(comm);
Pout<< "End\n" << endl;

View File

@ -88,12 +88,12 @@ int main(int argc, char *argv[])
//- Process IDs within a given communicator
Info<< "procIDs: "
<< flatOutput(UPstream::procID(UPstream::worldComm)) << endl;
<< flatOutput(UPstream::procID(UPstream::commWorld())) << endl;
rankInfo(UPstream::worldComm);
rankInfo(UPstream::commWorld());
Pout<< endl;
const int myProci = UPstream::myProcNo(UPstream::worldComm);
const int myProci = UPstream::myProcNo(UPstream::commWorld());
int localRanki = myProci;
labelList subRanks;
@ -101,9 +101,9 @@ int main(int argc, char *argv[])
#if 1
// With first ranks
subRanks = identity(UPstream::nProcs(UPstream::worldComm) / 2);
subRanks = identity(UPstream::nProcs(UPstream::commWorld()) / 2);
newComm.reset(UPstream::worldComm, subRanks);
newComm.reset(UPstream::commWorld(), subRanks);
localRanki = UPstream::myProcNo(newComm);
Pout.prefix() =
@ -120,14 +120,14 @@ int main(int argc, char *argv[])
#if 1
// With every other rank
subRanks = identity(UPstream::nProcs(UPstream::worldComm));
subRanks = identity(UPstream::nProcs(UPstream::commWorld()));
for (label& val : subRanks)
{
if (val % 2) val = -1;
}
newComm.reset(UPstream::worldComm, subRanks);
newComm.reset(UPstream::commWorld(), subRanks);
localRanki = UPstream::myProcNo(newComm);
Pout.prefix() =
@ -165,19 +165,19 @@ int main(int argc, char *argv[])
}
if (Pstream::parRun() && args.found("host-comm"))
{
// Host communicator, based on the current worldComm
// Host communicator, based on the current world communicator
// Use hostname
// Lowest rank per hostname is the IO rank
label numprocs = UPstream::nProcs(UPstream::globalComm);
label numprocs = UPstream::nProcs(UPstream::commGlobal());
stringList hosts(numprocs);
hosts[Pstream::myProcNo(UPstream::globalComm)] = hostName();
hosts[Pstream::myProcNo(UPstream::commGlobal())] = hostName();
labelList hostIDs_;
// Compact
if (Pstream::master(UPstream::globalComm))
if (Pstream::master(UPstream::commGlobal()))
{
DynamicList<word> hostNames(numprocs);
hostIDs_.resize_nocopy(numprocs);
@ -196,10 +196,10 @@ int main(int argc, char *argv[])
}
}
Pstream::broadcasts(UPstream::globalComm, hostIDs_);
Pstream::broadcasts(UPstream::commGlobal(), hostIDs_);
const label myHostId =
hostIDs_[Pstream::myProcNo(UPstream::globalComm)];
hostIDs_[Pstream::myProcNo(UPstream::commGlobal())];
DynamicList<label> subRanks;
forAll(hostIDs_, proci)
@ -210,11 +210,11 @@ int main(int argc, char *argv[])
}
}
// Allocate new communicator with globalComm as its parent
// Allocate new communicator with global communicator as its parent
const label hostComm =
UPstream::allocateCommunicator
(
UPstream::globalComm, // parent
UPstream::commGlobal(),
subRanks,
true
);

View File

@ -39,7 +39,6 @@ Description
int main(int argc, char *argv[])
{
#include "setRootCase.H"
#include "createTime.H"
@ -47,11 +46,42 @@ int main(int argc, char *argv[])
const pointMesh& pMesh = pointMesh::New(mesh);
#if 1
pointLabelField state
(
IOobject
(
"test-state",
runTime.timeName(),
mesh,
IOobject::MUST_READ,
IOobject::AUTO_WRITE
),
pMesh
);
#else
pointLabelField state
(
IOobject
(
"test-state",
runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::AUTO_WRITE
),
pMesh,
dimensioned<label>(dimLength, 1),
pointPatchLabelField::calculatedType()
);
state.write();
#endif
pointVectorField U
(
IOobject
(
"U",
"test-U",
runTime.timeName(),
mesh,
IOobject::NO_READ,
@ -62,6 +92,8 @@ int main(int argc, char *argv[])
pointPatchVectorField::calculatedType()
);
U.write();
pointVectorField V(U + 2*U);
Info<< "End\n" << endl;

View File

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

View File

@ -0,0 +1,5 @@
EXE_INC = \
-I$(LIB_SRC)/mesh/blockMesh/lnInclude
EXE_LIBS = \
-lblockMesh

View File

@ -0,0 +1,804 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2023 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Description
Simple timing tests for some polyMesh primitives
\*---------------------------------------------------------------------------*/
#include "argList.H"
#include "clockTime.H"
#include "Time.H"
#include "PDRblock.H"
#include "polyMesh.H"
#include "ListOps.H"
using namespace Foam;
void printAlloc(const polyMesh& mesh)
{
Info<< "memory"
<< " hasCellPoints:" << mesh.hasCellPoints()
<< " hasPointCells:" << mesh.hasPointCells() << endl;
}
void printInfo(const polyMesh& mesh)
{
Info<< "polyMesh"
<< " nPoints:" << mesh.nPoints()
<< " nInternalFaces:" << mesh.nInternalFaces()
<< " nFaces:" << mesh.nFaces()
<< " nCells:" << mesh.nCells() << endl;
}
// How point cells are calculated in OpenFOAM-v2212 and earlier
autoPtr<labelListList> pointCells_2212(const polyMesh& mesh)
{
const cellList& cf = mesh.cells();
// Count number of cells per point
labelList npc(mesh.nPoints(), Zero);
forAll(cf, celli)
{
const labelList curPoints = cf[celli].labels(mesh.faces());
for (const label pointi : curPoints)
{
++npc[pointi];
}
}
// Size and fill cells per point
auto pcPtr_ = autoPtr<labelListList>::New(npc.size());
labelListList& pointCellAddr = *pcPtr_;
forAll(pointCellAddr, pointi)
{
pointCellAddr[pointi].setSize(npc[pointi]);
npc[pointi] = 0;
}
forAll(cf, celli)
{
const labelList curPoints = cf[celli].labels(mesh.faces());
for (const label pointi : curPoints)
{
pointCellAddr[pointi][npc[pointi]++] = celli;
}
}
return pcPtr_;
}
// Line cell::labels but with persistent storage
void cell_labels
(
const cell& cFaces,
const faceUList& meshFaces,
DynamicList<label>& pointLabels
)
{
// const labelList& cFaces = *this;
label nVerts = 0;
for (const label facei : cFaces)
{
nVerts += meshFaces[facei].size();
}
// pointLabels.clear();
pointLabels.expandStorage();
// The first face has no duplicates, can copy in values
const labelList& firstFace = meshFaces[cFaces[0]];
std::copy(firstFace.cbegin(), firstFace.cend(), pointLabels.begin());
// Now already contains some vertices
nVerts = firstFace.size();
// For the rest of the faces. For each vertex, check if the point is
// already inserted (up to nVerts, which now carries the number of real
// points. If not, add it at the end of the list.
for (label facei = 1; facei < cFaces.size(); ++facei)
{
for (const label curPoint : meshFaces[cFaces[facei]])
{
bool pointFound = false;
for (label checki = 0; checki < nVerts; ++checki)
{
if (curPoint == pointLabels[checki])
{
pointFound = true;
break;
}
}
if (!pointFound)
{
pointLabels[nVerts] = curPoint;
++nVerts;
}
}
}
pointLabels.resize(nVerts);
}
// Like OpenFOAM-v2212, but with cell::labels unrolled to avoid allocations
autoPtr<labelListList> pointCells_2212mod(const polyMesh& mesh)
{
const cellList& cf = mesh.cells();
// Vertex labels for the current cell
DynamicList<label> vertices(256);
// Count number of cells per point
labelList npc(mesh.nPoints(), Zero);
for (const cell& c : cf)
{
cell_labels(c, mesh.faces(), vertices);
for (const label pointi : vertices)
{
++npc[pointi];
}
}
// Size and fill cells per point
auto pcPtr_ = autoPtr<labelListList>::New(npc.size());
labelListList& pointCellAddr = *pcPtr_;
forAll(pointCellAddr, pointi)
{
pointCellAddr[pointi].resize(npc[pointi]);
npc[pointi] = 0;
}
forAll(cf, celli)
{
cell_labels(cf[celli], mesh.faces(), vertices);
for (const label pointi : vertices)
{
pointCellAddr[pointi][npc[pointi]++] = celli;
}
}
return pcPtr_;
}
// How cells points are calculated in OpenFOAM-v2212 and earlier
autoPtr<labelListList> cellPoints_2212(const polyMesh& mesh)
{
autoPtr<labelListList> pointCells = pointCells_2212(mesh);
auto cpPtr_ = autoPtr<labelListList>::New(mesh.nCells());
invertManyToMany(mesh.nCells(), pointCells(), *cpPtr_);
return cpPtr_;
}
// Calculate with bitSet tracking and avoid cells::labels
autoPtr<labelListList> pointCells_bitSet(const polyMesh& mesh)
{
// Calculate point-cell topology
const cellList& cellLst = mesh.cells();
const faceList& faceLst = mesh.faces();
// For tracking (only use each point id once)
bitSet usedPoints(mesh.nPoints());
// Vertex labels for the current cell
DynamicList<label> vertices(256);
const label loopLen = mesh.nCells();
// Step 1: count number of cells per point
labelList pointCount(mesh.nPoints(), Zero);
for (label celli = 0; celli < loopLen; ++celli)
{
// Clear any previous contents
usedPoints.unset(vertices);
vertices.clear();
for (const label facei : cellLst[celli])
{
for (const label pointi : faceLst[facei])
{
// Only once for each point id
if (usedPoints.set(pointi))
{
vertices.push_back(pointi);
++pointCount[pointi];
}
}
}
}
// Step 2: set sizing, reset counters
auto pcPtr_ = autoPtr<labelListList>::New(mesh.nPoints());
auto& pointCellAddr = *pcPtr_;
forAll(pointCellAddr, pointi)
{
pointCellAddr[pointi].resize_nocopy(pointCount[pointi]);
pointCount[pointi] = 0;
}
// Step 3: fill in values. Logic as per step 1
for (label celli = 0; celli < loopLen; ++celli)
{
// Clear any previous contents
usedPoints.unset(vertices);
vertices.clear();
for (const label facei : cellLst[celli])
{
for (const label pointi : faceLst[facei])
{
// Only once for each point id
if (usedPoints.set(pointi))
{
vertices.push_back(pointi);
pointCellAddr[pointi][pointCount[pointi]++] = celli;
}
}
}
}
return pcPtr_;
}
// Calculate with bitSet tracking and avoid cells::labels
autoPtr<labelListList> cellPoints_bitSet(const polyMesh& mesh)
{
// Calculate cell-point topology
auto cpPtr_ = autoPtr<labelListList>::New(mesh.nCells());
auto& cellPointAddr = *cpPtr_;
const cellList& cellLst = mesh.cells();
const faceList& faceLst = mesh.faces();
// For tracking (only use each point id once)
bitSet usedPoints(mesh.nPoints());
// Vertex labels for the current cell
DynamicList<label> vertices(256);
const label loopLen = mesh.nCells();
for (label celli = 0; celli < loopLen; ++celli)
{
// Clear any previous contents
usedPoints.unset(vertices);
vertices.clear();
for (const label facei : cellLst[celli])
{
for (const label pointi : faceLst[facei])
{
// Only once for each point id
if (usedPoints.set(pointi))
{
vertices.push_back(pointi);
}
}
}
cellPointAddr[celli] = vertices; // unsorted
}
return cpPtr_;
}
// Calculate with linear lookup and avoid cells::labels
autoPtr<labelListList> pointCells_linear(const polyMesh& mesh)
{
// Calculate point-cell topology
const cellList& cellLst = mesh.cells();
const faceList& faceLst = mesh.faces();
// Vertex labels for the current cell
DynamicList<label> vertices(256);
const label loopLen = mesh.nCells();
// Step 1: count number of cells per point
labelList pointCount(mesh.nPoints(), Zero);
for (label celli = 0; celli < loopLen; ++celli)
{
// Clear any previous contents
vertices.clear();
for (const label facei : cellLst[celli])
{
for (const label pointi : faceLst[facei])
{
// Only once for each point id
if (!vertices.contains(pointi))
{
vertices.push_back(pointi);
++pointCount[pointi];
}
}
}
}
// Step 2: set sizing, reset counters
auto pcPtr_ = autoPtr<labelListList>::New(mesh.nPoints());
auto& pointCellAddr = *pcPtr_;
forAll(pointCellAddr, pointi)
{
pointCellAddr[pointi].resize_nocopy(pointCount[pointi]);
pointCount[pointi] = 0;
}
// Step 3: fill in values. Logic as per step 1
for (label celli = 0; celli < loopLen; ++celli)
{
// Clear any previous contents
vertices.clear();
for (const label facei : cellLst[celli])
{
for (const label pointi : faceLst[facei])
{
// Only once for each point id
if (!vertices.contains(pointi))
{
vertices.push_back(pointi);
pointCellAddr[pointi][pointCount[pointi]++] = celli;
}
}
}
}
return pcPtr_;
}
// Calculate with linear lookup and avoid cells::labels
autoPtr<labelListList> cellPoints_linear(const polyMesh& mesh)
{
// Calculate cell-point topology
auto cpPtr_ = autoPtr<labelListList>::New(mesh.nCells());
auto& cellPointAddr = *cpPtr_;
const cellList& cellLst = mesh.cells();
const faceList& faceLst = mesh.faces();
// Vertex labels for the current cell
DynamicList<label> vertices(256);
const label loopLen = mesh.nCells();
for (label celli = 0; celli < loopLen; ++celli)
{
// Clear any previous contents
vertices.clear();
for (const label facei : cellLst[celli])
{
for (const label pointi : faceLst[facei])
{
// Only once for each point id
if (!vertices.contains(pointi))
{
vertices.push_back(pointi);
}
}
}
cellPointAddr[celli] = vertices; // unsorted
}
return cpPtr_;
}
// Calculate point-cell from point-face information
autoPtr<labelListList> pointCells_faces(const polyMesh& mesh)
{
const labelList& own = mesh.faceOwner();
const labelList& nei = mesh.faceNeighbour();
const labelListList& pFaces = mesh.pointFaces();
const label loopLen = mesh.nPoints();
auto pcPtr_ = autoPtr<labelListList>::New(mesh.nPoints());
auto& pointCellAddr = *pcPtr_;
DynamicList<label> storage(256);
for (label pointi = 0; pointi < loopLen; ++pointi)
{
// Clear any previous contents
storage.clear();
for (const label facei : pFaces[pointi])
{
// Owner cell
storage.push_back(own[facei]);
// Neighbour cell
if (facei < mesh.nInternalFaces())
{
storage.push_back(nei[facei]);
}
}
// Sort + unique to eliminate duplicates
std::sort(storage.begin(), storage.end());
auto last = std::unique(storage.begin(), storage.end());
storage.resize(label(last - storage.begin()));
pointCellAddr[pointi] = storage;
}
return pcPtr_;
}
// Calculate point-cell from point-face information
autoPtr<labelListList> pointCells_bitSet_faces(const polyMesh& mesh)
{
const labelList& own = mesh.faceOwner();
const labelList& nei = mesh.faceNeighbour();
const labelListList& pFaces = mesh.pointFaces();
const label loopLen = mesh.nPoints();
auto pcPtr_ = autoPtr<labelListList>::New(mesh.nPoints());
auto& pointCellAddr = *pcPtr_;
// For tracking (only use each cell id once)
bitSet usedCells(mesh.nCells());
DynamicList<label> storage(256);
for (label pointi = 0; pointi < loopLen; ++pointi)
{
// Clear any previous contents
usedCells.unset(storage);
storage.clear();
for (const label facei : pFaces[pointi])
{
// Owner cell - only once
if (usedCells.set(own[facei]))
{
storage.push_back(own[facei]);
}
// Neighbour cell
if (facei < mesh.nInternalFaces() && usedCells.set(nei[facei]))
{
storage.push_back(nei[facei]);
}
}
pointCellAddr[pointi] = storage;
}
return pcPtr_;
}
// Calculate point-cell from cell-point information
autoPtr<labelListList> pointCells_bitSet_alon(const polyMesh& mesh)
{
autoPtr<labelListList> cellPoints = cellPoints_bitSet(mesh);
auto pcPtr_ = autoPtr<labelListList>::New(mesh.nPoints());
invertManyToMany(mesh.nPoints(), cellPoints(), *pcPtr_);
return pcPtr_;
}
// Eliminate duplicates with sort+unique
autoPtr<labelListList> cellPoints_sorted(const polyMesh& mesh)
{
// Calculate cell-point topology
auto cpPtr_ = autoPtr<labelListList>::New(mesh.nCells());
auto& cellPointAddr = *cpPtr_;
const cellList& cellLst = mesh.cells();
const faceList& faceLst = mesh.faces();
// Vertex labels for the current cell
DynamicList<label> vertices(256);
const label loopLen = mesh.nCells();
for (label celli = 0; celli < loopLen; ++celli)
{
// Clear any previous contents
vertices.clear();
for (const label facei : cellLst[celli])
{
for (const label pointi : faceLst[facei])
{
vertices.push_back(pointi);
}
}
// Sort + unique to eliminate duplicates
std::sort(vertices.begin(), vertices.end());
auto last = std::unique(vertices.begin(), vertices.end());
vertices.resize(label(last - vertices.begin()));
cellPointAddr[celli] = vertices;
}
return cpPtr_;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Main program:
int main(int argc, char *argv[])
{
argList::noBanner();
argList::noParallel();
argList::noFunctionObjects();
argList::addOption("nCells", "number", "The number of cells");
#include "setRootCase.H"
const scalar cellCount(args.getOrDefault<scalar>("nCells", 1000));
const label nDivs(::round(::cbrt(cellCount)));
PDRblock blkMesh(boundBox(zero_one{}), labelVector::uniform(nDivs));
autoPtr<Time> dummyTimePtr(Time::New());
Info<< "Requested " << cellCount
<< " cells, blockMesh with " << blkMesh.nCells() << " cells" << nl;
autoPtr<polyMesh> meshPtr = blkMesh.innerMesh
(
IOobject
(
"Testing",
dummyTimePtr->system(),
*dummyTimePtr,
IOobject::NO_READ,
IOobject::NO_WRITE,
IOobject::NO_REGISTER
)
);
auto& mesh = meshPtr();
printInfo(mesh);
printAlloc(mesh);
clockTime timing;
// pointCells
{
mesh.clearOut();
timing.resetTime();
(void) mesh.pointCells();
Info<< "pointCells (builtin): " << timing.elapsedTime() << " s" << nl;
}
// cellPoints
{
mesh.clearOut();
timing.resetTime();
(void) mesh.cellPoints();
Info<< "cellPoints (builtin): " << timing.elapsedTime() << " s" << nl;
}
Info<< nl;
// pointCells
{
mesh.clearOut();
timing.resetTime();
(void) pointCells_2212(mesh);
Info<< "pointCells (2212): " << timing.elapsedTime() << " s" << nl;
}
{
mesh.clearOut();
timing.resetTime();
(void) pointCells_2212mod(mesh);
Info<< "pointCells (2212mod): " << timing.elapsedTime() << " s" << nl;
}
{
mesh.clearOut();
timing.resetTime();
(void) pointCells_bitSet(mesh);
Info<< "pointCells (bitSet): " << timing.elapsedTime() << " s" << nl;
}
{
mesh.clearOut();
timing.resetTime();
(void) pointCells_linear(mesh);
Info<< "pointCells (linear): " << timing.elapsedTime() << " s" << nl;
}
{
mesh.clearOut();
timing.resetTime();
(void) pointCells_faces(mesh);
Info<< "pointCells (faces): " << timing.elapsedTime() << " s" << nl;
}
{
mesh.clearOut();
timing.resetTime();
(void) pointCells_bitSet_faces(mesh);
Info<< "pointCells (bitSet faces): " << timing.elapsedTime() << " s" << nl;
}
{
mesh.clearOut();
timing.resetTime();
(void) pointCells_bitSet_alon(mesh);
Info<< "pointCells (bitSet alon): " << timing.elapsedTime() << " s" << nl;
}
// cellPoints
{
mesh.clearOut();
timing.resetTime();
(void) cellPoints_2212(mesh);
Info<< "cellPoints (2212): " << timing.elapsedTime() << " s" << nl;
}
{
mesh.clearOut();
timing.resetTime();
(void) cellPoints_bitSet(mesh);
Info<< "cellPoints (bitSet): " << timing.elapsedTime() << " s" << nl;
}
{
mesh.clearOut();
timing.resetTime();
(void) cellPoints_linear(mesh);
Info<< "cellPoints (linear): " << timing.elapsedTime() << " s" << nl;
}
{
mesh.clearOut();
timing.resetTime();
(void) cellPoints_sorted(mesh);
Info<< "cellPoints (sorted): " << timing.elapsedTime() << " s" << nl;
}
// With precalculated values
{
mesh.clearOut();
const auto& cp = mesh.cellPoints();
timing.resetTime();
auto pcPtr_ = autoPtr<labelListList>::New(mesh.nPoints());
invertManyToMany(mesh.nPoints(), cp, *pcPtr_);
Info<< "pointCells (from cached cellPoints): " << timing.elapsedTime() << " s" << nl;
}
// With precalculated values
{
mesh.clearOut();
(void)mesh.pointFaces();
timing.resetTime();
(void) pointCells_bitSet_faces(mesh);
Info<< "pointCells (bitSet from cached pointFaces): " << timing.elapsedTime() << " s" << nl;
}
// With precalculated values
{
mesh.clearOut();
const auto& pc = mesh.pointCells();
timing.resetTime();
auto cpPtr_ = autoPtr<labelListList>::New(mesh.nCells());
invertManyToMany(mesh.nCells(), pc, *cpPtr_);
Info<< "cellPoints (from cached pointCells): " << timing.elapsedTime() << " s" << nl;
}
// Re-measure timings
Info<< nl;
{
mesh.clearOut();
timing.resetTime();
(void) mesh.pointCells();
Info<< "pointCells (builtin): " << timing.elapsedTime() << " s" << nl;
}
{
mesh.clearOut();
timing.resetTime();
(void) mesh.cellPoints();
Info<< "cellPoints (builtin): " << timing.elapsedTime() << " s" << nl;
}
Info<< "\nEnd\n" << nl;
return 0;
}
// ************************************************************************* //

View File

@ -224,73 +224,21 @@ int main(int argc, char *argv[])
<< lerp(vector::uniform(0), vector::uniform(100), 0.5) << nl;
}
{
const lerpOp1<vector> half(0.5);
const vector a(vector::uniform(20));
const vector b(vector::uniform(100));
Info<< "lerp half: "
<< a << " : " << b << " => " << half(a, b) << nl;
}
{
const labelVector a(labelVector::uniform(10000));
const labelVector b(labelVector::uniform(1));
Info<< "lerp (labelVector) = "
Info<<"lerp (labelVector) = "
<< lerp(a, b, 0.1) << nl;
}
{
const scalar a(0);
const scalar b(100);
Info<< "lerp of " << a << " : " << b << nl;
for (const double t : { 0.0, 0.5, 1.0, -0.5, 1.5 })
{
Info<< " " << t << " = " << lerp(a, b, t) << nl;
}
}
// No yet
#if 0
{
const label a(10000);
const label b(1);
Info<<"lerp (label) = "
<< label(lerp(a, b, 0.1)) << nl;
}
{
const bool a(true);
const bool b(false);
Info<<"lerp (bool) = "
<< (lerp(a, b, 0.5)) << nl;
}
#endif
{
const sphericalTensor a(10), b(20);
Info<<"lerp exact: "
<< (a == lerp(a, b, 0.0f)) << " "
<< (b == lerp(a, b, 1.0f)) << nl;
// Info<< "lerp: "
// << lerp(vector::uniform(0), vector::uniform(100), 0.5) << nl;
}
{
const tensor a(tensor::uniform(1e24));
const tensor b(tensor::uniform(0));
Info<<"lerp exact: "
<< (a == lerp(a, b, 0.0f)) << " "
<< (b == lerp(a, b, 1.0f)) << nl;
//
// Info<< "lerp: "
// << lerp(vector::uniform(0), vector::uniform(100), 0.5) << nl;
}

View File

@ -88,8 +88,7 @@ int main(int argc, char *argv[])
// Info<<"tree-bb faces: " << treeBoundBox::faces << nl
// <<"tree-bb edges: " << treeBoundBox::edges << endl;
treeBoundBox bb;
bb = cube(0, 1);
treeBoundBox bb(zero_one{});
triPoints tri;
tri.a() = point(-0.1, 0.5, 0.5);

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2021-2022 OpenCFD Ltd.
Copyright (C) 2021-2023 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
@ -76,9 +76,9 @@ Description
writer.beginCellData(4);
writer.writeProcIDs();
{
// Use primitive patch order
Field<scalar> fld
(
// Use primitive patch order
faMeshTools::flattenEdgeField(aMesh.magLe(), true)
);
writer.write("magLe", fld);
@ -93,11 +93,17 @@ Description
}
{
const Field<vector> edgeCentres
(
// Use primitive patch order
faMeshTools::flattenEdgeField(aMesh.edgeCentres(), true)
);
// finiteArea - edgeCentres
// (no other convenient way to display vectors on the edges)
vtk::lineWriter writer
(
aMesh.edgeCentres(),
edgeCentres,
edgeList::null(),
// vtk::formatType::INLINE_ASCII,
fileName
@ -109,19 +115,20 @@ Description
writer.writeGeometry();
// PointData
writer.beginPointData(4);
writer.beginPointData(3);
writer.writeProcIDs(); // Unfortunately cannot threshold on points
{
// Use primitive patch order
Field<vector> fld
(
// Use primitive patch order
faMeshTools::flattenEdgeField(aMesh.Le(), true)
);
writer.write("Le", fld);
}
{
// Use primitive patch order
Field<vector> fld
(
// Use primitive patch order
faMeshTools::flattenEdgeField(aMesh.edgeAreaNormals(), true)
);
writer.write("normal", fld);

View File

@ -7,7 +7,7 @@
# \\/ M anipulation |
#------------------------------------------------------------------------------
# Copyright (C) 2011-2015 OpenFOAM Foundation
# Copyright (C) 2017-2021 OpenCFD Ltd.
# Copyright (C) 2017-2023 OpenCFD Ltd.
#------------------------------------------------------------------------------
# License
# This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
@ -45,6 +45,7 @@ options:
-local Same as -spawn=1
-remote Same as -spawn=2
-clean Remove old processor*.{log,sh} files, mpirun.schema etc
-decompose-dict=<file> Specific decomposeParDict name
-help Print the usage
Invoke mpirun with separate per-processor log files or running in
@ -111,7 +112,7 @@ Linux)
esac
unset appName appArgs nProcs
unset method spawn optClean
unset method spawn optClean optValue
optConfirm=true
decompDict="system/decomposeParDict"
@ -126,7 +127,7 @@ do
then
knownOption=true # Assume success
case "$1" in
'') ;; # ignore junk
('') ;; # Ignore junk
-clean) optClean=true ;;
-yes) unset optConfirm ;;
@ -173,14 +174,25 @@ do
shift
;;
(-decompose-dict=*)
optValue="${1#*=}"
case "$optValue" in
('' | none | false) ;; ## Ignore
(*)
decompDict="$optValue"
appArgs="${appArgs}${appArgs:+ }-decomposeParDict '$decompDict'"
;;
esac
;;
-decomposeParDict)
# Grab values and add to args immediately
decompDict="$2"
appArgs="${appArgs}${appArgs:+ }$1 '$2'"
shift
appArgs="${appArgs}${appArgs:+ }-decomposeParDict '$decompDict'"
;;
*)
(*)
knownOption=false # Fallthrough to regular processing
;;
esac
@ -192,23 +204,24 @@ do
fi
fi
# Processing application arguments
case "$1" in
-help* | --help*) usage ;;
'') ;; # ignore junk
(-help* | --help*) usage ;;
('') ;; ## Ignore junk
-np)
(-np)
nProcs="$2"
shift
;;
-decomposeParDict)
(-decomposeParDict)
# Grab values and add to args immediately
decompDict="$2"
appArgs="${appArgs}${appArgs:+ }$1 '$2'"
appArgs="${appArgs}${appArgs:+ }-decomposeParDict '$decompDict'"
shift
;;
*)
(*)
if [ -z "$appName" ]
then
appName="$1"

View File

@ -6,7 +6,7 @@
# \\/ M anipulation |
#------------------------------------------------------------------------------
# Copyright (C) 2011-2016 OpenFOAM Foundation
# Copyright (C) 2015-2022 OpenCFD Ltd.
# Copyright (C) 2015-2023 OpenCFD Ltd.
#------------------------------------------------------------------------------
# License
# This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
@ -180,6 +180,16 @@ getNumberOfProcessors()
{
local dict="${1:-system/decomposeParDict}"
case "$dict" in
(system/*) # Already qualified
;;
(*)
# If it does not exist, assume it refers to location in system/
[ -f "$dict" ] || dict="system/$dict"
;;
esac
# Re-use positional parameters for automatic whitespace elimination
set -- $(foamDictionary -entry numberOfSubdomains -value "$dict" 2>/dev/null)
@ -223,7 +233,7 @@ getApplication()
#
runApplication()
{
local appName appRun logFile logMode
local appName appRun optValue logFile logMode
# Any additional parsed arguments (eg, decomposeParDict)
local appArgs
@ -232,25 +242,39 @@ runApplication()
while [ "$#" -gt 0 ] && [ -z "$appRun" ]
do
case "$1" in
-a | -append)
logMode=append
;;
-o | -overwrite)
logMode=overwrite
;;
-s | -suffix)
logFile=".$2"
shift
;;
-decomposeParDict)
appArgs="$appArgs $1 $2"
shift
;;
'')
;;
*)
appRun="$1"
;;
('') ;; # Ignore junk
(-a | -append)
logMode=append
;;
(-o | -overwrite)
logMode=overwrite
;;
(-s | -suffix)
logFile=".$2"
shift
;;
(-decompose-dict=*)
optValue="${1#*=}"
case "$optValue" in
('' | none | false) ;; ## Ignore
(*) appArgs="$appArgs -decomposeParDict $optValue" ;;
esac
;;
(-decomposeParDict)
optValue="$2"
shift
case "$optValue" in
('' | none | false) ;; ## Ignore
(*) appArgs="$appArgs -decomposeParDict $optValue" ;;
esac
;;
(*)
appRun="$1"
;;
esac
shift
done
@ -280,7 +304,7 @@ runApplication()
#
runParallel()
{
local appName appRun logFile logMode nProcs
local appName appRun optValue logFile logMode nProcs
# Any additional parsed arguments (eg, decomposeParDict)
local appArgs="-parallel"
@ -295,30 +319,46 @@ runParallel()
while [ "$#" -gt 0 ] && [ -z "$appRun" ]
do
case "$1" in
-a | -append)
logMode=append
('') ;; # Ignore junk
(-a | -append)
logMode=append
;;
(-o | -overwrite)
logMode=overwrite
;;
(-s | -suffix)
logFile=".$2"
shift
;;
(-n | -np)
nProcs="$2"
shift
;;
(-decompose-dict=*)
optValue="${1#*=}"
case "$optValue" in
('' | none | false) ;; ## Ignore
(*)
appArgs="$appArgs -decomposeParDict $optValue"
nProcs="$(getNumberOfProcessors "$optValue")"
;;
-o | -overwrite)
logMode=overwrite
;;
-s | -suffix)
logFile=".$2"
shift
;;
-n | -np)
nProcs="$2"
shift
;;
-decomposeParDict)
appArgs="$appArgs $1 $2"
nProcs=$(getNumberOfProcessors "$2")
shift
;;
'')
;;
*)
appRun="$1"
esac
;;
(-decomposeParDict)
optValue="$2"
shift
case "$optValue" in
('' | none | false) ;; ## Ignore
(*)
appArgs="$appArgs -decomposeParDict $optValue"
nProcs="$(getNumberOfProcessors "$optValue")"
;;
esac
;;
(*)
appRun="$1"
;;
esac
shift
done

View File

@ -173,6 +173,10 @@ public:
//- (discard old element at that location).
//- Return reference to the new list element.
template<class... Args>
inline T& emplace_set(const label i, Args&&... args);
//- Same as emplace_set()
template<class... Args>
inline T& emplace(const label i, Args&&... args);
//- Set element to given pointer and return old element (can be null)

View File

@ -172,11 +172,17 @@ inline void Foam::PtrList<T>::push_back(PtrList<T>&& other)
template<class T>
template<class... Args>
inline T& Foam::PtrList<T>::emplace
(
const label i,
Args&&... args
)
inline T& Foam::PtrList<T>::emplace_set(const label i, Args&&... args)
{
T* ptr = new T(std::forward<Args>(args)...);
(void)this->set(i, ptr);
return *ptr;
}
template<class T>
template<class... Args>
inline T& Foam::PtrList<T>::emplace(const label i, Args&&... args)
{
T* ptr = new T(std::forward<Args>(args)...);
(void)this->set(i, ptr);

View File

@ -470,8 +470,7 @@ public:
// Exchange
//- Helper: exchange sizes of sendBufs for specified
//- set of send/receive processes.
//- Helper: exchange sizes of sendBufs for specified send/recv ranks
template<class Container>
static void exchangeSizes
(
@ -483,6 +482,17 @@ public:
const label comm = UPstream::worldComm
);
//- Helper: exchange sizes of sendBufs for specified neighbour ranks
template<class Container>
static void exchangeSizes
(
const labelUList& neighProcs,
const Container& sendBufs,
labelList& sizes,
const label tag = UPstream::msgType(),
const label comm = UPstream::worldComm
);
//- Helper: exchange sizes of sendBufs.
//- The sendBufs is the data per processor (in the communicator).
// Returns sizes of sendBufs on the sending processor.

View File

@ -28,6 +28,30 @@ License
#include "PstreamBuffers.H"
#include "bitSet.H"
#include "debug.H"
#include "registerSwitch.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
int Foam::PstreamBuffers::algorithm
(
// Not really the most creative name...
Foam::debug::optimisationSwitch("pbufs.algorithm", -1)
);
registerOptSwitch
(
"pbufs.algorithm",
int,
Foam::PstreamBuffers::algorithm
);
// Simple enumerations
// -------------------
static constexpr int algorithm_PEX_allToAll = -1; // OpenFOAM 2212 and earlier
//static constexpr int algorithm_PEX_hybrid = 0; // New default?
static constexpr int algorithm_full_NBX = 1; // Experimental
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
@ -43,9 +67,58 @@ void Foam::PstreamBuffers::finalExchange
if (commsType_ == UPstream::commsTypes::nonBlocking)
{
// Dense storage uses all-to-all
Pstream::exchangeSizes(sendBuffers_, recvSizes, comm_);
if
(
wait
&& (algorithm >= algorithm_full_NBX)
&& (UPstream::maxCommsSize <= 0)
)
{
// NBX algorithm (nonblocking exchange)
// - when requested and waiting, no data chunking etc
PstreamDetail::exchangeConsensus<DynamicList<char>, char>
(
sendBuffers_,
recvBuffers_,
recvSizes,
(tag_ + 271828), // some unique tag?
comm_,
wait
);
return;
}
// PEX algorithm with two different flavours of exchanging sizes
// Assemble the send sizes (cf. Pstream::exchangeSizes)
labelList sendSizes(nProcs_);
forAll(sendBuffers_, proci)
{
sendSizes[proci] = sendBuffers_[proci].size();
}
recvSizes.resize_nocopy(nProcs_);
if (algorithm == algorithm_PEX_allToAll)
{
// PEX stage 1: exchange sizes (all-to-all)
UPstream::allToAll(sendSizes, recvSizes, comm_);
}
else
{
// PEX stage 1: exchange sizes (non-blocking consensus)
UPstream::allToAllConsensus
(
sendSizes,
recvSizes,
(tag_ + 314159), // some unique tag?
comm_
);
}
// PEX stage 2: point-to-point data exchange
Pstream::exchange<DynamicList<char>, char>
(
sendBuffers_,
@ -73,6 +146,30 @@ void Foam::PstreamBuffers::finalExchange
if (commsType_ == UPstream::commsTypes::nonBlocking)
{
// Preparation. Temporarily abuse recvSizes as logic to clear
// send buffers that are not in the neighbourhood connection
{
recvSizes.resize_nocopy(nProcs_);
recvSizes = 0;
// Preserve self-send, even if not described by neighbourhood
recvSizes[UPstream::myProcNo(comm_)] = 1;
for (const label proci : sendProcs)
{
recvSizes[proci] = 1; // Connected
}
for (label proci=0; proci < nProcs_; ++proci)
{
if (!recvSizes[proci]) // Not connected
{
sendBuffers_[proci].clear();
}
}
}
// PEX stage 1: exchange sizes (limited neighbourhood)
Pstream::exchangeSizes
(
sendProcs,
@ -83,6 +180,7 @@ void Foam::PstreamBuffers::finalExchange
comm_
);
// PEX stage 2: point-to-point data exchange
Pstream::exchange<DynamicList<char>, char>
(
sendBuffers_,
@ -96,11 +194,10 @@ void Foam::PstreamBuffers::finalExchange
}
void Foam::PstreamBuffers::finalExchangeGatherScatter
void Foam::PstreamBuffers::finalGatherScatter
(
const bool isGather,
const bool wait,
const bool needSizes,
labelList& recvSizes
)
{
@ -133,6 +230,12 @@ void Foam::PstreamBuffers::finalExchangeGatherScatter
if (commsType_ == UPstream::commsTypes::nonBlocking)
{
// Use PEX algorithm
// - for a non-sparse gather/scatter, it is presumed that
// MPI_Gather/MPI_Scatter will be the most efficient way to
// communicate the sizes.
// PEX stage 1: exchange sizes (gather or scatter)
if (isGather)
{
// gather mode (all-to-one): master [0] <- everyone
@ -166,7 +269,7 @@ void Foam::PstreamBuffers::finalExchangeGatherScatter
recvSizes[0] = myRecv;
}
// PEX stage 2: point-to-point data exchange
Pstream::exchange<DynamicList<char>, char>
(
sendBuffers_,
@ -378,7 +481,7 @@ Foam::label Foam::PstreamBuffers::recvDataCount(const label proci) const
Foam::labelList Foam::PstreamBuffers::recvDataCounts() const
{
labelList counts(recvPositions_.size(), Zero);
labelList counts(nProcs_, Zero);
if (finishedSendsCalled_)
{
@ -404,17 +507,20 @@ Foam::labelList Foam::PstreamBuffers::recvDataCounts() const
}
Foam::label Foam::PstreamBuffers::maxNonLocalRecvCount(const label proci) const
Foam::label Foam::PstreamBuffers::maxNonLocalRecvCount
(
const label excludeProci
) const
{
label maxLen = 0;
if (finishedSendsCalled_)
{
forAll(recvBuffers_, idx)
forAll(recvBuffers_, proci)
{
const label len(recvBuffers_[idx].size() - recvPositions_[idx]);
if (idx != proci)
if (excludeProci != proci)
{
label len(recvBuffers_[proci].size() - recvPositions_[proci]);
maxLen = max(maxLen, len);
}
}
@ -494,6 +600,9 @@ void Foam::PstreamBuffers::finishedSends
const bool wait
)
{
// Resize for copying back
recvSizes.resize_nocopy(sendBuffers_.size());
finalExchange(wait, recvSizes);
if (commsType_ != UPstream::commsTypes::nonBlocking)
@ -510,39 +619,25 @@ void Foam::PstreamBuffers::finishedSends
}
void Foam::PstreamBuffers::finishedSends
void Foam::PstreamBuffers::finishedNeighbourSends
(
const labelUList& sendProcs,
const labelUList& recvProcs,
const bool wait
)
{
labelList recvSizes;
finalExchange(sendProcs, recvProcs, wait, recvSizes);
}
void Foam::PstreamBuffers::finishedSends
(
const labelUList& sendProcs,
const labelUList& recvProcs,
const labelUList& neighProcs,
labelList& recvSizes,
const bool wait
)
{
finalExchange(sendProcs, recvProcs, wait, recvSizes);
finalExchange(neighProcs, neighProcs, wait, recvSizes);
}
if (commsType_ != UPstream::commsTypes::nonBlocking)
{
FatalErrorInFunction
<< "Obtaining sizes not supported in "
<< UPstream::commsTypeNames[commsType_] << endl
<< " since transfers already in progress. Use non-blocking instead."
<< exit(FatalError);
// Note: maybe possible only if using different tag from write started
// by ~UOPstream. Needs some work.
}
void Foam::PstreamBuffers::finishedNeighbourSends
(
const labelUList& neighProcs,
const bool wait
)
{
labelList recvSizes;
finalExchange(neighProcs, neighProcs, wait, recvSizes);
}
@ -562,10 +657,8 @@ bool Foam::PstreamBuffers::finishedSends
}
// Update send connections
// - reasonable to assume there are no self-sends on UPstream::myProcNo
forAll(sendBuffers_, proci)
{
// ie, sendDataCount(proci) != 0
if (sendConnections.set(proci, !sendBuffers_[proci].empty()))
{
// The state changed
@ -577,22 +670,20 @@ bool Foam::PstreamBuffers::finishedSends
if (changed)
{
// Create send/recv topology
// Update send/recv topology
labelList recvSizes;
finishedSends(recvSizes, wait); // eg, using all-to-all
// The send ranks
sendProcs.clear();
forAll(sendBuffers_, proci)
{
// ie, sendDataCount(proci) != 0
if (!sendBuffers_[proci].empty())
{
sendProcs.push_back(proci);
}
}
labelList recvSizes;
finishedSends(recvSizes, wait); // All-to-all
// The recv ranks
recvProcs.clear();
forAll(recvSizes, proci)
@ -606,46 +697,25 @@ bool Foam::PstreamBuffers::finishedSends
else
{
// Use existing send/recv ranks
finishedSends(sendProcs, recvProcs, wait);
labelList recvSizes;
finalExchange(sendProcs, recvProcs, wait, recvSizes);
}
return changed;
}
void Foam::PstreamBuffers::finishedNeighbourSends
(
const labelUList& neighProcs,
labelList& recvSizes,
const bool wait
)
{
finishedSends(neighProcs, neighProcs, recvSizes, wait);
}
void Foam::PstreamBuffers::finishedNeighbourSends
(
const labelUList& neighProcs,
const bool wait
)
{
finishedSends(neighProcs, neighProcs, wait);
}
void Foam::PstreamBuffers::finishedGathers(const bool wait)
{
labelList recvSizes;
finalExchangeGatherScatter(true, wait, false, recvSizes);
finalGatherScatter(true, wait, recvSizes);
}
void Foam::PstreamBuffers::finishedScatters(const bool wait)
{
labelList recvSizes;
finalExchangeGatherScatter(false, wait, false, recvSizes);
finalGatherScatter(false, wait, recvSizes);
}
@ -655,7 +725,7 @@ void Foam::PstreamBuffers::finishedGathers
const bool wait
)
{
finalExchangeGatherScatter(true, wait, true, recvSizes);
finalGatherScatter(true, wait, recvSizes);
if (commsType_ != UPstream::commsTypes::nonBlocking)
{
@ -677,7 +747,7 @@ void Foam::PstreamBuffers::finishedScatters
const bool wait
)
{
finalExchangeGatherScatter(false, wait, true, recvSizes);
finalGatherScatter(false, wait, recvSizes);
if (commsType_ != UPstream::commsTypes::nonBlocking)
{

View File

@ -164,7 +164,7 @@ class PstreamBuffers
);
//- Mark sends as done.
// Only exchange sizes using the sendProcs/recvProcs subset
// Only exchange sizes using the neighbour ranks
// (nonBlocking comms).
void finalExchange
(
@ -175,11 +175,10 @@ class PstreamBuffers
);
//- For all-to-one or one-to-all
void finalExchangeGatherScatter
void finalGatherScatter
(
const bool isGather,
const bool wait,
const bool needSizes, // If recvSizes needed or scratch
labelList& recvSizes
);
@ -202,6 +201,12 @@ class PstreamBuffers
public:
// Static Data
//- Preferred exchange algorithm (may change or be removed in future)
static int algorithm;
// Constructors
//- Construct given communication type (default: nonBlocking), message
@ -340,7 +345,7 @@ public:
//- Maximum receive size, excluding the specified processor rank
//- Must call finishedSends() or other finished.. method first!
label maxNonLocalRecvCount(const label proci) const;
label maxNonLocalRecvCount(const label excludeProci) const;
//- Number of unconsumed receive bytes for the specified processor.
//- Must call finishedSends() or other finished.. method first!
@ -397,60 +402,6 @@ public:
// Functions with restricted neighbours
//- Mark sends as done using subset of send/recv ranks
//- to exchange data on.
//
// Non-blocking mode: populates receive buffers.
// \param sendProcs ranks used for sends
// \param recvProcs ranks used for recvs
// \param wait wait for requests to complete (in nonBlocking mode)
//
// \warning currently only valid for nonBlocking comms.
void finishedSends
(
const labelUList& sendProcs,
const labelUList& recvProcs,
const bool wait = true
);
//- Mark sends as done using subset of send/recv ranks
//- to exchange data on. Recovers the sizes (bytes) received.
//
// Non-blocking mode: populates receive buffers.
//
// \param sendProcs ranks used for sends
// \param recvProcs ranks used for recvs
// \param[out] recvSizes the sizes (bytes) received
// \param wait wait for requests to complete (in nonBlocking mode)
//
// \warning currently only valid for nonBlocking comms.
void finishedSends
(
const labelUList& sendProcs,
const labelUList& recvProcs,
labelList& recvSizes,
const bool wait = true
);
//- A caching version that uses a limited send/recv connectivity.
//
// Non-blocking mode: populates receive buffers.
// \param sendConnections on/off for sending ranks
// \param sendProcs ranks used for sends
// \param recvProcs ranks used for recvs
// \param wait wait for requests to complete (in nonBlocking mode)
//
// \return True if the send/recv connectivity changed
//
// \warning currently only valid for nonBlocking comms.
bool finishedSends
(
bitSet& sendConnections,
DynamicList<label>& sendProcs,
DynamicList<label>& recvProcs,
const bool wait = true
);
//- Mark sends as done using subset of send/recv ranks
//- and recover the sizes (bytes) received.
//
@ -484,6 +435,25 @@ public:
const bool wait = true
);
//- A caching version that uses a limited send/recv connectivity.
//
// Non-blocking mode: populates receive buffers.
// \param sendConnections on/off for sending ranks
// \param sendProcs ranks used for sends
// \param recvProcs ranks used for recvs
// \param wait wait for requests to complete (in nonBlocking mode)
//
// \return True if the send/recv connectivity changed
//
// \warning currently only valid for nonBlocking comms.
bool finishedSends
(
bitSet& sendConnections,
DynamicList<label>& sendProcs,
DynamicList<label>& recvProcs,
const bool wait = true
);
// Gather/scatter modes

View File

@ -746,58 +746,89 @@ void Foam::Pstream::exchangeSizes
const label comm
)
{
//const label myProci = UPstream::myProcNo(comm);
const label myProci = UPstream::myProcNo(comm);
const label numProcs = UPstream::nProcs(comm);
if (sendBufs.size() != UPstream::nProcs(comm))
if (sendBufs.size() != numProcs)
{
FatalErrorInFunction
<< "Size of container " << sendBufs.size()
<< " does not equal the number of processors "
<< UPstream::nProcs(comm)
<< " does not equal the number of processors " << numProcs
<< Foam::abort(FatalError);
}
labelList sendSizes(sendProcs.size());
forAll(sendProcs, i)
labelList sendSizes(numProcs);
for (label proci = 0; proci < numProcs; ++proci)
{
sendSizes[i] = sendBufs[sendProcs[i]].size();
sendSizes[proci] = sendBufs[proci].size();
}
recvSizes.resize_nocopy(sendBufs.size());
recvSizes.resize_nocopy(numProcs);
recvSizes = 0; // Ensure non-received entries are properly zeroed
// Preserve self-send, even if not described by neighbourhood
recvSizes[myProci] = sendSizes[myProci];
const label startOfRequests = UPstream::nRequests();
for (const label proci : recvProcs)
{
UIPstream::read
(
UPstream::commsTypes::nonBlocking,
proci,
reinterpret_cast<char*>(&recvSizes[proci]),
sizeof(label),
tag,
comm
);
if (proci != myProci)
{
UIPstream::read
(
UPstream::commsTypes::nonBlocking,
proci,
reinterpret_cast<char*>(&recvSizes[proci]),
sizeof(label),
tag,
comm
);
}
}
forAll(sendProcs, i)
for (const label proci : sendProcs)
{
UOPstream::write
(
UPstream::commsTypes::nonBlocking,
sendProcs[i],
reinterpret_cast<char*>(&sendSizes[i]),
sizeof(label),
tag,
comm
);
if (proci != myProci)
{
UOPstream::write
(
UPstream::commsTypes::nonBlocking,
proci,
reinterpret_cast<char*>(&sendSizes[proci]),
sizeof(label),
tag,
comm
);
}
}
UPstream::waitRequests(startOfRequests);
}
template<class Container>
void Foam::Pstream::exchangeSizes
(
const labelUList& neighProcs,
const Container& sendBufs,
labelList& recvSizes,
const label tag,
const label comm
)
{
Pstream::exchangeSizes<Container>
(
neighProcs, // send
neighProcs, // recv
sendBufs,
recvSizes,
tag,
comm
);
}
// Sparse sending
template<class Container>
void Foam::Pstream::exchangeSizes

View File

@ -58,7 +58,7 @@ void reduce
const label comm
)
{
if (UPstream::warnComm != -1 && comm != UPstream::warnComm)
if (UPstream::warnComm >= 0 && comm != UPstream::warnComm)
{
Pout<< "** reducing:" << value << " with comm:" << comm << endl;
error::printStack(Pout);

View File

@ -284,24 +284,52 @@ public:
// Standard Communicators
//- Default world communicator (all processors).
//- Communicator for all ranks.
//- May differ from globalComm if local worlds are in use
static label worldComm;
//- Debugging: warn for use of any communicator differing from warnComm
static label warnComm;
//- Communicator for all processors, irrespective of any local worlds
//- Communicator for all ranks, irrespective of any local worlds
static constexpr label globalComm = 0;
//- A communicator within the current rank only
static constexpr label selfComm = 1;
//- Communicator for all ranks, irrespective of any local worlds
static constexpr label commGlobal() noexcept { return 0; }
//- Communicator within the current rank only
static constexpr label commSelf() noexcept { return 1; }
//- Communicator for all ranks (respecting any local worlds)
static label commWorld() noexcept { return worldComm; }
//- Alter value of world communicator
// \returns the previous value
static label commWorld(const label communicator) noexcept
{
label old(worldComm);
worldComm = communicator;
return old;
}
//- Alter communicator debugging setting.
//- Warns for use of any communicator differing from specified.
// \returns the previous warn communicator
static label commWarn(const label communicator) noexcept
{
label old(warnComm);
warnComm = communicator;
return old;
}
//- Number of currently defined communicators
static label nComms() noexcept { return parentComm_.size(); }
//- True if communicator appears to be user-allocated
static bool isUserComm(label communicator) noexcept
static bool isUserComm(const label communicator) noexcept
{
return (communicator > worldComm && communicator > selfComm);
}

View File

@ -143,7 +143,7 @@ Foam::OSstream& Foam::messageStream::stream(OSstream* alternative)
Foam::OSstream& Foam::messageStream::masterStream(const label communicator)
{
if (UPstream::warnComm != -1 && communicator != UPstream::warnComm)
if (UPstream::warnComm >= 0 && communicator != UPstream::warnComm)
{
Pout<< "** messageStream with comm:" << communicator << endl;
error::printStack(Pout);

View File

@ -6,6 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2023 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -33,12 +34,14 @@ License
namespace Foam
{
defineTemplateTypeNameAndDebug(pointLabelField::Internal, 0);
defineTemplateTypeNameAndDebug(pointScalarField::Internal, 0);
defineTemplateTypeNameAndDebug(pointVectorField::Internal, 0);
defineTemplateTypeNameAndDebug(pointSphericalTensorField::Internal, 0);
defineTemplateTypeNameAndDebug(pointSymmTensorField::Internal, 0);
defineTemplateTypeNameAndDebug(pointTensorField::Internal, 0);
defineTemplateTypeNameAndDebug(pointLabelField, 0);
defineTemplateTypeNameAndDebug(pointScalarField, 0);
defineTemplateTypeNameAndDebug(pointVectorField, 0);
defineTemplateTypeNameAndDebug(pointSphericalTensorField, 0);
@ -54,6 +57,7 @@ defineTemplateTypeNameAndDebug(pointTensorField, 0);
const Foam::wordList Foam::fieldTypes::point
({
"pointLabelField",
"pointScalarField",
"pointVectorField",
"pointSphericalTensorField",

View File

@ -33,8 +33,8 @@ SourceFiles
\*---------------------------------------------------------------------------*/
#ifndef pointFields_H
#define pointFields_H
#ifndef Foam_pointFields_H
#define Foam_pointFields_H
#include "GeometricFields.H"
#include "pointMesh.H"

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011 OpenFOAM Foundation
Copyright (C) 2018-2022 OpenCFD Ltd.
Copyright (C) 2018-2023 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -80,6 +80,7 @@ using PointInternalField = DimensionedField<Type, pointMesh>;
// Typedefs
typedef GeometricField<label, pointPatchField, pointMesh> pointLabelField;
typedef GeometricField<scalar, pointPatchField, pointMesh> pointScalarField;
typedef GeometricField<vector, pointPatchField, pointMesh> pointVectorField;
typedef GeometricField<sphericalTensor, pointPatchField, pointMesh>

View File

@ -6,6 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2023 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -29,7 +30,6 @@ License
#include "transformField.H"
#include "symmTransformField.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class Type>
@ -87,15 +87,17 @@ void Foam::basicSymmetryPointPatchField<Type>::evaluate
const Pstream::commsTypes
)
{
const vectorField& nHat = this->patch().pointNormals();
if (pTraits<Type>::rank == 0)
{
// Transform-invariant types
return;
}
tmp<Field<Type>> tvalues =
(
(
this->patchInternalField()
+ transform(I - 2.0*sqr(nHat), this->patchInternalField())
)/2.0
);
Field<Type> pif(this->patchInternalField());
symmTensorField rot(I - 2.0*sqr(this->patch().pointNormals()));
tmp<Field<Type>> tvalues = (pif + transform(rot, pif))/2.0;
// Get internal field to insert values into
Field<Type>& iF = const_cast<Field<Type>&>(this->primitiveField());

View File

@ -34,8 +34,8 @@ SourceFiles
\*---------------------------------------------------------------------------*/
#ifndef basicSymmetryPointPatchField_H
#define basicSymmetryPointPatchField_H
#ifndef Foam_basicSymmetryPointPatchField_H
#define Foam_basicSymmetryPointPatchField_H
#include "pointPatchField.H"
#include "symmetryPointPatch.H"
@ -54,7 +54,6 @@ class basicSymmetryPointPatchField
:
public pointPatchField<Type>
{
public:
// Constructors

View File

@ -6,6 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011 OpenFOAM Foundation
Copyright (C) 2023 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -29,17 +30,12 @@ License
#include "pointPatchFields.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
makePointPatchFields(calculated);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
makePointPatchFields(calculated);
makePointPatchFieldType(label, calculated);
}
// ************************************************************************* //

View File

@ -6,6 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011 OpenFOAM Foundation
Copyright (C) 2023 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -25,11 +26,10 @@ License
\*---------------------------------------------------------------------------*/
#ifndef calculatedPointPatchFields_H
#define calculatedPointPatchFields_H
#ifndef Foam_calculatedPointPatchFields_H
#define Foam_calculatedPointPatchFields_H
#include "calculatedPointPatchField.H"
#include "fieldTypes.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -39,6 +39,7 @@ namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
makePointPatchFieldTypedefs(calculated);
makePointPatchFieldTypedef(label, calculated);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -6,6 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011 OpenFOAM Foundation
Copyright (C) 2023 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -26,18 +27,15 @@ License
\*---------------------------------------------------------------------------*/
#include "coupledPointPatchFields.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
#include "pointPatchFields.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
makePointPatchFieldsTypeName(coupled);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
namespace Foam
{
makePointPatchFieldsTypeName(coupled);
makePointPatchFieldTypeName(label, coupled);
}
// ************************************************************************* //

View File

@ -6,6 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011 OpenFOAM Foundation
Copyright (C) 2023 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -25,12 +26,10 @@ License
\*---------------------------------------------------------------------------*/
#ifndef coupledPointPatchFields_H
#define coupledPointPatchFields_H
#ifndef Foam_coupledPointPatchFields_H
#define Foam_coupledPointPatchFields_H
#include "coupledPointPatchField.H"
#include "coupledPointPatch.H"
#include "fieldTypes.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -40,6 +39,7 @@ namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
makePointPatchFieldTypedefs(coupled);
makePointPatchFieldTypedef(label, coupled);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -6,6 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2015 OpenFOAM Foundation
Copyright (C) 2023 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -26,7 +27,6 @@ License
\*---------------------------------------------------------------------------*/
#include "fixedValuePointPatchField.H"
#include "boolList.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
@ -47,10 +47,10 @@ Foam::fixedValuePointPatchField<Type>::fixedValuePointPatchField
const pointPatch& p,
const DimensionedField<Type, pointMesh>& iF,
const dictionary& dict,
const bool valueRequired
IOobjectOption::readOption requireValue
)
:
valuePointPatchField<Type>(p, iF, dict, valueRequired)
valuePointPatchField<Type>(p, iF, dict, requireValue)
{}

View File

@ -6,6 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2023 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -34,8 +35,8 @@ SourceFiles
\*---------------------------------------------------------------------------*/
#ifndef fixedValuePointPatchField_H
#define fixedValuePointPatchField_H
#ifndef Foam_fixedValuePointPatchField_H
#define Foam_fixedValuePointPatchField_H
#include "valuePointPatchField.H"
@ -53,7 +54,6 @@ class fixedValuePointPatchField
:
public valuePointPatchField<Type>
{
public:
//- Runtime type information
@ -75,9 +75,25 @@ public:
const pointPatch&,
const DimensionedField<Type, pointMesh>&,
const dictionary&,
const bool valueRequired=true
IOobjectOption::readOption requireValue = IOobjectOption::MUST_READ
);
//- Compatibility. Prefer with readOption
fixedValuePointPatchField
(
const pointPatch& p,
const DimensionedField<Type, pointMesh>& iF,
const dictionary& dict,
const bool valueReqd
)
:
fixedValuePointPatchField
(
p, iF, dict,
(valueReqd? IOobjectOption::MUST_READ : IOobjectOption::NO_READ)
)
{}
//- Construct by mapping given patch field onto a new patch
fixedValuePointPatchField
(

View File

@ -84,29 +84,17 @@ Foam::valuePointPatchField<Type>::valuePointPatchField
const pointPatch& p,
const DimensionedField<Type, pointMesh>& iF,
const dictionary& dict,
const bool valueRequired
IOobjectOption::readOption requireValue
)
:
pointPatchField<Type>(p, iF, dict),
Field<Type>(p.size())
{
const auto* hasValue = dict.findEntry("value", keyType::LITERAL);
if (hasValue)
{
Field<Type>::assign(*hasValue, p.size());
}
else if (!valueRequired)
if (!readValueEntry(dict, requireValue))
{
// Not read (eg, optional and missing): define zero
Field<Type>::operator=(Zero);
}
else
{
FatalIOErrorInFunction(dict)
<< "Essential entry 'value' missing on patch "
<< p.name() << endl
<< exit(FatalIOError);
}
}

View File

@ -101,10 +101,27 @@ public:
(
const pointPatch&,
const DimensionedField<Type, pointMesh>&,
const dictionary&,
const bool valueRequired=true
const dictionary& dict,
//! The "value" entry (default: mandatory)
IOobjectOption::readOption requireValue = IOobjectOption::MUST_READ
);
//- Construct, forwarding to readOption variant
valuePointPatchField
(
const pointPatch& p,
const DimensionedField<Type, pointMesh>& iF,
const dictionary& dict,
const bool valueReqd
)
:
valuePointPatchField
(
p, iF, dict,
(valueReqd? IOobjectOption::MUST_READ : IOobjectOption::NO_READ)
)
{}
//- Construct by mapping given patch field onto a new patch
valuePointPatchField
(

View File

@ -6,6 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011 OpenFOAM Foundation
Copyright (C) 2023 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -29,17 +30,12 @@ License
#include "pointPatchFields.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
makePointPatchFields(value);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
makePointPatchFields(value);
makePointPatchFieldTypeName(label, value);
}
// ************************************************************************* //

View File

@ -6,6 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011 OpenFOAM Foundation
Copyright (C) 2023 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -25,11 +26,10 @@ License
\*---------------------------------------------------------------------------*/
#ifndef valuePointPatchFields_H
#define valuePointPatchFields_H
#ifndef Foam_valuePointPatchFields_H
#define Foam_valuePointPatchFields_H
#include "valuePointPatchField.H"
#include "fieldTypes.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -39,6 +39,7 @@ namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
makePointPatchFieldTypedefs(value);
makePointPatchFieldTypedef(label, value);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -6,6 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011 OpenFOAM Foundation
Copyright (C) 2023 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -29,17 +30,12 @@ License
#include "pointPatchFields.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
makePointPatchFields(zeroGradient);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
makePointPatchFields(zeroGradient);
makePointPatchFieldType(label, zeroGradient);
}
// ************************************************************************* //

View File

@ -6,6 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011 OpenFOAM Foundation
Copyright (C) 2023 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -25,11 +26,10 @@ License
\*---------------------------------------------------------------------------*/
#ifndef zeroGradientPointPatchFields_H
#define zeroGradientPointPatchFields_H
#ifndef Foam_zeroGradientPointPatchFields_H
#define Foam_zeroGradientPointPatchFields_H
#include "zeroGradientPointPatchField.H"
#include "fieldTypes.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -39,6 +39,7 @@ namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
makePointPatchFieldTypedefs(zeroGradient);
makePointPatchFieldTypedef(label, zeroGradient);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -6,6 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011 OpenFOAM Foundation
Copyright (C) 2023 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -29,17 +30,12 @@ License
#include "pointPatchFields.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
makePointPatchFields(empty);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
makePointPatchFieldsTypeName(empty);
makePointPatchFieldTypeName(label, empty);
}
// ************************************************************************* //

View File

@ -6,6 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011 OpenFOAM Foundation
Copyright (C) 2023 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -25,11 +26,10 @@ License
\*---------------------------------------------------------------------------*/
#ifndef emptyPointPatchFields_H
#define emptyPointPatchFields_H
#ifndef Foam_emptyPointPatchFields_H
#define Foam_emptyPointPatchFields_H
#include "emptyPointPatchField.H"
#include "fieldTypes.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -39,6 +39,7 @@ namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
makePointPatchFieldTypedefs(empty);
makePointPatchFieldTypedef(label, empty);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -6,6 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011 OpenFOAM Foundation
Copyright (C) 2023 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -29,17 +30,12 @@ License
#include "pointPatchFields.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
makePointPatchFields(processor);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
makePointPatchFields(processor);
makePointPatchFieldType(label, processor);
}
// ************************************************************************* //

View File

@ -6,6 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011 OpenFOAM Foundation
Copyright (C) 2023 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -25,11 +26,10 @@ License
\*---------------------------------------------------------------------------*/
#ifndef processorPointPatchFields_H
#define processorPointPatchFields_H
#ifndef Foam_processorPointPatchFields_H
#define Foam_processorPointPatchFields_H
#include "processorPointPatchField.H"
#include "fieldTypes.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -39,6 +39,7 @@ namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
makePointPatchFieldTypedefs(processor);
makePointPatchFieldTypedef(label, processor);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -6,6 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011 OpenFOAM Foundation
Copyright (C) 2023 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -29,17 +30,12 @@ License
#include "pointPatchFields.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
makePointPatchFields(symmetry);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
makePointPatchFields(symmetry);
makePointPatchFieldType(label, symmetry);
}
// ************************************************************************* //

View File

@ -6,6 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011 OpenFOAM Foundation
Copyright (C) 2023 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -25,11 +26,10 @@ License
\*---------------------------------------------------------------------------*/
#ifndef symmetryPointPatchFields_H
#define symmetryPointPatchFields_H
#ifndef Foam_symmetryPointPatchFields_H
#define Foam_symmetryPointPatchFields_H
#include "symmetryPointPatchField.H"
#include "fieldTypes.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -39,6 +39,7 @@ namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
makePointPatchFieldTypedefs(symmetry);
makePointPatchFieldTypedef(label, symmetry);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -6,6 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2013-2016 OpenFOAM Foundation
Copyright (C) 2023 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -106,15 +107,17 @@ void Foam::symmetryPlanePointPatchField<Type>::evaluate
const Pstream::commsTypes
)
{
vector nHat = symmetryPlanePatch_.n();
if (pTraits<Type>::rank == 0)
{
// Transform-invariant types
return;
}
tmp<Field<Type>> tvalues =
(
(
this->patchInternalField()
+ transform(I - 2.0*sqr(nHat), this->patchInternalField())
)/2.0
);
Field<Type> pif(this->patchInternalField());
symmTensor rot(I - 2.0*sqr(symmetryPlanePatch_.n()));
tmp<Field<Type>> tvalues = (pif + transform(rot, pif))/2.0;
// Get internal field to insert values into
Field<Type>& iF = const_cast<Field<Type>&>(this->primitiveField());

View File

@ -6,6 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2013-2017 OpenFOAM Foundation
Copyright (C) 2023 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -34,8 +35,8 @@ SourceFiles
\*---------------------------------------------------------------------------*/
#ifndef symmetryPlanePointPatchField_H
#define symmetryPlanePointPatchField_H
#ifndef Foam_symmetryPlanePointPatchField_H
#define Foam_symmetryPlanePointPatchField_H
#include "basicSymmetryPointPatchField.H"
#include "symmetryPlanePointPatch.H"
@ -54,7 +55,7 @@ class symmetryPlanePointPatchField
:
public basicSymmetryPointPatchField<Type>
{
// Private data
// Private Data
//- Local reference cast into the symmetryPlane patch
const symmetryPlanePointPatch& symmetryPlanePatch_;

View File

@ -6,6 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2013 OpenFOAM Foundation
Copyright (C) 2023 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -29,17 +30,13 @@ License
#include "pointPatchFields.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
makePointPatchFields(symmetryPlane);
makePointPatchFieldType(label, symmetryPlane);
}
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
makePointPatchFields(symmetryPlane);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //

View File

@ -6,6 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2013 OpenFOAM Foundation
Copyright (C) 2023 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -25,11 +26,10 @@ License
\*---------------------------------------------------------------------------*/
#ifndef symmetryPlanePointPatchFields_H
#define symmetryPlanePointPatchFields_H
#ifndef Foam_symmetryPlanePointPatchFields_H
#define Foam_symmetryPlanePointPatchFields_H
#include "symmetryPlanePointPatchField.H"
#include "fieldTypes.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -39,6 +39,7 @@ namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
makePointPatchFieldTypedefs(symmetryPlane);
makePointPatchFieldTypedef(label, symmetryPlane);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -28,7 +28,6 @@ License
#include "wedgePointPatchField.H"
#include "transformField.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class Type>
@ -101,12 +100,18 @@ Foam::wedgePointPatchField<Type>::wedgePointPatchField
template<class Type>
void Foam::wedgePointPatchField<Type>::evaluate(const Pstream::commsTypes)
{
// label, scalar, sphericalTensor are rotationally invariant
if (pTraits<Type>::rank == 0 || std::is_same<sphericalTensor, Type>::value)
{
return;
}
// In order to ensure that the wedge patch is always flat, take the
// normal vector from the first point
const vector& nHat = this->patch().pointNormals()[0];
tmp<Field<Type>> tvalues =
transform(I - nHat*nHat, this->patchInternalField());
symmTensor rot(I - sqr(this->patch().pointNormals()[0]));
tmp<Field<Type>> tvalues = transform(rot, this->patchInternalField());
// Get internal field to insert values into
Field<Type>& iF = const_cast<Field<Type>&>(this->primitiveField());

View File

@ -6,6 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011 OpenFOAM Foundation
Copyright (C) 2023 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -29,17 +30,13 @@ License
#include "pointPatchFields.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
makePointPatchFields(wedge);
makePointPatchFieldType(label, wedge);
}
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
makePointPatchFields(wedge);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //

View File

@ -6,6 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011 OpenFOAM Foundation
Copyright (C) 2023 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -25,11 +26,10 @@ License
\*---------------------------------------------------------------------------*/
#ifndef wedgePointPatchFields_H
#define wedgePointPatchFields_H
#ifndef Foam_wedgePointPatchFields_H
#define Foam_wedgePointPatchFields_H
#include "wedgePointPatchField.H"
#include "fieldTypes.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -39,6 +39,7 @@ namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
makePointPatchFieldTypedefs(wedge);
makePointPatchFieldTypedef(label, wedge);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2012-2016 OpenFOAM Foundation
Copyright (C) 2016-2021 OpenCFD Ltd.
Copyright (C) 2016-2023 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -161,11 +161,11 @@ Foam::codedFixedValuePointPatchField<Type>::codedFixedValuePointPatchField
(
const pointPatch& p,
const DimensionedField<Type, pointMesh>& iF,
const dictionary& dict,
const bool valueRequired
const dictionary& dict
)
:
parent_bctype(p, iF, dict, false),
// The 'value' is optional (handled below)
parent_bctype(p, iF, dict, IOobjectOption::NO_READ),
codedBase(),
dict_
(
@ -186,10 +186,7 @@ Foam::codedFixedValuePointPatchField<Type>::codedFixedValuePointPatchField
{
updateLibrary(name_);
// Note: 'value' is used even with valueRequired = false ! This is
// inconsistent with fixedValueFvPatchField behaviour.
if (!dict.found("value")) // Q: check for valueRequired?
if (!this->readValueEntry(dict))
{
// Evaluate to assign a value
this->evaluate(Pstream::commsTypes::blocking);

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2012-2017 OpenFOAM Foundation
Copyright (C) 2019-2021 OpenCFD Ltd.
Copyright (C) 2019-2023 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -100,8 +100,8 @@ SourceFiles
\*---------------------------------------------------------------------------*/
#ifndef codedFixedValuePointPatchField_H
#define codedFixedValuePointPatchField_H
#ifndef Foam_codedFixedValuePointPatchField_H
#define Foam_codedFixedValuePointPatchField_H
#include "fixedValuePointPatchFields.H"
#include "codedBase.H"
@ -187,8 +187,7 @@ public:
(
const pointPatch&,
const DimensionedField<Type, pointMesh>&,
const dictionary&,
const bool valueRequired=true
const dictionary&
);
//- Construct by mapping given codedFixedValuePointPatchField

View File

@ -6,6 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011 OpenFOAM Foundation
Copyright (C) 2023 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -29,17 +30,12 @@ License
#include "pointPatchFields.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
makePointPatchFields(slip);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
makePointPatchFields(slip);
makePointPatchFieldType(label, slip);
}
// ************************************************************************* //

View File

@ -6,6 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011 OpenFOAM Foundation
Copyright (C) 2023 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -25,11 +26,10 @@ License
\*---------------------------------------------------------------------------*/
#ifndef slipPointPatchFields_H
#define slipPointPatchFields_H
#ifndef Foam_slipPointPatchFields_H
#define Foam_slipPointPatchFields_H
#include "slipPointPatchField.H"
#include "fieldTypes.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -39,6 +39,7 @@ namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
makePointPatchFieldTypedefs(slip);
makePointPatchFieldTypedef(label, slip);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2022 OpenCFD Ltd.
Copyright (C) 2022-2023 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.

View File

@ -37,6 +37,7 @@ namespace Foam
defineTemplateRunTimeSelectionTable(PatchTypeField, patchMapper); \
defineTemplateRunTimeSelectionTable(PatchTypeField, dictionary);
makePointPatchField(pointPatchLabelField);
makePointPatchField(pointPatchScalarField);
makePointPatchField(pointPatchVectorField);
makePointPatchField(pointPatchSphericalTensorField);

View File

@ -31,8 +31,6 @@ License
#include "pointPatchField.H"
#include "pointPatchFieldsFwd.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -6,6 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011 OpenFOAM Foundation
Copyright (C) 2023 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -39,6 +40,7 @@ namespace Foam
template<class Type> class pointPatchField;
typedef pointPatchField<label> pointPatchLabelField;
typedef pointPatchField<scalar> pointPatchScalarField;
typedef pointPatchField<vector> pointPatchVectorField;
typedef pointPatchField<sphericalTensor> pointPatchSphericalTensorField;

View File

@ -1720,6 +1720,8 @@ void Foam::argList::parse
<< " nProcsSimpleSum : " << Pstream::nProcsSimpleSum << nl
<< " nonBlockingExchange: "
<< Pstream::nProcsNonblockingExchange << nl
<< " exchange algorithm : "
<< PstreamBuffers::algorithm << nl
<< " commsType : "
<< Pstream::commsTypeNames[Pstream::defaultCommsType] << nl
<< " polling iterations : " << Pstream::nPollProcInterfaces

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2016-2022 OpenCFD Ltd.
Copyright (C) 2016-2023 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -163,6 +163,9 @@ public:
//- Construct a bounding box containing a single initial point
inline explicit boundBox(const point& p);
//- Construct a 0/1 unit bounding box
inline explicit boundBox(const Foam::zero_one);
//- Construct from bound box min/max points
inline boundBox(const point& min, const point& max);
@ -291,6 +294,9 @@ public:
//- Reset to an inverted box
inline void reset();
//- Reset to a 0/1 unit bounding box
inline void reset(const Foam::zero_one);
//- Reset min/max to be identical to the specified point
inline void reset(const point& pt);

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2016-2022 OpenCFD Ltd.
Copyright (C) 2016-2023 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -112,6 +112,13 @@ inline Foam::boundBox::boundBox()
{}
inline Foam::boundBox::boundBox(const Foam::zero_one)
:
min_(point::zero),
max_(point::one)
{}
inline Foam::boundBox::boundBox(const point& p)
:
min_(p),
@ -299,6 +306,13 @@ inline void Foam::boundBox::reset()
}
inline void Foam::boundBox::reset(const Foam::zero_one)
{
min_ = point::zero;
max_ = point::one;
}
inline void Foam::boundBox::reset(const point& pt)
{
min_ = pt;

View File

@ -34,8 +34,8 @@ SourceFiles
\*---------------------------------------------------------------------------*/
#ifndef ijkAddressing_H
#define ijkAddressing_H
#ifndef Foam_ijkAddressing_H
#define Foam_ijkAddressing_H
#include "labelVector.H"
#include "vector.H"

View File

@ -38,8 +38,8 @@ SourceFiles
\*---------------------------------------------------------------------------*/
#ifndef ijkMesh_H
#define ijkMesh_H
#ifndef Foam_ijkMesh_H
#define Foam_ijkMesh_H
#include "ijkAddressing.H"

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2015-2022 OpenCFD Ltd.
Copyright (C) 2015-2023 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -2721,8 +2721,7 @@ void Foam::globalMeshData::updateMesh()
identity(UPstream::nProcs(UPstream::worldComm)),
true
);
const label oldWarnComm = UPstream::warnComm;
UPstream::warnComm = comm;
const label oldWarnComm = UPstream::commWarn(comm);
// Total number of faces.
@ -2760,8 +2759,9 @@ void Foam::globalMeshData::updateMesh()
comm
);
// Restore communicator settings
UPstream::freeCommunicator(comm);
UPstream::warnComm = oldWarnComm;
UPstream::commWarn(oldWarnComm);
if (debug)
{

View File

@ -74,31 +74,33 @@ void Foam::primitiveMesh::calcCellPoints() const
const cellList& cellLst = cells();
const faceList& faceLst = faces();
// Vertex labels for the current cell
DynamicList<label> vertices(256);
// Tracking (only use each point id once)
bitSet usedPoints(nPoints());
// Vertex labels for the current cell
DynamicList<label> currPoints(256);
const label loopLen = nCells();
for (label celli = 0; celli < loopLen; ++celli)
{
// Clear any previous contents
vertices.clear();
usedPoints.unset(currPoints);
currPoints.clear();
for (const label facei : cellLst[celli])
{
for (const label pointi : faceLst[facei])
{
vertices.push_back(pointi);
// Only once for each point id
if (usedPoints.set(pointi))
{
currPoints.push_back(pointi);
}
}
}
// Sort + unique to eliminate duplicates
std::sort(vertices.begin(), vertices.end());
auto last = std::unique(vertices.begin(), vertices.end());
vertices.resize(label(last - vertices.begin()));
cellPointAddr[celli] = vertices;
cellPointAddr[celli] = currPoints; // NB: unsorted
}
}
}

View File

@ -73,36 +73,42 @@ void Foam::primitiveMesh::calcPointCells() const
const labelList& nei = faceNeighbour();
const labelListList& pFaces = pointFaces();
// Tracking (only use each cell id once)
bitSet usedCells(nCells());
// Cell ids for the point currently being processed
DynamicList<label> currCells(256);
const label loopLen = nPoints();
pcPtr_ = new labelListList(nPoints());
auto& pointCellAddr = *pcPtr_;
DynamicList<label> storage(256);
for (label pointi = 0; pointi < loopLen; ++pointi)
{
// Clear any previous contents
storage.clear();
usedCells.unset(currCells);
currCells.clear();
for (const label facei : pFaces[pointi])
{
// Owner cell
storage.push_back(own[facei]);
// Owner cell - only allow one occurance
if (usedCells.set(own[facei]))
{
currCells.push_back(own[facei]);
}
// Neighbour cell
// Neighbour cell - only allow one occurance
if (facei < nInternalFaces())
{
storage.push_back(nei[facei]);
if (usedCells.set(nei[facei]))
{
currCells.push_back(nei[facei]);
}
}
}
// Sort + unique to eliminate duplicates
std::sort(storage.begin(), storage.end());
auto last = std::unique(storage.begin(), storage.end());
storage.resize(label(last - storage.begin()));
pointCellAddr[pointi] = storage;
pointCellAddr[pointi] = currCells; // NB: unsorted
}
}
else
@ -112,12 +118,11 @@ void Foam::primitiveMesh::calcPointCells() const
const cellList& cellLst = cells();
const faceList& faceLst = faces();
// Vertex labels for the current cell
// Note: since the number of points per cell is relatively small,
// using a bitSet to track does not help much.
// Using a labelHashSet to track has too many allocations.
DynamicList<label> vertices(256);
// Tracking (only use each point id once)
bitSet usedPoints(nPoints());
// Which of usedPoints needs to be unset [faster]
DynamicList<label> currPoints(256);
const label loopLen = nCells();
@ -128,16 +133,17 @@ void Foam::primitiveMesh::calcPointCells() const
for (label celli = 0; celli < loopLen; ++celli)
{
// Clear any previous contents
vertices.clear();
usedPoints.unset(currPoints);
currPoints.clear();
for (const label facei : cellLst[celli])
{
for (const label pointi : faceLst[facei])
{
// Only once for each point id
if (!vertices.contains(pointi))
if (usedPoints.set(pointi))
{
vertices.push_back(pointi);
currPoints.push_back(pointi); // Needed for cleanup
++pointCount[pointi];
}
}
@ -161,16 +167,17 @@ void Foam::primitiveMesh::calcPointCells() const
for (label celli = 0; celli < loopLen; ++celli)
{
// Clear any previous contents
vertices.clear();
usedPoints.unset(currPoints);
currPoints.clear();
for (const label facei : cellLst[celli])
{
for (const label pointi : faceLst[facei])
{
// Only once for each point id
if (!vertices.contains(pointi))
if (usedPoints.set(pointi))
{
vertices.push_back(pointi);
currPoints.push_back(pointi); // Needed for cleanup
pointCellAddr[pointi][pointCount[pointi]++] = celli;
}
}
@ -227,12 +234,8 @@ const Foam::labelList& Foam::primitiveMesh::pointCells
if (storage.size() > 1)
{
std::sort(storage.begin(), storage.end());
auto last = std::unique(storage.begin(), storage.end());
const label newLen = label(last - storage.begin());
storage.resize(newLen);
storage.resize(label(last - storage.begin()));
}
return storage;

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2017-2022 OpenCFD Ltd.
Copyright (C) 2017-2023 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -201,6 +201,9 @@ public:
// Constructors
//- Construct a 0/1 unit bounding box
inline explicit treeBoundBox(const Foam::zero_one);
//- Construct a bounding box containing a single initial point
inline explicit treeBoundBox(const point& p);

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011 OpenFOAM Foundation
Copyright (C) 2017-2022 OpenCFD Ltd.
Copyright (C) 2017-2023 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -31,6 +31,12 @@ License
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
inline Foam::treeBoundBox::treeBoundBox(const Foam::zero_one)
:
boundBox(zero_one{})
{}
inline Foam::treeBoundBox::treeBoundBox(const point& p)
:
boundBox(p)

View File

@ -214,7 +214,7 @@ void Foam::globalIndex::reset
// Non-parallel branch: use localSize on-proc, zero elsewhere
localLens.resize(len, Zero);
localLens[Pstream::myProcNo(comm)] = localSize;
localLens[UPstream::myProcNo(comm)] = localSize;
}
reset(localLens, true); // checkOverflow = true

View File

@ -519,7 +519,9 @@ public:
{
List<Type> allData;
gather(offsets, comm, procIDs, fld, allData, tag, ct);
if (Pstream::myProcNo(comm) == procIDs[0])
const int masterProci = procIDs.size() ? procIDs[0] : 0;
if (UPstream::myProcNo(comm) == masterProci)
{
fld.transfer(allData);
}

View File

@ -137,14 +137,14 @@ inline Foam::globalIndex::globalIndex
inline bool Foam::globalIndex::empty() const
{
return offsets_.empty() || offsets_.last() == 0;
return offsets_.empty() || offsets_.back() == 0;
}
inline Foam::label Foam::globalIndex::totalSize() const
{
const label len = (offsets_.size() - 1);
return (len < 1) ? static_cast<label>(0) : offsets_[len];
return (len < 1) ? 0 : offsets_[len];
}
@ -163,7 +163,7 @@ inline Foam::labelList Foam::globalIndex::sizes() const
inline Foam::label Foam::globalIndex::nProcs() const noexcept
{
const label len = (offsets_.size() - 1);
return (len < 1) ? static_cast<label>(0) : len;
return (len < 1) ? 0 : len;
}
@ -219,7 +219,7 @@ inline Foam::label Foam::globalIndex::localStart(const label proci) const
inline Foam::label Foam::globalIndex::localStart() const
{
return localStart(Pstream::myProcNo());
return localStart(UPstream::myProcNo());
}
@ -231,7 +231,7 @@ inline Foam::label Foam::globalIndex::localSize(const label proci) const
inline Foam::label Foam::globalIndex::localSize() const
{
return localSize(Pstream::myProcNo());
return localSize(UPstream::myProcNo());
}
@ -244,7 +244,7 @@ inline Foam::label Foam::globalIndex::maxSize() const
inline Foam::label Foam::globalIndex::maxNonLocalSize() const
{
return maxNonLocalSize(Pstream::myProcNo());
return maxNonLocalSize(UPstream::myProcNo());
}
@ -256,7 +256,7 @@ inline Foam::labelRange Foam::globalIndex::range(const label proci) const
inline Foam::labelRange Foam::globalIndex::range() const
{
return range(Pstream::myProcNo());
return range(UPstream::myProcNo());
}
@ -268,7 +268,7 @@ inline bool Foam::globalIndex::isLocal(const label proci, const label i) const
inline bool Foam::globalIndex::isLocal(const label i) const
{
return isLocal(Pstream::myProcNo(), i);
return isLocal(UPstream::myProcNo(), i);
}
@ -284,7 +284,7 @@ inline Foam::label Foam::globalIndex::toGlobal
inline Foam::label Foam::globalIndex::toGlobal(const label i) const
{
return toGlobal(Pstream::myProcNo(), i);
return toGlobal(UPstream::myProcNo(), i);
}
@ -306,7 +306,7 @@ inline Foam::labelList Foam::globalIndex::toGlobal
const labelUList& labels
) const
{
return toGlobal(Pstream::myProcNo(), labels);
return toGlobal(UPstream::myProcNo(), labels);
}
@ -327,7 +327,7 @@ inline void Foam::globalIndex::inplaceToGlobal
inline void Foam::globalIndex::inplaceToGlobal(labelUList& labels) const
{
inplaceToGlobal(Pstream::myProcNo(), labels);
inplaceToGlobal(UPstream::myProcNo(), labels);
}
@ -349,7 +349,7 @@ Foam::globalIndex::toLocal(const label proci, const label i) const
inline Foam::label Foam::globalIndex::toLocal(const label i) const
{
return toLocal(Pstream::myProcNo(), i);
return toLocal(UPstream::myProcNo(), i);
}
@ -363,7 +363,7 @@ inline Foam::label Foam::globalIndex::whichProcID(const label i) const
<< abort(FatalError);
}
const label proci(Pstream::myProcNo());
const int proci = UPstream::myProcNo();
return isLocal(proci, i) ? proci : findLower(offsets_, i+1);
}

View File

@ -91,7 +91,9 @@ void Foam::globalIndex::gatherValues
const label startOfRequests = UPstream::nRequests();
if (UPstream::myProcNo(comm) == procIDs[0])
const int masterProci = procIDs.size() ? procIDs[0] : 0;
if (UPstream::myProcNo(comm) == masterProci)
{
allValues.resize_nocopy(procIDs.size());
allValues[0] = localValue;
@ -126,7 +128,7 @@ void Foam::globalIndex::gatherValues
UOPstream::write
(
commsType,
procIDs[0],
masterProci,
reinterpret_cast<const char*>(&localValue),
sizeof(Type),
tag,
@ -135,7 +137,7 @@ void Foam::globalIndex::gatherValues
}
else
{
OPstream toMaster(commsType, procIDs[0], 0, tag, comm);
OPstream toMaster(commsType, masterProci, 0, tag, comm);
toMaster << localValue;
}
}
@ -176,9 +178,11 @@ void Foam::globalIndex::gather
const label startOfRequests = UPstream::nRequests();
if (Pstream::myProcNo(comm) == procIDs[0])
const int masterProci = procIDs.size() ? procIDs[0] : 0;
if (UPstream::myProcNo(comm) == masterProci)
{
allFld.resize_nocopy(off.last()); // == totalSize()
allFld.resize_nocopy(off.back()); // == totalSize()
// Assign my local data - respect offset information
// so that we can request 0 entries to be copied.
@ -226,7 +230,7 @@ void Foam::globalIndex::gather
UOPstream::write
(
commsType,
procIDs[0],
masterProci,
fld.cdata_bytes(),
fld.size_bytes(),
tag,
@ -235,7 +239,7 @@ void Foam::globalIndex::gather
}
else
{
OPstream toMaster(commsType, procIDs[0], 0, tag, comm);
OPstream toMaster(commsType, masterProci, 0, tag, comm);
toMaster << fld;
}
}
@ -294,9 +298,11 @@ void Foam::globalIndex::gather
const label startOfRequests = UPstream::nRequests();
if (Pstream::myProcNo(comm) == procIDs[0])
const int masterProci = procIDs.size() ? procIDs[0] : 0;
if (UPstream::myProcNo(comm) == masterProci)
{
allFld.resize_nocopy(off.last()); // == totalSize()
allFld.resize_nocopy(off.back()); // == totalSize()
// Assign my local data - respect offset information
// so that we can request 0 entries to be copied
@ -331,7 +337,7 @@ void Foam::globalIndex::gather
}
else
{
OPstream toMaster(commsType, procIDs[0], 0, tag, comm);
OPstream toMaster(commsType, masterProci, 0, tag, comm);
toMaster << fld;
}
}
@ -877,7 +883,9 @@ void Foam::globalIndex::scatter
const label startOfRequests = UPstream::nRequests();
if (Pstream::myProcNo(comm) == procIDs[0])
const int masterProci = procIDs.size() ? procIDs[0] : 0;
if (UPstream::myProcNo(comm) == masterProci)
{
for (label i = 1; i < procIDs.size(); ++i)
{
@ -929,7 +937,7 @@ void Foam::globalIndex::scatter
UIPstream::read
(
commsType,
procIDs[0],
masterProci,
fld.data_bytes(),
fld.size_bytes(),
tag,
@ -938,7 +946,7 @@ void Foam::globalIndex::scatter
}
else
{
IPstream fromMaster(commsType, procIDs[0], 0, tag, comm);
IPstream fromMaster(commsType, masterProci, 0, tag, comm);
fromMaster >> fld;
}
}

View File

@ -114,7 +114,7 @@ Foam::label Foam::UIPstream::read
<< " commsType:" << UPstream::commsTypeNames[commsType]
<< Foam::endl;
}
if (UPstream::warnComm != -1 && communicator != UPstream::warnComm)
if (UPstream::warnComm >= 0 && communicator != UPstream::warnComm)
{
Pout<< "UIPstream::read : starting read from:" << fromProcNo
<< " tag:" << tag << " comm:" << communicator

View File

@ -68,7 +68,7 @@ bool Foam::UOPstream::write
<< " commType:" << UPstream::commsTypeNames[commsType]
<< Foam::endl;
}
if (UPstream::warnComm != -1 && communicator != UPstream::warnComm)
if (UPstream::warnComm >= 0 && communicator != UPstream::warnComm)
{
Pout<< "UOPstream::write : starting write to:" << toProcNo
<< " tag:" << tag

View File

@ -54,7 +54,7 @@ bool Foam::UPstream::broadcast
<< " size:" << label(bufSize)
<< Foam::endl;
}
if (UPstream::warnComm != -1 && comm != UPstream::warnComm)
if (UPstream::warnComm >= 0 && comm != UPstream::warnComm)
{
Pout<< "UPstream::broadcast : root:" << rootProcNo
<< " comm:" << comm

View File

@ -78,7 +78,7 @@ void Foam::PstreamDetail::reduce0
return;
}
if (UPstream::warnComm != -1 && comm != UPstream::warnComm)
if (UPstream::warnComm >= 0 && comm != UPstream::warnComm)
{
Pout<< "** reducing:";
if (count == 1)
@ -135,7 +135,7 @@ void Foam::PstreamDetail::allReduce
const bool immediate = (req || requestID);
if (UPstream::warnComm != -1 && comm != UPstream::warnComm)
if (UPstream::warnComm >= 0 && comm != UPstream::warnComm)
{
if (immediate)
{
@ -246,7 +246,7 @@ void Foam::PstreamDetail::allToAll
const label numProc = UPstream::nProcs(comm);
if (UPstream::warnComm != -1 && comm != UPstream::warnComm)
if (UPstream::warnComm >= 0 && comm != UPstream::warnComm)
{
if (immediate)
{
@ -383,7 +383,7 @@ void Foam::PstreamDetail::allToAllv
const label np = UPstream::nProcs(comm);
if (UPstream::warnComm != -1 && comm != UPstream::warnComm)
if (UPstream::warnComm >= 0 && comm != UPstream::warnComm)
{
if (immediate)
{
@ -531,7 +531,7 @@ void Foam::PstreamDetail::allToAllConsensus
const label myProci = UPstream::myProcNo(comm);
const label numProc = UPstream::nProcs(comm);
if (UPstream::warnComm != -1 && comm != UPstream::warnComm)
if (UPstream::warnComm >= 0 && comm != UPstream::warnComm)
{
Pout<< "** non-blocking consensus Alltoall (list):";
Pout<< " numProc:" << numProc
@ -717,7 +717,7 @@ void Foam::PstreamDetail::allToAllConsensus
const label myProci = UPstream::myProcNo(comm);
const label numProc = UPstream::nProcs(comm);
if (UPstream::warnComm != -1 && comm != UPstream::warnComm)
if (UPstream::warnComm >= 0 && comm != UPstream::warnComm)
{
Pout<< "** non-blocking consensus Alltoall (map):";
Pout<< " numProc:" << numProc
@ -911,7 +911,7 @@ void Foam::PstreamDetail::gather
const label np = UPstream::nProcs(comm);
if (UPstream::warnComm != -1 && comm != UPstream::warnComm)
if (UPstream::warnComm >= 0 && comm != UPstream::warnComm)
{
if (immediate)
{
@ -1037,7 +1037,7 @@ void Foam::PstreamDetail::scatter
const label np = UPstream::nProcs(comm);
if (UPstream::warnComm != -1 && comm != UPstream::warnComm)
if (UPstream::warnComm >= 0 && comm != UPstream::warnComm)
{
if (immediate)
{
@ -1165,7 +1165,7 @@ void Foam::PstreamDetail::gatherv
const label np = UPstream::nProcs(comm);
if (UPstream::warnComm != -1 && comm != UPstream::warnComm)
if (UPstream::warnComm >= 0 && comm != UPstream::warnComm)
{
if (immediate)
{
@ -1317,7 +1317,7 @@ void Foam::PstreamDetail::scatterv
const label np = UPstream::nProcs(comm);
if (UPstream::warnComm != -1 && comm != UPstream::warnComm)
if (UPstream::warnComm >= 0 && comm != UPstream::warnComm)
{
if (immediate)
{

View File

@ -53,7 +53,7 @@ Foam::fixedShearStressFvPatchVectorField::fixedShearStressFvPatchVectorField
const dictionary& dict
)
:
fixedValueFvPatchVectorField(p, iF, dict, false),
fixedValueFvPatchVectorField(p, iF, dict, IOobjectOption::NO_READ),
tau0_(dict.getOrDefault<vector>("tau", Zero))
{
fvPatchField<vector>::operator=(patchInternalField());

View File

@ -67,14 +67,7 @@ Foam::porousBafflePressureFvPatchField::porousBafflePressureFvPatchField
{
if (valueRequired)
{
if (dict.found("value"))
{
fvPatchField<scalar>::operator=
(
Field<scalar>("value", dict, p.size())
);
}
else
if (!this->readValueEntry(dict))
{
this->evaluate(Pstream::commsTypes::blocking);
}

View File

@ -92,7 +92,7 @@ atmTurbulentHeatFluxTemperatureFvPatchScalarField
const dictionary& dict
)
:
fixedGradientFvPatchScalarField(p, iF),
fixedGradientFvPatchScalarField(p, iF), // Bypass dictionary constructor
heatSource_
(
heatSourceTypeNames.getOrDefault
@ -106,13 +106,11 @@ atmTurbulentHeatFluxTemperatureFvPatchScalarField
Cp0_(Function1<scalar>::New("Cp0", dict, &db())),
q_(PatchFunction1<scalar>::New(p.patch(), "q", dict))
{
if (dict.found("value") && dict.found("gradient"))
const auto* hasGrad = dict.findEntry("gradient", keyType::LITERAL);
if (hasGrad && this->readValueEntry(dict))
{
fvPatchField<scalar>::operator =
(
Field<scalar>("value", dict, p.size())
);
gradient() = Field<scalar>("gradient", dict, p.size());
gradient().assign(*hasGrad, p.size());
}
else
{

View File

@ -56,17 +56,10 @@ freeSurfacePressureFvPatchScalarField
const dictionary& dict
)
:
fixedValueFvPatchScalarField(p, iF, dict, false),
fixedValueFvPatchScalarField(p, iF, dict, IOobjectOption::NO_READ),
pa_("pa", dict, p.size())
{
if (dict.found("value"))
{
fvPatchScalarField::operator=
(
scalarField("value", dict, p.size())
);
}
else
if (!this->readValueEntry(dict))
{
fvPatchField<scalar>::operator=(pa_);
}

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2018-2022 OpenCFD Ltd.
Copyright (C) 2018-2023 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -76,11 +76,11 @@ Foam::Ostream& Foam::vtk::fileWriter::reportBadState
Foam::Ostream& Foam::vtk::fileWriter::reportBadState
(
Ostream& os,
outputState expected,
outputState expected1,
outputState expected2
) const
{
reportBadState(os, expected)
reportBadState(os, expected1)
<< " or (" << stateNames[expected2] << ')';
return os;
}
@ -554,10 +554,18 @@ bool Foam::vtk::fileWriter::writeProcIDs(const label nValues)
{
++nCellData_;
}
else if (isState(outputState::POINT_DATA))
{
++nPointData_;
}
else
{
reportBadState(FatalErrorInFunction, outputState::CELL_DATA)
<< " for procID field" << nl << endl
reportBadState
(
FatalErrorInFunction,
outputState::CELL_DATA,
outputState::POINT_DATA
) << " for procID field" << nl << endl
<< exit(FatalError);
return false;

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2018-2022 OpenCFD Ltd.
Copyright (C) 2018-2023 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -201,7 +201,8 @@ protected:
const UList<Type>& field
);
//- Write nValues of processor ids as CellData (no-op in serial)
//- Write nValues of processor ids as CellData or PointData
//- (no-op in serial)
bool writeProcIDs(const label nValues);
@ -305,10 +306,16 @@ public:
// \return True if the state changed
virtual bool beginPointData(label nFields = 0) = 0;
//- Return the number of CellData written for the Piece thus far.
//- True if output state corresponds to CELL_DATA
inline bool isCellData() const noexcept;
//- True if output state corresponds to POINT_DATA
inline bool isPointData() const noexcept;
//- The number of CellData written for the Piece thus far.
inline label nCellData() const noexcept;
//- Return the number of PointData written for the Piece thus far.
//- The number of PointData written for the Piece thus far.
inline label nPointData() const noexcept;

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2018-2022 OpenCFD Ltd.
Copyright (C) 2018-2023 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -107,4 +107,16 @@ inline Foam::label Foam::vtk::fileWriter::nPointData() const noexcept
}
inline bool Foam::vtk::fileWriter::isCellData() const noexcept
{
return (outputState::CELL_DATA == state_);
}
inline bool Foam::vtk::fileWriter::isPointData() const noexcept
{
return (outputState::POINT_DATA == state_);
}
// ************************************************************************* //

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2021 OpenCFD Ltd.
Copyright (C) 2021-2023 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -131,6 +131,10 @@ void Foam::vtk::lineWriter::piece
bool Foam::vtk::lineWriter::writeProcIDs()
{
if (this->isPointData())
{
return vtk::fileWriter::writeProcIDs(nLocalPoints_);
}
return vtk::fileWriter::writeProcIDs(nLocalLines_);
}

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2021 OpenCFD Ltd.
Copyright (C) 2021-2023 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -155,8 +155,8 @@ public:
void piece(const pointField& points, const edgeList& edges);
//- Write processor ids for each line as CellData
//- (no-op in serial)
//- Write processor ids for each line as CellData or for each point
//- as PointData, depending on isPointData() state. No-op in serial.
bool writeProcIDs();
//- Write a uniform field of Cell (Line) or Point values

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2018-2021 OpenCFD Ltd.
Copyright (C) 2018-2023 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -131,6 +131,10 @@ void Foam::vtk::surfaceWriter::piece
bool Foam::vtk::surfaceWriter::writeProcIDs()
{
if (this->isPointData())
{
return vtk::fileWriter::writeProcIDs(nLocalPoints_);
}
return vtk::fileWriter::writeProcIDs(nLocalPolys_);
}

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2018-2021 OpenCFD Ltd.
Copyright (C) 2018-2023 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -155,8 +155,8 @@ public:
void piece(const pointField& points, const faceList& faces);
//- Write processor ids for each poly as CellData
//- (no-op in serial)
//- Write processor ids for each poly as CellData or for each point
//- as PointData, depending on isPointData() state. No-op in serial.
bool writeProcIDs();
//- Write a uniform field of Cell (Poly) or Point values

View File

@ -44,6 +44,7 @@ $(faPatchFields)/faPatchField/faPatchFields.C
basicFaPatchFields = $(faPatchFields)/basic
$(basicFaPatchFields)/basicSymmetry/basicSymmetryFaPatchFields.C
$(basicFaPatchFields)/calculated/calculatedFaPatchFields.C
$(basicFaPatchFields)/extrapolatedCalculated/extrapolatedCalculatedFaPatchFields.C
$(basicFaPatchFields)/coupled/coupledFaPatchFields.C
$(basicFaPatchFields)/zeroGradient/zeroGradientFaPatchFields.C
$(basicFaPatchFields)/fixedValue/fixedValueFaPatchFields.C
@ -62,9 +63,13 @@ $(constraintFaPatchFields)/symmetry/symmetryFaPatchFields.C
derivedFaPatchFields = $(faPatchFields)/derived
$(derivedFaPatchFields)/fixedValueOutflow/fixedValueOutflowFaPatchFields.C
$(derivedFaPatchFields)/inletOutlet/inletOutletFaPatchFields.C
$(derivedFaPatchFields)/outletInlet/outletInletFaPatchFields.C
$(derivedFaPatchFields)/slip/slipFaPatchFields.C
$(derivedFaPatchFields)/edgeNormalFixedValue/edgeNormalFixedValueFaPatchVectorField.C
$(derivedFaPatchFields)/timeVaryingUniformFixedValue/timeVaryingUniformFixedValueFaPatchFields.C
$(derivedFaPatchFields)/uniformFixedGradient/uniformFixedGradientFaPatchFields.C
$(derivedFaPatchFields)/uniformFixedValue/uniformFixedValueFaPatchFields.C
$(derivedFaPatchFields)/uniformMixed/uniformMixedFaPatchFields.C
$(derivedFaPatchFields)/clampedPlate/clampedPlateFaPatchFields.C
faePatchFields = fields/faePatchFields

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2016-2017 Wikki Ltd
Copyright (C) 2018-2022 OpenCFD Ltd.
Copyright (C) 2018-2023 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -34,12 +34,14 @@ License
namespace Foam
{
defineTemplateTypeNameAndDebug(areaLabelField::Internal, 0);
defineTemplateTypeNameAndDebug(areaScalarField::Internal, 0);
defineTemplateTypeNameAndDebug(areaVectorField::Internal, 0);
defineTemplateTypeNameAndDebug(areaSphericalTensorField::Internal, 0);
defineTemplateTypeNameAndDebug(areaSymmTensorField::Internal, 0);
defineTemplateTypeNameAndDebug(areaTensorField::Internal, 0);
defineTemplateTypeNameAndDebug(areaLabelField, 0);
defineTemplateTypeNameAndDebug(areaScalarField, 0);
defineTemplateTypeNameAndDebug(areaVectorField, 0);
defineTemplateTypeNameAndDebug(areaSphericalTensorField, 0);

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2016-2017 Wikki Ltd
Copyright (C) 2018-2022 OpenCFD Ltd.
Copyright (C) 2018-2023 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -75,6 +75,7 @@ using AreaInternalField = DimensionedField<Type, areaMesh>;
// Typedefs
typedef GeometricField<label, faPatchField, areaMesh> areaLabelField;
typedef GeometricField<scalar, faPatchField, areaMesh> areaScalarField;
typedef GeometricField<vector, faPatchField, areaMesh> areaVectorField;
typedef GeometricField<sphericalTensor, faPatchField, areaMesh>

View File

@ -6,6 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2016-2017 Wikki Ltd
Copyright (C) 2023 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -33,12 +34,14 @@ License
namespace Foam
{
defineTemplateTypeNameAndDebug(edgeLabelField::Internal, 0);
defineTemplateTypeNameAndDebug(edgeScalarField::Internal, 0);
defineTemplateTypeNameAndDebug(edgeVectorField::Internal, 0);
defineTemplateTypeNameAndDebug(edgeSphericalTensorField::Internal, 0);
defineTemplateTypeNameAndDebug(edgeSymmTensorField::Internal, 0);
defineTemplateTypeNameAndDebug(edgeTensorField::Internal, 0);
defineTemplateTypeNameAndDebug(edgeLabelField, 0);
defineTemplateTypeNameAndDebug(edgeScalarField, 0);
defineTemplateTypeNameAndDebug(edgeVectorField, 0);
defineTemplateTypeNameAndDebug(edgeSphericalTensorField, 0);

View File

@ -60,6 +60,7 @@ template<class Type> class faePatchField;
// Typedefs
typedef GeometricField<label, faePatchField, edgeMesh> edgeLabelField;
typedef GeometricField<scalar, faePatchField, edgeMesh> edgeScalarField;
typedef GeometricField<vector, faePatchField, edgeMesh> edgeVectorField;
typedef GeometricField<sphericalTensor, faePatchField, edgeMesh>

View File

@ -6,6 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2016-2017 Wikki Ltd
Copyright (C) 2023 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -95,13 +96,23 @@ template<class Type>
Foam::tmp<Foam::Field<Type>>
Foam::basicSymmetryFaPatchField<Type>::snGrad() const
{
const vectorField nHat(this->patch().edgeNormals());
if (pTraits<Type>::rank == 0)
{
// Transform-invariant types
return tmp<Field<Type>>::New(this->size(), Zero);
}
else
{
symmTensorField rot(I - 2.0*sqr(this->patch().edgeNormals()));
return
(
transform(I - 2.0*sqr(nHat), this->patchInternalField())
- this->patchInternalField()
)*(this->patch().deltaCoeffs()/2.0);
Field<Type> pif(this->patchInternalField());
return
(
(transform(rot, pif) - pif)
* (this->patch().deltaCoeffs()/2.0)
);
}
}
@ -113,14 +124,19 @@ void Foam::basicSymmetryFaPatchField<Type>::evaluate(const Pstream::commsTypes)
this->updateCoeffs();
}
const vectorField nHat(this->patch().edgeNormals());
Field<Type>::operator=
(
(
this->patchInternalField()
+ transform(I - 2.0*sqr(nHat), this->patchInternalField())
)/2.0
);
if (pTraits<Type>::rank == 0)
{
// Transform-invariant types
Field<Type>::operator=(this->patchInternalField());
}
else
{
symmTensorField rot(I - 2.0*sqr(this->patch().edgeNormals()));
Field<Type> pif(this->patchInternalField());
Field<Type>::operator=((pif + transform(rot, pif))/2.0);
}
transformFaPatchField<Type>::evaluate();
}

View File

@ -38,8 +38,8 @@ SourceFiles
\*---------------------------------------------------------------------------*/
#ifndef basicSymmetryFaPatchField_H
#define basicSymmetryFaPatchField_H
#ifndef Foam_basicSymmetryFaPatchField_H
#define Foam_basicSymmetryFaPatchField_H
#include "transformFaPatchField.H"
#include "symmetryFaPatch.H"
@ -58,7 +58,6 @@ class basicSymmetryFaPatchField
:
public transformFaPatchField<Type>
{
public:
// Constructors
@ -71,6 +70,7 @@ public:
);
//- Construct from patch, internal field and dictionary
// The "value" entry: NO_READ
basicSymmetryFaPatchField
(
const faPatch&,
@ -78,7 +78,8 @@ public:
const dictionary&
);
//- Construct by mapping given basicSymmetryFaPatchField onto a new patch
//- Construct by mapping given basicSymmetryFaPatchField
//- onto a new patch
basicSymmetryFaPatchField
(
const basicSymmetryFaPatchField<Type>&,
@ -130,8 +131,6 @@ public:
virtual tmp<Field<Type>> snGrad() const;
//- Evaluate the patch field
// Default argument needed to allow call in constructors
// HJ, 30/Jun/2009
virtual void evaluate
(
const Pstream::commsTypes commsType = Pstream::commsTypes::blocking
@ -142,18 +141,6 @@ public:
};
// * * * * * * * * * * * Template Specialisations * * * * * * * * * * * * * //
template<>
tmp<scalarField> basicSymmetryFaPatchField<scalar>::snGrad() const;
template<>
void basicSymmetryFaPatchField<scalar>::evaluate
(
const Pstream::commsTypes commsType
);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam

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