@@ -10,15 +10,21 @@ AuxiliaryState *AuxiliaryState::DefaultAuxState = nullptr;
1010std::map<std::string, std::unique_ptr<AuxiliaryState>>
1111 AuxiliaryState::AllAuxStates;
1212
13+ static std::string stripDefault (const std::string &Name) {
14+ return Name != " Default" ? Name : " " ;
15+ }
16+
1317// Constructor. Constructs the member auxiliary variables and registers their
1418// fields with IOStreams
1519AuxiliaryState::AuxiliaryState (const std::string &Name, const HorzMesh *Mesh,
16- int NVertLevels, int NTracers)
17- : Mesh(Mesh), Name(Name), KineticAux(Name, Mesh, NVertLevels),
18- LayerThicknessAux (Name, Mesh, NVertLevels),
19- VorticityAux(Name, Mesh, NVertLevels),
20- VelocityDel2Aux(Name, Mesh, NVertLevels),
21- TracerAux(Name, Mesh, NVertLevels, NTracers) {
20+ Halo *MeshHalo, int NVertLevels, int NTracers)
21+ : Mesh(Mesh), MeshHalo(MeshHalo), Name(stripDefault(Name)),
22+ KineticAux (stripDefault(Name), Mesh, NVertLevels),
23+ LayerThicknessAux(stripDefault(Name), Mesh, NVertLevels),
24+ VorticityAux(stripDefault(Name), Mesh, NVertLevels),
25+ VelocityDel2Aux(stripDefault(Name), Mesh, NVertLevels),
26+ WindForcingAux(stripDefault(Name), Mesh),
27+ TracerAux(stripDefault(Name), Mesh, NVertLevels, NTracers) {
2228
2329 GroupName = " AuxiliaryState" ;
2430 if (Name != " Default" ) {
@@ -32,6 +38,7 @@ AuxiliaryState::AuxiliaryState(const std::string &Name, const HorzMesh *Mesh,
3238 LayerThicknessAux.registerFields (GroupName, AuxMeshName);
3339 VorticityAux.registerFields (GroupName, AuxMeshName);
3440 VelocityDel2Aux.registerFields (GroupName, AuxMeshName);
41+ WindForcingAux.registerFields (GroupName, AuxMeshName);
3542 TracerAux.registerFields (GroupName, AuxMeshName);
3643}
3744
@@ -42,6 +49,7 @@ AuxiliaryState::~AuxiliaryState() {
4249 LayerThicknessAux.unregisterFields ();
4350 VorticityAux.unregisterFields ();
4451 VelocityDel2Aux.unregisterFields ();
52+ WindForcingAux.unregisterFields ();
4553 TracerAux.unregisterFields ();
4654
4755 int Err = FieldGroup::destroy (GroupName);
@@ -64,6 +72,7 @@ void AuxiliaryState::computeMomAux(const OceanState *State, int ThickTimeLevel,
6472 OMEGA_SCOPE (LocLayerThicknessAux, LayerThicknessAux);
6573 OMEGA_SCOPE (LocVorticityAux, VorticityAux);
6674 OMEGA_SCOPE (LocVelocityDel2Aux, VelocityDel2Aux);
75+ OMEGA_SCOPE (LocWindForcingAux, WindForcingAux);
6776
6877 parallelFor (
6978 " vertexAuxState1" , {Mesh->NVerticesAll , NChunks},
@@ -82,7 +91,12 @@ void AuxiliaryState::computeMomAux(const OceanState *State, int ThickTimeLevel,
8291 const auto &RelVortVertex = VorticityAux.RelVortVertex ;
8392
8493 parallelFor (
85- " edgeAuxState1" , {Mesh->NEdgesAll , NChunks},
94+ " edgeAuxState1" , {Mesh->NEdgesAll }, KOKKOS_LAMBDA (int IEdge) {
95+ LocWindForcingAux.computeVarsOnEdge (IEdge);
96+ });
97+
98+ parallelFor (
99+ " edgeAuxState2" , {Mesh->NEdgesAll , NChunks},
86100 KOKKOS_LAMBDA (int IEdge, int KChunk) {
87101 LocVorticityAux.computeVarsOnEdge (IEdge, KChunk);
88102 LocLayerThicknessAux.computeVarsOnEdge (IEdge, KChunk, LayerThickCell,
@@ -153,16 +167,17 @@ void AuxiliaryState::computeAll(const OceanState *State,
153167
154168// Create a non-default auxiliary state
155169AuxiliaryState *AuxiliaryState::create (const std::string &Name,
156- const HorzMesh *Mesh, int NVertLevels ,
157- const int NTracers) {
170+ const HorzMesh *Mesh, Halo *MeshHalo ,
171+ int NVertLevels, const int NTracers) {
158172 if (AllAuxStates.find (Name) != AllAuxStates.end ()) {
159173 LOG_ERROR (" Attempted to create a new AuxiliaryState with name {} but it "
160174 " already exists" ,
161175 Name);
162176 return nullptr ;
163177 }
164178
165- auto *NewAuxState = new AuxiliaryState (Name, Mesh, NVertLevels, NTracers);
179+ auto *NewAuxState =
180+ new AuxiliaryState (Name, Mesh, MeshHalo, NVertLevels, NTracers);
166181 AllAuxStates.emplace (Name, NewAuxState);
167182
168183 return NewAuxState;
@@ -172,12 +187,13 @@ AuxiliaryState *AuxiliaryState::create(const std::string &Name,
172187// initialized.
173188void AuxiliaryState::init () {
174189 const HorzMesh *DefMesh = HorzMesh::getDefault ();
190+ Halo *DefHalo = Halo::getDefault ();
175191
176192 int NVertLevels = DefMesh->NVertLevels ;
177193 int NTracers = Tracers::getNumTracers ();
178194
179- AuxiliaryState::DefaultAuxState =
180- AuxiliaryState::create ( " Default" , DefMesh, NVertLevels, NTracers);
195+ AuxiliaryState::DefaultAuxState = AuxiliaryState::create (
196+ " Default" , DefMesh, DefHalo , NVertLevels, NTracers);
181197
182198 Config *OmegaConfig = Config::getOmegaConfig ();
183199 DefaultAuxState->readConfigOptions (OmegaConfig);
@@ -248,6 +264,37 @@ void AuxiliaryState::readConfigOptions(Config *OmegaConfig) {
248264 } else {
249265 ABORT_ERROR (" AuxiliaryState: Unknown FluxTracerType requested" );
250266 }
267+
268+ Config WindStressConfig (" WindStress" );
269+ Err += OmegaConfig->get (WindStressConfig);
270+
271+ std::string WindStressInterpTypeStr;
272+ Err += WindStressConfig.get (" InterpType" , WindStressInterpTypeStr);
273+ CHECK_ERROR_ABORT (
274+ Err, " AuxiliaryState: InterpType not found in WindStressConfig" );
275+
276+ if (WindStressInterpTypeStr == " Isotropic" ) {
277+ this ->WindForcingAux .InterpChoice = InterpCellToEdgeOption::Isotropic;
278+ } else if (WindStressInterpTypeStr == " Anisotropic" ) {
279+ this ->WindForcingAux .InterpChoice = InterpCellToEdgeOption::Anisotropic;
280+ } else {
281+ ABORT_ERROR (" AuxiliaryState: Unknown InterpType requested" );
282+ }
251283}
252284
285+ // ------------------------------------------------------------------------------
286+ // Perform auxiliary state halo exchange
287+ // Note that only non-computed auxiliary variables needs to be exchanged
288+ I4 AuxiliaryState::exchangeHalo () {
289+ I4 Err = 0 ;
290+
291+ Err +=
292+ MeshHalo->exchangeFullArrayHalo (WindForcingAux.ZonalStressCell , OnCell);
293+ Err +=
294+ MeshHalo->exchangeFullArrayHalo (WindForcingAux.MeridStressCell , OnCell);
295+
296+ return Err;
297+
298+ } // end exchangeHalo
299+
253300} // namespace OMEGA
0 commit comments