coupledFreestreamFvPatchField.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
6  \\/ M anipulation |
7  -------------------------------------------------------------------------------
8  License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24  \*---------------------------------------------------------------------------*/
25 
27 //#include "volFields.H"
28 #include "mappedPatchBase.H"
29 
30 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
31 
32 namespace Foam
33 {
34 
35  // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
36 
37  template<class Type>
39  (
40  const fvPatch& p,
42  )
43  :
45  {}
46 
47 
48  template<class Type>
50  (
52  const fvPatch& p,
54  const fvPatchFieldMapper& mapper
55  )
56  :
57  freestreamFvPatchField<Type>(ptf, p, iF, mapper)
58  {}
59 
60 
61  template<class Type>
63  (
64  const fvPatch& p,
66  const dictionary& dict
67  )
68  :
70  {
71  this->phiName_ = dict.lookupOrDefault<word>("phi","phi");
72 
73  freestreamValue() = Field<Type>("freestreamValue", dict, p.size());
74 
75  if (dict.found("value"))
76  {
78  (
79  Field<Type>("value", dict, p.size())
80  );
81  }
82  else
83  {
84  fvPatchField<Type>::operator=(freestreamValue());
85  }
86  }
87 
88 
89  template<class Type>
91  (
93  )
94  :
96  {}
97 
98 
99  template<class Type>
101  (
104  )
105  :
107  {}
108 
109 
110  // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
111  template<class Type>
113  {
114  if (this->updated())
115  {
116  return;
117  }
118 
119 
120  // Since we're inside initEvaluate/evaluate there might be processor
121  // comms underway. Change the tag we use.
122  int oldTag = UPstream::msgType();
123  UPstream::msgType() = oldTag+1;
124 
125  // Get the coupling information from the mappedPatchBase
126  const mappedPatchBase& mpp =
127  refCast<const mappedPatchBase>(this->patch().patch());
128  const polyMesh& nbrMesh = mpp.sampleMesh();
129  const label samplePatchI = mpp.samplePolyPatch().index();
130 
131  //define the nbrPatch ,just a patch, not include the field
132  const fvPatch& nbrPatch =
133  refCast<const fvMesh>(nbrMesh).boundary()[samplePatchI];
134 //this->patch() = nbrPatch;
135  // Field<Type>& Up = *this;
136  // vectorField Uc(this->patchInternalField());
137  // vectorField& Up = *this;
138  if (debug_)
139  {
140  //Info << endl<< "this patch name is : =====" << endl;
141  //Info << this->neighbourName_ << endl<< endl;
142 
143  // Info << endl<< "the parents patch(*this) is :====" << endl;
144  // Info << Up << endl<< endl;
145  //
146  // Info << endl<< "the neighbourMesh is : =" << endl;
147  // Info << nbrMesh.boundaryMesh() << endl << endl;
148  // Info << endl<< "the neighbourMesh face() is : =" << endl;
149  // Info << nbrMesh.faces() << endl << endl;
150  // Info << endl<< "the neighbourMesh point() is : =" << endl;
151  // Info << nbrMesh.points() << endl << endl;
152  // Info << endl<< "the neighbourMesh typeName is : =" << endl;
153  // Info << nbrMesh.typeName << endl << endl;
154  // Info << endl<< "the neighbourMesh faceOwner is : =" << endl;
155  // Info << nbrMesh.faceOwner() << endl << endl;
156  // Info << endl<< "the neighbourMesh faceNeighbour() is : =" << endl;
157  // Info << nbrMesh.faceNeighbour() << endl << endl;
158 
159 
160  //Info << endl<< "the neighbourPatch Index is =======" << endl;
161  //Info << samplePatchI << endl << endl;
162 
163  // Info << "this parearnt patch.patch() is =========" << endl;
164  // Info << this->patch().patch() << endl << endl;
165 
166  //Info <<"neighbourPatch Name is : " << nbrPatch.name()<<endl;
167  // Info <<"neighbourPatch patch() is : ============ " << endl << nbrPatch.patch()<<endl;
168  // Info <<"neighbourPatch start() is : " << nbrPatch.start()<<endl;
169  // Info <<"neighbourPatch size() is : " << nbrPatch.size()<<endl;
170  // Info <<"neighbourPatch type() is : " << nbrPatch.type()<<endl;
171  //Info <<"neighbourPatch TypeName is : " << nbrPatch.typeName_()<<endl;
172  }
173 
174 
175  const Field<scalar>& phip =
176  this->patch().template lookupPatchField<GeometricField<scalar, fvPatchField, volMesh>, scalar>("phi");
177  //<surfaceScalarField, scalar>
178  // (
179  // "phi" //不适用phiName_这个变量了,就永远固定是phi这个字符了,通常也不会有什么更改。
180  // );
181 
182  this->valueFraction() = 1.0 - pos(phip);
183 
185 
186  // //Info <<"neighbourPatch field is : " << nbrPatch.patchField<GeometricField<Type, fvPatchField, volMesh>,Type>()<<endl;
187  // //define the nbrField
188  // const coupledFixedValueFvPatchField&
189  // nbrField = refCast
190  // <const coupledFixedValueFvPatchField>
191  // (
192  // nbrPatch.lookupPatchField<GeometricField<Type, fvPatchField, volMesh>, Type>(this->neighbourName_)
193  // );
194  // if (debug_)
195  // {
196  // // Info << "==== neighbourPatch Field from lookupPatchField: " << endl << nbrField << endl;
197  // Info << "==== neighbourPatch Field typeName_ is : " << nbrField.fvPatchField<Type>::typeName_() << endl;
198  // Info << "==== neighbourPatch Field fixesvalue is : " << nbrField.fixesValue() << endl;
199  // Info << "==== neighbourPatch Field internalField() is : " << nbrField.internalField() << endl;
200  // // Info << "==== neighbourPatch Field grandientBoundaryCoeffs is : " << nbrField.gradientBoundaryCoeffs() << endl;
201  // // Info << "==== neighbourPatch Field grandientInternalCoeffs is : " << nbrField.gradientInternalCoeffs() << endl;
202 
203  // }
204  // // Field<Type> Utmpi = Field<Type>(this->size(), pTraits<Type>::zero));
205  // Field<Type> Utmp =Field<Type>(this->size(), pTraits<Type>::one);
206  // Utmp=nbrPatch.lookupPatchField<GeometricField<Type, fvPatchField, volMesh>, Type>(this->neighbourName_);
207 
208  // if (debug_)
209  // {
210  // Info << "patchField Utmp is ========" << endl;
211  // Info << Utmp << endl;
212  // }
213 
214  // mpp.distribute(Utmp);
215 
216  // if (debug_)
217  // {
218  // // Info<< "mpp mode() is " << endl;
219  // // Info << mpp.mode() <<endl;
220  // // Info<< "mpp sampleRegion() is " << endl;
221  // // Info << mpp.sameRegion() <<endl;
222  // // Info<< "mpp sampleMesh() is " << endl;
223  // // Info << mpp.sampleMesh()<<endl;
224  // // Info<< "mpp typeName_ is " << endl;
225  // // Info << mpp.typeName_() <<endl;
226  // // Info<< "mpp typeName is " << endl;
227  // // Info << mpp.typeName <<endl;
228  // // Info<< "mpp samplePatch() is " << endl;
229  // // Info << mpp.samplePatch() <<endl;
230  // }
231  // // Info << "==== neighbourPatch Field patchNeighbourField() is : " << nbrField.patchNeighbourField() << endl;
232  // //Info << "==== neighbourPatch Field value is : " << nbrField.component << endl;
233 
234  // // Swap to obtain full local values of neighbour internal field
235  // // vectorField UcNbr(nbrField.patchInternalField());
236  // // mpp.distribute(UcNbr);
237 
238  // // Evaluate the variable field
239  // Up =Utmp;//nbrPatch.patchInternalField();//nbrPatch.patchField();
240  // // Up = nbrField();
241  // if (debug_)
242  // {
243  // Info << endl<< "after get the data from neighbour patch, the parents patch(*this) now is :====" << endl;
244  // Info << Up << endl;
245  // Info << "update the value of Up successfully!" << endl;
246  // Info << "=============================" << endl;
247  // Info << "=============================" << endl;
248  // }
249 
250  // // Restore tag
251  // UPstream::msgType() = oldTag;
252  // this->fvPatchField<Type>::updateCoeffs();
253  //fvPatchField<type>::updateCoeffs();
254 
255 
256 
257 // template<class Type>
258 // void coupledFixedValueFvPatchField<Type>::evaluate(const Pstream::commsTypes)
259 // {
260 // if (!this->updated())
261 // {
262 // this->updateCoeffs();
263 // }
264 //
265 // // Field<Type>::operator=
266 // // (
267 // // valueFraction_*refValue_
268 // // +
269 // // (1.0 - valueFraction_)*
270 // // (
271 // // this->patchInternalField()
272 // // + refGrad_/this->patch().deltaCoeffs()
273 // // )
274 // // );
275 // fvPatchField<Type>::operator==(this->patchInternalField());
276 // fvPatchField<Type>::evaluate();
277 //
278 //
279 //
280 //
281 //
282 //
283 //
284 //
285 //
286 //
287 // const Field<scalar>& phip =
288 // this->patch().template lookupPatchField<surfaceScalarField, scalar>
289 // (
290 // "phi" //不适用phiName_这个变量了,就永远固定是phi这个字符了,通常也不会有什么更改。
291 // );
292 //
293 // this->valueFraction() = 1.0 - pos(phip);
294 //
295 // mixedFvPatchField<Type>::updateCoeffs();
296  }
297 
298 
299  template<class Type>
301  {
303  if (this->phiName_ != "phi")
304  {
305  os.writeKeyword("phi")
306  << this->phiName_ << token::END_STATEMENT << nl;
307  }
308  freestreamValue().writeEntry("freestreamValue", os);
309  this->writeEntry("value", os);
310  }
311 
312 
313  // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
314 
315 } // End namespace Foam
316 
317 // ************************************************************************* //
Foam::fvPatchField
Abstract base class with a fat-interface to all derived classes covering all possible ways in which t...
Definition: fvPatchField.H:65
Foam::fvPatchField::write
virtual void write(Ostream &) const
Write.
Definition: fvPatchField.C:349
Foam::fvPatchField::operator=
virtual void operator=(const UList< Type > &)
Foam::token::END_STATEMENT
@ END_STATEMENT
Definition: token.H:99
p
p
Definition: pEqn.H:62
Foam::word
A class for handling words, derived from string.
Definition: word.H:59
Foam::mappedPatchBase::samplePolyPatch
const polyPatch & samplePolyPatch() const
Get the patch on the region.
Definition: mappedPatchBase.C:1246
Foam::dictionary::lookupOrDefault
T lookupOrDefault(const word &, const T &, bool recursive=false, bool patternMatch=true) const
Find and return a T,.
Definition: dictionaryTemplates.C:33
Foam::mappedPatchBase
Determines a mapping between patch face centres and mesh cell or face centres and processors they're ...
Definition: mappedPatchBase.H:101
coupledFreestreamFvPatchField.H
Foam::polyMesh
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:74
Foam::freestreamFvPatchField
This boundary condition provides a free-stream condition. It is a 'mixed' condition derived from the ...
Definition: freestreamFvPatchField.H:91
Foam::mappedPatchBase::sampleMesh
const polyMesh & sampleMesh() const
Get the region mesh.
Definition: mappedPatchBase.C:1237
Foam::label
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
Foam::dictionary::found
bool found(const word &, bool recursive=false, bool patternMatch=true) const
Search dictionary for given keyword.
Definition: dictionary.C:304
Foam::Field< Type >
Foam::nl
static const char nl
Definition: Ostream.H:260
Foam::fvPatch
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:61
Foam::coupledFreestreamFvPatchField::write
virtual void write(Ostream &) const
Write.
Definition: coupledFreestreamFvPatchField.C:300
Foam::coupledFreestreamFvPatchField
This boundary condition provides a free-stream condition. It is a 'mixed' condition derived from the ...
Definition: coupledFreestreamFvPatchField.H:91
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::coupledFreestreamFvPatchField::updateCoeffs
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
Definition: coupledFreestreamFvPatchField.C:112
Foam::dictionary
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:137
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
Foam::fvPatchField< Type >::updateCoeffs
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
Definition: fvPatchField.C:296
Foam::UPstream::msgType
static int & msgType()
Message tag of standard messages.
Definition: UPstream.H:452
Foam::Ostream::writeKeyword
Ostream & writeKeyword(const keyType &)
Write the keyword followed by an appropriate indentation.
Definition: Ostream.C:59
Foam::coupledFreestreamFvPatchField::coupledFreestreamFvPatchField
coupledFreestreamFvPatchField(const fvPatch &, const DimensionedField< Type, volMesh > &)
Construct from patch and internal field.
Definition: coupledFreestreamFvPatchField.C:39
Foam::fvPatchFieldMapper
Foam::fvPatchFieldMapper.
Definition: fvPatchFieldMapper.H:45
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:53
Foam::patchIdentifier::index
label index() const
Return the index of this patch in the boundaryMesh.
Definition: patchIdentifier.H:133
Foam::DimensionedField
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
Definition: DimensionedField.H:51
mappedPatchBase.H
Foam::pos
dimensionedScalar pos(const dimensionedScalar &ds)
Definition: dimensionedScalar.C:190