user: Please show me the C implementation that matches the assembly code listed below:

```asm
<VolumeAveragedNavierStokesFullDevStress_3D_Evaluate>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x68,%rsp
  movsd  %xmm0,0x8(%rsp)
  movsd  %xmm1,(%rsp)
  mov    %rsi,0x40(%rsp)
  mov    %rdx,0x48(%rsp)
  mov    %r8,0x50(%rsp)
  test   %edi,%edi
  jle    L54
  mov    0xb0(%rsp),%rbx
  mov    %r9,0x10(%rsp)
  mov    0xa0(%rsp),%r13
  mov    0xa8(%rsp),%r12
  mov    %edi,%eax
  mov    %rax,0x58(%rsp)
  movq   $0x0,0x18(%rsp)
  mov    $0x0,%r14d
  mov    $0x0,%r15d
  jmp    L25
L26:
  movapd %xmm6,%xmm0
  call   <sqrt@plt>
  movapd %xmm0,%xmm6
  jmp    L5
L58:
  movapd %xmm2,%xmm3
  mulsd  %xmm6,%xmm3
  movsd  D26(%rip),%xmm5
  addsd  %xmm5,%xmm3
  movapd %xmm1,%xmm4
  mulsd  %xmm1,%xmm4
  movsd  (%rsp),%xmm8
  mulsd  %xmm8,%xmm4
  mulsd  %xmm0,%xmm4
  mulsd  %xmm3,%xmm4
  mulsd  0x20(%rsp),%xmm4
  xorpd  D57(%rip),%xmm1
  movsd  0x8(%rsp),%xmm9
  mulsd  %xmm9,%xmm1
  mov    0x48(%rsp),%rdi
  mulsd  (%rdi),%xmm1
  addsd  %xmm4,%xmm1
  mov    0x1b0(%rsp),%rax
  movsd  %xmm1,(%rax,%r15,8)
  movsd  0x0(%rbp),%xmm4
  movapd %xmm4,%xmm1
  mulsd  %xmm4,%xmm1
  mulsd  %xmm8,%xmm1
  mulsd  %xmm0,%xmm1
  mulsd  %xmm3,%xmm1
  mov    0x30(%rsp),%rax
  mulsd  (%rax),%xmm1
  xorpd  D57(%rip),%xmm4
  mulsd  %xmm9,%xmm4
  mulsd  0x8(%rdi),%xmm4
  addsd  %xmm4,%xmm1
  mov    0x1b8(%rsp),%rdx
  movsd  %xmm1,(%rdx,%r15,8)
  movsd  0x0(%rbp),%xmm4
  movapd %xmm4,%xmm1
  mulsd  %xmm4,%xmm1
  mulsd  %xmm8,%xmm1
  mulsd  %xmm0,%xmm1
  mulsd  %xmm3,%xmm1
  mov    0x38(%rsp),%rdx
  mulsd  (%rdx),%xmm1
  xorpd  D57(%rip),%xmm4
  mulsd  %xmm9,%xmm4
  mulsd  0x10(%rdi),%xmm4
  addsd  %xmm4,%xmm1
  mov    0x1c0(%rsp),%rsi
  movsd  %xmm1,(%rsi,%r15,8)
  movsd  0x0(%rbp),%xmm4
  mov    0x28(%rsp),%rsi
  movsd  (%rsi),%xmm1
  movapd %xmm6,%xmm3
  addsd  D115(%rip),%xmm3
  mulsd  %xmm1,%xmm1
  divsd  %xmm3,%xmm1
  addsd  %xmm6,%xmm1
  mulsd  %xmm2,%xmm1
  addsd  %xmm5,%xmm1
  mulsd  %xmm4,%xmm4
  mulsd  %xmm8,%xmm4
  mulsd  %xmm0,%xmm4
  mulsd  %xmm4,%xmm1
  mov    0x1c8(%rsp),%rdi
  movsd  %xmm1,(%rdi,%r15,8)
  movsd  0x0(%rbp),%xmm7
  movsd  (%rax),%xmm1
  mulsd  (%rsi),%xmm1
  divsd  %xmm3,%xmm1
  mulsd  %xmm2,%xmm1
  pxor   %xmm4,%xmm4
  addsd  %xmm4,%xmm1
  mulsd  %xmm7,%xmm7
  mulsd  %xmm8,%xmm7
  mulsd  %xmm0,%xmm7
  mulsd  %xmm7,%xmm1
  mov    0x1d0(%rsp),%rcx
  movsd  %xmm1,(%rcx,%r15,8)
  movsd  0x0(%rbp),%xmm7
  movsd  (%rdx),%xmm1
  mulsd  (%rsi),%xmm1
  divsd  %xmm3,%xmm1
  mulsd  %xmm2,%xmm1
  addsd  %xmm4,%xmm1
  mulsd  %xmm7,%xmm7
  mulsd  %xmm8,%xmm7
  mulsd  %xmm0,%xmm7
  mulsd  %xmm7,%xmm1
  mov    0x1d8(%rsp),%rdi
  movsd  %xmm1,(%rdi,%r15,8)
  movsd  0x0(%rbp),%xmm7
  movsd  (%rax),%xmm1
  mulsd  %xmm1,%xmm1
  divsd  %xmm3,%xmm1
  addsd  %xmm6,%xmm1
  mulsd  %xmm2,%xmm1
  addsd  %xmm5,%xmm1
  mulsd  %xmm7,%xmm7
  mulsd  %xmm8,%xmm7
  mulsd  %xmm0,%xmm7
  mulsd  %xmm7,%xmm1
  mov    0x1e8(%rsp),%rcx
  movsd  %xmm1,(%rcx,%r15,8)
  movsd  0x0(%rbp),%xmm7
  movsd  (%rsi),%xmm1
  mulsd  (%rax),%xmm1
  divsd  %xmm3,%xmm1
  mulsd  %xmm2,%xmm1
  addsd  %xmm4,%xmm1
  mulsd  %xmm7,%xmm7
  mulsd  %xmm8,%xmm7
  mulsd  %xmm0,%xmm7
  mulsd  %xmm7,%xmm1
  mov    0x1e0(%rsp),%rdi
  movsd  %xmm1,(%rdi,%r15,8)
  movsd  0x0(%rbp),%xmm7
  movsd  (%rdx),%xmm1
  mulsd  (%rax),%xmm1
  divsd  %xmm3,%xmm1
  mulsd  %xmm2,%xmm1
  addsd  %xmm4,%xmm1
  mulsd  %xmm7,%xmm7
  mulsd  %xmm8,%xmm7
  mulsd  %xmm0,%xmm7
  mulsd  %xmm7,%xmm1
  mov    0x1f0(%rsp),%rcx
  movsd  %xmm1,(%rcx,%r15,8)
  movsd  0x0(%rbp),%xmm7
  movsd  (%rdx),%xmm1
  mulsd  %xmm1,%xmm1
  divsd  %xmm3,%xmm1
  addsd  %xmm6,%xmm1
  mulsd  %xmm2,%xmm1
  addsd  %xmm5,%xmm1
  mulsd  %xmm7,%xmm7
  mulsd  %xmm8,%xmm7
  mulsd  %xmm0,%xmm7
  mulsd  %xmm7,%xmm1
  mov    0x208(%rsp),%rdi
  movsd  %xmm1,(%rdi,%r15,8)
  movsd  0x0(%rbp),%xmm5
  movsd  (%rsi),%xmm1
  mulsd  (%rdx),%xmm1
  divsd  %xmm3,%xmm1
  mulsd  %xmm2,%xmm1
  addsd  %xmm4,%xmm1
  mulsd  %xmm5,%xmm5
  mulsd  %xmm8,%xmm5
  mulsd  %xmm0,%xmm5
  mulsd  %xmm5,%xmm1
  mov    0x1f8(%rsp),%rsi
  movsd  %xmm1,(%rsi,%r15,8)
  movsd  0x0(%rbp),%xmm5
  movsd  (%rax),%xmm1
  mulsd  (%rdx),%xmm1
  divsd  %xmm3,%xmm1
  mulsd  %xmm2,%xmm1
  addsd  %xmm4,%xmm1
  mulsd  %xmm5,%xmm5
  mulsd  %xmm8,%xmm5
  mulsd  %xmm0,%xmm5
  mulsd  %xmm5,%xmm1
  mov    0x200(%rsp),%rax
  movsd  %xmm1,(%rax,%r15,8)
  movsd  0x0(%rbp),%xmm0
  mov    0x50(%rsp),%rax
  mulsd  (%rax,%r14,1),%xmm0
  mov    0x210(%rsp),%rdx
  movsd  %xmm0,(%rdx,%r15,8)
  movsd  0x0(%rbp),%xmm0
  mov    0x218(%rsp),%rdx
  movsd  %xmm0,(%rdx,%r14,1)
  mulsd  0x8(%rax,%r14,1),%xmm0
  mov    0x220(%rsp),%rsi
  movsd  %xmm0,(%rsi,%r15,8)
  movsd  0x0(%rbp),%xmm0
  mov    0x228(%rsp),%rdx
  movsd  %xmm0,0x8(%rdx,%r14,1)
  mulsd  0x10(%rax,%r14,1),%xmm0
  mov    0x230(%rsp),%rax
  movsd  %xmm0,(%rax,%r15,8)
  movsd  0x0(%rbp),%xmm0
  mov    0x238(%rsp),%rax
  movsd  %xmm0,0x10(%rax,%r14,1)
  add    $0x1,%r15
  add    $0x8,%rbx
  addq   $0x8,0x10(%rsp)
  add    $0x8,%r13
  add    $0x8,%r12
  add    $0x18,%r14
  addq   $0x48,0x18(%rsp)
  cmp    0x58(%rsp),%r15
  je     L54
L25:
  mov    %rbx,%rbp
  mov    0x10(%rsp),%rcx
  mov    %rcx,0x28(%rsp)
  movsd  0x8(%rsp),%xmm6
  movapd %xmm6,%xmm0
  mulsd  (%rbx),%xmm0
  mulsd  (%rcx),%xmm0
  mov    0xb8(%rsp),%rdi
  movsd  %xmm0,(%rdi,%r15,8)
  movapd %xmm6,%xmm0
  mulsd  (%rbx),%xmm0
  mov    0xc0(%rsp),%rdi
  movsd  %xmm0,(%rdi,%r15,8)
  mov    %r13,0x30(%rsp)
  movapd %xmm6,%xmm0
  mulsd  (%rbx),%xmm0
  mulsd  0x0(%r13),%xmm0
  mov    0xc8(%rsp),%rdi
  movsd  %xmm0,(%rdi,%r15,8)
  movapd %xmm6,%xmm0
  mulsd  (%rbx),%xmm0
  mov    0xd0(%rsp),%rdi
  movsd  %xmm0,(%rdi,%r15,8)
  mov    %r12,0x38(%rsp)
  movapd %xmm6,%xmm0
  mulsd  (%rbx),%xmm0
  mulsd  (%r12),%xmm0
  mov    0xd8(%rsp),%rdi
  movsd  %xmm0,(%rdi,%r15,8)
  movapd %xmm6,%xmm0
  mulsd  (%rbx),%xmm0
  mov    0xe0(%rsp),%rsi
  movsd  %xmm0,(%rsi,%r15,8)
  movsd  (%rbx),%xmm0
  mulsd  (%rcx),%xmm0
  mov    0xe8(%rsp),%rdi
  movsd  %xmm0,(%rdi,%r14,1)
  movsd  (%rbx),%xmm0
  mulsd  0x0(%r13),%xmm0
  movsd  %xmm0,0x8(%rdi,%r14,1)
  movsd  (%rbx),%xmm0
  mulsd  (%r12),%xmm0
  movsd  %xmm0,0x10(%rdi,%r14,1)
  movsd  (%rbx),%xmm0
  mov    0xf0(%rsp),%rsi
  movsd  %xmm0,(%rsi,%r14,1)
  mov    0xf8(%rsp),%rdi
  movsd  %xmm0,0x8(%rdi,%r14,1)
  movsd  (%rbx),%xmm0
  mov    0x100(%rsp),%rdx
  movsd  %xmm0,0x10(%rdx,%r14,1)
  movsd  (%rcx),%xmm1
  mulsd  %xmm6,%xmm0
  mulsd  %xmm1,%xmm0
  mulsd  %xmm1,%xmm0
  mov    0x108(%rsp),%rsi
  movsd  %xmm0,(%rsi,%r14,1)
  movapd %xmm6,%xmm0
  mulsd  (%rbx),%xmm0
  mulsd  (%rcx),%xmm0
  mulsd  0x0(%r13),%xmm0
  movsd  %xmm0,0x8(%rsi,%r14,1)
  movapd %xmm6,%xmm0
  mulsd  (%rbx),%xmm0
  mulsd  (%rcx),%xmm0
  mulsd  (%r12),%xmm0
  movsd  %xmm0,0x10(%rsi,%r14,1)
  movsd  (%rbx),%xmm0
  addsd  %xmm0,%xmm0
  mulsd  %xmm6,%xmm0
  mulsd  (%rcx),%xmm0
  mov    0x110(%rsp),%rax
  movsd  %xmm0,(%rax,%r14,1)
  movapd %xmm6,%xmm0
  mulsd  (%rbx),%xmm0
  mulsd  0x0(%r13),%xmm0
  movsd  %xmm0,0x8(%rax,%r14,1)
  movapd %xmm6,%xmm0
  mulsd  (%rbx),%xmm0
  mulsd  (%r12),%xmm0
  movsd  %xmm0,0x10(%rax,%r14,1)
  movapd %xmm6,%xmm0
  mulsd  (%rbx),%xmm0
  mulsd  (%rcx),%xmm0
  mov    0x118(%rsp),%rax
  movsd  %xmm0,0x8(%rax,%r14,1)
  movapd %xmm6,%xmm0
  mulsd  (%rbx),%xmm0
  mulsd  (%rcx),%xmm0
  mov    0x120(%rsp),%rax
  movsd  %xmm0,0x10(%rax,%r14,1)
  movapd %xmm6,%xmm0
  mulsd  (%rbx),%xmm0
  mulsd  0x0(%r13),%xmm0
  mulsd  (%rcx),%xmm0
  mov    0x128(%rsp),%rax
  movsd  %xmm0,(%rax,%r14,1)
  movsd  0x0(%r13),%xmm1
  movapd %xmm6,%xmm0
  mulsd  (%rbx),%xmm0
  mulsd  %xmm1,%xmm0
  mulsd  %xmm1,%xmm0
  movsd  %xmm0,0x8(%rax,%r14,1)
  movapd %xmm6,%xmm0
  mulsd  (%rbx),%xmm0
  mulsd  0x0(%r13),%xmm0
  mulsd  (%r12),%xmm0
  movsd  %xmm0,0x10(%rax,%r14,1)
  movapd %xmm6,%xmm0
  mulsd  (%rbx),%xmm0
  mulsd  0x0(%r13),%xmm0
  mov    0x130(%rsp),%rax
  movsd  %xmm0,(%rax,%r14,1)
  movapd %xmm6,%xmm0
  mulsd  (%rbx),%xmm0
  mulsd  0x0(%r13),%xmm0
  mov    0x140(%rsp),%rax
  movsd  %xmm0,0x10(%rax,%r14,1)
  movapd %xmm6,%xmm0
  mulsd  (%rbx),%xmm0
  mulsd  (%rcx),%xmm0
  mov    0x138(%rsp),%rax
  movsd  %xmm0,(%rax,%r14,1)
  movsd  (%rbx),%xmm0
  addsd  %xmm0,%xmm0
  mulsd  %xmm6,%xmm0
  mulsd  0x0(%r13),%xmm0
  movsd  %xmm0,0x8(%rax,%r14,1)
  movapd %xmm6,%xmm0
  mulsd  (%rbx),%xmm0
  mulsd  (%r12),%xmm0
  movsd  %xmm0,0x10(%rax,%r14,1)
  movapd %xmm6,%xmm0
  mulsd  (%rbx),%xmm0
  mulsd  (%r12),%xmm0
  mulsd  (%rcx),%xmm0
  mov    0x148(%rsp),%rax
  movsd  %xmm0,(%rax,%r14,1)
  movapd %xmm6,%xmm0
  mulsd  (%rbx),%xmm0
  mulsd  (%r12),%xmm0
  mulsd  0x0(%r13),%xmm0
  movsd  %xmm0,0x8(%rax,%r14,1)
  movsd  (%r12),%xmm1
  movapd %xmm6,%xmm0
  mulsd  (%rbx),%xmm0
  mulsd  %xmm1,%xmm0
  mulsd  %xmm1,%xmm0
  movsd  %xmm0,0x10(%rax,%r14,1)
  movapd %xmm6,%xmm0
  mulsd  (%rbx),%xmm0
  mulsd  (%r12),%xmm0
  mov    0x150(%rsp),%rax
  movsd  %xmm0,(%rax,%r14,1)
  movapd %xmm6,%xmm0
  mulsd  (%rbx),%xmm0
  mulsd  (%r12),%xmm0
  mov    0x158(%rsp),%rax
  movsd  %xmm0,0x8(%rax,%r14,1)
  movapd %xmm6,%xmm0
  mulsd  (%rbx),%xmm0
  mulsd  (%rcx),%xmm0
  mov    0x160(%rsp),%rax
  movsd  %xmm0,(%rax,%r14,1)
  movapd %xmm6,%xmm0
  mulsd  (%rbx),%xmm0
  mulsd  0x0(%r13),%xmm0
  movsd  %xmm0,0x8(%rax,%r14,1)
  movsd  (%rbx),%xmm0
  addsd  %xmm0,%xmm0
  mulsd  %xmm6,%xmm0
  mulsd  (%r12),%xmm0
  movsd  %xmm0,0x10(%rax,%r14,1)
  movsd  (%rbx),%xmm0
  addsd  %xmm0,%xmm0
  movsd  (%rsp),%xmm5
  mulsd  %xmm5,%xmm0
  mov    0x168(%rsp),%rdx
  mov    0x18(%rsp),%rax
  movsd  %xmm0,(%rdx,%rax,1)
  movapd %xmm5,%xmm0
  mulsd  (%rbx),%xmm0
  movsd  %xmm0,0x20(%rdx,%rax,1)
  movapd %xmm5,%xmm0
  mulsd  (%rbx),%xmm0
  movsd  %xmm0,0x40(%rdx,%rax,1)
  movapd %xmm5,%xmm0
  mulsd  (%rbx),%xmm0
  mov    0x180(%rsp),%rdx
  movsd  %xmm0,0x18(%rdx,%rax,1)
  movapd %xmm5,%xmm0
  mulsd  (%rbx),%xmm0
  mov    0x188(%rsp),%rsi
  movsd  %xmm0,0x30(%rsi,%rax,1)
  movapd %xmm5,%xmm0
  mulsd  (%rbx),%xmm0
  mov    0x170(%rsp),%rdi
  movsd  %xmm0,(%rdi,%rax,1)
  movsd  (%rbx),%xmm0
  addsd  %xmm0,%xmm0
  mulsd  %xmm5,%xmm0
  movsd  %xmm0,0x20(%rdi,%rax,1)
  movapd %xmm5,%xmm0
  mulsd  (%rbx),%xmm0
  movsd  %xmm0,0x40(%rdi,%rax,1)
  movapd %xmm5,%xmm0
  mulsd  (%rbx),%xmm0
  mov    0x190(%rsp),%rdi
  movsd  %xmm0,0x8(%rdi,%rax,1)
  movapd %xmm5,%xmm0
  mulsd  (%rbx),%xmm0
  mov    0x198(%rsp),%rdx
  movsd  %xmm0,0x38(%rdx,%rax,1)
  movapd %xmm5,%xmm0
  mulsd  (%rbx),%xmm0
  mov    0x178(%rsp),%rsi
  movsd  %xmm0,(%rsi,%rax,1)
  movapd %xmm5,%xmm0
  mulsd  (%rbx),%xmm0
  movsd  %xmm0,0x20(%rsi,%rax,1)
  movsd  (%rbx),%xmm0
  addsd  %xmm0,%xmm0
  mulsd  %xmm5,%xmm0
  movsd  %xmm0,0x40(%rsi,%rax,1)
  movapd %xmm5,%xmm0
  mulsd  (%rbx),%xmm0
  mov    0x1a0(%rsp),%rsi
  movsd  %xmm0,0x10(%rsi,%rax,1)
  mulsd  (%rbx),%xmm5
  mov    0x1a8(%rsp),%rdi
  movsd  %xmm5,0x28(%rdi,%rax,1)
  movsd  (%rcx),%xmm6
  movsd  %xmm6,0x20(%rsp)
  movsd  0x0(%r13),%xmm1
  movsd  (%r12),%xmm0
  mulsd  %xmm6,%xmm6
  mulsd  %xmm1,%xmm1
  addsd  %xmm1,%xmm6
  mulsd  %xmm0,%xmm0
  addsd  %xmm0,%xmm6
  pxor   %xmm3,%xmm3
  ucomisd %xmm6,%xmm3
  ja     L26
  sqrtsd %xmm6,%xmm6
L5:
  movsd  0x0(%rbp),%xmm1
  movsd  D26(%rip),%xmm4
  subsd  %xmm1,%xmm4
  movapd %xmm4,%xmm0
  andpd  D103(%rip),%xmm0
  pxor   %xmm2,%xmm2
  movsd  D82(%rip),%xmm3
  comisd %xmm0,%xmm3
  ja     L3
  mov    0x40(%rsp),%rax
  movapd %xmm1,%xmm2
  mulsd  (%rax,%r15,8),%xmm2
  mulsd  D55(%rip),%xmm2
  divsd  %xmm4,%xmm2
  divsd  (%rsp),%xmm2
L3:
  movapd %xmm1,%xmm3
  andpd  D103(%rip),%xmm3
  pxor   %xmm0,%xmm0
  movsd  D82(%rip),%xmm5
  comisd %xmm3,%xmm5
  ja     L58
  mov    0x40(%rsp),%rax
  movsd  (%rax,%r15,8),%xmm3
  movapd %xmm4,%xmm0
  mulsd  D21(%rip),%xmm0
  mulsd  %xmm4,%xmm0
  mulsd  %xmm3,%xmm3
  mulsd  %xmm1,%xmm3
  mulsd  %xmm1,%xmm3
  mulsd  %xmm1,%xmm3
  divsd  %xmm3,%xmm0
  jmp    L58
L54:
  add    $0x68,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
```

tool_calls: name: parse_data
arguments: data_tag: D26
type: f64
name: parse_data
arguments: data_tag: D57
type: f32[4]
name: parse_data
arguments: data_tag: D115
type: byte[8]
name: parse_data
arguments: data_tag: D103
type: qword[2]
name: parse_data
arguments: data_tag: D82
type: byte[8]
name: parse_data
arguments: data_tag: D55
type: byte[8]
name: parse_data
arguments: data_tag: D21
type: f64

tool: D26: 1

tool: {"D57": [0.0,-0.0,0.0,0.0]}

tool: {"D115": [0x11,0xea,0x2d,0x81,0x99,0x97,0x71,0x3d]}

tool: {"D103": [0x7fffffffffffffff,0x0000000000000000]}

tool: {"D82": [0x48,0xaf,0xbc,0x9a,0xf2,0xd7,0x7a,0x3e]}

tool: {"D55": [0x7b,0x14,0xae,0x47,0xe1,0x7a,0x84,0x3f]}

tool: D21: 180

assistant: ```c
void VolumeAveragedNavierStokesFullDevStress_3D_Evaluate(const int nPoints, const double rho, const double mu, const double *meanGrainSize, const double *g, const double *p, const double *grad_p, const double *u, const double *v, const double *w, const double *porosity, double *mom_u_acc, double *dmom_u_acc_u, double *mom_v_acc, double *dmom_v_acc_v, double *mom_w_acc, double *dmom_w_acc_w, double *mass_adv, double *dmass_adv_u, double *dmass_adv_v, double *dmass_adv_w, double *mom_u_adv, double *dmom_u_adv_u, double *dmom_u_adv_v, double *dmom_u_adv_w, double *mom_v_adv, double *dmom_v_adv_u, double *dmom_v_adv_v, double *dmom_v_adv_w, double *mom_w_adv, double *dmom_w_adv_u, double *dmom_w_adv_v, double *dmom_w_adv_w, double *mom_u_diff_ten, double *mom_v_diff_ten, double *mom_w_diff_ten, double *mom_uv_diff_ten, double *mom_uw_diff_ten, double *mom_vu_diff_ten, double *mom_vw_diff_ten, double *mom_wu_diff_ten, double *mom_wv_diff_ten, double *mom_u_source, double *mom_v_source, double *mom_w_source, double *dmom_u_source_u, double *dmom_u_source_v, double *dmom_u_source_w, double *dmom_v_source_u, double *dmom_v_source_v, double *dmom_v_source_w, double *dmom_w_source_u, double *dmom_w_source_v, double *dmom_w_source_w, double *mom_u_ham, double *dmom_u_ham_grad_p, double *mom_v_ham, double *dmom_v_ham_grad_p, double *mom_w_ham, double *dmom_w_ham_grad_p) {
  int k;
  double Ftilde, Kinv, uc;
  for (k = 0; k < nPoints; k++) {
    mom_u_acc[k] = porosity[k] * rho * u[k];
    dmom_u_acc_u[k] = porosity[k] * rho;
    mom_v_acc[k] = porosity[k] * rho * v[k];
    dmom_v_acc_v[k] = porosity[k] * rho;
    mom_w_acc[k] = porosity[k] * rho * w[k];
    dmom_w_acc_w[k] = porosity[k] * rho;
    mass_adv[k * 3 + 0] = porosity[k] * u[k];
    mass_adv[k * 3 + 1] = porosity[k] * v[k];
    mass_adv[k * 3 + 2] = porosity[k] * w[k];
    dmass_adv_u[k * 3 + 0] = porosity[k];
    dmass_adv_v[k * 3 + 1] = porosity[k];
    dmass_adv_w[k * 3 + 2] = porosity[k];
    mom_u_adv[k * 3 + 0] = porosity[k] * rho * u[k] * u[k];
    mom_u_adv[k * 3 + 1] = porosity[k] * rho * u[k] * v[k];
    mom_u_adv[k * 3 + 2] = porosity[k] * rho * u[k] * w[k];
    dmom_u_adv_u[k * 3 + 0] = 2.0 * porosity[k] * rho * u[k];
    dmom_u_adv_u[k * 3 + 1] = porosity[k] * rho * v[k];
    dmom_u_adv_u[k * 3 + 2] = porosity[k] * rho * w[k];
    dmom_u_adv_v[k * 3 + 1] = porosity[k] * rho * u[k];
    dmom_u_adv_w[k * 3 + 2] = porosity[k] * rho * u[k];
    mom_v_adv[k * 3 + 0] = porosity[k] * rho * v[k] * u[k];
    mom_v_adv[k * 3 + 1] = porosity[k] * rho * v[k] * v[k];
    mom_v_adv[k * 3 + 2] = porosity[k] * rho * v[k] * w[k];
    dmom_v_adv_u[k * 3 + 0] = porosity[k] * rho * v[k];
    dmom_v_adv_w[k * 3 + 2] = porosity[k] * rho * v[k];
    dmom_v_adv_v[k * 3 + 0] = porosity[k] * rho * u[k];
    dmom_v_adv_v[k * 3 + 1] = 2.0 * porosity[k] * rho * v[k];
    dmom_v_adv_v[k * 3 + 2] = porosity[k] * rho * w[k];
    mom_w_adv[k * 3 + 0] = porosity[k] * rho * w[k] * u[k];
    mom_w_adv[k * 3 + 1] = porosity[k] * rho * w[k] * v[k];
    mom_w_adv[k * 3 + 2] = porosity[k] * rho * w[k] * w[k];
    dmom_w_adv_u[k * 3 + 0] = porosity[k] * rho * w[k];
    dmom_w_adv_v[k * 3 + 1] = porosity[k] * rho * w[k];
    dmom_w_adv_w[k * 3 + 0] = porosity[k] * rho * u[k];
    dmom_w_adv_w[k * 3 + 1] = porosity[k] * rho * v[k];
    dmom_w_adv_w[k * 3 + 2] = 2.0 * porosity[k] * rho * w[k];
    mom_u_diff_ten[k * 9 + 0] = 2.0 * porosity[k] * mu;
    mom_u_diff_ten[k * 9 + 4] = porosity[k] * mu;
    mom_u_diff_ten[k * 9 + 8] = porosity[k] * mu;
    mom_uv_diff_ten[k * 9 + 3] = porosity[k] * mu;
    mom_uw_diff_ten[k * 9 + 6] = porosity[k] * mu;
    mom_v_diff_ten[k * 9 + 0] = porosity[k] * mu;
    mom_v_diff_ten[k * 9 + 4] = 2.0 * porosity[k] * mu;
    mom_v_diff_ten[k * 9 + 8] = porosity[k] * mu;
    mom_vu_diff_ten[k * 9 + 1] = porosity[k] * mu;
    mom_vw_diff_ten[k * 9 + 7] = porosity[k] * mu;
    mom_w_diff_ten[k * 9 + 0] = porosity[k] * mu;
    mom_w_diff_ten[k * 9 + 4] = porosity[k] * mu;
    mom_w_diff_ten[k * 9 + 8] = 2.0 * porosity[k] * mu;
    mom_wu_diff_ten[k * 9 + 2] = porosity[k] * mu;
    mom_wv_diff_ten[k * 9 + 5] = porosity[k] * mu;
    uc = sqrt(u[k] * u[k] + v[k] * v[k] + w[k] * w[k]);
    if (fabs(1.0 - porosity[k]) < 1.0e-7)
      Ftilde = 0.0;
    else
      Ftilde = porosity[k] * meanGrainSize[k] * 1.0e-2 / (1.0 - porosity[k]) / mu;
    if (fabs(porosity[k]) < 1.0e-7)
      Kinv = 0.0;
    else
      Kinv = 180.0 * (1.0 - porosity[k]) * (1.0 - porosity[k]) / (meanGrainSize[k] * meanGrainSize[k] * porosity[k] * porosity[k] * porosity[k]);
    mom_u_source[k] = -porosity[k] * rho * g[0] + porosity[k] * porosity[k] * mu * Kinv * (1.0 + Ftilde * uc) * u[k];
    mom_v_source[k] = -porosity[k] * rho * g[1] + porosity[k] * porosity[k] * mu * Kinv * (1.0 + Ftilde * uc) * v[k];
    mom_w_source[k] = -porosity[k] * rho * g[2] + porosity[k] * porosity[k] * mu * Kinv * (1.0 + Ftilde * uc) * w[k];
    dmom_u_source_u[k] = porosity[k] * porosity[k] * mu * Kinv * (1.0 + Ftilde * (uc + u[k] * u[k] / (uc + 1.0e-12)));
    dmom_u_source_v[k] = porosity[k] * porosity[k] * mu * Kinv * (0.0 + Ftilde * (v[k] * u[k] / (uc + 1.0e-12)));
    dmom_u_source_w[k] = porosity[k] * porosity[k] * mu * Kinv * (0.0 + Ftilde * (w[k] * u[k] / (uc + 1.0e-12)));
    dmom_v_source_v[k] = porosity[k] * porosity[k] * mu * Kinv * (1.0 + Ftilde * (uc + v[k] * v[k] / (uc + 1.0e-12)));
    dmom_v_source_u[k] = porosity[k] * porosity[k] * mu * Kinv * (0.0 + Ftilde * (u[k] * v[k] / (uc + 1.0e-12)));
    dmom_v_source_w[k] = porosity[k] * porosity[k] * mu * Kinv * (0.0 + Ftilde * (w[k] * v[k] / (uc + 1.0e-12)));
    dmom_w_source_w[k] = porosity[k] * porosity[k] * mu * Kinv * (1.0 + Ftilde * (uc + w[k] * w[k] / (uc + 1.0e-12)));
    dmom_w_source_u[k] = porosity[k] * porosity[k] * mu * Kinv * (0.0 + Ftilde * (u[k] * w[k] / (uc + 1.0e-12)));
    dmom_w_source_v[k] = porosity[k] * porosity[k] * mu * Kinv * (0.0 + Ftilde * (v[k] * w[k] / (uc + 1.0e-12)));
    mom_u_ham[k] = porosity[k] * grad_p[k * 3 + 0];
    dmom_u_ham_grad_p[k * 3 + 0] = porosity[k];
    mom_v_ham[k] = porosity[k] * grad_p[k * 3 + 1];
    dmom_v_ham_grad_p[k * 3 + 1] = porosity[k];
    mom_w_ham[k] = porosity[k] * grad_p[k * 3 + 2];
    dmom_w_ham_grad_p[k * 3 + 2] = porosity[k];
  }
}
```