# Computing the flux at an arbitrary 2D surface

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

August 7, 2018, 14:23
Computing the flux at an arbitrary 2D surface
#1
New Member

Andy
Join Date: Aug 2015
Posts: 8
Rep Power: 7
Hello,

I am trying to compute the massflow rate through an arbitrary surface (not necessarily a cell face). I had a look at this post:

Write cells and data intersecting a plane cuttingPlane

And tried to apply it to my case, which resulted in this:

1) Isolate the surface where I want to compute the mass flow
2) Reconstruct the flux at the surface using the surfaceScalarField values
4) Print the result to the terminal

I've checked the area from (1) and printing is ok (4), so I guess my problem could be in the reconstruction (2) or the addition (3), but I'm not sure.

If this is true, essentially my question boils down to "how to reconstruct fluxes at an arbitrary surface and add them up?"

So, this is the code I think is wrong (I have to add up the flux from phases 1 and 2) - it's also in solver.C

Code:
```// 1. Isolate the surface where I want to compute the mass flow

point pnt1(-0.007, 0.05, 0.0);
point pnt2(0.007, 0.05, 0.01);
point pnt3(0.007, 0.05, 0.0);
plane pl1(pnt1, pnt2, pnt3);

const keyType nameHere = keyType("orifice-cells");
sampledPlane smpPl("smpPl",mesh,pl1,nameHere, true);
smpPl.update();

// 2. In time loop: Reconstruct the flux at the surface

while(runTime.run())
{
.....

volScalarField phi_reconstruct1 = fvc::reconstructMag(phi1);
scalarField slicedDesiredField1 = smpPl.sample(phi_reconstruct1);
volScalarField phi_reconstruct2 = fvc::reconstructMag(phi2);
scalarField slicedDesiredField2 = smpPl.sample(phi_reconstruct2);

scalar area_phantom = gSum(smpPl.magSf());

// 3. Add the fluxes up

scalar sumField_phantom_phi1 = 0;
scalar sumField_phantom_phi2 = 0;

if (area_phantom > 0)
{
sumField_phantom_phi1 = gSum(slicedDesiredField1);
sumField_phantom_phi2 = gSum(slicedDesiredField2);
}

// 4. Print the result to the terminal

Info<< "Area (m^2) = "
<< area_phantom
<< " \n" << endl;

Info << " Massflow (g/s) = "
<< abs(1000*2900*sumField_phantom_phi1 + 1000*1.3*sumField_phantom_phi2)
<< " \n" << endl;
}```
I'm comparing the reconstructed massflows with the standard topoSet approach, where I sum the values at a faceZone using the dictionaries.

However, the result from the reconstructed phi is 18,536,101 g/s at t=6s, (reconstruct3.png) whilst the (correct) approach using topoSetDict gives 97.87 g/s (topoSet3.png), however the trends are similar.

Does anyone know where I've gone wrong?

Kind regards,

andypr
Attached Images
 topoSet3.png (12.1 KB, 10 views) reconstruct3.png (16.3 KB, 8 views)
Attached Files
 solver.C (5.4 KB, 8 views)

Last edited by andy_pr; August 8, 2018 at 08:21.

 Tags arbitrary 2d clip, flux, phi, reconstruction