Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

compute adjoint gradient using restriction/interpolation only when anisotropic materials are present #1886

Merged
merged 3 commits into from
Jan 7, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions src/meepgeom.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2965,8 +2965,14 @@ void material_grids_addgradient(double *v, size_t ng, std::complex<meep::realnum
material_grids_addgradient_point(
v+ng*f_i, vec_to_vector3(p), scalegrad*cyl_scale, geps,
adjoint_c, forward_c, fwd, adj, frequencies[f_i], gv, du);
/* more complicated case requires interpolation/restriction */
} else {
/* anisotropic materials require interpolation/restriction */
} else if (md->do_averaging ||
md->medium_1.epsilon_offdiag.x.re != 0 ||
md->medium_1.epsilon_offdiag.y.re != 0 ||
md->medium_1.epsilon_offdiag.z.re != 0 ||
md->medium_2.epsilon_offdiag.x.re != 0 ||
md->medium_2.epsilon_offdiag.y.re != 0 ||
md->medium_2.epsilon_offdiag.z.re != 0) {
/* we need to restrict the adjoint fields to
the two nodes of interest (which requires a factor
of 0.5 to scale), and interpolate the forward fields
Expand Down