An open source method of characteristics neutron transport code.
CPULSSolver.h
Go to the documentation of this file.
1 
9 #ifndef CPULSSOLVER_H_
10 #define CPULSSOLVER_H_
11 
12 #ifdef __cplusplus
13 #define _USE_MATH_DEFINES
14 #include "CPUSolver.h"
15 #include <math.h>
16 #include <omp.h>
17 #include <stdlib.h>
18 #endif
19 
20 
22 #define _scalar_flux_xyz(r,e,x) (_scalar_flux_xyz[(r)*_num_groups*3 + (x)*_num_groups + (e)])
23 
26 #define _reduced_sources_xyz(r,e,x) (_reduced_sources_xyz[(r)*_num_groups*3 + (x)*_num_groups + (e)])
27 
30 #define _stabilizing_flux_xyz(r,e,x) (_stabilizing_flux_xyz[(r)*_num_groups*3 + (e)*3 + (x)])
31 
33 #define _fixed_sources_xyz(r,e,i) (_fixed_sources_xyz[(r)*_num_groups + (e)][i])
34 
40 class CPULSSolver : public CPUSolver {
41 
42 protected:
43 
46 
48  FP_PRECISION* _FSR_source_constants;
49 
51  FP_PRECISION* _scalar_flux_xyz;
52 
54  FP_PRECISION* _reduced_sources_xyz;
55 
57  FP_PRECISION* _stabilizing_flux_xyz;
58 
60  std::vector<std::vector<double> > _fixed_sources_xyz;
61 
63  std::map< std::pair<int, int>, std::vector<double> > _fix_src_xyz_FSR_map;
64 
66  std::map< std::pair<Cell*, int>, std::vector<double> > _fix_src_xyz_cell_map;
67 
70 
73 
74 public:
75  CPULSSolver(TrackGenerator* track_generator=NULL);
76  virtual ~CPULSSolver();
77 
78  /* Initialization routines */
79  void initializeFluxArrays();
81  void initializeCmfd();
83  void initializeFSRs();
84 
85  /* Routines to handle fixed source moments */
87  void setFixedSourceMomentsByCell(Cell* cell, int group, double source_x,
88  double source_y, double source_z);
89  void setFixedSourceMomentByFSR(long fsr_id, int group, double source_x,
90  double source_y, double source_z);
91 
92  /* Worker routines */
93  void flattenFSRFluxes(FP_PRECISION value);
94  double normalizeFluxes();
95  void computeFSRSources(int iteration);
96  void tallyLSScalarFlux(segment* curr_segment, int azim_index,
97  int polar_index,
98  FP_PRECISION* fsr_flux,
99  FP_PRECISION* fsr_flux_x,
100  FP_PRECISION* fsr_flux_y,
101  FP_PRECISION* fsr_flux_z,
102  float* track_flux,
103  FP_PRECISION direction[3]);
104  void accumulateLinearFluxContribution(long fsr_id, FP_PRECISION weight,
105  FP_PRECISION* fsr_flux);
106  void addSourceToScalarFlux();
107 
108  /* Transport stabilization routines */
109  void computeStabilizingFlux();
110  void stabilizeFlux();
111  void checkLimitXS(int iteration);
112 
113  /* Routines to handle constant part of linear source */
116  FP_PRECISION* getSourceConstantsBuffer();
117 
118  /* Getter routine */
119  FP_PRECISION getFluxByCoords(LocalCoords* coords, int group);
120 };
121 
122 
123 #endif /* CPULSSOLVER_H_ */
This a subclass of the Solver class for multi-core CPUs using OpenMP multi-threading.
Definition: CPUSolver.h:54
FP_PRECISION getFluxByCoords(LocalCoords *coords, int group)
Get the flux at a specific point in the geometry.
Definition: CPULSSolver.cpp:1035
void checkLimitXS(int iteration)
Checks to see if limited XS should be reset.
Definition: CPULSSolver.cpp:1015
Represents a Cell inside of a Universe.
Definition: Cell.h:56
The LocalCoords represents a set of local coordinates on some level of nested Universes making up the...
Definition: LocalCoords.h:46
void tallyLSScalarFlux(segment *curr_segment, int azim_index, int polar_index, FP_PRECISION *fsr_flux, FP_PRECISION *fsr_flux_x, FP_PRECISION *fsr_flux_y, FP_PRECISION *fsr_flux_z, float *track_flux, FP_PRECISION direction[3])
Computes the contribution to the LSR scalar flux from a Track segment.
Definition: CPULSSolver.cpp:505
void setFixedSourceMomentByFSR(long fsr_id, int group, double source_x, double source_y, double source_z)
Assign fixed source moments for a FSR and energy group.
Definition: CPULSSolver.cpp:276
void stabilizeFlux()
Adjusts the scalar flux for transport stabilization.
Definition: CPULSSolver.cpp:925
The CPUSolver class.
void computeStabilizingFlux()
Computes the stabilizing flux for transport stabilization.
Definition: CPULSSolver.cpp:841
double normalizeFluxes()
Normalizes all FSR scalar fluxes and Track boundary angular fluxes to the total fission source (times...
Definition: CPULSSolver.cpp:325
void initializeCmfd()
Initializes a Cmfd object for acceleration prior to source iteration.
Definition: CPULSSolver.cpp:1089
void addSourceToScalarFlux()
Add the source term contribution in the transport equation to the FSR scalar flux.
Definition: CPULSSolver.cpp:744
The TrackGenerator is dedicated to generating and storing Tracks which cyclically wrap across the Geo...
Definition: TrackGenerator.h:36
CPULSSolver(TrackGenerator *track_generator=NULL)
Constructor initializes array pointers for fluxes and sources.
Definition: CPULSSolver.cpp:11
This a subclass of the CPUSolver class for using the linear source approximation. ...
Definition: CPULSSolver.h:40
void flattenFSRFluxes(FP_PRECISION value)
Set the scalar flux constants for each FSR and energy group to some value and the scalar flux moments...
Definition: CPULSSolver.cpp:306
void initializeFSRs()
Initializes the FSR constant linear source component, volumes and Materials array.
Definition: CPULSSolver.cpp:136
void initializeFixedSources()
Initializes the arrays for the fixed source and its moments.
Definition: CPULSSolver.cpp:154
void computeFSRSources(int iteration)
Computes the total source (fission, scattering, fixed) in each FSR.
Definition: CPULSSolver.cpp:349
FP_PRECISION * _FSR_source_constants
Definition: CPULSSolver.h:48
bool _stabilize_moments
Definition: CPULSSolver.h:69
A segment represents a line segment within a single flat source region along a track.
Definition: Track.h:27
double * _FSR_lin_exp_matrix
Definition: CPULSSolver.h:45
FP_PRECISION * getSourceConstantsBuffer()
Returns a memory buffer to the constant part (constant between MOC iterations) of the linear source...
Definition: CPULSSolver.cpp:1163
void accumulateLinearFluxContribution(long fsr_id, FP_PRECISION weight, FP_PRECISION *fsr_flux)
Move from buffers to global arrays the contributions of one (or several for per-stack solving) segmen...
Definition: CPULSSolver.cpp:710
virtual ~CPULSSolver()
Destructor deletes array for linear fluxes, sources and constants. CPUSolver parent class destructor ...
Definition: CPULSSolver.cpp:30
#define track_flux(p, e)
Definition: Cmfd.h:45
void initializeExpEvaluators()
Initializes new ExpEvaluator objects to compute exponentials.
Definition: CPULSSolver.cpp:1100
void setFixedSourceMomentsByCell(Cell *cell, int group, double source_x, double source_y, double source_z)
Assign fixed source moments for a Cell and energy group.
Definition: CPULSSolver.cpp:239
void initializeLinearSourceConstants()
Initialize linear source constant component and matrix coefficients.
Definition: CPULSSolver.cpp:1111
bool _fixed_source_moments_on
Definition: CPULSSolver.h:72
void initializeFluxArrays()
Allocates memory for boundary and scalar fluxes.
Definition: CPULSSolver.cpp:55
FP_PRECISION * _scalar_flux_xyz
Definition: CPULSSolver.h:51
std::map< std::pair< int, int >, std::vector< double > > _fix_src_xyz_FSR_map
Definition: CPULSSolver.h:63
FP_PRECISION * _reduced_sources_xyz
Definition: CPULSSolver.h:54
void initializeSourceArrays()
Allocates memory for FSR source arrays.
Definition: CPULSSolver.cpp:96
FP_PRECISION * _stabilizing_flux_xyz
Definition: CPULSSolver.h:57
std::map< std::pair< Cell *, int >, std::vector< double > > _fix_src_xyz_cell_map
Definition: CPULSSolver.h:66
std::vector< std::vector< double > > _fixed_sources_xyz
Definition: CPULSSolver.h:60
double * getLinearExpansionCoeffsBuffer()
Returns a memory buffer to the linear source expansion coefficent matrix.
Definition: CPULSSolver.cpp:1152