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

"if" function in boundary condition

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   April 7, 2015, 04:13
Default "if" function in boundary condition
  #1
New Member
 
Sasa Goran
Join Date: Feb 2015
Location: Japan
Posts: 23
Rep Power: 11
Supersale is on a distinguished road
Hello all,

i want to simulate a pressure-boundary condition consisting of two parts depending on time. basically, the first part (from t=0 till t=t1)is changing the pressure from 0 to the maximum and the second part (t1<) is making this pressure harmonically change.
In MATLAB/octave it looks like this:

Code:
 
for i=1:length(t)
     if  t(i)<=t1
         p_cos(i)=pMax/2*(1+C_if*cos(2*pi*f1*t(i)));    
     else 
         p_cos(i)=(p0*(1+(C1*cos(2*pi*f*t(i)-pi/2)+C1*cos(4*pi*f*t(i)+pi/2))));
     end    
end
but how can i do this in OpenFOAM?
All help apriciated!!
Supersale is offline   Reply With Quote

Old   April 7, 2015, 05:23
Default
  #2
Member
 
Join Date: Jun 2011
Posts: 53
Rep Power: 14
blacksquirrel is on a distinguished road
Hi Supersale,

OpenFOAM can handle time-dependent boundaries, described here:
http://www.openfoam.org/version2.1.0...conditions.php

But regarding your function I would suggest using groovyBC from swak4Foam:
https://openfoamwiki.net/index.php/Contrib/groovyBC
http://www.cfd-online.com/Forums/ope...end-inlet.html

Regards
Squirrel
blacksquirrel is offline   Reply With Quote

Old   April 7, 2015, 21:27
Default
  #3
New Member
 
Sasa Goran
Join Date: Feb 2015
Location: Japan
Posts: 23
Rep Power: 11
Supersale is on a distinguished road
Hi!

thanks for the reply, it seems to work using groovyBC. I used this code:

Code:
 
inlet
   {
     type            groovyBC;
     variables "p0=437500;f=64000.0;pi=3.14159265358979323846264338327950288;t1=5.5e-06;f1=1/(2*t1);pMax=530000;C1=(pMax-p0)/(p0*(cos(2*pi*f*t1-pi/2)+cos(4*pi*f*t1+pi/2)));p0_if=pMax/2;Cif=-(pMax/p0_if-1)/(cos(2*pi*f1*t1+pi));";
     valueExpression "(time()<t1) ? pMax/2*(1+Cif*cos(2*pi*f1*time())) : p0*(1+C1*cos(2*pi*f*time()-pi/2)+C1*cos(4*pi*f*time()+pi/2))";
     value           uniform 0; 
   }
Supersale is offline   Reply With Quote

Reply

Tags
time dependent


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
Wind turbine simulation Saturn CFX 58 July 3, 2020 01:13
Low Mixing time Problem Mavier CFX 5 April 29, 2013 00:00
Compile problem ivanyao OpenFOAM Running, Solving & CFD 1 October 12, 2012 09:31
vorticity boundary condition bearcharge Main CFD Forum 0 May 14, 2010 11:32
[blockMesh] Axisymmetrical mesh Rasmus Gjesing (Gjesing) OpenFOAM Meshing & Mesh Conversion 10 April 2, 2007 14:00


All times are GMT -4. The time now is 04:17.