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 "directMappedVelocityFluxFixedValueFvPatchField.H"
00027 #include <finiteVolume/fvPatchFieldMapper.H>
00028 #include <meshTools/directMappedPatchBase.H>
00029 #include <finiteVolume/volFields.H>
00030 #include <finiteVolume/surfaceFields.H>
00031 #include <OpenFOAM/addToRunTimeSelectionTable.H>
00032 #include <OpenFOAM/mapDistribute.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
00119 directMappedVelocityFluxFixedValueFvPatchField::
00120 directMappedVelocityFluxFixedValueFvPatchField
00121 (
00122 const directMappedVelocityFluxFixedValueFvPatchField& ptf
00123 )
00124 :
00125 fixedValueFvPatchVectorField(ptf),
00126 phiName_(ptf.phiName_)
00127 {}
00128
00129
00130 directMappedVelocityFluxFixedValueFvPatchField::
00131 directMappedVelocityFluxFixedValueFvPatchField
00132 (
00133 const directMappedVelocityFluxFixedValueFvPatchField& ptf,
00134 const DimensionedField<vector, volMesh>& iF
00135 )
00136 :
00137 fixedValueFvPatchVectorField(ptf, iF),
00138 phiName_(ptf.phiName_)
00139 {}
00140
00141
00142
00143
00144 void directMappedVelocityFluxFixedValueFvPatchField::updateCoeffs()
00145 {
00146 if (updated())
00147 {
00148 return;
00149 }
00150
00151
00152 const directMappedPatchBase& mpp = refCast<const directMappedPatchBase>
00153 (
00154 directMappedVelocityFluxFixedValueFvPatchField::patch().patch()
00155 );
00156 const mapDistribute& distMap = mpp.map();
00157 const fvMesh& nbrMesh = refCast<const fvMesh>(mpp.sampleMesh());
00158 const word& fieldName = dimensionedInternalField().name();
00159 const volVectorField& UField = nbrMesh.lookupObject<volVectorField>
00160 (
00161 fieldName
00162 );
00163
00164 surfaceScalarField& phiField = const_cast<surfaceScalarField&>
00165 (
00166 nbrMesh.lookupObject<surfaceScalarField>(phiName_)
00167 );
00168
00169 vectorField newUValues;
00170 scalarField newPhiValues;
00171
00172 switch (mpp.mode())
00173 {
00174 case directMappedPolyPatch::NEARESTFACE:
00175 {
00176 vectorField allUValues(nbrMesh.nFaces(), vector::zero);
00177 scalarField allPhiValues(nbrMesh.nFaces(), 0.0);
00178
00179 forAll(UField.boundaryField(), patchI)
00180 {
00181 const fvPatchVectorField& Upf = UField.boundaryField()[patchI];
00182 const scalarField& phipf = phiField.boundaryField()[patchI];
00183
00184 label faceStart = Upf.patch().patch().start();
00185
00186 forAll(Upf, faceI)
00187 {
00188 allUValues[faceStart + faceI] = Upf[faceI];
00189 allPhiValues[faceStart + faceI] = phipf[faceI];
00190 }
00191 }
00192
00193 mapDistribute::distribute
00194 (
00195 Pstream::defaultCommsType,
00196 distMap.schedule(),
00197 distMap.constructSize(),
00198 distMap.subMap(),
00199 distMap.constructMap(),
00200 allUValues
00201 );
00202 newUValues.transfer(allUValues);
00203
00204 mapDistribute::distribute
00205 (
00206 Pstream::defaultCommsType,
00207 distMap.schedule(),
00208 distMap.constructSize(),
00209 distMap.subMap(),
00210 distMap.constructMap(),
00211 allPhiValues
00212 );
00213 newPhiValues.transfer(allPhiValues);
00214
00215 break;
00216 }
00217 case directMappedPolyPatch::NEARESTPATCHFACE:
00218 {
00219 const label nbrPatchID = nbrMesh.boundaryMesh().findPatchID
00220 (
00221 mpp.samplePatch()
00222 );
00223
00224 newUValues = UField.boundaryField()[nbrPatchID];
00225
00226 mapDistribute::distribute
00227 (
00228 Pstream::defaultCommsType,
00229 distMap.schedule(),
00230 distMap.constructSize(),
00231 distMap.subMap(),
00232 distMap.constructMap(),
00233 newUValues
00234 );
00235
00236 newPhiValues = phiField.boundaryField()[nbrPatchID];
00237
00238 mapDistribute::distribute
00239 (
00240 Pstream::defaultCommsType,
00241 distMap.schedule(),
00242 distMap.constructSize(),
00243 distMap.subMap(),
00244 distMap.constructMap(),
00245 newPhiValues
00246 );
00247
00248 break;
00249 }
00250 default:
00251 {
00252 FatalErrorIn
00253 (
00254 "directMappedVelocityFluxFixedValueFvPatchField::updateCoeffs()"
00255 )<< "patch can only be used in NEARESTPATCHFACE or NEARESTFACE "
00256 << "mode" << nl << abort(FatalError);
00257 }
00258 }
00259
00260 operator==(newUValues);
00261 phiField.boundaryField()[patch().index()] == newPhiValues;
00262
00263 fixedValueFvPatchVectorField::updateCoeffs();
00264 }
00265
00266
00267 void directMappedVelocityFluxFixedValueFvPatchField::write(Ostream& os) const
00268 {
00269 fvPatchVectorField::write(os);
00270 os.writeKeyword("phi") << phiName_ << token::END_STATEMENT << nl;
00271 this->writeEntry("value", os);
00272 }
00273
00274
00275
00276 makePatchTypeField
00277 (
00278 fvPatchVectorField,
00279 directMappedVelocityFluxFixedValueFvPatchField
00280 );
00281
00282
00283
00284 }
00285
00286