@@ -578,12 +578,14 @@ def test_merge_and_map(actx_factory, group_cls, visualize=False):
578578
579579# {{{ element orientation
580580
581- @pytest .mark .parametrize ("case" , ["blob" , "gh-394" ])
581+ @pytest .mark .parametrize ("case" , ["blob" , "gh-394" , "3x3" , "3x3_twisted" ,
582+ "3x3_minus" , "3x3_bound" ])
582583def test_element_orientation_via_flipping (case ):
583584 from meshmode .mesh .io import FileSource , generate_gmsh
584585
585586 mesh_order = 3
586587
588+ meshfile = f"{ thisdir } /{ case } .msh"
587589 if case == "blob" :
588590 mesh = generate_gmsh (
589591 FileSource (str (thisdir / "blob-2d.step" )), 2 , order = mesh_order ,
@@ -593,13 +595,73 @@ def test_element_orientation_via_flipping(case):
593595 )
594596 elif case == "gh-394" :
595597 mesh = mio .read_gmsh (
596- str (thisdir / "gh-394.msh" ),
598+ meshfile ,
599+ force_ambient_dim = 2 ,
600+ mesh_construction_kwargs = {"skip_tests" : True })
601+ elif case == "3x3" : # regular ole rectangular 3x3 tensor product els (TPE)
602+ mesh = mio .read_gmsh (
603+ meshfile ,
604+ force_ambient_dim = 2 ,
605+ mesh_construction_kwargs = {"skip_tests" : True })
606+ elif case == "3x3_twisted" : # TPEs, rotated connectivities, all positive
607+ mesh = mio .read_gmsh (
608+ meshfile ,
609+ force_ambient_dim = 2 ,
610+ mesh_construction_kwargs = {"skip_tests" : True })
611+ elif case == "3x3_minus" : # TPEs with negative orientation (clockwise conn)
612+ mesh = mio .read_gmsh (
613+ meshfile ,
614+ force_ambient_dim = 2 ,
615+ mesh_construction_kwargs = {"skip_tests" : True })
616+ elif case == "3x3_bound" : # TPEs (clockwise conn, w/boundaries)
617+ mesh = mio .read_gmsh (
618+ meshfile ,
597619 force_ambient_dim = 2 ,
598620 mesh_construction_kwargs = {"skip_tests" : True })
599621 else :
600622 raise ValueError (f"unknown case: { case } " )
601623
624+ boundary_tags = set ()
625+ for igrp in range (len (mesh .groups )):
626+ print (f"{ meshfile = } Boundaries:" )
627+ bdry_fagrps = [
628+ fagrp for fagrp in mesh .facial_adjacency_groups [igrp ]
629+ if isinstance (fagrp , BoundaryAdjacencyGroup )]
630+ for bdry_fagrp in bdry_fagrps :
631+ print (f"Boundary tag: { bdry_fagrp .boundary_tag } " )
632+ boundary_tags .add (bdry_fagrp .boundary_tag )
633+ # print(f"----{bdry_fagrp.elements=}")
634+ # if bdry_fagrp.boundary_tag == "outer_bdy":
635+ # num_marked_outer_bdy += len(bdry_fagrp.elements)
636+ #if bdry_fagrp.boundary_tag == "inner_bdy":
637+ # num_marked_inner_bdy += len(bdry_fagrp.elements)
638+
602639 mesh_orient = mproc .find_volume_mesh_element_orientations (mesh )
640+ if not (mesh_orient > 0 ).all ():
641+ print (f"Mesh({ meshfile } ) is negative, trying to reorient." )
642+ mesh = mio .read_gmsh (
643+ meshfile ,
644+ force_ambient_dim = 2 ,
645+ mesh_construction_kwargs = {
646+ "skip_tests" : True ,
647+ "force_positive_orientation" : True })
648+ mesh_orient = mproc .find_volume_mesh_element_orientations (mesh )
649+ boundary_tags_reoriented = set ()
650+ for igrp in range (len (mesh .groups )):
651+ print (f"{ meshfile = } Reoriented Boundaries:" )
652+ bdry_fagrps = [
653+ fagrp for fagrp in mesh .facial_adjacency_groups [igrp ]
654+ if isinstance (fagrp , BoundaryAdjacencyGroup )]
655+ for bdry_fagrp in bdry_fagrps :
656+ print (f"Boundary tag: { bdry_fagrp .boundary_tag } " )
657+ boundary_tags_reoriented .add (bdry_fagrp .boundary_tag )
658+ # print(f"----{bdry_fagrp.elements=}")
659+ # if bdry_fagrp.boundary_tag == "outer_bdy":
660+ # num_marked_outer_bdy += len(bdry_fagrp.elements)
661+ #if bdry_fagrp.boundary_tag == "inner_bdy":
662+ # num_marked_inner_bdy += len(bdry_fagrp.elements)
663+ # Make sure rotation doesn't lose boundaries
664+ assert boundary_tags == boundary_tags_reoriented
603665
604666 assert (mesh_orient > 0 ).all ()
605667
0 commit comments