Test Function output for higher-order meshes.
(tempdir)
| 223 | |
| 224 | |
| 225 | def test_higher_order_function(tempdir): |
| 226 | """Test Function output for higher-order meshes.""" |
| 227 | gmsh = pytest.importorskip("gmsh") |
| 228 | |
| 229 | from dolfinx.io import gmsh as gmshio |
| 230 | |
| 231 | gmsh.initialize() |
| 232 | |
| 233 | def gmsh_tet_model(order): |
| 234 | gmsh.option.setNumber("General.Terminal", 0) |
| 235 | model = gmsh.model() |
| 236 | comm = MPI.COMM_WORLD |
| 237 | if comm.rank == 0: |
| 238 | model.add("Sphere minus box") |
| 239 | model.setCurrent("Sphere minus box") |
| 240 | model.occ.addSphere(0, 0, 0, 1) |
| 241 | model.occ.synchronize() |
| 242 | volume_entities = [model[1] for model in model.getEntities(3)] |
| 243 | model.addPhysicalGroup(3, volume_entities, tag=2) |
| 244 | model.mesh.generate(3) |
| 245 | gmsh.option.setNumber("General.Terminal", 1) |
| 246 | model.mesh.setOrder(order) |
| 247 | gmsh.option.setNumber("General.Terminal", 0) |
| 248 | |
| 249 | mesh_data = gmshio.model_to_mesh(model, comm, 0) |
| 250 | return mesh_data.mesh |
| 251 | |
| 252 | def gmsh_hex_model(order): |
| 253 | model = gmsh.model() |
| 254 | gmsh.option.setNumber("General.Terminal", 0) |
| 255 | model.add("Hexahedral mesh") |
| 256 | model.setCurrent("Hexahedral mesh") |
| 257 | comm = MPI.COMM_WORLD |
| 258 | if comm.rank == 0: |
| 259 | gmsh.option.setNumber("Mesh.RecombinationAlgorithm", 2) |
| 260 | gmsh.option.setNumber("Mesh.RecombineAll", 2) |
| 261 | gmsh.option.setNumber("Mesh.CharacteristicLengthFactor", 1) |
| 262 | circle = model.occ.addDisk(0, 0, 0, 1, 1) |
| 263 | circle_inner = model.occ.addDisk(0, 0, 0, 0.5, 0.5) |
| 264 | cut = model.occ.cut([(2, circle)], [(2, circle_inner)])[0] |
| 265 | extruded_geometry = model.occ.extrude(cut, 0, 0, 0.5, numElements=[5], recombine=True) |
| 266 | model.occ.synchronize() |
| 267 | model.addPhysicalGroup(2, [cut[0][1]], tag=1) |
| 268 | model.setPhysicalName(2, 1, "2D cylinder") |
| 269 | boundary_entities = model.getEntities(2) |
| 270 | other_boundary_entities = [] |
| 271 | for entity in boundary_entities: |
| 272 | if entity != cut[0][1]: |
| 273 | other_boundary_entities.append(entity[1]) |
| 274 | model.addPhysicalGroup(2, other_boundary_entities, tag=3) |
| 275 | model.setPhysicalName(2, 3, "Remaining boundaries") |
| 276 | model.mesh.generate(3) |
| 277 | model.mesh.setOrder(order) |
| 278 | volume_entities = [] |
| 279 | for entity in extruded_geometry: |
| 280 | if entity[0] == 3: |
| 281 | volume_entities.append(entity[1]) |
| 282 | model.addPhysicalGroup(3, volume_entities, tag=1) |
nothing calls this directly
no test coverage detected