Description
The discussion on #3098 had me thinking about how we might allow users to access more model data within forcing or boundary condition functions. The problem we encountered in the past (especially for diffusivity fields) is that dumping everything into the forcing function often caused GPU compilation to fail. That's why forcing functions only have access (for example) to velocities, tracers, and auxiliary fields:
A possible solution to this is a utility with_auxiliary_fields
for "rebuilding" a model with new auxiliary fields. I think this would be relatively simple to implement, because the auxiliary_fields
don't have any role within a model constructor. Thus we can develop something like
model = with_auxiliary_fields(model, new_auxiliary_fields)
which is quite easy I think, something like...
function with_auxiliary_fields(model::NonhydrostaticModel, new_auxiliary_fields)
model_properties = OrderedDict{Any, Any}(name => getproperty(model, name) for name in propertynames(model))
model_properties[:auxiliary_fields] = new_auxiliiary_fields
return NonhydrostaticModel(model_properties.values...)
end
Then users can run simulations with the "updated" model, putting any fields they like from the "old" model into auxiliary_fields
.