SnappyHexMesh Internal Flow Example (Diesel Injector)
5 Attachment(s)
Hello Foamers!
After working through this meshing process on the internal flow of a diesel injector I felt inclined to share my results as internal flow applications of SHM seem to inspire many questions on the forums. !!Disclaimer, I am no SHM expert, so if anyone wants to elaborate on any of these issues please do!! To begin with 2D slice of the 3D injector file I began with: Attachment 13919 Due to the sharp angles that are present in the geometry as well as circular shapes I needed to use surfaceFeatureExtract twice: Code:
surfaceFeatureExtract -includedAngle 180 -writeObj constant/triSurface/SprayA210675doublesmoothascii.stl outputfile Code:
surfaceFeatureExtract -includedAngle 150 -writeObj constant/triSurface/SprayA210675doublesmoothascii2.stl outputfile2 You can then check to see what surfaces were included in the output files you created. Looking at the file "filename_edgeMesh.obj" and taking a slice of the resulting image: Attachment 13923 You can see that the horizontal lines were were not captured by the surface edge program. Looking at the second _edgeMesh.obj file: Attachment 13924 The horizontal edges have now been captured. Note a few extra things have been captured that overlap with the first surface extraction, but that is fine. Next make sure that your blockmeshdict creates a mesh of sufficient density, ie make sure that the interior of the geometry you want to capture has nodes in it. There are a few things to make sure you edit before running a case like this. First make sure you load your geometry: Code:
geometry Code:
// Explicit feature edge refinement Specify how much refinement you want to perform (Note SHM takes the name of the stl you provide, in this case nozzle, and adds an underscore. Since I want to refine all surfaces I can use the wildcard * to make sure all surfaces are refined): Code:
refinementSurfaces Code:
locationInMesh (0.07 0.0 1.3); Code:
//- Highly experimental and wip: number of feature edge snapping Code:
layers Code:
/*--------------------------------*- C++ -*----------------------------------*\ Attachment 13921Attachment 13922 It's not totally complete as I need to reduce the number of cells (currently 2.25 million), but this shows the overall process and what things to consider. Some thoughts to consider if you may still be having problems: 1) Look at the bounding box you are using with your desired geometry. Could you make it smaller in order to reduce the initial mesh size? 2) Are you going to exceed the maxGlobalCells value? SHM will not abort if you exceed this value, but rather just stop creating new cells. By increasing the initial mesh density defined in the blockmeshdict you increase the chances of this value being exceeded. 3) If you increased the initial mesh density, how many refinement levels are you performing? By increasing the initial density of the mesh, the refinement levels do not need to be as large. Refinement levels dictate how many times each cell is split into smaller cells. So if you increase the density of the initial mesh and keep the refinement level at say 10 or 11, then you may be increasing the resulting mesh calculation much more than you may think. 4) All of these things could contribute to SHM eating up all of your memory and aborting the operation. If you are getting the memory error then try reducing the number of refinement levels, the initial mesh density, and even possibly the number of edge layers being created. Get it to a point where it will successfully run and then if necessary increase these values to get the desired mesh resolution. 5) If you are unsure if your memory is being completely utilized watch your SHM operation using the 'top' command. In my experience SHM aborted right when my memory maxed out. |
very nice
Hej,
thanks for sharing this. I like the idea of the double feature edge extraction and your thoughts on the the snapping edge feature. I have one more question, which of the .obj files do you usually inspect in order to see if you featureSurface extraction was good or not? |
.obj viewing
Quote:
Roman, I'm glad you find it useful, I had a hard time finding internal flows to base my mesh on so figured I would help provide one. The .obj file from surfacefeatureextract that I have been using is the "filename_edgeMesh.obj", which paraview can open directly. Though I'm sure there are other options available, like just looking at the .eMesh file. I believe I have seen some discussion in the forums about trying to open an .eMesh in paraview, but I didn't investigate it much. |
Greetings to all!
FYI: you can convert "eMesh" files to "obj" and vice-versa: Code:
surfaceFeatureConvert relative/path/file.eMesh file.obj Bruno |
HI Everyone :)
I want to improve the cell density in certain regions of my mesh(created using SHM). It would be great if anyone could help me understand how refinement levels work.:D Thank You Turbulence. |
Hi Turbulence,
You should find answers here: http://openfoamwiki.net/index.php/Sn...als_and_Guides - read the tutorial "A Comprehensive Tour of snappyHexMesh". Best regards, Bruno |
Irish 09-
Nice work and thank you! may i ask how you built your blockMeshDict file? how specific did you need to be with your original geometry for this to work? |
Hello Dmoore,
I'm glad you found this helpful. The blockMeshDict is just made to be slightly larger than the STL geometry I wish to mesh. Deciding how large the cells of your blockMesh is a bit difficult to determine. You first need to make sure that there are enough cells that some nodes are interior to the STL geometry and some are exterior. Once you accomplish that, you technically don't need to have more cells present. However, the more course your blockmesh starts, the more refinement will be necessary to get your desired mesh from SHM and therefore the longer SHM takes to complete. To even further complicate it though, is that if you make your original blockmesh too refined, then you can potentially have too many cells and I have in the past run out of memory on my desktop with 8GB of RAM, in which case SHM will crash. The problem that is occurring is that the first thing SHM does is refine the original blockmesh and then cuts out the parts that do not touch the STL geometry. Therefore you could be spending a lot of memory refining parts of the blockmesh that will just be cut off later anyway. So you need to balance how much to refine the original blockmesh and then add layers and refinementregions so that you do not just blindly refine the entire blockmesh domain before it conforms to the correct geometry. -Irish09 |
ok. That makes sense. I think my blockMesh is sufficient and I have the privelege of 64GB of RAM, so SHM doesn't limit me too much. I can successfully run the mesh in parallel but then when it comes time to run simpleFoam, I recieve this error:
[1] --> FOAM FATAL IO ERROR: [1] Cannot find patchField entry for contraction_contraction [1] [1] file: /home/teamsoh/OpenFOAM/teamsoh-2.2.0/run/sohWind/bigBlock/processor1/0/p.boundaryField from line 26 to line 45. [1] [1] From function GeometricField<Type, PatchField, GeoMesh>::GeometricBoundaryField::readField(const DimensionedField<Type, GeoMesh>&, const dictionary&) [1] in file /home/opencfd/OpenFOAM/OpenFOAM-2.2.0/src/OpenFOAM/lnInclude/GeometricBoundaryField.C at line 154. [1] FOAM parallel run exiting I can send you the casefile if you'd like? I noticed that the contraction_contraction line only shows up in the processor dict's.. any thoughts? Does this mean I have incorrectly set up my inlet/outlet/wall conditions? thanks! Dmoore |
Dmoore,
It certainly looks like something is wrong with the boundary conditions. I could take a look at the case file if you would like. |
Contraction casefile
1 Attachment(s)
I would be extremely grateful to have another set of eyes on it. I am attempting SHM for the first time this these past two weeks. In the past I have used PointWise to mesh. Thank you so much!:)
|
Hello Dmoore,
I've taken a look at your case file and I can see a potential problem, but you will have to let me know as it depends on what you are attempting to model. I am assuming, that you are wanting to model the flow in the interior of this contraction and don't care about the flow on the outside of the device. If I am assuming incorrectly let me know and I can re-evaluate. Based on this assumption of internal flow only, then the current problem I can see has to do with the STL file itself. Since your STL file is not closed, SHM cannot distinguish between the interior and the exterior of the geometry as it can travel from any point A to any point B without traveling through a wall (or inlet/outlet). There are two ways to go about fixing this. The first is to just add a surface where the inlet and outlet are going to be defined in whatever CAD program and then it use that as the STL file. SHM will treat these surfaces as part of the geometry, but does not mean they have to be walls. The second option requires making the original blockmesh smaller than the geometry you wish to mesh, which will essentially clip the geometry at whatever point the blockmesh crosses it and treat that as a wall. I recommend the first option, as the second is a bit more hacking and you don't have as much direct control over the geometry and resulting patches. Irish09 |
CAD file vs OpenFOAM
1 Attachment(s)
Yes, you are correct. I should have been more clear:). I am trying to simulate an internal flow within the geometry of the .stl file. I took your advice and closed off the two ends of the channel. I also reduced the volume of my blockMesh to fit within the channel so that it can snap to the inside walls of the channel.
surfaceFeatureExtract // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // Create time Reading surfaceFeatureExtractDict Surface : "contraction.3.stl" Feature line extraction is only valid on closed manifold surfaces. word::stripInvalid() called for word ��? For debug level (= 2) > 1 this is considered fatal Aborted (core dumped) Unfortunately when I close the ends however, it claims to be an 'open' manifold surface and crashes. The CAD program I have been using, SolidWorks, says otherwise and that it is closed and fully defined. Maybe this is a CAD issue instead of OpenFOAM? Dmoore |
Hello Dmoore,
I fear I might have slightly led you astray ;). You have taken ideas from both suggestion 1 and 2, but as I stated before I don't think the second idea was a worthwhile one. From your post I am given the impression that the blockmesh, in its entirety, fits within the contraction. This will not work as it must have nodes on both sides of the geometry in order to find the surface to snap to it. What I was mentioning before could potentially be used so that 2 of the 6 sides of the geometry were not within the original blockmesh, thus creating a boundary that way. I don't recommend this approach though. So I would revert back to the blockmesh file you had previously, in the case file you posted, and keep the geometry closed as you did here. However, the error you are getting has nothing to do with your blockmesh file. As this error is occuring in the surfacefeatureextract function, the blockmesh is not being utilized yet. I went and looked at: OpenFOAM/OpenFOAM-2.2.0/applications/utilities/surface/surfaceFeatureExtract And found that it always prints out "Feature line extraction is only valid on closed manifold surfaces.", so that actually isn't the error, just a statement to remind you. I would think it is a problem with your STL file from your solidworks program. I am unsure if surfacefeatureextract can handle both binary and ASCII STL files, so I would make sure it is ASCII, since I know that works. Otherwise I am unsure of how to help. As the first geometry you provided works fine with the function I would suggest seeing how the two differ. -Irish09 |
Irish 09-
thank you tremendously for your help. I did overlook writing to an ASCII format for the stl file, I think I was rushing :). Fixing that allowed me to extract surface geometry and run SHM but with the same original issue of nothing to snap to. It ran for about 20 minutes on 24 cores and returned an untouched blockMesh! haha bummer! I reverted the blockMesh as you sugguested, but for some reason something is still pretty funky :(. Thanks for the help though! I will post as soon as I am able to find my error! Dmoore |
Greetings to all!
@Dmoore: Quote:
Because if you didn't use this option, then check the time folders "1", "2" and/or "3", where the intermediate and final mesh will be located. Best regards, Bruno |
Wyldckat-
I ran the command line: mpirun -np 24 snappyHexMesh -overwrite -parallel Is there something missing from that sequence? I trying to run the following commands: blockMesh surfaceFeatureExtract (I am working with OpenFOAM v 2.2.0) decomposePar mpirun -np 24 snappyHexMesh -overwrite -parallel mpirun -np 24 simpleFoam -parallel > log thanks! Danny |
Hi Danny,
From the list of commands you've shown, the only problem I can see is that running simpleFoam right after snappyHexMesh might not work as expected. I haven't tested the following cases on OpenFOAM 2.2, but the steps I usually follow are demonstrated on the example cases given here: http://code.google.com/p/bluecfd-sin...untimes202_211 Without looking at the "snappyHexMeshDict", it's hard to estimate what might be wrong, but the following come to mind:
Bruno |
Dear Bruno-
Thank you for the response (my apologies for the delay of mine!) I have already done the checks you suggested, as well as updated my snappyHexMeshDict to conform to O.F v2.2.0. I think I may revert back to OpenFOAM v 2.1 if i cannot seem to troubleshoot this mesh error by the end of the week. I will let you know if it runs on v2.1 instead of v2.2 thanks again Dmoore |
Ok so I have diagnosed my problem with SHM-
SolidWorks (a 3D modeling software) creates objects and saves as an stl format (for SHM to use) but fills the objects with zero volume. In fact, the only volume taken up is by the lines that define the edges. This results in what seems to be an 'Open' volume when in fact it does not exist in the first place. I would be curious to know if anyone has ever used SolidWorks to mesh with SnappyHex, and if they have successfully, they will be my hero :) |
All times are GMT -4. The time now is 09:23. |