CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Running, Solving & CFD

VOF initialization with a STL file (closed volume)

Register Blogs Community New Posts Updated Threads Search

Like Tree10Likes
  • 10 Post By dglee

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   June 23, 2017, 02:16
Default VOF initialization with a STL file (closed volume)
  #1
New Member
 
Dongguk Lee
Join Date: Jun 2017
Location: Seoul, Korea
Posts: 2
Rep Power: 0
dglee is on a distinguished road
Hi guys,

I was looking for the way to set the VOF initial position by using a certain shape (closed volume of STL file).
Finally I was able to do that.
Since I was not able to find this way from web searching, I write this thread here. Just prepare your stl file and set your setFieldsDict file with "surfaceToCell" optioin.


/*--------------------------------*- C++ -*---------------------------------*\
| ========= | |
| \ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \ / O peration | Version: 4 |
| \ / A nd | Web: http://www.OpenFOAM.org |
| \/ M anipulation | |
\*--------------------------------------------------------------------------*/

FoamFile
{
version 4.1;
format ascii;
class dictionary;
object setFieldsDict;
location "system";
}
defaultFieldValues
(
volScalarFieldValue alpha.secPhase 0
);
regions
(
// Select based on surface
surfaceToCell
{
file "sphere.stl";
outsidePoints ((-1 -0.8 -0.5)); // definition of outside
includeCut false; // cells cut by surface
includeInside yes; // cells not on outside of surf
includeOutside no; // cells on outside of surf
nearDistance -1; // cells with centre near surf
curvature 0.9; // cells within nearDistance
fieldValues
(
volScalarFieldValue alpha.secPhase 1
);
}
);
guin, JFM, frantov and 7 others like this.
dglee is offline   Reply With Quote

Old   January 6, 2018, 09:47
Default
  #2
JFM
Member
 
JFM's Avatar
 
John Anonymous
Join Date: Jan 2011
Location: Melbourne Australia
Posts: 37
Rep Power: 15
JFM is on a distinguished road
Send a message via Skype™ to JFM
Hi Dongguk Lee

I appreciate you providing this post I have been looking for this type of approach for a period of time. I have taken your approach and tried to apply it to my particular case, however I am recieving the following error message:
Code:
Create time

Create mesh for time = 0

Reading setFieldsDict

Setting field default values
    Setting internal values of volScalarField alpha.water

Setting field region values


--> FOAM FATAL ERROR: 
Cannnot read "test_1.stl"

    From function bool Foam::triSurface::read(const Foam::fileName&, const Foam::word&, bool)
    in file triSurface/triSurface.C at line 360.

FOAM exiting
The code I have used in the setFieldsDict is:
Code:
defaultFieldValues
(
    volScalarFieldValue alpha.water 0
);

regions    // Select based on surface
(
      surfaceToCell
    //     https://www.cfd-online.com/Forums/openfoam-solving/189582-vof-initialization-stl-file-closed-volume.html
    {
        file                     "test_1.stl";
        outsidePoints            ((3.02858 1.94427 83.2));    // definition of volume outside
        includeCut                false;                        // cells cut by surface
        includeInside            yes;                        // include cells inside surface
        includeOutside            no;                            // exclude cells outside surface
        useSurfaceOrientation    true;                        // use surface normals
        nearDistance            -0.01;                        // cells with centre near surface
        curvature                0.9;                        // cells within nearDistance
        
        fieldValues
        (
            volScalarFieldValue alpha.water 1
        );
    }
);

// ************************************************************************* //
I have also attached a copy of the STL file I am hoping to use to set the initial phase conditions. This STL includes a volume of the alpha (water) phase and has been snapped to the external boundary vertices (inlet/outlet/wall patches) with the exception of the top surface which is set at the desired water surface elevation within the model domain.

I have checked the db/dictionary (surfaceToCells) and the layout of the function and what you have provided appears to be fine so i guess the issue relates to the STL itself.

Any assistance guidance will be appreciated.

Regards
JFM
Attached Files
File Type: gz test_1.stl.tar.gz (701 Bytes, 61 views)
JFM is offline   Reply With Quote

Old   January 7, 2018, 22:49
Default
  #3
New Member
 
Dongguk Lee
Join Date: Jun 2017
Location: Seoul, Korea
Posts: 2
Rep Power: 0
dglee is on a distinguished road
Hi JFM,

I tried with your "test_1.stl" file and it works fine.
Could you please try again, but please locate the "test_1.stl" file in your project directory. not inside of 0 or constant or system.
dglee is offline   Reply With Quote

