CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Community Contributions

[swak4Foam] mass Flow of water with Swak4Foam

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

Like Tree3Likes
  • 1 Post By wyldckat
  • 2 Post By wyldckat

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   August 19, 2015, 17:57
Default mass Flow of water with Swak4Foam
  #1
Member
 
Rafael Marques
Join Date: Mar 2014
Location: Almada/Mülheim a.d. Ruhr, Portugal/Germany
Posts: 67
Rep Power: 11
rafa13 is on a distinguished road
Hi Everybody,

I am simulating a wave breaker and i try to get the overtopping. I want to obtain the mass flow of the water on the top of the structure and I know that is possible to intergrate the velocity over a faceZone, so i want to ask if somebody can give me a hind how to do it?

The main question is how to integrate the velocity of alpha over a faceZone?


I created a expression Field with the x velocity of the water
VeloxAgua
{
type expressionField;
outputControl timeStep;
valueType internalField;
outputInterval 1;
fieldName UxAlpha;
variables (
"thres=0.5;"
"xDirection=vector(1,0,0);"
"Ua1x=alpha1>thres ? (U & xDirection) : 0;"
);
expression "Ua1x";

autowrite true;
}


but after that i don know hoew to integrate this UxAlpha over a faceZone.


thanks to everybody

Rafa Marques
rafa13 is offline   Reply With Quote

Old   August 21, 2015, 17:17
Default
  #2
Member
 
Rafael Marques
Join Date: Mar 2014
Location: Almada/Mülheim a.d. Ruhr, Portugal/Germany
Posts: 67
Rep Power: 11
rafa13 is on a distinguished road
Hi Bruno,

First i want to says thanks for your didactic answer. I finally got, my problem was that i hat now ideia how the information are stored in the cells so, i tried to get information of the cell volume with the cell face and that didn't work, so that is what i did to get the mass flow of the only of the water.

i created a simpled case of a water recipient that is drowning out through a pipe to know the answer.

them i created a faceZone and a slave cell with the toposetdict:

Code:
actions
(
  {
    name    massFlow;
        type    faceSet;
        action  new;
        source  boxToFace;
        sourceInfo
        {
                box  (0.8 -1 0) (0.805 1 0.1);
        }

   }
    {
        name    massFlow;
        type    faceZoneSet;
        action  new;
        source  setToFaceZone;
        sourceInfo
        {
            faceSet massFlow;           // name of cellSet
        }
    }


   {
        name    massFlow_SlaveCells;
        type    cellSet;
        action  new;
        source  faceZoneToCell;
        sourceInfo
        {
            name massFlow;
            option slave;
        }
    }

);
and changed the FlipMap bollean in constante/polyMesh/faceZones to 0.


and then i used swakExpression to get the water velocity at the faceZone, using the alpha as if condition (like the example in the swakWiki)


Code:
functions
(    
  
flowIntFluid
    {
        type swakExpression;
        valueType faceZone;
        zoneName massFlow;
        variables (             
             "thres=0.5;"
             "phiAl=U & Sf();"
             "phiAlpha1=alpha1>thres ? (phiAl*alpha1) : 0;"    
            );
        expression "phiAlpha1";
        accumulations (
           sum

        );
        verbose true;
       autoInterpolate true;
    }

flowIntFluid2
    {
        type swakExpression;
        valueType faceZone;
        zoneName massFlow;
        variables (             
             "thres=0.5;"
             "phiAlpha=alpha1>thres ? (phi*flip()*alpha1) : 0;"    
            );
        expression "phiAlpha";
        accumulations (
           sum

        );
        verbose true;
       autoInterpolate true;
    }
);
and know i thing i get the right results, but i now i get to different values and i red that U & Sf() is the same as phi, is that right? and if not what is the diference?


Thanks again i learned a lot

Rafa Marques


