FAQ/Programming

From OpenFOAMWiki
< FAQ
Revision as of 19:52, 11 January 2015 by Wyldckat (Talk | contribs)


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.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 doesn't 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 +