Compare commits

..

2 Commits

205 changed files with 2017 additions and 4528 deletions

View File

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

View File

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

View File

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

View File

@ -43,8 +43,9 @@ Description
- volScalarField with regions as different scalars (-detectOnly)
or
- mesh with multiple regions and mapped patches. These patches
either cover the whole interface between two region (default) or
only part according to faceZones (-useFaceZones)
either cover the whole interface between two region (default),
only part according to faceZones (-useFaceZones) or be auto-generated
according to an AMI method (see below)
or
- mesh with cells put into cellZones (-makeCellZones)
@ -57,7 +58,7 @@ Description
-combineZones '((zoneA "zoneB.*")(none otherZone))
This can be combined with e.g. 'cellZones' or 'cellZonesOnly'. The
addZones option supplies the destination region name as first element in
the list. The combineZones option synthesises the region name e.g.
the list. The combineZones option synthesises the region name e.g.
zoneA_zoneB0_zoneB1
- cellZonesOnly does not do a walk and uses the cellZones only. Use
@ -98,6 +99,14 @@ Description
- boundaryRegionAddressing : for every patch in this region the
patch in the original mesh (or -1 if added patch)
- auto-generate patches using AMI area-overlap detection. This requires a
patchSet to apply it to and an optional AMIMethod (default is
faceAreaWeightAMI2D).
-autoPatch '("solid*")'
-AMIMethod faceAreaWeightAMI2D
Any mapped patch thus generated should probably use the
nearestPatchFaceAMI sampling method.
\*---------------------------------------------------------------------------*/
#include "argList.H"
@ -116,6 +125,7 @@ Description
#include "fvMeshTools.H"
#include "zeroGradientFvPatchFields.H"
#include "processorMeshes.H"
#include "faceAreaWeightAMI2D.H"
using namespace Foam;
@ -317,12 +327,115 @@ void addToInterface
}
labelList getMinBoundaryValue
(
const polyMesh& mesh,
const word& AMIMethod,
const labelList& matchPatchIDs,
const labelList& cellRegion
)
{
// Neighbour cellRegion.
labelList coupledRegion(mesh.nBoundaryFaces());
forAll(coupledRegion, i)
{
label celli = mesh.faceOwner()[i+mesh.nInternalFaces()];
coupledRegion[i] = cellRegion[celli];
}
syncTools::swapBoundaryFaceList(mesh, coupledRegion);
// Add approximate matches
forAll(matchPatchIDs, i)
{
const label patchi = matchPatchIDs[i];
const auto& pp = mesh.boundaryMesh()[patchi];
for (label j = i+1; j < matchPatchIDs.size(); ++j)
{
const label nbrPatchi = matchPatchIDs[j];
const auto& nbrPp = mesh.boundaryMesh()[nbrPatchi];
// Use AMI to try and find matches
auto AMPtr(AMIInterpolation::New(AMIMethod));
AMPtr->calculate(pp, nbrPp, nullptr);
if
(
gAverage(AMPtr->tgtWeightsSum()) > SMALL
|| gAverage(AMPtr->srcWeightsSum()) > SMALL
)
{
// Pull remote data local
labelList thisDecomp(pp.size(), labelMax);
AMPtr->interpolateToSource
(
labelList(cellRegion, nbrPp.faceCells()),
[]
(
label& res,
const label facei,
const label& fld,
const scalar& w
)
{
res = min(res, fld);
},
thisDecomp,
thisDecomp // used in case of low-weight-corr
);
// Put thisDecomp into coupledRegion. Check for unmatched faces.
forAll(thisDecomp, i)
{
if (thisDecomp[i] != labelMax)
{
coupledRegion[pp.offset()+i] = thisDecomp[i];
}
}
labelList nbrDecomp(nbrPp.size(), labelMax);
AMPtr->interpolateToTarget
(
labelList(cellRegion, pp.faceCells()), //thisDecomp,
[]
(
label& res,
const label facei,
const label& fld,
const scalar& w
)
{
res = min(res, fld);
},
nbrDecomp,
nbrDecomp // used in case of low-weight-corr
);
// Put nbrDecomp into coupledRegion. Check for unmatched faces/
forAll(nbrDecomp, i)
{
if (nbrDecomp[i] != labelMax)
{
coupledRegion[nbrPp.offset()+i] = nbrDecomp[i];
}
}
}
}
}
return coupledRegion;
}
// Get region-region interface name and sizes.
// Returns interfaces as straight list for looping in identical order.
void getInterfaceSizes
(
const polyMesh& mesh,
const bool useFaceZones,
const word& AMIMethod,
const labelList& matchPatchIDs,
const labelList& cellRegion,
const wordList& regionNames,
@ -361,15 +474,16 @@ void getInterfaceSizes
// Boundary faces
// ~~~~~~~~~~~~~~
// Neighbour cellRegion.
labelList coupledRegion(mesh.nBoundaryFaces());
forAll(coupledRegion, i)
{
label celli = mesh.faceOwner()[i+mesh.nInternalFaces()];
coupledRegion[i] = cellRegion[celli];
}
syncTools::swapBoundaryFaceList(mesh, coupledRegion);
const labelList coupledRegion
(
getMinBoundaryValue
(
mesh,
AMIMethod,
matchPatchIDs,
cellRegion
)
);
forAll(coupledRegion, i)
{
@ -583,6 +697,8 @@ autoPtr<mapPolyMesh> createRegionMesh
const labelList& cellRegion,
const label regionI,
const word& regionName,
const word& AMIMethod,
const labelList& matchPatchIDs,
// Interface info
const labelList& interfacePatches,
const labelList& faceToInterface,
@ -594,15 +710,16 @@ autoPtr<mapPolyMesh> createRegionMesh
fvMeshTools::createDummyFvMeshFiles(mesh, regionName, true);
// Neighbour cellRegion.
labelList coupledRegion(mesh.nBoundaryFaces());
forAll(coupledRegion, i)
{
label celli = mesh.faceOwner()[i+mesh.nInternalFaces()];
coupledRegion[i] = cellRegion[celli];
}
syncTools::swapBoundaryFaceList(mesh, coupledRegion);
const labelList coupledRegion
(
getMinBoundaryValue
(
mesh,
AMIMethod,
matchPatchIDs,
cellRegion
)
);
// Topology change container. Start off from existing mesh.
polyTopoChange meshMod(mesh);
@ -621,20 +738,16 @@ autoPtr<mapPolyMesh> createRegionMesh
labelList exposedPatchIDs(exposedFaces.size());
forAll(exposedFaces, i)
{
label facei = exposedFaces[i];
label interfacei = faceToInterface[facei];
const label facei = exposedFaces[i];
const label interfacei = faceToInterface[facei];
label ownRegion = cellRegion[mesh.faceOwner()[facei]];
label neiRegion = -1;
if (mesh.isInternalFace(facei))
{
neiRegion = cellRegion[mesh.faceNeighbour()[facei]];
}
else
{
neiRegion = coupledRegion[facei-mesh.nInternalFaces()];
}
const label ownRegion = cellRegion[mesh.faceOwner()[facei]];
const label neiRegion
(
mesh.isInternalFace(facei)
? cellRegion[mesh.faceNeighbour()[facei]]
: coupledRegion[facei-mesh.nInternalFaces()]
);
// Check which side is being kept - determines which of the two
@ -681,6 +794,62 @@ autoPtr<mapPolyMesh> createRegionMesh
meshMod
);
// Do re-patching on non-removed cells ourselves. These are not exposed
// faces but are boundary faces
for (label bFacei = 0; bFacei < mesh.nBoundaryFaces(); bFacei++)
{
const label facei = mesh.nInternalFaces()+bFacei;
if (!meshMod.faceRemoved(facei))
{
const label interfacei = faceToInterface[facei];
const label ownRegion = cellRegion[mesh.faceOwner()[facei]];
const label neiRegion = coupledRegion[bFacei];
label exposedPatchID = -1;
if (ownRegion == regionI)
{
if (regionI < neiRegion)
{
exposedPatchID = interfacePatches[interfacei];
}
else if (regionI > neiRegion)
{
exposedPatchID = interfacePatches[interfacei]+1;
}
}
else if (neiRegion == regionI)
{
if (regionI < ownRegion)
{
exposedPatchID = interfacePatches[interfacei];
}
else if (regionI > ownRegion)
{
exposedPatchID = interfacePatches[interfacei]+1;
}
}
if (exposedPatchID != -1)
{
// In-place modify the patch
DynamicList<label>& patchID =
const_cast<DynamicList<label>&>(meshMod.region());
//Pout<< "For face:" << facei
// << " on interface:" << interfacei
// << " modifying from own:" << meshMod.faceOwner()[facei]
// << " nei:" << meshMod.faceNeighbour()[facei]
// << " verts:" << meshMod.faces()[facei]
// << " patch " << patchID[facei]
// << " to " << exposedPatchID << endl;
patchID[facei] = exposedPatchID;
}
}
}
autoPtr<mapPolyMesh> map = meshMod.makeMesh
(
newMesh,
@ -705,6 +874,8 @@ void createAndWriteRegion
const labelList& cellRegion,
const wordList& regionNames,
const bool prefixRegion,
const word& AMIMethod,
const labelList& matchPatchIDs,
const labelList& faceToInterface,
const labelList& interfacePatches,
const label regionI,
@ -721,6 +892,8 @@ void createAndWriteRegion
cellRegion,
regionI,
regionNames[regionI],
AMIMethod,
matchPatchIDs,
interfacePatches,
faceToInterface,
newMesh
@ -1019,6 +1192,7 @@ labelList addRegionPatches
const wordList& regionNames,
const edgeList& interfaces,
const List<Pair<word>>& interfaceNames
//const List<mappedPatchBase::sampleMode>& interfaceModes
)
{
Info<< nl << "Adding patches" << nl << endl;
@ -1042,7 +1216,7 @@ labelList addRegionPatches
0, // overridden
0, // overridden
regionNames[e[1]], // sampleRegion
mappedPatchBase::NEARESTPATCHFACE,
mappedPatchBase::NEARESTPATCHFACE, //interfaceModes[interI]
names[1], // samplePatch
point::zero, // offset
mesh.boundaryMesh()
@ -1064,7 +1238,7 @@ labelList addRegionPatches
0,
0,
regionNames[e[0]], // sampleRegion
mappedPatchBase::NEARESTPATCHFACE,
mappedPatchBase::NEARESTPATCHFACE, //interfaceModes[interI]
names[0],
point::zero, // offset
mesh.boundaryMesh()
@ -1455,6 +1629,7 @@ int main(int argc, char *argv[])
"Split mesh into multiple regions (detected by walking across faces)"
);
#include "addRegionOption.H"
#include "addOverwriteOption.H"
argList::addBoolOption
(
@ -1521,6 +1696,18 @@ int main(int argc, char *argv[])
"useFaceZones",
"Use faceZones to patch inter-region faces instead of single patch"
);
argList::addOption
(
"autoPatch",
"lists of patches",
"Find overlapping faces to auto-generate interface patches"
);
argList::addOption
(
"AMIMethod",
"word",
"type of AMI matching method"
);
argList::addBoolOption
(
"prefixRegion",
@ -1533,6 +1720,12 @@ int main(int argc, char *argv[])
#include "createTime.H"
#include "createNamedMesh.H"
// Note: could try to read multiple meshes and merge into one before
// operation but this would give problems with unique prefixes:
// - patches get renamed. So patchFields would need to be renamed.
// - what about e.g. 'samplePatch' in mapped patches?
const word oldInstance = mesh.pointsInstance();
word blockedFacesName;
@ -1556,6 +1749,14 @@ int main(int argc, char *argv[])
const bool useFaceZones = args.found("useFaceZones");
const bool prefixRegion = args.found("prefixRegion");
labelList matchPatchIDs;
word AMIMethod(faceAreaWeightAMI2D::typeName);
if (args.found("autoPatch"))
{
const wordRes patchNames(args.getList<wordRe>("autoPatch"));
matchPatchIDs = mesh.boundaryMesh().indices(patchNames);
args.readIfPresent("AMIMethod", AMIMethod);
}
if
(
@ -1585,6 +1786,13 @@ int main(int argc, char *argv[])
}
if (matchPatchIDs.size())
{
Info<< "Auto-detecting matching faces out of patches "
<< UIndirectList<word>(mesh.boundaryMesh().names(), matchPatchIDs)
<< nl << endl;
}
if (insidePoint && largestOnly)
{
@ -1652,8 +1860,8 @@ int main(int argc, char *argv[])
<< " This requires all"
<< " cells to be in one and only one cellZone." << nl << endl;
// Collect sets of zones into clusters. If no cluster is just an identity
// list (cluster 0 is cellZone 0 etc.)
// Collect sets of zones into clusters. If no cluster is just an
// identity list (cluster 0 is cellZone 0 etc.)
wordList clusterNames;
labelListList clusterToZones;
labelList zoneToCluster;
@ -1829,7 +2037,7 @@ int main(int argc, char *argv[])
{
label ownCluster = clusterID[mesh.faceOwner()[facei]];
label neiCluster = clusterID[mesh.faceNeighbour()[facei]];
if (ownCluster != neiCluster)
{
blockedFace[facei] = true;
@ -1968,6 +2176,8 @@ int main(int argc, char *argv[])
(
mesh,
useFaceZones,
AMIMethod,
matchPatchIDs,
cellRegion,
regionNames,
@ -2147,6 +2357,7 @@ int main(int argc, char *argv[])
regionNames,
interfaces,
interfaceNames
//interfaceModes
)
);
@ -2199,6 +2410,8 @@ int main(int argc, char *argv[])
cellRegion,
regionNames,
prefixRegion,
AMIMethod,
matchPatchIDs,
faceToInterface,
interfacePatches,
regionI,
@ -2220,6 +2433,8 @@ int main(int argc, char *argv[])
cellRegion,
regionNames,
prefixRegion,
AMIMethod,
matchPatchIDs,
faceToInterface,
interfacePatches,
regionI,
@ -2241,6 +2456,8 @@ int main(int argc, char *argv[])
cellRegion,
regionNames,
prefixRegion,
AMIMethod,
matchPatchIDs,
faceToInterface,
interfacePatches,
regionI,

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -124,9 +124,14 @@ public:
//- Get the current trigger index
label getTrigger() const;
//- Set new trigger index.
//- Set the trigger index. Normally only if greater than current
//
// \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
bool setTrigger(const label triggeri);
bool setTrigger(const label triggeri, bool increaseOnly = true);
//- Set dictionary, return true if set
bool getDict

View File

@ -64,10 +64,11 @@ void Foam::functionObjects::timeControl::readControls()
timeEnd_ = time_.userTimeToTime(timeEnd_);
}
controlMode_ =
controlModeNames_.getOrDefault("controlMode", dict_, controlMode::TIME);
dict_.readIfPresent("triggerStart", triggerStart_);
dict_.readIfPresent("triggerEnd", triggerEnd_);
if (dict_.readIfPresent("triggerStart", triggerStart_))
{
dict_.readIfPresent("triggerEnd", triggerEnd_);
controlMode_ = controlModeNames_.get("controlMode", dict_);
}
deltaTCoeff_ = GREAT;
if (dict_.readIfPresent("deltaTCoeff", deltaTCoeff_))
@ -96,18 +97,6 @@ bool Foam::functionObjects::timeControl::active() const
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_)
{
case controlMode::TIME:
@ -465,7 +454,7 @@ Foam::functionObjects::timeControl::timeControl
controlMode_(controlMode::TIME),
timeStart_(-VGREAT),
timeEnd_(VGREAT),
triggerStart_(labelMin),
triggerStart_(labelMax),
triggerEnd_(labelMax),
nStepsToStartTimeChange_(labelMax),
executeControl_(runTime, dict, "execute"),

View File

@ -1,238 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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

@ -1,189 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,68 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM, 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,16 +101,18 @@ public:
// Member Functions
//- Order in which comms is scheduled
const labelList& schedule() const noexcept
const labelList& schedule() const
{
return schedule_;
}
//- Per processor the order in which communication has been scheduled
const labelListList& procSchedule() const noexcept
const labelListList& procSchedule() const
{
return procSchedule_;
}
};

View File

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

View File

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

View File

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

View File

@ -54,7 +54,11 @@ Foam::globalIndex::calcListOffsets
if (checkOverflow && start < values[i])
{
reportOverflowAndExit(i);
FatalErrorInFunction
<< "Overflow : sum of sizes exceeds labelMax ("
<< labelMax << ") after index " << i << nl
<< "Please recompile with larger datatype for label." << nl
<< exit(FatalError);
}
}
values[len] = start;
@ -94,7 +98,7 @@ void Foam::globalIndex::gather
if (Pstream::myProcNo(comm) == procIDs[0])
{
allFld.resize_nocopy(off.last()); // == totalSize()
allFld.resize_nocopy(off.last());
// Assign my local data - respect offset information
// so that we can request 0 entries to be copied.
@ -108,11 +112,7 @@ void Foam::globalIndex::gather
{
SubList<Type> procSlot(allFld, off[i+1]-off[i], off[i]);
if (procSlot.empty())
{
// Nothing to do
}
else if (is_contiguous<Type>::value)
if (is_contiguous<Type>::value)
{
IPstream::read
(
@ -140,11 +140,7 @@ void Foam::globalIndex::gather
}
else
{
if (fld.empty())
{
// Nothing to do
}
else if (is_contiguous<Type>::value)
if (is_contiguous<Type>::value)
{
OPstream::write
(
@ -202,7 +198,7 @@ void Foam::globalIndex::gather
if (Pstream::myProcNo(comm) == procIDs[0])
{
allFld.resize_nocopy(off.last()); // == totalSize()
allFld.resize_nocopy(off.last());
// Assign my local data - respect offset information
// so that we can request 0 entries to be copied
@ -218,43 +214,29 @@ void Foam::globalIndex::gather
{
SubList<Type> procSlot(allFld, off[i+1]-off[i], off[i]);
if (procSlot.empty())
{
// Nothing to do
}
else
{
IPstream fromProc
(
commsType,
procIDs[i],
0,
tag,
comm
);
fromProc >> procSlot;
}
}
}
else
{
if (fld.empty())
{
// Nothing to do
}
else
{
OPstream toMaster
IPstream fromProc
(
commsType,
procIDs[0],
procIDs[i],
0,
tag,
comm
);
toMaster << fld;
fromProc >> procSlot;
}
}
else
{
OPstream toMaster
(
commsType,
procIDs[0],
0,
tag,
comm
);
toMaster << fld;
}
}
@ -459,7 +441,7 @@ void Foam::globalIndex::mpiGather
nSendBytes = 0;
}
allData.resize_nocopy(globalAddr.totalSize());
allData.resize_nocopy(globalAddr.size());
recvSizes.resize(nproc);
recvOffsets.resize(nproc+1);
@ -469,7 +451,7 @@ void Foam::globalIndex::mpiGather
recvSizes[proci] = globalAddr.localSize(proci) * sizeof(Type);
recvOffsets[proci] = globalAddr.localStart(proci) * sizeof(Type);
}
recvOffsets[nproc] = globalAddr.totalSize() * sizeof(Type);
recvOffsets[nproc] = globalAddr.size() * sizeof(Type);
}
else
{
@ -707,10 +689,6 @@ void Foam::globalIndex::scatter
// 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();
if (Pstream::myProcNo(comm) == procIDs[0])

View File

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

View File

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

View File

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

View File

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

View File

@ -41,8 +41,8 @@ SourceFiles
\*---------------------------------------------------------------------------*/
#ifndef Foam_stringListOps_H
#define Foam_stringListOps_H
#ifndef stringListOps_H
#define stringListOps_H
#include "labelList.H"
#include "stringList.H"
@ -358,18 +358,6 @@ 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.
// Uses a combination of allow and deny lists
//

View File

@ -135,18 +135,21 @@ template<class StringListType, class AccessOp>
Foam::labelList Foam::stringListOps::findMatching
(
const StringListType& input,
const wordRes::filter& pred,
const wordRes& allow,
const wordRes& deny,
AccessOp aop
)
{
const label len = input.size();
if (pred.empty())
if (allow.empty() && deny.empty())
{
// Accept all
return identity(len);
}
// Use combined accept/reject filter
const wordRes::filter pred(allow, deny);
labelList indices(len);
label count = 0;
@ -166,26 +169,4 @@ 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
localPoints.setSize(meshes.size());
labelList globalToCompact(globalPoints.totalSize(), -1);
labelList globalToCompact(globalPoints.size(), -1);
label nGlobal = 0;
forAll(meshes, meshi)
{

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -5,7 +5,8 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2022 OpenCFD Ltd.
Copyright (C) 2015 OpenFOAM Foundation
Copyright (C) 2015-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -27,6 +28,7 @@ License
#include "valueAverage.H"
#include "addToRunTimeSelectionTable.H"
#include "Time.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
@ -39,6 +41,21 @@ 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 * * * * * * * * * * * * * * //
Foam::functionObjects::valueAverage::valueAverage
@ -49,9 +66,30 @@ Foam::functionObjects::valueAverage::valueAverage
)
:
regionFunctionObject(name, runTime, dict),
valueAverageBase(name, obr_, dict, *this)
writeFile(obr_, name, typeName, dict),
functionObjectName_("unknown-functionObject"),
fieldNames_(),
window_(-1),
totalTime_(),
resetOnRestart_(false)
{
readState(this->propertyDict());
read(dict);
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());
}
@ -59,25 +97,103 @@ Foam::functionObjects::valueAverage::valueAverage
bool Foam::functionObjects::valueAverage::read(const dictionary& dict)
{
if (regionFunctionObject::read(dict) && valueAverageBase::read(dict))
regionFunctionObject::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_))
{
return true;
window_ = obr().time().userTimeToTime(window_);
}
return false;
totalTime_.setSize(fieldNames_.size());
forAll(totalTime_, i)
{
totalTime_[i] = time_.deltaTValue();
}
dict.readIfPresent("resetOnRestart", resetOnRestart_);
return true;
}
bool Foam::functionObjects::valueAverage::execute()
{
(void)valueAverageBase::calculate(this->propertyDict());
scalar dt = obr_.time().deltaTValue();
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;
}
bool Foam::functionObjects::valueAverage::write()
{
valueAverageBase::writeState(this->propertyDict());
return true;
}

View File

@ -5,7 +5,8 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2022 OpenCFD Ltd.
Copyright (C) 2015 OpenFOAM Foundation
Copyright (C) 2016-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -78,13 +79,14 @@ Usage
The inherited entries are elaborated in:
- \link regionFunctionObject.H \endlink
- \link valueAverageBase.H \endlink
- \link writeFile.H \endlink
Usage by the \c postProcess utility is not available.
See also
- Foam::functionObject
- Foam::functionObjects::valueAverageBase
- Foam::functionObjects::stateFunctionObject
- Foam::functionObjects::writeFile
- ExtendedCodeGuide::functionObjects::field::valueAverage
SourceFiles
@ -97,7 +99,6 @@ SourceFiles
#define functionObjects_valueAverage_H
#include "regionFunctionObject.H"
#include "valueAverageBase.H"
#include "writeFile.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -114,8 +115,45 @@ namespace functionObjects
class valueAverage
:
public regionFunctionObject,
public valueAverageBase
public writeFile
{
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:
//- Runtime type information
@ -163,6 +201,12 @@ public:
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
#include "valueAverageTemplates.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

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

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2012-2016 OpenFOAM Foundation
Copyright (C) 2015-2022 OpenCFD Ltd.
Copyright (C) 2015 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -27,10 +27,8 @@ License
\*---------------------------------------------------------------------------*/
#include "cloudInfo.H"
#include "cloud.H"
#include "kinematicCloud.H"
#include "dictionary.H"
#include "mathematicalConstants.H"
#include "PstreamReduceOps.H"
#include "addToRunTimeSelectionTable.H"
@ -76,10 +74,8 @@ Foam::functionObjects::cloudInfo::cloudInfo
const dictionary& dict
)
:
functionObjects::regionFunctionObject(name, runTime, dict),
functionObjects::logFiles(obr_, name, dict),
verbose_(false),
onExecute_(false)
regionFunctionObject(name, runTime, dict),
logFiles(obr_, name, dict)
{
read(dict);
}
@ -89,175 +85,55 @@ Foam::functionObjects::cloudInfo::cloudInfo
bool Foam::functionObjects::cloudInfo::read(const dictionary& dict)
{
parcelSelect_.clear();
verbose_ = false;
onExecute_ = false;
if (regionFunctionObject::read(dict) && logFiles::read(dict))
{
logFiles::resetNames(dict.get<wordList>("clouds"));
Info<< type() << " " << name() << ": ";
if (names().size())
if (writeToFile() && names().size())
{
Info<< "applying to clouds:" << nl;
for (const word& cldName : names())
forAll(names(), cloudi)
{
Info<< " " << cldName << nl;
Info<< " " << names()[cloudi] << nl;
writeFileHeader(files(cloudi));
}
Info<< endl;
// Actions to define selection
parcelSelect_ = dict.subOrEmptyDict("selection");
verbose_ = dict.getOrDefault("verbose", false);
onExecute_ = dict.getOrDefault("sampleOnExecute", false);
}
else
{
Info<< "no clouds to be processed" << nl << endl;
}
if (writeToFile())
{
forAll(names(), cloudi)
{
writeFileHeader(files(cloudi));
}
}
}
return true;
}
bool Foam::functionObjects::cloudInfo::performAction(unsigned request)
bool Foam::functionObjects::cloudInfo::execute()
{
if (!request || names().empty())
{
return true;
}
return true;
}
bool Foam::functionObjects::cloudInfo::write()
{
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 auto* kinCloudPtr = obr_.cfindObject<kinematicCloud>(cloudName);
const kinematicCloud& cloud =
obr_.lookupObject<kinematicCloud>(cloudName);
if (!kinCloudPtr)
{
// Safety
continue;
}
const label nTotParcels =
returnReduce(cloud.nParcels(), sumOp<label>());
const auto& kinCloud = *kinCloudPtr;
const auto* plainCloudPtr = isA<cloud>(kinCloud);
const scalar totMass =
returnReduce(cloud.massInSystem(), sumOp<scalar>());
if (!parcelSelect_.empty() && plainCloudPtr)
{
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);
}
const scalar Dmax = cloud.Dmax();
const scalar D10 = cloud.Dij(1, 0);
const scalar D32 = cloud.Dij(3, 2);
Log << type() << " " << name() << " write:" << nl
<< " number of parcels : " << nTotParcels << nl
@ -267,7 +143,7 @@ bool Foam::functionObjects::cloudInfo::performAction(unsigned request)
<< " D32 diameter : " << D32 << nl
<< endl;
if ((request & ACTION_WRITE) && writeToFile())
if (writeToFile())
{
auto& os = files(cloudi);
@ -286,21 +162,4 @@ bool Foam::functionObjects::cloudInfo::performAction(unsigned request)
}
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 |
-------------------------------------------------------------------------------
Copyright (C) 2012-2016 OpenFOAM Foundation
Copyright (C) 2015-2022 OpenCFD Ltd.
Copyright (C) 2015-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -58,8 +58,6 @@ Usage
Property | Description | Required | Default
type | type name: cloudInfo | 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
The output data of each cloud is written to a file named \<cloudName\>.dat
@ -74,12 +72,11 @@ SourceFiles
\*---------------------------------------------------------------------------*/
#ifndef Foam_functionObjects_cloudInfo_H
#define Foam_functionObjects_cloudInfo_H
#ifndef functionObjects_cloudInfo_H
#define functionObjects_cloudInfo_H
#include "regionFunctionObject.H"
#include "logFiles.H"
#include "parcelSelectionDetail.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -94,31 +91,13 @@ namespace functionObjects
class cloudInfo
:
public functionObjects::regionFunctionObject,
public functionObjects::logFiles,
public Foam::Detail::parcelSelection
public regionFunctionObject,
public logFiles
{
protected:
// Data Types
//- 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_;
//- Switch to send output to Info as well
Switch log_;
//- List of cloud names
wordList cloudNames_;
@ -126,14 +105,11 @@ protected:
//- Output file per cloud
PtrList<OFstream> filePtrs_;
// Protected Member Functions
//- File header information
virtual void writeFileHeader(Ostream& os) const;
//- Perform operation report/write
bool performAction(unsigned request);
//- No copy construct
cloudInfo(const cloudInfo&) = delete;

View File

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

View File

@ -5,7 +5,8 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2022 OpenCFD Ltd.
Copyright (C) 2015 OpenFOAM Foundation
Copyright (C) 2015-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -27,6 +28,7 @@ License
#include "averageCondition.H"
#include "addToRunTimeSelectionTable.H"
#include "Time.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
@ -42,6 +44,18 @@ 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 * * * * * * * * * * * * * * //
Foam::functionObjects::runTimeControls::averageCondition::averageCondition
@ -53,13 +67,44 @@ Foam::functionObjects::runTimeControls::averageCondition::averageCondition
)
:
runTimeCondition(name, obr, dict, state),
valueAverageBase(name, obr_, dict, state, false),
functionObjectName_(dict.get<word>("functionObject")),
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)),
iter_(-1)
{
dictionary& conditionDict = this->conditionDict();
readState(conditionDict);
forAll(fieldNames_, fieldi)
{
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_);
}
@ -74,18 +119,53 @@ bool Foam::functionObjects::runTimeControls::averageCondition::apply()
return true;
}
bool running = iter_ > nIterStartUp_;
bool satisfied = iter_ > nIterStartUp_;
++iter_;
dictionary& conditionDict = this->conditionDict();
const scalar dt = obr_.time().deltaTValue();
Log << " " << type() << ": " << name_ << " averages:" << nl;
Info<< incrIndent;
running = valueAverageBase::calculate(conditionDict) && running;
Info<< decrIndent;
DynamicList<label> unprocessedFields(fieldNames_.size());
return running;
forAll(fieldNames_, fieldi)
{
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;
}
@ -93,18 +173,25 @@ void Foam::functionObjects::runTimeControls::averageCondition::write()
{
dictionary& conditionDict = this->conditionDict();
valueAverageBase::writeState(conditionDict);
forAll(fieldNames_, fieldi)
{
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_);
}
void Foam::functionObjects::runTimeControls::averageCondition::reset()
{
valueAverageBase::resetState(this->conditionDict());
iter_ = 0;
}
// ************************************************************************* //

