How to modify icoFoam.C to include source term
Hi,
I am a novice in the use of OpenFOAM. I was wondering if anyone might be willing to help me modify icoFoam.C so that I can include a source term f, which has the form: f = (eta)*(u_n+1  u_n) / dt u_n+1 and u_n are the current and previous velocities. eta is a variable defined in setFields and created in create.H. I tried the code below but I don't seem to get good results. Indeed if i choose smaller time steps, the solver crashes. fvVectorMatrix UEqn ( fvm::ddt(U) + fvm::div(phi, U)  fvm::laplacian(nu, U) ); solve(UEqn == fvc::grad(p)eta*(fvm::ddt(U))); Please help, thank you. 
Quote:
Code:
fvVectorMatrix UEqn 
How to modify icoFoam.C to include source term
Hi Nima,
Thank you for your prompt reply. I have tried that option but the result i get is really weird...the solver seems to get 'stuck' as can be seen below Courant Number mean: 0.00944072 max: 0.0228351 DILUmyPBiCG: Solving for Ux, Initial residual = 4.94675e05, Final residual = 2.71278e105, No Iterations 22 DILUmyPBiCG: Solving for Uy, Initial residual = 7.4114e05, Final residual = 5.49146e105, No Iterations 22 DICPCG: Solving for p, Initial residual = 4.46202e05, Final residual = 8.4033e17, No Iterations 97 time step continuity errors : sum local = 7.31098e19, global = 2.32262e21, cumulative = 1.11216e17 DICPCG: Solving for p, Initial residual = 1.64486e06, Final residual = 9.034e17, No Iterations 92 time step continuity errors : sum local = 7.20432e19, global = 1.28127e21, cumulative = 1.11203e17 ExecutionTime = 19.94 s ClockTime = 35 s Time = 0.6035 Courant Number mean: 0.00944072 max: 0.0228347 DILUmyPBiCG: Solving for Ux, Initial residual = 4.94634e05, Final residual = 2.7106e105, No Iterations 22 DILUmyPBiCG: Solving for Uy, Initial residual = 7.40934e05, Final residual = 5.84491e105, No Iterations 22 DICPCG: Solving for p, Initial residual = 4.46209e05, Final residual = 8.40861e17, No Iterations 97 time step continuity errors : sum local = 7.16085e19, global = 4.24348e21, cumulative = 1.11246e17 DICPCG: Solving for p, Initial residual = 1.64556e06, Final residual = 9.18026e17, No Iterations 92 time step continuity errors : sum local = 7.14218e19, global = 3.90334e21, cumulative = 1.11285e17 ExecutionTime = 19.96 s ClockTime = 35 s 
Quote:

yes i get very low residuals as soon as the iterations begin and they do not reduce significantly

i have no idea! i dont think it is a cause of error

Hi,
I am modifying the icoFoam solver to include a momentum source in y direction. Code:
fvVectorMatrix UEqn Code:
volVectorField Source However, when I tried to make the Source time dependent as follows, Code:
volVectorField Source Code:
createFields.H: In function ‘int main(int, char**)’: 
as function "cos" is defined in math.h too!, so you should define which one, you want to use, so it would be solve with following structure:
Quote:

Hi Nima,
Many thanks for your quick reply. The problem is solved. Now, I would like to see the Source term only exists at a specific area. if (x y z) in zone (x1 to x2, y1 to y2, z1 to z2) Source = (0, a, 0) else Source = (0, 0, 0) endif Can you please enlighten me on how to realize this? 
there are two options:
1 define it from Dictionary, for example look at interFoam (dambreak test case) to see how to define a nonuniform internalField 2 you can write a pieces of code, you can use mesh.C() which returns position vector then you can check it whether your cell is set up in specific area or not 
Quote:

All times are GMT 4. The time now is 23:25. 