Changeset 2498
- Timestamp:
- 04/24/2008 03:20:51 PM (9 months ago)
- Location:
- trunk
- Files:
-
- 10 modified
-
INSTALLATION.txt (modified) (3 diffs)
-
examples/diffusion/steadyState/mesh1D/tri2Dinput.py (modified) (1 diff)
-
examples/diffusion/steadyState/mesh20x20/modifiedMeshInput.py (modified) (2 diffs)
-
fipy/meshes/common/mesh.py (modified) (1 diff)
-
fipy/meshes/numMesh/mesh.py (modified) (1 diff)
-
fipy/meshes/numMesh/mesh2D.py (modified) (1 diff)
-
fipy/meshes/numMesh/skewedGrid2D.py (modified) (1 diff)
-
fipy/viewers/gnuplotViewer/gnuplot1DViewer.py (modified) (1 diff)
-
fipy/viewers/mayaviViewer/mayaviSurfactantViewer.py (modified) (4 diffs)
-
fipy/viewers/mayaviViewer/mayaviViewer.py (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/INSTALLATION.txt
r2344 r2498 259 259 for specific platforms`_ are available |citeMatplotlibDownload|. 260 260 261 .. note:: 262 263 Matplotlib_ is noticeably slower than Pygist_ or Gnuplot.py_, but 264 has superior image rendering and plotting functionality. 265 261 266 .. _Matplotlib: http://www.nist.gov/cgi-bin/exit_nist.cgi?url=http://matplotlib.sourceforge.net 262 267 .. _Matplotlib installers for specific platforms: http://www.nist.gov/cgi-bin/exit_nist.cgi?url=http://sourceforge.net/project/showfiles.php?group_id=80706&package_id=82474 … … 309 314 may crash the |FiPy| run. "``.eps``" and "``.cgm``" export seem to work. 310 315 311 .. attention::312 313 Pygist_ seems to be unable to make contour plots on x86_64314 architectures running Linux.315 316 316 .. note:: 317 317 … … 322 322 .. note:: 323 323 324 Pygist_ can have problems finding color pallets, such as "``heat.gp``" and 325 "``work.gs``", when installed locally. You may need to set the 326 ``GISTPATH`` environment variable to point to the directory containing 327 these files (you may find it as "``g/``" within the directory you 328 specified for ``--home``). 324 Pygist_ can have problems finding color pallets such as 325 "``heat.gp``" and "``work.gs``" when installed locally. To avoid 326 this, copy the files in the "``INSTALLPATH/g``" directory into 327 "``INSTALLPATH/lib/python/gist/``" after installation. 329 328 330 329 .. _Pygist: http://www.nist.gov/cgi-bin/exit_nist.cgi?url=http://hifweb.lbl.gov/public/software/gist/ -
trunk/examples/diffusion/steadyState/mesh1D/tri2Dinput.py
r2331 r2498 97 97 viewer = viewers.make(vars = var) 98 98 viewer.plot() 99 x = mesh.getCellCenters()[ :,0]99 x = mesh.getCellCenters()[0] 100 100 Lx = nx * dx 101 101 analyticalArray = valueLeft + (valueRight - valueLeft) * x / Lx -
trunk/examples/diffusion/steadyState/mesh20x20/modifiedMeshInput.py
r2301 r2498 59 59 1 60 60 61 >>> max(mesh._getNonOrthogonality()) < 0.51 62 True 63 61 64 Note that this test case will only work if you run it by running the 62 65 main FiPy test suite. If you run it directly from the directory it is … … 100 103 errorViewer = viewers.make(vars = errorVar) 101 104 errorViewer.plot() 105 102 106 NonOrthoVar = CellVariable(name = "non-orthogonality", 103 107 mesh = mesh, 104 108 value = mesh._getNonOrthogonality()) 105 NOViewer = viewers.make(vars = NonOrthoVar) 109 NOViewer = viewers.make(vars = NonOrthoVar) 110 111 106 112 NOViewer.plot() 107 113 raw_input("finished") -
trunk/fipy/meshes/common/mesh.py
r2465 r2498 313 313 314 314 def _getNumberOfVertices(self): 315 return len(self.vertexCoords[:,0]) 315 if hasattr(self, 'numberOfVertices'): 316 return self.numberOfVertices 317 else: 318 return len(self.vertexCoords[:,0]) 316 319 317 320 def _getAdjacentCellIDs(self): -
trunk/fipy/meshes/numMesh/mesh.py
r2497 r2498 407 407 408 408 def getVertexCoords(self): 409 return self.vertexCoords 409 if hasattr(self, 'vertexCoords'): 410 return self.vertexCoords 411 else: 412 return self._createVertices() 410 413 411 414 def getExteriorFaces(self): -
trunk/fipy/meshes/numMesh/mesh2D.py
r2465 r2498 118 118 119 119 def _getNonOrthogonality(self): 120 exteriorFaceArray = numerix.zeros((self.faceCellIDs.shape[0],)) 120 121 exteriorFaceArray = numerix.zeros((self.faceCellIDs.shape[1],)) 121 122 numerix.put(exteriorFaceArray, self.getExteriorFaces(), 1) 122 123 unmaskedFaceCellIDs = MA.filled(self.faceCellIDs, 0) ## what we put in for the "fill" doesn't matter because only exterior faces have anything masked, and exterior faces have their displacement vectors set to zero. 123 124 ## if it's an exterior face, make the "displacement vector" equal to zero so the cross product will be zero. 124 faceDisplacementVectors = numerix.where(numerix.array(zip(exteriorFaceArray, exteriorFaceArray)), 0.0, numerix.take(self.getCellCenters(), unmaskedFaceCellIDs[:, 1]) - numerix.take(self.getCellCenters(), unmaskedFaceCellIDs[:, 0])) 125 faceCrossProducts = (faceDisplacementVectors[:, 0] * self.faceNormals[:, 1]) - (faceDisplacementVectors[:, 1] * self.faceNormals[:, 0]) 126 faceDisplacementVectorLengths = numerix.maximum(((faceDisplacementVectors[:, 0] ** 2) + (faceDisplacementVectors[:, 1] ** 2)) ** 0.5, 1.e-100) 125 126 faceDisplacementVectors = numerix.where(numerix.array(zip(exteriorFaceArray, exteriorFaceArray)), 0.0, numerix.take(self.getCellCenters().swapaxes(0,1), unmaskedFaceCellIDs[1, :]) - numerix.take(self.getCellCenters().swapaxes(0,1), unmaskedFaceCellIDs[0, :])).swapaxes(0,1) 127 faceCrossProducts = (faceDisplacementVectors[0, :] * self.faceNormals[1, :]) - (faceDisplacementVectors[1, :] * self.faceNormals[0, :]) 128 faceDisplacementVectorLengths = numerix.maximum(((faceDisplacementVectors[0, :] ** 2) + (faceDisplacementVectors[1, :] ** 2)) ** 0.5, 1.e-100) 127 129 faceWeightedNonOrthogonalities = abs(faceCrossProducts / faceDisplacementVectorLengths) * self.faceAreas 128 130 cellFaceWeightedNonOrthogonalities = numerix.take(faceWeightedNonOrthogonalities, self.cellFaceIDs) 129 131 cellFaceAreas = numerix.take(self.faceAreas, self.cellFaceIDs) 130 cellTotalWeightedValues = numerix.add.reduce(cellFaceWeightedNonOrthogonalities, axis = 1) 131 cellTotalFaceAreas = numerix.add.reduce(cellFaceAreas, axis = 1) 132 cellTotalWeightedValues = numerix.add.reduce(cellFaceWeightedNonOrthogonalities, axis = 0) 133 cellTotalFaceAreas = numerix.add.reduce(cellFaceAreas, axis = 0) 134 132 135 return (cellTotalWeightedValues / cellTotalFaceAreas) 133 136 -
trunk/fipy/meshes/numMesh/skewedGrid2D.py
r2356 r2498 70 70 else: 71 71 self.dy /= scale 72 73 self.numberOfVertices = (self.nx + 1) * (self.ny + 1) 74 75 vertices = self._createVertices() 72 73 from fipy import Grid2D 74 self.grid = Grid2D(nx=nx, ny=ny, dx=dx, dy=dy) 75 76 self.numberOfVertices = self.grid._getNumberOfVertices() 77 78 vertices = self.grid.getVertexCoords() 79 76 80 changedVertices = numerix.zeros(vertices.shape, 'd') 77 ## changedVertices = changedVertices.astype(numerix.Float) 78 for i in range(len(vertices )):81 82 for i in range(len(vertices[0])): 79 83 if((i % (nx+1)) != 0 and (i % (nx+1)) != nx and (i / nx+1) != 0 and (i / nx+1) != ny): 80 changedVertices[ i, 0] = vertices[i, 0] + (rand * ((random.random() * 2) - 1))81 changedVertices[ i, 1] = vertices[i, 1] + (rand * ((random.random() * 2) - 1))84 changedVertices[0, i] = vertices[0, i] + (rand * ((random.random() * 2) - 1)) 85 changedVertices[1, i] = vertices[1, i] + (rand * ((random.random() * 2) - 1)) 82 86 else: 83 changedVertices[i, 0] = vertices[i, 0] 84 changedVertices[i, 1] = vertices[i, 1] 85 faces = self._createFaces() 86 cells = self._createCells() 87 changedVertices[0, i] = vertices[0, i] 88 changedVertices[1, i] = vertices[1, i] 89 90 91 faces = self.grid._getFaceVertexIDs() 92 93 cells = self.grid._getCellFaceIDs() 94 87 95 Mesh2D.__init__(self, changedVertices, faces, cells) 88 96 89 97 self.setScale(value = scale) 90 98 91 def _createVertices(self): 92 x = numerix.arange(self.nx + 1) * self.dx 93 y = numerix.arange(self.ny + 1) * self.dy 94 x = numerix.resize(x, (self.numberOfVertices,)) 95 y = numerix.repeat(y, self.nx + 1) 96 return numerix.transpose(numerix.array((x, y))) 97 98 def _createFaces(self): 99 """ 100 v1, v2 refer to the cells. 101 Horizontel faces are first 102 """ 103 v1 = numerix.arange(self.numberOfVertices) 104 v2 = v1 + 1 105 horizontalFaces = vector.prune(numerix.transpose(numerix.array((v1, v2))), self.nx + 1, self.nx) 106 v1 = numerix.arange(self.numberOfVertices - (self.nx + 1)) 107 v2 = v1 + self.nx + 1 108 verticalFaces = numerix.transpose(numerix.array((v1, v2))) 109 110 ## reverse some of the face orientations to obtain the correct normals 111 112 tmp = horizontalFaces.copy() 113 horizontalFaces[:self.nx, 0] = tmp[:self.nx, 1] 114 horizontalFaces[:self.nx, 1] = tmp[:self.nx, 0] 115 116 tmp = verticalFaces.copy() 117 verticalFaces[:, 0] = tmp[:, 1] 118 verticalFaces[:, 1] = tmp[:, 0] 119 verticalFaces[::(self.nx + 1), 0] = tmp[::(self.nx + 1), 0] 120 verticalFaces[::(self.nx + 1), 1] = tmp[::(self.nx + 1), 1] 121 122 return numerix.concatenate((horizontalFaces, verticalFaces)) 123 124 def _createCells(self): 125 """ 126 cells = (f1, f2, f3, f4) going anticlock wise. 127 f1 etx refer to the faces 128 """ 129 self.numberOfHorizontalFaces = self.nx * (self.ny + 1) 130 self.numberOfFaces = self.numberOfHorizontalFaces + self.ny * (self.nx + 1) 131 f1 = numerix.arange(self.numberOfHorizontalFaces - self.nx) 132 f3 = f1 + self.nx 133 f2 = vector.prune(numerix.arange(self.numberOfHorizontalFaces, self.numberOfFaces), self.nx + 1) 134 f4 = f2 - 1 135 return numerix.transpose(numerix.array((f1, f2, f3, f4))) 136 99 ## def _createVertices(self): 100 ## x = numerix.arange(self.nx + 1) * self.dx 101 ## y = numerix.arange(self.ny + 1) * self.dy 102 ## x = numerix.resize(x, (self.numberOfVertices,)) 103 ## y = numerix.repeat(y, self.nx + 1) 104 ## return numerix.array((x, y)) 105 ## ## raw_input() 106 ## ## return numerix.transpose(numerix.array((x, y))) 107 108 ## def _createFaces(self): 109 ## """ 110 ## v1, v2 refer to the cells. 111 ## Horizontel faces are first 112 ## """ 113 ## v1 = numerix.arange(self.numberOfVertices) 114 ## v2 = v1 + 1 115 ## horizontalFaces = vector.prune(numerix.transpose(numerix.array((v1, v2))), self.nx + 1, self.nx) 116 ## v1 = numerix.arange(self.numberOfVertices - (self.nx + 1)) 117 ## v2 = v1 + self.nx + 1 118 ## verticalFaces = numerix.transpose(numerix.array((v1, v2))) 119 120 ## ## reverse some of the face orientations to obtain the correct normals 121 122 ## tmp = horizontalFaces.copy() 123 ## horizontalFaces[:self.nx, 0] = tmp[:self.nx, 1] 124 ## horizontalFaces[:self.nx, 1] = tmp[:self.nx, 0] 125 126 ## tmp = verticalFaces.copy() 127 ## verticalFaces[:, 0] = tmp[:, 1] 128 ## verticalFaces[:, 1] = tmp[:, 0] 129 ## verticalFaces[::(self.nx + 1), 0] = tmp[::(self.nx + 1), 0] 130 ## verticalFaces[::(self.nx + 1), 1] = tmp[::(self.nx + 1), 1] 131 132 ## return numerix.concatenate((horizontalFaces, verticalFaces)) 133 134 ## def _createCells(self): 135 ## """ 136 ## cells = (f1, f2, f3, f4) going anticlock wise. 137 ## f1 etx refer to the faces 138 ## """ 139 ## self.numberOfHorizontalFaces = self.nx * (self.ny + 1) 140 ## self.numberOfFaces = self.numberOfHorizontalFaces + self.ny * (self.nx + 1) 141 ## f1 = numerix.arange(self.numberOfHorizontalFaces - self.nx) 142 ## f3 = f1 + self.nx 143 ## f2 = vector.prune(numerix.arange(self.numberOfHorizontalFaces, self.numberOfFaces), self.nx + 1) 144 ## f4 = f2 - 1 145 ## return numerix.transpose(numerix.array((f1, f2, f3, f4))) 146 147 148 137 149 def getFacesLeft(self): 138 150 """Return list of faces on left boundary of Grid2D. 139 151 """ 140 return FaceIterator(mesh = self, ids = numerix.arange(self.numberOfHorizontalFaces, self.numberOfFaces, self.nx + 1)) 141 152 return self.grid.getFacesLeft() 153 ## return FaceIterator(mesh = self, ids = numerix.arange(self.numberOfHorizontalFaces, self.numberOfFaces, self.nx + 1)) 154 142 155 def getFacesRight(self): 143 156 """Return list of faces on right boundary of Grid2D. 144 157 """ 145 return FaceIterator(mesh = self, ids = numerix.arange(self.numberOfHorizontalFaces + self.nx, self.numberOfFaces, self.nx + 1)) 146 158 return self.grid.getFacesRight() 159 ## return FaceIterator(mesh = self, ids = numerix.arange(self.numberOfHorizontalFaces + self.nx, self.numberOfFaces, self.nx + 1)) 160 147 161 def getFacesTop(self): 148 162 """Return list of faces on top boundary of Grid2D. 149 163 """ 150 return FaceIterator(mesh = self, ids = numerix.arange(self.numberOfHorizontalFaces - self.nx, self.numberOfHorizontalFaces)) 164 return self.grid.getFacesTop() 165 ## return FaceIterator(mesh = self, ids = numerix.arange(self.numberOfHorizontalFaces - self.nx, self.numberOfHorizontalFaces)) 151 166 152 167 getFacesUp = getFacesTop 153 168 154 169 def getFacesBottom(self): 155 170 """Return list of faces on bottom boundary of Grid2D. 156 171 """ 157 return FaceIterator(mesh = self, ids = numerix.arange(self.nx)) 172 return self.grid.getFacesBottom() 173 ## return FaceIterator(mesh = self, ids = numerix.arange(self.nx)) 158 174 159 175 getFacesDown = getFacesBottom -
trunk/fipy/viewers/gnuplotViewer/gnuplot1DViewer.py
r2286 r2498 89 89 for var in self.vars: 90 90 tupleOfGnuplotData += (Gnuplot.Data(numerix.array(var.getMesh().getCellCenters()[0]), 91 var.getValue(),91 numerix.array(var.getValue()), 92 92 title=var.getName(), 93 93 with='lines'),) -
trunk/fipy/viewers/mayaviViewer/mayaviSurfactantViewer.py
r2297 r2498 133 133 134 134 IDs = numerix.nonzero(self.distanceVar._getCellInterfaceFlag()) 135 coordinates = numerix.take(numerix.array(self.distanceVar.getMesh().getCellCenters()), IDs) 136 137 coordinates -= numerix.take(self.distanceVar.getGrad() * self.distanceVar, IDs) 135 coordinates = numerix.take(numerix.array(self.distanceVar.getMesh().getCellCenters()).swapaxes(0,1), IDs) 136 137 coordinates -= numerix.take(numerix.array(self.distanceVar.getGrad() * self.distanceVar).swapaxes(0,1), IDs) 138 138 139 coordinates *= self.zoomFactor 139 140 … … 142 143 coordinates = numerix.concatenate((coordinates, shiftedCoords)) 143 144 144 145 145 from lines import _getOrderedLines 146 146 147 lines = _getOrderedLines(range(2 * len(IDs)), coordinates, thresholdDistance = self.distanceVar.getMesh()._getCellDistances().min() * 10) 147 148 … … 159 160 val, 160 161 data) 161 162 162 163 163 for line in lines: … … 255 255 if xmin is None: 256 256 xmin = self.surfactantVar.min() 257 257 258 258 slh.range_var.set((xmin, xmax)) 259 259 slh.set_range_var() 260 260 261 slh.v_range_var.set(( self.surfactantVar.min(), self.surfactantVar.max()))261 slh.v_range_var.set((float(self.surfactantVar.min()), float(self.surfactantVar.max()))) 262 262 slh.set_v_range_var() 263 263 264 264 self._viewer.Render() 265 265 -
trunk/fipy/viewers/mayaviViewer/mayaviViewer.py
r2497 r2498 131 131 132 132 for var in self.vars: 133 if var.getRank() > 0: 134 raise IndexError, "Mayavi can only plot scalar values" 133 135 self.structures.append(self._getStructure(var.getMesh())) 136 134 137 135 138 def _getStructure(self, mesh):
FiPy: A Finite Volume PDE Solver Using Python