CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Running, Solving & CFD (https://www.cfd-online.com/Forums/openfoam-solving/)
-   -   Floating Point Exception - Mesh Related?? (https://www.cfd-online.com/Forums/openfoam-solving/210934-floating-point-exception-mesh-related.html)

edomalley1 November 7, 2018 17:54

Floating Point Exception - Mesh Related??
 
Sometimes this case works great, and then I will slightly modify the geometry (change it's angle in space) and then it won't work. Sometimes it works but when I try to rerun the case with the same geometry, it won't work the second time. The case is based on the LES motorbike tutorial.


After running SHM and renumberMesh, potentialFoam immediately throws a floating point exception. Here's the log:


Code:

/*---------------------------------------------------------------------------*\
  =========                |
  \\      /  F ield        | OpenFOAM: The Open Source CFD Toolbox
  \\    /  O peration    | Website:  https://openfoam.org
    \\  /    A nd          | Version:  6
    \\/    M anipulation  |
\*---------------------------------------------------------------------------*/
Build  : 6-1a0c91b3baa8
Exec  : potentialFoam -parallel -initialiseUBCs
Date  : Nov 07 2018
Time  : 13:55:58
Host  : "CFDMachine"
PID    : 35991
I/O    : uncollated
Case  : /home/ed/OpenFOAM/ed-6/run/LESShoe/LuckBOA25/Shoe1
nProcs : 30
Slaves :
29
(
"CFDMachine.35992"
"CFDMachine.35993"
"CFDMachine.35994"
"CFDMachine.35995"
"CFDMachine.35996"
"CFDMachine.35997"
"CFDMachine.35998"
"CFDMachine.35999"
"CFDMachine.36000"
"CFDMachine.36006"
"CFDMachine.36012"
"CFDMachine.36013"
"CFDMachine.36016"
"CFDMachine.36018"
"CFDMachine.36020"
"CFDMachine.36025"
"CFDMachine.36028"
"CFDMachine.36029"
"CFDMachine.36030"
"CFDMachine.36031"
"CFDMachine.36032"
"CFDMachine.36033"
"CFDMachine.36034"
"CFDMachine.36041"
"CFDMachine.36048"
"CFDMachine.36053"
"CFDMachine.36056"
"CFDMachine.36057"
"CFDMachine.36063"
)

Pstream initialized with:
    floatTransfer      : 0
    nProcsSimpleSum    : 0
    commsType          : nonBlocking
    polling iterations : 0
sigFpe : Enabling floating point exception trapping (FOAM_SIGFPE).
fileModificationChecking : Monitoring run-time modified files using timeStampMaster (fileModificationSkew 10)
allowSystemOperations : Allowing user-supplied system call operations

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
Create time

Create mesh for time = 0

Reading velocity field U

Constructing pressure field p

Constructing velocity potential field Phi

No MRF models present


Calculating potential flow
[27] #0  Foam::error::printStack(Foam::Ostream&) at ??:?
[27] #1  Foam::sigFpe::sigHandler(int) at ??:?
[27] #2  ? in "/lib/x86_64-linux-gnu/libc.so.6"
[27] #3  Foam::DICPreconditioner::calcReciprocalD(Foam::Field<double>&, Foam::lduMatrix const&) at ??:?
[27] #4  Foam::DICPreconditioner::DICPreconditioner(Foam::lduMatrix::solver const&, Foam::dictionary const&) at ??:?
[27] #5  Foam::lduMatrix::preconditioner::addsymMatrixConstructorToTable<Foam::DICPreconditioner>::New(Foam::lduMatrix::solver const&, Foam::dictionary const&) at ??:?
[27] #6  Foam::lduMatrix::preconditioner::New(Foam::lduMatrix::solver const&, Foam::dictionary const&) at ??:?
[27] #7  Foam::PCG::solve(Foam::Field<double>&, Foam::Field<double> const&, unsigned char) const at ??:?
[27] #8  Foam::GAMGSolver::solveCoarsestLevel(Foam::Field<double>&, Foam::Field<double> const&) const at ??:?
[27] #9  Foam::GAMGSolver::Vcycle(Foam::PtrList<Foam::lduMatrix::smoother> const&, Foam::Field<double>&, Foam::Field<double> const&, Foam::Field<double>&, Foam::Field<double>&, Foam::Field<double>&, Foam::Field<double>&, Foam::Field<double>&, Foam::PtrList<Foam::Field<double> >&, Foam::PtrList<Foam::Field<double> >&, unsigned char) const at ??:?
[27] #10  Foam::GAMGSolver::solve(Foam::Field<double>&, Foam::Field<double> const&, unsigned char) const at ??:?
[27] #11  Foam::fvMatrix<double>::solveSegregated(Foam::dictionary const&) at ??:?
[27] #12  Foam::fvMatrix<double>::solve(Foam::dictionary const&) in "/opt/openfoam6/platforms/linux64GccDPInt32Opt/bin/potentialFoam"
[27] #13  Foam::fvMatrix<double>::solve() in "/opt/openfoam6/platforms/linux64GccDPInt32Opt/bin/potentialFoam"
[27] #14  ? in "/opt/openfoam6/platforms/linux64GccDPInt32Opt/bin/potentialFoam"
[27] #15  __libc_start_main in "/lib/x86_64-linux-gnu/libc.so.6"
[27] #16  ?[CFDMachine:36056] *** Process received signal ***
 in "/opt/openfoam6/platforms/linux64GccDPInt32Opt/bin/potentialFoam"
[CFDMachine:36056] Signal: Floating point exception (8)
[CFDMachine:36056] Signal code:  (-6)
[CFDMachine:36056] Failing at address: 0x3e800008cd8
[CFDMachine:36056] [ 0] /lib/x86_64-linux-gnu/libc.so.6(+0x3ef20)[0x7f6f7db9af20]
[CFDMachine:36056] [ 1] /lib/x86_64-linux-gnu/libc.so.6(gsignal+0xc7)[0x7f6f7db9ae97]
[CFDMachine:36056] [ 2] /lib/x86_64-linux-gnu/libc.so.6(+0x3ef20)[0x7f6f7db9af20]
[CFDMachine:36056] [ 3] /opt/openfoam6/platforms/linux64GccDPInt32Opt/lib/libOpenFOAM.so(_ZN4Foam17DICPreconditioner15calcReciprocalDERNS_5FieldIdEERKNS_9lduMatrixE+0x107)[0x7f6f7ef78917]
[CFDMachine:36056] [ 4] /opt/openfoam6/platforms/linux64GccDPInt32Opt/lib/libOpenFOAM.so(_ZN4Foam17DICPreconditionerC1ERKNS_9lduMatrix6solverERKNS_10dictionaryE+0x49)[0x7f6f7ef789d9]
[CFDMachine:36056] [ 5] /opt/openfoam6/platforms/linux64GccDPInt32Opt/lib/libOpenFOAM.so(_ZN4Foam9lduMatrix14preconditioner30addsymMatrixConstructorToTableINS_17DICPreconditionerEE3NewERKNS0_6solverERKNS_10dictionaryE+0x2e)[0x7f6f7ef78b0e]
[CFDMachine:36056] [ 6] /opt/openfoam6/platforms/linux64GccDPInt32Opt/lib/libOpenFOAM.so(_ZN4Foam9lduMatrix14preconditioner3NewERKNS0_6solverERKNS_10dictionaryE+0x23d)[0x7f6f7ef6506d]
[CFDMachine:36056] [ 7] /opt/openfoam6/platforms/linux64GccDPInt32Opt/lib/libOpenFOAM.so(_ZNK4Foam3PCG5solveERNS_5FieldIdEERKS2_h+0x4f7)[0x7f6f7ef69ec7]
[CFDMachine:36056] [ 8] /opt/openfoam6/platforms/linux64GccDPInt32Opt/lib/libOpenFOAM.so(_ZNK4Foam10GAMGSolver18solveCoarsestLevelERNS_5FieldIdEERKS2_+0x417)[0x7f6f7ef8e917]
[CFDMachine:36056] [ 9] /opt/openfoam6/platforms/linux64GccDPInt32Opt/lib/libOpenFOAM.so(_ZNK4Foam10GAMGSolver6VcycleERKNS_7PtrListINS_9lduMatrix8smootherEEERNS_5FieldIdEERKS8_S9_S9_S9_S9_S9_RNS1_IS8_EESD_h+0x577)[0x7f6f7ef8fb17]
[CFDMachine:36056] [10] /opt/openfoam6/platforms/linux64GccDPInt32Opt/lib/libOpenFOAM.so(_ZNK4Foam10GAMGSolver5solveERNS_5FieldIdEERKS2_h+0x4af)[0x7f6f7ef922ff]
[CFDMachine:36056] [11] /opt/openfoam6/platforms/linux64GccDPInt32Opt/lib/libfiniteVolume.so(_ZN4Foam8fvMatrixIdE15solveSegregatedERKNS_10dictionaryE+0x187)[0x7f6f80f0c827]
[CFDMachine:36056] [12] potentialFoam(_ZN4Foam8fvMatrixIdE5solveERKNS_10dictionaryE+0x15b)[0x55aeb07169db]
[CFDMachine:36056] [13] potentialFoam(_ZN4Foam8fvMatrixIdE5solveEv+0x16a)[0x55aeb0716dba]
[CFDMachine:36056] [14] potentialFoam(+0x2f8ae)[0x55aeb06bd8ae]
[CFDMachine:36056] [15] /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xe7)[0x7f6f7db7db97]
[CFDMachine:36056] [16] potentialFoam(+0x30d9a)[0x55aeb06bed9a]
[CFDMachine:36056] *** End of error message ***
--------------------------------------------------------------------------
mpirun noticed that process rank 27 with PID 0 on node CFDMachine exited on signal 8 (Floating point exception).
--------------------------------------------------------------------------


The mesh completed successfully with 1.9 million cells. When I run checkMesh -allGeometry -allTopology, it throws a couple failures:


Code:

  *There are 12356 faces with concave angles between consecutive edges. Max concave angle = 79.7401 degrees.
  <<Writing 12356 faces with concave angles to set concaveFaces
    Face flatness (1 = flat, 0 = butterfly) : min = 0.673316  average = 0.999032
  *There are 61 faces with ratio between projected and actual area < 0.8
    Minimum ratio (minimum flatness, maximum warpage) = 0.673316
  <<Writing 61 warped faces to set warpedFaces
    Cell determinant (wellposedness) : minimum: 0 average: 10.4582
 ***Cells with small determinant (< 0.001) found, number of cells: 20
  <<Writing 20 under-determined cells to set underdeterminedCells
 ***Concave cells (using face planes) found, number of cells: 87978
  <<Writing 87978 concave cells to set concaveCells
    Face interpolation weight : minimum: 0.0210496 average: 0.46873
 ***Faces with small interpolation weight (< 0.05) found, number of faces: 379
  <<Writing 379 faces with low interpolation weights to set lowWeightFaces
    Face volume ratio : minimum: 0.0121418 average: 0.854042
    Face volume ratio check OK.

Failed 3 mesh checks.

End


simpleFoam also has a FPE and then there is no case to copy over to the LES case to run pisoFoam.


I'm pulling my hair out here. I've tried all sorts of changes to my SHMDict file but it's not working. Here it is. Is the problem the errors checkMesh found? I can view the VTK files in paraView but if they are the problem, how do I fix them? Thanks!



Code:

/*--------------------------------*- C++ -*----------------------------------*\
  =========                |
  \\      /  F ield        | OpenFOAM: The Open Source CFD Toolbox
  \\    /  O peration    | Website:  https://openfoam.org
    \\  /    A nd          | Version:  6
    \\/    M anipulation  |
\*---------------------------------------------------------------------------*/
FoamFile
{
    version    2.0;
    format      ascii;
    class      dictionary;
    object      snappyHexMeshDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

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


// 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
{
    Shoe1
    {
        type triSurfaceMesh;
        file "Luck2BOA25.stl";
    }

    // Analytical shape; cylinder, sphere
    refinementBox
    {
        type searchableBox;
        min (-0.15 -0.1 -0.1);
        max ( 0.8  0.2 0.6);
    }
};



// Settings for the castellatedMesh generation.
castellatedMeshControls
{

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

    // If local number of cells is >= maxLocalCells on any processor
    // switches from from refinement followed by balancing
    // (current method) to (weighted) balancing before refinement.
    maxLocalCells 1000000;

    // 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 10000000;

    // 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 100;

    // Allow a certain level of imbalance during refining
    // (since balancing is quite expensive)
    // Expressed as fraction of perfect balance (= overall number of cells /
    // nProcs). 0=balance always.
    maxLoadUnbalance 0.10;


    // 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
    (
        {
            file "Luck2BOA25.eMesh";
            level 6;
        }
    );



    // 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
    {
        Shoe1
        {
            // Surface-wise min and max refinement level
            level (5 6);
        }
    }

    // Resolve sharp angles
    resolveFeatureAngle 60;


    // 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
    {
        refinementBox
        {
            mode inside;
            levels ((1E15 3));
        }
    }


    // 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.
    locationInMesh (-0.4 0.3001 0.01);


    // Whether any faceZones (as specified in the refinementSurfaces)
    // are only on the boundary of corresponding cellZones or also allow
    // free-standing zone faces. Not used if there are no faceZones.
    allowFreeStandingZoneFaces false;
}



// Settings for the snapping.
snapControls
{
    //- Number of patch smoothing iterations before finding correspondence
    //  to surface
    nSmoothPatch 3;

    //- Relative distance for points to be attracted by surface feature point
    //  or edge. True distance is this factor times local
    //  maximum edge length.
    tolerance 2.0;

    //- Number of mesh displacement relaxation iterations.
    nSolveIter 30;

    //- Maximum number of snapping relaxation iterations. Should stop
    //  before upon reaching a correct mesh.
    nRelaxIter 5;

    // Feature snapping

      //- Number of feature edge snapping iterations
      //  Leave out altogether to disable
      //nFeatureSnapIter 10;

      //- Detect (geometric only) features by sampling the surfaces
      // default = false
      //implicitFeatureSnap false;

      //- Use castellatedMeshControls::features (default=true)
      //explicitFeatureSnap true;

      //- Detect points on multiple surfaces (only for explicitFeatureSnap)
      //multiRegionFeatureSnap true;
}



// Settings for the layer addition.
addLayersControls
{
    // Are the thickness parameters below relative to the undistorted
    // size of the refined cell outside layer (true) or absolute sizes (false).
    relativeSizes true;

    // Per final patch (so not geometry!) the layer information
    layers
    {
        "Shoe1.*"
        {
            nSurfaceLayers 9;
        }
    }

    // Expansion factor for layer mesh
    expansionRatio 1.1;

    // Wanted thickness of final added cell layer. If multiple layers
    // is the thickness of the layer furthest away from the wall.
    // Relative to undistorted size of cell outside layer.
    // See relativeSizes parameter.
    finalLayerThickness 0.3;

    // Minimum thickness of cell layer. If for any reason layer
    // cannot be above minThickness do not add layer.
    // Relative to undistorted size of cell outside layer.
    minThickness 0.1;

    // If points get not extruded do nGrow layers of connected faces that are
    // also not grown. This helps convergence of the layer addition process
    // close to features.
    nGrow 0;


    // Advanced settings

    // When not to extrude surface. 0 is flat surface, 90 is when two faces
    // are perpendicular
    featureAngle 310;

    // Maximum number of snapping relaxation iterations. Should stop
    // before upon reaching a correct mesh.
    nRelaxIter 40;

    // Number of smoothing iterations of surface normals
    nSmoothSurfaceNormals 20;

    // Number of smoothing iterations of interior mesh movement direction
    nSmoothNormals 30;

    // Smooth layer thickness over surface patches
    nSmoothThickness 20;

    // Stop layer growth on highly warped cells
    maxFaceThicknessRatio 0.5;

    // Reduce layer growth where ratio thickness to medial
    // distance is large
    maxThicknessToMedialRatio 0.3;

    // Angle used to pick up medial axis points
    minMedianAxisAngle 90;

    // Create buffer region for new layer terminations
    nBufferCellsNoExtrude 0;

    // Overall max number of layer addition iterations
    nLayerIter 50;
}



// Generic mesh quality settings. At any undoable phase these determine
// where to undo.
meshQualityControls
{
    //- Maximum non-orthogonality allowed. Set to 180 to disable.
    maxNonOrtho 65;

    //- Max skewness allowed. Set to <0 to disable.
    maxBoundarySkewness 20;
    maxInternalSkewness 4;

    //- Max concaveness allowed. Is angle (in degrees) below which concavity
    //  is allowed. 0 is straight face, <0 would be convex face.
    //  Set to 180 to disable.
    maxConcave 80;

    //- Minimum projected area v.s. actual area. Set to -1 to disable.
    minFlatness 0.5;

    //- Minimum pyramid volume. Is absolute volume of cell pyramid.
    //  Set to a sensible fraction of the smallest cell volume expected.
    //  Set to very negative number (e.g. -1E30) to disable.
    minVol 1e-13;
    minTetQuality 1e-13;

    //- Minimum face area. Set to <0 to disable.
    minArea -1;

    //- Minimum face twist. Set to <-1 to disable. dot product of face normal
    //  and face centre triangles normal
    minTwist 0.02;

    //- Minimum normalised cell determinant
    //  1 = hex, <= 0 = folded or flattened illegal cell
    minDeterminant 0.001;

    //- minFaceWeight (0 -> 0.5)
    minFaceWeight 0.02;

    //- minVolRatio (0 -> 1)
    minVolRatio 0.01;

    // must be >0 for Fluent compatibility
    minTriangleTwist -1;


    // Advanced

    //- Number of error distribution iterations
    nSmoothScale 6;
    //- Amount to scale back displacement at error points
    errorReduction 0.75;
}


// Advanced

// Merge tolerance. Is fraction of overall bounding box of initial mesh.
// Note: the write tolerance needs to be higher than this.
mergeTolerance 1E-6;


RobertHB November 8, 2018 05:28

Quote:

Originally Posted by edomalley1 (Post 714538)
Code:

  *There are 12356 faces with concave angles between consecutive edges. Max concave angle = 79.7401 degrees.
  <<Writing 12356 faces with concave angles to set concaveFaces
    Face flatness (1 = flat, 0 = butterfly) : min = 0.673316  average = 0.999032
  *There are 61 faces with ratio between projected and actual area < 0.8
    Minimum ratio (minimum flatness, maximum warpage) = 0.673316
  <<Writing 61 warped faces to set warpedFaces
    Cell determinant (wellposedness) : minimum: 0 average: 10.4582
 ***Cells with small determinant (< 0.001) found, number of cells: 20
  <<Writing 20 under-determined cells to set underdeterminedCells
 ***Concave cells (using face planes) found, number of cells: 87978
  <<Writing 87978 concave cells to set concaveCells
    Face interpolation weight : minimum: 0.0210496 average: 0.46873
 ***Faces with small interpolation weight (< 0.05) found, number of faces: 379
  <<Writing 379 faces with low interpolation weights to set lowWeightFaces
    Face volume ratio : minimum: 0.0121418 average: 0.854042
    Face volume ratio check OK.

Failed 3 mesh checks.

End

Is the problem the errors checkMesh found?

The short answer is: yes. Generally* any checkMesh with more than 1 failed mesh check will be trouble. Especially if you have alot of "problem Cells".

Now, lets try to figure out a few solutions:
1. Try setting minRefinementCells to 0. Right now you are stopping refinement when there are still 100 cells left to refine.
2. Under Explicit feature edge refinement choose level 1; Further refinement will be done later on anyways and from my experiences the level setting does nothing anyways.
3. Under Surface based refinement choose level (1 6); As i figured out yesterday sHM might have troubles with refining directely to a high level.
4. Reduce your resolveFeatureAngle. The tooltip says "Applies maximum level of refinement to cells that can see intersections whose angle exceeds this" so 60 is pretty high and you may not get the refinement you need.
5. In snapControls reduce tolerance to 1.0. Again, the tooltip: "Ratio of distance for points to be attracted by surface feature point or edge, to local maximum edge length". So a high tolerance may try to snap eges from further away, whereas 1.0 only tries to snap one cell.

And one last one: Don't use snappyHexMesh -overwrite as long as you are unsure of where your problem is. This way you can use checkMesh on the individual snappyHexMesh timesteps and get a indication on which of the stages causes problems.

Lastly some good sources with detailed sHM dictionaries:
[1] openFoam.com/documentation
[2] sites.google.com/.../snappywiki
[3] Engys' A comprehensive tour of snappyHexMesh


*There are exceptions to the rule, by they are rare.

edomalley1 November 8, 2018 11:30

Robert -



Thanks! It is now working on geometry I previously got the FPE on! At first I tried all of your suggestions. My mesh had many fewer cells and I still got the FPE. I Have to admit I was a bit skeptical of this suggestion:


Quote:

3. Under Surface based refinement choose level (1 6); As i figured out yesterday sHM might have troubles with refining directely to a high level.
4. Reduce your resolveFeatureAngle. The tooltip says "Applies maximum level of refinement to cells that can see intersections whose angle exceeds this" so 60 is pretty high and you may not get the refinement you need.

When I implemented this I reduced the resolveFeatureAngle to 20.



So I went back to level (5 6) and an angle of 60 (since I'm already refining everything pretty far, I only need the extra refining on the sharp features)


And it worked - even improved the layer addition, which is very difficult with my geometry.


All times are GMT -4. The time now is 06:55.