Compare commits

...

26 Commits

Author SHA1 Message Date
5cf529659d ENH: selection mechanism for cloudInfo function object (#2390)
- can restrict calculation of D32 and other spray properties to a
  subset of parcels. Uses a predicate selection mechanism similar to
  vtkCloud etc.
2022-03-04 15:49:34 +01:00
b94ffe93f1 ENH: Adding lower and upper bounds to nonUniformTable index 2022-03-03 09:17:57 -08:00
3c2db201b7 BUG: createPatch: make tutorial run parallel. See #2386 2022-03-02 14:49:50 +00:00
eb676f08a1 BUG: access of non-const tmp value in surface writers
- was inadvertently introduced with the previous commit.
  Affected non-parallel use of the surface writers.
2022-03-02 15:12:59 +01:00
666e5f6dc4 GIT: remove stray file, fix server documentation path 2022-03-02 15:12:59 +01:00
a74b9ca763 ENH: createPatch: handle multiple regions. Fixes #2386
Also #1361.
2022-03-02 13:14:30 +00:00
1a55829ef9 ENH: add fieldLevel handling for surface writers (#2382)
- this can be used to apply a uniform field level to remove from
  a sampled field. For example,

      fieldLevel
      {
          "p.*"   1e5;        // Absolute -> gauge [Pa]
          T       273.15;     // [K] -> [C]
          U       #eval{ 10/sqrt(3) };  // Uniform mag(U)=10
      }

  After the fieldLevel has been removed, any fieldScale is applied.
  For example

      fieldScale
      {
          "p.*"   0.01;       // [Pa] -> [mbar]
      }

  The fieldLevel for vector and tensor fields may still need some
  further refinement.
2022-02-28 19:08:39 +01:00
cb10045094 ENH: add createNamedPolyMeshes.H file 2022-02-28 19:03:40 +01:00
02f57f8a36 ENH: use '<constant>' and '<system>' tags when creating relative names
- symmetric with expand()
2022-02-28 09:31:59 +01:00
fc43ed9d68 GIT: adjust for rebase edit of feature-runTimeControl-recycle 2022-02-28 09:22:06 +01:00
3c1da487f2 Merge branch 'feature-runTimeControl-recycle' into 'develop'
ENH: runTimeControl - enable resetting the trigger to an earlier instant

See merge request Development/openfoam!523
2022-02-25 16:18:01 +00:00
3d134167dd ENH: Refactored valueAverage FO and average runTimeCondition 2022-02-25 16:08:47 +01:00
bb04f5759d ENH: runTimeControl - enable resetting the trigger to an earlier instant
The runTimeControl function object can activate further function objects using
triggers. Previously the trigger index could only advance; this change set
allows users to set smaller values to enable function object recycling, e.g.

Repeat for N cycles:
1. average the pressure at a point in space
2. when the average stabilises, run for a further 100 iterations
3. set a new patch inlet velocity
  - back to (1)

- Removes old default behaviour that only permitted an increase in the
  trigger level. This type of 'ratcheting' mechanism (if required) is
  now the responsibility of the derived function object.
2022-02-25 15:39:26 +01:00
53c2eae543 ENH: runTimeControl - added 'none' condition as a no-op 2022-02-25 15:39:22 +01:00
fcb328332b Merge branch 'feature-clipped-AMIMethod' into 'develop'
ENH: cyclicAMI: extend faceAreaWeight to filter. See #2378

See merge request Development/openfoam!527
2022-02-24 11:56:53 +00:00
f46c398372 ENH: cyclicAMI: extend faceAreaWeight to filter. See #2378 2022-02-24 11:56:52 +00:00
ff8518a89a ENH: snappyHexMesh: express small regions. Fixes #2379
Extend selection of small cells to use absolute cell count
2022-02-24 09:44:53 +00:00
5386dd56db ENH: avoid read/write of empty slots for globalIndex gather 2022-02-21 19:53:21 +01:00
59dbee741f STYLE: use globalIndex localSize(), totalSize() in more places
- more explicit meaning than offset(), size() - respectively.
2022-02-21 19:53:21 +01:00
055a7b29e0 ENH: ensure indices are properly reset in SortList
- use more ListOps functions, add uniqueSort() method
2022-02-21 19:53:21 +01:00
711e1142ed BUG: FixedList/Pair writeEntry not re-readable (fixes #2351)
- notably affects writing continuous data in binary. If generating a
  compound token (eg, List<label>), need to add in the size prefix
  otherwise it cannot actually be parsed properly as a List.

BUG: bad fallthrough for compound reading (FixedList)

- the branch was likely never reached, but would have attempted to
  read twice due to a bad fall-through condition.
2022-02-21 19:53:21 +01:00
2a25b356b9 ENH: use GeometricField type aliases in sampling and expressions 2022-02-21 19:53:21 +01:00
a67f6bf7ae ENH: direct support of wordRes::filter in stringListOps 2022-02-21 19:53:21 +01:00
42f426f6c4 ENH: relocate graph writers to meshTools (not reqd by core OpenFOAM lib)
GIT: relocate globalIndex (is independent of mesh)

STYLE: include label/scalar Fwd in contiguous.H

STYLE: unneed commSchedule include in GeometricField
2022-02-21 19:53:21 +01:00
58f76ccc5f ENH: checkMesh: correct AMI weight directory. See #2356. 2022-02-21 16:14:08 +00:00
ad6f17652b BUG: uninitialized file pointer in thermoCoupleProbes (fixes #2365)
- as a side-effect of changes to probes, the file pointers are not
  automatically creating when reading the dictionary but delayed
  until prepare(WRITE_ACTION) is called.
  This nuance was missed in thermoCoupleProbes.
2022-02-17 12:44:56 +01:00
204 changed files with 4494 additions and 1766 deletions

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011 OpenFOAM Foundation Copyright (C) 2011 OpenFOAM Foundation
Copyright (C) 2017-2020 OpenCFD Ltd. Copyright (C) 2017-2022 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -196,19 +196,23 @@ int main(int argc, char *argv[])
SortList<scalar> sorter1(list1); SortList<scalar> sorter1(list1);
Info<< nl << "Sorted: " << flatOutput(sorter1) << nl;
Info<< nl << "Sort indices: " << flatOutput(sorter1.indices()) << nl; Info<< nl << "Sort indices: " << flatOutput(sorter1.indices()) << nl;
Info<< nl << "Reverse indices: " << flatOutput(sorter1.indices()) << nl; // Reverses indices
sorter1.reverse(); sorter1.reverse();
Info<< nl << "Again indices: " << flatOutput(sorter1.indices()) << nl; Info<< nl << "Reverse: " << flatOutput(sorter1.indices()) << nl;
sorter1.reset();
Info<< nl << "Reset indices: " << flatOutput(sorter1.indices()) << nl;
sorter1.reverseSort(); sorter1.reverseSort();
Info<< nl << "Reverse indices: " << flatOutput(sorter1.indices()) << nl; Info<< nl << "Reverse indices: " << flatOutput(sorter1.indices()) << nl;
Info<< nl << "Sorted : " << flatOutput(sorter1) << nl; Info<< nl << "Reverse sorted: " << flatOutput(sorter1) << nl;
sorter1.sort(std::greater<scalar>()); sorter1.sort(std::greater<scalar>());

View File

@ -1015,7 +1015,10 @@ Foam::label Foam::checkGeometry
const fileName outputDir const fileName outputDir
( (
mesh.time().globalPath()/functionObject::outputPrefix/"checkMesh" mesh.time().globalPath()
/functionObject::outputPrefix
/(mesh.name() == polyMesh::defaultRegion ? word::null : mesh.name())
/"checkMesh"
); );
forAll(pbm, patchi) forAll(pbm, patchi)
@ -1031,7 +1034,6 @@ Foam::label Foam::checkGeometry
<< cpp.name() << " and neighbour patch: " << cpp.name() << " and neighbour patch: "
<< cpp.neighbPatch().name() << endl; << cpp.neighbPatch().name() << endl;
const word pName("patch" + Foam::name(cpp.index()));
const AMIPatchToPatchInterpolation& ami = cpp.AMI(); const AMIPatchToPatchInterpolation& ami = cpp.AMI();
{ {
@ -1044,7 +1046,7 @@ Foam::label Foam::checkGeometry
( (
mesh, mesh,
wr, wr,
outputDir / pName + "-src_" + tmName, outputDir / cpp.name() + "-src_" + tmName,
ami.srcWeightsSum(), ami.srcWeightsSum(),
cpp.localFaces(), cpp.localFaces(),
cpp.meshPoints(), cpp.meshPoints(),
@ -1070,7 +1072,7 @@ Foam::label Foam::checkGeometry
( (
mergedPoints, mergedPoints,
mergedFaces, mergedFaces,
(outputDir / pName + "-src_" + tmName), (outputDir / cpp.name() + "-src_" + tmName),
false // serial - already merged false // serial - already merged
); );
@ -1080,6 +1082,8 @@ Foam::label Foam::checkGeometry
} }
} }
{ {
const auto& nbrPp = cpp.neighbPatch();
// Collect geometry // Collect geometry
faceList mergedFaces; faceList mergedFaces;
pointField mergedPoints; pointField mergedPoints;
@ -1089,11 +1093,14 @@ Foam::label Foam::checkGeometry
( (
mesh, mesh,
wr, wr,
outputDir / pName + "-tgt_" + tmName, (
outputDir
/ nbrPp.name() + "-tgt_" + tmName
),
ami.tgtWeightsSum(), ami.tgtWeightsSum(),
cpp.neighbPatch().localFaces(), nbrPp.localFaces(),
cpp.neighbPatch().meshPoints(), nbrPp.meshPoints(),
cpp.neighbPatch().meshPointMap(), nbrPp.meshPointMap(),
mergedFaces, mergedFaces,
mergedPoints, mergedPoints,
@ -1118,7 +1125,10 @@ Foam::label Foam::checkGeometry
( (
mergedPoints, mergedPoints,
mergedFaces, mergedFaces,
(outputDir / pName + "-tgt_" + tmName), (
outputDir
/ nbrPp.name() + "-tgt_" + tmName
),
false // serial - already merged false // serial - already merged
); );
@ -1135,8 +1145,6 @@ Foam::label Foam::checkGeometry
const auto& cpp = refCast<const mappedPatchBase>(pp); const auto& cpp = refCast<const mappedPatchBase>(pp);
const AMIPatchToPatchInterpolation& ami = cpp.AMI(); const AMIPatchToPatchInterpolation& ami = cpp.AMI();
const word pName("patch" + Foam::name(patchi));
// Collect geometry // Collect geometry
faceList mergedFaces; faceList mergedFaces;
pointField mergedPoints; pointField mergedPoints;
@ -1146,7 +1154,7 @@ Foam::label Foam::checkGeometry
( (
mesh, mesh,
wr, wr,
outputDir / pName + "-src_" + tmName, outputDir / pp.name() + "-src_" + tmName,
ami.srcWeightsSum(), ami.srcWeightsSum(),
pp.localFaces(), pp.localFaces(),
pp.meshPoints(), pp.meshPoints(),
@ -1173,7 +1181,7 @@ Foam::label Foam::checkGeometry
( (
cpp.sampleMesh(), cpp.sampleMesh(),
wr, wr,
outputDir / pName + "-tgt_" + tmName, outputDir / nbrPp.name() + "-tgt_" + tmName,
ami.tgtWeightsSum(), ami.tgtWeightsSum(),
nbrPp.localFaces(), nbrPp.localFaces(),
nbrPp.meshPoints(), nbrPp.meshPoints(),

View File

@ -98,11 +98,13 @@ void matchPatchFaces
const labelList& patchesj, const labelList& patchesj,
DynamicList<labelList>& interfaceMesh0, DynamicList<labelList>& interfaceMesh0,
DynamicList<label>& interfaceSource0,
DynamicList<labelList>& interfacePatch0, DynamicList<labelList>& interfacePatch0,
DynamicList<wordList>& interfaceNames0, DynamicList<wordList>& interfaceNames0,
DynamicList<List<DynamicList<label>>>& interfaceFaces0, DynamicList<List<DynamicList<label>>>& interfaceFaces0,
DynamicList<labelList>& interfaceMesh1, DynamicList<labelList>& interfaceMesh1,
DynamicList<label>& interfaceSource1,
DynamicList<labelList>& interfacePatch1, DynamicList<labelList>& interfacePatch1,
DynamicList<wordList>& interfaceNames1, DynamicList<wordList>& interfaceNames1,
DynamicList<List<DynamicList<label>>>& interfaceFaces1 DynamicList<List<DynamicList<label>>>& interfaceFaces1
@ -136,8 +138,10 @@ void matchPatchFaces
Info<< "Introducing interface " << inti << " between" Info<< "Introducing interface " << inti << " between"
<< " mesh " << meshes[meshi].name() << " mesh " << meshes[meshi].name()
//<< " source:" << sourcei
<< " patch " << ppi.name() << " patch " << ppi.name()
<< " and mesh " << meshes[meshj].name() << " and mesh " << meshes[meshj].name()
//<< " source:" << sourcej
<< " patch " << ppj.name() << " patch " << ppj.name()
<< endl; << endl;
@ -149,6 +153,8 @@ void matchPatchFaces
intMesh0.setSize(nSourcei, -1); intMesh0.setSize(nSourcei, -1);
intMesh0[sourcei] = meshi; intMesh0[sourcei] = meshi;
interfaceSource0.append(sourcei);
interfacePatch0.append(labelList()); interfacePatch0.append(labelList());
auto& intPatch0 = interfacePatch0.last(); auto& intPatch0 = interfacePatch0.last();
intPatch0.setSize(nSourcei, -1); intPatch0.setSize(nSourcei, -1);
@ -157,15 +163,11 @@ void matchPatchFaces
interfaceNames0.append(wordList()); interfaceNames0.append(wordList());
auto& intNames0 = interfaceNames0.last(); auto& intNames0 = interfaceNames0.last();
intNames0.setSize(nSourcei); intNames0.setSize(nSourcei);
//intNames0[sourcei] =
// meshes[meshi].name()
// + "_to_"
// + meshes[meshj].name();
intNames0[sourcei] = intNames0[sourcei] =
patchName(entryName, meshes[meshi], meshes[meshj]); patchName(entryName, meshes[meshi], meshes[meshj]);
// Mesh 0 // Mesh 1
//~~~~~~~ //~~~~~~~
interfaceMesh1.append(labelList()); interfaceMesh1.append(labelList());
@ -173,6 +175,8 @@ void matchPatchFaces
intMesh1.setSize(nSourcej, -1); intMesh1.setSize(nSourcej, -1);
intMesh1[sourcej] = meshj; intMesh1[sourcej] = meshj;
interfaceSource1.append(sourcej);
interfacePatch1.append(labelList()); interfacePatch1.append(labelList());
auto& intPatch1 = interfacePatch1.last(); auto& intPatch1 = interfacePatch1.last();
intPatch1.setSize(nSourcej, -1); intPatch1.setSize(nSourcej, -1);
@ -181,10 +185,6 @@ void matchPatchFaces
interfaceNames1.append(wordList()); interfaceNames1.append(wordList());
auto& intNames1 = interfaceNames1.last(); auto& intNames1 = interfaceNames1.last();
intNames1.setSize(nSourcej); intNames1.setSize(nSourcej);
//intNames1[sourcej] =
// meshes[meshj].name()
// + "_to_"
// + meshes[meshi].name();
intNames1[sourcej] = intNames1[sourcej] =
patchName(entryName, meshes[meshj], meshes[meshi]); patchName(entryName, meshes[meshj], meshes[meshi]);
@ -283,11 +283,13 @@ void matchPatchFaces
List<PtrList<dictionary>> patchInfoDicts, List<PtrList<dictionary>> patchInfoDicts,
DynamicList<labelList>& interfaceMesh0, DynamicList<labelList>& interfaceMesh0,
DynamicList<label>& interfaceSource0,
DynamicList<labelList>& interfacePatch0, DynamicList<labelList>& interfacePatch0,
DynamicList<List<DynamicList<label>>>& interfaceFaces0, DynamicList<List<DynamicList<label>>>& interfaceFaces0,
DynamicList<wordList>& interfaceNames0, DynamicList<wordList>& interfaceNames0,
DynamicList<labelList>& interfaceMesh1, DynamicList<labelList>& interfaceMesh1,
DynamicList<label>& interfaceSource1,
DynamicList<labelList>& interfacePatch1, DynamicList<labelList>& interfacePatch1,
DynamicList<List<DynamicList<label>>>& interfaceFaces1, DynamicList<List<DynamicList<label>>>& interfaceFaces1,
DynamicList<wordList>& interfaceNames1 DynamicList<wordList>& interfaceNames1
@ -338,11 +340,13 @@ void matchPatchFaces
patchesj, patchesj,
interfaceMesh0, interfaceMesh0,
interfaceSource0,
interfacePatch0, interfacePatch0,
interfaceNames0, interfaceNames0,
interfaceFaces0, interfaceFaces0,
interfaceMesh1, interfaceMesh1,
interfaceSource1,
interfacePatch1, interfacePatch1,
interfaceNames1, interfaceNames1,
interfaceFaces1 interfaceFaces1
@ -413,10 +417,23 @@ void changePatchID
if (!isRepatchedBoundary.set(facei-mesh.nInternalFaces())) if (!isRepatchedBoundary.set(facei-mesh.nInternalFaces()))
{ {
FatalErrorInFunction static label nWarnings = 0;
<< "Face " << facei << " is already marked to be moved" if (nWarnings == 0)
<< " to patch " << meshMod.region()[facei] {
<< exit(FatalError); const label newPatchi = meshMod.region()[facei];
//FatalErrorInFunction
WarningInFunction
<< "Face " << facei
<< " at " << mesh.faceCentres()[facei]
<< " marked for patch " << patchID
<< " name " << mesh.boundaryMesh()[patchID].name()
<< " is already marked for patch " << newPatchi
<< " name " << mesh.boundaryMesh()[newPatchi].name()
<< ". Suppressing further warnings"
//<< exit(FatalError);
<< endl;
}
nWarnings++;
} }
changePatchID(mesh, facei, patchID, meshMod); changePatchID(mesh, facei, patchID, meshMod);
@ -721,7 +738,6 @@ int main(int argc, char *argv[])
); );
#include "addOverwriteOption.H" #include "addOverwriteOption.H"
//#include "addRegionOption.H"
#include "addAllRegionOptions.H" #include "addAllRegionOptions.H"
argList::addOption("dict", "file", "Alternative createPatchDict"); argList::addOption("dict", "file", "Alternative createPatchDict");
@ -780,17 +796,25 @@ int main(int argc, char *argv[])
forAll(patchSources, sourcei) forAll(patchSources, sourcei)
{ {
const auto& pDict = patchSources[sourcei]; const auto& pDict = patchSources[sourcei];
patchNames[meshi][sourcei] = pDict.get<word>("name"); patchNames[meshi][sourcei] = pDict.getOrDefault<word>
(
"name",
word::null,
keyType::LITERAL
);
patchInfoDicts[meshi].set patchInfoDicts[meshi].set
( (
sourcei, sourcei,
new dictionary(pDict.subDict("patchInfo")) new dictionary(pDict.subDict("patchInfo"))
); );
const dictionary& patchDict = patchInfoDicts[meshi][sourcei]; dictionary& patchDict = patchInfoDicts[meshi][sourcei];
if (patchDict.found("AMIMethod")) if (patchDict.found("AMIMethod"))
{ {
matchMethods[meshi][sourcei] = patchDict.get<word>("AMIMethod"); matchMethods[meshi][sourcei] = patchDict.get<word>("AMIMethod");
// Disable full matching since we're trying to use AMIMethod to
// find out actual overlap
patchDict.add("requireMatch", false);
} }
wordRes matchNames; wordRes matchNames;
@ -817,9 +841,11 @@ int main(int argc, char *argv[])
// It matches all mesh against each other. Lower numbered mesh gets // It matches all mesh against each other. Lower numbered mesh gets
// postfix 0, higher numbered mesh postfix 1. // postfix 0, higher numbered mesh postfix 1.
// Per interface, per mesh, per patchSource: // Per interface, per patchSource:
// 1. the lower numbered mesh // 1. the lower numbered mesh
DynamicList<labelList> interfaceMesh0; DynamicList<labelList> interfaceMesh0;
// 1b. the source index (i.e. the patch dictionary)
DynamicList<label> interfaceSource0;
// 2. the patch on the interfaceMesh0 // 2. the patch on the interfaceMesh0
DynamicList<labelList> interfacePatch0; DynamicList<labelList> interfacePatch0;
// 3. the facelabels on the interfaceMesh0 // 3. the facelabels on the interfaceMesh0
@ -829,6 +855,7 @@ int main(int argc, char *argv[])
// Same for the higher numbered mesh // Same for the higher numbered mesh
DynamicList<labelList> interfaceMesh1; DynamicList<labelList> interfaceMesh1;
DynamicList<label> interfaceSource1;
DynamicList<labelList> interfacePatch1; DynamicList<labelList> interfacePatch1;
DynamicList<List<DynamicList<label>>> interfaceFaces1; DynamicList<List<DynamicList<label>>> interfaceFaces1;
DynamicList<wordList> interfaceNames1; DynamicList<wordList> interfaceNames1;
@ -843,15 +870,17 @@ int main(int argc, char *argv[])
interRegionSources, interRegionSources,
patchNames, patchNames,
matchPatchIDs, matchPatchIDs,
matchMethods, //faceAreaWeightAMI2D::typeName, matchMethods,
patchInfoDicts, patchInfoDicts,
interfaceMesh0, interfaceMesh0,
interfaceSource0,
interfacePatch0, interfacePatch0,
interfaceFaces0, interfaceFaces0,
interfaceNames0, interfaceNames0,
interfaceMesh1, interfaceMesh1,
interfaceSource1,
interfacePatch1, interfacePatch1,
interfaceFaces1, interfaceFaces1,
interfaceNames1 interfaceNames1
@ -859,6 +888,7 @@ int main(int argc, char *argv[])
} }
// Read fields // Read fields
List<PtrList<volScalarField>> vsFlds(meshes.size()); List<PtrList<volScalarField>> vsFlds(meshes.size());
List<PtrList<volVectorField>> vvFlds(meshes.size()); List<PtrList<volVectorField>> vvFlds(meshes.size());
@ -914,6 +944,9 @@ int main(int argc, char *argv[])
forAll(meshes, meshi) forAll(meshes, meshi)
{ {
fvMesh& mesh = meshes[meshi]; fvMesh& mesh = meshes[meshi];
Info<< "\n\nAdding patches to mesh " << mesh.name() << nl << endl;
const polyBoundaryMesh& patches = mesh.boundaryMesh(); const polyBoundaryMesh& patches = mesh.boundaryMesh();
const dictionary& dict = dicts[meshi]; const dictionary& dict = dicts[meshi];
@ -933,11 +966,20 @@ int main(int argc, char *argv[])
{ {
const dictionary& dict = patchSources[sourcei]; const dictionary& dict = patchSources[sourcei];
const word sourceType(dict.get<word>("constructFrom")); const word sourceType(dict.get<word>("constructFrom"));
const word patchName(dict.get<word>("name")); const word patchName
(
dict.getOrDefault<word>
(
"name",
word::null,
keyType::LITERAL
)
);
dictionary patchDict(dict.subDict("patchInfo")); dictionary patchDict(patchInfoDicts[meshi][sourcei]);
patchDict.set("nFaces", 0); patchDict.set("nFaces", 0);
patchDict.set("startFace", 0); //startFacei); patchDict.set("startFace", 0); // Gets overwritten
if (sourceType == "autoPatch") if (sourceType == "autoPatch")
{ {
@ -951,42 +993,45 @@ int main(int argc, char *argv[])
const labelList& allMeshes1 = interfaceMesh1[inti]; const labelList& allMeshes1 = interfaceMesh1[inti];
const wordList& allNames1 = interfaceNames1[inti]; const wordList& allNames1 = interfaceNames1[inti];
forAll(allMeshes0, sourcei) if
(
interfaceSource0[inti] == sourcei
&& allMeshes0[sourcei] == meshi
)
{ {
if (allMeshes0[sourcei] == meshi) // Current mesh is mesh0. mesh1 is the remote mesh.
const label sourcej = interfaceSource1[inti];
const word& patchName = allNames0[sourcei];
if (patches.findPatchID(patchName) == -1)
{ {
const auto& mesh1 = meshes[allMeshes1[sourcei]]; dictionary allDict(patchDict);
const word& patchName = allNames0[sourcei]; const auto& mesh1 = meshes[allMeshes1[sourcej]];
if (patches.findPatchID(patchName) == -1) allDict.set("sampleRegion", mesh1.name());
{ const auto& destPatch = allNames1[sourcej];
dictionary allDict(patchDict); allDict.set("samplePatch", destPatch);
allDict.set("sampleRegion", mesh1.name()); allDict.set("neighbourPatch", destPatch);
const auto& destPatch = allNames1[sourcei];
allDict.set("samplePatch", destPatch);
allDict.set("neighbourPatch", destPatch);
Info<< "Adding new patch " << patchName Info<< "Adding new patch " << patchName
<< " from " << allDict << endl; << " from " << allDict << endl;
autoPtr<polyPatch> ppPtr autoPtr<polyPatch> ppPtr
(
polyPatch::New
( (
polyPatch::New patchName,
( allDict,
patchName, 0, // overwritten
allDict, patches
0, // overwritten )
patches );
) fvMeshTools::addPatch
); (
fvMeshTools::addPatch mesh,
( ppPtr(),
mesh, patchDict.subOrEmptyDict("patchFields"),
ppPtr(), calculatedFvPatchScalarField::typeName,
patchDict.subOrEmptyDict("patchFields"), true
calculatedFvPatchScalarField::typeName, );
true
);
}
} }
} }
} }
@ -998,42 +1043,46 @@ int main(int argc, char *argv[])
const labelList& allMeshes1 = interfaceMesh1[inti]; const labelList& allMeshes1 = interfaceMesh1[inti];
const wordList& allNames1 = interfaceNames1[inti]; const wordList& allNames1 = interfaceNames1[inti];
forAll(allMeshes1, sourcei) if
(
interfaceSource1[inti] == sourcei
&& allMeshes1[sourcei] == meshi
)
{ {
if (allMeshes1[sourcei] == meshi) // Current mesh is mesh1. mesh0 is the remote mesh.
const label sourcej = interfaceSource0[inti];
const word& patchName = allNames1[sourcei];
if (patches.findPatchID(patchName) == -1)
{ {
const auto& mesh0 = meshes[allMeshes0[sourcei]]; dictionary allDict(patchDict);
const word& patchName = allNames1[sourcei]; const auto& destPatch = allNames0[sourcej];
if (patches.findPatchID(patchName) == -1) const auto& mesh0 = meshes[allMeshes0[sourcej]];
{ allDict.set("sampleRegion", mesh0.name());
dictionary allDict(patchDict); allDict.set("samplePatch", destPatch);
const auto& destPatch = allNames0[sourcei]; allDict.set("neighbourPatch", destPatch);
allDict.set("sampleRegion", mesh0.name());
allDict.set("samplePatch", destPatch);
allDict.set("neighbourPatch", destPatch);
Info<< "Adding new patch " << patchName Info<< "Adding new patch " << patchName
<< " from " << allDict << endl; << " from " << allDict << endl;
autoPtr<polyPatch> ppPtr autoPtr<polyPatch> ppPtr
(
polyPatch::New
( (
polyPatch::New patchName,
( allDict,
patchName, 0, // overwritten
allDict, patches
0, // overwritten )
patches );
) fvMeshTools::addPatch
); (
fvMeshTools::addPatch mesh,
( ppPtr(),
mesh, patchDict.subOrEmptyDict("patchFields"),
ppPtr(), calculatedFvPatchScalarField::typeName,
patchDict.subOrEmptyDict("patchFields"), true
calculatedFvPatchScalarField::typeName, );
true
);
}
} }
} }
} }
@ -1077,6 +1126,10 @@ int main(int argc, char *argv[])
forAll(meshes, meshi) forAll(meshes, meshi)
{ {
fvMesh& mesh = meshes[meshi]; fvMesh& mesh = meshes[meshi];
Info<< "\n\nRepatching mesh " << mesh.name() << nl << endl;
const polyBoundaryMesh& patches = mesh.boundaryMesh(); const polyBoundaryMesh& patches = mesh.boundaryMesh();
const dictionary& dict = dicts[meshi]; const dictionary& dict = dicts[meshi];
@ -1096,7 +1149,15 @@ int main(int argc, char *argv[])
forAll(patchSources, sourcei) forAll(patchSources, sourcei)
{ {
const dictionary& dict = patchSources[sourcei]; const dictionary& dict = patchSources[sourcei];
const word patchName(dict.get<word>("name")); const word patchName
(
dict.getOrDefault<word>
(
"name",
word::null,
keyType::LITERAL
)
);
const word sourceType(dict.get<word>("constructFrom")); const word sourceType(dict.get<word>("constructFrom"));
if (sourceType == "autoPatch") if (sourceType == "autoPatch")
@ -1111,49 +1172,57 @@ int main(int argc, char *argv[])
const wordList& allNames1 = interfaceNames1[inti]; const wordList& allNames1 = interfaceNames1[inti];
const auto& allFaces1 = interfaceFaces1[inti]; const auto& allFaces1 = interfaceFaces1[inti];
forAll(allMeshes0, sourcei) if
(
interfaceSource0[inti] == sourcei
&& allMeshes0[sourcei] == meshi
)
{ {
if (allMeshes0[sourcei] == meshi) // Current mesh is mesh0. mesh1 is the remote mesh.
{
const label destPatchi =
patches.findPatchID(allNames0[sourcei], false);
Pout<< "Matched mesh:" << mesh.name() const label destPatchi =
<< " to mesh:" patches.findPatchID(allNames0[sourcei], false);
<< meshes[allMeshes1[sourcei]].name()
<< " through:" << allNames0[sourcei] << endl;
changePatchID //const auto& mesh1 =
( // meshes[allMeshes1[interfaceSource1[inti]]];
mesh, //Pout<< "Matched mesh:" << mesh.name()
allFaces0[sourcei], // << " to mesh:" << mesh1.name()
destPatchi, // << " through:" << allNames0[sourcei] << endl;
isRepatchedBoundary,
meshMod changePatchID
); (
} mesh,
allFaces0[sourcei],
destPatchi,
isRepatchedBoundary,
meshMod
);
} }
forAll(allMeshes1, sourcei) if
(
interfaceSource1[inti] == sourcei
&& allMeshes1[sourcei] == meshi
)
{ {
if (allMeshes1[sourcei] == meshi) // Current mesh is mesh1. mesh0 is the remote mesh.
{
const label destPatchi =
patches.findPatchID(allNames1[sourcei], false);
Pout<< "Matched mesh:" << mesh.name() const label destPatchi =
<< " to mesh:" patches.findPatchID(allNames1[sourcei], false);
<< meshes[allMeshes0[sourcei]].name()
<< " through:" << allNames1[sourcei] << endl;
changePatchID //const auto& mesh0 =
( // meshes[allMeshes0[interfaceSource0[inti]]];
mesh, //Pout<< "Matched mesh:" << mesh.name()
allFaces1[sourcei], // << " to mesh:" << mesh0.name()
destPatchi, // << " through:" << allNames1[sourcei] << endl;
isRepatchedBoundary,
meshMod changePatchID
); (
} mesh,
allFaces1[sourcei],
destPatchi,
isRepatchedBoundary,
meshMod
);
} }
} }
} }
@ -1213,7 +1282,6 @@ int main(int argc, char *argv[])
<< exit(FatalError); << exit(FatalError);
} }
} }
Info<< endl;
// Change mesh, use inflation to reforce calculation of transformation // Change mesh, use inflation to reforce calculation of transformation
@ -1398,10 +1466,6 @@ int main(int argc, char *argv[])
{ {
dumpCyclicMatch("final_", mesh); dumpCyclicMatch("final_", mesh);
} }
// Set the precision of the points data to 10
IOstream::defaultPrecision(max(10u, IOstream::defaultPrecision()));
} }
if (!overwrite) if (!overwrite)
@ -1418,11 +1482,14 @@ int main(int argc, char *argv[])
} }
} }
// Set the precision of the points data to 10
IOstream::defaultPrecision(max(10u, IOstream::defaultPrecision()));
// Write resulting mesh // Write resulting mesh
forAll(meshes, meshi) forAll(meshes, meshi)
{ {
fvMesh& mesh = meshes[meshi]; fvMesh& mesh = meshes[meshi];
Info<< "Writing repatched mesh " << mesh.name() Info<< "\n\nWriting repatched mesh " << mesh.name()
<< " to " << runTime.timeName() << nl << endl; << " to " << runTime.timeName() << nl << endl;
mesh.clearOut(); // remove meshPhi mesh.clearOut(); // remove meshPhi
mesh.write(); mesh.write();

View File

@ -1,9 +1,14 @@
EXE_INC = \ EXE_INC = \
-I$(LIB_SRC)/fileFormats/lnInclude \
-I$(LIB_SRC)/surfMesh/lnInclude \ -I$(LIB_SRC)/surfMesh/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude \
-I$(LIB_SRC)/sampling/lnInclude \ -I$(LIB_SRC)/sampling/lnInclude \
-I$(LIB_SRC)/randomProcesses/lnInclude \ -I$(LIB_SRC)/randomProcesses/lnInclude \
-I$(FFTW_INC_DIR) -I$(FFTW_INC_DIR)
EXE_LIBS = \ EXE_LIBS = \
-lfileFormats \
-lsurfMesh \
-lmeshTools \
-lsampling \ -lsampling \
-lrandomProcesses -lrandomProcesses

View File

@ -1,9 +1,13 @@
EXE_INC = \ EXE_INC = \
-I$(LIB_SRC)/finiteVolume/lnInclude \ -I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/fileFormats/lnInclude \
-I$(LIB_SRC)/surfMesh/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude \ -I$(LIB_SRC)/meshTools/lnInclude \
-I$(LIB_SRC)/randomProcesses/lnInclude -I$(LIB_SRC)/randomProcesses/lnInclude
EXE_LIBS = \ EXE_LIBS = \
-lfiniteVolume \ -lfiniteVolume \
-lfileFormats \
-lsurfMesh \
-lmeshTools \ -lmeshTools \
-lrandomProcesses -lrandomProcesses

View File

@ -480,6 +480,8 @@ castellatedMeshControls
// when generating meshes with faceZones as baffles or boundary // when generating meshes with faceZones as baffles or boundary
// faces. // faces.
//minCellFraction 0.001; //minCellFraction 0.001;
// Optional: same but in absolute number of cells. Default is 0.
//nMinCells 100;
} }
// Settings for the snapping. // Settings for the snapping.

View File

@ -1,7 +1,7 @@
/*--------------------------------*- C++ -*----------------------------------*\ /*--------------------------------*- C++ -*----------------------------------*\
| ========= | | | ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v2112 | | \\ / O peration | Version: v2206 |
| \\ / A nd | Website: www.openfoam.com | | \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | | | \\/ M anipulation | |
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
@ -26,7 +26,7 @@ Documentation
( (
"$WM_PROJECT_USER_DIR/html" "$WM_PROJECT_USER_DIR/html"
"$WM_PROJECT_DIR/doc/Doxygen/html" "$WM_PROJECT_DIR/doc/Doxygen/html"
"https://www.openfoam.com/documentation/guides/latest/doc/" "https://www.openfoam.com/documentation/guides/latest/api/"
); );
} }

View File

@ -365,6 +365,7 @@ $(funcObjs)/logFiles/logFiles.C
$(funcObjs)/timeControl/timeControl.C $(funcObjs)/timeControl/timeControl.C
$(funcObjs)/timeControl/timeControlFunctionObject.C $(funcObjs)/timeControl/timeControlFunctionObject.C
$(funcObjs)/regionFunctionObject/regionFunctionObject.C $(funcObjs)/regionFunctionObject/regionFunctionObject.C
$(funcObjs)/valueAverageBase/valueAverageBase.C
Time = db/Time Time = db/Time
$(Time)/TimePaths.C $(Time)/TimePaths.C
@ -594,7 +595,6 @@ meshes/ProcessorTopology/commSchedule.C
globalMeshData = $(polyMesh)/globalMeshData globalMeshData = $(polyMesh)/globalMeshData
$(globalMeshData)/globalMeshData.C $(globalMeshData)/globalMeshData.C
$(globalMeshData)/globalPoints.C $(globalMeshData)/globalPoints.C
$(globalMeshData)/globalIndex.C
$(polyMesh)/syncTools/syncTools.C $(polyMesh)/syncTools/syncTools.C
$(polyMesh)/polyMeshTetDecomposition/polyMeshTetDecomposition.C $(polyMesh)/polyMeshTetDecomposition/polyMeshTetDecomposition.C
@ -803,22 +803,14 @@ $(interpolationWeights)/linearInterpolationWeights/linearInterpolationWeights.C
$(interpolationWeights)/splineInterpolationWeights/splineInterpolationWeights.C $(interpolationWeights)/splineInterpolationWeights/splineInterpolationWeights.C
algorithms/indexedOctree/indexedOctreeName.C algorithms/indexedOctree/indexedOctreeName.C
algorithms/indexedOctree/treeDataCell.C algorithms/indexedOctree/treeDataCell.C
algorithms/indexedOctree/volumeType.C algorithms/indexedOctree/volumeType.C
algorithms/dynamicIndexedOctree/dynamicIndexedOctreeName.C algorithms/dynamicIndexedOctree/dynamicIndexedOctreeName.C
algorithms/dynamicIndexedOctree/dynamicTreeDataPoint.C algorithms/dynamicIndexedOctree/dynamicTreeDataPoint.C
graph/curve/curve.C parallel/globalIndex/globalIndex.C
graph/graph.C
writers = graph/writers
$(writers)/rawGraph/rawGraph.C
$(writers)/gnuplotGraph/gnuplotGraph.C
$(writers)/xmgrGraph/xmgrGraph.C
meshes/data/data.C meshes/data/data.C

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2019-2021 OpenCFD Ltd. Copyright (C) 2019-2022 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -143,11 +143,14 @@ public:
// Access // Access
//- True if the number of rows is zero
inline bool empty() const noexcept;
//- The primary size (the number of rows) //- The primary size (the number of rows)
inline label size() const noexcept; inline label size() const noexcept;
//- True if the number of rows is zero //- The total addressed size
inline bool empty() const noexcept; inline label totalSize() const;
//- Return the offset table (= size()+1) //- Return the offset table (= size()+1)
inline const List<label>& offsets() const; inline const List<label>& offsets() const;

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2019-2020 OpenCFD Ltd. Copyright (C) 2019-2022 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -123,6 +123,13 @@ Foam::CompactListList<T, Container>::null()
} }
template<class T, class Container>
inline bool Foam::CompactListList<T, Container>::empty() const noexcept
{
return !size_;
}
template<class T, class Container> template<class T, class Container>
inline Foam::label Foam::CompactListList<T, Container>::size() const noexcept inline Foam::label Foam::CompactListList<T, Container>::size() const noexcept
{ {
@ -131,9 +138,10 @@ inline Foam::label Foam::CompactListList<T, Container>::size() const noexcept
template<class T, class Container> template<class T, class Container>
inline bool Foam::CompactListList<T, Container>::empty() const noexcept inline Foam::label Foam::CompactListList<T, Container>::totalSize() const
{ {
return !size_; const label len = (offsets_.size() - 1);
return (len < 1) ? static_cast<label>(0) : offsets_[len];
} }

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com \\ / A nd | www.openfoam.com
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2019 OpenCFD Ltd. Copyright (C) 2019-2022 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -37,8 +37,8 @@ SourceFiles
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#ifndef SortList_H #ifndef Foam_SortList_H
#define SortList_H #define Foam_SortList_H
#include "IndirectList.H" #include "IndirectList.H"
@ -72,13 +72,13 @@ public:
// Member Functions // Member Functions
//- Return the list of sorted indices. Updated every sort //- Return the list of sorted indices (updated every sort).
// Same as addressing() // Same as addressing()
inline const labelUList& indices() const; inline const labelUList& indices() const noexcept;
//- Return the list of indices. Updated every sort //- Return the list of indices (updated every sort).
// Same as addressing() // Same as addressing()
inline labelList& indices(); inline labelList& indices() noexcept;
//- Reverse the indices //- Reverse the indices
inline void reverse(); inline void reverse();
@ -94,9 +94,13 @@ public:
//- Functionally identical to sort with std::less\<T\>() //- Functionally identical to sort with std::less\<T\>()
inline void sort(); inline void sort();
//- Reverse (stable) sort the list //- Reverse (stable) sort the list.
//- Functionally identical to sort with std::greater\<T\>()
inline void reverseSort(); inline void reverseSort();
//- Sort the list, only retaining unique entries
inline void uniqueSort();
// Member Operators // Member Operators

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com \\ / A nd | www.openfoam.com
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2019 OpenCFD Ltd. Copyright (C) 2019-2022 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -32,7 +32,7 @@ License
template<class T> template<class T>
inline Foam::SortList<T>::SortList(const UList<T>& values) inline Foam::SortList<T>::SortList(const UList<T>& values)
: :
IndirectList<T>(values, identity(values.size())) IndirectList<T>(values, labelList())
{ {
sort(); sort();
} }
@ -42,7 +42,7 @@ template<class T>
template<class Compare> template<class Compare>
inline Foam::SortList<T>::SortList(const UList<T>& values, const Compare& comp) inline Foam::SortList<T>::SortList(const UList<T>& values, const Compare& comp)
: :
IndirectList<T>(values, identity(values.size())) IndirectList<T>(values, labelList())
{ {
sort<Compare>(comp); sort<Compare>(comp);
} }
@ -51,14 +51,14 @@ inline Foam::SortList<T>::SortList(const UList<T>& values, const Compare& comp)
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class T> template<class T>
inline const Foam::labelUList& Foam::SortList<T>::indices() const inline const Foam::labelUList& Foam::SortList<T>::indices() const noexcept
{ {
return this->addressing(); return this->addressing();
} }
template<class T> template<class T>
inline Foam::labelList& Foam::SortList<T>::indices() inline Foam::labelList& Foam::SortList<T>::indices() noexcept
{ {
return this->addressing(); return this->addressing();
} }
@ -74,10 +74,9 @@ inline void Foam::SortList<T>::reverse()
template<class T> template<class T>
inline void Foam::SortList<T>::reset() inline void Foam::SortList<T>::reset()
{ {
const label len = this->values().size(); auto& addr = this->indices();
labelList& addr = this->indices(); addr.resize_nocopy(this->values().size());
addr.resize(len);
ListOps::identity(addr); ListOps::identity(addr);
} }
@ -86,14 +85,11 @@ template<class T>
template<class Compare> template<class Compare>
inline void Foam::SortList<T>::sort(const Compare& comp) inline void Foam::SortList<T>::sort(const Compare& comp)
{ {
UList<T>& vals = this->values(); auto& vals = this->values();
labelList& addr = this->indices(); auto& addr = this->indices();
if (addr.size() != vals.size()) addr.resize_nocopy(vals.size());
{ ListOps::identity(addr);
addr.resize(vals.size());
ListOps::identity(addr);
}
std::stable_sort std::stable_sort
( (
@ -107,43 +103,26 @@ inline void Foam::SortList<T>::sort(const Compare& comp)
template<class T> template<class T>
inline void Foam::SortList<T>::sort() inline void Foam::SortList<T>::sort()
{ {
UList<T>& vals = this->values(); Foam::sortedOrder(this->values(), this->indices());
labelList& addr = this->indices(); }
if (addr.size() != vals.size())
{
addr.resize(vals.size());
ListOps::identity(addr);
}
// Forward sort of indices template<class T>
std::stable_sort inline void Foam::SortList<T>::uniqueSort()
( {
addr.begin(), Foam::uniqueOrder(this->values(), this->indices());
addr.end(),
[&](label a, label b) -> bool { return vals[a] < vals[b]; }
);
} }
template<class T> template<class T>
inline void Foam::SortList<T>::reverseSort() inline void Foam::SortList<T>::reverseSort()
{ {
UList<T>& vals = this->values(); // Reverse sorted order for indices
labelList& addr = this->indices(); Foam::sortedOrder
if (addr.size() != vals.size())
{
addr.resize(vals.size());
ListOps::identity(addr);
}
// Reverse sort of indices
std::stable_sort
( (
addr.begin(), this->values(),
addr.end(), this->indices(),
[&](label a, label b) -> bool { return vals[b] < vals[a]; } typename UList<T>::greater(this->values())
); );
} }

View File

@ -37,8 +37,8 @@ SourceFiles
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#ifndef FixedList_H #ifndef Foam_FixedList_H
#define FixedList_H #define Foam_FixedList_H
#include "bool.H" #include "bool.H"
#include "label.H" #include "label.H"

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2017-2021 OpenCFD Ltd. Copyright (C) 2017-2022 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -40,6 +40,11 @@ void Foam::FixedList<T, N>::writeEntry(Ostream& os) const
if (token::compound::isCompound(tag)) if (token::compound::isCompound(tag))
{ {
os << tag << token::SPACE; os << tag << token::SPACE;
if (os.format() == IOstream::BINARY && is_contiguous<T>::value)
{
// Need the size too so that List<Type>::readList parses correctly
os << static_cast<label>(N);
}
} }
os << *this; os << *this;
} }
@ -155,7 +160,7 @@ Foam::Istream& Foam::FixedList<T, N>::readList
if (is.format() == IOstream::BINARY && is_contiguous<T>::value) if (is.format() == IOstream::BINARY && is_contiguous<T>::value)
{ {
// Binary and contiguous // Binary and contiguous. Length is non-zero
Detail::readContiguous<T> Detail::readContiguous<T>
( (
@ -169,6 +174,7 @@ Foam::Istream& Foam::FixedList<T, N>::readList
"FixedList<T, N>::readList(Istream&) : " "FixedList<T, N>::readList(Istream&) : "
"reading the binary block" "reading the binary block"
); );
return is;
} }
else else
{ {
@ -183,23 +189,22 @@ Foam::Istream& Foam::FixedList<T, N>::readList
if (tok.isCompound()) if (tok.isCompound())
{ {
// Compound: transfer contents // Compound: transfer contents
// - in practice probably never reach this branch
list = dynamicCast<token::Compound<List<T>>> list = dynamicCast<token::Compound<List<T>>>
( (
tok.transferCompoundToken(is) tok.transferCompoundToken(is)
); );
return is;
} }
else if (tok.isLabel()) else if (tok.isLabel())
{ {
const label len = tok.labelToken();
// List lengths must match // List lengths must match
list.checkSize(len); list.checkSize(tok.labelToken());
} }
else if (!tok.isPunctuation()) else if (!tok.isPunctuation())
{ {
FatalIOErrorInFunction(is) FatalIOErrorInFunction(is)
<< "incorrect first token, expected <label> " << "incorrect first token, expected <label> or '(' , found "
"or '(' or '{', found "
<< tok.info() << nl << tok.info() << nl
<< exit(FatalIOError); << exit(FatalIOError);
} }
@ -228,9 +233,10 @@ Foam::Istream& Foam::FixedList<T, N>::readList
else else
{ {
// Uniform content (delimiter == token::BEGIN_BLOCK) // Uniform content (delimiter == token::BEGIN_BLOCK)
// - compatibility for v1812 and earlier (see issue #1160)
T val; T elem;
is >> val; is >> elem;
is.fatalCheck is.fatalCheck
( (
@ -240,7 +246,7 @@ Foam::Istream& Foam::FixedList<T, N>::readList
for (unsigned i=0; i<N; ++i) for (unsigned i=0; i<N; ++i)
{ {
list[i] = val; // Copy the value list[i] = elem; // Copy the value
} }
} }

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2017-2021 OpenCFD Ltd. Copyright (C) 2017-2022 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -143,7 +143,7 @@ void Foam::SortableList<T>::reverseSort()
template<class T> template<class T>
void Foam::SortableList<T>::partialSort(label n, label start) void Foam::SortableList<T>::partialSort(label n, label start)
{ {
indices_.resize(this->size()); indices_.resize_nocopy(this->size());
ListOps::identity(indices_); ListOps::identity(indices_);
// Forward partial sort of indices // Forward partial sort of indices
@ -163,7 +163,7 @@ void Foam::SortableList<T>::partialSort(label n, label start)
template<class T> template<class T>
void Foam::SortableList<T>::partialReverseSort(label n, label start) void Foam::SortableList<T>::partialReverseSort(label n, label start)
{ {
indices_.resize(this->size()); indices_.resize_nocopy(this->size());
ListOps::identity(indices_); ListOps::identity(indices_);
// Reverse partial sort of indices // Reverse partial sort of indices

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com \\ / A nd | www.openfoam.com
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2021 OpenCFD Ltd. Copyright (C) 2021-2022 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -96,13 +96,10 @@ Foam::label Foam::functionObjects::properties::getTrigger() const
bool Foam::functionObjects::properties::setTrigger bool Foam::functionObjects::properties::setTrigger
( (
const label triggeri, const label triggeri
bool increaseOnly
) )
{ {
const label currTriggeri = getTrigger(); if (triggeri != getTrigger())
if (increaseOnly ? (triggeri > currTriggeri) : (triggeri != currTriggeri))
{ {
set("triggerIndex", triggeri); set("triggerIndex", triggeri);
return true; return true;

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com \\ / A nd | www.openfoam.com
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2021 OpenCFD Ltd. Copyright (C) 2021-2022 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -123,14 +123,9 @@ public:
//- Get the current trigger index //- Get the current trigger index
label getTrigger() const; label getTrigger() const;
//- Set the trigger index. Normally only if greater than current //- Set new trigger index.
//
// \param triggeri the new trigger index
// \param increaseOnly (default) only change if new index
// is greater than the current index.
//
// \return True if the index changed // \return True if the index changed
bool setTrigger(const label triggeri, bool increaseOnly = true); bool setTrigger(const label triggeri);
//- Set dictionary from named object, return true if set //- Set dictionary from named object, return true if set
bool getObjectDict bool getObjectDict

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2015 OpenFOAM Foundation Copyright (C) 2015 OpenFOAM Foundation
Copyright (C) 2015-2021 OpenCFD Ltd. Copyright (C) 2015-2022 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -88,11 +88,10 @@ Foam::label Foam::functionObjects::stateFunctionObject::getTrigger() const
bool Foam::functionObjects::stateFunctionObject::setTrigger bool Foam::functionObjects::stateFunctionObject::setTrigger
( (
const label triggeri, const label triggeri
bool increaseOnly
) )
{ {
return stateDict().setTrigger(triggeri, increaseOnly); return stateDict().setTrigger(triggeri);
} }

View File

@ -124,14 +124,9 @@ public:
//- Get the current trigger index //- Get the current trigger index
label getTrigger() const; label getTrigger() const;
//- Set the trigger index. Normally only if greater than current //- Set new trigger index.
//
// \param triggeri the new trigger index
// \param increaseOnly (default) only change if new index
// is greater than the current index.
//
// \return True if the index changed // \return True if the index changed
bool setTrigger(const label triggeri, bool increaseOnly = true); bool setTrigger(const label triggeri);
//- Set dictionary, return true if set //- Set dictionary, return true if set
bool getDict bool getDict

View File

@ -64,11 +64,10 @@ void Foam::functionObjects::timeControl::readControls()
timeEnd_ = time_.userTimeToTime(timeEnd_); timeEnd_ = time_.userTimeToTime(timeEnd_);
} }
if (dict_.readIfPresent("triggerStart", triggerStart_)) controlMode_ =
{ controlModeNames_.getOrDefault("controlMode", dict_, controlMode::TIME);
dict_.readIfPresent("triggerEnd", triggerEnd_); dict_.readIfPresent("triggerStart", triggerStart_);
controlMode_ = controlModeNames_.get("controlMode", dict_); dict_.readIfPresent("triggerEnd", triggerEnd_);
}
deltaTCoeff_ = GREAT; deltaTCoeff_ = GREAT;
if (dict_.readIfPresent("deltaTCoeff", deltaTCoeff_)) if (dict_.readIfPresent("deltaTCoeff", deltaTCoeff_))
@ -97,6 +96,18 @@ bool Foam::functionObjects::timeControl::active() const
bool inTrigger = triggeri >= triggerStart_ && triggeri <= triggerEnd_; bool inTrigger = triggeri >= triggerStart_ && triggeri <= triggerEnd_;
DebugInFunction
<< name() << " mode:" << controlModeNames_[controlMode_] << nl
<< " - time:" << time_.value()
<< " timeStart:" << timeStart_
<< " timeEnd:" << timeEnd_
<< " inTime:" << inTime << nl
<< " - triggeri:" << triggeri
<< " triggerStart:" << triggerStart_
<< " triggerEnd:" << triggerEnd_
<< " inTrigger:" << inTrigger
<< endl;
switch (controlMode_) switch (controlMode_)
{ {
case controlMode::TIME: case controlMode::TIME:
@ -454,7 +465,7 @@ Foam::functionObjects::timeControl::timeControl
controlMode_(controlMode::TIME), controlMode_(controlMode::TIME),
timeStart_(-VGREAT), timeStart_(-VGREAT),
timeEnd_(VGREAT), timeEnd_(VGREAT),
triggerStart_(labelMax), triggerStart_(labelMin),
triggerEnd_(labelMax), triggerEnd_(labelMax),
nStepsToStartTimeChange_(labelMax), nStepsToStartTimeChange_(labelMax),
executeControl_(runTime, dict, "execute"), executeControl_(runTime, dict, "execute"),

View File

@ -0,0 +1,238 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2015 OpenFOAM Foundation
Copyright (C) 2015-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "valueAverageBase.H"
#include "Time.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
const Foam::Enum
<
Foam::functionObjects::valueAverageBase::windowType
>
Foam::functionObjects::valueAverageBase::windowTypeNames
({
{ windowType::NONE, "none" },
{ windowType::APPROXIMATE, "approximate" },
{ windowType::EXACT, "exact" }
});
// * * * * * * * * * * * * * * Protected Member Functions * * * * * * * * * //
void Foam::functionObjects::valueAverageBase::writeFileHeader(Ostream& os) const
{
writeHeader(os, "Value averages");
writeCommented(os, "Time");
forAll(fieldNames_, fieldi)
{
writeTabbed(os, fieldNames_[fieldi]);
}
os << endl;
}
void Foam::functionObjects::valueAverageBase::readState(dictionary& dict)
{
if (resetOnRestart_)
{
resetState(dict);
return;
}
forAll(fieldNames_, fieldi)
{
const word& fieldName = fieldNames_[fieldi];
if (dict.found(fieldName))
{
const dictionary& valueDict = dict.subDict(fieldName);
valueDict.readEntry("totalTime", totalTime_[fieldi]);
}
else
{
dict.set(fieldName, dictionary());
totalTime_[fieldi] = 0;
}
}
}
void Foam::functionObjects::valueAverageBase::writeState(dictionary& dict)
{
forAll(fieldNames_, fieldi)
{
const word& fieldName = fieldNames_[fieldi];
if (dict.found(fieldName))
{
dictionary& valueDict = dict.subDict(fieldName);
valueDict.add("totalTime", totalTime_[fieldi], true);
}
else
{
dictionary valueDict;
valueDict.add("totalTime", totalTime_[fieldi], true);
dict.add(fieldName, valueDict);
}
}
}
void Foam::functionObjects::valueAverageBase::resetState(dictionary& dict)
{
forAll(fieldNames_, fieldi)
{
dict.set(fieldNames_[fieldi], dictionary());
totalTime_[fieldi] = 0;
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::functionObjects::valueAverageBase::valueAverageBase
(
const word& name,
const objectRegistry& obr,
const dictionary& dict,
stateFunctionObject& state,
const bool writeToFile
)
:
writeFile(obr, name, state.type(), dict, writeToFile),
log(true),
resetOnRestart_(false),
windowType_(windowType::NONE),
state_(state),
functionObjectName_("unknown-functionObject"),
fieldNames_(),
tolerance_(dict.getOrDefault<scalar>("tolerance", -1)),
window_(-1),
totalTime_()
{
read(dict);
writeFileHeader(file());
}
// * * * * * * * * * * * * * * Public Member Functions * * * * * * * * * * * //
bool Foam::functionObjects::valueAverageBase::read(const dictionary& dict)
{
if (writeFile::read(dict))
{
// Make certain that the values are consistent with the defaults:
resetOnRestart_ = false;
dict.readEntry("functionObject", functionObjectName_);
dict.readEntry("fields", fieldNames_);
if (dict.readIfPresent("window", window_))
{
window_ = state_.time().userTimeToTime(window_);
if (window_ > 0)
{
windowType_ = windowTypeNames.get("windowType", dict);
}
}
totalTime_.resize(fieldNames_.size(), Zero);
dict.readIfPresent("resetOnRestart", resetOnRestart_);
dict.readIfPresent("log", log);
return true;
}
return false;
}
bool Foam::functionObjects::valueAverageBase::calculate(dictionary& dict)
{
scalar dt = state_.time().deltaTValue();
Log << indent << state_.type() << ": " << prefix_.c_str()
<< " averages:" << nl;
file() << state_.time().timeName();
DynamicList<word> unprocessedFields(fieldNames_.size());
bool converged = true;
forAll(fieldNames_, fieldi)
{
totalTime_[fieldi] += dt;
const bool processed =
(
calc<scalar>(fieldi, converged, dict)
|| calc<vector>(fieldi, converged, dict)
|| calc<sphericalTensor>(fieldi, converged, dict)
|| calc<symmTensor>(fieldi, converged, dict)
|| calc<tensor>(fieldi, converged, dict)
);
if (!processed)
{
unprocessedFields.append(fieldNames_[fieldi]);
file() << tab << "n/a";
}
}
file() << endl;
if (unprocessedFields.size())
{
WarningInFunction
<< "From function object: " << functionObjectName_ << nl
<< "Unprocessed fields:" << nl;
for (const word& fieldName : unprocessedFields)
{
Log << indent << " " << fieldName << nl;
}
if (unprocessedFields.size() == fieldNames_.size())
{
converged = false;
}
}
Log << endl;
return converged;
}
// ************************************************************************* //

View File

@ -0,0 +1,189 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2015 OpenFOAM Foundation
Copyright (C) 2016-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class
Foam::functionObjects::valueAverageBase
Description
Base class that computes the ensemble- or time-based singular-value average
values, with optional windowing, from the output of function objects
that generate non-field type values, e.g. \c Cd of \c forceCoeffs or
\c momentum_x in \c momentum function objects.
See also
- Foam::functionObjects::writeFile
SourceFiles
valueAverageBase.C
valueAverageBaseTemplates.C
\*---------------------------------------------------------------------------*/
#ifndef functionObjects_valueAverageBase_H
#define functionObjects_valueAverageBase_H
#include "writeFile.H"
#include "Enum.H"
#include "stateFunctionObject.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
namespace functionObjects
{
/*---------------------------------------------------------------------------*\
Class valueAverageBase Declaration
\*---------------------------------------------------------------------------*/
class valueAverageBase
:
public functionObjects::writeFile
{
public:
// Public Enumerations
//- Averaging window types
enum class windowType : uint8_t
{
NONE, //!< "none"
APPROXIMATE, //!< "approximate"
EXACT //!< "exact"
};
//- Names for windowType enumeration
static const Enum<windowType> windowTypeNames;
private:
// Private Data
//- Log flag
bool log;
protected:
// Protected Data
//- Reset the averaging process on restart
bool resetOnRestart_;
//- Window type
windowType windowType_;
//- Reference to the state functionObject
stateFunctionObject& state_;
//- Name of function object to retrieve data from
word functionObjectName_;
//- List of fields on which to operate
wordList fieldNames_;
//- Optional tolerance to check for converged results
scalar tolerance_;
//- Averaging window
scalar window_;
//- Average time per field
List<scalar> totalTime_;
// Protected Member Functions
//- Templated function to calculate the average
// Return true if processed
template<class Type>
bool calc(const label fieldi, bool& converged, dictionary& dict);
//- Output file header information
virtual void writeFileHeader(Ostream& os) const;
//- Read state from dictionary
virtual void readState(dictionary& dict);
//- Write state to dictionary for restarts
virtual void writeState(dictionary& dict);
//- Reset state
virtual void resetState(dictionary& dict);
public:
// Constructors
//- Construct from Time and dictionary
valueAverageBase
(
const word& name,
const objectRegistry& obr,
const dictionary& dict,
stateFunctionObject& state,
const bool writeToFile = true
);
//- No copy construct
valueAverageBase(const valueAverageBase&) = delete;
//- No copy assignment
void operator=(const valueAverageBase&) = delete;
//- Destructor
virtual ~valueAverageBase() = default;
// Public Member Functions
//- Read the field value average data
virtual bool read(const dictionary& dict);
//- Calculate the averages
virtual bool calculate(dictionary& dict);
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace functionObjects
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
#include "valueAverageBaseTemplates.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2015 OpenFOAM Foundation Copyright (C) 2015 OpenFOAM Foundation
Copyright (C) 2015-2016 OpenCFD Ltd. Copyright (C) 2015-2022 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -26,17 +26,14 @@ License
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#include "Time.H"
#include "FIFOStack.H"
// * * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * // // * * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * //
template<class Type> template<class Type>
void Foam::functionObjects::runTimeControls::averageCondition::calc bool Foam::functionObjects::valueAverageBase::calc
( (
const label fieldi, const label fieldi,
bool& satisfied, bool& converged,
bool& processed dictionary& dict
) )
{ {
const word& fieldName = fieldNames_[fieldi]; const word& fieldName = fieldNames_[fieldi];
@ -46,16 +43,16 @@ void Foam::functionObjects::runTimeControls::averageCondition::calc
if (pTraits<Type>::typeName != valueType) if (pTraits<Type>::typeName != valueType)
{ {
return; return false;
} }
const scalar dt = obr_.time().deltaTValue(); const scalar dt = state_.time().deltaTValue();
const Type currentValue = const Type currentValue =
state_.getObjectResult<Type>(functionObjectName_, fieldName); state_.getObjectResult<Type>(functionObjectName_, fieldName);
const word meanName(fieldName + "Mean");
// Current mean value // Current mean value
const word meanName(fieldName + "Mean");
Type meanValue = state_.getResult<Type>(meanName); Type meanValue = state_.getResult<Type>(meanName);
switch (windowType_) switch (windowType_)
@ -63,40 +60,35 @@ void Foam::functionObjects::runTimeControls::averageCondition::calc
case windowType::NONE: case windowType::NONE:
{ {
const scalar Dt = totalTime_[fieldi]; const scalar Dt = totalTime_[fieldi];
const scalar alpha = (Dt - dt)/Dt;
const scalar beta = dt/Dt; const scalar beta = dt/Dt;
meanValue = alpha*meanValue + beta*currentValue; meanValue = (1 - beta)*meanValue + beta*currentValue;
break; break;
} }
case windowType::APPROXIMATE: case windowType::APPROXIMATE:
{ {
const scalar Dt = totalTime_[fieldi]; const scalar Dt = totalTime_[fieldi];
scalar alpha = (Dt - dt)/Dt;
scalar beta = dt/Dt; scalar beta = dt/Dt;
if (Dt - dt >= window_) if (Dt - dt >= window_)
{ {
alpha = (window_ - dt)/window_;
beta = dt/window_; beta = dt/window_;
} }
else else
{ {
// Ensure that averaging is performed over window time converged = false;
// before condition can be satisfied
satisfied = false;
} }
meanValue = alpha*meanValue + beta*currentValue; meanValue = (1 - beta)*meanValue + beta*currentValue;
totalTime_[fieldi] += dt;
break; break;
} }
case windowType::EXACT: case windowType::EXACT:
{ {
FIFOStack<scalar> windowTimes; FIFOStack<scalar> windowTimes;
FIFOStack<Type> windowValues; FIFOStack<Type> windowValues;
dictionary& dict = this->conditionDict().subDict(fieldName); dictionary& fieldDict = dict.subDict(fieldName);
dict.readIfPresent("windowTimes", windowTimes); fieldDict.readIfPresent("windowTimes", windowTimes);
dict.readIfPresent("windowValues", windowValues); fieldDict.readIfPresent("windowValues", windowValues);
// Increment time for all existing values // Increment time for all existing values
for (scalar& dti : windowTimes) for (scalar& dti : windowTimes)
@ -151,8 +143,8 @@ void Foam::functionObjects::runTimeControls::averageCondition::calc
meanValue /= windowTimes.first(); meanValue /= windowTimes.first();
// Store the state information for the next step // Store the state information for the next step
dict.set("windowTimes", windowTimes); fieldDict.set("windowTimes", windowTimes);
dict.set("windowValues", windowValues); fieldDict.set("windowValues", windowValues);
break; break;
} }
@ -160,19 +152,19 @@ void Foam::functionObjects::runTimeControls::averageCondition::calc
scalar delta = mag(meanValue - currentValue); scalar delta = mag(meanValue - currentValue);
Log << " " << meanName << ": " << meanValue Log << indent << " " << meanName << ": " << meanValue
<< ", delta: " << delta << nl; << ", delta: " << delta << nl;
// Note: Writing result to owner function object and not the local run-time file() << tab << meanValue;
// condition
state_.setResult(meanName, meanValue); state_.setResult(meanName, meanValue);
if (delta > tolerance_) if ((tolerance_ > 0) && (delta > tolerance_))
{ {
satisfied = false; converged = false;
} }
processed = true; return true;
} }

View File

@ -27,7 +27,6 @@ License
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#include "emptyPolyPatch.H" #include "emptyPolyPatch.H"
#include "commSchedule.H"
#include "globalMeshData.H" #include "globalMeshData.H"
#include "cyclicPolyPatch.H" #include "cyclicPolyPatch.H"

View File

@ -67,13 +67,10 @@ if (args.dryRun() || args.found("dry-run-write"))
} }
else else
{ {
Foam::Info << "Create mesh";
if (args.readIfPresent("region", regionName)) if (args.readIfPresent("region", regionName))
{ {
Foam::Info << "Create mesh " << regionName; Foam::Info << ' ' << regionName;
}
else
{
Foam::Info << "Create mesh";
} }
Foam::Info << " for time = " << runTime.timeName() << Foam::nl; Foam::Info << " for time = " << runTime.timeName() << Foam::nl;

View File

@ -27,13 +27,10 @@ Provided Variables
Foam::word regionName(Foam::polyMesh::defaultRegion); Foam::word regionName(Foam::polyMesh::defaultRegion);
{ {
Foam::Info << "Create mesh";
if (args.readIfPresent("region", regionName)) if (args.readIfPresent("region", regionName))
{ {
Foam::Info << "Create mesh " << regionName; Foam::Info << ' ' << regionName;
}
else
{
Foam::Info << "Create mesh";
} }
Foam::Info << " for time = " << runTime.timeName() << Foam::nl; Foam::Info << " for time = " << runTime.timeName() << Foam::nl;
} }

View File

@ -26,13 +26,10 @@ Provided Variables
Foam::word regionName(Foam::polyMesh::defaultRegion); Foam::word regionName(Foam::polyMesh::defaultRegion);
{ {
Foam::Info << "Create polyMesh";
if (args.readIfPresent("region", regionName)) if (args.readIfPresent("region", regionName))
{ {
Foam::Info << "Create polyMesh " << regionName; Foam::Info << ' ' << regionName;
}
else
{
Foam::Info << "Create polyMesh";
} }
Foam::Info << " for time = " << runTime.timeName() << Foam::nl; Foam::Info << " for time = " << runTime.timeName() << Foam::nl;
} }
@ -51,4 +48,5 @@ Foam::polyMesh mesh
Foam::Info << Foam::endl; Foam::Info << Foam::endl;
// ************************************************************************* // // ************************************************************************* //

View File

@ -0,0 +1,68 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
Description
Create single or multiple polyMesh regions based on the
wordList 'regionNames'
Required Variables
- runTime [Time]
- regionNames [wordList]
Provided Variables
- meshes [PtrList<polyMesh>]
See Also
addAllRegionOptions.H
getAllRegionOptions.H
\*---------------------------------------------------------------------------*/
Foam::PtrList<Foam::polyMesh> meshes(regionNames.size());
{
forAll(regionNames, regioni)
{
const Foam::word& regionName = regionNames[regioni];
Foam::Info<< "Create polyMesh";
if
(
regionNames.size() > 1
|| regionName != Foam::polyMesh::defaultRegion
)
{
Foam::Info<< ' ' << regionName;
}
Foam::Info<< " for time = " << runTime.timeName() << Foam::nl;
meshes.set
(
regioni,
new Foam::polyMesh
(
Foam::IOobject
(
regionName,
runTime.timeName(),
runTime,
Foam::IOobject::MUST_READ
)
)
);
}
Foam::Info<< Foam::endl;
}
// ************************************************************************* //

View File

@ -101,18 +101,16 @@ public:
// Member Functions // Member Functions
//- Order in which comms is scheduled //- Order in which comms is scheduled
const labelList& schedule() const const labelList& schedule() const noexcept
{ {
return schedule_; return schedule_;
} }
//- Per processor the order in which communication has been scheduled //- Per processor the order in which communication has been scheduled
const labelListList& procSchedule() const const labelListList& procSchedule() const noexcept
{ {
return procSchedule_; return procSchedule_;
} }
}; };

View File

@ -157,7 +157,7 @@ void Foam::globalMeshData::calcSharedPoints() const
// Allocate global numbers // Allocate global numbers
globalIndex masterNumbering(nMaster); globalIndex masterNumbering(nMaster);
nGlobalPoints_ = masterNumbering.size(); nGlobalPoints_ = masterNumbering.totalSize();
// Push master number to slaves // Push master number to slaves

View File

@ -158,14 +158,14 @@ void Foam::PatchTools::gatherAndMerge
} }
mergedFaces.setSize(globalFacesPtr().size()); mergedFaces.setSize(globalFacesPtr().totalSize());
mergedPoints.setSize(globalPointsPtr().size()); mergedPoints.setSize(globalPointsPtr().totalSize());
// Insert master data first // Insert master data first
label pOffset = globalPointsPtr().offset(Pstream::masterNo()); label pOffset = globalPointsPtr().localStart(Pstream::masterNo());
SubList<point>(mergedPoints, myPoints.size(), pOffset) = myPoints; SubList<point>(mergedPoints, myPoints.size(), pOffset) = myPoints;
label fOffset = globalFacesPtr().offset(Pstream::masterNo()); label fOffset = globalFacesPtr().localStart(Pstream::masterNo());
SubList<FaceType>(mergedFaces, myFaces.size(), fOffset) = myFaces; SubList<FaceType>(mergedFaces, myFaces.size(), fOffset) = myFaces;
@ -177,11 +177,11 @@ void Foam::PatchTools::gatherAndMerge
pointField slavePoints(fromSlave); pointField slavePoints(fromSlave);
List<FaceType> slaveFaces(fromSlave); List<FaceType> slaveFaces(fromSlave);
label pOffset = globalPointsPtr().offset(slave); label pOffset = globalPointsPtr().localStart(slave);
SubList<point>(mergedPoints, slavePoints.size(), pOffset) = SubList<point>(mergedPoints, slavePoints.size(), pOffset) =
slavePoints; slavePoints;
label fOffset = globalFacesPtr().offset(slave); label fOffset = globalFacesPtr().localStart(slave);
SubList<FaceType>(mergedFaces, slaveFaces.size(), fOffset) = SubList<FaceType>(mergedFaces, slaveFaces.size(), fOffset) =
slaveFaces; slaveFaces;
} }

