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/)
-   -   defining sphere inside a cube model (https://www.cfd-online.com/Forums/openfoam-solving/144958-defining-sphere-inside-cube-model.html)

Wien3 November 25, 2014 05:54

defining sphere inside a cube model
 
Good Morning everyone!
I'm and trying to make a model which consists on a cube with a sphere inside, and a fluid which will flow along the cube. I achieved to do it with a cube inside a cube (as I commented in another post) but of course it is much more difficult with the sphere.

As I didn't know how to make a sphere, I read many post about it and I did it with snappyHexMesh at the end. Then, I assigned boundary conditions and run with 'buoyantBoussinesqSimpleFoam'. Everything worked fine until I entered in OpenFoam. I don't have any problems to see initial conditions, but when I press play this error message appears:
PHP Code:

--> FOAM FATAL IO ERROR
size 42875 is not equal to the given value of 42848

file
: /home/jstoeckl/Desktop/modelsphere/2000/U from line 18 to line 42930.

    From 
function Field<Type>::Field(const wordkeyword, const dictionary&, const label)
    
in file /home/opencfd/OpenFOAM/OpenFOAM-2.3.0/src/OpenFOAM/lnInclude/Field.C at line 292.

FOAM exiting 

I am pretty sure it has something to do with snappyMeshDict file, because it is the only new file for me, but maybe I'm wrong.

PHP Code:

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


geometry
{

    
sphere
    
{
        
type searchableSphere;
        
centre  (0 0 0);
        
radius  0.1;
    }
};

castellatedMeshControls
{
    
maxLocalCells 1000;
    
maxGlobalCells 2000;
    
minRefinementCells 10;
    
maxLoadUnbalance 0.50;
    
nCellsBetweenLevels 3;
    
features
    
(
    );
    
refinementSurfaces
    
{  
        
sphere
        
{
            
level (1 1 );
        
/*    regions
            {
                secondSolid
                {
                    level (5 5);
                }
            }
        */
            
patchInfo
            
{
                
type wall;
            }
        }
        
    }

    
resolveFeatureAngle 30;
    
refinementRegions
    
{
    
/*    sphere
        {
            mode outside;
            levels ((1.0 2));
        }
    */
    
}
    
    
locationInMesh (0.11 0 0);
    
allowFreeStandingZoneFaces true;
}


snapControls
{
    
nSmoothPatch 5;
    
tolerance 4.0;
    
nSolveIter 10;
    
nRelaxIter 10;
}

addLayersControls
{
    
relativeSizes false;
    
layers
    
{
        
sphere_region0
        
{
            
nSurfaceLayers 1;

        }

    }

    
expansionRatio 1.0;
//    finalLayerThickness 1e-9;
finalLayerThickness 0.015e-7;
  
//  finalLayerRatio 0.01;
    
minThickness 0.001e-7;
    
nGrow 0;
    
featureAngle 30;
    
nRelaxIter 10;
    
nSmoothSurfaceNormals 1;
    
nSmoothNormals 3;
    
nSmoothThickness 10;
    
maxFaceThicknessRatio 0.8;
    
maxThicknessToMedialRatio 0.8;
    
minMedianAxisAngle 40;
    
nBufferCellsNoExtrude 0;
    
nLayerIter 100;
    
nRelaxedIter 20;
}

meshQualityControls
{
    
maxNonOrtho 65;
    
maxBoundarySkewness 20;
    
maxInternalSkewness 4;
    
maxConcave 80;
    
minVol 1e-250;
    
minTetQuality 1e-25;
    
minArea -1;
    
minTwist 0.05;
    
minDeterminant 0.001;
    
minFaceWeight 0.05;
    
minVolRatio 1e-1;
    
minTriangleTwist -1;

    
nSmoothScale 4;
    
errorReduction 0.75;

    
relaxed
    
{
        
maxNonOrtho 75;
    }
}

debug 0;
mergeTolerance 1e-6

I attach a link where you can find my case folder.

http://freakshare.com/files/4oe8sdmy...phere.zip.html

If you could tell me the solution to my problem or at least guide my in some direction to solve would be great ;)

Thank you in advance

stosse November 25, 2014 08:30

