CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Post-Processing

Force sampling at adjustableRunTime instead of TimeStep

Register Blogs Community New Posts Updated Threads Search

Like Tree2Likes
  • 1 Post By Eldrael
  • 1 Post By jormollo

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   March 5, 2019, 07:03
Default Force sampling at adjustableRunTime instead of TimeStep
  #1
New Member
 
Jorge Molines
Join Date: Oct 2012
Posts: 11
Rep Power: 13
jormollo is on a distinguished road
Hello!
I am using OF 1812 with Ubuntu 18.04 and it works perfectly. However, I am trying to measure forces on a patch with a writeInterval equals to 0.05 seconds but the output of the force register is given for each TimeStep. How could I fix it?

Below I attach the code of my ControlDict.

Code:
/*---------------------------------------------------------------------------*\
| =========                 |                                                 |
| \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
|  \\    /   O peration     | Version:  1.3                                   |
|   \\  /    A nd           | Web:      http://www.openfoam.org               |
|    \\/     M anipulation  |                                                 |
\*---------------------------------------------------------------------------*/
FoamFile
{
    version         2.0;
    format          ascii;
    location        "system";
    class           dictionary;
    object          controlDict;
}

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

application interFoam;

startFrom       latestTime;

startTime       0;

stopAt          endTime;

endTime         20;

deltaT          0.001;

writeControl    adjustableRunTime;

writeInterval   0.1;

purgeWrite      0;

writeFormat     ascii;

writePrecision  6;

writeCompression on;

timeFormat      general;

timePrecision   6;

runTimeModifiable yes;

adjustTimeStep  yes;

maxCo           0.45;

maxAlphaCo      0.45;

maxDeltaT       0.05;

libs (
         "libOpenFOAM.so"
     );

functions
{


// Forces on crown wall
    forceProbeHor
    {
        type            forces;
        libs            ( "libforces.so" );
        writeFields     no;
        writeControl    adjustableRunTime;
        writeInterval   0.05;
        patches         ( Espaldonfrontal );
        log             false;
        CofR            (18.45 0.02 0.80); // center of rotation
//        rhoInf          1000;

    };

    forceProbeVer
    {
        type            forces;
        libs            ( "libforces.so" );
        writeFields     no;
        writeControl    adjustableRunTime;
        writeInterval   0.05;
        patches         ( Espaldonbase );
        log             false;
        CofR            (18.45 0.02 0.80); // center of rotation
//        rhoInf          1000;

    };
}
jormollo is offline   Reply With Quote

Old   March 8, 2019, 01:18
Default There is no way
  #2
New Member
 
Join Date: Mar 2016
Posts: 8
Rep Power: 10
Eldrael is on a distinguished road
Hello jormollo:

I do not think that you can order OpenFOAM to just write the postprocessing data each 0.05 seconds in a "de-coupled way" of your timestep.

I think that your best alternative is to create a script to read the data and postprocess on your own. Interpolation should do.

There are many alternatives, but you can just load the file to a pandas database in python launching the next script from the case folder:

HTML Code:
import pandas as pd
import numpy as np
from pathlib import Path

#Get all the forces files.
thisCase=Path('.')
allForcesFiles=[x for x in thisCase.glob('**/*forces.dat')]
allForcesAsDataframes=[]
header=['Time', 'Force pressure x','Force pressure y','Force pressure z', 'Force viscous x','Force viscous y','Force viscous z','Force porous x','Force porous y','Force porous z', 'Torque pressure x','Torque pressure y','Torque pressure z', 'Torque viscous x','Torque viscous y','Torque viscous z','Torque porous x','Torque porous y','Torque porous z']

#If there is more than one forces file the addressing of forces files and their names is in allForcesFiles.
for file in allForcesFiles:
    toDrop=[]
    thisDatabase=pd.read_csv(file, header=None, skiprows=range(3), delimiter="\s+|\(+|\)+",engine='python') 
    for column in thisDatabase: 
          if thisDatabase[column].isnull().values.any(): 
              toDrop.append(column)
    thisDatabase=thisDatabase.drop(toDrop,axis=1)
    thisDatabase.columns=header
    allForcesAsDataframes.append(thisDatabase)
Mind that the script might not be the most optimized way but it will work as expected. My recomendation is to load it with Spyder included in Anaconda.

Postprocessing aftwerards should be straightforward.
M.W.G. likes this.

Last edited by Eldrael; March 8, 2019 at 01:27. Reason: Added where the script should be launched
Eldrael is offline   Reply With Quote

Old   March 11, 2019, 02:45
Default There is no way
  #3
New Member
 
Jorge Molines
Join Date: Oct 2012
Posts: 11
Rep Power: 13
jormollo is on a distinguished road
Quote:
Originally Posted by Eldrael View Post
Hello jormollo:

I do not think that you can order OpenFOAM to just write the postprocessing data each 0.05 seconds in a "de-coupled way" of your timestep.

I think that your best alternative is to create a script to read the data and postprocess on your own. Interpolation should do.

There are many alternatives, but you can just load the file to a pandas database in python launching the next script from the case folder:

HTML Code:
import pandas as pd
import numpy as np
from pathlib import Path

#Get all the forces files.
thisCase=Path('.')
allForcesFiles=[x for x in thisCase.glob('**/*forces.dat')]
allForcesAsDataframes=[]
header=['Time', 'Force pressure x','Force pressure y','Force pressure z', 'Force viscous x','Force viscous y','Force viscous z','Force porous x','Force porous y','Force porous z', 'Torque pressure x','Torque pressure y','Torque pressure z', 'Torque viscous x','Torque viscous y','Torque viscous z','Torque porous x','Torque porous y','Torque porous z']

#If there is more than one forces file the addressing of forces files and their names is in allForcesFiles.
for file in allForcesFiles:
    toDrop=[]
    thisDatabase=pd.read_csv(file, header=None, skiprows=range(3), delimiter="\s+|\(+|\)+",engine='python') 
    for column in thisDatabase: 
          if thisDatabase[column].isnull().values.any(): 
              toDrop.append(column)
    thisDatabase=thisDatabase.drop(toDrop,axis=1)
    thisDatabase.columns=header
    allForcesAsDataframes.append(thisDatabase)
Mind that the script might not be the most optimized way but it will work as expected. My recomendation is to load it with Spyder included in Anaconda.

Postprocessing aftwerards should be straightforward.
Thank you for your recommendation. I achieved to do it with the pressure sampling for example using a "type probes" in the controlDict....If it is not possible I will filter the signal after recording it. Thanks!
M.W.G. likes this.
jormollo is offline   Reply With Quote

Reply


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
ActuatorDiskExplicitForce in OF2.1. Help be_inspired OpenFOAM Programming & Development 10 September 14, 2018 11:12
timestep variable - fixed sampling interval vut OpenFOAM Post-Processing 0 December 15, 2014 08:16
Force fluent to hold only last timestep ansys_matt FLUENT 3 August 24, 2014 22:07
Force coefficient oscillations for small timestep Bollonga FLUENT 0 November 8, 2013 13:53
Force can not converge colopolo CFX 13 October 4, 2011 22:03


All times are GMT -4. The time now is 13:16.