Skip to content

Throw Segfault for plotting macroscopic fields for vacuum case - #165

Merged
ajnonaka merged 1 commit into
AMReX-Microelectronics:developmentfrom
ajnonaka:macroscopic_fields_for_vacuum
Nov 9, 2026
Merged

ajnonaka merged 1 commit into
AMReX-Microelectronics:developmentfrom
ajnonaka:macroscopic_fields_for_vacuum

Conversation

@ajnonaka

@ajnonaka ajnonaka commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

Fixes #113.

Problem

Adding sigma, epsilon, or mu (or the LLG mag_Ms_*, mag_alpha_*, mag_exchange_*, mag_anisotropy_* fields) to fields_to_plot segfaults when algo.em_solver_medium is not macroscopic. The crash happens in FullDiagnostics::InitializeFieldFunctors, where MacroscopicProperties returns null MultiFab pointers because the material properties were never initialized.

Diagnostics::BaseReadParameters already has asserts meant to catch this with a clear message. They never fire because they check m_varnames, which is still empty at that point. It only gets filled from m_varnames_fields later in the same function.

Fix

The seven checks now look at m_varnames_fields instead of m_varnames, matching the existing check for G just above them.

Testing

  • With algo.em_solver_medium = vacuum and sigma in fields_to_plot: before, a segfault; after, the run stops with sigma in plotfiles only works with algo.em_solver_medium=macroscopic.
  • With algo.em_solver_medium = macroscopic: sigma, epsilon, and mu are still written correctly, with and without LLG and when restarting from a checkpoint.

Adding `sigma`, `epsilon`, or `mu` (or the LLG `mag_Ms_*`, `mag_alpha_*`, `mag_exchange_*`, `mag_anisotropy_*` fields) to `fields_to_plot` segfaults when `algo.em_solver_medium` is not `macroscopic`. The crash happens in `FullDiagnostics::InitializeFieldFunctors`, where `MacroscopicProperties` returns null MultiFab pointers because the material properties were never initialized.

`Diagnostics::BaseReadParameters` already has asserts meant to catch this with a clear message. They never fire because they check `m_varnames`, which is still empty at that point. It only gets filled from `m_varnames_fields` later in the same function.

The seven checks now look at `m_varnames_fields` instead of `m_varnames`, matching the existing check for `G` just above them.

- With `algo.em_solver_medium = vacuum` and `sigma` in `fields_to_plot`: before, a segfault; after, the run stops with `sigma in plotfiles only works with algo.em_solver_medium=macroscopic`.
- With `algo.em_solver_medium = macroscopic`: `sigma`, `epsilon`, and `mu` are still written correctly, with and without LLG and when restarting from a checkpoint.
@ajnonaka
ajnonaka merged commit 5404b36 into AMReX-Microelectronics:development Nov 9, 2026
10 of 15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fields_to_plot for material properties causes segfault

1 participant