26 #include "Transient.h" 95 virtual bool converged(
unsigned int)
override {
return true; }
99 virtual void syncSolutions(ExternalProblem::Direction direction)
override;
136 template <
typename T>
142 double (*f)(int, int);
145 int start_1d =
mesh->Nq;
147 int start_3d = start_1d * start_1d * start_1d;
148 int end_3d = end_1d * end_1d * end_1d;
155 double * Ttmp = (
double *)calloc(n_to_write,
sizeof(
double));
156 double * Telem = (
double *)calloc(start_3d,
sizeof(
double));
160 for (
int k = 0; k <
mesh->Nelements; ++k)
162 int offset = k * start_3d;
169 for (
int v = 0; v < start_3d; ++v)
170 Telem[v] = f(offset + v, 0 );
180 for (
int v = 0; v < end_3d; ++v, ++c)
181 Ttmp[c] = f(offset + indices[build][v], 0 );
187 for (
int v = 0; v < n_to_write; ++v)
202 template <
typename T>
208 double (*f)(int, int);
211 int start_1d =
mesh->Nq;
213 int start_2d = start_1d * start_1d;
214 int end_2d = end_1d * end_1d;
224 double * Ttmp = (
double *)calloc(n_to_write,
sizeof(
double));
225 double * Tface = (
double *)calloc(start_2d,
sizeof(
double));
226 double * scratch = (
double *)calloc(start_1d * end_1d,
sizeof(
double));
231 for (
int k = 0; k < bc.total_n_faces; ++k)
235 int i = bc.element[k];
237 int offset = i *
mesh->Nfaces * start_2d + j * start_2d;
244 for (
int v = 0; v < start_2d; ++v)
246 int id =
mesh->vmapM[offset + v];
247 Tface[v] = f(
id,
mesh->Nsgeo * (offset + v));
258 for (
int v = 0; v < end_2d; ++v, ++c)
260 int id =
mesh->vmapM[offset + indices[build][v]];
261 Ttmp[c] = f(
id,
mesh->Nsgeo * (offset + v));
269 for (
int v = 0; v < n_to_write; ++v)
290 template <
typename T>
294 const std::vector<double> * add =
nullptr)
297 void (*write_solution)(int, dfloat);
306 for (
int v = 0; v <
mesh->Np; ++v)
308 double extra = (add ==
nullptr) ? 0.0 : (*add)[
id + v];
309 write_solution(
id + v, s[v] + extra);
315 double * tmp = (
double *)calloc(
mesh->Np,
sizeof(
double));
319 for (
int v = 0; v <
mesh->Np; ++v)
321 double extra = (add ==
nullptr) ? 0.0 : (*add)[
id + v];
322 write_solution(
id + v, tmp[v] + extra);
336 template <
typename T>
340 void (*write_solution)(int, dfloat);
344 int offset = bc.
element[elem_id] *
mesh->Nfaces *
mesh->Nfp + bc.face[elem_id] *
mesh->Nfp;
349 for (
int i = 0; i <
mesh->Nfp; ++i)
350 write_solution(
mesh->vmapM[offset + i], s[i]);
355 double * tmp = (
double *)calloc(
mesh->Nfp,
sizeof(
double));
358 for (
int i = 0; i <
mesh->Nfp; ++i)
359 write_solution(
mesh->vmapM[offset + i], tmp[i]);
382 const unsigned int & var_num,
383 const Real & divisor,
384 const Real & additive,
385 double ** outgoing_data);
398 const unsigned int & var_num,
399 const Real & divisor,
400 const Real & additive,
401 double ** outgoing_data);
423 const unsigned int & var_num,
424 const Real & divisor,
425 const Real & additive,
426 double ** outgoing_data);
446 double * incoming_moose_value,
447 double * outgoing_nek_value);
std::string fieldFilePrefix(const int &number) const
synchronization::SynchronizationEnum _sync_interval
When to synchronize the NekRS solution with the mesh mirror.
Definition: NekRSProblem.h:610
const bool & _disable_fld_file_output
Whether to turn off all field file writing.
Definition: NekRSProblem.h:481
virtual bool synchronizeOut()
void(*)(int, dfloat) solutionWritePointer(const field::NekWriteEnum &field)
Definition: NekInterface.h:736
Transient * transientExecutioner() const
Definition: NekRSProblem.h:59
int _n_vertices_per_volume
Number of vertices per volume element of the transfer mesh.
Definition: NekRSProblem.h:512
Definition: NekRSMesh.h:50
NekRSMesh * _nek_mesh
Definition: NekRSProblem.h:524
const NekVolumeCoupling & volumeCoupling() const
Definition: NekRSMesh.h:131
void freePointer(T *ptr)
Definition: CardinalUtils.h:23
void copyScratchToDevice()
Copy the data sent from MOOSE->Nek from host to device.
const NekBoundaryCoupling & boundaryCoupling() const
Definition: NekRSMesh.h:125
bool _is_output_step
Whether the most recent time step was an output file writing step.
Definition: NekRSProblem.h:518
NekTimeStepper * _timestepper
The time stepper used for selection of time step size.
Definition: NekRSProblem.h:527
Transient * _transient_executioner
Underlying executioner.
Definition: NekRSProblem.h:530
double * _interpolation_incoming
Vandermonde interpolation matrix (for incoming transfers)
Definition: NekRSProblem.h:548
virtual void initialSetup() override
const bool & _write_fld_files
Definition: NekRSProblem.h:478
int nBuildPerSurfaceElem() const
Definition: NekRSMesh.h:83
int _n_surface_elems
Number of surface elements in the data transfer mesh, across all processes.
Definition: NekRSProblem.h:503
int _n_vertices_per_surface
Number of vertices per surface element of the transfer mesh.
Definition: NekRSProblem.h:506
void writeVolumeSolution(const int elem_id, const T &field, double *s, const std::vector< double > *add=nullptr)
Definition: NekRSProblem.h:291
Definition: CardinalEnums.h:91
unsigned int _n_usrwrk_slots
Definition: NekRSProblem.h:494
virtual bool converged(unsigned int) override
Definition: NekRSProblem.h:95
Real nondimensionalAdditive(const field::NekFieldEnum &field)
bool _nondimensional
Whether a dimensionalization action has been added.
Definition: NekRSProblem.h:484
double(*)(int, int) solutionPointer(const field::NekFieldEnum &field)
Definition: NekInterface.h:729
void copyIndividualScratchSlot(const unsigned int &slot) const
virtual bool synchronizeIn()
std::vector< ScalarTransferBase * > _scalar_transfers
All of the ScalarTransfer objecst which pass data in/out of NekRS.
Definition: NekRSProblem.h:619
void interpolateSurfaceFaceHex3D(double *scratch, const double *I, double *x, int N, double *Ix, int M)
virtual bool nondimensional() const
Definition: NekRSProblem.h:105
virtual void externalSolve() override
void interpolateVolumeSolutionToNek(const int elem_id, double *incoming_moose_value, double *outgoing_nek_value)
void mapVolumeDataToNekVolume(const unsigned int &e, const unsigned int &var_num, const Real &divisor, const Real &additive, double **outgoing_data)
virtual bool isOutputStep() const
Whether nekRS should write an output file for the current time step.
SynchronizationEnum
Definition: CardinalEnums.h:64
double _tSolveStepMax
Maximum step solve time.
Definition: NekRSProblem.h:569
const std::vector< std::string > * _usrwrk_output_prefix
Filename prefix to use for naming the field files containing the nrs->o_usrwrk array slots.
Definition: NekRSProblem.h:557
std::vector< int > element
Definition: NekVolumeCoupling.h:40
double _elapsedTime
Sum of the total elapsed time in NekRS solves.
Definition: NekRSProblem.h:563
Definition: CardinalProblem.h:26
int _n_points
Number of points for interpolated fields on the MOOSE mesh.
Definition: NekRSProblem.h:539
const unsigned int & _constant_interval
For constant synchronization intervals, the desired frequency (in units of Nek time steps)
Definition: NekRSProblem.h:497
double _elapsedStepSum
Sum of the elapsed time in NekRS solves.
Definition: NekRSProblem.h:560
void allgatherv(const std::vector< int > &base_counts, const T *input, T *output, const int multiplier=1)
Definition: NekInterface.h:987
static bool _first
flag to indicate whether this is the first pass to serialize the solution
Definition: NekRSProblem.h:613
void mapFaceDataToNekFace(const unsigned int &e, const unsigned int &var_num, const Real &divisor, const Real &additive, double **outgoing_data)
int _moose_Nq
For the MOOSE mesh, the number of quadrature points in each coordinate direction.
Definition: NekRSProblem.h:551
int nBuildPerVolumeElem() const
Definition: NekRSMesh.h:77
unsigned int nUsrWrkSlots() const
Definition: NekRSProblem.h:129
mesh_t * temperatureMesh()
bool isDataTransferHappening(ExternalProblem::Direction direction)
void writeBoundarySolution(const int elem_id, const T &field, double *s)
Definition: NekRSProblem.h:337
void mapFaceDataToNekVolume(const unsigned int &e, const unsigned int &var_num, const Real &divisor, const Real &additive, double **outgoing_data)
Map nodal points on a MOOSE face element to the GLL points on a Nek volume element.
const std::string & _casename
NekRS casename.
Definition: NekRSProblem.h:462
bool isUsrWrkSlotReservedForCoupling(const unsigned int &slot) const
Solve nekRS wrapped as a MOOSE app.
Definition: NekRSProblem.h:36
void boundarySolution(const T &field, double *s)
Definition: NekRSProblem.h:203
Real nondimensionalDivisor(const field::NekFieldEnum &field)
Return the reference divisor scale that defines the non-dimensional field.
static InputParameters validParams()
const bool & _skip_final_field_file
Whether to skip writing a field file on NekRS's last time steo.
Definition: NekRSProblem.h:500
const std::vector< unsigned int > * _usrwrk_output
Slots in the nrs->o_usrwrk array to write to a field file.
Definition: NekRSProblem.h:554
int _n_volume_elems
Number of volume elements in the data transfer mesh, across all processes.
Definition: NekRSProblem.h:509
void initializeInterpolationMatrices()
Initialize interpolation matrices for transfers in/out of nekRS.
virtual void addExternalVariables() override
NekRSProblem(const InputParameters ¶ms)
Definition: FieldTransferBase.h:28
int nPoints() const
Definition: NekRSProblem.h:50
double * _interpolation_outgoing
Vandermonde interpolation matrix (for outgoing transfers)
Definition: NekRSProblem.h:545
std::vector< std::vector< int > > cornerIndices() const
Definition: NekRSMesh.h:308
Definition: CardinalEnums.h:286
std::unique_ptr< NumericVector< Number > > _serialized_solution
Definition: NekRSProblem.h:452
double _tSolveStepMin
Minimum step solve time.
Definition: NekRSProblem.h:566
void writeFieldFile(const Real &time, const int &step) const
void volumeSolution(const T &field, double *s)
Definition: NekRSProblem.h:137
std::vector< FieldTransferBase * > _field_transfers
All of the FieldTransfer objects which pass data in/out of NekRS.
Definition: NekRSProblem.h:616
virtual void syncSolutions(ExternalProblem::Direction direction) override
const PostprocessorValue * _transfer_in
Postprocessor containing the signal of when a synchronization has occurred.
Definition: NekRSProblem.h:542
double _start_time
Start time of the simulation based on NekRS's .par file.
Definition: NekRSProblem.h:515
bool exactMirror() const
Definition: NekRSMesh.h:302
void interpolateVolumeHex3D(const double *I, double *x, int N, double *Ix, int M)
void interpolateBoundarySolutionToNek(double *incoming_moose_value, double *outgoing_nek_value)
std::vector< int > element
Definition: NekBoundaryCoupling.h:40
Time stepper that reads time step information directly from nekRS.
Definition: NekTimeStepper.h:37
std::set< unsigned int > _usrwrk_slots
Usrwrk slots managed by Cardinal.
Definition: NekRSProblem.h:622
std::string casename() const
Definition: NekRSProblem.h:369
virtual const bool hasMovingNekMesh() const
Definition: NekRSProblem.h:111
bool _needs_interpolation
Definition: NekRSProblem.h:536