9#define scdouble static_cast<double>
29 const size_t num_faces = cell.
faces_.size();
30 const size_t num_vertices = cell.
vertex_ids_.size();
32 const double volume = cell_mapping.CellVolume();
33 const double face_area = cell_mapping.FaceArea(f);
36 auto ComputeSurfaceArea = [&cell_mapping,&num_faces]()
38 double surface_area = 0.0;
39 for (
size_t fr=0; fr<num_faces; ++fr)
40 surface_area += cell_mapping.FaceArea(fr);
52 hp = 2.0*volume/face_area;
53 else if (num_faces == 4)
54 hp = volume/face_area;
57 const double surface_area = ComputeSurfaceArea();
59 if (num_faces % 2 == 0)
60 hp = 4.0*volume/surface_area;
63 hp = 2.0*volume/surface_area;
64 hp += sqrt(2.0 * volume /
72 const double surface_area = ComputeSurfaceArea();
75 hp = 3 * volume / surface_area;
76 else if (num_faces == 6 && num_vertices == 8)
77 hp = volume / surface_area;
79 hp = 6 * volume / surface_area;
82 throw std::logic_error(
83 "lbs::acceleration::DiffusionMIPSolver::HPerpendicular: "
84 "Unsupported cell type in call to HPerpendicular");
94 const std::vector<chi_mesh::Vector3>& cc_node_locs,
95 const std::vector<chi_mesh::Vector3>& ac_node_locs,
96 size_t ccf,
size_t acf,
100 const auto& cur_cell_mapping = sdm_.GetCellMapping(cur_cell);
101 const auto& adj_cell_mapping = sdm_.GetCellMapping(adj_cell);
103 const int i = cur_cell_mapping.MapFaceNode(ccf, ccfi);
104 const auto& node_i_loc = cc_node_locs[i];
106 const size_t adj_face_num_nodes = adj_cell_mapping.NumFaceNodes(acf);
108 for (
size_t fj=0; fj<adj_face_num_nodes; ++fj)
110 const int j = adj_cell_mapping.MapFaceNode(acf,fj);
111 if ((node_i_loc - ac_node_locs[j]).NormSquare() < epsilon)
115 throw std::logic_error(
116 "lbs::acceleration::DiffusionMIPSolver::MapFaceNodeDisc: Mapping failure.");
131 const std::string fname =
"lbs::acceleration::DiffusionMIPSolver::"
132 "CallLuaXYZFunction";
134 lua_getglobal(L, lua_func_name.c_str());
137 if (not lua_isfunction(L, -1))
138 throw std::logic_error(fname +
" attempted to access lua-function, " +
139 lua_func_name +
", but it seems the function"
140 " could not be retrieved.");
143 lua_pushnumber(L, xyz.
x);
144 lua_pushnumber(L, xyz.
y);
145 lua_pushnumber(L, xyz.
z);
150 if (lua_pcall(L,3,1,0) == 0)
152 LuaCheckNumberValue(fname, L, -1);
153 lua_return = lua_tonumber(L,-1);
156 throw std::logic_error(fname +
" attempted to call lua-function, " +
157 lua_func_name +
", but the call failed." +
const CellMapping & GetCellMapping(const chi_mesh::Cell &cell) const
std::vector< CellFace > faces_
std::vector< uint64_t > vertex_ids_
int MapFaceNodeDisc(const chi_mesh::Cell &cur_cell, const chi_mesh::Cell &adj_cell, const std::vector< chi_mesh::Vector3 > &cc_node_locs, const std::vector< chi_mesh::Vector3 > &ac_node_locs, size_t ccf, size_t acf, size_t ccfi, double epsilon=1.0e-12)
double HPerpendicular(const chi_mesh::Cell &cell, unsigned int f)
static double CallLuaXYZFunction(lua_State *L, const std::string &lua_func_name, const chi_mesh::Vector3 &xyz)
const chi_math::SpatialDiscretization & sdm_
std::string PrintStr() const