Usually, you can get a good idea of where something went wrong by looking at the error.
Quote:

size 42875 is not equal to the given value of 42848
means that the solver expects a specific number of values (the number of computational cells) but gets more/less. Try restarting from startTime (usually 0) either by deleting later time directories in your case dir, or modifying your controlDict (you are currently starting from 2000). The easiest way to set initial conditions is to have a uniform field (then you don't have to worry about number of cells anyway). Alternatively, you can use a field from a similar case with mapFields.

rolloblues November 25, 2014 08:33

Hi Wien,

If you open your mesh in paraFoam you can see that the problem is that you don't have any sphere at all inside your cube.
That's because, I suspect, the castellated mesh is too coarse to snap to the sphere try something like this:

Code:

refinementSurfaces
    { 
        sphere
        {
            level (2 2);
        /*    regions
            {
                secondSolid
                {
                    level (5 5);
                }
            }
        */
            patchInfo
            {
                type wall;
            }
        }
       
    }


Wien3 November 25, 2014 09:12

Good afternoon!

First of all thank you both for your answers.

@ stosse: I deleted previous other time folders, and in fact my starting time is 0 in controlDict. When you say uniform fields, do you refer to every single variable?

@ rolloblues: I applied that change, but it didn't work.

In fact I do have the sphere in the model. If I write in my terminal blockMesh and then snappyHexMesh", time folders 1, 2 and 3 are created. If I run OpenFoam I can see perfectly the sphere after pressing play.

The problem comes when I run after that buoyantBoussinesqSimpleFoam. In the terminal doesn't appear any error during the calculation time. I restart OpenFoam, I select the Volume Fields I want to analyse and I press play again.

It is in that specific moment when the error I commented before appears, and I don know why.

I hope I have explained better my problem.

Thank you in advance!

rolloblues November 25, 2014 09:14

My bad, sorry, I didn't noticed the other folders

stosse November 26, 2014 02:03

Uniform field means that the variable (U, p, etc.) has the same value in all cells. You set this in the starting time folder (3 in your case, since 1 and 2 are mesh generation steps) by setting something like (for U):
Quote:

internalField uniform (0 0 0);
and similar for other variables. This is something you should do for every variable.

For the start time, you have to change startFrom to startTime in controlDict if you want to use the specified start time. The default is to use the latest available time. I would recommend keeping the default setting, and deleting unwanted results before you rerun simulations. That way, you don't end up with results from multiple runs in the same case directory (if the write times are not exactly equal), or accidentaly run from a mesh generation step :)

By the way, if you use the -overwrite flag on snappyHexMesh,
Quote:

snappyHexMesh -overwrite
, it will overwrite your 0 folder so you don't end up with multiple mesh generation folders. Be sure to make a backup of your original 0 folder though :)

Wien3 November 26, 2014 03:37

Good Morning,

I read what you told me and I consider it makes sense! It is logic that the first 3 steps are taken to create the sphere and the buoyantBoussinesqSimpleFoam simulation should start from that point, and not from 0. So that is why I changed startFrom from startTime to latestTime (keeping startTime 0) and I didn't delete the 1,2,3 time folders.
I copied the 0 files in "3" and of course I was required to add commands about "sphere" in each of them. Again it doesn't imply any problem and the simulation runs perfectly.

However, I have another error exactly at the same point than before, after pressing play in the simulation. This time the error is:

PHP Code:

--> FOAM Warning 
    
From function polyMesh::readUpdateState polyMesh::readUpdate()
    
in file meshes/polyMesh/polyMeshIO.C at line 207
    Number of patches has changed
.  This may have unexpected consequences.  Proceed with care.
WarningIn /home/opencfd/OpenFOAM/ParaView-4.1.0/ParaViewCore/ServerManager/Rendering/vtkSMPVRepresentationProxy.cxxline 279
vtkSMPVRepresentationProxy 
(0x90e77b0): Could not determine array range

I think this "number of patches has changed" could have something to do with snappyHexMesh file.
I can again see the sphere but not the T, U, p... field evolution. I attach al link with the modified .zip in case someone could help me.

http://freakshare.com/files/q6mpmadd...phere.zip.html

Thank you in advance


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