FoamFile
{
    version     2.0;
    format      ascii;
    class       dictionary;
    object      snappyHexMeshDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

// Which of the steps to run
castellatedMesh true;
snap            true;
addLayers       true;

// For meshing internal geometry, autoBlockMesh can be set to true 
autoBlockMesh false;
blockData (0.01 0);

// Try and close small holes in geometry
crackDetection false;

// Geometry. Definition of all surfaces. All surfaces are of class
// searchableSurface.
// Surfaces are used
// - to specify refinement for any mesh cell intersecting it
// - to specify refinement for any mesh cell inside/outside/near
// - to 'snap' the mesh boundary to the surface
geometry
{
    disc
    {
        type  searchableCylinder;
        point1 (-0.4 0 0);
        point2 (-0.3 0 0); 
        radius 0.3;
    }
    porous
    {
        type searchableBox;
        min (-0.1 -0.2 0.1);
        max (0.1 0.2 0.5);
    }
    thermal
    {
        type searchableBox;
        min (-0.1 -0.2 -0.5);
        max (0.1 0.2 -0.1);
    }
    mrf
    {
        type  searchableCylinder;
        point1 (-0.5 0 0);
        point2 (-0.2 0 0); 
        radius 0.4;
    }
}

// Settings for the castellatedMesh generation.
castellatedMeshControls
{

    // Refinement parameters
    // ~~~~~~~~~~~~~~~~~~~~~

    // While refining maximum number of cells per processor. This is basically
    // the number of cells that fit on a processor. If you choose this too small
    // it will do just more refinement iterations to obtain a similar mesh.
    maxLocalCells 10000000;

    // Overall cell limit (approximately). Refinement will stop immediately
    // upon reaching this number so a refinement level might not complete.
    // Note that this is the number of cells before removing the part which
    // is not 'visible' from the keepPoint. The final number of cells might
    // actually be a lot less.
    maxGlobalCells 100000000;

    // The surface refinement loop might spend lots of iterations refining just a
    // few cells. This setting will cause refinement to stop if <= minimumRefine
    // are selected for refinement. Note: it will at least do one iteration
    // (unless the number of cells to refine is 0)
    minRefinementCells 20;

    // Number of buffer layers between different levels.
    // 1 means normal 2:1 refinement restriction, larger means slower
    // refinement.
    nCellsBetweenLevels 3;


    // Explicit feature edge refinement
    // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    // Specifies a level for any cell intersected by its edges.
    // This is a featureEdgeMesh, read from constant/triSurface for now.
    features
    (
    );

    // Surface based refinement
    // ~~~~~~~~~~~~~~~~~~~~~~~~

    // Specifies two levels for every surface. The first is the minimum level,
    // every cell intersecting a surface gets refined up to the minimum level.
    // The second level is the maximum level. Cells that 'see' multiple
    // intersections where the intersections make an
    // angle > resolveFeatureAngle get refined up to the maximum level.

    refinementSurfaces
    {
        disc
	    {
            // Surface-wise min and max refinement level
            level (2 3);
            regions
            {
            }
        }
        porous
	    {
            // Surface-wise min and max refinement level
            level (2 3);
            regions
            {
            }
            faceZone        porous;
            cellZone        porous;
            zoneInside      true;
        }
        thermal
	    {
            // Surface-wise min and max refinement level
            level (2 3);
            regions
            {
            }
            faceZone        thermal;
            cellZone        thermal;
            zoneInside      true;
        }
        mrf
	    {
            // Surface-wise min and max refinement level
            level (2 3);
            regions
            {
            }
            faceZone        mrf;
            cellZone        mrf;
            zoneInside      true;
        }
    }

    // Resolve sharp angles
    resolveFeatureAngle -40; //negative value = inactive
    featureRefineAngle 15.;


    // Region-wise refinement
    // ~~~~~~~~~~~~~~~~~~~~~~

    // Specifies refinement level for cells in relation to a surface. One of
    // three modes
    // - distance. 'levels' specifies per distance to the surface the
    //   wanted refinement level. The distances need to be specified in
    //   descending order.
    // - inside. 'levels' is only one entry and only the level is used. All
    //   cells inside the surface get refined up to the level. The surface
    //   needs to be closed for this to be possible.
    // - outside. Same but cells outside.

    refinementRegions
    {
    }
        

    // Mesh selection
    // ~~~~~~~~~~~~~~

    // After refinement patches get added for all refinementSurfaces and
    // all cells intersecting the surfaces get put into these patches. The
    // section reachable from the locationInMesh is kept.
    // NOTE: This point should never be on a face, always inside a cell, even
    // after refinement.
    locationsInMesh ((0 0 0));

    allowFreeStandingZoneFaces  true;

    wrapper
    {
        // Switch on/off wrapper (default off)        
    	wrap false;

	    // Flow outlet patches need to be defined using outlets keyword
	    // if outlets keyword is not specified picks up blockMesh boundaries
	    outlets (inlet outlet ffmaxy ffminy ffmaxz ffminz);

	    // Two mechanisms for excluding regions 1) list of exclusion
        //  points or 2) global cutoff (default).

    	//excludePoints ((0.0 0.0 0.5));
	    cutoff 0.02;
	
	    // Default is to use volume sources where cells within a distance 
	    // (set by volDistance) of non outlet patches are seeded with 
	    // volumetric sources
	    volSources true;
	    volDistance 1.0;

	    // adjust porosity and volumetric source strength to allow cutoff 
	    // to be consistently set
	    meshInMM false;

	    // Maximum number of solver iteration to perform
	    maxIter 400;

	    // Write wrapper debug
	    writeFields false;
    }
}



// Settings for the snapping.
snapControls
{
    // Per final patch (so not geometry!) the layer information
    featureEdges
    {
    }
 
    include "$FOAM_CONFIG/snappyMesh.snap";
}



// Settings for the layer addition.
addLayersControls
{
    relativeSizes true;

    // Per final patch (so not geometry!) the layer information
    layers
    {
    }
    
    include "$FOAM_CONFIG/snappyMesh.layers";
}

include "$FOAM_CONFIG/snappyMesh.qualityDict";
include "$FOAM_CONFIG/snappyMesh.misc";

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