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

[Other] How to add water in a non-rectangular bounding box?

Register Blogs Community New Posts Updated Threads Search

Like Tree2Likes

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   October 3, 2023, 11:51
Default How to add water in a non-rectangular bounding box?
  #1
New Member
 
Rhea
Join Date: Oct 2023
Posts: 13
Rep Power: 2
bunnybunny is on a distinguished road
Hi! I am new to CFD. I want to use the multiphase solver and generate a beach-type geometry (box with slanted side for beach) to observe the waves on the beach. I don't know how to create this fluid. I was able to create the whole domain via BlockMeshDict but the water, I don't know how to put.



I have checked setFieldsDict but I feel like it can only create boxes of fluid. (Correct me if I am wrong).



Thank you to anyone who can answer.
bunnybunny is offline   Reply With Quote

Old   October 4, 2023, 01:27
Default
  #2
Senior Member
 
M
Join Date: Dec 2017
Posts: 642
Rep Power: 12
AtoHM is on a distinguished road
Welcome to the forum bunnybunny,

you are on the right track, you should use setFields for this. You can define any region in terms of an stl file that you can create in your CAD tool of choice. Grab a template of setFieldsDict anywhere and use the surfaceToCell definition; adjust x/y/z_coords and waterFieldName to your case. I recommend to run this locally and check the outcome before you continue to run the simulation.

Code:
regions 

(

    surfaceToCell
    {
        file "waterInitialization.stl"; // placed inside case folder
        outsidePoints
        (
            (<x_coord> <y_coord> <z_coord>)
        );
        includeCut      true;    // whether or not to include cells that are cut by the stl
        includeInside   true;
        includeOutside  false;
        nearDistance    0.001;       // cells within that distance are also included
        curvature       1;
        fieldValues
        (
            volScalarFieldValue <waterFieldName> 1
        );
     }
 )
There is an alternative way using topoSetDict to create a cellZone and then - I think - setSet inside setFieldsDict to prescribe fieldValues. This has the advantage, that there is no need to define an outside coordinate as in the example above. But the above works just fine too.

Last edited by AtoHM; October 4, 2023 at 02:49.
AtoHM is offline   Reply With Quote

Old   October 4, 2023, 05:49
Default
  #3
New Member
 
Rhea
Join Date: Oct 2023
Posts: 13
Rep Power: 2
bunnybunny is on a distinguished road
Hi AtoHM, thanks for the reply. Very informative.


But how about for cases wherein I will not import an STL file? I created the beach in the blockMeshDict file. I am not sure if this strategy is correct.



Thank you.
bunnybunny is offline   Reply With Quote

Old   October 4, 2023, 06:20
Default
  #4
Senior Member
 
Yann
Join Date: Apr 2012
Location: France
Posts: 1,067
Rep Power: 26
Yann will become famous soon enough
Hello Rhea,

I am not sure I tried it before but if I'm not mistaken you can use the same sources in setFields than in topoSet. So you can use boxToCell or surfaceToCell but also cylinderToCell, sphereToCell, rotatedBoxToCell, etc...

But maybe you could post a drawing of your domain and the water body you want to initialize? At this point I am not sure to understand what kind of water shape you need.

Yann
Yann is offline   Reply With Quote

Old   October 4, 2023, 21:06
Default
  #5
New Member
 
Rhea
Join Date: Oct 2023
Posts: 13
Rep Power: 2
bunnybunny is on a distinguished road
Hello Yann, I am planning to create something like this.


Edit: Sorry I can't seem to upload the photo. It's basically a beach type of setup like this.


bunnybunny is offline   Reply With Quote

Old   October 4, 2023, 21:15
Default
  #6
New Member
 
Rhea
Join Date: Oct 2023
Posts: 13
Rep Power: 2
bunnybunny is on a distinguished road
Hello Yann, I cannot seem to upload my own photo. But it looks something like this:

https://pub.mdpi-res.com/jmse/jmse-1...png?1676882133


or maybe this


https://www.mdpi.com/jmse/jmse-11-00...00519-g001.png


Thank you.
bunnybunny is offline   Reply With Quote

Old   October 5, 2023, 01:52
Default
  #7
Senior Member
 
M
Join Date: Dec 2017
Posts: 642
Rep Power: 12
AtoHM is on a distinguished road
Why do you think you need something more than a box to set the water phase?
Your fluid domain should end at the beach sand ("wall"). You can use a generic box to set the water because where the sand is, you should have no cells for either air or water to exist.


You might want to attach an image of your blockMesh or the blockMeshDict here so we can see what that looks like. You can attach normal picture files to any forum post here, no need for external links.
Yann likes this.
AtoHM is offline   Reply With Quote

Old   October 5, 2023, 03:26
Default
  #8
Senior Member
 
Yann
Join Date: Apr 2012
Location: France
Posts: 1,067
Rep Power: 26
Yann will become famous soon enough
Hello,

I agree with AtoHM and I just wanted to add a detail to make things clearer: the box (or cylinder or whatever geometry) defined in setFieldsDict is just a way to select cells inside the domain. The box can be larger than the domain itself, it will only select the cells within the mesh which are inside the box.
AtoHM likes this.
Yann is offline   Reply With Quote

