CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Meshing & Mesh Conversion

[blockMesh] blockMesh with refineMesh

Register Blogs Members List Search Today's Posts Mark Forums Read

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   November 12, 2024, 11:36
Default blockMesh with refineMesh
  #1
New Member
 
Join Date: Oct 2024
Posts: 9
Rep Power: 2
ah_9 is on a distinguished road
Hi foamies,


I have a simple 2D cylinder geometry in which I need some refinement only in a particular lower area.

So I define a cellSet using topoSet and then refine the region recursively using refineMesh.


Can someone help me resolve this bad mesh on these particular regions?


This is my refineMeshDict
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

set ref;

coordinateSystem global;

globalCoeffs
{
tan1 (1 1 0);
tan2 (-1 1 0);
}

directions ( tan1 tan2 );

useHexTopology yes;

geometricCut no;

writeMesh no;


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



would snappyHexMesh give a better refinement? I did not try snappyHexMesh since I have a very simple 2D geometry

Any help would be great!
Attached Images
File Type: jpg 2D_cylinder.jpg (122.3 KB, 12 views)
File Type: jpg zoom_refined.jpg (199.9 KB, 10 views)
ah_9 is offline   Reply With Quote

Old   November 13, 2024, 12:07
Default
  #2
Senior Member
 
Join Date: Dec 2021
Posts: 251
Rep Power: 5
Alczem is on a distinguished road
Hey!


The issue seems to be a lack of transitioning from the coarse cellsize to the fine cellsize.


Since you generate a fully hexaedral mesh before refineMesh, I would give snappy a try, since it will take care of the decreasing cellsize itself. You could for instance add a searchableBox in the geometry subdictionary, then proceed to refine by a level or two in the refinementRegions subdictionary.


I am not sure how good your edges will be kept though, so double check once you are done with snappy.


Otherwise, you will have to use refineMesh several times to create a smooth transition zone between the coarse region and the fine region (by creating several cellzones, each slightly larger than the previous one).
Alczem is offline   Reply With Quote

Old   November 14, 2024, 04:52
Default
  #3
New Member
 
Join Date: Oct 2024
Posts: 9
Rep Power: 2
ah_9 is on a distinguished road
Quote:
Originally Posted by Alczem View Post
Hey!


The issue seems to be a lack of transitioning from the coarse cellsize to the fine cellsize.


Since you generate a fully hexaedral mesh before refineMesh, I would give snappy a try, since it will take care of the decreasing cellsize itself. You could for instance add a searchableBox in the geometry subdictionary, then proceed to refine by a level or two in the refinementRegions subdictionary.


I am not sure how good your edges will be kept though, so double check once you are done with snappy.


Otherwise, you will have to use refineMesh several times to create a smooth transition zone between the coarse region and the fine region (by creating several cellzones, each slightly larger than the previous one).
Thankyou for your reply! Okay, I will give snappy a try
ah_9 is offline   Reply With Quote

Old   November 14, 2024, 12:12
Default
  #4
New Member
 
Join Date: Oct 2024
Posts: 9
Rep Power: 2
ah_9 is on a distinguished road
Quote:
Originally Posted by Alczem View Post
Hey!


The issue seems to be a lack of transitioning from the coarse cellsize to the fine cellsize.


Since you generate a fully hexaedral mesh before refineMesh, I would give snappy a try, since it will take care of the decreasing cellsize itself. You could for instance add a searchableBox in the geometry subdictionary, then proceed to refine by a level or two in the refinementRegions subdictionary.


I am not sure how good your edges will be kept though, so double check once you are done with snappy.


Otherwise, you will have to use refineMesh several times to create a smooth transition zone between the coarse region and the fine region (by creating several cellzones, each slightly larger than the previous one).
With using sHM my mesh seems fine now but my volume fields seems to just vanish. I am using setFields command after my snappyHexMesh -overwrite command. I don't know what seems to be the issue. Can you help me with this?
ah_9 is offline   Reply With Quote

Old   November 15, 2024, 05:05
Default
  #5
Senior Member
 
Join Date: Dec 2021
Posts: 251
Rep Power: 5
Alczem is on a distinguished road
Hey!


It is probably due to some overwriting. My usual steps when meshing with snappyHexMesh are:
  • blockMesh
  • snappyHexMesh -overwrite
  • Copy the 0.orig folder to 0
  • setFields or whatever you need to initialize
  • Decompose and run the case
Based on your post, I would guess that the meshing process erases your 0 folder. Once you have run snappyHexMesh , make sure to copy your 0 folder once again, and run setFields.


Are you using cellzones with setFields? Maybe snappyHexMesh is not properly configured to create those, hence setFields won't work.


Can you share your case? I, or someone, will have a look when possible.
Alczem is offline   Reply With Quote

Old   November 15, 2024, 11:14
Default
  #6
New Member
 
Join Date: Oct 2024
Posts: 9
Rep Power: 2
ah_9 is on a distinguished road
Quote:
Originally Posted by Alczem View Post
Hey!


It is probably due to some overwriting. My usual steps when meshing with snappyHexMesh are:
  • blockMesh
  • snappyHexMesh -overwrite
  • Copy the 0.orig folder to 0
  • setFields or whatever you need to initialize
  • Decompose and run the case
Based on your post, I would guess that the meshing process erases your 0 folder. Once you have run snappyHexMesh , make sure to copy your 0 folder once again, and run setFields.


