GithubHelp home page GithubHelp logo

Sampling at a point in space about meshmode HOT 7 OPEN

inducer avatar inducer commented on August 29, 2024
Sampling at a point in space

from meshmode.

Comments (7)

dshtey2 avatar dshtey2 commented on August 29, 2024

Here is some additional information on my idea for how to accomplish this. I am looking for a routine that can succinctly accomplish this, or one that can perform an even simpler procedure:

  1. For a given sample point or points, determine which element(s) contain(s) that or those points (through some convex hull checking function, such as taking the sums of distances to all nodal points in an element and minimizing over all elements)
  2. After finding the desired element, reconstruct the solution in that element from its basis functions, and evaluate the solution at the desired sample point(s).

from meshmode.

inducer avatar inducer commented on August 29, 2024

Good question! Various parts of this might exist in a way that we might be able to factor out. First of all, @xywei might already have this functionality in a form that can be reused. @xywei, could you comment?

All of the above is for single-rank. Multi-rank is a bit more complicated, but many building blocks can be reused in that case.

from meshmode.

majosm avatar majosm commented on August 29, 2024

@inducer Do you have a sense of how well-behaved the basis functions are when evaluated outside of the unit element coordinate range?

I had suggested to @dshtey2 first using the elements' bounding boxes to find those that are "close" to the query point, then computing the unit coordinates of the point relative to them, and then using those unit coordinates to determine whether the query point is inside each element or not. This is sort of working, but we're running into some intermittent convergence issues when the point is outside of the element. For example, for a uniform 2D mesh on (0,1)x(0,1) and a query point (0, 0), the bounding box search finds 2 candidate elements (the lower and upper triangle halves of the first "box"). The coordinate computation succeeds for the lower triangle, but not for the upper. Interestingly, if you move the query point slightly off-axis in the y direction (either way), they both converge. Any idea if this is expected?

If necessary we could do an alternative test to find out if the point lies inside the element, but I only know how to do that for non-curved elements -- so I think we'd lose some generality there.

from meshmode.

inducer avatar inducer commented on August 29, 2024

While I don't think that in general there's much of an expectation that evaluating functions outside of the reference element would yield meaningful results, in your case (given purely affine mappings), you should be able to evaluate basically anywhere. (For context, in #228, I observed what seems like a similar non-uniqueness issue, but that was for a genuinely curvi mesh.)

When you say "the coordinate computation does not succeed", what does that mean? Gauss-Newton doesn't converge? Something else happens?

from meshmode.

majosm avatar majosm commented on August 29, 2024

While I don't think that in general there's much of an expectation that evaluating functions outside of the reference element would yield meaningful results, in your case (given purely affine mappings), you should be able to evaluate basically anywhere. (For context, in #228, I observed what seems like a similar non-uniqueness issue, but that was for a genuinely curvi mesh.)

Is there maybe a different way we should be approaching this?

When you say "the coordinate computation does not succeed", what does that mean? Gauss-Newton doesn't converge?

Yep. (Even after cranking up the iteration count.)

For a query point (0, 0) I get (each column is a candidate element; the second column is the one that fails):

src_unit_query_points=array([
       [-1., 21.],
       [-1.,  1.]])

For (0, 1e-5) I get:

src_unit_query_points=array([
       [-1.      ,  1.      ],
       [-0.999994,  0.999994]])

and for (0, -1e-5) I get:

src_unit_query_points=array([
       [-1.      ,  1.      ],
       [-1.000006,  1.000006]])

from meshmode.

inducer avatar inducer commented on August 29, 2024

Huh, interesting. That should be fixable. Could you put code to reproduce this somewhere? (Maybe a temporary PR)

from meshmode.

majosm avatar majosm commented on August 29, 2024

Huh, interesting. That should be fixable. Could you put code to reproduce this somewhere? (Maybe a temporary PR)

The code is in mirgecom at the moment, in @dshtey2's branch. I tweaked his test into a pytest test and put it up at illinois-ceesd/mirgecom#479. (It can also be run manually with pytest test_sampling.py.)

from meshmode.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.