31 void Foam::waveSuperposition::transformation
41 const scalar magG =
mag(g.value());
42 const vector gHat = g.value()/magG;
44 const vector dSurf = direction_ - gHat*(gHat & direction_);
45 const scalar magDSurf =
mag(dSurf);
46 const vector dSurfHat = direction_/magDSurf;
48 axes =
tensor(dSurfHat, - gHat ^ dSurfHat, - gHat);
52 xyz = axes & (p - origin_);
66 const vector2D d(
cos(waveAngles_[wavei]),
sin(waveAngles_[wavei]));
67 result += waveModels_[wavei].elevation(t, d.x()*speed_, d & xy);
70 return scale(xy)*result;
84 const vector2D d(
cos(waveAngles_[wavei]),
sin(waveAngles_[wavei]));
89 d &
zip(xyz.component(0), xyz.component(1)),
90 tmp<scalarField>(xyz.component(2))
95 waveModels_[wavei].velocity(t, d.x()*speed_, xz)
99 d.x()*uw.component(0),
100 d.y()*uw.component(0),
105 tmp<scalarField> s = scale(
zip(xyz.component(0), xyz.component(1)));
119 forAll(waveModels_, wavei)
121 const vector2D d(
cos(waveAngles_[wavei]),
sin(waveAngles_[wavei]));
126 d &
zip(xyz.component(0), xyz.component(1)),
127 tmp<scalarField>(xyz.component(2))
132 waveModels_[wavei].velocity(t, d.x()*speed_, xz)
134 result += waveModels_[wavei].pressure(t, d.x()*speed_, xz);
137 tmp<scalarField> s = scale(
zip(xyz.component(0), xyz.component(1)));
148 tmp<scalarField> tResult(
new scalarField(xy.size(), 1));
156 result[i] *= scale_->value(
x[i]);
160 if (crossScale_.valid())
165 result[i] *= crossScale_->value(
y[i]);
179 direction_(
vector(1, 0, 0)),
186 heightAboveWave_(false)
193 origin_(waves.origin_),
194 direction_(waves.direction_),
195 speed_(waves.speed_),
196 waveModels_(waves.waveModels_),
197 waveAngles_(waves.waveAngles_),
198 ramp_(waves.ramp_, false),
199 scale_(waves.scale_, false),
200 crossScale_(waves.crossScale_, false),
201 heightAboveWave_(waves.heightAboveWave_)
212 origin_(dict.
lookup(
"origin")),
213 direction_(dict.
lookup(
"direction")),
231 dict.
found(
"crossScale")
235 heightAboveWave_(dict.lookupOrDefault<
Switch>(
"heightAboveWave", false))
239 waveModels_.setSize(waveEntries.size());
240 waveAngles_.
setSize(waveEntries.size());
242 forAll(waveEntries, wavei)
244 const dictionary waveDict = waveEntries[wavei].dict();
272 transformation(p, axes, u, xyz);
276 - elevation(t,
zip(xyz.component(0), xyz.component(1)));
289 transformation(p, axes, u, xyz);
291 if (heightAboveWave_)
293 xyz.replace(2,
height(t, p));
296 return UMean(t) + (velocity(t, xyz) & axes);
309 transformation(p, axes, u, xyz);
311 axes =
tensor(- axes.
x(), - axes.
y(), axes.
z());
313 if (heightAboveWave_)
318 return UMean(t) + (velocity(t, xyz) & axes);
331 transformation(p, axes, u, xyz);
333 if (heightAboveWave_)
335 xyz.replace(2,
height(t, p));
338 return pressure(t, xyz);
358 forAll(waveModels_, wavei)
362 waveModels_[wavei].write(os);
369 ramp_->writeData(os);
373 scale_->writeData(os);
375 if (crossScale_.valid())
377 crossScale_->writeData(os);
379 if (heightAboveWave_)
tmp< vector2DField > zip(const tmp< scalarField > &x, const tmp< scalarField > &y)
Top level data entry class for use in dictionaries. Provides a mechanism to specify a variable as a c...
A wrapper around a list of wave models. Superimposes the modelled values of elevation and velocity...
bool found(const word &, bool recursive=false, bool patternMatch=true) const
Search dictionary for given keyword.
#define forAll(list, i)
Loop across all elements in list.
tmp< vectorField > UGas(const scalar t, const vectorField &p) const
Get the gas velocity at a given time and global positions.
Ostream & indent(Ostream &os)
Indent stream.
void write(Ostream &) const
Write.
Field< vector2D > vector2DField
Forward declarations of the specialisation of Field<T> for vector2D.
tmp< scalarField > pLiquid(const scalar t, const vectorField &p) const
Get the liquid pressure at a given time and global positions.
UniformDimensionedField< vector > uniformDimensionedVectorField
A list of keyword definitions, which are a keyword followed by any number of values (e...
void size(const label)
Override size to be inconsistent with allocated storage.
Vector2D< scalar > vector2D
vector2D obtained from generic Vector2D
~waveSuperposition()
Destructor.
A simple wrapper around bool so that it can be read as a word: true/false, on/off, yes/no, y/n, t/f, or none.
tmp< vectorField > ULiquid(const scalar t, const vectorField &p) const
Get the liquid velocity at a given time and global positions.
volVectorField vectorField(fieldObject, mesh)
Vector< scalar > vector
A scalar version of the templated Vector.
void replace(const direction, const Cmpt &)
const Type & lookupObject(const word &name) const
Lookup and return the object of the given Type.
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh >> &tdf1, const word &name, const dimensionSet &dimensions)
const word dictName() const
Return the local dictionary name (final part of scoped name)
tmp< scalarField > height(const scalar t, const vectorField &p) const
Get the height above the waves at a given time and global positions.
dimensionedScalar cos(const dimensionedScalar &ds)
tmp< scalarField > pGas(const scalar t, const vectorField &p) const
Get the gas pressure at a given time and global positions.
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
bool readScalar(const char *buf, doubleScalar &s)
Read whole of buf as a scalar. Return true if successful.
An Ostream is an abstract base class for all output systems (streams, files, token lists...
dimensionedScalar sin(const dimensionedScalar &ds)
Ostream & decrIndent(Ostream &os)
Decrement the indent level.
Ostream & writeKeyword(const keyType &)
Write the keyword followed by an appropriate indentation.
fileName::Type type(const fileName &, const bool followLink=true)
Return the file type: DIRECTORY or FILE.
void setSize(const label)
Reset size of List.
static autoPtr< waveModel > New(const objectRegistry &db, const dictionary &dict)
Select.
vector UMean(const scalar t) const
Get the mean flow velocity.
A class representing the concept of 0 used to avoid unnecessary manipulations for objects that are kn...
dimensioned< scalar > mag(const dimensioned< Type > &)
Field< vector > vectorField
Specialisation of Field<T> for vector.
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
A class for managing temporary objects.
Registry of regIOobjects.
Ostream & incrIndent(Ostream &os)
Increment the indent level.
Tensor< scalar > tensor
Tensor of scalars.
static const Vector< scalar > zero
static autoPtr< Function1< Type > > New(const word &entryName, const dictionary &dict)
Selector.
waveSuperposition(const objectRegistry &db)
Construct from a database.
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.