Are you using cellzones with setFields? Maybe snappyHexMesh is not properly configured to create those, hence setFields won't work.


Can you share your case? I, or someone, will have a look when possible.
Hey thanks for the reply again!
I can share my setFields and sHM files if that is ok.
And this is my procedure for reference
1. blockMesh
2. snappyHexMesh -overwrite
3. setFields
4. then run the solver.
I do not create the 0.orig, instead I have alpha.air.orig and alpha.particles.orig (which I then delete)


snappyHexMesh -
#includeEtc "caseDicts/mesh/generation/snappyHexMeshDict.cfg"

castellatedMesh on;
snap on;
addLayers on;

geometry
{
refinementBox
{
type searchableBox; // Define a box for the refinement region
min (-0.2 -0.2 0); // Minimum point of the box
max (0.2 -0.12 0.001); // Maximum point of the box
}
};

castellatedMeshControls
{
// Settings to control maximum cell count
maxLocalCells 5000000; // Max cells per processor
maxGlobalCells 10000000; // Max total cells

minRefinementCells 0; // Minimum cells required for refinement
nCellsBetweenLevels 2; // Smoothness between refinement levels

// Specify the refinement level for feature edges
resolveFeatureAngle 30; // Angle for resolving sharp edges

refinementSurfaces
{

}
// Define region to be refined
refinementRegions
{
refinementBox // Name of the box for the refinement region
{
mode inside; // Refine inside the box
levels ((1E15 2)); // Refinement level within the box
}
}
locationInMesh (0.0 0.0 0.0);
}
snapControls
{
// Snap settings (optional for refinement only)
nSmoothPatch 3; // Patch smoothing iterations
tolerance 2.0; // Tolerance for snapping
nSolveIter 30; // Number of solving iterations
nRelaxIter 5; // Number of relaxation iterations
//explicitFeatureSnap false;
//implicitFeatureSnap false;
}

addLayersControls
{
layers
{
}
// If boundary layers are needed, define them here
relativeSizes true;
expansionRatio 1.2;
finalLayerThickness 0.3;
minThickness 0.1;
nGrow 0;
}

meshQualityControls
{
// Standard mesh quality settings
maxNonOrtho 65;
maxBoundarySkewness 20;
maxInternalSkewness 4;
maxConcave 80;
minFlatness 0.5;
minVolRatio 0.01;
minTetQuality 1e-30;
minArea -1;
minTwist 0.05;
minDeterminant 0.001;
minFaceWeight 0.05;
minVolCollapseRatio 0.05;

// Advanced quality settings
relaxed
{
maxNonOrtho 75;
}
}
writeFlags
(
);


// Final settings for merging points
mergeTolerance 1E-6;

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

setFieldsDict -
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

defaultFieldValues
(
volScalarFieldValue alpha.air 1
volScalarFieldValue alpha.particles 0
);

regions
(

boxToCell
{
box (-0.2 -0.2 0) (0.2 -0.17112 0.001); //7.22% fill
fieldValues
(
volScalarFieldValue alpha.particles 0.6
volScalarFieldValue alpha.air 0.4

);
}

);


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


I can visualize my alpha.particles at time 0. but then they just disappear.
ah_9 is offline   Reply With Quote

Old   November 15, 2024, 11:50
Default
  #7
Senior Member
 
Join Date: Dec 2021
Posts: 251
Rep Power: 5
Alczem is on a distinguished road
I don't see any issue. If you can see your field at t=0, but it does not exist for subsequent timesteps, it probably means that it is not used/written by the solver. What solver do you use? You can maybe make a different thread and share the whole case, I do not think anyone can tell what is wrong with just what you have shared unfortunately.
Alczem is offline   Reply With Quote

Old   November 20, 2024, 06:01
Default
  #8
New Member
 
Join Date: Oct 2024
Posts: 9
Rep Power: 2
ah_9 is on a distinguished road
Quote:
Originally Posted by Alczem View Post
I don't see any issue. If you can see your field at t=0, but it does not exist for subsequent timesteps, it probably means that it is not used/written by the solver. What solver do you use? You can maybe make a different thread and share the whole case, I do not think anyone can tell what is wrong with just what you have shared unfortunately.
Hi again Alczem!

I found a problem while looking at checkMesh. Since I have a 2D geometry to start with frontAndBack faces with empty patch, sHM is also refining in the normal direction. Do you have any ideas how to fix this? I will also search for a fix now
ah_9 is offline   Reply With Quote

Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
[blockMesh] Problem with running blockMesh yoshiyagi OpenFOAM Meshing & Mesh Conversion 3 November 3, 2022 00:49
[mesh manipulation] BlockMesh cellSet refineMesh mattijs OpenFOAM Meshing & Mesh Conversion 41 April 7, 2020 10:32
[blockMesh] Multi-region Blockmesh - Refinemesh issues. Doug68 OpenFOAM Meshing & Mesh Conversion 3 February 18, 2016 21:09
[blockMesh] Multi-region Blockmesh - Refinemesh issues. Doug68 OpenFOAM Meshing & Mesh Conversion 0 February 17, 2016 04:39
[mesh manipulation] multiple calls to refineMesh parallel w/ dict failing Regis_ OpenFOAM Meshing & Mesh Conversion 2 June 4, 2015 14:44


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