CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Post-Processing (https://www.cfd-online.com/Forums/openfoam-post-processing/)
-   -   Can you use postProcess functions like "forces" on a faceSet? (https://www.cfd-online.com/Forums/openfoam-post-processing/235097-can-you-use-postprocess-functions-like-forces-faceset.html)

ssimmons March 31, 2021 16:51

Can you use postProcess functions like "forces" on a faceSet?
 
Hello Everyone,

This is my first post in the forums, so I apologise if I am missing something here or if I make any mistakes!

Basically, I have finished a number of simulations using the following forces function as a run-time function (in my controlDict):

Code:

forcesBlade
    {
        type            forces;
        libs              ("libforces.so");
        patches        (blade);
        pName          p;
        UName          U;
        rhoName        rho;
        rhoInf            1;
        CofR              (0 0.479105931997901 0.6);
        log                true;
        writeControl    timeStep;
        timeInterval    1;

This worked well for me, I was able to sample out the forces observed on this "blade" during operation.

Now, however, I am looking back on my simulations and realising: it might have been a good idea to split the "blade" into subsections. I have successfully created three subsections of the "blade": "bladeInner", "bladeMid", and "bladeOuter". These subsections are all faceSets (not patches).

I am wondering: is it possible to implement a function like "forces" by calling out a set (faceSet, cellSet, etc.) or even a zone (cellZone, faceZone, etc.) instead of a patch? I have tried something like this:

Code:

forcesBlade_inner
    {
        type            forces;
        libs              ("libforces.so");
        set              (bladeInner);
        pName          p;
        UName          U;
        rhoName        rho;
        rhoInf            1;
        CofR              (0 0.479105931997901 0.6);
        log                true;
        writeControl    timeStep;
        timeInterval    1;

But that did not seem to work. After digging through how the forces function works, I'm not sure if you are able to use it on anything other than a patch. Would I have to make my own function if that is the case? Or is there another solution anyone can think of?

I would really appreciate any suggestion, comments, or solutions!

ssimmons May 21, 2021 14:29

What I ended up doing...
 
Hi Again,

For anyone interested, here is what I ended up doing (although, I get the feeling no one else really has this issue).

Since I am not very confident with C++, I used some post processing function and paraview to accomplish this. My process:

1. I added the following lines to my controlDict to utilise OpenFOAM's wallShearStress function. My control dictionary specified most of the required and optional variables. I effectively only needed "type" and "libs". I left everything else commented for reference.

Code:

wallShearStress_screw
    {
        // Mandatory entries (unmodifiable)
        type            wallShearStress;
        libs ("libfieldFunctionObjects.so");

        //// Optional entries (runtime modifiable)
        //patches        (patch); // (wall1 "(wall2|wall3)");

        //// Optional (inherited) entries
        //writePrecision  8;
        //writeToFile    true;
        //useUserTime    true;
        //region          region0;
        //enabled        true;
        //log            true;
        //timeStart      0;
        //timeEnd        1000;
        //executeControl  timeStep;
        //executeInterval 1;
        //writeControl    timeStep;
        //writeInterval  1;

    }

2. I then ran the following in terminal to generate the wallShearStress value for each timestep.

Code:

interDyMFoam -postProcess
3. Then, I opened paraview for the case and specified the boundary patch that I wanted to find the forces on.

4. I used the calculator to create a field for density. Some FOAMers have set up their simulations so that density is a recorded output, so this might not be necessary in all cases. Density is required for my specific simulation since it is two-phase (hence the use of "interDyMFoam").

5. I created another calculator filter that calculated the viscous pressure. The calculator result name was "pViscous" and the entry was "-rho * wallShearStress".

6. I used the filter "generate surface normals" to create the "Normals" vector.

7. I used the calculator filter with the result name "pStatic" to calculate the hydrostatic component of pressure in my simulation with the entry "-p * Normals".

8. I calculated the cartesian distance from each cell to the centre of rotation. For brevity I just named the variable "CoR" in the calculator filter with the entry as "coordsX*iHat + (coordsY - 3.02916953)*jHat + (coordsZ - 3)*kHat". The numbers within the brackets correspont to the offset of the centre of rotation from the origin. I suppose you may be able to skip this step if you have the cell/point locations specified and the centre of rotation is the origin.

9. Next I found the torque values. Everything will eventually be integrated across the area of my domain's "blade" boundary. So, this step actually calculates the moment/torque divided by the area of each cell technically... (If you are concerned with units while you read my explanation here). The first calculator filter was for result name "momentStatic" and the entry was "-cross(forcesPressure, CoR)".

10. The final calculator filter was for result name "momentViscous" with the entry "-cross(forcesViscous, CoR)".

11. Then, I used various "clip" filters in paraview to break the "blade" boundary down to the segments I wanted to analyse. This step is very much geometry dependent, so I won't go into to much detail here. Suffice to say: I used the "clip" filter to get my desired geometries.

12. I used the "integrate variables" filter. Now the "momentStatic" and "momentViscous" terms are actually in units of a torque/moment.

13. Finally, I saved the data for all timesteps with a desired precision. The data is now in a format that you can easily post process with Python or MATLAB.

I hope this helps someone else!

Geon-Hong November 4, 2022 02:19

Wow, what a work!

Quote:

Originally Posted by ssimmons (Post 804376)
Hi Again,

For anyone interested, here is what I ended up doing (although, I get the feeling no one else really has this issue).

Since I am not very confident with C++, I used some post processing function and paraview to accomplish this. My process:

1. I added the following lines to my controlDict to utilise OpenFOAM's wallShearStress function. My control dictionary specified most of the required and optional variables. I effectively only needed "type" and "libs". I left everything else commented for reference.

Code:

wallShearStress_screw
    {
        // Mandatory entries (unmodifiable)
        type            wallShearStress;
        libs ("libfieldFunctionObjects.so");

        //// Optional entries (runtime modifiable)
        //patches        (patch); // (wall1 "(wall2|wall3)");

        //// Optional (inherited) entries
        //writePrecision  8;
        //writeToFile    true;
        //useUserTime    true;
        //region          region0;
        //enabled        true;
        //log            true;
        //timeStart      0;
        //timeEnd        1000;
        //executeControl  timeStep;
        //executeInterval 1;
        //writeControl    timeStep;
        //writeInterval  1;

    }

2. I then ran the following in terminal to generate the wallShearStress value for each timestep.

Code:

interDyMFoam -postProcess
3. Then, I opened paraview for the case and specified the boundary patch that I wanted to find the forces on.

4. I used the calculator to create a field for density. Some FOAMers have set up their simulations so that density is a recorded output, so this might not be necessary in all cases. Density is required for my specific simulation since it is two-phase (hence the use of "interDyMFoam").

5. I created another calculator filter that calculated the viscous pressure. The calculator result name was "pViscous" and the entry was "-rho * wallShearStress".

6. I used the filter "generate surface normals" to create the "Normals" vector.

7. I used the calculator filter with the result name "pStatic" to calculate the hydrostatic component of pressure in my simulation with the entry "-p * Normals".

8. I calculated the cartesian distance from each cell to the centre of rotation. For brevity I just named the variable "CoR" in the calculator filter with the entry as "coordsX*iHat + (coordsY - 3.02916953)*jHat + (coordsZ - 3)*kHat". The numbers within the brackets correspont to the offset of the centre of rotation from the origin. I suppose you may be able to skip this step if you have the cell/point locations specified and the centre of rotation is the origin.

9. Next I found the torque values. Everything will eventually be integrated across the area of my domain's "blade" boundary. So, this step actually calculates the moment/torque divided by the area of each cell technically... (If you are concerned with units while you read my explanation here). The first calculator filter was for result name "momentStatic" and the entry was "-cross(forcesPressure, CoR)".

10. The final calculator filter was for result name "momentViscous" with the entry "-cross(forcesViscous, CoR)".

11. Then, I used various "clip" filters in paraview to break the "blade" boundary down to the segments I wanted to analyse. This step is very much geometry dependent, so I won't go into to much detail here. Suffice to say: I used the "clip" filter to get my desired geometries.

12. I used the "integrate variables" filter. Now the "momentStatic" and "momentViscous" terms are actually in units of a torque/moment.

13. Finally, I saved the data for all timesteps with a desired precision. The data is now in a format that you can easily post process with Python or MATLAB.

I hope this helps someone else!



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