Chi-Tech
mgd_02d_update_flux_with_two_grid_flux.cc
Go to the documentation of this file.
2
6
7#include "chi_runtime.h"
8#include "chi_log.h"
9#include "utils/chi_timer.h"
10
11//============================================= assemble matrix A
13{
14 if (verbose > 2) Chi::log.Log() << "\nUpdating Thermal fluxes from two-grid";
15
16 const auto& grid = *grid_ptr_;
17 const auto& sdm = *sdm_ptr_;
18
19 // contains two_grid flux, stored in last num_groups entry
20 const double *xlocal_tg;
21 VecGetArrayRead(x_[num_groups_], &xlocal_tg);
22
23 int counter = 0;
24 for (const auto& cell : grid.local_cells)
25 {
26 const auto& cell_mapping = sdm.GetCellMapping(cell);
27 const size_t num_nodes = cell_mapping.NumNodes();
28 const auto& xstg = map_mat_id_2_tginfo.at(cell.material_id_);
29
30 for (unsigned int g = last_fast_group_; g < num_groups_; ++g)
31 {
32 for (size_t i=0; i<num_nodes; ++i)
33 {
34 const int64_t imap = sdm.MapDOFLocal(cell, i);
35 const int64_t imap_globl = sdm.MapDOF(cell, i);
36 const double aux = xlocal_tg[imap] * VF_[counter][i] * xstg.spectrum[g];
37 VecSetValue(x_[g], imap_globl, aux, ADD_VALUES);
38 }// i
39 }//g
40 counter++;
41 }//for cell
42
43 // finalize
44 for (unsigned int g = last_fast_group_; g < num_groups_; ++g)
45 {
46 VecAssemblyBegin(x_[g]);
47 VecAssemblyEnd(x_[g]);
48 }
49 // release two-grid flux
50 VecRestoreArrayRead(x_[num_groups_], &xlocal_tg);
51}
static chi::ChiLog & log
Definition: chi_runtime.h:81
LogStream Log(LOG_LVL level=LOG_0)
Definition: chi_log.cc:35
std::vector< std::vector< double > > VF_
std::map< int, TwoGridCollapsedInfo > map_mat_id_2_tginfo
std::vector< Vec > x_
chi_mesh::MeshContinuumPtr grid_ptr_
chi_math::SDMPtr sdm_ptr_