View File

@ -39,8 +39,15 @@ void Foam::globalIndex::reportOverflowAndExit
{ {
FatalErrorInFunction FatalErrorInFunction
<< "Overflow : sum of sizes exceeds labelMax (" << "Overflow : sum of sizes exceeds labelMax ("
<< labelMax << ") after index " << idx << " of " << labelMax << ") after index " << idx;
<< flatOutput(localSizes) << nl
if (!localSizes.empty())
{
FatalError << " of " << flatOutput(localSizes);
}
FatalError
<< nl
<< "Please recompile with larger datatype for label." << nl << "Please recompile with larger datatype for label." << nl
<< exit(FatalError); << exit(FatalError);
} }

View File

@ -89,7 +89,7 @@ class globalIndex
static void reportOverflowAndExit static void reportOverflowAndExit
( (
const label idx, const label idx,
const labelUList& localSizes const labelUList& localSizes = labelUList::null()
); );
public: public:
@ -175,7 +175,7 @@ public:
//- Global sum of localSizes. Same as totalSize() //- Global sum of localSizes. Same as totalSize()
inline label size() const; inline label size() const;
//- Global sum of localSizes. Same as size() //- Global sum of localSizes.
inline label totalSize() const; inline label totalSize() const;
//- The local sizes //- The local sizes
@ -285,9 +285,6 @@ public:
// Global (off-processor) queries // Global (off-processor) queries
//- Start of proci data
inline label offset(const label proci) const;
//- Start of proci data //- Start of proci data
inline label localStart(const label proci) const; inline label localStart(const label proci) const;
@ -328,6 +325,15 @@ public:
inline label whichProcID(const label i) const; inline label whichProcID(const label i) const;
// Housekeeping
//- Same as localStart
label offset(const label proci) const
{
return localStart(proci);
}
// Iteration // Iteration
//- Forward input iterator with const access //- Forward input iterator with const access

