Chi-Tech
lbs_01ga_init_fieldfuncs.cc
Go to the documentation of this file.
1#include "lbs_solver.h"
2
4
5#include "chi_runtime.h"
6
7namespace lbs
8{
9
11{
12 using namespace chi_math;
13
14 if (not field_functions_.empty()) return;
15
16 //============================================= Initialize Field Functions
17 // for flux moments
19
20 for (size_t g = 0; g < groups_.size(); ++g)
21 {
22 for (size_t m = 0; m < num_moments_; m++)
23 {
24 std::string prefix;
26 {
28 if (not prefix.empty()) prefix += "_";
29 }
30 if (options_.field_function_prefix_option == "solver_name")
31 prefix = TextName() + "_";
32
33 char buff[100];
34 snprintf(buff,
35 99,
36 "%sphi_g%03d_m%02d",
37 prefix.c_str(),
38 static_cast<int>(g),
39 static_cast<int>(m));
40 const std::string text_name = std::string(buff);
41
42 auto group_ff = std::make_shared<chi_physics::FieldFunctionGridBased>(
43 text_name, // Field name
44 discretization_, // Spatial discretization
45 Unknown(UnknownType::SCALAR)); // Unknown/Variable
46
47 Chi::field_function_stack.push_back(group_ff);
48 field_functions_.push_back(group_ff);
49
51 } // for m
52 } // for g
53
54 //============================================= Initialize power generation
55 // field function
57 {
58 std::string prefix;
60 {
62 if (not prefix.empty()) prefix += "_";
63 }
64 if (options_.field_function_prefix_option == "solver_name")
65 prefix = TextName() + "_";
66
67 auto power_ff = std::make_shared<chi_physics::FieldFunctionGridBased>(
68 prefix + "power_generation", // Field name
69 discretization_, // Spatial discretization
70 Unknown(UnknownType::SCALAR)); // Unknown/Variable
71
72 Chi::field_function_stack.push_back(power_ff);
73 field_functions_.push_back(power_ff);
74
76 }
77}
78
79} // namespace lbs
static std::vector< chi_physics::FieldFunctionPtr > field_function_stack
Definition: chi_runtime.h:92
std::vector< std::shared_ptr< FieldFunctionGridBased > > field_functions_
Definition: chi_solver.h:58
std::string TextName() const
Definition: chi_solver.cc:116
std::shared_ptr< chi_math::SpatialDiscretization > discretization_
Definition: lbs_solver.h:74
std::vector< LBSGroup > groups_
Definition: lbs_solver.h:67
size_t power_gen_fieldfunc_local_handle_
Definition: lbs_solver.h:106
lbs::Options options_
Definition: lbs_solver.h:61
std::map< std::pair< size_t, size_t >, size_t > phi_field_functions_local_map_
Definition: lbs_solver.h:105
size_t num_moments_
Definition: lbs_solver.h:62
std::string field_function_prefix_option
Definition: lbs_structs.h:151
std::string field_function_prefix
Definition: lbs_structs.h:152
bool power_field_function_on
Definition: lbs_structs.h:147