|
[Sponsors] |
How to calculate the Gradient of velocity fields? |
![]() |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
![]() |
![]() |
#1 |
New Member
Nafiz Ahmed Khan
Join Date: Nov 2023
Location: Canada
Posts: 27
Rep Power: 2 ![]() |
I'm using openFoam v2306 and trying to calculate the gradients of velocity fields during each iteration. I have used the code below in system/controlDict:
Code:
grad1 { type grad; libs (fieldFunctionObjects); field { U; } enabled true; log true; timeStart 0; timeEnd 4000; executeControl timeStep; executeInterval 1; writeControl timeStep; writeInterval 100; } |
|
![]() |
![]() |
![]() |
![]() |
#2 |
Senior Member
Yann
Join Date: Apr 2012
Location: France
Posts: 1,169
Rep Power: 27 ![]() |
Hello Nafiz,
There is a syntax error in your function definition. You should not even be able to run the solver. Your field parameter should be defined like this: Code:
field U; Cheers, Yann |
|
![]() |
![]() |
![]() |
![]() |
#3 |
New Member
Engineer
Join Date: Mar 2013
Posts: 27
Rep Power: 13 ![]() |
grad1
{ // Mandatory entries type grad; libs (fieldFunctionObjects); field U; // Optional (inherited) entries result gradU; region region0; enabled true; log true; timeStart 0.25; timeEnd 1000; executeControl timeStep; executeInterval 5; writeControl timeStep; writeInterval 25; } This should resolve your isse |
|
![]() |
![]() |
![]() |
![]() |
#4 |
New Member
Nafiz Ahmed Khan
Join Date: Nov 2023
Location: Canada
Posts: 27
Rep Power: 2 ![]() |
Hello
I've modified the code and still I couldn't find any results. Where should I be able to check the results. The modified code: Code:
application simpleFoam; startFrom latestTime; startTime 0; stopAt endTime; endTime 100; deltaT 1; writeControl timeStep; writeInterval 100; purgeWrite 0; writeFormat binary; writePrecision 12; writeCompression uncompressed; timeFormat general; timePrecision 6; runTimeModifiable yes; grad1 { // Mandatory entries type grad; libs (fieldFunctionObjects); field U; // Optional (inherited) entries result gradU; region region0; enabled true; log true; timeStart 0; timeEnd 100; executeControl timeStep; executeInterval 1; writeControl timeStep; writeInterval 100; } |
|
![]() |
![]() |
![]() |
![]() |
#5 |
Senior Member
Yann
Join Date: Apr 2012
Location: France
Posts: 1,169
Rep Power: 27 ![]() |
You should have a new gradU variable (file) in your timestep directories.
Did you re-run your simulation? |
|
![]() |
![]() |
![]() |
![]() |
#6 | |
Senior Member
Yann
Join Date: Apr 2012
Location: France
Posts: 1,169
Rep Power: 27 ![]() |
Quote:
Please check the syntax here: https://doc.openfoam.com/2306/tools/...ects/#run-time |
||
![]() |
![]() |
![]() |
![]() |
#7 |
New Member
Nafiz Ahmed Khan
Join Date: Nov 2023
Location: Canada
Posts: 27
Rep Power: 2 ![]() |
Hello Yann,
Yes I rerun the simulation after modifying the code. Still, I couldn't find any results in the timestep. Only epsilon, K, Nut, P,phi and U are available. What to do ? Best Nafiz |
|
![]() |
![]() |
![]() |
![]() |
#8 |
New Member
Nafiz Ahmed Khan
Join Date: Nov 2023
Location: Canada
Posts: 27
Rep Power: 2 ![]() |
Hello Yann,
This the modified code: Code:
functions { gradU { // Mandatory entries type grad; libs (fieldFunctionObjects); field U; // Optional (inherited) entries result gradU; region region0; enabled true; log true; timeStart 0; timeEnd 100; executeControl timeStep; executeInterval 1; writeControl timeStep; writeInterval 100; } } Code:
Time = 1 smoothSolver: Solving for Ux, Initial residual = 1, Final residual = 0.0240735220355, No Iterations 1 smoothSolver: Solving for Uy, Initial residual = 1, Final residual = 0.02458226803, No Iterations 1 smoothSolver: Solving for Uz, Initial residual = 0.999999999999, Final residual = 0.0136152165375, No Iterations 1 GAMG: Solving for p, Initial residual = 1, Final residual = 0.0910537418564, No Iterations 11 time step continuity errors : sum local = 1.04300070627e-05, global = 3.76833088599e-06, cumulative = 3.76833088599e-06 smoothSolver: Solving for epsilon, Initial residual = 1, Final residual = 0.0561016871376, No Iterations 4 smoothSolver: Solving for k, Initial residual = 1, Final residual = 0.0604477590299, No Iterations 4 ExecutionTime = 3.45 s ClockTime = 4 s --> FOAM FATAL ERROR: (openfoam-2306) Attempted non-const reference to const object: tmp<N4Foam14GeometricFieldINS_6TensorIdEENS_12fvPatchFieldENS_7volMeshEEE> From T& Foam::tmp<T>::ref() const [with T = Foam::GeometricField<Foam::Tensor<double>, Foam::fvPatchField, Foam::volMesh>] in file ./src/OpenFOAM/lnInclude/tmpI.H at line 255. FOAM aborting [stack trace] ============= #1 Foam::error::simpleExit(int, bool)sh: 1: addr2line: not found addr2line failed #2 ?sh: 1: addr2line: not found addr2line failed #3 ?sh: 1: addr2line: not found addr2line failed #4 Foam::functionObjects::grad::calc()sh: 1: addr2line: not found addr2line failed #5 Foam::functionObjects::fieldExpression::execute()sh: 1: addr2line: not found addr2line failed #6 Foam::functionObjects::timeControl::execute()sh: 1: addr2line: not found addr2line failed #7 Foam::functionObjectList::execute()sh: 1: addr2line: not found addr2line failed #8 Foam::Time::run() constsh: 1: addr2line: not found addr2line failed #9 Foam::Time::loop()sh: 1: addr2line: not found addr2line failed #10 ?sh: 1: addr2line: not found addr2line failed #11 ?sh: 1: addr2line: not found addr2line failed #12 __libc_start_mainsh: 1: addr2line: not found addr2line failed #13 ?sh: 1: addr2line: not found addr2line failed ============= Aborted (core dumped) |
|
![]() |
![]() |
![]() |
![]() |
#9 |
Senior Member
Yann
Join Date: Apr 2012
Location: France
Posts: 1,169
Rep Power: 27 ![]() |
Not sure about your error.
I don't think this is related, but you can remove these lines: Code:
timeStart 0; timeEnd 100; In order to sort things out, you can also try to remove these ones: Code:
result gradU; region region0; |
|
![]() |
![]() |
![]() |
![]() |
#10 |
New Member
Nafiz Ahmed Khan
Join Date: Nov 2023
Location: Canada
Posts: 27
Rep Power: 2 ![]() |
Hello Yann,
Still, the same issue exists. The updated code is: system/controlDict: Code:
application simpleFoam; startFrom latestTime; startTime 0; stopAt endTime; endTime 100; deltaT 1; writeControl timeStep; writeInterval 50; purgeWrite 0; writeFormat binary; writePrecision 12; writeCompression uncompressed; timeFormat general; timePrecision 6; runTimeModifiable yes; functions { gradU { // Mandatory entries type grad; libs (fieldFunctionObjects); field U; // Optional (inherited) entries enabled true; log true; executeControl timeStep; executeInterval 1; writeControl timeStep; writeInterval 50; } } |
|
![]() |
![]() |
![]() |
![]() |
#11 |
Senior Member
Yann
Join Date: Apr 2012
Location: France
Posts: 1,169
Rep Power: 27 ![]() |
Not sure what is going on, the function definition looks OK.
|
|
![]() |
![]() |
![]() |
![]() |
#12 |
New Member
Nafiz Ahmed Khan
Join Date: Nov 2023
Location: Canada
Posts: 27
Rep Power: 2 ![]() |
Thanks, YANN, for the comments.
The above problem was solved. I just deleted some lines from system/fvSolution: Code:
cache { grad(U); } Last edited by Nafiz375; July 23, 2024 at 16:51. |
|
![]() |
![]() |
![]() |
Tags |
gradient calculation |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Calculate fields and profiles for velocity time average and standard deviation | pbachant | OpenFOAM Post-Processing | 11 | August 16, 2019 06:24 |
serial udf to parallel udf | radioss | Fluent UDF and Scheme Programming | 10 | January 19, 2019 08:56 |
Same pressure gradient but different velocity field | TurbJet | Main CFD Forum | 22 | April 28, 2018 03:35 |
how to calculate dot product of velocity vector and temperature gradient | ramin_rz | Fluent UDF and Scheme Programming | 2 | March 13, 2016 16:57 |
Variables Definition in CFX Solver 5.6 | R P | CFX | 2 | October 26, 2004 02:13 |