Skip to content
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

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions adapter/PreciceInterface.c
Original file line number Diff line number Diff line change
Expand Up @@ -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_implicit = Precice_IsWriteCheckpointRequired();

}

void Precice_InitializeData( SimulationData * sim )
Expand Down Expand Up @@ -111,6 +114,11 @@ bool Precice_IsWriteCheckpointRequired()
return precicec_isActionRequired( "write-iteration-checkpoint" );
}

bool Precice_IsCouplingTimestepComplete()
{
return precicec_isCouplingTimestepComplete();
}

void Precice_FulfilledReadCheckpoint()
{
precicec_fulfilledAction( "read-iteration-checkpoint" );
Expand Down
7 changes: 7 additions & 0 deletions adapter/PreciceInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ typedef struct SimulationData {
double coupling_init_dtheta;
double precice_dt;
double solver_dt;
bool coupling_implicit;

} SimulationData;

Expand Down Expand Up @@ -186,6 +187,12 @@ bool Precice_IsReadCheckpointRequired();
*/
bool Precice_IsWriteCheckpointRequired();

/**
* @brief Returns true if coupling timestep is complete
* @return
*/
bool Precice_IsCouplingTimestepComplete();

/**
* @brief Tells preCICE that the checkpoint has been read
*/
Expand Down
7 changes: 6 additions & 1 deletion nonlingeo_precice.c
Original file line number Diff line number Diff line change
Expand Up @@ -1089,6 +1089,8 @@ void nonlingeo_precice(double **cop, ITG *nk, ITG **konp, ITG **ipkonp, char **l
/* Adapter: Create the interfaces and initialize the coupling */
printf("About to enter preCICE setup in Calculix with names %s and %s \n", preciceParticipantName, configFilename);
Precice_Setup( configFilename, preciceParticipantName, &simulationData );
// Initialize for the first step because Precice_IsCouplingTimestepComplete will return false until the end of the first step
if( !simulationData.coupling_implicit ) Precice_WriteIterationCheckpoint( &simulationData, vini );

/* Adapter: Give preCICE the control of the time stepping */
while( Precice_IsCouplingOngoing() ){
Expand All @@ -1114,11 +1116,14 @@ 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() ) // implicit coupling
{
Precice_WriteIterationCheckpoint( &simulationData, vini );
Precice_FulfilledWriteCheckpoint();
}
if( Precice_IsCouplingTimestepComplete() && !simulationData.coupling_implicit ) // explicit coupling
Precice_WriteIterationCheckpoint( &simulationData, vini );


for(k=0;k<*nboun;++k){xbounini[k]=xbounact[k];}
if((*ithermal==1)||(*ithermal>=3)){
Expand Down