# Set up and plot a square with side length one with 32 interior triangles,
# and then create an order one functional basis object of type FEM.
m <- 4
petList <- squareMesh(m)
pts <- petList$p
edg <- petList$e
tri <- petList$t
pts <- pts/m
plotFEM.mesh(pts, tri)
norder <- 1
FEMbasis <- create.FEM.basis(pts, edg, tri, norder)
# set up surface values on the nodes of this mesh
data <- sin(2*pi*pts[,1])*cos(2*pi*pts[,2])
# smooth the data
FEMList <- smooth.FEM.basis(pts, data, FEMbasis)
sincosfd <- FEMList$fd
# set up a 21 by 21 grid of plotting points
Npts <- 21
Xpts <- seq(0,1,len=Npts)
Ypts <- Xpts
# plot the surface
oldpar <- par(no.readonly = TRUE)
plotFEM.fd(sincosfd, Xpts, Ypts)
# plot the X partial derivative of the surface
plotFEM.fd(sincosfd, Xpts, Ypts, c(1,0))
# plot the Y partial derivative of the surface
plotFEM.fd(sincosfd, Xpts, Ypts, c(0,1))
par(oldpar)
Run the code above in your browser using DataLab