[ Moderator note: Moved from http://www.cfd-online.com/Forums/ope...code-do-2.html ]

Last edited by wyldckat; September 6, 2015 at 11:41. Reason: Added [CODE][/CODE] markers and moderator note
rafa13 is offline   Reply With Quote

Old   August 21, 2015, 18:10
Default
  #3
Retired Super Moderator
 
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,969
Blog Entries: 45
Rep Power: 127
wyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to all
Hi Rafa,

Sorry, I had plans on providing a more detailed answer, but I ended up not having the time and inspiration to do so
But you certainly have provided the main details that I would have had to test and write, so thank you for doing so!

Quote:
Originally Posted by rafa13 View Post
and changed the FlipMap bollean in constante/polyMesh/faceZones to 0.
There is a utility called orientFaceZone, which if you run without options, it should tell you this:
Code:
orientFaceZone [OPTIONS] <faceZone> <outsidePoint>


Quote:
Originally Posted by rafa13 View Post
and know i thing i get the right results, but i now i get to different values and i red that U & Sf() is the same as phi, is that right? and if not what is the diference?
"phi" is the field that has the volumetric flow rate through each face of the mesh. This field is the one mostly used in the equations that the solvers will resolve. This to say that the "phi" field gives you the most accurate flow rate values, because the "U" field (vectors are positioned in the centre of the cells) is actually a field reconstructed from "phi".
Curiously, this is in the FAQ: http://openfoamwiki.net/index.php/FA..._is_writing.3F

Best regards,
Bruno
__________________
wyldckat is offline   Reply With Quote

Old   August 22, 2015, 07:54
Default
  #4
Member
 
Rafael Marques
Join Date: Mar 2014
Location: Almada/Mülheim a.d. Ruhr, Portugal/Germany
Posts: 67
Rep Power: 11
rafa13 is on a distinguished road
Hi Bruno,

thanks for the quick answer, i tried to use the orientFaceZone utility but at the moment i didn't get it to work for now, i am quite a noob at openfoam and linux so everything takes a while for me to figured out.


one question about the flipmap, when i didn't turn it of i get negative results, is that because of the slave cells are switch?

and one more question the slave cells are the cells of both side off the faceZone and i get the information about the alpha1 from them? but i need the information of the cell where the water passing by first.


Greets
Rafa Marques
rafa13 is offline   Reply With Quote

Old   August 22, 2015, 08:02
Default
  #5
Retired Super Moderator
 
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,969
Blog Entries: 45
Rep Power: 127
wyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to all
Quote:
Originally Posted by rafa13 View Post
one question about the flipmap, when i didn't turn it of i get negative results, is that because of the slave cells are switch?

and one more question the slave cells are the cells of both side off the faceZone and i get the information about the alpha1 from them? but i need the information of the cell where the water passing by first.
Quick answer: You created the faceZone only based on the faces, which can lead to not having all of the faces in the "faceZone" with the same orientation. This is usually due to how the mesh was created, because the face orientation in each cell depends on how each cell was created. Here's a thread that demonstrates this issue: http://www.cfd-online.com/Forums/ope...-facezone.html - I suggest you study the whole thread, because a lot of the questions you have are already answered there.
rafa13 likes this.
wyldckat is offline   Reply With Quote

Old   August 22, 2015, 08:25
Default
  #6
Member
 
Rafael Marques
Join Date: Mar 2014
Location: Almada/Mülheim a.d. Ruhr, Portugal/Germany
Posts: 67
Rep Power: 11
rafa13 is on a distinguished road
Thanks again Bruno

i will study this thread !

greets
Rafa MArques
rafa13 is offline   Reply With Quote

Old   September 19, 2015, 15:58
Default Defining the field alpha
  #7
Senior Member
 
Saideep
Join Date: Apr 2015
Location: INDIA
Posts: 203
Rep Power: 11
Saideep is on a distinguished road
hi Bruno and Rafa;

Bruno, as usual thanks for redirecting me here. I spent quite a lot of time but never found this thread.

I tried this sort of procedure some time back but i had and have a problem. Now as rafa is taking outflux at certain specific face, I have not used the topoSetFields utility. I am only interested at the boundary face as of now.

I want to define and would like to read someting like this:
"phiAlpha1=alpha1>thres ? (phiAl*alpha1) : 0;"

but how can you write the output of alpha1 field?

In older versions of OF, you had to specify alpha field in createFields.h. But now its not the case. however, I traced back to the older versions of OF(1.7) and made changes accordingly to make my alpha field to be read and updated every time step. I think so I was sucessful but though i had a series of errors forcing me to specify someting like alpha.phase1 and related alpha.phase1 data in the fvSolutions dictionary though it does not update the values in the later time steps.

Also I tested both ways and alpha values{also results obviously} are different. I tested the damBreak case.

So, how did you do it?

Thanks and best;
Saideep
Saideep is offline   Reply With Quote

Old   September 19, 2015, 16:17
Default
  #8
Retired Super Moderator
 
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,969
Blog Entries: 45
Rep Power: 127
wyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to all
Hi Saideep,

Can you please adapt the tutorial case "interFoam/ras/waterChannel" and attach it onto your next post? I ask this because this tutorial case is the closest to your description and it would make it easier for me to test things.

Best regards,
Bruno
__________________
wyldckat is offline   Reply With Quote

Old   September 20, 2015, 06:19
Default
  #9
Senior Member
 
Saideep
Join Date: Apr 2015
Location: INDIA
Posts: 203
Rep Power: 11
Saideep is on a distinguished road
hi Bruno;

As told, I tested both interFoam and my modified solver{lets call it so } for the waterChannel case.

I also attached in a word doc with my changes to my modified solver. Just a few lines actually.

Also you can see the attached results which show some sort of variation between both the solvers. {ofcourse not much of use if i just specify for only 1 time step. This is at 15s.}

Apart from that an other question.

Does the function accumulate ( sum ) give a cumulative output or time specific output? I am under an assumption that it gives the cumulative sum of a field. Correct me if wrong.

Thanks;
Saideep
Attached Images
File Type: png fi1_interFoam.png (21.2 KB, 31 views)
File Type: png fi_modified.png (23.5 KB, 21 views)
Attached Files
File Type: pdf modifications.pdf (23.2 KB, 64 views)
Saideep is offline   Reply With Quote

Old   September 20, 2015, 06:49
Default
  #10
Retired Super Moderator
 
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,969
Blog Entries: 45
Rep Power: 127
wyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to all
Quick answers:
Quote:
Originally Posted by Saideep View Post
Also you can see the attached results which show some sort of variation between both the solvers. {ofcourse not much of use if i just specify for only 1 time step. This is at 15s.}
I can't remember if swak4Foam is able to use fields that have dots in the names, e.g. "alpha.water". This is why I asked for a test case, so that I could confirm if the problem exists or not. Because it should not be necessary to modify your solver to use the "alpha1" field.
In other words, the test case would make it quicker for me to take a look at whatever might be going wrong with the original case and settings.


Quote:
Originally Posted by Saideep View Post
Does the function accumulate ( sum ) give a cumulative output or time specific output? I am under an assumption that it gives the cumulative sum of a field. Correct me if wrong.
I already answered this in a thread mentioned a few posts above:
Quote:
Originally Posted by wyldckat View Post
Quick answer:
  1. When in doubt, create a small test case for which you know what the results should give you and make the measurements in that. This way you can ensure that things are working as intended and you gain experience in doing so.
    • In my experience, when it comes to OpenFOAM, engineering, science and programming: assume nothing, test everything. Otherwise, your results are always doubtful.
  2. Integrate over a "cellZone" is most likely done over space, i.e. integrated in volume.
  3. Inside the swak4Foam source code folder is the file "Documentation/swak4FoamReference.md" which roughly answers your question.
wyldckat is offline   Reply With Quote

Old   September 20, 2015, 07:32
Default
  #11
Senior Member
 
Saideep
Join Date: Apr 2015
Location: INDIA
Posts: 203
Rep Power: 11
Saideep is on a distinguished road
hi Bruno;

I will check out for accumulation (sum) function as you advised so that i am sure of what is it calculating.

But are you asking me to provide a test case for checking the difference in results?

Actually as you mentioned the presence of dot operator gives an error using swak4Foam. So, I was not able to use field alpha.water and so had to opt to create a field for alpha seperately and output that. But what is confusing me is the difference in results though i expect them to be the same.

Saideep
Saideep is offline   Reply With Quote

Old   September 20, 2015, 08:49
Default
  #12
Retired Super Moderator
 
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,969
Blog Entries: 45
Rep Power: 127
wyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to all
OK, it took some mental digging through my memories and then I remembered this bug report: http://sourceforge.net/p/openfoam-ex...swak4foam/210/
Quoting Bernhard's answer:
Quote:
Originally Posted by bgschaid
This is known. The problem is that OpenFOAM-words allow a lot of characters that the parser uses for other purposes (I think even +). Letting the parser accept these would either result in a rather weird expression syntax or a very ugly parser code. For this reason there is a workaround implemented in the parser since two versions back: the aliases-table (this is documented in the incomplete reference manual).
In your example add
Code:
aliases {
    alphaWater alpha.water;
}
to the specification directory. Then alphaWater in your expression will transparentlyΠuse alpha.water
There you have it, this is the simplest solution, instead of creating a modified solver.
lourencosm and Saideep like this.
wyldckat is offline   Reply With Quote

Old   November 21, 2022, 09:20
Default
  #13
lth
Member
 
lth's Avatar
 
lth
Join Date: Mar 2009
Location: Madison, WI, USA
Posts: 37
Blog Entries: 44
Rep Power: 16
lth is on a distinguished road
Hello,

Currently running OpenFOAM 6 and downloaded that version of Swak4Foam with rollback "hg update v0.4.2" for compilation needs per Bernhard's recommendation.

I'm attempting funkySetFields with OF6 interFoam for an alpha.water field, where in this post, and also https://sourceforge.net/p/openfoam-e...swak4foam/210/ and https://openfoamwiki.net/images/d/db...mReference.pdf

the reference is to place
aliases {
alphaWater alpha.water;
}

in the "specification directory".

Can someone help me understand what exactly this means or how to do this more specifically?

I have tried to place in:
0/alpha.water
and in:
system/funkySetFieldsDict
but running it does not seem to recognize the aliases command and continues to give:

"Parser Error for driver FieldValueExpressionDriver at "1.2-11" : "field alphaWater not existing or of wrong type" "alphaWater==1) ? (randNormal() > 0.0 ? 0.55 : ).45) : 0"

It only seems to go away if I make a duplicate of 0/alpha.water and name it 0/alphaWater.

In trying to add some GaussianNoise, your advice on this matter would be appreciated.

Thank you, LtH
lth is offline   Reply With Quote

Reply

Tags
alpha1, interfoam, mass flow, swak4foam, water

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
Define mass flow profile with regards to species mass fraction danS Fluent UDF and Scheme Programming 0 June 20, 2017 06:21
Target Mass Flow Rate Nitin FLUENT 9 June 17, 2017 10:30
Wrong flow in ratating domain problem Sanyo CFX 17 August 15, 2015 06:20
Low torque values on Screw Turbine Shaun Waters CFX 34 July 23, 2015 08:16
Discrete Phase & Mass Flow Rate MagnusZeus FLUENT 0 December 2, 2011 17:57


All times are GMT -4. The time now is 08:44.