CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > Siemens > STAR-CCM+

Position dependent field function

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   February 25, 2020, 05:59
Default Position dependent field function
  #1
New Member
 
Victor Nieto
Join Date: Feb 2020
Posts: 3
Rep Power: 6
vnieto11 is on a distinguished road
Greetings forum,

I am somewhat new to this field of CFD and I wanted to consult with some experts to see if I can get some help.


I am running a simulation of a porous wall for a casting process (at the moment just the air escaping from the cavity through the beforementioned porous wall). I am using the Porous media model.



I ran my first simulation with a constant viscous and inertial porous resistance, and the results where according to expected. Now I am trying to run a simulation with a wall with three regions with different permeability, in order to do that I am considering a field function that changes with the geometry of the wall section.


The wall thickness is t=10 mm (0.01 m) and I am considering three regions: the outer region is from 0 to 0.003, 0.003 to 0.009 and 0.009 to 0.01 m (the values correspond to the viscous resistance at each region).



($${Position}[0]<= 0.003)?1e2 :
(
($${Position}[0]> 0.003 && $${Position}[0]<=0.009)? 1e4:
(
($${Position}[0]> 0.009)?1e5:


My problem is that the syntax does not seem to work, are there any recommendations or mistakes in my code?
Thank you very much for your comments or suggestions


Best regards
VN
vnieto11 is offline   Reply With Quote

Old   February 25, 2020, 09:23
Default
  #2
Senior Member
 
Matt
Join Date: Aug 2014
Posts: 947
Rep Power: 17
fluid23 is on a distinguished road
To be clear, you want porous resistance coefficients to vary with position?

For the problem you have described, it is probably easier to just split your porous region into 3 separate bodies based on the datums you defined and then assign constants to each region separately.

However, this is an interesting question and I am curious how one might go about doing this so I will play around and see if I can figure it out.

Hopefully, someone else has already tried something similar and can offer better advice.
fluid23 is offline   Reply With Quote

Old   February 25, 2020, 09:31
Default
  #3
New Member
 
Victor Nieto
Join Date: Feb 2020
Posts: 3
Rep Power: 6
vnieto11 is on a distinguished road
Quote:
Originally Posted by fluid23 View Post
To be clear, you want porous resistance coefficients to vary with position?

For the problem you have described, it is probably easier to just split your porous region into 3 separate bodies based on the datums you defined and then assign constants to each region separately.

However, this is an interesting question and I am curious how one might go about doing this so I will play around and see if I can figure it out.

Hopefully, someone else has already tried something similar and can offer better advice.



Greetings,
Yes my idea is to vary the porous resistance coefficients with position, just now I tried sepeartion the porours regions into different regions and as you suggested it worked.



However I am also still curious if my initial approach will work,



Thank you for your suggestion.
Best regards


Victor Nieto
vnieto11 is offline   Reply With Quote

Old   February 25, 2020, 13:07
Default
  #4
Senior Member
 
Matt
Join Date: Aug 2014
Posts: 947
Rep Power: 17
fluid23 is on a distinguished road
Ok, this is actually very easy. It looks like you just have some syntax errors. Specifically, unclosed parentheses and an extra ternary statement that you don't need nor do you close properly. Try this, it should work...

($$Position[0] <= 0.003) ? 100 : ($$Position[0] > 0.003 && $$Position[0] <= 0.009) ? 10000 : 100000

Edit: I have attached an image that might help you see how the statement is constructed. Apologies if you are colorblind.
Attached Images
File Type: png syntax.PNG (7.1 KB, 18 views)

Last edited by fluid23; February 25, 2020 at 13:22. Reason: Added Image
fluid23 is offline   Reply With Quote

Old   February 26, 2020, 07:06
Default
  #5
Senior Member
 
Sebastian Engel
Join Date: Jun 2011
Location: Germany
Posts: 566
Rep Power: 20
bluebase will become famous soon enough
Hi Victor,

after you have understood Matt's answer, you might become aware, that the $$Position[0] > 0.003 in the elseif part becomes redundant, because all points which are not smaller than 0.003 ($$Position[0] <= 0.003) must be larger. Though i am sure Matt left this out, so it is easier for you to retrace your initial misunderstanding.

So your initial logic construct can be reduced to:

($$Position[0] <= 0.003) ? 100 : ($$Position[0] <= 0.009) ? 10000 : 100000




If your wall domain is relatively small to the rest of the domain (in terms of number of elements in that direction), you might reverse the logical relation, to get a (very) marginal improvement on simulation speed. If most of your domain is above 0.009, then right now, the sim needs to check two if statements. Only for the presumably small wall region, the simulations checks one statement only.
I'd write it like this:

($$Position[0] > 0.009) ? 100000 : ($$Position[0] > 0.003 ) ? 10000 : 100

In the majority, one statement check returns the 100000. Only for the wall zone, a second if statement needs to be checked.
bluebase is offline   Reply With Quote

Old   February 26, 2020, 07:43
Default
  #6
New Member
 
Victor Nieto
Join Date: Feb 2020
Posts: 3
Rep Power: 6
vnieto11 is on a distinguished road
Thank you, I ran the simulation and everything went smoothly. I realized the mistakes on the syntax and now I understand why it wasn´t working


best regards
VN





Quote:
Originally Posted by fluid23 View Post
Ok, this is actually very easy. It looks like you just have some syntax errors. Specifically, unclosed parentheses and an extra ternary statement that you don't need nor do you close properly. Try this, it should work...

($$Position[0] <= 0.003) ? 100 : ($$Position[0] > 0.003 && $$Position[0] <= 0.009) ? 10000 : 100000

Edit: I have attached an image that might help you see how the statement is constructed. Apologies if you are colorblind.
vnieto11 is offline   Reply With Quote

Reply

Tags
field functions, porous media, syntax error


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
whats the cause of error? immortality OpenFOAM Running, Solving & CFD 13 March 24, 2021 07:15
[mesh manipulation] refineMesh Error mohsen.boojari OpenFOAM Meshing & Mesh Conversion 3 March 1, 2018 22:07
''unknown radialModelType type Gidaspow'' PROBLEM WITH THE BED TUTORIAL AndoniBM OpenFOAM Running, Solving & CFD 2 March 25, 2015 18:44
NEED HELP for position field function!! EnronZhang STAR-CCM+ 6 October 26, 2012 16:30
Problem with compile the setParabolicInlet ivanyao OpenFOAM Running, Solving & CFD 6 September 5, 2008 20:50


All times are GMT -4. The time now is 08:10.