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

How do I install a custom solver?

Register Blogs Community New Posts Updated Threads Search

Like Tree6Likes
  • 1 Post By NJG
  • 5 Post By chegdan

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   January 25, 2013, 14:29
Default How do I install a custom solver?
  #1
NJG
Member
 
Nick Gutschow
Join Date: Jan 2013
Posts: 36
Rep Power: 13
NJG is on a distinguished road
First off let me say I am quite new to Ubuntu, C++, and OpenFOAM, nor am I all that adept at programming. My background is more in experimental fluid mechanics. But we all have to start somewhere, right?

Ok, so my goal here is to "install" (or "add" or any other verb that would be appropriate) a custom solver to OpenFOAM 2.1.1. I am working on a CFD project that is a follow up of some previous work that was done with this custom solver. I have successfully installed OpenFOAM on my system and run several tutorials, so she is running correctly I think. Now I have this custom solver and related folders and files that need to be added to my install in a way that I can run it. So, basically I need to know where these files need to go and how I should build/compile/whatever them.

Here is a rough inventory of what I have:

-applications/solvers/new-solver-name/...
-new-solver-name.C
-lots of .H files for various variables, readTransportProperties, and
createFields
-make/...
-a files and an options file

-src/
-finiteVolume/...
-an Allwmake file
-fields/fvPatchFields/derived/buoyantDynamicPressure/...
-a .C, .H, and .dep fvPathc files related to
buoyantDynamicPressure
-lnInclude/...
-apparently the same .C and .H file in the line above
-make/
-a files and an options file
-turbulenceModels/...
-an Allwmake file
-incompressible/...
-an Allwmake file
-RAS/...
-a bunch of folders including a couple kOmegas, a Make,
another lnInclude, and a derviedFvPatchFields, all
ultimately including solver specific (I think) C., H., and .dep
files

That's it. I can offer more detail as needed.

First off, I know I need to add these to my file tree somehow. But, I am unclear on whether I should add these into my $WM_PROJECT_USER_DIR (which I understand to be the "OpenFOAM/user-2.1.1/..." location from which the tutorials are run) or if they need to be added to $WM_PROJECT_DIR (which I understand to be the "FileSystem/opt/openfoam211/..." location that seems to contain all the OpenFOAM nuts and bolts), or both. And if I add them to the opt/openfoam211 side of things I am not sure if they are added in addition or in replacement off existing files.

Next, I will ultimately need to run/build/compile some of these so she is ready to go. I have a sense that this comes from the Allwmake files, but I am not sure how. And as for building the solver, I am not sure how to do that (wmake within the solver directory?), so some advice there would be nice as well.

Thanks so much for your help. I apologize for the basic nature of this request and am grateful for your responses. Also, if this question is in the wrong place in these forums, my apologies.

Best,
NG
Pavlord likes this.
NJG is offline   Reply With Quote

Old   January 25, 2013, 14:31
Default
  #2
NJG
Member
 
Nick Gutschow
Join Date: Jan 2013
Posts: 36
Rep Power: 13
NJG is on a distinguished road
Reading my post I see the indentation I used to make clear the folder structure of what I have was lost, so it is not so clear what is in what folder. My apologies, I can clear this up is needs be.
NJG is offline   Reply With Quote

Old   January 25, 2013, 14:50
Default
  #3
NJG
Member
 
Nick Gutschow
Join Date: Jan 2013
Posts: 36
Rep Power: 13
NJG is on a distinguished road
Let me also add that I am presently reading the User Guide section 3.2, which should shed a lot of light on this I hope, and so if you respond you can assume I have at least familiarized myself with that.

-NG
NJG is offline   Reply With Quote

Old   January 26, 2013, 06:49
Default
  #4
NJG
Member
 
Nick Gutschow
Join Date: Jan 2013
Posts: 36
Rep Power: 13
NJG is on a distinguished road
Ok, I have I think mostly figured this out. I can as wished put all my new stuff in $WM_PROJECT_USER_DIR as wished (and as I did). Most of problems have come from the fact the solver was written in a previous version of OpenFOAM, and then I need to go through and edit accordingly.

Any insight anyone has would still be appreciated.

-NG
NJG is offline   Reply With Quote

Old   January 30, 2013, 06:12
Default
  #5
Member
 
Jim Knopf
Join Date: Dec 2010
Posts: 60
Rep Power: 15
JimKnopf is on a distinguished road
Hi There,

I'm not sure you got a solution allready.

First: You can put your code where ever you want, if you have the openFoam Variables in your shell

