Bad caching of the ocean tides model
Opening this issue after this discussion.
If an OceanTides force model is set up inside a function, and this function is called in a program several times with different parameters, particularly with different degree or order values, the acceleration calculations are always done with the parameters from the first call. For example, the first call is with degree=order=10, then oceanTides.acceleration is calculated. The second call is with degree=order=20, but new acceleration is the same as the first one.
Suggested solution by @MaximeJ:
It doesn’t happen if two different DataContext are used. There’s definitely something happening in the caching of the ocean tides model. I think it’s located in GravityFields.getOceanTidesWaves(degree, order). After two successive calls with (10, 10) and (20, 20) the degree, order in the waves is still set to 10.
In OceanTidesReader, method stillAcceptData just checks if some ocean waves already exist.
/** {@inheritDoc} */
@Override
public boolean stillAcceptsData() {
return waves.isEmpty();
}
So I think it doesn’t care if the degree/order is higher than what’s already there.
I compared it to the same method in PotentialCoefficientsReader and here there’s a check on the degree/order of the harmonics already loaded.
/** {@inheritDoc} */
public boolean stillAcceptsData() {
return !(readComplete &&
getMaxAvailableDegree() >= getMaxParseDegree() &&
getMaxAvailableOrder() >= getMaxParseOrder());
}
I think the same behavior should be implemented in OceanTidesReader.