Accessing array of unknown dofs #848
Answered
by
joostvanzwieten
TomvanSluijs
asked this question in
Q&A
-
|
Hi, We want to take the time derivative of a residual by using a chain rule. As shown in the mwe below, we want to take the derivative to the dofs of variable u and we still need to multiply by the dofs of the time derivative of u, which is a separate field called dudt. However, we are not able to do this multiplication. Can you help us with the syntax of the line where dres_dt is defined? Best, |
Beta Was this translation helpful? Give feedback.
Answered by
joostvanzwieten
Jan 26, 2024
Replies: 1 comment
-
|
This should work dres_dt = res.derivative("udofs") @ function.Argument('dudtdofs', ns.basis.shape)Alternatively you can define ns = Namespace()
ns.x = geom
ns.define_for('x', gradient='∇', normal='n', jacobians=('dV', 'dS'))
ns.basis = domain.basis(btype, degree=degree)
ns.add_field(('u0', 'dudt', 'v'), ns.basis)
ns.add_field('t')
ns.u = 'u0 + t dudt'
res = domain.integral('∇_i(v) ∇_i(u) dV' @ ns, degree=degree*2)
res -= domain.boundary['right'].integral('v cos(1) cosh(x_1) dS' @ ns, degree=degree*2)
dres_dt = res.derivative('t')
''' |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
TomvanSluijs
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This should work
Alternatively you can define
uasu0 + t dudtand take the derivative tot: