[cig-commits] [commit] baagaard/fix-meshing-examples-trelis: Improve subduction meshing example. Make Trelis compatible. (b1df679)

cig_noreply at geodynamics.org cig_noreply at geodynamics.org
Thu Jun 19 16:16:46 PDT 2014


Repository : https://github.com/geodynamics/pylith

On branch  : baagaard/fix-meshing-examples-trelis
Link       : https://github.com/geodynamics/pylith/compare/0000000000000000000000000000000000000000...2c5c061b18ae348f664c7b60f1c3cb9d9c62d44b

>---------------------------------------------------------------

commit b1df6790e93822bc022c7840386d218c91b252da
Author: Brad Aagaard <baagaard at usgs.gov>
Date:   Thu Jun 19 16:15:50 2014 -0700

    Improve subduction meshing example. Make Trelis compatible.


>---------------------------------------------------------------

b1df6790e93822bc022c7840386d218c91b252da
 .../surface_nurbs/subduction/interface_netsurf.py  | 74 ++++++++++-----------
 examples/meshing/surface_nurbs/subduction/mesh.jou |  3 +-
 .../surface_nurbs/subduction/splay_skinsurf.py     | 50 +++++++--------
 .../surface_nurbs/subduction/topobath_netsurf.py   | 75 +++++++++++-----------
 4 files changed, 99 insertions(+), 103 deletions(-)

diff --git a/examples/meshing/surface_nurbs/subduction/interface_netsurf.py b/examples/meshing/surface_nurbs/subduction/interface_netsurf.py
index 01c351c..41f8bf7 100644
--- a/examples/meshing/surface_nurbs/subduction/interface_netsurf.py
+++ b/examples/meshing/surface_nurbs/subduction/interface_netsurf.py
@@ -27,56 +27,56 @@ journalFile = "interface_netsurf.jou"
 acisFile = "interface_surf.sat"
 
 # Journal file formatting, etc.
-separator = "# ----------------------------------------------------------\n"
-journalBeg = \
-           "# CUBIT journal file generated by interface_netsurf.py.\n" + \
-           "#\n" + \
-           "# Create an ACIS NURBS surface from intersecting lines.\n" + \
-           "#\n" + separator + \
-           "reset\n"
-lineBeg = "create curve spline"
-splineFmt = " location %10.2e %10.2e %10.2e"
-netFmt = "create surface net u curve %d to %d v curve %d to %d\n"
-delCmd = "delete curve all\n"
-expCmd = "export Acis '" + acisFile + "'\n"
-
 
 # Read coordinates and reshape them.
 intCoords = numpy.loadtxt(interfaceFile, dtype=numpy.float64).reshape(numContours, pointsPerContour, 3)
 
 j = open(journalFile, 'w')
-j.write(journalBeg)
+j.write("# CUBIT journal file generated by interface_netsurf.py.\n" + \
+            "#\n" + \
+            "# Create an ACIS NURBS surface from intersecting lines.\n" + \
+            "#\n" \
+            "# ----------------------------------------------------------\n" + \
+            "reset\n")
 
 # Loop over contours (u-lines).
-for contour in range(numContours):
-    points = intCoords[contour,:,:]
-    j.write(lineBeg)
-    for pointNum in range(pointsPerContour):
-        point = points[pointNum,:]
-        j.write(splineFmt % (point[0], point[1], point[2]))
-
-    j.write("\n")
+for iContour in range(numContours):
+    points = intCoords[iContour,:,:]
+    for iPoint in range(pointsPerContour):
+        point = points[iPoint,:]
+        j.write("create vertex x %10.2e y %10.2e z %10.2e\n" % \
+                    (point[0], point[1], point[2]))
+        if 0 == iPoint:
+            j.write("#{idBeg=Id('vertex')}\n")
+    j.write("#{idEnd=Id('vertex')}\n")
+    j.write("create curve spline vertex {idBeg} to {idEnd}\n")
+    if 0 == iContour:
+        j.write("#{idCBeg=Id('curve')}\n")
+j.write("#{idCEnd=Id('curve')}\n\n")
+j.write("delete vertex all\n")
 
 # Loop over profiles (v-lines).
-for profile in range(pointsPerContour):
-    points = intCoords[:,profile,:]
-    j.write(lineBeg)
-    for pointNum in range(numContours):
-        point = points[pointNum,:]
-        j.write(splineFmt % (point[0], point[1], point[2]))
-
-    j.write("\n")
+for iProfile in range(pointsPerContour):
+    points = intCoords[:,iProfile,:]
+    for iPoint in range(numContours):
+        point = points[iPoint,:]
+        j.write("create vertex x %10.2e y %10.2e z %10.2e\n" % \
+                    (point[0], point[1], point[2]))
+        if 0 == iPoint:
+            j.write("#{idBeg=Id('vertex')}\n")
+    j.write("#{idEnd=Id('vertex')}\n")
+    j.write("create curve spline vertex {idBeg} to {idEnd}\n")
+    if 0 == iProfile:
+        j.write("#{idPBeg=Id('curve')}\n")
+j.write("#{idPEnd=Id('curve')}\n\n")
+j.write("delete vertex all\n")
 
 # Create net surface.
