diff options
author | Thomas White <taw@physics.org> | 2014-02-22 03:34:03 -0800 |
---|---|---|
committer | Thomas White <taw@physics.org> | 2014-02-22 03:34:03 -0800 |
commit | aec05806f7bdefbc4669c326a85bd4fa0644eed7 (patch) | |
tree | 1bed5b3db0788bbff4c7cfda531683c0b12dde48 | |
parent | 5976fa23872b7239d0d16526fcc3041eb569dc6c (diff) |
Back up profile radius and div before iteration
-rw-r--r-- | src/post-refinement.c | 45 |
1 files changed, 28 insertions, 17 deletions
diff --git a/src/post-refinement.c b/src/post-refinement.c index 7ba8cd43..8a2cd6b1 100644 --- a/src/post-refinement.c +++ b/src/post-refinement.c @@ -622,39 +622,50 @@ static double guide_dev(Crystal *cr, const RefList *full) } -static Crystal *backup_crystal(Crystal *cr) +struct param_backup { - Crystal *b; + UnitCell *cell; + double profile_radius; + double div; +}; - b = crystal_new(); - crystal_set_cell(b, cell_new_from_cell(crystal_get_cell(cr))); + +static struct param_backup backup_crystal(Crystal *cr) +{ + struct param_backup b; + struct image *image = crystal_get_image(cr); + + b.cell = cell_new_from_cell(crystal_get_cell(cr)); + b.profile_radius = crystal_get_profile_radius(cr); + b.div = image->div; return b; } -static void revert_crystal(Crystal *cr, Crystal *backup) +static void revert_crystal(Crystal *cr, struct param_backup b) { double asx, asy, asz; double bsx, bsy, bsz; double csx, csy, csz; + struct image *image = crystal_get_image(cr); + + cell_get_reciprocal(b.cell, &asx, &asy, &asz, + &bsx, &bsy, &bsz, + &csx, &csy, &csz); - cell_get_reciprocal(crystal_get_cell(backup), - &asx, &asy, &asz, - &bsx, &bsy, &bsz, - &csx, &csy, &csz); + cell_set_reciprocal(crystal_get_cell(cr), asx, asy, asz, + bsx, bsy, bsz, + csx, csy, csz); - cell_set_reciprocal(crystal_get_cell(cr), - asx, asy, asz, - bsx, bsy, bsz, - csx, csy, csz); + crystal_set_profile_radius(cr, b.profile_radius); + image->div = b.div; } -static void free_backup_crystal(Crystal *cr) +static void free_backup_crystal(struct param_backup b) { - cell_free(crystal_get_cell(cr)); - crystal_free(cr); + cell_free(b.cell); } @@ -663,7 +674,7 @@ struct prdata pr_refine(Crystal *cr, const RefList *full, { double dev; int i; - Crystal *backup; + struct param_backup backup; const int verbose = 0; struct prdata prdata; double mean_p_change = 0.0; |