I’m starting so see where my misunderstanding is.
Until now I thought data initialization is only necessary for cases where some computation is required to get an initial value, i.e. you can’t just read it from an input file or similar, and you don’t want to repeat that computation in both participants.
If I understand you correctly, data initialization is required whenever zero isn’t valid or what you want, which for us means pretty much always (maybe we are special in that way). This is also mentioned at the top of this page: Step 7 - Data initialization | preCICE - The Coupling Library, but I hadn’t seen this before. This means that every participant needs to write initial values during the data initialization phase for all the coupled data (or at least needs to be prepared to write depending on the settings in precice config xml). It’s not intended for participants to e.g. read the initial value from some input source and skip the initializeData
phase.
This answers my question about reading data in the first time step, since it’s definitely OK to just always read data.
But it creates a problem for data initialization, which until now I was thinking of as a completely optional, advanced feature instead of a basic requirement. Maybe I’m bad at listening/reading, or does it need to be highlighted more in your course/documentation?
Our solver generally cannot easily write initial data during the initialization phase. There are a lot of state variables that the solver produces during simulation, but does not require initial values for. But just because the solver doesn’t have the variables readily available doesn’t mean it’s impossible to get valid initial values. The other participant solver, during it’s normal setup, may be able to get initial values without reading coupled data.
A concrete example: our solver (ISSM) computes temperatures. the temperature variable is not required to be initialized at all. Depending on the setup, it may even be completely inaccessible before the first time step of the solver is done. But initial temperature data might still be available from other sources, maybe measurements or results of previous simulations. The other participant solver (not talking about any specific solver here) might already have that data since it requires temperature data but doesn’t know anything about the coupling. So we could have a situation where one participant is required to write data it doesn’t have just so the other participant can read data it doesn’t need because it already has it. Obviously it’s possible, at least in principle, for ISSM to also read that measurement data or do the necessary computation so it can write initial data. This will require changes to the solver, the adapter, or both, and the necessary computation steps are very different for every variable, of which there are many.
I don’t know how big of a problem this is, the size of the changes will be anywhere between trivial and massive, so we’ll see. It probably means our adapter will have limited support for which variables to couple until we can implement the initial data computation for every variable. I realise that precice can’t change it’s behavior here because every existing adapter and coupling relies on it. So thanks for patiently correcting my misconceptions