CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   Main CFD Forum (https://www.cfd-online.com/Forums/main/)
-   -   Unsteady flow code - Problem with space loop (https://www.cfd-online.com/Forums/main/91351-unsteady-flow-code-problem-space-loop.html)

Hooman August 8, 2011 09:25

Unsteady flow code - Problem with space loop
 
Hi all,
I have discretized my equations in a way that for example the velocity depends on the velocity of the previous neighboring element so:

h = number of elements
t = 0: 0.5 : 10
for j= 1 : length(t)
for i = 2: h
v(i,j) = v(i-1,j) + b
p(i,j) = p(i,j) +b
end
end


This is not my actual formulations(codes) but the idea is that I need the value of the variable at the previous element so I start my loop from 2 to avoid getting i=0. But then this means that I don't have any values when I have i = 1 in the code. Is the only way to deal with this using boundary conditions. For example setting the value of the variable at i = 1 to be equal to that at i =2 ?

I hope I am clear enough.

Thanks.

cfdnewbie August 8, 2011 19:49

hm, I'm not clear what you are trying to do....which equation are you trying to solve? hyperbolic? parabolic? That would give you the type and number of boundary conditions you need... once you know that, you can apply the correct bc at your inflow / outflow.

cheers

Hooman August 9, 2011 06:00

I have a set of first order ODE's of the form:

dy/dt = f(y,t).

Thanks!

cfdnewbie August 9, 2011 17:31

Quote:

Originally Posted by Hooman (Post 319437)
I have a set of first order ODE's of the form:

dy/dt = f(y,t).

Thanks!


OK, you got me confused now....are you solving ODEs or PDEs? Because from your first post, I got the impression you where also dealing with a spatial derivative??

Hooman August 9, 2011 18:02

hmmm... Sorry ... well, that's the general form of the equation.....although the variables are evaluated at nodes which are at different locations... i.e. they change with space. So the 'i' is really a node number of a certain element. I hope this is more clear ...

Can I email you a simplified form of the equations, as my explanation is still probably unclear ... ?

Thanks! :)

cfdnewbie August 9, 2011 18:08

Quote:

Originally Posted by Hooman (Post 319540)
hmmm... Sorry ... well, that's the general form of the equation.....although the variables are evaluated at nodes which are at different locations... i.e. they change with space. So the 'i' is really a node number of a certain element. I hope this is more clear ...

Can I email you a simplified form of the equations, as my explanation is still probably unclear ... ?

Thanks! :)


So are you saying that you start with a PDE (in x and t) and then semi-discretize it (by evaluating things like d/dx at the nodes) and now you end up with an ODE in time? Then I got you :)

Hooman August 9, 2011 18:16

yes! you're right. Thanks!

So is there a specific type of boundary conditions or a mixture of some that needs to be used with this type of equation?

Thanks again.

cfdnewbie August 9, 2011 18:50

Yes, in fact, there is. The problem you are solving is hyperbolic, so you have to find out your inflow and your outflow regions. You only specify your inflow for all times t, and extrapolate the outflow from inside the domain.

I'm trying to make it a little bit clearer by this example:

say you want to solve the following standard hyperbolic problem (scalar):

du/dt + a du/dx = 0, with u=u(x,t), a >0

Thats the equation of a hyperbolic wave transport, i.e. everything will be transported (NOT damped) with speed a to the right (since a >0).

That means that the flow enters your domain from the left and exits on the right. So
what you do is the following:

you set your BCs ONLY at the left side, say thats at x=0:

u(x=0,t)=something

at the right side (outflow), you extrapolate your solution, i.e. u(x=right border,t) = u(x=rightborder-1,t).

Hope this helps!

Hooman August 10, 2011 16:03

Many thanks. That helped alot. :)

cfdnewbie August 10, 2011 17:05

glad i could help :)


All times are GMT -4. The time now is 02:50.