Initial commit of NavalHydro package from Wikki to the ShipHydroSIG
[ShipHydroSIG.git] / src / vofDynamicMesh / numericalBeach / numericalBeach.C
blob62828c72d47148fe340ea8b934ef77d9c7ca9a99
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright held by original author
6      \\/     M anipulation  |
7 -------------------------------------------------------------------------------
8 License
9     This file is part of OpenFOAM.
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 the
13     Free Software Foundation; either version 2 of the License, or (at your
14     option) any later version.
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.
21     You should have received a copy of the GNU General Public License
22     along with OpenFOAM; if not, write to the Free Software Foundation,
23     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 \*---------------------------------------------------------------------------*/
27 #include "numericalBeach.H"
28 #include "numericalBeachFvPatchField.H"
29 #include "volFields.H"
31 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
33 namespace Foam
36 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
38 numericalBeach::numericalBeach(volVectorField& U)
40     U_(U)
44 numericalBeach::~numericalBeach()
48 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
50 tmp<volScalarField> numericalBeach::damping() const
52     tmp<volScalarField> tDamping
53     (
54         new volScalarField
55         (
56             IOobject
57             (
58                 "damping",
59                 U_.db().time().timeName(),
60                 U_.mesh(),
61                 IOobject::NO_READ,
62                 IOobject::NO_WRITE
63             ),
64             U_.mesh(),
65             dimensionedScalar("zero", dimensionSet(0, 0, -1, 0, 0), 0.0)
66         )
67     );
69     volScalarField& damping = tDamping();
71     const volVectorField::GeometricBoundaryField& bvf = U_.boundaryField();
72     forAll(bvf, patchi)
73     {
74         if (isType<numericalBeachFvPatchField>(bvf[patchi]))
75         {
76             const numericalBeachFvPatchField& beach =
77                 dynamic_cast<const numericalBeachFvPatchField&> (bvf[patchi]);
79             damping = max(damping, beach.internalDamping());
80         }
81     }
83     return tDamping;
87 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
89 } // End namespace Foam
91 // ************************************************************************* //