Skip to content

Commit

Permalink
Update prob_relative interactions
Browse files Browse the repository at this point in the history
User values are preserved rather than resetting every time max_level or poisson_solver changes.
  • Loading branch information
proy30 committed Jan 10, 2025
1 parent 658b519 commit 6cc5b59
Showing 1 changed file with 12 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,18 @@ def populate_prob_relative_fields():
elif state.poisson_solver == "multigrid":
first_field_value = multigrid_first_field_value

state.prob_relative = [first_field_value] + [0.0] * (
tot_num_prob_relative_fields - 1
)
if state.prob_relative:
size = len(state.prob_relative)
num_of_extra_fields = tot_num_prob_relative_fields - size

if size < tot_num_prob_relative_fields:
state.prob_relative.extend([0.0] * (num_of_extra_fields))
elif size > tot_num_prob_relative_fields:
state.prob_relative = state.prob_relative[:tot_num_prob_relative_fields]
else:
state.prob_relative = [first_field_value] + [0.0] * (
tot_num_prob_relative_fields - 1
)

state.prob_relative_fields = [
{
Expand Down

0 comments on commit 6cc5b59

Please sign in to comment.