Skip to content

Commit

Permalink
Remove all instances of exporting adaptivity cpu time
Browse files Browse the repository at this point in the history
  • Loading branch information
IshaanDesai committed Feb 11, 2025
1 parent 79c5e10 commit 9fcfca9
Show file tree
Hide file tree
Showing 5 changed files with 1 addition and 53 deletions.
3 changes: 0 additions & 3 deletions docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,6 @@ Parameter | Description
`refining_constant` | Refining constant $$ C_r $$, set as $$ 0 =< C_r < 1 $$.
`every_implicit_iteration` | If True, adaptivity is calculated in every implicit iteration. <br> If False, adaptivity is calculated once at the start of the time window and then reused in every implicit time iteration.
`similarity_measure`| Similarity measure to be used for adaptivity. Can be either `L1`, `L2`, `L1rel` or `L2rel`. By default, `L1` is used. The `rel` variants calculate the respective relative norms. This parameter is *optional*.
`output_cpu_time` | Write CPU time of the adaptivity computation to preCICE, to be exported. This parameter is *optional*.

The primary tuning parameters for adaptivity are the history parameter $$ \Lambda $$, the coarsening constant $$ C_c $$, and the refining constant $$ C_r $$. Their effects can be interpreted as:

Expand Down Expand Up @@ -171,8 +170,6 @@ The Micro Manager uses the output functionality of preCICE, hence these data set
</participant>
```

If the parameter `output_cpu_time` in `adaptivity_settings` is set to `True`, a scalar data field `adaptivity_cpu_time` needs to be added in the same way as described above.

## Interpolate a crashed micro simulation

If the optional dependency `sklearn` is installed, the Micro Manager will derive the output of a crashed micro simulation by interpolating outputs from similar simulations. To enable this, set
Expand Down
3 changes: 0 additions & 3 deletions examples/precice-config-adaptivity.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
<data:scalar name="solve_cpu_time"/>
<data:scalar name="active_state"/>
<data:scalar name="active_steps"/>
<data:scalar name="adaptivity_cpu_time"/>

<mesh name="macro-mesh" dimensions="3">
<use-data name="macro-scalar-data"/>
Expand All @@ -23,7 +22,6 @@
<use-data name="solve_cpu_time"/>
<use-data name="active_state"/>
<use-data name="active_steps"/>
<use-data name="adaptivity_cpu_time"/>
</mesh>

<participant name="Macro-dummy">
Expand All @@ -43,7 +41,6 @@
<write-data name="solve_cpu_time" mesh="macro-mesh"/>
<write-data name="active_state" mesh="macro-mesh"/>
<write-data name="active_steps" mesh="macro-mesh"/>
<write-data name="adaptivity_cpu_time" mesh="macro-mesh"/>
</participant>

<m2n:sockets acceptor="Micro-Manager" connector="Macro-dummy"/>
Expand Down
41 changes: 0 additions & 41 deletions micro_manager/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,6 @@ def __init__(self, config_file_name):
self._adaptivity_every_implicit_iteration = False
self._adaptivity_similarity_measure = "L1"
self._adaptivity_output_n = 1
self._adaptivity_output_cpu_time = False
self._adaptivity_output_mem_usage = False

# Snapshot information
self._parameter_file_name = None
Expand Down Expand Up @@ -246,34 +244,6 @@ def read_json_micro_manager(self):
self._write_data_names.append("active_state")
self._write_data_names.append("active_steps")

try:
if (
self._data["simulation_params"]["adaptivity_settings"][
"output_cpu_time"
]
== "True"
):
self._adaptivity_output_cpu_time = True
self._write_data_names.append("adaptivity_cpu_time")
except BaseException:
self._logger.log_info_one_rank(
"Micro Manager will not output CPU time of the adaptivity computation."
)

try:
if (
self._data["simulation_params"]["adaptivity_settings"][
"output_mem_usage"
]
== "True"
):
self._adaptivity_output_mem_usage = True
self._write_data_names.append("adaptivity_mem_usage")
except BaseException:
self._logger.log_info_one_rank(
"Micro Manager will not output CPU time of the adaptivity computation."
)

if "interpolate_crash" in self._data["simulation_params"]:
if self._data["simulation_params"]["interpolate_crash"] == "True":
self._interpolate_crash = True
Expand Down Expand Up @@ -547,17 +517,6 @@ def is_adaptivity_required_in_every_implicit_iteration(self):
"""
return self._adaptivity_every_implicit_iteration

def output_adaptivity_cpu_time(self):
"""
Check if CPU time of the adaptivity computation needs to be output.
Returns
-------
adaptivity_cpu_time : bool
True if CPU time of the adaptivity computation needs to be output, False otherwise.
"""
return self._adaptivity_output_cpu_time

def get_micro_dt(self):
"""
Get the size of the micro time window.
Expand Down
4 changes: 1 addition & 3 deletions micro_manager/micro_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,6 @@ def __init__(self, config_file: str) -> None:
)

self._adaptivity_output_n = self._config.get_adaptivity_output_n()
self._output_adaptivity_cpu_time = self._config.output_adaptivity_cpu_time()

# Define the preCICE Participant
self._participant = precice.Participant(
Expand Down Expand Up @@ -201,8 +200,7 @@ def solve(self) -> None:

micro_sims_output, adaptivity_time = micro_sim_solve(micro_sims_input, dt)

if self._output_adaptivity_cpu_time:
adaptivity_cpu_time += adaptivity_time
adaptivity_cpu_time += adaptivity_time

# Check if more than a certain percentage of the micro simulations have crashed and terminate if threshold is exceeded
if self._interpolate_crashed_sims:
Expand Down
3 changes: 0 additions & 3 deletions tests/integration/test_unit_cube/precice-config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
<data:scalar name="macro-data-1" />
<data:scalar name="active_state" />
<data:scalar name="active_steps" />
<data:scalar name="adaptivity_cpu_time" />
<data:scalar name="solve_cpu_time" />

<mesh name="macro-cube-mesh" dimensions="3">
Expand All @@ -18,7 +17,6 @@
<use-data name="macro-data-1" />
<use-data name="active_state" />
<use-data name="active_steps" />
<use-data name="adaptivity_cpu_time" />
<use-data name="solve_cpu_time" />
</mesh>

Expand All @@ -36,7 +34,6 @@
<write-data name="micro-data-2" mesh="macro-cube-mesh" />
<write-data name="active_state" mesh="macro-cube-mesh" />
<write-data name="active_steps" mesh="macro-cube-mesh" />
<write-data name="adaptivity_cpu_time" mesh="macro-cube-mesh" />
<write-data name="solve_cpu_time" mesh="macro-cube-mesh" />
<export:vtu directory="output" />
</participant>
Expand Down

0 comments on commit 9fcfca9

Please sign in to comment.