|
[Sponsors] |
April 15, 2014, 01:13 |
interesting assignment operator "==" and "="
|
#1 |
Member
xuhe-openfoam
Join Date: Aug 2013
Location: DaLian,china
Posts: 82
Rep Power: 13 |
hi!
look down the piece of code of "pEqn.H" in interFoam (openfoam 2.2.0): Code:
00049 #include "continuityErrs.H" 00050 00051 p == p_rgh + rho*gh; 00052 00053 if (p_rgh.needReference()) 00054 { 00055 p += dimensionedScalar 00056 ( 00057 "p", 00058 p.dimensions(), 00059 pRefValue - getRefCellValue(p, pRefCell) 00060 ); 00061 p_rgh = p - rho*gh; 00062 } 00063 } Then I look up the source guide . I could only understand from the source guide that the difference between "=" and "==" is that: operator "=" will check first to make sure the variable couldn't be assigned to itself , while "==" won't check that ! ; I wonder is there any other difference between "==" and "=" ? could you help me ? thanks! |
|
April 15, 2014, 11:02 |
|
#2 |
Senior Member
Kyle Mooney
Join Date: Jul 2009
Location: San Francisco, CA USA
Posts: 323
Rep Power: 18 |
I "think" that the == will force an overwrite of the current boundary values even if they are set to a non-Dirichlet type. This is done in addition to altering the internalField values. I recall seeing a discussion on this somewhere in this forum but I can't seem to find it.
I might be wrong about this so don't hold me accountable! |
|
April 15, 2014, 11:34 |
|
#3 |
Member
xuhe-openfoam
Join Date: Aug 2013
Location: DaLian,china
Posts: 82
Rep Power: 13 |
thanks for your reply!
|
|
April 15, 2014, 12:14 |
|
#4 |
Member
xuhe-openfoam
Join Date: Aug 2013
Location: DaLian,china
Posts: 82
Rep Power: 13 |
it is there:
HTML Code:
http://www.cfd-online.com/Forums/openfoam-programming-development/85013-operator.html Hrv __________________ Hrvoje Jasak |
|
Tags |
assignment operator |
|
|