Old   January 10, 2020, 05:15
Default Same problem
  #4
New Member
 
Ann
Join Date: Nov 2019
Posts: 6
Rep Power: 6
Adyk is on a distinguished road
I know, this is an old thread, but maybe you read it anyway. This is exactly the same problem I struggle with:


Here is the error message

Code:
--> FOAM FATAL ERROR: 
Cannot read "1.stl"

    From function bool Foam::triSurface::read(const Foam::fileName&, const Foam::word&, bool)
    in file triSurface/triSurface.C at line 304.

FOAM exiting
and this is my setFieldsDict
Code:
FoamFile
{
    version     2.0;
    format      ascii;
    class       dictionary;
    object      setFieldsDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

defaultFieldValues
(
    volScalarFieldValue alpha.water 0
    volVectorFieldValue U (0 0 0)
);

regions
(

    surfaceToCell
    {
        file "1.stl";
        outsidePoints ((1 1 0.01)); // definition of outside
        includeCut false; // cells cut by surface
        includeInside yes; // cells not on outside of surf
        includeOutside no; // cells on outside of surf
        nearDistance -1; // cells with centre near surf
        curvature 0.9; // cells within nearDistance

        fieldValues
        (
            volScalarFieldValue alpha.water 1
            volVectorFieldValue U (0 0 0)
        ); 
    }

);
Well, i don't really understand the "outsidePoints ((x y z)); // definition of outside" , how do i define them? which values of my shape define the outside? Probably that's my problem..

I attached the stl file.

Hope you can help me!
Attached Files
File Type: gz 1.stl.gz (1.3 KB, 16 views)
Adyk is offline   Reply With Quote

Old   January 13, 2020, 02:55
Default
  #5
Senior Member
 
Yogesh Bapat
Join Date: Oct 2010
Posts: 102
Rep Power: 16
ybapat is on a distinguished road
Hello,


Outside point is point outside the stl and inside the geometry. Also I recommend you rename you file to start with string instead of 1. You need to keep the file in project directory or provide full path.



Regards,
-Yogesh
ybapat is offline   Reply With Quote

Old   January 13, 2020, 05:15
Default
  #6
New Member
 
Ann
Join Date: Nov 2019
Posts: 6
Rep Power: 6
Adyk is on a distinguished road
Thanks for your reply! Finally I got it. But there's another problem.. This is for my bachelor thesis, so it would be great, to get it work.
Okay, I'll rename it.
Does it matter, where this outside point is? And how can I define the position of the stl in my Mesh?

At the moment, I don't see the phase in ParaView. When I look at p_rgh or U I can see something (don't know what it is exactly, but something happens). But the shape itself is not visible (see attached files)
I also did the volume rendering, but there is nothing..

Does "surfaceToCell" give me the phase at all? Or is it just for U, p etc?
Attached Images
File Type: png alpha.water.png (15.4 KB, 56 views)
File Type: png U.png (43.3 KB, 75 views)
Adyk is offline   Reply With Quote

Old   January 14, 2020, 06:16
Default
  #7
Senior Member
 
Yogesh Bapat
Join Date: Oct 2010
Posts: 102
Rep Power: 16
ybapat is on a distinguished road
Hello,


Outside points is just any point outside the closed STL in which you want to patch the phase. surfaceToCell can be used to patch any scalar, vector etc. field.



Regards,
-Yogesh
ybapat is offline   Reply With Quote

Old   January 14, 2020, 06:17
Default
  #8
Senior Member
 
Yogesh Bapat
Join Date: Oct 2010
Posts: 102
Rep Power: 16
ybapat is on a distinguished road
Outside points is just any point outside the closed STL in which you want to patch the phase and inside the mesh
ybapat is offline   Reply With Quote

Reply

Tags
initialization, interfoam, setfields, vof


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
[swak4Foam] groovyBC in openFOAM-2.0 for parabolic velocity bc ofslcm OpenFOAM Community Contributions 25 March 6, 2017 11:03
[swak4Foam] swak4foam building problem GGerber OpenFOAM Community Contributions 54 April 24, 2015 17:02
friction forces icoFoam ofslcm OpenFOAM 3 April 7, 2012 11:57
Version 15 on Mac OS X gschaider OpenFOAM Installation 113 December 2, 2009 11:23
DxFoam reader update hjasak OpenFOAM Post-Processing 69 April 24, 2008 02:24


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