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

wallDistData.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 "wallDistData.H"
00028 #include "patchDataWave.H"
00029 #include "wallPolyPatch.H"
00030 #include "emptyFvPatchFields.H"
00031 
00032 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
00033 
00034 // Construct from components
00035 template<class TransferType>
00036 Foam::wallDistData<TransferType>::wallDistData
00037 (
00038     const Foam::fvMesh& mesh,
00039     GeometricField<Type, fvPatchField, volMesh>& field,
00040     const bool correctWalls
00041 )
00042 :
00043     volScalarField
00044     (
00045         IOobject
00046         (
00047             "y",
00048             mesh.time().timeName(),
00049             mesh
00050         ),
00051         mesh,
00052         dimensionedScalar("y", dimLength, GREAT)
00053     ),
00054     cellDistFuncs(mesh),
00055     field_(field),
00056     correctWalls_(correctWalls),
00057     nUnset_(0)
00058 {
00059     correct();
00060 }
00061 
00062 
00063 // * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
00064 
00065 template<class TransferType>
00066 Foam::wallDistData<TransferType>::~wallDistData()
00067 {}
00068 
00069 
00070 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00071 
00072 // Correct for mesh geom/topo changes
00073 template<class TransferType>
00074 void Foam::wallDistData<TransferType>::correct()
00075 {
00076     const polyMesh& mesh = cellDistFuncs::mesh();
00077 
00078     //
00079     // Fill data on wall patches with initial values
00080     //
00081 
00082     // Get patchids of walls
00083     labelHashSet wallPatchIDs(getPatchIDs(wallPolyPatch::typeName));
00084 
00085     // Collect pointers to data on patches
00086     UPtrList<Field<Type> > patchData(mesh.boundaryMesh().size());
00087 
00088     forAll(field_.boundaryField(), patchI)
00089     {
00090         patchData.set(patchI, &field_.boundaryField()[patchI]);
00091     }
00092 
00093     // Do mesh wave
00094     patchDataWave<TransferType> wave
00095     (
00096         mesh,
00097         wallPatchIDs,
00098         patchData,
00099         correctWalls_
00100     );
00101 
00102     // Transfer cell values from wave into *this and field_
00103     transfer(wave.distance());
00104 
00105     field_.transfer(wave.cellData());
00106 
00107     // Transfer values on patches into boundaryField of *this and field_
00108     forAll(boundaryField(), patchI)
00109     {
00110         scalarField& waveFld = wave.patchDistance()[patchI];
00111 
00112         if (boundaryField()[patchI].type() != emptyFvPatchScalarField::typeName)
00113         {
00114             boundaryField()[patchI].transfer(waveFld);
00115 
00116             Field<Type>& wavePatchData = wave.patchData()[patchI];
00117 
00118             field_.boundaryField()[patchI].transfer(wavePatchData);
00119         }
00120     }
00121 
00122     // Transfer number of unset values
00123     nUnset_ = wave.nUnset();
00124 }
00125 
00126 
00127 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd