I am hoping to import a field from a numpy array, one defined on the same dimensions as the mesh. I then want to interpolate it and have it as a grid function to operate upon in my weak formulation.

The field would be bounded between 0 and 1, representing a diffuse interface (or diffuse immersed boundary) where 0 is outside of the computational domain, 1 is inside, and anything in-between represents the boundary.

Is this possible?

It is possible, but you have to know a little bit what you are doing. What space do you use and where do you have data of the function (is it for example in the vertices or at some grid,…)?

Best

Christopher

I am attempting to implement a diffuse immersed boundary on a structured grid. I wish to import a field where the points outside of the domain are marked with a “0” and the points inside the domain are marked with a “1”, and the boundary will exist at any point between 0 and 1.

I was hoping to import a field from an outside source that would define this boundary/computational domain to then be interpolated where needed for the grid points in NGSolve

Have you had a look at ngsxfem already? There’s some functionality implemented there to do things like this. The tutorials may be a good starting point.

Are the points where the function is defined the grid points of the mesh? Then it would be as easy as to set the first values of an H1 GridFunction accordingly.

Best

Christopher