Chi-Tech
initcommon.cc
Go to the documentation of this file.
1#include "diffusion_solver.h"
2
5
6#include "chi_runtime.h"
7#include "chi_log.h"
8
9//###################################################################
10/**Initialization of common to all solver types.*/
12{
13 const std::string fname = "chi_diffusion::Solver::InitializeCommonItems";
15
16 if (grid_ptr_ == nullptr)
17 throw std::logic_error(fname + " No grid defined.");
18
19 auto globl_unique_bndry_ids = grid_ptr_->GetDomainUniqueBoundaryIDs();
20
21 const auto& grid_boundary_id_map = grid_ptr_->GetBoundaryIDMap();
22 for (uint64_t bndry_id : globl_unique_bndry_ids)
23 {
24 if (grid_boundary_id_map.count(bndry_id) == 0)
25 throw std::logic_error(fname + ": Boundary id " +
26 std::to_string(bndry_id) + " does not have a name-assignment.");
27
28 const auto& bndry_name = grid_boundary_id_map.at(bndry_id);
29 if (boundary_preferences_.find(bndry_name) != boundary_preferences_.end())
30 {
31 BoundaryInfo bndry_info = boundary_preferences_.at(bndry_name);
32 auto& bndry_vals = bndry_info.second;
33 switch (bndry_info.first)
34 {
36 {
37 boundaries_.insert(
38 std::make_pair(bndry_id, new
40 Chi::log.Log() << "Boundary \"" << bndry_name << "\" set to reflecting.";
41 break;
42 }
44 {
45 if (bndry_vals.empty()) bndry_vals.resize(1,0.0);
46 boundaries_.insert(
47 std::make_pair(bndry_id, new
48 chi_diffusion::BoundaryDirichlet(bndry_vals[0])));
49 Chi::log.Log() << "Boundary \"" << bndry_name << "\" set to dirichlet.";
50 break;
51 }
53 {
54 if (bndry_vals.size()<3) bndry_vals.resize(3,0.0);
55 boundaries_.insert(
56 std::make_pair(bndry_id, new
57 chi_diffusion::BoundaryRobin(bndry_vals[0],
58 bndry_vals[1],
59 bndry_vals[2])));
60 Chi::log.Log() << "Boundary \"" << bndry_name << "\" set to robin.";
61 break;
62 }
64 {
65 boundaries_.insert(
66 std::make_pair(bndry_id, new
67 chi_diffusion::BoundaryRobin(0.25, 0.5, 0.0)));
68 Chi::log.Log() << "Boundary \"" << bndry_name << "\" set to vacuum.";
69 break;
70 }
72 {
73 if (bndry_vals.size()<3) bndry_vals.resize(3,0.0);
74 boundaries_.insert(
75 std::make_pair(bndry_id, new
76 chi_diffusion::BoundaryRobin(bndry_vals[0],
77 bndry_vals[1],
78 bndry_vals[2])));
79 Chi::log.Log() << "Boundary \"" << bndry_name << "\" set to neumann.";
80 break;
81 }
82 }//switch boundary type
83 }
84 else
85 {
86 boundaries_.insert(
87 std::make_pair(bndry_id, new
90 << "No boundary preference found for boundary \"" << bndry_name
91 << "\" Dirichlet boundary added with zero boundary value.";
92 }
93 }//for neighbor_id_
94
96}
97
98
static chi::ChiLog & log
Definition: chi_runtime.h:81
LogStream Log(LOG_LVL level=LOG_0)
Definition: chi_log.cc:35
LogStream Log0Verbose1()
Definition: chi_log.h:234
std::pair< BoundaryType, std::vector< double > > BoundaryInfo
BoundaryPreferences boundary_preferences_
std::map< uint64_t, chi_diffusion::Boundary * > boundaries_
chi_mesh::MeshContinuumPtr grid_ptr_
void InitializeCommonItems()
Definition: initcommon.cc:11
chi_mesh::MeshContinuumPtr & GetGrid() const
MeshHandler & GetCurrentHandler()