
[Sponsors] 
Volume flow rate boundary condition in OpenFOAM 

LinkBack  Thread Tools  Search this Thread  Display Modes 
July 4, 2013, 15:44 
Volume flow rate boundary condition in OpenFOAM

#1 
Member
India
Join Date: Oct 2012
Posts: 84
Rep Power: 13 
Hi,
I am new to OpenFOAM and I facing problems in setting volume flow rate boundary conditions that varies with time. I am doing a transient simulation on a single bifurcating tube. The inlet has time varying volume flow rate (velocity profile at inlet is time varying parabola). At one outlet I want the outgoing volume flow rate to be 0.52 times that of inlet and at the other outlet to be 0.48 times that of inlet at each time step. Also, velocity sometimes goes negative so it also encounters reverse flow. Earlier I ran a steady state simulation using simpleFoam and groovyBC on the same geometry setting a steady parabolic velocity(not flow rate) profile at inlet. It ran with success. But when it comes to setting volume flow rate boundary condition using groovy I am facing trouble. Do I have to use "type" as "groovyBC" or change to "type" as "groovyFlowRateInletVelocity" for setting volume flow rate at inlet and outlet patches? When I use "groovyFlowRateInletVelocity" it does not seem to recognize variable defined on remote patches like "yp@INLET=pos().y", now when I use 'yp' later to define expression on outlet it doesn't recognizes "yp" so how should I access variables from other patches in case using "groovyFlowRateInletVelocity"? Can someone please tell me a way to go about in performing this kind of transient simulation? P.S I am not at all good with C++ so I am trying to implement BCs using groovy. Regards, Mayank 

July 4, 2013, 17:01 

#2  
Member
Daniel Pielmeier
Join Date: Apr 2012
Posts: 99
Rep Power: 14 
Quote:
As for the flow rate you can use type groovy and something like this: Code:
velocity=flowRate/area() I have not used this feature myself but you should be able to access the other patches like you described above. 

July 5, 2013, 17:35 