View File

@ -5,7 +5,8 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2022 OpenCFD Ltd.
Copyright (C) 2015 OpenFOAM Foundation
Copyright (C) 2016-2018 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -30,20 +31,18 @@ Description
Average run time condition - satisfied when average does not change by
more than a given value.
See also
- Foam::functionObjects::valueAverageBase
SourceFiles
averageCondition.H
averageCondition.C
\*---------------------------------------------------------------------------*/
#ifndef functionObjects_runTimeControls_averageCondition_H
#define functionObjects_runTimeControls_averageCondition_H
#ifndef averageCondition_H
#define averageCondition_H
#include "runTimeCondition.H"
#include "valueAverageBase.H"
#include "Switch.H"
#include "Enum.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -60,12 +59,46 @@ namespace runTimeControls
class averageCondition
:
public runTimeCondition,
public valueAverageBase
public runTimeCondition
{
public:
// Public enumerations
enum class windowType
{
NONE,
APPROXIMATE,
EXACT
};
static const Enum<windowType> windowTypeNames;
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
label nIterStartUp_;
@ -73,6 +106,17 @@ protected:
//- Current iteration count
label iter_;
// Protected Member Functions
//- Templated function to calculate the average
template<class Type>
void calc
(
const label fieldi,
bool& satisfied,
bool& processed
);
public:
@ -99,9 +143,6 @@ public:
//- Write
virtual void write();
//- Reset
virtual void reset();
};
@ -113,6 +154,12 @@ public:
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
#include "averageConditionTemplates.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,100 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class
Foam::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 |
-------------------------------------------------------------------------------
Copyright (C) 2015 OpenFOAM Foundation
Copyright (C) 2016-2022 OpenCFD Ltd.
Copyright (C) 2016 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -162,9 +162,6 @@ public:
//- Write
virtual void write() = 0;
//- Reset
virtual void reset() = 0;
};

