Compare commits
26 Commits
feature-sp
...
feature-cl
| Author | SHA1 | Date | |
|---|---|---|---|
| 5cf529659d | |||
| b94ffe93f1 | |||
| 3c2db201b7 | |||
| eb676f08a1 | |||
| 666e5f6dc4 | |||
| a74b9ca763 | |||
| 1a55829ef9 | |||
| cb10045094 | |||
| 02f57f8a36 | |||
| fc43ed9d68 | |||
| 3c1da487f2 | |||
| 3d134167dd | |||
| bb04f5759d | |||
| 53c2eae543 | |||
| fcb328332b | |||
| f46c398372 | |||
| ff8518a89a | |||
| 5386dd56db | |||
| 59dbee741f | |||
| 055a7b29e0 | |||
| 711e1142ed | |||
| 2a25b356b9 | |||
| a67f6bf7ae | |||
| 42f426f6c4 | |||
| 58f76ccc5f | |||
| ad6f17652b |
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011 OpenFOAM Foundation
|
||||
Copyright (C) 2017-2020 OpenCFD Ltd.
|
||||
Copyright (C) 2017-2022 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -196,19 +196,23 @@ int main(int argc, char *argv[])
|
||||
|
||||
SortList<scalar> sorter1(list1);
|
||||
|
||||
Info<< nl << "Sorted: " << flatOutput(sorter1) << nl;
|
||||
Info<< nl << "Sort indices: " << flatOutput(sorter1.indices()) << nl;
|
||||
|
||||
Info<< nl << "Reverse indices: " << flatOutput(sorter1.indices()) << nl;
|
||||
|
||||
// Reverses indices
|
||||
sorter1.reverse();
|
||||
|
||||
Info<< nl << "Again indices: " << flatOutput(sorter1.indices()) << nl;
|
||||
Info<< nl << "Reverse: " << flatOutput(sorter1.indices()) << nl;
|
||||
|
||||
sorter1.reset();
|
||||
|
||||
Info<< nl << "Reset indices: " << flatOutput(sorter1.indices()) << nl;
|
||||
|
||||
sorter1.reverseSort();
|
||||
|
||||
Info<< nl << "Reverse indices: " << flatOutput(sorter1.indices()) << nl;
|
||||
|
||||
Info<< nl << "Sorted : " << flatOutput(sorter1) << nl;
|
||||
Info<< nl << "Reverse sorted: " << flatOutput(sorter1) << nl;
|
||||
|
||||
sorter1.sort(std::greater<scalar>());
|
||||
|
||||
|
||||
@ -1015,7 +1015,10 @@ Foam::label Foam::checkGeometry
|
||||
|
||||
const fileName outputDir
|
||||
(
|
||||
mesh.time().globalPath()/functionObject::outputPrefix/"checkMesh"
|
||||
mesh.time().globalPath()
|
||||
/functionObject::outputPrefix
|
||||
/(mesh.name() == polyMesh::defaultRegion ? word::null : mesh.name())
|
||||
/"checkMesh"
|
||||
);
|
||||
|
||||
forAll(pbm, patchi)
|
||||
@ -1031,7 +1034,6 @@ 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();
|
||||
|
||||
{
|
||||
@ -1044,7 +1046,7 @@ Foam::label Foam::checkGeometry
|
||||
(
|
||||
mesh,
|
||||
wr,
|
||||
outputDir / pName + "-src_" + tmName,
|
||||
outputDir / cpp.name() + "-src_" + tmName,
|
||||
ami.srcWeightsSum(),
|
||||
cpp.localFaces(),
|
||||
cpp.meshPoints(),
|
||||
@ -1070,7 +1072,7 @@ Foam::label Foam::checkGeometry
|
||||
(
|
||||
mergedPoints,
|
||||
mergedFaces,
|
||||
(outputDir / pName + "-src_" + tmName),
|
||||
(outputDir / cpp.name() + "-src_" + tmName),
|
||||
false // serial - already merged
|
||||
);
|
||||
|
||||
@ -1080,6 +1082,8 @@ Foam::label Foam::checkGeometry
|
||||
}
|
||||
}
|
||||
{
|
||||
const auto& nbrPp = cpp.neighbPatch();
|
||||
|
||||
// Collect geometry
|
||||
faceList mergedFaces;
|
||||
pointField mergedPoints;
|
||||
@ -1089,11 +1093,14 @@ Foam::label Foam::checkGeometry
|
||||
(
|
||||
mesh,
|
||||
wr,
|
||||
outputDir / pName + "-tgt_" + tmName,
|
||||
(
|
||||
outputDir
|
||||
/ nbrPp.name() + "-tgt_" + tmName
|
||||
),
|
||||
ami.tgtWeightsSum(),
|
||||
cpp.neighbPatch().localFaces(),
|
||||
cpp.neighbPatch().meshPoints(),
|
||||
cpp.neighbPatch().meshPointMap(),
|
||||
nbrPp.localFaces(),
|
||||
nbrPp.meshPoints(),
|
||||
nbrPp.meshPointMap(),
|
||||
|
||||
mergedFaces,
|
||||
mergedPoints,
|
||||
@ -1118,7 +1125,10 @@ Foam::label Foam::checkGeometry
|
||||
(
|
||||
mergedPoints,
|
||||
mergedFaces,
|
||||
(outputDir / pName + "-tgt_" + tmName),
|
||||
(
|
||||
outputDir
|
||||
/ nbrPp.name() + "-tgt_" + tmName
|
||||
),
|
||||
false // serial - already merged
|
||||
);
|
||||
|
||||
@ -1135,8 +1145,6 @@ 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;
|
||||
@ -1146,7 +1154,7 @@ Foam::label Foam::checkGeometry
|
||||
(
|
||||
mesh,
|
||||
wr,
|
||||
outputDir / pName + "-src_" + tmName,
|
||||
outputDir / pp.name() + "-src_" + tmName,
|
||||
ami.srcWeightsSum(),
|
||||
pp.localFaces(),
|
||||
pp.meshPoints(),
|
||||
@ -1173,7 +1181,7 @@ Foam::label Foam::checkGeometry
|
||||
(
|
||||
cpp.sampleMesh(),
|
||||
wr,
|
||||
outputDir / pName + "-tgt_" + tmName,
|
||||
outputDir / nbrPp.name() + "-tgt_" + tmName,
|
||||
ami.tgtWeightsSum(),
|
||||
nbrPp.localFaces(),
|
||||
nbrPp.meshPoints(),
|
||||
|
||||
@ -98,11 +98,13 @@ 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
|
||||
@ -136,8 +138,10 @@ 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;
|
||||
|
||||
@ -149,6 +153,8 @@ void matchPatchFaces
|
||||
intMesh0.setSize(nSourcei, -1);
|
||||
intMesh0[sourcei] = meshi;
|
||||
|
||||
interfaceSource0.append(sourcei);
|
||||
|
||||
interfacePatch0.append(labelList());
|
||||
auto& intPatch0 = interfacePatch0.last();
|
||||
intPatch0.setSize(nSourcei, -1);
|
||||
@ -157,15 +163,11 @@ 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 0
|
||||
// Mesh 1
|
||||
//~~~~~~~
|
||||
|
||||
interfaceMesh1.append(labelList());
|
||||
@ -173,6 +175,8 @@ void matchPatchFaces
|
||||
intMesh1.setSize(nSourcej, -1);
|
||||
intMesh1[sourcej] = meshj;
|
||||
|
||||
interfaceSource1.append(sourcej);
|
||||
|
||||
interfacePatch1.append(labelList());
|
||||
auto& intPatch1 = interfacePatch1.last();
|
||||
intPatch1.setSize(nSourcej, -1);
|
||||
@ -181,10 +185,6 @@ 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,11 +283,13 @@ 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
|
||||
@ -338,11 +340,13 @@ void matchPatchFaces
|
||||
patchesj,
|
||||
|
||||
interfaceMesh0,
|
||||
interfaceSource0,
|
||||
interfacePatch0,
|
||||
interfaceNames0,
|
||||
interfaceFaces0,
|
||||
|
||||
interfaceMesh1,
|
||||
interfaceSource1,
|
||||
interfacePatch1,
|
||||
interfaceNames1,
|
||||
interfaceFaces1
|
||||
@ -413,10 +417,23 @@ void changePatchID
|
||||
|
||||
if (!isRepatchedBoundary.set(facei-mesh.nInternalFaces()))
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Face " << facei << " is already marked to be moved"
|
||||
<< " to patch " << meshMod.region()[facei]
|
||||
<< exit(FatalError);
|
||||
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++;
|
||||
}
|
||||
|
||||
changePatchID(mesh, facei, patchID, meshMod);
|
||||
@ -721,7 +738,6 @@ int main(int argc, char *argv[])
|
||||
);
|
||||
|
||||
#include "addOverwriteOption.H"
|
||||
//#include "addRegionOption.H"
|
||||
#include "addAllRegionOptions.H"
|
||||
|
||||
argList::addOption("dict", "file", "Alternative createPatchDict");
|
||||
@ -780,17 +796,25 @@ int main(int argc, char *argv[])
|
||||
forAll(patchSources, sourcei)
|
||||
{
|
||||
const auto& pDict = patchSources[sourcei];
|
||||
patchNames[meshi][sourcei] = pDict.get<word>("name");
|
||||
patchNames[meshi][sourcei] = pDict.getOrDefault<word>
|
||||
(
|
||||
"name",
|
||||
word::null,
|
||||
keyType::LITERAL
|
||||
);
|
||||
|
||||
patchInfoDicts[meshi].set
|
||||
(
|
||||
sourcei,
|
||||
new dictionary(pDict.subDict("patchInfo"))
|
||||
);
|
||||
const dictionary& patchDict = patchInfoDicts[meshi][sourcei];
|
||||
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;
|
||||
@ -817,9 +841,11 @@ 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 mesh, per patchSource:
|
||||
// Per interface, 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
|
||||
@ -829,6 +855,7 @@ 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;
|
||||
@ -843,15 +870,17 @@ int main(int argc, char *argv[])
|
||||
interRegionSources,
|
||||
patchNames,
|
||||
matchPatchIDs,
|
||||
matchMethods, //faceAreaWeightAMI2D::typeName,
|
||||
matchMethods,
|
||||
patchInfoDicts,
|
||||
|
||||
interfaceMesh0,
|
||||
interfaceSource0,
|
||||
interfacePatch0,
|
||||
interfaceFaces0,
|
||||
interfaceNames0,
|
||||
|
||||
interfaceMesh1,
|
||||
interfaceSource1,
|
||||
interfacePatch1,
|
||||
interfaceFaces1,
|
||||
interfaceNames1
|
||||
@ -859,6 +888,7 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Read fields
|
||||
List<PtrList<volScalarField>> vsFlds(meshes.size());
|
||||
List<PtrList<volVectorField>> vvFlds(meshes.size());
|
||||
@ -914,6 +944,9 @@ 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];
|
||||
|
||||
@ -933,11 +966,20 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
const dictionary& dict = patchSources[sourcei];
|
||||
const word sourceType(dict.get<word>("constructFrom"));
|
||||
const word patchName(dict.get<word>("name"));
|
||||
const word patchName
|
||||
(
|
||||
dict.getOrDefault<word>
|
||||
(
|
||||
"name",
|
||||
word::null,
|
||||
keyType::LITERAL
|
||||
)
|
||||
);
|
||||
|
||||
dictionary patchDict(dict.subDict("patchInfo"));
|
||||
dictionary patchDict(patchInfoDicts[meshi][sourcei]);
|
||||
patchDict.set("nFaces", 0);
|
||||
patchDict.set("startFace", 0); //startFacei);
|
||||
patchDict.set("startFace", 0); // Gets overwritten
|
||||
|
||||
|
||||
if (sourceType == "autoPatch")
|
||||
{
|
||||
@ -951,42 +993,45 @@ int main(int argc, char *argv[])
|
||||
const labelList& allMeshes1 = interfaceMesh1[inti];
|
||||
const wordList& allNames1 = interfaceNames1[inti];
|
||||
|
||||
forAll(allMeshes0, sourcei)
|
||||
if
|
||||
(
|
||||
interfaceSource0[inti] == sourcei
|
||||
&& allMeshes0[sourcei] == meshi
|
||||
)
|
||||
{
|
||||
if (allMeshes0[sourcei] == meshi)
|
||||
// Current mesh is mesh0. mesh1 is the remote mesh.
|
||||
const label sourcej = interfaceSource1[inti];
|
||||
const word& patchName = allNames0[sourcei];
|
||||
if (patches.findPatchID(patchName) == -1)
|
||||
{
|
||||
const auto& mesh1 = meshes[allMeshes1[sourcei]];
|
||||
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);
|
||||
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);
|
||||
|
||||
Info<< "Adding new patch " << patchName
|
||||
<< " from " << allDict << endl;
|
||||
Info<< "Adding new patch " << patchName
|
||||
<< " from " << allDict << endl;
|
||||
|
||||
autoPtr<polyPatch> ppPtr
|
||||
autoPtr<polyPatch> ppPtr
|
||||
(
|
||||
polyPatch::New
|
||||
(
|
||||
polyPatch::New
|
||||
(
|
||||
patchName,
|
||||
allDict,
|
||||
0, // overwritten
|
||||
patches
|
||||
)
|
||||
);
|
||||
fvMeshTools::addPatch
|
||||
(
|
||||
mesh,
|
||||
ppPtr(),
|
||||
patchDict.subOrEmptyDict("patchFields"),
|
||||
calculatedFvPatchScalarField::typeName,
|
||||
true
|
||||
);
|
||||
}
|
||||
patchName,
|
||||
allDict,
|
||||
0, // overwritten
|
||||
patches
|
||||
)
|
||||
);
|
||||
fvMeshTools::addPatch
|
||||
(
|
||||
mesh,
|
||||
ppPtr(),
|
||||
patchDict.subOrEmptyDict("patchFields"),
|
||||
calculatedFvPatchScalarField::typeName,
|
||||
true
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -998,42 +1043,46 @@ int main(int argc, char *argv[])
|
||||
const labelList& allMeshes1 = interfaceMesh1[inti];
|
||||
const wordList& allNames1 = interfaceNames1[inti];
|
||||
|
||||
forAll(allMeshes1, sourcei)
|
||||
if
|
||||
(
|
||||
interfaceSource1[inti] == sourcei
|
||||
&& allMeshes1[sourcei] == meshi
|
||||
)
|
||||
{
|
||||
if (allMeshes1[sourcei] == meshi)
|
||||
// Current mesh is mesh1. mesh0 is the remote mesh.
|
||||
|
||||
const label sourcej = interfaceSource0[inti];
|
||||
const word& patchName = allNames1[sourcei];
|
||||
if (patches.findPatchID(patchName) == -1)
|
||||
{
|
||||
const auto& mesh0 = meshes[allMeshes0[sourcei]];
|
||||
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);
|
||||
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);
|
||||
|
||||
Info<< "Adding new patch " << patchName
|
||||
<< " from " << allDict << endl;
|
||||
Info<< "Adding new patch " << patchName
|
||||
<< " from " << allDict << endl;
|
||||
|
||||
autoPtr<polyPatch> ppPtr
|
||||
autoPtr<polyPatch> ppPtr
|
||||
(
|
||||
polyPatch::New
|
||||
(
|
||||
polyPatch::New
|
||||
(
|
||||
patchName,
|
||||
allDict,
|
||||
0, // overwritten
|
||||
patches
|
||||
)
|
||||
);
|
||||
fvMeshTools::addPatch
|
||||
(
|
||||
mesh,
|
||||
ppPtr(),
|
||||
patchDict.subOrEmptyDict("patchFields"),
|
||||
calculatedFvPatchScalarField::typeName,
|
||||
true
|
||||
);
|
||||
}
|
||||
patchName,
|
||||
allDict,
|
||||
0, // overwritten
|
||||
patches
|
||||
)
|
||||
);
|
||||
fvMeshTools::addPatch
|
||||
(
|
||||
mesh,
|
||||
ppPtr(),
|
||||
patchDict.subOrEmptyDict("patchFields"),
|
||||
calculatedFvPatchScalarField::typeName,
|
||||
true
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1077,6 +1126,10 @@ 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];
|
||||
|
||||
@ -1096,7 +1149,15 @@ int main(int argc, char *argv[])
|
||||
forAll(patchSources, sourcei)
|
||||
{
|
||||
const dictionary& dict = patchSources[sourcei];
|
||||
const word patchName(dict.get<word>("name"));
|
||||
const word patchName
|
||||
(
|
||||
dict.getOrDefault<word>
|
||||
(
|
||||
"name",
|
||||
word::null,
|
||||
keyType::LITERAL
|
||||
)
|
||||
);
|
||||
const word sourceType(dict.get<word>("constructFrom"));
|
||||
|
||||
if (sourceType == "autoPatch")
|
||||
@ -1111,49 +1172,57 @@ int main(int argc, char *argv[])
|
||||
const wordList& allNames1 = interfaceNames1[inti];
|
||||
const auto& allFaces1 = interfaceFaces1[inti];
|
||||
|
||||
forAll(allMeshes0, sourcei)
|
||||
if
|
||||
(
|
||||
interfaceSource0[inti] == sourcei
|
||||
&& allMeshes0[sourcei] == meshi
|
||||
)
|
||||
{
|
||||
if (allMeshes0[sourcei] == meshi)
|
||||
{
|
||||
const label destPatchi =
|
||||
patches.findPatchID(allNames0[sourcei], false);
|
||||
// Current mesh is mesh0. mesh1 is the remote mesh.
|
||||
|
||||
Pout<< "Matched mesh:" << mesh.name()
|
||||
<< " to mesh:"
|
||||
<< meshes[allMeshes1[sourcei]].name()
|
||||
<< " through:" << allNames0[sourcei] << endl;
|
||||
const label destPatchi =
|
||||
patches.findPatchID(allNames0[sourcei], false);
|
||||
|
||||
changePatchID
|
||||
(
|
||||
mesh,
|
||||
allFaces0[sourcei],
|
||||
destPatchi,
|
||||
isRepatchedBoundary,
|
||||
meshMod
|
||||
);
|
||||
}
|
||||
//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
|
||||
);
|
||||
}
|
||||
forAll(allMeshes1, sourcei)
|
||||
if
|
||||
(
|
||||
interfaceSource1[inti] == sourcei
|
||||
&& allMeshes1[sourcei] == meshi
|
||||
)
|
||||
{
|
||||
if (allMeshes1[sourcei] == meshi)
|
||||
{
|
||||
const label destPatchi =
|
||||
patches.findPatchID(allNames1[sourcei], false);
|
||||
// Current mesh is mesh1. mesh0 is the remote mesh.
|
||||
|
||||
Pout<< "Matched mesh:" << mesh.name()
|
||||
<< " to mesh:"
|
||||
<< meshes[allMeshes0[sourcei]].name()
|
||||
<< " through:" << allNames1[sourcei] << endl;
|
||||
const label destPatchi =
|
||||
patches.findPatchID(allNames1[sourcei], false);
|
||||
|
||||
changePatchID
|
||||
(
|
||||
mesh,
|
||||
allFaces1[sourcei],
|
||||
destPatchi,
|
||||
isRepatchedBoundary,
|
||||
meshMod
|
||||
);
|
||||
}
|
||||
//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
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1213,7 +1282,6 @@ int main(int argc, char *argv[])
|
||||
<< exit(FatalError);
|
||||
}
|
||||
}
|
||||
Info<< endl;
|
||||
|
||||
|
||||
// Change mesh, use inflation to reforce calculation of transformation
|
||||
@ -1398,10 +1466,6 @@ 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)
|
||||
@ -1418,11 +1482,14 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
}
|
||||
|
||||
// Set the precision of the points data to 10
|
||||
IOstream::defaultPrecision(max(10u, IOstream::defaultPrecision()));
|
||||
|
||||
// Write resulting mesh
|
||||
forAll(meshes, meshi)
|
||||
{
|
||||
fvMesh& mesh = meshes[meshi];
|
||||
Info<< "Writing repatched mesh " << mesh.name()
|
||||
Info<< "\n\nWriting repatched mesh " << mesh.name()
|
||||
<< " to " << runTime.timeName() << nl << endl;
|
||||
mesh.clearOut(); // remove meshPhi
|
||||
mesh.write();
|
||||
|
||||
@ -43,9 +43,8 @@ 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),
|
||||
only part according to faceZones (-useFaceZones) or be auto-generated
|
||||
according to an AMI method (see below)
|
||||
either cover the whole interface between two region (default) or
|
||||
only part according to faceZones (-useFaceZones)
|
||||
or
|
||||
- mesh with cells put into cellZones (-makeCellZones)
|
||||
|
||||
@ -58,7 +57,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
|
||||
@ -99,14 +98,6 @@ 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"
|
||||
@ -125,7 +116,6 @@ Description
|
||||
#include "fvMeshTools.H"
|
||||
#include "zeroGradientFvPatchFields.H"
|
||||
#include "processorMeshes.H"
|
||||
#include "faceAreaWeightAMI2D.H"
|
||||
|
||||
using namespace Foam;
|
||||
|
||||
@ -327,115 +317,12 @@ 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,
|
||||
|
||||
@ -474,16 +361,15 @@ void getInterfaceSizes
|
||||
// Boundary faces
|
||||
// ~~~~~~~~~~~~~~
|
||||
|
||||
const labelList coupledRegion
|
||||
(
|
||||
getMinBoundaryValue
|
||||
(
|
||||
mesh,
|
||||
AMIMethod,
|
||||
matchPatchIDs,
|
||||
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);
|
||||
|
||||
forAll(coupledRegion, i)
|
||||
{
|
||||
@ -697,8 +583,6 @@ 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,
|
||||
@ -710,16 +594,15 @@ autoPtr<mapPolyMesh> createRegionMesh
|
||||
fvMeshTools::createDummyFvMeshFiles(mesh, regionName, true);
|
||||
|
||||
// Neighbour cellRegion.
|
||||
const labelList coupledRegion
|
||||
(
|
||||
getMinBoundaryValue
|
||||
(
|
||||
mesh,
|
||||
AMIMethod,
|
||||
matchPatchIDs,
|
||||
cellRegion
|
||||
)
|
||||
);
|
||||
labelList coupledRegion(mesh.nBoundaryFaces());
|
||||
|
||||
forAll(coupledRegion, i)
|
||||
{
|
||||
label celli = mesh.faceOwner()[i+mesh.nInternalFaces()];
|
||||
coupledRegion[i] = cellRegion[celli];
|
||||
}
|
||||
syncTools::swapBoundaryFaceList(mesh, coupledRegion);
|
||||
|
||||
|
||||
// Topology change container. Start off from existing mesh.
|
||||
polyTopoChange meshMod(mesh);
|
||||
@ -738,16 +621,20 @@ autoPtr<mapPolyMesh> createRegionMesh
|
||||
labelList exposedPatchIDs(exposedFaces.size());
|
||||
forAll(exposedFaces, i)
|
||||
{
|
||||
const label facei = exposedFaces[i];
|
||||
const label interfacei = faceToInterface[facei];
|
||||
label facei = exposedFaces[i];
|
||||
label interfacei = faceToInterface[facei];
|
||||
|
||||
const label ownRegion = cellRegion[mesh.faceOwner()[facei]];
|
||||
const label neiRegion
|
||||
(
|
||||
mesh.isInternalFace(facei)
|
||||
? cellRegion[mesh.faceNeighbour()[facei]]
|
||||
: coupledRegion[facei-mesh.nInternalFaces()]
|
||||
);
|
||||
label ownRegion = cellRegion[mesh.faceOwner()[facei]];
|
||||
label neiRegion = -1;
|
||||
|
||||
if (mesh.isInternalFace(facei))
|
||||
{
|
||||
neiRegion = cellRegion[mesh.faceNeighbour()[facei]];
|
||||
}
|
||||
else
|
||||
{
|
||||
neiRegion = coupledRegion[facei-mesh.nInternalFaces()];
|
||||
}
|
||||
|
||||
|
||||
// Check which side is being kept - determines which of the two
|
||||
@ -794,62 +681,6 @@ 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,
|
||||
@ -874,8 +705,6 @@ 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,
|
||||
@ -892,8 +721,6 @@ void createAndWriteRegion
|
||||
cellRegion,
|
||||
regionI,
|
||||
regionNames[regionI],
|
||||
AMIMethod,
|
||||
matchPatchIDs,
|
||||
interfacePatches,
|
||||
faceToInterface,
|
||||
newMesh
|
||||
@ -1192,7 +1019,6 @@ labelList addRegionPatches
|
||||
const wordList& regionNames,
|
||||
const edgeList& interfaces,
|
||||
const List<Pair<word>>& interfaceNames
|
||||
//const List<mappedPatchBase::sampleMode>& interfaceModes
|
||||
)
|
||||
{
|
||||
Info<< nl << "Adding patches" << nl << endl;
|
||||
@ -1216,7 +1042,7 @@ labelList addRegionPatches
|
||||
0, // overridden
|
||||
0, // overridden
|
||||
regionNames[e[1]], // sampleRegion
|
||||
mappedPatchBase::NEARESTPATCHFACE, //interfaceModes[interI]
|
||||
mappedPatchBase::NEARESTPATCHFACE,
|
||||
names[1], // samplePatch
|
||||
point::zero, // offset
|
||||
mesh.boundaryMesh()
|
||||
@ -1238,7 +1064,7 @@ labelList addRegionPatches
|
||||
0,
|
||||
0,
|
||||
regionNames[e[0]], // sampleRegion
|
||||
mappedPatchBase::NEARESTPATCHFACE, //interfaceModes[interI]
|
||||
mappedPatchBase::NEARESTPATCHFACE,
|
||||
names[0],
|
||||
point::zero, // offset
|
||||
mesh.boundaryMesh()
|
||||
@ -1629,7 +1455,6 @@ int main(int argc, char *argv[])
|
||||
"Split mesh into multiple regions (detected by walking across faces)"
|
||||
);
|
||||
#include "addRegionOption.H"
|
||||
|
||||
#include "addOverwriteOption.H"
|
||||
argList::addBoolOption
|
||||
(
|
||||
@ -1696,18 +1521,6 @@ 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",
|
||||
@ -1720,12 +1533,6 @@ 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;
|
||||
@ -1749,14 +1556,6 @@ 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
|
||||
(
|
||||
@ -1786,13 +1585,6 @@ 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)
|
||||
{
|
||||
@ -1860,8 +1652,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;
|
||||
@ -2037,7 +1829,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;
|
||||
@ -2176,8 +1968,6 @@ int main(int argc, char *argv[])
|
||||
(
|
||||
mesh,
|
||||
useFaceZones,
|
||||
AMIMethod,
|
||||
matchPatchIDs,
|
||||
cellRegion,
|
||||
regionNames,
|
||||
|
||||
@ -2357,7 +2147,6 @@ int main(int argc, char *argv[])
|
||||
regionNames,
|
||||
interfaces,
|
||||
interfaceNames
|
||||
//interfaceModes
|
||||
)
|
||||
);
|
||||
|
||||
@ -2410,8 +2199,6 @@ int main(int argc, char *argv[])
|
||||
cellRegion,
|
||||
regionNames,
|
||||
prefixRegion,
|
||||
AMIMethod,
|
||||
matchPatchIDs,
|
||||
faceToInterface,
|
||||
interfacePatches,
|
||||
regionI,
|
||||
@ -2433,8 +2220,6 @@ int main(int argc, char *argv[])
|
||||
cellRegion,
|
||||
regionNames,
|
||||
prefixRegion,
|
||||
AMIMethod,
|
||||
matchPatchIDs,
|
||||
faceToInterface,
|
||||
interfacePatches,
|
||||
regionI,
|
||||
@ -2456,8 +2241,6 @@ int main(int argc, char *argv[])
|
||||
cellRegion,
|
||||
regionNames,
|
||||
prefixRegion,
|
||||
AMIMethod,
|
||||
matchPatchIDs,
|
||||
faceToInterface,
|
||||
interfacePatches,
|
||||
regionI,
|
||||
|
||||
@ -1,9 +1,14 @@
|
||||
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
|
||||
|
||||
@ -1,9 +1,13 @@
|
||||
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
|
||||
|
||||
@ -480,6 +480,8 @@ 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.
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
/*--------------------------------*- C++ -*----------------------------------*\
|
||||
| ========= | |
|
||||
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
|
||||
| \\ / O peration | Version: v2112 |
|
||||
| \\ / O peration | Version: v2206 |
|
||||
| \\ / 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/doc/"
|
||||
"https://www.openfoam.com/documentation/guides/latest/api/"
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@ -365,6 +365,7 @@ $(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
|
||||
@ -594,7 +595,6 @@ 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,22 +803,14 @@ $(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
|
||||
|
||||
graph/curve/curve.C
|
||||
graph/graph.C
|
||||
|
||||
writers = graph/writers
|
||||
$(writers)/rawGraph/rawGraph.C
|
||||
$(writers)/gnuplotGraph/gnuplotGraph.C
|
||||
$(writers)/xmgrGraph/xmgrGraph.C
|
||||
parallel/globalIndex/globalIndex.C
|
||||
|
||||
meshes/data/data.C
|
||||
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
Copyright (C) 2019-2021 OpenCFD Ltd.
|
||||
Copyright (C) 2019-2022 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -143,11 +143,14 @@ 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;
|
||||
|
||||
//- True if the number of rows is zero
|
||||
inline bool empty() const noexcept;
|
||||
//- The total addressed size
|
||||
inline label totalSize() const;
|
||||
|
||||
//- Return the offset table (= size()+1)
|
||||
inline const List<label>& offsets() const;
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
Copyright (C) 2019-2020 OpenCFD Ltd.
|
||||
Copyright (C) 2019-2022 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -123,6 +123,13 @@ Foam::CompactListList<T, Container>::null()
|
||||
}
|
||||
|
||||
|
||||
template<class T, class Container>
|
||||
inline bool Foam::CompactListList<T, Container>::empty() const noexcept
|
||||
{
|
||||
return !size_;
|
||||
}
|
||||
|
||||
|
||||
template<class T, class Container>
|
||||
inline Foam::label Foam::CompactListList<T, Container>::size() const noexcept
|
||||
{
|
||||
@ -131,9 +138,10 @@ inline Foam::label Foam::CompactListList<T, Container>::size() const noexcept
|
||||
|
||||
|
||||
template<class T, class Container>
|
||||
inline bool Foam::CompactListList<T, Container>::empty() const noexcept
|
||||
inline Foam::label Foam::CompactListList<T, Container>::totalSize() const
|
||||
{
|
||||
return !size_;
|
||||
const label len = (offsets_.size() - 1);
|
||||
return (len < 1) ? static_cast<label>(0) : offsets_[len];
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2019 OpenCFD Ltd.
|
||||
Copyright (C) 2019-2022 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -37,8 +37,8 @@ SourceFiles
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef SortList_H
|
||||
#define SortList_H
|
||||
#ifndef Foam_SortList_H
|
||||
#define Foam_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;
|
||||
inline const labelUList& indices() const noexcept;
|
||||
|
||||
//- Return the list of indices. Updated every sort
|
||||
//- Return the list of indices (updated every sort).
|
||||
// Same as addressing()
|
||||
inline labelList& indices();
|
||||
inline labelList& indices() noexcept;
|
||||
|
||||
//- Reverse the indices
|
||||
inline void reverse();
|
||||
@ -94,9 +94,13 @@ public:
|
||||
//- Functionally identical to sort with std::less\<T\>()
|
||||
inline void sort();
|
||||
|
||||
//- Reverse (stable) sort the list
|
||||
//- Reverse (stable) sort the list.
|
||||
//- Functionally identical to sort with std::greater\<T\>()
|
||||
inline void reverseSort();
|
||||
|
||||
//- Sort the list, only retaining unique entries
|
||||
inline void uniqueSort();
|
||||
|
||||
|
||||
// Member Operators
|
||||
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2019 OpenCFD Ltd.
|
||||
Copyright (C) 2019-2022 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, identity(values.size()))
|
||||
IndirectList<T>(values, labelList())
|
||||
{
|
||||
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, identity(values.size()))
|
||||
IndirectList<T>(values, labelList())
|
||||
{
|
||||
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
|
||||
inline const Foam::labelUList& Foam::SortList<T>::indices() const noexcept
|
||||
{
|
||||
return this->addressing();
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
inline Foam::labelList& Foam::SortList<T>::indices()
|
||||
inline Foam::labelList& Foam::SortList<T>::indices() noexcept
|
||||
{
|
||||
return this->addressing();
|
||||
}
|
||||
@ -74,10 +74,9 @@ inline void Foam::SortList<T>::reverse()
|
||||
template<class T>
|
||||
inline void Foam::SortList<T>::reset()
|
||||
{
|
||||
const label len = this->values().size();
|
||||
auto& addr = this->indices();
|
||||
|
||||
labelList& addr = this->indices();
|
||||
addr.resize(len);
|
||||
addr.resize_nocopy(this->values().size());
|
||||
ListOps::identity(addr);
|
||||
}
|
||||
|
||||
@ -86,14 +85,11 @@ template<class T>
|
||||
template<class Compare>
|
||||
inline void Foam::SortList<T>::sort(const Compare& comp)
|
||||
{
|
||||
UList<T>& vals = this->values();
|
||||
labelList& addr = this->indices();
|
||||
auto& vals = this->values();
|
||||
auto& addr = this->indices();
|
||||
|
||||
if (addr.size() != vals.size())
|
||||
{
|
||||
addr.resize(vals.size());
|
||||
ListOps::identity(addr);
|
||||
}
|
||||
addr.resize_nocopy(vals.size());
|
||||
ListOps::identity(addr);
|
||||
|
||||
std::stable_sort
|
||||
(
|
||||
@ -107,43 +103,26 @@ inline void Foam::SortList<T>::sort(const Compare& comp)
|
||||
template<class T>
|
||||
inline void Foam::SortList<T>::sort()
|
||||
{
|
||||
UList<T>& vals = this->values();
|
||||
labelList& addr = this->indices();
|
||||
Foam::sortedOrder(this->values(), this->indices());
|
||||
}
|
||||
|
||||
if (addr.size() != vals.size())
|
||||
{
|
||||
addr.resize(vals.size());
|
||||
ListOps::identity(addr);
|
||||
}
|
||||
|
||||
// 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>::uniqueSort()
|
||||
{
|
||||
Foam::uniqueOrder(this->values(), this->indices());
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
inline void Foam::SortList<T>::reverseSort()
|
||||
{
|
||||
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
|
||||
// Reverse sorted order for indices
|
||||
Foam::sortedOrder
|
||||
(
|
||||
addr.begin(),
|
||||
addr.end(),
|
||||
[&](label a, label b) -> bool { return vals[b] < vals[a]; }
|
||||
this->values(),
|
||||
this->indices(),
|
||||
typename UList<T>::greater(this->values())
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@ -37,8 +37,8 @@ SourceFiles
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef FixedList_H
|
||||
#define FixedList_H
|
||||
#ifndef Foam_FixedList_H
|
||||
#define Foam_FixedList_H
|
||||
|
||||
#include "bool.H"
|
||||
#include "label.H"
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
Copyright (C) 2017-2021 OpenCFD Ltd.
|
||||
Copyright (C) 2017-2022 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -40,6 +40,11 @@ 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;
|
||||
}
|
||||
@ -155,7 +160,7 @@ Foam::Istream& Foam::FixedList<T, N>::readList
|
||||
|
||||
if (is.format() == IOstream::BINARY && is_contiguous<T>::value)
|
||||
{
|
||||
// Binary and contiguous
|
||||
// Binary and contiguous. Length is non-zero
|
||||
|
||||
Detail::readContiguous<T>
|
||||
(
|
||||
@ -169,6 +174,7 @@ Foam::Istream& Foam::FixedList<T, N>::readList
|
||||
"FixedList<T, N>::readList(Istream&) : "
|
||||
"reading the binary block"
|
||||
);
|
||||
return is;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -183,23 +189,22 @@ 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(len);
|
||||
list.checkSize(tok.labelToken());
|
||||
}
|
||||
else if (!tok.isPunctuation())
|
||||
{
|
||||
FatalIOErrorInFunction(is)
|
||||
<< "incorrect first token, expected <label> "
|
||||
"or '(' or '{', found "
|
||||
<< "incorrect first token, expected <label> or '(' , found "
|
||||
<< tok.info() << nl
|
||||
<< exit(FatalIOError);
|
||||
}
|
||||
@ -228,9 +233,10 @@ Foam::Istream& Foam::FixedList<T, N>::readList
|
||||
else
|
||||
{
|
||||
// Uniform content (delimiter == token::BEGIN_BLOCK)
|
||||
// - compatibility for v1812 and earlier (see issue #1160)
|
||||
|
||||
T val;
|
||||
is >> val;
|
||||
T elem;
|
||||
is >> elem;
|
||||
|
||||
is.fatalCheck
|
||||
(
|
||||
@ -240,7 +246,7 @@ Foam::Istream& Foam::FixedList<T, N>::readList
|
||||
|
||||
for (unsigned i=0; i<N; ++i)
|
||||
{
|
||||
list[i] = val; // Copy the value
|
||||
list[i] = elem; // Copy the value
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
Copyright (C) 2017-2021 OpenCFD Ltd.
|
||||
Copyright (C) 2017-2022 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(this->size());
|
||||
indices_.resize_nocopy(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(this->size());
|
||||
indices_.resize_nocopy(this->size());
|
||||
ListOps::identity(indices_);
|
||||
|
||||
// Reverse partial sort of indices
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2021 OpenCFD Ltd.
|
||||
Copyright (C) 2021-2022 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -96,13 +96,10 @@ Foam::label Foam::functionObjects::properties::getTrigger() const
|
||||
|
||||
bool Foam::functionObjects::properties::setTrigger
|
||||
(
|
||||
const label triggeri,
|
||||
bool increaseOnly
|
||||
const label triggeri
|
||||
)
|
||||
{
|
||||
const label currTriggeri = getTrigger();
|
||||
|
||||
if (increaseOnly ? (triggeri > currTriggeri) : (triggeri != currTriggeri))
|
||||
if (triggeri != getTrigger())
|
||||
{
|
||||
set("triggerIndex", triggeri);
|
||||
return true;
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2021 OpenCFD Ltd.
|
||||
Copyright (C) 2021-2022 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -123,14 +123,9 @@ public:
|
||||
//- Get the current trigger index
|
||||
label getTrigger() const;
|
||||
|
||||
//- 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.
|
||||
//
|
||||
//- Set new trigger index.
|
||||
// \return True if the index changed
|
||||
bool setTrigger(const label triggeri, bool increaseOnly = true);
|
||||
bool setTrigger(const label triggeri);
|
||||
|
||||
//- Set dictionary from named object, return true if set
|
||||
bool getObjectDict
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2015 OpenFOAM Foundation
|
||||
Copyright (C) 2015-2021 OpenCFD Ltd.
|
||||
Copyright (C) 2015-2022 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -88,11 +88,10 @@ Foam::label Foam::functionObjects::stateFunctionObject::getTrigger() const
|
||||
|
||||
bool Foam::functionObjects::stateFunctionObject::setTrigger
|
||||
(
|
||||
const label triggeri,
|
||||
bool increaseOnly
|
||||
const label triggeri
|
||||
)
|
||||
{
|
||||
return stateDict().setTrigger(triggeri, increaseOnly);
|
||||
return stateDict().setTrigger(triggeri);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -124,14 +124,9 @@ public:
|
||||
//- Get the current trigger index
|
||||
label getTrigger() const;
|
||||
|
||||
//- 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.
|
||||
//
|
||||
//- Set new trigger index.
|
||||
// \return True if the index changed
|
||||
bool setTrigger(const label triggeri, bool increaseOnly = true);
|
||||
bool setTrigger(const label triggeri);
|
||||
|
||||
//- Set dictionary, return true if set
|
||||
bool getDict
|
||||
|
||||
@ -64,11 +64,10 @@ void Foam::functionObjects::timeControl::readControls()
|
||||
timeEnd_ = time_.userTimeToTime(timeEnd_);
|
||||
}
|
||||
|
||||
if (dict_.readIfPresent("triggerStart", triggerStart_))
|
||||
{
|
||||
dict_.readIfPresent("triggerEnd", triggerEnd_);
|
||||
controlMode_ = controlModeNames_.get("controlMode", dict_);
|
||||
}
|
||||
controlMode_ =
|
||||
controlModeNames_.getOrDefault("controlMode", dict_, controlMode::TIME);
|
||||
dict_.readIfPresent("triggerStart", triggerStart_);
|
||||
dict_.readIfPresent("triggerEnd", triggerEnd_);
|
||||
|
||||
deltaTCoeff_ = GREAT;
|
||||
if (dict_.readIfPresent("deltaTCoeff", deltaTCoeff_))
|
||||
@ -97,6 +96,18 @@ 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:
|
||||
@ -454,7 +465,7 @@ Foam::functionObjects::timeControl::timeControl
|
||||
controlMode_(controlMode::TIME),
|
||||
timeStart_(-VGREAT),
|
||||
timeEnd_(VGREAT),
|
||||
triggerStart_(labelMax),
|
||||
triggerStart_(labelMin),
|
||||
triggerEnd_(labelMax),
|
||||
nStepsToStartTimeChange_(labelMax),
|
||||
executeControl_(runTime, dict, "execute"),
|
||||
|
||||
@ -0,0 +1,238 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2015 OpenFOAM Foundation
|
||||
Copyright (C) 2015-2022 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "valueAverageBase.H"
|
||||
#include "Time.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
const Foam::Enum
|
||||
<
|
||||
Foam::functionObjects::valueAverageBase::windowType
|
||||
>
|
||||
Foam::functionObjects::valueAverageBase::windowTypeNames
|
||||
({
|
||||
{ windowType::NONE, "none" },
|
||||
{ windowType::APPROXIMATE, "approximate" },
|
||||
{ windowType::EXACT, "exact" }
|
||||
});
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * Protected Member Functions * * * * * * * * * //
|
||||
|
||||
void Foam::functionObjects::valueAverageBase::writeFileHeader(Ostream& os) const
|
||||
{
|
||||
writeHeader(os, "Value averages");
|
||||
writeCommented(os, "Time");
|
||||
forAll(fieldNames_, fieldi)
|
||||
{
|
||||
writeTabbed(os, fieldNames_[fieldi]);
|
||||
}
|
||||
os << endl;
|
||||
}
|
||||
|
||||
|
||||
void Foam::functionObjects::valueAverageBase::readState(dictionary& dict)
|
||||
{
|
||||
if (resetOnRestart_)
|
||||
{
|
||||
resetState(dict);
|
||||
return;
|
||||
}
|
||||
|
||||
forAll(fieldNames_, fieldi)
|
||||
{
|
||||
const word& fieldName = fieldNames_[fieldi];
|
||||
|
||||
if (dict.found(fieldName))
|
||||
{
|
||||
const dictionary& valueDict = dict.subDict(fieldName);
|
||||
valueDict.readEntry("totalTime", totalTime_[fieldi]);
|
||||
}
|
||||
else
|
||||
{
|
||||
dict.set(fieldName, dictionary());
|
||||
totalTime_[fieldi] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::functionObjects::valueAverageBase::writeState(dictionary& dict)
|
||||
{
|
||||
forAll(fieldNames_, fieldi)
|
||||
{
|
||||
const word& fieldName = fieldNames_[fieldi];
|
||||
|
||||
if (dict.found(fieldName))
|
||||
{
|
||||
dictionary& valueDict = dict.subDict(fieldName);
|
||||
valueDict.add("totalTime", totalTime_[fieldi], true);
|
||||
}
|
||||
else
|
||||
{
|
||||
dictionary valueDict;
|
||||
valueDict.add("totalTime", totalTime_[fieldi], true);
|
||||
dict.add(fieldName, valueDict);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::functionObjects::valueAverageBase::resetState(dictionary& dict)
|
||||
{
|
||||
forAll(fieldNames_, fieldi)
|
||||
{
|
||||
dict.set(fieldNames_[fieldi], dictionary());
|
||||
totalTime_[fieldi] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::functionObjects::valueAverageBase::valueAverageBase
|
||||
(
|
||||
const word& name,
|
||||
const objectRegistry& obr,
|
||||
const dictionary& dict,
|
||||
stateFunctionObject& state,
|
||||
const bool writeToFile
|
||||
)
|
||||
:
|
||||
writeFile(obr, name, state.type(), dict, writeToFile),
|
||||
log(true),
|
||||
resetOnRestart_(false),
|
||||
windowType_(windowType::NONE),
|
||||
state_(state),
|
||||
functionObjectName_("unknown-functionObject"),
|
||||
fieldNames_(),
|
||||
tolerance_(dict.getOrDefault<scalar>("tolerance", -1)),
|
||||
window_(-1),
|
||||
totalTime_()
|
||||
{
|
||||
read(dict);
|
||||
|
||||
writeFileHeader(file());
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * Public Member Functions * * * * * * * * * * * //
|
||||
|
||||
bool Foam::functionObjects::valueAverageBase::read(const dictionary& dict)
|
||||
{
|
||||
if (writeFile::read(dict))
|
||||
{
|
||||
// Make certain that the values are consistent with the defaults:
|
||||
resetOnRestart_ = false;
|
||||
|
||||
dict.readEntry("functionObject", functionObjectName_);
|
||||
dict.readEntry("fields", fieldNames_);
|
||||
if (dict.readIfPresent("window", window_))
|
||||
{
|
||||
window_ = state_.time().userTimeToTime(window_);
|
||||
|
||||
if (window_ > 0)
|
||||
{
|
||||
windowType_ = windowTypeNames.get("windowType", dict);
|
||||
}
|
||||
}
|
||||
|
||||
totalTime_.resize(fieldNames_.size(), Zero);
|
||||
|
||||
dict.readIfPresent("resetOnRestart", resetOnRestart_);
|
||||
|
||||
dict.readIfPresent("log", log);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool Foam::functionObjects::valueAverageBase::calculate(dictionary& dict)
|
||||
{
|
||||
scalar dt = state_.time().deltaTValue();
|
||||
|
||||
Log << indent << state_.type() << ": " << prefix_.c_str()
|
||||
<< " averages:" << nl;
|
||||
|
||||
file() << state_.time().timeName();
|
||||
|
||||
DynamicList<word> unprocessedFields(fieldNames_.size());
|
||||
|
||||
bool converged = true;
|
||||
|
||||
forAll(fieldNames_, fieldi)
|
||||
{
|
||||
totalTime_[fieldi] += dt;
|
||||
|
||||
const bool processed =
|
||||
(
|
||||
calc<scalar>(fieldi, converged, dict)
|
||||
|| calc<vector>(fieldi, converged, dict)
|
||||
|| calc<sphericalTensor>(fieldi, converged, dict)
|
||||
|| calc<symmTensor>(fieldi, converged, dict)
|
||||
|| calc<tensor>(fieldi, converged, dict)
|
||||
);
|
||||
|
||||
if (!processed)
|
||||
{
|
||||
unprocessedFields.append(fieldNames_[fieldi]);
|
||||
|
||||
file() << tab << "n/a";
|
||||
}
|
||||
}
|
||||
|
||||
file() << endl;
|
||||
|
||||
if (unprocessedFields.size())
|
||||
{
|
||||
WarningInFunction
|
||||
<< "From function object: " << functionObjectName_ << nl
|
||||
<< "Unprocessed fields:" << nl;
|
||||
|
||||
for (const word& fieldName : unprocessedFields)
|
||||
{
|
||||
Log << indent << " " << fieldName << nl;
|
||||
}
|
||||
|
||||
if (unprocessedFields.size() == fieldNames_.size())
|
||||
{
|
||||
converged = false;
|
||||
}
|
||||
}
|
||||
|
||||
Log << endl;
|
||||
|
||||
return converged;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,189 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2015 OpenFOAM Foundation
|
||||
Copyright (C) 2016-2022 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Class
|
||||
Foam::functionObjects::valueAverageBase
|
||||
|
||||
Description
|
||||
Base class that computes the ensemble- or time-based singular-value average
|
||||
values, with optional windowing, from the output of function objects
|
||||
that generate non-field type values, e.g. \c Cd of \c forceCoeffs or
|
||||
\c momentum_x in \c momentum function objects.
|
||||
|
||||
See also
|
||||
- Foam::functionObjects::writeFile
|
||||
|
||||
SourceFiles
|
||||
valueAverageBase.C
|
||||
valueAverageBaseTemplates.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef functionObjects_valueAverageBase_H
|
||||
#define functionObjects_valueAverageBase_H
|
||||
|
||||
#include "writeFile.H"
|
||||
#include "Enum.H"
|
||||
#include "stateFunctionObject.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
namespace functionObjects
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class valueAverageBase Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class valueAverageBase
|
||||
:
|
||||
public functionObjects::writeFile
|
||||
{
|
||||
public:
|
||||
|
||||
// Public Enumerations
|
||||
|
||||
//- Averaging window types
|
||||
enum class windowType : uint8_t
|
||||
{
|
||||
NONE, //!< "none"
|
||||
APPROXIMATE, //!< "approximate"
|
||||
EXACT //!< "exact"
|
||||
};
|
||||
|
||||
//- Names for windowType enumeration
|
||||
static const Enum<windowType> windowTypeNames;
|
||||
|
||||
private:
|
||||
|
||||
// Private Data
|
||||
|
||||
//- Log flag
|
||||
bool log;
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
// Protected Data
|
||||
|
||||
//- Reset the averaging process on restart
|
||||
bool resetOnRestart_;
|
||||
|
||||
//- Window type
|
||||
windowType windowType_;
|
||||
|
||||
//- Reference to the state functionObject
|
||||
stateFunctionObject& state_;
|
||||
|
||||
//- Name of function object to retrieve data from
|
||||
word functionObjectName_;
|
||||
|
||||
//- List of fields on which to operate
|
||||
wordList fieldNames_;
|
||||
|
||||
//- Optional tolerance to check for converged results
|
||||
scalar tolerance_;
|
||||
|
||||
//- Averaging window
|
||||
scalar window_;
|
||||
|
||||
//- Average time per field
|
||||
List<scalar> totalTime_;
|
||||
|
||||
|
||||
// Protected Member Functions
|
||||
|
||||
//- Templated function to calculate the average
|
||||
// Return true if processed
|
||||
template<class Type>
|
||||
bool calc(const label fieldi, bool& converged, dictionary& dict);
|
||||
|
||||
//- Output file header information
|
||||
virtual void writeFileHeader(Ostream& os) const;
|
||||
|
||||
//- Read state from dictionary
|
||||
virtual void readState(dictionary& dict);
|
||||
|
||||
//- Write state to dictionary for restarts
|
||||
virtual void writeState(dictionary& dict);
|
||||
|
||||
//- Reset state
|
||||
virtual void resetState(dictionary& dict);
|
||||
|
||||
|
||||
public:
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from Time and dictionary
|
||||
valueAverageBase
|
||||
(
|
||||
const word& name,
|
||||
const objectRegistry& obr,
|
||||
const dictionary& dict,
|
||||
stateFunctionObject& state,
|
||||
const bool writeToFile = true
|
||||
);
|
||||
|
||||
//- No copy construct
|
||||
valueAverageBase(const valueAverageBase&) = delete;
|
||||
|
||||
//- No copy assignment
|
||||
void operator=(const valueAverageBase&) = delete;
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~valueAverageBase() = default;
|
||||
|
||||
|
||||
// Public Member Functions
|
||||
|
||||
//- Read the field value average data
|
||||
virtual bool read(const dictionary& dict);
|
||||
|
||||
//- Calculate the averages
|
||||
virtual bool calculate(dictionary& dict);
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace functionObjects
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#ifdef NoRepository
|
||||
#include "valueAverageBaseTemplates.C"
|
||||
#endif
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2015 OpenFOAM Foundation
|
||||
Copyright (C) 2015-2016 OpenCFD Ltd.
|
||||
Copyright (C) 2015-2022 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -26,17 +26,14 @@ License
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "Time.H"
|
||||
#include "FIFOStack.H"
|
||||
|
||||
// * * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
void Foam::functionObjects::runTimeControls::averageCondition::calc
|
||||
bool Foam::functionObjects::valueAverageBase::calc
|
||||
(
|
||||
const label fieldi,
|
||||
bool& satisfied,
|
||||
bool& processed
|
||||
bool& converged,
|
||||
dictionary& dict
|
||||
)
|
||||
{
|
||||
const word& fieldName = fieldNames_[fieldi];
|
||||
@ -46,16 +43,16 @@ void Foam::functionObjects::runTimeControls::averageCondition::calc
|
||||
|
||||
if (pTraits<Type>::typeName != valueType)
|
||||
{
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
const scalar dt = obr_.time().deltaTValue();
|
||||
const scalar dt = state_.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_)
|
||||
@ -63,40 +60,35 @@ void Foam::functionObjects::runTimeControls::averageCondition::calc
|
||||
case windowType::NONE:
|
||||
{
|
||||
const scalar Dt = totalTime_[fieldi];
|
||||
const scalar alpha = (Dt - dt)/Dt;
|
||||
const scalar beta = dt/Dt;
|
||||
meanValue = alpha*meanValue + beta*currentValue;
|
||||
meanValue = (1 - beta)*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
|
||||
{
|
||||
// Ensure that averaging is performed over window time
|
||||
// before condition can be satisfied
|
||||
satisfied = false;
|
||||
converged = false;
|
||||
}
|
||||
|
||||
meanValue = alpha*meanValue + beta*currentValue;
|
||||
totalTime_[fieldi] += dt;
|
||||
meanValue = (1 - beta)*meanValue + beta*currentValue;
|
||||
|
||||
break;
|
||||
}
|
||||
case windowType::EXACT:
|
||||
{
|
||||
FIFOStack<scalar> windowTimes;
|
||||
FIFOStack<Type> windowValues;
|
||||
dictionary& dict = this->conditionDict().subDict(fieldName);
|
||||
dict.readIfPresent("windowTimes", windowTimes);
|
||||
dict.readIfPresent("windowValues", windowValues);
|
||||
dictionary& fieldDict = dict.subDict(fieldName);
|
||||
fieldDict.readIfPresent("windowTimes", windowTimes);
|
||||
fieldDict.readIfPresent("windowValues", windowValues);
|
||||
|
||||
// Increment time for all existing values
|
||||
for (scalar& dti : windowTimes)
|
||||
@ -151,8 +143,8 @@ void Foam::functionObjects::runTimeControls::averageCondition::calc
|
||||
meanValue /= windowTimes.first();
|
||||
|
||||
// Store the state information for the next step
|
||||
dict.set("windowTimes", windowTimes);
|
||||
dict.set("windowValues", windowValues);
|
||||
fieldDict.set("windowTimes", windowTimes);
|
||||
fieldDict.set("windowValues", windowValues);
|
||||
|
||||
break;
|
||||
}
|
||||
@ -160,19 +152,19 @@ void Foam::functionObjects::runTimeControls::averageCondition::calc
|
||||
|
||||
scalar delta = mag(meanValue - currentValue);
|
||||
|
||||
Log << " " << meanName << ": " << meanValue
|
||||
Log << indent << " " << meanName << ": " << meanValue
|
||||
<< ", delta: " << delta << nl;
|
||||
|
||||
// Note: Writing result to owner function object and not the local run-time
|
||||
// condition
|
||||
file() << tab << meanValue;
|
||||
|
||||
state_.setResult(meanName, meanValue);
|
||||
|
||||
if (delta > tolerance_)
|
||||
if ((tolerance_ > 0) && (delta > tolerance_))
|
||||
{
|
||||
satisfied = false;
|
||||
converged = false;
|
||||
}
|
||||
|
||||
processed = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@ -27,7 +27,6 @@ License
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "emptyPolyPatch.H"
|
||||
#include "commSchedule.H"
|
||||
#include "globalMeshData.H"
|
||||
#include "cyclicPolyPatch.H"
|
||||
|
||||
|
||||
@ -67,13 +67,10 @@ if (args.dryRun() || args.found("dry-run-write"))
|
||||
}
|
||||
else
|
||||
{
|
||||
Foam::Info << "Create mesh";
|
||||
if (args.readIfPresent("region", regionName))
|
||||
{
|
||||
Foam::Info << "Create mesh " << regionName;
|
||||
}
|
||||
else
|
||||
{
|
||||
Foam::Info << "Create mesh";
|
||||
Foam::Info << ' ' << regionName;
|
||||
}
|
||||
Foam::Info << " for time = " << runTime.timeName() << Foam::nl;
|
||||
|
||||
|
||||
@ -27,13 +27,10 @@ Provided Variables
|
||||
Foam::word regionName(Foam::polyMesh::defaultRegion);
|
||||
|
||||
{
|
||||
Foam::Info << "Create mesh";
|
||||
if (args.readIfPresent("region", regionName))
|
||||
{
|
||||
Foam::Info << "Create mesh " << regionName;
|
||||
}
|
||||
else
|
||||
{
|
||||
Foam::Info << "Create mesh";
|
||||
Foam::Info << ' ' << regionName;
|
||||
}
|
||||
Foam::Info << " for time = " << runTime.timeName() << Foam::nl;
|
||||
}
|
||||
|
||||
@ -26,13 +26,10 @@ Provided Variables
|
||||
Foam::word regionName(Foam::polyMesh::defaultRegion);
|
||||
|
||||
{
|
||||
Foam::Info << "Create polyMesh";
|
||||
if (args.readIfPresent("region", regionName))
|
||||
{
|
||||
Foam::Info << "Create polyMesh " << regionName;
|
||||
}
|
||||
else
|
||||
{
|
||||
Foam::Info << "Create polyMesh";
|
||||
Foam::Info << ' ' << regionName;
|
||||
}
|
||||
Foam::Info << " for time = " << runTime.timeName() << Foam::nl;
|
||||
}
|
||||
@ -51,4 +48,5 @@ Foam::polyMesh mesh
|
||||
|
||||
Foam::Info << Foam::endl;
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
68
src/OpenFOAM/include/createNamedPolyMeshes.H
Normal file
68
src/OpenFOAM/include/createNamedPolyMeshes.H
Normal file
@ -0,0 +1,68 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2022 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
|
||||
|
||||
Description
|
||||
Create single or multiple polyMesh regions based on the
|
||||
wordList 'regionNames'
|
||||
|
||||
Required Variables
|
||||
- runTime [Time]
|
||||
- regionNames [wordList]
|
||||
|
||||
Provided Variables
|
||||
- meshes [PtrList<polyMesh>]
|
||||
|
||||
See Also
|
||||
addAllRegionOptions.H
|
||||
getAllRegionOptions.H
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
Foam::PtrList<Foam::polyMesh> meshes(regionNames.size());
|
||||
|
||||
{
|
||||
forAll(regionNames, regioni)
|
||||
{
|
||||
const Foam::word& regionName = regionNames[regioni];
|
||||
|
||||
Foam::Info<< "Create polyMesh";
|
||||
if
|
||||
(
|
||||
regionNames.size() > 1
|
||||
|| regionName != Foam::polyMesh::defaultRegion
|
||||
)
|
||||
{
|
||||
Foam::Info<< ' ' << regionName;
|
||||
}
|
||||
Foam::Info<< " for time = " << runTime.timeName() << Foam::nl;
|
||||
|
||||
meshes.set
|
||||
(
|
||||
regioni,
|
||||
new Foam::polyMesh
|
||||
(
|
||||
Foam::IOobject
|
||||
(
|
||||
regionName,
|
||||
runTime.timeName(),
|
||||
runTime,
|
||||
Foam::IOobject::MUST_READ
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
Foam::Info<< Foam::endl;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -101,18 +101,16 @@ public:
|
||||
// Member Functions
|
||||
|
||||
//- Order in which comms is scheduled
|
||||
const labelList& schedule() const
|
||||
const labelList& schedule() const noexcept
|
||||
{
|
||||
return schedule_;
|
||||
}
|
||||
|
||||
//- Per processor the order in which communication has been scheduled
|
||||
const labelListList& procSchedule() const
|
||||
const labelListList& procSchedule() const noexcept
|
||||
{
|
||||
return procSchedule_;
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -157,7 +157,7 @@ void Foam::globalMeshData::calcSharedPoints() const
|
||||
// Allocate global numbers
|
||||
globalIndex masterNumbering(nMaster);
|
||||
|
||||
nGlobalPoints_ = masterNumbering.size();
|
||||
nGlobalPoints_ = masterNumbering.totalSize();
|
||||
|
||||
|
||||
// Push master number to slaves
|
||||
|
||||
@ -158,14 +158,14 @@ void Foam::PatchTools::gatherAndMerge
|
||||
}
|
||||
|
||||
|
||||
mergedFaces.setSize(globalFacesPtr().size());
|
||||
mergedPoints.setSize(globalPointsPtr().size());
|
||||
mergedFaces.setSize(globalFacesPtr().totalSize());
|
||||
mergedPoints.setSize(globalPointsPtr().totalSize());
|
||||
|
||||
// Insert master data first
|
||||
label pOffset = globalPointsPtr().offset(Pstream::masterNo());
|
||||
label pOffset = globalPointsPtr().localStart(Pstream::masterNo());
|
||||
SubList<point>(mergedPoints, myPoints.size(), pOffset) = myPoints;
|
||||
|
||||
label fOffset = globalFacesPtr().offset(Pstream::masterNo());
|
||||
label fOffset = globalFacesPtr().localStart(Pstream::masterNo());
|
||||
SubList<FaceType>(mergedFaces, myFaces.size(), fOffset) = myFaces;
|
||||
|
||||
|
||||
@ -177,11 +177,11 @@ void Foam::PatchTools::gatherAndMerge
|
||||
pointField slavePoints(fromSlave);
|
||||
List<FaceType> slaveFaces(fromSlave);
|
||||
|
||||
label pOffset = globalPointsPtr().offset(slave);
|
||||
label pOffset = globalPointsPtr().localStart(slave);
|
||||
SubList<point>(mergedPoints, slavePoints.size(), pOffset) =
|
||||
slavePoints;
|
||||
|
||||
label fOffset = globalFacesPtr().offset(slave);
|
||||
label fOffset = globalFacesPtr().localStart(slave);
|
||||
SubList<FaceType>(mergedFaces, slaveFaces.size(), fOffset) =
|
||||
slaveFaces;
|
||||
}
|
||||
|
||||
@ -39,8 +39,15 @@ void Foam::globalIndex::reportOverflowAndExit
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Overflow : sum of sizes exceeds labelMax ("
|
||||
<< labelMax << ") after index " << idx << " of "
|
||||
<< flatOutput(localSizes) << nl
|
||||
<< labelMax << ") after index " << idx;
|
||||
|
||||
if (!localSizes.empty())
|
||||
{
|
||||
FatalError << " of " << flatOutput(localSizes);
|
||||
}
|
||||
|
||||
FatalError
|
||||
<< nl
|
||||
<< "Please recompile with larger datatype for label." << nl
|
||||
<< exit(FatalError);
|
||||
}
|
||||
@ -89,7 +89,7 @@ class globalIndex
|
||||
static void reportOverflowAndExit
|
||||
(
|
||||
const label idx,
|
||||
const labelUList& localSizes
|
||||
const labelUList& localSizes = labelUList::null()
|
||||
);
|
||||
|
||||
public:
|
||||
@ -175,7 +175,7 @@ public:
|
||||
//- Global sum of localSizes. Same as totalSize()
|
||||
inline label size() const;
|
||||
|
||||
//- Global sum of localSizes. Same as size()
|
||||
//- Global sum of localSizes.
|
||||
inline label totalSize() const;
|
||||
|
||||
//- The local sizes
|
||||
@ -285,9 +285,6 @@ 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;
|
||||
|
||||
@ -328,6 +325,15 @@ 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
|
||||
@ -187,12 +187,6 @@ inline const Foam::labelUList Foam::globalIndex::localStarts() const
|
||||
}
|
||||
|
||||
|
||||
inline Foam::label Foam::globalIndex::offset(const label proci) const
|
||||
{
|
||||
return offsets_[proci];
|
||||
}
|
||||
|
||||
|
||||
inline Foam::label Foam::globalIndex::localStart(const label proci) const
|
||||
{
|
||||
return offsets_[proci];
|
||||
@ -337,7 +331,7 @@ inline Foam::label Foam::globalIndex::toLocal(const label i) const
|
||||
|
||||
inline Foam::label Foam::globalIndex::whichProcID(const label i) const
|
||||
{
|
||||
if (i < 0 || i >= size())
|
||||
if (i < 0 || i >= totalSize())
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Global " << i << " does not belong on any processor."
|
||||
@ -54,11 +54,7 @@ Foam::globalIndex::calcListOffsets
|
||||
|
||||
if (checkOverflow && start < values[i])
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Overflow : sum of sizes exceeds labelMax ("
|
||||
<< labelMax << ") after index " << i << nl
|
||||
<< "Please recompile with larger datatype for label." << nl
|
||||
<< exit(FatalError);
|
||||
reportOverflowAndExit(i);
|
||||
}
|
||||
}
|
||||
values[len] = start;
|
||||
@ -98,7 +94,7 @@ void Foam::globalIndex::gather
|
||||
|
||||
if (Pstream::myProcNo(comm) == procIDs[0])
|
||||
{
|
||||
allFld.resize_nocopy(off.last());
|
||||
allFld.resize_nocopy(off.last()); // == totalSize()
|
||||
|
||||
// Assign my local data - respect offset information
|
||||
// so that we can request 0 entries to be copied.
|
||||
@ -112,7 +108,11 @@ void Foam::globalIndex::gather
|
||||
{
|
||||
SubList<Type> procSlot(allFld, off[i+1]-off[i], off[i]);
|
||||
|
||||
if (is_contiguous<Type>::value)
|
||||
if (procSlot.empty())
|
||||
{
|
||||
// Nothing to do
|
||||
}
|
||||
else if (is_contiguous<Type>::value)
|
||||
{
|
||||
IPstream::read
|
||||
(
|
||||
@ -140,7 +140,11 @@ void Foam::globalIndex::gather
|
||||
}
|
||||
else
|
||||
{
|
||||
if (is_contiguous<Type>::value)
|
||||
if (fld.empty())
|
||||
{
|
||||
// Nothing to do
|
||||
}
|
||||
else if (is_contiguous<Type>::value)
|
||||
{
|
||||
OPstream::write
|
||||
(
|
||||
@ -198,7 +202,7 @@ void Foam::globalIndex::gather
|
||||
|
||||
if (Pstream::myProcNo(comm) == procIDs[0])
|
||||
{
|
||||
allFld.resize_nocopy(off.last());
|
||||
allFld.resize_nocopy(off.last()); // == totalSize()
|
||||
|
||||
// Assign my local data - respect offset information
|
||||
// so that we can request 0 entries to be copied
|
||||
@ -214,28 +218,42 @@ void Foam::globalIndex::gather
|
||||
{
|
||||
SubList<Type> procSlot(allFld, off[i+1]-off[i], off[i]);
|
||||
|
||||
IPstream fromProc
|
||||
(
|
||||
commsType,
|
||||
procIDs[i],
|
||||
0,
|
||||
tag,
|
||||
comm
|
||||
);
|
||||
fromProc >> procSlot;
|
||||
if (procSlot.empty())
|
||||
{
|
||||
// Nothing to do
|
||||
}
|
||||
else
|
||||
{
|
||||
IPstream fromProc
|
||||
(
|
||||
commsType,
|
||||
procIDs[i],
|
||||
0,
|
||||
tag,
|
||||
comm
|
||||
);
|
||||
fromProc >> procSlot;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
OPstream toMaster
|
||||
(
|
||||
commsType,
|
||||
procIDs[0],
|
||||
0,
|
||||
tag,
|
||||
comm
|
||||
);
|
||||
toMaster << fld;
|
||||
if (fld.empty())
|
||||
{
|
||||
// Nothing to do
|
||||
}
|
||||
else
|
||||
{
|
||||
OPstream toMaster
|
||||
(
|
||||
commsType,
|
||||
procIDs[0],
|
||||
0,
|
||||
tag,
|
||||
comm
|
||||
);
|
||||
toMaster << fld;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -441,7 +459,7 @@ void Foam::globalIndex::mpiGather
|
||||
nSendBytes = 0;
|
||||
}
|
||||
|
||||
allData.resize_nocopy(globalAddr.size());
|
||||
allData.resize_nocopy(globalAddr.totalSize());
|
||||
|
||||
recvSizes.resize(nproc);
|
||||
recvOffsets.resize(nproc+1);
|
||||
@ -451,7 +469,7 @@ void Foam::globalIndex::mpiGather
|
||||
recvSizes[proci] = globalAddr.localSize(proci) * sizeof(Type);
|
||||
recvOffsets[proci] = globalAddr.localStart(proci) * sizeof(Type);
|
||||
}
|
||||
recvOffsets[nproc] = globalAddr.size() * sizeof(Type);
|
||||
recvOffsets[nproc] = globalAddr.totalSize() * sizeof(Type);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -689,6 +707,10 @@ 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])
|
||||
@ -59,11 +59,11 @@ Description
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef contiguous_H
|
||||
#define contiguous_H
|
||||
#ifndef Foam_contiguous_H
|
||||
#define Foam_contiguous_H
|
||||
|
||||
#include "scalar.H"
|
||||
#include "label.H"
|
||||
#include "scalarFwd.H"
|
||||
#include "labelFwd.H"
|
||||
#include <type_traits>
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2017 OpenFOAM Foundation
|
||||
Copyright (C) 2016-2021 OpenCFD Ltd.
|
||||
Copyright (C) 2016-2022 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -427,21 +427,50 @@ Foam::fileName Foam::fileName::relative
|
||||
const bool caseTag
|
||||
) const
|
||||
{
|
||||
const auto top = parent.size();
|
||||
const auto top = parent.length();
|
||||
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.size() > (top+1)) && f[top] == '/'
|
||||
top && (f.length() > (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
|
||||
@ -449,8 +478,32 @@ Foam::fileName Foam::fileName::relative
|
||||
return f.substr(top+1);
|
||||
}
|
||||
}
|
||||
else if (caseTag && f.size() && !f.isAbsolute())
|
||||
else if (caseTag && f.length() && !f.isAbsolute())
|
||||
{
|
||||
const auto trailing = f.find('/');
|
||||
|
||||
if (npos != trailing)
|
||||
{
|
||||
switch (trailing)
|
||||
{
|
||||
case 6: // "system"
|
||||
{
|
||||
if (!compare(0, 6, "system"))
|
||||
{
|
||||
return "<system>"/f.substr(trailing+1);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 8: // "constant"
|
||||
{
|
||||
if (!compare(0, 8, "constant"))
|
||||
{
|
||||
return "<constant>"/f.substr(trailing+1);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return "<case>"/f;
|
||||
}
|
||||
|
||||
|
||||
@ -41,8 +41,8 @@ SourceFiles
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef stringListOps_H
|
||||
#define stringListOps_H
|
||||
#ifndef Foam_stringListOps_H
|
||||
#define Foam_stringListOps_H
|
||||
|
||||
#include "labelList.H"
|
||||
#include "stringList.H"
|
||||
@ -358,6 +358,18 @@ struct foundOp
|
||||
};
|
||||
|
||||
|
||||
//- Return ids for items with matching names.
|
||||
// The filter predicate is a combination of allow and deny lists
|
||||
//
|
||||
// \return List indices for matches
|
||||
template<class StringListType, class AccessOp = noOp>
|
||||
labelList findMatching
|
||||
(
|
||||
const StringListType& input,
|
||||
const wordRes::filter& pred,
|
||||
AccessOp aop = noOp()
|
||||
);
|
||||
|
||||
//- Return ids for items with matching names.
|
||||
// Uses a combination of allow and deny lists
|
||||
//
|
||||
|
||||
@ -135,21 +135,18 @@ template<class StringListType, class AccessOp>
|
||||
Foam::labelList Foam::stringListOps::findMatching
|
||||
(
|
||||
const StringListType& input,
|
||||
const wordRes& allow,
|
||||
const wordRes& deny,
|
||||
const wordRes::filter& pred,
|
||||
AccessOp aop
|
||||
)
|
||||
{
|
||||
const label len = input.size();
|
||||
|
||||
if (allow.empty() && deny.empty())
|
||||
if (pred.empty())
|
||||
{
|
||||
// Accept all
|
||||
return identity(len);
|
||||
}
|
||||
|
||||
// Use combined accept/reject filter
|
||||
const wordRes::filter pred(allow, deny);
|
||||
|
||||
labelList indices(len);
|
||||
|
||||
label count = 0;
|
||||
@ -169,4 +166,26 @@ Foam::labelList Foam::stringListOps::findMatching
|
||||
}
|
||||
|
||||
|
||||
template<class StringListType, class AccessOp>
|
||||
Foam::labelList Foam::stringListOps::findMatching
|
||||
(
|
||||
const StringListType& input,
|
||||
const wordRes& allow,
|
||||
const wordRes& deny,
|
||||
AccessOp aop
|
||||
)
|
||||
{
|
||||
if (allow.empty() && deny.empty())
|
||||
{
|
||||
// Accept all
|
||||
return identity(input.size());
|
||||
}
|
||||
|
||||
// Use combined accept/reject filter
|
||||
const wordRes::filter pred(allow, deny);
|
||||
|
||||
return stringListOps::findMatching(input, pred, aop);
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -2626,7 +2626,7 @@ void Foam::polyMeshAdder::compactPoints
|
||||
|
||||
// Compact out unused points
|
||||
localPoints.setSize(meshes.size());
|
||||
labelList globalToCompact(globalPoints.size(), -1);
|
||||
labelList globalToCompact(globalPoints.totalSize(), -1);
|
||||
label nGlobal = 0;
|
||||
forAll(meshes, meshi)
|
||||
{
|
||||
|
||||
@ -135,7 +135,7 @@ void Foam::vtk::writeListParallel
|
||||
if (Pstream::master())
|
||||
{
|
||||
// Write master data - with value offset
|
||||
const label offsetId = procOffset.offset(0);
|
||||
const label offsetId = procOffset.localStart(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.offset(proci);
|
||||
const label offsetId = procOffset.localStart(proci);
|
||||
for (const label val : recvData)
|
||||
{
|
||||
vtk::write(fmt, val + offsetId);
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2010-2018 Bernhard Gschaider
|
||||
Copyright (C) 2019-2021 OpenCFD Ltd.
|
||||
Copyright (C) 2019-2022 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -166,7 +166,7 @@ protected:
|
||||
template<class Type>
|
||||
static inline word defaultBoundaryType
|
||||
(
|
||||
const GeometricField<Type, fvPatchField, volMesh>&
|
||||
const VolumeField<Type>&
|
||||
)
|
||||
{
|
||||
return "zeroGradient";
|
||||
@ -180,7 +180,7 @@ protected:
|
||||
template<class Type>
|
||||
static inline void correctField
|
||||
(
|
||||
GeometricField<Type, fvPatchField, volMesh>& fld
|
||||
VolumeField<Type>& fld
|
||||
)
|
||||
{
|
||||
fld.correctBoundaryConditions();
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2010-2018 Bernhard Gschaider
|
||||
Copyright (C) 2019-2021 OpenCFD Ltd.
|
||||
Copyright (C) 2019-2022 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -231,18 +231,14 @@ 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<pfieldType>(name)
|
||||
? this->foundField<PointField<Type>>(name)
|
||||
:
|
||||
(
|
||||
this->foundField<vfieldType>(name)
|
||||
|| this->foundField<sfieldType>(name)
|
||||
this->foundField<VolumeField<Type>>(name)
|
||||
|| this->foundField<SurfaceField<Type>>(name)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2019-2021 OpenCFD Ltd.
|
||||
Copyright (C) 2019-2022 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -118,17 +118,11 @@ 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<vfieldType> vfield;
|
||||
tmp<sfieldType> sfield;
|
||||
tmp<pfieldType> pfield;
|
||||
tmp<VolumeField<Type>> vfield;
|
||||
tmp<SurfaceField<Type>> sfield;
|
||||
tmp<PointField<Type>> pfield;
|
||||
|
||||
for (int checki = 0; !found && checki < 2; ++checki)
|
||||
{
|
||||
@ -144,17 +138,17 @@ Foam::expressions::patchExpr::parseDriver::getField(const word& name)
|
||||
|
||||
if (!found)
|
||||
{
|
||||
vfield.cref(dynamic_cast<const vfieldType*>(ioptr));
|
||||
vfield.cref(dynamic_cast<const VolumeField<Type>*>(ioptr));
|
||||
found = vfield.valid();
|
||||
}
|
||||
if (!found)
|
||||
{
|
||||
sfield.cref(dynamic_cast<const sfieldType*>(ioptr));
|
||||
sfield.cref(dynamic_cast<const SurfaceField<Type>*>(ioptr));
|
||||
found = sfield.valid();
|
||||
}
|
||||
if (!found)
|
||||
{
|
||||
pfield.cref(dynamic_cast<const pfieldType*>(ioptr));
|
||||
pfield.cref(dynamic_cast<const PointField<Type>*>(ioptr));
|
||||
found = pfield.valid();
|
||||
}
|
||||
}
|
||||
@ -165,17 +159,17 @@ Foam::expressions::patchExpr::parseDriver::getField(const word& name)
|
||||
{
|
||||
const word fldType = this->getTypeOfField(name);
|
||||
|
||||
if (fldType == vfieldType::typeName)
|
||||
if (fldType == VolumeField<Type>::typeName)
|
||||
{
|
||||
vfield = this->readAndRegister<vfieldType>(name, mesh());
|
||||
vfield = this->readAndRegister<VolumeField<Type>>(name, mesh());
|
||||
}
|
||||
else if (fldType == sfieldType::typeName)
|
||||
else if (fldType == SurfaceField<Type>::typeName)
|
||||
{
|
||||
sfield = this->readAndRegister<sfieldType>(name, mesh());
|
||||
sfield = this->readAndRegister<SurfaceField<Type>>(name, mesh());
|
||||
}
|
||||
else if (fldType == pfieldType::typeName)
|
||||
else if (fldType == PointField<Type>::typeName)
|
||||
{
|
||||
pfield = this->readAndRegister<pfieldType>
|
||||
pfield = this->readAndRegister<PointField<Type>>
|
||||
(
|
||||
name,
|
||||
pointMesh::New(mesh())
|
||||
@ -209,16 +203,16 @@ Foam::expressions::patchExpr::parseDriver::getField(const word& name)
|
||||
<< pTraits<Type>::typeName << nl << nl;
|
||||
|
||||
FatalError
|
||||
<< vfieldType::typeName << " Fields: "
|
||||
<< flatOutput(obr.sortedNames<vfieldType>()) << nl;
|
||||
<< VolumeField<Type>::typeName << " Fields: "
|
||||
<< flatOutput(obr.sortedNames<VolumeField<Type>>()) << nl;
|
||||
|
||||
FatalError
|
||||
<< sfieldType::typeName << " Fields: "
|
||||
<< flatOutput(obr.sortedNames<sfieldType>()) << nl;
|
||||
<< SurfaceField<Type>::typeName << " Fields: "
|
||||
<< flatOutput(obr.sortedNames<SurfaceField<Type>>()) << nl;
|
||||
|
||||
FatalError
|
||||
<< pfieldType::typeName << " Fields: "
|
||||
<< flatOutput(obr.sortedNames<pfieldType>()) << nl;
|
||||
<< PointField<Type>::typeName << " Fields: "
|
||||
<< flatOutput(obr.sortedNames<PointField<Type>>()) << nl;
|
||||
|
||||
FatalError
|
||||
<< exit(FatalError);
|
||||
@ -245,15 +239,10 @@ 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<vfieldType> vfield;
|
||||
tmp<pfieldType> pfield;
|
||||
tmp<VolumeField<Type>> vfield;
|
||||
tmp<PointField<Type>> pfield;
|
||||
|
||||
for (int checki = 0; !found && checki < 2; ++checki)
|
||||
{
|
||||
@ -269,12 +258,12 @@ Foam::expressions::patchExpr::parseDriver::patchInternalField
|
||||
|
||||
if (!found)
|
||||
{
|
||||
vfield.cref(dynamic_cast<const vfieldType*>(ioptr));
|
||||
vfield.cref(dynamic_cast<const VolumeField<Type>*>(ioptr));
|
||||
found = vfield.valid();
|
||||
}
|
||||
if (!found)
|
||||
{
|
||||
pfield.cref(dynamic_cast<const pfieldType*>(ioptr));
|
||||
pfield.cref(dynamic_cast<const PointField<Type>*>(ioptr));
|
||||
found = pfield.valid();
|
||||
}
|
||||
}
|
||||
@ -285,13 +274,13 @@ Foam::expressions::patchExpr::parseDriver::patchInternalField
|
||||
{
|
||||
const word fldType = this->getTypeOfField(name);
|
||||
|
||||
if (fldType == vfieldType::typeName)
|
||||
if (fldType == VolumeField<Type>::typeName)
|
||||
{
|
||||
vfield = this->readAndRegister<vfieldType>(name, mesh());
|
||||
vfield = this->readAndRegister<VolumeField<Type>>(name, mesh());
|
||||
}
|
||||
else if (fldType == pfieldType::typeName)
|
||||
else if (fldType == PointField<Type>::typeName)
|
||||
{
|
||||
pfield = this->readAndRegister<pfieldType>
|
||||
pfield = this->readAndRegister<PointField<Type>>
|
||||
(
|
||||
name,
|
||||
pointMesh::New(mesh())
|
||||
@ -315,12 +304,12 @@ Foam::expressions::patchExpr::parseDriver::patchInternalField
|
||||
<< pTraits<Type>::typeName << nl << nl;
|
||||
|
||||
FatalError
|
||||
<< vfieldType::typeName << " Fields: "
|
||||
<< flatOutput(obr.sortedNames<vfieldType>()) << nl;
|
||||
<< VolumeField<Type>::typeName << " Fields: "
|
||||
<< flatOutput(obr.sortedNames<VolumeField<Type>>()) << nl;
|
||||
|
||||
FatalError
|
||||
<< pfieldType::typeName << " Fields: "
|
||||
<< flatOutput(obr.sortedNames<pfieldType>()) << nl;
|
||||
<< PointField<Type>::typeName << " Fields: "
|
||||
<< flatOutput(obr.sortedNames<PointField<Type>>()) << nl;
|
||||
|
||||
FatalError
|
||||
<< exit(FatalError);
|
||||
@ -347,13 +336,9 @@ 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<vfieldType> vfield;
|
||||
tmp<VolumeField<Type>> vfield;
|
||||
|
||||
for (int checki = 0; !found && checki < 2; ++checki)
|
||||
{
|
||||
@ -369,7 +354,7 @@ Foam::expressions::patchExpr::parseDriver::patchNeighbourField
|
||||
|
||||
if (!found)
|
||||
{
|
||||
vfield.cref(dynamic_cast<const vfieldType*>(ioptr));
|
||||
vfield.cref(dynamic_cast<const VolumeField<Type>*>(ioptr));
|
||||
found = vfield.valid();
|
||||
}
|
||||
}
|
||||
@ -380,9 +365,9 @@ Foam::expressions::patchExpr::parseDriver::patchNeighbourField
|
||||
{
|
||||
const word fldType = this->getTypeOfField(name);
|
||||
|
||||
if (fldType == vfieldType::typeName)
|
||||
if (fldType == VolumeField<Type>::typeName)
|
||||
{
|
||||
vfield = this->readAndRegister<vfieldType>(name, mesh());
|
||||
vfield = this->readAndRegister<VolumeField<Type>>(name, mesh());
|
||||
}
|
||||
}
|
||||
|
||||
@ -398,8 +383,8 @@ Foam::expressions::patchExpr::parseDriver::patchNeighbourField
|
||||
<< pTraits<Type>::typeName << nl << nl;
|
||||
|
||||
FatalError
|
||||
<< vfieldType::typeName << " Fields: "
|
||||
<< flatOutput(obr.sortedNames<vfieldType>()) << nl;
|
||||
<< VolumeField<Type>::typeName << " Fields: "
|
||||
<< flatOutput(obr.sortedNames<VolumeField<Type>>()) << nl;
|
||||
|
||||
FatalError
|
||||
<< exit(FatalError);
|
||||
@ -426,13 +411,9 @@ 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<vfieldType> vfield;
|
||||
tmp<VolumeField<Type>> vfield;
|
||||
|
||||
for (int checki = 0; !found && checki < 2; ++checki)
|
||||
{
|
||||
@ -448,7 +429,7 @@ Foam::expressions::patchExpr::parseDriver::patchNormalField
|
||||
|
||||
if (!found)
|
||||
{
|
||||
vfield.cref(dynamic_cast<const vfieldType*>(ioptr));
|
||||
vfield.cref(dynamic_cast<const VolumeField<Type>*>(ioptr));
|
||||
found = vfield.valid();
|
||||
}
|
||||
}
|
||||
@ -459,9 +440,9 @@ Foam::expressions::patchExpr::parseDriver::patchNormalField
|
||||
{
|
||||
const word fldType = this->getTypeOfField(name);
|
||||
|
||||
if (fldType == vfieldType::typeName)
|
||||
if (fldType == VolumeField<Type>::typeName)
|
||||
{
|
||||
vfield = this->readAndRegister<vfieldType>(name, mesh());
|
||||
vfield = this->readAndRegister<VolumeField<Type>>(name, mesh());
|
||||
}
|
||||
}
|
||||
|
||||
@ -477,8 +458,8 @@ Foam::expressions::patchExpr::parseDriver::patchNormalField
|
||||
<< pTraits<Type>::typeName << nl << nl;
|
||||
|
||||
FatalError
|
||||
<< vfieldType::typeName << " Fields: "
|
||||
<< flatOutput(obr.sortedNames<vfieldType>()) << nl;
|
||||
<< VolumeField<Type>::typeName << " Fields: "
|
||||
<< flatOutput(obr.sortedNames<VolumeField<Type>>()) << nl;
|
||||
|
||||
FatalError
|
||||
<< exit(FatalError);
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2019-2021 OpenCFD Ltd.
|
||||
Copyright (C) 2019-2022 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -325,60 +325,48 @@ public:
|
||||
|
||||
//- Set result (vol field)
|
||||
template<class Type>
|
||||
void setResult
|
||||
(
|
||||
GeometricField<Type, fvPatchField, volMesh>* ptr,
|
||||
bool logical = false
|
||||
);
|
||||
void setResult(VolumeField<Type>* ptr, bool logical = false);
|
||||
|
||||
//- Set result (surface field)
|
||||
template<class Type>
|
||||
void setResult
|
||||
(
|
||||
GeometricField<Type, fvsPatchField, surfaceMesh>* ptr,
|
||||
bool logical = false
|
||||
);
|
||||
void setResult(SurfaceField<Type>* ptr, bool logical = false);
|
||||
|
||||
//- Set result (point field)
|
||||
template<class Type>
|
||||
void setResult
|
||||
(
|
||||
GeometricField<Type, pointPatchField, pointMesh>* ptr,
|
||||
bool logical = false
|
||||
);
|
||||
void setResult(PointField<Type>* ptr, bool logical = false);
|
||||
|
||||
|
||||
// New Fields
|
||||
|
||||
//- Return a new volume field with the mesh size
|
||||
template<class Type>
|
||||
tmp<GeometricField<Type, fvPatchField, volMesh>>
|
||||
tmp<VolumeField<Type>>
|
||||
newVolField(const Type& val = pTraits<Type>::zero) const;
|
||||
|
||||
//- Return a new surface field with the mesh nInternalFaces size
|
||||
template<class Type>
|
||||
tmp<GeometricField<Type, fvsPatchField, surfaceMesh>>
|
||||
tmp<SurfaceField<Type>>
|
||||
newSurfaceField(const Type& val = pTraits<Type>::zero) const;
|
||||
|
||||
//- Return a new point field with the mesh nPoints size
|
||||
template<class Type>
|
||||
tmp<GeometricField<Type, pointPatchField, pointMesh>>
|
||||
tmp<PointField<Type>>
|
||||
newPointField(const Type& val = pTraits<Type>::zero) const;
|
||||
|
||||
|
||||
//- Retrieve field (vol field)
|
||||
template<class Type>
|
||||
tmp<GeometricField<Type, fvPatchField, volMesh>>
|
||||
tmp<VolumeField<Type>>
|
||||
getVolField(const word& fldName, bool getOldTime=false);
|
||||
|
||||
//- Retrieve field (surface field)
|
||||
template<class Type>
|
||||
tmp<GeometricField<Type, fvsPatchField, surfaceMesh>>
|
||||
tmp<SurfaceField<Type>>
|
||||
getSurfaceField(const word& fldName, bool getOldTime=false);
|
||||
|
||||
//- Retrieve field (surface field)
|
||||
template<class Type>
|
||||
tmp<GeometricField<Type, pointPatchField, pointMesh>>
|
||||
tmp<PointField<Type>>
|
||||
getPointField(const word& fldName, bool getOldTime=false);
|
||||
|
||||
|
||||
@ -386,57 +374,39 @@ public:
|
||||
|
||||
//- Interpolate cell to face values
|
||||
template<class Type>
|
||||
tmp<GeometricField<Type, fvsPatchField, surfaceMesh>>
|
||||
cellToFace
|
||||
(
|
||||
const GeometricField<Type,fvPatchField,volMesh>& field
|
||||
) const;
|
||||
tmp<SurfaceField<Type>>
|
||||
cellToFace(const VolumeField<Type>& field) const;
|
||||
|
||||
//- Interpolate cell to point values
|
||||
template<class Type>
|
||||
tmp<GeometricField<Type, pointPatchField, pointMesh>>
|
||||
cellToPoint
|
||||
(
|
||||
const GeometricField<Type, fvPatchField, volMesh>& field
|
||||
) const;
|
||||
tmp<PointField<Type>>
|
||||
cellToPoint(const VolumeField<Type>& field) const;
|
||||
|
||||
//- Interpolate point to cell values
|
||||
template<class Type>
|
||||
tmp<GeometricField<Type, fvPatchField, volMesh>>
|
||||
pointToCell
|
||||
(
|
||||
const GeometricField<Type, pointPatchField, pointMesh>& field
|
||||
) const;
|
||||
tmp<VolumeField<Type>>
|
||||
pointToCell(const PointField<Type>& field) const;
|
||||
|
||||
|
||||
// Custom Field Functions
|
||||
|
||||
//- The volume-weighted average of a field
|
||||
template<class Type>
|
||||
Type volAverage
|
||||
(
|
||||
GeometricField<Type, fvPatchField, volMesh>& fld
|
||||
) const
|
||||
Type volAverage(VolumeField<Type>& fld) const
|
||||
{
|
||||
return weightedAverage(fld.mesh().V(), fld.primitiveField());
|
||||
}
|
||||
|
||||
//- The volume-weighted sum of a field
|
||||
template<class Type>
|
||||
Type volSum
|
||||
(
|
||||
GeometricField<Type, fvPatchField, volMesh>& fld
|
||||
) const
|
||||
Type volSum(VolumeField<Type>& fld) const
|
||||
{
|
||||
return weightedSum(fld.mesh().V(), fld.primitiveField());
|
||||
}
|
||||
|
||||
//- The area-weighted average of a field
|
||||
template<class Type>
|
||||
Type areaAverage
|
||||
(
|
||||
GeometricField<Type, fvsPatchField, surfaceMesh>& fld
|
||||
) const
|
||||
Type areaAverage(SurfaceField<Type>& fld) const
|
||||
{
|
||||
return weightedAverage
|
||||
(
|
||||
@ -447,10 +417,7 @@ public:
|
||||
|
||||
//- The area-weighted sum of a field
|
||||
template<class Type>
|
||||
Type areaSum
|
||||
(
|
||||
GeometricField<Type, fvsPatchField, surfaceMesh>& fld
|
||||
) const
|
||||
Type areaSum(SurfaceField<Type>& fld) const
|
||||
{
|
||||
return weightedSum
|
||||
(
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2019-2021 OpenCFD Ltd.
|
||||
Copyright (C) 2019-2022 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -62,16 +62,14 @@ void Foam::expressions::volumeExpr::parseDriver::setInternalFieldResult
|
||||
template<class Type>
|
||||
void Foam::expressions::volumeExpr::parseDriver::setResult
|
||||
(
|
||||
GeometricField<Type, fvPatchField, volMesh>* ptr,
|
||||
VolumeField<Type>* ptr,
|
||||
bool logical
|
||||
)
|
||||
{
|
||||
typedef GeometricField<Type, fvPatchField, volMesh> fieldType;
|
||||
|
||||
resultField_.reset(nullptr);
|
||||
|
||||
// Characteristics
|
||||
resultType_ = pTraits<fieldType>::typeName;
|
||||
resultType_ = VolumeField<Type>::typeName;
|
||||
isLogical_ = logical;
|
||||
fieldGeoType_ = VOLUME_DATA;
|
||||
|
||||
@ -91,16 +89,14 @@ void Foam::expressions::volumeExpr::parseDriver::setResult
|
||||
template<class Type>
|
||||
void Foam::expressions::volumeExpr::parseDriver::setResult
|
||||
(
|
||||
GeometricField<Type, fvsPatchField, surfaceMesh>* ptr,
|
||||
SurfaceField<Type>* ptr,
|
||||
bool logical
|
||||
)
|
||||
{
|
||||
typedef GeometricField<Type, fvsPatchField, surfaceMesh> fieldType;
|
||||
|
||||
resultField_.reset(nullptr);
|
||||
|
||||
// Characteristics
|
||||
resultType_ = pTraits<fieldType>::typeName;
|
||||
resultType_ = SurfaceField<Type>::typeName;
|
||||
isLogical_ = logical;
|
||||
fieldGeoType_ = FACE_DATA;
|
||||
|
||||
@ -120,16 +116,14 @@ void Foam::expressions::volumeExpr::parseDriver::setResult
|
||||
template<class Type>
|
||||
void Foam::expressions::volumeExpr::parseDriver::setResult
|
||||
(
|
||||
GeometricField<Type, pointPatchField, pointMesh>* ptr,
|
||||
PointField<Type>* ptr,
|
||||
bool logical
|
||||
)
|
||||
{
|
||||
typedef GeometricField<Type, pointPatchField, pointMesh> fieldType;
|
||||
|
||||
resultField_.reset(nullptr);
|
||||
|
||||
// Characteristics
|
||||
resultType_ = pTraits<fieldType>::typeName;
|
||||
resultType_ = PointField<Type>::typeName;
|
||||
isLogical_ = logical;
|
||||
fieldGeoType_ = POINT_DATA;
|
||||
|
||||
@ -182,16 +176,14 @@ Foam::expressions::volumeExpr::parseDriver::isResultType
|
||||
|
||||
|
||||
template<class Type>
|
||||
Foam::tmp<Foam::GeometricField<Type, Foam::fvPatchField, Foam::volMesh>>
|
||||
Foam::tmp<Foam::VolumeField<Type>>
|
||||
Foam::expressions::volumeExpr::parseDriver::getVolField
|
||||
(
|
||||
const word& fldName,
|
||||
bool getOldTime
|
||||
)
|
||||
{
|
||||
typedef GeometricField<Type, fvPatchField, volMesh> fieldType;
|
||||
|
||||
return this->getOrReadField<fieldType>
|
||||
return this->getOrReadField<VolumeField<Type>>
|
||||
(
|
||||
fldName,
|
||||
true, // mandatory
|
||||
@ -201,16 +193,14 @@ Foam::expressions::volumeExpr::parseDriver::getVolField
|
||||
|
||||
|
||||
template<class Type>
|
||||
Foam::tmp<Foam::GeometricField<Type, Foam::fvsPatchField, Foam::surfaceMesh>>
|
||||
Foam::tmp<Foam::SurfaceField<Type>>
|
||||
Foam::expressions::volumeExpr::parseDriver::getSurfaceField
|
||||
(
|
||||
const word& fldName,
|
||||
bool getOldTime
|
||||
)
|
||||
{
|
||||
typedef GeometricField<Type, fvsPatchField, surfaceMesh> fieldType;
|
||||
|
||||
return this->getOrReadField<fieldType>
|
||||
return this->getOrReadField<SurfaceField<Type>>
|
||||
(
|
||||
fldName,
|
||||
true, // mandatory
|
||||
@ -220,16 +210,14 @@ Foam::expressions::volumeExpr::parseDriver::getSurfaceField
|
||||
|
||||
|
||||
template<class Type>
|
||||
Foam::tmp<Foam::GeometricField<Type, Foam::pointPatchField, Foam::pointMesh>>
|
||||
Foam::tmp<Foam::PointField<Type>>
|
||||
Foam::expressions::volumeExpr::parseDriver::getPointField
|
||||
(
|
||||
const word& fldName,
|
||||
bool getOldTime
|
||||
)
|
||||
{
|
||||
typedef GeometricField<Type, pointPatchField, pointMesh> fieldType;
|
||||
|
||||
return this->getOrReadPointField<fieldType>
|
||||
return this->getOrReadPointField<PointField<Type>>
|
||||
(
|
||||
fldName,
|
||||
true, // mandatory
|
||||
@ -239,15 +227,13 @@ Foam::expressions::volumeExpr::parseDriver::getPointField
|
||||
|
||||
|
||||
template<class Type>
|
||||
Foam::tmp<Foam::GeometricField<Type, Foam::fvPatchField, Foam::volMesh>>
|
||||
Foam::tmp<Foam::VolumeField<Type>>
|
||||
Foam::expressions::volumeExpr::parseDriver::newVolField
|
||||
(
|
||||
const Type& val
|
||||
) const
|
||||
{
|
||||
typedef GeometricField<Type, fvPatchField, volMesh> fieldType;
|
||||
|
||||
return fieldType::New
|
||||
return VolumeField<Type>::New
|
||||
(
|
||||
word("constant.") + word(pTraits<Type>::typeName),
|
||||
mesh(),
|
||||
@ -257,15 +243,13 @@ Foam::expressions::volumeExpr::parseDriver::newVolField
|
||||
|
||||
|
||||
template<class Type>
|
||||
Foam::tmp<Foam::GeometricField<Type, Foam::fvsPatchField, Foam::surfaceMesh>>
|
||||
Foam::tmp<Foam::SurfaceField<Type>>
|
||||
Foam::expressions::volumeExpr::parseDriver::newSurfaceField
|
||||
(
|
||||
const Type& val
|
||||
) const
|
||||
{
|
||||
typedef GeometricField<Type, fvsPatchField, surfaceMesh> fieldType;
|
||||
|
||||
return fieldType::New
|
||||
return SurfaceField<Type>::New
|
||||
(
|
||||
word("constant.") + word(pTraits<Type>::typeName),
|
||||
mesh(),
|
||||
@ -275,15 +259,13 @@ Foam::expressions::volumeExpr::parseDriver::newSurfaceField
|
||||
|
||||
|
||||
template<class Type>
|
||||
Foam::tmp<Foam::GeometricField<Type, Foam::pointPatchField, Foam::pointMesh>>
|
||||
Foam::tmp<Foam::PointField<Type>>
|
||||
Foam::expressions::volumeExpr::parseDriver::newPointField
|
||||
(
|
||||
const Type& val
|
||||
) const
|
||||
{
|
||||
typedef GeometricField<Type, pointPatchField, pointMesh> fieldType;
|
||||
|
||||
return fieldType::New
|
||||
return PointField<Type>::New
|
||||
(
|
||||
word("constant.") + word(pTraits<Type>::typeName),
|
||||
pointMesh::New(mesh()),
|
||||
@ -293,10 +275,10 @@ Foam::expressions::volumeExpr::parseDriver::newPointField
|
||||
|
||||
|
||||
template<class Type>
|
||||
Foam::tmp<Foam::GeometricField<Type, Foam::fvsPatchField, Foam::surfaceMesh>>
|
||||
Foam::tmp<Foam::SurfaceField<Type>>
|
||||
Foam::expressions::volumeExpr::parseDriver::cellToFace
|
||||
(
|
||||
const GeometricField<Type, fvPatchField, volMesh>& field
|
||||
const VolumeField<Type>& field
|
||||
) const
|
||||
{
|
||||
return fvc::interpolate(field);
|
||||
@ -304,10 +286,10 @@ Foam::expressions::volumeExpr::parseDriver::cellToFace
|
||||
|
||||
|
||||
template<class Type>
|
||||
Foam::tmp<Foam::GeometricField<Type, Foam::pointPatchField, Foam::pointMesh>>
|
||||
Foam::tmp<Foam::PointField<Type>>
|
||||
Foam::expressions::volumeExpr::parseDriver::cellToPoint
|
||||
(
|
||||
const GeometricField<Type, fvPatchField, volMesh>& field
|
||||
const VolumeField<Type>& field
|
||||
) const
|
||||
{
|
||||
volPointInterpolation interp(this->mesh());
|
||||
@ -316,10 +298,10 @@ Foam::expressions::volumeExpr::parseDriver::cellToPoint
|
||||
|
||||
|
||||
template<class Type>
|
||||
Foam::tmp<Foam::GeometricField<Type,Foam::fvPatchField,Foam::volMesh>>
|
||||
Foam::tmp<Foam::VolumeField<Type>>
|
||||
Foam::expressions::volumeExpr::parseDriver::pointToCell
|
||||
(
|
||||
const GeometricField<Type, pointPatchField, pointMesh>& field
|
||||
const PointField<Type>& field
|
||||
) const
|
||||
{
|
||||
auto tresult = newVolField<Type>();
|
||||
|
||||
@ -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_().size(), Zero);
|
||||
labelList regionCount(globalFaces_().size(), 0);
|
||||
Field<Type> regionField(globalFaces_().totalSize(), Zero);
|
||||
labelList regionCount(globalFaces_().totalSize(), Zero);
|
||||
|
||||
forAll(cellToPatchFace, celli)
|
||||
{
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2021 OpenCFD Ltd.
|
||||
Copyright (C) 2021-2022 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -80,7 +80,7 @@ template<class Type>
|
||||
static void doCorrectBoundaryConditions
|
||||
(
|
||||
bool correctBCs,
|
||||
GeometricField<Type, fvPatchField, volMesh>& field
|
||||
VolumeField<Type>& field
|
||||
)
|
||||
{
|
||||
if (correctBCs)
|
||||
@ -104,7 +104,7 @@ template<class Type>
|
||||
void doCorrectBoundaryConditions
|
||||
(
|
||||
bool correctBCs,
|
||||
GeometricField<Type, pointPatchField, pointMesh>& field
|
||||
PointField<Type>& field
|
||||
)
|
||||
{
|
||||
if (correctBCs)
|
||||
@ -119,7 +119,7 @@ template<class Type>
|
||||
void doCorrectBoundaryConditions
|
||||
(
|
||||
bool correctBCs,
|
||||
GeometricField<Type, fvsPatchField, surfaceMesh>& field
|
||||
SurfaceField<Type>& field
|
||||
)
|
||||
{}
|
||||
|
||||
@ -148,15 +148,11 @@ bool Foam::functionObjects::fvExpressionField::loadAndStore(const IOobject& io)
|
||||
template<class Type>
|
||||
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<VolFieldType>(io)
|
||||
/// || loadAndStore<IntVolFieldType>(io)
|
||||
|| loadAndStore<SurfaceFieldType>(io)
|
||||
loadAndStore<VolumeField<Type>>(io)
|
||||
/// || loadAndStore<VolumeInternalField<Type>>(io)
|
||||
|| loadAndStore<SurfaceField<Type>>(io)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@ -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.size()
|
||||
<< " patch faces (" << globalFaces.totalSize()
|
||||
<< ") ?" << 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.size()
|
||||
<< " patch faces (" << globalFaces.totalSize()
|
||||
<< ") ?" << exit(FatalIOError);
|
||||
}
|
||||
|
||||
|
||||
@ -59,7 +59,7 @@ void Foam::functionObjects::nearWallFields::calcAddressing()
|
||||
// Global indexing
|
||||
globalIndex globalWalls(nPatchFaces);
|
||||
|
||||
DebugInFunction << "nPatchFaces: " << globalWalls.size() << endl;
|
||||
DebugInFunction << "nPatchFaces: " << globalWalls.totalSize() << endl;
|
||||
|
||||
// Construct cloud
|
||||
Cloud<findCellParticle> cloud
|
||||
|
||||
@ -563,7 +563,7 @@ bool Foam::functionObjects::streamLineBase::writeToFile()
|
||||
|
||||
const mapDistribute distMap
|
||||
(
|
||||
globalTrackIDs.size(),
|
||||
globalTrackIDs.totalSize(),
|
||||
std::move(sendMap),
|
||||
std::move(recvMap)
|
||||
);
|
||||
|
||||
@ -5,8 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2015 OpenFOAM Foundation
|
||||
Copyright (C) 2015-2020 OpenCFD Ltd.
|
||||
Copyright (C) 2022 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -28,7 +27,6 @@ License
|
||||
|
||||
#include "valueAverage.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
#include "Time.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
@ -41,21 +39,6 @@ namespace functionObjects
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * Protected Member Functions * * * * * * * * * //
|
||||
|
||||
void Foam::functionObjects::valueAverage::writeFileHeader(Ostream& os) const
|
||||
{
|
||||
writeHeader(os, "Value averages");
|
||||
writeCommented(os, "Time");
|
||||
forAll(fieldNames_, fieldi)
|
||||
{
|
||||
writeTabbed(os, fieldNames_[fieldi]);
|
||||
}
|
||||
os << endl;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::functionObjects::valueAverage::valueAverage
|
||||
@ -66,30 +49,9 @@ Foam::functionObjects::valueAverage::valueAverage
|
||||
)
|
||||
:
|
||||
regionFunctionObject(name, runTime, dict),
|
||||
writeFile(obr_, name, typeName, dict),
|
||||
functionObjectName_("unknown-functionObject"),
|
||||
fieldNames_(),
|
||||
window_(-1),
|
||||
totalTime_(),
|
||||
resetOnRestart_(false)
|
||||
valueAverageBase(name, obr_, dict, *this)
|
||||
{
|
||||
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());
|
||||
readState(this->propertyDict());
|
||||
}
|
||||
|
||||
|
||||
@ -97,103 +59,25 @@ Foam::functionObjects::valueAverage::valueAverage
|
||||
|
||||
bool Foam::functionObjects::valueAverage::read(const dictionary& 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_))
|
||||
if (regionFunctionObject::read(dict) && valueAverageBase::read(dict))
|
||||
{
|
||||
window_ = obr().time().userTimeToTime(window_);
|
||||
return true;
|
||||
}
|
||||
|
||||
totalTime_.setSize(fieldNames_.size());
|
||||
forAll(totalTime_, i)
|
||||
{
|
||||
totalTime_[i] = time_.deltaTValue();
|
||||
}
|
||||
|
||||
dict.readIfPresent("resetOnRestart", resetOnRestart_);
|
||||
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool Foam::functionObjects::valueAverage::execute()
|
||||
{
|
||||
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;
|
||||
|
||||
(void)valueAverageBase::calculate(this->propertyDict());
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool Foam::functionObjects::valueAverage::write()
|
||||
{
|
||||
valueAverageBase::writeState(this->propertyDict());
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@ -5,8 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2015 OpenFOAM Foundation
|
||||
Copyright (C) 2016-2020 OpenCFD Ltd.
|
||||
Copyright (C) 2022 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -79,14 +78,13 @@ Usage
|
||||
|
||||
The inherited entries are elaborated in:
|
||||
- \link regionFunctionObject.H \endlink
|
||||
- \link writeFile.H \endlink
|
||||
- \link valueAverageBase.H \endlink
|
||||
|
||||
Usage by the \c postProcess utility is not available.
|
||||
|
||||
See also
|
||||
- Foam::functionObject
|
||||
- Foam::functionObjects::stateFunctionObject
|
||||
- Foam::functionObjects::writeFile
|
||||
- Foam::functionObjects::valueAverageBase
|
||||
- ExtendedCodeGuide::functionObjects::field::valueAverage
|
||||
|
||||
SourceFiles
|
||||
@ -99,6 +97,7 @@ SourceFiles
|
||||
#define functionObjects_valueAverage_H
|
||||
|
||||
#include "regionFunctionObject.H"
|
||||
#include "valueAverageBase.H"
|
||||
#include "writeFile.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
@ -115,45 +114,8 @@ namespace functionObjects
|
||||
class valueAverage
|
||||
:
|
||||
public regionFunctionObject,
|
||||
public writeFile
|
||||
public valueAverageBase
|
||||
{
|
||||
protected:
|
||||
|
||||
// Protected Data
|
||||
|
||||
//- Name of function object to retrieve data from
|
||||
word functionObjectName_;
|
||||
|
||||
//- List of fields on which to operate
|
||||
wordList fieldNames_;
|
||||
|
||||
//- Averaging window
|
||||
scalar window_;
|
||||
|
||||
//- Average time per field
|
||||
List<scalar> totalTime_;
|
||||
|
||||
//- Reset the averaging process on restart
|
||||
Switch resetOnRestart_;
|
||||
|
||||
|
||||
// Protected Member Functions
|
||||
|
||||
//- Templated function to calculate the average
|
||||
template<class Type>
|
||||
void calc
|
||||
(
|
||||
const word& fieldName,
|
||||
const word& meanName,
|
||||
const scalar alpha,
|
||||
const scalar beta,
|
||||
bool& processed
|
||||
);
|
||||
|
||||
//- Output file header information
|
||||
virtual void writeFileHeader(Ostream& os) const;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
@ -201,12 +163,6 @@ public:
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#ifdef NoRepository
|
||||
#include "valueAverageTemplates.C"
|
||||
#endif
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2012-2016 OpenFOAM Foundation
|
||||
Copyright (C) 2015 OpenCFD Ltd.
|
||||
Copyright (C) 2015-2022 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -27,8 +27,10 @@ License
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "cloudInfo.H"
|
||||
#include "cloud.H"
|
||||
#include "kinematicCloud.H"
|
||||
#include "dictionary.H"
|
||||
#include "mathematicalConstants.H"
|
||||
#include "PstreamReduceOps.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
|
||||
@ -74,8 +76,10 @@ Foam::functionObjects::cloudInfo::cloudInfo
|
||||
const dictionary& dict
|
||||
)
|
||||
:
|
||||
regionFunctionObject(name, runTime, dict),
|
||||
logFiles(obr_, name, dict)
|
||||
functionObjects::regionFunctionObject(name, runTime, dict),
|
||||
functionObjects::logFiles(obr_, name, dict),
|
||||
verbose_(false),
|
||||
onExecute_(false)
|
||||
{
|
||||
read(dict);
|
||||
}
|
||||
@ -85,55 +89,175 @@ 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 (writeToFile() && names().size())
|
||||
if (names().size())
|
||||
{
|
||||
Info<< "applying to clouds:" << nl;
|
||||
forAll(names(), cloudi)
|
||||
for (const word& cldName : names())
|
||||
{
|
||||
Info<< " " << names()[cloudi] << nl;
|
||||
writeFileHeader(files(cloudi));
|
||||
Info<< " " << cldName << nl;
|
||||
}
|
||||
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::execute()
|
||||
bool Foam::functionObjects::cloudInfo::performAction(unsigned request)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if (!request || names().empty())
|
||||
{
|
||||
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 kinematicCloud& cloud =
|
||||
obr_.lookupObject<kinematicCloud>(cloudName);
|
||||
const auto* kinCloudPtr = obr_.cfindObject<kinematicCloud>(cloudName);
|
||||
|
||||
const label nTotParcels =
|
||||
returnReduce(cloud.nParcels(), sumOp<label>());
|
||||
if (!kinCloudPtr)
|
||||
{
|
||||
// Safety
|
||||
continue;
|
||||
}
|
||||
|
||||
const scalar totMass =
|
||||
returnReduce(cloud.massInSystem(), sumOp<scalar>());
|
||||
const auto& kinCloud = *kinCloudPtr;
|
||||
const auto* plainCloudPtr = isA<cloud>(kinCloud);
|
||||
|
||||
const scalar Dmax = cloud.Dmax();
|
||||
const scalar D10 = cloud.Dij(1, 0);
|
||||
const scalar D32 = cloud.Dij(3, 2);
|
||||
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);
|
||||
}
|
||||
|
||||
Log << type() << " " << name() << " write:" << nl
|
||||
<< " number of parcels : " << nTotParcels << nl
|
||||
@ -143,7 +267,7 @@ bool Foam::functionObjects::cloudInfo::write()
|
||||
<< " D32 diameter : " << D32 << nl
|
||||
<< endl;
|
||||
|
||||
if (writeToFile())
|
||||
if ((request & ACTION_WRITE) && writeToFile())
|
||||
{
|
||||
auto& os = files(cloudi);
|
||||
|
||||
@ -162,4 +286,21 @@ bool Foam::functionObjects::cloudInfo::write()
|
||||
}
|
||||
|
||||
|
||||
bool Foam::functionObjects::cloudInfo::execute()
|
||||
{
|
||||
if (onExecute_)
|
||||
{
|
||||
return performAction(ACTION_ALL & ~ACTION_WRITE);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool Foam::functionObjects::cloudInfo::write()
|
||||
{
|
||||
return performAction(ACTION_ALL);
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2012-2016 OpenFOAM Foundation
|
||||
Copyright (C) 2015-2020 OpenCFD Ltd.
|
||||
Copyright (C) 2015-2022 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -58,6 +58,8 @@ 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
|
||||
@ -72,11 +74,12 @@ SourceFiles
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef functionObjects_cloudInfo_H
|
||||
#define functionObjects_cloudInfo_H
|
||||
#ifndef Foam_functionObjects_cloudInfo_H
|
||||
#define Foam_functionObjects_cloudInfo_H
|
||||
|
||||
#include "regionFunctionObject.H"
|
||||
#include "logFiles.H"
|
||||
#include "parcelSelectionDetail.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -91,13 +94,31 @@ namespace functionObjects
|
||||
|
||||
class cloudInfo
|
||||
:
|
||||
public regionFunctionObject,
|
||||
public logFiles
|
||||
public functionObjects::regionFunctionObject,
|
||||
public functionObjects::logFiles,
|
||||
public Foam::Detail::parcelSelection
|
||||
{
|
||||
protected:
|
||||
|
||||
//- Switch to send output to Info as well
|
||||
Switch log_;
|
||||
// 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_;
|
||||
|
||||
//- List of cloud names
|
||||
wordList cloudNames_;
|
||||
@ -105,11 +126,14 @@ 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;
|
||||
|
||||
@ -22,12 +22,13 @@ 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
|
||||
|
||||
|
||||
@ -5,8 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2015 OpenFOAM Foundation
|
||||
Copyright (C) 2015-2020 OpenCFD Ltd.
|
||||
Copyright (C) 2022 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -28,7 +27,6 @@ License
|
||||
|
||||
#include "averageCondition.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
#include "Time.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
@ -44,18 +42,6 @@ namespace runTimeControls
|
||||
}
|
||||
}
|
||||
|
||||
const Foam::Enum
|
||||
<
|
||||
Foam::functionObjects::runTimeControls::averageCondition::windowType
|
||||
>
|
||||
Foam::functionObjects::runTimeControls::averageCondition::windowTypeNames
|
||||
({
|
||||
{ windowType::NONE, "none" },
|
||||
{ windowType::APPROXIMATE, "approximate" },
|
||||
{ windowType::EXACT, "exact" }
|
||||
});
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::functionObjects::runTimeControls::averageCondition::averageCondition
|
||||
@ -67,44 +53,13 @@ Foam::functionObjects::runTimeControls::averageCondition::averageCondition
|
||||
)
|
||||
:
|
||||
runTimeCondition(name, obr, dict, state),
|
||||
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)),
|
||||
valueAverageBase(name, obr_, dict, state, false),
|
||||
nIterStartUp_(dict.getOrDefault<label>("nIterStartUp", 10)),
|
||||
iter_(-1)
|
||||
{
|
||||
dictionary& conditionDict = this->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());
|
||||
}
|
||||
}
|
||||
}
|
||||
readState(conditionDict);
|
||||
|
||||
conditionDict.readIfPresent("iter", iter_);
|
||||
}
|
||||
@ -119,53 +74,18 @@ bool Foam::functionObjects::runTimeControls::averageCondition::apply()
|
||||
return true;
|
||||
}
|
||||
|
||||
bool satisfied = iter_ > nIterStartUp_;
|
||||
bool running = iter_ > nIterStartUp_;
|
||||
|
||||
++iter_;
|
||||
|
||||
const scalar dt = obr_.time().deltaTValue();
|
||||
dictionary& conditionDict = this->conditionDict();
|
||||
|
||||
Log << " " << type() << ": " << name_ << " averages:" << nl;
|
||||
|
||||
DynamicList<label> unprocessedFields(fieldNames_.size());
|
||||
Info<< incrIndent;
|
||||
running = valueAverageBase::calculate(conditionDict) && running;
|
||||
Info<< decrIndent;
|
||||
|
||||
forAll(fieldNames_, fieldi)
|
||||
{
|
||||
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;
|
||||
return running;
|
||||
}
|
||||
|
||||
|
||||
@ -173,25 +93,18 @@ void Foam::functionObjects::runTimeControls::averageCondition::write()
|
||||
{
|
||||
dictionary& conditionDict = this->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);
|
||||
}
|
||||
}
|
||||
valueAverageBase::writeState(conditionDict);
|
||||
|
||||
conditionDict.set("iter", iter_);
|
||||
}
|
||||
|
||||
|
||||
void Foam::functionObjects::runTimeControls::averageCondition::reset()
|
||||
{
|
||||
valueAverageBase::resetState(this->conditionDict());
|
||||
|
||||
iter_ = 0;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -5,8 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2015 OpenFOAM Foundation
|
||||
Copyright (C) 2016-2018 OpenCFD Ltd.
|
||||
Copyright (C) 2022 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -31,18 +30,20 @@ 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 averageCondition_H
|
||||
#define averageCondition_H
|
||||
#ifndef functionObjects_runTimeControls_averageCondition_H
|
||||
#define functionObjects_runTimeControls_averageCondition_H
|
||||
|
||||
#include "runTimeCondition.H"
|
||||
#include "Switch.H"
|
||||
#include "Enum.H"
|
||||
#include "valueAverageBase.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -59,46 +60,12 @@ namespace runTimeControls
|
||||
|
||||
class averageCondition
|
||||
:
|
||||
public runTimeCondition
|
||||
public runTimeCondition,
|
||||
public valueAverageBase
|
||||
{
|
||||
public:
|
||||
|
||||
// Public enumerations
|
||||
|
||||
enum class windowType
|
||||
{
|
||||
NONE,
|
||||
APPROXIMATE,
|
||||
EXACT
|
||||
};
|
||||
|
||||
static const Enum<windowType> windowTypeNames;
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
// 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_;
|
||||
// Protected Data
|
||||
|
||||
//- Number of start-up iterations before allowing satisfied checks
|
||||
label nIterStartUp_;
|
||||
@ -106,17 +73,6 @@ 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:
|
||||
|
||||
@ -143,6 +99,9 @@ public:
|
||||
|
||||
//- Write
|
||||
virtual void write();
|
||||
|
||||
//- Reset
|
||||
virtual void reset();
|
||||
};
|
||||
|
||||
|
||||
@ -154,12 +113,6 @@ public:
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#ifdef NoRepository
|
||||
#include "averageConditionTemplates.C"
|
||||
#endif
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -230,4 +230,11 @@ equationInitialResidualCondition::write()
|
||||
}
|
||||
|
||||
|
||||
void Foam::functionObjects::runTimeControls::
|
||||
equationInitialResidualCondition::reset()
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2015 OpenFOAM Foundation
|
||||
Copyright (C) 2016-2019 OpenCFD Ltd.
|
||||
Copyright (C) 2016-2022 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -130,6 +130,9 @@ public:
|
||||
|
||||
//- Write
|
||||
virtual void write();
|
||||
|
||||
//- Reset
|
||||
virtual void reset();
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2015 OpenFOAM Foundation
|
||||
Copyright (C) 2015-2020 OpenCFD Ltd.
|
||||
Copyright (C) 2015-2022 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -168,4 +168,11 @@ void Foam::functionObjects::runTimeControls::equationMaxIterCondition::write()
|
||||
}
|
||||
|
||||
|
||||
|
||||
void Foam::functionObjects::runTimeControls::equationMaxIterCondition::reset()
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2015 OpenFOAM Foundation
|
||||
Copyright (C) 2016 OpenCFD Ltd.
|
||||
Copyright (C) 2016-2022 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -97,6 +97,9 @@ public:
|
||||
|
||||
//- Write
|
||||
virtual void write();
|
||||
|
||||
//- Reset
|
||||
virtual void reset();
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2018-2020 OpenCFD Ltd.
|
||||
Copyright (C) 2018-2022 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -110,4 +110,10 @@ void Foam::functionObjects::runTimeControls::maxDurationCondition::write()
|
||||
}
|
||||
|
||||
|
||||
void Foam::functionObjects::runTimeControls::maxDurationCondition::reset()
|
||||
{
|
||||
initialised_ = false;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2018 OpenCFD Ltd.
|
||||
Copyright (C) 2018-2022 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -99,6 +99,9 @@ public:
|
||||
|
||||
//- Write
|
||||
virtual void write();
|
||||
|
||||
//- Reset
|
||||
virtual void reset();
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2015 OpenFOAM Foundation
|
||||
Copyright (C) 2015-2016 OpenCFD Ltd.
|
||||
Copyright (C) 2015-2022 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -166,4 +166,10 @@ void Foam::functionObjects::runTimeControls::minMaxCondition::write()
|
||||
}
|
||||
|
||||
|
||||
void Foam::functionObjects::runTimeControls::minMaxCondition::reset()
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -6,6 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2015 OpenFOAM Foundation
|
||||
Copyright (C) 2022 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -124,6 +125,9 @@ public:
|
||||
|
||||
//- Write
|
||||
virtual void write();
|
||||
|
||||
//- Reset
|
||||
virtual void reset();
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2015 OpenFOAM Foundation
|
||||
Copyright (C) 2019 OpenCFD Ltd.
|
||||
Copyright (C) 2019-2022 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -94,4 +94,10 @@ void Foam::functionObjects::runTimeControls::minTimeStepCondition::write()
|
||||
}
|
||||
|
||||
|
||||
void Foam::functionObjects::runTimeControls::minTimeStepCondition::reset()
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2015 OpenFOAM Foundation
|
||||
Copyright (C) 2016 OpenCFD Ltd.
|
||||
Copyright (C) 2016-2022 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -91,6 +91,9 @@ public:
|
||||
|
||||
//- Write
|
||||
virtual void write();
|
||||
|
||||
//- Reset
|
||||
virtual void reset();
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -5,8 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2015 OpenFOAM Foundation
|
||||
Copyright (C) 2015-2016 OpenCFD Ltd.
|
||||
Copyright (C) 2022 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -26,37 +25,56 @@ License
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
// * * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * //
|
||||
#include "noneCondition.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
|
||||
template<class Type>
|
||||
void Foam::functionObjects::valueAverage::calc
|
||||
(
|
||||
const word& fieldName,
|
||||
const word& meanName,
|
||||
const scalar alpha,
|
||||
const scalar beta,
|
||||
bool& processed
|
||||
)
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
const word valueType = objectResultType(functionObjectName_, fieldName);
|
||||
namespace functionObjects
|
||||
{
|
||||
namespace runTimeControls
|
||||
{
|
||||
defineTypeName(noneCondition);
|
||||
addToRunTimeSelectionTable(runTimeCondition, noneCondition, dictionary);
|
||||
|
||||
if (pTraits<Type>::typeName != valueType)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Type currentValue = getObjectResult<Type>(functionObjectName_, fieldName);
|
||||
|
||||
Type meanValue = getResult<Type>(meanName);
|
||||
meanValue = alpha*meanValue + beta*currentValue;
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
setResult(meanName, meanValue);
|
||||
Foam::functionObjects::runTimeControls::noneCondition::noneCondition
|
||||
(
|
||||
const word& name,
|
||||
const objectRegistry& obr,
|
||||
const dictionary& dict,
|
||||
stateFunctionObject& state
|
||||
)
|
||||
:
|
||||
runTimeCondition(name, obr, dict, state)
|
||||
{}
|
||||
|
||||
file() << tab << meanValue;
|
||||
|
||||
Log<< " " << meanName << ": " << meanValue << nl;
|
||||
// * * * * * * * * * * * * * * Public Member Functions * * * * * * * * * * * //
|
||||
|
||||
processed = true;
|
||||
bool Foam::functionObjects::runTimeControls::noneCondition::apply()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void Foam::functionObjects::runTimeControls::noneCondition::write()
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
|
||||
|
||||
void Foam::functionObjects::runTimeControls::noneCondition::reset()
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
|
||||
|
||||
@ -0,0 +1,100 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2022 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Class
|
||||
Foam::noneCondition
|
||||
|
||||
Description
|
||||
A no-op condition that simply returns true/nothing to do.
|
||||
|
||||
SourceFiles
|
||||
noneCondition.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef functionObjects_runTimeControls_noneCondition_H
|
||||
#define functionObjects_runTimeControls_noneCondition_H
|
||||
|
||||
#include "runTimeCondition.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
namespace functionObjects
|
||||
{
|
||||
namespace runTimeControls
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class noneCondition Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class noneCondition
|
||||
:
|
||||
public runTimeCondition
|
||||
{
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeNameNoDebug("none");
|
||||
|
||||
//- Constructor
|
||||
noneCondition
|
||||
(
|
||||
const word& name,
|
||||
const objectRegistry& obr,
|
||||
const dictionary& dict,
|
||||
stateFunctionObject& state
|
||||
);
|
||||
|
||||
//- Destructor
|
||||
virtual ~noneCondition() = default;
|
||||
|
||||
|
||||
// Public Member Functions
|
||||
|
||||
//- Apply the condition
|
||||
virtual bool apply();
|
||||
|
||||
//- Write
|
||||
virtual void write();
|
||||
|
||||
//- Reset
|
||||
virtual void reset();
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace runTimeControls
|
||||
} // End namespace functionObjects
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2015 OpenFOAM Foundation
|
||||
Copyright (C) 2016 OpenCFD Ltd.
|
||||
Copyright (C) 2016-2022 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -162,6 +162,9 @@ public:
|
||||
|
||||
//- Write
|
||||
virtual void write() = 0;
|
||||
|
||||
//- Reset
|
||||
virtual void reset() = 0;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2015 OpenFOAM Foundation
|
||||
Copyright (C) 2015-2021 OpenCFD Ltd.
|
||||
Copyright (C) 2015-2022 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -58,6 +58,7 @@ Foam::functionObjects::runTimeControls::runTimeControl::satisfiedActionNames
|
||||
{ satisfiedAction::SET_TRIGGER, "setTrigger"},
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::functionObjects::runTimeControls::runTimeControl::runTimeControl
|
||||
@ -74,7 +75,8 @@ Foam::functionObjects::runTimeControls::runTimeControl::runTimeControl
|
||||
writeStepI_(0),
|
||||
satisfiedAction_(satisfiedAction::END),
|
||||
triggerIndex_(labelMin),
|
||||
active_(getObjectProperty(name, "active", true))
|
||||
active_(getProperty("active", true)),
|
||||
canRestart_(getProperty("canRestart", false))
|
||||
{
|
||||
read(dict);
|
||||
}
|
||||
@ -99,6 +101,8 @@ 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());
|
||||
@ -128,9 +132,7 @@ bool Foam::functionObjects::runTimeControls::runTimeControl::read
|
||||
// Check that some conditions are set
|
||||
if (conditions_.empty())
|
||||
{
|
||||
Info<< type() << " " << name() << " output:" << nl
|
||||
<< " No conditions present" << nl
|
||||
<< endl;
|
||||
Info<< " No conditions present" << endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -147,12 +149,12 @@ bool Foam::functionObjects::runTimeControls::runTimeControl::read
|
||||
|
||||
if (!check)
|
||||
{
|
||||
Info<< type() << " " << name() << " output:" << nl
|
||||
<< " All conditions are inactive" << nl
|
||||
<< endl;
|
||||
Info<< " All conditions are inactive" << endl;
|
||||
}
|
||||
}
|
||||
|
||||
Info<< endl;
|
||||
|
||||
// Set the action to perform when all conditions are satisfied
|
||||
// - set to end for backwards compatibility with v1806
|
||||
satisfiedAction_ =
|
||||
@ -177,6 +179,12 @@ bool Foam::functionObjects::runTimeControls::runTimeControl::read
|
||||
|
||||
bool Foam::functionObjects::runTimeControls::runTimeControl::execute()
|
||||
{
|
||||
if (canRestart_)
|
||||
{
|
||||
active_ = true;
|
||||
canRestart_ = false;
|
||||
}
|
||||
|
||||
if (!active_)
|
||||
{
|
||||
return true;
|
||||
@ -199,7 +207,7 @@ bool Foam::functionObjects::runTimeControls::runTimeControl::execute()
|
||||
{
|
||||
bool conditionSatisfied = condition.apply();
|
||||
|
||||
label groupi = condition.groupID();
|
||||
const label groupi = condition.groupID();
|
||||
|
||||
auto conditionIter = groupMap_.cfind(groupi);
|
||||
|
||||
@ -271,14 +279,10 @@ bool Foam::functionObjects::runTimeControls::runTimeControl::execute()
|
||||
|
||||
if (nWriteStep_ != 0)
|
||||
{
|
||||
Info<< " - final step" << nl;
|
||||
}
|
||||
else
|
||||
{
|
||||
Info<< nl;
|
||||
Info<< " - final step";
|
||||
}
|
||||
|
||||
Info<< endl;
|
||||
Info<< nl << endl;
|
||||
active_ = false;
|
||||
|
||||
// Write any registered objects and set the end-time
|
||||
@ -299,11 +303,25 @@ 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;
|
||||
}
|
||||
}
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2015-2016 OpenFOAM Foundation
|
||||
Copyright (C) 2016-2021 OpenCFD Ltd.
|
||||
Copyright (C) 2016-2022 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -111,6 +111,11 @@ 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
|
||||
|
||||
|
||||
@ -68,8 +68,7 @@ Foam::functionObjects::thermoCoupleProbes::thermoCoupleProbes
|
||||
read(dict);
|
||||
}
|
||||
|
||||
// Check if the property exist (resume old calculation)
|
||||
// or of it is new.
|
||||
// Check if the property exists (resume old calculation) or is new
|
||||
dictionary probeDict;
|
||||
if (getDict(typeName, probeDict))
|
||||
{
|
||||
@ -77,7 +76,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
|
||||
@ -88,10 +87,6 @@ Foam::functionObjects::thermoCoupleProbes::thermoCoupleProbes
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::functionObjects::thermoCoupleProbes::~thermoCoupleProbes()
|
||||
{}
|
||||
|
||||
|
||||
Foam::label Foam::functionObjects::thermoCoupleProbes::nEqns() const
|
||||
{
|
||||
return this->size();
|
||||
@ -168,9 +163,12 @@ void Foam::functionObjects::thermoCoupleProbes::jacobian
|
||||
|
||||
bool Foam::functionObjects::thermoCoupleProbes::write()
|
||||
{
|
||||
if (this->size())
|
||||
if (!pointField::empty())
|
||||
{
|
||||
sampleAndWrite<scalar>(thermo_.T());
|
||||
(void) prepare(ACTION_WRITE);
|
||||
|
||||
const auto& Tfield = thermo_.T();
|
||||
writeValues(Tfield.name(), Ttc_, Tfield.time().timeOutputValue());
|
||||
|
||||
dictionary probeDict;
|
||||
probeDict.add("Tc", Ttc_);
|
||||
@ -184,7 +182,7 @@ bool Foam::functionObjects::thermoCoupleProbes::write()
|
||||
|
||||
bool Foam::functionObjects::thermoCoupleProbes::execute()
|
||||
{
|
||||
if (this->size())
|
||||
if (!pointField::empty())
|
||||
{
|
||||
scalar dt = mesh_.time().deltaTValue();
|
||||
scalar t = mesh_.time().value();
|
||||
|
||||
@ -79,8 +79,8 @@ SourceFiles
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef functionObjects_thermoCoupleProbes_H
|
||||
#define functionObjects_thermoCoupleProbes_H
|
||||
#ifndef Foam_functionObjects_thermoCoupleProbes_H
|
||||
#define Foam_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,18 +136,19 @@ protected:
|
||||
scalarField Ttc_;
|
||||
|
||||
|
||||
// Protected Member Functions
|
||||
|
||||
//- Sample and write a particular volume field
|
||||
template<class Type>
|
||||
void sampleAndWrite
|
||||
(
|
||||
const GeometricField<Type, fvPatchField, volMesh>&
|
||||
);
|
||||
|
||||
|
||||
private:
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Sample/write
|
||||
template<class Type>
|
||||
void writeValues
|
||||
(
|
||||
const word& fieldName,
|
||||
const Field<Type>& values,
|
||||
const scalar timeValue
|
||||
);
|
||||
|
||||
//- No copy construct
|
||||
thermoCoupleProbes(const thermoCoupleProbes&) = delete;
|
||||
|
||||
@ -176,40 +177,40 @@ public:
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~thermoCoupleProbes();
|
||||
virtual ~thermoCoupleProbes() = default;
|
||||
|
||||
|
||||
// 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
|
||||
|
||||
//- Sample and write
|
||||
virtual bool write();
|
||||
|
||||
//- Execute, currently does nothing
|
||||
virtual bool execute();
|
||||
|
||||
//- Read
|
||||
virtual bool read(const dictionary&);
|
||||
|
||||
//- Execute. Evaluates the ODESolver
|
||||
virtual bool execute();
|
||||
|
||||
//- Sample and write
|
||||
virtual bool write();
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2016 OpenCFD Ltd.
|
||||
Copyright (C) 2016-2022 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -28,25 +28,28 @@ License
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
void Foam::functionObjects::thermoCoupleProbes::sampleAndWrite
|
||||
void Foam::functionObjects::thermoCoupleProbes::writeValues
|
||||
(
|
||||
const GeometricField<Type, fvPatchField, volMesh>& vField
|
||||
const word& fieldName,
|
||||
const Field<Type>& values,
|
||||
const scalar timeValue
|
||||
)
|
||||
{
|
||||
if (Pstream::master())
|
||||
{
|
||||
unsigned int w = IOstream::defaultPrecision() + 7;
|
||||
OFstream& probeStream = *probeFilePtrs_[vField.name()];
|
||||
const unsigned int w = IOstream::defaultPrecision() + 7;
|
||||
OFstream& os = *probeFilePtrs_[fieldName];
|
||||
|
||||
probeStream
|
||||
<< setw(w)
|
||||
<< vField.time().timeOutputValue();
|
||||
os << setw(w) << timeValue;
|
||||
|
||||
forAll(*this, probeI)
|
||||
forAll(*this, probei)
|
||||
{
|
||||
probeStream << ' ' << setw(w) << Ttc_[probeI];
|
||||
// if (includeOutOfBounds_ || processor_[probei] != -1)
|
||||
{
|
||||
os << ' ' << setw(w) << values[probei];
|
||||
}
|
||||
}
|
||||
probeStream << endl;
|
||||
os << endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2017 OpenFOAM Foundation
|
||||
Copyright (C) 2015-2019 OpenCFD Ltd.
|
||||
Copyright (C) 2015-2022 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.size(), point::max);
|
||||
List<label> allInjectorCells(globalPositions.size(), -1);
|
||||
List<label> allInjectorTetFaces(globalPositions.size(), -1);
|
||||
List<label> allInjectorTetPts(globalPositions.size(), -1);
|
||||
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);
|
||||
|
||||
// Gather all positions on to all processors
|
||||
SubList<vector>
|
||||
(
|
||||
allPositions,
|
||||
globalPositions.localSize(Pstream::myProcNo()),
|
||||
globalPositions.offset(Pstream::myProcNo())
|
||||
globalPositions.localStart(Pstream::myProcNo())
|
||||
) = positions;
|
||||
|
||||
Pstream::listCombineGather(allPositions, minEqOp<point>());
|
||||
@ -128,19 +128,19 @@ void Foam::CellZoneInjection<CloudType>::setPositions
|
||||
(
|
||||
allInjectorCells,
|
||||
globalPositions.localSize(Pstream::myProcNo()),
|
||||
globalPositions.offset(Pstream::myProcNo())
|
||||
globalPositions.localStart(Pstream::myProcNo())
|
||||
) = injectorCells;
|
||||
SubList<label>
|
||||
(
|
||||
allInjectorTetFaces,
|
||||
globalPositions.localSize(Pstream::myProcNo()),
|
||||
globalPositions.offset(Pstream::myProcNo())
|
||||
globalPositions.localStart(Pstream::myProcNo())
|
||||
) = injectorTetFaces;
|
||||
SubList<label>
|
||||
(
|
||||
allInjectorTetPts,
|
||||
globalPositions.localSize(Pstream::myProcNo()),
|
||||
globalPositions.offset(Pstream::myProcNo())
|
||||
globalPositions.localStart(Pstream::myProcNo())
|
||||
) = injectorTetPts;
|
||||
|
||||
// Transfer data
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
Copyright (C) 2019-2020 OpenCFD Ltd.
|
||||
Copyright (C) 2019-2022 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.size();
|
||||
const label nParcelSum = globalParcels.totalSize();
|
||||
|
||||
if (nParcelSum == 0)
|
||||
{
|
||||
@ -139,7 +139,7 @@ inline Foam::scalar Foam::SprayCloud<CloudType>::penetration
|
||||
(
|
||||
allMass,
|
||||
globalParcels.localSize(proci),
|
||||
globalParcels.offset(proci)
|
||||
globalParcels.localStart(proci)
|
||||
) = procMass[proci];
|
||||
|
||||
// flatten the distance list
|
||||
@ -147,7 +147,7 @@ inline Foam::scalar Foam::SprayCloud<CloudType>::penetration
|
||||
(
|
||||
allDist,
|
||||
globalParcels.localSize(proci),
|
||||
globalParcels.offset(proci)
|
||||
globalParcels.localStart(proci)
|
||||
) = procDist[proci];
|
||||
}
|
||||
|
||||
|
||||
@ -95,6 +95,7 @@ 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;
|
||||
|
||||
@ -115,6 +115,8 @@ class refinementParameters
|
||||
|
||||
const scalar minCellFraction_;
|
||||
|
||||
const label nMinCells_;
|
||||
|
||||
const bool dryRun_;
|
||||
|
||||
|
||||
@ -244,6 +246,13 @@ 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
|
||||
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2015 OpenFOAM Foundation
|
||||
Copyright (C) 2015-2021 OpenCFD Ltd.
|
||||
Copyright (C) 2015-2022 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -3209,21 +3209,22 @@ void Foam::snappyRefineDriver::deleteSmallRegions
|
||||
forAll(nCellsPerRegion, regioni)
|
||||
{
|
||||
const label zonei = regionToZone[regioni];
|
||||
label& nRegionCells = nCellsPerRegion[regioni];
|
||||
|
||||
if
|
||||
(
|
||||
nCellsPerRegion[regioni]
|
||||
< refineParams.minCellFraction()*nCellsPerZone[zonei]
|
||||
nRegionCells < refineParams.minCellFraction()*nCellsPerZone[zonei]
|
||||
|| nRegionCells < refineParams.nMinCells()
|
||||
)
|
||||
{
|
||||
Info<< "Deleting region " << regioni
|
||||
<< " (size " << nCellsPerRegion[regioni]
|
||||
<< " (size " << nRegionCells
|
||||
<< ") of zone size " << nCellsPerZone[zonei]
|
||||
<< endl;
|
||||
|
||||
// Mark region to be deleted. 0 size (= global) should never
|
||||
// occur.
|
||||
nCellsPerRegion[regioni] = 0;
|
||||
nRegionCells = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -81,6 +81,57 @@ void Foam::advancingFrontAMI::checkPatches() const
|
||||
}
|
||||
|
||||
|
||||
bool Foam::advancingFrontAMI::isCandidate
|
||||
(
|
||||
const label srcFacei,
|
||||
const label tgtFacei
|
||||
) const
|
||||
{
|
||||
const auto& srcPatch = this->srcPatch();
|
||||
const auto& tgtPatch = this->tgtPatch();
|
||||
|
||||
if
|
||||
(
|
||||
(srcMagSf_[srcFacei] < ROOTVSMALL)
|
||||
|| (tgtMagSf_[tgtFacei] < ROOTVSMALL)
|
||||
)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (maxDistance2_ > 0)
|
||||
{
|
||||
const point& srcFc = srcPatch.faceCentres()[srcFacei];
|
||||
const point& tgtFc = tgtPatch.faceCentres()[tgtFacei];
|
||||
const vector& srcN = srcPatch.faceNormals()[srcFacei];
|
||||
|
||||
const scalar normalDist((tgtFc-srcFc)&srcN);
|
||||
//if (magSqr(srcFc-tgtFc) >= maxDistance2_)
|
||||
if (sqr(normalDist) >= maxDistance2_)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (minCosAngle_ > -1)
|
||||
{
|
||||
const vector& srcN = srcPatch.faceNormals()[srcFacei];
|
||||
vector tgtN = tgtPatch.faceNormals()[tgtFacei];
|
||||
if (!reverseTarget_)
|
||||
{
|
||||
tgtN = -tgtN;
|
||||
}
|
||||
|
||||
if ((srcN & tgtN) <= minCosAngle_)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void Foam::advancingFrontAMI::createExtendedTgtPatch()
|
||||
{
|
||||
// Create processor map of extended cells. This map gets (possibly
|
||||
@ -251,7 +302,7 @@ Foam::label Foam::advancingFrontAMI::findTargetFace
|
||||
const pointIndexHit sample =
|
||||
treePtr_->findNearest(srcPt, magSqr(bb.max() - bb.centre()), fnOp);
|
||||
|
||||
if (sample.hit())
|
||||
if (sample.hit() && isCandidate(srcFacei, sample.index()))
|
||||
{
|
||||
targetFacei = sample.index();
|
||||
|
||||
@ -375,6 +426,8 @@ Foam::advancingFrontAMI::advancingFrontAMI
|
||||
)
|
||||
:
|
||||
AMIInterpolation(dict, reverseTarget),
|
||||
maxDistance2_(dict.getOrDefault<scalar>("maxDistance2", -1)),
|
||||
minCosAngle_(dict.getOrDefault<scalar>("minCosAngle", -1)),
|
||||
srcTris_(),
|
||||
tgtTris_(),
|
||||
extendedTgtPatchPtr_(nullptr),
|
||||
@ -404,6 +457,8 @@ Foam::advancingFrontAMI::advancingFrontAMI
|
||||
)
|
||||
:
|
||||
AMIInterpolation(requireMatch, reverseTarget, lowWeightCorrection),
|
||||
maxDistance2_(-1),
|
||||
minCosAngle_(-1),
|
||||
srcTris_(),
|
||||
tgtTris_(),
|
||||
extendedTgtPatchPtr_(nullptr),
|
||||
@ -419,6 +474,8 @@ Foam::advancingFrontAMI::advancingFrontAMI
|
||||
Foam::advancingFrontAMI::advancingFrontAMI(const advancingFrontAMI& ami)
|
||||
:
|
||||
AMIInterpolation(ami),
|
||||
maxDistance2_(ami.maxDistance2_),
|
||||
minCosAngle_(ami.minCosAngle_),
|
||||
srcTris_(),
|
||||
tgtTris_(),
|
||||
extendedTgtPatchPtr_(nullptr),
|
||||
@ -452,6 +509,24 @@ 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);
|
||||
@ -479,6 +554,8 @@ 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",
|
||||
|
||||
@ -106,6 +106,12 @@ 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_;
|
||||
|
||||
@ -148,6 +154,10 @@ 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,
|
||||
|
||||
@ -379,12 +379,8 @@ void Foam::faceAreaWeightAMI::calcInterArea
|
||||
{
|
||||
addProfiling(ami, "faceAreaWeightAMI::interArea");
|
||||
|
||||
// Quick reject if either face has zero area
|
||||
if
|
||||
(
|
||||
(srcMagSf_[srcFacei] < ROOTVSMALL)
|
||||
|| (tgtMagSf_[tgtFacei] < ROOTVSMALL)
|
||||
)
|
||||
// Quick reject if either face has zero area/too far away/wrong orientation
|
||||
if (!isCandidate(srcFacei, tgtFacei))
|
||||
{
|
||||
return;
|
||||
}
|
||||
@ -459,12 +455,8 @@ bool Foam::faceAreaWeightAMI::overlaps
|
||||
const scalar threshold
|
||||
) const
|
||||
{
|
||||
// Quick reject if either face has zero area
|
||||
if
|
||||
(
|
||||
(srcMagSf_[srcFacei] < ROOTVSMALL)
|
||||
|| (tgtMagSf_[tgtFacei] < ROOTVSMALL)
|
||||
)
|
||||
// Quick reject if either face has zero area/too far away/wrong orientation
|
||||
if (!isCandidate(srcFacei, tgtFacei))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -133,12 +133,8 @@ void Foam::faceAreaWeightAMI2D::storeInterArea
|
||||
{
|
||||
addProfiling(ami, "faceAreaWeightAMI2D::calcInterArea");
|
||||
|
||||
// Quick reject if either face has zero area
|
||||
if
|
||||
(
|
||||
(srcMagSf_[srcFacei] < ROOTVSMALL)
|
||||
|| (tgtMagSf_[tgtFacei] < ROOTVSMALL)
|
||||
)
|
||||
// Quick reject if either face has zero area/too far away/wrong orientation
|
||||
if (!isCandidate(srcFacei, tgtFacei))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
@ -147,6 +147,14 @@ $(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
|
||||
|
||||
@ -34,8 +34,8 @@ SourceFiles
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef curve_H
|
||||
#define curve_H
|
||||
#ifndef Foam_curve_H
|
||||
#define Foam_curve_H
|
||||
|
||||
#include "string.H"
|
||||
#include "primitiveFields.H"
|
||||
@ -46,8 +46,7 @@ SourceFiles
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// Forward declaration of friend functions and operators
|
||||
|
||||
// Forward Declarations
|
||||
class curve;
|
||||
Ostream& operator<<(Ostream&, const curve&);
|
||||
|
||||
@ -60,13 +59,11 @@ class curve
|
||||
:
|
||||
public scalarField
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
//- The style (line, symbol, etc) of a curve
|
||||
class curveStyle
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
//- Enumeration definitions
|
||||
@ -116,9 +113,10 @@ public:
|
||||
|
||||
private:
|
||||
|
||||
// private data
|
||||
// Private Data
|
||||
|
||||
string name_;
|
||||
|
||||
curveStyle style_;
|
||||
|
||||
|
||||
@ -126,9 +124,6 @@ public:
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct as interpolation of an existing curve
|
||||
//curve(const curve&, const label);
|
||||
|
||||
//- Construct from name, style and size
|
||||
curve
|
||||
(
|
||||
@ -151,7 +146,7 @@ public:
|
||||
}
|
||||
|
||||
|
||||
// Member functions
|
||||
// Member Functions
|
||||
|
||||
// Access
|
||||
|
||||
@ -166,12 +161,6 @@ public:
|
||||
}
|
||||
|
||||
|
||||
// Friend functions
|
||||
|
||||
//- Gradient of the curve
|
||||
//friend curve grad(const curve&);
|
||||
|
||||
|
||||
// Ostream operator
|
||||
|
||||
friend Ostream& operator<<(Ostream&, const curve&);
|
||||
@ -29,7 +29,6 @@ License
|
||||
#include "graph.H"
|
||||
#include "OFstream.H"
|
||||
#include "IOmanip.H"
|
||||
#include "Pair.H"
|
||||
#include "OSspecific.H"
|
||||
#include "SubField.H"
|
||||
|
||||
@ -272,9 +271,9 @@ void Foam::graph::write(Ostream& os, const word& format) const
|
||||
|
||||
void Foam::graph::write(const fileName& pName, const word& format) const
|
||||
{
|
||||
autoPtr<writer> graphWriter(writer::New(format));
|
||||
autoPtr<writer> writer(writer::New(format));
|
||||
|
||||
OFstream graphFile(pName + '.' + graphWriter().ext());
|
||||
OFstream graphFile(pName + '.' + writer().ext());
|
||||
|
||||
if (graphFile.good())
|
||||
{
|
||||
@ -35,23 +35,21 @@ SourceFiles
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef graph_H
|
||||
#define graph_H
|
||||
#ifndef Foam_graph_H
|
||||
#define Foam_graph_H
|
||||
|
||||
#include "string.H"
|
||||
#include "point.H"
|
||||
#include "HashPtrTable.H"
|
||||
#include "curve.H"
|
||||
#include "HashPtrTable.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// Forward declaration of friend functions and operators
|
||||
|
||||
// Forward Declaration
|
||||
class graph;
|
||||
|
||||
Ostream& operator<<(Ostream&, const graph&);
|
||||
|
||||
|
||||
@ -63,7 +61,7 @@ class graph
|
||||
:
|
||||
public HashPtrTable<curve>
|
||||
{
|
||||
// private data
|
||||
// Private Data
|
||||
|
||||
string title_;
|
||||
string xName_;
|
||||
@ -71,13 +69,10 @@ class graph
|
||||
|
||||
scalarField x_;
|
||||
|
||||
|
||||
struct xy
|
||||
{
|
||||
scalar x_, y_;
|
||||
|
||||
xy()
|
||||
{}
|
||||
|
||||
// Friend Operators
|
||||
|
||||
@ -143,10 +138,10 @@ public:
|
||||
);
|
||||
|
||||
//- Construct from Istream
|
||||
graph(Istream& is);
|
||||
explicit graph(Istream& is);
|
||||
|
||||
|
||||
// Member functions
|
||||
// Member Functions
|
||||
|
||||
// Access
|
||||
|
||||
@ -190,7 +185,6 @@ public:
|
||||
//- Abstract base class for a graph writer
|
||||
class writer
|
||||
{
|
||||
|
||||
protected:
|
||||
|
||||
void writeXY
|
||||
@ -219,17 +213,13 @@ public:
|
||||
// Selectors
|
||||
|
||||
//- Return a reference to the selected writer
|
||||
static autoPtr<writer> New
|
||||
(
|
||||
const word& writeFormat
|
||||
);
|
||||
static autoPtr<writer> New(const word& writeFormat);
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct null
|
||||
writer()
|
||||
{}
|
||||
//- Default construct
|
||||
writer() = default;
|
||||
|
||||
|
||||
//- Destructor
|
||||
@ -238,19 +228,14 @@ public:
|
||||
|
||||
// Member Functions
|
||||
|
||||
// Access
|
||||
//- The fileName extension for this graph format
|
||||
virtual word ext() 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 graph in appropriate format
|
||||
virtual void write(const graph&, Ostream&) const = 0;
|
||||
};
|
||||
|
||||
|
||||
//- Write out graph data as a simple table
|
||||
void writeTable(Ostream&) const;
|
||||
|
||||
@ -272,7 +257,7 @@ public:
|
||||
static word wordify(const string& sname);
|
||||
|
||||
|
||||
// Friend operators
|
||||
// Friend Operators
|
||||
|
||||
//- Ostream Operator
|
||||
friend Ostream& operator<<(Ostream&, const graph&);
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2012 OpenFOAM Foundation
|
||||
Copyright (C) 2019 OpenCFD Ltd.
|
||||
Copyright (C) 2019-2022 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -26,50 +26,49 @@ License
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "gnuplotGraph.H"
|
||||
#include "gnuplotGraphWriter.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
defineTypeNameAndDebug(gnuplotGraph, 0);
|
||||
const word gnuplotGraph::ext_("gplt");
|
||||
typedef graph::writer graphWriter;
|
||||
|
||||
typedef graph::writer graphWriter;
|
||||
addToRunTimeSelectionTable(graphWriter, gnuplotGraph, word);
|
||||
namespace graphWriters
|
||||
{
|
||||
defineTypeName(gnuplotWriter);
|
||||
addToRunTimeSelectionTable(graphWriter, gnuplotWriter, word);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
void Foam::gnuplotGraph::write(const graph& g, Ostream& os) const
|
||||
void Foam::graphWriters::gnuplotWriter::write
|
||||
(
|
||||
const graph& g,
|
||||
Ostream& os
|
||||
) const
|
||||
{
|
||||
os << "#set term postscript color" << endl
|
||||
<< "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;
|
||||
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;
|
||||
|
||||
label nplots = 0;
|
||||
forAllConstIters(g, iter)
|
||||
{
|
||||
if (!firstField)
|
||||
{
|
||||
os << ',';
|
||||
}
|
||||
firstField = false;
|
||||
|
||||
os << (nplots++ ? ", \\" : "plot \\") << nl;
|
||||
os << "'-' title " << iter()->name() << " with lines";
|
||||
}
|
||||
os << "; pause -1" << endl;
|
||||
os << "; pause -1" << nl;
|
||||
|
||||
|
||||
forAllConstIters(g, iter)
|
||||
{
|
||||
os << endl;
|
||||
os << nl;
|
||||
writeXY(g.x(), *iter(), os);
|
||||
}
|
||||
}
|
||||
@ -6,6 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011 OpenFOAM Foundation
|
||||
Copyright (C) 2022 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -24,18 +25,18 @@ License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Class
|
||||
Foam::gnuplotGraph
|
||||
Foam::graphWriters::gnuplotWriter
|
||||
|
||||
Description
|
||||
Output in gnuplot (http://www.gnuplot.info) format
|
||||
|
||||
SourceFiles
|
||||
gnuplotGraph.C
|
||||
gnuplotGraphWriter.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef gnuplotGraph_H
|
||||
#define gnuplotGraph_H
|
||||
#ifndef Foam_gnuplotGraphWriter_H
|
||||
#define Foam_gnuplotGraphWriter_H
|
||||
|
||||
#include "graph.H"
|
||||
|
||||
@ -43,57 +44,42 @@ SourceFiles
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
namespace graphWriters
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class gnuplotGraph Declaration
|
||||
Class gnuplotWriter Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class gnuplotGraph
|
||||
class gnuplotWriter
|
||||
:
|
||||
public graph::writer
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("gnuplot");
|
||||
|
||||
//- FileName extension for this graph format
|
||||
static const word ext_;
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct null
|
||||
gnuplotGraph()
|
||||
{}
|
||||
TypeNameNoDebug("gnuplot");
|
||||
|
||||
//- Default construct
|
||||
gnuplotWriter() = default;
|
||||
|
||||
//- Destructor
|
||||
~gnuplotGraph()
|
||||
{}
|
||||
~gnuplotWriter() = default;
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
// Access
|
||||
//- The fileName extension for this graph format
|
||||
word ext() const { return "gplt"; }
|
||||
|
||||
//- Return the appropriate fileName extension
|
||||
// for this graph format
|
||||
const word& ext() const
|
||||
{
|
||||
return ext_;
|
||||
}
|
||||
|
||||
|
||||
// Write
|
||||
|
||||
void write(const graph&, Ostream& os) const;
|
||||
//- Write
|
||||
void write(const graph&, Ostream& os) const;
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace graphWriters
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
@ -6,6 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2012 OpenFOAM Foundation
|
||||
Copyright (C) 2022 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -25,24 +26,30 @@ License
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "rawGraph.H"
|
||||
#include "rawGraphWriter.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
defineTypeNameAndDebug(rawGraph, 0);
|
||||
const word rawGraph::ext_("xy");
|
||||
typedef graph::writer graphWriter;
|
||||
|
||||
typedef graph::writer graphWriter;
|
||||
addToRunTimeSelectionTable(graphWriter, rawGraph, word);
|
||||
namespace graphWriters
|
||||
{
|
||||
defineTypeName(rawWriter);
|
||||
addToRunTimeSelectionTable(graphWriter, rawWriter, word);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
void Foam::rawGraph::write(const graph& g, Ostream& os) const
|
||||
void Foam::graphWriters::rawWriter::write
|
||||
(
|
||||
const graph& g,
|
||||
Ostream& os
|
||||
) const
|
||||
{
|
||||
g.writeTable(os);
|
||||
}
|
||||
@ -6,6 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011 OpenFOAM Foundation
|
||||
Copyright (C) 2022 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -24,18 +25,18 @@ License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Class
|
||||
Foam::rawGraph
|
||||
Foam::graphWriters::rawWriter
|
||||
|
||||
Description
|
||||
A raw xy graph output
|
||||
|
||||
SourceFiles
|
||||
rawGraph.C
|
||||
rawGraphWriter.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef rawGraph_H
|
||||
#define rawGraph_H
|
||||
#ifndef Foam_rawGraphWriter_H
|
||||
#define Foam_rawGraphWriter_H
|
||||
|
||||
#include "graph.H"
|
||||
|
||||
@ -43,57 +44,42 @@ SourceFiles
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
namespace graphWriters
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class rawGraph Declaration
|
||||
Class rawWriter Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class rawGraph
|
||||
class rawWriter
|
||||
:
|
||||
public graph::writer
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("raw");
|
||||
|
||||
//- FileName extension for this graph format
|
||||
static const word ext_;
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct null
|
||||
rawGraph()
|
||||
{}
|
||||
TypeNameNoDebug("raw");
|
||||
|
||||
//- Default construct
|
||||
rawWriter() = default;
|
||||
|
||||
//- Destructor
|
||||
~rawGraph()
|
||||
{}
|
||||
~rawWriter() = default;
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
// Access
|
||||
//- The fileName extension for this graph format
|
||||
word ext() const { return "xy"; }
|
||||
|
||||
//- Return the appropriate fileName extension
|
||||
// for this graph format
|
||||
const word& ext() const
|
||||
{
|
||||
return ext_;
|
||||
}
|
||||
|
||||
|
||||
// Write
|
||||
|
||||
void write(const graph&, Ostream& os) const;
|
||||
//- Write
|
||||
void write(const graph&, Ostream& os) const;
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace graphWriters
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
Copyright (C) 2019 OpenCFD Ltd.
|
||||
Copyright (C) 2019-2022 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -26,43 +26,49 @@ License
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "xmgrGraph.H"
|
||||
#include "xmgraceGraphWriter.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
defineTypeNameAndDebug(xmgrGraph, 0);
|
||||
const word xmgrGraph::ext_("agr");
|
||||
|
||||
typedef graph::writer graphWriter;
|
||||
addToRunTimeSelectionTable(graphWriter, xmgrGraph, word);
|
||||
typedef graph::writer graphWriter;
|
||||
|
||||
namespace graphWriters
|
||||
{
|
||||
defineTypeName(xmgraceWriter);
|
||||
addToRunTimeSelectionTable(graphWriter, xmgraceWriter, word);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
void Foam::xmgrGraph::write(const graph& g, Ostream& os) const
|
||||
void Foam::graphWriters::xmgraceWriter::write
|
||||
(
|
||||
const graph& g,
|
||||
Ostream& os
|
||||
) const
|
||||
{
|
||||
os << "@title " << g.title() << nl
|
||||
<< "@xaxis label " << g.xName() << nl
|
||||
<< "@yaxis label " << g.yName() << endl;
|
||||
<< "@yaxis label " << g.yName() << nl;
|
||||
|
||||
label fieldi = 0;
|
||||
label nWritten_ = 0;
|
||||
|
||||
forAllConstIters(g, iter)
|
||||
{
|
||||
os << "@s" << fieldi << " legend "
|
||||
os << "@s" << nWritten_ << " legend "
|
||||
<< iter()->name() << nl
|
||||
<< "@target G0.S" << fieldi << nl
|
||||
<< "@type xy" << endl;
|
||||
<< "@target G0.S" << nWritten_ << nl
|
||||
<< "@type xy" << nl;
|
||||
|
||||
writeXY(g.x(), *iter(), os);
|
||||
|
||||
os << endl;
|
||||
|
||||
fieldi++;
|
||||
++nWritten_;
|
||||
}
|
||||
}
|
||||
|
||||
@ -6,6 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011 OpenFOAM Foundation
|
||||
Copyright (C) 2022 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -24,19 +25,19 @@ License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Class
|
||||
Foam::xmgrGraph
|
||||
Foam::graphWriters::xmgraceWriter
|
||||
|
||||
Description
|
||||
Output and \b agr file for \em xmgrace
|
||||
(http://plasma-gate.weizmann.ac.il/Grace/)
|
||||
|
||||
SourceFiles
|
||||
xmgrGraph.C
|
||||
xmgraceGraphWriter.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef xmgrGraph_H
|
||||
#define xmgrGraph_H
|
||||
#ifndef Foam_xmgraceGraphWriter_H
|
||||
#define Foam_xmgraceGraphWriter_H
|
||||
|
||||
#include "graph.H"
|
||||
|
||||
@ -44,57 +45,42 @@ SourceFiles
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
namespace graphWriters
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class xmgrGraph Declaration
|
||||
Class xmgraceWriter Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class xmgrGraph
|
||||
class xmgraceWriter
|
||||
:
|
||||
public graph::writer
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("xmgr");
|
||||
|
||||
//- FileName extension for this graph format
|
||||
static const word ext_;
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct null
|
||||
xmgrGraph()
|
||||
{}
|
||||
TypeNameNoDebug("xmgr");
|
||||
|
||||
//- Default construct
|
||||
xmgraceWriter() = default;
|
||||
|
||||
//- Destructor
|
||||
~xmgrGraph()
|
||||
{}
|
||||
~xmgraceWriter() = default;
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
// Access
|
||||
//- The fileName extension for this graph format
|
||||
word ext() const { return "agr"; }
|
||||
|
||||
//- Return the appropriate fileName extension
|
||||
// for this graph format
|
||||
const word& ext() const
|
||||
{
|
||||
return ext_;
|
||||
}
|
||||
|
||||
|
||||
// Write
|
||||
|
||||
void write(const graph&, Ostream& os) const;
|
||||
//- Write
|
||||
void write(const graph&, Ostream& os) const;
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace graphWriters
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user