Old   October 5, 2023, 05:50
Default
  #9
New Member
 
Rhea
Join Date: Oct 2023
Posts: 13
Rep Power: 2
bunnybunny is on a distinguished road
Hello, thanks for the replies, I didn't know I can extend the setFieldsDict to outside of the blockMeshDict geometry, I have tried it with regular rectangular prism and it works.


However, my question now is when I try to make the blockMeshDict into the beach geometry, the fluid(water) is no longer appearing. What could have been the problem?


I am showing here my blockmeshdict file in case.
Code:
vertices
(
    (    0    0    0    )
    (    0.3    0    0    )
    (    0.3    0.09    0    )
    (    0    0.09    0    )
    (    0    0    0.2    )
    (    0.4    0    0.2    )
    (    0.4    0.09    0.2    )
    (    0    0.09    0.2    )
);

blocks
(
    hex (0 1 2 3 4 5 6 7) (100 75 1) simpleGrading (1 1 1)
);


edges
(
);

boundary
(
    leftWall
    {
        type wall;
        faces
        (
            (0 4 7 3)
        );
    }
    rightWall
    {
        type wall;
        faces
        (
            (2 6 5 1)
        );
    }
    lowerWall
    {
        type wall;
        faces
        (
            (0 1 5 4)
            (3 2 6 7)
            (0 1 2 3)
        );
    }
    atmosphere
    {
        type patch;
        faces
        (
            (4 5 6 7)
        );
    }
);
Additionally, when I try to change just the vertices (to make it a rectangular prism), the fluid is appearing again. But somehow, when it is the beach geometry, the fluid suddenly is gone.

Last edited by bunnybunny; October 5, 2023 at 05:51. Reason: Clarification, more context
bunnybunny is offline   Reply With Quote

Old   October 5, 2023, 06:14
Default
  #10
Senior Member
 
Yann
Join Date: Apr 2012
Location: France
Posts: 1,067
Rep Power: 26
Yann will become famous soon enough
Some screenshots of your mesh/domain would help to visualize what you are doing.

You can show what work and don't work.
Yann is offline   Reply With Quote

Old   October 5, 2023, 06:19
Default
  #11
New Member
 
Rhea
Join Date: Oct 2023
Posts: 13
Rep Power: 2
bunnybunny is on a distinguished road
This is what I am trying to simulate. And then maybe add water until the middle height.But then there is no water appearing.

https://imgur.com/CIXuGdJ

I tried to run a case wherein it is rectangular, and the water appears.

Last edited by bunnybunny; October 5, 2023 at 06:19. Reason: typo
bunnybunny is offline   Reply With Quote

Old   October 5, 2023, 06:24
Default
  #12
Senior Member
 
Yann
Join Date: Apr 2012
Location: France
Posts: 1,067
Rep Power: 26
Yann will become famous soon enough
Could you also post the same screenshot on your working case (rectangular domain) at time 0?

Also can you post your setFieldsDict definition?
Yann is offline   Reply With Quote

Old   October 5, 2023, 09:40
Default
  #13
New Member
 
Rhea
Join Date: Oct 2023
Posts: 13
Rep Power: 2
bunnybunny is on a distinguished road
Hello, I was able to solve the problem with making the fluid appear. Turns out that I wasn't able to fix the mesh in the BlockMeshDict.


However, now I get a new problem. When the geometry is rectangular, the simulation runs well. Now, using the beach type geometry, i get this error just after one time step (t=0.005)


PIMPLE: iteration 1
smoothSolver: Solving for alpha.water, Initial residual = 5.77942e-09, Final residual = 5.77942e-09, No Iterations 0
Phase-1 volume fraction = 0.4375 Min(alpha.water) = -1.63506e-13 Max(alpha.water) = 1
MULES: Correcting alpha.water
MULES: Correcting alpha.water
Phase-1 volume fraction = 0.4375 Min(alpha.water) = -1.63506e-13 Max(alpha.water) = 1
#0 Foam::error:rintStack(Foam::Ostream&) at ??:?
#1 Foam::sigFpe::sigHandler(int) at ??:?
#2 ? in /lib/x86_64-linux-gnu/libc.so.6
#3 Foam::scalarProduct<double, double>::type Foam::sumProd<double>(Foam::UList<double> const&, Foam::UList<double> const&) at ??:?
#4 Foam::PCG::scalarSolve(Foam::Field<double>&, Foam::Field<double> const&, unsigned char) const at ??:?
#5 Foam::PCG::solve(Foam::Field<double>&, Foam::Field<double> const&, unsigned char) const at ??:?
#6 Foam::fvMatrix<double>::solveSegregated(Foam::dict ionary const&) at ??:?
#7 Foam::fvMatrix<double>::solveSegregatedOrCoupled(F oam::dictionary const&) at ??:?
#8 Foam::fvMesh::solve(Foam::fvMatrix<double>&, Foam::dictionary const&) const at ??:?

Last edited by bunnybunny; October 5, 2023 at 09:41. Reason: typo
bunnybunny is offline   Reply With Quote

