insightcae-documentation

Extensions to Backend Tools

OpenFOAM

InsightCAE bundles a number of extensions to OpenFOAM which are used in cases created by the toolkit.

Additional Tools

computeVectorPotential

computeVectorPotential reads a velocity field U and computes a vector potential A, whose curl reproduces the velocity:

curl(A) = U

The vector potential is computed in the Coulomb gauge (div(A) = 0) by solving the vector Poisson equation

laplacian(A) = -curl(U)

Optionally, a mean velocity field is subtracted first. The vector potential of the fluctuation U - UMean is computed then, e.g. for the analysis of LES results.

The result is written as a field A (dimension of velocity times length) into each processed time directory.

Usage
computeVectorPotential [-UName U] [-UMeanName UMean] [-AName A] [-writeResidual] [time selection options] [-parallel]

Example: vector potential of the velocity fluctuation at the latest time:

computeVectorPotential -latestTime -UMeanName UMean

The case does not need any entries for A in fvSchemes or fvSolution. If fvSolution contains a solver entry A, it is used for all linear solves. Otherwise PCG/DIC with a tolerance of 1e-10 is used.

Options
Option Default Description
-UName <name> U name of the velocity field
-UMeanName <name> none name of a mean velocity field, which is subtracted from the velocity field before the computation. Time directories without this field are skipped.
-AName <name> A name of the vector potential field. If this field already exists in the time directory, its boundary conditions are used (see below).
-writeResidual off additionally write the field curl(A) - U as <AName>_curlResidual
-noHarmonicCorrection off disable the harmonic correction (see below)
-harmonicPatches '(<names or regexps>)' all patches with Dirichlet conditions restrict the harmonic correction fields to these patches. This reduces the effort for cases with many wall patches.
-maxDefectIter <n> 30 maximum number of defect correction iterations (see below). 0 disables the defect correction.
-defectTol <tol> 1e-6 tolerance of the defect correction (relative change of A)
-maxOuterIter <n> 500 maximum number of outer iterations of each Poisson solve
-outerTol <tol> 1e-8 tolerance of the outer iterations (relative change)
-laplacianScheme '<scheme>' Gauss linear corrected discretisation of the laplacian
-solverLog off print the performance of every linear solver call

In addition, the usual time selection options (-time, -latestTime, -noZero, …) and -parallel are available.

Boundary conditions

If the field A does not exist, the boundary conditions are created as follows:

On boundaries with in- or outflow (U.n != 0), the default conditions are not exact. The tangential value of A on these boundaries is determined by the velocity distribution and must be prescribed by the user. To do so, create a field A with suitable boundary conditions in the time directory (e.g. fixedValue with the correct tangential values). Its boundary conditions are then used.

Note: an A field written by a previous run of the tool also contains the boundary values of the harmonic correction. It is reused, if it is not deleted.

Periodic boundaries and harmonic correction

The solution of the Poisson equation with zero tangential wall values cannot represent a net flux through a pair of periodic patches. Examples are the bulk flow in a periodic channel or pipe and the swirl through the periodic sides of a rotational sector. This part of the velocity field is a potential flow (curl-free and divergence-free). It is restored by a least-squares fit of the remaining residual U - curl(A) with the curls of two kinds of correction fields:

All correction fields satisfy the periodic constraints, so A remains periodic. The transformation of translational and rotational cyclic and cyclicAMI patches is determined from the patch geometry. This also works for decomposed cases, where the cyclic faces are distributed to processorCyclic patches.

A mean velocity along a direction which is periodic in all directions (e.g. a triply periodic box with a mean flow) cannot be represented by any periodic vector potential. In this case, the missing mean velocity is reported in a warning. If required, subtract it first using -UMeanName.

The correction fields are only constructed per patch. If separate walls are contained in a single patch (e.g. inner and outer cylinder of an annulus), the walls should be split into separate patches.

Defect correction

The compact laplacian and the Gauss curl (with linear interpolation) do not match exactly. For fields with a lot of content at grid scale (e.g. turbulent fluctuations from LES), this mismatch causes a significant error. It is removed by a defect correction. Each iteration computes the residual r = U - curl(A), solves laplacian(dA) = -curl(r) with homogeneous boundary conditions and adds dA to A. The iteration is accelerated by Anderson mixing. For smooth fields, it converges within a few iterations. For LES fluctuation fields, the default of 30 iterations considerably reduces the residual. Each iteration costs one Poisson solution, so -maxDefectIter can be lowered if run time matters more.

