These guidelines are based on the working folder located here.

Advanced features


1) Local time stepping

In the system/ directory, open the fvSchemes dictionary and edit the default ddtSchemes entry to localEuler rDeltaT.

The Lorrain scramjet tutorial is a suitable case to employ LTS and the aforementioned time discretisation scheme is the only modification to be made.

Local time stepping is currently inappropriate for axisymmetric and chemically-reacting simulations.



2) On-the-fly dictionary editing

On-the-fly editing was made available primarily for computations on a high-performance computer where days can be lost waiting in a priority queue. The different steps to follow are explained below depending on the dictionary that is affected by the changes.

For the transportProperties dictionary:

  • Open the transportProperties dictionary
  • Edit one or several entries inside the rarefiedParameters or transportModels subdictionaries
  • NB: if you save the file at this point, nothing will happen
  • Add a new key to the modified subdictionary
    applyChanges        true;
    
  • Save the file
  • NB: For safety, once the modification has taken effect, the file can be re-opened and the applyChanges entry can be removed. Save again.
  • If this operation worked, then your simulation should have entered into a second sub-phase of the run, as shown in the log file

Before:

Phase no 1.0  ExecutionTime = 72.29 s  ClockTime = 74 s  Iteration no 4504 (0.04 s)

After:

Phase no 1.1  ExecutionTime = 72.32 s  ClockTime = 74 s  Iteration no 4505 (0.03 s)

For the thermo2TModel dictionary:

  • The steps to follow are similar to the transportProperties dictionary: add the applyChanges key after editing the desired subdictionary and save.

For any other dictionaries:

  • Make modifications to the dictionary in question (e.g., adding additional chemical reactions, etc) and save.
  • Open the hTCProperties dictionary and add the applyChanges key
  • Save the hTCProperties dictionary

As shown in the log file, the simulation enters into a new stage/phase

Before:

Phase no 1.1  ExecutionTime = 153.02 s  ClockTime = 157 s  Iteration no 9074 (0.03 s)

After:

Phase no 2.0  ExecutionTime = 153.05 s  ClockTime = 157 s  Iteration no 9075 (0.03 s)

For all dictionaries,

    applyChangesAtWriteTime        true;

can be used instead of

    applyChanges        true;

should the solution needs to be printed before making modification(s) to the computation.


For boundary conditions:

  • Open the hTCProperties dictionary
  • Add the key
    applyChangesAtWriteTimeAndWait        #numberOfSeconds;
    

    where #numberOfSeconds is an integer value prescribing the time during which the simulation will be paused (give yourself enough time!).

  • Save the hTCProperties dictionary
  • Type in: tail -f log.hy2Foam into the terminal window and wait until the next write time
  • Once the simulation is sleeping, reconstructPar can be used (for a parallel job)
  • Edit the desired boundary condition and save
  • Delete the processors#ID folders and run: decomposePar -latestTime
  • Monitor the log file as the simulation restarts to make sure everything went well



3) Bounding the temperature field

In the thermophysicalProperties dictionary, the temperatureBounds subdictionary shown below can be copy-pasted to bound the temperature field and increase robustness. After stopping the simulation, please make sure that the minimum and maximum temperature values are strictly within these bounds.

temperatureBounds
{
    Tlow      200; //default is   100 K
    Thigh   40000; //default is 40000 K
}

If the temperature field goes unbounded, a warning will be printed in the log file for this iteration. It reports the number of times the limit function had to be called and the minimum/maximum temperature recorded before bounding.

Attempt to use rho2ReactionThermo out of temperature range 3197 times during this iteration.
		Thigh: 40000 < 45289



4) The hyLight switch

>> Unavailable until further notice <<

The hyLight switch located into the thermophysicalProperties dictionary disables some of the code features to run a minimalistic version of the solver. For instance, quantities like the Knudsen number or the overall temperature will not be calculated at each time step when this switch is on (and that even if the set-up of the transportProperties dictionary is telling otherwise). The solution should not be affected by the state of the hyLight switch, only the number of fields to be printed might differ.



5) Adaptive mesh refinement

The dynamicMeshDict dictionary needs to be added to the standard hy2Foam working directory: please refer to the official OpenFOAM tutorials and copy-paste the most appropriate one in the constant/ folder. For instance, the following command line will list all dynamicMeshDict available

tut
find . -type f -name "dynamicMeshDict"

and the one located here

./multiphase/interDyMFoam/RAS/motorBike/constant/dynamicMeshDict

is suitable. In the dynamicRefineFvMeshCoeffs subdictionary, the field on which refinement/coarsening is based is given by the key field. You can either provide the name of an existing field or input any of three hardcoded fields: MachGradient, normalisedDensityGradient or normalisedPressureGradient. If you choose one of these three hardcoded adaptation fields, it will be printed in the results folders. Finally, an example is given below:

dynamicRefineFvMeshCoeffs
{
    // How often to refine
    refineInterval  10000;
    
    // Field to base refinement on
    field normalisedDensityGradient;
    
    // Refine field inbetween lower..upper
    lowerRefineLevel 1.0;
    upperRefineLevel 1e6;
    
    // Unrefine field inbetween 0..unrefine
    unrefineLevel 0.5;
    
    // Have slower than 2:1 refinement
    nBufferLayers   1;
    // Refine cells only up to maxRefinement levels
    maxRefinement   3;
    // Stop refinement if maxCells reached
    maxCells        2000000;
    // Flux field and corresponding velocity field. Fluxes on changed
    // faces get recalculated by interpolating the velocity. Use 'none'
    // on surfaceScalarFields that do not need to be reinterpolated.
    correctFluxes
    (
        (pos none)
        (neg none)
        (phi none)
        (phiEp none)
        (phiEvk none)
        (amaxSf none)
        (rho_pos none)
        (rho_neg none)
        (cSf_pos none)
        (cSf_neg none)
        (e_pos none)
        (e_neg none)
        (ev_pos none)
        (ev_neg none)
        (p_pos none)
        (p_neg none)
        (rPsi_pos none)
        (rPsi_neg none)
    );
    
    // Write the refinement level as a volScalarField
    dumpLevel       true;
}

The command line to run hy2Foam with adaptive mesh refinement, is

hy2DyMFoam > log.hy2DyMFoam 2>&1 &

In the logfile, the number of adaptation cycles that the mesh has undergone at any time is given before the ‘/’ symbol, that is 2 in the following example:

Phase no 2/1.0  ExecutionTime = 153.02 s  ClockTime = 157 s  Iteration no 9074 (0.03 s)

NB: In Paraview, on the left-hand side panel, Properties tab, untick Decompose Polyhedra and then set Representation to Surface With Edges.