Best Python code snippet using fMBT_python
slab_interface_netsurf.py
Source:slab_interface_netsurf.py
1#!/usr/bin/env python2# ----------------------------------------------------------------------3#4# Brad T. Aagaard, U.S. Geological Survey5# Charles A. Williams, GNS Science6# Matthew G. Knepley, University of Chicago7#8# This code was developed as part of the Computational Infrastructure9# for Geodynamics (http://geodynamics.org).10#11# Copyright (c) 2010-2015 University of California, Davis12#13# See COPYING for license information.14#15# ----------------------------------------------------------------------16#17# PREREQUISITES: numpy18#19# ======================================================================20from __future__ import print_function21import numpy22import sys23for i in range(len(sys.argv)): # read parameter from shell(contain the prefix)24 if(sys.argv[i].find("-p")==0):25 P1=sys.argv[i+1]26 P2=sys.argv[i+2]27 P3=sys.argv[i+3]28 P4=sys.argv[i+4]29 P5=sys.argv[i+5]30print(P1,P2,P3,P4,P5)31# Define parameters.32interfaceFile = P133numContours = int(P3)34pointsPerContour = int(P2)35journalFile = P436acisFile = P537# Journal file formatting, etc.38# Read coordinates and reshape them.39intCoords = numpy.loadtxt(interfaceFile, dtype=numpy.float64).reshape(numContours, pointsPerContour, 3)40j = open(journalFile, 'w')41j.write("# CUBIT journal file generated by interface_netsurf.py.\n" + \42 "#\n" + \43 "# Create an ACIS NURBS surface from intersecting lines.\n" + \44 "#\n" \45 "# ----------------------------------------------------------\n" + \46 "reset\n")47# Loop over contours (u-lines).48for iContour in range(numContours):49 points = intCoords[iContour,:,:]50 for iPoint in range(pointsPerContour):51 point = points[iPoint,:]52 j.write("create vertex x %10.5e y %10.5e z %10.5e\n" % \53 (point[0], point[1], point[2]))54 if 0 == iPoint:55 j.write("${idBeg=Id('vertex')}\n")56 j.write("${idEnd=Id('vertex')}\n")57 j.write("create curve spline vertex {idBeg} to {idEnd} delete\n")58 if 0 == iContour:59 j.write("${idCBeg=Id('curve')}\n")60j.write("${idCEnd=Id('curve')}\n\n")61# Loop over profiles (v-lines).62for iProfile in range(pointsPerContour):63 points = intCoords[:,iProfile,:]64 for iPoint in range(numContours):65 point = points[iPoint,:]66 j.write("create vertex x %10.5e y %10.5e z %10.5e\n" % \67 (point[0], point[1], point[2]))68 if 0 == iPoint:69 j.write("${idBeg=Id('vertex')}\n")70 j.write("${idEnd=Id('vertex')}\n")71 j.write("create curve spline vertex {idBeg} to {idEnd} delete\n")72 if 0 == iProfile:73 j.write("${idPBeg=Id('curve')}\n")74j.write("${idPEnd=Id('curve')}\n\n")75# Create net surface.76j.write("create surface net u curve {idCBeg} to {idCEnd} v curve {idPBeg} to {idPEnd}\n")77## Rotate the surface78#j.write("\n")79#length = numpy.max(intCoords[:,:,0]) - numpy.min(intCoords[:,:,0])80#width = numpy.max(intCoords[:,:,1]) - numpy.min(intCoords[:,:,1])81#offset_x = (numpy.max(intCoords[:,:,0]) + numpy.min(intCoords[:,:,0]))/2.082#offset_y = (numpy.max(intCoords[:,:,1]) + numpy.min(intCoords[:,:,1]))/2.083#print(length,width, offset_x, offset_y)84#85#86#create surface rectangle width length height width87#surface 2 move x offset_x y offset_y z 088#surface 2 move x 0 y 0 z -3000 copy89#surface 2 move x 0 y 0 z -3000090#91# Delete spline curves and export Acis file.92j.write("delete curve all\n")93j.write("export Acis '%s' overwrite\n" % acisFile)94j.close()...
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!