View source: R/MovementMatrix_Fn.R
1 | MovementMatrix_Fn(mesh, TriList)
|
mesh |
|
TriList |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | ##---- Should be DIRECTLY executable !! ----
##-- ==> Define data, use random,
##-- or do help(data=index) for the standard data sets.
## The function is currently defined as
function (mesh, TriList)
{
M1 = M2 = M3 = M4 = matrix(0, ncol = n_r, nrow = n_r)
for (i in 1:n_r) {
for (j in 1:3) {
if (!is.na(mesh$graph$tt[i, j])) {
v2 <- list(TriList$E0, TriList$E1, TriList$E2)[[j]][i,
]
M1[mesh$graph$tt[i, j], i] = M1[mesh$graph$tt[i,
j], i] + posflux(c(1, 0), v2)/TriList$Tri_Area[i]
M2[mesh$graph$tt[i, j], i] = M2[mesh$graph$tt[i,
j], i] + posflux(c(0, 1), v2)/TriList$Tri_Area[i]
M3[mesh$graph$tt[i, j], i] = M3[mesh$graph$tt[i,
j], i] + posflux(c(-1, 0), v2)/TriList$Tri_Area[i]
M4[mesh$graph$tt[i, j], i] = M4[mesh$graph$tt[i,
j], i] + posflux(c(0, -1), v2)/TriList$Tri_Area[i]
}
}
M1[i, i] = -1 * sum(M1[, i])
M2[i, i] = -1 * sum(M2[, i])
M3[i, i] = -1 * sum(M3[, i])
M4[i, i] = -1 * sum(M4[, i])
}
maxout = max(abs(diag(M1 + M2 + M3 + M4)))
Return = list(maxout = maxout, M1 = M1/maxout, M2 = M2/maxout,
M3 = M3/maxout, M4 = M4/maxout)
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.