[cig-commits] r13095 - short/3D/PyLith/trunk/playpen/euler
willic3 at geodynamics.org
willic3 at geodynamics.org
Wed Oct 15 16:46:37 PDT 2008
Author: willic3
Date: 2008-10-15 16:46:37 -0700 (Wed, 15 Oct 2008)
New Revision: 13095
Modified:
short/3D/PyLith/trunk/playpen/euler/euler.py
short/3D/PyLith/trunk/playpen/euler/grabfaces.py
short/3D/PyLith/trunk/playpen/euler/grabpoints.py
Log:
Fixed scaling for euler.py.
Added option to excude points if normal magnitude is zero for grabpoints.py
and grabfaces.py.
Modified: short/3D/PyLith/trunk/playpen/euler/euler.py
===================================================================
--- short/3D/PyLith/trunk/playpen/euler/euler.py 2008-10-15 22:11:36 UTC (rev 13094)
+++ short/3D/PyLith/trunk/playpen/euler/euler.py 2008-10-15 23:46:37 UTC (rev 13095)
@@ -266,15 +266,15 @@
velocity = self._euler2Velocity(pointsLL[point])
if self.bcType == 'dislocation':
vlocal = self._localTrans(velocity, normalsArr[point])
- velocity = vlocal
+ velocity = self.bcScale * vlocal
else:
- velocity[0] = self.defaultValues[0]
- velocity[1] = self.defaultValues[1]
- velocity[2] = self.defaultValues[2]
+ velocity[0] = self.bcScale * self.defaultValues[0]
+ velocity[1] = self.bcScale * self.defaultValues[1]
+ velocity[2] = self.bcScale * self.defaultValues[2]
for dim in range(self.spaceDim):
f.write(' %.12e' % self.pointsUTM[iCount + dim])
for dim in range(self.spaceDim):
- f.write(' %.12e' % self.bcScale * velocity[dim])
+ f.write(' %.12e' % velocity[dim])
f.write('\n')
iCount += 3
return
Modified: short/3D/PyLith/trunk/playpen/euler/grabfaces.py
===================================================================
--- short/3D/PyLith/trunk/playpen/euler/grabfaces.py 2008-10-15 22:11:36 UTC (rev 13094)
+++ short/3D/PyLith/trunk/playpen/euler/grabfaces.py 2008-10-15 23:46:37 UTC (rev 13095)
@@ -13,7 +13,8 @@
## @file euler/grabfaces
## @brief Python application to grab a set of points specified in a UCD
-## face description file and write them to a file.
+## face description file along with the associated normals and write them to a
+## file.
import math
import numpy
@@ -22,7 +23,7 @@
class GrabFaces(Application):
"""
- Python application to grab a set of point coordinates and values from a UCD
+ Python application to grab a set of point coordinates and normals from a UCD
face description file.
"""
@@ -39,6 +40,7 @@
## @li \b fault_id_num ID number (material number) of fault to use.
## @li \b point_output_file Filename of output set of points and normals.
## @li \b node_values_list List specifying position of desired attributes in UCD face nodal attributes.
+ ## @li \b exclude_zero_normals Flag indicating whether to exclude points if the associated normal has zero magnitude.
##
## \b Facilities
## @li None
@@ -58,7 +60,11 @@
nodeValuesList = pyre.inventory.list("node_values_list", default=[1, 2, 3])
nodeValuesList.meta['tip'] = "Position of desired values in UCD face nodal attributes."
+ excludeZeroNormals = pyre.inventory.bool("exclude_zero_normals",
+ default=False)
+ excludeZeroNormals.meta['tip'] = "Whether to exclude points with zero normals."
+
# PUBLIC METHODS /////////////////////////////////////////////////////
def __init__(self, name="grabfaces"):
@@ -84,6 +90,7 @@
self.faultIDNum = self.inventory.faultIDNum
self.pointOutputFile = self.inventory.pointOutputFile
self.nodeValuesList = self.inventory.nodeValuesList
+ self.excludeZeroNormals = self.inventory.excludeZeroNormals
return
@@ -144,7 +151,12 @@
if vertex == ucdInd:
data = lines[lineCount].split()
normals = [float(data[v0]), float(data[v1]), float(data[v2])]
- if normals[0] != 0.0 or normals[1] != 0.0 or normals[2] != 0.0:
+ outputPoint = not self.excludeZeroNormals
+ outputPoint = outputPoint or \
+ normals[0] != 0.0 or \
+ normals[1] != 0.0 or \
+ normals[2] != 0.0
+ if outputPoint:
for dim in range(3):
o.write(' %.12e' % vertCoords[coordCount + dim])
Modified: short/3D/PyLith/trunk/playpen/euler/grabpoints.py
===================================================================
--- short/3D/PyLith/trunk/playpen/euler/grabpoints.py 2008-10-15 22:11:36 UTC (rev 13094)
+++ short/3D/PyLith/trunk/playpen/euler/grabpoints.py 2008-10-15 23:46:37 UTC (rev 13095)
@@ -13,7 +13,8 @@
## @file grabpoints/grabpoints
## @brief Python application to grab a set of points specified in a pset
-## file from a UCD file and write them to a file.
+## file from a UCD file along with the associated normals and write them to a
+## file.
import math
import numpy
@@ -23,7 +24,7 @@
class GrabPoints(Application):
"""
Python application to grab a specified set of point coordinates and
- values from a UCD file.
+ normals from a UCD file.
"""
class Inventory(Application.Inventory):
@@ -39,6 +40,8 @@
## @li \b ucd_file Filename of input UCD file.
## @li \b point_output_file Filename of output set of points and normals.
## @li \b values_list List specifying position of desired attributes in UCD file.
+ ## @li \b output_index Flag indicating whether to output the vertex indices.
+ ## @li \b exclude_zero_normals Flag indicating whether to exclude points if the associated normal has zero magnitude.
##
## \b Facilities
## @li None
@@ -61,7 +64,11 @@
outputIndex = pyre.inventory.bool("output_index", default=False)
outputIndex.meta['tip'] = "Whether to output vertex indices."
+ excludeZeroNormals = pyre.inventory.bool("exclude_zero_normals",
+ default=False)
+ excludeZeroNormals.meta['tip'] = "Whether to exclude points with zero normals."
+
# PUBLIC METHODS /////////////////////////////////////////////////////
def __init__(self, name="grabpoints"):
@@ -92,6 +99,7 @@
self.pointOutputFile = self.inventory.pointOutputFile
self.valuesList = self.inventory.valuesList
self.outputIndex = self.inventory.outputIndex
+ self.excludeZeroNormals = self.inventory.excludeZeroNormals
return
@@ -131,10 +139,10 @@
vertex = self.indices[vertInd]
if vertex == ucdInd:
data = lines[lineCount].split()
- for dim in range(1,4):
+ for dim in range(1,4):
self.pointCoords.append(float(data[dim]))
vertInd += 1
- vertInd = min([vertInd, len(self.indices) - 1])
+ vertInd = min([vertInd, len(self.indices) - 1])
ucdInd += 1
# Skip elements and then start reading normals/values and write out
@@ -155,18 +163,23 @@
if vertex == ucdInd:
data = lines[lineCount].split()
normals = [float(data[v0]), float(data[v1]), float(data[v2])]
- if normals[0] != 0.0 or normals[1] != 0.0 or normals[2] != 0.0:
+ outputPoint = not self.excludeZeroNormals
+ outputPoint = outputPoint or \
+ normals[0] != 0.0 or \
+ normals[1] != 0.0 or \
+ normals[2] != 0.0
+
+ if outputPoint:
+ if self.outputIndex:
+ o.write(' %i' % vertex)
- if self.outputIndex:
- o.write(' %i' % vertex)
+ for dim in range(3):
+ o.write(' %.12e' % self.pointCoords[coordCount + dim])
- for dim in range(3):
- o.write(' %.12e' % self.pointCoords[coordCount + dim])
+ for dim in range(3):
+ o.write(' %.12e' % normals[dim])
- for dim in range(3):
- o.write(' %.12e' % normals[dim])
-
- o.write('\n')
+ o.write('\n')
vertInd += 1
coordCount += 3
More information about the CIG-COMMITS
mailing list