Initial commit for version 2.0.x patch release
[OpenFOAM-2.0.x.git] / src / finiteVolume / fields / fvPatchFields / constraint / processor / processorFvPatchField.H
blob703c740920d7acf78bfbf359032a4fe166be5a65
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 2004-2010 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
13     the Free Software Foundation, either version 3 of the License, or
14     (at your 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, see <http://www.gnu.org/licenses/>.
24 Class
25     Foam::processorFvPatchField
27 Description
28     Foam::processorFvPatchField
30 SourceFiles
31     processorFvPatchField.C
33 \*---------------------------------------------------------------------------*/
35 #ifndef processorFvPatchField_H
36 #define processorFvPatchField_H
38 #include "coupledFvPatchField.H"
39 #include "processorLduInterfaceField.H"
40 #include "processorFvPatch.H"
42 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
44 namespace Foam
47 /*---------------------------------------------------------------------------*\
48                       Class processorFvPatch Declaration
49 \*---------------------------------------------------------------------------*/
51 template<class Type>
52 class processorFvPatchField
54     public processorLduInterfaceField,
55     public coupledFvPatchField<Type>
57     // Private data
59         //- Local reference cast into the processor patch
60         const processorFvPatch& procPatch_;
63 public:
65     //- Runtime type information
66     TypeName(processorFvPatch::typeName_());
69     // Constructors
71         //- Construct from patch and internal field
72         processorFvPatchField
73         (
74             const fvPatch&,
75             const DimensionedField<Type, volMesh>&
76         );
78         //- Construct from patch and internal field and patch field
79         processorFvPatchField
80         (
81             const fvPatch&,
82             const DimensionedField<Type, volMesh>&,
83             const Field<Type>&
84         );
86         //- Construct from patch, internal field and dictionary
87         processorFvPatchField
88         (
89             const fvPatch&,
90             const DimensionedField<Type, volMesh>&,
91             const dictionary&
92         );
94         //- Construct by mapping given processorFvPatchField onto a new patch
95         processorFvPatchField
96         (
97             const processorFvPatchField<Type>&,
98             const fvPatch&,
99             const DimensionedField<Type, volMesh>&,
100             const fvPatchFieldMapper&
101         );
103         //- Construct as copy
104         processorFvPatchField(const processorFvPatchField<Type>&);
106         //- Construct and return a clone
107         virtual tmp<fvPatchField<Type> > clone() const
108         {
109             return tmp<fvPatchField<Type> >
110             (
111                 new processorFvPatchField<Type>(*this)
112             );
113         }
115         //- Construct as copy setting internal field reference
116         processorFvPatchField
117         (
118             const processorFvPatchField<Type>&,
119             const DimensionedField<Type, volMesh>&
120         );
122         //- Construct and return a clone setting internal field reference
123         virtual tmp<fvPatchField<Type> > clone
124         (
125             const DimensionedField<Type, volMesh>& iF
126         ) const
127         {
128             return tmp<fvPatchField<Type> >
129             (
130                 new processorFvPatchField<Type>(*this, iF)
131             );
132         }
135     //- Destructor
136     ~processorFvPatchField();
139     // Member functions
141         // Access
143             //- Return true if running parallel
144             virtual bool coupled() const
145             {
146                 if (Pstream::parRun())
147                 {
148                     return true;
149                 }
150                 else
151                 {
152                     return false;
153                 }
154             }
156             //- Return neighbour field given internal field
157             tmp<Field<Type> > patchNeighbourField() const;
160         // Evaluation functions
162             //- Initialise the evaluation of the patch field
163             virtual void initEvaluate(const Pstream::commsTypes commsType);
165             //- Evaluate the patch field
166             virtual void evaluate(const Pstream::commsTypes commsType);
168             //- Return patch-normal gradient
169             virtual tmp<Field<Type> > snGrad() const;
171             //- Initialise neighbour matrix update
172             virtual void initInterfaceMatrixUpdate
173             (
174                 const scalarField& psiInternal,
175                 scalarField& result,
176                 const lduMatrix& m,
177                 const scalarField& coeffs,
178                 const direction cmpt,
179                 const Pstream::commsTypes commsType
180             ) const;
182             //- Update result field based on interface functionality
183             virtual void updateInterfaceMatrix
184             (
185                 const scalarField& psiInternal,
186                 scalarField& result,
187                 const lduMatrix& m,
188                 const scalarField& coeffs,
189                 const direction cmpt,
190                 const Pstream::commsTypes commsType
191             ) const;
193         //- Processor coupled interface functions
195             //- Return processor number
196             virtual int myProcNo() const
197             {
198                 return procPatch_.myProcNo();
199             }
201             //- Return neigbour processor number
202             virtual int neighbProcNo() const
203             {
204                 return procPatch_.neighbProcNo();
205             }
207             //- Does the patch field perform the transfromation
208             virtual bool doTransform() const
209             {
210                 return !(procPatch_.parallel() || pTraits<Type>::rank == 0);
211             }
213             //- Return face transformation tensor
214             virtual const tensorField& forwardT() const
215             {
216                 return procPatch_.forwardT();
217             }
219             //- Return rank of component for transform
220             virtual int rank() const
221             {
222                 return pTraits<Type>::rank;
223             }
227 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
229 } // End namespace Foam
231 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
233 #ifdef NoRepository
234 #   include "processorFvPatchField.C"
235 #endif
237 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
239 #endif
241 // ************************************************************************* //