FreeFOAM The Cross-Platform CFD Toolkit
Hosted by SourceForge:
Get FreeFOAM at SourceForge.net.
            Fast, secure and Free Open Source software downloads

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-2010 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
00013     the Free Software Foundation, either version 3 of the License, or
00014     (at your 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, see <http://www.gnu.org/licenses/>.
00023 
00024 \*---------------------------------------------------------------------------*/
00025 
00026 #include "mixedPointPatchField.H"
00027 #include <OpenFOAM/pointPatchFieldMapper.H>
00028 
00029 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00030 
00031 namespace Foam
00032 {
00033 
00034 // * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
00035 
00036 template<class Type>
00037 void mixedPointPatchField<Type>::checkFieldSize() const
00038 {
00039     if
00040     (
00041         this->size() != this->patch().size()
00042      || refValue_.size() != this->patch().size()
00043      || valueFraction_.size() != this->patch().size()
00044     )
00045     {
00046         FatalErrorIn
00047         (
00048             "void mixedPointPatchField<Type>::checkField() const"
00049         )   << "field does not correspond to patch. " << endl
00050             << "Field size: " << this->size() << " value size: "
00051             << refValue_.size()
00052             << " valueFraction size: " << valueFraction_.size()
00053             << " patch size: " << this->patch().size()
00054             << abort(FatalError);
00055     }
00056 }
00057 
00058 
00059 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
00060 
00061 template<class Type>
00062 mixedPointPatchField<Type>::mixedPointPatchField
00063 (
00064     const pointPatch& p,
00065     const DimensionedField<Type, pointMesh>& iF
00066 )
00067 :
00068     valuePointPatchField<Type>(p, iF),
00069     refValue_(p.size()),
00070     valueFraction_(p.size())
00071 {}
00072 
00073 
00074 template<class Type>
00075 mixedPointPatchField<Type>::mixedPointPatchField
00076 (
00077     const pointPatch& p,
00078     const DimensionedField<Type, pointMesh>& iF,
00079     const dictionary& dict
00080 )
00081 :
00082     valuePointPatchField<Type>(p, iF, dict, false),
00083     refValue_("refValue", dict, p.size()),
00084     valueFraction_("valueFraction", dict, p.size())
00085 {}
00086 
00087 
00088 template<class Type>
00089 mixedPointPatchField<Type>::mixedPointPatchField
00090 (
00091     const mixedPointPatchField<Type>& ptf,
00092     const pointPatch& p,
00093     const DimensionedField<Type, pointMesh>& iF,
00094     const pointPatchFieldMapper& mapper
00095 )
00096 :
00097     valuePointPatchField<Type>
00098     (
00099         ptf,
00100         p,
00101         iF,
00102         mapper
00103     ),
00104     refValue_(ptf.refValue_, mapper),
00105     valueFraction_(ptf.valueFraction_, mapper)
00106 
00107 {}
00108 
00109 
00110 template<class Type>
00111 mixedPointPatchField<Type>::mixedPointPatchField
00112 (
00113     const mixedPointPatchField<Type>& ptf,
00114     const DimensionedField<Type, pointMesh>& iF
00115 )
00116 :
00117     valuePointPatchField<Type>(ptf, iF),
00118     refValue_(ptf.refValue_),
00119     valueFraction_(ptf.valueFraction_)
00120 {}
00121 
00122 
00123 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00124 
00125 // Map and resize from self given a mapper
00126 template<class Type>
00127 void mixedPointPatchField<Type>::autoMap
00128 (
00129     const pointPatchFieldMapper& m
00130 )
00131 {
00132     Field<Type>::autoMap(m);
00133     refValue_.autoMap(m);
00134     valueFraction_.autoMap(m);
00135 }
00136 
00137 
00138 // Grab the values using rmap
00139 template<class Type>
00140 void mixedPointPatchField<Type>::rmap
00141 (
00142     const pointPatchField<Type>& ptf,
00143     const labelList& addr
00144 )
00145 {
00146     const mixedPointPatchField<Type>& mptf =
00147         refCast<const mixedPointPatchField<Type> >(ptf);
00148 
00149     Field<Type>::rmap(mptf, addr);
00150     refValue_.rmap(mptf.refValue_, addr);
00151     valueFraction_.rmap(mptf.valueFraction_, addr);
00152 }
00153 
00154 
00155 // Evaluate patch field
00156 template<class Type>
00157 void mixedPointPatchField<Type>::evaluate(const Pstream::commsTypes)
00158 {
00159     Field<Type>::operator=
00160     (
00161         valueFraction_*refValue_
00162       + (1.0 - valueFraction_)*this->patchInternalField()
00163     );
00164 
00165     // Get internal field to insert values into
00166     Field<Type>& iF = const_cast<Field<Type>&>(this->internalField());
00167 
00168     this->setInInternalField(iF, *this);
00169 }
00170 
00171 
00172 // Write
00173 template<class Type>
00174 void mixedPointPatchField<Type>::write(Ostream& os) const
00175 {
00176     pointPatchField<Type>::write(os);
00177     refValue_.writeEntry("refValue", os);
00178     valueFraction_.writeEntry("valueFraction", os);
00179 }
00180 
00181 
00182 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00183 
00184 } // End namespace Foam
00185 
00186 // ************************ vim: set sw=4 sts=4 et: ************************ //
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines