Merge branch 'master' of ssh://git.code.sf.net/p/foam-extend/foam-extend-3.2
[foam-extend-3.2.git] / src / dynamicMesh / meshMotion / fvMotionSolver / fvPatchFields / derived / cellMotion / cellMotionFvPatchField.C
blob093eb9e1e62b8e0f982d6f47d3ad3593be18461f
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 "cellMotionFvPatchField.H"
27 #include "fvMesh.H"
28 #include "volMesh.H"
29 #include "pointFields.H"
31 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
33 namespace Foam
36 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
38 template<class Type>
39 cellMotionFvPatchField<Type>::cellMotionFvPatchField
41     const fvPatch& p,
42     const DimensionedField<Type, volMesh>& iF
45     fixedValueFvPatchField<Type>(p, iF)
49 template<class Type>
50 cellMotionFvPatchField<Type>::cellMotionFvPatchField
52     const cellMotionFvPatchField<Type>& ptf,
53     const fvPatch& p,
54     const DimensionedField<Type, volMesh>& iF,
55     const fvPatchFieldMapper& mapper
58     fixedValueFvPatchField<Type>(ptf, p, iF, mapper)
62 template<class Type>
63 cellMotionFvPatchField<Type>::cellMotionFvPatchField
65     const fvPatch& p,
66     const DimensionedField<Type, volMesh>& iF,
67     const dictionary& dict
70     fixedValueFvPatchField<Type>(p, iF)
72     fvPatchField<Type>::operator=(Field<Type>("value", dict, p.size()));
76 template<class Type>
77 cellMotionFvPatchField<Type>::cellMotionFvPatchField
79     const cellMotionFvPatchField<Type>& ptf
82     fixedValueFvPatchField<Type>(ptf)
86 template<class Type>
87 cellMotionFvPatchField<Type>::cellMotionFvPatchField
89     const cellMotionFvPatchField<Type>& ptf,
90     const DimensionedField<Type, volMesh>& iF
93     fixedValueFvPatchField<Type>(ptf, iF)
97 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
99 template<class Type>
100 void cellMotionFvPatchField<Type>::updateCoeffs()
102     if (this->updated())
103     {
104         return;
105     }
107     const fvPatch& p = this->patch();
108     const polyPatch& pp = p.patch();
109     const fvMesh& mesh = this->dimensionedInternalField().mesh();
110     const pointField& points = mesh.points();
112     word pfName = this->dimensionedInternalField().name();
113     pfName.replace("cell", "point");
115     const GeometricField<Type, pointPatchField, pointMesh>& pointMotion =
116         this->db().objectRegistry::template
117         lookupObject<GeometricField<Type, pointPatchField, pointMesh> >
118         (
119             pfName
120         );
122     forAll(p, i)
123     {
124         this->operator[](i) = pp[i].average(points, pointMotion);
125     }
127     fixedValueFvPatchField<Type>::updateCoeffs();
131 template<class Type>
132 void cellMotionFvPatchField<Type>::write(Ostream& os) const
134     fvPatchField<Type>::write(os);
135     this->writeEntry("value", os);
139 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
141 } // End namespace Foam
143 // ************************************************************************* //