DynamicMeshDict

From OpenFOAMWiki
Revision as of 12:37, 29 July 2016 by Nickninevah (Talk | contribs)

1 Description

This controls deformation and morphing of the mesh during a simulation. This dictionary is only necessary on solvers that invoke mesh motion. Generally, all these solvers will have the term DyM included in the base solver name. For example, a standard base solver might be pimpleFoam. With mesh motion, the solver will be pimpleDyMFoam and require a dynamicMeshDict.

Also note that the exact behavior of dynamicMeshDict is one of the less standardized features of OpenFOAM. The exact details and solver capabilities may vary depending on your specific version of OpenFOAM. This guide was created using OpenFOAM version 2.2 from Engys.


2 Example Dictionary File (6DOF Body Motion)

/*--------------------------------*- C++ -*----------------------------------*\
|       o          |                                                          |
|    o     o       | OpenFOAM (Engys Edition):                                |
|   o   O   o      | Version: 2.2_engysEdition-beta                           |
|    o     o       | Web:     http://www.engys.com                            |
|       o          |                                                          |
\*---------------------------------------------------------------------------*/
FoamFile
{
    version     2.0;
    format      binary;
    class       dictionary;
    location    "../constant";
    object      dynamicMeshDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

dynamicFvMesh   dynamicMotionSolverFvMesh;

staticFvMeshCoeffs
{
}

motionSolverLibs ( "libsixDoFRigidBodyMotionDev.so" );

solver          sixDoFRigidBodyMotion;

diffusivity     quadratic inverseDistance 1 ( Body );

sixDoFRigidBodyMotionCoeffs
{
    patches         ( Body );
    innerDistance   25;
    outerDistance   275;
    centreOfMass    ( 16.81 -1087.4 -1063.3 );
    mass            4.1453e+06;
    g               ( 0 0 -9.8065 );
    momentOfInertia ( 2.7874e+08 5.8901e+08 6.6762e+08 );
    velocity        ( 0 -0.5 -0.25 );
    rhoName         rhoInf;
    rhoInf          1024.81;
    accelerationRelaxation 0.9;
    accelerationDamping 0.95;
    report          on;
    reportToFile    on;
    solver
    {
        type            CrankNicolson;
    }
    constraints
    {
    }
    restraints
    {
        Bouyancy
        {
            sixDoFRigidBodyMotionRestraint constantForce;
            refAttachmentPt ( 16.8 -1087.4 -1062 );
            constantForce   ( 0 0 4.0994e+07 );
        }
    }
}


// ************************************************************************* //

3 Motion Types

The dictionary allows specification of four types of mesh motion.

  1. staticFvMesh: provides no mesh motion. The mesh is static. Useful for debugging a simulation that involves mesh motion.
  2. solidBodyMotionFvMesh: Prescribed mesh motion. No topology change in mesh.
  3. dynamicRefineFvMesh: refines the simulation mesh and provides topology changes based on simulation fields.
  4. dynamicMotionSolverFvMesh: Mesh motion based on solved mesh motion for rigid body motion.

The following code blocks show the template of commands required for each motion type. Additional parameters are also required to specify the details of each motion type.

3.1 Command Template: No Mesh Motion

dynamicFvMesh staticFvMesh;
staticFvMeshCoeffs
{
}

3.2 Command Template: Prescribed Rigid Body Motion

dynamicFvMesh solidBodyMotionFvMesh;
solidBodyMotionFvMeshCoeffs
{
               //Parameter definitions
}

3.3 Command Template: Dynamic Mesh Refinement Template

dynamicFvMesh dynamicRefineFvMesh;
dynamicRefineFvMeshCoeffs
{
               //Parameter definitions
}

3.4 Command Template: 6DOF Motion Solver

dynamicFvMesh dynamicMotionSolverFvMesh;
motionSolverLibs ("libsixDoFRigidBodyMotion.so");
solver sixDoFRigidBodyMotion;
sixDoFRigidBodyMotionCoeffs
{
               //Parameter definitions
}

4 Parameter Definitions - staticFvMesh

There are no parameters required for a staticFVMesh. In fact, this dictionary is not really required. The only possible reasons to use this are cases where you may need to employ an openFOAM solver with dynamic mesh motion, but you don't actually want to have mesh motion. If anyone knows a useful example of this, please add here.

5 Parameter Definitions - solidBodyMotionFvMesh

6 Parameter Definitions - dynamicRefineFvMesh

dynamicRefineFvMesh does not morph the mesh shape. Instead, it performs topological refinements to the mesh, based on the gradient of specified fields. This is useful for cases like sonic shockwaves. Situations where you have a large region with relatively little change in field variables, and a small section with rapid and extreme change in field variables.

If this small section is stationary, don't use the dynamicRefineFvMesh. It is far more efficient to manually specify a mesh refinement. But if that segment of high field gradients travels, then dynamicRefineFvMesh may be the tool you need. It will automatically refine the mesh to adapt to the high gradient region, and then coarsen the mesh again then the high gradient region passes. Be warned, this can be computationally intensive. It may not always be the best way to speedup your runs.

6.1 Example Interface

   dynamicFvMesh dynamicRefineFvMesh;
   dynamicRefineFvMeshCoeffs
   {
       refineInterval 1;
       field alpha1;
       lowerRefineLevel 0.001;
       upperRefineLevel 0.999;
       unrefineLevel 10;
       nBufferLayers 1;
       maxRefinement 2;
       maxCells 200000;
       correctFluxes (( phi none) (nHatf none) (rhoPhi none) (ghf none) );
       dumpLevel true;
   }

6.2 Coefficient Definitions

6.2.1 Refine Interval

 refineInterval 1;

This specifies how often mesh refinement should be performed. The interval is the number of outer iterations between mesh refinements. You can also think of this as the number of timesteps between refinements.

6.2.2 Field

 field alpha1;

The field specifies which field the dictionary shall use to determine mesh refinements. Fields can be scalar or vector. If a vector field is used, the dictionary will utilize the vector magnitude of that field. Only one field can be specified for mesh refinement.

6.2.3 Lower and Upper Refine Level

 lowerRefineLevel 0.001;
 upperRefineLevel 0.999;

These specify the limits of when to trigger mesh refinement or coarsening. The limits you specify here match values of the field variable you specified. Any field values below the lowerRefineLevel will trigger mesh refinement. Any field values above the upperRefineLevel will trigger mesh coarsening.

6.2.4 UnRefine Level

 unrefineLevel 10;

This specifies the max number of times the cells can be coarsened. This works on the same principle of snappyHexMesh. The level you specify is really a power of 2. So in this case, the unrefineLevel states that cells can increase by a maximum factor of 2^10 = 1024 times their original size. This gets to specify a maximum coarsening limit. You typically want this to be a large number of levels.

They do not specify the level of refinement. The coarsening level is the opposite of the mesh refinement levels specified in snappyHexMesh. Higher numbers here mean more layers of coarsening.

6.2.5 Max Refinement

 maxRefinement 3;

The maximum number of layers of refinement that a cell can experience. This is similar to the unrefineLevel, only now we are considering refinement, not coarsening. Again, the refinement level specifies a power of 2. So a max refinement of 3 is 2^-3 = 0.125 times the original cell size. This refinement is relative to whatever the current cell size is. Use this to prevent cells from getting ridiculously small. Typical values are in the range of 2 - 4. Be wary of going to higher refinement levels as it can quickly escalate to tiny mesh sizes.

6.2.6 Buffer Layers

 nBufferLayers;

The number of buffer layers between levels around a refined cell. This specifies how many layers the mesh must hold a cell size before proceeding to the next level of refinement (or coarsening). Typical ranges are between 1 - 4. A good starting value is 1.0. Use this control to smooth out the transitions between cell sizes and eliminate any artificial pressure waves due to drastic changes in cell size.

6.2.7 Max Cells

 maxCells 150000000;

Use this to control the total number of cells in your mesh. The dynamic refinement will not exceed this maximum number of cells in your domain.

6.2.8 Correct Fluxes

 correctFluxes
 (
   (phi none) (phie Urel) (phi U)
   (alpha none)
   (rho*phi none)
 );

This is a list of fields that require flux correction. In this field, include any entries that need flux correction. Refinement will split cells that already have field definitions within them. This entry specifies which fields need fluxes correct for the new cell faces. The correctFluxes parameter is a list of field definitions and matched velocity field. For each pair, specify a flux field and corresponding velocity field. Fluxes changed on faces get recalculated by interpolating the velocity. Use 'none' on surfaceScalarFields that do not need to be reinterpolated.

6.2.9 Dump Level

 dumpLevel true;

This writes the refinement level for each cell as a volScalarField. This is useful for debugging to visualize the distribution of mesh refinements on your simulation.

7 Parameter Definitions - dynamicMotionSolverFvMesh

8 User Notes

If you are using the sixDoFRigidBodyMotion, you must import the additional motion solver library.

motionSolverLibs ( "libsixDoFRigidBodyMotionDev.so" );

The solver also allows you to specify an innerDistance and outerDistance parameter. These control how the sixDof solver morphs the mesh.

  1. Anything within the innerDistance directly moves the mesh nodes as a rigid body.
  2. Between the innerDistance and outerDistance, the mesh nodes are morphed.
  3. Outside the outerDistance, no morphing occurs.

But be careful. The outerDistance parameter must always be larger than the innerDistance parameter. If you try to specify outerDistance as smaller than innerDistance, the solver will override your inputs with default values.