75 const scalar
xMin = bb.min().x();
76 const scalar
xMax = bb.max().x();
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;
93 const vectorField CfLocal(Rgl_ & patch_.faceCentres());
97 zMin_.setSize(patch_.size());
98 zMax_.setSize(patch_.size());
99 const faceList& faces = patch_.localFaces();
102 const face&
f = faces[facei];
103 const label nPoint =
f.size();
104 zMin_[facei] = CpLocal[
f[0]].z();
105 zMax_[facei] = CpLocal[
f[0]].z();
107 for (label fpi = 1; fpi < nPoint; ++fpi)
109 const label pointi =
f[fpi];
110 zMin_[facei] =
min(zMin_[facei], CpLocal[pointi].z());
111 zMax_[facei] =
max(zMax_[facei], CpLocal[pointi].z());
116 zMin0_ =
gMin(zMin_);
119 faceToPaddle_.setSize(patch_.size(), -1);
122 faceToPaddle_[facei] = floor((CfLocal[facei].
y() - yMin)/paddleDy);
131 auto& level = tlevel.ref();
136 const scalarField alphac(alphap.patchInternalField());
144 label paddlei = faceToPaddle_[facei];
145 paddleMagSf[paddlei] += magSf[facei];
146 paddleWettedMagSf[paddlei] += magSf[facei]*alphac[facei];
149 forAll(paddleMagSf, paddlei)
151 reduce(paddleMagSf[paddlei], sumOp<scalar>());
152 reduce(paddleWettedMagSf[paddlei], sumOp<scalar>());
154 paddleWettedMagSf[paddlei]*zSpan_
155 /(paddleMagSf[paddlei] + ROOTVSMALL);
166 const label paddlei = faceToPaddle_[facei];
167 const scalar paddleCalc = level[paddlei];
169 const scalar zMin0 = zMin_[facei] - zMin0_;
170 const scalar zMax0 = zMax_[facei] - zMin0_;
172 if (zMax0 < paddleCalc)
176 else if (zMin0 > paddleCalc)
182 scalar dz = paddleCalc - zMin0;
183 alpha_[facei] = dz/(zMax0 - zMin0);
197 const label paddlei = faceToPaddle_[facei];
198 const scalar paddleCalc = level[paddlei];
199 const scalar paddleHeight =
min(paddleCalc, waterDepthRef_);
200 const scalar zMin = zMin_[facei] - zMin0_;
201 const scalar zMax = zMax_[facei] - zMin0_;
206 if (zMax < paddleHeight)
208 z = z_[facei] - zMin0_;
210 else if (zMin > paddleCalc)
216 if (paddleCalc < waterDepthRef_)
218 if ((zMax > paddleCalc) && (zMin < paddleCalc))
220 scalar dz = paddleCalc - zMin;
221 fraction = dz/(zMax - zMin);
222 z = z_[facei] - zMin0_;
227 if (zMax < paddleCalc)
231 else if ((zMax > paddleCalc) && (zMin < paddleCalc))
233 scalar dz = paddleCalc - zMin;
234 fraction = dz/(zMax - zMin);
246 const dictionary&
dict,
248 const polyPatch&
patch,
266 g_(meshObjects::gravity::
New(
mesh.time()).value()),
281 activeAbsorption_(false),
307 readEntry(
"nPaddle", nPaddle_);
311 <<
"Number of paddles must be greater than zero. Supplied" 312 <<
" value nPaddles = " << nPaddle_
319 initialiseGeometry();
324 scalar waterDepth = 0;
327 waterDepthRef_ = waterDepth;
334 waterDepthRef_ = level.first();
339 waterDepthRef_ += SMALL;
342 add(
"waterDepthRef", waterDepthRef_);
351 if (mesh_.time().timeIndex() != currTimeIndex_)
353 Info<<
"Updating " <<
type() <<
" wave model for patch " 354 << patch_.name() <<
endl;
357 const scalar tCoeff = timeCoeff(t);
369 setLevel(t, tCoeff, calculatedLevel);
372 setVelocity(t, tCoeff, calculatedLevel);
375 setAlpha(calculatedLevel);
378 if (activeAbsorption_)
384 const label paddlei = faceToPaddle_[facei];
386 if (zMin_[facei] - zMin0_ < activeLevel[paddlei])
389 (calculatedLevel[paddlei] - activeLevel[paddlei])
390 *
sqrt(
mag(g_)/activeLevel[paddlei]);
392 U_[facei].x() += UCorr;
404 currTimeIndex_ = mesh_.time().timeIndex();
423 os <<
"Wave model: patch " << patch_.
name() <<
nl 424 <<
" Type : " <<
type() <<
nl 425 <<
" Velocity field name : " << UName_ <<
nl 426 <<
" Phase fraction field name : " << alphaName_ <<
nl 427 <<
" Transformation from local to global system : " << Rlg_ <<
nl 428 <<
" Number of paddles: " << nPaddle_ <<
nl 429 <<
" Reference water depth : " << waterDepthRef_ <<
nl 430 <<
" Active absorption: " << activeAbsorption_ <<
nl;
Different types of constants.
List< scalar > scalarList
List of scalar.
word dictName() const
The local dictionary name (final part of scoped name)
virtual const scalarField & alpha() const
Return the latest wave indicator field prediction.
virtual void initialiseGeometry()
Initialise.
virtual void setAlpha(const scalarField &level)
Set the alpha field based on the water level.
errorManipArg< error, int > exit(error &err, const int errNo=1)
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
virtual void correct(const scalar t)
Correct the model for time, t[s].
Type gMin(const FieldField< Field, Type > &f)
virtual const fileName & name() const override
Read/write access to the name of the stream.
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
virtual tmp< scalarField > waterLevel() const
Water level.
constexpr char nl
The newline '\n' character (0x0a)
const word dictName("faMeshDefinition")
dimensionedScalar sqrt(const dimensionedScalar &ds)
Ostream & endl(Ostream &os)
Add newline and flush stream.
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh >> &tf1, const word &name, const dimensionSet &dimensions, const bool initCopy=false)
Global function forwards to reuseTmpDimensionedField::New.
A bounding box defined in terms of min/max extrema points.
quaternion normalised(const quaternion &q)
Return the normalised (unit) quaternion of the given quaternion.
static word modelName(const word &patchName)
Utility function to construct the model name.
void reduce(T &value, [[maybe_unused]] BinaryOp bop, [[maybe_unused]] const int tag=UPstream::msgType(), const int communicator=UPstream::worldComm)
Reduce inplace (cf. MPI Allreduce)
#define forAll(list, i)
Loop across all elements in list.
GeometricField< scalar, fvPatchField, volMesh > volScalarField
List< face > faceList
List of faces.
fileName::Type type(const fileName &name, const bool followLink=true)
Return the file type: DIRECTORY or FILE, normally following symbolic links.
virtual const vectorField & U() const
Return the latest wave velocity prediction.
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
Base class for waveModels.
static const Identity< scalar > I
void readFields(const typename GeoFieldType::Mesh &mesh, const IOobjectList &objects, const NameMatchPredicate &selectedFields, DynamicList< regIOobject *> &storedObjects)
Read the selected GeometricFields of the templated type and store on the objectRegistry.
fvPatchField< scalar > fvPatchScalarField
A class for handling words, derived from Foam::string.
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
Reading is optional [identical to LAZY_READ].
static tmp< T > New(Args &&... args)
Construct tmp with forwarding arguments.
label min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
InfoProxy< IOobject > info() const noexcept
Return info proxy, for printing information to a stream.
tmp< Field< cmptType > > component(const direction) const
Return a component field of the field.
An Ostream is an abstract base class for all output systems (streams, files, token lists...
void add(FieldField< Field1, typename typeOfSum< Type1, Type2 >::type > &f, const FieldField< Field1, Type1 > &f1, const FieldField< Field2, Type2 > &f2)
A Vector of values with scalar precision, where scalar is float/double depending on the compilation f...
defineRunTimeSelectionTable(reactionRateFlameArea, dictionary)
const volScalarField & Cp
Type gAverage(const FieldField< Field, Type > &f, const label comm)
The global arithmetic average of a FieldField.
OBJstream os(runTime.globalPath()/outputName)
defineTypeNameAndDebug(combustionModel, 0)
virtual void setPaddlePropeties(const scalarField &level, const label facei, scalar &fraction, scalar &z) const
Set the paddle coverage fraction and reference height.
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
meshDefDict readIfPresent("polyMeshPatches", polyPatchNames)
const std::string patch
OpenFOAM patch number as a std::string.
messageStream Info
Information stream (stdout output on master, null elsewhere)
virtual bool readDict(const dictionary &overrideDict)
Read from dictionary.
Field< vector > vectorField
Specialisation of Field<T> for vector.
A class for managing temporary objects.
const dimensionedScalar alpha
Fine-structure constant: default SI units: [].
IOerror FatalIOError
Error stream (stdout output on all processes), with additional 'FOAM FATAL IO ERROR' header text and ...
static constexpr const zero Zero
Global zero (0)
waveModel(const dictionary &dict, const fvMesh &mesh, const polyPatch &patch, const bool readFields=true)
Constructor.