XGCa
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
diag_diffusion_profiles.hpp
Go to the documentation of this file.
1 
11 #ifndef DIAG_DIFFUSION_PROFILES_HPP
12 #define DIAG_DIFFUSION_PROFILES_HPP
13 
14 #include "globals.hpp"
15 #include "space_settings.hpp"
16 #include "sml.hpp"
17 #include "moments.hpp"
18 #include "diagnostic.hpp" // Base diagnostic class interface
19 
30  //bool is_on; //!< Flag to indicate if this diagnostic is active.
34  int n_species; //<! Number of species to buffer and write out
35  int n_surf; //<! Number of flux-surfaces to sample
36  int n_samples; //<! Number of sampled time slices
37  int sample_count; //<! Index of current sample (buffer position)
38 
39 public:
40  bool is_on;
41  View<double***,CLayout,HostType> profiles_buffer_n; //<! Buffer for the time evolution of the density profile
42  View<double***,CLayout,HostType> profiles_buffer_u; //<! Buffer for the time evolution of the parallel mean flow profile
43  View<double***,CLayout,HostType> profiles_buffer_T; //<! Buffer for the time evolution of the temperature profile
44  View<double*,CLayout,HostType> psi_grid;
45  View<double*,CLayout,HostType> time_buffer;
46  View<int*,CLayout,HostType> step_buffer;
47 
48  // Default constructor is mapped to the parent class
50 
51  /*
52  *
53  * This function initializes the diffusion profiles diagnostic by reading configuration options,
54  * setting up the internal state, allocating buffers for the profile data, and initializing the output trigger.
55  *
56  */
58  const Grid<DeviceType>& grid, const Plasma& plasma, int f_source_period);
59 
61  // * @brief Return whether the diffusion diagnostic is on
62  // *
63  // * @return Whether the diffusion diagnostic is on
64  // *
65  // */
66  //bool is_on() const {return is_on;}
72  int get_n_species() const {return n_species;}
78  int get_n_surf() const {return n_surf;}
84  int get_n_samples() const {return n_samples;}
85 
91  bool is_triggered_output(int step){
92  return step_trigger_output.is_triggered(step);
93  }
94 
95  /*
96  *
97  * This function collects a new sample of diffusion profile data from the simulation,
98  * averaging over toroidal and flux surfaces, and stores it in the internal buffers.
99  *
100  */
101  void collect_sample(const Simulation<DeviceType>& sml,
102  const Grid<DeviceType>& grid, Plasma& plasma,
103  const Moments& f0_moments,
104  const DomainDecomposition<DeviceType>& pol_decomp);
105 
106  /*
107  * This function writes the buffered diffusion profile data to disk or stream
108  * using the configured IO mechanism. The output is performed on the appropriate
109  * simulation step as determined by the output trigger.
110  */
111  void write();
112 
118  void reset_buffer(){
119  sample_count = 0;
120  Kokkos::deep_copy(profiles_buffer_n,0.0);
121  Kokkos::deep_copy(profiles_buffer_u,0.0);
122  Kokkos::deep_copy(profiles_buffer_T,0.0);
123  Kokkos::deep_copy(time_buffer,0.0);
124  Kokkos::deep_copy(step_buffer,0);
125  }
126 };
127 
128 #endif // DIAG_DIFFUSION_PROFILES_HPP
int output_rate
Rate (time steps) at which the collected data is written out.
Definition: diag_diffusion_profiles.hpp:31
bool is_on
Flag to indicate if this diagnostic is active.
Definition: diag_diffusion_profiles.hpp:40
View< double *, CLayout, HostType > time_buffer
Time (in s) of each sample.
Definition: diag_diffusion_profiles.hpp:45
View< double ***, CLayout, HostType > profiles_buffer_u
Definition: diag_diffusion_profiles.hpp:42
void collect_sample(const Simulation< DeviceType > &sml, const Grid< DeviceType > &grid, Plasma &plasma, const Moments &f0_moments, const DomainDecomposition< DeviceType > &pol_decomp)
Collect a sample of diffusion profile data.
Definition: diag_diffusion_profiles.cpp:102
int n_species
Definition: diag_diffusion_profiles.hpp:34
int n_samples
Definition: diag_diffusion_profiles.hpp:36
Definition: sml.hpp:8
void write()
Write the buffered diffusion profile data to disk.
Definition: diag_diffusion_profiles.cpp:181
View< double ***, CLayout, HostType > profiles_buffer_T
Definition: diag_diffusion_profiles.hpp:43
subroutine plasma(grid, itr, p, dene_out, deni_out, Te_out, Ti_out, Vparai_out)
Calculate the plasma density, temperature, and parallel velocity for a point in triangle itr using pl...
Definition: neutral_totalf.F90:1248
Definition: NamelistReader.hpp:193
DiffusionProfilesDiag()
Definition: diag_diffusion_profiles.hpp:49
Definition: moments.hpp:9
int sampling_rate
Rate (multiples of sml_f_source_period) at which the profile data is sampled.
Definition: diag_diffusion_profiles.hpp:32
void reset_buffer()
Reset the profile data buffer.
Definition: diag_diffusion_profiles.hpp:118
View< double ***, CLayout, HostType > profiles_buffer_n
Definition: diag_diffusion_profiles.hpp:41
int sample_count
Definition: diag_diffusion_profiles.hpp:37
int get_n_species() const
Return whether the diffusion diagnostic is on.
Definition: diag_diffusion_profiles.hpp:72
int n_surf
Definition: diag_diffusion_profiles.hpp:35
bool is_triggered(int step) const
Definition: step_trigger.hpp:25
int get_n_samples() const
Get the number of samples taken.
Definition: diag_diffusion_profiles.hpp:84
View< int *, CLayout, HostType > step_buffer
Time step index of each sample.
Definition: diag_diffusion_profiles.hpp:46
int get_n_surf() const
Get the number of flux-surfaces sampled.
Definition: diag_diffusion_profiles.hpp:78
void init(NLReader::NamelistReader &nlr, const Simulation< DeviceType > &sml, const Grid< DeviceType > &grid, const Plasma &plasma, int f_source_period)
Initialize the DiffusionProfilesDiag diagnostic.
Definition: diag_diffusion_profiles.cpp:33
Diagnostic for writing diffusion profile data using ADIOS2.
Definition: diag_diffusion_profiles.hpp:29
View< double *, CLayout, HostType > psi_grid
Poloidal flux grid of the sampled profile data.
Definition: diag_diffusion_profiles.hpp:44
StepTrigger step_trigger_output
Trigger for writing the diagnostic output. (The default trigger is used for the data sampling step...
Definition: diag_diffusion_profiles.hpp:33
Definition: plasma.hpp:13
Definition: diagnostic.hpp:10
Definition: step_trigger.hpp:4
bool is_triggered_output(int step)
Returns whether the buffer should be written out on this step.
Definition: diag_diffusion_profiles.hpp:91