34 namespace functionObjects
41 regionSizeDistribution,
47 template<
class T,
unsigned Size>
68 void Foam::functionObjects::regionSizeDistribution::writeAlphaFields
76 const scalar maxDropletVol = 1.0/6.0*
pow(maxDiam_, 3);
91 alphaName_ +
"_liquidCore",
92 obr_.time().timeName(),
104 alphaName_ +
"_background",
105 obr_.time().timeName(),
117 label regionI = regions[celli];
118 if (patchRegions.
found(regionI))
120 backgroundAlpha[celli] = 0;
124 liquidCore[celli] = 0;
126 scalar regionVol = regionVolume[regionI];
127 if (regionVol < maxDropletVol)
129 backgroundAlpha[celli] = 0;
133 liquidCore.correctBoundaryConditions();
134 backgroundAlpha.correctBoundaryConditions();
136 Info<<
" Volume of liquid-core = " 139 Info<<
" Volume of background = " 143 Info<<
" Writing liquid-core field to " << liquidCore.name() <<
endl;
145 Info<<
" Writing background field to " << backgroundAlpha.name() <<
endl;
146 backgroundAlpha.
write();
151 Foam::functionObjects::regionSizeDistribution::findPatchRegions
160 const labelHashSet patchIDs(mesh_.boundaryMesh().patchSet(patchNames_));
162 label nPatchFaces = 0;
165 nPatchFaces += mesh_.boundaryMesh()[iter.key()].size();
181 regions[faceCells[i]],
198 Foam::functionObjects::regionSizeDistribution::divide
211 result[i] = num[i]/denom[i];
224 void Foam::functionObjects::regionSizeDistribution::generateFields
226 const word& fieldName,
240 binSum[indices[i]] += sortedField[i];
248 fieldNames.
append(fieldName +
"_sum");
250 fieldNames.
append(fieldName +
"_avg");
256 void Foam::functionObjects::regionSizeDistribution::generateFields
258 const word& fieldName,
272 binSum[indices[i]] += sortedField[i];
282 binSqrSum[indices[i]] +=
Foam::sqr(sortedField[i]);
291 fieldNames.
append(fieldName +
"_sum");
293 fieldNames.
append(fieldName +
"_avg");
295 fieldNames.
append(fieldName +
"_dev");
302 void Foam::functionObjects::regionSizeDistribution::generateFields
304 const word& fieldName,
316 Map<Type> regionField(regionSum(regions, cellField));
321 sortedNormalisation*extractData(sortedRegions, regionField)
348 alphaName_(dict.
lookup(
"alpha")),
349 patchNames_(dict.
lookup(
"patches"))
365 dict.
lookup(
"alpha") >> alphaName_;
366 dict.
lookup(
"patches") >> patchNames_;
367 dict.
lookup(
"threshold") >> threshold_;
368 dict.
lookup(
"maxDiameter") >> maxDiam_;
371 dict.
lookup(
"nBins") >> nBins_;
372 dict.
lookup(
"fields") >> fields_;
383 fields.
append(alphaName_);
401 Info<<
" Looking up field " << alphaName_ <<
endl;
405 Info<<
" Reading field " << alphaName_ <<
endl;
413 mesh_.time().timeName(),
431 Info<<
" Volume of alpha = " 435 const scalar meshVol =
gSum(mesh_.V());
436 const scalar maxDropletVol = 1.0/6.0*
pow(maxDiam_, 3);
437 const scalar
delta = (maxDiam_-minDiam_)/nBins_;
439 Info<<
" Mesh volume = " << meshVol <<
endl;
440 Info<<
" Maximum droplet diameter = " << maxDiam_ <<
endl;
441 Info<<
" Maximum droplet volume = " << maxDropletVol <<
endl;
445 boolList blockedFace(mesh_.nFaces(),
false);
449 for (
label facei = 0; facei < mesh_.nInternalFaces(); facei++)
451 scalar ownVal = alpha[mesh_.faceOwner()[facei]];
452 scalar neiVal = alpha[mesh_.faceNeighbour()[facei]];
456 (ownVal < threshold_ && neiVal > threshold_)
457 || (ownVal > threshold_ && neiVal < threshold_)
460 blockedFace[facei] =
true;
480 scalar ownVal = ownFld[i];
481 scalar neiVal = nbrFld[i];
485 (ownVal < threshold_ && neiVal > threshold_)
486 || (ownVal > threshold_ && neiVal < threshold_)
489 blockedFace[start+i] =
true;
501 <<
" disconnected regions" <<
endl;
511 mesh_.time().timeName(),
519 Info<<
" Dumping region as volScalarField to " << region.name()
524 region[celli] = regions[celli];
526 region.correctBoundaryConditions();
532 Map<label> patchRegions(findPatchRegions(regions));
537 Map<scalar> allRegionVolume(regionSum(regions, mesh_.V()));
538 Map<scalar> allRegionAlphaVolume(regionSum(regions, alphaVol));
551 <<
tab <<
"Volume(mesh)" 552 <<
tab <<
"Volume(" << alpha.
name() <<
"):" 555 scalar meshSumVol = 0.0;
556 scalar alphaSumVol = 0.0;
565 vIter != allRegionVolume.end()
566 && aIter != allRegionAlphaVolume.
end();
567 ++vIter, ++aIter, ++numIter
576 meshSumVol += vIter();
577 alphaSumVol += aIter();
582 <<
tab << alphaSumVol
592 Info<<
" Patch connected regions (liquid core):" <<
endl;
594 <<
tab <<
"Volume(mesh)" 595 <<
tab <<
"Volume(" << alpha.
name() <<
"):" 599 label regionI = iter.key();
600 Info<<
" " <<
tab << iter.key()
601 <<
tab << allRegionVolume[regionI]
602 <<
tab << allRegionAlphaVolume[regionI] <<
endl;
609 Info<<
" Background regions:" <<
endl;
611 <<
tab <<
"Volume(mesh)" 612 <<
tab <<
"Volume(" << alpha.
name() <<
"):" 620 vIter != allRegionVolume.end()
621 && aIter != allRegionAlphaVolume.
end();
628 && vIter() >= maxDropletVol
647 writeAlphaFields(regions, patchRegions, allRegionVolume, alpha);
656 label regionI = vIter.key();
659 patchRegions.
found(regionI)
660 || vIter() >= maxDropletVol
663 allRegionVolume.erase(vIter);
664 allRegionAlphaVolume.
erase(regionI);
665 allRegionNumCells.
erase(regionI);
669 if (allRegionVolume.size())
696 forAll(sortedDiameters, i)
706 labelList indices(sortedDiameters.size());
707 forAll(sortedDiameters, i)
709 indices[i] = (sortedDiameters[i]-minDiam_)/delta;
714 forAll(sortedDiameters, i)
716 binCount[indices[i]] += 1.0;
723 <<
tab <<
"Min diameter" 732 <<
tab << binCount[binI] <<
endl;
740 #define DeclareTypeFields(Type, nullArg) \ 741 PtrList<Field<Type>> Type##Fields; 743 #undef DeclareTypeFields 746 fieldNames.
append(
"binCount");
747 #define TypeFieldsAppend(Type, nullArg) \ 748 appendFields(binCount, Type##Fields); 749 #undef TypeFieldsAppend 767 #define GenerateTypeFields(Type, nullArg) \ 769 if (obr_.foundObject<VolField<Type>>(fields_[fieldi])) \ 773 const VolField<Type>& field = \ 774 obr_.lookupObject<VolField<Type>>(fields_[fieldi]); \ 779 (alphaVol*field)(), \ 790 #undef GenerateTypeFields 792 if (!found) cannotFindObject(fields_[fieldi]);
796 #define TypeFieldsExpand(Type, nullArg) \ 797 Type##Fields.setSize(fieldNames.size()); 799 #undef TypeFieldsAppend 802 formatterPtr_().write
808 #define TypeFieldsParameter(Type, nullArg) , Type##Fields 810 #undef TypeFieldsParameter static autoPtr< setWriter > New(const word &writeType, const IOstream::streamFormat writeFormat=IOstream::ASCII, const IOstream::compressionType writeCompression=IOstream::UNCOMPRESSED)
Select given write options.
#define TypeFieldsExpand(Type, nullArg)
void divide(FieldField< Field, Type > &f, const FieldField< Field, Type > &f1, const FieldField< Field, scalar > &f2)
This class separates the mesh into distinct unconnected regions, each of which is then given a label ...
void append(T *)
Append an element at the end of the list.
Field< label > labelField
Specialisation of Field<T> for label.
#define forAll(list, i)
Loop across all elements in list.
virtual bool write()
Calculate the regionSizeDistribution and write.
virtual Ostream & write(const char)=0
Write character.
const word & name() const
Return name.
An STL-conforming const_iterator.
virtual bool execute()
Do nothing.
void reset(T *=nullptr)
If object pointer already set, delete object and set to given.
static iteratorEnd end()
iteratorEnd set to beyond the end of any HashTable
A 1D vector of objects of type <T> with a fixed size <Size>.
A list of keyword definitions, which are a keyword followed by any number of values (e...
#define forAllConstIter(Container, container, iter)
Iterate across all elements in the container object of type.
const Boundary & boundaryField() const
Return const-reference to the boundary field.
T & ref() const
Return non-const reference or generate a fatal error.
dimensionedSymmTensor sqr(const dimensionedVector &dv)
const polyBoundaryMesh & boundaryMesh() const
Return boundaryMesh reference.
#define forAllIter(Container, container, iter)
Iterate across all elements in the container object of type.
void size(const label)
Override size to be inconsistent with allocated storage.
addToRunTimeSelectionTable(functionObject, Qdot, dictionary)
static int myProcNo(const label communicator=0)
Number of this process (starting from masterNo() = 0)
dimensionedScalar sqrt(const dimensionedScalar &ds)
Ostream & endl(Ostream &os)
Add newline and flush stream.
Plus op for FixedList<scalar>
static bool master(const label communicator=0)
Am I the master process.
Abstract base class with a fat-interface to all derived classes covering all possible ways in which t...
dimensioned< Type > domainIntegrate(const GeometricField< Type, fvPatchField, volMesh > &vf)
const Internal::FieldType & primitiveField() const
Return a const-reference to the internal field.
const dimensionSet dimless
#define TypeFieldsParameter(Type, nullArg)
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
regionSizeDistribution(const word &name, const Time &runTime, const dictionary &)
Construct for given objectRegistry and dictionary.
Macros for easy insertion into run-time selection tables.
static List< word > fieldNames
bool erase(const iterator &)
Erase a hashedEntry specified by given iterator.
static void mapCombineScatter(const List< commsStruct > &comms, Container &Values, const int tag, const label comm)
Scatter data. Reverse of combineGather.
bool insert(const Key &, const T &newElmt)
Insert a new hashedEntry.
virtual wordList fields() const
Return the list of fields required.
bool read(const char *, int32_t &)
const Key & key() const
Return the Key corresponding to the iterator.
Holds list of sampling positions.
Type gSum(const FieldField< Field, Type > &f)
const labelUList & faceCells() const
Return face-cell addressing.
bool found(const Key &) const
Return true if hashedEntry is found in table.
Pre-declare SubField and related Field type.
A class for handling words, derived from string.
const polyPatch & patch() const
Return the polyPatch.
void append(const T &)
Append an element at the end of the list.
dimensionedScalar cbrt(const dimensionedScalar &ds)
bool readIfPresent(const word &, T &, bool recursive=false, bool patternMatch=true) const
Find an entry if present, and assign to T.
virtual bool coupled() const
Return true if this patch field is coupled.
Volume integrate volField creating a volField.
static void mapCombineGather(const List< commsStruct > &comms, Container &Values, const CombineOp &cop, const int tag, const label comm)
iterator begin()
Iterator set to the beginning of the HashTable.
bool valid() const
Return true if the autoPtr valid (ie, the pointer is set)
virtual bool read(const dictionary &)
Read the regionSizeDistribution data.
void setSize(const label)
Reset size of PtrList. If extending the PtrList, new entries are.
const fvPatch & patch() const
Return patch.
#define DeclareTypeFields(Type, nullArg)
virtual tmp< Field< Type > > patchInternalField() const
Return internal field next to patch as patch field.
virtual ~regionSizeDistribution()
word name(const complex &)
Return a string representation of a complex.
defineTypeNameAndDebug(Qdot, 0)
dimensionedScalar pow(const dimensionedScalar &ds, const dimensionedScalar &expt)
Info<< "Reading field p_rgh\"<< endl;volScalarField p_rgh(IOobject("p_rgh", runTime.timeName(), mesh, IOobject::MUST_READ, IOobject::AUTO_WRITE), mesh);pressureReference pressureReference(p, p_rgh, pimple.dict(), thermo.incompressible());mesh.schemes().setFluxRequired(p_rgh.name());hydrostaticInitialisation(p_rgh, p, rho, U, gh, ghf, pRef, thermo, pimple.dict());Info<< "Creating field dpdt\"<< endl;volScalarField dpdt(IOobject("dpdt", runTime.timeName(), mesh), mesh, dimensionedScalar(p.dimensions()/dimTime, 0));Info<< "Creating field kinetic energy K\"<< endl;volScalarField K("K", 0.5 *magSqr(U));dimensionedScalar initialMass=fvc::domainIntegrate(rho);multivariateSurfaceInterpolationScheme< scalar >::fieldTable fields
dimensioned< scalar > dimensionedScalar
Dimensioned scalar obtained from generic dimensioned type.
A templated 1D list of pointers to objects of type <T>, where the size of the array is known and used...
List< label > sortedToc() const
Return the table of contents as a sorted list.
label start() const
Return start label of this patch in the polyMesh face list.
fileType type(const fileName &, const bool checkVariants=true, const bool followLink=true)
Return the file type: directory or file.
label nRegions() const
Return total number of regions.
FOR_ALL_FIELD_TYPES(DefineFvWallInfoType)
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Specialisation of Foam::functionObject for an Foam::fvMesh, providing a reference to the Foam::fvMesh...
virtual bool write(const bool write=true) const
Write using setting from DB.
A class for managing temporary objects.
A patch is a list of labels that address the faces in the global face list.
#define GenerateTypeFields(Type, nullArg)
virtual tmp< Field< Type > > patchNeighbourField(const Pstream::commsTypes commsType=Pstream::commsTypes::blocking) const
Return patchField on the opposite patch of a coupled patch.
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.