Forward compatibility: flex
[foam-extend-3.2.git] / src / immersedBoundary / immersedBoundaryDynamicMesh / movingImmersedBoundary / movingImmersedBoundary.C
blob4aac168966894bdad41ede85bc46c0107ad20849
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | foam-extend: Open Source CFD
4    \\    /   O peration     |
5     \\  /    A nd           | For copyright notice see file Copyright
6      \\/     M anipulation  |
7 -------------------------------------------------------------------------------
8 License
9     This file is part of foam-extend.
11     foam-extend 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 3 of the License, or (at your
14     option) any later version.
16     foam-extend is distributed in the hope that it will be useful, but
17     WITHOUT ANY WARRANTY; without even the implied warranty of
18     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
19     General Public License for more details.
21     You should have received a copy of the GNU General Public License
22     along with foam-extend.  If not, see <http://www.gnu.org/licenses/>.
24 \*---------------------------------------------------------------------------*/
26 #include "movingImmersedBoundary.H"
27 #include "immersedBoundaryPolyPatch.H"
28 #include "transformField.H"
30 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
32 Foam::movingImmersedBoundary::movingImmersedBoundary
34     const word& name,
35     const fvMesh& mesh,
36     const dictionary& dict
39     name_(name),
40     mesh_(mesh),
41     sbmfPtr_(solidBodyMotionFunction::New(dict, mesh.time())),
42     refIbSurface_
43     (
44         IOobject
45         (
46             name  + ".ftr",
47             mesh.time().constant(),      // instance
48             "triSurface",                // local
49             mesh,                        // registry
50             IOobject::MUST_READ,
51             IOobject::NO_WRITE
52         )
53     )
57 // * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
59 Foam::movingImmersedBoundary::~movingImmersedBoundary()
63 // * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * * //
65 void Foam::movingImmersedBoundary::movePoints() const
67     // Get ibMesh from patch
68     const label patchID = mesh().boundaryMesh().findPatchID(name());
70     if (patchID < 0)
71     {
72         FatalErrorIn
73         (
74             "void movingImmersedBoundary::movePoints() const"
75         )   << "Patch " << name() << " not found.  Available patch names: "
76             << mesh().boundaryMesh().names()
77             << abort(FatalError);
78     }
80     // Get non-const reference to velocity field
81     volVectorField& U = const_cast<volVectorField&>
82     (
83         mesh().lookupObject<volVectorField>("U")
84     );
86     // Get non-const reference to patch field
87     immersedBoundaryFvPatchVectorField& ibPatchField =
88         refCast<immersedBoundaryFvPatchVectorField>
89         (
90             U.boundaryField()[patchID]
91         );
94     const immersedBoundaryPolyPatch& cibPatch =
95         refCast<const immersedBoundaryPolyPatch>
96         (
97             mesh().boundaryMesh()[patchID]
98         );
100     // Get non-const reference to patch
101     immersedBoundaryPolyPatch& ibPatch =
102         const_cast<immersedBoundaryPolyPatch&>(cibPatch);
104     const vectorField oldIbPoints = ibPatch.ibMesh().coordinates();
106     // Move points
107     ibPatch.moveTriSurfacePoints
108     (
109         transform(sbmfPtr_->transformation(), refIbSurface_.points())
110     );
112     // Set refValue_ to moving boundary velocity
113     ibPatchField.refValue() =
114         (ibPatch.ibMesh().coordinates() - oldIbPoints)/
115         mesh().time().deltaT().value();
119 // ************************************************************************* //