(*Preparation of Neumann boundary conditions for v*)
gradu = {x, y} \[Function] Evaluate[D[ufun[x, y], {{x, y}, 1}]];
J = N@RotationMatrix[Pi/2];
p = R["Coordinates"];
{i, j} = Transpose[R["BoundaryElements"][[1, 1]]];
normalprojections = MapThread[Dot, {R["BoundaryNormals"][[1]]MapThreadDot[R["BoundaryNormals"][[1]], (gradu @@@ (0.5 (p[[i]] + p[[j]]))).(-J)}];
boundaryedgelengts = Sqrt[Total[(p[[i]] - p[[j]])^2, {2}]];
{α, β} = Transpose[bndedges];
vertexbndedgeconnectivity = SparseArray[
Transpose[{
Join[α, β],
Join[Range[Length[α]], Range[Length[β]]]
}] -> 1,
{Length[p], Length[bndedges]}
];
(*Solving the system and creating an interpolating function*)
b = vertexbndedgeconnectivity.(normalprojections boundaryedgelengts);
vvals = solver[b];
vfun = ElementMeshInterpolation[{R}, vvals];
tex = Import["https://i.sstatic.net/gRwc1.png"];
texcoords = Transpose[{
Total[(f @@@ p)^2, {2}],
ConstantArray[0.5, Length[p]]
}];
g = GraphicsRow[{
Graphics[{
Texture[tex],
GraphicsComplex[
p,
Polygon@R["MeshElements"][[1, 1]]ElementMeshToGraphicsComplex[R,
VertexTextureCoordinates -> texcoords
]texcoords]
}],
Graphics[{
Texture[tex],
GraphicsComplex[
f @@@ pElementMeshToGraphicsComplex[R,
VertexTextureCoordinates -> Polygon@R["MeshElements"][[1texcoords, 1]],
VertexTextureCoordinates"CoordinateConversion" -> texcoords
(f @@@ # &)]
}]
},
ImageSize -> Full]Full
]