Skip to content

Configuration

Gerasimos Chourdakis edited this page Dec 20, 2018 · 20 revisions

In order to run a coupled simulation, you need to:

  1. prepare a preCICE configuration file (described in the preCICE configuration),
  2. prepare an adapter's configuration file,
  3. set the coupling boundaries in the OpenFOAM case,
  4. load the adapter, and
  5. start all the solvers normally, from the same directory, e.g. in two different terminals.

If you prefer, you may find an already prepared case in the tutorials/ directory. See also the description of this case in our Tutorial for CHT: Flow over a heated plate.

You may skip the section "Advanced configuration" in the beginning, as it concerns only special cases.

The adapter's configuration file

The adapter is configured via the file precice-adapter-config.yml, which needs to be present in the case directory. This file is a YAML file with the following form:

participant: Fluid

precice-config-file: /path/to/precice-config.xml

interfaces:
- mesh: Fluid-Mesh
  patches: [interface]
  write-data: Temperature
  read-data: Heat-Flux

CHTenabled: true

The participant needs to be the same as the one specified in the precice-config-file, which is the main preCICE configuration file. If the path is omitted, precice-config.xml must be in the parent directory of the cases, where preCICE is started from.

In the interfaces, a list with the coupled interfaces is provided. The mesh needs to be the same as the one specified in the precice-config-file. The patches specifies a list of the names of the OpenFOAM boundary patches that are participating in the coupled simulation. These need to be defined in the files included in the 0/ directory. The values for write-data and read-data for conjugate heat transfer can be Temperature, Heat-Flux, Sink-Temperature, or Heat-Transfer-Coefficient. Values like Sink-Temperature-Domain1 are also allowed.

For a Dirichlet-Neumann coupling, the write-data and read-data can be either (Temperature, Heat-Flux) or (Heat-Flux, Temperature). For a Robin-Robin coupling, they can be either (Heat-Transfer-Coefficient, Sink-Temperature) or (Sink-Temperature, Heat-Transfer-Coefficient).

The CHTenabled enables the Conjugate Heat Transfer module. There is also a Fluid-Structure Interaction module (todo: add more information when FSI is merged).

Configuration of the OpenFOAM case

A few changes are required in the configuration of an OpenFOAM case, in order to specify the interfaces and load the adapter. For some solvers, additional parameters may be needed (see "advanced configuration").

Boundary conditions

The type of the read-data needs to be in accordance with the respective boundary conditions set for each field in the 0/ directory of the case. For conjugate heat transfer, use the following:

  • For read-data: Temperature, use type: fixedValue for the interface in 0/T. OpenFOAM requires that you also give a (redundant) value, but the adapter will overwrite it. ParaView uses this value for the initial time. As a placeholder, you can e.g. use the value from the internalField.
interface
{
    type            fixedValue;
    value           $internalField;
}
  • For read-data: Heat-Flux, use type: fixedGradient for the interface in 0/T. OpenFOAM requires that you also give a (redundant) gradient, but the adapter will overwrite it.
interface
{
    type            fixedGradient;
    gradient        0;
}
  • For read-data: Sink-Temperature or Heat-Transfer-Coefficient, use type: mixed for the interface in 0/T. OpenFOAM requires that you also give (redundant) values for refValue, refGradient, and valueFraction, but the adapter will overwrite them.
interface
{
    type            mixed;
    refValue        uniform 293;
    valueFraction   uniform 0.5;
    refGradient     uniform 0;
}

Read the OpenFOAM User Guide for more on boundary conditions.

Load the adapter

To load this adapter, you must include the following in the system/controlDict configuration file of the case:

functions
{
    preCICE_Adapter
    {
        type preciceAdapterFunctionObject;
        libs ("libpreciceAdapterFunctionObject.so");
    }
}

This directs the solver to use the preciceAdapterFunctionObject function object, which is part of the libpreciceAdapterFunctionObject.so shared library. The name preCICE_Adapter can be arbitrary.


Advanced configuration

These additional parameters may only concern some users is special cases. Keep reading if you want to use an incompressible or basic solver for conjugate heat transfer, if you are using a solver with different variable names (e.g. a multiphase solver) or if you are trying to debug a simulation.

Additional properties for some solvers

Some solvers may not read all the material properties that are required for a coupled simulation. These parameters need to be added in the OpenFOAM configuration files, but the solver does not need to read them.

Conjugate heat transfer

For conjugate heat transfer, the adapter assumes that a solver belongs to one of the following categories: compressible, incompressible, or basic. Most of the solvers belong in the compressible category and do not need any additional information. The other two need one or two extra parameters, in order to compute the heat flux.

For incompressible solvers (like the buoyantBoussinesqPimpleFoam), you need to add the density and the specific heat in the constant/transportProperties file. For example:

rho              rho [ 1 -3  0  0 0 0 0 ] 50;
Cp               Cp  [ 0  2 -2 -1 0 0 0 ] 5;

For basic solvers (like the laplacianFoam), you need to add a constant conductivity in the constant/transportProperties:

DT               DT  [ 0  2 -1  0 0 0 0 ] 1;
k                k   [ 1  1 -3 -1 0 0 0 ] 100;

Do not delete the, already provided in the pure solver, DT, as laplacianFoam expects it. The value of k is connected to the one of DT and depends on the density (rho [ 1 -3 0 0 0 0 0 ]) and heat capacity (Cp [ 0 2 -2 -1 0 0 0 ]). It needs to hold DT = k / rho / Cp.

Additional parameters in the adapter's configuration file

Some optional parameters can allow the adapter to work with more solvers, whose type is not determined automatically, their fields have different names or they do not work well with some features of the adapter.

User-defined solver type

The adapter tries to automatically determine the solver type, based on the dictionaries that the solver uses. However, you may manually specify the solver type to be basic, incompressible or compressible for a CHT simulation:

solverType: compressible

This will force the adapter use the boundary condition implementations for the respective type.

Parameters and fields with different names

The names of the parameters and fields that the adapter looks for can be changed, in order to support a wider variety of solvers. You may specify the following parameters in the adapter's configuration file (the values correspond to the default values):

# Temperature field
nameT: T
# transportProperties dictionary
nameTransportProperties: transportProperties
# thermal conductivity
nameKappa: k
# density
nameRho: rho
# heat capacity for constant pressure
nameCp: Cp
# Prandtl number
namePr: Pr
# turbulent thermal diffusivity
nameAlphat: alphat

Debugging

The adapter also recognises a few more parameters, which are mainly used in debugging or development. These are optional and expect a yes or a no value. Some or all of these options may be removed in the future.

  • preventEarlyExit: No prevents the adapter from setting the solver's endTime to infinity.
  • evaluateBoundaries: No prevents the adapter from computing the values on the faces (from the values on the cell centers) after reading a checkpoint.
  • subcycling: No disallows the subcycling and an error is reported in that case.
  • disableCheckpointing: Yes prevents the adapter from adding any fields into the list of checkpointed fields.

The user can toggle debug messages at build time.