-uline1 = 1
-uline2 = numContours
-vline1 = numContours + 1
-vline2 = vline1 + pointsPerContour - 1
-j.write(netFmt % (uline1, uline2, vline1, vline2))
+j.write("create surface net u curve {idCBeg} to {idCEnd} v curve {idPBeg} to {idPEnd}\n")
 
 # Delete spline curves and export Acis file.
-j.write(delCmd)
-j.write(expCmd)
+j.write("delete curve all\n")
+j.write("export Acis '%s' overwrite\n" % acisFile)
 j.close()
 
 # End of file
diff --git a/examples/meshing/surface_nurbs/subduction/mesh.jou b/examples/meshing/surface_nurbs/subduction/mesh.jou
index 5ebe8e0..9979e01 100644
--- a/examples/meshing/surface_nurbs/subduction/mesh.jou
+++ b/examples/meshing/surface_nurbs/subduction/mesh.jou
@@ -37,7 +37,7 @@ mesh surface all
 mesh volume all
 
 # ----------------------------------------------------------------------
-# Smooth mesh to imporve quality.
+# Smooth mesh to improve quality.
 # ----------------------------------------------------------------------
 cleanup volume all
 volume all smooth scheme condition number beta 2.0 cpu 4
@@ -51,7 +51,6 @@ playback 'bc.jou'
 # ----------------------------------------------------------------------
 # Export exodus file.
 # ----------------------------------------------------------------------
-set large exodus off
 export mesh "mesh.exo" dimension 3 overwrite
 
 
diff --git a/examples/meshing/surface_nurbs/subduction/splay_skinsurf.py b/examples/meshing/surface_nurbs/subduction/splay_skinsurf.py
index 5ff9a14..682629a 100644
--- a/examples/meshing/surface_nurbs/subduction/splay_skinsurf.py
+++ b/examples/meshing/surface_nurbs/subduction/splay_skinsurf.py
@@ -26,43 +26,41 @@ pointsPerProfile = 4
 journalFile = "splay_skinsurf.jou"
 acisFile = "splay_surf.sat"
 
-# Journal file formatting, etc.
-separator = "# ----------------------------------------------------------\n"
-journalBeg = \
-           "# CUBIT journal file generated by splay_skinsurf.py.\n" + \
-           "#\n" + \
-           "# Create an ACIS NURBS surface from a set of profiles.\n" + \
-           "#\n" + separator + \
-           "reset\n"
-lineBeg = "create curve spline"
-splineFmt = " location %10.2e %10.2e %10.2e"
-skinCmd = "create surface skin curve all\n"
-delCmd = "delete curve all\n"
-expCmd = "export Acis '" + acisFile + "'\n"
-
 
 # Read coordinates and reshape them.
 splayCoords = numpy.loadtxt(splayFile, dtype=numpy.float64).reshape(numProfiles, pointsPerProfile, 3)
 
 j = open(journalFile, 'w')
-j.write(journalBeg)
+j.write("# CUBIT journal file generated by splay_skinsurf.py.\n" + \
+            "#\n" + \
+            "# Create an ACIS NURBS surface from a set of profiles.\n" + \
+            "#\n" \
+            "# ----------------------------------------------------------\n" + \
+            "reset\n")
 
-# Loop over profiles.
-for profile in range(numProfiles):
-    points = splayCoords[profile,:,:]
-    j.write(lineBeg)
-    for pointNum in range(pointsPerProfile):
-        point = points[pointNum,:]
-        j.write(splineFmt % (point[0], point[1], point[2]))
 
-    j.write("\n")
+# Loop over profiles.
+for iProfile in range(numProfiles):
+    points = splayCoords[iProfile,:,:]
+    for iPoint in range(pointsPerProfile):
+        point = points[iPoint,:]
+        j.write("create vertex x %10.2e y %10.2e z %10.2e\n" % \
+                    (point[0], point[1], point[2]))
+        if 0 == iPoint:
+            j.write("#{idBeg=Id('vertex')}\n")
+    j.write("#{idEnd=Id('vertex')}\n")
+    j.write("create curve spline vertex {idBeg} to {idEnd}\n")
+    if 0 == iProfile:
+        j.write("#{idCBeg=Id('curve')}\n")
+j.write("#{idCEnd=Id('curve')}\n\n")
+j.write("delete vertex all\n")
 
 # Create skin surface.
