Firedrake assemble of bilinear form and Boundary conditions question. #3948
-
Hi, I would like your help in order to clarify some things I have not understand about the application of boundary conditions using Firedrake.
in order to use a neural network to approximate the solution using a loss function My question is that when I execute the code |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
There's a couple of things to say here. The direct answer is that if you want the reduced global matrix then you need to use The second thing is that you seem to be hand-rolling a Firedrake-ml coupling. We actually already have those for Pytorch and JAX, and you could use the same template to create solutions for other frameworks. The coupling code is in https://www.firedrakeproject.org/firedrake.ml.html and there's an arXiv paper about it at: https://arxiv.org/pdf/2303.06871 In this case, I don't think you want to create the matrix at all. You can just tape the evaluation of the loss in Firedrake, and wrap that computation up as a ReducedFunctional. You then wrap that in a |
Beta Was this translation helpful? Give feedback.
-
@dham I modified the code
but when I execute
I get
which is not the same when I do it on a non RestrictedFuctionSpace. Am I doing something wrong? |
Beta Was this translation helpful? Give feedback.
There's a couple of things to say here. The direct answer is that if you want the reduced global matrix then you need to use
RestrictedFunctionSpace
to create test and trial spaces restricted to the non-constrained dofs. If you assemble a matrix or residual based on those then you'll get the restricted matrix.The second thing is that you seem to be hand-rolling a Firedrake-ml coupling. We actually already have those for Pytorch and JAX, and you could use the same template to create solutions for other frameworks. The coupling code is in https://www.firedrakeproject.org/firedrake.ml.html and there's an arXiv paper about it at: https://arxiv.org/pdf/2303.06871
In this case, I don't think y…