waveForcing.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2022-2023 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 Class
25  Foam::fv::waveForcing
26 
27 Description
28  This fvModel applies forcing to the liquid phase-fraction field and all
29  components of the vector field to relax the fields towards those
30  calculated from the current wave distribution.
31 
32  The forcing force coefficient \f$\lambda\f$ should be set based on the
33  desired level of forcing and the residence time the waves through the
34  forcing zone. For example, if waves moving at 2 [m/s] are travelling
35  through a forcing zone 8 [m] in length, then the residence time is 4 [s]. If
36  it is deemed necessary to force for 5 time-scales, then \f$\lambda\f$ should
37  be set to equal 5/(4 [s]) = 1.2 [1/s].
38 
39 Usage
40  Example usage:
41  \verbatim
42  waveForcing1
43  {
44  type waveForcing;
45 
46  libs ("libwaves.so");
47 
48  liquidPhase water;
49 
50  // Define the line along which to apply the graduation
51  origin (600 0 0);
52  direction (-1 0 0);
53 
54  // // Or, define multiple lines
55  // origins ((600 0 0) (600 -300 0) (600 300 0));
56  // directions ((-1 0 0) (0 1 0) (0 -1 0));
57 
58  scale
59  {
60  type halfCosineRamp;
61  start 0;
62  duration 300;
63  }
64 
65  lambda 0.5; // Forcing coefficient
66 
67  // lambda 2; // Optional boundary forcing coefficient
68  // Useful when wave BCs are specified
69  // without mean flow
70  }
71  \endverbatim
72 
73 See also
74  Foam::fv::forcing
75 
76 SourceFiles
77  waveForcing.C
78 
79 \*---------------------------------------------------------------------------*/
80 
81 #ifndef waveForcing_H
82 #define waveForcing_H
83 
84 #include "forcing.H"
85 #include "waveSuperposition.H"
86 
87 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
88 
89 namespace Foam
90 {
91 namespace fv
92 {
93 
94 /*---------------------------------------------------------------------------*\
95  Class waveForcing Declaration
96 \*---------------------------------------------------------------------------*/
97 
98 class waveForcing
99 :
100  public forcing
101 {
102  // Private Data
103 
104  //- Reference to the waves
105  const waveSuperposition& waves_;
106 
107  //- Name of the liquid phase
108  const word liquidPhaseName_;
109 
110  //- Name of the liquid phase-fraction field
111  const word alphaName_;
112 
113  //- Name of the velocity field
114  const word UName_;
115 
116  //- Phase-fraction field calculated from the current wave form
117  tmp<volScalarField::Internal> alphaWaves_;
118 
119  //- Velocity field calculated from the current wave form
121 
122  //- Forcing coefficient scale field
124 
125 
126 public:
127 
128  //- Runtime type information
129  TypeName("waveForcing");
130 
131 
132  // Constructors
133 
134  //- Construct from components
136  (
137  const word& name,
138  const word& modelType,
139  const fvMesh& mesh,
140  const dictionary& dict
141  );
142 
143 
144  //- Destructor
145  virtual ~waveForcing()
146  {}
147 
148 
149  // Member Functions
150 
151  // Checks
152 
153  //- Return the list of fields for which the fvModel adds source term
154  // to the transport equation
155  virtual wordList addSupFields() const;
156 
157 
158  // Add explicit and implicit contributions
159 
160  //- Source term to VoF phase-fraction equation
161  virtual void addSup
162  (
163  fvMatrix<scalar>& eqn,
164  const word& fieldName
165  ) const;
166 
167  //- Source term to momentum equation
168  virtual void addSup
169  (
170  const volScalarField& rho,
171  fvMatrix<vector>& eqn,
172  const word& fieldName
173  ) const;
174 
175 
176  // Mesh changes
177 
178  //- Update for mesh motion
179  virtual bool movePoints();
180 
181  //- Update topology using the given map
182  virtual void topoChange(const polyTopoChangeMap&);
183 
184  //- Update from another mesh using the given map
185  virtual void mapMesh(const polyMeshMap&);
186 
187  //- Redistribute or update using the given distribution map
188  virtual void distribute(const polyDistributionMap&);
189 
190 
191  //- Correct the wave forcing coefficients
192  virtual void correct();
193 };
194 
195 
196 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
197 
198 } // End namespace fv
199 } // End namespace Foam
200 
201 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
202 
203 #endif
204 
205 // ************************************************************************* //
Generic GeometricField class.
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:160
A special matrix type and solver, designed for finite volume solutions of scalar equations....
Definition: fvMatrix.H:118
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:101
const fvMesh & mesh() const
Return const access to the mesh database.
Definition: fvModelI.H:34
const word & name() const
Return const access to the source name.
Definition: fvModelI.H:28
Base fvModel for forcing functions.
Definition: forcing.H:59
This fvModel applies forcing to the liquid phase-fraction field and all components of the vector fiel...
Definition: waveForcing.H:100
virtual bool movePoints()
Update for mesh motion.
Definition: waveForcing.C:116
virtual wordList addSupFields() const
Return the list of fields for which the fvModel adds source term.
Definition: waveForcing.C:68
virtual void correct()
Correct the wave forcing coefficients.
Definition: waveForcing.C:141
virtual void addSup(fvMatrix< scalar > &eqn, const word &fieldName) const
Source term to VoF phase-fraction equation.
Definition: waveForcing.C:75
virtual void topoChange(const polyTopoChangeMap &)
Update topology using the given map.
Definition: waveForcing.C:123
virtual void distribute(const polyDistributionMap &)
Redistribute or update using the given distribution map.
Definition: waveForcing.C:135
virtual ~waveForcing()
Destructor.
Definition: waveForcing.H:144
virtual void mapMesh(const polyMeshMap &)
Update from another mesh using the given map.
Definition: waveForcing.C:129
TypeName("waveForcing")
Runtime type information.
waveForcing(const word &name, const word &modelType, const fvMesh &mesh, const dictionary &dict)
Construct from components.
Definition: waveForcing.C:50
Class containing mesh-to-mesh mapping information after a mesh distribution where we send parts of me...
Class containing mesh-to-mesh mapping information.
Definition: polyMeshMap.H:51
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
A class for managing temporary objects.
Definition: tmp.H:55
A wrapper around a list of wave models. Superimposes the modelled values of elevation and velocity....
A class for handling words, derived from string.
Definition: word.H:62
Namespace for OpenFOAM.
labelList fv(nPoints)
dictionary dict