Outer iterations

Each Poisson equation is solved component-wise (segregated). Some couplings between the components are treated explicitly: across rotational periodic patches, in the directionMixed conditions on inclined walls, and in the non-orthogonal correction. These are converged by outer iterations, accelerated by Anderson mixing, until the relative change falls below -outerTol. On 2D meshes, the component normal to the plane (the stream function) is solved as a separate scalar equation, since OpenFOAM does not solve the empty direction of vector equations.

Diagnostics

After the computation, the following quantities are reported:

A warning is given for a relative residual above 1%. Typical causes:

All curls and divergences are evaluated by the Gauss theorem with linear interpolation, independently of the case’s fvSchemes.

FieldDataProvider

The FieldDataProvider class provides a swiss-army-knife-like source for field data. It is used in a number of places, where field data is required as a parameter. Some examples are described in the next section.

The field data is described by a single line of text. The provided data can be steady or unsteady and homogeneous or inhomogeneous.

The syntax of the input line is:

<provider type> [additional input for some provider types] <steady|unsteady>   <time instance 1 data>  <time instance 2 data> ...

The different provider types together with their required value data are described in the following.

The keywords unsteady or steady select whether the input is time dependent. The steady keyword is the default and can be omitted. For unsteady input, the time instance data is a pair of a scalar time value and the value data. In the steady case, only the value data is required.

These provider types are known:

uniform

The value data is single value.

Example:

uniform (1 0 0)

nonuniform

The value data is a list of values. The required number of entries is dependent on the context in which the FieldDataProvider is used. For a boundary condition for example, it needs to match the number of faces.

Example:

nonuniform 7(0 0 0 1 1 2 3)

linearProfile

The value data is the name of a file which contains table of coordinate/value pairs, one per row. Between the lines is linearly interpolated.

This type requires additional input data:

  1. the origin of the coordinate axis,

  2. the direction of the coordinate axis.

Note: For vector and tensor values, the table file needs to contain one column per component in addition to the first column which contains the coordinate. The components are used as they are and are not transformed. For coordinates beyond the bounds of the table, the corresponding values at the bounds of the table are used (“clamp” behaviour).

Example:

linearProfile (0 0 0) (0 1 0) "$FOAM_CASE/umean.txt"

This defines a linear profile starting at the global origin and the coordinate running along the y axis. The table file content could look like this (for a vector field):

1 0 0 0
0.9 1 0 0
-0.9 1 0 0
-1 0 0 0

radialProfile

circumferentialProfile

The input for each instant is a file containing a table of components vs. angle. The coordinate system specification requires the base point, the axis direction and the direction of angle 0. The mapping is done this way: for each face, the angle is computed, the values for the angle are interpolated from the table and applied to the boundary. If the value is a tensor, it is transformed according to the current angle.

Example:

circumferentialProfile (0 0 0) (0 0 1)  (1 0 0) steady "$FOAM_CASE/T_vs_phi.txt"

In this example, die coordinate system has its origin at (0 0 0)^T, the axis points along the global Z direction and the angle 0 is along the global X direction. The profile points are read from the file T_vs_phi.txt in the case directory.

fittedProfile

vtkField

The data is read from a VTK file and interpolated to the CFD grid. The VTK grid needs to geometricall coincide with the target CFD mesh. There may be many fields in the VTK dataset and the one to be used has to be specified.

Example:

vtkField "$FOAM_CASE/data.vtk" "U"

extendedFixedValue

The extendedFixedValue boundary condition uses the FieldDataProvider class (see section 4.1.1) to apply the provided fields as a Dirichlet boundary condition in OpenFOAM cases.

The following settings need to be set in an OpenFOAM cases that uses this BC:

  1. the library containing the BC needs to be added in the system/controlDict

    libs ( "libextendedFixedValueBC.so" );
    
  2. use the extendedFixedValue boundary condition type in some field file:

    boundary
    {
       dirichletPatch
       {
    	type extendedFixedValue;
    	source uniform 3;
    	value uniform 3;
       }
    }
    

The source entry in the boundary section of the field file defines the actual FieldDataProvider input (see 4.1.1 for the syntax of the input statement).

The value statement needs to be present but will be replaced upon solver start with the value(s) evaluated from the FieldDataProvider machinery.