Merge branch 'upstream/OpenFOAM' into master
[freefoam.git] / src / finiteVolume / fvMesh / extendedStencil / cellToFace / extendedUpwindCellToFaceStencil.H
blobb2783ea74375b0851e77ae15603515e6d1e79ec0
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 1991-2009 OpenCFD Ltd.
6      \\/     M anipulation  |
7 -------------------------------------------------------------------------------
8 License
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
19     for more details.
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 Class
26     Foam::extendedUpwindCellToFaceStencil
28 Description
29     Creates upwind stencil by shifting a centred stencil to upwind and downwind
30     faces and optionally removing all non-(up/down)wind faces ('pureUpwind').
32     Note: the minOpposedness parameter is to decide which upwind and
33     downwind faces to combine the stencils from. If myArea is the
34     local area and upwindArea
35     the area of the possible upwind candidate it will be included if
36         (upwindArea & myArea)/magSqr(myArea) > minOpposedness
37     so this includes both cosine and area. WIP.
39 SourceFiles
40     extendedUpwindCellToFaceStencil.C
41     extendedUpwindCellToFaceStencilTemplates.C
43 \*---------------------------------------------------------------------------*/
45 #ifndef extendedUpwindCellToFaceStencil_H
46 #define extendedUpwindCellToFaceStencil_H
48 #include "extendedCellToFaceStencil.H"
50 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
52 namespace Foam
55 class cellToFaceStencil;
57 /*---------------------------------------------------------------------------*\
58                            Class extendedUpwindCellToFaceStencil Declaration
59 \*---------------------------------------------------------------------------*/
61 class extendedUpwindCellToFaceStencil
63     public extendedCellToFaceStencil
65     // Private data
67         //- Does stencil contain upwind points only
68         const bool pureUpwind_;
70         //- Swap map for getting neigbouring data
71         autoPtr<mapDistribute> ownMapPtr_;
72         autoPtr<mapDistribute> neiMapPtr_;
74         //- Per face the stencil.
75         labelListList ownStencil_;
76         labelListList neiStencil_;
80     // Private Member Functions
82         //- Find most 'opposite' faces of cell
83         void selectOppositeFaces
84         (
85             const boolList& nonEmptyFace,
86             const scalar minOpposedness,
87             const label faceI,
88             const label cellI,
89             DynamicList<label>& oppositeFaces
90         ) const;
92         //- Transport (centred) face stencil to 'opposite' face.
93         void transportStencil
94         (
95             const boolList& nonEmptyFace,
96             const labelListList& faceStencil,
97             const scalar minOpposedness,
98             const label faceI,
99             const label cellI,
100             const bool stencilHasNeighbour,
102             DynamicList<label>& oppositeFaces,
103             labelHashSet& faceStencilSet,
104             labelList& transportedStencil
105         ) const;
107         //- Transport (centred) face stencil to 'opposite' faces.
108         void transportStencils
109         (
110             const labelListList& faceStencil,
111             const scalar minOpposedness,
112             labelListList& ownStencil,
113             labelListList& neiStencil
114         );
117         //- Disallow default bitwise copy construct
118         extendedUpwindCellToFaceStencil(const extendedUpwindCellToFaceStencil&);
120         //- Disallow default bitwise assignment
121         void operator=(const extendedUpwindCellToFaceStencil&);
124 public:
126     // Constructors
128         //- Construct from mesh and uncompacted centred face stencil.
129         //  Transports facestencil to create owner and neighbour versions.
130         //  pureUpwind to remove any remaining downwind cells.
131         extendedUpwindCellToFaceStencil
132         (
133             const cellToFaceStencil&,
134             const bool pureUpwind,
135             const scalar minOpposedness
136         );
138         //- Construct from mesh and uncompacted centred face stencil. Splits
139         //  stencil into owner and neighbour (so always pure upwind)
140         extendedUpwindCellToFaceStencil
141         (
142             const cellToFaceStencil&
143         );
146     // Member Functions
148         bool pureUpwind() const
149         {
150             return pureUpwind_;
151         }
153         //- Return reference to the parallel distribution map
154         const mapDistribute& ownMap() const
155         {
156             return ownMapPtr_();
157         }
159         //- Return reference to the parallel distribution map
160         const mapDistribute& neiMap() const
161         {
162             return neiMapPtr_();
163         }
165         //- Return reference to the stencil
166         const labelListList& ownStencil() const
167         {
168             return ownStencil_;
169         }
171         //- Return reference to the stencil
172         const labelListList& neiStencil() const
173         {
174             return neiStencil_;
175         }
177         //- Sum vol field contributions to create face values
178         template<class Type>
179         tmp<GeometricField<Type, fvsPatchField, surfaceMesh> > weightedSum
180         (
181             const surfaceScalarField& phi,
182             const GeometricField<Type, fvPatchField, volMesh>& fld,
183             const List<List<scalar> >& ownWeights,
184             const List<List<scalar> >& neiWeights
185         ) const;
190 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
192 } // End namespace Foam
194 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
196 #ifdef NoRepository
197 #   include "extendedUpwindCellToFaceStencilTemplates.C"
198 #endif
200 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
202 #endif
204 // ************************ vim: set sw=4 sts=4 et: ************************ //