|
[Sponsors] |
March 8, 2024, 06:57 |
Update Cell Values Outside of Boundary Code
|
#1 |
New Member
Kuzey Can Derman
Join Date: Oct 2022
Posts: 12
Rep Power: 4 |
Hello,
I am trying to change the value of a variable in updateFields.H inside solver folder for a purpose. Problem is when I try to print the values of this variable in boundary condition file (in p) to check ıf it is correct, it prints all zero meaning I failed. What may be the problem ? createFields: Code:
volScalarField checkVol ( IOobject ( "checkVol", runTime.timeName(), mesh, IOobject::NO_READ, IOobject::AUTO_WRITE ), mesh, dimensionedScalar("checkVol", dimless, 0.0 ) ); Code:
forAll(checkVol, facei) { checkVol[facei] = 250; } Code:
const fvPatchField<scalar>& checkVol= patch().lookupPatchField<volScalarField, scalar>("checkVol"); forAll(checkVol, checki) { Info << "checkVol: " << checkVol[checki] << endl; } Any help is appreciated. |
|
March 10, 2024, 16:19 |
|
#2 |
Senior Member
Mark Olesen
Join Date: Mar 2009
Location: https://olesenm.github.io/
Posts: 1,715
Rep Power: 40 |
Your choice of variable names is a bit misleading. If you write this:
Code:
forAll(checkVol, celli) { checkVol[celli] = 250; } Code:
checkVol.correctBoundaryCondtions(); |
|
March 12, 2024, 06:10 |
|
#3 |
New Member
Kuzey Can Derman
Join Date: Oct 2022
Posts: 12
Rep Power: 4 |
Thanks for the response Olesen.
Sorry that I gave a hard to understand code, this was because, I tried to give a template of what I am doing since there are few more things with similar variables and I had restrictions. To answer you, checkVol is a not a boundary value itself like p or U but a intermediate step for calculating U and p, think it like phi or gamma. checkVol value is calculated inside another updateCheck.h file just before updateFields.H. So no need to call correctBoudnaryCondition function. The problem is after it is calculated and assigned in that updateCheck.h file as previously mentioned, its values can be printed out. But when trying to print its values inside p boundary condition, it gives all zeros for it. |
|
March 13, 2024, 05:27 |
|
#4 |
New Member
Kuzey Can Derman
Join Date: Oct 2022
Posts: 12
Rep Power: 4 |
UPDATE !!!
I was using lookupPatchField to retrieve checkVol which was giving me zeros, I changed inital to 225 instead. Then it started to print out 225s instead of zeros. This concluded that it was just giving initial values and no other intermediate processes were done (unless some other function that turns the values to initials but seems unlikely). Then I tried to use the lookupObject to retrieve whole field instead of that single patch. This way it gave me 250 like it was supposed to (as I was changing values to 250 in updateFields, just arbitary value). From now on I can use these values and my problem is fixed for now. BUT this raises new questions to me. -Why did lookupObject worked as intended but lookupPatchField not? -Isn't lookupPatchField is similar to lookupObject but the difference is it just gives the values on these patches instead of whole domain? Thanks. |
|
March 14, 2024, 16:02 |
|
#5 |
Senior Member
Mark Olesen
Join Date: Mar 2009
Location: https://olesenm.github.io/
Posts: 1,715
Rep Power: 40 |
You concluded that you do not need to call correctBoundaryConditions() despite my attempt to describe why it is necessary and what it does.
For what it's worth, I think that I have a somewhat better than basic knowledge of OpenFOAM and that my suggestion may have some merit. |
|
March 15, 2024, 02:44 |
|
#6 |
New Member
Kuzey Can Derman
Join Date: Oct 2022
Posts: 12
Rep Power: 4 |
It was inappropriate to not try what you said and just continue, after asking a question here. I understand and am sorry about that.
I changed part of my code back and tried what you said. Added checkVol.correctBoundaryCondition() inside updateFields. And it doesn't work. My code is not well written in "OpenFOAM way", probably that is the issue. |
|
Tags |
boundary condition, programing |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
[Other] refineWallLayer Error | Yuby | OpenFOAM Meshing & Mesh Conversion | 2 | November 11, 2021 12:04 |
sliding mesh problem in CFX | Saima | CFX | 46 | September 11, 2021 08:38 |
[swak4Foam] About groovyBC to set distributed fixedGradient values for each cell boundary patch | nwpukaka | OpenFOAM Community Contributions | 6 | August 12, 2014 07:34 |
parallel code | samiam1000 | SU2 | 3 | March 25, 2013 05:55 |
Convective Heat Transfer - Heat Exchanger | Mark | CFX | 6 | November 15, 2004 16:55 |