34 namespace functionObjects
47 template<
class T,
unsigned Size>
68 void Foam::functionObjects::regionSizeDistribution::writeAlphaFields
70 const regionSplit& regions,
71 const Map<label>& patchRegions,
72 const Map<scalar>& regionVolume,
76 const scalar maxDropletVol = 1.0/6.0*
pow(maxDiam_, 3);
91 alphaName_ +
"_liquidCore",
104 alphaName_ +
"_background",
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();
144 <<
"Writing liquid-core field to " << liquidCore.
name() <<
endl;
147 <<
"Writing background field to " << backgroundAlpha.
name() <<
endl;
148 backgroundAlpha.
write();
153 Foam::functionObjects::regionSizeDistribution::findPatchRegions
155 const regionSplit& regions
162 const labelHashSet patchIDs(mesh_.poly().boundary().patchSet(patchNames_));
164 label nPatchFaces = 0;
167 nPatchFaces += mesh_.poly().boundary()[iter.key()].size();
171 Map<label> patchRegions(nPatchFaces);
174 const polyPatch& pp = mesh_.poly().boundary()[iter.key()];
177 const labelList& faceCells = pp.faceCells();
183 regions[faceCells[i]],
200 Foam::functionObjects::regionSizeDistribution::divide
213 result[i] = num[i]/denom[i];
226 void Foam::functionObjects::regionSizeDistribution::generateFields
228 const word& fieldName,
242 binSum[indices[i]] += sortedField[i];
258 void Foam::functionObjects::regionSizeDistribution::generateFields
260 const word& fieldName,
265 PtrList<scalarField>&
fields
274 binSum[indices[i]] += sortedField[i];
284 binSqrSum[indices[i]] +=
Foam::sqr(sortedField[i]);
304 void Foam::functionObjects::regionSizeDistribution::generateFields
306 const word& fieldName,
307 const Field<Type>& cellField,
308 const regionSplit& regions,
314 PtrList<Field<Type>>&
fields
318 Map<Type> regionField(regionSum(regions, cellField));
321 Field<Type> sortedField
323 sortedNormalisation*extractData(sortedRegions, regionField)
367 dict.lookup(
"alpha") >> alphaName_;
368 dict.lookup(
"patches") >> patchNames_;
369 dict.lookup(
"threshold") >> threshold_;
370 dict.lookup(
"maxDiameter") >> maxDiam_;
372 dict.readIfPresent(
"minDiameter", minDiam_);
373 dict.lookup(
"nBins") >> nBins_;
374 dict.lookup(
"fields") >> fields_;
385 fields.append(alphaName_);
437 const scalar meshVol =
gSum(mesh_.V());
438 const scalar maxDropletVol = 1.0/6.0*
pow(maxDiam_, 3);
439 const scalar
delta = (maxDiam_-minDiam_)/nBins_;
442 Info<<
indent <<
"Maximum droplet diameter = " << maxDiam_ <<
endl;
443 Info<<
indent <<
"Maximum droplet volume = " << maxDropletVol <<
endl;
447 boolList blockedFace(mesh_.nFaces(),
false);
450 for (
label facei = 0; facei < mesh_.nInternalFaces(); facei++)
452 scalar ownVal =
alpha[mesh_.faceOwner()[facei]];
453 scalar neiVal =
alpha[mesh_.faceNeighbour()[facei]];
457 (ownVal < threshold_ && neiVal > threshold_)
458 || (ownVal > threshold_ && neiVal < threshold_)
461 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;
500 <<
" disconnected regions" <<
endl;
523 region[celli] = regions[celli];
525 region.correctBoundaryConditions();
531 Map<label> patchRegions(findPatchRegions(regions));
536 Map<scalar> allRegionVolume(regionSum(regions, mesh_.V()));
537 Map<scalar> allRegionAlphaVolume(regionSum(regions, alphaVol));
550 <<
tab <<
"Volume(mesh)"
551 <<
tab <<
"Volume(" <<
alpha.name() <<
"):"
554 scalar meshSumVol = 0.0;
555 scalar alphaSumVol = 0.0;
564 vIter != allRegionVolume.
end()
565 && aIter != allRegionAlphaVolume.
end();
566 ++vIter, ++aIter, ++numIter
575 meshSumVol += vIter();
576 alphaSumVol += aIter();
581 <<
tab << alphaSumVol
587 Info<<
indent <<
"Patch connected regions (liquid core):" <<
endl;
589 <<
tab <<
"Volume(mesh)"
590 <<
tab <<
"Volume(" <<
alpha.name() <<
"):"
594 label regionI = iter.key();
596 <<
tab << allRegionVolume[regionI]
597 <<
tab << allRegionAlphaVolume[regionI] <<
endl;
605 <<
tab <<
"Volume(mesh)"
606 <<
tab <<
"Volume(" <<
alpha.name() <<
"):"
614 vIter != allRegionVolume.
end()
615 && aIter != allRegionAlphaVolume.
end();
621 !patchRegions.
found(vIter.key())
622 && vIter() >= maxDropletVol
640 writeAlphaFields(regions, patchRegions, allRegionVolume,
alpha);
649 label regionI = vIter.key();
652 patchRegions.
found(regionI)
653 || vIter() >= maxDropletVol
656 allRegionVolume.
erase(vIter);
657 allRegionAlphaVolume.
erase(regionI);
658 allRegionNumCells.
erase(regionI);
662 if (allRegionVolume.
size())
689 forAll(sortedDiameters, i)
700 forAll(sortedDiameters, i)
702 indices[i] = (sortedDiameters[i]-minDiam_)/
delta;
707 forAll(sortedDiameters, i)
709 binCount[indices[i]] += 1.0;
716 <<
tab <<
"Min diameter"
725 <<
tab << binCount[binI] <<
endl;
733 #define DeclareTypeFields(Type, nullArg) \
734 PtrList<Field<Type>> Type##Fields;
736 #undef DeclareTypeFields
740 #define TypeFieldsAppend(Type, nullArg) \
741 appendFields(binCount, Type##Fields);
742 #undef TypeFieldsAppend
760 #define GenerateTypeFields(Type, nullArg) \
762 if (obr_.foundObject<VolField<Type>>(fields_[fieldi])) \
766 const VolField<Type>& field = \
767 obr_.lookupObject<VolField<Type>>(fields_[fieldi]); \
772 (alphaVol*field)(), \
783 #undef GenerateTypeFields
785 if (!
found) cannotFindObject(fields_[fieldi]);
789 #define TypeFieldsExpand(Type, nullArg) \
790 Type##Fields.setSize(fieldNames.size());
792 #undef TypeFieldsAppend
795 formatterPtr_().write
#define forAll(list, i)
Loop across all elements in list.
#define forAllIter(Container, container, iter)
Iterate across all elements in the container object of type.
#define forAllConstIter(Container, container, iter)
Iterate across all elements in the container object of type.
Macros for easy insertion into run-time selection tables.
Pre-declare SubField and related Field type.
A 1D vector of objects of type <T> with a fixed size <Size>.
Generic GeometricField class.
List< Key > sortedToc() const
Return the table of contents as a sorted list.
bool erase(const iterator &)
Erase a hashedEntry specified by given iterator.
iterator begin()
Iterator set to the beginning of the HashTable.
label size() const
Return number of elements in table.
bool found(const Key &) const
Return true if hashedEntry is found in table.
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
virtual const fileName & name() const
Return the name of the stream.
Plus op for FixedList<scalar>
void append(const T &)
Append an element at the end of the list.
void size(const label)
Override size to be inconsistent with allocated storage.
A HashTable to objects of type <T> with a label key.
virtual Ostream & write(const token &)
Write token.
static void mapCombineScatter(const List< commsStruct > &comms, Container &Values, const int tag, const label comm)
Scatter data. Reverse of combineGather.
static void mapCombineGather(const List< commsStruct > &comms, Container &Values, const CombineOp &cop, const int tag, const label comm)
A templated 1D list of pointers to objects of type <T>, where the size of the array is known and used...
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
static bool master(const label communicator=0)
Am I the master process.
static int myProcNo(const label communicator=0)
Number of this process (starting from masterNo() = 0)
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
bool valid() const
Return true if the autoPtr valid (ie, the pointer is set)
void reset(T *=nullptr)
If object pointer already set, delete object and set to given.
Holds list of sampling positions.
A list of keywords followed by any number of values (e.g. words and numbers) or sub-dictionaries.
const word & name() const
Return const reference to name.
Abstract base-class for Time/database functionObjects.
const Time & time_
Reference to time.
Specialisation of Foam::functionObject for an Foam::fvMesh, providing a reference to the Foam::fvMesh...
const objectRegistry & obr_
Reference to the objectRegistry.
Creates a size distribution via interrogating a continuous phase fraction field.
regionSizeDistribution(const word &name, const Time &runTime, const dictionary &)
Construct for given objectRegistry and dictionary.
virtual wordList fields() const
Return the list of fields required.
virtual ~regionSizeDistribution()
virtual bool execute()
Do nothing.
virtual bool write()
Calculate the regionSizeDistribution and write.
virtual bool read(const dictionary &)
Read the regionSizeDistribution data.
const word & name() const
Return reference to name.
Abstract base class with a fat-interface to all derived classes covering all possible ways in which t...
virtual bool coupled() const
Return true if this patch field is coupled.
virtual tmp< Field< Type > > patchInternalField() const
Return internal field next to patch as patch field.
virtual tmp< Field< Type > > patchNeighbourField(const Pstream::commsTypes commsType=Pstream::commsTypes::blocking) const
Return patchField on the opposite patch of a coupled patch.
const fvPatch & patch() const
Return patch.
static const word & calculatedType()
Return the type of the calculated for of fvPatchField.
const polyPatch & poly() const
Return the polyPatch.
label start() const
Return start label of this patch in the polyMesh face list.
virtual bool write(const bool write=true) const
Write using setting from DB.
This class separates the mesh into distinct unconnected regions, each of which is then given a label ...
label nRegions() const
Return total number of regions.
static autoPtr< setWriter > New(const word &writeType, const IOstream::streamFormat writeFormat=IOstream::ASCII, const IOstream::compressionType writeCompression=IOstream::UNCOMPRESSED)
Select given write options.
A class for managing temporary objects.
T & ref() const
Return non-const reference or generate a fatal error.
Template function which returns the un-mangled name of a given type. Useful for types which do not ha...
A class for handling words, derived from string.
Volume integrate volField creating a volField.
static List< word > fieldNames
Info<< "Calculating turbulent flame speed field St\n"<< endl;volScalarField St(IOobject("St", runTime.name(), mesh, IOobject::NO_READ, IOobject::AUTO_WRITE), flameWrinkling->Xi() *Su);multivariateSurfaceInterpolationScheme< scalar >::fieldTable fields
volScalarField alpha(IOobject("alpha", runTime.name(), mesh, IOobject::READ_IF_PRESENT, IOobject::AUTO_WRITE), lambda *max(Ua &U, zeroSensitivity))
defineTypeNameAndDebug(fvMeshFunctionObject, 0)
addToRunTimeSelectionTable(functionObject, fvModel, dictionary)
dimensioned< Type > domainIntegrate(const VolField< Type > &vf)
const unitSet & lookup(const word &unitName)
Lookup and return the named unit from the table.
List< word > wordList
A List of words.
const dimensionSet & dimless
List< label > labelList
A List of labels.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Ostream & endl(Ostream &os)
Add newline and flush stream.
FOR_ALL_FIELD_TYPES(makeDimensionedPointFieldFunctions)
const fvMesh & region(const dictionary &dict)
Cast the give dictionary to the corresponding region fvMesh.
Type gSum(const UList< Type > &f, const label comm)
void divide(pointPatchField< Type > &f, const pointPatchField< Type > &f1, const pointPatchField< scalar > &f2)
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
tmp< DimensionedField< typename outerProduct< Type, Type >::type, GeoMesh, Field >> sqr(const DimensionedField< Type, GeoMesh, PrimitiveField > &df)
VolField< scalar > volScalarField
Field< label > labelField
Specialisation of Field<T> for label.
void cbrt(LagrangianPatchField< scalar > &f, const LagrangianPatchField< scalar > &f1)
word name(const LagrangianState state)
Return a string representation of a Lagrangian state enumeration.
tmp< DimensionedField< typename powProduct< Type, r >::type, GeoMesh, Field > > pow(const DimensionedField< Type, GeoMesh, PrimitiveField > &df, typename powProduct< Type, r >::type)
HashSet< label, Hash< label > > labelHashSet
A HashSet with label keys.
void sqrt(LagrangianPatchField< scalar > &f, const LagrangianPatchField< scalar > &f1)
Ostream & indent(Ostream &os)
Indent stream.
fileType type(const fileName &, const bool checkVariants=true, const bool followLink=true)
Return the file type: directory or file.
#define GenerateTypeFields(Type, nullArg)
#define TypeFieldsParameter(Type, nullArg)
#define DeclareTypeFields(Type, nullArg)
#define TypeFieldsExpand(Type, nullArg)
static iteratorEnd end()
iteratorEnd set to beyond the end of any HashTable