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 "displacementFvMotionSolver.H"
28 #include "addToRunTimeSelectionTable.H"
29 #include "mapPolyMesh.H"
31 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
35 defineTypeNameAndDebug(displacementFvMotionSolver, 0);
39 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
41 Foam::displacementFvMotionSolver::displacementFvMotionSolver
55 mesh.time().constant(),
65 if (points0_.size() != mesh.nPoints())
69 "displacementFvMotionSolver::displacementFvMotionSolver\n"
74 ) << "Number of points in mesh " << mesh.nPoints()
75 << " differs from number of points " << points0_.size()
81 mesh.time().constant(),
93 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
95 Foam::displacementFvMotionSolver::~displacementFvMotionSolver()
99 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
101 void Foam::displacementFvMotionSolver::updateMesh(const mapPolyMesh& mpm)
103 fvMotionSolver::updateMesh(mpm);
105 // Map points0_. Bit special since we somehow have to come up with
106 // a sensible points0 position for introduced points.
107 // Find out scaling between points0 and current points
109 // Get the new points either from the map or the mesh
110 const pointField& points =
112 mpm.hasMotionPoints()
113 ? mpm.preMotionPoints()
117 // Note: boundBox does reduce
118 const vector span0 = boundBox(points0_).span();
119 const vector span = boundBox(points).span();
121 vector scaleFactors(cmptDivide(span0, span));
123 pointField newPoints0(mpm.pointMap().size());
125 forAll(newPoints0, pointI)
127 label oldPointI = mpm.pointMap()[pointI];
131 label masterPointI = mpm.reversePointMap()[oldPointI];
133 if (masterPointI == pointI)
135 newPoints0[pointI] = points0_[oldPointI];
139 // New point. Assume motion is scaling.
140 newPoints0[pointI] = points0_[oldPointI] + cmptMultiply
143 points[pointI]-points[masterPointI]
151 "displacementLaplacianFvMotionSolver::updateMesh"
152 "(const mapPolyMesh& mpm)"
153 ) << "Cannot work out coordinates of introduced vertices."
154 << " New vertex " << pointI << " at coordinate "
155 << points[pointI] << exit(FatalError);
158 points0_.transfer(newPoints0);
162 // ************************************************************************* //