CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Programming & Development

fvPatchField<Type>::operator==

Register Blogs Members List Search Today's Posts Mark Forums Read

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   July 16, 2020, 11:02
Default fvPatchField<Type>::operator==
  #1
Senior Member
 
Gerry Kan's Avatar
 
Gerry Kan
Join Date: May 2016
Posts: 347
Rep Power: 10
Gerry Kan is on a distinguished road
Howdy Foamers:

Browsing through the uniformFixedValue fvPatchField implementation there is a call to an operator like this in the member function updateCoeffs():

Code:
fvPatchField<Type>::operator == ( uniformValue_->value(t) );
Digging into fvPatchField.C, the function is implemented as follows:

Code:
template<class Type>
void Foam::fvPatchField<Type>::operator ==  ( const Type& t )  {
    Field<Type>::operator = (t);
}
I am familiar with operator overloading C++, but I have never seen operators to be called like this before. I could guess that the == ends up being some kind of assignment. It would be great if someone could provide a more accurate description of what both lines do.

Thanks in advance, Gerry.

Last edited by Gerry Kan; July 16, 2020 at 12:02.
Gerry Kan is offline   Reply With Quote

Old   July 17, 2020, 06:57
Default
  #2
Senior Member
 
Gerry Kan's Avatar
 
Gerry Kan
Join Date: May 2016
Posts: 347
Rep Power: 10
Gerry Kan is on a distinguished road
Howdy Foamers:

I think it is simply used as an assignment, and based on this OpenFOAM will somehow update the solver coefficients. I didn't dig so deep to see if this is the case but my results seems to tell me something is happening in the right direction.

Gerry.
Gerry Kan is offline   Reply With Quote

Old   July 17, 2020, 14:28
Default
  #3
Senior Member
 
Hrvoje Jasak
Join Date: Mar 2009
Location: London, England
Posts: 1,904
Rep Power: 33
hjasak will become famous soon enough
Hi,

We use operator== to indicate forced assignment, in contrast with normal assignment of an fvPatchField.

Normal assignment is a virtual overload depending on type, where for example it does nothing for a fixedValue derives class.

What the code says is “when forcing assignment, use the op= of the base class for the Field. This is not a virtual hierarchy and it will do the actual assignment job.

Hope this helps,

Hrv
__________________
Hrvoje Jasak
Providing commercial FOAM/OpenFOAM and CFD Consulting: http://wikki.co.uk
hjasak is offline   Reply With Quote

Old   July 20, 2020, 03:38
Default
  #4
Senior Member
 
Gerry Kan's Avatar
 
Gerry Kan
Join Date: May 2016
Posts: 347
Rep Power: 10
Gerry Kan is on a distinguished road
Dear Professor Jasak:

Thank you very much for taking your time to explain this. In the end I went (just a little) deeper to the definition of the overloaded Field assignment operator and it confirmed your comments and my observation.

In the end I would like to use this to assign a Field to the fvPatchField using this variant of the forced assignment operator, that is:

Code:
void Foam::fvPatchField<Type>::operator == ( const Field<Type>& tf )
instead of:

Code:
void Foam::fvPatchField<Type>::operator == ( const Type& t )
I am still in the process of trying to get it to work, as I am still having some problems with referencing my incoming Field. However I think your input has made this much more clear and I believe I know how to proceed.

Thank you again, Gerry.
Gerry Kan is offline   Reply With Quote

Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On



All times are GMT -4. The time now is 19:41.