Skip to content

Commit

Permalink
Fix for Issue NanoComp#1834 (NanoComp#1840)
Browse files Browse the repository at this point in the history
* Fix memory leaks

* Add kkg to authors list

* Expose set_default_material and use it in libpympb/pympb.cpp
  • Loading branch information
kkg4theweb authored and Mo Chen committed Feb 16, 2022
1 parent 84dac05 commit f9d0bb7
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
6 changes: 4 additions & 2 deletions libpympb/pympb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/meepgeom.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions src/meepgeom.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit f9d0bb7

Please sign in to comment.