1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
7 -------------------------------------------------------------------------------
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
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 "displacementLaplacianFvMotionSolver.H"
28 #include "motionDiffusivity.H"
29 #include "fvmLaplacian.H"
30 #include "addToRunTimeSelectionTable.H"
32 #include "meshTools.H"
33 #include "mapPolyMesh.H"
34 #include "volPointInterpolation.H"
36 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
40 defineTypeNameAndDebug(displacementLaplacianFvMotionSolver, 0);
42 addToRunTimeSelectionTable
45 displacementLaplacianFvMotionSolver,
51 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
53 Foam::displacementLaplacianFvMotionSolver::displacementLaplacianFvMotionSolver
59 displacementFvMotionSolver(mesh, is),
65 fvMesh_.time().timeName(),
70 pointMesh::New(fvMesh_)
77 mesh.time().timeName(),
79 IOobject::READ_IF_PRESENT,
86 pointDisplacement_.dimensions(),
89 cellMotionBoundaryTypes<vector>(pointDisplacement_.boundaryField())
94 motionDiffusivity::New(*this, lookup("diffusivity"))
98 found("frozenPointsZone")
99 ? fvMesh_.pointZones().findZoneID(lookup("frozenPointsZone"))
106 fvMesh_.time().timeName(),
114 Info<< "displacementLaplacianFvMotionSolver:" << nl
115 << " diffusivity : " << diffusivityPtr_().type() << nl
116 << " frozenPoints zone : " << frozenPointsZone_ << endl;
127 pointMesh::New(fvMesh_)
133 Info<< "displacementLaplacianFvMotionSolver :"
134 << " Read pointVectorField "
135 << io.name() << " to be used for boundary conditions on points."
137 << "Boundary conditions:"
138 << pointLocation_().boundaryField().types() << endl;
144 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
146 Foam::displacementLaplacianFvMotionSolver::
147 ~displacementLaplacianFvMotionSolver()
151 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
153 Foam::tmp<Foam::pointField>
154 Foam::displacementLaplacianFvMotionSolver::curPoints() const
156 volPointInterpolation::New(fvMesh_).interpolate
162 if (pointLocation_.valid())
166 Info<< "displacementLaplacianFvMotionSolver : applying "
167 << " boundary conditions on " << pointLocation_().name()
168 << " to new point location."
172 pointLocation_().internalField() =
174 + pointDisplacement_.internalField();
176 pointLocation_().correctBoundaryConditions();
178 // Implement frozen points
179 if (frozenPointsZone_ != -1)
181 const pointZone& pz = fvMesh_.pointZones()[frozenPointsZone_];
185 pointLocation_()[pz[i]] = points0()[pz[i]];
189 twoDCorrectPoints(pointLocation_().internalField());
191 return tmp<pointField>(pointLocation_().internalField());
195 tmp<pointField> tcurPoints
197 points0() + pointDisplacement_.internalField()
200 // Implement frozen points
201 if (frozenPointsZone_ != -1)
203 const pointZone& pz = fvMesh_.pointZones()[frozenPointsZone_];
207 tcurPoints()[pz[i]] = points0()[pz[i]];
211 twoDCorrectPoints(tcurPoints());
218 void Foam::displacementLaplacianFvMotionSolver::solve()
220 // The points have moved so before interpolation update
221 // the fvMotionSolver accordingly
222 movePoints(fvMesh_.points());
224 diffusivityPtr_->correct();
225 pointDisplacement_.boundaryField().updateCoeffs();
231 diffusivityPtr_->operator()(),
233 "laplacian(diffusivity,cellDisplacement)"
239 void Foam::displacementLaplacianFvMotionSolver::updateMesh
241 const mapPolyMesh& mpm
244 displacementFvMotionSolver::updateMesh(mpm);
246 // Update diffusivity. Note two stage to make sure old one is de-registered
247 // before creating/registering new one.
248 diffusivityPtr_.reset(NULL);
249 diffusivityPtr_ = motionDiffusivity::New(*this, lookup("diffusivity"));
253 // ************************************************************************* //