#3 
Member
India
Join Date: Oct 2012
Posts: 84
Rep Power: 13 
So I guess I need to provide more details on my case so that people can help.
Below are my case file and also I have attached an image of the geometry. But this time I am trying a steady steady state simulation using simpleFoam. 0/U Code:
/** C++ **\  =========    \\ / F ield  OpenFOAM: The Open Source CFD Toolbox   \\ / O peration  Version: 2.1.1   \\ / A nd  Web: www.OpenFOAM.org   \\/ M anipulation   \**/ FoamFile { version 2.0; format ascii; class volVectorField; object U; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // dimensions [0 1 1 0 0 0 0]; internalField uniform (0 0 0); boundaryField { INLET { type flowRateInletVelocity; flowRateExpression "0"; flowRate swak { expression "area()*0.3518"; // incoming volume flow rate from inlet based on mean inlet velocity valueType patch; patchName INLET; }; value uniform ( 0 0 0 ); } OUTLET1 { type flowRateInletVelocity; flowRateExpression "0"; flowRate swak { variables "area1@INLET=area();"; expression "0.52*area1*0.3518"; // volume flow going out of domain from outlet 1 valueType patch; patchName OUTLET1; }; value uniform ( 0 0 0 ); } OUTLET2 { type flowRateInletVelocity; flowRateExpression "0"; flowRate swak { variables "area2@INLET=area();"; // going out of domain from outlet 2 expression "0.42*area2*0.3518"; valueType patch; patchName OUTLET2; }; value uniform ( 0 0 0 ); } WALL { type fixedValue; value uniform (0 0 0); } } // ************************************************************************* // Code:
/** C++ **\  =========    \\ / F ield  OpenFOAM: The Open Source CFD Toolbox   \\ / O peration  Version: 2.1.1   \\ / A nd  Web: www.OpenFOAM.org   \\/ M anipulation   \**/ FoamFile { version 2.0; format ascii; class volScalarField; object p; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // dimensions [0 2 2 0 0 0 0]; internalField uniform 0; boundaryField { INLET { type zeroGradient; } OUTLET1 { type zeroGradient; } OUTLET2 { type zeroGradient; } WALL { type zeroGradient; } } // ************************************************************************* // Code:
/** C++ **\  =========    \\ / F ield  OpenFOAM: The Open Source CFD Toolbox   \\ / O peration  Version: 2.1.1   \\ / A nd  Web: www.OpenFOAM.org   \\/ M anipulation   \**/ FoamFile { version 2.0; format ascii; class dictionary; location "system"; object controlDict; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // libs ( "libOpenFOAM.so" "libgroovyBC.so" "libgroovyStandardBCs.so" "libswak4FoamParsers.so") ; application simpleFoam; startFrom startTime; startTime 0; stopAt endTime; endTime 100; deltaT 0.005; writeControl timeStep; writeInterval 20; purgeWrite 0; writeFormat ascii; writePrecision 6; writeCompression off; timeFormat general; timePrecision 6; runTimeModifiable true; functions { initSwak { // needed to allow DataEntry to work type initSwakFunctionObject; region region0; } }; // ************************************************************************* // Create time Create mesh for time = 0 Reading field p Reading field U Reading/calculating face flux field phi Selecting incompressible transport model Newtonian Selecting RAS turbulence model laminar No field sources present SIMPLE: convergence criteria field p tolerance 1e05 field U tolerance 1e05 field nuTilda tolerance 1e05 Starting time loop Time = 0.005 swak4Foam: Allocating new repository for sampledGlobalVariables > FOAM Warning : From function ConcretePluginFunction<DriverType>::exists in file lnInclude/ConcretePluginFunction.C at line 111 Constructor table of plugin functions for PatchValueExpressionDriver is not initialized > FOAM FATAL ERROR: Parser Error for driver PatchValueExpressionDriver at "1.711" :"field area1 not existing or of wrong type" "0.52*area1*0.3518" ^^^^^  Context of the error:  From dictionary: Evaluating expression "0.52*area1*0.3518" From function parsingValue in file lnInclude/CommonValueExpressionDriverI.H at line 1039. FOAM exiting I know I have done some insanely stupid things but please guys help me understand my mistakes......This is a real learning opportunity for me. 

July 6, 2013, 00:46 

#4 
Member
India
Join Date: Oct 2012
Posts: 84
Rep Power: 13 
ok, solved one problem the syntax in current version with swak4Foam has changed to <variable name> {<patch name>}=<expression> rather than <variable name>@<patch name>=<expression>


July 6, 2013, 03:07 

#5 
Member
India
Join Date: Oct 2012
Posts: 84
Rep Power: 13 
So I went ahead and changed the syntax and got a converged steady state solution. But I am not getting satisfactory results.
now my 0/U file looks like below but rest of the files remain same as posted above: 0/U Code:
/** C++ **\  =========    \\ / F ield  OpenFOAM: The Open Source CFD Toolbox   \\ / O peration  Version: 2.1.1   \\ / A nd  Web: www.OpenFOAM.org   \\/ M anipulation   \**/ FoamFile { version 2.0; format ascii; class volVectorField; object U; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // dimensions [0 1 1 0 0 0 0]; internalField uniform (0 0 0); boundaryField { INLET { type flowRateInletVelocity; flowRateExpression "0"; flowRate swak { expression "0.3518*area()"; // incoming volume flow rate from inlet based on mean inlet velocity valueType patch; patchName INLET; }; value uniform ( 0 0 0 ); } OUTLET1 { type flowRateInletVelocity; flowRateExpression "0"; flowRate swak { variables "area1{INLET}=area();"; expression "0.52*area1*0.3518"; // volume flow going out of domain from outlet 1 valueType patch; patchName OUTLET1; }; value uniform ( 0 0 0 ); } OUTLET2 { type flowRateInletVelocity; flowRateExpression "0"; flowRate swak { variables "area2{INLET}=area();"; expression "0.48*area2*0.3518"; valueType patch; patchName OUTLET2; }; value uniform ( 0 0 0 ); } WALL { type fixedValue; value uniform (0 0 0); } } // ************************************************************************* // Time = 0.39 > FOAM Warning : From function ExpressionResult::getUniformInternal(const label size,bool noWarn) in file ExpressionResult/ExpressionResultI.H at line 324 The minimum value 1.37739e05 and the maximum 5.99827e05 differ. I will use the average 3.66384e05 > FOAM Warning : From function ExpressionResult::getUniformInternal(const label size,bool noWarn) in file ExpressionResult/ExpressionResultI.H at line 324 The minimum value 1.37739e05 and the maximum 5.99827e05 differ. I will use the average 3.66384e05 smoothSolver: Solving for Ux, Initial residual = 1.16172e06, Final residual = 4.74177e08, No Iterations 4 smoothSolver: Solving for Uy, Initial residual = 1.43494e06, Final residual = 6.6445e08, No Iterations 4 smoothSolver: Solving for Uz, Initial residual = 2.8996e06, Final residual = 6.96369e08, No Iterations 4 GAMG: Solving for p, Initial residual = 9.54405e06, Final residual = 4.09708e07, No Iterations 2 time step continuity errors : sum local = 8.50625e10, global = 4.95172e20, cumulative = 5.0987e18 > FOAM Warning : From function ExpressionResult::getUniformInternal(const label size,bool noWarn) in file ExpressionResult/ExpressionResultI.H at line 324 The minimum value 1.37739e05 and the maximum 5.99827e05 differ. I will use the average 3.66384e05 > FOAM Warning : From function ExpressionResult::getUniformInternal(const label size,bool noWarn) in file ExpressionResult/ExpressionResultI.H at line 324 The minimum value 1.37739e05 and the maximum 5.99827e05 differ. I will use the average 3.66384e05 ExecutionTime = 2.16 s ClockTime = 2 s SIMPLE solution converged in 0.39 iterations Can somebody please explain me the meaning of these warnings, how they affect the solution and how to remove them? 

July 6, 2013, 13:20 

#6 
Member
Daniel Pielmeier
Join Date: Apr 2012
Posts: 99
Rep Power: 14 
I don't think you need to use area () when you use the flowRateInletVelocity boundary condition as the value you specify is already the flow rate. So for this case you probably wont need the swak expression at all and you can use plain flowRateInletVelocity.


July 6, 2013, 22:47 

#7 
Member
India
Join Date: Oct 2012
Posts: 84
Rep Power: 13 
Hi Daniel,
First of all, thanks for your replies. Yes, I can do it just by placing values. But my real aim is to perform transient simulation in which inlet flow field depends both on time and space coordinates of inlet patch. I find groovy/swak4Foam a good tool as it provides freedom of inputting flow fields in the form of expression which is generally required. It gave me good results in first place when I specified a parabolic inlet velocity profile at inlet but I don't know whats wrong with flowRateInletVelocity. Basically what I am trying to do is that I am imposing Poiseuille flow (2*Uavg*(R^2r^2)/R^2))) at the inlet and imposing volume flow rate condition at outlet i.e on one outlet volume flow rate is 0.52 times that on inlet and on the other outlet it is 0.48 time the inlet. I modified 0/U a little: 0/U Code:
/** C++ **\  =========    \\ / F ield  OpenFOAM: The Open Source CFD Toolbox   \\ / O peration  Version: 2.1.1   \\ / A nd  Web: www.OpenFOAM.org   \\/ M anipulation   \**/ FoamFile { version 2.0; format ascii; class volVectorField; object U; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // dimensions [0 1 1 0 0 0 0]; internalField uniform (0 0 0); boundaryField { INLET { type groovyBC; variables "r2=(pow(pos().x,2)+pow(pos().z,2));R2=area()/pi;para=((R2r2)/R2)*normal();"; valueExpression "2*0.351*para"; //where 0.351 is the average velocity value uniform (0 0 0); } WALL { type fixedValue; value uniform (0 0 0); } OUTLET1 { type flowRateInletVelocity; flowRateExpression "0"; flowRate swak { variables "area1{INLET}=area();flow1= 0.52*area1*0.351;"; expression "flow1"; // volume flow going out of domain from outlet 1 which 0.52 times that at inlet valueType patch; patchName OUTLET1; }; value uniform ( 0 0 0 ); } OUTLET2 { type flowRateInletVelocity; flowRateExpression "0"; flowRate swak { variables "area2{INLET}=area();flow2= 0.48*area2*0.351;"; // volume flow going out of domain from outlet 2 which 0.48 times that at inlet expression "flow2"; valueType patch; patchName OUTLET2; }; value uniform ( 0 0 0 ); } } // ************************************************************************* // Code:
/** C++ **\  =========    \\ / F ield  OpenFOAM: The Open Source CFD Toolbox   \\ / O peration  Version: 2.1.1   \\ / A nd  Web: www.OpenFOAM.org   \\/ M anipulation   \**/ FoamFile { version 2.0; format ascii; class volScalarField; object p; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // dimensions [0 2 2 0 0 0 0]; internalField uniform 0; boundaryField { INLET { type zeroGradient; } OUTLET1 { type zeroGradient; } OUTLET2 { type zeroGradient; } WALL { type zeroGradient; } } // ************************************************************************* // Create time Create mesh for time = 0 Reading field p Reading field U Reading/calculating face flux field phi Selecting incompressible transport model Newtonian Selecting RAS turbulence model laminar No field sources present SIMPLE: convergence criteria field p tolerance 1e05 field U tolerance 1e05 field nuTilda tolerance 1e05 Starting time loop Time = 0.005 swak4Foam: Allocating new repository for sampledGlobalVariables > FOAM Warning : From function ExpressionResult::getUniformInternal(const label size,bool noWarn) in file ExpressionResult/ExpressionResultI.H at line 324 The minimum value 3.51015e06 and the maximum 1.85231e05 differ. I will use the average 1.09453e05 > FOAM Warning : From function ExpressionResult::getUniformInternal(const label size,bool noWarn) in file ExpressionResult/ExpressionResultI.H at line 324 The minimum value 3.51015e06 and the maximum 1.85231e05 differ. I will use the average 1.09453e05 smoothSolver: Solving for Ux, Initial residual = 1, Final residual = 0.0267623, No Iterations 4 smoothSolver: Solving for Uy, Initial residual = 1, Final residual = 0.022866, No Iterations 4 smoothSolver: Solving for Uz, Initial residual = 1, Final residual = 0.0548532, No Iterations 2 > FOAM FATAL ERROR: Continuity error cannot be removed by adjusting the outflow. Please check the velocity boundary conditions and/or run potentialFoam to initialise the outflow. Total flux : 0.035612 Specified mass inflow : 0.0439753 Specified mass outflow : 1.32494e05 Adjustable mass outflow : 0 From function adjustPhi(surfaceScalarField& phi, const volVectorField& U,const volScalarField& p in file cfdTools/general/adjustPhi/adjustPhi.C at line 118. FOAM exiting First of all why is it referring 'mass inflow' since simpleFoam is a incompressible solver I am inputting volume flow rate and not mass flow rate. Second why there is a difference in inlet and total outlet flow rates. Can somebody help me resolve it? 

July 7, 2013, 03:54 

#8 
Member
Daniel Pielmeier
Join Date: Apr 2012
Posts: 99
Rep Power: 14 
Okay I did not read carefully your previous posts and there were some misunderstanding on my side.
I have to take a closer look at this but currently don't have the time. Maybe someone else can help you in the meantime. Last edited by billie; July 7, 2013 at 04:05. Reason: Nonsense 

July 8, 2013, 11:47 

#9 
Member
India
Join Date: Oct 2012
Posts: 84
Rep Power: 13 
I am trying to make my 0/U file as compact as possible. A new version is below:
Code:
0/U /** C++ **\  =========    \\ / F ield  OpenFOAM: The Open Source CFD Toolbox   \\ / O peration  Version: 2.1.1   \\ / A nd  Web: www.OpenFOAM.org   \\/ M anipulation   \**/ FoamFile { version 2.0; format ascii; class volVectorField; object U; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // dimensions [0 1 1 0 0 0 0]; internalField uniform (0 0 0); boundaryField { INLET { type groovyBC; variables "r2=(pow(pos().x,2)+pow(pos().z,2));R2=area()/pi;para=((R2r2)/R2)*normal();"; valueExpression "2*0.351*para"; //where 0.351 is the average velocity value uniform (0 0 0); } WALL { type fixedValue; value uniform (0 0 0); } OUTLET1 { type flowRateInletVelocity; flowRateExpression "0"; flowRate swak { variables "phi1{INLET}=0.52*phi;"; expression "phi1"; // volume flow going out of domain from outlet 1 which 0.52 times that at inlet valueType patch; patchName OUTLET1;}; value uniform ( 0 0 0 ); } OUTLET2 { type flowRateInletVelocity; flowRateExpression "0"; flowRate swak { variables "phi2{INLET}=0.48*phi;"; expression "phi2"; // volume flow going out of domain from outlet 1 which 0.52 times that at inlet valueType patch; patchName OUTLET1;}; value uniform ( 0 0 0 ); } } // ************************************************************************* // I am applying simple math: Flow rate @ inlet= 0.52*Flow rate @ inlet on the patch outlet 1 + 0.48 times* Flow rate @ inlet on the patch outlet 2..........i dunno why its not working. Help please! Mayank. 

February 21, 2014, 10:32 
outflow u: flowRateInletVelocity (with negative value) p: zeroGradient ??

#10 
New Member
RB
Join Date: Aug 2013
Posts: 5
Rep Power: 12 
Hi,
Sorry to dig up this thread, but have you been any further in your understanding of your problem? I won't be really helpful, but I will ask you more questions: I'm trying to figure out how to set properly an outflow with flowRateInletVelocity. Are you sure of the boundary combination for "multiple" outflow (pointing out of the domain), knowing the inlet has been set with u: flowRateInletVelocity, p: zeroGradient): Outflow: u: flowRateInletVelocity (with a negative value, as the flow leave the domain). p: zeroGradient? Shouldn't at least one of the outflow be set with a fixedValue pressure / zeroGradient velocity? Thanks for sharing your progress and experience, Regards, Remi 

March 31, 2014, 06:46 

#11 
Senior Member

Hi,
I am not sure, how good i understood your question. the standard setting is; 0/U : inlet type flowRateInletVelocity; flowRate 2; // Volumetric/mass flow rate [m3/s or kg/s] value uniform (0 0 0); outlet outlet { type zeroGradient; } For pressure: inlet { type zeroGradient; } outlet { type fixedValue; value uniform 0; } Thanks, Sivakumar 

April 29, 2014, 12:32 

#12  
New Member
IZUNNA DAVID
Join Date: Mar 2010
Location: NEWCASTLE
Posts: 2
Rep Power: 0 
Quote:
I am just wondering if you were able to sort out the problem about inlet condition depending on time and space coordinates. I am facing a similar problem in which the inlet expands with time.It is a typical case of LNG pool spreading and evaporation which starts with a small area (circular) and increase with time. I have a code to calculate the area at every time step.Thus, I either need to use the area to work out the mass flow rate and implement this at the inlet boundary or use the area to work out the velocity and apply this velocity only within the area (velocity outside the area will then be zero). I do not know how to implement any of the above.Any help from you will be highly appreciated.Thank you boss DAVID 

April 29, 2014, 12:37 

#13 
Member
India
Join Date: Oct 2012
Posts: 84
Rep Power: 13 
Hi,
You can use codedFixedValue boundary condition or swak4Foam to give any expression or perform calculation based on time and space coordinates. Search codedFixedValue in the forum to look for syntax and all. Regards, Mayank 

August 11, 2014, 20:16 
known inlet pressure and flow rate, how to set BC?

#14  
New Member
Kai
Join Date: Mar 2014
Posts: 5
Rep Power: 12 
Quote:
Dear Sivakumar, I need to do something like what you said, except my known BCs are: flowrate (mass or volume) inlet pressure I basically need to find the resulting outlet pressure of flow going through different geometries, something like a nozzle, with a given inlet water pressure and volumetric flowrate. Currently, I am doing something like this: 0/U : inlet type fixedValue; value uniform (3 0 0); outlet { type flowRateInletVelocity; volumetricFlowRate 1e3 //(m^3/s) } 0/p: inlet { type fixedValue; value uniform 830; } outlet { type zeroGradient; } In theory I know my inlet velocity as well, which is why i set it equal to that value. But I read somewhere the BC for pressure and velocity are supposedly coupled, and there are restrictions in specifying them together? I was thinking maybe I need to use something like pressureInletVelocityOutlet that sort of BC? Can someone kindly direct me further? Much thanks 

Thread Tools  Search this Thread 
Display Modes  


Similar Threads  
Thread  Thread Starter  Forum  Replies  Last Post 
Setting mass flow rate boundary condition  maysmech  OpenFOAM  15  July 22, 2021 11:30 
Boundary condition problem for open channel flow  Andy  CFX  9  June 11, 2016 07:20 
Problem of simulating of small droplet with radius of 2mm  liguifan  OpenFOAM Running, Solving & CFD  5  June 3, 2014 02:53 
Corrected (Referred) Mass Flow Rate Boundary Condition  ermuir  CFX  1  November 20, 2012 17:11 
[blockMesh] error message with modeling a cube with a hold at the center  hsingtzu  OpenFOAM Meshing & Mesh Conversion  2  March 14, 2012 09:56 