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()),
267 g_(meshObjects::gravity::
New(
mesh.time()).value()),
282 activeAbsorption_(false),
283 U_(patch.size(),
Zero),
284 alpha_(patch.size(),
Zero)
300 IOdictionary::regIOobject::read();
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;
tmp< Field< cmptType > > component(const direction) const
Return a component field of the field.
const Boundary & boundaryField() const
Return const-reference to the boundary field.
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,...
virtual const fileName & name() const
Read/write access to the name of the stream.
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
virtual void correct()
Solve the turbulence equations and correct the turbulence viscosity.
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
static autoPtr< Time > New()
Construct (dummy) Time - no functionObjects or libraries.
T & first()
Return the first element of the list.
void size(const label n)
Older name for setAddressableSize.
const Cmpt & z() const
Access to the vector z component.
const Cmpt & y() const
Access to the vector y component.
const Cmpt & x() const
Access to the vector x component.
A bounding box defined in terms of min/max extrema points.
const point & min() const
Minimum describing the bounding box.
const point & max() const
Maximum describing the bounding box.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
InfoProxy< ensightCells > info() const
Return info proxy.
A face is a list of labels corresponding to mesh vertices.
Mesh data needed to do the Finite Volume discretisation.
A patch is a list of labels that address the faces in the global face list.
const word & modelName() const
Return const access to the name of the sub-model.
A class for managing temporary objects.
Base class for waveModels.
virtual void initialiseGeometry()
Initialise.
virtual const scalarField & alpha() const
Return the latest wave indicator field prediction.
virtual const vectorField & U() const
Return the latest wave velocity prediction.
virtual void setPaddlePropeties(const scalarField &level, const label facei, scalar &fraction, scalar &z) const
Set the paddle coverage fraction and reference height.
static const word dictName
Dictionary name.
virtual tmp< scalarField > waterLevel() const
Water level.
virtual void setAlpha(const scalarField &level)
Set the alpha field based on the water level.
virtual bool readDict(const dictionary &overrideDict)
Read from dictionary.
A class for handling words, derived from Foam::string.
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
const volScalarField & Cp
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
OBJstream os(runTime.globalPath()/outputName)
Different types of constants.
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
quaternion normalised(const quaternion &q)
Return the normalised (unit) quaternion of the given quaternion.
messageStream Info
Information stream (stdout output on master, null elsewhere)
static const Identity< scalar > I
void readFields(const typename GeoFieldType::Mesh &mesh, const IOobjectList &objects, const wordHashSet &selectedFields, LIFOStack< regIOobject * > &storedObjects)
Read the selected GeometricFields of the templated type.
fileName::Type type(const fileName &name, const bool followLink=true)
Return the file type: DIRECTORY or FILE, normally following symbolic links.
Ostream & endl(Ostream &os)
Add newline and flush stream.
dimensionedScalar sqrt(const dimensionedScalar &ds)
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
void add(FieldField< Field1, typename typeOfSum< Type1, Type2 >::type > &f, const FieldField< Field1, Type1 > &f1, const FieldField< Field2, Type2 > &f2)
void reduce(const List< UPstream::commsStruct > &comms, T &value, const BinaryOp &bop, const int tag, const label comm)
label min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
Type gAverage(const FieldField< Field, Type > &f)
static constexpr const zero Zero
Global zero (0)
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh > > &tdf1, const word &name, const dimensionSet &dimensions)
Global function forwards to reuseTmpDimensionedField::New.
Type gMin(const FieldField< Field, Type > &f)
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
errorManipArg< error, int > exit(error &err, const int errNo=1)
constexpr char nl
The newline '\n' character (0x0a)
#define defineRunTimeSelectionTable(baseType, argNames)
Define run-time selection table.
#define forAll(list, i)
Loop across all elements in list.
A non-counting (dummy) refCount.
propsDict readIfPresent("fields", acceptFields)