I want to optimize the vertex positions in a mesh, with a given cost function on the associated triangles. The paper gives a cost function, which evaluates to an real number by using a sum over the triangles in the mesh, which connect the vertices to a valid simplical complex. They suggest to use a L-BFGS solver and i want to use PETSc to for the calculations.
The solver interface for L-BFGS (and some other algorithms) in PETSc gets a vector with the current values and has a pointer to a output vector for the residual values, with the same cardinality.
How do i design the cost function and the residual vector based on the cost function to evaluate the cost of vertex positions based on the resulting triangles?
i filled the f vector like this: $[v_1^x, v_1^y, v_1^z, \dots, v_N^x, v_N^y, v_N^z]$.
What do it put in the vector returned to get a good solution? I tried ...
- all the same: $\text{cost}(v) \equiv cost \in \mathbb{R}\ \forall v$ (
VecSet(r, cost)
.) - $\text{cost}(v_i^x) = \text{cost}(v_i^y) = \text{cost}(v_i^z) = \sum_{t \in T, v_i\in t} \text{cost}(t)\ \forall i=1\dots N$ with $T$ as the set of all triangles and the relation $v \in t$ when $v$ is a vertex of a triangle $t$.
Both do not obtain good solutions. Further i guess the residual may need to differ in x,y,z to get useful gradients for moving the vertices.