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
00027 #include "directMappedVelocityFluxFixedValueFvPatchField.H"
00028 #include "fvPatchFieldMapper.H"
00029 #include "directMappedPatchBase.H"
00030 #include "volFields.H"
00031 #include "surfaceFields.H"
00032 #include "addToRunTimeSelectionTable.H"
00033
00034
00035
00036 namespace Foam
00037 {
00038
00039
00040
00041 directMappedVelocityFluxFixedValueFvPatchField::
00042 directMappedVelocityFluxFixedValueFvPatchField
00043 (
00044 const fvPatch& p,
00045 const DimensionedField<vector, volMesh>& iF
00046 )
00047 :
00048 fixedValueFvPatchVectorField(p, iF),
00049 phiName_("undefinedPhi")
00050 {}
00051
00052
00053 directMappedVelocityFluxFixedValueFvPatchField::
00054 directMappedVelocityFluxFixedValueFvPatchField
00055 (
00056 const directMappedVelocityFluxFixedValueFvPatchField& ptf,
00057 const fvPatch& p,
00058 const DimensionedField<vector, volMesh>& iF,
00059 const fvPatchFieldMapper& mapper
00060 )
00061 :
00062 fixedValueFvPatchVectorField(ptf, p, iF, mapper),
00063 phiName_(ptf.phiName_)
00064 {
00065 if (!isA<directMappedPatchBase>(this->patch().patch()))
00066 {
00067 FatalErrorIn
00068 (
00069 "directMappedVelocityFluxFixedValueFvPatchField::"
00070 "directMappedVelocityFluxFixedValueFvPatchField\n"
00071 "(\n"
00072 " const directMappedVelocityFluxFixedValueFvPatchField&,\n"
00073 " const fvPatch&,\n"
00074 " const DimensionedField<vector, volMesh>&,\n"
00075 " const fvPatchFieldMapper&\n"
00076 ")\n"
00077 ) << "\n patch type '" << p.type()
00078 << "' not type '" << directMappedPatchBase::typeName << "'"
00079 << "\n for patch " << p.name()
00080 << " of field " << dimensionedInternalField().name()
00081 << " in file " << dimensionedInternalField().objectPath()
00082 << exit(FatalError);
00083 }
00084 }
00085
00086
00087 directMappedVelocityFluxFixedValueFvPatchField::
00088 directMappedVelocityFluxFixedValueFvPatchField
00089 (
00090 const fvPatch& p,
00091 const DimensionedField<vector, volMesh>& iF,
00092 const dictionary& dict
00093 )
00094 :
00095 fixedValueFvPatchVectorField(p, iF, dict),
00096 phiName_(dict.lookup("phi"))
00097 {
00098 if (!isA<directMappedPatchBase>(this->patch().patch()))
00099 {
00100 FatalErrorIn
00101 (
00102 "directMappedVelocityFluxFixedValueFvPatchField::"
00103 "directMappedVelocityFluxFixedValueFvPatchField\n"
00104 "(\n"
00105 " const fvPatch& p,\n"
00106 " const DimensionedField<vector, volMesh>& iF,\n"
00107 " const dictionary& dict\n"
00108 ")\n"
00109 ) << "\n patch type '" << p.type()
00110 << "' not type '" << directMappedPatchBase::typeName << "'"
00111 << "\n for patch " << p.name()
00112 << " of field " << dimensionedInternalField().name()
00113 << " in file " << dimensionedInternalField().objectPath()
00114 << exit(FatalError);
00115 }
00116
00117
00118 const directMappedPolyPatch& mpp = refCast<const directMappedPolyPatch>
00119 (
00120 patch().patch()
00121 );
00122 (void)mpp.map().schedule();
00123 }
00124
00125
00126 directMappedVelocityFluxFixedValueFvPatchField::
00127 directMappedVelocityFluxFixedValueFvPatchField
00128 (
00129 const directMappedVelocityFluxFixedValueFvPatchField& ptf
00130 )
00131 :
00132 fixedValueFvPatchVectorField(ptf),
00133 phiName_(ptf.phiName_)
00134 {}
00135
00136
00137 directMappedVelocityFluxFixedValueFvPatchField::
00138 directMappedVelocityFluxFixedValueFvPatchField
00139 (
00140 const directMappedVelocityFluxFixedValueFvPatchField& ptf,
00141 const DimensionedField<vector, volMesh>& iF
00142 )
00143 :
00144 fixedValueFvPatchVectorField(ptf, iF),
00145 phiName_(ptf.phiName_)
00146 {}
00147
00148
00149
00150
00151 void directMappedVelocityFluxFixedValueFvPatchField::updateCoeffs()
00152 {
00153 if (updated())
00154 {
00155 return;
00156 }
00157
00158
00159 const directMappedPatchBase& mpp = refCast<const directMappedPatchBase>
00160 (
00161 directMappedVelocityFluxFixedValueFvPatchField::patch().patch()
00162 );
00163 const mapDistribute& distMap = mpp.map();
00164 const fvMesh& nbrMesh = refCast<const fvMesh>(mpp.sampleMesh());
00165 const word& fieldName = dimensionedInternalField().name();
00166 const volVectorField& UField = nbrMesh.lookupObject<volVectorField>
00167 (
00168 fieldName
00169 );
00170
00171 surfaceScalarField& phiField = const_cast<surfaceScalarField&>
00172 (
00173 nbrMesh.lookupObject<surfaceScalarField>(phiName_)
00174 );
00175
00176 vectorField newUValues;
00177 scalarField newPhiValues;
00178
00179 switch (mpp.mode())
00180 {
00181 case directMappedPolyPatch::NEARESTFACE:
00182 {
00183 vectorField allUValues(nbrMesh.nFaces(), vector::zero);
00184 scalarField allPhiValues(nbrMesh.nFaces(), 0.0);
00185
00186 forAll(UField.boundaryField(), patchI)
00187 {
00188 const fvPatchVectorField& Upf = UField.boundaryField()[patchI];
00189 const scalarField& phipf = phiField.boundaryField()[patchI];
00190
00191 label faceStart = Upf.patch().patch().start();
00192
00193 forAll(Upf, faceI)
00194 {
00195 allUValues[faceStart++] = Upf[faceI];
00196 allPhiValues[faceStart] = phipf[faceI];
00197 }
00198 }
00199
00200 mapDistribute::distribute
00201 (
00202 Pstream::defaultCommsType,
00203 distMap.schedule(),
00204 distMap.constructSize(),
00205 distMap.subMap(),
00206 distMap.constructMap(),
00207 allUValues
00208 );
00209 newUValues = patch().patchSlice(newUValues);
00210
00211 mapDistribute::distribute
00212 (
00213 Pstream::defaultCommsType,
00214 distMap.schedule(),
00215 distMap.constructSize(),
00216 distMap.subMap(),
00217 distMap.constructMap(),
00218 newPhiValues
00219 );
00220 newPhiValues = patch().patchSlice(newPhiValues);
00221
00222 break;
00223 }
00224 case directMappedPolyPatch::NEARESTPATCHFACE:
00225 {
00226 const label nbrPatchID = nbrMesh.boundaryMesh().findPatchID
00227 (
00228 mpp.samplePatch()
00229 );
00230
00231 newUValues = UField.boundaryField()[nbrPatchID];
00232
00233 mapDistribute::distribute
00234 (
00235 Pstream::defaultCommsType,
00236 distMap.schedule(),
00237 distMap.constructSize(),
00238 distMap.subMap(),
00239 distMap.constructMap(),
00240 newUValues
00241 );
00242
00243 newPhiValues = phiField.boundaryField()[nbrPatchID];
00244
00245 mapDistribute::distribute
00246 (
00247 Pstream::defaultCommsType,
00248 distMap.schedule(),
00249 distMap.constructSize(),
00250 distMap.subMap(),
00251 distMap.constructMap(),
00252 newPhiValues
00253 );
00254
00255 break;
00256 }
00257 default:
00258 {
00259 FatalErrorIn
00260 (
00261 "directMappedVelocityFluxFixedValueFvPatchField::updateCoeffs()"
00262 )<< "patch can only be used in NEARESTPATCHFACE or NEARESTFACE "
00263 << "mode" << nl << abort(FatalError);
00264 }
00265 }
00266
00267 operator==(newUValues);
00268 phiField.boundaryField()[patch().index()] == newPhiValues;
00269
00270 fixedValueFvPatchVectorField::updateCoeffs();
00271 }
00272
00273
00274 void directMappedVelocityFluxFixedValueFvPatchField::write(Ostream& os) const
00275 {
00276 fvPatchVectorField::write(os);
00277 os.writeKeyword("phi") << phiName_ << token::END_STATEMENT << nl;
00278 this->writeEntry("value", os);
00279 }
00280
00281
00282
00283 makePatchTypeField
00284 (
00285 fvPatchVectorField,
00286 directMappedVelocityFluxFixedValueFvPatchField
00287 );
00288
00289
00290
00291 }
00292
00293