## 3 Numerical Implementations and Algorithms
### Additional Solid Routines
```
Input:Macroscopic velocity field \(v\) and time increment \(\Delta t\) Result:Macroscopic displacement tensor field \(\mathbf{U}\) for\(b\gets 0\)toBlockLattice.Count()-1 do \(G_{x}{}^{p}\leftarrow\) BlockLattice[b].GetBlockLatticeGlobalPositionX() ; // Get current lattice position X \(G_{y}{}^{p}\leftarrow\) BlockLattice[b].GetBlockLatticeGlobalPositionY() ; // Get current lattice position Y for\(x\gets 0\)toBlockLattice[b].GetNx()-1 do for\(y\gets 0\)toBlockLattice[b].GetNy()-1 do \(G_{x}{}\gets x+G_{x}{}^{p}\) ; // Current cell global position X \(G_{y}{}\gets y+G_{y}{}^{p}\) ; // Current cell global position Y \(\mathbf{U}[G_{x},G_{y}]\mathrel{+}=v^{cell}\times\Delta t\) ; // Time integration  end for  end for
```  
**Algorithm 1**Displacement Routine [Physical Units]  
```
Input:Macroscopic displacement tensor field \(\mathbf{U}\), space discretization \(\Delta x\) and solid constitutive law \(C\) Result:Macroscopic strain and stress tensor fields: \(\mathbf{E}\) and \(\Sigma\) for\(b\gets 0\)toBlockLattice.Count()-1 do \(G_{x}{}^{p}\leftarrow\) BlockLattice[b].GetBlockLatticeGlobalPositionX() ; // Get current lattice position X \(G_{y}{}^{p}\leftarrow\) BlockLattice[b].GetBlockLatticeGlobalPositionY() ; // Get current lattice position Y for\(x\gets 0\)toBlockLattice[b].GetNx()-1 do for\(y\gets 0\)toBlockLattice[b].GetNy()-1 do \(G_{x}{}\gets x+G_{x}{}^{p}\) ; // Current cell global position X \(G_{y}{}\gets y+G_{y}{}^{p}\) ; // Current cell global position Y \(\mathbf{P}\leftarrow\) BlockLattice[b].GetCellVicinityParameters(\(x,y\)) ; // Vicinity parameters \(\mathbf{E}[G_{x},G_{y}]=\) ComputeStrainFromDisplacement(\(\mathbf{U},\Delta x,\mathbf{P}\)) ; // Strain computation \(\Sigma[G_{x},G_{y}]=\) ComputeStressFromStrain(\(\mathbf{E}[G_{x},G_{y}],\mathbf{C}\)) ; // Stress computation with solid constitutive law C  end for  end for
```  
**Algorithm 2**Strain and Stress Routine [Physical Units]  
```
Input:Macroscopic displacement tensor field \(\mathbf{U}\), space discretization \(\Delta x\) and solid constitutive law \(C\) Result:Macroscopic strain and stress tensor fields: \(\mathbf{E}\) and \(\Sigma\) for\(b\gets 0\)toBlockLattice.Count()-1 do \(G_{x}{}^{p}\leftarrow\) BlockLattice[b].GetBlockLatticeGlobalPositionX() ; // Get current lattice position X \(G_{y}{}^{p}\leftarrow\) BlockLattice[b].GetBlockLatticeGlobalPositionY() ; // Get current lattice position Y for\(x\gets 0\)toBlockLattice[b].GetNx()-1 do for\(y\gets 0\)toBlockLattice[b].GetNy()-1 do \(G_{x}{}\gets x+G_{x}{}^{p}\) ; // Current cell global position X \(G_{y}{}\gets y+G_{y}{}^{p}\) ; // Current cell global position Y \(\mathbf{P}\leftarrow\) BlockLattice[b].GetCellVicinityParameters(\(x,y\)) ; // Vicinity parameters \(\mathbf{E}[G_{x},G_{y}]=\) ComputeStrainFromDisplacement(\(\mathbf{U},\Delta x,\mathbf{P}\)) ; // Strain computation \(\Sigma[G_{x},G_{y}]=\) ComputeStressFromStrain(\(\mathbf{E}[G_{x},G_{y}],\mathbf{C}\)) ; // Stress computation with solid constitutive law C  end for  end for
```  
**Algorithm 3**Strain and Stress Routine [Physical Units]  
```
Input:Macroscopic displacement tensor field \(\mathbf{U}\), space discretization \(\Delta x\) and solid constitutive law \(C\) Result:Macroscopic strain and stress tensor fields: \(\mathbf{E}\) and \(\Sigma\) for\(b\gets 0\)toBlockLattice.Count()-1 do \(G_{x}{}^{p}\leftarrow\) BlockLattice[b].GetBlockLatticeGlobalPositionX() ; // Get current lattice position X \(G_{y}{}^{p}\leftarrow\) BlockLattice[b].GetBlockLatticeGlobalPositionY() ; // Get current lattice position Y for\(x\gets 0\)toBlockLattice[b].GetNx()-1 do for\(y\gets 0\)toBlockLattice[b].GetNy()-1 do \(G_{x}{}\gets x+G_{x}{}^{p}\) ; // Current cell global position X \(G_{y}{}\gets y+G_{y}{}^{p}\) ; // Current cell global position Y \(\mathbf{P}\leftarrow\) BlockLattice[b].GetCellVicinityParameters(\(x,y\)) ; // Vicinity parameters \(\mathbf{E}[G_{x},G_{y}]=\) ComputeStrainFromDisplacement(\(\mathbf{U},\Delta x,\mathbf{P}\)) ; // Strain computation \(\Sigma[G_{x},G_{y}]=\) ComputeStressFromStrain(\(\mathbf{E}[G_{x},G_{y}],\mathbf{C}\)) ; // Stress computation with solid constitutive law C  end for  end for
```  
**Algorithm 4**Strain and Stress Routine [Physical Units]  
```
Input:Macroscopic displacement tensor field \(\mathbf{U}\), space discretization \(\Delta x\) and solid constitutive law \(C\) Result:Macroscopic strain and stress tensor fields: \(\mathbf{E}\) and \(\Sigma\) for\(b\gets 0\)toBlockLattice.Count()-1 do \(G_{x}{}^{p}\leftarrow\) BlockLattice[b].GetBlockLatticeGlobalPositionX() ; // Get current lattice position X \


```
Input:Macroscopic stress tensor field \(\Sigma\) and space discretization \(\Delta x\) Result: Macroscopic stress divergence tensor field \(\
abla_{x}\cdot(\Sigma)\) for\(b\gets 0\)toBlockLattice.Count()-1 do \(G_{x}{}^{p}\leftarrow\) BlockLattice[b].GetBlockLatticeGlobalPositionX() ; // Get current lattice positionX \(G_{y}{}^{p}\leftarrow\) BlockLattice[b].GetBlockLatticeGlobalPositionY() ; // Get current lattice positionY for\(x\gets 0\)toBlockLattice[b].GetNx()-1 do for\(y\gets 0\)toBlockLattice[b].GetNy()-1 do \(G_{x}\gets x+G_{x}{}^{p}\) ; // Current cell global positionX \(G_{y}\gets y+G_{y}{}^{p}\) ; // Current cell global positionY \(\mathbf{P}\leftarrow\) BlockLattice[b].GetCellVicinityParameters(\(x,y\)) ; // Vicinity parameters \(\
abla_{x}\cdot(\Sigma)[G_{x},G_{y}]=\) ComputeStressDivergenceFromStress(\(\Sigma\), \(\Delta x\), \(\mathbf{P}\)) ; // \(\
abla_{x}\cdot(\Sigma)[G_{x},G_{y}]\) computation BlockLattice[b](\(x\), \(y\)).ApplyLatticeBodyForce(\(\
abla_{x}\cdot(\Sigma)[G_{x},G_{y}]\));// Apply lattice body force to the current cell  end for  end for
```
**Algorithm 3**Body Force Routine [Physical Units]

These three routines allow the computation of required tensor fields over the lattice domain.