-j.write(skinCmd)
+j.write("create surface skin curve {idCBeg} to {idCEnd}\n")
 
 # Delete spline curves and export Acis file.
-j.write(delCmd)
-j.write(expCmd)
+j.write("delete curve all\n")
+j.write("export Acis '%s' overwrite\n" % acisFile)
 j.close()
 
 # End of file
diff --git a/examples/meshing/surface_nurbs/subduction/topobath_netsurf.py b/examples/meshing/surface_nurbs/subduction/topobath_netsurf.py
index e45cebb..6e25cfa 100644
--- a/examples/meshing/surface_nurbs/subduction/topobath_netsurf.py
+++ b/examples/meshing/surface_nurbs/subduction/topobath_netsurf.py
@@ -26,57 +26,56 @@ pointsPerProfile = 3
 journalFile = "topobath_netsurf.jou"
 acisFile = "topobath_surf.sat"
 
-# Journal file formatting, etc.
-separator = "# ----------------------------------------------------------\n"
-journalBeg = \
-           "# CUBIT journal file generated by topobath_netsurf.py.\n" + \
-           "#\n" + \
-           "# Create an ACIS NURBS surface from intersecting lines.\n" + \
-           "#\n" + separator + \
-           "reset\n"
-lineBeg = "create curve spline"
-splineFmt = " location %10.2e %10.2e %10.2e"
-netFmt = "create surface net u curve %d to %d v curve %d to %d\n"
-delCmd = "delete curve all\n"
-expCmd = "export Acis '" + acisFile + "'\n"
-
 
 # Read coordinates and reshape them.
 demCoords = numpy.loadtxt(demFile, dtype=numpy.float64).reshape(numProfiles, pointsPerProfile, 3)
 
 j = open(journalFile, 'w')
-j.write(journalBeg)
+j.write("# CUBIT journal file generated by topobath_netsurf.py.\n" + \
+            "#\n" + \
+            "# Create an ACIS NURBS surface from intersecting lines.\n" + \
+            "#\n" \
+            "# ----------------------------------------------------------\n" + \
+            "reset\n")
 
 # Loop over profiles (u-lines).
-for profile in range(numProfiles):
-    points = demCoords[profile,:,:]
-    j.write(lineBeg)
-    for pointNum in range(pointsPerProfile):
-        point = points[pointNum,:]
-        j.write(splineFmt % (point[0], point[1], point[2]))
-
-    j.write("\n")
+for iProfile in range(numProfiles):
+    points = demCoords[iProfile,:,:]
+    for iPoint in range(pointsPerProfile):
+        point = points[iPoint,:]
+        j.write("create vertex x %10.2e y %10.2e z %10.2e\n" % \
+                    (point[0], point[1], point[2]))
+        if 0 == iPoint:
+            j.write("#{idBeg=Id('vertex')}\n")
+    j.write("#{idEnd=Id('vertex')}\n")
+    j.write("create curve spline vertex {idBeg} to {idEnd}\n")
+    if 0 == iProfile:
+        j.write("#{idPBeg=Id('curve')}\n")
+j.write("#{idPEnd=Id('curve')}\n\n")
+j.write("delete vertex all\n")
 
 # Loop over contours (v-lines).
-for contour in range(pointsPerProfile):
-    points = demCoords[:,contour,:]
-    j.write(lineBeg)
-    for pointNum in range(numProfiles):
-        point = points[pointNum,:]
-        j.write(splineFmt % (point[0], point[1], point[2]))
-
-    j.write("\n")
+for iContour in range(pointsPerProfile):
+    points = demCoords[:,iContour,:]
+    for iPoint in range(numProfiles):
+        point = points[iPoint,:]
+        j.write("create vertex x %10.2e y %10.2e z %10.2e\n" % \
+                    (point[0], point[1], point[2]))
+        if 0 == iPoint:
+            j.write("#{idBeg=Id('vertex')}\n")
+    j.write("#{idEnd=Id('vertex')}\n")
+    j.write("create curve spline vertex {idBeg} to {idEnd}\n")
+    if 0 == iContour:
+        j.write("#{idCBeg=Id('curve')}\n")
+j.write("#{idCEnd=Id('curve')}\n\n")
+j.write("delete vertex all\n")
 
 # Create net surface.
-uline1 = 1
-uline2 = numProfiles
-vline1 = numProfiles + 1
-vline2 = vline1 + pointsPerProfile - 1
-j.write(netFmt % (uline1, uline2, vline1, vline2))
+j.write("create surface net u curve {idCBeg} to {idCEnd} v curve {idPBeg} to {idPEnd}\n")
 
 # Delete spline curves and export Acis file.
-j.write(delCmd)
-j.write(expCmd)
+j.write("delete curve all\n")
+j.write("export Acis '%s' overwrite\n" % acisFile)
 j.close()
 
 # End of file



More information about the CIG-COMMITS mailing list