CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM (https://www.cfd-online.com/Forums/openfoam/)
-   -   Internal faces for monitoring (https://www.cfd-online.com/Forums/openfoam/75393-internal-faces-monitoring.html)

jason.ryon April 23, 2010 16:40

Internal faces for monitoring
 
I would like to know how to monitor at an internal face (faceZone or faceSet). I want to know p, U, etc... for every point in the faceZone, as well as the mass flow through the entire face.

This is what I have tried so far, but can't seem to get things to work:
1. Import mesh (with "interior" surfaces) from Fluent using:
>fluentMeshToFoam mesh.msh -writeSets -writeZones
2. I see the name (interior_001) in faceZones of the faceZone that I want to monitor
3. Now, I have tried using the "surfaces" functionObject which works for slice planes or patches, but is it possible to use this to output a faceZone or faceSet?
4. I also tried even using the libfieldFunctionObjects.so but this seems to only work on a faceZone that is a patch and not an internal one.
5. Also, I have used libsimplefunctionobjects to work very well for mass flow at patches (i.e. pressure_inlet) but I don't know if this works for internal faceZones too.
http://openfoamwiki.net/index.php/Co...unctionObjects

I am sorry if this has been posted before, I searched through the Forum but keep hitting dead-ends.

Thanks,
Jason

josp April 24, 2010 07:48

(Assuming OpenFOAM-1.6.x) insert this into your controlDict and update according to your case:

Code:

functions
(
//=========================================================//
Meas-outlet  // Name also used to identify output folder
    {
        type            faceSource;
        functionObjectLibs ("libfieldFunctionObjects.so");
        enabled        true;
        outputControl  timeStep;
        outputInterval  1;
        log            true;
        valueOutput    false;
        source          faceZone;  // Type of face source: faceZone, patch
        sourceName      meas-outlet;
        operation      sum;
        fields
        (
            phi
        );
    }

This should integrate massflow (or volume flow for incompressible flow). I'm unsure about the other scalars as they are not defined at the faces so they have to be interpolated..

OpenFOAM-1.6.x/src/postProcessing/functionObjects/field/fieldValues/faceSource/faceSource.H:

- if the field is a volField the faceZone can only consist of boundary faces.

You could write something yourself like:
Code:

surfaceScalarField test = fvc::interpolate(field);
label q = mesh.faceZones().findZoneID(surfaceName);
const labelList& faces = mesh.faceZones()[q];

forAll(faces, j)
{
label facei = faces[j];
result+= test[facei]
...
}

Or check if surfaceInterpolateFieldsFunctionObjects can help you.

jason.ryon April 26, 2010 16:56

josp,

Thanks for your response. I think this sum(phi) is close to what I am looking for, but not quite right. I am wondering though if this is "mass flow" or "mass flow rate"? I am looking for "mass flow rate".

I tried the sum(phi) at an inlet patch, and it is giving me results that are not the same as "mass flow rate" from Fluent or from the libsimpleFunctionObjects mass-flux calculations (both of which match up reasonably well to each other):

Thanks again for your help,
Jason

CedricVH April 27, 2010 05:31

sum(phi) is the mass flow rate trough the patch. However, in incompressible solvers, phi has the dimension m^3/s and not kg/s. You will have to multiply this value with rho to have the same results as Fluent.

ubaid June 20, 2010 15:21

surfaceScalarField
 
Hello everybody,

I am new to openfoam but have a similar question. I am wondering what I will get as an output if i have the following case.

surfaceScalarField abc

Info<<"Whats this"<<abc[100];

will it give me output of abc at the face number 100?

If I have faceSets, and get the facenumbers out of these facesets, could i get the value of abc at the putting the face number inside the brackets as following
Info<<"value at the required facenumber"<<abs[facenumber];

Thanks in advance.

majkl May 10, 2012 08:35

Quote:

Originally Posted by josp (Post 256174)
surfaceScalarField test = fvc::interpolate(field);
label q = mesh.faceZones().findZoneID(surfaceName);
const labelList& faces = mesh.faceZones()[q];

forAll(faces, j)
{
label facei = faces[j];
result+= test[facei]
...
}
[/CODE]Or check if surfaceInterpolateFieldsFunctionObjects can help you.

Well, it must be implemented in faceSource.H file? Thank you for your response. Majkl

Iose October 11, 2018 07:52

Hi guys,
could you provide me some more information if you had/have succesfully implemented monitoring pressure on faceZones. I used OpenFOAM v6 and I am able to online monitoring phi as flux on the internal faces - faceZones, but if I want to monitoring pressure it doesn't work. Any help would be appreciated.

Thanks.

wyldckat October 13, 2018 06:13

Quick answer: You will have to create a baffle from that faceZone and apply cyclic boundary conditions to it. Search for "createBafflesDict" in the "tutorials" folder... I don't remember which tutorial has it...

Iose October 15, 2018 03:14

Hi wyldckat,
you have a briliant idea. It works. My createBaffleDict looks:
Code:

/*--------------------------------*- C++ -*----------------------------------*\
  =========                |
  \\      /  F ield        | OpenFOAM: The Open Source CFD Toolbox
  \\    /  O peration    | Website:  https://openfoam.org
    \\  /    A nd          | Version:  dev
    \\/    M anipulation  |
\*---------------------------------------------------------------------------*/
FoamFile
{
    version    2.0;
    format      ascii;
    class      dictionary;
    object      createBafflesDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

// Whether to convert internal faces only (so leave boundary faces intact).
// This is only relevant if your face selection type can pick up boundary
// faces.
internalFacesOnly true;

fields true;

// Baffles to create.
baffles
{
    I0_B
    {
        //- Use predefined faceZone to select faces and orientation.
        type        faceZone;
        zoneName    I0;

        patchPairs
        {
            type            cyclic;
        }
    }
   
    I3_B
    {
        //- Use predefined faceZone to select faces and orientation.
        type        faceZone;
        zoneName    I3;

        patchPairs
        {
            type            cyclic;   
        }
    }
}


// ************************************************************************* //

And my output looks like this:
Code:

/*---------------------------------------------------------------------------*\
  =========                |
  \\      /  F ield        | OpenFOAM: The Open Source CFD Toolbox
  \\    /  O peration    | Website:  https://openfoam.org
    \\  /    A nd          | Version:  dev
    \\/    M anipulation  |
\*---------------------------------------------------------------------------*/
Build  : dev-8f3f2f7365c1
Exec  : createBaffles -overwrite
Date  : Oct 15 2018
Time  : 08:37:25
Host  : "dobesj-Precision-T5600"
PID    : 26264
I/O    : uncollated
Case  : /media/dobesj/Data_disc/Re_CS_OF
nProcs : 1
sigFpe : Enabling floating point exception trapping (FOAM_SIGFPE).
fileModificationChecking : Monitoring run-time modified files using timeStampMaster (fileModificationSkew 10)
allowSystemOperations : Allowing user-supplied system call operations

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
Create time

Create mesh for time = 0

Reading baffle criteria from createBafflesDict

Not converting faces on non-coupled patches.

Reading geometric fields

Reading volScalarField p
Reading volScalarField nut
Reading volScalarField k
Reading volScalarField epsilon
Reading volScalarField omega
Reading volVectorField U
Created zone I0_B at index 24 with 610 faces
Created zone I3_B at index 25 with 610 faces
Converted 1220 faces into boundary faces in patches
4
(
I0_B_master
I0_B_slave
I3_B_master
I3_B_slave
)


--> FOAM Warning :
    From function int main(int, char**)
    in file createBaffles.C at line 854
    Setting field on boundary faces to zero.
You might have to edit these fields.
Writing mesh to 0
End

Maybe one little question about FOAM Warning - the error tells me that I don't setup boundary condition for cyclic, am I right?

Thanks.

----

Hi wyldckat,
thank you for your briliant idea, it works. In my log file, during create baffles I received that warning:

Code:

--> FOAM Warning :
    From function int main(int, char**)
    in file createBaffles.C at line 854
    Setting field on boundary faces to zero.
You might have to edit these fields.

This is only about information that I don't setup boundary condition for cyclic face zones, am I right?

wyldckat October 20, 2018 16:12

Quick answer: There is a quick way you can automatically apply boundary conditions to types of boundaries... This line:
Code:

#includeEtc "caseDicts/setConstraintTypes"
when added to the start of the block "boundaryField", can be used for automatically assigning boundary conditions, based on geometric boundary type... here is a thread on this topic: https://www.cfd-online.com/Forums/op...ainttypes.html

The tutorial case "heatTransfer/buoyantSimpleFoam/circuitBoardCooling" is also a good example on how to both use this and define the new boundary conditions via "system/createBafflesDict".

artymk4 April 18, 2019 09:11

I had the same problem. Now I solved it with help from Ione and wyldckat so I'm sharing my code if it helps anyone.
I wanted to output average pressure on internal face "CKOUT" which was defined as faceZone. First I tried with function type surfaceFieldValue but I got error "Unable to process internal faces for volume field p"
Then I made file createBafflesDict similar to Iose's and ran command createBaffles
Two new patches were created, CKOUT_master and CKOUT_slave. Files U, p, k etc. in 0/ folder needs to have these two patches included this way:
Code:

    CKOUT_master
    {
        type            cyclic;
    }
    CKOUT_slave
    {
        type            cyclic;
    }

Now you can add function to your controlDict file that will output pressure on internal face. My function looks like this*:
Code:

functions
{
    p_CKOUT
    {
        type patchAverage;
        fields (p);
        functionObjectLibs ("libsimpleFunctionObjects.so");
        patches
        (
            CK_OUTmaster
        );
        allowCoupled true;
        writeStartTime no;
        outputControlMode outputTime;
//        outputControlMode timeStep;
//        outputInterval 10;
    }
}

* As far as I know, you need swak4foam installed if you want this function to work.


Alternative option, if you don't have swak4foam, is that you put this to controlDict:
Code:

functions
{
    #includeFunc patchAverage(name=CKOUT_master,p)
}

But this way you cannot control how often is the average pressure calculated and saved. It is calculated every time step so this might slow down your simulation a little bit.

Daniel_C October 13, 2021 15:39

faceZoneAverage OpenFOAM V8 and V9
 
Since OF V8 it should be possible to have the field values processed for a given faceZone.

If I add a function file in system in this way e.g. :

Code:

/*--------------------------------*- C++ -*----------------------------------*\
  =========                |
  \\      /  F ield        | OpenFOAM: The Open Source CFD Toolbox
  \\    /  O peration    | Website:  https://openfoam.org
    \\  /    A nd          | Version:  9
    \\/    M anipulation  |
-------------------------------------------------------------------------------
Description
    Calculates the average values of fields on a faceZone.

\*---------------------------------------------------------------------------*/

        type            surfaceFieldValue;
        libs            ("libfieldFunctionObjects.so");
        writeControl    timeStep;
        writeInterval  1;
        log            yes;
        writeTotalArea  no;
        writeFields    no;
        regionType      faceZone;
        name            my_facezone;
        operation      areaAverage;
        fields 
        (
            U
        );

// ************************************************************************* //

And after include the function in controlDict via #includeFunc my_function, it throws an exception in the terminal at runtime:

Quote:

surfaceFieldValue my_function: faceZone(my_facezone):
Unable to process internal faces for volume field U
The same is true for other scalars e.g. p. Except for phi. Seems there is something I'd missed. Can anyone give me a hint, what I am doing wrong?

Regards

Daniel

Behradskn June 4, 2023 14:20

Since type is surfaceFieldValue, so you only can read the face values like phi, but you can't read a volume field like U.


All times are GMT -4. The time now is 14:45.