FAQ/Programming

From OpenFOAMWiki
< FAQ


1 FAQ Section 7: Programming

Questions about writing applications and solvers

1.1 Compiling

1.1.1 Where does wmake get the values for the environmental variables from?

All wmake variables come from (in this order)

  1. $WM_DIR/rules/General/general
  2. $WM_DIR/rules/${WM_ARCH}${WM_COMPILER}/general
  3. $WM_DIR/rules/${WM_ARCH}/c++

(Source: [1])

For a complete list of foam related environment variables, see Environment_variables.

1.1.2 What does "-lOpenFOAM" and '-lfiniteVolume' mean?

For example, in the file src/finiteVolume/Make/options is the following content: EXE_INC = \

   -I$(LIB_SRC)/triSurface/lnInclude \
   -I$(LIB_SRC)/meshTools/lnInclude \

LIB_LIBS = \

   -lOpenFOAM \
   -ltriSurface \
   -lmeshTools

The last 3 lines refer to the libraries OpenFOAM, triSurface and meshTools:

  • On Linux, this equates to the respective 3 files: libOpenFOAM.so, libtriSurface.so and libmeshTools.so
  • On Mac OS X, this equates to the respective 3 files: libOpenFOAM.dylib, libtriSurface.dylib and libmeshTools.dylib
  • On Window, this equates to the respective 3 files, although there are two variants of files:
    • The interface files: libOpenFOAM.a, libtriSurface.a and libmeshTools.a - these are always needed for building on Windows with GCC.
    • The actual binary library files, i.e. the ones used for running OpenFOAM: libOpenFOAM.dll, libtriSurface.dll and libmeshTools.dll

For a lot mode details about this, read: 3. Shared Libraries chapter at tldp.org

1.2 Working with fields

1.2.1 How to calculate the field value of an arbitrary point?

See Calculating the field value at an arbitrary point.

1.3 OpenFOAM's template library

1.3.1 What is the object registry?

See objectRegistry explained.

1.3.2 What do the filenames mean?

OpenFOAM's file naming convention. For exampleClass, these filenames may exist:

  • exampleClass.H - Main header.
  • exampleClass.C - Main body.
  • exampleClassFwd.H - Forward declarations.
  • exampleClassI.H - Inline functions implemented.
  • exampleClassIO.C - IO functions implemented.
  • exampleClassM.H - Macros.
  • exampleClassFunctionName.C - FunctionName's implementation (seperated for no other reason than aesthetics).

There may be others as well. Unknown naming conventions:

  • exampleClasss.H
  • exampleClasss.C

Some filenames add an s to the end. These may be associated with static variables / functions. They may also be associated with the NoRepository flag.

1.3.3 What is tmp<>?

See tmp explained.

1.3.4 What is runtime selection?

See Runtime selection mechanism.

1.4 Adding new features

1.4.1 How do I add a new wall-function?

See the How-To: Adding a new wall-function.

1.4.2 How do I add a new boundary condition?

See the How-To: Adding a new boundary condition.

1.5 Frequently occurring issues

1.5.1 error: call of overloaded ‘sqrt(double)’ is ambiguous

For example, if you use a piece of code like this one:

volScalarField strainRate = sqrt(2.0)*mag(symm(fvc::grad(U)));

you're likely to get this error message:

error: call of overloaded ‘sqrt(double)’ is ambiguous

Possible solutions, instead of simply using sqrt(2.0):

::sqrt(2.0)
scalar(::sqrt(2.0))
::sqrt(scalar(2.0))

The reason for this is that OpenFOAM has got several function overloads for sqrt for dealing with fields, but it does not overload the original function sqrt, which leads to the compiler getting confused with which overload it should uses.

For more details, please refer to posts #10 and #11 on this thread: adding strainRate in a solver

Facts about "FAQ/Programming"RDF feed
FaqdescriptionQuestions about writing applications and solvers +
FaqnameProgramming +
Faqnumber7 +