# Position dependent field function

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

 February 25, 2020, 05:59 Position dependent field function #1 New Member   Victor Nieto Join Date: Feb 2020 Posts: 3 Rep Power: 6 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

 February 25, 2020, 09:23 #2 Senior Member   Matt Join Date: Aug 2014 Posts: 947 Rep Power: 17 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.

February 25, 2020, 09:31
#3
New Member

Victor Nieto
Join Date: Feb 2020
Posts: 3
Rep Power: 6
Quote:
 Originally Posted by fluid23 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,

Best regards

Victor Nieto

February 25, 2020, 13:07
#4
Senior Member

Matt
Join Date: Aug 2014
Posts: 947
Rep Power: 17
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
 syntax.PNG (7.1 KB, 17 views)

Last edited by fluid23; February 25, 2020 at 13:22. Reason: Added Image

 February 26, 2020, 07:06 #5 Senior Member   Sebastian Engel Join Date: Jun 2011 Location: Germany Posts: 566 Rep Power: 20 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.

February 26, 2020, 07:43
#6
New Member

Victor Nieto
Join Date: Feb 2020
Posts: 3
Rep Power: 6
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 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.

 Tags field functions, porous media, syntax error