Skip to content

Instantly share code, notes, and snippets.

@robinknowles
Created August 12, 2022 15:27
Show Gist options
  • Save robinknowles/747ab306ca205eb7300486890d324812 to your computer and use it in GitHub Desktop.
Save robinknowles/747ab306ca205eb7300486890d324812 to your computer and use it in GitHub Desktop.
An example of using binField to create a force x-ray
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v2206 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
// Calculate lift force coefficient acting on the motorbike patch group
// Then "bin" that data along the X & Y axes to create a force x-ray
// Force Calculation & Write Field
forceCoeffs
{
type forceCoeffs;
libs (forces);
writeControl writeTime;
writeFields true;
patches (motorBikeGroup);
p p;
U U;
rho rhoInf; // Indicates incompressible
log true;
rhoInf 1; // Required when rho = rhoInf
liftDir (0 0 1);
dragDir (1 0 0);
CofR (0 0 0);
pitchAxis (0 1 0);
magUInf 20;
lRef 1; // Reference Length
Aref 1; // Frontal Area
// Turn on to include forces from porous zones
porosity off;
// New v2206 feature: only output Cl (lift) data
coefficients (Cl);
}
// Bin Force Data
binField
{
type binField;
libs (fieldFunctionObjects);
writeControl writeTime;
// uniformBin: bin data along mulitple axes
binModel uniformBin;
// bin force data from previous calc
fields (forceCoeff);
// only bin forces acting on the motorBikeGroup
patches (motorBikeGroup);
// decomposePatchValues
// - no: write total force for each bin
// - yes: write total, pressure & viscous force components for each bin
decomposePatchValues no;
// Set the datum for the binned data & uses the std cartesian axes
// (TIP: use origin to avoid confusion)
CofR (0 0 0);
// specify cellZones if porous zone forces are required
cellZones ();
binData
{
// number of bins required in XYZ directions
nBin (21 8 1);
// Optional: specify min & max for directions of interest
// the bounding box of the specifed patches is used by default
minMax
{
e0 (-0.3 1.8); // min-max in X-Direction
e1 (-0.4 0.4); // min-max in Y-Direction
}
// Report each bin force independently
// i.e. do not accumulate forces across the bins
cumulative no;
}
}
// ************************************************************************* //
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment