Chi-Tech
mgd_01b_set_bc.cc
Go to the documentation of this file.
2
3#include "chi_runtime.h"
4#include "chi_log.h"
5#include "utils/chi_timer.h"
6
8
10
12
14
15//============================================= assemble matrix A
16void mg_diffusion::Solver::Set_BCs(const std::vector<uint64_t>& globl_unique_bndry_ids)
17{
18 Chi::log.Log0Verbose1() << "Setting Boundary Conditions";
19
20 uint64_t max_boundary_id = 0;
21 for (const auto& id : globl_unique_bndry_ids)
22 max_boundary_id = std::max(id,max_boundary_id);
23
24 Chi::log.Log() << "Max boundary id identified: " << max_boundary_id;
25
26 for (int bndry=0; bndry<(max_boundary_id+1); ++bndry)
27 {
28 if (boundary_preferences_.find(bndry) != boundary_preferences_.end())
29 {
30 BoundaryInfo bndry_info = boundary_preferences_.at(bndry);
31 auto& bndry_vals = bndry_info.second;
32
33 switch (bndry_info.first)
34 {
35 case BoundaryType::Reflecting: // ------------- REFLECTING
36 {
38 Chi::log.Log() << "Boundary " << bndry << " set to reflecting.";
39 break;
40 }
41 case BoundaryType::Robin: // ------------- ROBIN
42 {
43 if (bndry_vals.size()!=3)
44 throw std::logic_error(std::string(__PRETTY_FUNCTION__) +
45 " Robin needs 3 values in bndry vals.");
46 boundaries_.push_back(Boundary{BoundaryType::Robin, bndry_vals});
47 Chi::log.Log() << "Boundary " << bndry << " set to robin.";
48 break;
49 }
50 case BoundaryType::Vacuum: // ------------- VACUUM
51 {
53 std::vector<double> a_values(ng, 0.25);
54 std::vector<double> b_values(ng, 0.5);
55 std::vector<double> f_values(ng, 0.0);
57 {a_values,b_values,f_values}});
58 Chi::log.Log() << "Boundary " << bndry << " set to vacuum.";
59 break;
60 }
61 case BoundaryType::Neumann: // ------------- NEUMANN
62 {
63 if (bndry_vals.size()!=3)
64 throw std::logic_error(std::string(__PRETTY_FUNCTION__) +
65 " Neumann needs 3 values in bndry vals.");
66 boundaries_.push_back(Boundary{BoundaryType::Robin, bndry_vals});
67 Chi::log.Log() << "Boundary " << bndry << " set to neumann.";
68 break;
69 }
70 }//switch boundary type
71 }
72 else
73 {
75 std::vector<double> a_values(ng, 0.25);
76 std::vector<double> b_values(ng, 0.5);
77 std::vector<double> f_values(ng, 0.0);
78 boundaries_.push_back({BoundaryType::Robin, {a_values, b_values, f_values}});
80 << "No boundary preference found for boundary index " << bndry
81 << "Vacuum boundary added as default.";
82 }
83 }//for bndry
84
85}
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
BoundaryPreferences boundary_preferences_
std::vector< Boundary > boundaries_
std::pair< BoundaryType, std::array< std::vector< double >, 3 > > BoundaryInfo
void Set_BCs(const std::vector< uint64_t > &globl_unique_bndry_ids)