1 #ifndef VERTEXCFD_CLOSURE_RADREACTION_IMPL_HPP
2 #define VERTEXCFD_CLOSURE_RADREACTION_IMPL_HPP
4 #include "utils/VertexCFD_Utils_ScalarFieldView.hpp"
6 #include <Panzer_HierarchicParallelism.hpp>
12 namespace ClosureModel
15 template<
class EvalType,
class Traits>
16 RADReaction<EvalType, Traits>::RADReaction(
17 const panzer::IntegrationRule& ir,
18 const SpeciesProperties::ConstantSpeciesProperties& species_prop,
19 const std::string& neutron_flux_name)
20 : _num_species(species_prop.numSpecies())
21 , _neutron_flux(neutron_flux_name, ir.dl_scalar)
22 , _bateman_matrix(Kokkos::ViewAllocateWithoutInitializing(
"bateman_"
26 , _mic_cross_section(Kokkos::ViewAllocateWithoutInitializing(
"microscopic_"
31 , _build_bateman(species_prop.buildBateman())
32 , _build_transmutation(species_prop.buildTransmutationSource())
37 auto bateman_matrix_host
38 = Kokkos::create_mirror_view(Kokkos::HostSpace{}, _bateman_matrix);
39 bateman_matrix_host = species_prop.batemanMatrix();
40 Kokkos::deep_copy(_bateman_matrix, bateman_matrix_host);
44 if (_build_transmutation)
46 auto mic_cross_sec_host = Kokkos::create_mirror_view(
47 Kokkos::HostSpace{}, _mic_cross_section);
48 mic_cross_sec_host = species_prop.microscopicCrossSection();
49 Kokkos::deep_copy(_mic_cross_section, mic_cross_sec_host);
53 Utils::addEvaluatedScalarFieldView(*
this,
57 "REACTION_TERM_reaction_advection_"
58 "diffusion_equation_");
61 Utils::addDependentScalarFieldView(
62 *
this, ir.dl_scalar, _num_species, _species,
"species_");
64 if (_build_transmutation)
65 this->addDependentField(_neutron_flux);
67 this->setName(
"RAD Equation Reaction Term");
71 template<
class EvalType,
class Traits>
72 void RADReaction<EvalType, Traits>::evaluateFields(
73 typename Traits::EvalData workset)
75 auto policy = panzer::HP::inst().teamPolicy<scalar_type, PHX::Device>(
77 Kokkos::parallel_for(this->getName(), policy, *
this);
81 template<
class EvalType,
class Traits>
82 KOKKOS_INLINE_FUNCTION
void RADReaction<EvalType, Traits>::operator()(
83 const Kokkos::TeamPolicy<PHX::exec_space>::member_type& team)
const
85 const int cell = team.league_rank();
86 const int num_point = _reaction_term[0].extent(1);
88 Kokkos::parallel_for(Kokkos::TeamThreadRange(team, 0, num_point),
89 [&](
const int point) {
90 for (
int num = 0; num < _num_species; ++num)
92 _reaction_term[num](cell, point) = 0.0;
93 for (
int spe = 0; spe < _num_species; ++spe)
96 _reaction_term[num](cell, point)
97 += _species[spe](cell, point)
98 * _bateman_matrix(num, spe);
100 if (_build_transmutation)
101 _reaction_term[num](cell, point)
102 += _species[spe](cell, point)
103 * _neutron_flux(cell, point)
104 * _mic_cross_section(num, spe);
115 #endif // end VERTEXCFD_CLOSURE_RADREACTION_IMPL_HPP