Skip to content

Commit 303a221

Browse files
hajdikgawng
andauthored
Mesh check error printout (#81)
* print all errors * this mostly works * error catch * cleanup * change printout from inputFile to outputFile * removed duplicate initialization, move stop outside of loop * fprettify? * fprettify?? * allow for inputfile or outputfile for case name in printout * Eirikur comments * fprettify * Eirikur comments --------- Co-authored-by: Galen Ng <[email protected]>
1 parent ba26b6e commit 303a221

File tree

2 files changed

+35
-14
lines changed

2 files changed

+35
-14
lines changed

pyhyp/pyHyp.py

+6-4
Original file line numberDiff line numberDiff line change
@@ -212,10 +212,12 @@ def __init__(self, comm=None, options=None, commonOptions=None, debug=False, ski
212212
elif type(options) is dict:
213213
# Only the root processor will print
214214
if myid == 0:
215-
print("")
216-
print("")
217-
print("Running case %d : %s" % (index, options["inputFile"]))
218-
print("")
215+
# change the printout based on which option is actually present
216+
if "inputFile" in options.keys():
217+
caseName = options["inputFile"]
218+
else:
219+
caseName = options["outputFile"]
220+
print("\n\nRunning case %d : %s\n" % (index, caseName))
219221

220222
# Create pyHyp object using the corresponding options
221223
hypGrid = pyHyp(comm, options, debug)

src/3D/setup3d.F90

+29-10
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ subroutine setup(fileName, fileType)
4343
integer(kind=intType) :: i, j, k, ii, jj, iii, jjj, ierr, iStart, iEnd
4444
integer(kind=intType) :: isize, ind, icell, idim, BCToSet, il, jl, iEdge, iBCToSet
4545
logical :: found
46+
logical :: bcTopoError
47+
logical :: bcError
4648
character(5) :: faceStr
4749
integer(kind=intType), dimension(:), pointer :: lPtr1, lPtr2
4850
real(kind=realType), dimension(:, :), pointer :: xPtr, xPtrRowInward
@@ -591,6 +593,11 @@ subroutine setup(fileName, fileType)
591593
end do patchLoop0
592594

593595
nAverage = 0
596+
597+
! error flag for issues with BCs or topology
598+
bcError = .False.
599+
bcTopoError = .False.
600+
594601
patchLoop: do ii = 1, nPatch
595602
il = patches(ii)%il
596603
jl = patches(ii)%jl
@@ -631,10 +638,11 @@ subroutine setup(fileName, fileType)
631638
! it means someone explictly specifid it which is an
632639
! error since this isn't *actually* a boundary condition
633640
if (BCs(iEdge, ii) /= BCDefault) then
641+
bcError = .True.
642+
634643
101 format(a, a, a, I3, a)
635644
print 101, 'ERROR: A boundary condition was specifed for ', &
636645
trim(faceStr), ' patch on Block', ii, ' but it is not a physical boundary.'
637-
stop
638646
end if
639647

640648
else if (fullTopoType(iNode) == topoEdge) then
@@ -689,7 +697,7 @@ subroutine setup(fileName, fileType)
689697
! Do a sanity check: This should only occur if i==1 or i==iSize
690698
if (i /= 1 .and. i /= iSize) then
691699
print *, 'ERROR: Unknown corner topology error detected.', i, isize
692-
stop
700+
bcTopoError = .True.
693701
end if
694702

695703
! By definition , corner topology nodes must have 2 neighbours
@@ -799,6 +807,13 @@ subroutine setup(fileName, fileType)
799807
end do
800808
end do patchLoop
801809

810+
! if there was an error in the BC setup stop
811+
if (bcError) then
812+
print *, 'ERROR: pyHyp exited due to one or more issues with mesh boundary conditions. &
813+
&See above error printouts.'
814+
stop
815+
end if
816+
802817
do i = 1, nUnique
803818
! Special loop for the LCorners
804819
if (fullTopoType(i) == topoLCorner) then
@@ -895,8 +910,8 @@ subroutine setup(fileName, fileType)
895910
! fullnPtr populated.
896911
do i = 1, nUnique
897912
if (fullNPtr(1, i) == 0) then
898-
print *, 'There was a general error with topology computation for node:', uniquePts(:, i)
899-
stop
913+
print *, 'ERROR: There was a general error with topology computation for node:', uniquePts(:, i)
914+
bcTopoError = .True.
900915
end if
901916
end do
902917

@@ -905,17 +920,21 @@ subroutine setup(fileName, fileType)
905920
! their fullnPtr populated.
906921
do i = 1, nUnique
907922
if (fullTopoType(i) == topoEdge .and. fullBCType(1, i) == BCDefault) then
908-
print *, 'There was a missing boundary condition for edge node:', uniquePts(:, i)
909-
stop
910-
923+
print *, 'ERROR: There was a missing boundary condition for edge node:', uniquePts(:, i)
924+
bcTopoError = .True.
911925
else if (fullTopoType(i) == topoCorner .and. (fullBCType(1, i) == BCDefault .or. &
912926
fullBCType(2, i) == BCDefault)) then
913-
print *, 'There was a missing boundary condition for corner node:', uniquePts(:, i)
914-
stop
927+
print *, 'ERROR: There was a missing boundary condition for corner node:', uniquePts(:, i)
928+
bcTopoError = .True.
915929
end if
916-
917930
end do
918931

932+
! if we ran into topology or BC errors, stop
933+
if (bcTopoError) then
934+
print *, 'ERROR: pyHyp exited due to one or more issues with mesh topology. See above error printouts.'
935+
stop
936+
end if
937+
919938
! Free up some more memory
920939
deallocate (nte, ntePtr, directedNodeConn, nodeConn, nEdge, nDirectedEdge)
921940

0 commit comments

Comments
 (0)