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

Old and new values of a field

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

Reply
 
LinkBack Thread Tools Display Modes
Old   February 19, 2015, 18:07
Default Old and new values of a field
  #1
New Member
 
Join Date: Sep 2014
Posts: 15
Rep Power: 4
Franko is on a distinguished road
Hi, I have a problem with using old value of a field.

I have A and B - dimensionless volScalarFields
I also have
Code:
dimensionedScalar c ("c", dimensionSet(0, 0, 1, 0, 0, 0 ,0), 1.0);
In the beginning, I know A_i^n and B_i^n, i = 0,1,...,I

I want to solve two equations below in OpenFOAM (n - number of time layer):

1) A_i^{n+1} = 2*B_i^n;

2) \frac{A_i^{n+1}B_i^{n+1} - A_i^nB_i^n}{\tau} + B_i^{n+1} = 0

i = 0,1,...,I

(I want to find A_i^{n+1} from the first equation and then B_i^{n+1} from the second one)

I used this code with Euler scheme:

Code:
A = 2*B;

fvScalarMatrix BEqn
(
c*fvm::ddt(A,B) + fvm::Sp(1,B)
);
BEqn.solve();
The problem here with row
Code:
A = 2*B
This row let me find A_i^{n+1} but it also deleted old A_i^n values because OpenFOAM took the second equation as

\frac{A_i^{n+1}B_i^{n+1} - A_i^{n+1}B_i^n}{\tau} + B_i^{n+1} = 0

And I got the wrong decision!

What code will solve A_i^{n+1} = 2*B_i^n equation and won't delete old A_i^n values?
Thank you very much for any help ...
Franko is offline   Reply With Quote

Old   February 24, 2015, 07:42
Default simple equation
  #2
New Member
 
Join Date: Sep 2014
Posts: 15
Rep Power: 4
Franko is on a distinguished road
So, what will be the best way to solve the equations without any derivatives in OpenFOAM?
For example look at the equation A = 2B
(A and B - volScalarFields).

Do you use this code to solve it:
Code:
A=2*B;
??
Is that correct code?
Please help!
Franko is offline   Reply With Quote

Old   February 27, 2015, 05:06
Default
  #3
Senior Member
 
anonymous
Join Date: Aug 2014
Posts: 198
Rep Power: 4
ssss is on a distinguished road
Are you going to use always that kind of temporal discretization? If the answer is yes, you can access runTime delta T:

Code:
dimensionedScalar mydeltaT1("mydeltaT",dimensionSet(0, 0, 1, 0, 0, 0, 0),scalar(runTime.deltaTValue()));
And then solve manually the set of equations.
ssss is offline   Reply With Quote

Reply

Thread Tools
Display Modes

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 On
Pingbacks are On
Refbacks are On



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