mesh-adaptation / animate

Anisotropic mesh adaptation toolkit for Firedrake
MIT License
5 stars 0 forks source link

Bug-fix for Riemann init from tensor field (copy) with active tape #64

Closed stephankramer closed 6 months ago

stephankramer commented 6 months ago

In the following example

from firedrake import *
from animate import RiemannianMetric
from firedrake_adjoint import *
mesh=UnitSquareMesh(1,1)
TP=TensorFunctionSpace(mesh, "CG", 1)
T=Function(TP)
x=RiemannianMetric(T)

because the tape is switched on, when RiemannianMetric's __init__ is called, which in turn calls __init__of Function, the input metric/tensor T is copied onto tape. This uses the RiemannianMetric copy method. It succesfully creates a copy of the tensor and turns it into a RiemannianMetric, but then tries to copy metric_parameters from self (the new Riemannian metric being created) to the copy, but self does not have metric_parameters yet.