Skip to content

Commit

Permalink
Avoid seg fault for 3D extrusion without a MODEL block (#59)
Browse files Browse the repository at this point in the history
* ensure modelDict exists to avoid seg fault

* add two more extrusion tests without a MODEL

* remove BoxRotated test due to floating point error comparison issues

* Check modelDict if used

If a sweep curve is requested in the control block, it needs the curve it's swept on in a model block. Throw a fatal exception if there is no model block in this case.

* remove unused variables

* unify naming for the BoxRotated extruded mesh

* fix incorrect label name on figure in docs

---------

Co-authored-by: David Kopriva <kopriva@math.fsu.edu>
  • Loading branch information
andrewwinters5000 and DavidAKopriva authored Jun 1, 2023
1 parent fd9043d commit f559ac6
Show file tree
Hide file tree
Showing 9 changed files with 6,996 additions and 6,937 deletions.
8 changes: 8 additions & 0 deletions Benchmarks/BenchmarkData/Box3D.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
2
50 108
1.00000E+00
1.00000E+00
1.00000E+00
1.00000E+00
0.00000E+00
1.00000E+00
1 change: 1 addition & 0 deletions Benchmarks/BenchmarkFiles.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,5 @@ Benchmarks/ControlFiles/BottomFromFile.control
Benchmarks/ControlFiles/ABAQUS_IceCreamCone.control
Benchmarks/ControlFiles/SeaMount.control
Benchmarks/ControlFiles/SeaMountCubic.control
Benchmarks/ControlFiles/Box3D.control
Benchmarks/ControlFiles/BoneAndMarrow.control
46 changes: 46 additions & 0 deletions Benchmarks/ControlFiles/Box3D.control
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
%
% This control file uses no model and so generates a structured mesh
% in a box. The mesh size and position is given by the BackgroundGrid
% block. The background grid size is ignored when a BackgroundGrid block
% is present.
%
\begin{CONTROL_INPUT}

\begin{RUN_PARAMETERS}
mesh file name = Benchmarks/MeshFiles/Tests/Box3D.mesh
plot file name = Benchmarks/PlotFiles/Tests/Box3D.tec
stats file name = Benchmarks/StatsFiles/Tests/Box3D.txt
test file name = Benchmarks/BenchmarkData/Box3D.txt
mesh file format = ISM
polynomial order = 4
plot file format = skeleton
\end{RUN_PARAMETERS}

\begin{SIMPLE_EXTRUSION}
direction = 3
height = 2.0
subdivisions = 2
start surface name = bottom
end surface name = top
\end{SIMPLE_EXTRUSION}

\begin{BACKGROUND_GRID}
x0 = [0.0, 0.0, 0.0]
dx = [1.0, 1.0, 1.0]
N = [5,5,5]
\end{BACKGROUND_GRID}

\begin{SPRING_SMOOTHER}
smoothing = ON
smoothing type = LinearAndCrossBarSpring
spring constant = 1.0
mass = 1.0
rest length = 0.0
damping coefficient = 5.0
number of iterations = 5
time step = 0.1
\end{SPRING_SMOOTHER}

\end{CONTROL_INPUT}

\end{FILE}
2 changes: 1 addition & 1 deletion Documentation/docs/TheISMMeshFileFormats.md
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ If there are still questions, the source code for writing the mesh files can be
### Example
As a concrete example, we present the mesh file for a circular domain with five elements, shown in Fig. 8.15 of the book "Implementing Spectral Methods", reproduced below.

![HexElement](https://user-images.githubusercontent.com/25242486/195528317-bb536e54-66df-4f9a-9417-819a09a25bc6.png)
![SEMPoisson2DMesh](https://user-images.githubusercontent.com/25242486/195528317-bb536e54-66df-4f9a-9417-819a09a25bc6.png)
<p align = "center"> Fig. 26. The Quad mesh for a circle for whose mesh file is shown below.</p>

The mesh has five elements with eight corner nodes. The outer boundary (called "outer") is eighth order, so it has nine points defined for each curve.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
\begin{CONTROL_INPUT}

\begin{RUN_PARAMETERS}
mesh file name = Examples/3D/BoxRotated/Box3D.mesh
plot file name = Examples/3D/BoxRotated/Box3D.tec
mesh file name = Examples/3D/BoxRotated/Box3DRot.mesh
plot file name = Examples/3D/BoxRotated/Box3DRot.tec
stats file name = none
mesh file format = ISM
polynomial order = 4
Expand Down
7,594 changes: 3,797 additions & 3,797 deletions Examples/3D/BoxRotated/Box3DRot.mesh

Large diffs are not rendered by default.

6,262 changes: 3,131 additions & 3,131 deletions Examples/3D/BoxRotated/Box3D.tec → Examples/3D/BoxRotated/Box3DRot.tec

Large diffs are not rendered by default.

10 changes: 8 additions & 2 deletions Source/3DSource/3DMeshController.f90
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,14 @@ SUBROUTINE Check3DMeshParametersIntegrity( controlDict, modelDict )
obj => controlDict % objectForKey(key = SWEEP_CURVE_CONTROL_KEY)
generatorDict => valueDictionaryFromObject(obj)
algorithmChoice = SWEEP_ALGORITHM
CALL CheckCurveSweepBlock(controlDict = generatorDict, &
modelDict = modelDict)
IF ( .NOT. ASSOCIATED(modelDict) ) THEN
CALL ThrowErrorExceptionOfType(poster = "Check3DMeshParametersIntegrity", &
msg = "A model block and sweep curve is required for sweeping", &
typ = FT_ERROR_FATAL)
ELSE
CALL CheckCurveSweepBlock(controlDict = generatorDict, &
modelDict = modelDict)
END IF
ELSE
CALL ThrowErrorExceptionOfType(poster = "generate3DMesh", &
msg = "No generator for 3D mesh found in control file", &
Expand Down
6 changes: 2 additions & 4 deletions Source/HOHQMesh.f90
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,7 @@ SUBROUTINE HOHQMesh(projectDict, project, stats, didGenerate3DMesh, test)
IF ( shouldGenerate3D ) THEN
obj => projectDict % objectForKey(key = "MODEL")
modelDict => valueDictionaryFromObject(obj)
CALL modelDict % retain()
CALL Check3DMeshParametersIntegrity(controlDict, modelDict)
CALL releaseFTValueDictionary(modelDict)
END IF
CALL trapExceptions !Abort on fatal exceptions
!
Expand Down Expand Up @@ -208,11 +206,11 @@ SUBROUTINE HOHQMesh(projectDict, project, stats, didGenerate3DMesh, test)
PRINT *, " Number of nodes = ", SIZE(project % hexMesh % nodes)
PRINT *, " Number of Elements = ", SIZE(project % hexMesh % elements)
PRINT *

WRITE(numb,FMT='(I3)') SIZE(stats % avgValues)
namesFmt = "(7A16)"
valuesFmt = "(A16," // TRIM(numb) // "(F16.8))"

PRINT *, "Mesh Quality:"
WRITE(6,namesFmt) "Measure", "Minimum", "Maximum", "Average", "Acceptable Low", "Acceptable High", "Reference"
DO k = 1, SIZE(shapeMeasureNames3D)
Expand Down

0 comments on commit f559ac6

Please sign in to comment.