Skip to content

Commit

Permalink
Add null check when getting Coordinates from Mesh
Browse files Browse the repository at this point in the history
If Coordinates are in the process of being constructed the object may not have been registered with Mesh yet.
  • Loading branch information
tomchapman committed Dec 21, 2024
1 parent 15cffda commit af34f77
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/field/field_data.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,11 @@ BOUT_HOST_DEVICE Coordinates* FieldData::getCoordinates() const {
if (fieldCoordinates_shared) {
return fieldCoordinates_shared.get();
}
fieldCoordinates = getMesh()->getCoordinatesSmart(FieldData::getLocation());
coordinates_from_mesh = getMesh()->getCoordinatesSmart(FieldData::getLocation());
// If Coordinates are in the process of being constructed the object may not have been registered with Mesh yet
if (coordinates_from_mesh != nullptr) {
fieldCoordinates = coordinates_from_mesh;
}
return fieldCoordinates.lock().get();
}

Expand Down

0 comments on commit af34f77

Please sign in to comment.