OpenFOAM logo
The Open Source CFD Toolbox
  Source Guide OpenCFD Solutions Contact OpenFOAM

displacementFvMotionSolver.C

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------------*\
00002   =========                 |
00003   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
00004    \\    /   O peration     |
00005     \\  /    A nd           | Copyright (C) 1991-2009 OpenCFD Ltd.
00006      \\/     M anipulation  |
00007 -------------------------------------------------------------------------------
00008 License
00009     This file is part of OpenFOAM.
00010 
00011     OpenFOAM is free software; you can redistribute it and/or modify it
00012     under the terms of the GNU General Public License as published by the
00013     Free Software Foundation; either version 2 of the License, or (at your
00014     option) any later version.
00015 
00016     OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
00017     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00018     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00019     for more details.
00020 
00021     You should have received a copy of the GNU General Public License
00022     along with OpenFOAM; if not, write to the Free Software Foundation,
00023     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
00024 
00025 \*---------------------------------------------------------------------------*/
00026 
00027 #include "displacementFvMotionSolver.H"
00028 #include "addToRunTimeSelectionTable.H"
00029 #include "mapPolyMesh.H"
00030 
00031 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
00032 
00033 namespace Foam
00034 {
00035     defineTypeNameAndDebug(displacementFvMotionSolver, 0);
00036 }
00037 
00038 
00039 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
00040 
00041 Foam::displacementFvMotionSolver::displacementFvMotionSolver
00042 (
00043     const polyMesh& mesh,
00044     Istream&
00045 )
00046 :
00047     fvMotionSolver(mesh),
00048     points0_
00049     (
00050         pointIOField
00051         (
00052             IOobject
00053             (
00054                 "points",
00055                 mesh.time().constant(),
00056                 polyMesh::meshSubDir,
00057                 mesh,
00058                 IOobject::MUST_READ,
00059                 IOobject::NO_WRITE,
00060                 false
00061             )
00062         )
00063     )
00064 {}
00065 
00066 
00067 // * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
00068 
00069 Foam::displacementFvMotionSolver::~displacementFvMotionSolver()
00070 {}
00071 
00072 
00073 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00074 
00075 void Foam::displacementFvMotionSolver::updateMesh(const mapPolyMesh& mpm)
00076 {
00077     fvMotionSolver::updateMesh(mpm);
00078 
00079     // Map points0_. Bit special since we somehow have to come up with
00080     // a sensible points0 position for introduced points.
00081     // Find out scaling between points0 and current points
00082 
00083     // Get the new points either from the map or the mesh
00084     const pointField& points =
00085     (
00086         mpm.hasMotionPoints()
00087       ? mpm.preMotionPoints()
00088       : fvMesh_.points()
00089     );
00090 
00091     // Note: boundBox does reduce
00092     const vector span0 = boundBox(points0_).span();
00093     const vector span  = boundBox(points).span();
00094 
00095     vector scaleFactors(cmptDivide(span0, span));
00096 
00097     pointField newPoints0(mpm.pointMap().size());
00098 
00099     forAll(newPoints0, pointI)
00100     {
00101         label oldPointI = mpm.pointMap()[pointI];
00102 
00103         if (oldPointI >= 0)
00104         {
00105             label masterPointI = mpm.reversePointMap()[oldPointI];
00106 
00107             if (masterPointI == pointI)
00108             {
00109                 newPoints0[pointI] = points0_[oldPointI];
00110             }
00111             else
00112             {
00113                 // New point. Assume motion is scaling.
00114                 newPoints0[pointI] = points0_[oldPointI] + cmptMultiply
00115                 (
00116                     scaleFactors,
00117                     points[pointI]-points[masterPointI]
00118                 );
00119             }
00120         }
00121         else
00122         {
00123             FatalErrorIn
00124             (
00125                 "displacementLaplacianFvMotionSolver::updateMesh"
00126                 "(const mapPolyMesh& mpm)"
00127             )   << "Cannot work out coordinates of introduced vertices."
00128                 << " New vertex " << pointI << " at coordinate "
00129                 << points[pointI] << exit(FatalError);
00130         }
00131     }
00132     points0_.transfer(newPoints0);
00133 }
00134 
00135 
00136 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd