88 """Assemble weak form for A_{CC}^{(k,ell)}
89 :arg fs_pair: pair of cell function space indices that couple
90 k = fs_pair[0]: first function space (to-space): a cell function space
91 ell = fs_pair[1]: second function space (from-space): a cell function space
97 ndof_k = self.
_fe_C[k].ndof
98 ndof_ell = self.
_fe_C[ell].ndof
99 A_k_ell = np.empty((ndof_k, ndof_ell))
103 max_degree = max(self.
_fe_C[k].degree, self.
_fe_C[ell].degree)
106 if fs_pair == (0, 0):
112 for i
in range(ndof_k):
113 for j
in range(ndof_ell):
115 for q, w
in zip(quad2d.points, quad2d.weights):
116 A_k_ell[i, j] += factor * w * ( self.
_fe_C[k].evaluate_derivative(i, 0, q) * self.
_fe_C[ell].evaluate_derivative(j, 0, q)
118 self.
_fe_C[k].evaluate_derivative(i, 1, q) * self.
_fe_C[ell].evaluate_derivative(j, 1, q)
121 A_k_ell = np.zeros((k, ell))
123 return {gamma: A_k_ell}
129 """Assemble weak form for A_{CF}^{(k,ell)}
130 :arg fs_pair: pair of function space indices that couple
131 k = fs_pair[0]: first function space (to-space): a cell function space
132 ell = fs_pair[1]: second function space (from-space): a facet function space
133 :arg relative_position: relative position of the facet within a cell given by
138 ndof_k = self.
_fe_C[k].ndof
139 ndof_ell = self.
_fe_F[ell].ndof
140 A_k_ell = np.empty((ndof_k, ndof_ell))
144 max_degree = max(self.
_fe_C[k].degree, self.
_fe_F[ell].degree)
150 if relative_position ==
"left":
151 restr = np.array([[-1.0, 0.0],
154 elif relative_position ==
"right":
155 restr = np.array([[1.0, 0.0],
158 elif relative_position ==
"bottom":
159 restr = np.array([[ 0.0, 1.0],
162 elif relative_position ==
"top":
163 restr = np.array([[0.0, 1.0],
167 raise ValueError(
"Invalid value of relative_position")
170 if fs_pair == (0, 2):
173 if relative_position
in [
"left",
"right"]:
180 facet_coord = np.dot(restr, np.array([1.0, q]))
181 return self.
_fe_C[k].evaluate(i, facet_coord)
182 func_ell = self.
_fe_F[ell].evaluate
185 for i
in range(ndof_k):
186 for j
in range(ndof_ell):
188 for q, w
in zip(quad.points, quad.weights):
189 A_k_ell[i, j] += factor * w * func_k(i, q) * func_ell(j, q)
192 A_k_ell = np.zeros((ndof_k, ndof_ell))
195 return {gamma: A_k_ell}
201 """Assemble weak form for A_{CF}^{(k,ell)}
202 :arg fs_pair: pair of function space indices that couple
203 k = fs_pair[0]: first function space (to-space): a facet function space
204 ell = fs_pair[1]: second function space (from-space): a cell function space
205 :arg relative_position: relative position of the facet within a cell
209 ndof_k = self.
_fe_F[k].ndof
210 ndof_ell = self.
_fe_C[ell].ndof
211 A_k_ell = np.empty((ndof_k, ndof_ell))
214 max_degree = max(self.
_fe_F[k].degree, self.
_fe_C[ell].degree)
220 if relative_position ==
"left":
221 restr = np.array([[-1.0, 0.0],
224 elif relative_position ==
"right":
225 restr = np.array([[1.0, 0.0],
228 elif relative_position ==
"bottom":
229 restr = np.array([[ 0.0, 1.0],
232 elif relative_position ==
"top":
233 restr = np.array([[0.0, 1.0],
237 raise ValueError(
"Invalid value of relative_position")
242 if fs_pair == (0, 0):
243 if relative_position
in [
"left",
"bottom"]:
245 func_k = self.
_fe_F[k].evaluate
247 facet_coord = np.dot(restr, np.array([1.0, q]))
248 if relative_position ==
"left":
250 return self.
_fe_C[ell].evaluate_derivative(i, 0, facet_coord)
253 return self.
_fe_C[ell].evaluate_derivative(i, 1, facet_coord)
256 for i
in range(ndof_k):
257 for j
in range(ndof_ell):
259 for q, w
in zip(quad.points, quad.weights):
260 A_k_ell[i, j] += factor * w * func_k(i, q) * func_ell(j, q)
263 A_k_ell = np.zeros((ndof_k, ndof_ell))
265 elif fs_pair == (1, 0):
266 if relative_position
in [
"right",
"top"]:
268 func_k = self.
_fe_F[k].evaluate
270 facet_coord = np.dot(restr, np.array([1.0, q]))
271 if relative_position ==
"right":
273 return self.
_fe_C[ell].evaluate_derivative(i, 0, facet_coord)
276 return self.
_fe_C[ell].evaluate_derivative(i, 1, facet_coord)
279 for i
in range(ndof_k):
280 for j
in range(ndof_ell):
282 for q, w
in zip(quad.points, quad.weights):
283 A_k_ell[i, j] += factor * w * func_k(i, q) * func_ell(j, q)
286 A_k_ell = np.zeros((ndof_k, ndof_ell))
289 A_k_ell = np.zeros((ndof_k, ndof_ell))
292 return {gamma: A_k_ell}
298 """Assemble weak form for A_{FF}^{(k,ell)}
299 :arg fs_pair: pair of function space indices that couple
300 k = fs_pair[0]: first function space (to-space): a facet function space
301 ell = fs_pair[1]: second function space (from-space): a facet function space
302 :arg relative_position: relative position of the facet within a cell
306 ndof_k = self.
_fe_F[k].ndof
307 ndof_ell = self.
_fe_F[ell].ndof
308 A_k_ell = np.empty((ndof_k, ndof_ell))
312 max_degree = max(self.
_fe_F[k].degree, self.
_fe_F[ell].degree)
315 if fs_pair
in [(0,0), (1,1)]:
316 func_k = self.
_fe_F[k].evaluate
317 func_ell = self.
_fe_F[ell].evaluate
320 if relative_position
in [
"left",
"right"]:
326 for i
in range(ndof_k):
327 for j
in range(ndof_ell):
329 for q, w
in zip(quad.points, quad.weights):
330 A_k_ell[i, j] += factor * w * func_k(i, q) * func_ell(j, q)
332 elif fs_pair == (2, 2):
334 A_k_ell = np.eye(ndof_k)
336 elif fs_pair
in [(2,0), (2,1)]:
338 A_k_ell = -0.5*np.eye(ndof_k)
342 A_k_ell = np.zeros((ndof_k, ndof_ell))
345 return {gamma: A_k_ell}