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

Calculating the drag coefficient at each time step

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   November 13, 2022, 12:56
Default Calculating the drag coefficient at each time step
  #1
VVN
New Member
 
Vijay
Join Date: Feb 2020
Posts: 7
Rep Power: 6
VVN is on a distinguished road
Hello All,

I want to calculate drag coefficient at each time step on front face of each obstacle (here 6 buildings). Here is my blockMesh file

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

convertToMeters 1;

vertices
(
    (0 0 0)
    (200 0 0)
    (200 150 0)
    (0 150 0)
    (0 0 250)
    (200 0 250)
    (200 150 250)
    (0 150 250)
);

blocks
(
    hex (0 1 2 3 4 5 6 7) (50 50 50) simpleGrading (1 1 1)
);

edges
(
);

boundary
(
    atmosphere
    {
        type patch;
        faces
        (
            (4 5 6 7)
        );
    }
    bottom
    {
        type wall;
        faces
        (
            (0 3 2 1)
        );
    }
    left
    {
        type cyclic;
        neighbourPatch    right;
        faces
        (
            (0 4 7 3)
        );
    }
    right
    {
        type cyclic;
        neighbourPatch    left;
        faces
        (
            (2 6 5 1)
        );
    }
    entry
    {
        type wall;
        faces
        (
            (1 5 4 0)
        );
    }
    exit
    {
        type patch;
        faces
        (
            
            (3 7 6 2)
        );
    }
    building
    {
        type wall;
        faces
        (
        );
    }
);

mergePatchPairs
(
);

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

I am able to remove solid domain (buildings) using toposet. Here is toposet file -

Code:
 /*--------------------------------*- C++ -*----------------------------------*\
    =========                 |
    \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
     \\    /   O peration     | Website:  https://openfoam.org
      \\  /    A nd           | Version:  7
       \\/     M anipulation  |
  \*---------------------------------------------------------------------------*/
  FoamFile
  {
      version     2.0;
      format      ascii;
      class       dictionary;
      object      topoSetDict;
  }
  
  // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
  
  actions
  (
      {
          name    c0;
          type    cellSet;
          action  clear;
      }
      {
          name    c0;
          type    cellSet;
          action  invert;
      }
 
      {
          name    c0;
          type    cellSet;
          action  delete;
          source  boxToCell;
          sourceInfo
          {
          boxes
          (			( 35 50 0 ) ( 65 70 80 )
 			( 85 50 0 ) ( 115 70 80 )
 			( 135 50 0 ) ( 165 70 80 )
 			( 35 100 0 ) ( 65 120 80 )
 			( 85 100 0 ) ( 115 120 80 )
 			( 135 100 0 ) ( 165 120 80 )
         );
         }
     }
     
);

// ************************************************************************* //
But could you please tell me how to proceed further? I have simulated the results and now want to extract drag coefficient.

To try out, I added forcecoeff function in controldict file.

Code:
functions
{
forceCoeffs1
{
    // Mandatory entries
    type            forceCoeffs;
    libs            ("libforces.so");
    patches         (building);


    // Optional entries

    // Field names
    p               p;
    U               U;
    rho             rho;
    rho         rhoInf;
    rhoInf      1000;

    // Reference pressure [Pa]
    pRef            0;

    // Include porosity effects?
    porosity        no;

    // Store and write volume field representations of forces and moments
    writeFields     yes;

    // Centre of rotation for moment calculations
    CofR            (0 0 0);

    // Lift direction
    liftDir         (0 0 1);

    // Drag direction
    dragDir         (0 1 0);

    // Pitch axis
    pitchAxis       (1 0 0);

    // Freestream velocity magnitude [m/s]
    magUInf         30;

    // Reference length [m]
    lRef            80;

    // Reference area [m2]
    Aref            2400;

    // Spatial data binning
    // - extents given by the bounds of the input geometry
    binData
    {
        nBin        20;
        direction   (0 1 0);
        cumulative  yes;
    }
}
}

// ************************************************************************* //
But here for patching I used 'building' patch which contains all my 6 buildings and this gives wrong results. I want to have drag coefficient for each building. So I will be require to have 6 different patches, if I am correct.

Could anyone tell me how can I create patch for front face of each building which was deleted from topoSet? How can I use createPatch here? And if anyone has different approach, let me know.

Thank you in advance : )
VVN is offline   Reply With Quote

Reply

Tags
createpatchdict, forcecoeffs, toposetdict


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
bash script for pseudo-parallel usage of reconstructPar kwardle OpenFOAM Post-Processing 42 May 8, 2024 00:17
Transient simulation not converging skabilan OpenFOAM Running, Solving & CFD 14 December 17, 2019 00:12
How to write k and epsilon before the abnormal end xiuying OpenFOAM Running, Solving & CFD 8 August 27, 2013 16:33
plot over time fferroni OpenFOAM Post-Processing 7 June 8, 2012 08:56
Upgraded from Karmic Koala 9.10 to Lucid Lynx10.04.3 bookie56 OpenFOAM Installation 8 August 13, 2011 05:03


All times are GMT -4. The time now is 17:49.