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

flow rate correction in timeVaryingMappedFixedValue

Register Blogs Community New Posts Updated Threads Search

Like Tree3Likes
  • 1 Post By HPE
  • 1 Post By vishalS
  • 1 Post By HPE

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   May 9, 2020, 07:45
Default flow rate correction in timeVaryingMappedFixedValue
  #1
New Member
 
Join Date: Sep 2018
Posts: 3
Rep Power: 7
vishalS is on a distinguished road
Hi all, hope everyone is doing good.

I am using timeVaryingMappedFixedValue BC within pisoFoam to introduce turbulence at an inlet. The problem is that due to spatial interpolation the flow rate (Q) varies slightly with every time step and I'd like to keep it fixed by rescaling the velocity field by a factor (Q_ideal/Q_calculated). Could someone please let me know if such a BC already exists. If not, is there an example on how to calculate the flow rate ( surfaceIntegral(v.dA) ) in an OpenFoam BC?

Please consider me a beginner in OpenFoam code implementation.

Thank you.
vishalS is offline   Reply With Quote

Old   May 9, 2020, 09:45
Default
  #2
HPE
Senior Member
 
HPE's Avatar
 
Herpes Free Engineer
Join Date: Sep 2019
Location: The Home Under The Ground with the Lost Boys
Posts: 932
Rep Power: 12
HPE is on a distinguished road
Hi,

- I don't know any such BC - but I think it is a good idea.
- An alternative may be using one of the "coded" boundary conditions. Please have a look at available documentation for these.
- Just very rough, untested ideas below. Please be cautious.
- First you need to compute the first time-step flow rate, and keep it throughout your simulation in order to refer back at future time steps. For example, a function (I haven't test it - it is just to give some idea, I'm afraid):

Code:
scalar computeInitFlowRate(const vector& UReference)
{
    // Compute patch normal across all processors
    const vector patchNormal
    (
        (-gAverage(patch().nf()) ).normalise()
    );

    // Compute initial flow rate based on an input "UReference" velocity
    return gSum
    (
        (UReference & patchNormal)*patch().magSf()
    );
}
Then at a new time-step, you need to correct the new "U" field during the simulation back to the flow rate based on "UReference", for example, with a following function - or something similar:

Code:
void correctFlowRate(vectorField& U, const vector& UReference)
{
    const scalar initFlowRate = computeInitFlowRate(UReference);

    U *= (initFlowRate/gSum(U & -patch().Sf()));
}
Hope this may give a tiny insight for a good start, and good luck.
vishalS likes this.
HPE is offline   Reply With Quote

Old   May 10, 2020, 09:16
Default
  #3
New Member
 
Join Date: Sep 2018
Posts: 3
Rep Power: 7
vishalS is on a distinguished road
Hi HPE,

Thanks very much for your answer.

- I am not using the available BCs because my inlet is non-planar. It is a cylindrical strip instead (see attachment), so it is easier for me to read in the time files.
- Non-planar inlet also means that I need local area vectors to calculate \int_A u \cdot \mathrm{d}A.

As a first step, I am trying to print out the inlet flow rate at the current time step. With a very rusty openFoam knowledge, I have tried the following in accordance with what you suggested and the original timeVaryingMappedFixedValue BC:
Code:
template<class Type>
void Foam::timeVaryingMappedFixedValueFixedQFvPatchField<Type>::calcFlowRate(vectorField& U)
{
  const vectorField& areaVec = this->patch().Sf();  // area vectors
  Pout << "Test Flow Rate: " << gSum( U & -areaVec ) ;  // summation of dot product
}
and then call it in updateCoeffs() as:
Code:
calcFlowRate(Uvec);
However I do not know how to declare Uvec in updateCoeffs(). May be something like Field<Type>& Uvec = xxx ; but not exactly sure.

What do you think of the overall approach and could you/someone help regarding the declaration bit please?

Thanks again,
Vishal
Attached Images
File Type: png Screenshot from 2020-03-01 19-07-15.png (119.3 KB, 4 views)
vishalS is offline   Reply With Quote

Old   May 13, 2020, 06:13
Default
  #4
New Member
 
Join Date: Sep 2018
Posts: 3
Rep Power: 7
vishalS is on a distinguished road
Hi all,

I had to create a specialisation of the template. Things seem to work now. Thanks to HPE and Marta from this post How to determine the type of an object in the object registry

Have a nice one.
HPE likes this.
vishalS is offline   Reply With Quote

Old   May 13, 2020, 16:46
Default
  #5
HPE
Senior Member
 
HPE's Avatar
 
Herpes Free Engineer
Join Date: Sep 2019
Location: The Home Under The Ground with the Lost Boys
Posts: 932
Rep Power: 12
HPE is on a distinguished road
Hi

- Just as a side note, the code in my previous post should be applicable to non-planar patches as well - since the average considers only the patch-normal distance.

Hope this helps.
vishalS likes this.
HPE is offline   Reply With Quote

Old   December 14, 2021, 15:03
Default
  #6
Member
 
chen112p's Avatar
 
Junting Chen
Join Date: Feb 2016
Location: Ontario Canada
Posts: 37
Rep Power: 10
chen112p is on a distinguished road
Hello HPE, do you mind to give a bit more hint on where and how to implement this modify? Many thanks!
chen112p is offline   Reply With Quote

Reply

Tags
fix flow rate


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
Match Pressure Inlet/Outlet Boundary Condition Mass Flow Rate MSchneid Fluent UDF and Scheme Programming 3 February 23, 2019 06:00
actual flow rate not match the designed flow rate in ventilation modeling minecraftgp OpenFOAM Running, Solving & CFD 2 November 18, 2018 12:37
Iteration number - flow rate relation helvas CFX 6 May 30, 2016 02:57
Calculating mass flow rate at multiphase flows Kuslo187 OpenFOAM Post-Processing 1 August 21, 2015 18:11
Discrete Phase & Mass Flow Rate MagnusZeus FLUENT 0 December 2, 2011 17:57


All times are GMT -4. The time now is 01:24.