FreeFOAM The Cross-Platform CFD Toolkit
Hosted by SourceForge:
Get FreeFOAM at SourceForge.net.
            Fast, secure and Free Open Source software downloads

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