Quote:
|
Create a new field from an expression
Hi Dear Bernhard
thanks for your posts, replies and "swak4Foam". I could solve a PDE using "solveLaplacianPDE" function But I have another question on the "expessionField" function. I am trying to create and calculate a new transformed velocity field using this function. I followed ,for starting, the example available in slides on swak4Foam (No C++, please. We’re users!, Bernhard F.W. Gschaider, June 2011, slide number 61/176): --------------------------------------------------------------------------------------------------------------------------------- libs ( " libswakFunctionObjects .so" ); functions ( liquidVel { type expressionField; outputControl outputTime; //outputInterval 1; fieldName Uliquid; expression "U*alpha1"; autowrite true } ) ; --------------------------------------------------------------------------------------------------------------------------------------- but it does not work and OpenFoam gives the following error: --------------------------------------------------------------------------------------------------------------------------------------- /*---------------------------------------------------------------------------*\ | ========= | | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | | \\ / O peration | Version: 2.1.x | | \\ / A nd | Web: www.OpenFOAM.org | | \\/ M anipulation | | \*---------------------------------------------------------------------------*/ Build : 2.1.x-0cbac23c1af5 Exec : interFoamWithSources Date : Oct 27 2013 Time : 17:53:21 Host : "ali-pc" PID : 2918 Case : /home/ali/OpenFOAM/ali-2.1.x/run/Afkhami2008/cylinder-radius0.2-sourceterm-PDE nProcs : 1 sigFpe : Enabling floating point exception trapping (FOAM_SIGFPE). fileModificationChecking : Monitoring run-time modified files using timeStampMaster allowSystemOperations : Disallowing user-supplied system call operations // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // Create time Create mesh for time = 0 PIMPLE: Operating solver in PISO mode Reading field p_rgh Reading field alpha1 Reading field U Reading/calculating face flux field phi Reading transportProperties Selecting incompressible transport model Newtonian Selecting incompressible transport model Newtonian Selecting turbulence model type laminar Reading g Calculating field g.h time step continuity errors : sum local = 0, global = 0, cumulative = 0 DICPCG: Solving for pcorr, Initial residual = 0, Final residual = 0, No Iterations 0 time step continuity errors : sum local = 0, global = 0, cumulative = 0 Courant Number mean: 0 max: 0 Starting time loop --> FOAM FATAL IO ERROR: attempt to read beyond EOF file: /home/ali/OpenFOAM/ali-2.1.x/run/Afkhami2008/cylinder-radius0.2-sourceterm-PDE/system/controlDict::functions at line 88. From function ITstream::read(token&) in file db/IOstreams/Tstreams/ITstream.C at line 83. FOAM exiting ----------------------------------------------------------------------------------------------------------------------------------- I have created the "Uliquid" file in the "0" folder based on the "U" file. I have no idea on this error message. I'm Looking forward to some directions. your valuable time is highly appreciated. thanks, Ali Ghaffari |
you missed semicolon in your expression, it should be like that:
Quote:
|
Quote:
thanks for your reply. I modified it by semicolon But again exactly the same error message appears. What else may be wrong? thanks |
Quote:
Is it maybe the line "autowrite true" without the semicolon? |
Hi Dear Bernhard Gschaider
yes it was the reason for error : "autowrite true" without the semicolon. thanks so much. |
Hi Dear Bernhard Gschaider
Its me again with another question. I have calculated the magnitude of the gradient of a scalar field in two ways: 1) by using the "magGrad" from "foamCalc" utility: foamCalc magGrad distance 2) by defining a new Field in "controldict" file: functions( distGrad { type expressionField; outputControl timeStep; outputInterval 1; fieldName graddistance; expression "-grad(distance)"; autowrite true; } ); and finally I have calculated the magnitude of the new field "graddistance". ("distance" is a new scalar field which is calculated from solving the Laplaces equation via "solveLaplacianPDE" function.) But the results are very much different (in order of 1000000). It is so strange and confusing for me. Which way is more reliable? I need the gradient of "distance" in the solution time. Is there any better method for its calculation? Thank you Regards |
Quote:
|
Quote:
|
Quote:
|
Dear Bernhard Gschaider
Thanks for your attention. I could finally find the reason of the differences. It was due to the "writePrecision" in the controlDict file. The differences were existed when the default value ,6, was chosen. But by increasing the "writePrecision" the differences decreased. finally no differences were observed by choosing the "20" for "writePrecision". I think that the "magGrad" function from "foamCalc" reads the data from written results files But the "grad" function from "swak" reads data from RAM. Please correct me if I am wrong? thanks Ali |
Quote:
So that problem solved itself? Fine. |
All times are GMT -4. The time now is 20:12. |