View File

@ -187,12 +187,6 @@ inline const Foam::labelUList Foam::globalIndex::localStarts() const
} }
inline Foam::label Foam::globalIndex::offset(const label proci) const
{
return offsets_[proci];
}
inline Foam::label Foam::globalIndex::localStart(const label proci) const inline Foam::label Foam::globalIndex::localStart(const label proci) const
{ {
return offsets_[proci]; return offsets_[proci];
@ -337,7 +331,7 @@ inline Foam::label Foam::globalIndex::toLocal(const label i) const
inline Foam::label Foam::globalIndex::whichProcID(const label i) const inline Foam::label Foam::globalIndex::whichProcID(const label i) const
{ {
if (i < 0 || i >= size()) if (i < 0 || i >= totalSize())
{ {
FatalErrorInFunction FatalErrorInFunction
<< "Global " << i << " does not belong on any processor." << "Global " << i << " does not belong on any processor."

View File

@ -54,11 +54,7 @@ Foam::globalIndex::calcListOffsets
if (checkOverflow && start < values[i]) if (checkOverflow && start < values[i])
{ {
FatalErrorInFunction reportOverflowAndExit(i);
<< "Overflow : sum of sizes exceeds labelMax ("
<< labelMax << ") after index " << i << nl
<< "Please recompile with larger datatype for label." << nl
<< exit(FatalError);
} }
} }
values[len] = start; values[len] = start;
@ -98,7 +94,7 @@ void Foam::globalIndex::gather
if (Pstream::myProcNo(comm) == procIDs[0]) if (Pstream::myProcNo(comm) == procIDs[0])
{ {
allFld.resize_nocopy(off.last()); allFld.resize_nocopy(off.last()); // == totalSize()
// Assign my local data - respect offset information // Assign my local data - respect offset information
// so that we can request 0 entries to be copied. // so that we can request 0 entries to be copied.
@ -112,7 +108,11 @@ void Foam::globalIndex::gather
{ {
SubList<Type> procSlot(allFld, off[i+1]-off[i], off[i]); SubList<Type> procSlot(allFld, off[i+1]-off[i], off[i]);
if (is_contiguous<Type>::value) if (procSlot.empty())
{
// Nothing to do
}
else if (is_contiguous<Type>::value)
{ {
IPstream::read IPstream::read
( (
@ -140,7 +140,11 @@ void Foam::globalIndex::gather
} }
else else
{ {
if (is_contiguous<Type>::value) if (fld.empty())
{
// Nothing to do
}
else if (is_contiguous<Type>::value)
{ {
OPstream::write OPstream::write
( (
@ -198,7 +202,7 @@ void Foam::globalIndex::gather
if (Pstream::myProcNo(comm) == procIDs[0]) if (Pstream::myProcNo(comm) == procIDs[0])
{ {
allFld.resize_nocopy(off.last()); allFld.resize_nocopy(off.last()); // == totalSize()
// Assign my local data - respect offset information // Assign my local data - respect offset information
// so that we can request 0 entries to be copied // so that we can request 0 entries to be copied
@ -214,28 +218,42 @@ void Foam::globalIndex::gather
{ {
SubList<Type> procSlot(allFld, off[i+1]-off[i], off[i]); SubList<Type> procSlot(allFld, off[i+1]-off[i], off[i]);
IPstream fromProc if (procSlot.empty())
( {
commsType, // Nothing to do
procIDs[i], }
0, else
tag, {
comm IPstream fromProc
); (
fromProc >> procSlot; commsType,
procIDs[i],
0,
tag,
comm
);
fromProc >> procSlot;
}
} }
} }
else else
{ {
OPstream toMaster if (fld.empty())
( {
commsType, // Nothing to do
procIDs[0], }
0, else
tag, {
comm OPstream toMaster
); (
toMaster << fld; commsType,
procIDs[0],
0,
tag,
comm
);
toMaster << fld;
}
} }
} }
@ -441,7 +459,7 @@ void Foam::globalIndex::mpiGather
nSendBytes = 0; nSendBytes = 0;
} }
allData.resize_nocopy(globalAddr.size()); allData.resize_nocopy(globalAddr.totalSize());
recvSizes.resize(nproc); recvSizes.resize(nproc);
recvOffsets.resize(nproc+1); recvOffsets.resize(nproc+1);
@ -451,7 +469,7 @@ void Foam::globalIndex::mpiGather
recvSizes[proci] = globalAddr.localSize(proci) * sizeof(Type); recvSizes[proci] = globalAddr.localSize(proci) * sizeof(Type);
recvOffsets[proci] = globalAddr.localStart(proci) * sizeof(Type); recvOffsets[proci] = globalAddr.localStart(proci) * sizeof(Type);
} }
recvOffsets[nproc] = globalAddr.size() * sizeof(Type); recvOffsets[nproc] = globalAddr.totalSize() * sizeof(Type);
} }
else else
{ {
@ -689,6 +707,10 @@ void Foam::globalIndex::scatter
// Could also warn and change to scheduled etc... // Could also warn and change to scheduled etc...
} }
// FUTURE:
// could decide which procs will receive data and use mpiScatter
// to distribute. Could then skip send/receive for those procs...
const label startOfRequests = UPstream::nRequests(); const label startOfRequests = UPstream::nRequests();
if (Pstream::myProcNo(comm) == procIDs[0]) if (Pstream::myProcNo(comm) == procIDs[0])

View File

@ -59,11 +59,11 @@ Description
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#ifndef contiguous_H #ifndef Foam_contiguous_H
#define contiguous_H #define Foam_contiguous_H
#include "scalar.H" #include "scalarFwd.H"
#include "label.H" #include "labelFwd.H"
#include <type_traits> #include <type_traits>
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2016-2021 OpenCFD Ltd. Copyright (C) 2016-2022 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -427,21 +427,50 @@ Foam::fileName Foam::fileName::relative
const bool caseTag const bool caseTag
) const ) const
{ {
const auto top = parent.size(); const auto top = parent.length();
const fileName& f = *this; const fileName& f = *this;
// Everything after "parent/xxx/yyy" -> "xxx/yyy" // Everything after "parent/xxx/yyy" -> "xxx/yyy"
// //
// case-relative: // case-relative:
// "parent/xxx/yyy" -> "<case>/xxx/yyy" // "parent/xxx/yyy" -> "<case>/xxx/yyy"
// "parent/constant/xxx/yyy" -> "<constant>/xxx/yyy"
// "parent/system/xxx/yyy" -> "<system>/xxx/yyy"
//
// as per stringOps::inplaceExpand()
if if
( (
top && (f.size() > (top+1)) && f[top] == '/' top && (f.length() > (top+1)) && f[top] == '/'
&& f.starts_with(parent) && f.starts_with(parent)
) )
{ {
if (caseTag) if (caseTag)
{ {
const auto trailing = f.find('/', top+1);
if (npos != trailing)
{
switch (trailing-top-1)
{
case 6: // "system"
{
if (!compare((top+1), 6, "system"))
{
return "<system>"/f.substr(trailing+1);
}
break;
}
case 8: // "constant"
{
if (!compare((top+1), 8, "constant"))
{
return "<constant>"/f.substr(trailing+1);
}
break;
}
}
}
return "<case>"/f.substr(top+1); return "<case>"/f.substr(top+1);
} }
else else
@ -449,8 +478,32 @@ Foam::fileName Foam::fileName::relative
return f.substr(top+1); return f.substr(top+1);
} }
} }
else if (caseTag && f.size() && !f.isAbsolute()) else if (caseTag && f.length() && !f.isAbsolute())
{ {
const auto trailing = f.find('/');
if (npos != trailing)
{
switch (trailing)
{
case 6: // "system"
{
if (!compare(0, 6, "system"))
{
return "<system>"/f.substr(trailing+1);
}
break;
}
case 8: // "constant"
{
if (!compare(0, 8, "constant"))
{
return "<constant>"/f.substr(trailing+1);
}
break;
}
}
}
return "<case>"/f; return "<case>"/f;
} }

View File

@ -41,8 +41,8 @@ SourceFiles
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#ifndef stringListOps_H #ifndef Foam_stringListOps_H
#define stringListOps_H #define Foam_stringListOps_H
#include "labelList.H" #include "labelList.H"
#include "stringList.H" #include "stringList.H"
@ -358,6 +358,18 @@ struct foundOp
}; };
//- Return ids for items with matching names.
// The filter predicate is a combination of allow and deny lists
//
// \return List indices for matches
template<class StringListType, class AccessOp = noOp>
labelList findMatching
(
const StringListType& input,
const wordRes::filter& pred,
AccessOp aop = noOp()
);
//- Return ids for items with matching names. //- Return ids for items with matching names.
// Uses a combination of allow and deny lists // Uses a combination of allow and deny lists
// //

View File

@ -135,21 +135,18 @@ template<class StringListType, class AccessOp>
Foam::labelList Foam::stringListOps::findMatching Foam::labelList Foam::stringListOps::findMatching
( (
const StringListType& input, const StringListType& input,
const wordRes& allow, const wordRes::filter& pred,
const wordRes& deny,
AccessOp aop AccessOp aop
) )
{ {
const label len = input.size(); const label len = input.size();
if (allow.empty() && deny.empty()) if (pred.empty())
{ {
// Accept all
return identity(len); return identity(len);
} }
// Use combined accept/reject filter
const wordRes::filter pred(allow, deny);
labelList indices(len); labelList indices(len);
label count = 0; label count = 0;
@ -169,4 +166,26 @@ Foam::labelList Foam::stringListOps::findMatching
} }
template<class StringListType, class AccessOp>
Foam::labelList Foam::stringListOps::findMatching
(
const StringListType& input,
const wordRes& allow,
const wordRes& deny,
AccessOp aop
)
{
if (allow.empty() && deny.empty())
{
// Accept all
return identity(input.size());
}
// Use combined accept/reject filter
const wordRes::filter pred(allow, deny);
return stringListOps::findMatching(input, pred, aop);
}
// ************************************************************************* // // ************************************************************************* //

View File

@ -2626,7 +2626,7 @@ void Foam::polyMeshAdder::compactPoints
// Compact out unused points // Compact out unused points
localPoints.setSize(meshes.size()); localPoints.setSize(meshes.size());
labelList globalToCompact(globalPoints.size(), -1); labelList globalToCompact(globalPoints.totalSize(), -1);
label nGlobal = 0; label nGlobal = 0;
forAll(meshes, meshi) forAll(meshes, meshi)
{ {

View File

@ -135,7 +135,7 @@ void Foam::vtk::writeListParallel
if (Pstream::master()) if (Pstream::master())
{ {
// Write master data - with value offset // Write master data - with value offset
const label offsetId = procOffset.offset(0); const label offsetId = procOffset.localStart(0);
for (const label val : values) for (const label val : values)
{ {
vtk::write(fmt, val + offsetId); vtk::write(fmt, val + offsetId);
@ -156,7 +156,7 @@ void Foam::vtk::writeListParallel
); );
// With value offset // With value offset
const label offsetId = procOffset.offset(proci); const label offsetId = procOffset.localStart(proci);
for (const label val : recvData) for (const label val : recvData)
{ {
vtk::write(fmt, val + offsetId); vtk::write(fmt, val + offsetId);

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2010-2018 Bernhard Gschaider Copyright (C) 2010-2018 Bernhard Gschaider
Copyright (C) 2019-2021 OpenCFD Ltd. Copyright (C) 2019-2022 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -166,7 +166,7 @@ protected:
template<class Type> template<class Type>
static inline word defaultBoundaryType static inline word defaultBoundaryType
( (
const GeometricField<Type, fvPatchField, volMesh>& const VolumeField<Type>&
) )
{ {
return "zeroGradient"; return "zeroGradient";
@ -180,7 +180,7 @@ protected:
template<class Type> template<class Type>
static inline void correctField static inline void correctField
( (
GeometricField<Type, fvPatchField, volMesh>& fld VolumeField<Type>& fld
) )
{ {
fld.correctBoundaryConditions(); fld.correctBoundaryConditions();

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2010-2018 Bernhard Gschaider Copyright (C) 2010-2018 Bernhard Gschaider
Copyright (C) 2019-2021 OpenCFD Ltd. Copyright (C) 2019-2022 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -231,18 +231,14 @@ bool Foam::expressions::fvExprDriver::isField
Info<< "fvExprDriver::isField <" << name << '>' << endl; Info<< "fvExprDriver::isField <" << name << '>' << endl;
} }
typedef GeometricField<Type, fvPatchField, volMesh> vfieldType;
typedef GeometricField<Type, fvsPatchField, surfaceMesh> sfieldType;
typedef GeometricField<Type, pointPatchField, pointMesh> pfieldType;
return return
( (
wantPointData wantPointData
? this->foundField<pfieldType>(name) ? this->foundField<PointField<Type>>(name)
: :
( (
this->foundField<vfieldType>(name) this->foundField<VolumeField<Type>>(name)
|| this->foundField<sfieldType>(name) || this->foundField<SurfaceField<Type>>(name)
) )
); );
} }

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com \\ / A nd | www.openfoam.com
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2019-2021 OpenCFD Ltd. Copyright (C) 2019-2022 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -118,17 +118,11 @@ Foam::expressions::patchExpr::parseDriver::getField(const word& name)
const label patchIndex = patch_.index(); const label patchIndex = patch_.index();
// Field types
typedef GeometricField<Type, fvPatchField, volMesh> vfieldType;
typedef GeometricField<Type, fvsPatchField, surfaceMesh> sfieldType;
typedef GeometricField<Type, pointPatchField, pointMesh> pfieldType;
// Local, temporary storage and/or lookup values // Local, temporary storage and/or lookup values
bool found = false; bool found = false;
tmp<vfieldType> vfield; tmp<VolumeField<Type>> vfield;
tmp<sfieldType> sfield; tmp<SurfaceField<Type>> sfield;
tmp<pfieldType> pfield; tmp<PointField<Type>> pfield;
for (int checki = 0; !found && checki < 2; ++checki) for (int checki = 0; !found && checki < 2; ++checki)
{ {
@ -144,17 +138,17 @@ Foam::expressions::patchExpr::parseDriver::getField(const word& name)
if (!found) if (!found)
{ {
vfield.cref(dynamic_cast<const vfieldType*>(ioptr)); vfield.cref(dynamic_cast<const VolumeField<Type>*>(ioptr));
found = vfield.valid(); found = vfield.valid();
} }
if (!found) if (!found)
{ {
sfield.cref(dynamic_cast<const sfieldType*>(ioptr)); sfield.cref(dynamic_cast<const SurfaceField<Type>*>(ioptr));
found = sfield.valid(); found = sfield.valid();
} }
if (!found) if (!found)
{ {
pfield.cref(dynamic_cast<const pfieldType*>(ioptr)); pfield.cref(dynamic_cast<const PointField<Type>*>(ioptr));
found = pfield.valid(); found = pfield.valid();
} }
} }
@ -165,17 +159,17 @@ Foam::expressions::patchExpr::parseDriver::getField(const word& name)
{ {
const word fldType = this->getTypeOfField(name); const word fldType = this->getTypeOfField(name);
if (fldType == vfieldType::typeName) if (fldType == VolumeField<Type>::typeName)
{ {
vfield = this->readAndRegister<vfieldType>(name, mesh()); vfield = this->readAndRegister<VolumeField<Type>>(name, mesh());
} }
else if (fldType == sfieldType::typeName) else if (fldType == SurfaceField<Type>::typeName)
{ {
sfield = this->readAndRegister<sfieldType>(name, mesh()); sfield = this->readAndRegister<SurfaceField<Type>>(name, mesh());
} }
else if (fldType == pfieldType::typeName) else if (fldType == PointField<Type>::typeName)
{ {
pfield = this->readAndRegister<pfieldType> pfield = this->readAndRegister<PointField<Type>>
( (
name, name,
pointMesh::New(mesh()) pointMesh::New(mesh())
@ -209,16 +203,16 @@ Foam::expressions::patchExpr::parseDriver::getField(const word& name)
<< pTraits<Type>::typeName << nl << nl; << pTraits<Type>::typeName << nl << nl;
FatalError FatalError
<< vfieldType::typeName << " Fields: " << VolumeField<Type>::typeName << " Fields: "
<< flatOutput(obr.sortedNames<vfieldType>()) << nl; << flatOutput(obr.sortedNames<VolumeField<Type>>()) << nl;
FatalError FatalError
<< sfieldType::typeName << " Fields: " << SurfaceField<Type>::typeName << " Fields: "
<< flatOutput(obr.sortedNames<sfieldType>()) << nl; << flatOutput(obr.sortedNames<SurfaceField<Type>>()) << nl;
FatalError FatalError
<< pfieldType::typeName << " Fields: " << PointField<Type>::typeName << " Fields: "
<< flatOutput(obr.sortedNames<pfieldType>()) << nl; << flatOutput(obr.sortedNames<PointField<Type>>()) << nl;
FatalError FatalError
<< exit(FatalError); << exit(FatalError);
@ -245,15 +239,10 @@ Foam::expressions::patchExpr::parseDriver::patchInternalField
const label patchIndex = patch_.index(); const label patchIndex = patch_.index();
// Field types
typedef GeometricField<Type, fvPatchField, volMesh> vfieldType;
typedef GeometricField<Type, pointPatchField, pointMesh> pfieldType;
// Local, temporary storage and/or lookup values // Local, temporary storage and/or lookup values
bool found = false; bool found = false;
tmp<vfieldType> vfield; tmp<VolumeField<Type>> vfield;
tmp<pfieldType> pfield; tmp<PointField<Type>> pfield;
for (int checki = 0; !found && checki < 2; ++checki) for (int checki = 0; !found && checki < 2; ++checki)
{ {
@ -269,12 +258,12 @@ Foam::expressions::patchExpr::parseDriver::patchInternalField
if (!found) if (!found)
{ {
vfield.cref(dynamic_cast<const vfieldType*>(ioptr)); vfield.cref(dynamic_cast<const VolumeField<Type>*>(ioptr));
found = vfield.valid(); found = vfield.valid();
} }
if (!found) if (!found)
{ {
pfield.cref(dynamic_cast<const pfieldType*>(ioptr)); pfield.cref(dynamic_cast<const PointField<Type>*>(ioptr));
found = pfield.valid(); found = pfield.valid();
} }
} }
@ -285,13 +274,13 @@ Foam::expressions::patchExpr::parseDriver::patchInternalField
{ {
const word fldType = this->getTypeOfField(name); const word fldType = this->getTypeOfField(name);
if (fldType == vfieldType::typeName) if (fldType == VolumeField<Type>::typeName)
{ {
vfield = this->readAndRegister<vfieldType>(name, mesh()); vfield = this->readAndRegister<VolumeField<Type>>(name, mesh());
} }
else if (fldType == pfieldType::typeName) else if (fldType == PointField<Type>::typeName)
{ {
pfield = this->readAndRegister<pfieldType> pfield = this->readAndRegister<PointField<Type>>
( (
name, name,
pointMesh::New(mesh()) pointMesh::New(mesh())
@ -315,12 +304,12 @@ Foam::expressions::patchExpr::parseDriver::patchInternalField
<< pTraits<Type>::typeName << nl << nl; << pTraits<Type>::typeName << nl << nl;
FatalError FatalError
<< vfieldType::typeName << " Fields: " << VolumeField<Type>::typeName << " Fields: "
<< flatOutput(obr.sortedNames<vfieldType>()) << nl; << flatOutput(obr.sortedNames<VolumeField<Type>>()) << nl;
FatalError FatalError
<< pfieldType::typeName << " Fields: " << PointField<Type>::typeName << " Fields: "
<< flatOutput(obr.sortedNames<pfieldType>()) << nl; << flatOutput(obr.sortedNames<PointField<Type>>()) << nl;
FatalError FatalError
<< exit(FatalError); << exit(FatalError);
@ -347,13 +336,9 @@ Foam::expressions::patchExpr::parseDriver::patchNeighbourField
const label patchIndex = patch_.index(); const label patchIndex = patch_.index();
// Field types
typedef GeometricField<Type, fvPatchField, volMesh> vfieldType;
// Local, temporary storage and/or lookup values // Local, temporary storage and/or lookup values
bool found = false; bool found = false;
tmp<vfieldType> vfield; tmp<VolumeField<Type>> vfield;
for (int checki = 0; !found && checki < 2; ++checki) for (int checki = 0; !found && checki < 2; ++checki)
{ {
@ -369,7 +354,7 @@ Foam::expressions::patchExpr::parseDriver::patchNeighbourField
if (!found) if (!found)
{ {
vfield.cref(dynamic_cast<const vfieldType*>(ioptr)); vfield.cref(dynamic_cast<const VolumeField<Type>*>(ioptr));
found = vfield.valid(); found = vfield.valid();
} }
} }
@ -380,9 +365,9 @@ Foam::expressions::patchExpr::parseDriver::patchNeighbourField
{ {
const word fldType = this->getTypeOfField(name); const word fldType = this->getTypeOfField(name);
if (fldType == vfieldType::typeName) if (fldType == VolumeField<Type>::typeName)
{ {
vfield = this->readAndRegister<vfieldType>(name, mesh()); vfield = this->readAndRegister<VolumeField<Type>>(name, mesh());
} }
} }
@ -398,8 +383,8 @@ Foam::expressions::patchExpr::parseDriver::patchNeighbourField
<< pTraits<Type>::typeName << nl << nl; << pTraits<Type>::typeName << nl << nl;
FatalError FatalError
<< vfieldType::typeName << " Fields: " << VolumeField<Type>::typeName << " Fields: "
<< flatOutput(obr.sortedNames<vfieldType>()) << nl; << flatOutput(obr.sortedNames<VolumeField<Type>>()) << nl;
FatalError FatalError
<< exit(FatalError); << exit(FatalError);
@ -426,13 +411,9 @@ Foam::expressions::patchExpr::parseDriver::patchNormalField
const label patchIndex = patch_.index(); const label patchIndex = patch_.index();
// Field types
typedef GeometricField<Type, fvPatchField, volMesh> vfieldType;
// Local, temporary storage and/or lookup values // Local, temporary storage and/or lookup values
bool found = false; bool found = false;
tmp<vfieldType> vfield; tmp<VolumeField<Type>> vfield;
for (int checki = 0; !found && checki < 2; ++checki) for (int checki = 0; !found && checki < 2; ++checki)
{ {
@ -448,7 +429,7 @@ Foam::expressions::patchExpr::parseDriver::patchNormalField
if (!found) if (!found)
{ {
vfield.cref(dynamic_cast<const vfieldType*>(ioptr)); vfield.cref(dynamic_cast<const VolumeField<Type>*>(ioptr));
found = vfield.valid(); found = vfield.valid();
} }
} }
@ -459,9 +440,9 @@ Foam::expressions::patchExpr::parseDriver::patchNormalField
{ {
const word fldType = this->getTypeOfField(name); const word fldType = this->getTypeOfField(name);
if (fldType == vfieldType::typeName) if (fldType == VolumeField<Type>::typeName)
{ {
vfield = this->readAndRegister<vfieldType>(name, mesh()); vfield = this->readAndRegister<VolumeField<Type>>(name, mesh());
} }
} }
@ -477,8 +458,8 @@ Foam::expressions::patchExpr::parseDriver::patchNormalField
<< pTraits<Type>::typeName << nl << nl; << pTraits<Type>::typeName << nl << nl;
FatalError FatalError
<< vfieldType::typeName << " Fields: " << VolumeField<Type>::typeName << " Fields: "
<< flatOutput(obr.sortedNames<vfieldType>()) << nl; << flatOutput(obr.sortedNames<VolumeField<Type>>()) << nl;
FatalError FatalError
<< exit(FatalError); << exit(FatalError);

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com \\ / A nd | www.openfoam.com
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2019-2021 OpenCFD Ltd. Copyright (C) 2019-2022 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -325,60 +325,48 @@ public:
//- Set result (vol field) //- Set result (vol field)
template<class Type> template<class Type>
void setResult void setResult(VolumeField<Type>* ptr, bool logical = false);
(
GeometricField<Type, fvPatchField, volMesh>* ptr,
bool logical = false
);
//- Set result (surface field) //- Set result (surface field)
template<class Type> template<class Type>
void setResult void setResult(SurfaceField<Type>* ptr, bool logical = false);
(
GeometricField<Type, fvsPatchField, surfaceMesh>* ptr,
bool logical = false
);
//- Set result (point field) //- Set result (point field)
template<class Type> template<class Type>
void setResult void setResult(PointField<Type>* ptr, bool logical = false);
(
GeometricField<Type, pointPatchField, pointMesh>* ptr,
bool logical = false
);
// New Fields // New Fields
//- Return a new volume field with the mesh size //- Return a new volume field with the mesh size
template<class Type> template<class Type>
tmp<GeometricField<Type, fvPatchField, volMesh>> tmp<VolumeField<Type>>
newVolField(const Type& val = pTraits<Type>::zero) const; newVolField(const Type& val = pTraits<Type>::zero) const;
//- Return a new surface field with the mesh nInternalFaces size //- Return a new surface field with the mesh nInternalFaces size
template<class Type> template<class Type>
tmp<GeometricField<Type, fvsPatchField, surfaceMesh>> tmp<SurfaceField<Type>>
newSurfaceField(const Type& val = pTraits<Type>::zero) const; newSurfaceField(const Type& val = pTraits<Type>::zero) const;
//- Return a new point field with the mesh nPoints size //- Return a new point field with the mesh nPoints size
template<class Type> template<class Type>
tmp<GeometricField<Type, pointPatchField, pointMesh>> tmp<PointField<Type>>
newPointField(const Type& val = pTraits<Type>::zero) const; newPointField(const Type& val = pTraits<Type>::zero) const;
//- Retrieve field (vol field) //- Retrieve field (vol field)
template<class Type> template<class Type>
tmp<GeometricField<Type, fvPatchField, volMesh>> tmp<VolumeField<Type>>
getVolField(const word& fldName, bool getOldTime=false); getVolField(const word& fldName, bool getOldTime=false);
//- Retrieve field (surface field) //- Retrieve field (surface field)
template<class Type> template<class Type>
tmp<GeometricField<Type, fvsPatchField, surfaceMesh>> tmp<SurfaceField<Type>>
getSurfaceField(const word& fldName, bool getOldTime=false); getSurfaceField(const word& fldName, bool getOldTime=false);
//- Retrieve field (surface field) //- Retrieve field (surface field)
template<class Type> template<class Type>
tmp<GeometricField<Type, pointPatchField, pointMesh>> tmp<PointField<Type>>
getPointField(const word& fldName, bool getOldTime=false); getPointField(const word& fldName, bool getOldTime=false);
@ -386,57 +374,39 @@ public:
//- Interpolate cell to face values //- Interpolate cell to face values
template<class Type> template<class Type>
tmp<GeometricField<Type, fvsPatchField, surfaceMesh>> tmp<SurfaceField<Type>>
cellToFace cellToFace(const VolumeField<Type>& field) const;
(
const GeometricField<Type,fvPatchField,volMesh>& field
) const;
//- Interpolate cell to point values //- Interpolate cell to point values
template<class Type> template<class Type>
tmp<GeometricField<Type, pointPatchField, pointMesh>> tmp<PointField<Type>>
cellToPoint cellToPoint(const VolumeField<Type>& field) const;
(
const GeometricField<Type, fvPatchField, volMesh>& field
) const;
//- Interpolate point to cell values //- Interpolate point to cell values
template<class Type> template<class Type>
tmp<GeometricField<Type, fvPatchField, volMesh>> tmp<VolumeField<Type>>
pointToCell pointToCell(const PointField<Type>& field) const;
(
const GeometricField<Type, pointPatchField, pointMesh>& field
) const;
// Custom Field Functions // Custom Field Functions
//- The volume-weighted average of a field //- The volume-weighted average of a field
template<class Type> template<class Type>
Type volAverage Type volAverage(VolumeField<Type>& fld) const
(
GeometricField<Type, fvPatchField, volMesh>& fld
) const
{ {
return weightedAverage(fld.mesh().V(), fld.primitiveField()); return weightedAverage(fld.mesh().V(), fld.primitiveField());
} }
//- The volume-weighted sum of a field //- The volume-weighted sum of a field
template<class Type> template<class Type>
Type volSum Type volSum(VolumeField<Type>& fld) const
(
GeometricField<Type, fvPatchField, volMesh>& fld
) const
{ {
return weightedSum(fld.mesh().V(), fld.primitiveField()); return weightedSum(fld.mesh().V(), fld.primitiveField());
} }
//- The area-weighted average of a field //- The area-weighted average of a field
template<class Type> template<class Type>
Type areaAverage Type areaAverage(SurfaceField<Type>& fld) const
(
GeometricField<Type, fvsPatchField, surfaceMesh>& fld
) const
{ {
return weightedAverage return weightedAverage
( (
@ -447,10 +417,7 @@ public:
//- The area-weighted sum of a field //- The area-weighted sum of a field
template<class Type> template<class Type>
Type areaSum Type areaSum(SurfaceField<Type>& fld) const
(
GeometricField<Type, fvsPatchField, surfaceMesh>& fld
) const
{ {
return weightedSum return weightedSum
( (

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com \\ / A nd | www.openfoam.com
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2019-2021 OpenCFD Ltd. Copyright (C) 2019-2022 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -62,16 +62,14 @@ void Foam::expressions::volumeExpr::parseDriver::setInternalFieldResult
template<class Type> template<class Type>
void Foam::expressions::volumeExpr::parseDriver::setResult void Foam::expressions::volumeExpr::parseDriver::setResult
( (
GeometricField<Type, fvPatchField, volMesh>* ptr, VolumeField<Type>* ptr,
bool logical bool logical
) )
{ {
typedef GeometricField<Type, fvPatchField, volMesh> fieldType;
resultField_.reset(nullptr); resultField_.reset(nullptr);
// Characteristics // Characteristics
resultType_ = pTraits<fieldType>::typeName; resultType_ = VolumeField<Type>::typeName;
isLogical_ = logical; isLogical_ = logical;
fieldGeoType_ = VOLUME_DATA; fieldGeoType_ = VOLUME_DATA;
@ -91,16 +89,14 @@ void Foam::expressions::volumeExpr::parseDriver::setResult
template<class Type> template<class Type>
void Foam::expressions::volumeExpr::parseDriver::setResult void Foam::expressions::volumeExpr::parseDriver::setResult
( (
GeometricField<Type, fvsPatchField, surfaceMesh>* ptr, SurfaceField<Type>* ptr,
bool logical bool logical
) )
{ {
typedef GeometricField<Type, fvsPatchField, surfaceMesh> fieldType;
resultField_.reset(nullptr); resultField_.reset(nullptr);
// Characteristics // Characteristics
resultType_ = pTraits<fieldType>::typeName; resultType_ = SurfaceField<Type>::typeName;
isLogical_ = logical; isLogical_ = logical;
fieldGeoType_ = FACE_DATA; fieldGeoType_ = FACE_DATA;
@ -120,16 +116,14 @@ void Foam::expressions::volumeExpr::parseDriver::setResult
template<class Type> template<class Type>
void Foam::expressions::volumeExpr::parseDriver::setResult void Foam::expressions::volumeExpr::parseDriver::setResult
( (
GeometricField<Type, pointPatchField, pointMesh>* ptr, PointField<Type>* ptr,
bool logical bool logical
) )
{ {
typedef GeometricField<Type, pointPatchField, pointMesh> fieldType;
resultField_.reset(nullptr); resultField_.reset(nullptr);
// Characteristics // Characteristics
resultType_ = pTraits<fieldType>::typeName; resultType_ = PointField<Type>::typeName;
isLogical_ = logical; isLogical_ = logical;
fieldGeoType_ = POINT_DATA; fieldGeoType_ = POINT_DATA;
@ -182,16 +176,14 @@ Foam::expressions::volumeExpr::parseDriver::isResultType
template<class Type> template<class Type>
Foam::tmp<Foam::GeometricField<Type, Foam::fvPatchField, Foam::volMesh>> Foam::tmp<Foam::VolumeField<Type>>
Foam::expressions::volumeExpr::parseDriver::getVolField Foam::expressions::volumeExpr::parseDriver::getVolField
( (
const word& fldName, const word& fldName,
bool getOldTime bool getOldTime
) )
{ {
typedef GeometricField<Type, fvPatchField, volMesh> fieldType; return this->getOrReadField<VolumeField<Type>>
return this->getOrReadField<fieldType>
( (
fldName, fldName,
true, // mandatory true, // mandatory
@ -201,16 +193,14 @@ Foam::expressions::volumeExpr::parseDriver::getVolField
template<class Type> template<class Type>
Foam::tmp<Foam::GeometricField<Type, Foam::fvsPatchField, Foam::surfaceMesh>> Foam::tmp<Foam::SurfaceField<Type>>
Foam::expressions::volumeExpr::parseDriver::getSurfaceField Foam::expressions::volumeExpr::parseDriver::getSurfaceField
( (
const word& fldName, const word& fldName,
bool getOldTime bool getOldTime
) )
{ {
typedef GeometricField<Type, fvsPatchField, surfaceMesh> fieldType; return this->getOrReadField<SurfaceField<Type>>
return this->getOrReadField<fieldType>
( (
fldName, fldName,
true, // mandatory true, // mandatory
@ -220,16 +210,14 @@ Foam::expressions::volumeExpr::parseDriver::getSurfaceField
template<class Type> template<class Type>
Foam::tmp<Foam::GeometricField<Type, Foam::pointPatchField, Foam::pointMesh>> Foam::tmp<Foam::PointField<Type>>
Foam::expressions::volumeExpr::parseDriver::getPointField Foam::expressions::volumeExpr::parseDriver::getPointField
( (
const word& fldName, const word& fldName,
bool getOldTime bool getOldTime
) )
{ {
typedef GeometricField<Type, pointPatchField, pointMesh> fieldType; return this->getOrReadPointField<PointField<Type>>
return this->getOrReadPointField<fieldType>
( (
fldName, fldName,
true, // mandatory true, // mandatory
@ -239,15 +227,13 @@ Foam::expressions::volumeExpr::parseDriver::getPointField
template<class Type> template<class Type>
Foam::tmp<Foam::GeometricField<Type, Foam::fvPatchField, Foam::volMesh>> Foam::tmp<Foam::VolumeField<Type>>
Foam::expressions::volumeExpr::parseDriver::newVolField Foam::expressions::volumeExpr::parseDriver::newVolField
( (
const Type& val const Type& val
) const ) const
{ {
typedef GeometricField<Type, fvPatchField, volMesh> fieldType; return VolumeField<Type>::New
return fieldType::New
( (
word("constant.") + word(pTraits<Type>::typeName), word("constant.") + word(pTraits<Type>::typeName),
mesh(), mesh(),
@ -257,15 +243,13 @@ Foam::expressions::volumeExpr::parseDriver::newVolField
template<class Type> template<class Type>
Foam::tmp<Foam::GeometricField<Type, Foam::fvsPatchField, Foam::surfaceMesh>> Foam::tmp<Foam::SurfaceField<Type>>
Foam::expressions::volumeExpr::parseDriver::newSurfaceField Foam::expressions::volumeExpr::parseDriver::newSurfaceField
( (
const Type& val const Type& val
) const ) const
{ {
typedef GeometricField<Type, fvsPatchField, surfaceMesh> fieldType; return SurfaceField<Type>::New
return fieldType::New
( (
word("constant.") + word(pTraits<Type>::typeName), word("constant.") + word(pTraits<Type>::typeName),
mesh(), mesh(),
@ -275,15 +259,13 @@ Foam::expressions::volumeExpr::parseDriver::newSurfaceField
template<class Type> template<class Type>
Foam::tmp<Foam::GeometricField<Type, Foam::pointPatchField, Foam::pointMesh>> Foam::tmp<Foam::PointField<Type>>
Foam::expressions::volumeExpr::parseDriver::newPointField Foam::expressions::volumeExpr::parseDriver::newPointField
( (
const Type& val const Type& val
) const ) const
{ {
typedef GeometricField<Type, pointPatchField, pointMesh> fieldType; return PointField<Type>::New
return fieldType::New
( (
word("constant.") + word(pTraits<Type>::typeName), word("constant.") + word(pTraits<Type>::typeName),
pointMesh::New(mesh()), pointMesh::New(mesh()),
@ -293,10 +275,10 @@ Foam::expressions::volumeExpr::parseDriver::newPointField
template<class Type> template<class Type>
Foam::tmp<Foam::GeometricField<Type, Foam::fvsPatchField, Foam::surfaceMesh>> Foam::tmp<Foam::SurfaceField<Type>>
Foam::expressions::volumeExpr::parseDriver::cellToFace Foam::expressions::volumeExpr::parseDriver::cellToFace
( (
const GeometricField<Type, fvPatchField, volMesh>& field const VolumeField<Type>& field
) const ) const
{ {
return fvc::interpolate(field); return fvc::interpolate(field);
@ -304,10 +286,10 @@ Foam::expressions::volumeExpr::parseDriver::cellToFace
template<class Type> template<class Type>
Foam::tmp<Foam::GeometricField<Type, Foam::pointPatchField, Foam::pointMesh>> Foam::tmp<Foam::PointField<Type>>
Foam::expressions::volumeExpr::parseDriver::cellToPoint Foam::expressions::volumeExpr::parseDriver::cellToPoint
( (
const GeometricField<Type, fvPatchField, volMesh>& field const VolumeField<Type>& field
) const ) const
{ {
volPointInterpolation interp(this->mesh()); volPointInterpolation interp(this->mesh());
@ -316,10 +298,10 @@ Foam::expressions::volumeExpr::parseDriver::cellToPoint
template<class Type> template<class Type>
Foam::tmp<Foam::GeometricField<Type,Foam::fvPatchField,Foam::volMesh>> Foam::tmp<Foam::VolumeField<Type>>
Foam::expressions::volumeExpr::parseDriver::pointToCell Foam::expressions::volumeExpr::parseDriver::pointToCell
( (
const GeometricField<Type, pointPatchField, pointMesh>& field const PointField<Type>& field
) const ) const
{ {
auto tresult = newVolField<Type>(); auto tresult = newVolField<Type>();

View File

@ -76,8 +76,8 @@ bool Foam::functionObjects::columnAverage::columnAverageField
const labelList& cellToPatchFace = ms.cellToPatchFaceAddressing(); const labelList& cellToPatchFace = ms.cellToPatchFaceAddressing();
// Brute force: collect per-global-patchface on all processors // Brute force: collect per-global-patchface on all processors
Field<Type> regionField(globalFaces_().size(), Zero); Field<Type> regionField(globalFaces_().totalSize(), Zero);
labelList regionCount(globalFaces_().size(), 0); labelList regionCount(globalFaces_().totalSize(), Zero);
forAll(cellToPatchFace, celli) forAll(cellToPatchFace, celli)
{ {

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com \\ / A nd | www.openfoam.com
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2021 OpenCFD Ltd. Copyright (C) 2021-2022 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -80,7 +80,7 @@ template<class Type>
static void doCorrectBoundaryConditions static void doCorrectBoundaryConditions
( (
bool correctBCs, bool correctBCs,
GeometricField<Type, fvPatchField, volMesh>& field VolumeField<Type>& field
) )
{ {
if (correctBCs) if (correctBCs)
@ -104,7 +104,7 @@ template<class Type>
void doCorrectBoundaryConditions void doCorrectBoundaryConditions
( (
bool correctBCs, bool correctBCs,
GeometricField<Type, pointPatchField, pointMesh>& field PointField<Type>& field
) )
{ {
if (correctBCs) if (correctBCs)
@ -119,7 +119,7 @@ template<class Type>
void doCorrectBoundaryConditions void doCorrectBoundaryConditions
( (
bool correctBCs, bool correctBCs,
GeometricField<Type, fvsPatchField, surfaceMesh>& field SurfaceField<Type>& field
) )
{} {}
@ -148,15 +148,11 @@ bool Foam::functionObjects::fvExpressionField::loadAndStore(const IOobject& io)
template<class Type> template<class Type>
bool Foam::functionObjects::fvExpressionField::loadField(const IOobject& io) bool Foam::functionObjects::fvExpressionField::loadField(const IOobject& io)
{ {
typedef GeometricField<Type, fvPatchField, volMesh> VolFieldType;
// typedef typename VolFieldType::Internal IntVolFieldType;
typedef GeometricField<Type, fvsPatchField, surfaceMesh> SurfaceFieldType;
return return
( (
loadAndStore<VolFieldType>(io) loadAndStore<VolumeField<Type>>(io)
/// || loadAndStore<IntVolFieldType>(io) /// || loadAndStore<VolumeInternalField<Type>>(io)
|| loadAndStore<SurfaceFieldType>(io) || loadAndStore<SurfaceField<Type>>(io)
); );
} }

View File

@ -141,7 +141,7 @@ void Foam::functionObjects::externalCoupled::readColumns
<< "Trying to read data for processor " << proci << "Trying to read data for processor " << proci
<< " row " << rowi << " row " << rowi
<< ". Does your file have as many rows as there are" << ". Does your file have as many rows as there are"
<< " patch faces (" << globalFaces.size() << " patch faces (" << globalFaces.totalSize()
<< ") ?" << exit(FatalIOError); << ") ?" << exit(FatalIOError);
} }
@ -206,7 +206,7 @@ void Foam::functionObjects::externalCoupled::readLines
<< "Trying to read data for processor " << proci << "Trying to read data for processor " << proci
<< " row " << rowi << " row " << rowi
<< ". Does your file have as many rows as there are" << ". Does your file have as many rows as there are"
<< " patch faces (" << globalFaces.size() << " patch faces (" << globalFaces.totalSize()
<< ") ?" << exit(FatalIOError); << ") ?" << exit(FatalIOError);
} }

View File

@ -59,7 +59,7 @@ void Foam::functionObjects::nearWallFields::calcAddressing()
// Global indexing // Global indexing
globalIndex globalWalls(nPatchFaces); globalIndex globalWalls(nPatchFaces);
DebugInFunction << "nPatchFaces: " << globalWalls.size() << endl; DebugInFunction << "nPatchFaces: " << globalWalls.totalSize() << endl;
// Construct cloud // Construct cloud
Cloud<findCellParticle> cloud Cloud<findCellParticle> cloud

View File

@ -563,7 +563,7 @@ bool Foam::functionObjects::streamLineBase::writeToFile()
const mapDistribute distMap const mapDistribute distMap
( (
globalTrackIDs.size(), globalTrackIDs.totalSize(),
std::move(sendMap), std::move(sendMap),
std::move(recvMap) std::move(recvMap)
); );

View File

@ -5,8 +5,7 @@
\\ / A nd | www.openfoam.com \\ / A nd | www.openfoam.com
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2015 OpenFOAM Foundation Copyright (C) 2022 OpenCFD Ltd.
Copyright (C) 2015-2020 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -28,7 +27,6 @@ License
#include "valueAverage.H" #include "valueAverage.H"
#include "addToRunTimeSelectionTable.H" #include "addToRunTimeSelectionTable.H"
#include "Time.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
@ -41,21 +39,6 @@ namespace functionObjects
} }
} }
// * * * * * * * * * * * * * * Protected Member Functions * * * * * * * * * //
void Foam::functionObjects::valueAverage::writeFileHeader(Ostream& os) const
{
writeHeader(os, "Value averages");
writeCommented(os, "Time");
forAll(fieldNames_, fieldi)
{
writeTabbed(os, fieldNames_[fieldi]);
}
os << endl;
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::functionObjects::valueAverage::valueAverage Foam::functionObjects::valueAverage::valueAverage
@ -66,30 +49,9 @@ Foam::functionObjects::valueAverage::valueAverage
) )
: :
regionFunctionObject(name, runTime, dict), regionFunctionObject(name, runTime, dict),
writeFile(obr_, name, typeName, dict), valueAverageBase(name, obr_, dict, *this)
functionObjectName_("unknown-functionObject"),
fieldNames_(),
window_(-1),
totalTime_(),
resetOnRestart_(false)
{ {
read(dict); readState(this->propertyDict());
if (resetOnRestart_)
{
forAll(fieldNames_, fieldi)
{
const word& fieldName = fieldNames_[fieldi];
if (dict.found(fieldName))
{
const dictionary& valueDict = dict.subDict(fieldName);
valueDict.readEntry("totalTime", totalTime_[fieldi]);
}
}
}
writeFileHeader(file());
} }
@ -97,103 +59,25 @@ Foam::functionObjects::valueAverage::valueAverage
bool Foam::functionObjects::valueAverage::read(const dictionary& dict) bool Foam::functionObjects::valueAverage::read(const dictionary& dict)
{ {
regionFunctionObject::read(dict); if (regionFunctionObject::read(dict) && valueAverageBase::read(dict))
writeFile::read(dict);
// Make certain that the values are consistent with the defaults:
resetOnRestart_ = false;
dict.readEntry("functionObject", functionObjectName_);
dict.readEntry("fields", fieldNames_);
if (dict.readIfPresent("window", window_))
{ {
window_ = obr().time().userTimeToTime(window_); return true;
} }
totalTime_.setSize(fieldNames_.size()); return false;
forAll(totalTime_, i)
{
totalTime_[i] = time_.deltaTValue();
}
dict.readIfPresent("resetOnRestart", resetOnRestart_);
return true;
} }
bool Foam::functionObjects::valueAverage::execute() bool Foam::functionObjects::valueAverage::execute()
{ {
scalar dt = obr_.time().deltaTValue(); (void)valueAverageBase::calculate(this->propertyDict());
Log << type() << ": " << name() << " averages:" << nl;
file() << time_.timeName();
DynamicList<label> unprocessedFields(fieldNames_.size());
forAll(fieldNames_, fieldi)
{
const word& fieldName(fieldNames_[fieldi]);
const word meanName(fieldName + "Mean");
scalar Dt = totalTime_[fieldi];
scalar alpha = (Dt - dt)/Dt;
scalar beta = dt/Dt;
if (window_ > 0)
{
if (Dt - dt >= window_)
{
alpha = (window_ - dt)/window_;
beta = dt/window_;
}
}
bool processed = false;
calc<scalar>(fieldName, meanName, alpha, beta, processed);
calc<vector>(fieldName, meanName, alpha, beta, processed);
calc<sphericalTensor>(fieldName, meanName, alpha, beta, processed);
calc<symmTensor>(fieldName, meanName, alpha, beta, processed);
calc<tensor>(fieldName, meanName, alpha, beta, processed);
if (!processed)
{
unprocessedFields.append(fieldi);
if (writeToFile())
{
file() << tab << "n/a";
}
}
totalTime_[fieldi] += dt;
}
file()<< endl;
if (unprocessedFields.size())
{
WarningInFunction
<< "From function object: " << functionObjectName_ << nl
<< "Unprocessed fields:" << nl;
forAll(unprocessedFields, i)
{
label fieldi = unprocessedFields[i];
Log << " " << fieldNames_[fieldi] << nl;
}
Log << endl;
}
Log << endl;
return true; return true;
} }
bool Foam::functionObjects::valueAverage::write() bool Foam::functionObjects::valueAverage::write()
{ {
valueAverageBase::writeState(this->propertyDict());
return true; return true;
} }

View File

@ -5,8 +5,7 @@
\\ / A nd | www.openfoam.com \\ / A nd | www.openfoam.com
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2015 OpenFOAM Foundation Copyright (C) 2022 OpenCFD Ltd.
Copyright (C) 2016-2020 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -79,14 +78,13 @@ Usage
The inherited entries are elaborated in: The inherited entries are elaborated in:
- \link regionFunctionObject.H \endlink - \link regionFunctionObject.H \endlink
- \link writeFile.H \endlink - \link valueAverageBase.H \endlink
Usage by the \c postProcess utility is not available. Usage by the \c postProcess utility is not available.
See also See also
- Foam::functionObject - Foam::functionObject
- Foam::functionObjects::stateFunctionObject - Foam::functionObjects::valueAverageBase
- Foam::functionObjects::writeFile
- ExtendedCodeGuide::functionObjects::field::valueAverage - ExtendedCodeGuide::functionObjects::field::valueAverage
SourceFiles SourceFiles
@ -99,6 +97,7 @@ SourceFiles
#define functionObjects_valueAverage_H #define functionObjects_valueAverage_H
#include "regionFunctionObject.H" #include "regionFunctionObject.H"
#include "valueAverageBase.H"
#include "writeFile.H" #include "writeFile.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -115,45 +114,8 @@ namespace functionObjects
class valueAverage class valueAverage
: :
public regionFunctionObject, public regionFunctionObject,
public writeFile public valueAverageBase
{ {
protected:
// Protected Data
//- Name of function object to retrieve data from
word functionObjectName_;
//- List of fields on which to operate
wordList fieldNames_;
//- Averaging window
scalar window_;
//- Average time per field
List<scalar> totalTime_;
//- Reset the averaging process on restart
Switch resetOnRestart_;
// Protected Member Functions
//- Templated function to calculate the average
template<class Type>
void calc
(
const word& fieldName,
const word& meanName,
const scalar alpha,
const scalar beta,
bool& processed
);
//- Output file header information
virtual void writeFileHeader(Ostream& os) const;
public: public:
//- Runtime type information //- Runtime type information
@ -201,12 +163,6 @@ public:
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
#include "valueAverageTemplates.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif #endif
// ************************************************************************* // // ************************************************************************* //

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2012-2016 OpenFOAM Foundation Copyright (C) 2012-2016 OpenFOAM Foundation
Copyright (C) 2015 OpenCFD Ltd. Copyright (C) 2015-2022 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -27,8 +27,10 @@ License
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#include "cloudInfo.H" #include "cloudInfo.H"
#include "cloud.H"
#include "kinematicCloud.H" #include "kinematicCloud.H"
#include "dictionary.H" #include "dictionary.H"
#include "mathematicalConstants.H"
#include "PstreamReduceOps.H" #include "PstreamReduceOps.H"
#include "addToRunTimeSelectionTable.H" #include "addToRunTimeSelectionTable.H"
@ -74,8 +76,10 @@ Foam::functionObjects::cloudInfo::cloudInfo
const dictionary& dict const dictionary& dict
) )
: :
regionFunctionObject(name, runTime, dict), functionObjects::regionFunctionObject(name, runTime, dict),
logFiles(obr_, name, dict) functionObjects::logFiles(obr_, name, dict),
verbose_(false),
onExecute_(false)
{ {
read(dict); read(dict);
} }
@ -85,55 +89,175 @@ Foam::functionObjects::cloudInfo::cloudInfo
bool Foam::functionObjects::cloudInfo::read(const dictionary& dict) bool Foam::functionObjects::cloudInfo::read(const dictionary& dict)
{ {
parcelSelect_.clear();
verbose_ = false;
onExecute_ = false;
if (regionFunctionObject::read(dict) && logFiles::read(dict)) if (regionFunctionObject::read(dict) && logFiles::read(dict))
{ {
logFiles::resetNames(dict.get<wordList>("clouds")); logFiles::resetNames(dict.get<wordList>("clouds"));
Info<< type() << " " << name() << ": "; Info<< type() << " " << name() << ": ";
if (writeToFile() && names().size()) if (names().size())
{ {
Info<< "applying to clouds:" << nl; Info<< "applying to clouds:" << nl;
forAll(names(), cloudi) for (const word& cldName : names())
{ {
Info<< " " << names()[cloudi] << nl; Info<< " " << cldName << nl;
writeFileHeader(files(cloudi));
} }
Info<< endl; Info<< endl;
// Actions to define selection
parcelSelect_ = dict.subOrEmptyDict("selection");
verbose_ = dict.getOrDefault("verbose", false);
onExecute_ = dict.getOrDefault("sampleOnExecute", false);
} }
else else
{ {
Info<< "no clouds to be processed" << nl << endl; Info<< "no clouds to be processed" << nl << endl;
} }
if (writeToFile())
{
forAll(names(), cloudi)
{
writeFileHeader(files(cloudi));
}
}
} }
return true; return true;
} }
bool Foam::functionObjects::cloudInfo::execute() bool Foam::functionObjects::cloudInfo::performAction(unsigned request)
{ {
return true; if (!request || names().empty())
} {
return true;
}
bool Foam::functionObjects::cloudInfo::write()
{
forAll(names(), cloudi) forAll(names(), cloudi)
{ {
// The reported quantities
label nTotParcels = 0;
scalar totMass = 0, Dmax = 0, D10 = 0, D32 = 0;
bool applyFilter = false;
const word& cloudName = names()[cloudi]; const word& cloudName = names()[cloudi];
const kinematicCloud& cloud = const auto* kinCloudPtr = obr_.cfindObject<kinematicCloud>(cloudName);
obr_.lookupObject<kinematicCloud>(cloudName);
const label nTotParcels = if (!kinCloudPtr)
returnReduce(cloud.nParcels(), sumOp<label>()); {
// Safety
continue;
}
const scalar totMass = const auto& kinCloud = *kinCloudPtr;
returnReduce(cloud.massInSystem(), sumOp<scalar>()); const auto* plainCloudPtr = isA<cloud>(kinCloud);
const scalar Dmax = cloud.Dmax(); if (!parcelSelect_.empty() && plainCloudPtr)
const scalar D10 = cloud.Dij(1, 0); {
const scalar D32 = cloud.Dij(3, 2); const auto& plainCloud = *plainCloudPtr;
// Filtering - simply use cloud methods
objectRegistry obrTmp
(
IOobject
(
"tmp::cloudInfo::" + cloudName,
obr_.time().constant(),
obr_,
IOobject::NO_READ,
IOobject::NO_WRITE,
false
)
);
plainCloud.writeObjects(obrTmp);
// Apply output filter (for the current cloud)
applyFilter = calculateFilter(obrTmp, log);
// Expected/required fields
const auto* diamFldPtr = obrTmp.cfindObject<IOField<scalar>>("d");
const auto* rhoFldPtr = obrTmp.cfindObject<IOField<scalar>>("rho");
const auto* nParticleFldPtr =
obrTmp.cfindObject<IOField<scalar>>("nParticle");
do
{
#undef doLocalCode
#define doLocalCode(FldPtr, FldName) \
if (applyFilter && !FldPtr) \
{ \
WarningInFunction \
<< "Missing \"" << #FldName \
<< "\" field - disabling filter" << nl; \
applyFilter = false; \
break; \
}
doLocalCode(diamFldPtr, d);
doLocalCode(rhoFldPtr, rho);
doLocalCode(nParticleFldPtr, nParticle);
#undef doLocalCode
}
while (false);
if (applyFilter)
{
// Filtered. Need to do everything by hand!
const auto& diams = *diamFldPtr;
const auto& rhos = *rhoFldPtr;
const auto& nParts = *nParticleFldPtr;
FixedList<scalar, 4> Dsums(Zero);
for (const label particlei : parcelAddr_)
{
++nTotParcels;
const scalar d = diams[particlei];
const scalar rho = rhos[particlei];
const scalar np = nParts[particlei];
totMass += np*rho*pow3(d);
Dmax = max(Dmax, d);
Dsums[0] += np;
Dsums[1] += np*(d);
Dsums[2] += np*(sqr(d));
Dsums[3] += np*(pow3(d));
}
reduce(nTotParcels, sumOp<label>());
reduce(totMass, sumOp<scalar>());
reduce(Dmax, maxOp<scalar>());
reduce(Dsums, sumOp<scalar>());
totMass *= (constant::mathematical::pi/6.0);
Dmax = max(0, Dmax);
D10 = Dsums[1]/(max(Dsums[0], VSMALL));
D32 = Dsums[3]/(max(Dsums[2], VSMALL));
}
}
if (!applyFilter)
{
// No filter - use regular cloud methods
nTotParcels = returnReduce(kinCloud.nParcels(), sumOp<label>());
totMass = returnReduce(kinCloud.massInSystem(), sumOp<scalar>());
Dmax = kinCloud.Dmax();
D10 = kinCloud.Dij(1, 0);
D32 = kinCloud.Dij(3, 2);
}
Log << type() << " " << name() << " write:" << nl Log << type() << " " << name() << " write:" << nl
<< " number of parcels : " << nTotParcels << nl << " number of parcels : " << nTotParcels << nl
@ -143,7 +267,7 @@ bool Foam::functionObjects::cloudInfo::write()
<< " D32 diameter : " << D32 << nl << " D32 diameter : " << D32 << nl
<< endl; << endl;
if (writeToFile()) if ((request & ACTION_WRITE) && writeToFile())
{ {
auto& os = files(cloudi); auto& os = files(cloudi);
@ -162,4 +286,21 @@ bool Foam::functionObjects::cloudInfo::write()
} }
bool Foam::functionObjects::cloudInfo::execute()
{
if (onExecute_)
{
return performAction(ACTION_ALL & ~ACTION_WRITE);
}
return true;
}
bool Foam::functionObjects::cloudInfo::write()
{
return performAction(ACTION_ALL);
}
// ************************************************************************* // // ************************************************************************* //

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2012-2016 OpenFOAM Foundation Copyright (C) 2012-2016 OpenFOAM Foundation
Copyright (C) 2015-2020 OpenCFD Ltd. Copyright (C) 2015-2022 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -58,6 +58,8 @@ Usage
Property | Description | Required | Default Property | Description | Required | Default
type | type name: cloudInfo | yes | type | type name: cloudInfo | yes |
clouds | list of clouds names to process | yes | clouds | list of clouds names to process | yes |
selection | Parcel selection control | no | empty-dict
sampleOnExecute| Sample/report (on execute) without writing | no | false
\endtable \endtable
The output data of each cloud is written to a file named \<cloudName\>.dat The output data of each cloud is written to a file named \<cloudName\>.dat
@ -72,11 +74,12 @@ SourceFiles
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#ifndef functionObjects_cloudInfo_H #ifndef Foam_functionObjects_cloudInfo_H
#define functionObjects_cloudInfo_H #define Foam_functionObjects_cloudInfo_H
#include "regionFunctionObject.H" #include "regionFunctionObject.H"
#include "logFiles.H" #include "logFiles.H"
#include "parcelSelectionDetail.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -91,13 +94,31 @@ namespace functionObjects
class cloudInfo class cloudInfo
: :
public regionFunctionObject, public functionObjects::regionFunctionObject,
public logFiles public functionObjects::logFiles,
public Foam::Detail::parcelSelection
{ {
protected: protected:
//- Switch to send output to Info as well // Data Types
Switch log_;
//- Local control for sampling actions
enum sampleActionType : unsigned
{
ACTION_NONE = 0,
ACTION_WRITE = 0x1,
ACTION_STORE = 0x2,
ACTION_ALL = 0xF
};
// Protected Data
//- Additional verbosity
bool verbose_;
//- Perform sample actions on execute as well
bool onExecute_;
//- List of cloud names //- List of cloud names
wordList cloudNames_; wordList cloudNames_;
@ -105,11 +126,14 @@ protected:
//- Output file per cloud //- Output file per cloud
PtrList<OFstream> filePtrs_; PtrList<OFstream> filePtrs_;
// Protected Member Functions // Protected Member Functions
//- File header information //- File header information
virtual void writeFileHeader(Ostream& os) const; virtual void writeFileHeader(Ostream& os) const;
//- Perform operation report/write
bool performAction(unsigned request);
//- No copy construct //- No copy construct
cloudInfo(const cloudInfo&) = delete; cloudInfo(const cloudInfo&) = delete;

View File

@ -22,12 +22,13 @@ timeInfo/timeInfo.C
runTimeControl/runTimeControl.C runTimeControl/runTimeControl.C
runTimeControl/runTimeCondition/runTimeCondition/runTimeCondition.C runTimeControl/runTimeCondition/runTimeCondition/runTimeCondition.C
runTimeControl/runTimeCondition/runTimeCondition/runTimeConditionNew.C runTimeControl/runTimeCondition/runTimeCondition/runTimeConditionNew.C
runTimeControl/runTimeCondition/averageCondition/averageCondition.C
runTimeControl/runTimeCondition/equationMaxIterCondition/equationMaxIterCondition.C runTimeControl/runTimeCondition/equationMaxIterCondition/equationMaxIterCondition.C
runTimeControl/runTimeCondition/equationInitialResidualCondition/equationInitialResidualCondition.C runTimeControl/runTimeCondition/equationInitialResidualCondition/equationInitialResidualCondition.C
runTimeControl/runTimeCondition/maxDurationCondition/maxDurationCondition.C runTimeControl/runTimeCondition/maxDurationCondition/maxDurationCondition.C
runTimeControl/runTimeCondition/minMaxCondition/minMaxCondition.C runTimeControl/runTimeCondition/minMaxCondition/minMaxCondition.C
runTimeControl/runTimeCondition/averageCondition/averageCondition.C
runTimeControl/runTimeCondition/minTimeStepCondition/minTimeStepCondition.C runTimeControl/runTimeCondition/minTimeStepCondition/minTimeStepCondition.C
runTimeControl/runTimeCondition/noneCondition/noneCondition.C
setTimeStep/setTimeStepFunctionObject.C setTimeStep/setTimeStepFunctionObject.C

View File

@ -5,8 +5,7 @@
\\ / A nd | www.openfoam.com \\ / A nd | www.openfoam.com
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2015 OpenFOAM Foundation Copyright (C) 2022 OpenCFD Ltd.
Copyright (C) 2015-2020 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -28,7 +27,6 @@ License
#include "averageCondition.H" #include "averageCondition.H"
#include "addToRunTimeSelectionTable.H" #include "addToRunTimeSelectionTable.H"
#include "Time.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
@ -44,18 +42,6 @@ namespace runTimeControls
} }
} }
const Foam::Enum
<
Foam::functionObjects::runTimeControls::averageCondition::windowType
>
Foam::functionObjects::runTimeControls::averageCondition::windowTypeNames
({
{ windowType::NONE, "none" },
{ windowType::APPROXIMATE, "approximate" },
{ windowType::EXACT, "exact" }
});
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::functionObjects::runTimeControls::averageCondition::averageCondition Foam::functionObjects::runTimeControls::averageCondition::averageCondition
@ -67,44 +53,13 @@ Foam::functionObjects::runTimeControls::averageCondition::averageCondition
) )
: :
runTimeCondition(name, obr, dict, state), runTimeCondition(name, obr, dict, state),
functionObjectName_(dict.get<word>("functionObject")), valueAverageBase(name, obr_, dict, state, false),
fieldNames_(dict.get<wordList>("fields")),
tolerance_(dict.get<scalar>("tolerance")),
window_(dict.getOrDefault<scalar>("window", -1)),
windowType_
(
window_ > 0
? windowTypeNames.get("windowType", dict)
: windowType::NONE
),
totalTime_(fieldNames_.size(), scalar(0)),
resetOnRestart_(dict.getOrDefault("resetOnRestart", false)),
nIterStartUp_(dict.getOrDefault<label>("nIterStartUp", 10)), nIterStartUp_(dict.getOrDefault<label>("nIterStartUp", 10)),
iter_(-1) iter_(-1)
{ {
dictionary& conditionDict = this->conditionDict(); dictionary& conditionDict = this->conditionDict();
forAll(fieldNames_, fieldi) readState(conditionDict);
{
const word& fieldName = fieldNames_[fieldi];
if (resetOnRestart_)
{
conditionDict.set(fieldName, dictionary());
}
else
{
if (conditionDict.found(fieldName))
{
const dictionary& valueDict = conditionDict.subDict(fieldName);
valueDict.readIfPresent("totalTime", totalTime_[fieldi]);
}
else
{
conditionDict.set(fieldName, dictionary());
}
}
}
conditionDict.readIfPresent("iter", iter_); conditionDict.readIfPresent("iter", iter_);
} }
@ -119,53 +74,18 @@ bool Foam::functionObjects::runTimeControls::averageCondition::apply()
return true; return true;
} }
bool satisfied = iter_ > nIterStartUp_; bool running = iter_ > nIterStartUp_;
++iter_; ++iter_;
const scalar dt = obr_.time().deltaTValue(); dictionary& conditionDict = this->conditionDict();
Log << " " << type() << ": " << name_ << " averages:" << nl;
DynamicList<label> unprocessedFields(fieldNames_.size()); Info<< incrIndent;
running = valueAverageBase::calculate(conditionDict) && running;
Info<< decrIndent;
forAll(fieldNames_, fieldi) return running;
{
totalTime_[fieldi] += dt;
bool processed = false;
calc<scalar>(fieldi, satisfied, processed);
calc<vector>(fieldi, satisfied, processed);
calc<sphericalTensor>(fieldi, satisfied, processed);
calc<symmTensor>(fieldi, satisfied, processed);
calc<tensor>(fieldi, satisfied, processed);
if (!processed)
{
unprocessedFields.append(fieldi);
}
}
if (unprocessedFields.size())
{
WarningInFunction
<< "From function object: " << functionObjectName_ << nl
<< "Unprocessed fields:" << nl;
for (const label fieldi : unprocessedFields)
{
Info<< " " << fieldNames_[fieldi] << nl;
}
if (unprocessedFields.size() == fieldNames_.size())
{
satisfied = false;
}
}
Log << endl;
return satisfied;
} }
@ -173,25 +93,18 @@ void Foam::functionObjects::runTimeControls::averageCondition::write()
{ {
dictionary& conditionDict = this->conditionDict(); dictionary& conditionDict = this->conditionDict();
forAll(fieldNames_, fieldi) valueAverageBase::writeState(conditionDict);
{
const word& fieldName = fieldNames_[fieldi];
if (conditionDict.found(fieldName))
{
dictionary& valueDict = conditionDict.subDict(fieldName);
valueDict.add("totalTime", totalTime_[fieldi], true);
}
else
{
dictionary valueDict;
valueDict.add("totalTime", totalTime_[fieldi], true);
conditionDict.add(fieldName, valueDict);
}
}
conditionDict.set("iter", iter_); conditionDict.set("iter", iter_);
} }
void Foam::functionObjects::runTimeControls::averageCondition::reset()
{
valueAverageBase::resetState(this->conditionDict());
iter_ = 0;
}
// ************************************************************************* // // ************************************************************************* //

View File

@ -5,8 +5,7 @@
\\ / A nd | www.openfoam.com \\ / A nd | www.openfoam.com
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2015 OpenFOAM Foundation Copyright (C) 2022 OpenCFD Ltd.
Copyright (C) 2016-2018 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -31,18 +30,20 @@ Description
Average run time condition - satisfied when average does not change by Average run time condition - satisfied when average does not change by
more than a given value. more than a given value.
See also
- Foam::functionObjects::valueAverageBase
SourceFiles SourceFiles
averageCondition.H averageCondition.H
averageCondition.C averageCondition.C
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#ifndef averageCondition_H #ifndef functionObjects_runTimeControls_averageCondition_H
#define averageCondition_H #define functionObjects_runTimeControls_averageCondition_H
#include "runTimeCondition.H" #include "runTimeCondition.H"
#include "Switch.H" #include "valueAverageBase.H"
#include "Enum.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -59,46 +60,12 @@ namespace runTimeControls
class averageCondition class averageCondition
: :
public runTimeCondition public runTimeCondition,
public valueAverageBase
{ {
public:
// Public enumerations
enum class windowType
{
NONE,
APPROXIMATE,
EXACT
};
static const Enum<windowType> windowTypeNames;
protected: protected:
// Protected data // Protected Data
//- Name of function object to retrieve data from
word functionObjectName_;
//- List of fields on which to operate
wordList fieldNames_;
//- Satisfied when difference in mean values is less than this value
const scalar tolerance_;
//- Averaging window
const scalar window_;
//- Averaging window type
windowType windowType_;
//- Average time per field
List<scalar> totalTime_;
//- Reset the averaging process on restart flag
Switch resetOnRestart_;
//- Number of start-up iterations before allowing satisfied checks //- Number of start-up iterations before allowing satisfied checks
label nIterStartUp_; label nIterStartUp_;
@ -106,17 +73,6 @@ protected:
//- Current iteration count //- Current iteration count
label iter_; label iter_;
// Protected Member Functions
//- Templated function to calculate the average
template<class Type>
void calc
(
const label fieldi,
bool& satisfied,
bool& processed
);
public: public:
@ -143,6 +99,9 @@ public:
//- Write //- Write
virtual void write(); virtual void write();
//- Reset
virtual void reset();
}; };
@ -154,12 +113,6 @@ public:
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
#include "averageConditionTemplates.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif #endif
// ************************************************************************* // // ************************************************************************* //

View File

@ -230,4 +230,11 @@ equationInitialResidualCondition::write()
} }
void Foam::functionObjects::runTimeControls::
equationInitialResidualCondition::reset()
{
// do nothing
}
// ************************************************************************* // // ************************************************************************* //

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2015 OpenFOAM Foundation Copyright (C) 2015 OpenFOAM Foundation
Copyright (C) 2016-2019 OpenCFD Ltd. Copyright (C) 2016-2022 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -130,6 +130,9 @@ public:
//- Write //- Write
virtual void write(); virtual void write();
//- Reset
virtual void reset();
}; };

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2015 OpenFOAM Foundation Copyright (C) 2015 OpenFOAM Foundation
Copyright (C) 2015-2020 OpenCFD Ltd. Copyright (C) 2015-2022 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -168,4 +168,11 @@ void Foam::functionObjects::runTimeControls::equationMaxIterCondition::write()
} }
void Foam::functionObjects::runTimeControls::equationMaxIterCondition::reset()
{
// do nothing
}
// ************************************************************************* // // ************************************************************************* //

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2015 OpenFOAM Foundation Copyright (C) 2015 OpenFOAM Foundation
Copyright (C) 2016 OpenCFD Ltd. Copyright (C) 2016-2022 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -97,6 +97,9 @@ public:
//- Write //- Write
virtual void write(); virtual void write();
//- Reset
virtual void reset();
}; };

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com \\ / A nd | www.openfoam.com
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2018-2020 OpenCFD Ltd. Copyright (C) 2018-2022 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -110,4 +110,10 @@ void Foam::functionObjects::runTimeControls::maxDurationCondition::write()
} }
void Foam::functionObjects::runTimeControls::maxDurationCondition::reset()
{
initialised_ = false;
}
// ************************************************************************* // // ************************************************************************* //

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com \\ / A nd | www.openfoam.com
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2018 OpenCFD Ltd. Copyright (C) 2018-2022 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -99,6 +99,9 @@ public:
//- Write //- Write
virtual void write(); virtual void write();
//- Reset
virtual void reset();
}; };

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2015 OpenFOAM Foundation Copyright (C) 2015 OpenFOAM Foundation
Copyright (C) 2015-2016 OpenCFD Ltd. Copyright (C) 2015-2022 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -166,4 +166,10 @@ void Foam::functionObjects::runTimeControls::minMaxCondition::write()
} }
void Foam::functionObjects::runTimeControls::minMaxCondition::reset()
{
// do nothing
}
// ************************************************************************* // // ************************************************************************* //

View File

@ -6,6 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2015 OpenFOAM Foundation Copyright (C) 2015 OpenFOAM Foundation
Copyright (C) 2022 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -124,6 +125,9 @@ public:
//- Write //- Write
virtual void write(); virtual void write();
//- Reset
virtual void reset();
}; };

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2015 OpenFOAM Foundation Copyright (C) 2015 OpenFOAM Foundation
Copyright (C) 2019 OpenCFD Ltd. Copyright (C) 2019-2022 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -94,4 +94,10 @@ void Foam::functionObjects::runTimeControls::minTimeStepCondition::write()
} }
void Foam::functionObjects::runTimeControls::minTimeStepCondition::reset()
{
// do nothing
}
// ************************************************************************* // // ************************************************************************* //

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2015 OpenFOAM Foundation Copyright (C) 2015 OpenFOAM Foundation
Copyright (C) 2016 OpenCFD Ltd. Copyright (C) 2016-2022 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -91,6 +91,9 @@ public:
//- Write //- Write
virtual void write(); virtual void write();
//- Reset
virtual void reset();
}; };

View File

@ -5,8 +5,7 @@
\\ / A nd | www.openfoam.com \\ / A nd | www.openfoam.com
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2015 OpenFOAM Foundation Copyright (C) 2022 OpenCFD Ltd.
Copyright (C) 2015-2016 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -26,37 +25,56 @@ License
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
// * * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * // #include "noneCondition.H"
#include "addToRunTimeSelectionTable.H"
template<class Type> // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
void Foam::functionObjects::valueAverage::calc
( namespace Foam
const word& fieldName,
const word& meanName,
const scalar alpha,
const scalar beta,
bool& processed
)
{ {
const word valueType = objectResultType(functionObjectName_, fieldName); namespace functionObjects
{
namespace runTimeControls
{
defineTypeName(noneCondition);
addToRunTimeSelectionTable(runTimeCondition, noneCondition, dictionary);
if (pTraits<Type>::typeName != valueType) }
{ }
return; }
}
Type currentValue = getObjectResult<Type>(functionObjectName_, fieldName);
Type meanValue = getResult<Type>(meanName); // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
meanValue = alpha*meanValue + beta*currentValue;
setResult(meanName, meanValue); Foam::functionObjects::runTimeControls::noneCondition::noneCondition
(
const word& name,
const objectRegistry& obr,
const dictionary& dict,
stateFunctionObject& state
)
:
runTimeCondition(name, obr, dict, state)
{}
file() << tab << meanValue;
Log<< " " << meanName << ": " << meanValue << nl; // * * * * * * * * * * * * * * Public Member Functions * * * * * * * * * * * //
processed = true; bool Foam::functionObjects::runTimeControls::noneCondition::apply()
{
return true;
}
void Foam::functionObjects::runTimeControls::noneCondition::write()
{
// do nothing
}
void Foam::functionObjects::runTimeControls::noneCondition::reset()
{
// do nothing
} }

View File

@ -0,0 +1,100 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class
Foam::noneCondition
Description
A no-op condition that simply returns true/nothing to do.
SourceFiles
noneCondition.C
\*---------------------------------------------------------------------------*/
#ifndef functionObjects_runTimeControls_noneCondition_H
#define functionObjects_runTimeControls_noneCondition_H
#include "runTimeCondition.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
namespace functionObjects
{
namespace runTimeControls
{
/*---------------------------------------------------------------------------*\
Class noneCondition Declaration
\*---------------------------------------------------------------------------*/
class noneCondition
:
public runTimeCondition
{
public:
//- Runtime type information
TypeNameNoDebug("none");
//- Constructor
noneCondition
(
const word& name,
const objectRegistry& obr,
const dictionary& dict,
stateFunctionObject& state
);
//- Destructor
virtual ~noneCondition() = default;
// Public Member Functions
//- Apply the condition
virtual bool apply();
//- Write
virtual void write();
//- Reset
virtual void reset();
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace runTimeControls
} // End namespace functionObjects
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2015 OpenFOAM Foundation Copyright (C) 2015 OpenFOAM Foundation
Copyright (C) 2016 OpenCFD Ltd. Copyright (C) 2016-2022 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -162,6 +162,9 @@ public:
//- Write //- Write
virtual void write() = 0; virtual void write() = 0;
//- Reset
virtual void reset() = 0;
}; };

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2015 OpenFOAM Foundation Copyright (C) 2015 OpenFOAM Foundation
Copyright (C) 2015-2021 OpenCFD Ltd. Copyright (C) 2015-2022 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -58,6 +58,7 @@ Foam::functionObjects::runTimeControls::runTimeControl::satisfiedActionNames
{ satisfiedAction::SET_TRIGGER, "setTrigger"}, { satisfiedAction::SET_TRIGGER, "setTrigger"},
}; };
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::functionObjects::runTimeControls::runTimeControl::runTimeControl Foam::functionObjects::runTimeControls::runTimeControl::runTimeControl
@ -74,7 +75,8 @@ Foam::functionObjects::runTimeControls::runTimeControl::runTimeControl
writeStepI_(0), writeStepI_(0),
satisfiedAction_(satisfiedAction::END), satisfiedAction_(satisfiedAction::END),
triggerIndex_(labelMin), triggerIndex_(labelMin),
active_(getObjectProperty(name, "active", true)) active_(getProperty("active", true)),
canRestart_(getProperty("canRestart", false))
{ {
read(dict); read(dict);
} }
@ -99,6 +101,8 @@ bool Foam::functionObjects::runTimeControls::runTimeControl::read
if (fvMeshFunctionObject::read(dict)) if (fvMeshFunctionObject::read(dict))
{ {
Info<< type() << " " << name() << ":" << nl;
const dictionary& conditionsDict = dict.subDict("conditions"); const dictionary& conditionsDict = dict.subDict("conditions");
const wordList conditionNames(conditionsDict.toc()); const wordList conditionNames(conditionsDict.toc());
conditions_.setSize(conditionNames.size()); conditions_.setSize(conditionNames.size());
@ -128,9 +132,7 @@ bool Foam::functionObjects::runTimeControls::runTimeControl::read
// Check that some conditions are set // Check that some conditions are set
if (conditions_.empty()) if (conditions_.empty())
{ {
Info<< type() << " " << name() << " output:" << nl Info<< " No conditions present" << endl;
<< " No conditions present" << nl
<< endl;
} }
else else
{ {
@ -147,12 +149,12 @@ bool Foam::functionObjects::runTimeControls::runTimeControl::read
if (!check) if (!check)
{ {
Info<< type() << " " << name() << " output:" << nl Info<< " All conditions are inactive" << endl;
<< " All conditions are inactive" << nl
<< endl;
} }
} }
Info<< endl;
// Set the action to perform when all conditions are satisfied // Set the action to perform when all conditions are satisfied
// - set to end for backwards compatibility with v1806 // - set to end for backwards compatibility with v1806
satisfiedAction_ = satisfiedAction_ =
@ -177,6 +179,12 @@ bool Foam::functionObjects::runTimeControls::runTimeControl::read
bool Foam::functionObjects::runTimeControls::runTimeControl::execute() bool Foam::functionObjects::runTimeControls::runTimeControl::execute()
{ {
if (canRestart_)
{
active_ = true;
canRestart_ = false;
}
if (!active_) if (!active_)
{ {
return true; return true;
@ -199,7 +207,7 @@ bool Foam::functionObjects::runTimeControls::runTimeControl::execute()
{ {
bool conditionSatisfied = condition.apply(); bool conditionSatisfied = condition.apply();
label groupi = condition.groupID(); const label groupi = condition.groupID();
auto conditionIter = groupMap_.cfind(groupi); auto conditionIter = groupMap_.cfind(groupi);
@ -271,14 +279,10 @@ bool Foam::functionObjects::runTimeControls::runTimeControl::execute()
if (nWriteStep_ != 0) if (nWriteStep_ != 0)
{ {
Info<< " - final step" << nl; Info<< " - final step";
}
else
{
Info<< nl;
} }
Info<< endl; Info<< nl << endl;
active_ = false; active_ = false;
// Write any registered objects and set the end-time // Write any registered objects and set the end-time
@ -299,11 +303,25 @@ bool Foam::functionObjects::runTimeControls::runTimeControl::execute()
case satisfiedAction::SET_TRIGGER: case satisfiedAction::SET_TRIGGER:
{ {
Info<< " Setting trigger " << triggerIndex_ << nl; Info<< " Setting trigger " << triggerIndex_ << nl;
setTrigger(triggerIndex_); setTrigger(triggerIndex_);
// Deactivate the model // Deactivate the model
active_ = false; active_ = false;
setProperty("active", active_); setProperty("active", active_);
// Can be restarted
canRestart_ = true;
setProperty("canRestart", canRestart_);
// Reset all conditions in case the control is recycled/trigger
// index is set to a smaller value
forAll(conditions_, conditioni)
{
runTimeCondition& condition = conditions_[conditioni];
condition.reset();
}
break; break;
} }
} }

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2015-2016 OpenFOAM Foundation Copyright (C) 2015-2016 OpenFOAM Foundation
Copyright (C) 2016-2021 OpenCFD Ltd. Copyright (C) 2016-2022 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -111,6 +111,11 @@ private:
// trigger has been set // trigger has been set
bool active_; bool active_;
//- Can be restarted flag
// Used in the trigger case after the trigger has been set to allow
// this object to be restarted/reset the active flag
bool canRestart_;
// Private Member Functions // Private Member Functions

View File

@ -68,8 +68,7 @@ Foam::functionObjects::thermoCoupleProbes::thermoCoupleProbes
read(dict); read(dict);
} }
// Check if the property exist (resume old calculation) // Check if the property exists (resume old calculation) or is new
// or of it is new.
dictionary probeDict; dictionary probeDict;
if (getDict(typeName, probeDict)) if (getDict(typeName, probeDict))
{ {
@ -77,7 +76,7 @@ Foam::functionObjects::thermoCoupleProbes::thermoCoupleProbes
} }
else else
{ {
Ttc_ = probes::sample(thermo_.T()); Ttc_ = probes::sample(thermo_.T());
} }
// Note: can only create the solver once all samples have been found // Note: can only create the solver once all samples have been found
@ -88,10 +87,6 @@ Foam::functionObjects::thermoCoupleProbes::thermoCoupleProbes
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::functionObjects::thermoCoupleProbes::~thermoCoupleProbes()
{}
Foam::label Foam::functionObjects::thermoCoupleProbes::nEqns() const Foam::label Foam::functionObjects::thermoCoupleProbes::nEqns() const
{ {
return this->size(); return this->size();
@ -168,9 +163,12 @@ void Foam::functionObjects::thermoCoupleProbes::jacobian
bool Foam::functionObjects::thermoCoupleProbes::write() bool Foam::functionObjects::thermoCoupleProbes::write()
{ {
if (this->size()) if (!pointField::empty())
{ {
sampleAndWrite<scalar>(thermo_.T()); (void) prepare(ACTION_WRITE);
const auto& Tfield = thermo_.T();
writeValues(Tfield.name(), Ttc_, Tfield.time().timeOutputValue());
dictionary probeDict; dictionary probeDict;
probeDict.add("Tc", Ttc_); probeDict.add("Tc", Ttc_);
@ -184,7 +182,7 @@ bool Foam::functionObjects::thermoCoupleProbes::write()
bool Foam::functionObjects::thermoCoupleProbes::execute() bool Foam::functionObjects::thermoCoupleProbes::execute()
{ {
if (this->size()) if (!pointField::empty())
{ {
scalar dt = mesh_.time().deltaTValue(); scalar dt = mesh_.time().deltaTValue();
scalar t = mesh_.time().value(); scalar t = mesh_.time().value();

View File

@ -79,8 +79,8 @@ SourceFiles
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#ifndef functionObjects_thermoCoupleProbes_H #ifndef Foam_functionObjects_thermoCoupleProbes_H
#define functionObjects_thermoCoupleProbes_H #define Foam_functionObjects_thermoCoupleProbes_H
#include "probes.H" #include "probes.H"
#include "ODESystem.H" #include "ODESystem.H"
@ -106,7 +106,7 @@ class thermoCoupleProbes
{ {
protected: protected:
// Protected data // Protected Data
//- Thermocouple density //- Thermocouple density
scalar rho_; scalar rho_;
@ -126,7 +126,7 @@ protected:
//- Name of the incident radiation field //- Name of the incident radiation field
word radiationFieldName_; word radiationFieldName_;
//- Fluid thermo reference //- Fluid thermo reference
const fluidThermo& thermo_; const fluidThermo& thermo_;
//- ODESolver //- ODESolver
@ -136,18 +136,19 @@ protected:
scalarField Ttc_; scalarField Ttc_;
// Protected Member Functions
//- Sample and write a particular volume field
template<class Type>
void sampleAndWrite
(
const GeometricField<Type, fvPatchField, volMesh>&
);
private: private:
// Private Member Functions
//- Sample/write
template<class Type>
void writeValues
(
const word& fieldName,
const Field<Type>& values,
const scalar timeValue
);
//- No copy construct //- No copy construct
thermoCoupleProbes(const thermoCoupleProbes&) = delete; thermoCoupleProbes(const thermoCoupleProbes&) = delete;
@ -176,40 +177,40 @@ public:
//- Destructor //- Destructor
virtual ~thermoCoupleProbes(); virtual ~thermoCoupleProbes() = default;
// ODE functions (overriding abstract functions in ODE.H) // ODE functions (overriding abstract functions in ODE.H)
//- Number of ODE's to solve //- Number of ODE's to solve
virtual label nEqns() const; virtual label nEqns() const;
virtual void derivatives virtual void derivatives
( (
const scalar x, const scalar x,
const scalarField& y, const scalarField& y,
scalarField& dydx scalarField& dydx
) const; ) const;
virtual void jacobian virtual void jacobian
( (
const scalar t, const scalar t,
const scalarField& y, const scalarField& y,
scalarField& dfdt, scalarField& dfdt,
scalarSquareMatrix& dfdy scalarSquareMatrix& dfdy
) const; ) const;
// Public Member Functions // Public Member Functions
//- Sample and write
virtual bool write();
//- Execute, currently does nothing
virtual bool execute();
//- Read //- Read
virtual bool read(const dictionary&); virtual bool read(const dictionary&);
//- Execute. Evaluates the ODESolver
virtual bool execute();
//- Sample and write
virtual bool write();
}; };

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com \\ / A nd | www.openfoam.com
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2016 OpenCFD Ltd. Copyright (C) 2016-2022 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -28,25 +28,28 @@ License
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
template<class Type> template<class Type>
void Foam::functionObjects::thermoCoupleProbes::sampleAndWrite void Foam::functionObjects::thermoCoupleProbes::writeValues
( (
const GeometricField<Type, fvPatchField, volMesh>& vField const word& fieldName,
const Field<Type>& values,
const scalar timeValue
) )
{ {
if (Pstream::master()) if (Pstream::master())
{ {
unsigned int w = IOstream::defaultPrecision() + 7; const unsigned int w = IOstream::defaultPrecision() + 7;
OFstream& probeStream = *probeFilePtrs_[vField.name()]; OFstream& os = *probeFilePtrs_[fieldName];
probeStream os << setw(w) << timeValue;
<< setw(w)
<< vField.time().timeOutputValue();
forAll(*this, probeI) forAll(*this, probei)
{ {
probeStream << ' ' << setw(w) << Ttc_[probeI]; // if (includeOutOfBounds_ || processor_[probei] != -1)
{
os << ' ' << setw(w) << values[probei];
}
} }
probeStream << endl; os << endl;
} }
} }

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2015-2019 OpenCFD Ltd. Copyright (C) 2015-2022 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -107,17 +107,17 @@ void Foam::CellZoneInjection<CloudType>::setPositions
// Parallel operation manipulations // Parallel operation manipulations
globalIndex globalPositions(positions.size()); globalIndex globalPositions(positions.size());
List<vector> allPositions(globalPositions.size(), point::max); List<vector> allPositions(globalPositions.totalSize(), point::max);
List<label> allInjectorCells(globalPositions.size(), -1); List<label> allInjectorCells(globalPositions.totalSize(), -1);
List<label> allInjectorTetFaces(globalPositions.size(), -1); List<label> allInjectorTetFaces(globalPositions.totalSize(), -1);
List<label> allInjectorTetPts(globalPositions.size(), -1); List<label> allInjectorTetPts(globalPositions.totalSize(), -1);
// Gather all positions on to all processors // Gather all positions on to all processors
SubList<vector> SubList<vector>
( (
allPositions, allPositions,
globalPositions.localSize(Pstream::myProcNo()), globalPositions.localSize(Pstream::myProcNo()),
globalPositions.offset(Pstream::myProcNo()) globalPositions.localStart(Pstream::myProcNo())
) = positions; ) = positions;
Pstream::listCombineGather(allPositions, minEqOp<point>()); Pstream::listCombineGather(allPositions, minEqOp<point>());
@ -128,19 +128,19 @@ void Foam::CellZoneInjection<CloudType>::setPositions
( (
allInjectorCells, allInjectorCells,
globalPositions.localSize(Pstream::myProcNo()), globalPositions.localSize(Pstream::myProcNo()),
globalPositions.offset(Pstream::myProcNo()) globalPositions.localStart(Pstream::myProcNo())
) = injectorCells; ) = injectorCells;
SubList<label> SubList<label>
( (
allInjectorTetFaces, allInjectorTetFaces,
globalPositions.localSize(Pstream::myProcNo()), globalPositions.localSize(Pstream::myProcNo()),
globalPositions.offset(Pstream::myProcNo()) globalPositions.localStart(Pstream::myProcNo())
) = injectorTetFaces; ) = injectorTetFaces;
SubList<label> SubList<label>
( (
allInjectorTetPts, allInjectorTetPts,
globalPositions.localSize(Pstream::myProcNo()), globalPositions.localSize(Pstream::myProcNo()),
globalPositions.offset(Pstream::myProcNo()) globalPositions.localStart(Pstream::myProcNo())
) = injectorTetPts; ) = injectorTetPts;
// Transfer data // Transfer data

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2019-2020 OpenCFD Ltd. Copyright (C) 2019-2022 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -92,7 +92,7 @@ inline Foam::scalar Foam::SprayCloud<CloudType>::penetration
const label nParcel = this->size(); const label nParcel = this->size();
globalIndex globalParcels(nParcel); globalIndex globalParcels(nParcel);
const label nParcelSum = globalParcels.size(); const label nParcelSum = globalParcels.totalSize();
if (nParcelSum == 0) if (nParcelSum == 0)
{ {
@ -139,7 +139,7 @@ inline Foam::scalar Foam::SprayCloud<CloudType>::penetration
( (
allMass, allMass,
globalParcels.localSize(proci), globalParcels.localSize(proci),
globalParcels.offset(proci) globalParcels.localStart(proci)
) = procMass[proci]; ) = procMass[proci];
// flatten the distance list // flatten the distance list
@ -147,7 +147,7 @@ inline Foam::scalar Foam::SprayCloud<CloudType>::penetration
( (
allDist, allDist,
globalParcels.localSize(proci), globalParcels.localSize(proci),
globalParcels.offset(proci) globalParcels.localStart(proci)
) = procDist[proci]; ) = procDist[proci];
} }

View File

@ -95,6 +95,7 @@ Foam::refinementParameters::refinementParameters
nErodeCellZone_(dict.getOrDefault<label>("nCellZoneErodeIter", 0)), nErodeCellZone_(dict.getOrDefault<label>("nCellZoneErodeIter", 0)),
nFilterIter_(dict.getOrDefault<label>("nFilterIter", 2)), nFilterIter_(dict.getOrDefault<label>("nFilterIter", 2)),
minCellFraction_(dict.getOrDefault<scalar>("minCellFraction", 0)), minCellFraction_(dict.getOrDefault<scalar>("minCellFraction", 0)),
nMinCells_(dict.getOrDefault<label>("nMinCells", 0)),
dryRun_(dryRun) dryRun_(dryRun)
{ {
point locationInMesh; point locationInMesh;

View File

@ -115,6 +115,8 @@ class refinementParameters
const scalar minCellFraction_; const scalar minCellFraction_;
const label nMinCells_;
const bool dryRun_; const bool dryRun_;
@ -244,6 +246,13 @@ public:
return minCellFraction_; return minCellFraction_;
} }
//- When are disconnected regions small. Absolute number of cells
// in a zone or background. Default 0.
label nMinCells() const
{
return nMinCells_;
}
// Other // Other

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2015 OpenFOAM Foundation Copyright (C) 2011-2015 OpenFOAM Foundation
Copyright (C) 2015-2021 OpenCFD Ltd. Copyright (C) 2015-2022 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -3209,21 +3209,22 @@ void Foam::snappyRefineDriver::deleteSmallRegions
forAll(nCellsPerRegion, regioni) forAll(nCellsPerRegion, regioni)
{ {
const label zonei = regionToZone[regioni]; const label zonei = regionToZone[regioni];
label& nRegionCells = nCellsPerRegion[regioni];
if if
( (
nCellsPerRegion[regioni] nRegionCells < refineParams.minCellFraction()*nCellsPerZone[zonei]
< refineParams.minCellFraction()*nCellsPerZone[zonei] || nRegionCells < refineParams.nMinCells()
) )
{ {
Info<< "Deleting region " << regioni Info<< "Deleting region " << regioni
<< " (size " << nCellsPerRegion[regioni] << " (size " << nRegionCells
<< ") of zone size " << nCellsPerZone[zonei] << ") of zone size " << nCellsPerZone[zonei]
<< endl; << endl;
// Mark region to be deleted. 0 size (= global) should never // Mark region to be deleted. 0 size (= global) should never
// occur. // occur.
nCellsPerRegion[regioni] = 0; nRegionCells = 0;
} }
} }

View File

@ -81,6 +81,57 @@ void Foam::advancingFrontAMI::checkPatches() const
} }
bool Foam::advancingFrontAMI::isCandidate
(
const label srcFacei,
const label tgtFacei
) const
{
const auto& srcPatch = this->srcPatch();
const auto& tgtPatch = this->tgtPatch();
if
(
(srcMagSf_[srcFacei] < ROOTVSMALL)
|| (tgtMagSf_[tgtFacei] < ROOTVSMALL)
)
{
return false;
}
if (maxDistance2_ > 0)
{
const point& srcFc = srcPatch.faceCentres()[srcFacei];
const point& tgtFc = tgtPatch.faceCentres()[tgtFacei];
const vector& srcN = srcPatch.faceNormals()[srcFacei];
const scalar normalDist((tgtFc-srcFc)&srcN);
//if (magSqr(srcFc-tgtFc) >= maxDistance2_)
if (sqr(normalDist) >= maxDistance2_)
{
return false;
}
}
if (minCosAngle_ > -1)
{
const vector& srcN = srcPatch.faceNormals()[srcFacei];
vector tgtN = tgtPatch.faceNormals()[tgtFacei];
if (!reverseTarget_)
{
tgtN = -tgtN;
}
if ((srcN & tgtN) <= minCosAngle_)
{
return false;
}
}
return true;
}
void Foam::advancingFrontAMI::createExtendedTgtPatch() void Foam::advancingFrontAMI::createExtendedTgtPatch()
{ {
// Create processor map of extended cells. This map gets (possibly // Create processor map of extended cells. This map gets (possibly
@ -251,7 +302,7 @@ Foam::label Foam::advancingFrontAMI::findTargetFace
const pointIndexHit sample = const pointIndexHit sample =
treePtr_->findNearest(srcPt, magSqr(bb.max() - bb.centre()), fnOp); treePtr_->findNearest(srcPt, magSqr(bb.max() - bb.centre()), fnOp);
if (sample.hit()) if (sample.hit() && isCandidate(srcFacei, sample.index()))
{ {
targetFacei = sample.index(); targetFacei = sample.index();
@ -375,6 +426,8 @@ Foam::advancingFrontAMI::advancingFrontAMI
) )
: :
AMIInterpolation(dict, reverseTarget), AMIInterpolation(dict, reverseTarget),
maxDistance2_(dict.getOrDefault<scalar>("maxDistance2", -1)),
minCosAngle_(dict.getOrDefault<scalar>("minCosAngle", -1)),
srcTris_(), srcTris_(),
tgtTris_(), tgtTris_(),
extendedTgtPatchPtr_(nullptr), extendedTgtPatchPtr_(nullptr),
@ -404,6 +457,8 @@ Foam::advancingFrontAMI::advancingFrontAMI
) )
: :
AMIInterpolation(requireMatch, reverseTarget, lowWeightCorrection), AMIInterpolation(requireMatch, reverseTarget, lowWeightCorrection),
maxDistance2_(-1),
minCosAngle_(-1),
srcTris_(), srcTris_(),
tgtTris_(), tgtTris_(),
extendedTgtPatchPtr_(nullptr), extendedTgtPatchPtr_(nullptr),
@ -419,6 +474,8 @@ Foam::advancingFrontAMI::advancingFrontAMI
Foam::advancingFrontAMI::advancingFrontAMI(const advancingFrontAMI& ami) Foam::advancingFrontAMI::advancingFrontAMI(const advancingFrontAMI& ami)
: :
AMIInterpolation(ami), AMIInterpolation(ami),
maxDistance2_(ami.maxDistance2_),
minCosAngle_(ami.minCosAngle_),
srcTris_(), srcTris_(),
tgtTris_(), tgtTris_(),
extendedTgtPatchPtr_(nullptr), extendedTgtPatchPtr_(nullptr),
@ -452,6 +509,24 @@ bool Foam::advancingFrontAMI::calculate
const auto& src = this->srcPatch(); const auto& src = this->srcPatch();
const auto& tgt = this->tgtPatch(); const auto& tgt = this->tgtPatch();
if (maxDistance2_ > 0)
{
// Early trigger face centre calculation
(void)src.faceCentres();
(void)tgt.faceCentres();
// Early trigger face normals calculation
(void)src.faceNormals();
(void)tgt.faceNormals();
}
if (minCosAngle_ > -1)
{
// Early trigger face normals calculation
(void)src.faceNormals();
(void)tgt.faceNormals();
}
// Initialise area magnitudes // Initialise area magnitudes
srcMagSf_.setSize(src.size(), 1.0); srcMagSf_.setSize(src.size(), 1.0);
tgtMagSf_.setSize(tgt.size(), 1.0); tgtMagSf_.setSize(tgt.size(), 1.0);
@ -479,6 +554,8 @@ bool Foam::advancingFrontAMI::calculate
void Foam::advancingFrontAMI::write(Ostream& os) const void Foam::advancingFrontAMI::write(Ostream& os) const
{ {
AMIInterpolation::write(os); AMIInterpolation::write(os);
os.writeEntryIfDifferent<scalar>("maxDistance2", -1, maxDistance2_);
os.writeEntryIfDifferent<scalar>("minCosAngle", -1, minCosAngle_);
os.writeEntryIfDifferent<word> os.writeEntryIfDifferent<word>
( (
"triMode", "triMode",

View File

@ -106,6 +106,12 @@ protected:
// Protected data // Protected data
//- Maximum squared distance
const scalar maxDistance2_;
//- Minimum (cos of) angle. 1 for perfectly matching.
const scalar minCosAngle_;
//- Storage for src-side triangle decomposition //- Storage for src-side triangle decomposition
List<DynamicList<face>> srcTris_; List<DynamicList<face>> srcTris_;
@ -148,6 +154,10 @@ protected:
//- Check AMI patch coupling //- Check AMI patch coupling
void checkPatches() const; void checkPatches() const;
//- Is source/target a valid pair (i.e. not too far/different
// orientation). Used for prefiltering before e.g. area overlap
bool isCandidate(const label srcFacei, const label tgtFacei) const;
virtual bool calculate virtual bool calculate
( (
const primitivePatch& srcPatch, const primitivePatch& srcPatch,

View File

@ -379,12 +379,8 @@ void Foam::faceAreaWeightAMI::calcInterArea
{ {
addProfiling(ami, "faceAreaWeightAMI::interArea"); addProfiling(ami, "faceAreaWeightAMI::interArea");
// Quick reject if either face has zero area // Quick reject if either face has zero area/too far away/wrong orientation
if if (!isCandidate(srcFacei, tgtFacei))
(
(srcMagSf_[srcFacei] < ROOTVSMALL)
|| (tgtMagSf_[tgtFacei] < ROOTVSMALL)
)
{ {
return; return;
} }
@ -459,12 +455,8 @@ bool Foam::faceAreaWeightAMI::overlaps
const scalar threshold const scalar threshold
) const ) const
{ {
// Quick reject if either face has zero area // Quick reject if either face has zero area/too far away/wrong orientation
if if (!isCandidate(srcFacei, tgtFacei))
(
(srcMagSf_[srcFacei] < ROOTVSMALL)
|| (tgtMagSf_[tgtFacei] < ROOTVSMALL)
)
{ {
return false; return false;
} }

View File

@ -133,12 +133,8 @@ void Foam::faceAreaWeightAMI2D::storeInterArea
{ {
addProfiling(ami, "faceAreaWeightAMI2D::calcInterArea"); addProfiling(ami, "faceAreaWeightAMI2D::calcInterArea");
// Quick reject if either face has zero area // Quick reject if either face has zero area/too far away/wrong orientation
if if (!isCandidate(srcFacei, tgtFacei))
(
(srcMagSf_[srcFacei] < ROOTVSMALL)
|| (tgtMagSf_[tgtFacei] < ROOTVSMALL)
)
{ {
return; return;
} }

View File

@ -147,6 +147,14 @@ $(setWriters)/vtk/foamVtkCoordSetWriter.C
$(setWriters)/vtk/vtkSetWriterRunTime.C $(setWriters)/vtk/vtkSetWriterRunTime.C
$(setWriters)/xmgrace/xmgraceSetWriterRunTime.C $(setWriters)/xmgrace/xmgraceSetWriterRunTime.C
graph/curve.C
graph/graph.C
graphWriters = graph/writers
$(graphWriters)/raw/rawGraphWriter.C
$(graphWriters)/gnuplot/gnuplotGraphWriter.C
$(graphWriters)/xmgrace/xmgraceGraphWriter.C
topoSets = topoSet/topoSets topoSets = topoSet/topoSets
$(topoSets)/cellBitSet.C $(topoSets)/cellBitSet.C

View File

@ -34,8 +34,8 @@ SourceFiles
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#ifndef curve_H #ifndef Foam_curve_H
#define curve_H #define Foam_curve_H
#include "string.H" #include "string.H"
#include "primitiveFields.H" #include "primitiveFields.H"
@ -46,8 +46,7 @@ SourceFiles
namespace Foam namespace Foam
{ {
// Forward declaration of friend functions and operators // Forward Declarations
class curve; class curve;
Ostream& operator<<(Ostream&, const curve&); Ostream& operator<<(Ostream&, const curve&);
@ -60,13 +59,11 @@ class curve
: :
public scalarField public scalarField
{ {
public: public:
//- The style (line, symbol, etc) of a curve //- The style (line, symbol, etc) of a curve
class curveStyle class curveStyle
{ {
public: public:
//- Enumeration definitions //- Enumeration definitions
@ -116,9 +113,10 @@ public:
private: private:
// private data // Private Data
string name_; string name_;
curveStyle style_; curveStyle style_;
@ -126,9 +124,6 @@ public:
// Constructors // Constructors
//- Construct as interpolation of an existing curve
//curve(const curve&, const label);
//- Construct from name, style and size //- Construct from name, style and size
curve curve
( (
@ -151,7 +146,7 @@ public:
} }
// Member functions // Member Functions
// Access // Access
@ -166,12 +161,6 @@ public:
} }
// Friend functions
//- Gradient of the curve
//friend curve grad(const curve&);
// Ostream operator // Ostream operator
friend Ostream& operator<<(Ostream&, const curve&); friend Ostream& operator<<(Ostream&, const curve&);

View File

@ -29,7 +29,6 @@ License
#include "graph.H" #include "graph.H"
#include "OFstream.H" #include "OFstream.H"
#include "IOmanip.H" #include "IOmanip.H"
#include "Pair.H"
#include "OSspecific.H" #include "OSspecific.H"
#include "SubField.H" #include "SubField.H"
@ -272,9 +271,9 @@ void Foam::graph::write(Ostream& os, const word& format) const
void Foam::graph::write(const fileName& pName, const word& format) const void Foam::graph::write(const fileName& pName, const word& format) const
{ {
autoPtr<writer> graphWriter(writer::New(format)); autoPtr<writer> writer(writer::New(format));
OFstream graphFile(pName + '.' + graphWriter().ext()); OFstream graphFile(pName + '.' + writer().ext());
if (graphFile.good()) if (graphFile.good())
{ {

View File

@ -35,23 +35,21 @@ SourceFiles
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#ifndef graph_H #ifndef Foam_graph_H
#define graph_H #define Foam_graph_H
#include "string.H" #include "string.H"
#include "point.H" #include "point.H"
#include "HashPtrTable.H"
#include "curve.H" #include "curve.H"
#include "HashPtrTable.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam namespace Foam
{ {
// Forward declaration of friend functions and operators // Forward Declaration
class graph; class graph;
Ostream& operator<<(Ostream&, const graph&); Ostream& operator<<(Ostream&, const graph&);
@ -63,7 +61,7 @@ class graph
: :
public HashPtrTable<curve> public HashPtrTable<curve>
{ {
// private data // Private Data
string title_; string title_;
string xName_; string xName_;
@ -71,13 +69,10 @@ class graph
scalarField x_; scalarField x_;
struct xy struct xy
{ {
scalar x_, y_; scalar x_, y_;
xy()
{}
// Friend Operators // Friend Operators
@ -143,10 +138,10 @@ public:
); );
//- Construct from Istream //- Construct from Istream
graph(Istream& is); explicit graph(Istream& is);
// Member functions // Member Functions
// Access // Access
@ -190,7 +185,6 @@ public:
//- Abstract base class for a graph writer //- Abstract base class for a graph writer
class writer class writer
{ {
protected: protected:
void writeXY void writeXY
@ -219,17 +213,13 @@ public:
// Selectors // Selectors
//- Return a reference to the selected writer //- Return a reference to the selected writer
static autoPtr<writer> New static autoPtr<writer> New(const word& writeFormat);
(
const word& writeFormat
);
// Constructors // Constructors
//- Construct null //- Default construct
writer() writer() = default;
{}
//- Destructor //- Destructor
@ -238,19 +228,14 @@ public:
// Member Functions // Member Functions
// Access //- The fileName extension for this graph format
virtual word ext() const = 0;
//- Return the appropriate fileName extension //- Write graph in appropriate format
// for this graph format virtual void write(const graph&, Ostream&) const = 0;
virtual const word& ext() const = 0;
// Write
//- Write graph in appropriate format
virtual void write(const graph&, Ostream&) const = 0;
}; };
//- Write out graph data as a simple table //- Write out graph data as a simple table
void writeTable(Ostream&) const; void writeTable(Ostream&) const;
@ -272,7 +257,7 @@ public:
static word wordify(const string& sname); static word wordify(const string& sname);
// Friend operators // Friend Operators
//- Ostream Operator //- Ostream Operator
friend Ostream& operator<<(Ostream&, const graph&); friend Ostream& operator<<(Ostream&, const graph&);

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2012 OpenFOAM Foundation Copyright (C) 2011-2012 OpenFOAM Foundation
Copyright (C) 2019 OpenCFD Ltd. Copyright (C) 2019-2022 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -26,50 +26,49 @@ License
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#include "gnuplotGraph.H" #include "gnuplotGraphWriter.H"
#include "addToRunTimeSelectionTable.H" #include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam namespace Foam
{ {
defineTypeNameAndDebug(gnuplotGraph, 0); typedef graph::writer graphWriter;
const word gnuplotGraph::ext_("gplt");
typedef graph::writer graphWriter; namespace graphWriters
addToRunTimeSelectionTable(graphWriter, gnuplotGraph, word); {
defineTypeName(gnuplotWriter);
addToRunTimeSelectionTable(graphWriter, gnuplotWriter, word);
}
} }
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::gnuplotGraph::write(const graph& g, Ostream& os) const void Foam::graphWriters::gnuplotWriter::write
(
const graph& g,
Ostream& os
) const
{ {
os << "#set term postscript color" << endl os << "set term pngcairo" << nl
<< "set output \"" << word(g.title()) << ".ps\"" << endl << "set output \"" << word(g.title()) << ".png\"" << nl
<< "set title " << g.title() << " 0,0" << endl << "show title" << endl << "set title " << g.title() << " 0,0" << nl << "show title" << nl
<< "set xlabel " << g.xName() << " 0,0" << endl << "show xlabel" << endl << "set xlabel " << g.xName() << " 0,0" << nl << "show xlabel" << nl
<< "set ylabel " << g.yName() << " 0,0" << endl << "show ylabel" << endl << "set ylabel " << g.yName() << " 0,0" << nl << "show ylabel" << nl;
<< "plot";
bool firstField = true;
label nplots = 0;
forAllConstIters(g, iter) forAllConstIters(g, iter)
{ {
if (!firstField) os << (nplots++ ? ", \\" : "plot \\") << nl;
{
os << ',';
}
firstField = false;
os << "'-' title " << iter()->name() << " with lines"; os << "'-' title " << iter()->name() << " with lines";
} }
os << "; pause -1" << endl; os << "; pause -1" << nl;
forAllConstIters(g, iter) forAllConstIters(g, iter)
{ {
os << endl; os << nl;
writeXY(g.x(), *iter(), os); writeXY(g.x(), *iter(), os);
} }
} }

View File

@ -6,6 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011 OpenFOAM Foundation Copyright (C) 2011 OpenFOAM Foundation
Copyright (C) 2022 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -24,18 +25,18 @@ License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class Class
Foam::gnuplotGraph Foam::graphWriters::gnuplotWriter
Description Description
Output in gnuplot (http://www.gnuplot.info) format Output in gnuplot (http://www.gnuplot.info) format
SourceFiles SourceFiles
gnuplotGraph.C gnuplotGraphWriter.C
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#ifndef gnuplotGraph_H #ifndef Foam_gnuplotGraphWriter_H
#define gnuplotGraph_H #define Foam_gnuplotGraphWriter_H
#include "graph.H" #include "graph.H"
@ -43,57 +44,42 @@ SourceFiles
namespace Foam namespace Foam
{ {
namespace graphWriters
{
/*---------------------------------------------------------------------------*\ /*---------------------------------------------------------------------------*\
Class gnuplotGraph Declaration Class gnuplotWriter Declaration
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
class gnuplotGraph class gnuplotWriter
: :
public graph::writer public graph::writer
{ {
public: public:
//- Runtime type information //- Runtime type information
TypeName("gnuplot"); TypeNameNoDebug("gnuplot");
//- FileName extension for this graph format
static const word ext_;
// Constructors
//- Construct null
gnuplotGraph()
{}
//- Default construct
gnuplotWriter() = default;
//- Destructor //- Destructor
~gnuplotGraph() ~gnuplotWriter() = default;
{}
// Member Functions // Member Functions
// Access //- The fileName extension for this graph format
word ext() const { return "gplt"; }
//- Return the appropriate fileName extension //- Write
// for this graph format void write(const graph&, Ostream& os) const;
const word& ext() const
{
return ext_;
}
// Write
void write(const graph&, Ostream& os) const;
}; };
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace graphWriters
} // End namespace Foam } // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -6,6 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2012 OpenFOAM Foundation Copyright (C) 2011-2012 OpenFOAM Foundation
Copyright (C) 2022 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -25,24 +26,30 @@ License
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#include "rawGraph.H" #include "rawGraphWriter.H"
#include "addToRunTimeSelectionTable.H" #include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam namespace Foam
{ {
defineTypeNameAndDebug(rawGraph, 0); typedef graph::writer graphWriter;
const word rawGraph::ext_("xy");
typedef graph::writer graphWriter; namespace graphWriters
addToRunTimeSelectionTable(graphWriter, rawGraph, word); {
defineTypeName(rawWriter);
addToRunTimeSelectionTable(graphWriter, rawWriter, word);
}
} }
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::rawGraph::write(const graph& g, Ostream& os) const void Foam::graphWriters::rawWriter::write
(
const graph& g,
Ostream& os
) const
{ {
g.writeTable(os); g.writeTable(os);
} }

View File

@ -6,6 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011 OpenFOAM Foundation Copyright (C) 2011 OpenFOAM Foundation
Copyright (C) 2022 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -24,18 +25,18 @@ License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class Class
Foam::rawGraph Foam::graphWriters::rawWriter
Description Description
A raw xy graph output A raw xy graph output
SourceFiles SourceFiles
rawGraph.C rawGraphWriter.C
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#ifndef rawGraph_H #ifndef Foam_rawGraphWriter_H
#define rawGraph_H #define Foam_rawGraphWriter_H
#include "graph.H" #include "graph.H"
@ -43,57 +44,42 @@ SourceFiles
namespace Foam namespace Foam
{ {
namespace graphWriters
{
/*---------------------------------------------------------------------------*\ /*---------------------------------------------------------------------------*\
Class rawGraph Declaration Class rawWriter Declaration
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
class rawGraph class rawWriter
: :
public graph::writer public graph::writer
{ {
public: public:
//- Runtime type information //- Runtime type information
TypeName("raw"); TypeNameNoDebug("raw");
//- FileName extension for this graph format
static const word ext_;
// Constructors
//- Construct null
rawGraph()
{}
//- Default construct
rawWriter() = default;
//- Destructor //- Destructor
~rawGraph() ~rawWriter() = default;
{}
// Member Functions // Member Functions
// Access //- The fileName extension for this graph format
word ext() const { return "xy"; }
//- Return the appropriate fileName extension //- Write
// for this graph format void write(const graph&, Ostream& os) const;
const word& ext() const
{
return ext_;
}
// Write
void write(const graph&, Ostream& os) const;
}; };
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace graphWriters
} // End namespace Foam } // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2019 OpenCFD Ltd. Copyright (C) 2019-2022 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -26,43 +26,49 @@ License
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#include "xmgrGraph.H" #include "xmgraceGraphWriter.H"
#include "addToRunTimeSelectionTable.H" #include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam namespace Foam
{ {
defineTypeNameAndDebug(xmgrGraph, 0);
const word xmgrGraph::ext_("agr");
typedef graph::writer graphWriter; typedef graph::writer graphWriter;
addToRunTimeSelectionTable(graphWriter, xmgrGraph, word);
namespace graphWriters
{
defineTypeName(xmgraceWriter);
addToRunTimeSelectionTable(graphWriter, xmgraceWriter, word);
}
} }
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::xmgrGraph::write(const graph& g, Ostream& os) const void Foam::graphWriters::xmgraceWriter::write
(
const graph& g,
Ostream& os
) const
{ {
os << "@title " << g.title() << nl os << "@title " << g.title() << nl
<< "@xaxis label " << g.xName() << nl << "@xaxis label " << g.xName() << nl
<< "@yaxis label " << g.yName() << endl; << "@yaxis label " << g.yName() << nl;
label fieldi = 0; label nWritten_ = 0;
forAllConstIters(g, iter) forAllConstIters(g, iter)
{ {
os << "@s" << fieldi << " legend " os << "@s" << nWritten_ << " legend "
<< iter()->name() << nl << iter()->name() << nl
<< "@target G0.S" << fieldi << nl << "@target G0.S" << nWritten_ << nl
<< "@type xy" << endl; << "@type xy" << nl;
writeXY(g.x(), *iter(), os); writeXY(g.x(), *iter(), os);
os << endl; os << endl;
fieldi++; ++nWritten_;
} }
} }

View File

@ -6,6 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011 OpenFOAM Foundation Copyright (C) 2011 OpenFOAM Foundation
Copyright (C) 2022 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -24,19 +25,19 @@ License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class Class
Foam::xmgrGraph Foam::graphWriters::xmgraceWriter
Description Description
Output and \b agr file for \em xmgrace Output and \b agr file for \em xmgrace
(http://plasma-gate.weizmann.ac.il/Grace/) (http://plasma-gate.weizmann.ac.il/Grace/)
SourceFiles SourceFiles
xmgrGraph.C xmgraceGraphWriter.C
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#ifndef xmgrGraph_H #ifndef Foam_xmgraceGraphWriter_H
#define xmgrGraph_H #define Foam_xmgraceGraphWriter_H
#include "graph.H" #include "graph.H"
@ -44,57 +45,42 @@ SourceFiles
namespace Foam namespace Foam
{ {
namespace graphWriters
{
/*---------------------------------------------------------------------------*\ /*---------------------------------------------------------------------------*\
Class xmgrGraph Declaration Class xmgraceWriter Declaration
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
class xmgrGraph class xmgraceWriter
: :
public graph::writer public graph::writer
{ {
public: public:
//- Runtime type information //- Runtime type information
TypeName("xmgr"); TypeNameNoDebug("xmgr");
//- FileName extension for this graph format
static const word ext_;
// Constructors
//- Construct null
xmgrGraph()
{}
//- Default construct
xmgraceWriter() = default;
//- Destructor //- Destructor
~xmgrGraph() ~xmgraceWriter() = default;
{}
// Member Functions // Member Functions
// Access //- The fileName extension for this graph format
word ext() const { return "agr"; }
//- Return the appropriate fileName extension //- Write
// for this graph format void write(const graph&, Ostream& os) const;
const word& ext() const
{
return ext_;
}
// Write
void write(const graph&, Ostream& os) const;
}; };
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace graphWriters
} // End namespace Foam } // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -294,7 +294,7 @@ public:
//- Return total number of regions //- Return total number of regions
label nRegions() const label nRegions() const
{ {
return globalNumbering().size(); return globalNumbering().totalSize();
} }
//- Manually consolidate regions globally by swapping information //- Manually consolidate regions globally by swapping information

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