An open source method of characteristics neutron transport code.
Cmfd.h
Go to the documentation of this file.
1 
8 #ifndef CMFD_H_
9 #define CMFD_H_
10 
11 #ifdef __cplusplus
12 #define _USE_MATH_DEFINES
13 #ifdef SWIG
14 #include "Python.h"
15 #endif
16 #include "log.h"
17 #include "constants.h"
18 #include "Universe.h"
19 #include "Track.h"
20 #include "Track3D.h"
21 #include "Quadrature.h"
22 #include "linalg.h"
23 #include "Geometry.h"
24 #include "Timer.h"
25 #endif
26 
28 #ifdef THREED
29 #define _SOLVE_3D (true)
30 #endif
31 
33 class Geometry;
34 
36 inline bool stencilCompare(const std::pair<int, double>& firstElem,
37  const std::pair<int, double>& secondElem) {
38  return firstElem.second < secondElem.second;
39 }
40 
41 #undef track_flux
42 
45 #define track_flux(p,e) (track_flux[(p)*_num_moc_groups + (e)]
46 
51 class Cmfd {
52 
53 private:
54 
56  Quadrature* _quadrature;
57 
59  Geometry* _geometry;
60 
62  double _k_eff;
63 
65  Matrix* _A;
66 
68  Matrix* _M;
69 
71  Vector* _old_source;
72 
74  Vector* _new_source;
75 
76  /* Domain boundary communication buffers */
77  CMFD_PRECISION*** _boundary_volumes;
78  CMFD_PRECISION*** _boundary_reaction;
79  CMFD_PRECISION*** _boundary_diffusion;
80  CMFD_PRECISION*** _old_boundary_flux;
81  CMFD_PRECISION*** _boundary_surface_currents;
82 
83  CMFD_PRECISION*** _send_volumes;
84  CMFD_PRECISION*** _send_reaction;
85  CMFD_PRECISION*** _send_diffusion;
86  CMFD_PRECISION*** _send_currents;
87 
88  CMFD_PRECISION* _send_split_current_data;
89  CMFD_PRECISION* _receive_split_current_data;
90  CMFD_PRECISION** _send_split_currents_array;
91  CMFD_PRECISION** _receive_split_currents_array;
92  CMFD_PRECISION*** _off_domain_split_currents;
93  CMFD_PRECISION*** _received_split_currents;
94 
97  Vector* _new_flux;
98 
101  Vector* _old_flux;
102 
104  Vector* _old_dif_surf_corr;
105 
107  bool _old_dif_surf_valid;
108 
110  double _SOR_factor;
111 
113  double _source_convergence_threshold;
114 
116  int _num_x;
117 
119  int _num_y;
120 
122  int _num_z;
123 
125  int _num_moc_groups;
126 
128  int _num_polar;
129 
131  int _num_azim;
132 
135  int _num_cmfd_groups;
136 
138  int* _group_indices;
139 
141  int* _group_indices_map;
142 
144  int _num_backup_groups;
145 
147  std::vector< std::vector<int> > _backup_group_structure;
148 
150  int* _cmfd_group_to_backup_group;
151 
153  bool _user_group_indices;
154 
156  bool _linear_source;
157 
159  bool _flux_limiting;
160 
163  bool _balance_sigma_t;
164 
166  long _num_FSRs;
167 
169  FP_PRECISION* _FSR_volumes;
170 
172  Material** _FSR_materials;
173 
175  FP_PRECISION* _FSR_fluxes;
176 
178  FP_PRECISION* _FSR_sources;
179 
181  FP_PRECISION* _flux_moments;
182 
184  Vector* _volumes;
185 
187  Material** _materials;
188 
190  double _width_x;
191  double _width_y;
192  double _width_z;
193  double _cell_width_x;
194  double _cell_width_y;
195  double _cell_width_z;
196 
198  std::vector<double> _cell_widths_x;
199  std::vector<double> _cell_widths_y;
200  std::vector<double> _cell_widths_z;
201 
203  std::vector<double> _accumulate_x;
204  std::vector<double> _accumulate_y;
205  std::vector<double> _accumulate_z;
206 
208  bool _non_uniform;
209 
211  bool _widths_adjusted_for_domains;
212 
214  boundaryType* _boundaries;
215 
217  Vector* _surface_currents;
218 
220  Vector* _starting_currents;
221 
223  Vector* _net_currents;
224 
227  Vector* _full_surface_currents;
228 
230  std::map<int, CMFD_PRECISION> _edge_corner_currents;
231 
233  std::vector< std::vector<long> > _cell_fsrs;
234 
236  Lattice* _lattice;
237 
239  bool _flux_update_on;
240 
242  bool _centroid_update_on;
243 
245  bool _check_neutron_balance;
246 
248  bool _negative_fluxes_allowed;
249 
251  int _k_nearest;
252 
254  double _relaxation_factor;
255 
257  std::map<long, std::vector< std::pair<int, double> > >
258  _k_nearest_stencils;
259 
261  omp_lock_t* _cell_locks;
262 
264  omp_lock_t _edge_corner_lock;
265 
266 #ifndef THREED
267 
268  bool _SOLVE_3D;
269 #endif
270 
272  double* _azim_spacings;
273 
275  double** _polar_spacings;
276 
278  int _use_axial_interpolation;
279 
281  std::vector<double*> _axial_interpolants;
282 
283  /* Structure to contain information about the convergence of the CMFD */
284  ConvergenceData* _convergence_data;
285 
286  /* MPI communicator to transfer buffers, mainly currents at interfaces */
287  DomainCommunicator* _domain_communicator;
288 
289  /* Buffer to contain received data */
290  CMFD_PRECISION* _inter_domain_data;
291 
292  /* Buffer to contain sent data from domain */
293  CMFD_PRECISION* _send_domain_data;
294 
295  /* For each face (1st dimension of the array), will contain data received */
296  CMFD_PRECISION** _domain_data_by_surface;
297 
298  /* For each face (1st dimension of the array), will contain data to send */
299  CMFD_PRECISION** _send_data_by_surface;
300 
301  /* Map of the indexes to each boundary in the tally arrays */
302  std::vector<std::map<int, int> > _boundary_index_map;
303 
304  /* The number of on-domain cells in the x-direction */
305  int _local_num_x;
306 
307  /* The number of on-domain cells in the y-direction */
308  int _local_num_y;
309 
310  /* The number of on-domain cells in the z-direction */
311  int _local_num_z;
312 
313  std::vector<int> _accumulate_lmx;
314  std::vector<int> _accumulate_lmy;
315  std::vector<int> _accumulate_lmz;
316 
317  /* Size of _tally_memory array */
318  long _total_tally_size;
319 
320  /* 1D array that contains all tallies (diffusion, reaction and volume) */
321  CMFD_PRECISION* _tally_memory;
322 
323  /* 2D array that contains reaction rates in each cell and group */
324  CMFD_PRECISION** _reaction_tally;
325 
326  /* 2D array that contains volume tallies of each cell */
327  CMFD_PRECISION** _volume_tally;
328 
329  /* 2D array that contains diffusion tallies for each cell and groups */
330  CMFD_PRECISION** _diffusion_tally;
331 
332  /* Boolean to check if tallies are allocated */
333  bool _tallies_allocated;
334 
335  /* Boolean to check if the domain communicator (for domain decomposed CMFD)
336  * has been allocated */
337  bool _domain_communicator_allocated;
338 
340  Timer* _timer;
341 
343  Cmfd* _backup_cmfd;
344 
345  /* Private worker functions */
346  CMFD_PRECISION computeLarsensEDCFactor(CMFD_PRECISION dif_coef,
347  CMFD_PRECISION delta);
348  void constructMatrices(int moc_iteration);
349  void collapseXS();
350  void updateMOCFlux();
351  void rescaleFlux();
352  void splitVertexCurrents();
353  void splitEdgeCurrents();
354  void getVertexSplitSurfaces(int cell, int vertex, std::vector<int>* surfaces);
355  void getEdgeSplitSurfaces(int cell, int edge, std::vector<int>* surfaces);
356  void initializeMaterials();
357  void initializeCurrents();
358  void generateKNearestStencils();
359  int convertDirectionToSurface(int* direction);
360  void convertSurfaceToDirection(int surface, int* direction);
361  std::string getSurfaceNameFromDirection(int* direction);
362  std::string getSurfaceNameFromSurface(int surface);
363 
364  /* Private getter functions */
365  int getCellNext(int cell_id, int surface_id, bool global=true,
366  bool neighbor=false);
367  int getCellByStencil(int cell_id, int stencil_id);
368  CMFD_PRECISION getFluxRatio(int cell_id, int group, long fsr);
369  CMFD_PRECISION getUpdateRatio(int cell_id, int moc_group, long fsr);
370  double getDistanceToCentroid(Point* centroid, int cell_id, int local_cell_id,
371  int stencil_index);
372  void getSurfaceDiffusionCoefficient(int cmfd_cell, int surface,
373  int group, int moc_iteration, CMFD_PRECISION& dif_surf,
374  CMFD_PRECISION& dif_surf_corr);
375  CMFD_PRECISION getDiffusionCoefficient(int cmfd_cell, int group);
376  CMFD_PRECISION getSurfaceWidth(int surface, int global_ind);
377  CMFD_PRECISION getPerpendicularSurfaceWidth(int surface, int global_ind);
378  int getSense(int surface);
379  int getLocalCMFDCell(int cmfd_cell); //TODO: optimize, document
380  int getGlobalCMFDCell(int cmfd_cell); //TODO: optimize, document
381  int getCellColor(int cmfd_cell); //TODO: optimize, document
382  void packBuffers();
383 #ifdef MPIx
384  void ghostCellExchange();
385  void communicateSplits(bool faces);
386 #endif
387  void unpackSplitCurrents(bool faces);
388  void copyFullSurfaceCurrents();
389  void checkNeutronBalance(bool pre_split=true, bool old_source=false);
390  void printProlongationFactors(int iteration);
391 
392 public:
393 
394  Cmfd();
395  virtual ~Cmfd();
396 
397  /* Worker functions */
398  double computeKeff(int moc_iteration);
399  void initialize();
400  void initializeCellMap();
401  void initializeGroupMap();
402  void allocateTallies();
403  void initializeLattice(Point* offset, bool is_2D=false);
405  void copyCurrentsToBackup();
406  int findCmfdCell(LocalCoords* coords);
407  int findCmfdSurface(int cell_id, LocalCoords* coords);
408  int findCmfdSurfaceOTF(int cell_id, double z, int surface_2D);
409  void addFSRToCell(int cell_id, long fsr_id);
410  void zeroCurrents();
411  void tallyCurrent(segment* curr_segment, float* track_flux,
412  int azim_index, int polar_index, bool fwd);
413  void tallyStartingCurrent(Point* point, double delta_x, double delta_y,
414  double delta_z, float* track_flux, double weight);
415  void recordNetCurrents();
417  void printTimerReport();
418  void checkBalance();
419 
420  /* Get parameters */
421  int getNumCmfdGroups();
422  int getNumMOCGroups();
423  int getNumCells();
424  int getCmfdGroup(int group);
425  int getBoundary(int side);
426  Lattice* getLattice();
427  int getNumX();
428  int getNumY();
429  int getNumZ();
431  CMFD_PRECISION*** getBoundarySurfaceCurrents();
432  int convertFSRIdToCmfdCell(long fsr_id);
433  int convertGlobalFSRIdToCmfdCell(long global_fsr_id);
434  std::vector< std::vector<long> >* getCellFSRs();
435  bool isFluxUpdateOn();
436  bool isCentroidUpdateOn();
437  bool isSigmaTRebalanceOn();
438 
439  /* Set parameters */
440  void setSORRelaxationFactor(double SOR_factor);
441  void setCMFDRelaxationFactor(double relaxation_factor);
442  void setGeometry(Geometry* geometry);
443  void setWidthX(double width);
444  void setWidthY(double width);
445  void setWidthZ(double width);
446  void setNumX(int num_x);
447  void setNumY(int num_y);
448  void setNumZ(int num_z);
449  void setNumFSRs(long num_fsrs);
450  void setNumMOCGroups(int num_moc_groups);
451  void setBoundary(int side, boundaryType boundary);
452  void setLatticeStructure(int num_x, int num_y, int num_z=1);
453  void setFluxUpdateOn(bool flux_update_on);
454  void setCentroidUpdateOn(bool centroid_update_on);
455  void setGroupStructure(std::vector< std::vector<int> > group_indices);
456  void setSourceConvergenceThreshold(double source_thresh);
457  void setQuadrature(Quadrature* quadrature);
458  void setKNearest(int k_nearest);
459  void setSolve3D(bool solve_3d);
460  void setAzimSpacings(const std::vector<double>& azim_spacings,
461  int num_azim);
462  void setPolarSpacings(const std::vector< std::vector<double> >&
463  polar_spacings, int num_azim, int num_polar);
464  void setKeff(double k_eff);
465  void setBackupGroupStructure(std::vector< std::vector<int> > group_indices);
466 
467 #ifdef MPIx
468  void setNumDomains(int num_x, int num_y, int num_z);
469  void setDomainIndexes(int idx_x, int idx_y, int idx_z);
470 #endif
471  void setConvergenceData(ConvergenceData* convergence_data);
472  void useAxialInterpolation(int interpolate);
473 
474  /* Methods to try to fix stability issues */
475  void useFluxLimiting(bool flux_limiting);
476  void enforceBalanceOnDiagonal(int cmfd_cell, int group);
477  void rebalanceSigmaT(bool balance_sigma_t);
478 
479  /* Set FSR parameters */
480  void setFSRMaterials(Material** FSR_materials);
481  void setFSRVolumes(FP_PRECISION* FSR_volumes);
482  void setFSRFluxes(FP_PRECISION* scalar_flux);
483  void setFSRSources(FP_PRECISION* sources);
484  void setCellFSRs(std::vector< std::vector<long> >* cell_fsrs);
485  void setFluxMoments(FP_PRECISION* flux_moments);
486 
487  /* Set XYZ widths of non-uniform meshes */
488  void setWidths(std::vector< std::vector<double> > widths);
489 
490  /* For debug use */
491  void printCmfdCellSizes();
492 };
493 
494 
500 inline int Cmfd::getCmfdGroup(int group) {
501  return _group_indices_map[group];
502 }
503 
504 
516 inline int Cmfd::findCmfdSurfaceOTF(int cell_id, double z, int surface_2D) {
517  int global_cell_id = getGlobalCMFDCell(cell_id);
518  return _lattice->getLatticeSurfaceOTF(global_cell_id, z, surface_2D);
519 }
520 
521 
527 inline int Cmfd::getGlobalCMFDCell(int cmfd_cell) {
528 
529  int x_start = 0;
530  int y_start = 0;
531  int z_start = 0;
532  if (_domain_communicator != NULL) {
533  x_start = _accumulate_lmx[_domain_communicator->_domain_idx_x];
534  y_start = _accumulate_lmy[_domain_communicator->_domain_idx_y];
535  z_start = _accumulate_lmz[_domain_communicator->_domain_idx_z];
536  }
537 
538  int ix = cmfd_cell % _local_num_x;
539  int iy = (cmfd_cell % (_local_num_x * _local_num_y)) / _local_num_x;
540  int iz = cmfd_cell / (_local_num_x * _local_num_y);
541 
542  return ((iz + z_start) * _num_y + iy + y_start) * _num_x
543  + ix + x_start;
544 }
545 
546 
556 inline void Cmfd::tallyCurrent(segment* curr_segment, float* track_flux,
557  int azim_index, int polar_index, bool fwd) {
558 
559  int surf_id, cell_id, cmfd_group;
560  int ncg = _num_cmfd_groups;
561 
562  /* Check if the current needs to be tallied */
563  bool tally_current = false;
564  if (curr_segment->_cmfd_surface_fwd != -1 && fwd) {
565  surf_id = curr_segment->_cmfd_surface_fwd % NUM_SURFACES;
566  cell_id = curr_segment->_cmfd_surface_fwd / NUM_SURFACES;
567  tally_current = true;
568  }
569  else if (curr_segment->_cmfd_surface_bwd != -1 && !fwd) {
570  surf_id = curr_segment->_cmfd_surface_bwd % NUM_SURFACES;
571  cell_id = curr_segment->_cmfd_surface_bwd / NUM_SURFACES;
572  tally_current = true;
573  }
574 
575  /* Tally current if necessary */
576  if (tally_current) {
577 
578  CMFD_PRECISION currents[_num_cmfd_groups]
579  __attribute__ ((aligned(VEC_ALIGNMENT)));
580  memset(&currents[0], 0, _num_cmfd_groups * sizeof(CMFD_PRECISION));
581  int local_cell_id = getLocalCMFDCell(cell_id);
582 
583  if (_SOLVE_3D) {
584  double wgt = _quadrature->getWeightInline(azim_index, polar_index);
585  for (int e=0; e < _num_moc_groups; e++) {
586 
587  /* Get the CMFD group */
588  cmfd_group = getCmfdGroup(e);
589 
590  /* Increment the surface group current */
591  currents[cmfd_group] += track_flux[e];
592  }
593 
594 #pragma omp simd aligned(currents)
595  for (int g=0; g < ncg; g++)
596  currents[g] *= wgt;
597 
598  /* Increment currents on faces */
599  if (surf_id < NUM_FACES) {
600  _surface_currents->incrementValues
601  (local_cell_id, surf_id*ncg, (surf_id+1)*ncg - 1, currents);
602  }
603  /* Increment currents on corners and edges */
604  else {
605 
606  int first_ind = (local_cell_id * NUM_SURFACES + surf_id) * ncg;
607  omp_set_lock(&_edge_corner_lock);
608 
609 #pragma omp simd aligned(currents)
610  for (int g=0; g < ncg; g++)
611  _edge_corner_currents[first_ind+g] += currents[g];
612 
613  omp_unset_lock(&_edge_corner_lock);
614  }
615  }
616  else {
617  int pe = 0;
618  for (int p=0; p < _num_polar/2; p++) {
619  for (int e=0; e < _num_moc_groups; e++) {
620 
621  /* Get the CMFD group */
622  cmfd_group = getCmfdGroup(e);
623 
624  currents[cmfd_group] += track_flux[pe]
625  * _quadrature->getWeightInline(azim_index, p);
626  pe++;
627  }
628  }
629 
630  /* Increment currents on face */
631  if (surf_id < NUM_FACES) {
632  _surface_currents->incrementValues
633  (local_cell_id, surf_id*ncg, (surf_id+1)*ncg - 1, currents);
634  }
635  else {
636  omp_set_lock(&_edge_corner_lock);
637 
638  int first_ind = (local_cell_id * NUM_SURFACES + surf_id) * ncg;
639 
640  /* Add contribution to corner current */
641 #pragma omp simd aligned(currents)
642  for (int g=0; g < ncg; g++)
643  _edge_corner_currents[first_ind+g] += currents[g];
644 
645  omp_unset_lock(&_edge_corner_lock);
646 
647  }
648  }
649  }
650 }
651 #endif /* CMFD_H_ */
void setFluxMoments(FP_PRECISION *flux_moments)
Set pointer to source region flux moments array.
Definition: Cmfd.cpp:1620
int _cmfd_surface_fwd
Definition: Track.h:42
int surface_id()
Returns an auto-generated unique surface ID.
Definition: Surface.cpp:16
int findCmfdCell(LocalCoords *coords)
Find the CMFD cell that a LocalCoords object is in.
Definition: Cmfd.cpp:1926
void recordNetCurrents()
Records net currents (leakage) on every CMFD cell for every group.
Definition: Cmfd.cpp:5376
bool isSigmaTRebalanceOn()
Returns a flag indicating whether the sigma-t rebalance is on.
Definition: Cmfd.cpp:2731
#define NUM_FACES
Definition: constants.h:116
void setFSRFluxes(FP_PRECISION *scalar_flux)
Set pointer to FSR flux array.
Definition: Cmfd.cpp:1602
The LocalCoords represents a set of local coordinates on some level of nested Universes making up the...
Definition: LocalCoords.h:46
void setQuadrature(Quadrature *quadrature)
Sets the Quadrature object in use by the MOC Solver.
Definition: Cmfd.cpp:2784
int cell_id()
Returns an auto-generated unique Cell ID.
Definition: Cell.cpp:20
int convertGlobalFSRIdToCmfdCell(long global_fsr_id)
Return the CMFD cell ID that a FSR lies in.
Definition: Cmfd.cpp:2558
void setCMFDRelaxationFactor(double relaxation_factor)
Set the CMFD relaxation factor applied to diffusion coefficients.
Definition: Cmfd.cpp:1644
int getNumCells()
Get the number of CMFD cells.
Definition: Cmfd.cpp:1996
void printInputParamsSummary()
A function that prints a summary of the CMFD input parameters.
Definition: Cmfd.cpp:4234
bool isCentroidUpdateOn()
Get flag indicating whether to use FSR centroids to update the MOC flux.
Definition: Cmfd.cpp:2761
void setKeff(double k_eff)
Set the value of the k effective for the CMFD solver. This is meant for research / debugging purposes...
Definition: Cmfd.cpp:4177
void setBackupGroupStructure(std::vector< std::vector< int > > group_indices)
Set the backup CMFD solver&#39;s group structure. It is necessarily coarser than and must align with the ...
Definition: Cmfd.cpp:4187
void setNumY(int num_y)
Set the number of Mesh cells in a column.
Definition: Cmfd.cpp:277
void setFSRSources(FP_PRECISION *sources)
Set pointer to FSR source array.
Definition: Cmfd.cpp:1611
Definition: Vector.h:27
void setNumX(int num_x)
Set the number of Mesh cells in a row.
Definition: Cmfd.cpp:258
double getWeightInline(size_t azim, size_t polar) const
Returns the total weight for Tracks with the given azimuthal and polar indexes without error checking...
Definition: Quadrature.h:313
boundaryType
The types of boundary conditions supported by OpenMOC for Surfaces.
Definition: boundary_type.h:15
Math constants and comparision tolerances.
bool isFluxUpdateOn()
Get flag indicating whether to update the MOC flux.
Definition: Cmfd.cpp:2740
void useAxialInterpolation(int interpolate)
Set the flag indicating whether to use quadratic axial interpolation for update ratios.
Definition: Cmfd.cpp:2643
void setKNearest(int k_nearest)
Set a number of k-nearest neighbor cells to use in updating the FSR flux.
Definition: Cmfd.cpp:3326
Verbose iteration information for the CMFD eigenvalue solver.
Definition: linalg.h:31
int getNumMOCGroups()
Get the number of MOC energy groups.
Definition: Cmfd.cpp:1987
virtual ~Cmfd()
Destructor deletes arrays of A and M row insertion arrays.
Definition: Cmfd.cpp:107
void setNumZ(int num_z)
Set the number of Mesh cells in the z-direction.
Definition: Cmfd.cpp:296
void tallyCurrent(segment *curr_segment, float *track_flux, int azim_index, int polar_index, bool fwd)
Tallies the current contribution from this segment across the the appropriate CMFD mesh cell surface...
Definition: Cmfd.h:556
void setGeometry(Geometry *geometry)
Set a pointer to the Geometry.
Definition: Cmfd.cpp:3316
void useFluxLimiting(bool flux_limiting)
Turns on the flux limiting condition.
Definition: Cmfd.cpp:2664
void setAzimSpacings(const std::vector< double > &azim_spacings, int num_azim)
Sets the azimuthal spacings.
Definition: Cmfd.cpp:4132
void printCmfdCellSizes()
Print information about CMFD cell dimensions.
Definition: Cmfd.cpp:5482
Class to represent a 2D/3D point in space.
Definition: Point.h:24
The Timer class.
int getNumZ()
Get the number of Mesh cells in the z-direction.
Definition: Cmfd.cpp:333
int _cmfd_surface_bwd
Definition: Track.h:45
Structure for communication of fluxes between neighbor domains.
Definition: linalg.h:74
void setNumFSRs(long num_fsrs)
set the number of FSRs.
Definition: Cmfd.cpp:2005
The arbitrary quadrature parent class.
Definition: Quadrature.h:76
void enforceBalanceOnDiagonal(int cmfd_cell, int group)
Modifies the diagonal element to be consistent with the MOC solve.
Definition: Cmfd.cpp:2681
void setLatticeStructure(int num_x, int num_y, int num_z=1)
The structure of the Lattice to be used as the CMFD mesh.
Definition: Cmfd.cpp:1947
The master class containing references to all geometry-related objects - Surfaces, Cells, Universes and Lattices - and Materials.
Definition: Geometry.h:122
void tallyStartingCurrent(Point *point, double delta_x, double delta_y, double delta_z, float *track_flux, double weight)
This function tallies the current impinging on the domain from starting fluxes.
Definition: Cmfd.cpp:5306
void setWidthY(double width)
Set Mesh width in the y-direction.
Definition: Cmfd.cpp:369
void zeroCurrents()
Zero the surface currents for each mesh cell and energy group.
Definition: Cmfd.cpp:3342
void setWidths(std::vector< std::vector< double > > widths)
Set width of non-uniform meshes in x y z directions.
Definition: Cmfd.cpp:5463
A segment represents a line segment within a single flat source region along a track.
Definition: Track.h:27
void setGroupStructure(std::vector< std::vector< int > > group_indices)
Set a coarse energy group structure for CMFD.
Definition: Cmfd.cpp:1687
double computeKeff(int moc_iteration)
Solve the nonlinear diffusion acceleration problem to accelerate the convergence of the MOC problem...
Definition: Cmfd.cpp:1145
The 3D Track class.
void setSORRelaxationFactor(double SOR_factor)
Set successive over-relaxation relaxation factor.
Definition: Cmfd.cpp:1630
int getNumY()
Get the number of Mesh cells in a column.
Definition: Cmfd.cpp:324
void setFluxUpdateOn(bool flux_update_on)
Set flag indicating whether to update the MOC flux.
Definition: Cmfd.cpp:2620
CMFD_PRECISION *** getBoundarySurfaceCurrents()
Get the array of surface currents on the boundaries.
Definition: Cmfd.cpp:351
void setBoundary(int side, boundaryType boundary)
Set the CMFD boundary type for a given surface.
Definition: Cmfd.cpp:2507
int getNumX()
Get the number of Mesh cells in a row.
Definition: Cmfd.cpp:315
void setConvergenceData(ConvergenceData *convergence_data)
Sets the a ConvergenceData object to record diagnostics.
Definition: Cmfd.cpp:2632
void initialize()
Initialize the Matrix and Vector objects, k-nearest stencils, the CMFD cell currents and MOC material...
Definition: Cmfd.cpp:3388
The Universe class.
void setNumMOCGroups(int num_moc_groups)
Set the number of MOC energy groups.
Definition: Cmfd.cpp:1978
#define track_flux(p, e)
Definition: Cmfd.h:45
int getCmfdGroup(int group)
Get the CMFD group given an MOC group.
Definition: Cmfd.h:500
std::vector< std::vector< long > > * getCellFSRs()
Return a pointer to the vector of vectors that contains the FSRs that lie in each cell...
Definition: Cmfd.cpp:2593
void copyCurrentsToBackup()
Copies the current from the regular to the backup CMFD solver.
Definition: Cmfd.cpp:3985
Definition: Matrix.h:26
void setFSRVolumes(FP_PRECISION *FSR_volumes)
Set the pointer to the array of FSR_volumes.
Definition: Cmfd.cpp:1593
int getLatticeSurfaceOTF(int cell, double z, int surface_2D)
Finds the Lattice cell surface that a point lies on. If the point is not on a surface, -1 is returned.
Definition: Universe.cpp:2225
A class for Coarse Mesh Finite Difference (CMFD) acceleration.
Definition: Cmfd.h:51
void setFSRMaterials(Material **FSR_materials)
Set the FSR materials array pointer.
Definition: Cmfd.cpp:1584
void setCentroidUpdateOn(bool centroid_update_on)
Set flag indicating whether to use FSR centroids to update the MOC flux.
Definition: Cmfd.cpp:2751
The Material class represents a unique material and its relevant nuclear data (i.e., multigroup cross-sections) for neutron transport.
Definition: Material.h:51
void rebalanceSigmaT(bool balance_sigma_t)
Rebalances the total cross section to be consistent with the MOC solution on every sweep...
Definition: Cmfd.cpp:2722
int getNumCmfdGroups()
Get the number of coarse CMFD energy groups.
Definition: Cmfd.cpp:1667
Cmfd()
Constructor initializes boundaries and variables that describe the CMFD object.
Definition: Cmfd.cpp:10
#define scalar_flux(tid, e)
Definition: GPUSolver.h:38
void setWidthZ(double width)
Set Mesh width in the z-direction.
Definition: Cmfd.cpp:378
void setSolve3D(bool solve_3d)
Sets a flag to indicate whether a 2D or 3D problem is being solved.
Definition: Cmfd.cpp:4120
void initializeCellMap()
Initializes the vector of vectors that links CMFD cells with FSRs.
Definition: Cmfd.cpp:1800
void checkBalance()
Forces CMFD to check neutron balance on every solve.
Definition: Cmfd.cpp:1658
void setWidthX(double width)
Set Mesh width in the x-direction.
Definition: Cmfd.cpp:360
The Quadrature abstract class and subclasses.
bool stencilCompare(const std::pair< int, double > &firstElem, const std::pair< int, double > &secondElem)
Definition: Cmfd.h:36
void setPolarSpacings(const std::vector< std::vector< double > > &polar_spacings, int num_azim, int num_polar)
Sets the polar spacings.
Definition: Cmfd.cpp:4152
void initializeLattice(Point *offset, bool is_2D=false)
Initialize the CMFD lattice and compute mesh dimensions, considering both uniform/non-uniform and 2D/...
Definition: Cmfd.cpp:3766
int getBoundary(int side)
Get the boundaryType for one side of the CMFD mesh.
Definition: Cmfd.cpp:2517
void initializeBackupCmfdSolver()
Initializes a backup CMFD solver.
Definition: Cmfd.cpp:3899
void setSourceConvergenceThreshold(double source_thresh)
Sets the threshold for CMFD source convergence (>0).
Definition: Cmfd.cpp:2770
int findCmfdSurfaceOTF(int cell_id, double z, int surface_2D)
Quickly finds a 3D CMFD surface given a cell, global coordinate, and 2D CMFD surface. Intended for use in axial on-the-fly ray tracing.
Definition: Cmfd.h:516
Represents a repeating 3D Lattice of Universes.
Definition: Universe.h:156
int convertFSRIdToCmfdCell(long fsr_id)
Return the CMFD cell ID that a FSR lies in.
Definition: Cmfd.cpp:2537
The Timer class is for timing and profiling regions of code.
Definition: Timer.h:40
void incrementValues(int cell, int group_start, int group_end, CMFD_PRECISION *vals)
Increment values in the vector.
Definition: Vector.cpp:92
Utility functions for writing log messages to the screen.
Lattice * getLattice()
Returns the Lattice object used as the CMFD mesh.
Definition: Cmfd.cpp:1958
The generic Track class.
void initializeGroupMap()
Initialize and set array that links the MOC energy groups to the CMFD energy groups.
Definition: Cmfd.cpp:1862
void allocateTallies()
Allocates memory for the CMFD tallies.
Definition: Cmfd.cpp:1818
void printTimerReport()
Report the physical time use by major components of the CMFD solver.
Definition: Cmfd.cpp:4281
The Geometry class.
void addFSRToCell(int cell_id, long fsr_id)
Add an FSR ID to a vector that contains all the FSR IDs contained within a CMFD mesh cell...
Definition: Cmfd.cpp:1969
int findCmfdSurface(int cell_id, LocalCoords *coords)
Find the CMFD surface that a LocalCoords object lies on.
Definition: Cmfd.cpp:1911
void setCellFSRs(std::vector< std::vector< long > > *cell_fsrs)
Set the vector of vectors that contains the FSRs that lie in each cell.
Definition: Cmfd.cpp:2603
Vector * getLocalCurrents()
Get the Vector of surface currents.
Definition: Cmfd.cpp:342