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 const std::vector<double> * add =
nullptr);
304 const std::vector<double> * add =
nullptr);
332 const unsigned int & var_num,
333 const Real & divisor,
334 const Real & additive,
335 double ** outgoing_data);
348 const unsigned int & var_num,
349 const Real & divisor,
350 const Real & additive,
351 double ** outgoing_data);
373 const unsigned int & var_num,
374 const Real & divisor,
375 const Real & additive,
376 double ** outgoing_data);
396 double * incoming_moose_value,
397 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:560
const bool & _disable_fld_file_output
Whether to turn off all field file writing.
Definition: NekRSProblem.h:431
virtual bool synchronizeOut()
Transient * transientExecutioner() const
Definition: NekRSProblem.h:59
NekWriteEnum
Enumeration of possible fields to write in nekRS.
Definition: CardinalEnums.h:117
int _n_vertices_per_volume
Number of vertices per volume element of the transfer mesh.
Definition: NekRSProblem.h:462
Definition: NekRSMesh.h:50
NekRSMesh * _nek_mesh
Definition: NekRSProblem.h:474
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:468
NekTimeStepper * _timestepper
The time stepper used for selection of time step size.
Definition: NekRSProblem.h:477
Transient * _transient_executioner
Underlying executioner.
Definition: NekRSProblem.h:480
double * _interpolation_incoming
Vandermonde interpolation matrix (for incoming transfers)
Definition: NekRSProblem.h:498
virtual void initialSetup() override
const bool & _write_fld_files
Definition: NekRSProblem.h:428
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:453
int _n_vertices_per_surface
Number of vertices per surface element of the transfer mesh.
Definition: NekRSProblem.h:456
void writeBoundarySolution(const int slot, const int elem_id, double *s)
Definition: CardinalEnums.h:92
unsigned int _n_usrwrk_slots
Definition: NekRSProblem.h:444
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:434
double(*)(int, int) solutionPointer(const field::NekFieldEnum &field)
Definition: NekInterface.h:720
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:569
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:65
void writeVolumeSolution(const int slot, const int elem_id, double *s, const std::vector< double > *add=nullptr)
double _tSolveStepMax
Maximum step solve time.
Definition: NekRSProblem.h:519
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:507
double _elapsedTime
Sum of the total elapsed time in NekRS solves.
Definition: NekRSProblem.h:513
void writeVolumeDisplacement(const int elem_id, double *s, const field::NekWriteEnum f, const std::vector< double > *add=nullptr)
Definition: CardinalProblem.h:26
int _n_points
Number of points for interpolated fields on the MOOSE mesh.
Definition: NekRSProblem.h:489
const unsigned int & _constant_interval
For constant synchronization intervals, the desired frequency (in units of Nek time steps)
Definition: NekRSProblem.h:447
double _elapsedStepSum
Sum of the elapsed time in NekRS solves.
Definition: NekRSProblem.h:510
void allgatherv(const std::vector< int > &base_counts, const T *input, T *output, const int multiplier=1)
Definition: NekInterface.h:929
static bool _first
flag to indicate whether this is the first pass to serialize the solution
Definition: NekRSProblem.h:563
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:501
int nBuildPerVolumeElem() const
Definition: NekRSMesh.h:77
unsigned int nUsrWrkSlots() const
Definition: NekRSProblem.h:129
bool isDataTransferHappening(ExternalProblem::Direction direction)
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:412
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:450
const std::vector< unsigned int > * _usrwrk_output
Slots in the nrs->o_usrwrk array to write to a field file.
Definition: NekRSProblem.h:504
int _n_volume_elems
Number of volume elements in the data transfer mesh, across all processes.
Definition: NekRSProblem.h:459
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:495
std::vector< std::vector< int > > cornerIndices() const
Definition: NekRSMesh.h:308
Definition: CardinalEnums.h:287
std::unique_ptr< NumericVector< Number > > _serialized_solution
Definition: NekRSProblem.h:402
double _tSolveStepMin
Minimum step solve time.
Definition: NekRSProblem.h:516
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:566
virtual void syncSolutions(ExternalProblem::Direction direction) override
const PostprocessorValue * _transfer_in
Postprocessor containing the signal of when a synchronization has occurred.
Definition: NekRSProblem.h:492
double _start_time
Start time of the simulation based on NekRS's .par file.
Definition: NekRSProblem.h:465
void interpolateVolumeHex3D(const double *I, double *x, int N, double *Ix, int M)
void interpolateBoundarySolutionToNek(double *incoming_moose_value, double *outgoing_nek_value)
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:572
std::string casename() const
Definition: NekRSProblem.h:319
virtual const bool hasMovingNekMesh() const
Definition: NekRSProblem.h:111
bool _needs_interpolation
Definition: NekRSProblem.h:486