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

Difference between operator= and operator==

Register Blogs Community New Posts Updated Threads Search

 
 
LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
Old   December 5, 2022, 05:45
Post Difference between operator= and operator==
  #1
New Member
 
peyman havaej
Join Date: Jan 2016
Posts: 16
Rep Power: 10
peyman.havaej is on a distinguished road
Dear all,

I have developed a boundary condition, which is very similar to the movingWallVelocity in foam extend.

In this code, the velocity of the wall is updated according to a rigid body motion. Hence, it is a time-dependent condition.

I tried two different ways to update the boundary values:

1-
Code:
vectorField::operator=(Up + n*(Un - (n & Up)) + UNew);
In the case of using the '=' sign, the boundary values in time solution folders are updated, while the solver converges slowly.

2-
Code:
vectorField::operator==(Up + n*(Un - (n & Up)) + UNew);
In the case of using the '==' sign, the boundary values in time solution folders are not updated, while the solver converges much faster.

Here, UNew is between 0-0.1 and it is varying by time.

There is a big difference between the transient simulations of these cases, and I don't know which one is correct.

According to this discussion, I know that:
Quote:
operator== will FORCE assignment, even if patch field type says it should not be so. For example for a fixedValue patch, operator== will change its value and operator= will do nothing.

Hrv
However, I am not sure which operator should be used in my simulation. Also, what is the cause of different numerical results when force assignment is used?

Any comments or further explanations would be appreciated.

Kind regards,
Peyman
peyman.havaej is offline   Reply With Quote

 

Tags
assignment, boundary condition, openfoam, operator, programming


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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Difference between forAll(boundary...) and operator==(..) in custom boundary quarkz OpenFOAM Programming & Development 3 April 1, 2022 19:55


All times are GMT -4. The time now is 07:38.