diff --git a/libpympb/pympb.cpp b/libpympb/pympb.cpp index 6e4a00240..2c3885199 100644 --- a/libpympb/pympb.cpp +++ b/libpympb/pympb.cpp @@ -676,7 +676,7 @@ void mode_solver::init(int p, bool reset_fields, geometric_object_list *geometry meep_geom::material_data *_default_material) { int have_old_fields = 0; - default_material = _default_material; + set_default_material(_default_material); n[0] = grid_size.x; n[1] = grid_size.y; @@ -909,7 +909,9 @@ void mode_solver::reset_epsilon(geometric_object_list *geometry) { }; if (!epsilon_input_file.empty()) { - default_material = meep_geom::make_file_material(epsilon_input_file.c_str()); + meep_geom::material_type material = meep_geom::make_file_material(epsilon_input_file.c_str()); + set_default_material(material); + material_free(material); } // TODO: support mu_input_file diff --git a/src/meepgeom.cpp b/src/meepgeom.cpp index c96c8f879..eb7648395 100644 --- a/src/meepgeom.cpp +++ b/src/meepgeom.cpp @@ -29,7 +29,7 @@ namespace meep_geom { material_data vacuum_material_data; material_type vacuum = &vacuum_material_data; -static void set_default_material(material_type _default_material) { +void set_default_material(material_type _default_material) { if (default_material != NULL) { if (default_material == _default_material) return; material_free((material_type)default_material); diff --git a/src/meepgeom.hpp b/src/meepgeom.hpp index bb2f0d132..5802807e7 100644 --- a/src/meepgeom.hpp +++ b/src/meepgeom.hpp @@ -253,6 +253,7 @@ material_type make_material_grid(bool do_averaging, double beta, double eta, dou vector3 vec_to_vector3(const meep::vec &pt); meep::vec vector3_to_vec(const vector3 v3); +void set_default_material(material_type _default_material); void epsilon_material_grid(material_data *md, double u); void epsilon_file_material(material_data *md, vector3 p); bool susceptibility_equal(const susceptibility &s1, const susceptibility &s2);