1515#include " include/constants.hpp"
1616#include < cmath>
1717
18+ #ifdef USE_MPI
19+ #include " include/Halo.hpp"
20+ #endif
21+
1822namespace Nextsim {
1923
2024// The brittle momentum solver for CG velocity fields
@@ -116,6 +120,20 @@ template <int DGadvection> class BrittleCGDynamicsKernel : public CGDynamicsKern
116120 {
117121 advectDynamicsFields (tst.step .seconds ());
118122
123+ // halo exchange
124+ // - damage, hice, cice
125+ // - s11, s12, s22
126+ // - e11, e12, e22
127+ // - dStressY, dStressX
128+ // - u, v
129+ // Note: only need to create one halo object per array type, dimensionality and size.
130+ #ifdef USE_MPI
131+ Halo halo (hice);
132+ halo.exchangeHalos (static_cast <DGVector<DGadvection>&>(hice));
133+ halo.exchangeHalos (static_cast <DGVector<DGadvection>&>(cice));
134+ halo.exchangeHalos (static_cast <DGVector<DGadvection>&>(damage));
135+ #endif
136+
119137 prepareIteration ({ { hiceName, hice }, { ciceName, cice } });
120138
121139 // The timestep for the brittle solver is the solver subtimestep
@@ -128,18 +146,42 @@ template <int DGadvection> class BrittleCGDynamicsKernel : public CGDynamicsKern
128146
129147 projectVelocityToStrain ();
130148
149+ #ifdef USE_MPI
150+ Halo haloDGVector (e11 );
151+ haloDGVector.exchangeHalos (e11 );
152+ haloDGVector.exchangeHalos (e12 );
153+ haloDGVector.exchangeHalos (e22 );
154+ #endif
155+
131156 std::array<std::reference_wrapper<DGVector<DGstressComp>>, N_TENSOR_ELEMENTS> stress
132157 = { s11, s12, s22 }; // Call the step function on the StressUpdateStep class
133158 // Call the step function on the StressUpdateStep class
134159 stressStep.stressUpdateHighOrder (
135160 params, *smesh, stress, { e11 , e12 , e22 }, hice, cice, deltaT);
136161
162+ #ifdef USE_MPI
163+ haloDGVector.exchangeHalos (s11);
164+ haloDGVector.exchangeHalos (s12);
165+ haloDGVector.exchangeHalos (s22);
166+ #endif
167+
137168 stressDivergence (); // Compute divergence of stress tensor
138169
170+ #ifdef USE_MPI
171+ Halo haloCGVector (dStressX);
172+ haloCGVector.exchangeHalos (dStressX);
173+ haloCGVector.exchangeHalos (dStressY);
174+ #endif
175+
139176 updateMomentum (tst);
140177
141178 applyBoundaries ();
142179
180+ #ifdef USE_MPI
181+ haloCGVector.exchangeHalos (u);
182+ haloCGVector.exchangeHalos (v);
183+ #endif
184+
143185 // Land mask
144186 }
145187
0 commit comments