The measure introduced in the following paper: Shewchuk, Jonathan. "What is a good linear finite element? interpolation, conditioning, anisotropy, and quality measures (preprint)." University of California at Berkeley 73 (2002).
(mesh)
| 131 | mesh.set_attribute("orientations", orientations); |
| 132 | |
| 133 | def compute_grad_upper_bound(mesh): |
| 134 | """ The measure introduced in the following paper: |
| 135 | |
| 136 | Shewchuk, Jonathan. "What is a good linear finite element? interpolation, |
| 137 | conditioning, anisotropy, and quality measures (preprint)." University of |
| 138 | California at Berkeley 73 (2002). |
| 139 | """ |
| 140 | area = lambda p0, p1, p2: 0.5 * numpy.linalg.norm(np.cross(p1-p0, p2-p0)); |
| 141 | measure = np.zeros(mesh.num_voxels); |
| 142 | mesh.add_attribute("voxel_volume"); |
| 143 | vols = mesh.get_attribute("voxel_volume").ravel(); |
| 144 | vertices = mesh.vertices; |
| 145 | tets = mesh.voxels; |
| 146 | for i in range(mesh.num_voxels): |
| 147 | tet = tets[i]; |
| 148 | p = vertices[tet]; |
| 149 | A0 = area(p[1], p[2], p[3]); |
| 150 | A1 = area(p[0], p[2], p[3]); |
| 151 | A2 = area(p[0], p[1], p[3]); |
| 152 | A3 = area(p[0], p[1], p[2]); |
| 153 | l01 = numpy.linalg.norm(p[0] - p[1]); |
| 154 | l02 = numpy.linalg.norm(p[0] - p[2]); |
| 155 | l03 = numpy.linalg.norm(p[0] - p[3]); |
| 156 | l12 = numpy.linalg.norm(p[1] - p[2]); |
| 157 | l13 = numpy.linalg.norm(p[1] - p[3]); |
| 158 | l23 = numpy.linalg.norm(p[2] - p[3]); |
| 159 | V = vols[i]; |
| 160 | measure[i] = ((A0*A1*l01*l01 + A0*A2*l02*l02 + A0*A3*l03*l03 |
| 161 | + A1*A2*l12*l12 + A1*A3*l13*l13 + A2*A3*l23*l23) / (6.0 * V) |
| 162 | + np.amax([A0*l01, A0*l02, A0*l03, |
| 163 | A1*l01, A1*l12, A1*l13, |
| 164 | A2*l02, A2*l12, A2*l23, |
| 165 | A3*l03, A3*l13, A3*l23])) / (A0+A1+A2+A3) /\ |
| 166 | np.amax([l01, l02, l03, l12, l13, l23]); |
| 167 | mesh.add_attribute("grad_bound"); |
| 168 | mesh.set_attribute("grad_bound", measure); |
| 169 | |
| 170 | def compute_tet_quality_measures(mesh): |
| 171 | mesh.add_attribute("voxel_inradius"); |
no test coverage detected