Chi-Tech
lbsrz_01d_init_spat_discr.cc
Go to the documentation of this file.
2
5
6#include "chi_runtime.h"
7#include "chi_log.h"
8
10
11#include <iomanip>
12
13namespace lbs
14{
15
17{
18 Chi::log.Log() << "Initializing spatial discretization_.\n";
19
22
23 // primary discretisation
24 switch (options_.geometry_type)
25 {
27 {
30 break;
31 }
34 {
37 break;
38 }
39 default:
40 {
41 Chi::log.LogAllError() << "D_DO_RZ_SteadyState::SteadyStateSolver::"
42 "InitializeSpatialDiscretization : "
43 << "invalid geometry, static_cast<int>(type) = "
44 << static_cast<int>(options_.geometry_type);
45 Chi::Exit(EXIT_FAILURE);
46 }
47 }
48
50 SDM_PWLD;
51 discretization_ = SDM_PWLD::New(*grid_ptr_, qorder, system);
52
54
55 // secondary discretisation
56 // system - manipulated such that the spatial discretisation returns
57 // a cell view of the same type but with weighting of degree one less
58 // than the primary discretisation
59 switch (options_.geometry_type)
60 {
62 {
65 break;
66 }
69 {
72 break;
73 }
74 default:
75 {
76 Chi::log.LogAllError() << "D_DO_RZ_SteadyState::SteadyStateSolver::"
77 "InitializeSpatialDiscretization : "
78 << "invalid geometry, static_cast<int>(type) = "
79 << static_cast<int>(options_.geometry_type);
80 Chi::Exit(EXIT_FAILURE);
81 }
82 }
83
85 SDM_PWLD::New(*grid_ptr_, qorder, system);
86
88}
89
91{
92 Chi::log.Log() << "Computing RZ secondary unit integrals.\n";
93 const auto& sdm = *discretization_;
94
95 //======================================== Define spatial weighting functions
96 std::function<double(const chi_mesh::Vector3&)> swf =
98
99 //======================================== Define lambda for cell-wise comps
100 auto ComputeCellUnitIntegrals =
101 [&sdm, &swf](const chi_mesh::Cell& cell)
102 {
103 const auto& cell_mapping = sdm.GetCellMapping(cell);
104 // const size_t cell_num_faces = cell.faces.size();
105 const size_t cell_num_nodes = cell_mapping.NumNodes();
106 const auto vol_qp_data = cell_mapping.MakeVolumetricQuadraturePointData();
107
108 MatDbl IntV_shapeI_shapeJ(cell_num_nodes, VecDbl(cell_num_nodes));
109
110 // Volume integrals
111 for (unsigned int i = 0; i < cell_num_nodes; ++i)
112 {
113 for (unsigned int j = 0; j < cell_num_nodes; ++j)
114 {
115 for (const auto& qp : vol_qp_data.QuadraturePointIndices())
116 {
117 IntV_shapeI_shapeJ[i][j] +=
118 swf(vol_qp_data.QPointXYZ(qp)) * vol_qp_data.ShapeValue(i, qp) *
119 vol_qp_data.ShapeValue(j, qp) * vol_qp_data.JxW(qp); // M-matrix
120 } // for qp
121 } // for j
122 } // for i
123
124 return lbs::UnitCellMatrices{{}, // K-matrix
125 {}, // G-matrix
126 IntV_shapeI_shapeJ, // M-matrix
127 {}, // Vi-vectors
128
129 {}, // face M-matrices
130 {}, // face G-matrices
131 {}}; // face Si-vectors
132 };
133
134 const size_t num_local_cells = grid_ptr_->local_cells.size();
135 secondary_unit_cell_matrices_.resize(num_local_cells);
136
137 for (const auto& cell : grid_ptr_->local_cells)
138 secondary_unit_cell_matrices_[cell.local_id_] =
139 ComputeCellUnitIntegrals(cell);
140
142 Chi::log.Log()
143 << "Secondary Cell matrices computed. Process memory = "
144 << std::setprecision(3) << chi::Console::GetMemoryUsageInMB() << " MB";
145}
146
147} // namespace lbs
static void Exit(int error_code)
Definition: chi_runtime.cc:342
static chi::ChiLog & log
Definition: chi_runtime.h:81
static chi::MPI_Info & mpi
Definition: chi_runtime.h:78
LogStream LogAllError()
Definition: chi_log.h:239
LogStream Log(LOG_LVL level=LOG_0)
Definition: chi_log.cc:35
static double GetMemoryUsageInMB()
Get current memory usage in Megabytes.
void Barrier() const
Definition: mpi_info.cc:38
static double CylindricalRZSpatialWeightFunction(const chi_mesh::Vector3 &point)
std::shared_ptr< chi_math::SpatialDiscretization > discretization_secondary_
std::vector< lbs::UnitCellMatrices > secondary_unit_cell_matrices_
chi_mesh::MeshContinuumPtr grid_ptr_
Definition: lbs_solver.h:75
std::shared_ptr< chi_math::SpatialDiscretization > discretization_
Definition: lbs_solver.h:74
lbs::Options options_
Definition: lbs_solver.h:61
std::vector< VecDbl > MatDbl
Definition: lbs_structs.h:19
std::vector< double > VecDbl
Definition: lbs_structs.h:18
GeometryType geometry_type
Definition: lbs_structs.h:124