3
$\begingroup$

Can somebody point me to software/code to extract a solenoidal (a.k.a. divergence-free) field from a 2D vector field numerically?

There are a plethora of papers and documents describing how to do this, but for some reason none of the authors (or anybody else for that matter) puts a simple piece of source code online implementing that functionality. All I found are rather huge packages or very cryptic pieces of code.

Update. More concretely for my situation: I have two 2D arrays of size 64x64 with double-precision floating point numbers. These two arrays represent the x- and y-velocities of a fluid flow. Periodic boundaries are employed. I would like to extract the solenoidal part of the velocities into two new 2D arrays.

$\endgroup$
  • 3
    $\begingroup$ Do you want to do this analytically or do you have your field defined over a mesh? How is it done? Maybe if you write more details about it, somebody can point you in the right direction. $\endgroup$ – nicoguaro Feb 23 '17 at 14:04
  • $\begingroup$ I thought the tags 'numerical-analysis' and 'numerics' would be sufficient for that. Updated question $\endgroup$ – Bart Feb 23 '17 at 15:40
  • 1
    $\begingroup$ I believe the numerical vs. analytical question was just a specific example of where details are missing. Here is another. Is this over a bounded domain in 2D? If so, is it rectangular? $\endgroup$ – Bill Greene Feb 23 '17 at 15:44
  • $\begingroup$ Maybe the solenoidal part comes as the solution of certain PDEs? You can check what equations it satisfies. Then solve the PDEs for it. $\endgroup$ – Pu Zhang Feb 23 '17 at 16:24
  • 2
    $\begingroup$ Your question was not specific enough. People made comments trying to help other people understand what you want. Since contributions here are done in people's free time, they prefer to invest that time in well written questions. $\endgroup$ – nicoguaro Feb 25 '17 at 7:16
1
$\begingroup$

After some searching I found a C/C++ function called project() in the article
'Real-Time Fluid Dynamics for Games' by Jos Stam
http://www.dgp.toronto.edu/people/stam/reality/Research/pdf/GDC03.pdf
I had to do a little bit of editing, such as increasing iteration variable k (dependent on how divergent your input field is) and employing periodic boundaries. After that it worked for me and solved my problem. The article also contains a fairly intuitive description of what the function outputs without going into the details of how it does this.

I also found the reasonably small Python software package windspharm can extract a solenoidal field http://ajdawson.github.io/windspharm/api/windspharm.cdms.html#windspharm.cdms.VectorWind.nondivergentcomponent
I did not test this one though.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.