Merge branch 'master' of ssh://git.code.sf.net/p/foam-extend/foam-extend-3.2
[foam-extend-3.2.git] / src / dbns / multigrid / mgFieldLevel / fineMgFieldLevel.H
blobe355bcfb8984e4662bd929e0b7354cd39f2fbb76
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 Class
25     Foam::fineMgFieldLevel
27 Description
28     Fine multigrid field level. Allow for access to fvField at the fine level.
30 SourceFiles
31     fineMgFieldLevel.C
33 \*---------------------------------------------------------------------------*/
35 #ifndef fineMgFieldLevel_H
36 #define fineMgFieldLevel_H
38 #include "mgFieldLevel.H"
39 #include "mgMeshLevel.H"
40 #include "volFields.H"
41 #include "surfaceFields.H"
43 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
45 namespace Foam
48 /*---------------------------------------------------------------------------*\
49                        Class fineMgFieldLevel Declaration
50 \*---------------------------------------------------------------------------*/
52 class fineMgFieldLevel
54     public mgFieldLevel
56     // Private data
58         // reference to fine mesh level
59         const mgMeshLevel& meshLevel_;
61         // reference to fine mesh
62         const fvMesh& mesh_;
64         //- Number of cells
65         label nCells_;
67         //- Number of internal face
68         label nInternalFaces_;
71     // Primitive variables
73         //- Fine p
74         const volScalarField& p_;
76         //- Fine U
77         const volVectorField& U_;
79         //- Fine T
80         const volScalarField& T_;
82         //- Fine Cv
83         volScalarField const Cv_;
85         //- Fine R
86         volScalarField const R_;
89     // Residuals
91         //- fine rhoRes
92         const volScalarField& rhoRes_;
94         //- fine rhoURes
95         const volVectorField& rhoURes_;
97         //- fine rhoERes
98         const volScalarField& rhoERes_;
101     // Fluxes
103         //- fine rhoFlux
104         surfaceScalarField& rhoFlux_;
106         //- fine rhoUFlux
107         surfaceVectorField& rhoUFlux_;
109         //- fine rhoEFlux
110         surfaceScalarField& rhoEFlux_;
113     // Conservative variables
115         //- fine rho
116         volScalarField& rho_;
118         //- fine rhoU
119         volVectorField& rhoU_;
121         //- fine rhoE
122         volScalarField& rhoE_;
125     // Helper data
127         label level_;
130     // Private Member Functions
132         //- Disallow default bitwise copy construct
133         fineMgFieldLevel(const fineMgFieldLevel&);
135         //- Disallow default bitwise assignment
136         void operator=(const fineMgFieldLevel&);
139 public:
141         //- Runtime type information
142         TypeName("fineMgFieldLevel");
145     // Constructors
147         //- Construct from mesh
148         fineMgFieldLevel
149         (
150             const mgMeshLevel& fineMeshLevel,
151             const volScalarField& p,
152             const volVectorField& U,
153             const volScalarField& T,
154             const volScalarField& Cv,
155             const volScalarField& R,
156             const volScalarField& rhoRes,
157             const volVectorField& rhoURes,
158             const volScalarField& rhoERes,
159             surfaceScalarField& rhoFlux,
160             surfaceVectorField& rhoUFlux,
161             surfaceScalarField& rhoEFlux,
162             volScalarField& rho,
163             volVectorField& rhoU,
164             volScalarField& rhoE
165         )
166         :
167           meshLevel_(fineMeshLevel),
168           mesh_(fineMeshLevel.mesh()),
169           nCells_(fineMeshLevel.nCells()),
170           nInternalFaces_(fineMeshLevel.nInternalFaces()),
171           p_(p),
172           U_(U),
173           T_(T),
174           Cv_(Cv),
175           R_(R),
176           rhoRes_(rhoRes),
177           rhoURes_(rhoURes),
178           rhoERes_(rhoERes),
179           rhoFlux_(rhoFlux),
180           rhoUFlux_(rhoUFlux),
181           rhoEFlux_(rhoEFlux),
182           rho_(rho),
183           rhoU_(rhoU),
184           rhoE_(rhoE),
185           level_(0)
186         {}
189     //- Destructor
191         virtual ~fineMgFieldLevel()
192         {}
195     // Member Functions
197             //- Is this the finest level?
198             virtual bool finest() const
199             {
200                 return meshLevel_.finest();
201             }
203         // Addressing
205             //- Return number of cells
206             virtual label nCells() const
207             {
208                 return mesh_.nCells();
209             }
211             //- Return number of internal faces
212             virtual label nInternalFaces() const
213             {
214                 return mesh_.nInternalFaces();
215             }
217             //- Return number of patches
218             virtual label nPatches() const
219             {
220                 return mesh_.boundary().size();
221             }
223             //- Access to child array
224             virtual const labelList& child() const
225             {
226                 return meshLevel_.child();
227             }
229             //- Access to fine level
230             virtual const mgFieldLevel& fineLevel() const
231             {
232                 return *this;
233             }
236         // Field data
239             //- Return p
240             virtual const scalarField& pVar() const
241             {
242                 return p_.internalField();
243             }
245             virtual const volScalarField& p() const
246             {
247                 return p_;
248             }
250             //- Return p value for patches
251             virtual const scalarField& patchP
252             (
253                 const label patchNo
254             ) const
255             {
256                 return p_.boundaryField()[patchNo];
257             }
259             //- Return U
260             virtual const vectorField& UVar() const
261             {
262                 return U_.internalField();
263             }
265             virtual const volVectorField& U() const
266             {
267                 return U_;
268             }
270             //- Return U value for patches
271             virtual const vectorField& patchU
272             (
273                 const label patchNo
274             ) const
275             {
276                 return U_.boundaryField()[patchNo];
277             }
279             //- Return T
280             virtual const scalarField& TVar() const
281             {
282                 return T_.internalField();
283             }
285             virtual const volScalarField& T() const
286             {
287                 return T_;
288             }
290             //- Return T value for patches
291             virtual const scalarField& patchT
292             (
293                 const label patchNo
294             ) const
295             {
296                 return T_.boundaryField()[patchNo];
297             }
299             //- Return Cv
300             virtual const scalarField& CvVar() const
301             {
302                 return Cv_.internalField();
303             }
305             virtual const volScalarField& Cv() const
306             {
307                 return Cv_;
308             }
310             //- Return p value for patches
311             virtual const scalarField& patchCv
312             (
313                 const label patchNo
314             ) const
315             {
316                 return Cv_.boundaryField()[patchNo];
317             }
319             //- Return R
320             virtual const scalarField& RVar() const
321             {
322                 return R_.internalField();
323             }
325             virtual const volScalarField& R() const
326             {
327                 return R_;
328             }
330             //- Return p value for patches
331             virtual const scalarField& patchR
332             (
333                 const label patchNo
334             ) const
335             {
336                 return R_.boundaryField()[patchNo];
337             }
340         // Fluxes
342             //- Access to rhoFlux field
343             virtual surfaceScalarField& rhoFlux() const
344             {
345                 return rhoFlux_;
346             }
348             //- Access to rhoUFlux field
349             virtual surfaceVectorField& rhoUFlux() const
350             {
351                 return rhoUFlux_;
352             }
354             //- Access to rhoEFlux field
355             virtual surfaceScalarField& rhoEFlux() const
356             {
357                 return rhoEFlux_;
358             }
361         // Residuals
363             //- Access to rhoRes field
364             virtual const volScalarField& rhoRes() const
365             {
366                 return rhoRes_;
367             }
369             virtual const scalarField& rhoResVar() const
370             {
371                 return rhoRes_.internalField();
372             }
374             virtual const scalarField& patchRhoRes
375             (
376                 const label patchNo
377             ) const
378             {
379                 return rhoRes_.boundaryField()[patchNo];
380             }
382             //- Access to rhoURes field
383             virtual const volVectorField& rhoURes() const
384             {
385                 return rhoURes_;
386             }
388             virtual const vectorField& rhoUResVar() const
389             {
390                 return rhoURes_.internalField();
391             }
393             virtual const vectorField& patchRhoURes
394             (
395                 const label patchNo
396             ) const
397             {
398                 return rhoURes_.boundaryField()[patchNo];
399             }
401             //- Access to rhoERes field
402             virtual const volScalarField& rhoERes() const
403             {
404                 return rhoERes_;
405             }
407             virtual const scalarField& rhoEResVar() const
408             {
409                 return rhoERes_.internalField();
410             }
412             virtual const scalarField& patchRhoERes
413             (
414                 const label patchNo
415             ) const
416             {
417                 return rhoERes_.boundaryField()[patchNo];
418             }
421         // Conservative variables
423             //- Access to rho field
424             virtual const volScalarField& rho() const
425             {
426                 return rho_;
427             }
429             virtual const scalarField& rhoVar() const
430             {
431                 return rho_.internalField();
432             }
434             virtual const scalarField& patchRho
435             (
436                 const label patchNo
437             ) const
438             {
439                 return rho_.boundaryField()[patchNo];
440             }
442             //- Access to rhoU field
443             virtual const volVectorField& rhoU() const
444             {
445                 return rhoU_;
446             }
448             virtual const vectorField& rhoUVar() const
449             {
450                 return rhoU_.internalField();
451             }
453             virtual const vectorField& patchRhoU
454             (
455                 const label patchNo
456             ) const
457             {
458                 return rhoU_.boundaryField()[patchNo];
459             }
461             //- Access to rhoE field
462             virtual const volScalarField& rhoE() const
463             {
464                 return rhoE_;
465             }
467             virtual const scalarField& rhoEVar() const
468             {
469                 return rhoE_.internalField();
470             }
472             virtual const scalarField& patchRhoE
473             (
474                 const label patchNo
475             ) const
476             {
477                 return rhoE_.boundaryField()[patchNo];
478             }
480             //- Access to helper data
481             virtual label const& level() const
482             {
483                 return level_;
484             }
489 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
491 } // End namespace Foam
493 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
495 #endif
497 // ************************************************************************* //