You have to compile the code with wmake. Make sure that in the Make/files file

EXE=$(FOAM_USER_APPBIN)/nameOfSolver


If your solver is for a older foam version, you may need to adjust the includes in options.

Greets
Jim
JimKnopf is offline   Reply With Quote

Old   January 30, 2013, 19:03
Default a method to the madness
  #6
Senior Member
 
Daniel P. Combest
Join Date: Mar 2009
Location: St. Louis, USA
Posts: 621
Rep Power: 0
chegdan will become famous soon enoughchegdan will become famous soon enough
To add to this discussion, I would approach this in a slightly different manner in the version of a long post starting...now:

1. Compile OpenFOAM yourself If you are using ubuntu, I would remove the existing OpenFOAM install that you did with sudo apt-get install and compile 2.1.x from scratch. It is actually very straightforward and will be good practice to get to know Ubuntu and OpenFOAM. Some good instructions are located here. Though the package install of Ubuntu is handy, i think compiling from scratch is a much better idea.

2. Practice compiling a simple solver There are other things that may be difficult for a novice programmer when compiling a custom solver (like debugging). But a good intermediate step is to compile an existing solver with a different name or add more to an existing solver. A basic example is located here. At this point you might want to get a cup of coffee and start reading the users guide and programmers guide. This will save you lots of time by reading them and also avoid posting something that is already answered in the manuals.

3. Program and Compile your custom solver By now, you will have some experience as to what you need to do to compile a custom solver. If there are mistakes in your coding, you will need to debug it and recompile after you correct errors. Take each error message and correct them one by one, thinking about what could be causing the error. Use the source code documentation here to help with the coding and figuring out how classes are assembled in OpenFOAM and what you can access in your solver. You will receive errors and if you don't know what the error message is, then search the forum or use google. If you are stuck, then provide lots of detail and/or code. As a tip, better formatting will get some attention from users, as it shows you took time to communicate your question. Some examples and help are located here. Be patient on your posts and don't bump them as people might be less likely to answer a question that is replied to by the author 23 times in a 2 day period (you're doing well so far ). Use the edit functionality to correct your posts if you have made a mistake (i will probably need to do that for this post). Refer to http://www.cfd-online.com/Forums/ope...-get-help.html to get some help to how to post.

4. Set up a test case Even if a solver compiles, it may still give errors at runtime e.g. floating point errors due to divide by zero. Setting up a test case with an adequate mesh, correct boundary conditions, and some knowledge of expected outcome e.g. the temperature on the left side will be higher than here because of ... is helpful. Change your discretization schemes in a logical and methodical way e.g. use steadyState for a times discretization scheme if its a steady state solver or use upwind for your divergence schemes as a first approximation.

5. Validate your solver Come up with a simple example that may have an analytic solution or experimental results. Play with the disretization schemes (in a logical and methodical manner) and use reasonable values for physiochemical values (i.e. viscosity, diffusivity, etc.), initial conditions, and boundary values. Always try to tune your case to get closer to the analytic solutions. If it is still very far off from your validation data, go back and reassess your model and possibly change your solver.

6. Celebrate and then plan a strategy and execute said strategy If you have validated your solver and everything works great then you take a break, relax for a bit, and continue your work at a later time. Writing the solvers and then running them are two different things so take a break and gather your wits to come up with an efficient strategy for running cases (e.g. what dimensionless numbers are present in my system and how can i design a set of runs to test a meaningful range of values?). Once you have a strategy, you can automate the running of cases with bash scripts like the allrun scripts located in many tutorials; if you like python you can use pyFoam to run and analyze your results; and/or use swak4Foam to create realistic initial conditions, boundary conditions, or probe your domain.

You may already know some of this, but its good to have them written down here in case others stumble upon the same question. Good luck and post back if you need help.

p.s. sorry for the long post.

Last edited by chegdan; January 30, 2013 at 19:43. Reason: typos and additions to post
chegdan 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
ANSYS Workbench on "Uncertified" Linux Distros hsr CFX 289 April 20, 2023 09:23
Unexplained Error during Solver Runs cfb CFX 6 November 9, 2012 15:42
Strange residuals of the Density Based Solver Pat84 FLUENT 0 October 22, 2012 15:59
Custom derivative method in ODE solver. l_r_mcglashan OpenFOAM 1 January 27, 2011 23:12
why the solver reject it? Anyone with experience? bearcat CFX 6 April 28, 2008 14:08


All times are GMT -4. The time now is 10:39.