How to Get Drag and Lift Coefficients for Flow Around a Cylinder

The ds(4) is indicating that the integral should be over the subdomain labeled “4”. The integer labels are arbitrary, but the cylinder is marked as “4” in cylinder().mark(bc, 4). But if you just use ds() I think it will integrate over all boundaries.

So the boundaries are handled slightly different from the tutorial, but I think the full steps (which are all in the code from ria01) should be

  1. Define the cylinder and other boundaries using SubDomain (rather than Expression as in the tutorial)
  2. Define a MeshFunction and mark boundaries with integers (maybe helpful to name these, like CYLINDER=4)
  3. Define BCs using the SubDomain objects
  4. Define the measure ds using your MeshFunction as the subdomain_data

Then it’s just the form and assembly, which it sounds like you have figured out already.

1 Like