Go to the documentation of this file.
77 const scalar yMin = bb.
min().
y();
78 const scalar yMax = bb.
max().
y();
79 zSpan_ = bb.
max().
z() - bb.
min().
z();
82 xPaddle_.setSize(nPaddle_, 0);
83 yPaddle_.setSize(nPaddle_, 0);
85 const scalar paddleDy = (yMax - yMin)/scalar(nPaddle_);
86 for (label paddlei = 0; paddlei < nPaddle_; ++paddlei)
88 xPaddle_[paddlei] = xMid;
89 yPaddle_[paddlei] = paddlei*paddleDy + yMin + 0.5*paddleDy;
98 zMin_.setSize(patch_.size());
99 zMax_.setSize(patch_.size());
100 const faceList& faces = patch_.localFaces();
103 const face&
f = faces[facei];
104 const label nPoint =
f.size();
105 zMin_[facei] = CpLocal[
f[0]].z();
106 zMax_[facei] = CpLocal[
f[0]].z();
108 for (label fpi = 1; fpi < nPoint; ++fpi)
110 const label pointi =
f[fpi];
111 zMin_[facei] =
min(zMin_[facei], CpLocal[pointi].z());
112 zMax_[facei] =
max(zMax_[facei], CpLocal[pointi].z());
117 zMin0_ =
gMin(zMin_);
120 faceToPaddle_.setSize(patch_.size(), -1);
121 forAll(faceToPaddle_, facei)
123 faceToPaddle_[facei] = floor((CfLocal[facei].
y() - yMin)/paddleDy);
132 auto& level = tlevel.ref();
137 const scalarField alphac(alphap.patchInternalField());
145 label paddlei = faceToPaddle_[facei];
146 paddleMagSf[paddlei] += magSf[facei];
147 paddleWettedMagSf[paddlei] += magSf[facei]*alphac[facei];
150 forAll(paddleMagSf, paddlei)
155 paddleWettedMagSf[paddlei]*zSpan_
156 /(paddleMagSf[paddlei] + ROOTVSMALL);
167 const label paddlei = faceToPaddle_[facei];
168 const scalar paddleCalc = level[paddlei];
170 const scalar zMin0 = zMin_[facei] - zMin0_;
171 const scalar zMax0 = zMax_[facei] - zMin0_;
173 if (zMax0 < paddleCalc)
177 else if (zMin0 > paddleCalc)
183 scalar dz = paddleCalc - zMin0;
184 alpha_[facei] = dz/(zMax0 - zMin0);
198 const label paddlei = faceToPaddle_[facei];
199 const scalar paddleCalc = level[paddlei];
200 const scalar paddleHeight =
min(paddleCalc, waterDepthRef_);
201 const scalar zMin = zMin_[facei] - zMin0_;
202 const scalar zMax = zMax_[facei] - zMin0_;
207 if (zMax < paddleHeight)
209 z = z_[facei] - zMin0_;
211 else if (zMin > paddleCalc)
217 if (paddleCalc < waterDepthRef_)
219 if ((zMax > paddleCalc) && (zMin < paddleCalc))
221 scalar dz = paddleCalc - zMin;
222 fraction = dz/(zMax - zMin);
223 z = z_[facei] - zMin0_;
228 if (zMax < paddleCalc)
232 else if ((zMax > paddleCalc) && (zMin < paddleCalc))
234 scalar dz = paddleCalc - zMin;
235 fraction = dz/(zMax - zMin);
257 modelName(
patch.name()),
282 activeAbsorption_(
false),
305 readIfPresent(
"U", UName_);
306 readIfPresent(
"alpha", alphaName_);
308 readEntry(
"nPaddle", nPaddle_);
312 <<
"Number of paddles must be greater than zero. Supplied"
313 <<
" value nPaddles = " << nPaddle_
317 readIfPresent(
"initialDepth", initialDepth_);
320 initialiseGeometry();
323 if (!readIfPresent(
"waterDepthRef", waterDepthRef_))
325 scalar waterDepth = 0;
326 if (readIfPresent(
"waterDepth", waterDepth))
328 waterDepthRef_ = waterDepth;
335 waterDepthRef_ = level.first();
340 waterDepthRef_ += SMALL;
343 add(
"waterDepthRef", waterDepthRef_);
352 if (mesh_.time().timeIndex() != currTimeIndex_)
354 Info<<
"Updating " <<
type() <<
" wave model for patch "
355 << patch_.name() <<
endl;
358 const scalar tCoeff = timeCoeff(t);
370 setLevel(t, tCoeff, calculatedLevel);
373 setVelocity(t, tCoeff, calculatedLevel);
376 setAlpha(calculatedLevel);
379 if (activeAbsorption_)
385 const label paddlei = faceToPaddle_[facei];
387 if (zMin_[facei] - zMin0_ < activeLevel[paddlei])
390 (calculatedLevel[paddlei] - activeLevel[paddlei])
391 *
sqrt(
mag(g_)/activeLevel[paddlei]);
393 U_[facei].x() += UCorr;
405 currTimeIndex_ = mesh_.time().timeIndex();
424 os <<
"Wave model: patch " << patch_.
name() <<
nl
425 <<
" Type : " <<
type() <<
nl
426 <<
" Velocity field name : " << UName_ <<
nl
427 <<
" Phase fraction field name : " << alphaName_ <<
nl
428 <<
" Transformation from local to global system : " << Rlg_ <<
nl
429 <<
" Number of paddles: " << nPaddle_ <<
nl
430 <<
" Reference water depth : " << waterDepthRef_ <<
nl
431 <<
" Active absorption: " << activeAbsorption_ <<
nl;
IOdictionary is derived from dictionary and IOobject to give the dictionary automatic IO functionalit...
Defines the attributes of an object for which implicit objectRegistry management is supported,...
const Cmpt & x() const
Access to the vector x component.
A class for handling words, derived from Foam::string.
virtual void initialiseGeometry()
Initialise.
A class for managing temporary objects.
static constexpr const zero Zero
Global zero (0)
Type gAverage(const FieldField< Field, Type > &f)
Different types of constants.
defineRunTimeSelectionTable(reactionRateFlameArea, dictionary)
const dimensionedScalar alpha
Fine-structure constant: default SI units: [].
virtual const scalarField & alpha() const
Return the latest wave indicator field prediction.
const word dictName("blockMeshDict")
waveModel(const dictionary &dict, const fvMesh &mesh, const polyPatch &patch, const bool readFields=true)
Constructor.
Ostream & endl(Ostream &os)
Add newline and flush stream.
const point & max() const
Maximum describing the bounding box.
InfoProxy< IOobject > info() const
Return info proxy.
const Cmpt & z() const
Access to the vector z component.
label min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
const point & min() const
Minimum describing the bounding box.
virtual tmp< scalarField > waterLevel() const
Water level.
#define forAll(list, i)
Loop across all elements in list.
virtual const vectorField & U() const
Return the latest wave velocity prediction.
virtual word timeName() const
Return current time name.
void reduce(const List< UPstream::commsStruct > &comms, T &Value, const BinaryOp &bop, const int tag, const label comm)
virtual void setAlpha(const scalarField &level)
Set the alpha field based on the water level.
messageStream Info
Information stream (uses stdout - output is on the master only)
A patch is a list of labels that address the faces in the global face list.
static word modelName(const word &patchName)
Utility function to construct the model name.
virtual void setPaddlePropeties(const scalarField &level, const label facei, scalar &fraction, scalar &z) const
Set the paddle coverage fraction and reference height.
virtual const fileName & name() const
Return the name of the stream.
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
word dictName() const
The local dictionary name (final part of scoped name)
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
void add(FieldField< Field1, typename typeOfSum< Type1, Type2 >::type > &f, const FieldField< Field1, Type1 > &f1, const FieldField< Field2, Type2 > &f2)
Mesh data needed to do the Finite Volume discretisation.
tmp< Field< cmptType > > component(const direction) const
Return a component field of the field.
errorManipArg< error, int > exit(error &err, const int errNo=1)
void readFields(const typename GeoFieldType::Mesh &mesh, const IOobjectList &objects, const wordHashSet &selectedFields, LIFOStack< regIOobject * > &storedObjects)
Read the selected GeometricFields of the templated type.
virtual bool readDict(const dictionary &overrideDict)
Read from dictionary.
VectorSpace< Form, Cmpt, Ncmpts > normalised(const VectorSpace< Form, Cmpt, Ncmpts > &vs)
const Cmpt & y() const
Access to the vector y component.
const std::string patch
OpenFOAM patch number as a std::string.
dimensionedScalar sqrt(const dimensionedScalar &ds)
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
fileName::Type type(const fileName &name, const bool followLink=true)
Return the file type: DIRECTORY or FILE, normally following symbolic links.
static tmp< T > New(Args &&... args)
Construct tmp of T with forwarding arguments.
const volScalarField & Cp
A bounding box defined in terms of min/max extrema points.
static const Vector< scalar > zero
A face is a list of labels corresponding to mesh vertices.
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Type gMin(const FieldField< Field, Type > &f)
virtual void correct(const scalar t)
Correct the model for time, t[s].
defineTypeNameAndDebug(combustionModel, 0)
Tensor< scalar > tensor
Tensor of scalars, i.e. Tensor<scalar>.
static const gravity & New(const Time &runTime)
Construct on Time.