28 throw std::logic_error(
"Unassigned field function in slice "
29 "field function interpolator.");
36 std::vector<uint64_t> intersecting_cell_indices;
38 for (
const auto& cell : grid.local_cells)
40 auto cell_local_index = cell.local_id_;
43 throw std::logic_error(
"FieldFunctionInterpolationSlice "
44 "does not support 1D cells.");
46 intersecting_cell_indices.push_back(cell_local_index);
49 bool intersects =
false;
51 size_t num_faces = cell.faces_.size();
52 for (
size_t f=0; f<num_faces; f++)
54 const auto& face = cell.faces_[f];
56 size_t num_edges = face.vertex_ids_.size();
57 for (
size_t e=0; e<num_edges; e++)
59 size_t ep1 = (e < (num_edges-1))? e+1 : 0;
60 uint64_t v0_i = face.vertex_ids_[e];
61 uint64_t v1_i = face.vertex_ids_[ep1];
63 std::vector<chi_mesh::Vector3> tet_points;
65 tet_points.push_back(grid.vertices[v0_i]);
66 tet_points.push_back(grid.vertices[v1_i]);
67 tet_points.push_back(cell.faces_[f].centroid_);
68 tet_points.push_back(cell.centroid_);
72 intersecting_cell_indices.push_back(cell_local_index);
77 if (intersects)
break;
81 throw std::logic_error(
"Unsupported cell type in call "
82 "to Slice Initialize.");
87 for (
const uint64_t cell_local_index : intersecting_cell_indices)
89 const auto& cell = grid.local_cells[cell_local_index];
97 for (uint64_t v0gi : cell.vertex_ids_)
101 const auto nudge = 1.0e-4*(grid.vertices[v0gi] - cell.centroid_);
103 face_isds.
point = grid.vertices[v0gi] - nudge;
104 face_isds.
point2d = grid.vertices[v0gi];
117 for (
size_t p=0; p<num_points; p++)
135 size_t num_faces = cell.faces_.size();
136 for (
size_t f=0; f<num_faces; f++)
138 const auto& face = cell.faces_[f];
140 size_t num_edges = face.vertex_ids_.size();
141 for (
size_t e=0; e<num_edges; e++)
143 size_t ep1 = (e < (num_edges-1))? e+1 : 0;
144 uint64_t v0gi = face.vertex_ids_[e ];
145 uint64_t v1gi = face.vertex_ids_[ep1];
147 const auto& v0 = grid.vertices[v0gi];
148 const auto& v1 = grid.vertices[v1gi];
151 std::pair<double,double> weights;
155 v0, v1, interstion_point,
159 bool duplicate_found =
false;
162 double dif = (existing_face_isds.point -
163 interstion_point).NormSquare();
166 duplicate_found =
true;
172 if (!duplicate_found)
176 face_isds.
point = interstion_point;
189 for (
int p=0; p<num_points; p++)
201 "for a cell that is indicated as being "
202 "intersected. Slice FF interp.";
213 std::vector<FFIFaceEdgeIntersection> unsorted_points;
214 for (
int p=0; p<num_points; p++)
231 unsorted_points.erase(unsorted_points.begin());
233 while (!unsorted_points.empty())
235 for (
int p=0; p<unsorted_points.size(); p++)
240 bool illegal_value =
false;
241 for (
int pr=0; pr<unsorted_points.size(); pr++)
246 unsorted_points[p].point2d;
250 illegal_value =
true;
259 unsorted_points.erase(unsorted_points.begin()+p);
LogStream LogAllWarning()
std::vector< chi_physics::FieldFunctionGridBasedPtr > field_functions_
std::vector< FFICellIntersection > cell_intersections_
chi_mesh::Normal tangent_
void Initialize() override
chi_mesh::Vector3 plane_point_
bool CheckPlaneTetIntersect(const chi_mesh::Normal &plane_normal, const chi_mesh::Vector3 &plane_point, const std::vector< chi_mesh::Vector3 > &tet_points)
bool CheckPlaneLineIntersect(const chi_mesh::Normal &plane_normal, const chi_mesh::Vector3 &plane_point, const chi_mesh::Vector3 &line_point_0, const chi_mesh::Vector3 &line_point_1, chi_mesh::Vector3 &intersection_point, std::pair< double, double > *weights=nullptr)
chi_mesh::Vector3 intersection_2d_centre
uint64_t ref_cell_local_id
chi_mesh::Vector3 intersection_centre
std::vector< FFIFaceEdgeIntersection > intersections
chi_mesh::Vector3 point2d
Vector3 Cross(const Vector3 &that) const
Vector3 Dot(const chi_mesh::TensorRank2Dim3 &that) const