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 "processorFvPatchField.H"
00027 #include <finiteVolume/processorFvPatch.H>
00028 #include <OpenFOAM/IPstream.H>
00029 #include <OpenFOAM/OPstream.H>
00030 #include <OpenFOAM/demandDrivenData.H>
00031 #include <OpenFOAM/transformField.H>
00032
00033
00034
00035 namespace Foam
00036 {
00037
00038
00039
00040 template<class Type>
00041 processorFvPatchField<Type>::processorFvPatchField
00042 (
00043 const fvPatch& p,
00044 const DimensionedField<Type, volMesh>& iF
00045 )
00046 :
00047 coupledFvPatchField<Type>(p, iF),
00048 procPatch_(refCast<const processorFvPatch>(p))
00049 {}
00050
00051
00052 template<class Type>
00053 processorFvPatchField<Type>::processorFvPatchField
00054 (
00055 const fvPatch& p,
00056 const DimensionedField<Type, volMesh>& iF,
00057 const Field<Type>& f
00058 )
00059 :
00060 coupledFvPatchField<Type>(p, iF, f),
00061 procPatch_(refCast<const processorFvPatch>(p))
00062 {}
00063
00064
00065
00066 template<class Type>
00067 processorFvPatchField<Type>::processorFvPatchField
00068 (
00069 const processorFvPatchField<Type>& ptf,
00070 const fvPatch& p,
00071 const DimensionedField<Type, volMesh>& iF,
00072 const fvPatchFieldMapper& mapper
00073 )
00074 :
00075 coupledFvPatchField<Type>(ptf, p, iF, mapper),
00076 procPatch_(refCast<const processorFvPatch>(p))
00077 {
00078 if (!isType<processorFvPatch>(this->patch()))
00079 {
00080 FatalErrorIn
00081 (
00082 "processorFvPatchField<Type>::processorFvPatchField\n"
00083 "(\n"
00084 " const processorFvPatchField<Type>& ptf,\n"
00085 " const fvPatch& p,\n"
00086 " const DimensionedField<Type, volMesh>& iF,\n"
00087 " const fvPatchFieldMapper& mapper\n"
00088 ")\n"
00089 ) << "\n patch type '" << p.type()
00090 << "' not constraint type '" << typeName << "'"
00091 << "\n for patch " << p.name()
00092 << " of field " << this->dimensionedInternalField().name()
00093 << " in file " << this->dimensionedInternalField().objectPath()
00094 << exit(FatalIOError);
00095 }
00096 }
00097
00098
00099 template<class Type>
00100 processorFvPatchField<Type>::processorFvPatchField
00101 (
00102 const fvPatch& p,
00103 const DimensionedField<Type, volMesh>& iF,
00104 const dictionary& dict
00105 )
00106 :
00107 coupledFvPatchField<Type>(p, iF, dict),
00108 procPatch_(refCast<const processorFvPatch>(p))
00109 {
00110 if (!isType<processorFvPatch>(p))
00111 {
00112 FatalIOErrorIn
00113 (
00114 "processorFvPatchField<Type>::processorFvPatchField\n"
00115 "(\n"
00116 " const fvPatch& p,\n"
00117 " const Field<Type>& field,\n"
00118 " const dictionary& dict\n"
00119 ")\n",
00120 dict
00121 ) << "\n patch type '" << p.type()
00122 << "' not constraint type '" << typeName << "'"
00123 << "\n for patch " << p.name()
00124 << " of field " << this->dimensionedInternalField().name()
00125 << " in file " << this->dimensionedInternalField().objectPath()
00126 << exit(FatalIOError);
00127 }
00128 }
00129
00130
00131 template<class Type>
00132 processorFvPatchField<Type>::processorFvPatchField
00133 (
00134 const processorFvPatchField<Type>& ptf
00135 )
00136 :
00137 processorLduInterfaceField(),
00138 coupledFvPatchField<Type>(ptf),
00139 procPatch_(refCast<const processorFvPatch>(ptf.patch()))
00140 {}
00141
00142
00143 template<class Type>
00144 processorFvPatchField<Type>::processorFvPatchField
00145 (
00146 const processorFvPatchField<Type>& ptf,
00147 const DimensionedField<Type, volMesh>& iF
00148 )
00149 :
00150 coupledFvPatchField<Type>(ptf, iF),
00151 procPatch_(refCast<const processorFvPatch>(ptf.patch()))
00152 {}
00153
00154
00155
00156
00157 template<class Type>
00158 processorFvPatchField<Type>::~processorFvPatchField()
00159 {}
00160
00161
00162
00163
00164 template<class Type>
00165 tmp<Field<Type> > processorFvPatchField<Type>::patchNeighbourField() const
00166 {
00167 return *this;
00168 }
00169
00170
00171 template<class Type>
00172 void processorFvPatchField<Type>::initEvaluate
00173 (
00174 const Pstream::commsTypes commsType
00175 )
00176 {
00177 if (Pstream::parRun())
00178 {
00179 procPatch_.compressedSend(commsType, this->patchInternalField()());
00180 }
00181 }
00182
00183
00184 template<class Type>
00185 void processorFvPatchField<Type>::evaluate
00186 (
00187 const Pstream::commsTypes commsType
00188 )
00189 {
00190 if (Pstream::parRun())
00191 {
00192 procPatch_.compressedReceive<Type>(commsType, *this);
00193
00194 if (doTransform())
00195 {
00196 transform(*this, procPatch_.forwardT(), *this);
00197 }
00198 }
00199 }
00200
00201
00202 template<class Type>
00203 tmp<Field<Type> > processorFvPatchField<Type>::snGrad() const
00204 {
00205 return this->patch().deltaCoeffs()*(*this - this->patchInternalField());
00206 }
00207
00208
00209 template<class Type>
00210 void processorFvPatchField<Type>::initInterfaceMatrixUpdate
00211 (
00212 const scalarField& psiInternal,
00213 scalarField&,
00214 const lduMatrix&,
00215 const scalarField&,
00216 const direction,
00217 const Pstream::commsTypes commsType
00218 ) const
00219 {
00220 procPatch_.compressedSend
00221 (
00222 commsType,
00223 this->patch().patchInternalField(psiInternal)()
00224 );
00225 }
00226
00227
00228 template<class Type>
00229 void processorFvPatchField<Type>::updateInterfaceMatrix
00230 (
00231 const scalarField&,
00232 scalarField& result,
00233 const lduMatrix&,
00234 const scalarField& coeffs,
00235 const direction cmpt,
00236 const Pstream::commsTypes commsType
00237 ) const
00238 {
00239 scalarField pnf
00240 (
00241 procPatch_.compressedReceive<scalar>(commsType, this->size())()
00242 );
00243
00244
00245 transformCoupleField(pnf, cmpt);
00246
00247
00248
00249 const unallocLabelList& faceCells = this->patch().faceCells();
00250
00251 forAll(faceCells, elemI)
00252 {
00253 result[faceCells[elemI]] -= coeffs[elemI]*pnf[elemI];
00254 }
00255 }
00256
00257
00258
00259
00260 }
00261
00262