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;
95 z_ = CfLocal.component(2);
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);
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)
152 reduce(paddleMagSf[paddlei], sumOp<scalar>());
153 reduce(paddleWettedMagSf[paddlei], sumOp<scalar>());
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);
247 const dictionary&
dict,
249 const polyPatch&
patch,
267 g_(meshObjects::gravity::
New(
mesh.time()).value()),
282 activeAbsorption_(false),
308 readEntry(
"nPaddle", nPaddle_);
312 <<
"Number of paddles must be greater than zero. Supplied" 313 <<
" value nPaddles = " << nPaddle_
320 initialiseGeometry();
325 scalar waterDepth = 0;
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;
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.
#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.
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
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.
Type gAverage(const FieldField< Field, Type > &f)
meshDefDict readIfPresent("polyMeshPatches", polyPatchNames)
const std::string patch
OpenFOAM patch number as a std::string.
void reduce(const List< UPstream::commsStruct > &comms, T &value, const BinaryOp &bop, const int tag, const label comm)
Reduce inplace (cf. MPI Allreduce) using specified communication schedule.
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.