12#ifndef MFEM_FACE_MAP_UTILS_HPP
13#define MFEM_FACE_MAP_UTILS_HPP
29std::pair<int,int> GetFaceNormal3D(
const int face_id);
45void FillFaceMap(
const int n_face_dofs_per_component,
46 const std::vector<int> &offsets,
47 const std::vector<int> &strides,
48 const std::vector<int> &n_dofs_per_dim,
49 Array<int> &face_map);
52void GetTensorFaceMap(
const int dim,
const int order,
const int face_id,
53 Array<int> &face_map);
59inline int ToLexOrdering2D(
const int face_id,
const int size1d,
const int i)
61 if (face_id==2 || face_id==3)
75inline int PermuteFace2D(
const int face_id1,
const int face_id2,
76 const int orientation,
const int size1d,
81 if (face_id1 == 2 || face_id1 == 3)
83 new_index = size1d-1-
index;
92 new_index = size1d-1-new_index;
95 return ToLexOrdering2D(face_id2, size1d, new_index);
102inline int ToLexOrdering3D(
const int face_id,
const int size1d,
const int i,
105 if (face_id==2 || face_id==1 || face_id==5)
109 else if (face_id==3 || face_id==4)
111 return (size1d-1-i) + j*size1d;
115 return i + (size1d-1-j)*size1d;
126inline int PermuteFace3D(
const int face_id1,
const int face_id2,
127 const int orientation,
128 const int size1d,
const int index)
130 int i=0, j=0, new_i=0, new_j=0;
134 if (face_id1==3 || face_id1==4)
138 else if (face_id1==0)
155 new_j = (size1d-1-i);
158 new_i = (size1d-1-i);
162 new_i = (size1d-1-i);
163 new_j = (size1d-1-j);
166 new_i = (size1d-1-j);
167 new_j = (size1d-1-i);
170 new_i = (size1d-1-j);
175 new_j = (size1d-1-j);
178 return ToLexOrdering3D(face_id2, size1d, new_i, new_j);
187inline void FaceIdxToVolIdx2D(
const int qi,
const int nq,
const int face_id0,
188 const int face_id1,
const int side,
int &i,
int &j)
193 const int orientation = side;
195 const int face_id = (side == 0) ? face_id0 : face_id1;
196 const int edge_idx = (side == 0) ? qi : PermuteFace2D(face_id0, face_id1,
197 orientation, nq, qi);
199 const int level = (face_id == 0 || face_id == 3) ? 0 : (nq-1);
200 const bool x_axis = (face_id == 0 || face_id == 2);
202 i = x_axis ? edge_idx : level;
203 j = x_axis ? level : edge_idx;
212inline void FaceIdxToVolIdx3D(
const int index,
const int size1d,
213 const int face_id0,
const int face_id1,
214 const int side,
const int orientation,
215 int& i,
int& j,
int& k)
217 MFEM_VERIFY_KERNEL(face_id1 >= 0 || side == 0,
218 "Accessing second side but face_id1 is not valid.");
220 const int face_id = (side == 0) ? face_id0 : face_id1;
221 const int fidx = (side == 0) ?
index
222 : PermuteFace3D(face_id0, face_id1, orientation, size1d,
index);
224 const bool xy_plane = (face_id == 0 || face_id == 5);
225 const bool yz_plane = (face_id == 2 || face_id == 4);
227 const int level = (face_id == 0 || face_id == 1 || face_id == 4)
230 const int _i = fidx % size1d;
231 const int _j = fidx / size1d;
233 k = xy_plane ? level : _j;
234 j = yz_plane ? _i : xy_plane ? _j : level;
235 i = yz_plane ? level : _i;
int index(int i, int j, int nx, int ny)