mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: Forces function object - user can now select bin limits
This commit is contained in:
@ -107,6 +107,7 @@ void Foam::functionObjects::forces::writeBinHeader
|
|||||||
writeHeader(os, header + " bins");
|
writeHeader(os, header + " bins");
|
||||||
writeHeaderValue(os, "bins", nBin_);
|
writeHeaderValue(os, "bins", nBin_);
|
||||||
writeHeaderValue(os, "start", binMin_);
|
writeHeaderValue(os, "start", binMin_);
|
||||||
|
writeHeaderValue(os, "end", binMax_);
|
||||||
writeHeaderValue(os, "delta", binDx_);
|
writeHeaderValue(os, "delta", binDx_);
|
||||||
writeHeaderValue(os, "direction", binDir_);
|
writeHeaderValue(os, "direction", binDir_);
|
||||||
|
|
||||||
@ -249,14 +250,14 @@ void Foam::functionObjects::forces::initialiseBins()
|
|||||||
const polyBoundaryMesh& pbm = mesh_.boundaryMesh();
|
const polyBoundaryMesh& pbm = mesh_.boundaryMesh();
|
||||||
|
|
||||||
// Determine extents of patches
|
// Determine extents of patches
|
||||||
binMin_ = GREAT;
|
scalar geomMin = GREAT;
|
||||||
scalar binMax = -GREAT;
|
scalar geomMax = -GREAT;
|
||||||
for (const label patchi : patchSet_)
|
for (const label patchi : patchSet_)
|
||||||
{
|
{
|
||||||
const polyPatch& pp = pbm[patchi];
|
const polyPatch& pp = pbm[patchi];
|
||||||
scalarField d(pp.faceCentres() & binDir_);
|
scalarField d(pp.faceCentres() & binDir_);
|
||||||
binMin_ = min(min(d), binMin_);
|
geomMin = min(min(d), geomMin);
|
||||||
binMax = max(max(d), binMax);
|
geomMax = max(max(d), geomMax);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Include porosity
|
// Include porosity
|
||||||
@ -276,22 +277,31 @@ void Foam::functionObjects::forces::initialiseBins()
|
|||||||
{
|
{
|
||||||
const cellZone& cZone = mesh_.cellZones()[zonei];
|
const cellZone& cZone = mesh_.cellZones()[zonei];
|
||||||
const scalarField d(dd, cZone);
|
const scalarField d(dd, cZone);
|
||||||
binMin_ = min(min(d), binMin_);
|
geomMin = min(min(d), geomMin);
|
||||||
binMax = max(max(d), binMax);
|
geomMax = max(max(d), geomMax);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
reduce(binMin_, minOp<scalar>());
|
reduce(geomMin, minOp<scalar>());
|
||||||
reduce(binMax, maxOp<scalar>());
|
reduce(geomMax, maxOp<scalar>());
|
||||||
|
|
||||||
// Slightly boost binMax so that region of interest is fully
|
// Slightly boost max so that region of interest is fully within bounds
|
||||||
// within bounds
|
geomMax = 1.0001*(geomMax - geomMin) + geomMin;
|
||||||
binMax = 1.0001*(binMax - binMin_) + binMin_;
|
|
||||||
|
|
||||||
binDx_ = (binMax - binMin_)/scalar(nBin_);
|
// Use geometry limits if not specified by the user
|
||||||
|
if (binMin_ == GREAT)
|
||||||
|
{
|
||||||
|
binMin_ = geomMin;
|
||||||
|
}
|
||||||
|
if (binMax_ == GREAT)
|
||||||
|
{
|
||||||
|
binMax_ = geomMax;
|
||||||
|
}
|
||||||
|
|
||||||
// Create the bin points used for writing
|
binDx_ = (binMax_ - binMin_)/scalar(nBin_);
|
||||||
|
|
||||||
|
// Create the bin mid-points used for writing
|
||||||
binPoints_.setSize(nBin_);
|
binPoints_.setSize(nBin_);
|
||||||
forAll(binPoints_, i)
|
forAll(binPoints_, i)
|
||||||
{
|
{
|
||||||
@ -723,8 +733,9 @@ Foam::functionObjects::forces::forces
|
|||||||
porosity_(false),
|
porosity_(false),
|
||||||
nBin_(1),
|
nBin_(1),
|
||||||
binDir_(Zero),
|
binDir_(Zero),
|
||||||
binDx_(0.0),
|
binDx_(0),
|
||||||
binMin_(GREAT),
|
binMin_(GREAT),
|
||||||
|
binMax_(GREAT),
|
||||||
binPoints_(),
|
binPoints_(),
|
||||||
binCumulative_(true),
|
binCumulative_(true),
|
||||||
writeFields_(false),
|
writeFields_(false),
|
||||||
@ -767,8 +778,9 @@ Foam::functionObjects::forces::forces
|
|||||||
porosity_(false),
|
porosity_(false),
|
||||||
nBin_(1),
|
nBin_(1),
|
||||||
binDir_(Zero),
|
binDir_(Zero),
|
||||||
binDx_(0.0),
|
binDx_(0),
|
||||||
binMin_(GREAT),
|
binMin_(GREAT),
|
||||||
|
binMax_(GREAT),
|
||||||
binPoints_(),
|
binPoints_(),
|
||||||
binCumulative_(true),
|
binCumulative_(true),
|
||||||
writeFields_(false),
|
writeFields_(false),
|
||||||
@ -848,8 +860,9 @@ bool Foam::functionObjects::forces::read(const dictionary& dict)
|
|||||||
|
|
||||||
if (dict.found("binData"))
|
if (dict.found("binData"))
|
||||||
{
|
{
|
||||||
|
Info<< " Activated data bins" << endl;
|
||||||
const dictionary& binDict(dict.subDict("binData"));
|
const dictionary& binDict(dict.subDict("binData"));
|
||||||
binDict.readEntry("nBin", nBin_);
|
nBin_ = binDict.get<label>("nBin");
|
||||||
|
|
||||||
if (nBin_ < 0)
|
if (nBin_ < 0)
|
||||||
{
|
{
|
||||||
@ -865,9 +878,21 @@ bool Foam::functionObjects::forces::read(const dictionary& dict)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
Info<< " Employing " << nBin_ << " bins" << endl;
|
Info<< " Employing " << nBin_ << " bins" << endl;
|
||||||
binDict.readEntry("cumulative", binCumulative_);
|
if (binDict.readIfPresent("min", binMin_))
|
||||||
binDict.readEntry("direction", binDir_);
|
{
|
||||||
|
Info<< " - min : " << binMin_ << endl;
|
||||||
|
}
|
||||||
|
if (binDict.readIfPresent("max", binMax_))
|
||||||
|
{
|
||||||
|
Info<< " - max : " << binMax_ << endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
binCumulative_ = binDict.get<bool>("cumulative");
|
||||||
|
Info<< " - cumuluative : " << binCumulative_ << endl;
|
||||||
|
|
||||||
|
binDir_ = binDict.get<vector>("direction");
|
||||||
binDir_.normalise();
|
binDir_.normalise();
|
||||||
|
Info<< " - direction : " << binDir_ << endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -240,6 +240,9 @@ protected:
|
|||||||
//- Minimum bin bounds
|
//- Minimum bin bounds
|
||||||
scalar binMin_;
|
scalar binMin_;
|
||||||
|
|
||||||
|
//- Maximum bin bounds
|
||||||
|
scalar binMax_;
|
||||||
|
|
||||||
//- Bin positions along binDir
|
//- Bin positions along binDir
|
||||||
List<point> binPoints_;
|
List<point> binPoints_;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user