| Algorithm 1 Last Resort Flowchart | |
| 1: | Last_Resort_Algorithm(Ψi,ηe) |
| 2: | Ψi ← Boundary surface |
| 3: | ηe ← Minimum desired element quality |
| 4: | Output: PotentialMeshj |
| 5: | if Ψi has only 4 remaining faces then |
| 6: | Form the tetrahedral element e |
| 7: | PotentialMeshj ← e |
| 8: | return PotentialMeshj |
| 9: | end if |
| 10: | for all Faces, Fi, in current boundary surface Ψi do |
| 11: | if Fi can produce at least one acceptable tetrahedron whose quality q > ηe then |
| 12: | Ni ← number of possible tetrahedrons |
| 13: | if Ni < Nmin then |
| 14: | Nmin← Ni |
| 15: | Insert Fi to the top of Listfaces stack and push all the current faces down |
| 16: | end if |
| 17: | else |
| 18: | return NULL |
| 19: | end if |
| 20: | end for |
| 21: | while Listfaces ≠ ∅ do |
| 22: | Pick the face from top of the Listfaces stack andform its best tetrahedron e |
| 23: | Update Ψi boundary surface based on insertion of element e |
| 24: | Assign the new boundary to ψi |
| 25: | Call M ← Last_Resort_Algorithm(ψi,ηe) |
| 26: | if M is not NULL then |
| 27: | PotentialMeshj = PotentialMeshj ∪ M |
| 28: | return PotentialMeshj |
| 29: | else |
| 30: | Remove the top enitity in Listfaces stack and continue |
| 31: | end if |
| 32: | end while |
| 33: | return NULL |