9#define scdouble static_cast<double>
27 const auto& cell_mapping = sdm.GetCellMapping(cell);
30 const size_t num_faces = cell.
faces_.size();
31 const size_t num_vertices = cell.
vertex_ids_.size();
33 const double volume = cell_mapping.CellVolume();
34 const double face_area = cell_mapping.FaceArea(f);
37 auto ComputeSurfaceArea = [&cell_mapping,&num_faces]()
39 double surface_area = 0.0;
40 for (
size_t fr=0; fr<num_faces; ++fr)
41 surface_area += cell_mapping.FaceArea(fr);
53 hp = 2.0*volume/face_area;
54 else if (num_faces == 4)
55 hp = volume/face_area;
58 const double surface_area = ComputeSurfaceArea();
60 if (num_faces % 2 == 0)
61 hp = 4.0*volume/surface_area;
64 hp = 2.0*volume/surface_area;
65 hp += sqrt(2.0 * volume /
73 const double surface_area = ComputeSurfaceArea();
76 hp = 3 * volume / surface_area;
77 else if (num_faces == 6 && num_vertices == 8)
78 hp = volume / surface_area;
80 hp = 6 * volume / surface_area;
83 throw std::logic_error(
84 "dfem_diffusion::Solver::HPerpendicular: "
85 "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& sdm = *sdm_ptr_;
102 const auto& cur_cell_mapping = sdm.GetCellMapping(cur_cell);
103 const auto& adj_cell_mapping = sdm.GetCellMapping(adj_cell);
105 const int i = cur_cell_mapping.MapFaceNode(ccf, ccfi);
106 const auto& node_i_loc = cc_node_locs[i];
108 const size_t adj_face_num_nodes = adj_cell_mapping.NumFaceNodes(acf);
110 for (
size_t fj=0; fj<adj_face_num_nodes; ++fj)
112 const int j = adj_cell_mapping.MapFaceNode(acf,fj);
113 if ((node_i_loc - ac_node_locs[j]).NormSquare() < epsilon)
117 throw std::logic_error(
118 "dfem_diffusion::Solver::MapFaceNodeDisc: Mapping failure.");
132 const std::string& lua_func_name,
137 lua_getglobal(L, lua_func_name.c_str());
140 if (not lua_isfunction(L, -1))
141 throw std::logic_error(
"CallLua_iXYZFunction attempted to access lua-function, " +
142 lua_func_name +
", but it seems the function"
143 " could not be retrieved.");
146 lua_pushinteger(L, imat);
147 lua_pushnumber(L, xyz.
x);
148 lua_pushnumber(L, xyz.
y);
149 lua_pushnumber(L, xyz.
z);
154 if (lua_pcall(L,4,1,0) == 0)
156 LuaCheckNumberValue(
"CallLua_iXYZFunction", L, -1);
157 lua_return = lua_tonumber(L,-1);
160 throw std::logic_error(
"dfem_diffusion::CallLua_iXYZFunction attempted to call lua-function, " +
161 lua_func_name +
", but the call failed." +
173 auto& ff = *field_functions_.front();
174 ff.UpdateFieldVector(x_);
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)
static double CallLua_iXYZFunction(lua_State *L, const std::string &, int, const chi_mesh::Vector3 &)
void UpdateFieldFunctions()
chi_math::SDMPtr sdm_ptr_
double HPerpendicular(const chi_mesh::Cell &cell, unsigned int f)
std::string PrintStr() const