-
-
Notifications
You must be signed in to change notification settings - Fork 20
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
save state after every coupling iteration in explicit coupling #23
base: develop
Are you sure you want to change the base?
Conversation
I am not sure I understand the solution. Why store a checkpoint in explicit coupling? Maybe you can extract only the relevant bit and call it always, independent of the checkpointing? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the contributions! :D I hope these comments help express a bit better in the fix what I think you actually want to do.
nonlingeo_precice.c
Outdated
@@ -1114,10 +1114,10 @@ void nonlingeo_precice(double **cop, ITG *nk, ITG **konp, ITG **ipkonp, char **l | |||
|
|||
memcpy(&vini[0],&vold[0],sizeof(double)*mt**nk); | |||
|
|||
if( Precice_IsWriteCheckpointRequired() ) | |||
if( Precice_IsWriteCheckpointRequired() || simulationData.coupling_explicit) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would then almost always be true, right? I understnad that you always want checkpoints to be stored (to trigger some internal update).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For explicit coupling, yes.
adapter/PreciceInterface.c
Outdated
@@ -47,6 +47,9 @@ void Precice_Setup( char * configFilename, char * participantName, SimulationDat | |||
// Initialize coupling data | |||
Precice_InitializeData( sim ); | |||
|
|||
// find if coupling is implicit or explicit. Implicit coupling will return true at the very beginning and explicit will always return false | |||
sim->coupling_explicit = !Precice_IsWriteCheckpointRequired(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you need such a boolean, it would be better to make is coupling_implicit
. Usually we assume that implicit coupling is the special case that requires special treatment. You could then still write if (!coupling_implicit)
.
But I think you don't need this check in the first place, it should be enough to call what you want always.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sure, !coupling_implicit
or coupling_explicit
is no problem. But a check is needed. Because the call I want to happen always is only in the case of explicit coupling. For implicit coupling it should follow Precice_IsWriteCheckpointRequired()
(only at the ends of coupling iterations).
There is more information in issue #8. It's not exactly a "checkpoint". We just want the calculix-adapter/adapter/PreciceInterface.c Lines 140 to 154 in b01641e
so that the reference point w.r.t. which we compute DisplacementDeltas, sim->coupling_init_v (v_init ) gets updated in every iteration for only explicit cases.calculix-adapter/adapter/CCXHelpers.c Line 135 in b01641e
So yes, we could extract the memcpy line and write it. But the only differences between calling writecheckpoint and calling memcpy are the 2 lines of saving theta and dtheta . It really doesn't make any difference.
But, all of this is only if my understanding of the definition of DisplacementDeltas is correct. What is the reference point for DisplacementDeltas? Is it the Displacement from the last sub-cycle? Like it is implemented now. Or, is it the Displacement from the beginning of the coupling iteration? Like how it is for implicit cases, where the reference point is set at the beginning of a new coupling iteration, controlled by the |
A question from #8
That is correct, but I guess the description of a restart is vague. The "restart" is when the simulation must be stopped and restarted from the same point in time. An example would be if the fluid mesh is too distorted. The simulation can be stopped, the fluid mesh re-meshed, and the simulation restarted from the last time step. This then does involve restarting CalculiX from the previous loaded condition.
Before calculix-adapter/nonlingeo_precice.c Lines 1115 to 1121 in b01641e
This is just to clarify that DisplacementDeltas should be the displacement at the current time - displacement at the end of the previous timestep. |
The part about restart from #8 is only something I misunderstood back then. Nothing to do with this PR or issue #8 itself.
That is correct, and that will be the case once the PR is merged. First we copy calculix-adapter/nonlingeo_precice.c Lines 1115 to 1119 in 0e035ea
After the solution for the current time step is computed, v is copied into vold and we call WriteCouplingData .calculix-adapter/nonlingeo_precice.c Lines 2664 to 2666 in 0e035ea
Inside WriteCouplingData we compute DisplacementDelta ,calculix-adapter/adapter/PreciceInterface.c Lines 301 to 303 in 0e035ea
where v_init is the old solution we stored at the beginning of the iteration and v is a direct pointer access to the current solution CalculiX had just finished calculating.calculix-adapter/adapter/CCXHelpers.c Lines 125 to 137 in 0e035ea
|
I am sorry for the very late reply here. I appreciate the contribution a lot, but I am not 100% happy with the current solution. It was already a bit hacky before (current master) and now it seems to get too complicated. Up front, to clarify again: Explicitly storing whether a implicit or explicit coupling scheme is used (through a variable such as I guess the cleaner solution here is to use two separate variables:
Understandable? |
Yes, understood. However, check the bit below, calculix-adapter/nonlingeo_precice.c Lines 1119 to 1125 in d1a4f5a
in implicit coupling, when does isTimestepComplete return true ? Is it only at the end of a converged coupling time-step, or every time the coupling iteration reaches the end of the coupling time-step (even when readIterationCheckpoint is going to restart the iteration)? If it is the former, yeah we can use isTimestepComplete for DisplacementDeltas , and isWriteCheckpointRequired for everything else. But, in the latter case we cannot and will need an explicit/implicit switch to in addition to isTimestepComplete . This doubt lead me to create separate cases for implicit and explicit.
I vaguely remember checking this and I think it is the latter. |
It only returns true if the timestep is completely completed, so converged (for implicit coupling) and last sub timestep. So the former. If it is really the latter it would be a bug in preCICE. |
fix #8
A small hack to make DisplacementDeltas work for explicit coupling as well. My question however is, is DisplacementDeltas change in displacement within a sub-cycle or change in displacement relative to the displacement at the beginning of the coupling step. I hope I'm clear here. The changes here assume the former.