109 """Assemble weak form for A_{CC}^{(k,ell)}
110 :arg fs_pair: pair of cell function space indices that couple
111 k = fs_pair[0]: first function space (to-space): a cell function space
112 ell = fs_pair[1]: second function space (from-space): a cell function space
118 ndof_k = self.
_fe_C[k].ndof
119 ndof_ell = self.
_fe_C[ell].ndof
120 A_k_ell = np.empty((ndof_k, ndof_ell))
124 max_degree = max(self.
_fe_C[k].degree, self.
_fe_C[ell].degree)
127 if fs_pair == (0, 0):
133 for i
in range(ndof_k):
134 for j
in range(ndof_ell):
136 for q, w
in zip(quad2d.points, quad2d.weights):
137 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)
139 self.
_fe_C[k].evaluate_derivative(i, 1, q) * self.
_fe_C[ell].evaluate_derivative(j, 1, q)
142 A_k_ell = np.zeros((k, ell))
144 return {gamma: A_k_ell}
150 """Assemble weak form for A_{CF}^{(k,ell)}
151 :arg fs_pair: pair of function space indices that couple
152 k = fs_pair[0]: first function space (to-space): a cell function space
153 ell = fs_pair[1]: second function space (from-space): a facet function space
154 :arg relative_position: relative position of the facet within a cell given by
159 ndof_k = self.
_fe_C[k].ndof
160 ndof_ell = self.
_fe_F[ell].ndof
161 A_k_ell = np.empty((ndof_k, ndof_ell))
165 max_degree = max(self.
_fe_C[k].degree, self.
_fe_F[ell].degree)
171 if relative_position ==
"left":
172 restr = np.array([[-1.0, 0.0],
175 elif relative_position ==
"right":
176 restr = np.array([[1.0, 0.0],
179 elif relative_position ==
"bottom":
180 restr = np.array([[ 0.0, 1.0],
183 elif relative_position ==
"top":
184 restr = np.array([[0.0, 1.0],
188 raise ValueError(
"Invalid value of relative_position")
191 if fs_pair == (0, 2):
193 if relative_position
in [
"left",
"right"]:
200 facet_coord = np.dot(restr, np.array([1.0, q]))
201 return self.
_fe_C[k].evaluate(i, facet_coord)
202 func_ell = self.
_fe_F[ell].evaluate
204 factor = -1.0 * 0.5 * n_sign
208 for i
in range(ndof_k):
209 for j
in range(ndof_ell):
211 for q, w
in zip(quad.points, quad.weights):
212 A_k_ell[i, j] += factor * w * func_k(i, q) * func_ell(j, q)
214 elif fs_pair == (0, 5):
222 facet_coord = np.dot(restr, np.array([1.0, q]))
223 if relative_position
in [
"left",
"right"]:
224 return self.
_fe_C[k].evaluate_derivative(i, 0, facet_coord)
226 return self.
_fe_C[k].evaluate_derivative(i, 1, facet_coord)
227 func_ell = self.
_fe_F[ell].evaluate
232 A_penalty_1 = np.zeros_like(A_k_ell)
233 for i
in range(ndof_k):
234 for j
in range(ndof_ell):
235 for q, w
in zip(quad.points, quad.weights):
236 A_penalty_1[i, j] += self.
_theta * factor * w * func_k(i, q) * func_ell(j, q)
253 facet_coord = np.dot(restr, np.array([1.0, q]))
254 return self.
_fe_C[k].evaluate(i, facet_coord)
255 func_ell = self.
_fe_F[ell].evaluate
257 factor = 0.5 * 2.0 * n_sign
261 A_penalty_2 = np.zeros_like(A_k_ell)
262 for i
in range(ndof_k):
263 for j
in range(ndof_ell):
264 for q, w
in zip(quad.points, quad.weights):
265 A_penalty_2[i, j] += self.
_gamma_F * factor * w * func_k(i, q) * func_ell(j, q)
271 A_k_ell = A_penalty_1 + A_penalty_2
276 A_k_ell = np.zeros((ndof_k, ndof_ell))
279 return {gamma: A_k_ell}
286 """Assemble weak form for A_{CF}^{(k,ell)}
287 :arg fs_pair: pair of function space indices that couple
288 k = fs_pair[0]: first function space (to-space): a facet function space
289 ell = fs_pair[1]: second function space (from-space): a cell function space
290 :arg relative_position: relative position of the facet within a cell
294 ndof_k = self.
_fe_F[k].ndof
295 ndof_ell = self.
_fe_C[ell].ndof
296 A_k_ell = np.empty((ndof_k, ndof_ell))
299 max_degree = max(self.
_fe_F[k].degree, self.
_fe_C[ell].degree)
305 if relative_position ==
"left":
306 restr = np.array([[-1.0, 0.0],
309 elif relative_position ==
"right":
310 restr = np.array([[1.0, 0.0],
313 elif relative_position ==
"bottom":
314 restr = np.array([[ 0.0, 1.0],
317 elif relative_position ==
"top":
318 restr = np.array([[0.0, 1.0],
322 raise ValueError(
"Invalid value of relative_position")
327 if fs_pair == (0, 0):
328 if relative_position
in [
"left",
"bottom"]:
332 func_k = self.
_fe_F[k].evaluate
334 facet_coord = np.dot(restr, np.array([1.0, q]))
335 if relative_position ==
"left":
337 return self.
_fe_C[ell].evaluate_derivative(i, 0, facet_coord)
340 return self.
_fe_C[ell].evaluate_derivative(i, 1, facet_coord)
343 for i
in range(ndof_k):
344 for j
in range(ndof_ell):
346 for q, w
in zip(quad.points, quad.weights):
347 A_k_ell[i, j] += factor * w * func_k(i, q) * func_ell(j, q)
350 A_k_ell = np.zeros((ndof_k, ndof_ell))
352 elif fs_pair == (1, 0):
353 if relative_position
in [
"right",
"top"]:
356 func_k = self.
_fe_F[k].evaluate
358 facet_coord = np.dot(restr, np.array([1.0, q]))
359 if relative_position ==
"right":
361 return self.
_fe_C[ell].evaluate_derivative(i, 0, facet_coord)
364 return self.
_fe_C[ell].evaluate_derivative(i, 1, facet_coord)
367 for i
in range(ndof_k):
368 for j
in range(ndof_ell):
370 for q, w
in zip(quad.points, quad.weights):
371 A_k_ell[i, j] += factor * w * func_k(i, q) * func_ell(j, q)
374 A_k_ell = np.zeros((ndof_k, ndof_ell))
376 elif fs_pair == (3, 0):
378 factor = factor * (-1.0)
380 if relative_position
in [
"left",
"bottom"]:
381 if relative_position ==
"left":
387 func_k = self.
_fe_F[k].evaluate
389 facet_coord = np.dot(restr, np.array([1.0, q]))
391 return self.
_fe_C[ell].evaluate(i, facet_coord)
394 for i
in range(ndof_k):
395 for j
in range(ndof_ell):
397 for q, w
in zip(quad.points, quad.weights):
398 A_k_ell[i, j] += factor * w * func_k(i, q) * func_ell(j, q)
401 A_k_ell = np.zeros((ndof_k, ndof_ell))
404 elif fs_pair == (4, 0):
406 if relative_position
in [
"right",
"top"]:
407 if relative_position ==
"right":
413 func_k = self.
_fe_F[k].evaluate
415 facet_coord = np.dot(restr, np.array([1.0, q]))
417 return self.
_fe_C[ell].evaluate(i, facet_coord)
420 for i
in range(ndof_k):
421 for j
in range(ndof_ell):
423 for q, w
in zip(quad.points, quad.weights):
424 A_k_ell[i, j] += factor * w * func_k(i, q) * func_ell(j, q)
427 A_k_ell = np.zeros((ndof_k, ndof_ell))
430 A_k_ell = np.zeros((ndof_k, ndof_ell))
433 return {gamma: A_k_ell}
439 """Assemble weak form for A_{FF}^{(k,ell)}
440 :arg fs_pair: pair of function space indices that couple
441 k = fs_pair[0]: first function space (to-space): a facet function space
442 ell = fs_pair[1]: second function space (from-space): a facet function space
443 :arg relative_position: relative position of the facet within a cell
447 ndof_k = self.
_fe_F[k].ndof
448 ndof_ell = self.
_fe_F[ell].ndof
449 A_k_ell = np.empty((ndof_k, ndof_ell))
453 max_degree = max(self.
_fe_F[k].degree, self.
_fe_F[ell].degree)
456 if fs_pair
in [(0,0), (1,1), (3,3), (4,4)]:
457 func_k = self.
_fe_F[k].evaluate
458 func_ell = self.
_fe_F[ell].evaluate
461 if relative_position
in [
"left",
"right"]:
467 for i
in range(ndof_k):
468 for j
in range(ndof_ell):
470 for q, w
in zip(quad.points, quad.weights):
471 A_k_ell[i, j] += factor * w * func_k(i, q) * func_ell(j, q)
473 elif fs_pair == (2, 2):
475 A_k_ell = np.eye(ndof_k)
477 elif fs_pair
in [(2,0), (2,1)]:
479 A_k_ell = -0.5*np.eye(ndof_k)
483 A_k_ell = np.zeros((ndof_k, ndof_ell))
486 return {gamma: A_k_ell}