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

How to compile a new utility

Register Blogs Members List Search Today's Posts Mark Forums Read

Like Tree1Likes
  • 1 Post By alberto

Reply
 
LinkBack Thread Tools 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: 4
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: 4
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. manual/documentation/guide/tutorial/andanythingelse. 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,814
Rep Power: 21
alberto 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 likes this.
__________________
Alberto

GeekoCFD - A free distribution based on openSUSE 64 bit with CFD tools, including OpenFOAM. Available as live DVD/USB, hard drive image and virtual image.
GeekoCFD 32bit - The 32bit edition of GeekoCFD.
GeekoCFD text mode - A smaller version of GeekoCFD, text-mode only, with only OpenFOAM. Available in a variety of virtual formats.

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: 4
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
Member
 
Omkar Champhekar
Join Date: Nov 2009
Location: Cincinnati, Ohio
Posts: 80
Rep Power: 4
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

Thread Tools
Display Modes

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 On
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 26 January 24, 2012 12:09
problem with sampling Utility in openFOAM 1.6 carmir OpenFOAM Post-Processing 7 December 6, 2011 18:47
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 17:48.