Old   October 5, 2023, 09:48
Default
  #14
New Member
 
Rhea
Join Date: Oct 2023
Posts: 13
Rep Power: 2
bunnybunny is on a distinguished road
Another thing is, I have noticed that the water are actually on the sides (walls) only. I am not sure if the box is actually filled.
bunnybunny is offline   Reply With Quote

Old   October 5, 2023, 10:02
Default
  #15
Senior Member
 
Yann
Join Date: Apr 2012
Location: France
Posts: 1,067
Rep Power: 26
Yann will become famous soon enough
Please provide your setFieldsDict definition. Are you sure the water is only initialized on the walls or could it be a visualization matter?

Open your case in paraView and create a slice to visualize alpha.water in the domain (preferably cell values, surface with edges)

Regarding to your case, first thing coming to my mind would be a boundary condition issue. What BCs did you define?
Yann is offline   Reply With Quote

Old   October 5, 2023, 10:17
Default
  #16
New Member
 
Rhea
Join Date: Oct 2023
Posts: 13
Rep Power: 2
bunnybunny is on a distinguished road
Hello, I have followed your advice and checked on paraview and the whole thing is filled, thankfully. It's just a visualization issue.


Anyway, regarding my model, if the blockmeshdict is a rectangular prism, i have tried a dambreak case in it and the simulation runs smoothly.
However, i tried exactly the same case (except for changing two vertices so i can make one wall slanted), and then suddenly, the simulation stops after one iteration.


Is there a problem with the fact that the wall is slanted? I have checked boundary conditions. I am now using Around, and Atmosphere. But still same thing. Rectangular domain works, but a beach-type does not
bunnybunny is offline   Reply With Quote

Old   October 6, 2023, 04:35
Default
  #17
Senior Member
 
Yann
Join Date: Apr 2012
Location: France
Posts: 1,067
Rep Power: 26
Yann will become famous soon enough
Quote:
Originally Posted by bunnybunny View Post
Is there a problem with the fact that the wall is slanted? I have checked boundary conditions. I am now using Around, and Atmosphere. But still same thing. Rectangular domain works, but a beach-type does not
Maybe yes, maybe not. It's impossible to tell with this few information about your setup.

You get your error when the solver is supposed to solve pressure, this is why I thinking boundary conditions should be checked first, but this could come from something else too. Since I don't know what boundary conditions your used, I cannot really help.

Yann
Yann is offline   Reply With Quote

Old   October 6, 2023, 07:16
Default
  #18
New Member
 
Rhea
Join Date: Oct 2023
Posts: 13
Rep Power: 2
bunnybunny is on a distinguished road
Here are my boundary conditions, just in case it can help:


For alpha.water:
Code:
boundaryField
{
    atmosphere
    {
        type            inletOutlet;
        inletValue      uniform 0;
        value           uniform 0;
    }

    around
    {
        type            zeroGradient;
    }
}
For the p_rgh:
Code:
boundaryField
{
    atmosphere
    {
        type            totalPressure;
        p0              uniform 0;
        U               U;
        phi             phi;
        rho             rho;
        psi             none;
        gamma           1;
        value           uniform 0;
    }

    around
    {
        type            fixedFluxPressure;
        value           uniform 0;
    }
}
And for the U file:
Code:
boundaryField
{
    atmosphere
    {
        type            pressureInletOutletVelocity;
        value           uniform (0 0 0);
    }

    around
    {
        type            fixedValue;
        value           uniform (0 0 0);
    }
}

I am really stuck. Thank you in advance for all the help.
bunnybunny is offline   Reply With Quote

Old   October 6, 2023, 11:30
Default
  #19
Senior Member
 
Yann
Join Date: Apr 2012
Location: France
Posts: 1,067
Rep Power: 26
Yann will become famous soon enough
Nothing wrong so far.

What OpenFOAM version are you using?
Would it be possible to post your case here to have a deeper look?

Yann
Yann is offline   Reply With Quote

Old   October 9, 2023, 09:24
Default
  #20
New Member
 
Rhea
Join Date: Oct 2023
Posts: 13
Rep Power: 2
bunnybunny is on a distinguished road
Hi, Sorry for late reply. I am using v2112. Here is the case folder.


https://file.io/71eJb5bAk6Ed


Feel free to let me know if I have done anything wrong as I am a beginner to cfd.
bunnybunny is offline   Reply With Quote

Reply

Tags
beach, multiphase, slope, water, waves


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
Mass imbalance problem in multiphase water and steam CFX case Antech CFX 1 October 26, 2020 04:03
phantom region created outside blockmesh bounding box derekm OpenFOAM Pre-Processing 0 May 15, 2014 10:31
2D Box dropping into water kailingkk Fluent Multiphase 1 April 9, 2014 19:06
snapyHexMesh Bounding box vmsandip2011 OpenFOAM Pre-Processing 5 May 26, 2012 02:13
Terrible Mistake In Fluid Dynamics History Abhi Main CFD Forum 12 July 8, 2002 09:11


All times are GMT -4. The time now is 17:00.