From 9961035bf58a0a4bea05f6e077d9fcfe60100ce6 Mon Sep 17 00:00:00 2001
From: Alexander Jaust <alexander.jaust@ipvs.uni-stuttgart.de>
Date: Thu, 25 Apr 2019 13:11:16 +0200
Subject: [PATCH] some fixes and work on implicit coupling

---
 .../iterative/main_freeflow.cc                     | 14 ++++++--------
 .../iterative/main_solidenergy.cc                  | 13 ++-----------
 .../monolithic/problem_heat.hh                     |  3 ++-
 3 files changed, 10 insertions(+), 20 deletions(-)

diff --git a/appl/conjugateheattransfer/iterative/main_freeflow.cc b/appl/conjugateheattransfer/iterative/main_freeflow.cc
index e454639..27532ee 100644
--- a/appl/conjugateheattransfer/iterative/main_freeflow.cc
+++ b/appl/conjugateheattransfer/iterative/main_freeflow.cc
@@ -219,12 +219,7 @@ int main(int argc, char** argv) try
       couplingInterface.announceInitialDataWritten();
     }
     couplingInterface.initializeData();
-/*
-    if (couplingInterface.isInitialDataAvailable())
-    {
-      couplingInterface.readHeatFluxFromOtherSolver();
-    }
-*/
+
     // instantiate time loop
     using Scalar = GetPropType<FreeFlowTypeTag, Properties::Scalar>;
     const auto tEnd = getParam<Scalar>("TimeLoop.TEnd");
@@ -263,7 +258,7 @@ int main(int argc, char** argv) try
         }
 
         // Read heat flux from precice.
-        couplingInterface.readHeatFluxFromOtherSolver();
+        couplingInterface.readTemperatureFromOtherSolver();
 
         // set previous solution for storage evaluations
         assembler->setPreviousSolution(solOld);
@@ -273,7 +268,7 @@ int main(int argc, char** argv) try
 
         // make the new solution the old solution
         //TODO DO WE HAVE TO MOVE THAT?
-        solOld = sol;
+        //solOld = sol;
         freeFlowGridVariables->advanceTimeStep();
 
         // Write heatflux to wrapper
@@ -292,6 +287,7 @@ int main(int argc, char** argv) try
         {
             //Read checkpoint
             sol = sol_checkpoint;
+            //freeFlowGridVariables->advanceTimeStep();
             freeFlowGridVariables->update(sol);
             couplingInterface.announceIterationCheckpointRead();
         }
@@ -306,6 +302,8 @@ int main(int argc, char** argv) try
             // report statistics of this time step
             timeLoop->reportTimeStep();
 
+            solOld = sol;
+
         }
 
     } while (!timeLoop->finished() && couplingInterface.isCouplingOngoing());
diff --git a/appl/conjugateheattransfer/iterative/main_solidenergy.cc b/appl/conjugateheattransfer/iterative/main_solidenergy.cc
index 380a794..95194de 100644
--- a/appl/conjugateheattransfer/iterative/main_solidenergy.cc
+++ b/appl/conjugateheattransfer/iterative/main_solidenergy.cc
@@ -228,12 +228,6 @@ int main(int argc, char** argv) try
     }
 
     couplingInterface.initializeData();
-/*
-    if (couplingInterface.isInitialDataAvailable())
-    {
-      couplingInterface.readHeatFluxFromOtherSolver();
-    }
-    */
     // instantiate time loop
     using Scalar = GetPropType<SolidEnergyTypeTag, Properties::Scalar>;
     const auto tEnd = getParam<Scalar>("TimeLoop.TEnd");
@@ -290,7 +284,6 @@ int main(int argc, char** argv) try
         // make the new solution the old solution
 
         //TODO DO WE HAVE TO MOVE THAT?
-        solOld = sol;
         solidEnergyGridVariables->advanceTimeStep();
 
         setBoundaryTemperatures<GetPropType<SolidEnergyTypeTag, Properties::ThermalConductivityModel>>(*solidEnergyProblem, *solidEnergyGridVariables, sol );
@@ -307,6 +300,7 @@ int main(int argc, char** argv) try
         {
             //Read checkpoint
             sol = sol_checkpoint;
+            //solidEnergyGridVariables->advanceTimeStep();
             solidEnergyGridVariables->update(sol);
             couplingInterface.announceIterationCheckpointRead();
         }
@@ -321,10 +315,7 @@ int main(int argc, char** argv) try
             // report statistics of this time step
             timeLoop->reportTimeStep();
 
-            // Get the temperature here
-            // TODO
-
-
+            solOld = sol;
         }
 
     } while (!timeLoop->finished() && couplingInterface.isCouplingOngoing() );
diff --git a/appl/conjugateheattransfer/monolithic/problem_heat.hh b/appl/conjugateheattransfer/monolithic/problem_heat.hh
index 2bdf2dd..832a32f 100644
--- a/appl/conjugateheattransfer/monolithic/problem_heat.hh
+++ b/appl/conjugateheattransfer/monolithic/problem_heat.hh
@@ -180,7 +180,8 @@ public:
         const auto faceId = scvf.index();
         if ( couplingInterface_.isCoupledEntity(faceId) )
         {
-             values[Indices::energyEqIdx] = couplingInterface_.getHeatFluxOnFace(faceId) ;
+          // ALEX: I made the heat flux negative since the normal vectors of both solvers are different!
+          values[Indices::energyEqIdx] = - couplingInterface_.getHeatFluxOnFace(faceId) ;
         }
 #endif
 
-- 
GitLab