Interpolated Test Functions in Variational Forms: Handling post_jacobian_callback Modifications with Fieldsplit Solvers and R Spaces
#4830
Replies: 1 comment
-
|
Inspired by @colinjcotter, I have figured out how to implement the term involving Assume that and in Firedrake, where Implementing the bilinear form with a gradientElement-wise formulation of the gradient termFor the gradient term, on an element Here, Here, VectorFunctionSpace(mesh, "DG", 1)Firedrake implementationWe compute V_DG1 = FunctionSpace(mesh, "DG", 1, variant="equispaced")
v_dg1 = TestFunction(V_DG1)
area = CellVolume(mesh)
V_v_DG1 = VectorFunctionSpace(mesh, "DG", 1, variant="equispaced")
grad_v = Function(V_v_DG1)
grad_v_dg1 = assemble(grad(v_dg1)[0]/area*dx)
dim = mesh.geometric_dimension()
for i in range(dim):
assemble(grad(v_dg1)[i]/area*dx, tensor=grad_v_dg1)
grad_v.dat.data[:, i] = grad_v_dg1.dat.data[:]With this construction, the gradient bilinear form can be implemented as (dim + 1) * inner(grad(u), g * v * grad_v) * dx(scheme=vertex_rule)where def get_vertex_qrule(topological_dim):
import FIAT, finat
dim2cell = {
1: FIAT.reference_element.UFCInterval(),
2: FIAT.reference_element.UFCTriangle(),
3: FIAT.reference_element.UFCTetrahedron()
}
ref_cell = dim2cell.get(topological_dim, None)
if ref_cell is None:
raise NotImplementedError
point_set = finat.quadrature.PointSet(ref_cell.vertices)
weights = [1 / math.factorial(len(ref_cell.vertices))] * len(ref_cell.vertices)
return finat.quadrature.QuadratureRule(point_set, weights) |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I am using Firedrake to solve a variational problem involving an interpolated test function, for example
$u$ and $v$ are the trial and test functions, $g$ is a known function, and $I_h$ denotes an interpolation operator.
dot(grad(u), grad(I_h(g*v))) * dx,where
I can handle this formulation by using$\mathbb{R}$ (Real) space, this approach no longer works. In this case, the solver uses field splitting, and the subproblems obtained after splitting cannot apply the same
post_jacobian_callbackwhen defining the solver. However, when the problem involves anpost_jacobian_callbackmodification.I tried patching the
_SNESContext.splitfunction to add callback functions to the subproblems, modifying both theAssembledPCto correct the matrix and theImplicitMatrixContextto correct the operator action. However, the results still seem incorrect. Am I missing something?Do you have any suggestions on how to handle this situation?
Beta Was this translation helpful? Give feedback.
All reactions