An open source method of characteristics neutron transport code.
MOCKernel.h
Go to the documentation of this file.
1 
8 #ifndef MOCKERNEL_H_
9 #define MOCKERNEL_H_
10 
11 #ifdef SWIG
12 #include "Python.h"
13 #endif
14 #include "Track.h"
15 #include "Track3D.h"
16 #include "Geometry.h"
17 #include "Quadrature.h"
18 
19 
20 /* Forward declaration of TrackGenerator */
21 class TrackGenerator;
22 
23 /* Forward declaration of CPUSolver */
24 class CPUSolver;
25 
41 class MOCKernel {
42 
43 protected:
44 
46  int _count;
47 
49  FP_PRECISION _max_tau;
50 
53 
54 public:
55 
56  MOCKernel(TrackGenerator* track_generator);
57  virtual ~MOCKernel();
58 
59  /* Function to get the current segment count */
60  int getCount();
61 
62  /* Sets the max optical path length to a different value */
63  void setMaxOpticalLength(FP_PRECISION max_tau);
64 
65  /* Prepare MOCKernel for handling a new track */
66  virtual void newTrack(Track* track);
67 
68  /* Executing function describes kernel behavior */
69  virtual void execute(FP_PRECISION length, Material* mat, long fsr_id,
70  int track_idx, int cmfd_surface_fwd,
71  int cmfd_surface_bwd, FP_PRECISION x_start, FP_PRECISION y_start,
72  FP_PRECISION z_start, FP_PRECISION phi, FP_PRECISION theta)=0;
73 
74 };
75 
76 
85 class CounterKernel: public MOCKernel {
86 
87 public:
88  CounterKernel(TrackGenerator* track_generator);
89  void execute(FP_PRECISION length, Material* mat, long fsr_id,
90  int track_idx, int cmfd_surface_fwd, int cmfd_surface_bwd,
91  FP_PRECISION x_start, FP_PRECISION y_start, FP_PRECISION z_start,
92  FP_PRECISION phi, FP_PRECISION theta);
93 };
94 
95 
105 class VolumeKernel: public MOCKernel {
106 
107 private:
108 
110  omp_lock_t* _FSR_locks;
111 
113  FP_PRECISION* _FSR_volumes;
114 
116  FP_PRECISION _weight;
117 
119  Quadrature* _quadrature;
120 
121 public:
122 
123  VolumeKernel(TrackGenerator* track_generator);
124  void newTrack(Track* track);
125  void execute(FP_PRECISION length, Material* mat, long fsr_id,
126  int track_idx, int cmfd_surface_fwd, int cmfd_surface_bwd,
127  FP_PRECISION x_start, FP_PRECISION y_start, FP_PRECISION z_start,
128  FP_PRECISION phi, FP_PRECISION theta);
129 };
130 
131 
141 
142 private:
143 
145  segment* _segments;
146 
147 public:
148  SegmentationKernel(TrackGenerator* track_generator);
149  void execute(FP_PRECISION length, Material* mat, long fsr_id,
150  int track_idx, int cmfd_surface_fwd, int cmfd_surface_bwd,
151  FP_PRECISION x_start, FP_PRECISION y_start, FP_PRECISION z_start,
152  FP_PRECISION phi, FP_PRECISION theta);
153 };
154 
162 class TransportKernel: public MOCKernel {
163 private:
164 
166  CPUSolver* _cpu_solver;
167 
169  TrackGenerator* _track_generator;
170 
172  FP_PRECISION* _thread_fsr_flux;
173 
175  int _azim_index;
176 
178  int _xy_index;
179 
181  int _polar_index;
182 
184  int _track_id;
185 
187  bool _direction;
188 
189  int _min_track_idx;
190  int _max_track_idx;
191 
192 public:
193  TransportKernel(TrackGenerator* track_generator);
194  virtual ~TransportKernel();
195  void newTrack(Track* track);
196  void setCPUSolver(CPUSolver* cpu_solver);
197  void setTrackFlux(FP_PRECISION* fwd_flux, FP_PRECISION* bwd_flux,
198  int track_id);
199  void setTrackIndexes(int azim_index, int polar_index);
200  void setDirection(bool direction);
201  bool getDirection();
202  void execute(FP_PRECISION length, Material* mat, long fsr_id,
203  int track_idx, int cmfd_surface_fwd, int cmfd_surface_bwd,
204  FP_PRECISION x_start, FP_PRECISION y_start, FP_PRECISION z_start,
205  FP_PRECISION phi, FP_PRECISION theta);
206  void post();
207 };
208 
209 
210 #endif /* MOCKERNEL_H_ */
This a subclass of the Solver class for multi-core CPUs using OpenMP multi-threading.
Definition: CPUSolver.h:54
VolumeKernel(TrackGenerator *track_generator)
Constructor for the VolumeKernel assigns default values, calls the MOCKernel constructor, and pulls references to FSR locks and FSR volumes from the provided TrackGenerator.
Definition: MOCKernel.cpp:26
void execute(FP_PRECISION length, Material *mat, long fsr_id, int track_idx, int cmfd_surface_fwd, int cmfd_surface_bwd, FP_PRECISION x_start, FP_PRECISION y_start, FP_PRECISION z_start, FP_PRECISION phi, FP_PRECISION theta)
Apply MOC equations, tally fluxes and tally CMFD currents.
Definition: MOCKernel.cpp:353
MOCKernel(TrackGenerator *track_generator)
Constructor for the MOCKernel assigns default values.
Definition: MOCKernel.cpp:10
int _count
Definition: MOCKernel.h:46
int _num_groups
Definition: MOCKernel.h:52
The TrackGenerator is dedicated to generating and storing Tracks which cyclically wrap across the Geo...
Definition: TrackGenerator.h:36
virtual void newTrack(Track *track)
Prepares an MOCKernel for a new Track.
Definition: MOCKernel.cpp:76
void setCPUSolver(CPUSolver *cpu_solver)
Sets a pointer to the CPUSolver to enable use of transport functions.
Definition: MOCKernel.cpp:300
int getCount()
Reads and returns the current count.
Definition: MOCKernel.cpp:119
The arbitrary quadrature parent class.
Definition: Quadrature.h:76
void newTrack(Track *track)
Create a new track3D from an existing one.
Definition: MOCKernel.cpp:309
Calculates the volume in FSRs by adding weighted segment lengths.
Definition: MOCKernel.h:105
A segment represents a line segment within a single flat source region along a track.
Definition: Track.h:27
The 3D Track class.
An MOCKernel object specifies a functionality to apply to MOC segments.
Definition: MOCKernel.h:41
void post()
Obtain and transfer the boundary track angular fluxes.
Definition: MOCKernel.cpp:422
FP_PRECISION _max_tau
Definition: MOCKernel.h:49
bool getDirection()
Returns the direction of the current track.
Definition: MOCKernel.cpp:332
Applies transport equations to segment data.
Definition: MOCKernel.h:162
void execute(FP_PRECISION length, Material *mat, long fsr_id, int track_idx, int cmfd_surface_fwd, int cmfd_surface_bwd, FP_PRECISION x_start, FP_PRECISION y_start, FP_PRECISION z_start, FP_PRECISION phi, FP_PRECISION theta)
Increments the counter for the number of segments on the track.
Definition: MOCKernel.cpp:176
void execute(FP_PRECISION length, Material *mat, long fsr_id, int track_idx, int cmfd_surface_fwd, int cmfd_surface_bwd, FP_PRECISION x_start, FP_PRECISION y_start, FP_PRECISION z_start, FP_PRECISION phi, FP_PRECISION theta)
Adds segment contribution to the FSR volume.
Definition: MOCKernel.cpp:145
TransportKernel(TrackGenerator *track_generator)
Constructor for the TransportKernel.
Definition: MOCKernel.cpp:276
void execute(FP_PRECISION length, Material *mat, long fsr_id, int track_idx, int cmfd_surface_fwd, int cmfd_surface_bwd, FP_PRECISION x_start, FP_PRECISION y_start, FP_PRECISION z_start, FP_PRECISION phi, FP_PRECISION theta)
Writes segment information to the segmentation data array.
Definition: MOCKernel.cpp:216
The Material class represents a unique material and its relevant nuclear data (i.e., multigroup cross-sections) for neutron transport.
Definition: Material.h:51
Forms segment data associated with a 3D track.
Definition: MOCKernel.h:140
The Quadrature abstract class and subclasses.
void setDirection(bool direction)
Sets the direction of the current track.
Definition: MOCKernel.cpp:323
SegmentationKernel(TrackGenerator *track_generator)
Constructor for the SegmentationKernel assigns default values, calls the MOCKernel constructor...
Definition: MOCKernel.cpp:48
virtual ~MOCKernel()
Destructor for MOCKernel.
Definition: MOCKernel.cpp:109
void setMaxOpticalLength(FP_PRECISION max_tau)
Resets the maximum optcal path length for a segment.
Definition: MOCKernel.cpp:131
virtual ~TransportKernel()
Destructor for the TransportKernel.
Definition: MOCKernel.cpp:292
The generic Track class.
Counts the number of segments of a track.
Definition: MOCKernel.h:85
A Track represents a characteristic line across the geometry.
Definition: Track.h:67
void newTrack(Track *track)
Prepares a VolumeKernel for a new Track.
Definition: MOCKernel.cpp:86
CounterKernel(TrackGenerator *track_generator)
Constructor for the CounterKernel assigns default values and calls the MOCKernel constructor.
Definition: MOCKernel.cpp:67
The Geometry class.