OpenFOAM logo
The Open Source CFD Toolbox
  Source Guide OpenCFD Solutions Contact OpenFOAM

mixedPointPatchField.C

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------------*\
00002   =========                 |
00003   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
00004    \\    /   O peration     |
00005     \\  /    A nd           | Copyright (C) 1991-2009 OpenCFD Ltd.
00006      \\/     M anipulation  |
00007 -------------------------------------------------------------------------------
00008 License
00009     This file is part of OpenFOAM.
00010 
00011     OpenFOAM is free software; you can redistribute it and/or modify it
00012     under the terms of the GNU General Public License as published by the
00013     Free Software Foundation; either version 2 of the License, or (at your
00014     option) any later version.
00015 
00016     OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
00017     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00018     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00019     for more details.
00020 
00021     You should have received a copy of the GNU General Public License
00022     along with OpenFOAM; if not, write to the Free Software Foundation,
00023     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
00024 
00025 \*---------------------------------------------------------------------------*/
00026 
00027 #include "mixedPointPatchField.H"
00028 #include "pointPatchFieldMapper.H"
00029 
00030 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00031 
00032 namespace Foam
00033 {
00034 
00035 // * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
00036 
00037 template<class Type>
00038 void mixedPointPatchField<Type>::checkFieldSize() const
00039 {
00040     if
00041     (
00042         this->size() != this->patch().size()
00043      || refValue_.size() != this->patch().size()
00044      || valueFraction_.size() != this->patch().size()
00045     )
00046     {
00047         FatalErrorIn
00048         (
00049             "void mixedPointPatchField<Type>::checkField() const"
00050         )   << "field does not correspond to patch. " << endl
00051             << "Field size: " << this->size() << " value size: "
00052             << refValue_.size()
00053             << " valueFraction size: " << valueFraction_.size()
00054             << " patch size: " << this->patch().size()
00055             << abort(FatalError);
00056     }
00057 }
00058 
00059 
00060 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
00061 
00062 template<class Type>
00063 mixedPointPatchField<Type>::mixedPointPatchField
00064 (
00065     const pointPatch& p,
00066     const DimensionedField<Type, pointMesh>& iF
00067 )
00068 :
00069     valuePointPatchField<Type>(p, iF),
00070     refValue_(p.size()),
00071     valueFraction_(p.size())
00072 {}
00073 
00074 
00075 template<class Type>
00076 mixedPointPatchField<Type>::mixedPointPatchField
00077 (
00078     const pointPatch& p,
00079     const DimensionedField<Type, pointMesh>& iF,
00080     const dictionary& dict
00081 )
00082 :
00083     valuePointPatchField<Type>(p, iF, dict, false),
00084     refValue_("refValue", dict, p.size()),
00085     valueFraction_("valueFraction", dict, p.size())
00086 {}
00087 
00088 
00089 template<class Type>
00090 mixedPointPatchField<Type>::mixedPointPatchField
00091 (
00092     const mixedPointPatchField<Type>& ptf,
00093     const pointPatch& p,
00094     const DimensionedField<Type, pointMesh>& iF,
00095     const pointPatchFieldMapper& mapper
00096 )
00097 :
00098     valuePointPatchField<Type>
00099     (
00100         ptf,
00101         p,
00102         iF,
00103         mapper
00104     ),
00105     refValue_(ptf.refValue_, mapper),
00106     valueFraction_(ptf.valueFraction_, mapper)
00107 
00108 {}
00109 
00110 
00111 template<class Type>
00112 mixedPointPatchField<Type>::mixedPointPatchField
00113 (
00114     const mixedPointPatchField<Type>& ptf,
00115     const DimensionedField<Type, pointMesh>& iF
00116 )
00117 :
00118     valuePointPatchField<Type>(ptf, iF),
00119     refValue_(ptf.refValue_),
00120     valueFraction_(ptf.valueFraction_)
00121 {}
00122 
00123 
00124 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00125 
00126 // Map and resize from self given a mapper
00127 template<class Type>
00128 void mixedPointPatchField<Type>::autoMap
00129 (
00130     const pointPatchFieldMapper& m
00131 )
00132 {
00133     Field<Type>::autoMap(m);
00134     refValue_.autoMap(m);
00135     valueFraction_.autoMap(m);
00136 }
00137 
00138 
00139 // Grab the values using rmap
00140 template<class Type>
00141 void mixedPointPatchField<Type>::rmap
00142 (
00143     const pointPatchField<Type>& ptf,
00144     const labelList& addr
00145 )
00146 {
00147     const mixedPointPatchField<Type>& mptf =
00148         refCast<const mixedPointPatchField<Type> >(ptf);
00149 
00150     Field<Type>::rmap(mptf, addr);
00151     refValue_.rmap(mptf.refValue_, addr);
00152     valueFraction_.rmap(mptf.valueFraction_, addr);
00153 }
00154 
00155 
00156 // Evaluate patch field
00157 template<class Type>
00158 void mixedPointPatchField<Type>::evaluate(const Pstream::commsTypes)
00159 {
00160     Field<Type>::operator=
00161     (
00162         valueFraction_*refValue_
00163       + (1.0 - valueFraction_)*this->patchInternalField()
00164     );
00165 
00166     // Get internal field to insert values into
00167     Field<Type>& iF = const_cast<Field<Type>&>(this->internalField());
00168 
00169     setInInternalField(iF, *this);
00170 }
00171 
00172 
00173 // Write
00174 template<class Type>
00175 void mixedPointPatchField<Type>::write(Ostream& os) const
00176 {
00177     pointPatchField<Type>::write(os);
00178     refValue_.writeEntry("refValue", os);
00179     valueFraction_.writeEntry("valueFraction", os);
00180 }
00181 
00182 
00183 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00184 
00185 } // End namespace Foam
00186 
00187 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd