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")),
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();
119 nbrCyclicSf_ = refCast<const cyclicFvPatch>
121 p.boundaryMesh()[cyclicPatchLabel_],
123 ).neighbFvPatch().Sf();
126 dict.readIfPresent(
"p", pName_);
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);
208 nbrCyclicSf_ = refCast<const cyclicFvPatch>
210 patch().boundaryMesh()
214 ).neighbFvPatch().patch().patchSlice(areas);
225 fixedValueFvPatchVectorField::rmap(ptf, addr);
229 initWallSf_ =
patch().patchSlice(areas);
231 patch().boundaryMesh()[cyclicPatchLabel_].patchSlice(areas);
232 nbrCyclicSf_ = refCast<const cyclicFvPatch>
234 patch().boundaryMesh()
238 ).neighbFvPatch().patch().patchSlice(areas);
250 if (curTimeIndex_ != this->db().time().
timeIndex())
255 const fvPatch& cyclicPatch =
patch().boundaryMesh()[cyclicPatchLabel_];
256 const labelList& cyclicFaceCells = cyclicPatch.patch().faceCells();
257 const fvPatch& nbrPatch =
258 refCast<const cyclicFvPatch>(cyclicPatch).neighbFvPatch();
260 const labelList& 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);
283 reduce(valueDiff, sumOp<scalar>());
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_)
325 if (
patch().boundaryMesh().mesh().moving())
331 initWallSf_ =
patch().Sf();
332 initCyclicSf_ =
patch().boundaryMesh()[cyclicPatchLabel_].Sf();
333 nbrCyclicSf_ = refCast<const cyclicFvPatch>
335 patch().boundaryMesh()[cyclicPatchLabel_]
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());
355 const_cast<polyPatch&
>(cyclicPatch.patch()).areaFraction(areaFraction);
359 const_cast<vectorField&
>(nbrPatch.Sf()) = areaFraction*nbrCyclicSf_;
361 const_cast<polyPatch&
>(nbrPatch.patch()).areaFraction(areaFraction);
363 curTimeIndex_ = this->db().time().timeIndex();
366 fixedValueFvPatchVectorField::updateCoeffs();
377 os.
writeEntry(
"maxOpenFractionDelta", maxOpenFractionDelta_);
393 activePressureForceBaffleVelocityFvPatchVectorField
List< ReturnType > get(const UPtrList< T > &list, const AccessOp &aop)
List of values generated by applying the access operation to each list item.
This boundary condition is applied to the flow velocity, to simulate the opening or closure of a baff...
fvPatchField< vector > fvPatchVectorField
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
A list of keyword definitions, which are a keyword followed by a number of values (eg...
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
Addressing for all faces on surface of mesh. Can either be read from polyMesh or from triSurface...
Ostream & endl(Ostream &os)
Add newline and flush stream.
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Ostream & writeEntry(const keyType &key, const T &value)
Write a keyword/value entry.
void writeValueEntry(Ostream &os) const
Write *this field as a "value" entry.
virtual void write(Ostream &) const
Write.
Lookup type of boundary radiation properties.
Macros for easy insertion into run-time selection tables.
#define forAll(list, i)
Loop across all elements in list.
GeometricField< scalar, fvPatchField, volMesh > volScalarField
virtual void write(Ostream &) const
Write.
const dimensionedScalar e
Elementary charge.
const wordList area
Standard area field types (scalar, vector, tensor, etc)
A class for handling words, derived from Foam::string.
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
activePressureForceBaffleVelocityFvPatchVectorField(const fvPatch &, const DimensionedField< vector, volMesh > &)
Construct from patch and internal field.
A FieldMapper for finite-volume patch fields.
virtual void autoMap(const fvPatchFieldMapper &)
Map (and resize as needed) from self given a mapping object.
label min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
Ostream & writeEntryIfDifferent(const word &key, const T &value1, const T &value2)
Write a keyword/value entry only when the two values differ.
An Ostream is an abstract base class for all output systems (streams, files, token lists...
OBJstream os(runTime.globalPath()/outputName)
virtual void operator=(const UList< vector > &)
static bool master(const label communicator=worldComm)
True if process corresponds to the master rank in the communicator.
A simple container of IOobject preferences. Can also be used for general handling of read/no-read/rea...
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
const std::string patch
OpenFOAM patch number as a std::string.
messageStream Info
Information stream (stdout output on master, null elsewhere)
SubField< vector > subField
Declare type of subField.
Field< vector > vectorField
Specialisation of Field<T> for vector.
List< label > labelList
A List of labels.
makePatchTypeField(fvPatchScalarField, atmBoundaryLayerInletEpsilonFvPatchScalarField)
virtual void rmap(const fvPatchVectorField &, const labelList &)
Reverse map the given fvPatchField onto this fvPatchField.
void reduce(T &value, const BinaryOp &bop, const int tag=UPstream::msgType(), const label comm=UPstream::worldComm)
Reduce inplace (cf. MPI Allreduce) using linear/tree communication schedule.
dimensionSet clamp(const dimensionSet &a, const dimensionSet &range)
static constexpr const zero Zero
Global zero (0)