CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM

How to compile a new utility

Register Blogs Community New Posts Updated Threads Search

Like Tree3Likes
  • 3 Post By alberto

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   December 12, 2009, 12:55
Unhappy How to compile a new utility
  #1
New Member
 
raul
Join Date: Nov 2009
Posts: 13
Rep Power: 16
rudy is on a distinguished road
Hi,
I am new openfoam user and I am not good at programming . I intend to find grad of a scalar variable which is a solution of my computation . Initially I used a function "gradient of unstructured variable" from paraFoam but it is giving me some error.So I am trying to make my own utility to calculate gradient of scalar quantity.Now,I guess if I make a new utility i would have to compile it with my solver and for that I am following instructions given in Userguide.I mentioned utilityFunctionObjects lib name in solver/Make/options and then used wmake command from inside solver dir. I guess it goes on well and ultimately yields a messege that solver is uptodate,but when i use the new utility command name from inside case directory it says command is not found.Can anyone please tell me what exact steps I should take to compile my newly defined utility file with the intended solver.
Thanks and regards,
rudy.
rudy is offline   Reply With Quote

Old   December 12, 2009, 20:29
Default
  #2
Member
 
Alan Russell
Join Date: Aug 2009
Location: Boise, Idaho USA
Posts: 61
Rep Power: 16
AlanR is on a distinguished road
Rudy,

Some searching through the OF forums will turn up a number of links to courses, tutorials, etc that cover programming and customizing applications. Here's a link that may be helpful: http://www.openfoamworkshop.org/2009...ngTutorial.pdf. A recent thread has an excellent list of links. http://www.cfd-online.com/Forums/ope...thingelse.html. Learning Foam is challenging, but it's worth the effort.
Good luck, Alan
AlanR is offline   Reply With Quote

Old   December 13, 2009, 00:42
Default
  #3
Senior Member
 
Alberto Passalacqua
Join Date: Mar 2009
Location: Ames, Iowa, United States
Posts: 1,912
Rep Power: 36
alberto will become famous soon enoughalberto will become famous soon enough
Quote:
Originally Posted by rudy View Post
Hi,
I am new openfoam user and I am not good at programming . I intend to find grad of a scalar variable which is a solution of my computation . Initially I used a function "gradient of unstructured variable" from paraFoam but it is giving me some error.So I am trying to make my own utility to calculate gradient of scalar quantity.Now,I guess if I make a new utility i would have to compile it with my solver and for that I am following instructions given in Userguide.I mentioned utilityFunctionObjects lib name in solver/Make/options and then used wmake command from inside solver dir. I guess it goes on well and ultimately yields a messege that solver is uptodate,but when i use the new utility command name from inside case directory it says command is not found.Can anyone please tell me what exact steps I should take to compile my newly defined utility file with the intended solver.
Thanks and regards,
rudy.
Take a look at laplacianFoam. In write.H gradients of the temperature are computed and stored. The procedure is general.

To sum it up
  • Compute the gradient vector and store it in a volVectorField as in
Code:
volVectorField gradT = fvc::grad(T);
  • You can decompose the gradient in its components too, storing them in separate files. For example for the x component, which will be stored in a file called "gradTx", you can use:
Code:
volScalarField gradTx
        (
            IOobject
            (
                "gradTx",
                runTime.timeName(),
                mesh,
                IOobject::NO_READ,
                IOobject::AUTO_WRITE
            ),
            gradT.component(vector::X)
        );
Note that
  • the instructions are enclosed in an if whose condition is runTime.outputTime(), which means that fields will be written when a set of data will be automatically saved by the solver
  • the gradient components are stored, but the gradient vector field is not stored. To do that simply add th following line after the definition of gradT:
Code:
 gradT.write();
You can edit your code adding similar lines for the variable of your interest, and then rebuild the application with
Code:
wmake
in the directory containing the source code.

I hope this help.

Best,
Alberto

P.S. Simple answers to simple questions! Sometime a "search for it" simply does not work, especially for new users.
elvis, tfuwa and y_jiang like this.
__________________
Alberto Passalacqua

GeekoCFD - A free distribution based on openSUSE 64 bit with CFD tools, including OpenFOAM. Available as in both physical and virtual formats (current status: http://albertopassalacqua.com/?p=1541)
OpenQBMM - An open-source implementation of quadrature-based moment methods.

To obtain more accurate answers, please specify the version of OpenFOAM you are using.

Last edited by alberto; December 13, 2009 at 00:44. Reason: Added notes on build
alberto is offline   Reply With Quote

Old   December 14, 2009, 08:43
Default
  #4
New Member
 
raul
Join Date: Nov 2009
Posts: 13
Rep Power: 16
rudy is on a distinguished road
Thanks a lot to both of u, I did develop my own utility to find gradient using ur instructions and it's working now...
regards,
rudy
rudy is offline   Reply With Quote

Old   October 1, 2011, 22:48
Default
  #5
Senior Member
 
Join Date: Nov 2009
Location: Michigan
Posts: 135
Rep Power: 16
doubtsincfd is on a distinguished road
gradT.write(); returns a zeroGradient field for patches. But the field is non-zero in component files like gradTx. Why?
doubtsincfd is offline   Reply With Quote

Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
ATTN ALL: SOLUTON TO UDF COMPILE PROBLEM Rizwan Fluent UDF and Scheme Programming 40 March 18, 2018 06:05
problem with sampling Utility in openFOAM 1.6 carmir OpenFOAM Post-Processing 10 February 26, 2014 02:00
Error compile file udf czfluent Fluent UDF and Scheme Programming 24 September 26, 2009 13:24
Can someone PLEASE document the development version installation bernd OpenFOAM Installation 76 November 14, 2008 21:51
Help for udf compile error richard FLUENT 3 October 12, 2003 23:13


All times are GMT -4. The time now is 12:15.