You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The following schematic shows the analytic expressions necessary to compute the gradient of the weights array u for a MaterialGrid in 2d from which the normal vector to an interface can be obtained at any Yee grid point using bilinear interpolation. In the figure, the MaterialGrid are the green points and the Yee grid points for Ex and Ey are the blue and red points, respectively.
To set this up, we will need to modify the existing material_function::normal_vector routine which uses spherical quadrature such that for the case of a MaterialGrid it uses the analytic formulas shown above:
for (int i = 0; i < num_sphere_quad[num_dirs - 1]; ++i) {
double weight;
vec pt = sphere_pt(p, R, i, weight);
double chi1p1_val = chi1p1(ft, pt);
if (i > 0 && i < min_iters) {
if (chi1p1_val != chi1p1_prev) { break_early = false; }
if (i == min_iters - 1 && break_early) {
// Don't average regions where epsilon is uniform
returnzero_vec(v.dim);
}
}
chi1p1_prev = chi1p1_val;
gradient += (pt - p) * (weight * chi1p1_val);
}
return gradient;
}
We can then verify that the new approach to computing the normal vector is working correctly by comparing with the results obtained using spherical quadrature for e.g. a test case involving a cylinder (similar to #1522 (comment)).
The text was updated successfully, but these errors were encountered:
The first thing is to implement a function matgrid_grad that computes the gradient, similar to matgrid_val. Then you can call this when computing the normal vector if you detect that that pixel is completely within a material-grid object.
The following schematic shows the analytic expressions necessary to compute the gradient of the
weights
arrayu
for aMaterialGrid
in 2d from which the normal vector to an interface can be obtained at any Yee grid point using bilinear interpolation. In the figure, theMaterialGrid
are the green points and the Yee grid points for Ex and Ey are the blue and red points, respectively.To set this up, we will need to modify the existing
material_function::normal_vector
routine which uses spherical quadrature such that for the case of aMaterialGrid
it uses the analytic formulas shown above:meep/src/anisotropic_averaging.cpp
Lines 40 to 64 in 272bd0c
We can then verify that the new approach to computing the normal vector is working correctly by comparing with the results obtained using spherical quadrature for e.g. a test case involving a cylinder (similar to #1522 (comment)).
The text was updated successfully, but these errors were encountered: