1
1
#include " enrico/nekrs_driver.h"
2
2
#include " enrico/error.h"
3
- #include " iapws/iapws.h"
4
3
#include " fldFile.hpp"
5
- #include " nekrs.hpp "
4
+ #include " iapws/iapws.h "
6
5
#include " nekInterfaceAdapter.hpp"
6
+ #include " nekrs.hpp"
7
7
8
8
#include < gsl-lite/gsl-lite.hpp>
9
9
@@ -30,9 +30,7 @@ NekRSDriver::NekRSDriver(MPI_Comm comm, pugi::xml_node node)
30
30
output_heat_source_ = node.child (" output_heat_source" ).text ().as_bool ();
31
31
}
32
32
33
- host_.setup ({
34
- {" mode" , " Serial" }
35
- });
33
+ host_.setup ({{" mode" , " Serial" }});
36
34
37
35
// commg_in and comm_in should be the same when there is only a single nekRS session.
38
36
setup_file_ = node.child_value (" casename" );
@@ -44,8 +42,8 @@ NekRSDriver::NekRSDriver(MPI_Comm comm, pugi::xml_node node)
44
42
setup_file_ /* _setupFile */ ,
45
43
" " /* backend_ */ ,
46
44
" " /* _deviceId */ ,
47
- 1 /* nSessions */ ,
48
- 0 /* sessionID */ ,
45
+ 1 /* nSessions */ ,
46
+ 0 /* sessionID */ ,
49
47
0 /* debug */ );
50
48
51
49
nrs_ptr_ = reinterpret_cast <nrs_t *>(nekrs::nrsPtr ());
@@ -56,7 +54,7 @@ NekRSDriver::NekRSDriver(MPI_Comm comm, pugi::xml_node node)
56
54
" NekRS simulation is not setup for conjugate-heat transfer (CHT). "
57
55
" ENRICO must be run with a CHT simulation." );
58
56
59
- mesh_t * mesh = nrs_ptr_->cds ->mesh [0 ];
57
+ mesh_t * mesh = nrs_ptr_->cds ->mesh [0 ];
60
58
n_local_elem_ = mesh->Nelements ;
61
59
poly_deg_ = mesh->N ;
62
60
n_gll_ = mesh->Np ;
@@ -68,15 +66,15 @@ NekRSDriver::NekRSDriver(MPI_Comm comm, pugi::xml_node node)
68
66
x_ = mesh->x ;
69
67
y_ = mesh->y ;
70
68
z_ = mesh->z ;
71
-
69
+
72
70
element_info_ = mesh->elementInfo ;
73
71
74
72
auto cds = nrs_ptr_->cds ;
75
73
76
74
// Copy rho_cp_ from the device to host
77
75
rho_cp_.resize (mesh->Nelements * mesh->Np );
78
76
occa::memory o_rho = cds->o_rho ;
79
- o_rho.copyTo (rho_cp_.data (), mesh->Nlocal * sizeof (dfloat));
77
+ o_rho.copyTo (rho_cp_.data (), mesh->Nlocal * sizeof (dfloat));
80
78
81
79
temperature_ = cds->S ;
82
80
@@ -141,10 +139,13 @@ void NekRSDriver::solve_step()
141
139
dt = nekrs::dt (tstep_);
142
140
143
141
int outputStep = nekrs::outputStep (time_ + dt, tstep_);
144
- if (nekrs::writeInterval () == 0 ) outputStep = 0 ;
145
- if (last_step) outputStep = 1 ;
146
- if (nekrs::writeInterval () < 0 ) outputStep = 0 ;
147
- nekrs::outputStep (outputStep);
142
+ if (nekrs::writeInterval () == 0 )
143
+ outputStep = 0 ;
144
+ if (last_step)
145
+ outputStep = 1 ;
146
+ if (nekrs::writeInterval () < 0 )
147
+ outputStep = 0 ;
148
+ nekrs::outputStep (outputStep);
148
149
149
150
nekrs::initStep (time_, dt, tstep_);
150
151
@@ -161,13 +162,13 @@ void NekRSDriver::solve_step()
161
162
elapsedStepSum += elapsedStep;
162
163
nekrs::updateTimer (" elapsedStep" , elapsedStep);
163
164
nekrs::updateTimer (" elapsedStepSum" , elapsedStepSum);
164
- nekrs::updateTimer (" elapsed" , elapsedStepSum);
165
+ nekrs::updateTimer (" elapsed" , elapsedStepSum);
165
166
166
167
if (nekrs::printInfoFreq ()) {
167
168
if (tstep_ % nekrs::printInfoFreq () == 0 )
168
169
nekrs::printInfo (time_, tstep_, true , false );
169
170
}
170
-
171
+
171
172
if (tstep_ % runtime_stat_freq == 0 || last_step)
172
173
nekrs::printRuntimeStatistics (tstep_);
173
174
}
@@ -178,11 +179,10 @@ void NekRSDriver::write_step(int timestep, int iteration)
178
179
{
179
180
timer_write_step.start ();
180
181
nekrs::outfld (time_, timestep);
181
- int FP64 = 1 ;
182
+ int FP64 = 1 ;
182
183
if (output_heat_source_) {
183
184
comm_.message (" Writing heat source to .fld file" );
184
- occa::memory o_localq =
185
- host_.wrapMemory <double >(localq_->data (), localq_->size ());
185
+ occa::memory o_localq = host_.wrapMemory <double >(localq_->data (), localq_->size ());
186
186
writeFld (" qsc" , time_, 1 , 0 , FP64, &nrs_ptr_->o_U , &nrs_ptr_->o_P , &o_localq, 1 );
187
187
}
188
188
timer_write_step.stop ();
@@ -236,7 +236,6 @@ std::vector<double> NekRSDriver::volume() const
236
236
237
237
double NekRSDriver::temperature_at (int32_t local_elem) const
238
238
{
239
- // comm_.message("at the beginning of function temperature_at()");
240
239
Expects (local_elem < n_local_elem ());
241
240
242
241
double sum0 = 0 .;
@@ -255,7 +254,7 @@ std::vector<double> NekRSDriver::temperature() const
255
254
for (int32_t i = 0 ; i < n_local_elem (); ++i) {
256
255
t[i] = this ->temperature_at (i);
257
256
}
258
-
257
+
259
258
return t;
260
259
}
261
260
0 commit comments