View File

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

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2015-2016 OpenFOAM Foundation
Copyright (C) 2016-2022 OpenCFD Ltd.
Copyright (C) 2016-2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -111,11 +111,6 @@ private:
// trigger has been set
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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -81,57 +81,6 @@ 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()
{
// Create processor map of extended cells. This map gets (possibly
@ -302,7 +251,7 @@ Foam::label Foam::advancingFrontAMI::findTargetFace
const pointIndexHit sample =
treePtr_->findNearest(srcPt, magSqr(bb.max() - bb.centre()), fnOp);
if (sample.hit() && isCandidate(srcFacei, sample.index()))
if (sample.hit())
{
targetFacei = sample.index();
@ -426,8 +375,6 @@ Foam::advancingFrontAMI::advancingFrontAMI
)
:
AMIInterpolation(dict, reverseTarget),
maxDistance2_(dict.getOrDefault<scalar>("maxDistance2", -1)),
minCosAngle_(dict.getOrDefault<scalar>("minCosAngle", -1)),
srcTris_(),
tgtTris_(),
extendedTgtPatchPtr_(nullptr),
@ -457,8 +404,6 @@ Foam::advancingFrontAMI::advancingFrontAMI
)
:
AMIInterpolation(requireMatch, reverseTarget, lowWeightCorrection),
maxDistance2_(-1),
minCosAngle_(-1),
srcTris_(),
tgtTris_(),
extendedTgtPatchPtr_(nullptr),
@ -474,8 +419,6 @@ Foam::advancingFrontAMI::advancingFrontAMI
Foam::advancingFrontAMI::advancingFrontAMI(const advancingFrontAMI& ami)
:
AMIInterpolation(ami),
maxDistance2_(ami.maxDistance2_),
minCosAngle_(ami.minCosAngle_),
srcTris_(),
tgtTris_(),
extendedTgtPatchPtr_(nullptr),
@ -509,24 +452,6 @@ bool Foam::advancingFrontAMI::calculate
const auto& src = this->srcPatch();
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
srcMagSf_.setSize(src.size(), 1.0);
tgtMagSf_.setSize(tgt.size(), 1.0);
@ -554,8 +479,6 @@ bool Foam::advancingFrontAMI::calculate
void Foam::advancingFrontAMI::write(Ostream& os) const
{
AMIInterpolation::write(os);
os.writeEntryIfDifferent<scalar>("maxDistance2", -1, maxDistance2_);
os.writeEntryIfDifferent<scalar>("minCosAngle", -1, minCosAngle_);
os.writeEntryIfDifferent<word>
(
"triMode",

View File

@ -106,12 +106,6 @@ protected:
// 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
List<DynamicList<face>> srcTris_;
@ -154,10 +148,6 @@ protected:
//- Check AMI patch coupling
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
(
const primitivePatch& srcPatch,

View File

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

View File

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

View File

@ -147,14 +147,6 @@ $(setWriters)/vtk/foamVtkCoordSetWriter.C
$(setWriters)/vtk/vtkSetWriterRunTime.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)/cellBitSet.C

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