coupledFixedValueFvPatchField.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-2015 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 namespace Foam
32 {
33 
34  // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
35 
36  template<class Type>
38  (
39  const fvPatch& p,
41  )
42  :
44  {}
45 
46 
47  template<class Type>
49  (
50  const fvPatch& p,
52  const dictionary& dict
53  )
54  :
55  fvPatchField<Type>(p, iF, dict, true),
56  neighbourName_(dict.lookupOrDefault<word>("fieldName","U"))
57  {}
58 
59 
60  template<class Type>
62  (
64  const fvPatch& p,
66  const fvPatchFieldMapper& mapper
67  )
68  :
69  fvPatchField<Type>(ptf, p, iF, mapper)
70  {
71  if (notNull(iF) && mapper.hasUnmapped())
72  {
74  << "On field " << iF.name() << " patch " << p.name()
75  << " patchField " << this->type()
76  << " : mapper does not map all values." << nl
77  << " To avoid this warning fully specify the mapping in derived"
78  << " patch fields." << endl;
79  }
80  }
81 
82 
83  template<class Type>
85  (
87  )
88  :
90  {}
91 
92 
93  template<class Type>
95  (
98  )
99  :
100  fvPatchField<Type>(ptf, iF)
101  {}
102 
103 
104  // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
105 
106  template<class Type>
108  (
109  const tmp<scalarField>&
110  ) const
111  {
112  return tmp<Field<Type> >
113  (
114  new Field<Type>(this->size(), pTraits<Type>::zero)
115  );
116  }
117 
118 
119  template<class Type>
121  (
122  const tmp<scalarField>&
123  ) const
124  {
125  return *this;
126  }
127 
128 
129  template<class Type>
131  {
132  return -pTraits<Type>::one*this->patch().deltaCoeffs();
133  }
134 
135 
136  template<class Type>
138  {
139  return this->patch().deltaCoeffs()*(*this);
140  }
141 
142  template<class Type>
144  {
145  if (this->updated())
146  {
147  return;
148  }
149  // Since we're inside initEvaluate/evaluate there might be processor
150  // comms underway. Change the tag we use.
151  int oldTag = UPstream::msgType();
152  UPstream::msgType() = oldTag+1;
153 
154  // Get the coupling information from the mappedPatchBase
155  const mappedPatchBase& mpp =
156  refCast<const mappedPatchBase>(this->patch().patch());
157  const polyMesh& nbrMesh = mpp.sampleMesh();
158  const label samplePatchI = mpp.samplePolyPatch().index();
159 
160  //define the nbrPatch ,just a patch, not include the field
161  const fvPatch& nbrPatch =
162  refCast<const fvMesh>(nbrMesh).boundary()[samplePatchI];
163 
164  Field<Type>& Up = *this;
165  // vectorField Uc(this->patchInternalField());
166  // vectorField& Up = *this;
167  if (debug_)
168  {
169  Info << endl<< "this patch name is : =====" << endl;
170  Info << this->neighbourName_ << endl<< endl;
171 
172 // Info << endl<< "the parents patch(*this) is :====" << endl;
173 // Info << Up << endl<< endl;
174 //
175 // Info << endl<< "the neighbourMesh is : =" << endl;
176 // Info << nbrMesh.boundaryMesh() << endl << endl;
177 // Info << endl<< "the neighbourMesh face() is : =" << endl;
178 // Info << nbrMesh.faces() << endl << endl;
179 // Info << endl<< "the neighbourMesh point() is : =" << endl;
180 // Info << nbrMesh.points() << endl << endl;
181 // Info << endl<< "the neighbourMesh typeName is : =" << endl;
182 // Info << nbrMesh.typeName << endl << endl;
183 // Info << endl<< "the neighbourMesh faceOwner is : =" << endl;
184 // Info << nbrMesh.faceOwner() << endl << endl;
185 // Info << endl<< "the neighbourMesh faceNeighbour() is : =" << endl;
186 // Info << nbrMesh.faceNeighbour() << endl << endl;
187 
188 
189  Info << endl<< "the neighbourPatch Index is =======" << endl;
190  Info << samplePatchI << endl << endl;
191 
192 // Info << "this parearnt patch.patch() is =========" << endl;
193 // Info << this->patch().patch() << endl << endl;
194 
195  Info <<"neighbourPatch Name is : " << nbrPatch.name()<<endl;
196 // Info <<"neighbourPatch patch() is : ============ " << endl << nbrPatch.patch()<<endl;
197 // Info <<"neighbourPatch start() is : " << nbrPatch.start()<<endl;
198 // Info <<"neighbourPatch size() is : " << nbrPatch.size()<<endl;
199 // Info <<"neighbourPatch type() is : " << nbrPatch.type()<<endl;
200  Info <<"neighbourPatch TypeName is : " << nbrPatch.typeName_()<<endl;
201  }
202  //Info <<"neighbourPatch field is : " << nbrPatch.patchField<GeometricField<Type, fvPatchField, volMesh>,Type>()<<endl;
203  //define the nbrField
205  nbrField = refCast
207  (
208  nbrPatch.lookupPatchField<GeometricField<Type, fvPatchField, volMesh>, Type>(this->neighbourName_)
209  );
210  if (debug_)
211  {
212 // Info << "==== neighbourPatch Field from lookupPatchField: " << endl << nbrField << endl;
213  Info << "==== neighbourPatch Field typeName_ is : " << nbrField.fvPatchField<Type>::typeName_() << endl;
214  Info << "==== neighbourPatch Field fixesvalue is : " << nbrField.fixesValue() << endl;
215  Info << "==== neighbourPatch Field internalField() is : " << nbrField.internalField() << endl;
216  // Info << "==== neighbourPatch Field grandientBoundaryCoeffs is : " << nbrField.gradientBoundaryCoeffs() << endl;
217 // Info << "==== neighbourPatch Field grandientInternalCoeffs is : " << nbrField.gradientInternalCoeffs() << endl;
218 
219  }
220  // Field<Type> Utmpi = Field<Type>(this->size(), pTraits<Type>::zero));
221  Field<Type> Utmp =Field<Type>(this->size(), pTraits<Type>::one);
222  Utmp=nbrPatch.lookupPatchField<GeometricField<Type, fvPatchField, volMesh>, Type>(this->neighbourName_);
223 
224  if (debug_)
225  {
226  Info << "patchField Utmp is ========" << endl;
227  Info << Utmp << endl;
228  }
229 
230  mpp.distribute(Utmp);
231 
232  if (debug_)
233  {
234 // Info<< "mpp mode() is " << endl;
235 // Info << mpp.mode() <<endl;
236 // Info<< "mpp sampleRegion() is " << endl;
237 // Info << mpp.sameRegion() <<endl;
238 // Info<< "mpp sampleMesh() is " << endl;
239 // Info << mpp.sampleMesh()<<endl;
240 // Info<< "mpp typeName_ is " << endl;
241 // Info << mpp.typeName_() <<endl;
242 // Info<< "mpp typeName is " << endl;
243 // Info << mpp.typeName <<endl;
244 // Info<< "mpp samplePatch() is " << endl;
245 // Info << mpp.samplePatch() <<endl;
246  }
247  // Info << "==== neighbourPatch Field patchNeighbourField() is : " << nbrField.patchNeighbourField() << endl;
248  //Info << "==== neighbourPatch Field value is : " << nbrField.component << endl;
249 
250  // Swap to obtain full local values of neighbour internal field
251  // vectorField UcNbr(nbrField.patchInternalField());
252  // mpp.distribute(UcNbr);
253 
254  // Evaluate the variable field
255  Up =Utmp;//nbrPatch.patchInternalField();//nbrPatch.patchField();
256  // Up = nbrField();
257  if (debug_)
258  {
259  Info << endl<< "after get the data from neighbour patch, the parents patch(*this) now is :====" << endl;
260  Info << Up << endl;
261  Info << "update the value of Up successfully!" << endl;
262  Info << "=============================" << endl;
263  Info << "=============================" << endl;
264  }
265 
266  // Restore tag
267  UPstream::msgType() = oldTag;
269  //fvPatchField<type>::updateCoeffs();
270  }
271 
272 
273  template<class Type>
275  {
276  if (!this->updated())
277  {
278  this->updateCoeffs();
279  }
280 
281  // Field<Type>::operator=
282  // (
283  // valueFraction_*refValue_
284  // +
285  // (1.0 - valueFraction_)*
286  // (
287  // this->patchInternalField()
288  // + refGrad_/this->patch().deltaCoeffs()
289  // )
290  // );
291  fvPatchField<Type>::operator==(this->patchInternalField());
293  }
294 
295 
296  template<class Type>
298  {
300  this->writeEntry("value", os);
301  }
302 
303  // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
304 
305 } // End namespace Foam
306 
307 // ************************************************************************* //
Foam::fvPatchField< Type >
Foam::coupledFixedValueFvPatchField::valueBoundaryCoeffs
virtual tmp< Field< Type > > valueBoundaryCoeffs(const tmp< scalarField > &) const
Return the matrix source coefficients corresponding to the.
Definition: coupledFixedValueFvPatchField.C:121
volFields.H
Foam::fvPatchField::write
virtual void write(Ostream &) const
Write.
Definition: fvPatchField.C:349
Foam::fvPatchField::operator==
virtual void operator==(const fvPatchField< Type > &)
Foam::fvPatchField::evaluate
virtual void evaluate(const Pstream::commsTypes commsType=Pstream::blocking)
Evaluate the patch field, sets Updated to false.
Definition: fvPatchField.C:318
p
p
Definition: pEqn.H:62
Foam::word
A class for handling words, derived from string.
Definition: word.H:59
Foam::coupledFixedValueFvPatchField::write
virtual void write(Ostream &) const
Write.
Definition: coupledFixedValueFvPatchField.C:297
Foam::coupledFixedValueFvPatchField::gradientInternalCoeffs
virtual tmp< Field< Type > > gradientInternalCoeffs() const
Return the matrix diagonal coefficients corresponding to the.
Definition: coupledFixedValueFvPatchField.C:130
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:118
Foam::notNull
bool notNull(const T &t)
Return true if t is not a reference to the nullObject of type T.
Definition: nullObjectI.H:46
Foam::coupledFixedValueFvPatchField
Definition: coupledFixedValueFvPatchField.H:80
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::coupledFixedValueFvPatchField::coupledFixedValueFvPatchField
coupledFixedValueFvPatchField(const fvPatch &, const DimensionedField< Type, volMesh > &)
Construct from patch and internal field.
Definition: coupledFixedValueFvPatchField.C:38
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
Foam::FieldMapper::hasUnmapped
virtual bool hasUnmapped() const =0
Are there unmapped values? I.e. do all size() elements get.
Foam::mappedPatchBase
Determines a mapping between patch face centres and mesh cell or face centres and processors they're ...
Definition: mappedPatchBase.H:101
Foam::coupledFixedValueFvPatchField::updateCoeffs
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
Definition: coupledFixedValueFvPatchField.C:143
Foam::polyMesh
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:74
Foam::fvPatch::name
const word & name() const
Return name.
Definition: fvPatch.H:149
coupledFixedValueFvPatchField.H
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::Field< Type >
Foam::nl
static const char nl
Definition: Ostream.H:260
Foam::Info
messageStream Info
Foam::mappedPatchBase::distribute
void distribute(List< Type > &lst) const
Wrapper around map/interpolate data distribution.
Definition: mappedPatchBaseTemplates.C:27
Foam::fvPatch
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:61
dict
dictionary dict
Definition: searchingEngine.H:14
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::refCast
To & refCast(From &r)
Reference type cast template function.
Definition: typeInfo.H:106
Foam::fvPatchField::updateCoeffs
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
Definition: fvPatchField.C:296
Foam::coupledFixedValueFvPatchField::gradientBoundaryCoeffs
virtual tmp< Field< Type > > gradientBoundaryCoeffs() const
Return the matrix source coefficients corresponding to the.
Definition: coupledFixedValueFvPatchField.C:137
Foam::UPstream::msgType
static int & msgType()
Message tag of standard messages.
Definition: UPstream.H:452
Foam::UPstream::commsTypes
commsTypes
Types of communications.
Definition: UPstream.H:64
Foam::coupledFixedValueFvPatchField::valueInternalCoeffs
virtual tmp< Field< Type > > valueInternalCoeffs(const tmp< scalarField > &) const
Return the matrix diagonal coefficients corresponding to the.
Definition: coupledFixedValueFvPatchField.C:108
Foam::pTraits
Traits class for primitives.
Definition: pTraits.H:50
Foam::coupledFixedValueFvPatchField::evaluate
virtual void evaluate(const Pstream::commsTypes commsType=Pstream::blocking)
Evaluate the patch field.
Definition: coupledFixedValueFvPatchField.C:274
Foam::coupledFixedValueFvPatchField::fixesValue
virtual bool fixesValue() const
Return true if this patch field fixes a value.
Definition: coupledFixedValueFvPatchField.H:164
Foam::fvPatch::lookupPatchField
const GeometricField::PatchFieldType & lookupPatchField(const word &name, const GeometricField *=NULL, const Type *=NULL) const
Lookup and return the patchField of the named field from the.
Definition: fvPatchFvMeshTemplates.C:32
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::type
fileName::Type type(const fileName &)
Return the file type: DIRECTORY or FILE.
Definition: POSIX.C:588
Foam::GeometricField
Generic GeometricField class.
Definition: surfaceFieldsFwd.H:52
WarningInFunction
#define WarningInFunction
Report a warning using Foam::Warning.
Definition: messageStream.H:259
Foam::patchIdentifier::index
label index() const
Return the index of this patch in the boundaryMesh.
Definition: patchIdentifier.H:133
Foam::fvPatchField::internalField
const Field< Type > & internalField() const
Return internal field reference.
Definition: fvPatchField.H:313
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