fix: add velocity to nodal function
This commit is contained in:
19
src/Grid.fs
19
src/Grid.fs
@@ -361,7 +361,7 @@ module Util =
|
||||
Sx / a, Sy / a, r
|
||||
|
||||
static member propToNodal (nIdx: NeighborIndex) (s: float []) =
|
||||
[| 0 .. nIdx.NodesAroundNode.Count - 1 |]
|
||||
[| 0 .. nIdx.NodesAroundNode.Count - 1 |] // total number of nodes
|
||||
|> Array.Parallel.map (fun i ->
|
||||
let ns = nIdx.ElemsAroundNode[i]
|
||||
ns
|
||||
@@ -369,7 +369,7 @@ module Util =
|
||||
|> (*) (1. / float ns.Length))
|
||||
|
||||
static member speedToNodal (nIdx: NeighborIndex) (s: (float * float) []) =
|
||||
[| 0 .. nIdx.NodesAroundNode.Count - 1 |]
|
||||
[| 0 .. nIdx.NodesAroundNode.Count - 1 |] // total number of nodes
|
||||
|> Array.Parallel.map (fun i ->
|
||||
let ns = nIdx.ElemsAroundNode[i]
|
||||
ns
|
||||
@@ -380,6 +380,19 @@ module Util =
|
||||
0.
|
||||
|> (*) (1. / float ns.Length))
|
||||
|
||||
static member velocityToNodal (nIdx: NeighborIndex) (s: (float * float) []) =
|
||||
[| 0 .. nIdx.NodesAroundNode.Count - 1 |] // total number of nodes
|
||||
|> Array.Parallel.map (fun i ->
|
||||
let ns = nIdx.ElemsAroundNode[i]
|
||||
let n = float ns.Length
|
||||
ns
|
||||
|> Array.fold
|
||||
(fun (au, av) n ->
|
||||
let u, v = s[n]
|
||||
u + au, v + av)
|
||||
(0., 0.)
|
||||
|> fun (u, v) -> u / n, v / n)
|
||||
|
||||
type Node =
|
||||
static member calcNodeControlArea (idx: NeighborIndex) (grid: IGrid) =
|
||||
let half = (*) 0.5
|
||||
@@ -670,4 +683,4 @@ type ExtendedGrid(grid: IGrid) =
|
||||
elementTree <- binarySerializer.UnPickle<IdxTree> pickle |> Some
|
||||
true
|
||||
else
|
||||
false
|
||||
false
|
||||
Reference in New Issue
Block a user