CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Meshing & Mesh Conversion (https://www.cfd-online.com/Forums/openfoam-meshing/)
-   -   [snappyHexMesh] SnappyHexMesh crashes if nRelaxIter>0 (https://www.cfd-online.com/Forums/openfoam-meshing/192003-snappyhexmesh-crashes-if-nrelaxiter-0-a.html)

kishore96 August 26, 2017 05:27

SnappyHexMesh crashes if nRelaxIter>0
 
snappyHexMesh crashes with an fpe when I run it with nRelaxIter set to a non-zero value (even 1). The checkSurface utility doesn't find any errors on my stl files. On the mesh created by blockMesh, checkMesh only finds errors related to sides not being parallel or perpendicular to the empty directions. I am ignoring the aforementioned error as it is expected in a wedge shaped mesh, if I understand correctly. A backtrace from a similar crash, but with a higher number of cells, 6 threads, and more refinement, is below:

Code:

[2]
[2]
[2] --> FOAM FATAL ERROR:
[2] attempt to access element from zero sized list
[2]
[2]    From function void Foam::UList<T>::checkIndex(Foam::label) const [with T = Foam::Vector<double>; Foam::label = int]
[2]    in file /opt/OpenFOAM/OpenFOAM-5.0/src/OpenFOAM/lnInclude/UListI.H at line 100.
[2]
FOAM parallel run aborting
[2]
[2] #0  Foam::error::printStack(Foam::Ostream&) at /opt/OpenFOAM/OpenFOAM-5.0/src/OSspecific/POSIX/printStack.C:218
[2] #1  Foam::error::abort() at /opt/OpenFOAM/OpenFOAM-5.0/src/OpenFOAM/lnInclude/error.C:230
[2] #2  Foam::Ostream& Foam::operator<< <Foam::error>(Foam::Ostream&, Foam::errorManip<Foam::error>) at /opt/OpenFOAM/OpenFOAM-5.0/src/OpenFOAM/lnInclude/errorManip.H:85 (discriminator 3)
[2] #3  Foam::UList<Foam::Vector<double> >::checkIndex(int) const at /opt/OpenFOAM/OpenFOAM-5.0/src/OpenFOAM/lnInclude/UListI.H:100
[2] #4  Foam::UList<Foam::Vector<double> >::operator[](int) const at /opt/OpenFOAM/OpenFOAM-5.0/src/OpenFOAM/lnInclude/UListI.H:201
[2] #5  Foam::wedgePointPatchField<Foam::Vector<double> >::evaluate(Foam::UPstream::commsTypes) at /opt/OpenFOAM/OpenFOAM-5.0/src/OpenFOAM/fields/pointPatchFields/constraint/wedge/wedgePointPatchField.C:106
[2] #6  Foam::motionSmootherAlgo::setDisplacementPatchFields(Foam::List<int> const&, Foam::GeometricField<Foam::Vector<double>, Foam::pointPatchField, Foam::pointMesh>&) at /opt/OpenFOAM/OpenFOAM-5.0/src/dynamicMesh/motionSmoother/motionSmootherAlgo.C:453 (discriminator 2)
[2] #7  Foam::motionSmootherAlgo::setDisplacement(Foam::List<int> const&, Foam::PrimitivePatch<Foam::face, Foam::IndirectList, Foam::Field<Foam::Vector<double> > const&, Foam::Vector<double> > const&, Foam::Field<Foam::Vector<double> >&, Foam::GeometricField<Foam::Vector<double>, Foam::pointPatchField, Foam::pointMesh>&) at /opt/OpenFOAM/OpenFOAM-5.0/src/dynamicMesh/motionSmoother/motionSmootherAlgo.C:540
[2] #8  Foam::motionSmootherAlgo::setDisplacement(Foam::Field<Foam::Vector<double> >&) at /opt/OpenFOAM/OpenFOAM-5.0/src/dynamicMesh/motionSmoother/motionSmootherAlgo.C:574
[2] #9  Foam::snappySnapDriver::preSmoothPatch(Foam::meshRefinement const&, Foam::snapParameters const&, int, Foam::List<Foam::Pair<int> > const&, Foam::motionSmoother&)
Scaling iteration 0
 at /opt/OpenFOAM/OpenFOAM-5.0/src/mesh/snappyHexMesh/snappyHexMeshDriver/snappySnapDriver.C:688
[2] #10  Foam::snappySnapDriver::doSnap(Foam::dictionary const&, Foam::dictionary const&, double, double, Foam::snapParameters const&) at /opt/OpenFOAM/OpenFOAM-5.0/src/mesh/snappyHexMesh/snappyHexMeshDriver/snappySnapDriver.C:2438
[2] #11  ? at /opt/OpenFOAM/OpenFOAM-5.0/applications/utilities/mesh/generation/snappyHexMesh/snappyHexMesh.C:1352
[2] #12  __libc_start_main in "/lib/x86_64-linux-gnu/libc.so.6"
[2] #13  ? at ??:?

However, the crash happens when snappyHexMesh is not run in parallel as well. You can find a zip file containing the case here https://drive.google.com/file/d/0Bx0...ew?usp=sharing
I could not attach the case with this post as it was larger than the file size limit.

To reproduce the issue, you can just run blockMesh, and then snappyHexMesh (make sure the nRelaxIter in the snapControls section is set to a non-zero value)

I am sure that OpenFOAM has been installed correctly, as it runs on the motorbike and damBreak tutorials without errors.

System info:
OpenFOAM version: 5.0
OS: Ubuntu 14.04
Installation method: compiled from source

kishore96 August 26, 2017 05:43

The last few lines before the crash
 
Below are the last few lines (along with a few warnings printed by OpenFOAM) before the crash

Code:

... (lines omitted)

Morph iteration 0
-----------------
Calculating patchDisplacement as distance to nearest surface point ...
--> FOAM Warning :
    From function static Foam::vectorField Foam::snappySnapDriver::calcNearestSurface(const Foam::meshRefinement&, const scalarField&, const indirectPrimitivePatch&, Foam::pointField&, Foam::vectorField&)
    in file snappyHexMeshDriver/snappySnapDriver.C at line 1638
    For point:2806 coordinate:(0.583371677647 -0.0107526856863 0.403601610601) did not find any surface within:0.00507876424408 metre.
--> FOAM Warning :
    From function static Foam::vectorField Foam::snappySnapDriver::calcNearestSurface(const Foam::meshRefinement&, const scalarField&, const indirectPrimitivePatch&, Foam::pointField&, Foam::vectorField&)
    in file snappyHexMeshDriver/snappySnapDriver.C at line 1638
    For point:2807 coordinate:(0.583371677647 -0.0107526856863 0.403601610601) did not find any surface within:0.00507876424408 metre.
Wanted displacement : average:0.00123021245932 min:0 max:0.00405749222893
Calculated surface displacement in = 0.12 s


Detecting near surfaces ...
Overriding nearest with intersection of close gaps at 6 out of 5020 points.
Overriding displacement on features :
  implicit features    : true
  explicit features    : false
  multi-patch features : false

Attraction:
    linear  : max:(-0.0105531075434 -0.0395889237491 -0.00761028679883) avg:(-1.33905350955e-05 -2.58488704835e-05 -2.77309744911e-05)
    feature  : max:(-0.00325393759621 0 0.00263132929079) avg:(-9.38958065509e-06 1.3965024102e-06 1.69558338098e-05)
Feature analysis : total master points:5020 attraction to :
    feature point  : 18
    feature edge    : 1994
    nearest surface : 3008
    rest            : 0

--> FOAM Warning : Displacement (0.000262897868646 -1.15438668754e-05 -0.000394541258243) at mesh point 24028 coord (0.549386813178 0.00996395178442 0.387534770708) points through the surrounding patch faces
Smoothing displacement ...
Iteration 0
Displacement smoothed in = 1.3 s


Moving mesh ...

Iteration 0
Moving mesh using displacement scaling : min:1  max:1
Correcting 2-D mesh motion ...done
Checking faces in error :
    non-orthogonality > 65  degrees                        : 34819
    faces with face pyramid volume < 1e-13                : 27949
    faces with face-decomposition tet quality < 1e-15      : 2626
    faces with concavity > 80  degrees                    : 0
    faces with skewness > 4  (internal) or 20  (boundary) : 0
    faces with interpolation weights (0..1)  < 0.02        : 2092
    faces with volume ratio of neighbour cells < 0.01      : 0
    faces with face twist < 0.02                          : 2
    faces on cells with determinant < 0.001                : 9

Iteration 1
Displacement scaling for error reduction set to 0.
Moving mesh using displacement scaling : min:0.75  max:0.980248571768
Correcting 2-D mesh motion ...done
Checking faces in error :
    non-orthogonality > 65  degrees                        : 34977
    faces with face pyramid volume < 1e-13                : 27781
    faces with face-decomposition tet quality < 1e-15      : 2629
    faces with concavity > 80  degrees                    : 0
    faces with skewness > 4  (internal) or 20  (boundary) : 0
    faces with interpolation weights (0..1)  < 0.02        : 2092
    faces with volume ratio of neighbour cells < 0.01      : 0
    faces with face twist < 0.02                          : 9
    faces on cells with determinant < 0.001                : 9
Moved mesh in = 11.09 s


--> FOAM Warning :
    From function void Foam::snappySnapDriver::doSnap(const Foam::dictionary&, const Foam::dictionary&, Foam::scalar, Foam::scalar, const Foam::snapParameters&)
    in file snappyHexMeshDriver/snappySnapDriver.C at line 2764
    Did not succesfully snap mesh. Continuing to snap to resolve easy
    surfaces but the resulting mesh will not satisfy your quality constraints


Morph iteration 1
-----------------
Calculating patchDisplacement as distance to nearest surface point ...
Wanted displacement : average:0.00104768265191 min:1.33261419951e-06 max:0.00310982816607
Calculated surface displacement in = 0.12 s


Detecting near surfaces ...
Overriding nearest with intersection of close gaps at 1 out of 5020 points.
Overriding displacement on features :
  implicit features    : true
  explicit features    : false
  multi-patch features : false

#0  Foam::error::printStack(Foam::Ostream&) at ~/OpenFOAM-5.0-debug/OpenFOAM-5.0/src/OSspecific/POSIX/printStack.C:218
#1  Foam::sigFpe::sigHandler(int) at ~/OpenFOAM-5.0-debug/OpenFOAM-5.0/src/OSspecific/POSIX/signals/sigFpe.C:106
#2  ? in "/lib/x86_64-linux-gnu/libc.so.6"
#3  Foam::divideOp3<double, double, double>::operator()(double const&, double const&) const at ~/OpenFOAM-5.0-debug/OpenFOAM-5.0/src/OpenFOAM/lnInclude/ops.H:168
#4  void Foam::VectorSpaceOps<(unsigned char)3, (unsigned char)0>::opVS<Foam::Vector<double>, Foam::VectorSpace<Foam::Vector<double>, double, (unsigned char)3>, double, Foam::divideOp3<double, double, double> >(Foam::Vector<double>&, Foam::VectorSpace<Foam::Vector<double>, double, (unsigned char)3> const&, double const&, Foam::divideOp3<double, double, double>) at ~/OpenFOAM-5.0-debug/OpenFOAM-5.0/src/OpenFOAM/lnInclude/VectorSpaceOps.H:74
#5  Foam::Vector<double> Foam::operator/<Foam::Vector<double>, double, (unsigned char)3>(Foam::VectorSpace<Foam::Vector<double>, double, (unsigned char)3> const&, double) at ~/OpenFOAM-5.0-debug/OpenFOAM-5.0/src/OpenFOAM/lnInclude/VectorSpaceI.H:706
#6  Foam::snappySnapDriver::calcNearestFacePointProperties(int, Foam::PrimitivePatch<Foam::face, Foam::IndirectList, Foam::Field<Foam::Vector<double> > const&, Foam::Vector<double> > const&, Foam::Field<Foam::Vector<double> > const&, Foam::Field<Foam::Vector<double> > const&, Foam::List<int> const&, Foam::List<Foam::List<Foam::Vector<double> > >&, Foam::List<Foam::List<Foam::Vector<double> > >&, Foam::List<Foam::List<Foam::Vector<double> > >&, Foam::List<Foam::List<int> >&) const at ~/OpenFOAM-5.0-debug/OpenFOAM-5.0/src/mesh/snappyHexMesh/snappyHexMeshDriver/snappySnapDriverFeature.C:570 (discriminator 2)
#7  Foam::snappySnapDriver::calcNearestSurfaceFeature(Foam::snapParameters const&, bool, int, double, double, Foam::Field<double> const&, Foam::Field<Foam::Vector<double> > const&, Foam::motionSmoother&, Foam::Field<Foam::Vector<double> >&, Foam::List<Foam::pointConstraint>&) const at ~/OpenFOAM-5.0-debug/OpenFOAM-5.0/src/mesh/snappyHexMesh/snappyHexMeshDriver/snappySnapDriverFeature.C:3087
#8  Foam::snappySnapDriver::doSnap(Foam::dictionary const&, Foam::dictionary const&, double, double, Foam::snapParameters const&) at ~/OpenFOAM-5.0-debug/OpenFOAM-5.0/src/mesh/snappyHexMesh/snappyHexMeshDriver/snappySnapDriver.C:2727
#9  ? at ~/OpenFOAM-5.0-debug/OpenFOAM-5.0/applications/utilities/mesh/generation/snappyHexMesh/snappyHexMesh.C:1352
#10  __libc_start_main in "/lib/x86_64-linux-gnu/libc.so.6"
#11  ? at ??:?
Floating point exception (core dumped)


Antimony August 26, 2017 22:52

Hi,

This may or may not help, but I remember reading that explicit features was better than implicit features in terms of meshing. Perhaps you could switch on explicitFeatures and switch off implicitFeatures and give it a try?

Cheers,
Antimony

kishore96 August 26, 2017 23:14

Quote:

Originally Posted by Antimony (Post 661999)
Hi,

This may or may not help, but I remember reading that explicit features was better than implicit features in terms of meshing. Perhaps you could switch on explicitFeatures and switch off implicitFeatures and give it a try?

Cheers,
Antimony

The crash occurs even with the nFeatureSnapIter set to 0, which if I understand correctly, should disable feature snapping. However, I will try to learn how to use the explicit feature snapping option and report if it allows meshing to proceed without errors.

kishore96 August 26, 2017 23:34

Crash still occurs with explicit feature edges
 
I have tried meshing with explicit feature edge extraction, using the following surfaceFeatureExtractDict. The crash still occurs if nRelaxIter is set to a nonzero value.

Code:

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

diffuser-scaled.obj
{
    // How to obtain raw features (extractFromFile || extractFromSurface)
    extractionMethod    extractFromSurface;

    extractFromSurfaceCoeffs
    {
        // Mark edges whose adjacent surface normals are at an angle less
        // than includedAngle as features
        // - 0  : selects no edges
        // - 180: selects all edges
        includedAngle  180;
    }

    // Write options

        // Write features to obj format for postprocessing
        writeObj                yes;
}


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


Antimony August 28, 2017 03:28

Hi,

Looks like it is an error in OFv5 snappy. I tried on OF 2.3 and it ran without giving the error that you mentioned.

You might want to port one of the older version of snappy and try.

Cheers,
Antimony

kishore96 August 28, 2017 06:37

Quote:

Originally Posted by Antimony (Post 662105)
Hi,

Looks like it is an error in OFv5 snappy. I tried on OF 2.3 and it ran without giving the error that you mentioned.

You might want to port one of the older version of snappy and try.

Cheers,
Antimony

Thanks for checking. I'm compiling an older version of OpenFOAM right now, and if it works on that, I guess I'll report it as a bug.

kishpishar August 28, 2017 16:23

Hi,

I am also noting the in the new OpenFOAM version (5.0) both snappyHexMesh and checkMesh are very slow. Have you noticed it as well?

Cheers
Kumar

kishore96 August 28, 2017 20:44

I'm not sure. I haven't run any speed comparisons.

kishore96 August 30, 2017 06:52

Quote:

Originally Posted by Antimony (Post 662105)
Hi,

Looks like it is an error in OFv5 snappy. I tried on OF 2.3 and it ran without giving the error that you mentioned.

You might want to port one of the older version of snappy and try.

Cheers,
Antimony

I have tried on both OpenFOAM versions 2.4 and 4.1, and they give the same problem, which makes it seem highly unlikely that it is a bug in version 5.0. Do you have any other suggestions? I will try to compile version to 2.3 in a few days, but I don't expect it to give different results.

kishore96 August 30, 2017 08:47

No errors when I disable refinement!
 
I just figured out that disabling all refinement helps snappy complete without errors, and the resulting mesh actually looks pretty nice, but not as fine as I need. I'll see whether I can figure out some way to run snappy in stages and get the refinement done.

kishore96 August 31, 2017 07:42

A workaround (?)
 
So I managed to get a decent mesh by the following slightly convoluted procedure which I'm listing here in case anyone stumbles upon this thread with the same problem.
  • blockMesh
  • snappyHexMesh (only castellation + refinement) (use overwrite option)
  • extrudeMesh (using the 'wedge' method)
  • Delete all files matching *{L,l}evel* in constant/polyMesh/ and 0/
    • if you don't do this, snappy won't run in the next step
  • snappyHexMesh (snapping step)
I now have a decent mesh with smooth surfaces that is refined in regions I require, although I'm still not sure what the root cause of this problem is, or if it is a bug. I still haven't tried adding layers, but I'm hopeful it'll work.


All times are GMT -4. The time now is 07:54.