44 fixedValueFvPatchVectorField(
p, iF),
47 cyclicPatchLabel_(-1),
53 maxOpenFractionDelta_(0),
55 minThresholdValue_(0),
71 fixedValueFvPatchVectorField(ptf,
p, iF, mapper),
73 cyclicPatchName_(ptf.cyclicPatchName_),
74 cyclicPatchLabel_(ptf.cyclicPatchLabel_),
75 initWallSf_(ptf.initWallSf_),
76 initCyclicSf_(ptf.initCyclicSf_),
77 nbrCyclicSf_(ptf.nbrCyclicSf_),
78 openFraction_(ptf.openFraction_),
79 openingTime_(ptf.openingTime_),
80 maxOpenFractionDelta_(ptf.maxOpenFractionDelta_),
82 minThresholdValue_(ptf.minThresholdValue_),
84 baffleActivated_(ptf.baffleActivated_),
85 opening_(ptf.opening_)
98 pName_(
dict.getOrDefault<
word>(
"p",
"p")),
100 cyclicPatchLabel_(
p.patch().
boundaryMesh().findPatchID(cyclicPatchName_)),
104 openFraction_(
dict.get<scalar>(
"openFraction")),
105 openingTime_(
dict.get<scalar>(
"openingTime")),
106 maxOpenFractionDelta_(
dict.get<scalar>(
"maxOpenFractionDelta")),
108 minThresholdValue_(
dict.get<scalar>(
"minThresholdValue")),
109 fBased_(
dict.get<bool>(
"forceBased")),
111 opening_(
dict.get<bool>(
"opening"))
117 initWallSf_ =
p.Sf();
118 initCyclicSf_ =
p.boundaryMesh()[cyclicPatchLabel_].Sf();
121 p.boundaryMesh()[cyclicPatchLabel_],
123 ).neighbFvPatch().Sf();
126 dict.readIfPresent(
"p", pName_);
133 const activePressureForceBaffleVelocityFvPatchVectorField& ptf
136 fixedValueFvPatchVectorField(ptf),
138 cyclicPatchName_(ptf.cyclicPatchName_),
139 cyclicPatchLabel_(ptf.cyclicPatchLabel_),
140 initWallSf_(ptf.initWallSf_),
141 initCyclicSf_(ptf.initCyclicSf_),
142 nbrCyclicSf_(ptf.nbrCyclicSf_),
143 openFraction_(ptf.openFraction_),
144 openingTime_(ptf.openingTime_),
145 maxOpenFractionDelta_(ptf.maxOpenFractionDelta_),
147 minThresholdValue_(ptf.minThresholdValue_),
148 fBased_(ptf.fBased_),
149 baffleActivated_(ptf.baffleActivated_),
150 opening_(ptf.opening_)
161 fixedValueFvPatchVectorField(ptf, iF),
163 cyclicPatchName_(ptf.cyclicPatchName_),
164 cyclicPatchLabel_(ptf.cyclicPatchLabel_),
165 initWallSf_(ptf.initWallSf_),
166 initCyclicSf_(ptf.initCyclicSf_),
167 nbrCyclicSf_(ptf.nbrCyclicSf_),
168 openFraction_(ptf.openFraction_),
169 openingTime_(ptf.openingTime_),
170 maxOpenFractionDelta_(ptf.maxOpenFractionDelta_),
172 minThresholdValue_(ptf.minThresholdValue_),
173 fBased_(ptf.fBased_),
174 baffleActivated_(ptf.baffleActivated_),
175 opening_(ptf.opening_)
186 fixedValueFvPatchVectorField::autoMap(m);
198 Info <<
"faceArea[active] "<< i <<
endl;
202 if (
patch().size() > 0)
205 initWallSf_ =
patch().patchSlice(areas);
207 patch().boundaryMesh()[cyclicPatchLabel_].patchSlice(areas);
214 ).neighbFvPatch().patch().patchSlice(areas);
225 fixedValueFvPatchVectorField::rmap(ptf, addr);
228 const vectorField& areas = patch().boundaryMesh().mesh().faceAreas();
229 initWallSf_ = patch().patchSlice(areas);
231 patch().boundaryMesh()[cyclicPatchLabel_].patchSlice(areas);
234 patch().boundaryMesh()
238 ).neighbFvPatch().patch().patchSlice(areas);
250 if (curTimeIndex_ != this->db().time().
timeIndex())
255 const fvPatch& cyclicPatch = patch().boundaryMesh()[cyclicPatchLabel_];
256 const labelUList& cyclicFaceCells = cyclicPatch.patch().faceCells();
257 const fvPatch& nbrPatch =
260 const labelUList& nbrFaceCells = nbrPatch.patch().faceCells();
262 scalar valueDiff = 0;
266 forAll(cyclicFaceCells, facei)
268 valueDiff +=
p[cyclicFaceCells[facei]]*
mag(initCyclicSf_[facei]);
269 area +=
mag(initCyclicSf_[facei]);
273 forAll(nbrFaceCells, facei)
275 valueDiff -=
p[nbrFaceCells[facei]]*
mag(initCyclicSf_[facei]);
280 valueDiff = valueDiff/(
area + VSMALL);
289 Info<<
"Force difference (threshold) = " << valueDiff
290 <<
"(" << minThresholdValue_ <<
")" <<
endl;
294 Info<<
"Area-averaged pressure difference (threshold) = "
295 << valueDiff <<
"(" << minThresholdValue_ <<
")" <<
endl;
299 if (
mag(valueDiff) >
mag(minThresholdValue_) || baffleActivated_)
306 this->db().time().deltaTValue()/openingTime_,
307 maxOpenFractionDelta_
311 baffleActivated_ =
true;
313 openFraction_ =
clamp(openFraction_, scalar(1
e-6), scalar(1 - 1
e-6));
317 Info<<
"Open fraction = " << openFraction_ <<
endl;
320 const scalar areaFraction =
322 opening_ ? openFraction_ : (1 - openFraction_)
331 initWallSf_ =
patch().Sf();
332 initCyclicSf_ =
patch().boundaryMesh()[cyclicPatchLabel_].Sf();
336 ).neighbFvPatch().Sf();
342 vectorField newSfw((1 - areaFraction)*initWallSf_);
345 Sfw[facei] = newSfw[facei];
349 const_cast<polyPatch&
>(
patch().patch()).areaFraction(1-areaFraction);
353 const_cast<vectorField&
>(cyclicPatch.Sf()) = areaFraction*initCyclicSf_;
354 const_cast<scalarField&
>(cyclicPatch.magSf()) =
mag(cyclicPatch.Sf());
359 const_cast<vectorField&
>(nbrPatch.Sf()) = areaFraction*nbrCyclicSf_;
363 curTimeIndex_ = this->db().time().timeIndex();
366 fixedValueFvPatchVectorField::updateCoeffs();
374 os.writeEntryIfDifferent<
word>(
"p",
"p", pName_);
375 os.writeEntry(
"cyclicPatch", cyclicPatchName_);
376 os.writeEntry(
"openingTime", openingTime_);
377 os.writeEntry(
"maxOpenFractionDelta", maxOpenFractionDelta_);
378 os.writeEntry(
"openFraction", openFraction_);
379 os.writeEntry(
"minThresholdValue", minThresholdValue_);
380 os.writeEntry(
"forceBased", fBased_);
381 os.writeEntry(
"opening", opening_);
Macros for easy insertion into run-time selection tables.
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
SubField< vector > subField
A simple container of IOobject preferences. Can also be used for general handling of read/no-read/rea...
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
static bool master(const label communicator=worldComm)
True if process corresponds to the master rank in the communicator.
This boundary condition is applied to the flow velocity, to simulate the opening or closure of a baff...
virtual void autoMap(const fvPatchFieldMapper &)
Map (and resize as needed) from self given a mapping object.
virtual void write(Ostream &) const
Write.
virtual void rmap(const fvPatchVectorField &, const labelList &)
Reverse map the given fvPatchField onto this fvPatchField.
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
activePressureForceBaffleVelocityFvPatchVectorField(const fvPatch &, const DimensionedField< vector, volMesh > &)
Construct from patch and internal field.
Addressing for all faces on surface of mesh. Can either be read from polyMesh or from triSurface....
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
A FieldMapper for finite-volume patch fields.
virtual void write(Ostream &) const
Write.
void writeValueEntry(Ostream &os) const
Write *this field as a "value" entry.
virtual void operator=(const UList< vector > &)
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
const polyPatch & patch() const noexcept
Return the polyPatch.
const scalarField & magSf() const
Return face area magnitudes, like the fvMesh::magSf() method.
const vectorField & Sf() const
Return face area vectors, like the fvMesh::Sf() method.
A patch is a list of labels that address the faces in the global face list.
tmp< scalarField > areaFraction(const pointField &points) const
Calculate the area fraction as the ratio of the stored face area and the area given by the face point...
const labelUList & faceCells() const
Return face-cell addressing.
Lookup type of boundary radiation properties.
A class for handling words, derived from Foam::string.
OBJstream os(runTime.globalPath()/outputName)
#define makePatchTypeField(PatchTypeField, typePatchTypeField)
Define a concrete fvPatchField type and add to run-time tables Example, (fvPatchScalarField,...
const wordList area
Standard area field types (scalar, vector, tensor, etc).
const std::string patch
OpenFOAM patch number as a std::string.
Type & refCast(U &obj)
A dynamic_cast (for references) to Type reference.
List< label > labelList
A List of labels.
GeometricField< scalar, fvPatchField, volMesh > volScalarField
messageStream Info
Information stream (stdout output on master, null elsewhere).
dimensionSet clamp(const dimensionSet &a, const dimensionSet &range)
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
Ostream & endl(Ostream &os)
Add newline and flush stream.
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
void reduce(T &value, BinaryOp bop, const int tag=UPstream::msgType(), const int communicator=UPstream::worldComm)
Reduce inplace (cf. MPI Allreduce).
label min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
Field< vector > vectorField
Specialisation of Field<T> for vector.
static constexpr const zero Zero
Global zero (0).
UList< label > labelUList
A UList of labels.
fvPatchField< vector > fvPatchVectorField
#define forAll(list, i)
Loop across all elements in list.