Exemplo n.º 1
0
# compute nodal field from MLS points
services.importData("MLS Point Values", "SCALAR", pinit)
services.compute("Compute Nodal Field")
nodeVals = services.exportData("MLS Field Values", "SCALAR_FIELD")

# compute reference volume
numNodes = len(nodeVals)
x = [1.0 for i in range(numNodes)]
analyze.importData("Topology", "SCALAR_FIELD", x)
analyze.compute("Compute Constraint Value")
refValue = analyze.exportData("Constraint Value", "SCALAR")

# open exodus file for output and configure
inputMeshName = "mitchell_tri.gen"
outMesh = exodus.ExodusDB()
outMesh.read(inputMeshName)
outMesh.nodeVarNames = ["topology"]
outMesh.numNodeVars = len(outMesh.nodeVarNames)

outMesh.nodeVars = [[nodeVals]]
outMesh.varTimes = [1.0]


#define objective
def f(x, grad):

    # compute nodal field from MLS points
    services.importData("MLS Point Values", "SCALAR", x.tolist())
    services.compute("Compute Nodal Field")
    nodeVals = services.exportData("MLS Field Values", "SCALAR_FIELD")
Exemplo n.º 2
0
import exodus
import math

mesh = exodus.ExodusDB()
mesh.read("InternalEnergyGradX.exo")
gradx = mesh.getNodeData(0, "gradientx_x")

x0 = 2.5;

endNodes = []
for iNode in range(mesh.numNodes):
  if abs(mesh.coordinates[0][iNode] - x0) < 1e-8:
    endNodes.append(iNode)

val = 0.0
for inode in endNodes:
  val += gradx[inode]

print "sum on end: ", val