00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #include "directionMixedFvPatchField.H"
00027 #include <OpenFOAM/symmTransformField.H>
00028
00029
00030
00031 namespace Foam
00032 {
00033
00034
00035
00036 template<class Type>
00037 directionMixedFvPatchField<Type>::directionMixedFvPatchField
00038 (
00039 const fvPatch& p,
00040 const DimensionedField<Type, volMesh>& iF
00041 )
00042 :
00043 transformFvPatchField<Type>(p, iF),
00044 refValue_(p.size()),
00045 refGrad_(p.size()),
00046 valueFraction_(p.size())
00047 {}
00048
00049
00050 template<class Type>
00051 directionMixedFvPatchField<Type>::directionMixedFvPatchField
00052 (
00053 const directionMixedFvPatchField<Type>& ptf,
00054 const fvPatch& p,
00055 const DimensionedField<Type, volMesh>& iF,
00056 const fvPatchFieldMapper& mapper
00057 )
00058 :
00059 transformFvPatchField<Type>(ptf, p, iF, mapper),
00060 refValue_(ptf.refValue_, mapper),
00061 refGrad_(ptf.refGrad_, mapper),
00062 valueFraction_(ptf.valueFraction_, mapper)
00063 {}
00064
00065
00066 template<class Type>
00067 directionMixedFvPatchField<Type>::directionMixedFvPatchField
00068 (
00069 const fvPatch& p,
00070 const DimensionedField<Type, volMesh>& iF,
00071 const dictionary& dict
00072 )
00073 :
00074 transformFvPatchField<Type>(p, iF, dict),
00075 refValue_("refValue", dict, p.size()),
00076 refGrad_("refGradient", dict, p.size()),
00077 valueFraction_("valueFraction", dict, p.size())
00078 {
00079 evaluate();
00080 }
00081
00082
00083 template<class Type>
00084 directionMixedFvPatchField<Type>::directionMixedFvPatchField
00085 (
00086 const directionMixedFvPatchField<Type>& ptf,
00087 const DimensionedField<Type, volMesh>& iF
00088 )
00089 :
00090 transformFvPatchField<Type>(ptf, iF),
00091 refValue_(ptf.refValue_),
00092 refGrad_(ptf.refGrad_),
00093 valueFraction_(ptf.valueFraction_)
00094 {}
00095
00096
00097
00098
00099 template<class Type>
00100 void directionMixedFvPatchField<Type>::autoMap
00101 (
00102 const fvPatchFieldMapper& m
00103 )
00104 {
00105 transformFvPatchField<Type>::autoMap(m);
00106 refValue_.autoMap(m);
00107 refGrad_.autoMap(m);
00108 valueFraction_.autoMap(m);
00109 }
00110
00111
00112 template<class Type>
00113 void directionMixedFvPatchField<Type>::rmap
00114 (
00115 const fvPatchField<Type>& ptf,
00116 const labelList& addr
00117 )
00118 {
00119 transformFvPatchField<Type>::rmap(ptf, addr);
00120
00121 const directionMixedFvPatchField<Type>& dmptf =
00122 refCast<const directionMixedFvPatchField<Type> >(ptf);
00123
00124 refValue_.rmap(dmptf.refValue_, addr);
00125 refGrad_.rmap(dmptf.refGrad_, addr);
00126 valueFraction_.rmap(dmptf.valueFraction_, addr);
00127 }
00128
00129
00130 template<class Type>
00131 tmp<Field<Type> > directionMixedFvPatchField<Type>::snGrad() const
00132 {
00133 Field<Type> pif = this->patchInternalField();
00134
00135 Field<Type> normalValue = transform(valueFraction_, refValue_);
00136
00137 Field<Type> gradValue = pif + refGrad_/this->patch().deltaCoeffs();
00138
00139 Field<Type> transformGradValue =
00140 transform(I - valueFraction_, gradValue);
00141
00142 return
00143 (normalValue + transformGradValue - pif)*
00144 this->patch().deltaCoeffs();
00145 }
00146
00147
00148 template<class Type>
00149 void directionMixedFvPatchField<Type>::evaluate(const Pstream::commsTypes)
00150 {
00151 if (!this->updated())
00152 {
00153 this->updateCoeffs();
00154 }
00155
00156 Field<Type> normalValue = transform(valueFraction_, refValue_);
00157
00158 Field<Type> gradValue =
00159 this->patchInternalField() + refGrad_/this->patch().deltaCoeffs();
00160
00161 Field<Type> transformGradValue =
00162 transform(I - valueFraction_, gradValue);
00163
00164 Field<Type>::operator=(normalValue + transformGradValue);
00165
00166 transformFvPatchField<Type>::evaluate();
00167 }
00168
00169
00170 template<class Type>
00171 tmp<Field<Type> > directionMixedFvPatchField<Type>::snGradTransformDiag() const
00172 {
00173 vectorField diag(valueFraction_.size());
00174
00175 diag.replace
00176 (
00177 vector::X,
00178 sqrt(mag(valueFraction_.component(symmTensor::XX)))
00179 );
00180 diag.replace
00181 (
00182 vector::Y,
00183 sqrt(mag(valueFraction_.component(symmTensor::YY)))
00184 );
00185 diag.replace
00186 (
00187 vector::Z,
00188 sqrt(mag(valueFraction_.component(symmTensor::ZZ)))
00189 );
00190
00191 return transformFieldMask<Type>(pow<vector, pTraits<Type>::rank>(diag));
00192 }
00193
00194
00195 template<class Type>
00196 void directionMixedFvPatchField<Type>::write(Ostream& os) const
00197 {
00198 transformFvPatchField<Type>::write(os);
00199 refValue_.writeEntry("refValue", os);
00200 refGrad_.writeEntry("refGradient", os);
00201 valueFraction_.writeEntry("valueFraction", os);
00202 this->writeEntry("value", os);
00203 }
00204
00205
00206
00207
00208 }
00209
00210