Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Follow-up: Do not leave NaN values in output vectors. #5274

Merged
merged 1 commit into from
Jul 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,19 @@ namespace aspect
return_value ("artificial_viscosity_composition",
new Vector<float>(this->get_triangulation().n_active_cells()));
this->get_artificial_viscosity_composition(*return_value.second, compositional_field);

// The function we call above sets the artificial viscosity to
// signaling_nan on all artificial cells and, possibly, ghost cells.
// This runs into trouble in DataOut that wants to copy this vector
// from Vector<float> to Vector<double>, and the conversion trips
// up over the NaNs, causing a floating point exception.
//
// To avoid this, strip out the NaNs and instead set these values
// to zero -- we won't be outputting these values anyway.
for (const auto &cell : this->get_triangulation().active_cell_iterators())
if (cell->is_locally_owned() == false)
(*return_value.second)[cell->active_cell_index()] = 0;

return return_value;
}

Expand Down
6 changes: 5 additions & 1 deletion tests/composition_active_nans.prm
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ set End time = 0.1

subsection Postprocess
subsection Visualization
set List of output variables = density, artificial viscosity
set List of output variables = density, artificial viscosity, artificial viscosity composition

subsection Artificial viscosity composition
set Name of compositional field = C_1
end
end
end