Merge branch 'master' of ssh://git.code.sf.net/p/foam-extend/foam-extend-3.2
[foam-extend-3.2.git] / src / finiteVolume / fvMesh / wallDist / wallDistData.C
blobf9a050c8d60c581a1cd71b26d5bb547a73307d27
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | foam-extend: Open Source CFD
4    \\    /   O peration     | Version:     3.2
5     \\  /    A nd           | Web:         http://www.foam-extend.org
6      \\/     M anipulation  | For copyright notice see file Copyright
7 -------------------------------------------------------------------------------
8 License
9     This file is part of foam-extend.
11     foam-extend 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 3 of the License, or (at your
14     option) any later version.
16     foam-extend is distributed in the hope that it will be useful, but
17     WITHOUT ANY WARRANTY; without even the implied warranty of
18     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
19     General Public License for more details.
21     You should have received a copy of the GNU General Public License
22     along with foam-extend.  If not, see <http://www.gnu.org/licenses/>.
24 \*---------------------------------------------------------------------------*/
26 #include "wallDistData.H"
27 #include "patchDataWave.H"
28 #include "wallPolyPatch.H"
29 #include "emptyFvPatchFields.H"
31 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
33 // Construct from components
34 template<class TransferType>
35 Foam::wallDistData<TransferType>::wallDistData
37     const Foam::fvMesh& mesh,
38     GeometricField<Type, fvPatchField, volMesh>& field,
39     const bool correctWalls
42     volScalarField
43     (
44         IOobject
45         (
46             "y",
47             mesh.time().timeName(),
48             mesh
49         ),
50         mesh,
51         dimensionedScalar("y", dimLength, GREAT)
52     ),
53     cellDistFuncs(mesh),
54     field_(field),
55     correctWalls_(correctWalls),
56     nUnset_(0)
58     correct();
62 // * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
64 template<class TransferType>
65 Foam::wallDistData<TransferType>::~wallDistData()
69 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
71 // Correct for mesh geom/topo changes
72 template<class TransferType>
73 void Foam::wallDistData<TransferType>::correct()
75     Info<< "wallDistData.correct() called" << endl;
77     const polyMesh& mesh = cellDistFuncs::mesh();
79     //
80     // Fill data on wall patches with initial values
81     //
83     const polyBoundaryMesh& bMesh = mesh.boundaryMesh();
84     labelHashSet wallPatchIDs(bMesh.size());
85     forAll(bMesh, patchI)
86     {
87         if (bMesh[patchI].isWall())
88         {
89             wallPatchIDs.insert(patchI);
90         }
91     }
93     // Get patchids of walls
94     // labelHashSet wallPatchIDs(getPatchIDs<wallPolyPatch>());
96     // Collect pointers to data on patches
97     UPtrList<Field<Type> > patchData(mesh.boundaryMesh().size());
99     forAll(field_.boundaryField(), patchI)
100     {
101         patchData.set(patchI, &field_.boundaryField()[patchI]);
102     }
104     // Do mesh wave
105     patchDataWave<TransferType> wave
106     (
107         mesh,
108         wallPatchIDs,
109         patchData,
110         correctWalls_
111     );
113     // Transfer cell values from wave into *this and field_
114     transfer(wave.distance());
116     field_.transfer(wave.cellData());
118     // Transfer values on patches into boundaryField of *this and field_
119     forAll(boundaryField(), patchI)
120     {
121         scalarField& waveFld = wave.patchDistance()[patchI];
123         if (!isA<emptyFvPatchScalarField>(boundaryField()[patchI]))
124         {
125             boundaryField()[patchI].transfer(waveFld);
127             Field<Type>& wavePatchData = wave.patchData()[patchI];
129             field_.boundaryField()[patchI].transfer(wavePatchData);
130         }
131     }
133     // Transfer number of unset values
134     nUnset_ = wave.nUnset();
138 // ************************************************************************* //