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/)
-   -   Need some help with my masters thesis! (https://www.cfd-online.com/Forums/openfoam-solving/200010-need-some-help-my-masters-thesis.html)

ltiago94 March 21, 2018 16:39

Need some help with my masters thesis!
 
Hello everyone, I'm new to CFD and OpenFoam in particular. My dissertation theme is to model a block for coast protection that someone already had tested in laboratory.
I intend to recreate the experiments but using OpenFoam and numerical modelling to validate the results and maybe improve the structure. I had already written some files and did some tutorials but now I'm stuck in a point I can't leave and that's not good for my project.

I'm having trouble with defining some settings for the problem to run in openfoam, for example, to define a geometry for the block to be removed from the mesh and proceed with the analysis.

My main problems are with the setFieldsDict, because I need to define a depth of the channel filled with water but the other part is air.
Also, I don't know how to define the geometry for the block (simple one to start) and to include it in the entire process.

If anyone could help me I'd be really grateful.
Thanks,
Tiago

piu58 March 22, 2018 00:37

It is best to start with the tutorials. Choose the one which fits most to your problem, let it run, fumble around, change something.
After that you should be able at least to modify an existing case.

ltiago94 March 22, 2018 09:50

Quote:

Originally Posted by piu58 (Post 686082)
It is best to start with the tutorials. Choose the one which fits most to your problem, let it run, fumble around, change something.
After that you should be able at least to modify an existing case.

Hello and thanks for the reply. I already did some tutorials that OpenFOAM suggests. The thing is that some of them don't include the parts where I need to use snappyHexMesh and a geometry in the mesh, which I will need in my project. I have troubles with creating a geometry (even a simple one to start) and go from there, use snappyHexMesh to refine the mesh and extract the surface of my structure, and then the extrudeMesh to convert the 3D mesh in 2D so the process can be simpler and faster.
Also I don´t know exactly how to make the setFieldsDict know that a part of the mesh is filled with water and the other one with air, so when I execute the process, the wave information will alternate the free surface.

aow March 23, 2018 16:10

1 Attachment(s)
Hello Luis,

I've been simulating both dam break and piston driven wave s in long flumes for my PhD using the interFoam and olaDyMFoam solvers. olaDyMFoam is a modified version of interFoam developed and maintained by Pablo Higuera (see https://github.com/phicau/olaFlow), which implements a builtin method for performing mesh motion (it compresses/expands a region of the mesh) to allow for such boundary conditions as a moving piston wall based on a time history of wall displacement and also free surface elevation with the latter being an optional input. If you want an explanation of how to compile the olaDyMFoam solver so that it's properly added into an existing OpenFOAM installation, then let me know and I'd be happy to try to walk you through it.

I've attached a modified example case of my piston wave maker setup since I don't have an OpenFOAM-5.0 version of the dambreak flume. Note that I changed the solver name in the controlDict file to be interFoam instead of olaDyMFoam, deleted the "0.org/pointDisplacement" file, and deleted the wave generation files in the "constant" directory, etc..., but I have not actually tested that it runs (not that anything would happen anyway since I took out the piston motion and left it as a tank full of water with no imposed velocity). However, the "buildUnbroken.sh" file should show you the general work flow required to setup a case like you're talking about, providing I understood your post correctly.

To setup the initial conditions, you need to make sure you make a 0 directory (I make a directory called 0.org and copy it to be called 0 so I can start over from scratch when I need to) with files for each parameter used in the model, which depends on the solver used and the turbulence model you choose. For example, when using a 2-equation, k-epsilon type turbulence model with the interFoam solver, the parameter files are epsilon, k, p_rgh, U, and alpha.water (there may be nut and nuTilda in a tutorial, but they're not necessary for k-epsilon simulations since nut gets calculated from k and epsilon and nuTilda is for the 1-equation, SpallartAllmaras turbulence model). Take a look at the 0.org directory in the attached example case for how to setup these files. The actual values will of course vary depending on the type of flow you're simulating so don't take mine as being universal.

Concerning building a model, I try to go through the following steps...
  1. Modify an existing blockMeshDict file from a tutorial (I used the damBreak one) to build the bounding box(es) that will define the initial shape of your domain (see https://cfd.direct/openfoam/user-guide/blockMesh/)
  2. If you need to mesh a complex geometry, then generate an .stl (stereolithography) file for it using a suitable CAD program (Autodesk's Inventor is a good, free program for students) or generate the file manually using python, Matlab, etc... to calculate the data and print it to a file following the standard .stl format (see https://en.wikipedia.org/wiki/STL_(file_format))
  3. To use an .stl file with snappyHexMesh (sHM), you will need to first extract data from it into a format that sHM can use with the surfaceFeatureExtract utility (look in the system directory of the motorBike tutorial to see the surfaceFeatureExtractDict and snappyHexMeshDict (sHMDict) files).
  4. Choose the part of the domain you want to mesh. For example, I usually want to insert the .stl as a boundary surface that is hollow inside the wave flume domain made using the blockMesh utility. To do this, you need to edit the "locationInMesh" point in your sHMDict so that it is inside your domain, but outside the .stl surface (sHM only keeps cells in the region where this point is located).
  5. Choose how to mesh around the .stl surface using the 3 steps built into sHM: castellatedMesh, snap, and addLayers (for a detailed explanation, see the OpenFOAM manual at https://cfd.direct/openfoam/user-guide/snappyhexmesh/). Setting the first one to "true" in your sHMDict will refine the mesh in a blocky, hex-based manner so that the mesh conforms to feature edges, a surface, or within a refinement region. I recommend trying just the surface for meshing your .stl surface and region refinement if needed in specific areas. When choosing the refinement levels for these options, remember that "level 0" is the cell size created by blockMesh and all higher numbers represent divisions by 2 (for example an 8 cm cell at level 0 would be split into 4 cm cells in a level 1 region, 2 cm cells in a level 2 region, etc...). After the castellatedMesh step, the snap step will attempt to change the cells by displacing points in a manner that makes the mesh smoother and conforms better to the .stl surface. Again, follow the files I attached or suitable tutorial like the motorBike one.
  6. To build the mesh you setup with the file modifications I described above, execute the following commands in order: blockMesh, surfaceFeatureExtract, snappyHexMesh. Be sure that you've sourced the .bashrc file for your OpenFOAM installation first or else your system will not know what these commands are (example: "source /<yourDirectory>/OpenFoam-5.0/etc/.bashrc") and that you've got access to a computer or node with enough processors if you want to run snappyHexMesh in parallel (see attached example case file "buildUnbroken.sh" for how to do this)

This basically takes care of building all of the geometry and you can get further details from the example case I've attached to this post. Lastly, you should use the setFields utility to fill in non-zero alpha.water values. For my cases, using a single rectangular volume region was sufficient. Note that the bounds of this region do not necessarily have to line up with the boundary edges; the utility will just ignore regions that are outside the domain (check the setFieldsDict in the attached example case). Note that in the setFieldsDict, you should set the "defaultFieldValues" so that alpha.water is 0, which will make the domain air everywhere to begin with. Then whatever part of the domain you select in the "regions" should have alpha.water set to 1. I hope this makes it clearer for you as to how you should use the setFields utility. Typically, I've found it's best to do this step last before you run a case in serial or decompose it to run in parallel. This way you can make whatever crazy geometry you want and then make a big box that goes through your domain at the correct depth and outside the boundaries everywhere else to fill in the water without missing any cells.

Let me know if you have any questions or if I was unclear.

Best regards,

Andrew

PS - I just realized I forgot to modify the "inlet" boundary condition for "0.org/U". It should be something other than "movingWallVelocity" since interFoam would be used instead of olaDyMFoam.

ltiago94 March 23, 2018 18:30

Hello and thanks for the reply and the great information that you provided.

Could I email you the files I already did by myself to you so you could take a look into them and see what I'm doing wrong?

I think that I'm doing wrong on some values for the boundary conditions and probably doing some other minor mistakes that I cant see but result in major differences.
Also, I have a .stl file with my geometry for the block I want to test but maybe the fact that the block wasnt designed starting from the (0 0 0) results in the block not showing up in the mesh.


if you could help me I'd really appreciate it.


best regards,
Tiago

aow March 23, 2018 18:38

Luis,

Sure, I don't mind taking a look. If they're not too large, please attach the files to a post and I'll try them out.

Concerning the placement of the .stl file, each point within the file will be used with the exact coordinates written in the file so if you expected it to be at the origin, but drew it in a CAD program away from the origin, then the CAD program would export it there and your .stl file may not fit inside your domain.

Best,

Andrew

ltiago94 March 23, 2018 18:41

I think that's what happened probably. I'll need to draw the geometry again.

The files are too large to attach to a post here. It has also pictures of a sketch of the experiments I want to test in OpenFOAM

best regards,

Luís Tiago

aow March 23, 2018 18:45

Luís,

Could you upload the files to something like Dropbox or Google Drive and send me a link? Or would they fit in a private message? Let me know what works best for you.

Andrew

ltiago94 March 23, 2018 18:53

I dont know why but cant attach files in a private message

aow March 23, 2018 19:12

Quote:

Originally Posted by ltiago94 (Post 686375)
I dont know why but cant attach files in a private message

Hmm, I had never tried that myself so I guess you cannot. Anyway, I sent you my work email so you can send me the files if they fit in an email. If not then just send me a link to where you are able to upload the files.


All times are GMT -4. The time now is 23:26.