How to write specific term in openfoam solver
Hello Foamers,
I am trying to modify the laplacian foam. Here is the code for equation, volScalarField U(a+(b*T)+(c*T*T)); fvScalarMatrix TEqn ( fvm::ddt(T) - fvm::laplacian(U,T) - (k) == fvOptions(T) ); fvOptions.constrain(TEqn); TEqn.solve(); fvOptions.correct(T); } Where, a,b,c & k are constants. Now, I want to write the value of "U" for each time step. How can I do that? Thanks in advance |
You can create volScalar field using IOObject and use AUTO_WRITE option for it. It will write at every save option. If you want to write every time step you can use write function after end of each time step. Then it will write every time step.
|
if (runTime.writeTime())
{ volScalarField U(a+(b*T)+(c*T*T)); ( IOobject ( "U", runTime.timeName(), mesh, IOobject::NO_READ, IOobject::AUTO_WRITE ), U ); runTime.write(); } I tried this one, but its not working. Solver is compiling, case is running but it is not writing "U" file. |
Quote:
PHP Code:
2. Now use your expression inside your solver PHP Code:
Best, Vivek S |
Thanks, Now its writing U for each time step.
I just change dimensions with this: dimensionSet(0,2,-1,0,0,0,0), But issue is, It is taking default value of time 0 uniform value. While running the case, Value of T is non-uniform and value of U is uniform. Any idean what is the mistake? |
Are you specifying BC's of U in 0 time folder?
If not , then your values of U should be non-uniform in internalField & calculated values at Boundary patches. |
No, I am not specifying BC for U in my time 0 folder.
Look at the calculated value for U in all next time steps... internalField uniform 77.359; boundaryField { Side1 { type zeroGradient; } Side2 { type zeroGradient; } walls { type empty; } } But my T is changing non-uniformally... like this internalField nonuniform List<scalar> 50 ( 571.591 559.42 547.284 535.214 523.241 511.396 499.706 488.2 476.904 465.844 455.041 444.518 434.293 424.384 414.806 405.571 396.691 388.173 380.024 372.248 364.847 357.82 351.166 344.881 338.959 333.393 328.175 323.294 318.741 314.503 310.566 306.918 303.545 300.431 297.563 294.923 292.498 290.271 288.228 286.352 284.628 283.041 281.576 280.219 278.953 277.765 276.641 275.566 274.525 273.506 ) ; boundaryField { Side1 { type fixedValue; value uniform 573; } Side2 { type fixedValue; value uniform 273; } walls { type empty; } } |
I think you have called U variable outside of your time loop if I am correct
Put it inside the time loop |
Thanks Vivek,
Its working. |
All times are GMT -4. The time now is 01:27. |