You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The following example surprisingly executes just fine and hides a wrong problem formulation.
frommpi4pyimportMPIimportnumpyasnpimportdolfinximportufln=32mesh=dolfinx.mesh.create_unit_square(
MPI.COMM_WORLD, n, n, ghost_mode=dolfinx.mesh.GhostMode.shared_facet
)
V=dolfinx.fem.functionspace(mesh, ("P", 1))
f=1L=dolfinx.fem.form(f*ufl.TestFunction(V) *ufl.dx)
L_trial=dolfinx.fem.form(f*ufl.TrialFunction(V) *ufl.dx)
b=dolfinx.fem.assemble_vector(L)
b_trial=dolfinx.fem.assemble_vector(L_trial)
assertnp.allclose(b.x.array, b_trial.x.array)
Since for uflTrialFunction and TestFunction only differ in labelling, it makes sense that this works. However, equivalently a linear form with argument being a trial function (which is defined as the argument after a test function) does not make any sense on usage level.
I don’t really see an issue with it working with a trialfunction.
A trialfunction is just a wrapper around ufl.Argument that ensures that it is ordered first if one has both test and trial functions in the form.
A user could even use ufl.Argument, with any number as input. I once tested this for a form with a TrialFunction, TestFunction and an Argument(V, number=3) to make a form for a rank three tensor.
Having an argument labeled '2', to indicate its the second argument, without a first argument existing sounds inconsistent to me.
It also allows for code smells such as
u,v = TrialFunction(V), TestFunction(V)
u*v * ufl.dx == u * ufl.dx
if in this case a was not symmetric it could even be functionally different.
The latter line here is to indicate a UFL equation?
I’ll leave it to other developers to chime in on this, but personally I think it is a user-responsibility to ensure that the variational forms make sense.
Describe new/missing feature
The following example surprisingly executes just fine and hides a wrong problem formulation.
Since for
ufl
TrialFunction
andTestFunction
only differ in labelling, it makes sense that this works. However, equivalently a linear form with argument being a trial function (which is defined as the argument after a test function) does not make any sense on usage level.Suggested user interface
The text was updated successfully, but these errors were encountered: