CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Programming & Development (https://www.cfd-online.com/Forums/openfoam-programming-development/)
-   -   Old and new values of a field (https://www.cfd-online.com/Forums/openfoam-programming-development/148803-old-new-values-field.html)

Franko February 19, 2015 17:07

Old and new values of a field
 
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 February 24, 2015 06:42

simple equation
 
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!

ssss February 27, 2015 04:06

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.


All times are GMT -4. The time now is 21:18.