fipy package¶
Subpackages¶
- fipy.boundaryConditions package
- fipy.matrices package
- fipy.meshes package
- Subpackages
- Submodules
- fipy.meshes.abstractMesh module
AbstractMesh
AbstractMesh.VTKCellDataSet
AbstractMesh.VTKFaceDataSet
AbstractMesh.__add__()
AbstractMesh.__div__()
AbstractMesh.__getstate__()
AbstractMesh.__mul__()
AbstractMesh.__radd__()
AbstractMesh.__repr__()
AbstractMesh.__rmul__()
AbstractMesh.__setstate__()
AbstractMesh.__sub__()
AbstractMesh.__truediv__()
AbstractMesh.aspect2D
AbstractMesh.cellCenters
AbstractMesh.cellDistanceVectors
AbstractMesh.cellFaceIDs
AbstractMesh.cellToFaceDistanceVectors
AbstractMesh.cellVolumes
AbstractMesh.extents
AbstractMesh.exteriorFaces
AbstractMesh.faceCenters
AbstractMesh.facesBack
AbstractMesh.facesBottom
AbstractMesh.facesDown
AbstractMesh.facesFront
AbstractMesh.facesLeft
AbstractMesh.facesRight
AbstractMesh.facesTop
AbstractMesh.facesUp
AbstractMesh.getNearestCell()
AbstractMesh.interiorFaceCellIDs
AbstractMesh.interiorFaceIDs
AbstractMesh.interiorFaces
AbstractMesh.scale
AbstractMesh.scaledCellDistances
AbstractMesh.scaledCellToCellDistances
AbstractMesh.scaledCellVolumes
AbstractMesh.scaledFaceAreas
AbstractMesh.scaledFaceToCellDistances
AbstractMesh.x
AbstractMesh.y
AbstractMesh.z
- fipy.meshes.cylindricalGrid1D module
- fipy.meshes.cylindricalGrid2D module
- fipy.meshes.cylindricalNonUniformGrid1D module
CylindricalNonUniformGrid1D
CylindricalNonUniformGrid1D.VTKCellDataSet
CylindricalNonUniformGrid1D.VTKFaceDataSet
CylindricalNonUniformGrid1D.__add__()
CylindricalNonUniformGrid1D.__div__()
CylindricalNonUniformGrid1D.__getstate__()
CylindricalNonUniformGrid1D.__mul__()
CylindricalNonUniformGrid1D.__radd__()
CylindricalNonUniformGrid1D.__repr__()
CylindricalNonUniformGrid1D.__rmul__()
CylindricalNonUniformGrid1D.__setstate__()
CylindricalNonUniformGrid1D.__sub__()
CylindricalNonUniformGrid1D.__truediv__()
CylindricalNonUniformGrid1D.aspect2D
CylindricalNonUniformGrid1D.cellCenters
CylindricalNonUniformGrid1D.cellDistanceVectors
CylindricalNonUniformGrid1D.cellFaceIDs
CylindricalNonUniformGrid1D.cellToFaceDistanceVectors
CylindricalNonUniformGrid1D.cellVolumes
CylindricalNonUniformGrid1D.extents
CylindricalNonUniformGrid1D.exteriorFaces
CylindricalNonUniformGrid1D.faceCenters
CylindricalNonUniformGrid1D.facesBack
CylindricalNonUniformGrid1D.facesBottom
CylindricalNonUniformGrid1D.facesDown
CylindricalNonUniformGrid1D.facesFront
CylindricalNonUniformGrid1D.facesLeft
CylindricalNonUniformGrid1D.facesRight
CylindricalNonUniformGrid1D.facesTop
CylindricalNonUniformGrid1D.facesUp
CylindricalNonUniformGrid1D.getNearestCell()
CylindricalNonUniformGrid1D.interiorFaceCellIDs
CylindricalNonUniformGrid1D.interiorFaceIDs
CylindricalNonUniformGrid1D.interiorFaces
CylindricalNonUniformGrid1D.scale
CylindricalNonUniformGrid1D.scaledCellDistances
CylindricalNonUniformGrid1D.scaledCellToCellDistances
CylindricalNonUniformGrid1D.scaledCellVolumes
CylindricalNonUniformGrid1D.scaledFaceAreas
CylindricalNonUniformGrid1D.scaledFaceToCellDistances
CylindricalNonUniformGrid1D.x
CylindricalNonUniformGrid1D.y
CylindricalNonUniformGrid1D.z
- fipy.meshes.cylindricalNonUniformGrid2D module
CylindricalNonUniformGrid2D
CylindricalNonUniformGrid2D.VTKCellDataSet
CylindricalNonUniformGrid2D.VTKFaceDataSet
CylindricalNonUniformGrid2D.__add__()
CylindricalNonUniformGrid2D.__div__()
CylindricalNonUniformGrid2D.__getstate__()
CylindricalNonUniformGrid2D.__mul__()
CylindricalNonUniformGrid2D.__radd__()
CylindricalNonUniformGrid2D.__repr__()
CylindricalNonUniformGrid2D.__rmul__()
CylindricalNonUniformGrid2D.__setstate__()
CylindricalNonUniformGrid2D.__sub__()
CylindricalNonUniformGrid2D.__truediv__()
CylindricalNonUniformGrid2D.aspect2D
CylindricalNonUniformGrid2D.cellCenters
CylindricalNonUniformGrid2D.cellDistanceVectors
CylindricalNonUniformGrid2D.cellFaceIDs
CylindricalNonUniformGrid2D.cellToFaceDistanceVectors
CylindricalNonUniformGrid2D.cellVolumes
CylindricalNonUniformGrid2D.extents
CylindricalNonUniformGrid2D.exteriorFaces
CylindricalNonUniformGrid2D.extrude()
CylindricalNonUniformGrid2D.faceCenters
CylindricalNonUniformGrid2D.facesBack
CylindricalNonUniformGrid2D.facesBottom
CylindricalNonUniformGrid2D.facesDown
CylindricalNonUniformGrid2D.facesFront
CylindricalNonUniformGrid2D.facesLeft
CylindricalNonUniformGrid2D.facesRight
CylindricalNonUniformGrid2D.facesTop
CylindricalNonUniformGrid2D.facesUp
CylindricalNonUniformGrid2D.getNearestCell()
CylindricalNonUniformGrid2D.interiorFaceCellIDs
CylindricalNonUniformGrid2D.interiorFaceIDs
CylindricalNonUniformGrid2D.interiorFaces
CylindricalNonUniformGrid2D.scale
CylindricalNonUniformGrid2D.scaledCellDistances
CylindricalNonUniformGrid2D.scaledCellToCellDistances
CylindricalNonUniformGrid2D.scaledCellVolumes
CylindricalNonUniformGrid2D.scaledFaceAreas
CylindricalNonUniformGrid2D.scaledFaceToCellDistances
CylindricalNonUniformGrid2D.x
CylindricalNonUniformGrid2D.y
CylindricalNonUniformGrid2D.z
- fipy.meshes.cylindricalUniformGrid1D module
CylindricalUniformGrid1D
CylindricalUniformGrid1D.VTKCellDataSet
CylindricalUniformGrid1D.VTKFaceDataSet
CylindricalUniformGrid1D.__add__()
CylindricalUniformGrid1D.__div__()
CylindricalUniformGrid1D.__getstate__()
CylindricalUniformGrid1D.__mul__()
CylindricalUniformGrid1D.__radd__()
CylindricalUniformGrid1D.__repr__()
CylindricalUniformGrid1D.__rmul__()
CylindricalUniformGrid1D.__setstate__()
CylindricalUniformGrid1D.__sub__()
CylindricalUniformGrid1D.__truediv__()
CylindricalUniformGrid1D.aspect2D
CylindricalUniformGrid1D.cellCenters
CylindricalUniformGrid1D.cellDistanceVectors
CylindricalUniformGrid1D.cellFaceIDs
CylindricalUniformGrid1D.cellToFaceDistanceVectors
CylindricalUniformGrid1D.cellVolumes
CylindricalUniformGrid1D.extents
CylindricalUniformGrid1D.exteriorFaces
CylindricalUniformGrid1D.faceCellIDs
CylindricalUniformGrid1D.faceCenters
CylindricalUniformGrid1D.faceNormals
CylindricalUniformGrid1D.facesBack
CylindricalUniformGrid1D.facesBottom
CylindricalUniformGrid1D.facesDown
CylindricalUniformGrid1D.facesFront
CylindricalUniformGrid1D.facesLeft
CylindricalUniformGrid1D.facesRight
CylindricalUniformGrid1D.facesTop
CylindricalUniformGrid1D.facesUp
CylindricalUniformGrid1D.getNearestCell()
CylindricalUniformGrid1D.interiorFaceCellIDs
CylindricalUniformGrid1D.interiorFaceIDs
CylindricalUniformGrid1D.interiorFaces
CylindricalUniformGrid1D.scale
CylindricalUniformGrid1D.scaledCellDistances
CylindricalUniformGrid1D.scaledCellToCellDistances
CylindricalUniformGrid1D.scaledCellVolumes
CylindricalUniformGrid1D.scaledFaceAreas
CylindricalUniformGrid1D.scaledFaceToCellDistances
CylindricalUniformGrid1D.vertexCoords
CylindricalUniformGrid1D.x
CylindricalUniformGrid1D.y
CylindricalUniformGrid1D.z
- fipy.meshes.cylindricalUniformGrid2D module
CylindricalUniformGrid2D
CylindricalUniformGrid2D.VTKCellDataSet
CylindricalUniformGrid2D.VTKFaceDataSet
CylindricalUniformGrid2D.__add__()
CylindricalUniformGrid2D.__div__()
CylindricalUniformGrid2D.__getstate__()
CylindricalUniformGrid2D.__mul__()
CylindricalUniformGrid2D.__radd__()
CylindricalUniformGrid2D.__repr__()
CylindricalUniformGrid2D.__rmul__()
CylindricalUniformGrid2D.__setstate__()
CylindricalUniformGrid2D.__sub__()
CylindricalUniformGrid2D.__truediv__()
CylindricalUniformGrid2D.aspect2D
CylindricalUniformGrid2D.cellCenters
CylindricalUniformGrid2D.cellDistanceVectors
CylindricalUniformGrid2D.cellFaceIDs
CylindricalUniformGrid2D.cellToFaceDistanceVectors
CylindricalUniformGrid2D.cellVolumes
CylindricalUniformGrid2D.extents
CylindricalUniformGrid2D.exteriorFaces
CylindricalUniformGrid2D.faceCellIDs
CylindricalUniformGrid2D.faceCenters
CylindricalUniformGrid2D.faceNormals
CylindricalUniformGrid2D.faceVertexIDs
CylindricalUniformGrid2D.facesBack
CylindricalUniformGrid2D.facesBottom
CylindricalUniformGrid2D.facesDown
CylindricalUniformGrid2D.facesFront
CylindricalUniformGrid2D.facesLeft
CylindricalUniformGrid2D.facesRight
CylindricalUniformGrid2D.facesTop
CylindricalUniformGrid2D.facesUp
CylindricalUniformGrid2D.getNearestCell()
CylindricalUniformGrid2D.interiorFaceCellIDs
CylindricalUniformGrid2D.interiorFaceIDs
CylindricalUniformGrid2D.interiorFaces
CylindricalUniformGrid2D.scale
CylindricalUniformGrid2D.scaledCellDistances
CylindricalUniformGrid2D.scaledCellToCellDistances
CylindricalUniformGrid2D.scaledCellVolumes
CylindricalUniformGrid2D.scaledFaceAreas
CylindricalUniformGrid2D.scaledFaceToCellDistances
CylindricalUniformGrid2D.vertexCoords
CylindricalUniformGrid2D.x
CylindricalUniformGrid2D.y
CylindricalUniformGrid2D.z
- fipy.meshes.factoryMeshes module
- fipy.meshes.gmshMesh module
Gmsh2D
Gmsh2D.VTKCellDataSet
Gmsh2D.VTKFaceDataSet
Gmsh2D.__add__()
Gmsh2D.__div__()
Gmsh2D.__getstate__()
Gmsh2D.__mul__()
Gmsh2D.__radd__()
Gmsh2D.__repr__()
Gmsh2D.__rmul__()
Gmsh2D.__setstate__()
Gmsh2D.__sub__()
Gmsh2D.__truediv__()
Gmsh2D.aspect2D
Gmsh2D.cellCenters
Gmsh2D.cellDistanceVectors
Gmsh2D.cellFaceIDs
Gmsh2D.cellToFaceDistanceVectors
Gmsh2D.cellVolumes
Gmsh2D.extents
Gmsh2D.exteriorFaces
Gmsh2D.extrude()
Gmsh2D.faceCenters
Gmsh2D.facesBack
Gmsh2D.facesBottom
Gmsh2D.facesDown
Gmsh2D.facesFront
Gmsh2D.facesLeft
Gmsh2D.facesRight
Gmsh2D.facesTop
Gmsh2D.facesUp
Gmsh2D.getNearestCell()
Gmsh2D.interiorFaceCellIDs
Gmsh2D.interiorFaceIDs
Gmsh2D.interiorFaces
Gmsh2D.scale
Gmsh2D.scaledCellDistances
Gmsh2D.scaledCellToCellDistances
Gmsh2D.scaledCellVolumes
Gmsh2D.scaledFaceAreas
Gmsh2D.scaledFaceToCellDistances
Gmsh2D.x
Gmsh2D.y
Gmsh2D.z
Gmsh2DIn3DSpace
Gmsh2DIn3DSpace.VTKCellDataSet
Gmsh2DIn3DSpace.VTKFaceDataSet
Gmsh2DIn3DSpace.__add__()
Gmsh2DIn3DSpace.__div__()
Gmsh2DIn3DSpace.__getstate__()
Gmsh2DIn3DSpace.__mul__()
Gmsh2DIn3DSpace.__radd__()
Gmsh2DIn3DSpace.__repr__()
Gmsh2DIn3DSpace.__rmul__()
Gmsh2DIn3DSpace.__setstate__()
Gmsh2DIn3DSpace.__sub__()
Gmsh2DIn3DSpace.__truediv__()
Gmsh2DIn3DSpace.aspect2D
Gmsh2DIn3DSpace.cellCenters
Gmsh2DIn3DSpace.cellDistanceVectors
Gmsh2DIn3DSpace.cellFaceIDs
Gmsh2DIn3DSpace.cellToFaceDistanceVectors
Gmsh2DIn3DSpace.cellVolumes
Gmsh2DIn3DSpace.extents
Gmsh2DIn3DSpace.exteriorFaces
Gmsh2DIn3DSpace.extrude()
Gmsh2DIn3DSpace.faceCenters
Gmsh2DIn3DSpace.facesBack
Gmsh2DIn3DSpace.facesBottom
Gmsh2DIn3DSpace.facesDown
Gmsh2DIn3DSpace.facesFront
Gmsh2DIn3DSpace.facesLeft
Gmsh2DIn3DSpace.facesRight
Gmsh2DIn3DSpace.facesTop
Gmsh2DIn3DSpace.facesUp
Gmsh2DIn3DSpace.getNearestCell()
Gmsh2DIn3DSpace.interiorFaceCellIDs
Gmsh2DIn3DSpace.interiorFaceIDs
Gmsh2DIn3DSpace.interiorFaces
Gmsh2DIn3DSpace.scale
Gmsh2DIn3DSpace.scaledCellDistances
Gmsh2DIn3DSpace.scaledCellToCellDistances
Gmsh2DIn3DSpace.scaledCellVolumes
Gmsh2DIn3DSpace.scaledFaceAreas
Gmsh2DIn3DSpace.scaledFaceToCellDistances
Gmsh2DIn3DSpace.x
Gmsh2DIn3DSpace.y
Gmsh2DIn3DSpace.z
Gmsh3D
Gmsh3D.VTKCellDataSet
Gmsh3D.VTKFaceDataSet
Gmsh3D.__add__()
Gmsh3D.__div__()
Gmsh3D.__getstate__()
Gmsh3D.__mul__()
Gmsh3D.__radd__()
Gmsh3D.__repr__()
Gmsh3D.__rmul__()
Gmsh3D.__setstate__()
Gmsh3D.__sub__()
Gmsh3D.__truediv__()
Gmsh3D.aspect2D
Gmsh3D.cellCenters
Gmsh3D.cellDistanceVectors
Gmsh3D.cellFaceIDs
Gmsh3D.cellToFaceDistanceVectors
Gmsh3D.cellVolumes
Gmsh3D.extents
Gmsh3D.exteriorFaces
Gmsh3D.faceCenters
Gmsh3D.facesBack
Gmsh3D.facesBottom
Gmsh3D.facesDown
Gmsh3D.facesFront
Gmsh3D.facesLeft
Gmsh3D.facesRight
Gmsh3D.facesTop
Gmsh3D.facesUp
Gmsh3D.getNearestCell()
Gmsh3D.interiorFaceCellIDs
Gmsh3D.interiorFaceIDs
Gmsh3D.interiorFaces
Gmsh3D.scale
Gmsh3D.scaledCellDistances
Gmsh3D.scaledCellToCellDistances
Gmsh3D.scaledCellVolumes
Gmsh3D.scaledFaceAreas
Gmsh3D.scaledFaceToCellDistances
Gmsh3D.x
Gmsh3D.y
Gmsh3D.z
GmshGrid2D
GmshGrid2D.VTKCellDataSet
GmshGrid2D.VTKFaceDataSet
GmshGrid2D.__add__()
GmshGrid2D.__div__()
GmshGrid2D.__getstate__()
GmshGrid2D.__mul__()
GmshGrid2D.__radd__()
GmshGrid2D.__repr__()
GmshGrid2D.__rmul__()
GmshGrid2D.__setstate__()
GmshGrid2D.__sub__()
GmshGrid2D.__truediv__()
GmshGrid2D.aspect2D
GmshGrid2D.cellCenters
GmshGrid2D.cellDistanceVectors
GmshGrid2D.cellFaceIDs
GmshGrid2D.cellToFaceDistanceVectors
GmshGrid2D.cellVolumes
GmshGrid2D.extents
GmshGrid2D.exteriorFaces
GmshGrid2D.extrude()
GmshGrid2D.faceCenters
GmshGrid2D.facesBack
GmshGrid2D.facesBottom
GmshGrid2D.facesDown
GmshGrid2D.facesFront
GmshGrid2D.facesLeft
GmshGrid2D.facesRight
GmshGrid2D.facesTop
GmshGrid2D.facesUp
GmshGrid2D.getNearestCell()
GmshGrid2D.interiorFaceCellIDs
GmshGrid2D.interiorFaceIDs
GmshGrid2D.interiorFaces
GmshGrid2D.scale
GmshGrid2D.scaledCellDistances
GmshGrid2D.scaledCellToCellDistances
GmshGrid2D.scaledCellVolumes
GmshGrid2D.scaledFaceAreas
GmshGrid2D.scaledFaceToCellDistances
GmshGrid2D.x
GmshGrid2D.y
GmshGrid2D.z
GmshGrid3D
GmshGrid3D.VTKCellDataSet
GmshGrid3D.VTKFaceDataSet
GmshGrid3D.__add__()
GmshGrid3D.__div__()
GmshGrid3D.__getstate__()
GmshGrid3D.__mul__()
GmshGrid3D.__radd__()
GmshGrid3D.__repr__()
GmshGrid3D.__rmul__()
GmshGrid3D.__setstate__()
GmshGrid3D.__sub__()
GmshGrid3D.__truediv__()
GmshGrid3D.aspect2D
GmshGrid3D.cellCenters
GmshGrid3D.cellDistanceVectors
GmshGrid3D.cellFaceIDs
GmshGrid3D.cellToFaceDistanceVectors
GmshGrid3D.cellVolumes
GmshGrid3D.extents
GmshGrid3D.exteriorFaces
GmshGrid3D.faceCenters
GmshGrid3D.facesBack
GmshGrid3D.facesBottom
GmshGrid3D.facesDown
GmshGrid3D.facesFront
GmshGrid3D.facesLeft
GmshGrid3D.facesRight
GmshGrid3D.facesTop
GmshGrid3D.facesUp
GmshGrid3D.getNearestCell()
GmshGrid3D.interiorFaceCellIDs
GmshGrid3D.interiorFaceIDs
GmshGrid3D.interiorFaces
GmshGrid3D.scale
GmshGrid3D.scaledCellDistances
GmshGrid3D.scaledCellToCellDistances
GmshGrid3D.scaledCellVolumes
GmshGrid3D.scaledFaceAreas
GmshGrid3D.scaledFaceToCellDistances
GmshGrid3D.x
GmshGrid3D.y
GmshGrid3D.z
openMSHFile()
openPOSFile()
- fipy.meshes.grid1D module
- fipy.meshes.grid2D module
- fipy.meshes.grid3D module
- fipy.meshes.mesh module
Mesh
Mesh.VTKCellDataSet
Mesh.VTKFaceDataSet
Mesh.__add__()
Mesh.__div__()
Mesh.__getstate__()
Mesh.__mul__()
Mesh.__radd__()
Mesh.__repr__()
Mesh.__rmul__()
Mesh.__setstate__()
Mesh.__sub__()
Mesh.__truediv__()
Mesh.aspect2D
Mesh.cellCenters
Mesh.cellDistanceVectors
Mesh.cellFaceIDs
Mesh.cellToFaceDistanceVectors
Mesh.cellVolumes
Mesh.extents
Mesh.exteriorFaces
Mesh.faceCenters
Mesh.facesBack
Mesh.facesBottom
Mesh.facesDown
Mesh.facesFront
Mesh.facesLeft
Mesh.facesRight
Mesh.facesTop
Mesh.facesUp
Mesh.getNearestCell()
Mesh.interiorFaceCellIDs
Mesh.interiorFaceIDs
Mesh.interiorFaces
Mesh.scale
Mesh.scaledCellDistances
Mesh.scaledCellToCellDistances
Mesh.scaledCellVolumes
Mesh.scaledFaceAreas
Mesh.scaledFaceToCellDistances
Mesh.x
Mesh.y
Mesh.z
MeshAdditionError
MeshAdditionError.__cause__
MeshAdditionError.__context__
MeshAdditionError.__delattr__()
MeshAdditionError.__getattribute__()
MeshAdditionError.__reduce__()
MeshAdditionError.__repr__()
MeshAdditionError.__setattr__()
MeshAdditionError.__setstate__()
MeshAdditionError.__str__()
MeshAdditionError.__suppress_context__
MeshAdditionError.__traceback__
MeshAdditionError.add_note()
MeshAdditionError.args
MeshAdditionError.with_traceback()
- fipy.meshes.mesh1D module
Mesh1D
Mesh1D.VTKCellDataSet
Mesh1D.VTKFaceDataSet
Mesh1D.__add__()
Mesh1D.__div__()
Mesh1D.__getstate__()
Mesh1D.__mul__()
Mesh1D.__radd__()
Mesh1D.__repr__()
Mesh1D.__rmul__()
Mesh1D.__setstate__()
Mesh1D.__sub__()
Mesh1D.__truediv__()
Mesh1D.aspect2D
Mesh1D.cellCenters
Mesh1D.cellDistanceVectors
Mesh1D.cellFaceIDs
Mesh1D.cellToFaceDistanceVectors
Mesh1D.cellVolumes
Mesh1D.extents
Mesh1D.exteriorFaces
Mesh1D.faceCenters
Mesh1D.facesBack
Mesh1D.facesBottom
Mesh1D.facesDown
Mesh1D.facesFront
Mesh1D.facesLeft
Mesh1D.facesRight
Mesh1D.facesTop
Mesh1D.facesUp
Mesh1D.getNearestCell()
Mesh1D.interiorFaceCellIDs
Mesh1D.interiorFaceIDs
Mesh1D.interiorFaces
Mesh1D.scale
Mesh1D.scaledCellDistances
Mesh1D.scaledCellToCellDistances
Mesh1D.scaledCellVolumes
Mesh1D.scaledFaceAreas
Mesh1D.scaledFaceToCellDistances
Mesh1D.x
Mesh1D.y
Mesh1D.z
- fipy.meshes.mesh2D module
Mesh2D
Mesh2D.VTKCellDataSet
Mesh2D.VTKFaceDataSet
Mesh2D.__add__()
Mesh2D.__div__()
Mesh2D.__getstate__()
Mesh2D.__mul__()
Mesh2D.__radd__()
Mesh2D.__repr__()
Mesh2D.__rmul__()
Mesh2D.__setstate__()
Mesh2D.__sub__()
Mesh2D.__truediv__()
Mesh2D.aspect2D
Mesh2D.cellCenters
Mesh2D.cellDistanceVectors
Mesh2D.cellFaceIDs
Mesh2D.cellToFaceDistanceVectors
Mesh2D.cellVolumes
Mesh2D.extents
Mesh2D.exteriorFaces
Mesh2D.extrude()
Mesh2D.faceCenters
Mesh2D.facesBack
Mesh2D.facesBottom
Mesh2D.facesDown
Mesh2D.facesFront
Mesh2D.facesLeft
Mesh2D.facesRight
Mesh2D.facesTop
Mesh2D.facesUp
Mesh2D.getNearestCell()
Mesh2D.interiorFaceCellIDs
Mesh2D.interiorFaceIDs
Mesh2D.interiorFaces
Mesh2D.scale
Mesh2D.scaledCellDistances
Mesh2D.scaledCellToCellDistances
Mesh2D.scaledCellVolumes
Mesh2D.scaledFaceAreas
Mesh2D.scaledFaceToCellDistances
Mesh2D.x
Mesh2D.y
Mesh2D.z
- fipy.meshes.nonUniformGrid1D module
NonUniformGrid1D
NonUniformGrid1D.VTKCellDataSet
NonUniformGrid1D.VTKFaceDataSet
NonUniformGrid1D.__add__()
NonUniformGrid1D.__div__()
NonUniformGrid1D.__getstate__()
NonUniformGrid1D.__mul__()
NonUniformGrid1D.__radd__()
NonUniformGrid1D.__repr__()
NonUniformGrid1D.__rmul__()
NonUniformGrid1D.__setstate__()
NonUniformGrid1D.__sub__()
NonUniformGrid1D.__truediv__()
NonUniformGrid1D.aspect2D
NonUniformGrid1D.cellCenters
NonUniformGrid1D.cellDistanceVectors
NonUniformGrid1D.cellFaceIDs
NonUniformGrid1D.cellToFaceDistanceVectors
NonUniformGrid1D.cellVolumes
NonUniformGrid1D.extents
NonUniformGrid1D.exteriorFaces
NonUniformGrid1D.faceCenters
NonUniformGrid1D.facesBack
NonUniformGrid1D.facesBottom
NonUniformGrid1D.facesDown
NonUniformGrid1D.facesFront
NonUniformGrid1D.facesLeft
NonUniformGrid1D.facesRight
NonUniformGrid1D.facesTop
NonUniformGrid1D.facesUp
NonUniformGrid1D.getNearestCell()
NonUniformGrid1D.interiorFaceCellIDs
NonUniformGrid1D.interiorFaceIDs
NonUniformGrid1D.interiorFaces
NonUniformGrid1D.scale
NonUniformGrid1D.scaledCellDistances
NonUniformGrid1D.scaledCellToCellDistances
NonUniformGrid1D.scaledCellVolumes
NonUniformGrid1D.scaledFaceAreas
NonUniformGrid1D.scaledFaceToCellDistances
NonUniformGrid1D.x
NonUniformGrid1D.y
NonUniformGrid1D.z
- fipy.meshes.nonUniformGrid2D module
NonUniformGrid2D
NonUniformGrid2D.VTKCellDataSet
NonUniformGrid2D.VTKFaceDataSet
NonUniformGrid2D.__add__()
NonUniformGrid2D.__div__()
NonUniformGrid2D.__getstate__()
NonUniformGrid2D.__mul__()
NonUniformGrid2D.__radd__()
NonUniformGrid2D.__repr__()
NonUniformGrid2D.__rmul__()
NonUniformGrid2D.__setstate__()
NonUniformGrid2D.__sub__()
NonUniformGrid2D.__truediv__()
NonUniformGrid2D.aspect2D
NonUniformGrid2D.cellCenters
NonUniformGrid2D.cellDistanceVectors
NonUniformGrid2D.cellFaceIDs
NonUniformGrid2D.cellToFaceDistanceVectors
NonUniformGrid2D.cellVolumes
NonUniformGrid2D.extents
NonUniformGrid2D.exteriorFaces
NonUniformGrid2D.extrude()
NonUniformGrid2D.faceCenters
NonUniformGrid2D.facesBack
NonUniformGrid2D.facesBottom
NonUniformGrid2D.facesDown
NonUniformGrid2D.facesFront
NonUniformGrid2D.facesLeft
NonUniformGrid2D.facesRight
NonUniformGrid2D.facesTop
NonUniformGrid2D.facesUp
NonUniformGrid2D.getNearestCell()
NonUniformGrid2D.interiorFaceCellIDs
NonUniformGrid2D.interiorFaceIDs
NonUniformGrid2D.interiorFaces
NonUniformGrid2D.scale
NonUniformGrid2D.scaledCellDistances
NonUniformGrid2D.scaledCellToCellDistances
NonUniformGrid2D.scaledCellVolumes
NonUniformGrid2D.scaledFaceAreas
NonUniformGrid2D.scaledFaceToCellDistances
NonUniformGrid2D.x
NonUniformGrid2D.y
NonUniformGrid2D.z
- fipy.meshes.nonUniformGrid3D module
NonUniformGrid3D
NonUniformGrid3D.VTKCellDataSet
NonUniformGrid3D.VTKFaceDataSet
NonUniformGrid3D.__add__()
NonUniformGrid3D.__div__()
NonUniformGrid3D.__getstate__()
NonUniformGrid3D.__mul__()
NonUniformGrid3D.__radd__()
NonUniformGrid3D.__repr__()
NonUniformGrid3D.__rmul__()
NonUniformGrid3D.__setstate__()
NonUniformGrid3D.__sub__()
NonUniformGrid3D.__truediv__()
NonUniformGrid3D.aspect2D
NonUniformGrid3D.cellCenters
NonUniformGrid3D.cellDistanceVectors
NonUniformGrid3D.cellFaceIDs
NonUniformGrid3D.cellToFaceDistanceVectors
NonUniformGrid3D.cellVolumes
NonUniformGrid3D.extents
NonUniformGrid3D.exteriorFaces
NonUniformGrid3D.faceCenters
NonUniformGrid3D.facesBack
NonUniformGrid3D.facesBottom
NonUniformGrid3D.facesDown
NonUniformGrid3D.facesFront
NonUniformGrid3D.facesLeft
NonUniformGrid3D.facesRight
NonUniformGrid3D.facesTop
NonUniformGrid3D.facesUp
NonUniformGrid3D.getNearestCell()
NonUniformGrid3D.interiorFaceCellIDs
NonUniformGrid3D.interiorFaceIDs
NonUniformGrid3D.interiorFaces
NonUniformGrid3D.scale
NonUniformGrid3D.scaledCellDistances
NonUniformGrid3D.scaledCellToCellDistances
NonUniformGrid3D.scaledCellVolumes
NonUniformGrid3D.scaledFaceAreas
NonUniformGrid3D.scaledFaceToCellDistances
NonUniformGrid3D.x
NonUniformGrid3D.y
NonUniformGrid3D.z
- fipy.meshes.periodicGrid1D module
PeriodicGrid1D
PeriodicGrid1D.VTKCellDataSet
PeriodicGrid1D.VTKFaceDataSet
PeriodicGrid1D.__add__()
PeriodicGrid1D.__div__()
PeriodicGrid1D.__getstate__()
PeriodicGrid1D.__mul__()
PeriodicGrid1D.__radd__()
PeriodicGrid1D.__repr__()
PeriodicGrid1D.__rmul__()
PeriodicGrid1D.__setstate__()
PeriodicGrid1D.__sub__()
PeriodicGrid1D.__truediv__()
PeriodicGrid1D.aspect2D
PeriodicGrid1D.cellCenters
PeriodicGrid1D.cellDistanceVectors
PeriodicGrid1D.cellFaceIDs
PeriodicGrid1D.cellToFaceDistanceVectors
PeriodicGrid1D.cellVolumes
PeriodicGrid1D.extents
PeriodicGrid1D.exteriorFaces
PeriodicGrid1D.faceCenters
PeriodicGrid1D.facesBack
PeriodicGrid1D.facesBottom
PeriodicGrid1D.facesDown
PeriodicGrid1D.facesFront
PeriodicGrid1D.facesLeft
PeriodicGrid1D.facesRight
PeriodicGrid1D.facesTop
PeriodicGrid1D.facesUp
PeriodicGrid1D.getNearestCell()
PeriodicGrid1D.interiorFaceCellIDs
PeriodicGrid1D.interiorFaceIDs
PeriodicGrid1D.interiorFaces
PeriodicGrid1D.scale
PeriodicGrid1D.scaledCellDistances
PeriodicGrid1D.scaledCellToCellDistances
PeriodicGrid1D.scaledCellVolumes
PeriodicGrid1D.scaledFaceAreas
PeriodicGrid1D.scaledFaceToCellDistances
PeriodicGrid1D.x
PeriodicGrid1D.y
PeriodicGrid1D.z
- fipy.meshes.periodicGrid2D module
PeriodicGrid2D
PeriodicGrid2D.VTKCellDataSet
PeriodicGrid2D.VTKFaceDataSet
PeriodicGrid2D.__add__()
PeriodicGrid2D.__div__()
PeriodicGrid2D.__getstate__()
PeriodicGrid2D.__mul__()
PeriodicGrid2D.__radd__()
PeriodicGrid2D.__repr__()
PeriodicGrid2D.__rmul__()
PeriodicGrid2D.__setstate__()
PeriodicGrid2D.__sub__()
PeriodicGrid2D.__truediv__()
PeriodicGrid2D.aspect2D
PeriodicGrid2D.cellCenters
PeriodicGrid2D.cellDistanceVectors
PeriodicGrid2D.cellFaceIDs
PeriodicGrid2D.cellToFaceDistanceVectors
PeriodicGrid2D.cellVolumes
PeriodicGrid2D.extents
PeriodicGrid2D.exteriorFaces
PeriodicGrid2D.extrude()
PeriodicGrid2D.faceCenters
PeriodicGrid2D.facesBack
PeriodicGrid2D.facesBottom
PeriodicGrid2D.facesDown
PeriodicGrid2D.facesFront
PeriodicGrid2D.facesLeft
PeriodicGrid2D.facesRight
PeriodicGrid2D.facesTop
PeriodicGrid2D.facesUp
PeriodicGrid2D.getNearestCell()
PeriodicGrid2D.interiorFaceCellIDs
PeriodicGrid2D.interiorFaceIDs
PeriodicGrid2D.interiorFaces
PeriodicGrid2D.scale
PeriodicGrid2D.scaledCellDistances
PeriodicGrid2D.scaledCellToCellDistances
PeriodicGrid2D.scaledCellVolumes
PeriodicGrid2D.scaledFaceAreas
PeriodicGrid2D.scaledFaceToCellDistances
PeriodicGrid2D.x
PeriodicGrid2D.y
PeriodicGrid2D.z
PeriodicGrid2DLeftRight
PeriodicGrid2DLeftRight.VTKCellDataSet
PeriodicGrid2DLeftRight.VTKFaceDataSet
PeriodicGrid2DLeftRight.__add__()
PeriodicGrid2DLeftRight.__div__()
PeriodicGrid2DLeftRight.__getstate__()
PeriodicGrid2DLeftRight.__mul__()
PeriodicGrid2DLeftRight.__radd__()
PeriodicGrid2DLeftRight.__repr__()
PeriodicGrid2DLeftRight.__rmul__()
PeriodicGrid2DLeftRight.__setstate__()
PeriodicGrid2DLeftRight.__sub__()
PeriodicGrid2DLeftRight.__truediv__()
PeriodicGrid2DLeftRight.aspect2D
PeriodicGrid2DLeftRight.cellCenters
PeriodicGrid2DLeftRight.cellDistanceVectors
PeriodicGrid2DLeftRight.cellFaceIDs
PeriodicGrid2DLeftRight.cellToFaceDistanceVectors
PeriodicGrid2DLeftRight.cellVolumes
PeriodicGrid2DLeftRight.extents
PeriodicGrid2DLeftRight.exteriorFaces
PeriodicGrid2DLeftRight.extrude()
PeriodicGrid2DLeftRight.faceCenters
PeriodicGrid2DLeftRight.facesBack
PeriodicGrid2DLeftRight.facesBottom
PeriodicGrid2DLeftRight.facesDown
PeriodicGrid2DLeftRight.facesFront
PeriodicGrid2DLeftRight.facesLeft
PeriodicGrid2DLeftRight.facesRight
PeriodicGrid2DLeftRight.facesTop
PeriodicGrid2DLeftRight.facesUp
PeriodicGrid2DLeftRight.getNearestCell()
PeriodicGrid2DLeftRight.interiorFaceCellIDs
PeriodicGrid2DLeftRight.interiorFaceIDs
PeriodicGrid2DLeftRight.interiorFaces
PeriodicGrid2DLeftRight.scale
PeriodicGrid2DLeftRight.scaledCellDistances
PeriodicGrid2DLeftRight.scaledCellToCellDistances
PeriodicGrid2DLeftRight.scaledCellVolumes
PeriodicGrid2DLeftRight.scaledFaceAreas
PeriodicGrid2DLeftRight.scaledFaceToCellDistances
PeriodicGrid2DLeftRight.x
PeriodicGrid2DLeftRight.y
PeriodicGrid2DLeftRight.z
PeriodicGrid2DTopBottom
PeriodicGrid2DTopBottom.VTKCellDataSet
PeriodicGrid2DTopBottom.VTKFaceDataSet
PeriodicGrid2DTopBottom.__add__()
PeriodicGrid2DTopBottom.__div__()
PeriodicGrid2DTopBottom.__getstate__()
PeriodicGrid2DTopBottom.__mul__()
PeriodicGrid2DTopBottom.__radd__()
PeriodicGrid2DTopBottom.__repr__()
PeriodicGrid2DTopBottom.__rmul__()
PeriodicGrid2DTopBottom.__setstate__()
PeriodicGrid2DTopBottom.__sub__()
PeriodicGrid2DTopBottom.__truediv__()
PeriodicGrid2DTopBottom.aspect2D
PeriodicGrid2DTopBottom.cellCenters
PeriodicGrid2DTopBottom.cellDistanceVectors
PeriodicGrid2DTopBottom.cellFaceIDs
PeriodicGrid2DTopBottom.cellToFaceDistanceVectors
PeriodicGrid2DTopBottom.cellVolumes
PeriodicGrid2DTopBottom.extents
PeriodicGrid2DTopBottom.exteriorFaces
PeriodicGrid2DTopBottom.extrude()
PeriodicGrid2DTopBottom.faceCenters
PeriodicGrid2DTopBottom.facesBack
PeriodicGrid2DTopBottom.facesBottom
PeriodicGrid2DTopBottom.facesDown
PeriodicGrid2DTopBottom.facesFront
PeriodicGrid2DTopBottom.facesLeft
PeriodicGrid2DTopBottom.facesRight
PeriodicGrid2DTopBottom.facesTop
PeriodicGrid2DTopBottom.facesUp
PeriodicGrid2DTopBottom.getNearestCell()
PeriodicGrid2DTopBottom.interiorFaceCellIDs
PeriodicGrid2DTopBottom.interiorFaceIDs
PeriodicGrid2DTopBottom.interiorFaces
PeriodicGrid2DTopBottom.scale
PeriodicGrid2DTopBottom.scaledCellDistances
PeriodicGrid2DTopBottom.scaledCellToCellDistances
PeriodicGrid2DTopBottom.scaledCellVolumes
PeriodicGrid2DTopBottom.scaledFaceAreas
PeriodicGrid2DTopBottom.scaledFaceToCellDistances
PeriodicGrid2DTopBottom.x
PeriodicGrid2DTopBottom.y
PeriodicGrid2DTopBottom.z
- fipy.meshes.periodicGrid3D module
PeriodicGrid3D
PeriodicGrid3D.VTKCellDataSet
PeriodicGrid3D.VTKFaceDataSet
PeriodicGrid3D.__add__()
PeriodicGrid3D.__div__()
PeriodicGrid3D.__getstate__()
PeriodicGrid3D.__mul__()
PeriodicGrid3D.__radd__()
PeriodicGrid3D.__repr__()
PeriodicGrid3D.__rmul__()
PeriodicGrid3D.__setstate__()
PeriodicGrid3D.__sub__()
PeriodicGrid3D.__truediv__()
PeriodicGrid3D.aspect2D
PeriodicGrid3D.cellCenters
PeriodicGrid3D.cellDistanceVectors
PeriodicGrid3D.cellFaceIDs
PeriodicGrid3D.cellToFaceDistanceVectors
PeriodicGrid3D.cellVolumes
PeriodicGrid3D.extents
PeriodicGrid3D.exteriorFaces
PeriodicGrid3D.faceCenters
PeriodicGrid3D.facesBack
PeriodicGrid3D.facesBottom
PeriodicGrid3D.facesDown
PeriodicGrid3D.facesFront
PeriodicGrid3D.facesLeft
PeriodicGrid3D.facesRight
PeriodicGrid3D.facesTop
PeriodicGrid3D.facesUp
PeriodicGrid3D.getNearestCell()
PeriodicGrid3D.interiorFaceCellIDs
PeriodicGrid3D.interiorFaceIDs
PeriodicGrid3D.interiorFaces
PeriodicGrid3D.scale
PeriodicGrid3D.scaledCellDistances
PeriodicGrid3D.scaledCellToCellDistances
PeriodicGrid3D.scaledCellVolumes
PeriodicGrid3D.scaledFaceAreas
PeriodicGrid3D.scaledFaceToCellDistances
PeriodicGrid3D.x
PeriodicGrid3D.y
PeriodicGrid3D.z
PeriodicGrid3DFrontBack
PeriodicGrid3DFrontBack.VTKCellDataSet
PeriodicGrid3DFrontBack.VTKFaceDataSet
PeriodicGrid3DFrontBack.__add__()
PeriodicGrid3DFrontBack.__div__()
PeriodicGrid3DFrontBack.__getstate__()
PeriodicGrid3DFrontBack.__mul__()
PeriodicGrid3DFrontBack.__radd__()
PeriodicGrid3DFrontBack.__repr__()
PeriodicGrid3DFrontBack.__rmul__()
PeriodicGrid3DFrontBack.__setstate__()
PeriodicGrid3DFrontBack.__sub__()
PeriodicGrid3DFrontBack.__truediv__()
PeriodicGrid3DFrontBack.aspect2D
PeriodicGrid3DFrontBack.cellCenters
PeriodicGrid3DFrontBack.cellDistanceVectors
PeriodicGrid3DFrontBack.cellFaceIDs
PeriodicGrid3DFrontBack.cellToFaceDistanceVectors
PeriodicGrid3DFrontBack.cellVolumes
PeriodicGrid3DFrontBack.extents
PeriodicGrid3DFrontBack.exteriorFaces
PeriodicGrid3DFrontBack.faceCenters
PeriodicGrid3DFrontBack.facesBack
PeriodicGrid3DFrontBack.facesBottom
PeriodicGrid3DFrontBack.facesDown
PeriodicGrid3DFrontBack.facesFront
PeriodicGrid3DFrontBack.facesLeft
PeriodicGrid3DFrontBack.facesRight
PeriodicGrid3DFrontBack.facesTop
PeriodicGrid3DFrontBack.facesUp
PeriodicGrid3DFrontBack.getNearestCell()
PeriodicGrid3DFrontBack.interiorFaceCellIDs
PeriodicGrid3DFrontBack.interiorFaceIDs
PeriodicGrid3DFrontBack.interiorFaces
PeriodicGrid3DFrontBack.scale
PeriodicGrid3DFrontBack.scaledCellDistances
PeriodicGrid3DFrontBack.scaledCellToCellDistances
PeriodicGrid3DFrontBack.scaledCellVolumes
PeriodicGrid3DFrontBack.scaledFaceAreas
PeriodicGrid3DFrontBack.scaledFaceToCellDistances
PeriodicGrid3DFrontBack.x
PeriodicGrid3DFrontBack.y
PeriodicGrid3DFrontBack.z
PeriodicGrid3DLeftRight
PeriodicGrid3DLeftRight.VTKCellDataSet
PeriodicGrid3DLeftRight.VTKFaceDataSet
PeriodicGrid3DLeftRight.__add__()
PeriodicGrid3DLeftRight.__div__()
PeriodicGrid3DLeftRight.__getstate__()
PeriodicGrid3DLeftRight.__mul__()
PeriodicGrid3DLeftRight.__radd__()
PeriodicGrid3DLeftRight.__repr__()
PeriodicGrid3DLeftRight.__rmul__()
PeriodicGrid3DLeftRight.__setstate__()
PeriodicGrid3DLeftRight.__sub__()
PeriodicGrid3DLeftRight.__truediv__()
PeriodicGrid3DLeftRight.aspect2D
PeriodicGrid3DLeftRight.cellCenters
PeriodicGrid3DLeftRight.cellDistanceVectors
PeriodicGrid3DLeftRight.cellFaceIDs
PeriodicGrid3DLeftRight.cellToFaceDistanceVectors
PeriodicGrid3DLeftRight.cellVolumes
PeriodicGrid3DLeftRight.extents
PeriodicGrid3DLeftRight.exteriorFaces
PeriodicGrid3DLeftRight.faceCenters
PeriodicGrid3DLeftRight.facesBack
PeriodicGrid3DLeftRight.facesBottom
PeriodicGrid3DLeftRight.facesDown
PeriodicGrid3DLeftRight.facesFront
PeriodicGrid3DLeftRight.facesLeft
PeriodicGrid3DLeftRight.facesRight
PeriodicGrid3DLeftRight.facesTop
PeriodicGrid3DLeftRight.facesUp
PeriodicGrid3DLeftRight.getNearestCell()
PeriodicGrid3DLeftRight.interiorFaceCellIDs
PeriodicGrid3DLeftRight.interiorFaceIDs
PeriodicGrid3DLeftRight.interiorFaces
PeriodicGrid3DLeftRight.scale
PeriodicGrid3DLeftRight.scaledCellDistances
PeriodicGrid3DLeftRight.scaledCellToCellDistances
PeriodicGrid3DLeftRight.scaledCellVolumes
PeriodicGrid3DLeftRight.scaledFaceAreas
PeriodicGrid3DLeftRight.scaledFaceToCellDistances
PeriodicGrid3DLeftRight.x
PeriodicGrid3DLeftRight.y
PeriodicGrid3DLeftRight.z
PeriodicGrid3DLeftRightFrontBack
PeriodicGrid3DLeftRightFrontBack.VTKCellDataSet
PeriodicGrid3DLeftRightFrontBack.VTKFaceDataSet
PeriodicGrid3DLeftRightFrontBack.__add__()
PeriodicGrid3DLeftRightFrontBack.__div__()
PeriodicGrid3DLeftRightFrontBack.__getstate__()
PeriodicGrid3DLeftRightFrontBack.__mul__()
PeriodicGrid3DLeftRightFrontBack.__radd__()
PeriodicGrid3DLeftRightFrontBack.__repr__()
PeriodicGrid3DLeftRightFrontBack.__rmul__()
PeriodicGrid3DLeftRightFrontBack.__setstate__()
PeriodicGrid3DLeftRightFrontBack.__sub__()
PeriodicGrid3DLeftRightFrontBack.__truediv__()
PeriodicGrid3DLeftRightFrontBack.aspect2D
PeriodicGrid3DLeftRightFrontBack.cellCenters
PeriodicGrid3DLeftRightFrontBack.cellDistanceVectors
PeriodicGrid3DLeftRightFrontBack.cellFaceIDs
PeriodicGrid3DLeftRightFrontBack.cellToFaceDistanceVectors
PeriodicGrid3DLeftRightFrontBack.cellVolumes
PeriodicGrid3DLeftRightFrontBack.extents
PeriodicGrid3DLeftRightFrontBack.exteriorFaces
PeriodicGrid3DLeftRightFrontBack.faceCenters
PeriodicGrid3DLeftRightFrontBack.facesBack
PeriodicGrid3DLeftRightFrontBack.facesBottom
PeriodicGrid3DLeftRightFrontBack.facesDown
PeriodicGrid3DLeftRightFrontBack.facesFront
PeriodicGrid3DLeftRightFrontBack.facesLeft
PeriodicGrid3DLeftRightFrontBack.facesRight
PeriodicGrid3DLeftRightFrontBack.facesTop
PeriodicGrid3DLeftRightFrontBack.facesUp
PeriodicGrid3DLeftRightFrontBack.getNearestCell()
PeriodicGrid3DLeftRightFrontBack.interiorFaceCellIDs
PeriodicGrid3DLeftRightFrontBack.interiorFaceIDs
PeriodicGrid3DLeftRightFrontBack.interiorFaces
PeriodicGrid3DLeftRightFrontBack.scale
PeriodicGrid3DLeftRightFrontBack.scaledCellDistances
PeriodicGrid3DLeftRightFrontBack.scaledCellToCellDistances
PeriodicGrid3DLeftRightFrontBack.scaledCellVolumes
PeriodicGrid3DLeftRightFrontBack.scaledFaceAreas
PeriodicGrid3DLeftRightFrontBack.scaledFaceToCellDistances
PeriodicGrid3DLeftRightFrontBack.x
PeriodicGrid3DLeftRightFrontBack.y
PeriodicGrid3DLeftRightFrontBack.z
PeriodicGrid3DLeftRightTopBottom
PeriodicGrid3DLeftRightTopBottom.VTKCellDataSet
PeriodicGrid3DLeftRightTopBottom.VTKFaceDataSet
PeriodicGrid3DLeftRightTopBottom.__add__()
PeriodicGrid3DLeftRightTopBottom.__div__()
PeriodicGrid3DLeftRightTopBottom.__getstate__()
PeriodicGrid3DLeftRightTopBottom.__mul__()
PeriodicGrid3DLeftRightTopBottom.__radd__()
PeriodicGrid3DLeftRightTopBottom.__repr__()
PeriodicGrid3DLeftRightTopBottom.__rmul__()
PeriodicGrid3DLeftRightTopBottom.__setstate__()
PeriodicGrid3DLeftRightTopBottom.__sub__()
PeriodicGrid3DLeftRightTopBottom.__truediv__()
PeriodicGrid3DLeftRightTopBottom.aspect2D
PeriodicGrid3DLeftRightTopBottom.cellCenters
PeriodicGrid3DLeftRightTopBottom.cellDistanceVectors
PeriodicGrid3DLeftRightTopBottom.cellFaceIDs
PeriodicGrid3DLeftRightTopBottom.cellToFaceDistanceVectors
PeriodicGrid3DLeftRightTopBottom.cellVolumes
PeriodicGrid3DLeftRightTopBottom.extents
PeriodicGrid3DLeftRightTopBottom.exteriorFaces
PeriodicGrid3DLeftRightTopBottom.faceCenters
PeriodicGrid3DLeftRightTopBottom.facesBack
PeriodicGrid3DLeftRightTopBottom.facesBottom
PeriodicGrid3DLeftRightTopBottom.facesDown
PeriodicGrid3DLeftRightTopBottom.facesFront
PeriodicGrid3DLeftRightTopBottom.facesLeft
PeriodicGrid3DLeftRightTopBottom.facesRight
PeriodicGrid3DLeftRightTopBottom.facesTop
PeriodicGrid3DLeftRightTopBottom.facesUp
PeriodicGrid3DLeftRightTopBottom.getNearestCell()
PeriodicGrid3DLeftRightTopBottom.interiorFaceCellIDs
PeriodicGrid3DLeftRightTopBottom.interiorFaceIDs
PeriodicGrid3DLeftRightTopBottom.interiorFaces
PeriodicGrid3DLeftRightTopBottom.scale
PeriodicGrid3DLeftRightTopBottom.scaledCellDistances
PeriodicGrid3DLeftRightTopBottom.scaledCellToCellDistances
PeriodicGrid3DLeftRightTopBottom.scaledCellVolumes
PeriodicGrid3DLeftRightTopBottom.scaledFaceAreas
PeriodicGrid3DLeftRightTopBottom.scaledFaceToCellDistances
PeriodicGrid3DLeftRightTopBottom.x
PeriodicGrid3DLeftRightTopBottom.y
PeriodicGrid3DLeftRightTopBottom.z
PeriodicGrid3DTopBottom
PeriodicGrid3DTopBottom.VTKCellDataSet
PeriodicGrid3DTopBottom.VTKFaceDataSet
PeriodicGrid3DTopBottom.__add__()
PeriodicGrid3DTopBottom.__div__()
PeriodicGrid3DTopBottom.__getstate__()
PeriodicGrid3DTopBottom.__mul__()
PeriodicGrid3DTopBottom.__radd__()
PeriodicGrid3DTopBottom.__repr__()
PeriodicGrid3DTopBottom.__rmul__()
PeriodicGrid3DTopBottom.__setstate__()
PeriodicGrid3DTopBottom.__sub__()
PeriodicGrid3DTopBottom.__truediv__()
PeriodicGrid3DTopBottom.aspect2D
PeriodicGrid3DTopBottom.cellCenters
PeriodicGrid3DTopBottom.cellDistanceVectors
PeriodicGrid3DTopBottom.cellFaceIDs
PeriodicGrid3DTopBottom.cellToFaceDistanceVectors
PeriodicGrid3DTopBottom.cellVolumes
PeriodicGrid3DTopBottom.extents
PeriodicGrid3DTopBottom.exteriorFaces
PeriodicGrid3DTopBottom.faceCenters
PeriodicGrid3DTopBottom.facesBack
PeriodicGrid3DTopBottom.facesBottom
PeriodicGrid3DTopBottom.facesDown
PeriodicGrid3DTopBottom.facesFront
PeriodicGrid3DTopBottom.facesLeft
PeriodicGrid3DTopBottom.facesRight
PeriodicGrid3DTopBottom.facesTop
PeriodicGrid3DTopBottom.facesUp
PeriodicGrid3DTopBottom.getNearestCell()
PeriodicGrid3DTopBottom.interiorFaceCellIDs
PeriodicGrid3DTopBottom.interiorFaceIDs
PeriodicGrid3DTopBottom.interiorFaces
PeriodicGrid3DTopBottom.scale
PeriodicGrid3DTopBottom.scaledCellDistances
PeriodicGrid3DTopBottom.scaledCellToCellDistances
PeriodicGrid3DTopBottom.scaledCellVolumes
PeriodicGrid3DTopBottom.scaledFaceAreas
PeriodicGrid3DTopBottom.scaledFaceToCellDistances
PeriodicGrid3DTopBottom.x
PeriodicGrid3DTopBottom.y
PeriodicGrid3DTopBottom.z
PeriodicGrid3DTopBottomFrontBack
PeriodicGrid3DTopBottomFrontBack.VTKCellDataSet
PeriodicGrid3DTopBottomFrontBack.VTKFaceDataSet
PeriodicGrid3DTopBottomFrontBack.__add__()
PeriodicGrid3DTopBottomFrontBack.__div__()
PeriodicGrid3DTopBottomFrontBack.__getstate__()
PeriodicGrid3DTopBottomFrontBack.__mul__()
PeriodicGrid3DTopBottomFrontBack.__radd__()
PeriodicGrid3DTopBottomFrontBack.__repr__()
PeriodicGrid3DTopBottomFrontBack.__rmul__()
PeriodicGrid3DTopBottomFrontBack.__setstate__()
PeriodicGrid3DTopBottomFrontBack.__sub__()
PeriodicGrid3DTopBottomFrontBack.__truediv__()
PeriodicGrid3DTopBottomFrontBack.aspect2D
PeriodicGrid3DTopBottomFrontBack.cellCenters
PeriodicGrid3DTopBottomFrontBack.cellDistanceVectors
PeriodicGrid3DTopBottomFrontBack.cellFaceIDs
PeriodicGrid3DTopBottomFrontBack.cellToFaceDistanceVectors
PeriodicGrid3DTopBottomFrontBack.cellVolumes
PeriodicGrid3DTopBottomFrontBack.extents
PeriodicGrid3DTopBottomFrontBack.exteriorFaces
PeriodicGrid3DTopBottomFrontBack.faceCenters
PeriodicGrid3DTopBottomFrontBack.facesBack
PeriodicGrid3DTopBottomFrontBack.facesBottom
PeriodicGrid3DTopBottomFrontBack.facesDown
PeriodicGrid3DTopBottomFrontBack.facesFront
PeriodicGrid3DTopBottomFrontBack.facesLeft
PeriodicGrid3DTopBottomFrontBack.facesRight
PeriodicGrid3DTopBottomFrontBack.facesTop
PeriodicGrid3DTopBottomFrontBack.facesUp
PeriodicGrid3DTopBottomFrontBack.getNearestCell()
PeriodicGrid3DTopBottomFrontBack.interiorFaceCellIDs
PeriodicGrid3DTopBottomFrontBack.interiorFaceIDs
PeriodicGrid3DTopBottomFrontBack.interiorFaces
PeriodicGrid3DTopBottomFrontBack.scale
PeriodicGrid3DTopBottomFrontBack.scaledCellDistances
PeriodicGrid3DTopBottomFrontBack.scaledCellToCellDistances
PeriodicGrid3DTopBottomFrontBack.scaledCellVolumes
PeriodicGrid3DTopBottomFrontBack.scaledFaceAreas
PeriodicGrid3DTopBottomFrontBack.scaledFaceToCellDistances
PeriodicGrid3DTopBottomFrontBack.x
PeriodicGrid3DTopBottomFrontBack.y
PeriodicGrid3DTopBottomFrontBack.z
- fipy.meshes.skewedGrid2D module
SkewedGrid2D
SkewedGrid2D.VTKCellDataSet
SkewedGrid2D.VTKFaceDataSet
SkewedGrid2D.__add__()
SkewedGrid2D.__div__()
SkewedGrid2D.__getstate__()
SkewedGrid2D.__mul__()
SkewedGrid2D.__radd__()
SkewedGrid2D.__repr__()
SkewedGrid2D.__rmul__()
SkewedGrid2D.__setstate__()
SkewedGrid2D.__sub__()
SkewedGrid2D.__truediv__()
SkewedGrid2D.aspect2D
SkewedGrid2D.cellCenters
SkewedGrid2D.cellDistanceVectors
SkewedGrid2D.cellFaceIDs
SkewedGrid2D.cellToFaceDistanceVectors
SkewedGrid2D.cellVolumes
SkewedGrid2D.extents
SkewedGrid2D.exteriorFaces
SkewedGrid2D.extrude()
SkewedGrid2D.faceCenters
SkewedGrid2D.facesBack
SkewedGrid2D.facesBottom
SkewedGrid2D.facesDown
SkewedGrid2D.facesFront
SkewedGrid2D.facesLeft
SkewedGrid2D.facesRight
SkewedGrid2D.facesTop
SkewedGrid2D.facesUp
SkewedGrid2D.getNearestCell()
SkewedGrid2D.interiorFaceCellIDs
SkewedGrid2D.interiorFaceIDs
SkewedGrid2D.interiorFaces
SkewedGrid2D.physicalShape
SkewedGrid2D.scale
SkewedGrid2D.scaledCellDistances
SkewedGrid2D.scaledCellToCellDistances
SkewedGrid2D.scaledCellVolumes
SkewedGrid2D.scaledFaceAreas
SkewedGrid2D.scaledFaceToCellDistances
SkewedGrid2D.shape
SkewedGrid2D.x
SkewedGrid2D.y
SkewedGrid2D.z
- fipy.meshes.sphericalNonUniformGrid1D module
SphericalNonUniformGrid1D
SphericalNonUniformGrid1D.VTKCellDataSet
SphericalNonUniformGrid1D.VTKFaceDataSet
SphericalNonUniformGrid1D.__add__()
SphericalNonUniformGrid1D.__div__()
SphericalNonUniformGrid1D.__getstate__()
SphericalNonUniformGrid1D.__mul__()
SphericalNonUniformGrid1D.__radd__()
SphericalNonUniformGrid1D.__repr__()
SphericalNonUniformGrid1D.__rmul__()
SphericalNonUniformGrid1D.__setstate__()
SphericalNonUniformGrid1D.__sub__()
SphericalNonUniformGrid1D.__truediv__()
SphericalNonUniformGrid1D.aspect2D
SphericalNonUniformGrid1D.cellCenters
SphericalNonUniformGrid1D.cellDistanceVectors
SphericalNonUniformGrid1D.cellFaceIDs
SphericalNonUniformGrid1D.cellToFaceDistanceVectors
SphericalNonUniformGrid1D.cellVolumes
SphericalNonUniformGrid1D.extents
SphericalNonUniformGrid1D.exteriorFaces
SphericalNonUniformGrid1D.faceCenters
SphericalNonUniformGrid1D.facesBack
SphericalNonUniformGrid1D.facesBottom
SphericalNonUniformGrid1D.facesDown
SphericalNonUniformGrid1D.facesFront
SphericalNonUniformGrid1D.facesLeft
SphericalNonUniformGrid1D.facesRight
SphericalNonUniformGrid1D.facesTop
SphericalNonUniformGrid1D.facesUp
SphericalNonUniformGrid1D.getNearestCell()
SphericalNonUniformGrid1D.interiorFaceCellIDs
SphericalNonUniformGrid1D.interiorFaceIDs
SphericalNonUniformGrid1D.interiorFaces
SphericalNonUniformGrid1D.scale
SphericalNonUniformGrid1D.scaledCellDistances
SphericalNonUniformGrid1D.scaledCellToCellDistances
SphericalNonUniformGrid1D.scaledCellVolumes
SphericalNonUniformGrid1D.scaledFaceAreas
SphericalNonUniformGrid1D.scaledFaceToCellDistances
SphericalNonUniformGrid1D.x
SphericalNonUniformGrid1D.y
SphericalNonUniformGrid1D.z
- fipy.meshes.sphericalUniformGrid1D module
SphericalUniformGrid1D
SphericalUniformGrid1D.VTKCellDataSet
SphericalUniformGrid1D.VTKFaceDataSet
SphericalUniformGrid1D.__add__()
SphericalUniformGrid1D.__div__()
SphericalUniformGrid1D.__getstate__()
SphericalUniformGrid1D.__mul__()
SphericalUniformGrid1D.__radd__()
SphericalUniformGrid1D.__repr__()
SphericalUniformGrid1D.__rmul__()
SphericalUniformGrid1D.__setstate__()
SphericalUniformGrid1D.__sub__()
SphericalUniformGrid1D.__truediv__()
SphericalUniformGrid1D.aspect2D
SphericalUniformGrid1D.cellCenters
SphericalUniformGrid1D.cellDistanceVectors
SphericalUniformGrid1D.cellFaceIDs
SphericalUniformGrid1D.cellToFaceDistanceVectors
SphericalUniformGrid1D.cellVolumes
SphericalUniformGrid1D.extents
SphericalUniformGrid1D.exteriorFaces
SphericalUniformGrid1D.faceCellIDs
SphericalUniformGrid1D.faceCenters
SphericalUniformGrid1D.faceNormals
SphericalUniformGrid1D.facesBack
SphericalUniformGrid1D.facesBottom
SphericalUniformGrid1D.facesDown
SphericalUniformGrid1D.facesFront
SphericalUniformGrid1D.facesLeft
SphericalUniformGrid1D.facesRight
SphericalUniformGrid1D.facesTop
SphericalUniformGrid1D.facesUp
SphericalUniformGrid1D.getNearestCell()
SphericalUniformGrid1D.interiorFaceCellIDs
SphericalUniformGrid1D.interiorFaceIDs
SphericalUniformGrid1D.interiorFaces
SphericalUniformGrid1D.scale
SphericalUniformGrid1D.scaledCellDistances
SphericalUniformGrid1D.scaledCellToCellDistances
SphericalUniformGrid1D.scaledCellVolumes
SphericalUniformGrid1D.scaledFaceAreas
SphericalUniformGrid1D.scaledFaceToCellDistances
SphericalUniformGrid1D.vertexCoords
SphericalUniformGrid1D.x
SphericalUniformGrid1D.y
SphericalUniformGrid1D.z
- fipy.meshes.test module
- fipy.meshes.tri2D module
Tri2D
Tri2D.VTKCellDataSet
Tri2D.VTKFaceDataSet
Tri2D.__add__()
Tri2D.__div__()
Tri2D.__getstate__()
Tri2D.__mul__()
Tri2D.__radd__()
Tri2D.__repr__()
Tri2D.__rmul__()
Tri2D.__setstate__()
Tri2D.__sub__()
Tri2D.__truediv__()
Tri2D.aspect2D
Tri2D.cellCenters
Tri2D.cellDistanceVectors
Tri2D.cellFaceIDs
Tri2D.cellToFaceDistanceVectors
Tri2D.cellVolumes
Tri2D.extents
Tri2D.exteriorFaces
Tri2D.extrude()
Tri2D.faceCenters
Tri2D.facesBack
Tri2D.facesBottom
Tri2D.facesDown
Tri2D.facesFront
Tri2D.facesLeft
Tri2D.facesRight
Tri2D.facesTop
Tri2D.facesUp
Tri2D.getNearestCell()
Tri2D.interiorFaceCellIDs
Tri2D.interiorFaceIDs
Tri2D.interiorFaces
Tri2D.physicalShape
Tri2D.scale
Tri2D.scaledCellDistances
Tri2D.scaledCellToCellDistances
Tri2D.scaledCellVolumes
Tri2D.scaledFaceAreas
Tri2D.scaledFaceToCellDistances
Tri2D.shape
Tri2D.x
Tri2D.y
Tri2D.z
- fipy.meshes.uniformGrid module
UniformGrid
UniformGrid.VTKCellDataSet
UniformGrid.VTKFaceDataSet
UniformGrid.__add__()
UniformGrid.__div__()
UniformGrid.__getstate__()
UniformGrid.__mul__()
UniformGrid.__radd__()
UniformGrid.__repr__()
UniformGrid.__rmul__()
UniformGrid.__setstate__()
UniformGrid.__sub__()
UniformGrid.__truediv__()
UniformGrid.aspect2D
UniformGrid.cellCenters
UniformGrid.cellDistanceVectors
UniformGrid.cellFaceIDs
UniformGrid.cellToFaceDistanceVectors
UniformGrid.cellVolumes
UniformGrid.extents
UniformGrid.exteriorFaces
UniformGrid.faceCenters
UniformGrid.facesBack
UniformGrid.facesBottom
UniformGrid.facesDown
UniformGrid.facesFront
UniformGrid.facesLeft
UniformGrid.facesRight
UniformGrid.facesTop
UniformGrid.facesUp
UniformGrid.getNearestCell()
UniformGrid.interiorFaceCellIDs
UniformGrid.interiorFaceIDs
UniformGrid.interiorFaces
UniformGrid.scale
UniformGrid.scaledCellDistances
UniformGrid.scaledCellToCellDistances
UniformGrid.scaledCellVolumes
UniformGrid.scaledFaceAreas
UniformGrid.scaledFaceToCellDistances
UniformGrid.x
UniformGrid.y
UniformGrid.z
- fipy.meshes.uniformGrid1D module
UniformGrid1D
UniformGrid1D.VTKCellDataSet
UniformGrid1D.VTKFaceDataSet
UniformGrid1D.__add__()
UniformGrid1D.__div__()
UniformGrid1D.__getstate__()
UniformGrid1D.__mul__()
UniformGrid1D.__radd__()
UniformGrid1D.__repr__()
UniformGrid1D.__rmul__()
UniformGrid1D.__setstate__()
UniformGrid1D.__sub__()
UniformGrid1D.__truediv__()
UniformGrid1D.aspect2D
UniformGrid1D.cellCenters
UniformGrid1D.cellDistanceVectors
UniformGrid1D.cellFaceIDs
UniformGrid1D.cellToFaceDistanceVectors
UniformGrid1D.cellVolumes
UniformGrid1D.extents
UniformGrid1D.exteriorFaces
UniformGrid1D.faceCellIDs
UniformGrid1D.faceCenters
UniformGrid1D.faceNormals
UniformGrid1D.facesBack
UniformGrid1D.facesBottom
UniformGrid1D.facesDown
UniformGrid1D.facesFront
UniformGrid1D.facesLeft
UniformGrid1D.facesRight
UniformGrid1D.facesTop
UniformGrid1D.facesUp
UniformGrid1D.getNearestCell()
UniformGrid1D.interiorFaceCellIDs
UniformGrid1D.interiorFaceIDs
UniformGrid1D.interiorFaces
UniformGrid1D.scale
UniformGrid1D.scaledCellDistances
UniformGrid1D.scaledCellToCellDistances
UniformGrid1D.scaledCellVolumes
UniformGrid1D.scaledFaceAreas
UniformGrid1D.scaledFaceToCellDistances
UniformGrid1D.vertexCoords
UniformGrid1D.x
UniformGrid1D.y
UniformGrid1D.z
- fipy.meshes.uniformGrid2D module
UniformGrid2D
UniformGrid2D.VTKCellDataSet
UniformGrid2D.VTKFaceDataSet
UniformGrid2D.__add__()
UniformGrid2D.__div__()
UniformGrid2D.__getstate__()
UniformGrid2D.__mul__()
UniformGrid2D.__radd__()
UniformGrid2D.__repr__()
UniformGrid2D.__rmul__()
UniformGrid2D.__setstate__()
UniformGrid2D.__sub__()
UniformGrid2D.__truediv__()
UniformGrid2D.aspect2D
UniformGrid2D.cellCenters
UniformGrid2D.cellDistanceVectors
UniformGrid2D.cellFaceIDs
UniformGrid2D.cellToFaceDistanceVectors
UniformGrid2D.cellVolumes
UniformGrid2D.extents
UniformGrid2D.exteriorFaces
UniformGrid2D.faceCellIDs
UniformGrid2D.faceCenters
UniformGrid2D.faceNormals
UniformGrid2D.faceVertexIDs
UniformGrid2D.facesBack
UniformGrid2D.facesBottom
UniformGrid2D.facesDown
UniformGrid2D.facesFront
UniformGrid2D.facesLeft
UniformGrid2D.facesRight
UniformGrid2D.facesTop
UniformGrid2D.facesUp
UniformGrid2D.getNearestCell()
UniformGrid2D.interiorFaceCellIDs
UniformGrid2D.interiorFaceIDs
UniformGrid2D.interiorFaces
UniformGrid2D.scale
UniformGrid2D.scaledCellDistances
UniformGrid2D.scaledCellToCellDistances
UniformGrid2D.scaledCellVolumes
UniformGrid2D.scaledFaceAreas
UniformGrid2D.scaledFaceToCellDistances
UniformGrid2D.vertexCoords
UniformGrid2D.x
UniformGrid2D.y
UniformGrid2D.z
- fipy.meshes.uniformGrid3D module
UniformGrid3D
UniformGrid3D.VTKCellDataSet
UniformGrid3D.VTKFaceDataSet
UniformGrid3D.__add__()
UniformGrid3D.__div__()
UniformGrid3D.__getstate__()
UniformGrid3D.__mul__()
UniformGrid3D.__radd__()
UniformGrid3D.__repr__()
UniformGrid3D.__rmul__()
UniformGrid3D.__setstate__()
UniformGrid3D.__sub__()
UniformGrid3D.__truediv__()
UniformGrid3D.aspect2D
UniformGrid3D.cellCenters
UniformGrid3D.cellDistanceVectors
UniformGrid3D.cellFaceIDs
UniformGrid3D.cellToFaceDistanceVectors
UniformGrid3D.cellVolumes
UniformGrid3D.extents
UniformGrid3D.exteriorFaces
UniformGrid3D.faceCellIDs
UniformGrid3D.faceCenters
UniformGrid3D.faceNormals
UniformGrid3D.faceVertexIDs
UniformGrid3D.facesBack
UniformGrid3D.facesBottom
UniformGrid3D.facesDown
UniformGrid3D.facesFront
UniformGrid3D.facesLeft
UniformGrid3D.facesRight
UniformGrid3D.facesTop
UniformGrid3D.facesUp
UniformGrid3D.getNearestCell()
UniformGrid3D.interiorFaceCellIDs
UniformGrid3D.interiorFaceIDs
UniformGrid3D.interiorFaces
UniformGrid3D.scale
UniformGrid3D.scaledCellDistances
UniformGrid3D.scaledCellToCellDistances
UniformGrid3D.scaledCellVolumes
UniformGrid3D.scaledFaceAreas
UniformGrid3D.scaledFaceToCellDistances
UniformGrid3D.vertexCoords
UniformGrid3D.x
UniformGrid3D.y
UniformGrid3D.z
- Module contents
CylindricalGrid1D()
CylindricalGrid2D()
Gmsh2D
Gmsh2D.VTKCellDataSet
Gmsh2D.VTKFaceDataSet
Gmsh2D.__add__()
Gmsh2D.__div__()
Gmsh2D.__getstate__()
Gmsh2D.__mul__()
Gmsh2D.__radd__()
Gmsh2D.__repr__()
Gmsh2D.__rmul__()
Gmsh2D.__setstate__()
Gmsh2D.__sub__()
Gmsh2D.__truediv__()
Gmsh2D.aspect2D
Gmsh2D.cellCenters
Gmsh2D.cellDistanceVectors
Gmsh2D.cellFaceIDs
Gmsh2D.cellToFaceDistanceVectors
Gmsh2D.cellVolumes
Gmsh2D.extents
Gmsh2D.exteriorFaces
Gmsh2D.extrude()
Gmsh2D.faceCenters
Gmsh2D.facesBack
Gmsh2D.facesBottom
Gmsh2D.facesDown
Gmsh2D.facesFront
Gmsh2D.facesLeft
Gmsh2D.facesRight
Gmsh2D.facesTop
Gmsh2D.facesUp
Gmsh2D.getNearestCell()
Gmsh2D.interiorFaceCellIDs
Gmsh2D.interiorFaceIDs
Gmsh2D.interiorFaces
Gmsh2D.scale
Gmsh2D.scaledCellDistances
Gmsh2D.scaledCellToCellDistances
Gmsh2D.scaledCellVolumes
Gmsh2D.scaledFaceAreas
Gmsh2D.scaledFaceToCellDistances
Gmsh2D.x
Gmsh2D.y
Gmsh2D.z
Gmsh2DIn3DSpace
Gmsh2DIn3DSpace.VTKCellDataSet
Gmsh2DIn3DSpace.VTKFaceDataSet
Gmsh2DIn3DSpace.__add__()
Gmsh2DIn3DSpace.__div__()
Gmsh2DIn3DSpace.__getstate__()
Gmsh2DIn3DSpace.__mul__()
Gmsh2DIn3DSpace.__radd__()
Gmsh2DIn3DSpace.__repr__()
Gmsh2DIn3DSpace.__rmul__()
Gmsh2DIn3DSpace.__setstate__()
Gmsh2DIn3DSpace.__sub__()
Gmsh2DIn3DSpace.__truediv__()
Gmsh2DIn3DSpace.aspect2D
Gmsh2DIn3DSpace.cellCenters
Gmsh2DIn3DSpace.cellDistanceVectors
Gmsh2DIn3DSpace.cellFaceIDs
Gmsh2DIn3DSpace.cellToFaceDistanceVectors
Gmsh2DIn3DSpace.cellVolumes
Gmsh2DIn3DSpace.extents
Gmsh2DIn3DSpace.exteriorFaces
Gmsh2DIn3DSpace.extrude()
Gmsh2DIn3DSpace.faceCenters
Gmsh2DIn3DSpace.facesBack
Gmsh2DIn3DSpace.facesBottom
Gmsh2DIn3DSpace.facesDown
Gmsh2DIn3DSpace.facesFront
Gmsh2DIn3DSpace.facesLeft
Gmsh2DIn3DSpace.facesRight
Gmsh2DIn3DSpace.facesTop
Gmsh2DIn3DSpace.facesUp
Gmsh2DIn3DSpace.getNearestCell()
Gmsh2DIn3DSpace.interiorFaceCellIDs
Gmsh2DIn3DSpace.interiorFaceIDs
Gmsh2DIn3DSpace.interiorFaces
Gmsh2DIn3DSpace.scale
Gmsh2DIn3DSpace.scaledCellDistances
Gmsh2DIn3DSpace.scaledCellToCellDistances
Gmsh2DIn3DSpace.scaledCellVolumes
Gmsh2DIn3DSpace.scaledFaceAreas
Gmsh2DIn3DSpace.scaledFaceToCellDistances
Gmsh2DIn3DSpace.x
Gmsh2DIn3DSpace.y
Gmsh2DIn3DSpace.z
Gmsh3D
Gmsh3D.VTKCellDataSet
Gmsh3D.VTKFaceDataSet
Gmsh3D.__add__()
Gmsh3D.__div__()
Gmsh3D.__getstate__()
Gmsh3D.__mul__()
Gmsh3D.__radd__()
Gmsh3D.__repr__()
Gmsh3D.__rmul__()
Gmsh3D.__setstate__()
Gmsh3D.__sub__()
Gmsh3D.__truediv__()
Gmsh3D.aspect2D
Gmsh3D.cellCenters
Gmsh3D.cellDistanceVectors
Gmsh3D.cellFaceIDs
Gmsh3D.cellToFaceDistanceVectors
Gmsh3D.cellVolumes
Gmsh3D.extents
Gmsh3D.exteriorFaces
Gmsh3D.faceCenters
Gmsh3D.facesBack
Gmsh3D.facesBottom
Gmsh3D.facesDown
Gmsh3D.facesFront
Gmsh3D.facesLeft
Gmsh3D.facesRight
Gmsh3D.facesTop
Gmsh3D.facesUp
Gmsh3D.getNearestCell()
Gmsh3D.interiorFaceCellIDs
Gmsh3D.interiorFaceIDs
Gmsh3D.interiorFaces
Gmsh3D.scale
Gmsh3D.scaledCellDistances
Gmsh3D.scaledCellToCellDistances
Gmsh3D.scaledCellVolumes
Gmsh3D.scaledFaceAreas
Gmsh3D.scaledFaceToCellDistances
Gmsh3D.x
Gmsh3D.y
Gmsh3D.z
GmshGrid2D
GmshGrid2D.VTKCellDataSet
GmshGrid2D.VTKFaceDataSet
GmshGrid2D.__add__()
GmshGrid2D.__div__()
GmshGrid2D.__getstate__()
GmshGrid2D.__mul__()
GmshGrid2D.__radd__()
GmshGrid2D.__repr__()
GmshGrid2D.__rmul__()
GmshGrid2D.__setstate__()
GmshGrid2D.__sub__()
GmshGrid2D.__truediv__()
GmshGrid2D.aspect2D
GmshGrid2D.cellCenters
GmshGrid2D.cellDistanceVectors
GmshGrid2D.cellFaceIDs
GmshGrid2D.cellToFaceDistanceVectors
GmshGrid2D.cellVolumes
GmshGrid2D.extents
GmshGrid2D.exteriorFaces
GmshGrid2D.extrude()
GmshGrid2D.faceCenters
GmshGrid2D.facesBack
GmshGrid2D.facesBottom
GmshGrid2D.facesDown
GmshGrid2D.facesFront
GmshGrid2D.facesLeft
GmshGrid2D.facesRight
GmshGrid2D.facesTop
GmshGrid2D.facesUp
GmshGrid2D.getNearestCell()
GmshGrid2D.interiorFaceCellIDs
GmshGrid2D.interiorFaceIDs
GmshGrid2D.interiorFaces
GmshGrid2D.scale
GmshGrid2D.scaledCellDistances
GmshGrid2D.scaledCellToCellDistances
GmshGrid2D.scaledCellVolumes
GmshGrid2D.scaledFaceAreas
GmshGrid2D.scaledFaceToCellDistances
GmshGrid2D.x
GmshGrid2D.y
GmshGrid2D.z
GmshGrid3D
GmshGrid3D.VTKCellDataSet
GmshGrid3D.VTKFaceDataSet
GmshGrid3D.__add__()
GmshGrid3D.__div__()
GmshGrid3D.__getstate__()
GmshGrid3D.__mul__()
GmshGrid3D.__radd__()
GmshGrid3D.__repr__()
GmshGrid3D.__rmul__()
GmshGrid3D.__setstate__()
GmshGrid3D.__sub__()
GmshGrid3D.__truediv__()
GmshGrid3D.aspect2D
GmshGrid3D.cellCenters
GmshGrid3D.cellDistanceVectors
GmshGrid3D.cellFaceIDs
GmshGrid3D.cellToFaceDistanceVectors
GmshGrid3D.cellVolumes
GmshGrid3D.extents
GmshGrid3D.exteriorFaces
GmshGrid3D.faceCenters
GmshGrid3D.facesBack
GmshGrid3D.facesBottom
GmshGrid3D.facesDown
GmshGrid3D.facesFront
GmshGrid3D.facesLeft
GmshGrid3D.facesRight
GmshGrid3D.facesTop
GmshGrid3D.facesUp
GmshGrid3D.getNearestCell()
GmshGrid3D.interiorFaceCellIDs
GmshGrid3D.interiorFaceIDs
GmshGrid3D.interiorFaces
GmshGrid3D.scale
GmshGrid3D.scaledCellDistances
GmshGrid3D.scaledCellToCellDistances
GmshGrid3D.scaledCellVolumes
GmshGrid3D.scaledFaceAreas
GmshGrid3D.scaledFaceToCellDistances
GmshGrid3D.x
GmshGrid3D.y
GmshGrid3D.z
Grid1D()
Grid2D()
Grid3D()
PeriodicGrid1D
PeriodicGrid1D.VTKCellDataSet
PeriodicGrid1D.VTKFaceDataSet
PeriodicGrid1D.__add__()
PeriodicGrid1D.__div__()
PeriodicGrid1D.__getstate__()
PeriodicGrid1D.__mul__()
PeriodicGrid1D.__radd__()
PeriodicGrid1D.__repr__()
PeriodicGrid1D.__rmul__()
PeriodicGrid1D.__setstate__()
PeriodicGrid1D.__sub__()
PeriodicGrid1D.__truediv__()
PeriodicGrid1D.aspect2D
PeriodicGrid1D.cellCenters
PeriodicGrid1D.cellDistanceVectors
PeriodicGrid1D.cellFaceIDs
PeriodicGrid1D.cellToFaceDistanceVectors
PeriodicGrid1D.cellVolumes
PeriodicGrid1D.extents
PeriodicGrid1D.exteriorFaces
PeriodicGrid1D.faceCenters
PeriodicGrid1D.facesBack
PeriodicGrid1D.facesBottom
PeriodicGrid1D.facesDown
PeriodicGrid1D.facesFront
PeriodicGrid1D.facesLeft
PeriodicGrid1D.facesRight
PeriodicGrid1D.facesTop
PeriodicGrid1D.facesUp
PeriodicGrid1D.getNearestCell()
PeriodicGrid1D.interiorFaceCellIDs
PeriodicGrid1D.interiorFaceIDs
PeriodicGrid1D.interiorFaces
PeriodicGrid1D.scale
PeriodicGrid1D.scaledCellDistances
PeriodicGrid1D.scaledCellToCellDistances
PeriodicGrid1D.scaledCellVolumes
PeriodicGrid1D.scaledFaceAreas
PeriodicGrid1D.scaledFaceToCellDistances
PeriodicGrid1D.x
PeriodicGrid1D.y
PeriodicGrid1D.z
PeriodicGrid2D
PeriodicGrid2D.VTKCellDataSet
PeriodicGrid2D.VTKFaceDataSet
PeriodicGrid2D.__add__()
PeriodicGrid2D.__div__()
PeriodicGrid2D.__getstate__()
PeriodicGrid2D.__mul__()
PeriodicGrid2D.__radd__()
PeriodicGrid2D.__repr__()
PeriodicGrid2D.__rmul__()
PeriodicGrid2D.__setstate__()
PeriodicGrid2D.__sub__()
PeriodicGrid2D.__truediv__()
PeriodicGrid2D.aspect2D
PeriodicGrid2D.cellCenters
PeriodicGrid2D.cellDistanceVectors
PeriodicGrid2D.cellFaceIDs
PeriodicGrid2D.cellToFaceDistanceVectors
PeriodicGrid2D.cellVolumes
PeriodicGrid2D.extents
PeriodicGrid2D.exteriorFaces
PeriodicGrid2D.extrude()
PeriodicGrid2D.faceCenters
PeriodicGrid2D.facesBack
PeriodicGrid2D.facesBottom
PeriodicGrid2D.facesDown
PeriodicGrid2D.facesFront
PeriodicGrid2D.facesLeft
PeriodicGrid2D.facesRight
PeriodicGrid2D.facesTop
PeriodicGrid2D.facesUp
PeriodicGrid2D.getNearestCell()
PeriodicGrid2D.interiorFaceCellIDs
PeriodicGrid2D.interiorFaceIDs
PeriodicGrid2D.interiorFaces
PeriodicGrid2D.scale
PeriodicGrid2D.scaledCellDistances
PeriodicGrid2D.scaledCellToCellDistances
PeriodicGrid2D.scaledCellVolumes
PeriodicGrid2D.scaledFaceAreas
PeriodicGrid2D.scaledFaceToCellDistances
PeriodicGrid2D.x
PeriodicGrid2D.y
PeriodicGrid2D.z
PeriodicGrid2DLeftRight
PeriodicGrid2DLeftRight.VTKCellDataSet
PeriodicGrid2DLeftRight.VTKFaceDataSet
PeriodicGrid2DLeftRight.__add__()
PeriodicGrid2DLeftRight.__div__()
PeriodicGrid2DLeftRight.__getstate__()
PeriodicGrid2DLeftRight.__mul__()
PeriodicGrid2DLeftRight.__radd__()
PeriodicGrid2DLeftRight.__repr__()
PeriodicGrid2DLeftRight.__rmul__()
PeriodicGrid2DLeftRight.__setstate__()
PeriodicGrid2DLeftRight.__sub__()
PeriodicGrid2DLeftRight.__truediv__()
PeriodicGrid2DLeftRight.aspect2D
PeriodicGrid2DLeftRight.cellCenters
PeriodicGrid2DLeftRight.cellDistanceVectors
PeriodicGrid2DLeftRight.cellFaceIDs
PeriodicGrid2DLeftRight.cellToFaceDistanceVectors
PeriodicGrid2DLeftRight.cellVolumes
PeriodicGrid2DLeftRight.extents
PeriodicGrid2DLeftRight.exteriorFaces
PeriodicGrid2DLeftRight.extrude()
PeriodicGrid2DLeftRight.faceCenters
PeriodicGrid2DLeftRight.facesBack
PeriodicGrid2DLeftRight.facesBottom
PeriodicGrid2DLeftRight.facesDown
PeriodicGrid2DLeftRight.facesFront
PeriodicGrid2DLeftRight.facesLeft
PeriodicGrid2DLeftRight.facesRight
PeriodicGrid2DLeftRight.facesTop
PeriodicGrid2DLeftRight.facesUp
PeriodicGrid2DLeftRight.getNearestCell()
PeriodicGrid2DLeftRight.interiorFaceCellIDs
PeriodicGrid2DLeftRight.interiorFaceIDs
PeriodicGrid2DLeftRight.interiorFaces
PeriodicGrid2DLeftRight.scale
PeriodicGrid2DLeftRight.scaledCellDistances
PeriodicGrid2DLeftRight.scaledCellToCellDistances
PeriodicGrid2DLeftRight.scaledCellVolumes
PeriodicGrid2DLeftRight.scaledFaceAreas
PeriodicGrid2DLeftRight.scaledFaceToCellDistances
PeriodicGrid2DLeftRight.x
PeriodicGrid2DLeftRight.y
PeriodicGrid2DLeftRight.z
PeriodicGrid2DTopBottom
PeriodicGrid2DTopBottom.VTKCellDataSet
PeriodicGrid2DTopBottom.VTKFaceDataSet
PeriodicGrid2DTopBottom.__add__()
PeriodicGrid2DTopBottom.__div__()
PeriodicGrid2DTopBottom.__getstate__()
PeriodicGrid2DTopBottom.__mul__()
PeriodicGrid2DTopBottom.__radd__()
PeriodicGrid2DTopBottom.__repr__()
PeriodicGrid2DTopBottom.__rmul__()
PeriodicGrid2DTopBottom.__setstate__()
PeriodicGrid2DTopBottom.__sub__()
PeriodicGrid2DTopBottom.__truediv__()
PeriodicGrid2DTopBottom.aspect2D
PeriodicGrid2DTopBottom.cellCenters
PeriodicGrid2DTopBottom.cellDistanceVectors
PeriodicGrid2DTopBottom.cellFaceIDs
PeriodicGrid2DTopBottom.cellToFaceDistanceVectors
PeriodicGrid2DTopBottom.cellVolumes
PeriodicGrid2DTopBottom.extents
PeriodicGrid2DTopBottom.exteriorFaces
PeriodicGrid2DTopBottom.extrude()
PeriodicGrid2DTopBottom.faceCenters
PeriodicGrid2DTopBottom.facesBack
PeriodicGrid2DTopBottom.facesBottom
PeriodicGrid2DTopBottom.facesDown
PeriodicGrid2DTopBottom.facesFront
PeriodicGrid2DTopBottom.facesLeft
PeriodicGrid2DTopBottom.facesRight
PeriodicGrid2DTopBottom.facesTop
PeriodicGrid2DTopBottom.facesUp
PeriodicGrid2DTopBottom.getNearestCell()
PeriodicGrid2DTopBottom.interiorFaceCellIDs
PeriodicGrid2DTopBottom.interiorFaceIDs
PeriodicGrid2DTopBottom.interiorFaces
PeriodicGrid2DTopBottom.scale
PeriodicGrid2DTopBottom.scaledCellDistances
PeriodicGrid2DTopBottom.scaledCellToCellDistances
PeriodicGrid2DTopBottom.scaledCellVolumes
PeriodicGrid2DTopBottom.scaledFaceAreas
PeriodicGrid2DTopBottom.scaledFaceToCellDistances
PeriodicGrid2DTopBottom.x
PeriodicGrid2DTopBottom.y
PeriodicGrid2DTopBottom.z
PeriodicGrid3D
PeriodicGrid3D.VTKCellDataSet
PeriodicGrid3D.VTKFaceDataSet
PeriodicGrid3D.__add__()
PeriodicGrid3D.__div__()
PeriodicGrid3D.__getstate__()
PeriodicGrid3D.__mul__()
PeriodicGrid3D.__radd__()
PeriodicGrid3D.__repr__()
PeriodicGrid3D.__rmul__()
PeriodicGrid3D.__setstate__()
PeriodicGrid3D.__sub__()
PeriodicGrid3D.__truediv__()
PeriodicGrid3D.aspect2D
PeriodicGrid3D.cellCenters
PeriodicGrid3D.cellDistanceVectors
PeriodicGrid3D.cellFaceIDs
PeriodicGrid3D.cellToFaceDistanceVectors
PeriodicGrid3D.cellVolumes
PeriodicGrid3D.extents
PeriodicGrid3D.exteriorFaces
PeriodicGrid3D.faceCenters
PeriodicGrid3D.facesBack
PeriodicGrid3D.facesBottom
PeriodicGrid3D.facesDown
PeriodicGrid3D.facesFront
PeriodicGrid3D.facesLeft
PeriodicGrid3D.facesRight
PeriodicGrid3D.facesTop
PeriodicGrid3D.facesUp
PeriodicGrid3D.getNearestCell()
PeriodicGrid3D.interiorFaceCellIDs
PeriodicGrid3D.interiorFaceIDs
PeriodicGrid3D.interiorFaces
PeriodicGrid3D.scale
PeriodicGrid3D.scaledCellDistances
PeriodicGrid3D.scaledCellToCellDistances
PeriodicGrid3D.scaledCellVolumes
PeriodicGrid3D.scaledFaceAreas
PeriodicGrid3D.scaledFaceToCellDistances
PeriodicGrid3D.x
PeriodicGrid3D.y
PeriodicGrid3D.z
PeriodicGrid3DFrontBack
PeriodicGrid3DFrontBack.VTKCellDataSet
PeriodicGrid3DFrontBack.VTKFaceDataSet
PeriodicGrid3DFrontBack.__add__()
PeriodicGrid3DFrontBack.__div__()
PeriodicGrid3DFrontBack.__getstate__()
PeriodicGrid3DFrontBack.__mul__()
PeriodicGrid3DFrontBack.__radd__()
PeriodicGrid3DFrontBack.__repr__()
PeriodicGrid3DFrontBack.__rmul__()
PeriodicGrid3DFrontBack.__setstate__()
PeriodicGrid3DFrontBack.__sub__()
PeriodicGrid3DFrontBack.__truediv__()
PeriodicGrid3DFrontBack.aspect2D
PeriodicGrid3DFrontBack.cellCenters
PeriodicGrid3DFrontBack.cellDistanceVectors
PeriodicGrid3DFrontBack.cellFaceIDs
PeriodicGrid3DFrontBack.cellToFaceDistanceVectors
PeriodicGrid3DFrontBack.cellVolumes
PeriodicGrid3DFrontBack.extents
PeriodicGrid3DFrontBack.exteriorFaces
PeriodicGrid3DFrontBack.faceCenters
PeriodicGrid3DFrontBack.facesBack
PeriodicGrid3DFrontBack.facesBottom
PeriodicGrid3DFrontBack.facesDown
PeriodicGrid3DFrontBack.facesFront
PeriodicGrid3DFrontBack.facesLeft
PeriodicGrid3DFrontBack.facesRight
PeriodicGrid3DFrontBack.facesTop
PeriodicGrid3DFrontBack.facesUp
PeriodicGrid3DFrontBack.getNearestCell()
PeriodicGrid3DFrontBack.interiorFaceCellIDs
PeriodicGrid3DFrontBack.interiorFaceIDs
PeriodicGrid3DFrontBack.interiorFaces
PeriodicGrid3DFrontBack.scale
PeriodicGrid3DFrontBack.scaledCellDistances
PeriodicGrid3DFrontBack.scaledCellToCellDistances
PeriodicGrid3DFrontBack.scaledCellVolumes
PeriodicGrid3DFrontBack.scaledFaceAreas
PeriodicGrid3DFrontBack.scaledFaceToCellDistances
PeriodicGrid3DFrontBack.x
PeriodicGrid3DFrontBack.y
PeriodicGrid3DFrontBack.z
PeriodicGrid3DLeftRight
PeriodicGrid3DLeftRight.VTKCellDataSet
PeriodicGrid3DLeftRight.VTKFaceDataSet
PeriodicGrid3DLeftRight.__add__()
PeriodicGrid3DLeftRight.__div__()
PeriodicGrid3DLeftRight.__getstate__()
PeriodicGrid3DLeftRight.__mul__()
PeriodicGrid3DLeftRight.__radd__()
PeriodicGrid3DLeftRight.__repr__()
PeriodicGrid3DLeftRight.__rmul__()
PeriodicGrid3DLeftRight.__setstate__()
PeriodicGrid3DLeftRight.__sub__()
PeriodicGrid3DLeftRight.__truediv__()
PeriodicGrid3DLeftRight.aspect2D
PeriodicGrid3DLeftRight.cellCenters
PeriodicGrid3DLeftRight.cellDistanceVectors
PeriodicGrid3DLeftRight.cellFaceIDs
PeriodicGrid3DLeftRight.cellToFaceDistanceVectors
PeriodicGrid3DLeftRight.cellVolumes
PeriodicGrid3DLeftRight.extents
PeriodicGrid3DLeftRight.exteriorFaces
PeriodicGrid3DLeftRight.faceCenters
PeriodicGrid3DLeftRight.facesBack
PeriodicGrid3DLeftRight.facesBottom
PeriodicGrid3DLeftRight.facesDown
PeriodicGrid3DLeftRight.facesFront
PeriodicGrid3DLeftRight.facesLeft
PeriodicGrid3DLeftRight.facesRight
PeriodicGrid3DLeftRight.facesTop
PeriodicGrid3DLeftRight.facesUp
PeriodicGrid3DLeftRight.getNearestCell()
PeriodicGrid3DLeftRight.interiorFaceCellIDs
PeriodicGrid3DLeftRight.interiorFaceIDs
PeriodicGrid3DLeftRight.interiorFaces
PeriodicGrid3DLeftRight.scale
PeriodicGrid3DLeftRight.scaledCellDistances
PeriodicGrid3DLeftRight.scaledCellToCellDistances
PeriodicGrid3DLeftRight.scaledCellVolumes
PeriodicGrid3DLeftRight.scaledFaceAreas
PeriodicGrid3DLeftRight.scaledFaceToCellDistances
PeriodicGrid3DLeftRight.x
PeriodicGrid3DLeftRight.y
PeriodicGrid3DLeftRight.z
PeriodicGrid3DLeftRightFrontBack
PeriodicGrid3DLeftRightFrontBack.VTKCellDataSet
PeriodicGrid3DLeftRightFrontBack.VTKFaceDataSet
PeriodicGrid3DLeftRightFrontBack.__add__()
PeriodicGrid3DLeftRightFrontBack.__div__()
PeriodicGrid3DLeftRightFrontBack.__getstate__()
PeriodicGrid3DLeftRightFrontBack.__mul__()
PeriodicGrid3DLeftRightFrontBack.__radd__()
PeriodicGrid3DLeftRightFrontBack.__repr__()
PeriodicGrid3DLeftRightFrontBack.__rmul__()
PeriodicGrid3DLeftRightFrontBack.__setstate__()
PeriodicGrid3DLeftRightFrontBack.__sub__()
PeriodicGrid3DLeftRightFrontBack.__truediv__()
PeriodicGrid3DLeftRightFrontBack.aspect2D
PeriodicGrid3DLeftRightFrontBack.cellCenters
PeriodicGrid3DLeftRightFrontBack.cellDistanceVectors
PeriodicGrid3DLeftRightFrontBack.cellFaceIDs
PeriodicGrid3DLeftRightFrontBack.cellToFaceDistanceVectors
PeriodicGrid3DLeftRightFrontBack.cellVolumes
PeriodicGrid3DLeftRightFrontBack.extents
PeriodicGrid3DLeftRightFrontBack.exteriorFaces
PeriodicGrid3DLeftRightFrontBack.faceCenters
PeriodicGrid3DLeftRightFrontBack.facesBack
PeriodicGrid3DLeftRightFrontBack.facesBottom
PeriodicGrid3DLeftRightFrontBack.facesDown
PeriodicGrid3DLeftRightFrontBack.facesFront
PeriodicGrid3DLeftRightFrontBack.facesLeft
PeriodicGrid3DLeftRightFrontBack.facesRight
PeriodicGrid3DLeftRightFrontBack.facesTop
PeriodicGrid3DLeftRightFrontBack.facesUp
PeriodicGrid3DLeftRightFrontBack.getNearestCell()
PeriodicGrid3DLeftRightFrontBack.interiorFaceCellIDs
PeriodicGrid3DLeftRightFrontBack.interiorFaceIDs
PeriodicGrid3DLeftRightFrontBack.interiorFaces
PeriodicGrid3DLeftRightFrontBack.scale
PeriodicGrid3DLeftRightFrontBack.scaledCellDistances
PeriodicGrid3DLeftRightFrontBack.scaledCellToCellDistances
PeriodicGrid3DLeftRightFrontBack.scaledCellVolumes
PeriodicGrid3DLeftRightFrontBack.scaledFaceAreas
PeriodicGrid3DLeftRightFrontBack.scaledFaceToCellDistances
PeriodicGrid3DLeftRightFrontBack.x
PeriodicGrid3DLeftRightFrontBack.y
PeriodicGrid3DLeftRightFrontBack.z
PeriodicGrid3DLeftRightTopBottom
PeriodicGrid3DLeftRightTopBottom.VTKCellDataSet
PeriodicGrid3DLeftRightTopBottom.VTKFaceDataSet
PeriodicGrid3DLeftRightTopBottom.__add__()
PeriodicGrid3DLeftRightTopBottom.__div__()
PeriodicGrid3DLeftRightTopBottom.__getstate__()
PeriodicGrid3DLeftRightTopBottom.__mul__()
PeriodicGrid3DLeftRightTopBottom.__radd__()
PeriodicGrid3DLeftRightTopBottom.__repr__()
PeriodicGrid3DLeftRightTopBottom.__rmul__()
PeriodicGrid3DLeftRightTopBottom.__setstate__()
PeriodicGrid3DLeftRightTopBottom.__sub__()
PeriodicGrid3DLeftRightTopBottom.__truediv__()
PeriodicGrid3DLeftRightTopBottom.aspect2D
PeriodicGrid3DLeftRightTopBottom.cellCenters
PeriodicGrid3DLeftRightTopBottom.cellDistanceVectors
PeriodicGrid3DLeftRightTopBottom.cellFaceIDs
PeriodicGrid3DLeftRightTopBottom.cellToFaceDistanceVectors
PeriodicGrid3DLeftRightTopBottom.cellVolumes
PeriodicGrid3DLeftRightTopBottom.extents
PeriodicGrid3DLeftRightTopBottom.exteriorFaces
PeriodicGrid3DLeftRightTopBottom.faceCenters
PeriodicGrid3DLeftRightTopBottom.facesBack
PeriodicGrid3DLeftRightTopBottom.facesBottom
PeriodicGrid3DLeftRightTopBottom.facesDown
PeriodicGrid3DLeftRightTopBottom.facesFront
PeriodicGrid3DLeftRightTopBottom.facesLeft
PeriodicGrid3DLeftRightTopBottom.facesRight
PeriodicGrid3DLeftRightTopBottom.facesTop
PeriodicGrid3DLeftRightTopBottom.facesUp
PeriodicGrid3DLeftRightTopBottom.getNearestCell()
PeriodicGrid3DLeftRightTopBottom.interiorFaceCellIDs
PeriodicGrid3DLeftRightTopBottom.interiorFaceIDs
PeriodicGrid3DLeftRightTopBottom.interiorFaces
PeriodicGrid3DLeftRightTopBottom.scale
PeriodicGrid3DLeftRightTopBottom.scaledCellDistances
PeriodicGrid3DLeftRightTopBottom.scaledCellToCellDistances
PeriodicGrid3DLeftRightTopBottom.scaledCellVolumes
PeriodicGrid3DLeftRightTopBottom.scaledFaceAreas
PeriodicGrid3DLeftRightTopBottom.scaledFaceToCellDistances
PeriodicGrid3DLeftRightTopBottom.x
PeriodicGrid3DLeftRightTopBottom.y
PeriodicGrid3DLeftRightTopBottom.z
PeriodicGrid3DTopBottom
PeriodicGrid3DTopBottom.VTKCellDataSet
PeriodicGrid3DTopBottom.VTKFaceDataSet
PeriodicGrid3DTopBottom.__add__()
PeriodicGrid3DTopBottom.__div__()
PeriodicGrid3DTopBottom.__getstate__()
PeriodicGrid3DTopBottom.__mul__()
PeriodicGrid3DTopBottom.__radd__()
PeriodicGrid3DTopBottom.__repr__()
PeriodicGrid3DTopBottom.__rmul__()
PeriodicGrid3DTopBottom.__setstate__()
PeriodicGrid3DTopBottom.__sub__()
PeriodicGrid3DTopBottom.__truediv__()
PeriodicGrid3DTopBottom.aspect2D
PeriodicGrid3DTopBottom.cellCenters
PeriodicGrid3DTopBottom.cellDistanceVectors
PeriodicGrid3DTopBottom.cellFaceIDs
PeriodicGrid3DTopBottom.cellToFaceDistanceVectors
PeriodicGrid3DTopBottom.cellVolumes
PeriodicGrid3DTopBottom.extents
PeriodicGrid3DTopBottom.exteriorFaces
PeriodicGrid3DTopBottom.faceCenters
PeriodicGrid3DTopBottom.facesBack
PeriodicGrid3DTopBottom.facesBottom
PeriodicGrid3DTopBottom.facesDown
PeriodicGrid3DTopBottom.facesFront
PeriodicGrid3DTopBottom.facesLeft
PeriodicGrid3DTopBottom.facesRight
PeriodicGrid3DTopBottom.facesTop
PeriodicGrid3DTopBottom.facesUp
PeriodicGrid3DTopBottom.getNearestCell()
PeriodicGrid3DTopBottom.interiorFaceCellIDs
PeriodicGrid3DTopBottom.interiorFaceIDs
PeriodicGrid3DTopBottom.interiorFaces
PeriodicGrid3DTopBottom.scale
PeriodicGrid3DTopBottom.scaledCellDistances
PeriodicGrid3DTopBottom.scaledCellToCellDistances
PeriodicGrid3DTopBottom.scaledCellVolumes
PeriodicGrid3DTopBottom.scaledFaceAreas
PeriodicGrid3DTopBottom.scaledFaceToCellDistances
PeriodicGrid3DTopBottom.x
PeriodicGrid3DTopBottom.y
PeriodicGrid3DTopBottom.z
PeriodicGrid3DTopBottomFrontBack
PeriodicGrid3DTopBottomFrontBack.VTKCellDataSet
PeriodicGrid3DTopBottomFrontBack.VTKFaceDataSet
PeriodicGrid3DTopBottomFrontBack.__add__()
PeriodicGrid3DTopBottomFrontBack.__div__()
PeriodicGrid3DTopBottomFrontBack.__getstate__()
PeriodicGrid3DTopBottomFrontBack.__mul__()
PeriodicGrid3DTopBottomFrontBack.__radd__()
PeriodicGrid3DTopBottomFrontBack.__repr__()
PeriodicGrid3DTopBottomFrontBack.__rmul__()
PeriodicGrid3DTopBottomFrontBack.__setstate__()
PeriodicGrid3DTopBottomFrontBack.__sub__()
PeriodicGrid3DTopBottomFrontBack.__truediv__()
PeriodicGrid3DTopBottomFrontBack.aspect2D
PeriodicGrid3DTopBottomFrontBack.cellCenters
PeriodicGrid3DTopBottomFrontBack.cellDistanceVectors
PeriodicGrid3DTopBottomFrontBack.cellFaceIDs
PeriodicGrid3DTopBottomFrontBack.cellToFaceDistanceVectors
PeriodicGrid3DTopBottomFrontBack.cellVolumes
PeriodicGrid3DTopBottomFrontBack.extents
PeriodicGrid3DTopBottomFrontBack.exteriorFaces
PeriodicGrid3DTopBottomFrontBack.faceCenters
PeriodicGrid3DTopBottomFrontBack.facesBack
PeriodicGrid3DTopBottomFrontBack.facesBottom
PeriodicGrid3DTopBottomFrontBack.facesDown
PeriodicGrid3DTopBottomFrontBack.facesFront
PeriodicGrid3DTopBottomFrontBack.facesLeft
PeriodicGrid3DTopBottomFrontBack.facesRight
PeriodicGrid3DTopBottomFrontBack.facesTop
PeriodicGrid3DTopBottomFrontBack.facesUp
PeriodicGrid3DTopBottomFrontBack.getNearestCell()
PeriodicGrid3DTopBottomFrontBack.interiorFaceCellIDs
PeriodicGrid3DTopBottomFrontBack.interiorFaceIDs
PeriodicGrid3DTopBottomFrontBack.interiorFaces
PeriodicGrid3DTopBottomFrontBack.scale
PeriodicGrid3DTopBottomFrontBack.scaledCellDistances
PeriodicGrid3DTopBottomFrontBack.scaledCellToCellDistances
PeriodicGrid3DTopBottomFrontBack.scaledCellVolumes
PeriodicGrid3DTopBottomFrontBack.scaledFaceAreas
PeriodicGrid3DTopBottomFrontBack.scaledFaceToCellDistances
PeriodicGrid3DTopBottomFrontBack.x
PeriodicGrid3DTopBottomFrontBack.y
PeriodicGrid3DTopBottomFrontBack.z
SkewedGrid2D
SkewedGrid2D.VTKCellDataSet
SkewedGrid2D.VTKFaceDataSet
SkewedGrid2D.__add__()
SkewedGrid2D.__div__()
SkewedGrid2D.__getstate__()
SkewedGrid2D.__mul__()
SkewedGrid2D.__radd__()
SkewedGrid2D.__repr__()
SkewedGrid2D.__rmul__()
SkewedGrid2D.__setstate__()
SkewedGrid2D.__sub__()
SkewedGrid2D.__truediv__()
SkewedGrid2D.aspect2D
SkewedGrid2D.cellCenters
SkewedGrid2D.cellDistanceVectors
SkewedGrid2D.cellFaceIDs
SkewedGrid2D.cellToFaceDistanceVectors
SkewedGrid2D.cellVolumes
SkewedGrid2D.extents
SkewedGrid2D.exteriorFaces
SkewedGrid2D.extrude()
SkewedGrid2D.faceCenters
SkewedGrid2D.facesBack
SkewedGrid2D.facesBottom
SkewedGrid2D.facesDown
SkewedGrid2D.facesFront
SkewedGrid2D.facesLeft
SkewedGrid2D.facesRight
SkewedGrid2D.facesTop
SkewedGrid2D.facesUp
SkewedGrid2D.getNearestCell()
SkewedGrid2D.interiorFaceCellIDs
SkewedGrid2D.interiorFaceIDs
SkewedGrid2D.interiorFaces
SkewedGrid2D.physicalShape
SkewedGrid2D.scale
SkewedGrid2D.scaledCellDistances
SkewedGrid2D.scaledCellToCellDistances
SkewedGrid2D.scaledCellVolumes
SkewedGrid2D.scaledFaceAreas
SkewedGrid2D.scaledFaceToCellDistances
SkewedGrid2D.shape
SkewedGrid2D.x
SkewedGrid2D.y
SkewedGrid2D.z
SphericalGrid1D()
Tri2D
Tri2D.VTKCellDataSet
Tri2D.VTKFaceDataSet
Tri2D.__add__()
Tri2D.__div__()
Tri2D.__getstate__()
Tri2D.__mul__()
Tri2D.__radd__()
Tri2D.__repr__()
Tri2D.__rmul__()
Tri2D.__setstate__()
Tri2D.__sub__()
Tri2D.__truediv__()
Tri2D.aspect2D
Tri2D.cellCenters
Tri2D.cellDistanceVectors
Tri2D.cellFaceIDs
Tri2D.cellToFaceDistanceVectors
Tri2D.cellVolumes
Tri2D.extents
Tri2D.exteriorFaces
Tri2D.extrude()
Tri2D.faceCenters
Tri2D.facesBack
Tri2D.facesBottom
Tri2D.facesDown
Tri2D.facesFront
Tri2D.facesLeft
Tri2D.facesRight
Tri2D.facesTop
Tri2D.facesUp
Tri2D.getNearestCell()
Tri2D.interiorFaceCellIDs
Tri2D.interiorFaceIDs
Tri2D.interiorFaces
Tri2D.physicalShape
Tri2D.scale
Tri2D.scaledCellDistances
Tri2D.scaledCellToCellDistances
Tri2D.scaledCellVolumes
Tri2D.scaledFaceAreas
Tri2D.scaledFaceToCellDistances
Tri2D.shape
Tri2D.x
Tri2D.y
Tri2D.z
openMSHFile()
openPOSFile()
- fipy.solvers package
- Subpackages
- fipy.solvers.petsc package
- Subpackages
- Submodules
- fipy.solvers.petsc.dummySolver module
- fipy.solvers.petsc.linearBicgSolver module
- fipy.solvers.petsc.linearCGSSolver module
- fipy.solvers.petsc.linearGMRESSolver module
- fipy.solvers.petsc.linearLUSolver module
- fipy.solvers.petsc.linearPCGSolver module
- fipy.solvers.petsc.petscKrylovSolver module
- fipy.solvers.petsc.petscSolver module
- Module contents
- fipy.solvers.pyAMG package
- fipy.solvers.pyamgx package
- Subpackages
- Submodules
- fipy.solvers.pyamgx.aggregationAMGSolver module
- fipy.solvers.pyamgx.classicalAMGSolver module
- fipy.solvers.pyamgx.linearBiCGStabSolver module
- fipy.solvers.pyamgx.linearCGSolver module
- fipy.solvers.pyamgx.linearFGMRESSolver module
- fipy.solvers.pyamgx.linearGMRESSolver module
- fipy.solvers.pyamgx.linearLUSolver module
- fipy.solvers.pyamgx.pyAMGXSolver module
- Module contents
- fipy.solvers.pysparse package
- Subpackages
- Submodules
- fipy.solvers.pysparse.linearCGSSolver module
- fipy.solvers.pysparse.linearGMRESSolver module
- fipy.solvers.pysparse.linearJORSolver module
- fipy.solvers.pysparse.linearLUSolver module
- fipy.solvers.pysparse.linearPCGSolver module
- fipy.solvers.pysparse.pysparseSolver module
- Module contents
- fipy.solvers.scipy package
- Submodules
- fipy.solvers.scipy.linearBicgstabSolver module
- fipy.solvers.scipy.linearCGSSolver module
- fipy.solvers.scipy.linearGMRESSolver module
- fipy.solvers.scipy.linearLUSolver module
- fipy.solvers.scipy.linearPCGSolver module
- fipy.solvers.scipy.scipyKrylovSolver module
- fipy.solvers.scipy.scipySolver module
- Module contents
- fipy.solvers.trilinos package
- Subpackages
- Submodules
- fipy.solvers.trilinos.linearBicgstabSolver module
- fipy.solvers.trilinos.linearCGSSolver module
- fipy.solvers.trilinos.linearGMRESSolver module
- fipy.solvers.trilinos.linearLUSolver module
- fipy.solvers.trilinos.linearPCGSolver module
- fipy.solvers.trilinos.trilinosAztecOOSolver module
- fipy.solvers.trilinos.trilinosMLTest module
- fipy.solvers.trilinos.trilinosNonlinearSolver module
- fipy.solvers.trilinos.trilinosSolver module
- Module contents
- fipy.solvers.petsc package
- Submodules
- fipy.solvers.pysparseMatrixSolver module
- fipy.solvers.solver module
IllConditionedPreconditionerWarning
IllConditionedPreconditionerWarning.__cause__
IllConditionedPreconditionerWarning.__context__
IllConditionedPreconditionerWarning.__delattr__()
IllConditionedPreconditionerWarning.__getattribute__()
IllConditionedPreconditionerWarning.__reduce__()
IllConditionedPreconditionerWarning.__repr__()
IllConditionedPreconditionerWarning.__setattr__()
IllConditionedPreconditionerWarning.__setstate__()
IllConditionedPreconditionerWarning.__str__()
IllConditionedPreconditionerWarning.__suppress_context__
IllConditionedPreconditionerWarning.__traceback__
IllConditionedPreconditionerWarning.add_note()
IllConditionedPreconditionerWarning.args
IllConditionedPreconditionerWarning.with_traceback()
MatrixIllConditionedWarning
MatrixIllConditionedWarning.__cause__
MatrixIllConditionedWarning.__context__
MatrixIllConditionedWarning.__delattr__()
MatrixIllConditionedWarning.__getattribute__()
MatrixIllConditionedWarning.__reduce__()
MatrixIllConditionedWarning.__repr__()
MatrixIllConditionedWarning.__setattr__()
MatrixIllConditionedWarning.__setstate__()
MatrixIllConditionedWarning.__str__()
MatrixIllConditionedWarning.__suppress_context__
MatrixIllConditionedWarning.__traceback__
MatrixIllConditionedWarning.add_note()
MatrixIllConditionedWarning.args
MatrixIllConditionedWarning.with_traceback()
MaximumIterationWarning
MaximumIterationWarning.__cause__
MaximumIterationWarning.__context__
MaximumIterationWarning.__delattr__()
MaximumIterationWarning.__getattribute__()
MaximumIterationWarning.__reduce__()
MaximumIterationWarning.__repr__()
MaximumIterationWarning.__setattr__()
MaximumIterationWarning.__setstate__()
MaximumIterationWarning.__str__()
MaximumIterationWarning.__suppress_context__
MaximumIterationWarning.__traceback__
MaximumIterationWarning.add_note()
MaximumIterationWarning.args
MaximumIterationWarning.with_traceback()
PreconditionerNotPositiveDefiniteWarning
PreconditionerNotPositiveDefiniteWarning.__cause__
PreconditionerNotPositiveDefiniteWarning.__context__
PreconditionerNotPositiveDefiniteWarning.__delattr__()
PreconditionerNotPositiveDefiniteWarning.__getattribute__()
PreconditionerNotPositiveDefiniteWarning.__reduce__()
PreconditionerNotPositiveDefiniteWarning.__repr__()
PreconditionerNotPositiveDefiniteWarning.__setattr__()
PreconditionerNotPositiveDefiniteWarning.__setstate__()
PreconditionerNotPositiveDefiniteWarning.__str__()
PreconditionerNotPositiveDefiniteWarning.__suppress_context__
PreconditionerNotPositiveDefiniteWarning.__traceback__
PreconditionerNotPositiveDefiniteWarning.add_note()
PreconditionerNotPositiveDefiniteWarning.args
PreconditionerNotPositiveDefiniteWarning.with_traceback()
PreconditionerWarning
PreconditionerWarning.__cause__
PreconditionerWarning.__context__
PreconditionerWarning.__delattr__()
PreconditionerWarning.__getattribute__()
PreconditionerWarning.__reduce__()
PreconditionerWarning.__repr__()
PreconditionerWarning.__setattr__()
PreconditionerWarning.__setstate__()
PreconditionerWarning.__str__()
PreconditionerWarning.__suppress_context__
PreconditionerWarning.__traceback__
PreconditionerWarning.add_note()
PreconditionerWarning.args
PreconditionerWarning.with_traceback()
ScalarQuantityOutOfRangeWarning
ScalarQuantityOutOfRangeWarning.__cause__
ScalarQuantityOutOfRangeWarning.__context__
ScalarQuantityOutOfRangeWarning.__delattr__()
ScalarQuantityOutOfRangeWarning.__getattribute__()
ScalarQuantityOutOfRangeWarning.__reduce__()
ScalarQuantityOutOfRangeWarning.__repr__()
ScalarQuantityOutOfRangeWarning.__setattr__()
ScalarQuantityOutOfRangeWarning.__setstate__()
ScalarQuantityOutOfRangeWarning.__str__()
ScalarQuantityOutOfRangeWarning.__suppress_context__
ScalarQuantityOutOfRangeWarning.__traceback__
ScalarQuantityOutOfRangeWarning.add_note()
ScalarQuantityOutOfRangeWarning.args
ScalarQuantityOutOfRangeWarning.with_traceback()
Solver
SolverConvergenceWarning
SolverConvergenceWarning.__cause__
SolverConvergenceWarning.__context__
SolverConvergenceWarning.__delattr__()
SolverConvergenceWarning.__getattribute__()
SolverConvergenceWarning.__reduce__()
SolverConvergenceWarning.__repr__()
SolverConvergenceWarning.__setattr__()
SolverConvergenceWarning.__setstate__()
SolverConvergenceWarning.__str__()
SolverConvergenceWarning.__suppress_context__
SolverConvergenceWarning.__traceback__
SolverConvergenceWarning.add_note()
SolverConvergenceWarning.args
SolverConvergenceWarning.with_traceback()
StagnatedSolverWarning
StagnatedSolverWarning.__cause__
StagnatedSolverWarning.__context__
StagnatedSolverWarning.__delattr__()
StagnatedSolverWarning.__getattribute__()
StagnatedSolverWarning.__reduce__()
StagnatedSolverWarning.__repr__()
StagnatedSolverWarning.__setattr__()
StagnatedSolverWarning.__setstate__()
StagnatedSolverWarning.__str__()
StagnatedSolverWarning.__suppress_context__
StagnatedSolverWarning.__traceback__
StagnatedSolverWarning.add_note()
StagnatedSolverWarning.args
StagnatedSolverWarning.with_traceback()
- fipy.solvers.test module
- Module contents
DefaultAsymmetricSolver
DefaultSolver
DummySolver
GeneralSolver
IllConditionedPreconditionerWarning
IllConditionedPreconditionerWarning.__cause__
IllConditionedPreconditionerWarning.__context__
IllConditionedPreconditionerWarning.__delattr__()
IllConditionedPreconditionerWarning.__getattribute__()
IllConditionedPreconditionerWarning.__reduce__()
IllConditionedPreconditionerWarning.__repr__()
IllConditionedPreconditionerWarning.__setattr__()
IllConditionedPreconditionerWarning.__setstate__()
IllConditionedPreconditionerWarning.__str__()
IllConditionedPreconditionerWarning.__suppress_context__
IllConditionedPreconditionerWarning.__traceback__
IllConditionedPreconditionerWarning.add_note()
IllConditionedPreconditionerWarning.args
IllConditionedPreconditionerWarning.with_traceback()
LinearBicgSolver
LinearCGSSolver
LinearGMRESSolver
LinearLUSolver
LinearPCGSolver
MatrixIllConditionedWarning
MatrixIllConditionedWarning.__cause__
MatrixIllConditionedWarning.__context__
MatrixIllConditionedWarning.__delattr__()
MatrixIllConditionedWarning.__getattribute__()
MatrixIllConditionedWarning.__reduce__()
MatrixIllConditionedWarning.__repr__()
MatrixIllConditionedWarning.__setattr__()
MatrixIllConditionedWarning.__setstate__()
MatrixIllConditionedWarning.__str__()
MatrixIllConditionedWarning.__suppress_context__
MatrixIllConditionedWarning.__traceback__
MatrixIllConditionedWarning.add_note()
MatrixIllConditionedWarning.args
MatrixIllConditionedWarning.with_traceback()
MaximumIterationWarning
MaximumIterationWarning.__cause__
MaximumIterationWarning.__context__
MaximumIterationWarning.__delattr__()
MaximumIterationWarning.__getattribute__()
MaximumIterationWarning.__reduce__()
MaximumIterationWarning.__repr__()
MaximumIterationWarning.__setattr__()
MaximumIterationWarning.__setstate__()
MaximumIterationWarning.__str__()
MaximumIterationWarning.__suppress_context__
MaximumIterationWarning.__traceback__
MaximumIterationWarning.add_note()
MaximumIterationWarning.args
MaximumIterationWarning.with_traceback()
PreconditionerNotPositiveDefiniteWarning
PreconditionerNotPositiveDefiniteWarning.__cause__
PreconditionerNotPositiveDefiniteWarning.__context__
PreconditionerNotPositiveDefiniteWarning.__delattr__()
PreconditionerNotPositiveDefiniteWarning.__getattribute__()
PreconditionerNotPositiveDefiniteWarning.__reduce__()
PreconditionerNotPositiveDefiniteWarning.__repr__()
PreconditionerNotPositiveDefiniteWarning.__setattr__()
PreconditionerNotPositiveDefiniteWarning.__setstate__()
PreconditionerNotPositiveDefiniteWarning.__str__()
PreconditionerNotPositiveDefiniteWarning.__suppress_context__
PreconditionerNotPositiveDefiniteWarning.__traceback__
PreconditionerNotPositiveDefiniteWarning.add_note()
PreconditionerNotPositiveDefiniteWarning.args
PreconditionerNotPositiveDefiniteWarning.with_traceback()
PreconditionerWarning
PreconditionerWarning.__cause__
PreconditionerWarning.__context__
PreconditionerWarning.__delattr__()
PreconditionerWarning.__getattribute__()
PreconditionerWarning.__reduce__()
PreconditionerWarning.__repr__()
PreconditionerWarning.__setattr__()
PreconditionerWarning.__setstate__()
PreconditionerWarning.__str__()
PreconditionerWarning.__suppress_context__
PreconditionerWarning.__traceback__
PreconditionerWarning.add_note()
PreconditionerWarning.args
PreconditionerWarning.with_traceback()
ScalarQuantityOutOfRangeWarning
ScalarQuantityOutOfRangeWarning.__cause__
ScalarQuantityOutOfRangeWarning.__context__
ScalarQuantityOutOfRangeWarning.__delattr__()
ScalarQuantityOutOfRangeWarning.__getattribute__()
ScalarQuantityOutOfRangeWarning.__reduce__()
ScalarQuantityOutOfRangeWarning.__repr__()
ScalarQuantityOutOfRangeWarning.__setattr__()
ScalarQuantityOutOfRangeWarning.__setstate__()
ScalarQuantityOutOfRangeWarning.__str__()
ScalarQuantityOutOfRangeWarning.__suppress_context__
ScalarQuantityOutOfRangeWarning.__traceback__
ScalarQuantityOutOfRangeWarning.add_note()
ScalarQuantityOutOfRangeWarning.args
ScalarQuantityOutOfRangeWarning.with_traceback()
Solver
SolverConvergenceWarning
SolverConvergenceWarning.__cause__
SolverConvergenceWarning.__context__
SolverConvergenceWarning.__delattr__()
SolverConvergenceWarning.__getattribute__()
SolverConvergenceWarning.__reduce__()
SolverConvergenceWarning.__repr__()
SolverConvergenceWarning.__setattr__()
SolverConvergenceWarning.__setstate__()
SolverConvergenceWarning.__str__()
SolverConvergenceWarning.__suppress_context__
SolverConvergenceWarning.__traceback__
SolverConvergenceWarning.add_note()
SolverConvergenceWarning.args
SolverConvergenceWarning.with_traceback()
StagnatedSolverWarning
StagnatedSolverWarning.__cause__
StagnatedSolverWarning.__context__
StagnatedSolverWarning.__delattr__()
StagnatedSolverWarning.__getattribute__()
StagnatedSolverWarning.__reduce__()
StagnatedSolverWarning.__repr__()
StagnatedSolverWarning.__setattr__()
StagnatedSolverWarning.__setstate__()
StagnatedSolverWarning.__str__()
StagnatedSolverWarning.__suppress_context__
StagnatedSolverWarning.__traceback__
StagnatedSolverWarning.add_note()
StagnatedSolverWarning.args
StagnatedSolverWarning.with_traceback()
- Subpackages
- fipy.steppers package
- fipy.terms package
- Submodules
- fipy.terms.abstractBinaryTerm module
- fipy.terms.abstractConvectionTerm module
- fipy.terms.abstractDiffusionTerm module
- fipy.terms.abstractUpwindConvectionTerm module
- fipy.terms.advectionTerm module
AdvectionTerm
AdvectionTerm.RHSvector
AdvectionTerm.__add__()
AdvectionTerm.__and__()
AdvectionTerm.__div__()
AdvectionTerm.__eq__()
AdvectionTerm.__hash__()
AdvectionTerm.__mul__()
AdvectionTerm.__neg__()
AdvectionTerm.__pos__()
AdvectionTerm.__radd__()
AdvectionTerm.__rand__()
AdvectionTerm.__repr__()
AdvectionTerm.__rmul__()
AdvectionTerm.__rsub__()
AdvectionTerm.__sub__()
AdvectionTerm.__truediv__()
AdvectionTerm.cacheMatrix()
AdvectionTerm.cacheRHSvector()
AdvectionTerm.copy()
AdvectionTerm.getDefaultSolver()
AdvectionTerm.justErrorVector()
AdvectionTerm.justResidualVector()
AdvectionTerm.matrix
AdvectionTerm.residualVectorAndNorm()
AdvectionTerm.solve()
AdvectionTerm.sweep()
- fipy.terms.asymmetricConvectionTerm module
- fipy.terms.binaryTerm module
- fipy.terms.cellTerm module
CellTerm
CellTerm.RHSvector
CellTerm.__add__()
CellTerm.__and__()
CellTerm.__div__()
CellTerm.__eq__()
CellTerm.__hash__()
CellTerm.__mul__()
CellTerm.__neg__()
CellTerm.__pos__()
CellTerm.__radd__()
CellTerm.__rand__()
CellTerm.__repr__()
CellTerm.__rmul__()
CellTerm.__rsub__()
CellTerm.__sub__()
CellTerm.__truediv__()
CellTerm.cacheMatrix()
CellTerm.cacheRHSvector()
CellTerm.copy()
CellTerm.getDefaultSolver()
CellTerm.justErrorVector()
CellTerm.justResidualVector()
CellTerm.matrix
CellTerm.residualVectorAndNorm()
CellTerm.solve()
CellTerm.sweep()
- fipy.terms.centralDiffConvectionTerm module
CentralDifferenceConvectionTerm
CentralDifferenceConvectionTerm.RHSvector
CentralDifferenceConvectionTerm.__add__()
CentralDifferenceConvectionTerm.__and__()
CentralDifferenceConvectionTerm.__div__()
CentralDifferenceConvectionTerm.__eq__()
CentralDifferenceConvectionTerm.__hash__()
CentralDifferenceConvectionTerm.__mul__()
CentralDifferenceConvectionTerm.__neg__()
CentralDifferenceConvectionTerm.__pos__()
CentralDifferenceConvectionTerm.__radd__()
CentralDifferenceConvectionTerm.__rand__()
CentralDifferenceConvectionTerm.__repr__()
CentralDifferenceConvectionTerm.__rmul__()
CentralDifferenceConvectionTerm.__rsub__()
CentralDifferenceConvectionTerm.__sub__()
CentralDifferenceConvectionTerm.__truediv__()
CentralDifferenceConvectionTerm.cacheMatrix()
CentralDifferenceConvectionTerm.cacheRHSvector()
CentralDifferenceConvectionTerm.copy()
CentralDifferenceConvectionTerm.getDefaultSolver()
CentralDifferenceConvectionTerm.justErrorVector()
CentralDifferenceConvectionTerm.justResidualVector()
CentralDifferenceConvectionTerm.matrix
CentralDifferenceConvectionTerm.residualVectorAndNorm()
CentralDifferenceConvectionTerm.solve()
CentralDifferenceConvectionTerm.sweep()
- fipy.terms.coupledBinaryTerm module
- fipy.terms.diffusionTerm module
DiffusionTerm
DiffusionTerm.RHSvector
DiffusionTerm.__add__()
DiffusionTerm.__and__()
DiffusionTerm.__div__()
DiffusionTerm.__eq__()
DiffusionTerm.__hash__()
DiffusionTerm.__mul__()
DiffusionTerm.__neg__()
DiffusionTerm.__pos__()
DiffusionTerm.__radd__()
DiffusionTerm.__rand__()
DiffusionTerm.__repr__()
DiffusionTerm.__rmul__()
DiffusionTerm.__rsub__()
DiffusionTerm.__sub__()
DiffusionTerm.__truediv__()
DiffusionTerm.cacheMatrix()
DiffusionTerm.cacheRHSvector()
DiffusionTerm.copy()
DiffusionTerm.getDefaultSolver()
DiffusionTerm.justErrorVector()
DiffusionTerm.justResidualVector()
DiffusionTerm.matrix
DiffusionTerm.residualVectorAndNorm()
DiffusionTerm.solve()
DiffusionTerm.sweep()
DiffusionTermCorrection
DiffusionTermCorrection.RHSvector
DiffusionTermCorrection.__add__()
DiffusionTermCorrection.__and__()
DiffusionTermCorrection.__div__()
DiffusionTermCorrection.__eq__()
DiffusionTermCorrection.__hash__()
DiffusionTermCorrection.__mul__()
DiffusionTermCorrection.__neg__()
DiffusionTermCorrection.__pos__()
DiffusionTermCorrection.__radd__()
DiffusionTermCorrection.__rand__()
DiffusionTermCorrection.__repr__()
DiffusionTermCorrection.__rmul__()
DiffusionTermCorrection.__rsub__()
DiffusionTermCorrection.__sub__()
DiffusionTermCorrection.__truediv__()
DiffusionTermCorrection.cacheMatrix()
DiffusionTermCorrection.cacheRHSvector()
DiffusionTermCorrection.copy()
DiffusionTermCorrection.getDefaultSolver()
DiffusionTermCorrection.justErrorVector()
DiffusionTermCorrection.justResidualVector()
DiffusionTermCorrection.matrix
DiffusionTermCorrection.residualVectorAndNorm()
DiffusionTermCorrection.solve()
DiffusionTermCorrection.sweep()
DiffusionTermNoCorrection
DiffusionTermNoCorrection.RHSvector
DiffusionTermNoCorrection.__add__()
DiffusionTermNoCorrection.__and__()
DiffusionTermNoCorrection.__div__()
DiffusionTermNoCorrection.__eq__()
DiffusionTermNoCorrection.__hash__()
DiffusionTermNoCorrection.__mul__()
DiffusionTermNoCorrection.__neg__()
DiffusionTermNoCorrection.__pos__()
DiffusionTermNoCorrection.__radd__()
DiffusionTermNoCorrection.__rand__()
DiffusionTermNoCorrection.__repr__()
DiffusionTermNoCorrection.__rmul__()
DiffusionTermNoCorrection.__rsub__()
DiffusionTermNoCorrection.__sub__()
DiffusionTermNoCorrection.__truediv__()
DiffusionTermNoCorrection.cacheMatrix()
DiffusionTermNoCorrection.cacheRHSvector()
DiffusionTermNoCorrection.copy()
DiffusionTermNoCorrection.getDefaultSolver()
DiffusionTermNoCorrection.justErrorVector()
DiffusionTermNoCorrection.justResidualVector()
DiffusionTermNoCorrection.matrix
DiffusionTermNoCorrection.residualVectorAndNorm()
DiffusionTermNoCorrection.solve()
DiffusionTermNoCorrection.sweep()
- fipy.terms.diffusionTermCorrection module
DiffusionTermCorrection
DiffusionTermCorrection.RHSvector
DiffusionTermCorrection.__add__()
DiffusionTermCorrection.__and__()
DiffusionTermCorrection.__div__()
DiffusionTermCorrection.__eq__()
DiffusionTermCorrection.__hash__()
DiffusionTermCorrection.__mul__()
DiffusionTermCorrection.__neg__()
DiffusionTermCorrection.__pos__()
DiffusionTermCorrection.__radd__()
DiffusionTermCorrection.__rand__()
DiffusionTermCorrection.__repr__()
DiffusionTermCorrection.__rmul__()
DiffusionTermCorrection.__rsub__()
DiffusionTermCorrection.__sub__()
DiffusionTermCorrection.__truediv__()
DiffusionTermCorrection.cacheMatrix()
DiffusionTermCorrection.cacheRHSvector()
DiffusionTermCorrection.copy()
DiffusionTermCorrection.getDefaultSolver()
DiffusionTermCorrection.justErrorVector()
DiffusionTermCorrection.justResidualVector()
DiffusionTermCorrection.matrix
DiffusionTermCorrection.residualVectorAndNorm()
DiffusionTermCorrection.solve()
DiffusionTermCorrection.sweep()
- fipy.terms.diffusionTermNoCorrection module
DiffusionTermNoCorrection
DiffusionTermNoCorrection.RHSvector
DiffusionTermNoCorrection.__add__()
DiffusionTermNoCorrection.__and__()
DiffusionTermNoCorrection.__div__()
DiffusionTermNoCorrection.__eq__()
DiffusionTermNoCorrection.__hash__()
DiffusionTermNoCorrection.__mul__()
DiffusionTermNoCorrection.__neg__()
DiffusionTermNoCorrection.__pos__()
DiffusionTermNoCorrection.__radd__()
DiffusionTermNoCorrection.__rand__()
DiffusionTermNoCorrection.__repr__()
DiffusionTermNoCorrection.__rmul__()
DiffusionTermNoCorrection.__rsub__()
DiffusionTermNoCorrection.__sub__()
DiffusionTermNoCorrection.__truediv__()
DiffusionTermNoCorrection.cacheMatrix()
DiffusionTermNoCorrection.cacheRHSvector()
DiffusionTermNoCorrection.copy()
DiffusionTermNoCorrection.getDefaultSolver()
DiffusionTermNoCorrection.justErrorVector()
DiffusionTermNoCorrection.justResidualVector()
DiffusionTermNoCorrection.matrix
DiffusionTermNoCorrection.residualVectorAndNorm()
DiffusionTermNoCorrection.solve()
DiffusionTermNoCorrection.sweep()
- fipy.terms.explicitDiffusionTerm module
ExplicitDiffusionTerm
ExplicitDiffusionTerm.RHSvector
ExplicitDiffusionTerm.__add__()
ExplicitDiffusionTerm.__and__()
ExplicitDiffusionTerm.__div__()
ExplicitDiffusionTerm.__eq__()
ExplicitDiffusionTerm.__hash__()
ExplicitDiffusionTerm.__mul__()
ExplicitDiffusionTerm.__neg__()
ExplicitDiffusionTerm.__pos__()
ExplicitDiffusionTerm.__radd__()
ExplicitDiffusionTerm.__rand__()
ExplicitDiffusionTerm.__repr__()
ExplicitDiffusionTerm.__rmul__()
ExplicitDiffusionTerm.__rsub__()
ExplicitDiffusionTerm.__sub__()
ExplicitDiffusionTerm.__truediv__()
ExplicitDiffusionTerm.cacheMatrix()
ExplicitDiffusionTerm.cacheRHSvector()
ExplicitDiffusionTerm.copy()
ExplicitDiffusionTerm.getDefaultSolver()
ExplicitDiffusionTerm.justErrorVector()
ExplicitDiffusionTerm.justResidualVector()
ExplicitDiffusionTerm.matrix
ExplicitDiffusionTerm.residualVectorAndNorm()
ExplicitDiffusionTerm.solve()
ExplicitDiffusionTerm.sweep()
- fipy.terms.explicitSourceTerm module
- fipy.terms.explicitUpwindConvectionTerm module
ExplicitUpwindConvectionTerm
ExplicitUpwindConvectionTerm.RHSvector
ExplicitUpwindConvectionTerm.__add__()
ExplicitUpwindConvectionTerm.__and__()
ExplicitUpwindConvectionTerm.__div__()
ExplicitUpwindConvectionTerm.__eq__()
ExplicitUpwindConvectionTerm.__hash__()
ExplicitUpwindConvectionTerm.__mul__()
ExplicitUpwindConvectionTerm.__neg__()
ExplicitUpwindConvectionTerm.__pos__()
ExplicitUpwindConvectionTerm.__radd__()
ExplicitUpwindConvectionTerm.__rand__()
ExplicitUpwindConvectionTerm.__repr__()
ExplicitUpwindConvectionTerm.__rmul__()
ExplicitUpwindConvectionTerm.__rsub__()
ExplicitUpwindConvectionTerm.__sub__()
ExplicitUpwindConvectionTerm.__truediv__()
ExplicitUpwindConvectionTerm.cacheMatrix()
ExplicitUpwindConvectionTerm.cacheRHSvector()
ExplicitUpwindConvectionTerm.copy()
ExplicitUpwindConvectionTerm.getDefaultSolver()
ExplicitUpwindConvectionTerm.justErrorVector()
ExplicitUpwindConvectionTerm.justResidualVector()
ExplicitUpwindConvectionTerm.matrix
ExplicitUpwindConvectionTerm.residualVectorAndNorm()
ExplicitUpwindConvectionTerm.solve()
ExplicitUpwindConvectionTerm.sweep()
- fipy.terms.exponentialConvectionTerm module
ExponentialConvectionTerm
ExponentialConvectionTerm.RHSvector
ExponentialConvectionTerm.__add__()
ExponentialConvectionTerm.__and__()
ExponentialConvectionTerm.__div__()
ExponentialConvectionTerm.__eq__()
ExponentialConvectionTerm.__hash__()
ExponentialConvectionTerm.__mul__()
ExponentialConvectionTerm.__neg__()
ExponentialConvectionTerm.__pos__()
ExponentialConvectionTerm.__radd__()
ExponentialConvectionTerm.__rand__()
ExponentialConvectionTerm.__repr__()
ExponentialConvectionTerm.__rmul__()
ExponentialConvectionTerm.__rsub__()
ExponentialConvectionTerm.__sub__()
ExponentialConvectionTerm.__truediv__()
ExponentialConvectionTerm.cacheMatrix()
ExponentialConvectionTerm.cacheRHSvector()
ExponentialConvectionTerm.copy()
ExponentialConvectionTerm.getDefaultSolver()
ExponentialConvectionTerm.justErrorVector()
ExponentialConvectionTerm.justResidualVector()
ExponentialConvectionTerm.matrix
ExponentialConvectionTerm.residualVectorAndNorm()
ExponentialConvectionTerm.solve()
ExponentialConvectionTerm.sweep()
- fipy.terms.faceTerm module
FaceTerm
FaceTerm.RHSvector
FaceTerm.__add__()
FaceTerm.__and__()
FaceTerm.__div__()
FaceTerm.__eq__()
FaceTerm.__hash__()
FaceTerm.__mul__()
FaceTerm.__neg__()
FaceTerm.__pos__()
FaceTerm.__radd__()
FaceTerm.__rand__()
FaceTerm.__repr__()
FaceTerm.__rmul__()
FaceTerm.__rsub__()
FaceTerm.__sub__()
FaceTerm.__truediv__()
FaceTerm.cacheMatrix()
FaceTerm.cacheRHSvector()
FaceTerm.copy()
FaceTerm.getDefaultSolver()
FaceTerm.justErrorVector()
FaceTerm.justResidualVector()
FaceTerm.matrix
FaceTerm.residualVectorAndNorm()
FaceTerm.solve()
FaceTerm.sweep()
- fipy.terms.firstOrderAdvectionTerm module
FirstOrderAdvectionTerm
FirstOrderAdvectionTerm.RHSvector
FirstOrderAdvectionTerm.__add__()
FirstOrderAdvectionTerm.__and__()
FirstOrderAdvectionTerm.__div__()
FirstOrderAdvectionTerm.__eq__()
FirstOrderAdvectionTerm.__hash__()
FirstOrderAdvectionTerm.__mul__()
FirstOrderAdvectionTerm.__neg__()
FirstOrderAdvectionTerm.__pos__()
FirstOrderAdvectionTerm.__radd__()
FirstOrderAdvectionTerm.__rand__()
FirstOrderAdvectionTerm.__repr__()
FirstOrderAdvectionTerm.__rmul__()
FirstOrderAdvectionTerm.__rsub__()
FirstOrderAdvectionTerm.__sub__()
FirstOrderAdvectionTerm.__truediv__()
FirstOrderAdvectionTerm.cacheMatrix()
FirstOrderAdvectionTerm.cacheRHSvector()
FirstOrderAdvectionTerm.copy()
FirstOrderAdvectionTerm.getDefaultSolver()
FirstOrderAdvectionTerm.justErrorVector()
FirstOrderAdvectionTerm.justResidualVector()
FirstOrderAdvectionTerm.matrix
FirstOrderAdvectionTerm.residualVectorAndNorm()
FirstOrderAdvectionTerm.solve()
FirstOrderAdvectionTerm.sweep()
- fipy.terms.hybridConvectionTerm module
HybridConvectionTerm
HybridConvectionTerm.RHSvector
HybridConvectionTerm.__add__()
HybridConvectionTerm.__and__()
HybridConvectionTerm.__div__()
HybridConvectionTerm.__eq__()
HybridConvectionTerm.__hash__()
HybridConvectionTerm.__mul__()
HybridConvectionTerm.__neg__()
HybridConvectionTerm.__pos__()
HybridConvectionTerm.__radd__()
HybridConvectionTerm.__rand__()
HybridConvectionTerm.__repr__()
HybridConvectionTerm.__rmul__()
HybridConvectionTerm.__rsub__()
HybridConvectionTerm.__sub__()
HybridConvectionTerm.__truediv__()
HybridConvectionTerm.cacheMatrix()
HybridConvectionTerm.cacheRHSvector()
HybridConvectionTerm.copy()
HybridConvectionTerm.getDefaultSolver()
HybridConvectionTerm.justErrorVector()
HybridConvectionTerm.justResidualVector()
HybridConvectionTerm.matrix
HybridConvectionTerm.residualVectorAndNorm()
HybridConvectionTerm.solve()
HybridConvectionTerm.sweep()
- fipy.terms.implicitDiffusionTerm module
- fipy.terms.implicitSourceTerm module
ImplicitSourceTerm
ImplicitSourceTerm.RHSvector
ImplicitSourceTerm.__add__()
ImplicitSourceTerm.__and__()
ImplicitSourceTerm.__div__()
ImplicitSourceTerm.__eq__()
ImplicitSourceTerm.__hash__()
ImplicitSourceTerm.__mul__()
ImplicitSourceTerm.__neg__()
ImplicitSourceTerm.__pos__()
ImplicitSourceTerm.__radd__()
ImplicitSourceTerm.__rand__()
ImplicitSourceTerm.__repr__()
ImplicitSourceTerm.__rmul__()
ImplicitSourceTerm.__rsub__()
ImplicitSourceTerm.__sub__()
ImplicitSourceTerm.__truediv__()
ImplicitSourceTerm.cacheMatrix()
ImplicitSourceTerm.cacheRHSvector()
ImplicitSourceTerm.copy()
ImplicitSourceTerm.getDefaultSolver()
ImplicitSourceTerm.justErrorVector()
ImplicitSourceTerm.justResidualVector()
ImplicitSourceTerm.matrix
ImplicitSourceTerm.residualVectorAndNorm()
ImplicitSourceTerm.solve()
ImplicitSourceTerm.sweep()
- fipy.terms.nonDiffusionTerm module
- fipy.terms.powerLawConvectionTerm module
PowerLawConvectionTerm
PowerLawConvectionTerm.RHSvector
PowerLawConvectionTerm.__add__()
PowerLawConvectionTerm.__and__()
PowerLawConvectionTerm.__div__()
PowerLawConvectionTerm.__eq__()
PowerLawConvectionTerm.__hash__()
PowerLawConvectionTerm.__mul__()
PowerLawConvectionTerm.__neg__()
PowerLawConvectionTerm.__pos__()
PowerLawConvectionTerm.__radd__()
PowerLawConvectionTerm.__rand__()
PowerLawConvectionTerm.__repr__()
PowerLawConvectionTerm.__rmul__()
PowerLawConvectionTerm.__rsub__()
PowerLawConvectionTerm.__sub__()
PowerLawConvectionTerm.__truediv__()
PowerLawConvectionTerm.cacheMatrix()
PowerLawConvectionTerm.cacheRHSvector()
PowerLawConvectionTerm.copy()
PowerLawConvectionTerm.getDefaultSolver()
PowerLawConvectionTerm.justErrorVector()
PowerLawConvectionTerm.justResidualVector()
PowerLawConvectionTerm.matrix
PowerLawConvectionTerm.residualVectorAndNorm()
PowerLawConvectionTerm.solve()
PowerLawConvectionTerm.sweep()
- fipy.terms.residualTerm module
ResidualTerm
ResidualTerm.RHSvector
ResidualTerm.__add__()
ResidualTerm.__and__()
ResidualTerm.__div__()
ResidualTerm.__eq__()
ResidualTerm.__hash__()
ResidualTerm.__mul__()
ResidualTerm.__neg__()
ResidualTerm.__pos__()
ResidualTerm.__radd__()
ResidualTerm.__rand__()
ResidualTerm.__repr__()
ResidualTerm.__rmul__()
ResidualTerm.__rsub__()
ResidualTerm.__sub__()
ResidualTerm.__truediv__()
ResidualTerm.cacheMatrix()
ResidualTerm.cacheRHSvector()
ResidualTerm.copy()
ResidualTerm.getDefaultSolver()
ResidualTerm.justErrorVector()
ResidualTerm.justResidualVector()
ResidualTerm.matrix
ResidualTerm.residualVectorAndNorm()
ResidualTerm.solve()
ResidualTerm.sweep()
- fipy.terms.sourceTerm module
SourceTerm
SourceTerm.RHSvector
SourceTerm.__add__()
SourceTerm.__and__()
SourceTerm.__div__()
SourceTerm.__eq__()
SourceTerm.__hash__()
SourceTerm.__mul__()
SourceTerm.__neg__()
SourceTerm.__pos__()
SourceTerm.__radd__()
SourceTerm.__rand__()
SourceTerm.__repr__()
SourceTerm.__rmul__()
SourceTerm.__rsub__()
SourceTerm.__sub__()
SourceTerm.__truediv__()
SourceTerm.cacheMatrix()
SourceTerm.cacheRHSvector()
SourceTerm.copy()
SourceTerm.getDefaultSolver()
SourceTerm.justErrorVector()
SourceTerm.justResidualVector()
SourceTerm.matrix
SourceTerm.residualVectorAndNorm()
SourceTerm.solve()
SourceTerm.sweep()
- fipy.terms.term module
Term
Term.RHSvector
Term.__add__()
Term.__and__()
Term.__div__()
Term.__eq__()
Term.__hash__()
Term.__mul__()
Term.__neg__()
Term.__pos__()
Term.__radd__()
Term.__rand__()
Term.__repr__()
Term.__rmul__()
Term.__rsub__()
Term.__sub__()
Term.__truediv__()
Term.cacheMatrix()
Term.cacheRHSvector()
Term.copy()
Term.getDefaultSolver()
Term.justErrorVector()
Term.justResidualVector()
Term.matrix
Term.residualVectorAndNorm()
Term.solve()
Term.sweep()
- fipy.terms.test module
- fipy.terms.transientTerm module
TransientTerm
TransientTerm.RHSvector
TransientTerm.__add__()
TransientTerm.__and__()
TransientTerm.__div__()
TransientTerm.__eq__()
TransientTerm.__hash__()
TransientTerm.__mul__()
TransientTerm.__neg__()
TransientTerm.__pos__()
TransientTerm.__radd__()
TransientTerm.__rand__()
TransientTerm.__repr__()
TransientTerm.__rmul__()
TransientTerm.__rsub__()
TransientTerm.__sub__()
TransientTerm.__truediv__()
TransientTerm.cacheMatrix()
TransientTerm.cacheRHSvector()
TransientTerm.copy()
TransientTerm.getDefaultSolver()
TransientTerm.justErrorVector()
TransientTerm.justResidualVector()
TransientTerm.matrix
TransientTerm.residualVectorAndNorm()
TransientTerm.solve()
TransientTerm.sweep()
- fipy.terms.unaryTerm module
- fipy.terms.upwindConvectionTerm module
UpwindConvectionTerm
UpwindConvectionTerm.RHSvector
UpwindConvectionTerm.__add__()
UpwindConvectionTerm.__and__()
UpwindConvectionTerm.__div__()
UpwindConvectionTerm.__eq__()
UpwindConvectionTerm.__hash__()
UpwindConvectionTerm.__mul__()
UpwindConvectionTerm.__neg__()
UpwindConvectionTerm.__pos__()
UpwindConvectionTerm.__radd__()
UpwindConvectionTerm.__rand__()
UpwindConvectionTerm.__repr__()
UpwindConvectionTerm.__rmul__()
UpwindConvectionTerm.__rsub__()
UpwindConvectionTerm.__sub__()
UpwindConvectionTerm.__truediv__()
UpwindConvectionTerm.cacheMatrix()
UpwindConvectionTerm.cacheRHSvector()
UpwindConvectionTerm.copy()
UpwindConvectionTerm.getDefaultSolver()
UpwindConvectionTerm.justErrorVector()
UpwindConvectionTerm.justResidualVector()
UpwindConvectionTerm.matrix
UpwindConvectionTerm.residualVectorAndNorm()
UpwindConvectionTerm.solve()
UpwindConvectionTerm.sweep()
- fipy.terms.vanLeerConvectionTerm module
VanLeerConvectionTerm
VanLeerConvectionTerm.RHSvector
VanLeerConvectionTerm.__add__()
VanLeerConvectionTerm.__and__()
VanLeerConvectionTerm.__div__()
VanLeerConvectionTerm.__eq__()
VanLeerConvectionTerm.__hash__()
VanLeerConvectionTerm.__mul__()
VanLeerConvectionTerm.__neg__()
VanLeerConvectionTerm.__pos__()
VanLeerConvectionTerm.__radd__()
VanLeerConvectionTerm.__rand__()
VanLeerConvectionTerm.__repr__()
VanLeerConvectionTerm.__rmul__()
VanLeerConvectionTerm.__rsub__()
VanLeerConvectionTerm.__sub__()
VanLeerConvectionTerm.__truediv__()
VanLeerConvectionTerm.cacheMatrix()
VanLeerConvectionTerm.cacheRHSvector()
VanLeerConvectionTerm.copy()
VanLeerConvectionTerm.getDefaultSolver()
VanLeerConvectionTerm.justErrorVector()
VanLeerConvectionTerm.justResidualVector()
VanLeerConvectionTerm.matrix
VanLeerConvectionTerm.residualVectorAndNorm()
VanLeerConvectionTerm.solve()
VanLeerConvectionTerm.sweep()
- Module contents
AbstractBaseClassError
AbstractBaseClassError.__cause__
AbstractBaseClassError.__context__
AbstractBaseClassError.__delattr__()
AbstractBaseClassError.__getattribute__()
AbstractBaseClassError.__reduce__()
AbstractBaseClassError.__repr__()
AbstractBaseClassError.__setattr__()
AbstractBaseClassError.__setstate__()
AbstractBaseClassError.__str__()
AbstractBaseClassError.__suppress_context__
AbstractBaseClassError.__traceback__
AbstractBaseClassError.add_note()
AbstractBaseClassError.args
AbstractBaseClassError.with_traceback()
AdvectionTerm
AdvectionTerm.RHSvector
AdvectionTerm.__add__()
AdvectionTerm.__and__()
AdvectionTerm.__div__()
AdvectionTerm.__eq__()
AdvectionTerm.__hash__()
AdvectionTerm.__mul__()
AdvectionTerm.__neg__()
AdvectionTerm.__pos__()
AdvectionTerm.__radd__()
AdvectionTerm.__rand__()
AdvectionTerm.__repr__()
AdvectionTerm.__rmul__()
AdvectionTerm.__rsub__()
AdvectionTerm.__sub__()
AdvectionTerm.__truediv__()
AdvectionTerm.cacheMatrix()
AdvectionTerm.cacheRHSvector()
AdvectionTerm.copy()
AdvectionTerm.getDefaultSolver()
AdvectionTerm.justErrorVector()
AdvectionTerm.justResidualVector()
AdvectionTerm.matrix
AdvectionTerm.residualVectorAndNorm()
AdvectionTerm.solve()
AdvectionTerm.sweep()
CentralDifferenceConvectionTerm
CentralDifferenceConvectionTerm.RHSvector
CentralDifferenceConvectionTerm.__add__()
CentralDifferenceConvectionTerm.__and__()
CentralDifferenceConvectionTerm.__div__()
CentralDifferenceConvectionTerm.__eq__()
CentralDifferenceConvectionTerm.__hash__()
CentralDifferenceConvectionTerm.__mul__()
CentralDifferenceConvectionTerm.__neg__()
CentralDifferenceConvectionTerm.__pos__()
CentralDifferenceConvectionTerm.__radd__()
CentralDifferenceConvectionTerm.__rand__()
CentralDifferenceConvectionTerm.__repr__()
CentralDifferenceConvectionTerm.__rmul__()
CentralDifferenceConvectionTerm.__rsub__()
CentralDifferenceConvectionTerm.__sub__()
CentralDifferenceConvectionTerm.__truediv__()
CentralDifferenceConvectionTerm.cacheMatrix()
CentralDifferenceConvectionTerm.cacheRHSvector()
CentralDifferenceConvectionTerm.copy()
CentralDifferenceConvectionTerm.getDefaultSolver()
CentralDifferenceConvectionTerm.justErrorVector()
CentralDifferenceConvectionTerm.justResidualVector()
CentralDifferenceConvectionTerm.matrix
CentralDifferenceConvectionTerm.residualVectorAndNorm()
CentralDifferenceConvectionTerm.solve()
CentralDifferenceConvectionTerm.sweep()
ConvectionTerm
DiffusionTerm
DiffusionTerm.RHSvector
DiffusionTerm.__add__()
DiffusionTerm.__and__()
DiffusionTerm.__div__()
DiffusionTerm.__eq__()
DiffusionTerm.__hash__()
DiffusionTerm.__mul__()
DiffusionTerm.__neg__()
DiffusionTerm.__pos__()
DiffusionTerm.__radd__()
DiffusionTerm.__rand__()
DiffusionTerm.__repr__()
DiffusionTerm.__rmul__()
DiffusionTerm.__rsub__()
DiffusionTerm.__sub__()
DiffusionTerm.__truediv__()
DiffusionTerm.cacheMatrix()
DiffusionTerm.cacheRHSvector()
DiffusionTerm.copy()
DiffusionTerm.getDefaultSolver()
DiffusionTerm.justErrorVector()
DiffusionTerm.justResidualVector()
DiffusionTerm.matrix
DiffusionTerm.residualVectorAndNorm()
DiffusionTerm.solve()
DiffusionTerm.sweep()
DiffusionTermCorrection
DiffusionTermCorrection.RHSvector
DiffusionTermCorrection.__add__()
DiffusionTermCorrection.__and__()
DiffusionTermCorrection.__div__()
DiffusionTermCorrection.__eq__()
DiffusionTermCorrection.__hash__()
DiffusionTermCorrection.__mul__()
DiffusionTermCorrection.__neg__()
DiffusionTermCorrection.__pos__()
DiffusionTermCorrection.__radd__()
DiffusionTermCorrection.__rand__()
DiffusionTermCorrection.__repr__()
DiffusionTermCorrection.__rmul__()
DiffusionTermCorrection.__rsub__()
DiffusionTermCorrection.__sub__()
DiffusionTermCorrection.__truediv__()
DiffusionTermCorrection.cacheMatrix()
DiffusionTermCorrection.cacheRHSvector()
DiffusionTermCorrection.copy()
DiffusionTermCorrection.getDefaultSolver()
DiffusionTermCorrection.justErrorVector()
DiffusionTermCorrection.justResidualVector()
DiffusionTermCorrection.matrix
DiffusionTermCorrection.residualVectorAndNorm()
DiffusionTermCorrection.solve()
DiffusionTermCorrection.sweep()
DiffusionTermNoCorrection
DiffusionTermNoCorrection.RHSvector
DiffusionTermNoCorrection.__add__()
DiffusionTermNoCorrection.__and__()
DiffusionTermNoCorrection.__div__()
DiffusionTermNoCorrection.__eq__()
DiffusionTermNoCorrection.__hash__()
DiffusionTermNoCorrection.__mul__()
DiffusionTermNoCorrection.__neg__()
DiffusionTermNoCorrection.__pos__()
DiffusionTermNoCorrection.__radd__()
DiffusionTermNoCorrection.__rand__()
DiffusionTermNoCorrection.__repr__()
DiffusionTermNoCorrection.__rmul__()
DiffusionTermNoCorrection.__rsub__()
DiffusionTermNoCorrection.__sub__()
DiffusionTermNoCorrection.__truediv__()
DiffusionTermNoCorrection.cacheMatrix()
DiffusionTermNoCorrection.cacheRHSvector()
DiffusionTermNoCorrection.copy()
DiffusionTermNoCorrection.getDefaultSolver()
DiffusionTermNoCorrection.justErrorVector()
DiffusionTermNoCorrection.justResidualVector()
DiffusionTermNoCorrection.matrix
DiffusionTermNoCorrection.residualVectorAndNorm()
DiffusionTermNoCorrection.solve()
DiffusionTermNoCorrection.sweep()
ExplicitDiffusionTerm
ExplicitDiffusionTerm.RHSvector
ExplicitDiffusionTerm.__add__()
ExplicitDiffusionTerm.__and__()
ExplicitDiffusionTerm.__div__()
ExplicitDiffusionTerm.__eq__()
ExplicitDiffusionTerm.__hash__()
ExplicitDiffusionTerm.__mul__()
ExplicitDiffusionTerm.__neg__()
ExplicitDiffusionTerm.__pos__()
ExplicitDiffusionTerm.__radd__()
ExplicitDiffusionTerm.__rand__()
ExplicitDiffusionTerm.__repr__()
ExplicitDiffusionTerm.__rmul__()
ExplicitDiffusionTerm.__rsub__()
ExplicitDiffusionTerm.__sub__()
ExplicitDiffusionTerm.__truediv__()
ExplicitDiffusionTerm.cacheMatrix()
ExplicitDiffusionTerm.cacheRHSvector()
ExplicitDiffusionTerm.copy()
ExplicitDiffusionTerm.getDefaultSolver()
ExplicitDiffusionTerm.justErrorVector()
ExplicitDiffusionTerm.justResidualVector()
ExplicitDiffusionTerm.matrix
ExplicitDiffusionTerm.residualVectorAndNorm()
ExplicitDiffusionTerm.solve()
ExplicitDiffusionTerm.sweep()
ExplicitUpwindConvectionTerm
ExplicitUpwindConvectionTerm.RHSvector
ExplicitUpwindConvectionTerm.__add__()
ExplicitUpwindConvectionTerm.__and__()
ExplicitUpwindConvectionTerm.__div__()
ExplicitUpwindConvectionTerm.__eq__()
ExplicitUpwindConvectionTerm.__hash__()
ExplicitUpwindConvectionTerm.__mul__()
ExplicitUpwindConvectionTerm.__neg__()
ExplicitUpwindConvectionTerm.__pos__()
ExplicitUpwindConvectionTerm.__radd__()
ExplicitUpwindConvectionTerm.__rand__()
ExplicitUpwindConvectionTerm.__repr__()
ExplicitUpwindConvectionTerm.__rmul__()
ExplicitUpwindConvectionTerm.__rsub__()
ExplicitUpwindConvectionTerm.__sub__()
ExplicitUpwindConvectionTerm.__truediv__()
ExplicitUpwindConvectionTerm.cacheMatrix()
ExplicitUpwindConvectionTerm.cacheRHSvector()
ExplicitUpwindConvectionTerm.copy()
ExplicitUpwindConvectionTerm.getDefaultSolver()
ExplicitUpwindConvectionTerm.justErrorVector()
ExplicitUpwindConvectionTerm.justResidualVector()
ExplicitUpwindConvectionTerm.matrix
ExplicitUpwindConvectionTerm.residualVectorAndNorm()
ExplicitUpwindConvectionTerm.solve()
ExplicitUpwindConvectionTerm.sweep()
ExplicitVariableError
ExplicitVariableError.__cause__
ExplicitVariableError.__context__
ExplicitVariableError.__delattr__()
ExplicitVariableError.__getattribute__()
ExplicitVariableError.__reduce__()
ExplicitVariableError.__repr__()
ExplicitVariableError.__setattr__()
ExplicitVariableError.__setstate__()
ExplicitVariableError.__str__()
ExplicitVariableError.__suppress_context__
ExplicitVariableError.__traceback__
ExplicitVariableError.add_note()
ExplicitVariableError.args
ExplicitVariableError.with_traceback()
ExponentialConvectionTerm
ExponentialConvectionTerm.RHSvector
ExponentialConvectionTerm.__add__()
ExponentialConvectionTerm.__and__()
ExponentialConvectionTerm.__div__()
ExponentialConvectionTerm.__eq__()
ExponentialConvectionTerm.__hash__()
ExponentialConvectionTerm.__mul__()
ExponentialConvectionTerm.__neg__()
ExponentialConvectionTerm.__pos__()
ExponentialConvectionTerm.__radd__()
ExponentialConvectionTerm.__rand__()
ExponentialConvectionTerm.__repr__()
ExponentialConvectionTerm.__rmul__()
ExponentialConvectionTerm.__rsub__()
ExponentialConvectionTerm.__sub__()
ExponentialConvectionTerm.__truediv__()
ExponentialConvectionTerm.cacheMatrix()
ExponentialConvectionTerm.cacheRHSvector()
ExponentialConvectionTerm.copy()
ExponentialConvectionTerm.getDefaultSolver()
ExponentialConvectionTerm.justErrorVector()
ExponentialConvectionTerm.justResidualVector()
ExponentialConvectionTerm.matrix
ExponentialConvectionTerm.residualVectorAndNorm()
ExponentialConvectionTerm.solve()
ExponentialConvectionTerm.sweep()
FirstOrderAdvectionTerm
FirstOrderAdvectionTerm.RHSvector
FirstOrderAdvectionTerm.__add__()
FirstOrderAdvectionTerm.__and__()
FirstOrderAdvectionTerm.__div__()
FirstOrderAdvectionTerm.__eq__()
FirstOrderAdvectionTerm.__hash__()
FirstOrderAdvectionTerm.__mul__()
FirstOrderAdvectionTerm.__neg__()
FirstOrderAdvectionTerm.__pos__()
FirstOrderAdvectionTerm.__radd__()
FirstOrderAdvectionTerm.__rand__()
FirstOrderAdvectionTerm.__repr__()
FirstOrderAdvectionTerm.__rmul__()
FirstOrderAdvectionTerm.__rsub__()
FirstOrderAdvectionTerm.__sub__()
FirstOrderAdvectionTerm.__truediv__()
FirstOrderAdvectionTerm.cacheMatrix()
FirstOrderAdvectionTerm.cacheRHSvector()
FirstOrderAdvectionTerm.copy()
FirstOrderAdvectionTerm.getDefaultSolver()
FirstOrderAdvectionTerm.justErrorVector()
FirstOrderAdvectionTerm.justResidualVector()
FirstOrderAdvectionTerm.matrix
FirstOrderAdvectionTerm.residualVectorAndNorm()
FirstOrderAdvectionTerm.solve()
FirstOrderAdvectionTerm.sweep()
HybridConvectionTerm
HybridConvectionTerm.RHSvector
HybridConvectionTerm.__add__()
HybridConvectionTerm.__and__()
HybridConvectionTerm.__div__()
HybridConvectionTerm.__eq__()
HybridConvectionTerm.__hash__()
HybridConvectionTerm.__mul__()
HybridConvectionTerm.__neg__()
HybridConvectionTerm.__pos__()
HybridConvectionTerm.__radd__()
HybridConvectionTerm.__rand__()
HybridConvectionTerm.__repr__()
HybridConvectionTerm.__rmul__()
HybridConvectionTerm.__rsub__()
HybridConvectionTerm.__sub__()
HybridConvectionTerm.__truediv__()
HybridConvectionTerm.cacheMatrix()
HybridConvectionTerm.cacheRHSvector()
HybridConvectionTerm.copy()
HybridConvectionTerm.getDefaultSolver()
HybridConvectionTerm.justErrorVector()
HybridConvectionTerm.justResidualVector()
HybridConvectionTerm.matrix
HybridConvectionTerm.residualVectorAndNorm()
HybridConvectionTerm.solve()
HybridConvectionTerm.sweep()
ImplicitDiffusionTerm
ImplicitSourceTerm
ImplicitSourceTerm.RHSvector
ImplicitSourceTerm.__add__()
ImplicitSourceTerm.__and__()
ImplicitSourceTerm.__div__()
ImplicitSourceTerm.__eq__()
ImplicitSourceTerm.__hash__()
ImplicitSourceTerm.__mul__()
ImplicitSourceTerm.__neg__()
ImplicitSourceTerm.__pos__()
ImplicitSourceTerm.__radd__()
ImplicitSourceTerm.__rand__()
ImplicitSourceTerm.__repr__()
ImplicitSourceTerm.__rmul__()
ImplicitSourceTerm.__rsub__()
ImplicitSourceTerm.__sub__()
ImplicitSourceTerm.__truediv__()
ImplicitSourceTerm.cacheMatrix()
ImplicitSourceTerm.cacheRHSvector()
ImplicitSourceTerm.copy()
ImplicitSourceTerm.getDefaultSolver()
ImplicitSourceTerm.justErrorVector()
ImplicitSourceTerm.justResidualVector()
ImplicitSourceTerm.matrix
ImplicitSourceTerm.residualVectorAndNorm()
ImplicitSourceTerm.solve()
ImplicitSourceTerm.sweep()
IncorrectSolutionVariable
IncorrectSolutionVariable.__cause__
IncorrectSolutionVariable.__context__
IncorrectSolutionVariable.__delattr__()
IncorrectSolutionVariable.__getattribute__()
IncorrectSolutionVariable.__reduce__()
IncorrectSolutionVariable.__repr__()
IncorrectSolutionVariable.__setattr__()
IncorrectSolutionVariable.__setstate__()
IncorrectSolutionVariable.__str__()
IncorrectSolutionVariable.__suppress_context__
IncorrectSolutionVariable.__traceback__
IncorrectSolutionVariable.add_note()
IncorrectSolutionVariable.args
IncorrectSolutionVariable.with_traceback()
PowerLawConvectionTerm
PowerLawConvectionTerm.RHSvector
PowerLawConvectionTerm.__add__()
PowerLawConvectionTerm.__and__()
PowerLawConvectionTerm.__div__()
PowerLawConvectionTerm.__eq__()
PowerLawConvectionTerm.__hash__()
PowerLawConvectionTerm.__mul__()
PowerLawConvectionTerm.__neg__()
PowerLawConvectionTerm.__pos__()
PowerLawConvectionTerm.__radd__()
PowerLawConvectionTerm.__rand__()
PowerLawConvectionTerm.__repr__()
PowerLawConvectionTerm.__rmul__()
PowerLawConvectionTerm.__rsub__()
PowerLawConvectionTerm.__sub__()
PowerLawConvectionTerm.__truediv__()
PowerLawConvectionTerm.cacheMatrix()
PowerLawConvectionTerm.cacheRHSvector()
PowerLawConvectionTerm.copy()
PowerLawConvectionTerm.getDefaultSolver()
PowerLawConvectionTerm.justErrorVector()
PowerLawConvectionTerm.justResidualVector()
PowerLawConvectionTerm.matrix
PowerLawConvectionTerm.residualVectorAndNorm()
PowerLawConvectionTerm.solve()
PowerLawConvectionTerm.sweep()
ResidualTerm
ResidualTerm.RHSvector
ResidualTerm.__add__()
ResidualTerm.__and__()
ResidualTerm.__div__()
ResidualTerm.__eq__()
ResidualTerm.__hash__()
ResidualTerm.__mul__()
ResidualTerm.__neg__()
ResidualTerm.__pos__()
ResidualTerm.__radd__()
ResidualTerm.__rand__()
ResidualTerm.__repr__()
ResidualTerm.__rmul__()
ResidualTerm.__rsub__()
ResidualTerm.__sub__()
ResidualTerm.__truediv__()
ResidualTerm.cacheMatrix()
ResidualTerm.cacheRHSvector()
ResidualTerm.copy()
ResidualTerm.getDefaultSolver()
ResidualTerm.justErrorVector()
ResidualTerm.justResidualVector()
ResidualTerm.matrix
ResidualTerm.residualVectorAndNorm()
ResidualTerm.solve()
ResidualTerm.sweep()
SolutionVariableNumberError
SolutionVariableNumberError.__cause__
SolutionVariableNumberError.__context__
SolutionVariableNumberError.__delattr__()
SolutionVariableNumberError.__getattribute__()
SolutionVariableNumberError.__reduce__()
SolutionVariableNumberError.__repr__()
SolutionVariableNumberError.__setattr__()
SolutionVariableNumberError.__setstate__()
SolutionVariableNumberError.__str__()
SolutionVariableNumberError.__suppress_context__
SolutionVariableNumberError.__traceback__
SolutionVariableNumberError.add_note()
SolutionVariableNumberError.args
SolutionVariableNumberError.with_traceback()
SolutionVariableRequiredError
SolutionVariableRequiredError.__cause__
SolutionVariableRequiredError.__context__
SolutionVariableRequiredError.__delattr__()
SolutionVariableRequiredError.__getattribute__()
SolutionVariableRequiredError.__reduce__()
SolutionVariableRequiredError.__repr__()
SolutionVariableRequiredError.__setattr__()
SolutionVariableRequiredError.__setstate__()
SolutionVariableRequiredError.__str__()
SolutionVariableRequiredError.__suppress_context__
SolutionVariableRequiredError.__traceback__
SolutionVariableRequiredError.add_note()
SolutionVariableRequiredError.args
SolutionVariableRequiredError.with_traceback()
TermMultiplyError
TermMultiplyError.__cause__
TermMultiplyError.__context__
TermMultiplyError.__delattr__()
TermMultiplyError.__getattribute__()
TermMultiplyError.__reduce__()
TermMultiplyError.__repr__()
TermMultiplyError.__setattr__()
TermMultiplyError.__setstate__()
TermMultiplyError.__str__()
TermMultiplyError.__suppress_context__
TermMultiplyError.__traceback__
TermMultiplyError.add_note()
TermMultiplyError.args
TermMultiplyError.with_traceback()
TransientTerm
TransientTerm.RHSvector
TransientTerm.__add__()
TransientTerm.__and__()
TransientTerm.__div__()
TransientTerm.__eq__()
TransientTerm.__hash__()
TransientTerm.__mul__()
TransientTerm.__neg__()
TransientTerm.__pos__()
TransientTerm.__radd__()
TransientTerm.__rand__()
TransientTerm.__repr__()
TransientTerm.__rmul__()
TransientTerm.__rsub__()
TransientTerm.__sub__()
TransientTerm.__truediv__()
TransientTerm.cacheMatrix()
TransientTerm.cacheRHSvector()
TransientTerm.copy()
TransientTerm.getDefaultSolver()
TransientTerm.justErrorVector()
TransientTerm.justResidualVector()
TransientTerm.matrix
TransientTerm.residualVectorAndNorm()
TransientTerm.solve()
TransientTerm.sweep()
UpwindConvectionTerm
UpwindConvectionTerm.RHSvector
UpwindConvectionTerm.__add__()
UpwindConvectionTerm.__and__()
UpwindConvectionTerm.__div__()
UpwindConvectionTerm.__eq__()
UpwindConvectionTerm.__hash__()
UpwindConvectionTerm.__mul__()
UpwindConvectionTerm.__neg__()
UpwindConvectionTerm.__pos__()
UpwindConvectionTerm.__radd__()
UpwindConvectionTerm.__rand__()
UpwindConvectionTerm.__repr__()
UpwindConvectionTerm.__rmul__()
UpwindConvectionTerm.__rsub__()
UpwindConvectionTerm.__sub__()
UpwindConvectionTerm.__truediv__()
UpwindConvectionTerm.cacheMatrix()
UpwindConvectionTerm.cacheRHSvector()
UpwindConvectionTerm.copy()
UpwindConvectionTerm.getDefaultSolver()
UpwindConvectionTerm.justErrorVector()
UpwindConvectionTerm.justResidualVector()
UpwindConvectionTerm.matrix
UpwindConvectionTerm.residualVectorAndNorm()
UpwindConvectionTerm.solve()
UpwindConvectionTerm.sweep()
VanLeerConvectionTerm
VanLeerConvectionTerm.RHSvector
VanLeerConvectionTerm.__add__()
VanLeerConvectionTerm.__and__()
VanLeerConvectionTerm.__div__()
VanLeerConvectionTerm.__eq__()
VanLeerConvectionTerm.__hash__()
VanLeerConvectionTerm.__mul__()
VanLeerConvectionTerm.__neg__()
VanLeerConvectionTerm.__pos__()
VanLeerConvectionTerm.__radd__()
VanLeerConvectionTerm.__rand__()
VanLeerConvectionTerm.__repr__()
VanLeerConvectionTerm.__rmul__()
VanLeerConvectionTerm.__rsub__()
VanLeerConvectionTerm.__sub__()
VanLeerConvectionTerm.__truediv__()
VanLeerConvectionTerm.cacheMatrix()
VanLeerConvectionTerm.cacheRHSvector()
VanLeerConvectionTerm.copy()
VanLeerConvectionTerm.getDefaultSolver()
VanLeerConvectionTerm.justErrorVector()
VanLeerConvectionTerm.justResidualVector()
VanLeerConvectionTerm.matrix
VanLeerConvectionTerm.residualVectorAndNorm()
VanLeerConvectionTerm.solve()
VanLeerConvectionTerm.sweep()
VectorCoeffError
VectorCoeffError.__cause__
VectorCoeffError.__context__
VectorCoeffError.__delattr__()
VectorCoeffError.__getattribute__()
VectorCoeffError.__reduce__()
VectorCoeffError.__repr__()
VectorCoeffError.__setattr__()
VectorCoeffError.__setstate__()
VectorCoeffError.__str__()
VectorCoeffError.__suppress_context__
VectorCoeffError.__traceback__
VectorCoeffError.add_note()
VectorCoeffError.args
VectorCoeffError.with_traceback()
- fipy.tests package
- fipy.tools package
- Subpackages
- Submodules
- fipy.tools.debug module
- fipy.tools.decorators module
- fipy.tools.dump module
- fipy.tools.inline module
- fipy.tools.numerix module
L1norm()
L2norm()
LINFnorm()
all()
allclose()
allequal()
dot()
dtype
dtype.__bool__()
dtype.__eq__()
dtype.__ge__()
dtype.__getitem__()
dtype.__gt__()
dtype.__hash__()
dtype.__le__()
dtype.__len__()
dtype.__lt__()
dtype.__mul__()
dtype.__ne__()
dtype.__reduce__()
dtype.__repr__()
dtype.__rmul__()
dtype.__setstate__()
dtype.__str__()
dtype.alignment
dtype.base
dtype.byteorder
dtype.char
dtype.descr
dtype.fields
dtype.flags
dtype.hasobject
dtype.isalignedstruct
dtype.isbuiltin
dtype.isnative
dtype.itemsize
dtype.kind
dtype.metadata
dtype.name
dtype.names
dtype.ndim
dtype.newbyteorder()
dtype.num
dtype.shape
dtype.str
dtype.subdtype
dtype.type
getShape()
getUnit()
isFloat()
isInt()
isclose()
nearest()
put()
rank()
reshape()
sqrtDot()
sum()
take()
tostring()
- fipy.tools.parser module
- fipy.tools.sharedtempfile module
- fipy.tools.test module
- fipy.tools.vector module
- fipy.tools.version module
- fipy.tools.vitals module
Vitals
Vitals.ATTRIBUTE_NODE
Vitals.CDATA_SECTION_NODE
Vitals.COMMENT_NODE
Vitals.DOCUMENT_FRAGMENT_NODE
Vitals.DOCUMENT_NODE
Vitals.DOCUMENT_TYPE_NODE
Vitals.ELEMENT_NODE
Vitals.ENTITY_NODE
Vitals.ENTITY_REFERENCE_NODE
Vitals.NOTATION_NODE
Vitals.PROCESSING_INSTRUCTION_NODE
Vitals.TEXT_NODE
Vitals.__slots__
Vitals.__str__()
Vitals.actualEncoding
Vitals.appendChild()
Vitals.appendInfo()
Vitals.async_
Vitals.attributes
Vitals.childNodes
Vitals.dictToXML()
Vitals.doctype
Vitals.documentElement
Vitals.documentURI
Vitals.encoding
Vitals.errorHandler
Vitals.firstChild
Vitals.implementation
Vitals.lastChild
Vitals.localName
Vitals.namespaceURI
Vitals.nextSibling
Vitals.nodeName
Vitals.nodeType
Vitals.nodeValue
Vitals.ownerDocument
Vitals.parentNode
Vitals.prefix
Vitals.previousSibling
Vitals.save()
Vitals.standalone
Vitals.strictErrorChecking
Vitals.svn()
Vitals.svncmd()
Vitals.tupleToXML()
Vitals.version
- Module contents
PhysicalField
PhysicalField.__abs__()
PhysicalField.__add__()
PhysicalField.__array__()
PhysicalField.__array_priority__
PhysicalField.__array_wrap__()
PhysicalField.__bool__()
PhysicalField.__div__()
PhysicalField.__eq__()
PhysicalField.__float__()
PhysicalField.__ge__()
PhysicalField.__getitem__()
PhysicalField.__gt__()
PhysicalField.__hash__()
PhysicalField.__le__()
PhysicalField.__len__()
PhysicalField.__lt__()
PhysicalField.__mod__()
PhysicalField.__mul__()
PhysicalField.__ne__()
PhysicalField.__neg__()
PhysicalField.__nonzero__()
PhysicalField.__pos__()
PhysicalField.__pow__()
PhysicalField.__radd__()
PhysicalField.__rdiv__()
PhysicalField.__repr__()
PhysicalField.__rmul__()
PhysicalField.__rpow__()
PhysicalField.__rsub__()
PhysicalField.__rtruediv__()
PhysicalField.__setitem__()
PhysicalField.__str__()
PhysicalField.__sub__()
PhysicalField.__truediv__()
PhysicalField.add()
PhysicalField.allclose()
PhysicalField.allequal()
PhysicalField.arccos()
PhysicalField.arccosh()
PhysicalField.arcsin()
PhysicalField.arctan()
PhysicalField.arctan2()
PhysicalField.arctanh()
PhysicalField.ceil()
PhysicalField.conjugate()
PhysicalField.convertToUnit()
PhysicalField.copy()
PhysicalField.cos()
PhysicalField.cosh()
PhysicalField.divide()
PhysicalField.dot()
PhysicalField.floor()
PhysicalField.getsctype()
PhysicalField.inBaseUnits()
PhysicalField.inDimensionless()
PhysicalField.inRadians()
PhysicalField.inSIUnits()
PhysicalField.inUnitsOf()
PhysicalField.isCompatible()
PhysicalField.itemset()
PhysicalField.itemsize
PhysicalField.log()
PhysicalField.log10()
PhysicalField.multiply()
PhysicalField.numericValue
PhysicalField.put()
PhysicalField.ravel()
PhysicalField.reshape()
PhysicalField.shape
PhysicalField.sign()
PhysicalField.sin()
PhysicalField.sinh()
PhysicalField.sqrt()
PhysicalField.subtract()
PhysicalField.sum()
PhysicalField.take()
PhysicalField.tan()
PhysicalField.tanh()
PhysicalField.tostring()
PhysicalField.unit
SharedTemporaryFile()
Vitals
Vitals.ATTRIBUTE_NODE
Vitals.CDATA_SECTION_NODE
Vitals.COMMENT_NODE
Vitals.DOCUMENT_FRAGMENT_NODE
Vitals.DOCUMENT_NODE
Vitals.DOCUMENT_TYPE_NODE
Vitals.ELEMENT_NODE
Vitals.ENTITY_NODE
Vitals.ENTITY_REFERENCE_NODE
Vitals.NOTATION_NODE
Vitals.PROCESSING_INSTRUCTION_NODE
Vitals.TEXT_NODE
Vitals.__slots__
Vitals.__str__()
Vitals.actualEncoding
Vitals.appendChild()
Vitals.appendInfo()
Vitals.async_
Vitals.attributes
Vitals.childNodes
Vitals.dictToXML()
Vitals.doctype
Vitals.documentElement
Vitals.documentURI
Vitals.encoding
Vitals.errorHandler
Vitals.firstChild
Vitals.implementation
Vitals.lastChild
Vitals.localName
Vitals.namespaceURI
Vitals.nextSibling
Vitals.nodeName
Vitals.nodeType
Vitals.nodeValue
Vitals.ownerDocument
Vitals.parentNode
Vitals.prefix
Vitals.previousSibling
Vitals.save()
Vitals.standalone
Vitals.strictErrorChecking
Vitals.svn()
Vitals.svncmd()
Vitals.tupleToXML()
Vitals.version
- fipy.variables package
- Submodules
- fipy.variables.addOverFacesVariable module
- fipy.variables.arithmeticCellToFaceVariable module
- fipy.variables.betaNoiseVariable module
BetaNoiseVariable
BetaNoiseVariable.__abs__()
BetaNoiseVariable.__add__()
BetaNoiseVariable.__and__()
BetaNoiseVariable.__array__()
BetaNoiseVariable.__array_priority__
BetaNoiseVariable.__array_wrap__()
BetaNoiseVariable.__bool__()
BetaNoiseVariable.__call__()
BetaNoiseVariable.__div__()
BetaNoiseVariable.__eq__()
BetaNoiseVariable.__float__()
BetaNoiseVariable.__ge__()
BetaNoiseVariable.__getitem__()
BetaNoiseVariable.__getstate__()
BetaNoiseVariable.__gt__()
BetaNoiseVariable.__hash__()
BetaNoiseVariable.__int__()
BetaNoiseVariable.__invert__()
BetaNoiseVariable.__iter__()
BetaNoiseVariable.__le__()
BetaNoiseVariable.__len__()
BetaNoiseVariable.__lt__()
BetaNoiseVariable.__mod__()
BetaNoiseVariable.__mul__()
BetaNoiseVariable.__ne__()
BetaNoiseVariable.__neg__()
BetaNoiseVariable.__new__()
BetaNoiseVariable.__nonzero__()
BetaNoiseVariable.__or__()
BetaNoiseVariable.__pos__()
BetaNoiseVariable.__pow__()
BetaNoiseVariable.__radd__()
BetaNoiseVariable.__rdiv__()
BetaNoiseVariable.__repr__()
BetaNoiseVariable.__rmul__()
BetaNoiseVariable.__rpow__()
BetaNoiseVariable.__rsub__()
BetaNoiseVariable.__rtruediv__()
BetaNoiseVariable.__setitem__()
BetaNoiseVariable.__setstate__()
BetaNoiseVariable.__str__()
BetaNoiseVariable.__sub__()
BetaNoiseVariable.__truediv__()
BetaNoiseVariable.all()
BetaNoiseVariable.allclose()
BetaNoiseVariable.allequal()
BetaNoiseVariable.any()
BetaNoiseVariable.arithmeticFaceValue
BetaNoiseVariable.cacheMe()
BetaNoiseVariable.cellVolumeAverage
BetaNoiseVariable.constrain()
BetaNoiseVariable.constraintMask
BetaNoiseVariable.constraints
BetaNoiseVariable.copy()
BetaNoiseVariable.dontCacheMe()
BetaNoiseVariable.dot()
BetaNoiseVariable.faceGrad
BetaNoiseVariable.faceGradAverage
BetaNoiseVariable.faceValue
BetaNoiseVariable.gaussGrad
BetaNoiseVariable.getsctype()
BetaNoiseVariable.globalValue
BetaNoiseVariable.grad
BetaNoiseVariable.harmonicFaceValue
BetaNoiseVariable.inBaseUnits()
BetaNoiseVariable.inUnitsOf()
BetaNoiseVariable.itemset()
BetaNoiseVariable.itemsize
BetaNoiseVariable.leastSquaresGrad
BetaNoiseVariable.mag
BetaNoiseVariable.max()
BetaNoiseVariable.min()
BetaNoiseVariable.minmodFaceValue
BetaNoiseVariable.name
BetaNoiseVariable.numericValue
BetaNoiseVariable.old
BetaNoiseVariable.parallelRandom()
BetaNoiseVariable.put()
BetaNoiseVariable.random()
BetaNoiseVariable.rank
BetaNoiseVariable.ravel()
BetaNoiseVariable.rdot()
BetaNoiseVariable.release()
BetaNoiseVariable.scramble()
BetaNoiseVariable.setValue()
BetaNoiseVariable.shape
BetaNoiseVariable.std()
BetaNoiseVariable.subscribedVariables
BetaNoiseVariable.sum()
BetaNoiseVariable.take()
BetaNoiseVariable.tostring()
BetaNoiseVariable.unit
BetaNoiseVariable.updateOld()
BetaNoiseVariable.value
- fipy.variables.binaryOperatorVariable module
- fipy.variables.cellToFaceVariable module
- fipy.variables.cellVariable module
CellVariable
CellVariable.__abs__()
CellVariable.__add__()
CellVariable.__and__()
CellVariable.__array__()
CellVariable.__array_priority__
CellVariable.__array_wrap__()
CellVariable.__bool__()
CellVariable.__call__()
CellVariable.__div__()
CellVariable.__eq__()
CellVariable.__float__()
CellVariable.__ge__()
CellVariable.__getitem__()
CellVariable.__getstate__()
CellVariable.__gt__()
CellVariable.__hash__()
CellVariable.__int__()
CellVariable.__invert__()
CellVariable.__iter__()
CellVariable.__le__()
CellVariable.__len__()
CellVariable.__lt__()
CellVariable.__mod__()
CellVariable.__mul__()
CellVariable.__ne__()
CellVariable.__neg__()
CellVariable.__new__()
CellVariable.__nonzero__()
CellVariable.__or__()
CellVariable.__pos__()
CellVariable.__pow__()
CellVariable.__radd__()
CellVariable.__rdiv__()
CellVariable.__repr__()
CellVariable.__rmul__()
CellVariable.__rpow__()
CellVariable.__rsub__()
CellVariable.__rtruediv__()
CellVariable.__setitem__()
CellVariable.__setstate__()
CellVariable.__str__()
CellVariable.__sub__()
CellVariable.__truediv__()
CellVariable.all()
CellVariable.allclose()
CellVariable.allequal()
CellVariable.any()
CellVariable.arithmeticFaceValue
CellVariable.cacheMe()
CellVariable.cellVolumeAverage
CellVariable.constrain()
CellVariable.constraintMask
CellVariable.constraints
CellVariable.copy()
CellVariable.dontCacheMe()
CellVariable.dot()
CellVariable.faceGrad
CellVariable.faceGradAverage
CellVariable.faceValue
CellVariable.gaussGrad
CellVariable.getsctype()
CellVariable.globalValue
CellVariable.grad
CellVariable.harmonicFaceValue
CellVariable.inBaseUnits()
CellVariable.inUnitsOf()
CellVariable.itemset()
CellVariable.itemsize
CellVariable.leastSquaresGrad
CellVariable.mag
CellVariable.max()
CellVariable.min()
CellVariable.minmodFaceValue
CellVariable.name
CellVariable.numericValue
CellVariable.old
CellVariable.put()
CellVariable.rank
CellVariable.ravel()
CellVariable.rdot()
CellVariable.release()
CellVariable.setValue()
CellVariable.shape
CellVariable.std()
CellVariable.subscribedVariables
CellVariable.sum()
CellVariable.take()
CellVariable.tostring()
CellVariable.unit
CellVariable.updateOld()
CellVariable.value
- fipy.variables.constant module
- fipy.variables.constraintMask module
- fipy.variables.coupledCellVariable module
- fipy.variables.distanceVariable module
DistanceVariable
DistanceVariable.__abs__()
DistanceVariable.__add__()
DistanceVariable.__and__()
DistanceVariable.__array__()
DistanceVariable.__array_priority__
DistanceVariable.__array_wrap__()
DistanceVariable.__bool__()
DistanceVariable.__call__()
DistanceVariable.__div__()
DistanceVariable.__eq__()
DistanceVariable.__float__()
DistanceVariable.__ge__()
DistanceVariable.__getitem__()
DistanceVariable.__getstate__()
DistanceVariable.__gt__()
DistanceVariable.__hash__()
DistanceVariable.__int__()
DistanceVariable.__invert__()
DistanceVariable.__iter__()
DistanceVariable.__le__()
DistanceVariable.__len__()
DistanceVariable.__lt__()
DistanceVariable.__mod__()
DistanceVariable.__mul__()
DistanceVariable.__ne__()
DistanceVariable.__neg__()
DistanceVariable.__new__()
DistanceVariable.__nonzero__()
DistanceVariable.__or__()
DistanceVariable.__pos__()
DistanceVariable.__pow__()
DistanceVariable.__radd__()
DistanceVariable.__rdiv__()
DistanceVariable.__repr__()
DistanceVariable.__rmul__()
DistanceVariable.__rpow__()
DistanceVariable.__rsub__()
DistanceVariable.__rtruediv__()
DistanceVariable.__setitem__()
DistanceVariable.__setstate__()
DistanceVariable.__str__()
DistanceVariable.__sub__()
DistanceVariable.__truediv__()
DistanceVariable.all()
DistanceVariable.allclose()
DistanceVariable.allequal()
DistanceVariable.any()
DistanceVariable.arithmeticFaceValue
DistanceVariable.cacheMe()
DistanceVariable.calcDistanceFunction()
DistanceVariable.cellInterfaceAreas
DistanceVariable.cellVolumeAverage
DistanceVariable.constrain()
DistanceVariable.constraintMask
DistanceVariable.constraints
DistanceVariable.copy()
DistanceVariable.dontCacheMe()
DistanceVariable.dot()
DistanceVariable.extendVariable()
DistanceVariable.faceGrad
DistanceVariable.faceGradAverage
DistanceVariable.faceValue
DistanceVariable.gaussGrad
DistanceVariable.getLSMshape()
DistanceVariable.getsctype()
DistanceVariable.globalValue
DistanceVariable.grad
DistanceVariable.harmonicFaceValue
DistanceVariable.inBaseUnits()
DistanceVariable.inUnitsOf()
DistanceVariable.itemset()
DistanceVariable.itemsize
DistanceVariable.leastSquaresGrad
DistanceVariable.mag
DistanceVariable.max()
DistanceVariable.min()
DistanceVariable.minmodFaceValue
DistanceVariable.name
DistanceVariable.numericValue
DistanceVariable.old
DistanceVariable.put()
DistanceVariable.rank
DistanceVariable.ravel()
DistanceVariable.rdot()
DistanceVariable.release()
DistanceVariable.setValue()
DistanceVariable.shape
DistanceVariable.std()
DistanceVariable.subscribedVariables
DistanceVariable.sum()
DistanceVariable.take()
DistanceVariable.tostring()
DistanceVariable.unit
DistanceVariable.updateOld()
DistanceVariable.value
- fipy.variables.exponentialNoiseVariable module
ExponentialNoiseVariable
ExponentialNoiseVariable.__abs__()
ExponentialNoiseVariable.__add__()
ExponentialNoiseVariable.__and__()
ExponentialNoiseVariable.__array__()
ExponentialNoiseVariable.__array_priority__
ExponentialNoiseVariable.__array_wrap__()
ExponentialNoiseVariable.__bool__()
ExponentialNoiseVariable.__call__()
ExponentialNoiseVariable.__div__()
ExponentialNoiseVariable.__eq__()
ExponentialNoiseVariable.__float__()
ExponentialNoiseVariable.__ge__()
ExponentialNoiseVariable.__getitem__()
ExponentialNoiseVariable.__getstate__()
ExponentialNoiseVariable.__gt__()
ExponentialNoiseVariable.__hash__()
ExponentialNoiseVariable.__int__()
ExponentialNoiseVariable.__invert__()
ExponentialNoiseVariable.__iter__()
ExponentialNoiseVariable.__le__()
ExponentialNoiseVariable.__len__()
ExponentialNoiseVariable.__lt__()
ExponentialNoiseVariable.__mod__()
ExponentialNoiseVariable.__mul__()
ExponentialNoiseVariable.__ne__()
ExponentialNoiseVariable.__neg__()
ExponentialNoiseVariable.__new__()
ExponentialNoiseVariable.__nonzero__()
ExponentialNoiseVariable.__or__()
ExponentialNoiseVariable.__pos__()
ExponentialNoiseVariable.__pow__()
ExponentialNoiseVariable.__radd__()
ExponentialNoiseVariable.__rdiv__()
ExponentialNoiseVariable.__repr__()
ExponentialNoiseVariable.__rmul__()
ExponentialNoiseVariable.__rpow__()
ExponentialNoiseVariable.__rsub__()
ExponentialNoiseVariable.__rtruediv__()
ExponentialNoiseVariable.__setitem__()
ExponentialNoiseVariable.__setstate__()
ExponentialNoiseVariable.__str__()
ExponentialNoiseVariable.__sub__()
ExponentialNoiseVariable.__truediv__()
ExponentialNoiseVariable.all()
ExponentialNoiseVariable.allclose()
ExponentialNoiseVariable.allequal()
ExponentialNoiseVariable.any()
ExponentialNoiseVariable.arithmeticFaceValue
ExponentialNoiseVariable.cacheMe()
ExponentialNoiseVariable.cellVolumeAverage
ExponentialNoiseVariable.constrain()
ExponentialNoiseVariable.constraintMask
ExponentialNoiseVariable.constraints
ExponentialNoiseVariable.copy()
ExponentialNoiseVariable.dontCacheMe()
ExponentialNoiseVariable.dot()
ExponentialNoiseVariable.faceGrad
ExponentialNoiseVariable.faceGradAverage
ExponentialNoiseVariable.faceValue
ExponentialNoiseVariable.gaussGrad
ExponentialNoiseVariable.getsctype()
ExponentialNoiseVariable.globalValue
ExponentialNoiseVariable.grad
ExponentialNoiseVariable.harmonicFaceValue
ExponentialNoiseVariable.inBaseUnits()
ExponentialNoiseVariable.inUnitsOf()
ExponentialNoiseVariable.itemset()
ExponentialNoiseVariable.itemsize
ExponentialNoiseVariable.leastSquaresGrad
ExponentialNoiseVariable.mag
ExponentialNoiseVariable.max()
ExponentialNoiseVariable.min()
ExponentialNoiseVariable.minmodFaceValue
ExponentialNoiseVariable.name
ExponentialNoiseVariable.numericValue
ExponentialNoiseVariable.old
ExponentialNoiseVariable.parallelRandom()
ExponentialNoiseVariable.put()
ExponentialNoiseVariable.random()
ExponentialNoiseVariable.rank
ExponentialNoiseVariable.ravel()
ExponentialNoiseVariable.rdot()
ExponentialNoiseVariable.release()
ExponentialNoiseVariable.scramble()
ExponentialNoiseVariable.setValue()
ExponentialNoiseVariable.shape
ExponentialNoiseVariable.std()
ExponentialNoiseVariable.subscribedVariables
ExponentialNoiseVariable.sum()
ExponentialNoiseVariable.take()
ExponentialNoiseVariable.tostring()
ExponentialNoiseVariable.unit
ExponentialNoiseVariable.updateOld()
ExponentialNoiseVariable.value
- fipy.variables.faceGradContributionsVariable module
- fipy.variables.faceGradVariable module
- fipy.variables.faceVariable module
FaceVariable
FaceVariable.__abs__()
FaceVariable.__add__()
FaceVariable.__and__()
FaceVariable.__array__()
FaceVariable.__array_priority__
FaceVariable.__array_wrap__()
FaceVariable.__bool__()
FaceVariable.__call__()
FaceVariable.__div__()
FaceVariable.__eq__()
FaceVariable.__float__()
FaceVariable.__ge__()
FaceVariable.__getitem__()
FaceVariable.__getstate__()
FaceVariable.__gt__()
FaceVariable.__hash__()
FaceVariable.__int__()
FaceVariable.__invert__()
FaceVariable.__iter__()
FaceVariable.__le__()
FaceVariable.__len__()
FaceVariable.__lt__()
FaceVariable.__mod__()
FaceVariable.__mul__()
FaceVariable.__ne__()
FaceVariable.__neg__()
FaceVariable.__new__()
FaceVariable.__nonzero__()
FaceVariable.__or__()
FaceVariable.__pos__()
FaceVariable.__pow__()
FaceVariable.__radd__()
FaceVariable.__rdiv__()
FaceVariable.__repr__()
FaceVariable.__rmul__()
FaceVariable.__rpow__()
FaceVariable.__rsub__()
FaceVariable.__rtruediv__()
FaceVariable.__setitem__()
FaceVariable.__setstate__()
FaceVariable.__str__()
FaceVariable.__sub__()
FaceVariable.__truediv__()
FaceVariable.all()
FaceVariable.allclose()
FaceVariable.allequal()
FaceVariable.any()
FaceVariable.cacheMe()
FaceVariable.constrain()
FaceVariable.constraintMask
FaceVariable.constraints
FaceVariable.copy()
FaceVariable.divergence
FaceVariable.dontCacheMe()
FaceVariable.dot()
FaceVariable.getsctype()
FaceVariable.globalValue
FaceVariable.inBaseUnits()
FaceVariable.inUnitsOf()
FaceVariable.itemset()
FaceVariable.itemsize
FaceVariable.mag
FaceVariable.max()
FaceVariable.min()
FaceVariable.name
FaceVariable.numericValue
FaceVariable.put()
FaceVariable.rank
FaceVariable.ravel()
FaceVariable.rdot()
FaceVariable.release()
FaceVariable.setValue()
FaceVariable.shape
FaceVariable.std()
FaceVariable.subscribedVariables
FaceVariable.sum()
FaceVariable.take()
FaceVariable.tostring()
FaceVariable.unit
FaceVariable.value
- fipy.variables.gammaNoiseVariable module
GammaNoiseVariable
GammaNoiseVariable.__abs__()
GammaNoiseVariable.__add__()
GammaNoiseVariable.__and__()
GammaNoiseVariable.__array__()
GammaNoiseVariable.__array_priority__
GammaNoiseVariable.__array_wrap__()
GammaNoiseVariable.__bool__()
GammaNoiseVariable.__call__()
GammaNoiseVariable.__div__()
GammaNoiseVariable.__eq__()
GammaNoiseVariable.__float__()
GammaNoiseVariable.__ge__()
GammaNoiseVariable.__getitem__()
GammaNoiseVariable.__getstate__()
GammaNoiseVariable.__gt__()
GammaNoiseVariable.__hash__()
GammaNoiseVariable.__int__()
GammaNoiseVariable.__invert__()
GammaNoiseVariable.__iter__()
GammaNoiseVariable.__le__()
GammaNoiseVariable.__len__()
GammaNoiseVariable.__lt__()
GammaNoiseVariable.__mod__()
GammaNoiseVariable.__mul__()
GammaNoiseVariable.__ne__()
GammaNoiseVariable.__neg__()
GammaNoiseVariable.__new__()
GammaNoiseVariable.__nonzero__()
GammaNoiseVariable.__or__()
GammaNoiseVariable.__pos__()
GammaNoiseVariable.__pow__()
GammaNoiseVariable.__radd__()
GammaNoiseVariable.__rdiv__()
GammaNoiseVariable.__repr__()
GammaNoiseVariable.__rmul__()
GammaNoiseVariable.__rpow__()
GammaNoiseVariable.__rsub__()
GammaNoiseVariable.__rtruediv__()
GammaNoiseVariable.__setitem__()
GammaNoiseVariable.__setstate__()
GammaNoiseVariable.__str__()
GammaNoiseVariable.__sub__()
GammaNoiseVariable.__truediv__()
GammaNoiseVariable.all()
GammaNoiseVariable.allclose()
GammaNoiseVariable.allequal()
GammaNoiseVariable.any()
GammaNoiseVariable.arithmeticFaceValue
GammaNoiseVariable.cacheMe()
GammaNoiseVariable.cellVolumeAverage
GammaNoiseVariable.constrain()
GammaNoiseVariable.constraintMask
GammaNoiseVariable.constraints
GammaNoiseVariable.copy()
GammaNoiseVariable.dontCacheMe()
GammaNoiseVariable.dot()
GammaNoiseVariable.faceGrad
GammaNoiseVariable.faceGradAverage
GammaNoiseVariable.faceValue
GammaNoiseVariable.gaussGrad
GammaNoiseVariable.getsctype()
GammaNoiseVariable.globalValue
GammaNoiseVariable.grad
GammaNoiseVariable.harmonicFaceValue
GammaNoiseVariable.inBaseUnits()
GammaNoiseVariable.inUnitsOf()
GammaNoiseVariable.itemset()
GammaNoiseVariable.itemsize
GammaNoiseVariable.leastSquaresGrad
GammaNoiseVariable.mag
GammaNoiseVariable.max()
GammaNoiseVariable.min()
GammaNoiseVariable.minmodFaceValue
GammaNoiseVariable.name
GammaNoiseVariable.numericValue
GammaNoiseVariable.old
GammaNoiseVariable.parallelRandom()
GammaNoiseVariable.put()
GammaNoiseVariable.random()
GammaNoiseVariable.rank
GammaNoiseVariable.ravel()
GammaNoiseVariable.rdot()
GammaNoiseVariable.release()
GammaNoiseVariable.scramble()
GammaNoiseVariable.setValue()
GammaNoiseVariable.shape
GammaNoiseVariable.std()
GammaNoiseVariable.subscribedVariables
GammaNoiseVariable.sum()
GammaNoiseVariable.take()
GammaNoiseVariable.tostring()
GammaNoiseVariable.unit
GammaNoiseVariable.updateOld()
GammaNoiseVariable.value
- fipy.variables.gaussCellGradVariable module
- fipy.variables.gaussianNoiseVariable module
GaussianNoiseVariable
GaussianNoiseVariable.__abs__()
GaussianNoiseVariable.__add__()
GaussianNoiseVariable.__and__()
GaussianNoiseVariable.__array__()
GaussianNoiseVariable.__array_priority__
GaussianNoiseVariable.__array_wrap__()
GaussianNoiseVariable.__bool__()
GaussianNoiseVariable.__call__()
GaussianNoiseVariable.__div__()
GaussianNoiseVariable.__eq__()
GaussianNoiseVariable.__float__()
GaussianNoiseVariable.__ge__()
GaussianNoiseVariable.__getitem__()
GaussianNoiseVariable.__getstate__()
GaussianNoiseVariable.__gt__()
GaussianNoiseVariable.__hash__()
GaussianNoiseVariable.__int__()
GaussianNoiseVariable.__invert__()
GaussianNoiseVariable.__iter__()
GaussianNoiseVariable.__le__()
GaussianNoiseVariable.__len__()
GaussianNoiseVariable.__lt__()
GaussianNoiseVariable.__mod__()
GaussianNoiseVariable.__mul__()
GaussianNoiseVariable.__ne__()
GaussianNoiseVariable.__neg__()
GaussianNoiseVariable.__new__()
GaussianNoiseVariable.__nonzero__()
GaussianNoiseVariable.__or__()
GaussianNoiseVariable.__pos__()
GaussianNoiseVariable.__pow__()
GaussianNoiseVariable.__radd__()
GaussianNoiseVariable.__rdiv__()
GaussianNoiseVariable.__repr__()
GaussianNoiseVariable.__rmul__()
GaussianNoiseVariable.__rpow__()
GaussianNoiseVariable.__rsub__()
GaussianNoiseVariable.__rtruediv__()
GaussianNoiseVariable.__setitem__()
GaussianNoiseVariable.__setstate__()
GaussianNoiseVariable.__str__()
GaussianNoiseVariable.__sub__()
GaussianNoiseVariable.__truediv__()
GaussianNoiseVariable.all()
GaussianNoiseVariable.allclose()
GaussianNoiseVariable.allequal()
GaussianNoiseVariable.any()
GaussianNoiseVariable.arithmeticFaceValue
GaussianNoiseVariable.cacheMe()
GaussianNoiseVariable.cellVolumeAverage
GaussianNoiseVariable.constrain()
GaussianNoiseVariable.constraintMask
GaussianNoiseVariable.constraints
GaussianNoiseVariable.copy()
GaussianNoiseVariable.dontCacheMe()
GaussianNoiseVariable.dot()
GaussianNoiseVariable.faceGrad
GaussianNoiseVariable.faceGradAverage
GaussianNoiseVariable.faceValue
GaussianNoiseVariable.gaussGrad
GaussianNoiseVariable.getsctype()
GaussianNoiseVariable.globalValue
GaussianNoiseVariable.grad
GaussianNoiseVariable.harmonicFaceValue
GaussianNoiseVariable.inBaseUnits()
GaussianNoiseVariable.inUnitsOf()
GaussianNoiseVariable.itemset()
GaussianNoiseVariable.itemsize
GaussianNoiseVariable.leastSquaresGrad
GaussianNoiseVariable.mag
GaussianNoiseVariable.max()
GaussianNoiseVariable.min()
GaussianNoiseVariable.minmodFaceValue
GaussianNoiseVariable.name
GaussianNoiseVariable.numericValue
GaussianNoiseVariable.old
GaussianNoiseVariable.parallelRandom()
GaussianNoiseVariable.put()
GaussianNoiseVariable.random()
GaussianNoiseVariable.rank
GaussianNoiseVariable.ravel()
GaussianNoiseVariable.rdot()
GaussianNoiseVariable.release()
GaussianNoiseVariable.scramble()
GaussianNoiseVariable.setValue()
GaussianNoiseVariable.shape
GaussianNoiseVariable.std()
GaussianNoiseVariable.subscribedVariables
GaussianNoiseVariable.sum()
GaussianNoiseVariable.take()
GaussianNoiseVariable.tostring()
GaussianNoiseVariable.unit
GaussianNoiseVariable.updateOld()
GaussianNoiseVariable.value
- fipy.variables.harmonicCellToFaceVariable module
- fipy.variables.histogramVariable module
HistogramVariable
HistogramVariable.__abs__()
HistogramVariable.__add__()
HistogramVariable.__and__()
HistogramVariable.__array__()
HistogramVariable.__array_priority__
HistogramVariable.__array_wrap__()
HistogramVariable.__bool__()
HistogramVariable.__call__()
HistogramVariable.__div__()
HistogramVariable.__eq__()
HistogramVariable.__float__()
HistogramVariable.__ge__()
HistogramVariable.__getitem__()
HistogramVariable.__getstate__()
HistogramVariable.__gt__()
HistogramVariable.__hash__()
HistogramVariable.__int__()
HistogramVariable.__invert__()
HistogramVariable.__iter__()
HistogramVariable.__le__()
HistogramVariable.__len__()
HistogramVariable.__lt__()
HistogramVariable.__mod__()
HistogramVariable.__mul__()
HistogramVariable.__ne__()
HistogramVariable.__neg__()
HistogramVariable.__new__()
HistogramVariable.__nonzero__()
HistogramVariable.__or__()
HistogramVariable.__pos__()
HistogramVariable.__pow__()
HistogramVariable.__radd__()
HistogramVariable.__rdiv__()
HistogramVariable.__repr__()
HistogramVariable.__rmul__()
HistogramVariable.__rpow__()
HistogramVariable.__rsub__()
HistogramVariable.__rtruediv__()
HistogramVariable.__setitem__()
HistogramVariable.__setstate__()
HistogramVariable.__str__()
HistogramVariable.__sub__()
HistogramVariable.__truediv__()
HistogramVariable.all()
HistogramVariable.allclose()
HistogramVariable.allequal()
HistogramVariable.any()
HistogramVariable.arithmeticFaceValue
HistogramVariable.cacheMe()
HistogramVariable.cellVolumeAverage
HistogramVariable.constrain()
HistogramVariable.constraintMask
HistogramVariable.constraints
HistogramVariable.copy()
HistogramVariable.dontCacheMe()
HistogramVariable.dot()
HistogramVariable.faceGrad
HistogramVariable.faceGradAverage
HistogramVariable.faceValue
HistogramVariable.gaussGrad
HistogramVariable.getsctype()
HistogramVariable.globalValue
HistogramVariable.grad
HistogramVariable.harmonicFaceValue
HistogramVariable.inBaseUnits()
HistogramVariable.inUnitsOf()
HistogramVariable.itemset()
HistogramVariable.itemsize
HistogramVariable.leastSquaresGrad
HistogramVariable.mag
HistogramVariable.max()
HistogramVariable.min()
HistogramVariable.minmodFaceValue
HistogramVariable.name
HistogramVariable.numericValue
HistogramVariable.old
HistogramVariable.put()
HistogramVariable.rank
HistogramVariable.ravel()
HistogramVariable.rdot()
HistogramVariable.release()
HistogramVariable.setValue()
HistogramVariable.shape
HistogramVariable.std()
HistogramVariable.subscribedVariables
HistogramVariable.sum()
HistogramVariable.take()
HistogramVariable.tostring()
HistogramVariable.unit
HistogramVariable.updateOld()
HistogramVariable.value
- fipy.variables.interfaceAreaVariable module
- fipy.variables.interfaceFlagVariable module
- fipy.variables.leastSquaresCellGradVariable module
- fipy.variables.levelSetDiffusionVariable module
- fipy.variables.meshVariable module
- fipy.variables.minmodCellToFaceVariable module
- fipy.variables.modCellGradVariable module
- fipy.variables.modCellToFaceVariable module
- fipy.variables.modFaceGradVariable module
- fipy.variables.modPhysicalField module
- fipy.variables.modularVariable module
ModularVariable
ModularVariable.__abs__()
ModularVariable.__add__()
ModularVariable.__and__()
ModularVariable.__array__()
ModularVariable.__array_priority__
ModularVariable.__array_wrap__()
ModularVariable.__bool__()
ModularVariable.__call__()
ModularVariable.__div__()
ModularVariable.__eq__()
ModularVariable.__float__()
ModularVariable.__ge__()
ModularVariable.__getitem__()
ModularVariable.__getstate__()
ModularVariable.__gt__()
ModularVariable.__hash__()
ModularVariable.__int__()
ModularVariable.__invert__()
ModularVariable.__iter__()
ModularVariable.__le__()
ModularVariable.__len__()
ModularVariable.__lt__()
ModularVariable.__mod__()
ModularVariable.__mul__()
ModularVariable.__ne__()
ModularVariable.__neg__()
ModularVariable.__new__()
ModularVariable.__nonzero__()
ModularVariable.__or__()
ModularVariable.__pos__()
ModularVariable.__pow__()
ModularVariable.__radd__()
ModularVariable.__rdiv__()
ModularVariable.__repr__()
ModularVariable.__rmul__()
ModularVariable.__rpow__()
ModularVariable.__rsub__()
ModularVariable.__rtruediv__()
ModularVariable.__setitem__()
ModularVariable.__setstate__()
ModularVariable.__str__()
ModularVariable.__sub__()
ModularVariable.__truediv__()
ModularVariable.all()
ModularVariable.allclose()
ModularVariable.allequal()
ModularVariable.any()
ModularVariable.arithmeticFaceValue
ModularVariable.cacheMe()
ModularVariable.cellVolumeAverage
ModularVariable.constrain()
ModularVariable.constraintMask
ModularVariable.constraints
ModularVariable.copy()
ModularVariable.dontCacheMe()
ModularVariable.dot()
ModularVariable.faceGrad
ModularVariable.faceGradAverage
ModularVariable.faceGradNoMod
ModularVariable.faceValue
ModularVariable.gaussGrad
ModularVariable.getsctype()
ModularVariable.globalValue
ModularVariable.grad
ModularVariable.harmonicFaceValue
ModularVariable.inBaseUnits()
ModularVariable.inUnitsOf()
ModularVariable.itemset()
ModularVariable.itemsize
ModularVariable.leastSquaresGrad
ModularVariable.mag
ModularVariable.max()
ModularVariable.min()
ModularVariable.minmodFaceValue
ModularVariable.name
ModularVariable.numericValue
ModularVariable.old
ModularVariable.put()
ModularVariable.rank
ModularVariable.ravel()
ModularVariable.rdot()
ModularVariable.release()
ModularVariable.setValue()
ModularVariable.shape
ModularVariable.std()
ModularVariable.subscribedVariables
ModularVariable.sum()
ModularVariable.take()
ModularVariable.tostring()
ModularVariable.unit
ModularVariable.updateOld()
ModularVariable.value
- fipy.variables.noiseVariable module
NoiseVariable
NoiseVariable.__abs__()
NoiseVariable.__add__()
NoiseVariable.__and__()
NoiseVariable.__array__()
NoiseVariable.__array_priority__
NoiseVariable.__array_wrap__()
NoiseVariable.__bool__()
NoiseVariable.__call__()
NoiseVariable.__div__()
NoiseVariable.__eq__()
NoiseVariable.__float__()
NoiseVariable.__ge__()
NoiseVariable.__getitem__()
NoiseVariable.__getstate__()
NoiseVariable.__gt__()
NoiseVariable.__hash__()
NoiseVariable.__int__()
NoiseVariable.__invert__()
NoiseVariable.__iter__()
NoiseVariable.__le__()
NoiseVariable.__len__()
NoiseVariable.__lt__()
NoiseVariable.__mod__()
NoiseVariable.__mul__()
NoiseVariable.__ne__()
NoiseVariable.__neg__()
NoiseVariable.__new__()
NoiseVariable.__nonzero__()
NoiseVariable.__or__()
NoiseVariable.__pos__()
NoiseVariable.__pow__()
NoiseVariable.__radd__()
NoiseVariable.__rdiv__()
NoiseVariable.__repr__()
NoiseVariable.__rmul__()
NoiseVariable.__rpow__()
NoiseVariable.__rsub__()
NoiseVariable.__rtruediv__()
NoiseVariable.__setitem__()
NoiseVariable.__setstate__()
NoiseVariable.__str__()
NoiseVariable.__sub__()
NoiseVariable.__truediv__()
NoiseVariable.all()
NoiseVariable.allclose()
NoiseVariable.allequal()
NoiseVariable.any()
NoiseVariable.arithmeticFaceValue
NoiseVariable.cacheMe()
NoiseVariable.cellVolumeAverage
NoiseVariable.constrain()
NoiseVariable.constraintMask
NoiseVariable.constraints
NoiseVariable.copy()
NoiseVariable.dontCacheMe()
NoiseVariable.dot()
NoiseVariable.faceGrad
NoiseVariable.faceGradAverage
NoiseVariable.faceValue
NoiseVariable.gaussGrad
NoiseVariable.getsctype()
NoiseVariable.globalValue
NoiseVariable.grad
NoiseVariable.harmonicFaceValue
NoiseVariable.inBaseUnits()
NoiseVariable.inUnitsOf()
NoiseVariable.itemset()
NoiseVariable.itemsize
NoiseVariable.leastSquaresGrad
NoiseVariable.mag
NoiseVariable.max()
NoiseVariable.min()
NoiseVariable.minmodFaceValue
NoiseVariable.name
NoiseVariable.numericValue
NoiseVariable.old
NoiseVariable.parallelRandom()
NoiseVariable.put()
NoiseVariable.random()
NoiseVariable.rank
NoiseVariable.ravel()
NoiseVariable.rdot()
NoiseVariable.release()
NoiseVariable.scramble()
NoiseVariable.setValue()
NoiseVariable.shape
NoiseVariable.std()
NoiseVariable.subscribedVariables
NoiseVariable.sum()
NoiseVariable.take()
NoiseVariable.tostring()
NoiseVariable.unit
NoiseVariable.updateOld()
NoiseVariable.value
- fipy.variables.operatorVariable module
- fipy.variables.scharfetterGummelFaceVariable module
ScharfetterGummelFaceVariable
ScharfetterGummelFaceVariable.__abs__()
ScharfetterGummelFaceVariable.__add__()
ScharfetterGummelFaceVariable.__and__()
ScharfetterGummelFaceVariable.__array__()
ScharfetterGummelFaceVariable.__array_priority__
ScharfetterGummelFaceVariable.__array_wrap__()
ScharfetterGummelFaceVariable.__bool__()
ScharfetterGummelFaceVariable.__call__()
ScharfetterGummelFaceVariable.__div__()
ScharfetterGummelFaceVariable.__eq__()
ScharfetterGummelFaceVariable.__float__()
ScharfetterGummelFaceVariable.__ge__()
ScharfetterGummelFaceVariable.__getitem__()
ScharfetterGummelFaceVariable.__getstate__()
ScharfetterGummelFaceVariable.__gt__()
ScharfetterGummelFaceVariable.__hash__()
ScharfetterGummelFaceVariable.__int__()
ScharfetterGummelFaceVariable.__invert__()
ScharfetterGummelFaceVariable.__iter__()
ScharfetterGummelFaceVariable.__le__()
ScharfetterGummelFaceVariable.__len__()
ScharfetterGummelFaceVariable.__lt__()
ScharfetterGummelFaceVariable.__mod__()
ScharfetterGummelFaceVariable.__mul__()
ScharfetterGummelFaceVariable.__ne__()
ScharfetterGummelFaceVariable.__neg__()
ScharfetterGummelFaceVariable.__new__()
ScharfetterGummelFaceVariable.__nonzero__()
ScharfetterGummelFaceVariable.__or__()
ScharfetterGummelFaceVariable.__pos__()
ScharfetterGummelFaceVariable.__pow__()
ScharfetterGummelFaceVariable.__radd__()
ScharfetterGummelFaceVariable.__rdiv__()
ScharfetterGummelFaceVariable.__repr__()
ScharfetterGummelFaceVariable.__rmul__()
ScharfetterGummelFaceVariable.__rpow__()
ScharfetterGummelFaceVariable.__rsub__()
ScharfetterGummelFaceVariable.__rtruediv__()
ScharfetterGummelFaceVariable.__setitem__()
ScharfetterGummelFaceVariable.__setstate__()
ScharfetterGummelFaceVariable.__str__()
ScharfetterGummelFaceVariable.__sub__()
ScharfetterGummelFaceVariable.__truediv__()
ScharfetterGummelFaceVariable.all()
ScharfetterGummelFaceVariable.allclose()
ScharfetterGummelFaceVariable.allequal()
ScharfetterGummelFaceVariable.any()
ScharfetterGummelFaceVariable.cacheMe()
ScharfetterGummelFaceVariable.constrain()
ScharfetterGummelFaceVariable.constraintMask
ScharfetterGummelFaceVariable.constraints
ScharfetterGummelFaceVariable.copy()
ScharfetterGummelFaceVariable.divergence
ScharfetterGummelFaceVariable.dontCacheMe()
ScharfetterGummelFaceVariable.dot()
ScharfetterGummelFaceVariable.getsctype()
ScharfetterGummelFaceVariable.globalValue
ScharfetterGummelFaceVariable.inBaseUnits()
ScharfetterGummelFaceVariable.inUnitsOf()
ScharfetterGummelFaceVariable.itemset()
ScharfetterGummelFaceVariable.itemsize
ScharfetterGummelFaceVariable.mag
ScharfetterGummelFaceVariable.max()
ScharfetterGummelFaceVariable.min()
ScharfetterGummelFaceVariable.name
ScharfetterGummelFaceVariable.numericValue
ScharfetterGummelFaceVariable.put()
ScharfetterGummelFaceVariable.rank
ScharfetterGummelFaceVariable.ravel()
ScharfetterGummelFaceVariable.rdot()
ScharfetterGummelFaceVariable.release()
ScharfetterGummelFaceVariable.setValue()
ScharfetterGummelFaceVariable.shape
ScharfetterGummelFaceVariable.std()
ScharfetterGummelFaceVariable.subscribedVariables
ScharfetterGummelFaceVariable.sum()
ScharfetterGummelFaceVariable.take()
ScharfetterGummelFaceVariable.tostring()
ScharfetterGummelFaceVariable.unit
ScharfetterGummelFaceVariable.value
- fipy.variables.surfactantConvectionVariable module
SurfactantConvectionVariable
SurfactantConvectionVariable.__abs__()
SurfactantConvectionVariable.__add__()
SurfactantConvectionVariable.__and__()
SurfactantConvectionVariable.__array__()
SurfactantConvectionVariable.__array_priority__
SurfactantConvectionVariable.__array_wrap__()
SurfactantConvectionVariable.__bool__()
SurfactantConvectionVariable.__call__()
SurfactantConvectionVariable.__div__()
SurfactantConvectionVariable.__eq__()
SurfactantConvectionVariable.__float__()
SurfactantConvectionVariable.__ge__()
SurfactantConvectionVariable.__getitem__()
SurfactantConvectionVariable.__getstate__()
SurfactantConvectionVariable.__gt__()
SurfactantConvectionVariable.__hash__()
SurfactantConvectionVariable.__int__()
SurfactantConvectionVariable.__invert__()
SurfactantConvectionVariable.__iter__()
SurfactantConvectionVariable.__le__()
SurfactantConvectionVariable.__len__()
SurfactantConvectionVariable.__lt__()
SurfactantConvectionVariable.__mod__()
SurfactantConvectionVariable.__mul__()
SurfactantConvectionVariable.__ne__()
SurfactantConvectionVariable.__neg__()
SurfactantConvectionVariable.__new__()
SurfactantConvectionVariable.__nonzero__()
SurfactantConvectionVariable.__or__()
SurfactantConvectionVariable.__pos__()
SurfactantConvectionVariable.__pow__()
SurfactantConvectionVariable.__radd__()
SurfactantConvectionVariable.__rdiv__()
SurfactantConvectionVariable.__repr__()
SurfactantConvectionVariable.__rmul__()
SurfactantConvectionVariable.__rpow__()
SurfactantConvectionVariable.__rsub__()
SurfactantConvectionVariable.__rtruediv__()
SurfactantConvectionVariable.__setitem__()
SurfactantConvectionVariable.__setstate__()
SurfactantConvectionVariable.__str__()
SurfactantConvectionVariable.__sub__()
SurfactantConvectionVariable.__truediv__()
SurfactantConvectionVariable.all()
SurfactantConvectionVariable.allclose()
SurfactantConvectionVariable.allequal()
SurfactantConvectionVariable.any()
SurfactantConvectionVariable.cacheMe()
SurfactantConvectionVariable.constrain()
SurfactantConvectionVariable.constraintMask
SurfactantConvectionVariable.constraints
SurfactantConvectionVariable.copy()
SurfactantConvectionVariable.divergence
SurfactantConvectionVariable.dontCacheMe()
SurfactantConvectionVariable.dot()
SurfactantConvectionVariable.getsctype()
SurfactantConvectionVariable.globalValue
SurfactantConvectionVariable.inBaseUnits()
SurfactantConvectionVariable.inUnitsOf()
SurfactantConvectionVariable.itemset()
SurfactantConvectionVariable.itemsize
SurfactantConvectionVariable.mag
SurfactantConvectionVariable.max()
SurfactantConvectionVariable.min()
SurfactantConvectionVariable.name
SurfactantConvectionVariable.numericValue
SurfactantConvectionVariable.put()
SurfactantConvectionVariable.rank
SurfactantConvectionVariable.ravel()
SurfactantConvectionVariable.rdot()
SurfactantConvectionVariable.release()
SurfactantConvectionVariable.setValue()
SurfactantConvectionVariable.shape
SurfactantConvectionVariable.std()
SurfactantConvectionVariable.subscribedVariables
SurfactantConvectionVariable.sum()
SurfactantConvectionVariable.take()
SurfactantConvectionVariable.tostring()
SurfactantConvectionVariable.unit
SurfactantConvectionVariable.value
- fipy.variables.surfactantVariable module
SurfactantVariable
SurfactantVariable.__abs__()
SurfactantVariable.__add__()
SurfactantVariable.__and__()
SurfactantVariable.__array__()
SurfactantVariable.__array_priority__
SurfactantVariable.__array_wrap__()
SurfactantVariable.__bool__()
SurfactantVariable.__call__()
SurfactantVariable.__div__()
SurfactantVariable.__eq__()
SurfactantVariable.__float__()
SurfactantVariable.__ge__()
SurfactantVariable.__getitem__()
SurfactantVariable.__getstate__()
SurfactantVariable.__gt__()
SurfactantVariable.__hash__()
SurfactantVariable.__int__()
SurfactantVariable.__invert__()
SurfactantVariable.__iter__()
SurfactantVariable.__le__()
SurfactantVariable.__len__()
SurfactantVariable.__lt__()
SurfactantVariable.__mod__()
SurfactantVariable.__mul__()
SurfactantVariable.__ne__()
SurfactantVariable.__neg__()
SurfactantVariable.__new__()
SurfactantVariable.__nonzero__()
SurfactantVariable.__or__()
SurfactantVariable.__pos__()
SurfactantVariable.__pow__()
SurfactantVariable.__radd__()
SurfactantVariable.__rdiv__()
SurfactantVariable.__repr__()
SurfactantVariable.__rmul__()
SurfactantVariable.__rpow__()
SurfactantVariable.__rsub__()
SurfactantVariable.__rtruediv__()
SurfactantVariable.__setitem__()
SurfactantVariable.__setstate__()
SurfactantVariable.__str__()
SurfactantVariable.__sub__()
SurfactantVariable.__truediv__()
SurfactantVariable.all()
SurfactantVariable.allclose()
SurfactantVariable.allequal()
SurfactantVariable.any()
SurfactantVariable.arithmeticFaceValue
SurfactantVariable.cacheMe()
SurfactantVariable.cellVolumeAverage
SurfactantVariable.constrain()
SurfactantVariable.constraintMask
SurfactantVariable.constraints
SurfactantVariable.copy()
SurfactantVariable.dontCacheMe()
SurfactantVariable.dot()
SurfactantVariable.faceGrad
SurfactantVariable.faceGradAverage
SurfactantVariable.faceValue
SurfactantVariable.gaussGrad
SurfactantVariable.getsctype()
SurfactantVariable.globalValue
SurfactantVariable.grad
SurfactantVariable.harmonicFaceValue
SurfactantVariable.inBaseUnits()
SurfactantVariable.inUnitsOf()
SurfactantVariable.interfaceVar
SurfactantVariable.itemset()
SurfactantVariable.itemsize
SurfactantVariable.leastSquaresGrad
SurfactantVariable.mag
SurfactantVariable.max()
SurfactantVariable.min()
SurfactantVariable.minmodFaceValue
SurfactantVariable.name
SurfactantVariable.numericValue
SurfactantVariable.old
SurfactantVariable.put()
SurfactantVariable.rank
SurfactantVariable.ravel()
SurfactantVariable.rdot()
SurfactantVariable.release()
SurfactantVariable.setValue()
SurfactantVariable.shape
SurfactantVariable.std()
SurfactantVariable.subscribedVariables
SurfactantVariable.sum()
SurfactantVariable.take()
SurfactantVariable.tostring()
SurfactantVariable.unit
SurfactantVariable.updateOld()
SurfactantVariable.value
- fipy.variables.test module
- fipy.variables.unaryOperatorVariable module
- fipy.variables.uniformNoiseVariable module
UniformNoiseVariable
UniformNoiseVariable.__abs__()
UniformNoiseVariable.__add__()
UniformNoiseVariable.__and__()
UniformNoiseVariable.__array__()
UniformNoiseVariable.__array_priority__
UniformNoiseVariable.__array_wrap__()
UniformNoiseVariable.__bool__()
UniformNoiseVariable.__call__()
UniformNoiseVariable.__div__()
UniformNoiseVariable.__eq__()
UniformNoiseVariable.__float__()
UniformNoiseVariable.__ge__()
UniformNoiseVariable.__getitem__()
UniformNoiseVariable.__getstate__()
UniformNoiseVariable.__gt__()
UniformNoiseVariable.__hash__()
UniformNoiseVariable.__int__()
UniformNoiseVariable.__invert__()
UniformNoiseVariable.__iter__()
UniformNoiseVariable.__le__()
UniformNoiseVariable.__len__()
UniformNoiseVariable.__lt__()
UniformNoiseVariable.__mod__()
UniformNoiseVariable.__mul__()
UniformNoiseVariable.__ne__()
UniformNoiseVariable.__neg__()
UniformNoiseVariable.__new__()
UniformNoiseVariable.__nonzero__()
UniformNoiseVariable.__or__()
UniformNoiseVariable.__pos__()
UniformNoiseVariable.__pow__()
UniformNoiseVariable.__radd__()
UniformNoiseVariable.__rdiv__()
UniformNoiseVariable.__repr__()
UniformNoiseVariable.__rmul__()
UniformNoiseVariable.__rpow__()
UniformNoiseVariable.__rsub__()
UniformNoiseVariable.__rtruediv__()
UniformNoiseVariable.__setitem__()
UniformNoiseVariable.__setstate__()
UniformNoiseVariable.__str__()
UniformNoiseVariable.__sub__()
UniformNoiseVariable.__truediv__()
UniformNoiseVariable.all()
UniformNoiseVariable.allclose()
UniformNoiseVariable.allequal()
UniformNoiseVariable.any()
UniformNoiseVariable.arithmeticFaceValue
UniformNoiseVariable.cacheMe()
UniformNoiseVariable.cellVolumeAverage
UniformNoiseVariable.constrain()
UniformNoiseVariable.constraintMask
UniformNoiseVariable.constraints
UniformNoiseVariable.copy()
UniformNoiseVariable.dontCacheMe()
UniformNoiseVariable.dot()
UniformNoiseVariable.faceGrad
UniformNoiseVariable.faceGradAverage
UniformNoiseVariable.faceValue
UniformNoiseVariable.gaussGrad
UniformNoiseVariable.getsctype()
UniformNoiseVariable.globalValue
UniformNoiseVariable.grad
UniformNoiseVariable.harmonicFaceValue
UniformNoiseVariable.inBaseUnits()
UniformNoiseVariable.inUnitsOf()
UniformNoiseVariable.itemset()
UniformNoiseVariable.itemsize
UniformNoiseVariable.leastSquaresGrad
UniformNoiseVariable.mag
UniformNoiseVariable.max()
UniformNoiseVariable.min()
UniformNoiseVariable.minmodFaceValue
UniformNoiseVariable.name
UniformNoiseVariable.numericValue
UniformNoiseVariable.old
UniformNoiseVariable.parallelRandom()
UniformNoiseVariable.put()
UniformNoiseVariable.random()
UniformNoiseVariable.rank
UniformNoiseVariable.ravel()
UniformNoiseVariable.rdot()
UniformNoiseVariable.release()
UniformNoiseVariable.scramble()
UniformNoiseVariable.setValue()
UniformNoiseVariable.shape
UniformNoiseVariable.std()
UniformNoiseVariable.subscribedVariables
UniformNoiseVariable.sum()
UniformNoiseVariable.take()
UniformNoiseVariable.tostring()
UniformNoiseVariable.unit
UniformNoiseVariable.updateOld()
UniformNoiseVariable.value
- fipy.variables.variable module
Variable
Variable.__abs__()
Variable.__add__()
Variable.__and__()
Variable.__array__()
Variable.__array_priority__
Variable.__array_wrap__()
Variable.__bool__()
Variable.__call__()
Variable.__div__()
Variable.__eq__()
Variable.__float__()
Variable.__ge__()
Variable.__getitem__()
Variable.__getstate__()
Variable.__gt__()
Variable.__hash__()
Variable.__int__()
Variable.__invert__()
Variable.__iter__()
Variable.__le__()
Variable.__len__()
Variable.__lt__()
Variable.__mod__()
Variable.__mul__()
Variable.__ne__()
Variable.__neg__()
Variable.__new__()
Variable.__nonzero__()
Variable.__or__()
Variable.__pos__()
Variable.__pow__()
Variable.__radd__()
Variable.__rdiv__()
Variable.__repr__()
Variable.__rmul__()
Variable.__rpow__()
Variable.__rsub__()
Variable.__rtruediv__()
Variable.__setitem__()
Variable.__setstate__()
Variable.__str__()
Variable.__sub__()
Variable.__truediv__()
Variable.all()
Variable.allclose()
Variable.allequal()
Variable.any()
Variable.cacheMe()
Variable.constrain()
Variable.constraints
Variable.copy()
Variable.dontCacheMe()
Variable.dot()
Variable.getsctype()
Variable.inBaseUnits()
Variable.inUnitsOf()
Variable.itemset()
Variable.itemsize
Variable.mag
Variable.max()
Variable.min()
Variable.name
Variable.numericValue
Variable.put()
Variable.ravel()
Variable.release()
Variable.setValue()
Variable.shape
Variable.std()
Variable.subscribedVariables
Variable.sum()
Variable.take()
Variable.tostring()
Variable.unit
Variable.value
- Module contents
BetaNoiseVariable
BetaNoiseVariable.__abs__()
BetaNoiseVariable.__add__()
BetaNoiseVariable.__and__()
BetaNoiseVariable.__array__()
BetaNoiseVariable.__array_priority__
BetaNoiseVariable.__array_wrap__()
BetaNoiseVariable.__bool__()
BetaNoiseVariable.__call__()
BetaNoiseVariable.__div__()
BetaNoiseVariable.__eq__()
BetaNoiseVariable.__float__()
BetaNoiseVariable.__ge__()
BetaNoiseVariable.__getitem__()
BetaNoiseVariable.__getstate__()
BetaNoiseVariable.__gt__()
BetaNoiseVariable.__hash__()
BetaNoiseVariable.__int__()
BetaNoiseVariable.__invert__()
BetaNoiseVariable.__iter__()
BetaNoiseVariable.__le__()
BetaNoiseVariable.__len__()
BetaNoiseVariable.__lt__()
BetaNoiseVariable.__mod__()
BetaNoiseVariable.__mul__()
BetaNoiseVariable.__ne__()
BetaNoiseVariable.__neg__()
BetaNoiseVariable.__new__()
BetaNoiseVariable.__nonzero__()
BetaNoiseVariable.__or__()
BetaNoiseVariable.__pos__()
BetaNoiseVariable.__pow__()
BetaNoiseVariable.__radd__()
BetaNoiseVariable.__rdiv__()
BetaNoiseVariable.__repr__()
BetaNoiseVariable.__rmul__()
BetaNoiseVariable.__rpow__()
BetaNoiseVariable.__rsub__()
BetaNoiseVariable.__rtruediv__()
BetaNoiseVariable.__setitem__()
BetaNoiseVariable.__setstate__()
BetaNoiseVariable.__str__()
BetaNoiseVariable.__sub__()
BetaNoiseVariable.__truediv__()
BetaNoiseVariable.all()
BetaNoiseVariable.allclose()
BetaNoiseVariable.allequal()
BetaNoiseVariable.any()
BetaNoiseVariable.arithmeticFaceValue
BetaNoiseVariable.cacheMe()
BetaNoiseVariable.cellVolumeAverage
BetaNoiseVariable.constrain()
BetaNoiseVariable.constraintMask
BetaNoiseVariable.constraints
BetaNoiseVariable.copy()
BetaNoiseVariable.dontCacheMe()
BetaNoiseVariable.dot()
BetaNoiseVariable.faceGrad
BetaNoiseVariable.faceGradAverage
BetaNoiseVariable.faceValue
BetaNoiseVariable.gaussGrad
BetaNoiseVariable.getsctype()
BetaNoiseVariable.globalValue
BetaNoiseVariable.grad
BetaNoiseVariable.harmonicFaceValue
BetaNoiseVariable.inBaseUnits()
BetaNoiseVariable.inUnitsOf()
BetaNoiseVariable.itemset()
BetaNoiseVariable.itemsize
BetaNoiseVariable.leastSquaresGrad
BetaNoiseVariable.mag
BetaNoiseVariable.max()
BetaNoiseVariable.min()
BetaNoiseVariable.minmodFaceValue
BetaNoiseVariable.name
BetaNoiseVariable.numericValue
BetaNoiseVariable.old
BetaNoiseVariable.parallelRandom()
BetaNoiseVariable.put()
BetaNoiseVariable.random()
BetaNoiseVariable.rank
BetaNoiseVariable.ravel()
BetaNoiseVariable.rdot()
BetaNoiseVariable.release()
BetaNoiseVariable.scramble()
BetaNoiseVariable.setValue()
BetaNoiseVariable.shape
BetaNoiseVariable.std()
BetaNoiseVariable.subscribedVariables
BetaNoiseVariable.sum()
BetaNoiseVariable.take()
BetaNoiseVariable.tostring()
BetaNoiseVariable.unit
BetaNoiseVariable.updateOld()
BetaNoiseVariable.value
CellVariable
CellVariable.__abs__()
CellVariable.__add__()
CellVariable.__and__()
CellVariable.__array__()
CellVariable.__array_priority__
CellVariable.__array_wrap__()
CellVariable.__bool__()
CellVariable.__call__()
CellVariable.__div__()
CellVariable.__eq__()
CellVariable.__float__()
CellVariable.__ge__()
CellVariable.__getitem__()
CellVariable.__getstate__()
CellVariable.__gt__()
CellVariable.__hash__()
CellVariable.__int__()
CellVariable.__invert__()
CellVariable.__iter__()
CellVariable.__le__()
CellVariable.__len__()
CellVariable.__lt__()
CellVariable.__mod__()
CellVariable.__mul__()
CellVariable.__ne__()
CellVariable.__neg__()
CellVariable.__new__()
CellVariable.__nonzero__()
CellVariable.__or__()
CellVariable.__pos__()
CellVariable.__pow__()
CellVariable.__radd__()
CellVariable.__rdiv__()
CellVariable.__repr__()
CellVariable.__rmul__()
CellVariable.__rpow__()
CellVariable.__rsub__()
CellVariable.__rtruediv__()
CellVariable.__setitem__()
CellVariable.__setstate__()
CellVariable.__str__()
CellVariable.__sub__()
CellVariable.__truediv__()
CellVariable.all()
CellVariable.allclose()
CellVariable.allequal()
CellVariable.any()
CellVariable.arithmeticFaceValue
CellVariable.cacheMe()
CellVariable.cellVolumeAverage
CellVariable.constrain()
CellVariable.constraintMask
CellVariable.constraints
CellVariable.copy()
CellVariable.dontCacheMe()
CellVariable.dot()
CellVariable.faceGrad
CellVariable.faceGradAverage
CellVariable.faceValue
CellVariable.gaussGrad
CellVariable.getsctype()
CellVariable.globalValue
CellVariable.grad
CellVariable.harmonicFaceValue
CellVariable.inBaseUnits()
CellVariable.inUnitsOf()
CellVariable.itemset()
CellVariable.itemsize
CellVariable.leastSquaresGrad
CellVariable.mag
CellVariable.max()
CellVariable.min()
CellVariable.minmodFaceValue
CellVariable.name
CellVariable.numericValue
CellVariable.old
CellVariable.put()
CellVariable.rank
CellVariable.ravel()
CellVariable.rdot()
CellVariable.release()
CellVariable.setValue()
CellVariable.shape
CellVariable.std()
CellVariable.subscribedVariables
CellVariable.sum()
CellVariable.take()
CellVariable.tostring()
CellVariable.unit
CellVariable.updateOld()
CellVariable.value
DistanceVariable
DistanceVariable.__abs__()
DistanceVariable.__add__()
DistanceVariable.__and__()
DistanceVariable.__array__()
DistanceVariable.__array_priority__
DistanceVariable.__array_wrap__()
DistanceVariable.__bool__()
DistanceVariable.__call__()
DistanceVariable.__div__()
DistanceVariable.__eq__()
DistanceVariable.__float__()
DistanceVariable.__ge__()
DistanceVariable.__getitem__()
DistanceVariable.__getstate__()
DistanceVariable.__gt__()
DistanceVariable.__hash__()
DistanceVariable.__int__()
DistanceVariable.__invert__()
DistanceVariable.__iter__()
DistanceVariable.__le__()
DistanceVariable.__len__()
DistanceVariable.__lt__()
DistanceVariable.__mod__()
DistanceVariable.__mul__()
DistanceVariable.__ne__()
DistanceVariable.__neg__()
DistanceVariable.__new__()
DistanceVariable.__nonzero__()
DistanceVariable.__or__()
DistanceVariable.__pos__()
DistanceVariable.__pow__()
DistanceVariable.__radd__()
DistanceVariable.__rdiv__()
DistanceVariable.__repr__()
DistanceVariable.__rmul__()
DistanceVariable.__rpow__()
DistanceVariable.__rsub__()
DistanceVariable.__rtruediv__()
DistanceVariable.__setitem__()
DistanceVariable.__setstate__()
DistanceVariable.__str__()
DistanceVariable.__sub__()
DistanceVariable.__truediv__()
DistanceVariable.all()
DistanceVariable.allclose()
DistanceVariable.allequal()
DistanceVariable.any()
DistanceVariable.arithmeticFaceValue
DistanceVariable.cacheMe()
DistanceVariable.calcDistanceFunction()
DistanceVariable.cellInterfaceAreas
DistanceVariable.cellVolumeAverage
DistanceVariable.constrain()
DistanceVariable.constraintMask
DistanceVariable.constraints
DistanceVariable.copy()
DistanceVariable.dontCacheMe()
DistanceVariable.dot()
DistanceVariable.extendVariable()
DistanceVariable.faceGrad
DistanceVariable.faceGradAverage
DistanceVariable.faceValue
DistanceVariable.gaussGrad
DistanceVariable.getLSMshape()
DistanceVariable.getsctype()
DistanceVariable.globalValue
DistanceVariable.grad
DistanceVariable.harmonicFaceValue
DistanceVariable.inBaseUnits()
DistanceVariable.inUnitsOf()
DistanceVariable.itemset()
DistanceVariable.itemsize
DistanceVariable.leastSquaresGrad
DistanceVariable.mag
DistanceVariable.max()
DistanceVariable.min()
DistanceVariable.minmodFaceValue
DistanceVariable.name
DistanceVariable.numericValue
DistanceVariable.old
DistanceVariable.put()
DistanceVariable.rank
DistanceVariable.ravel()
DistanceVariable.rdot()
DistanceVariable.release()
DistanceVariable.setValue()
DistanceVariable.shape
DistanceVariable.std()
DistanceVariable.subscribedVariables
DistanceVariable.sum()
DistanceVariable.take()
DistanceVariable.tostring()
DistanceVariable.unit
DistanceVariable.updateOld()
DistanceVariable.value
ExponentialNoiseVariable
ExponentialNoiseVariable.__abs__()
ExponentialNoiseVariable.__add__()
ExponentialNoiseVariable.__and__()
ExponentialNoiseVariable.__array__()
ExponentialNoiseVariable.__array_priority__
ExponentialNoiseVariable.__array_wrap__()
ExponentialNoiseVariable.__bool__()
ExponentialNoiseVariable.__call__()
ExponentialNoiseVariable.__div__()
ExponentialNoiseVariable.__eq__()
ExponentialNoiseVariable.__float__()
ExponentialNoiseVariable.__ge__()
ExponentialNoiseVariable.__getitem__()
ExponentialNoiseVariable.__getstate__()
ExponentialNoiseVariable.__gt__()
ExponentialNoiseVariable.__hash__()
ExponentialNoiseVariable.__int__()
ExponentialNoiseVariable.__invert__()
ExponentialNoiseVariable.__iter__()
ExponentialNoiseVariable.__le__()
ExponentialNoiseVariable.__len__()
ExponentialNoiseVariable.__lt__()
ExponentialNoiseVariable.__mod__()
ExponentialNoiseVariable.__mul__()
ExponentialNoiseVariable.__ne__()
ExponentialNoiseVariable.__neg__()
ExponentialNoiseVariable.__new__()
ExponentialNoiseVariable.__nonzero__()
ExponentialNoiseVariable.__or__()
ExponentialNoiseVariable.__pos__()
ExponentialNoiseVariable.__pow__()
ExponentialNoiseVariable.__radd__()
ExponentialNoiseVariable.__rdiv__()
ExponentialNoiseVariable.__repr__()
ExponentialNoiseVariable.__rmul__()
ExponentialNoiseVariable.__rpow__()
ExponentialNoiseVariable.__rsub__()
ExponentialNoiseVariable.__rtruediv__()
ExponentialNoiseVariable.__setitem__()
ExponentialNoiseVariable.__setstate__()
ExponentialNoiseVariable.__str__()
ExponentialNoiseVariable.__sub__()
ExponentialNoiseVariable.__truediv__()
ExponentialNoiseVariable.all()
ExponentialNoiseVariable.allclose()
ExponentialNoiseVariable.allequal()
ExponentialNoiseVariable.any()
ExponentialNoiseVariable.arithmeticFaceValue
ExponentialNoiseVariable.cacheMe()
ExponentialNoiseVariable.cellVolumeAverage
ExponentialNoiseVariable.constrain()
ExponentialNoiseVariable.constraintMask
ExponentialNoiseVariable.constraints
ExponentialNoiseVariable.copy()
ExponentialNoiseVariable.dontCacheMe()
ExponentialNoiseVariable.dot()
ExponentialNoiseVariable.faceGrad
ExponentialNoiseVariable.faceGradAverage
ExponentialNoiseVariable.faceValue
ExponentialNoiseVariable.gaussGrad
ExponentialNoiseVariable.getsctype()
ExponentialNoiseVariable.globalValue
ExponentialNoiseVariable.grad
ExponentialNoiseVariable.harmonicFaceValue
ExponentialNoiseVariable.inBaseUnits()
ExponentialNoiseVariable.inUnitsOf()
ExponentialNoiseVariable.itemset()
ExponentialNoiseVariable.itemsize
ExponentialNoiseVariable.leastSquaresGrad
ExponentialNoiseVariable.mag
ExponentialNoiseVariable.max()
ExponentialNoiseVariable.min()
ExponentialNoiseVariable.minmodFaceValue
ExponentialNoiseVariable.name
ExponentialNoiseVariable.numericValue
ExponentialNoiseVariable.old
ExponentialNoiseVariable.parallelRandom()
ExponentialNoiseVariable.put()
ExponentialNoiseVariable.random()
ExponentialNoiseVariable.rank
ExponentialNoiseVariable.ravel()
ExponentialNoiseVariable.rdot()
ExponentialNoiseVariable.release()
ExponentialNoiseVariable.scramble()
ExponentialNoiseVariable.setValue()
ExponentialNoiseVariable.shape
ExponentialNoiseVariable.std()
ExponentialNoiseVariable.subscribedVariables
ExponentialNoiseVariable.sum()
ExponentialNoiseVariable.take()
ExponentialNoiseVariable.tostring()
ExponentialNoiseVariable.unit
ExponentialNoiseVariable.updateOld()
ExponentialNoiseVariable.value
FaceVariable
FaceVariable.__abs__()
FaceVariable.__add__()
FaceVariable.__and__()
FaceVariable.__array__()
FaceVariable.__array_priority__
FaceVariable.__array_wrap__()
FaceVariable.__bool__()
FaceVariable.__call__()
FaceVariable.__div__()
FaceVariable.__eq__()
FaceVariable.__float__()
FaceVariable.__ge__()
FaceVariable.__getitem__()
FaceVariable.__getstate__()
FaceVariable.__gt__()
FaceVariable.__hash__()
FaceVariable.__int__()
FaceVariable.__invert__()
FaceVariable.__iter__()
FaceVariable.__le__()
FaceVariable.__len__()
FaceVariable.__lt__()
FaceVariable.__mod__()
FaceVariable.__mul__()
FaceVariable.__ne__()
FaceVariable.__neg__()
FaceVariable.__new__()
FaceVariable.__nonzero__()
FaceVariable.__or__()
FaceVariable.__pos__()
FaceVariable.__pow__()
FaceVariable.__radd__()
FaceVariable.__rdiv__()
FaceVariable.__repr__()
FaceVariable.__rmul__()
FaceVariable.__rpow__()
FaceVariable.__rsub__()
FaceVariable.__rtruediv__()
FaceVariable.__setitem__()
FaceVariable.__setstate__()
FaceVariable.__str__()
FaceVariable.__sub__()
FaceVariable.__truediv__()
FaceVariable.all()
FaceVariable.allclose()
FaceVariable.allequal()
FaceVariable.any()
FaceVariable.cacheMe()
FaceVariable.constrain()
FaceVariable.constraintMask
FaceVariable.constraints
FaceVariable.copy()
FaceVariable.divergence
FaceVariable.dontCacheMe()
FaceVariable.dot()
FaceVariable.getsctype()
FaceVariable.globalValue
FaceVariable.inBaseUnits()
FaceVariable.inUnitsOf()
FaceVariable.itemset()
FaceVariable.itemsize
FaceVariable.mag
FaceVariable.max()
FaceVariable.min()
FaceVariable.name
FaceVariable.numericValue
FaceVariable.put()
FaceVariable.rank
FaceVariable.ravel()
FaceVariable.rdot()
FaceVariable.release()
FaceVariable.setValue()
FaceVariable.shape
FaceVariable.std()
FaceVariable.subscribedVariables
FaceVariable.sum()
FaceVariable.take()
FaceVariable.tostring()
FaceVariable.unit
FaceVariable.value
GammaNoiseVariable
GammaNoiseVariable.__abs__()
GammaNoiseVariable.__add__()
GammaNoiseVariable.__and__()
GammaNoiseVariable.__array__()
GammaNoiseVariable.__array_priority__
GammaNoiseVariable.__array_wrap__()
GammaNoiseVariable.__bool__()
GammaNoiseVariable.__call__()
GammaNoiseVariable.__div__()
GammaNoiseVariable.__eq__()
GammaNoiseVariable.__float__()
GammaNoiseVariable.__ge__()
GammaNoiseVariable.__getitem__()
GammaNoiseVariable.__getstate__()
GammaNoiseVariable.__gt__()
GammaNoiseVariable.__hash__()
GammaNoiseVariable.__int__()
GammaNoiseVariable.__invert__()
GammaNoiseVariable.__iter__()
GammaNoiseVariable.__le__()
GammaNoiseVariable.__len__()
GammaNoiseVariable.__lt__()
GammaNoiseVariable.__mod__()
GammaNoiseVariable.__mul__()
GammaNoiseVariable.__ne__()
GammaNoiseVariable.__neg__()
GammaNoiseVariable.__new__()
GammaNoiseVariable.__nonzero__()
GammaNoiseVariable.__or__()
GammaNoiseVariable.__pos__()
GammaNoiseVariable.__pow__()
GammaNoiseVariable.__radd__()
GammaNoiseVariable.__rdiv__()
GammaNoiseVariable.__repr__()
GammaNoiseVariable.__rmul__()
GammaNoiseVariable.__rpow__()
GammaNoiseVariable.__rsub__()
GammaNoiseVariable.__rtruediv__()
GammaNoiseVariable.__setitem__()
GammaNoiseVariable.__setstate__()
GammaNoiseVariable.__str__()
GammaNoiseVariable.__sub__()
GammaNoiseVariable.__truediv__()
GammaNoiseVariable.all()
GammaNoiseVariable.allclose()
GammaNoiseVariable.allequal()
GammaNoiseVariable.any()
GammaNoiseVariable.arithmeticFaceValue
GammaNoiseVariable.cacheMe()
GammaNoiseVariable.cellVolumeAverage
GammaNoiseVariable.constrain()
GammaNoiseVariable.constraintMask
GammaNoiseVariable.constraints
GammaNoiseVariable.copy()
GammaNoiseVariable.dontCacheMe()
GammaNoiseVariable.dot()
GammaNoiseVariable.faceGrad
GammaNoiseVariable.faceGradAverage
GammaNoiseVariable.faceValue
GammaNoiseVariable.gaussGrad
GammaNoiseVariable.getsctype()
GammaNoiseVariable.globalValue
GammaNoiseVariable.grad
GammaNoiseVariable.harmonicFaceValue
GammaNoiseVariable.inBaseUnits()
GammaNoiseVariable.inUnitsOf()
GammaNoiseVariable.itemset()
GammaNoiseVariable.itemsize
GammaNoiseVariable.leastSquaresGrad
GammaNoiseVariable.mag
GammaNoiseVariable.max()
GammaNoiseVariable.min()
GammaNoiseVariable.minmodFaceValue
GammaNoiseVariable.name
GammaNoiseVariable.numericValue
GammaNoiseVariable.old
GammaNoiseVariable.parallelRandom()
GammaNoiseVariable.put()
GammaNoiseVariable.random()
GammaNoiseVariable.rank
GammaNoiseVariable.ravel()
GammaNoiseVariable.rdot()
GammaNoiseVariable.release()
GammaNoiseVariable.scramble()
GammaNoiseVariable.setValue()
GammaNoiseVariable.shape
GammaNoiseVariable.std()
GammaNoiseVariable.subscribedVariables
GammaNoiseVariable.sum()
GammaNoiseVariable.take()
GammaNoiseVariable.tostring()
GammaNoiseVariable.unit
GammaNoiseVariable.updateOld()
GammaNoiseVariable.value
GaussianNoiseVariable
GaussianNoiseVariable.__abs__()
GaussianNoiseVariable.__add__()
GaussianNoiseVariable.__and__()
GaussianNoiseVariable.__array__()
GaussianNoiseVariable.__array_priority__
GaussianNoiseVariable.__array_wrap__()
GaussianNoiseVariable.__bool__()
GaussianNoiseVariable.__call__()
GaussianNoiseVariable.__div__()
GaussianNoiseVariable.__eq__()
GaussianNoiseVariable.__float__()
GaussianNoiseVariable.__ge__()
GaussianNoiseVariable.__getitem__()
GaussianNoiseVariable.__getstate__()
GaussianNoiseVariable.__gt__()
GaussianNoiseVariable.__hash__()
GaussianNoiseVariable.__int__()
GaussianNoiseVariable.__invert__()
GaussianNoiseVariable.__iter__()
GaussianNoiseVariable.__le__()
GaussianNoiseVariable.__len__()
GaussianNoiseVariable.__lt__()
GaussianNoiseVariable.__mod__()
GaussianNoiseVariable.__mul__()
GaussianNoiseVariable.__ne__()
GaussianNoiseVariable.__neg__()
GaussianNoiseVariable.__new__()
GaussianNoiseVariable.__nonzero__()
GaussianNoiseVariable.__or__()
GaussianNoiseVariable.__pos__()
GaussianNoiseVariable.__pow__()
GaussianNoiseVariable.__radd__()
GaussianNoiseVariable.__rdiv__()
GaussianNoiseVariable.__repr__()
GaussianNoiseVariable.__rmul__()
GaussianNoiseVariable.__rpow__()
GaussianNoiseVariable.__rsub__()
GaussianNoiseVariable.__rtruediv__()
GaussianNoiseVariable.__setitem__()
GaussianNoiseVariable.__setstate__()
GaussianNoiseVariable.__str__()
GaussianNoiseVariable.__sub__()
GaussianNoiseVariable.__truediv__()
GaussianNoiseVariable.all()
GaussianNoiseVariable.allclose()
GaussianNoiseVariable.allequal()
GaussianNoiseVariable.any()
GaussianNoiseVariable.arithmeticFaceValue
GaussianNoiseVariable.cacheMe()
GaussianNoiseVariable.cellVolumeAverage
GaussianNoiseVariable.constrain()
GaussianNoiseVariable.constraintMask
GaussianNoiseVariable.constraints
GaussianNoiseVariable.copy()
GaussianNoiseVariable.dontCacheMe()
GaussianNoiseVariable.dot()
GaussianNoiseVariable.faceGrad
GaussianNoiseVariable.faceGradAverage
GaussianNoiseVariable.faceValue
GaussianNoiseVariable.gaussGrad
GaussianNoiseVariable.getsctype()
GaussianNoiseVariable.globalValue
GaussianNoiseVariable.grad
GaussianNoiseVariable.harmonicFaceValue
GaussianNoiseVariable.inBaseUnits()
GaussianNoiseVariable.inUnitsOf()
GaussianNoiseVariable.itemset()
GaussianNoiseVariable.itemsize
GaussianNoiseVariable.leastSquaresGrad
GaussianNoiseVariable.mag
GaussianNoiseVariable.max()
GaussianNoiseVariable.min()
GaussianNoiseVariable.minmodFaceValue
GaussianNoiseVariable.name
GaussianNoiseVariable.numericValue
GaussianNoiseVariable.old
GaussianNoiseVariable.parallelRandom()
GaussianNoiseVariable.put()
GaussianNoiseVariable.random()
GaussianNoiseVariable.rank
GaussianNoiseVariable.ravel()
GaussianNoiseVariable.rdot()
GaussianNoiseVariable.release()
GaussianNoiseVariable.scramble()
GaussianNoiseVariable.setValue()
GaussianNoiseVariable.shape
GaussianNoiseVariable.std()
GaussianNoiseVariable.subscribedVariables
GaussianNoiseVariable.sum()
GaussianNoiseVariable.take()
GaussianNoiseVariable.tostring()
GaussianNoiseVariable.unit
GaussianNoiseVariable.updateOld()
GaussianNoiseVariable.value
HistogramVariable
HistogramVariable.__abs__()
HistogramVariable.__add__()
HistogramVariable.__and__()
HistogramVariable.__array__()
HistogramVariable.__array_priority__
HistogramVariable.__array_wrap__()
HistogramVariable.__bool__()
HistogramVariable.__call__()
HistogramVariable.__div__()
HistogramVariable.__eq__()
HistogramVariable.__float__()
HistogramVariable.__ge__()
HistogramVariable.__getitem__()
HistogramVariable.__getstate__()
HistogramVariable.__gt__()
HistogramVariable.__hash__()
HistogramVariable.__int__()
HistogramVariable.__invert__()
HistogramVariable.__iter__()
HistogramVariable.__le__()
HistogramVariable.__len__()
HistogramVariable.__lt__()
HistogramVariable.__mod__()
HistogramVariable.__mul__()
HistogramVariable.__ne__()
HistogramVariable.__neg__()
HistogramVariable.__new__()
HistogramVariable.__nonzero__()
HistogramVariable.__or__()
HistogramVariable.__pos__()
HistogramVariable.__pow__()
HistogramVariable.__radd__()
HistogramVariable.__rdiv__()
HistogramVariable.__repr__()
HistogramVariable.__rmul__()
HistogramVariable.__rpow__()
HistogramVariable.__rsub__()
HistogramVariable.__rtruediv__()
HistogramVariable.__setitem__()
HistogramVariable.__setstate__()
HistogramVariable.__str__()
HistogramVariable.__sub__()
HistogramVariable.__truediv__()
HistogramVariable.all()
HistogramVariable.allclose()
HistogramVariable.allequal()
HistogramVariable.any()
HistogramVariable.arithmeticFaceValue
HistogramVariable.cacheMe()
HistogramVariable.cellVolumeAverage
HistogramVariable.constrain()
HistogramVariable.constraintMask
HistogramVariable.constraints
HistogramVariable.copy()
HistogramVariable.dontCacheMe()
HistogramVariable.dot()
HistogramVariable.faceGrad
HistogramVariable.faceGradAverage
HistogramVariable.faceValue
HistogramVariable.gaussGrad
HistogramVariable.getsctype()
HistogramVariable.globalValue
HistogramVariable.grad
HistogramVariable.harmonicFaceValue
HistogramVariable.inBaseUnits()
HistogramVariable.inUnitsOf()
HistogramVariable.itemset()
HistogramVariable.itemsize
HistogramVariable.leastSquaresGrad
HistogramVariable.mag
HistogramVariable.max()
HistogramVariable.min()
HistogramVariable.minmodFaceValue
HistogramVariable.name
HistogramVariable.numericValue
HistogramVariable.old
HistogramVariable.put()
HistogramVariable.rank
HistogramVariable.ravel()
HistogramVariable.rdot()
HistogramVariable.release()
HistogramVariable.setValue()
HistogramVariable.shape
HistogramVariable.std()
HistogramVariable.subscribedVariables
HistogramVariable.sum()
HistogramVariable.take()
HistogramVariable.tostring()
HistogramVariable.unit
HistogramVariable.updateOld()
HistogramVariable.value
ModularVariable
ModularVariable.__abs__()
ModularVariable.__add__()
ModularVariable.__and__()
ModularVariable.__array__()
ModularVariable.__array_priority__
ModularVariable.__array_wrap__()
ModularVariable.__bool__()
ModularVariable.__call__()
ModularVariable.__div__()
ModularVariable.__eq__()
ModularVariable.__float__()
ModularVariable.__ge__()
ModularVariable.__getitem__()
ModularVariable.__getstate__()
ModularVariable.__gt__()
ModularVariable.__hash__()
ModularVariable.__int__()
ModularVariable.__invert__()
ModularVariable.__iter__()
ModularVariable.__le__()
ModularVariable.__len__()
ModularVariable.__lt__()
ModularVariable.__mod__()
ModularVariable.__mul__()
ModularVariable.__ne__()
ModularVariable.__neg__()
ModularVariable.__new__()
ModularVariable.__nonzero__()
ModularVariable.__or__()
ModularVariable.__pos__()
ModularVariable.__pow__()
ModularVariable.__radd__()
ModularVariable.__rdiv__()
ModularVariable.__repr__()
ModularVariable.__rmul__()
ModularVariable.__rpow__()
ModularVariable.__rsub__()
ModularVariable.__rtruediv__()
ModularVariable.__setitem__()
ModularVariable.__setstate__()
ModularVariable.__str__()
ModularVariable.__sub__()
ModularVariable.__truediv__()
ModularVariable.all()
ModularVariable.allclose()
ModularVariable.allequal()
ModularVariable.any()
ModularVariable.arithmeticFaceValue
ModularVariable.cacheMe()
ModularVariable.cellVolumeAverage
ModularVariable.constrain()
ModularVariable.constraintMask
ModularVariable.constraints
ModularVariable.copy()
ModularVariable.dontCacheMe()
ModularVariable.dot()
ModularVariable.faceGrad
ModularVariable.faceGradAverage
ModularVariable.faceGradNoMod
ModularVariable.faceValue
ModularVariable.gaussGrad
ModularVariable.getsctype()
ModularVariable.globalValue
ModularVariable.grad
ModularVariable.harmonicFaceValue
ModularVariable.inBaseUnits()
ModularVariable.inUnitsOf()
ModularVariable.itemset()
ModularVariable.itemsize
ModularVariable.leastSquaresGrad
ModularVariable.mag
ModularVariable.max()
ModularVariable.min()
ModularVariable.minmodFaceValue
ModularVariable.name
ModularVariable.numericValue
ModularVariable.old
ModularVariable.put()
ModularVariable.rank
ModularVariable.ravel()
ModularVariable.rdot()
ModularVariable.release()
ModularVariable.setValue()
ModularVariable.shape
ModularVariable.std()
ModularVariable.subscribedVariables
ModularVariable.sum()
ModularVariable.take()
ModularVariable.tostring()
ModularVariable.unit
ModularVariable.updateOld()
ModularVariable.value
ScharfetterGummelFaceVariable
ScharfetterGummelFaceVariable.__abs__()
ScharfetterGummelFaceVariable.__add__()
ScharfetterGummelFaceVariable.__and__()
ScharfetterGummelFaceVariable.__array__()
ScharfetterGummelFaceVariable.__array_priority__
ScharfetterGummelFaceVariable.__array_wrap__()
ScharfetterGummelFaceVariable.__bool__()
ScharfetterGummelFaceVariable.__call__()
ScharfetterGummelFaceVariable.__div__()
ScharfetterGummelFaceVariable.__eq__()
ScharfetterGummelFaceVariable.__float__()
ScharfetterGummelFaceVariable.__ge__()
ScharfetterGummelFaceVariable.__getitem__()
ScharfetterGummelFaceVariable.__getstate__()
ScharfetterGummelFaceVariable.__gt__()
ScharfetterGummelFaceVariable.__hash__()
ScharfetterGummelFaceVariable.__int__()
ScharfetterGummelFaceVariable.__invert__()
ScharfetterGummelFaceVariable.__iter__()
ScharfetterGummelFaceVariable.__le__()
ScharfetterGummelFaceVariable.__len__()
ScharfetterGummelFaceVariable.__lt__()
ScharfetterGummelFaceVariable.__mod__()
ScharfetterGummelFaceVariable.__mul__()
ScharfetterGummelFaceVariable.__ne__()
ScharfetterGummelFaceVariable.__neg__()
ScharfetterGummelFaceVariable.__new__()
ScharfetterGummelFaceVariable.__nonzero__()
ScharfetterGummelFaceVariable.__or__()
ScharfetterGummelFaceVariable.__pos__()
ScharfetterGummelFaceVariable.__pow__()
ScharfetterGummelFaceVariable.__radd__()
ScharfetterGummelFaceVariable.__rdiv__()
ScharfetterGummelFaceVariable.__repr__()
ScharfetterGummelFaceVariable.__rmul__()
ScharfetterGummelFaceVariable.__rpow__()
ScharfetterGummelFaceVariable.__rsub__()
ScharfetterGummelFaceVariable.__rtruediv__()
ScharfetterGummelFaceVariable.__setitem__()
ScharfetterGummelFaceVariable.__setstate__()
ScharfetterGummelFaceVariable.__str__()
ScharfetterGummelFaceVariable.__sub__()
ScharfetterGummelFaceVariable.__truediv__()
ScharfetterGummelFaceVariable.all()
ScharfetterGummelFaceVariable.allclose()
ScharfetterGummelFaceVariable.allequal()
ScharfetterGummelFaceVariable.any()
ScharfetterGummelFaceVariable.cacheMe()
ScharfetterGummelFaceVariable.constrain()
ScharfetterGummelFaceVariable.constraintMask
ScharfetterGummelFaceVariable.constraints
ScharfetterGummelFaceVariable.copy()
ScharfetterGummelFaceVariable.divergence
ScharfetterGummelFaceVariable.dontCacheMe()
ScharfetterGummelFaceVariable.dot()
ScharfetterGummelFaceVariable.getsctype()
ScharfetterGummelFaceVariable.globalValue
ScharfetterGummelFaceVariable.inBaseUnits()
ScharfetterGummelFaceVariable.inUnitsOf()
ScharfetterGummelFaceVariable.itemset()
ScharfetterGummelFaceVariable.itemsize
ScharfetterGummelFaceVariable.mag
ScharfetterGummelFaceVariable.max()
ScharfetterGummelFaceVariable.min()
ScharfetterGummelFaceVariable.name
ScharfetterGummelFaceVariable.numericValue
ScharfetterGummelFaceVariable.put()
ScharfetterGummelFaceVariable.rank
ScharfetterGummelFaceVariable.ravel()
ScharfetterGummelFaceVariable.rdot()
ScharfetterGummelFaceVariable.release()
ScharfetterGummelFaceVariable.setValue()
ScharfetterGummelFaceVariable.shape
ScharfetterGummelFaceVariable.std()
ScharfetterGummelFaceVariable.subscribedVariables
ScharfetterGummelFaceVariable.sum()
ScharfetterGummelFaceVariable.take()
ScharfetterGummelFaceVariable.tostring()
ScharfetterGummelFaceVariable.unit
ScharfetterGummelFaceVariable.value
SurfactantConvectionVariable
SurfactantConvectionVariable.__abs__()
SurfactantConvectionVariable.__add__()
SurfactantConvectionVariable.__and__()
SurfactantConvectionVariable.__array__()
SurfactantConvectionVariable.__array_priority__
SurfactantConvectionVariable.__array_wrap__()
SurfactantConvectionVariable.__bool__()
SurfactantConvectionVariable.__call__()
SurfactantConvectionVariable.__div__()
SurfactantConvectionVariable.__eq__()
SurfactantConvectionVariable.__float__()
SurfactantConvectionVariable.__ge__()
SurfactantConvectionVariable.__getitem__()
SurfactantConvectionVariable.__getstate__()
SurfactantConvectionVariable.__gt__()
SurfactantConvectionVariable.__hash__()
SurfactantConvectionVariable.__int__()
SurfactantConvectionVariable.__invert__()
SurfactantConvectionVariable.__iter__()
SurfactantConvectionVariable.__le__()
SurfactantConvectionVariable.__len__()
SurfactantConvectionVariable.__lt__()
SurfactantConvectionVariable.__mod__()
SurfactantConvectionVariable.__mul__()
SurfactantConvectionVariable.__ne__()
SurfactantConvectionVariable.__neg__()
SurfactantConvectionVariable.__new__()
SurfactantConvectionVariable.__nonzero__()
SurfactantConvectionVariable.__or__()
SurfactantConvectionVariable.__pos__()
SurfactantConvectionVariable.__pow__()
SurfactantConvectionVariable.__radd__()
SurfactantConvectionVariable.__rdiv__()
SurfactantConvectionVariable.__repr__()
SurfactantConvectionVariable.__rmul__()
SurfactantConvectionVariable.__rpow__()
SurfactantConvectionVariable.__rsub__()
SurfactantConvectionVariable.__rtruediv__()
SurfactantConvectionVariable.__setitem__()
SurfactantConvectionVariable.__setstate__()
SurfactantConvectionVariable.__str__()
SurfactantConvectionVariable.__sub__()
SurfactantConvectionVariable.__truediv__()
SurfactantConvectionVariable.all()
SurfactantConvectionVariable.allclose()
SurfactantConvectionVariable.allequal()
SurfactantConvectionVariable.any()
SurfactantConvectionVariable.cacheMe()
SurfactantConvectionVariable.constrain()
SurfactantConvectionVariable.constraintMask
SurfactantConvectionVariable.constraints
SurfactantConvectionVariable.copy()
SurfactantConvectionVariable.divergence
SurfactantConvectionVariable.dontCacheMe()
SurfactantConvectionVariable.dot()
SurfactantConvectionVariable.getsctype()
SurfactantConvectionVariable.globalValue
SurfactantConvectionVariable.inBaseUnits()
SurfactantConvectionVariable.inUnitsOf()
SurfactantConvectionVariable.itemset()
SurfactantConvectionVariable.itemsize
SurfactantConvectionVariable.mag
SurfactantConvectionVariable.max()
SurfactantConvectionVariable.min()
SurfactantConvectionVariable.name
SurfactantConvectionVariable.numericValue
SurfactantConvectionVariable.put()
SurfactantConvectionVariable.rank
SurfactantConvectionVariable.ravel()
SurfactantConvectionVariable.rdot()
SurfactantConvectionVariable.release()
SurfactantConvectionVariable.setValue()
SurfactantConvectionVariable.shape
SurfactantConvectionVariable.std()
SurfactantConvectionVariable.subscribedVariables
SurfactantConvectionVariable.sum()
SurfactantConvectionVariable.take()
SurfactantConvectionVariable.tostring()
SurfactantConvectionVariable.unit
SurfactantConvectionVariable.value
SurfactantVariable
SurfactantVariable.__abs__()
SurfactantVariable.__add__()
SurfactantVariable.__and__()
SurfactantVariable.__array__()
SurfactantVariable.__array_priority__
SurfactantVariable.__array_wrap__()
SurfactantVariable.__bool__()
SurfactantVariable.__call__()
SurfactantVariable.__div__()
SurfactantVariable.__eq__()
SurfactantVariable.__float__()
SurfactantVariable.__ge__()
SurfactantVariable.__getitem__()
SurfactantVariable.__getstate__()
SurfactantVariable.__gt__()
SurfactantVariable.__hash__()
SurfactantVariable.__int__()
SurfactantVariable.__invert__()
SurfactantVariable.__iter__()
SurfactantVariable.__le__()
SurfactantVariable.__len__()
SurfactantVariable.__lt__()
SurfactantVariable.__mod__()
SurfactantVariable.__mul__()
SurfactantVariable.__ne__()
SurfactantVariable.__neg__()
SurfactantVariable.__new__()
SurfactantVariable.__nonzero__()
SurfactantVariable.__or__()
SurfactantVariable.__pos__()
SurfactantVariable.__pow__()
SurfactantVariable.__radd__()
SurfactantVariable.__rdiv__()
SurfactantVariable.__repr__()
SurfactantVariable.__rmul__()
SurfactantVariable.__rpow__()
SurfactantVariable.__rsub__()
SurfactantVariable.__rtruediv__()
SurfactantVariable.__setitem__()
SurfactantVariable.__setstate__()
SurfactantVariable.__str__()
SurfactantVariable.__sub__()
SurfactantVariable.__truediv__()
SurfactantVariable.all()
SurfactantVariable.allclose()
SurfactantVariable.allequal()
SurfactantVariable.any()
SurfactantVariable.arithmeticFaceValue
SurfactantVariable.cacheMe()
SurfactantVariable.cellVolumeAverage
SurfactantVariable.constrain()
SurfactantVariable.constraintMask
SurfactantVariable.constraints
SurfactantVariable.copy()
SurfactantVariable.dontCacheMe()
SurfactantVariable.dot()
SurfactantVariable.faceGrad
SurfactantVariable.faceGradAverage
SurfactantVariable.faceValue
SurfactantVariable.gaussGrad
SurfactantVariable.getsctype()
SurfactantVariable.globalValue
SurfactantVariable.grad
SurfactantVariable.harmonicFaceValue
SurfactantVariable.inBaseUnits()
SurfactantVariable.inUnitsOf()
SurfactantVariable.interfaceVar
SurfactantVariable.itemset()
SurfactantVariable.itemsize
SurfactantVariable.leastSquaresGrad
SurfactantVariable.mag
SurfactantVariable.max()
SurfactantVariable.min()
SurfactantVariable.minmodFaceValue
SurfactantVariable.name
SurfactantVariable.numericValue
SurfactantVariable.old
SurfactantVariable.put()
SurfactantVariable.rank
SurfactantVariable.ravel()
SurfactantVariable.rdot()
SurfactantVariable.release()
SurfactantVariable.setValue()
SurfactantVariable.shape
SurfactantVariable.std()
SurfactantVariable.subscribedVariables
SurfactantVariable.sum()
SurfactantVariable.take()
SurfactantVariable.tostring()
SurfactantVariable.unit
SurfactantVariable.updateOld()
SurfactantVariable.value
UniformNoiseVariable
UniformNoiseVariable.__abs__()
UniformNoiseVariable.__add__()
UniformNoiseVariable.__and__()
UniformNoiseVariable.__array__()
UniformNoiseVariable.__array_priority__
UniformNoiseVariable.__array_wrap__()
UniformNoiseVariable.__bool__()
UniformNoiseVariable.__call__()
UniformNoiseVariable.__div__()
UniformNoiseVariable.__eq__()
UniformNoiseVariable.__float__()
UniformNoiseVariable.__ge__()
UniformNoiseVariable.__getitem__()
UniformNoiseVariable.__getstate__()
UniformNoiseVariable.__gt__()
UniformNoiseVariable.__hash__()
UniformNoiseVariable.__int__()
UniformNoiseVariable.__invert__()
UniformNoiseVariable.__iter__()
UniformNoiseVariable.__le__()
UniformNoiseVariable.__len__()
UniformNoiseVariable.__lt__()
UniformNoiseVariable.__mod__()
UniformNoiseVariable.__mul__()
UniformNoiseVariable.__ne__()
UniformNoiseVariable.__neg__()
UniformNoiseVariable.__new__()
UniformNoiseVariable.__nonzero__()
UniformNoiseVariable.__or__()
UniformNoiseVariable.__pos__()
UniformNoiseVariable.__pow__()
UniformNoiseVariable.__radd__()
UniformNoiseVariable.__rdiv__()
UniformNoiseVariable.__repr__()
UniformNoiseVariable.__rmul__()
UniformNoiseVariable.__rpow__()
UniformNoiseVariable.__rsub__()
UniformNoiseVariable.__rtruediv__()
UniformNoiseVariable.__setitem__()
UniformNoiseVariable.__setstate__()
UniformNoiseVariable.__str__()
UniformNoiseVariable.__sub__()
UniformNoiseVariable.__truediv__()
UniformNoiseVariable.all()
UniformNoiseVariable.allclose()
UniformNoiseVariable.allequal()
UniformNoiseVariable.any()
UniformNoiseVariable.arithmeticFaceValue
UniformNoiseVariable.cacheMe()
UniformNoiseVariable.cellVolumeAverage
UniformNoiseVariable.constrain()
UniformNoiseVariable.constraintMask
UniformNoiseVariable.constraints
UniformNoiseVariable.copy()
UniformNoiseVariable.dontCacheMe()
UniformNoiseVariable.dot()
UniformNoiseVariable.faceGrad
UniformNoiseVariable.faceGradAverage
UniformNoiseVariable.faceValue
UniformNoiseVariable.gaussGrad
UniformNoiseVariable.getsctype()
UniformNoiseVariable.globalValue
UniformNoiseVariable.grad
UniformNoiseVariable.harmonicFaceValue
UniformNoiseVariable.inBaseUnits()
UniformNoiseVariable.inUnitsOf()
UniformNoiseVariable.itemset()
UniformNoiseVariable.itemsize
UniformNoiseVariable.leastSquaresGrad
UniformNoiseVariable.mag
UniformNoiseVariable.max()
UniformNoiseVariable.min()
UniformNoiseVariable.minmodFaceValue
UniformNoiseVariable.name
UniformNoiseVariable.numericValue
UniformNoiseVariable.old
UniformNoiseVariable.parallelRandom()
UniformNoiseVariable.put()
UniformNoiseVariable.random()
UniformNoiseVariable.rank
UniformNoiseVariable.ravel()
UniformNoiseVariable.rdot()
UniformNoiseVariable.release()
UniformNoiseVariable.scramble()
UniformNoiseVariable.setValue()
UniformNoiseVariable.shape
UniformNoiseVariable.std()
UniformNoiseVariable.subscribedVariables
UniformNoiseVariable.sum()
UniformNoiseVariable.take()
UniformNoiseVariable.tostring()
UniformNoiseVariable.unit
UniformNoiseVariable.updateOld()
UniformNoiseVariable.value
Variable
Variable.__abs__()
Variable.__add__()
Variable.__and__()
Variable.__array__()
Variable.__array_priority__
Variable.__array_wrap__()
Variable.__bool__()
Variable.__call__()
Variable.__div__()
Variable.__eq__()
Variable.__float__()
Variable.__ge__()
Variable.__getitem__()
Variable.__getstate__()
Variable.__gt__()
Variable.__hash__()
Variable.__int__()
Variable.__invert__()
Variable.__iter__()
Variable.__le__()
Variable.__len__()
Variable.__lt__()
Variable.__mod__()
Variable.__mul__()
Variable.__ne__()
Variable.__neg__()
Variable.__new__()
Variable.__nonzero__()
Variable.__or__()
Variable.__pos__()
Variable.__pow__()
Variable.__radd__()
Variable.__rdiv__()
Variable.__repr__()
Variable.__rmul__()
Variable.__rpow__()
Variable.__rsub__()
Variable.__rtruediv__()
Variable.__setitem__()
Variable.__setstate__()
Variable.__str__()
Variable.__sub__()
Variable.__truediv__()
Variable.all()
Variable.allclose()
Variable.allequal()
Variable.any()
Variable.cacheMe()
Variable.constrain()
Variable.constraints
Variable.copy()
Variable.dontCacheMe()
Variable.dot()
Variable.getsctype()
Variable.inBaseUnits()
Variable.inUnitsOf()
Variable.itemset()
Variable.itemsize
Variable.mag
Variable.max()
Variable.min()
Variable.name
Variable.numericValue
Variable.put()
Variable.ravel()
Variable.release()
Variable.setValue()
Variable.shape
Variable.std()
Variable.subscribedVariables
Variable.sum()
Variable.take()
Variable.tostring()
Variable.unit
Variable.value
- fipy.viewers package
- Subpackages
- fipy.viewers.matplotlibViewer package
- Submodules
- fipy.viewers.matplotlibViewer.matplotlib1DViewer module
- fipy.viewers.matplotlibViewer.matplotlib2DContourViewer module
- fipy.viewers.matplotlibViewer.matplotlib2DGridContourViewer module
- fipy.viewers.matplotlibViewer.matplotlib2DGridViewer module
- fipy.viewers.matplotlibViewer.matplotlib2DViewer module
- fipy.viewers.matplotlibViewer.matplotlibSparseMatrixViewer module
- fipy.viewers.matplotlibViewer.matplotlibStreamViewer module
- fipy.viewers.matplotlibViewer.matplotlibVectorViewer module
- fipy.viewers.matplotlibViewer.matplotlibViewer module
- fipy.viewers.matplotlibViewer.test module
- Module contents
- fipy.viewers.mayaviViewer package
- fipy.viewers.vtkViewer package
- fipy.viewers.matplotlibViewer package
- Submodules
- fipy.viewers.multiViewer module
- fipy.viewers.test module
- fipy.viewers.testinteractive module
- fipy.viewers.tsvViewer module
- fipy.viewers.viewer module
- Module contents
DummyViewer
Matplotlib1DViewer
Matplotlib1DViewer.axes
Matplotlib1DViewer.cmap
Matplotlib1DViewer.colorbar
Matplotlib1DViewer.fig
Matplotlib1DViewer.figaspect()
Matplotlib1DViewer.id
Matplotlib1DViewer.limits
Matplotlib1DViewer.lines
Matplotlib1DViewer.log
Matplotlib1DViewer.plot()
Matplotlib1DViewer.plotMesh()
Matplotlib1DViewer.setLimits()
Matplotlib1DViewer.title
Matplotlib1DViewer.vars
Matplotlib2DContourViewer
Matplotlib2DContourViewer.axes
Matplotlib2DContourViewer.cmap
Matplotlib2DContourViewer.colorbar
Matplotlib2DContourViewer.fig
Matplotlib2DContourViewer.figaspect()
Matplotlib2DContourViewer.id
Matplotlib2DContourViewer.levels
Matplotlib2DContourViewer.limits
Matplotlib2DContourViewer.log
Matplotlib2DContourViewer.plot()
Matplotlib2DContourViewer.plotMesh()
Matplotlib2DContourViewer.setLimits()
Matplotlib2DContourViewer.title
Matplotlib2DContourViewer.vars
Matplotlib2DGridContourViewer
Matplotlib2DGridContourViewer.axes
Matplotlib2DGridContourViewer.cmap
Matplotlib2DGridContourViewer.colorbar
Matplotlib2DGridContourViewer.fig
Matplotlib2DGridContourViewer.figaspect()
Matplotlib2DGridContourViewer.id
Matplotlib2DGridContourViewer.levels
Matplotlib2DGridContourViewer.limits
Matplotlib2DGridContourViewer.log
Matplotlib2DGridContourViewer.plot()
Matplotlib2DGridContourViewer.plotMesh()
Matplotlib2DGridContourViewer.setLimits()
Matplotlib2DGridContourViewer.title
Matplotlib2DGridContourViewer.vars
Matplotlib2DGridViewer
Matplotlib2DGridViewer.axes
Matplotlib2DGridViewer.cmap
Matplotlib2DGridViewer.colorbar
Matplotlib2DGridViewer.fig
Matplotlib2DGridViewer.figaspect()
Matplotlib2DGridViewer.id
Matplotlib2DGridViewer.limits
Matplotlib2DGridViewer.log
Matplotlib2DGridViewer.plot()
Matplotlib2DGridViewer.plotMesh()
Matplotlib2DGridViewer.setLimits()
Matplotlib2DGridViewer.title
Matplotlib2DGridViewer.vars
Matplotlib2DViewer
Matplotlib2DViewer.axes
Matplotlib2DViewer.cmap
Matplotlib2DViewer.collection
Matplotlib2DViewer.colorbar
Matplotlib2DViewer.fig
Matplotlib2DViewer.figaspect()
Matplotlib2DViewer.id
Matplotlib2DViewer.limits
Matplotlib2DViewer.log
Matplotlib2DViewer.plot()
Matplotlib2DViewer.plotMesh()
Matplotlib2DViewer.setLimits()
Matplotlib2DViewer.title
Matplotlib2DViewer.vars
MatplotlibStreamViewer
MatplotlibStreamViewer.axes
MatplotlibStreamViewer.cmap
MatplotlibStreamViewer.colorbar
MatplotlibStreamViewer.fig
MatplotlibStreamViewer.figaspect()
MatplotlibStreamViewer.id
MatplotlibStreamViewer.kwargs
MatplotlibStreamViewer.limits
MatplotlibStreamViewer.log
MatplotlibStreamViewer.plot()
MatplotlibStreamViewer.plotMesh()
MatplotlibStreamViewer.setLimits()
MatplotlibStreamViewer.title
MatplotlibStreamViewer.vars
MatplotlibVectorViewer
MatplotlibVectorViewer.axes
MatplotlibVectorViewer.cmap
MatplotlibVectorViewer.colorbar
MatplotlibVectorViewer.fig
MatplotlibVectorViewer.figaspect()
MatplotlibVectorViewer.id
MatplotlibVectorViewer.limits
MatplotlibVectorViewer.log
MatplotlibVectorViewer.plot()
MatplotlibVectorViewer.plotMesh()
MatplotlibVectorViewer.quiver()
MatplotlibVectorViewer.setLimits()
MatplotlibVectorViewer.title
MatplotlibVectorViewer.vars
MatplotlibViewer()
MayaviClient
MeshDimensionError
MeshDimensionError.__cause__
MeshDimensionError.__context__
MeshDimensionError.__delattr__()
MeshDimensionError.__getattribute__()
MeshDimensionError.__reduce__()
MeshDimensionError.__repr__()
MeshDimensionError.__setattr__()
MeshDimensionError.__setstate__()
MeshDimensionError.__str__()
MeshDimensionError.__suppress_context__
MeshDimensionError.__traceback__
MeshDimensionError.add_note()
MeshDimensionError.args
MeshDimensionError.with_traceback()
MultiViewer
TSVViewer
VTKCellViewer
VTKFaceViewer
VTKViewer()
Viewer()
- Subpackages
Submodules¶
fipy.testFiPy module¶
Module contents¶
FiPy is an object oriented, partial differential equation (PDE) solver, written in Python, based on a standard finite volume (FV) approach. The framework has been developed in the Materials Science and Engineering Division (MSED) and Center for Theoretical and Computational Materials Science (CTCMS), in the Material Measurement Laboratory (MML) at the National Institute of Standards and Technology (NIST).
The solution of coupled sets of PDEs is ubiquitous to the numerical simulation of science problems. Numerous PDE solvers exist, using a variety of languages and numerical approaches. Many are proprietary, expensive and difficult to customize. As a result, scientists spend considerable resources repeatedly developing limited tools for specific problems. Our approach, combining the FV method and Python, provides a tool that is extensible, powerful and freely available. A significant advantage to Python is the existing suite of tools for array calculations, sparse matrices and data rendering.
The FiPy framework includes terms for transient diffusion, convection and standard sources, enabling the solution of arbitrary combinations of coupled elliptic, hyperbolic and parabolic PDEs. Currently implemented models include phase field [1] [2] [3] treatments of polycrystalline, dendritic, and electrochemical phase transformations, as well as drug eluting stents [4], reactive wetting [5], photovoltaics [6] and a level set treatment of the electrodeposition process [7].
- exception fipy.AbstractBaseClassError(s="can't instantiate abstract base class")¶
Bases:
NotImplementedError
- __cause__¶
exception cause
- __context__¶
exception context
- __delattr__(name, /)¶
Implement delattr(self, name).
- __getattribute__(name, /)¶
Return getattr(self, name).
- __reduce__()¶
Helper for pickle.
- __repr__()¶
Return repr(self).
- __setattr__(name, value, /)¶
Implement setattr(self, name, value).
- __setstate__()¶
- __str__()¶
Return str(self).
- __suppress_context__¶
- __traceback__¶
- add_note()¶
Exception.add_note(note) – add a note to the exception
- args¶
- with_traceback()¶
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
- class fipy.AdvectionTerm(coeff=None)¶
Bases:
FirstOrderAdvectionTerm
The AdvectionTerm object constructs the b vector contribution for the advection term given by
from the advection equation given by:
The construction of the gradient magnitude term requires upwinding as in the standard FirstOrderAdvectionTerm. The higher order terms are incorporated as follows. The formula used here is given by:
where,
and
also,
Here are some simple test cases for this problem:
>>> from fipy.meshes import Grid1D >>> from fipy.solvers import * >>> SparseMatrix = LinearPCGSolver()._matrixClass >>> mesh = Grid1D(dx = 1., nx = 3)
Trivial test:
>>> from fipy.variables.cellVariable import CellVariable >>> coeff = CellVariable(mesh = mesh, value = numerix.zeros(3, 'd')) >>> v, L, b = AdvectionTerm(0.)._buildMatrix(coeff, SparseMatrix) >>> print(numerix.allclose(b, numerix.zeros(3, 'd'), atol = 1e-10)) True
Less trivial test:
>>> coeff = CellVariable(mesh = mesh, value = numerix.arange(3)) >>> v, L, b = AdvectionTerm(1.)._buildMatrix(coeff, SparseMatrix) >>> print(numerix.allclose(b, numerix.array((0., -1., -1.)), atol = 1e-10)) True
Even less trivial
>>> coeff = CellVariable(mesh = mesh, value = numerix.arange(3)) >>> v, L, b = AdvectionTerm(-1.)._buildMatrix(coeff, SparseMatrix) >>> print(numerix.allclose(b, numerix.array((1., 1., 0.)), atol = 1e-10)) True
Another trivial test case (more trivial than a trivial test case standing on a harpsichord singing “trivial test cases are here again”)
>>> vel = numerix.array((-1, 2, -3)) >>> coeff = CellVariable(mesh = mesh, value = numerix.array((4, 6, 1))) >>> v, L, b = AdvectionTerm(vel)._buildMatrix(coeff, SparseMatrix) >>> print(numerix.allclose(b, -vel * numerix.array((2, numerix.sqrt(5**2 + 2**2), 5)), atol = 1e-10)) True
Somewhat less trivial test case:
>>> from fipy.meshes import Grid2D >>> mesh = Grid2D(dx = 1., dy = 1., nx = 2, ny = 2) >>> vel = numerix.array((3, -5, -6, -3)) >>> coeff = CellVariable(mesh = mesh, value = numerix.array((3, 1, 6, 7))) >>> v, L, b = AdvectionTerm(vel)._buildMatrix(coeff, SparseMatrix) >>> answer = -vel * numerix.array((2, numerix.sqrt(2**2 + 6**2), 1, 0)) >>> print(numerix.allclose(b, answer, atol = 1e-10)) True
For the above test cases the AdvectionTerm gives the same result as the AdvectionTerm. The following test imposes a quadratic field. The higher order term can resolve this field correctly.
The returned vector
b
should have the value:Build the test case in the following way,
>>> mesh = Grid1D(dx = 1., nx = 5) >>> vel = 1. >>> coeff = CellVariable(mesh = mesh, value = mesh.cellCenters[0]**2) >>> v, L, b = __AdvectionTerm(vel)._buildMatrix(coeff, SparseMatrix)
The first order term is not accurate. The first and last element are ignored because they don’t have any neighbors for higher order evaluation
>>> print(numerix.allclose(CellVariable(mesh=mesh, ... value=b).globalValue[1:-1], -2 * mesh.cellCenters.globalValue[0][1:-1])) False
The higher order term is spot on.
>>> v, L, b = AdvectionTerm(vel)._buildMatrix(coeff, SparseMatrix) >>> print(numerix.allclose(CellVariable(mesh=mesh, ... value=b).globalValue[1:-1], -2 * mesh.cellCenters.globalValue[0][1:-1])) True
The AdvectionTerm will also resolve a circular field with more accuracy,
Build the test case in the following way,
>>> mesh = Grid2D(dx = 1., dy = 1., nx = 10, ny = 10) >>> vel = 1. >>> x, y = mesh.cellCenters >>> r = numerix.sqrt(x**2 + y**2) >>> coeff = CellVariable(mesh = mesh, value = r) >>> v, L, b = __AdvectionTerm(1.)._buildMatrix(coeff, SparseMatrix) >>> error = CellVariable(mesh=mesh, value=b + 1) >>> ans = CellVariable(mesh=mesh, value=b + 1) >>> ans[(x > 2) & (x < 8) & (y > 2) & (y < 8)] = 0.123105625618 >>> print((error <= ans).all()) True
The maximum error is large (about 12 %) for the first order advection.
>>> v, L, b = AdvectionTerm(1.)._buildMatrix(coeff, SparseMatrix) >>> error = CellVariable(mesh=mesh, value=b + 1) >>> ans = CellVariable(mesh=mesh, value=b + 1) >>> ans[(x > 2) & (x < 8) & (y > 2) & (y < 8)] = 0.0201715476598 >>> print((error <= ans).all()) True
The maximum error is 2 % when using a higher order contribution.
Create a Term.
- Parameters:
coeff (float or CellVariable or FaceVariable) – Coefficient for the term. FaceVariable objects are only acceptable for diffusion or convection terms.
- property RHSvector¶
Return the RHS vector calculated in solve() or sweep(). The cacheRHSvector() method should be called before solve() or sweep() to cache the vector.
- __add__(other)¶
- __and__(other)¶
- __div__(other)¶
- __eq__(other)¶
Return self==value.
- __hash__()¶
Return hash(self).
- __mul__(other)¶
Multiply a term
>>> 2. * __NonDiffusionTerm(coeff=0.5) __NonDiffusionTerm(coeff=1.0)
Test for ticket:291.
>>> from fipy import PowerLawConvectionTerm >>> PowerLawConvectionTerm(coeff=[[1], [0]]) * 1.0 PowerLawConvectionTerm(coeff=array([[ 1.], [ 0.]]))
- __neg__()¶
Negate a Term.
>>> -__NonDiffusionTerm(coeff=1.) __NonDiffusionTerm(coeff=-1.0)
- __pos__()¶
- __radd__(other)¶
- __rand__(other)¶
- __repr__()¶
The representation of a Term object is given by,
>>> print(__UnaryTerm(123.456)) __UnaryTerm(coeff=123.456)
- __rmul__(other)¶
Multiply a term
>>> 2. * __NonDiffusionTerm(coeff=0.5) __NonDiffusionTerm(coeff=1.0)
Test for ticket:291.
>>> from fipy import PowerLawConvectionTerm >>> PowerLawConvectionTerm(coeff=[[1], [0]]) * 1.0 PowerLawConvectionTerm(coeff=array([[ 1.], [ 0.]]))
- __rsub__(other)¶
- __sub__(other)¶
- __truediv__(other)¶
- cacheMatrix()¶
Informs solve() and sweep() to cache their matrix so that matrix can return the matrix.
- cacheRHSvector()¶
Informs solve() and sweep() to cache their right hand side vector so that getRHSvector() can return it.
- copy()¶
- getDefaultSolver(var=None, solver=None, *args, **kwargs)¶
- justErrorVector(var=None, solver=None, boundaryConditions=(), dt=1.0, underRelaxation=None, residualFn=None)¶
Builds the Term’s linear system once.
This method also recalculates and returns the error as well as applying under-relaxation.
justErrorVector returns the overlapping local value in parallel (not the non-overlapping value).
>>> from fipy.solvers import DummySolver >>> from fipy import * >>> m = Grid1D(nx=10) >>> v = CellVariable(mesh=m) >>> len(DiffusionTerm().justErrorVector(v, solver=DummySolver())) == m.numberOfCells True
- Parameters:
var (CellVariable) – Variable to be solved for. Provides the initial condition, the old value and holds the solution on completion.
solver (Solver) – Iterative solver to be used to solve the linear system of equations. The default sovler depends on the solver package selected.
boundaryConditions (
tuple
ofBoundaryCondition
) –dt (float) – Timestep size.
underRelaxation (float) – Usually a value between 0 and 1 or None in the case of no under-relaxation
residualFn (function) – Takes var, matrix, and RHSvector arguments, used to customize the residual calculation.
- Returns:
error – The residual vector
- Return type:
- justResidualVector(var=None, solver=None, boundaryConditions=(), dt=None, underRelaxation=None, residualFn=None)¶
Builds the Term’s linear system once.
This method also recalculates and returns the residual as well as applying under-relaxation.
justResidualVector returns the overlapping local value in parallel (not the non-overlapping value).
>>> from fipy import * >>> m = Grid1D(nx=10) >>> v = CellVariable(mesh=m) >>> len(numerix.asarray(DiffusionTerm().justResidualVector(v))) == m.numberOfCells True
- Parameters:
var (CellVariable) – Variable to be solved for. Provides the initial condition, the old value and holds the solution on completion.
solver (Solver) – Iterative solver to be used to solve the linear system of equations. The default sovler depends on the solver package selected.
boundaryConditions (
tuple
ofBoundaryCondition
) –dt (float) – Timestep size.
underRelaxation (float) – Usually a value between 0 and 1 or None in the case of no under-relaxation
residualFn (function) – Takes var, matrix, and RHSvector arguments, used to customize the residual calculation.
- Returns:
residual – The residual vector
- Return type:
- property matrix¶
Return the matrix calculated in solve() or sweep(). The cacheMatrix() method should be called before solve() or sweep() to cache the matrix.
- residualVectorAndNorm(var=None, solver=None, boundaryConditions=(), dt=None, underRelaxation=None, residualFn=None)¶
Builds the Term’s linear system once.
This method also recalculates and returns the residual as well as applying under-relaxation.
- Parameters:
var (CellVariable) – Variable to be solved for. Provides the initial condition, the old value and holds the solution on completion.
solver (Solver) – Iterative solver to be used to solve the linear system of equations. The default sovler depends on the solver package selected.
boundaryConditions (
tuple
ofBoundaryCondition
) –dt (float) – Timestep size.
underRelaxation (float) – Usually a value between 0 and 1 or None in the case of no under-relaxation
residualFn (function) – Takes var, matrix, and RHSvector arguments, used to customize the residual calculation.
- Returns:
residual (~fipy.variables.cellVariable.CellVariable) – The residual vector
norm (float) – The L2 norm of residual,
- solve(var=None, solver=None, boundaryConditions=(), dt=None)¶
Builds and solves the Term’s linear system once. This method does not return the residual. It should be used when the residual is not required.
- Parameters:
var (CellVariable) – Variable to be solved for. Provides the initial condition, the old value and holds the solution on completion.
solver (Solver) – Iterative solver to be used to solve the linear system of equations. The default sovler depends on the solver package selected.
boundaryConditions (
tuple
ofBoundaryCondition
) –dt (float) – Timestep size.
- sweep(var=None, solver=None, boundaryConditions=(), dt=None, underRelaxation=None, residualFn=None, cacheResidual=False, cacheError=False)¶
Builds and solves the Term’s linear system once. This method also recalculates and returns the residual as well as applying under-relaxation.
- Parameters:
var (CellVariable) – Variable to be solved for. Provides the initial condition, the old value and holds the solution on completion.
solver (Solver) – Iterative solver to be used to solve the linear system of equations. The default sovler depends on the solver package selected.
boundaryConditions (
tuple
ofBoundaryCondition
) –dt (float) – Timestep size.
underRelaxation (float) – Usually a value between 0 and 1 or None in the case of no under-relaxation
residualFn (function) – Takes var, matrix, and RHSvector arguments, used to customize the residual calculation.
cacheResidual (bool) – If True, calculate and store the residual vector
in the residualVector member of Term
cacheError (bool) – If True, use the residual vector
to solve
for the error vector
and store it in the errorVector member of Term
- Returns:
residual – The residual vector
- Return type:
- class fipy.BetaNoiseVariable(*args, **kwds)¶
Bases:
NoiseVariable
Represents a beta distribution of random numbers with the probability distribution
with a shape parameter
, a rate parameter
, and
.
Seed the random module for the sake of deterministic test results.
>>> from fipy import numerix >>> numerix.random.seed(1)
We generate noise on a uniform Cartesian mesh
>>> from fipy.variables.variable import Variable >>> alpha = Variable() >>> beta = Variable() >>> from fipy.meshes import Grid2D >>> noise = BetaNoiseVariable(mesh = Grid2D(nx = 100, ny = 100), alpha = alpha, beta = beta)
We histogram the root-volume-weighted noise distribution
>>> from fipy.variables.histogramVariable import HistogramVariable >>> histogram = HistogramVariable(distribution = noise, dx = 0.01, nx = 100)
and compare to a Gaussian distribution
>>> from fipy.variables.cellVariable import CellVariable >>> betadist = CellVariable(mesh = histogram.mesh) >>> x = CellVariable(mesh=histogram.mesh, value=histogram.mesh.cellCenters[0]) >>> from scipy.special import gamma as Gamma >>> betadist = ((Gamma(alpha + beta) / (Gamma(alpha) * Gamma(beta))) ... * x**(alpha - 1) * (1 - x)**(beta - 1))
>>> if __name__ == '__main__': ... from fipy import Viewer ... viewer = Viewer(vars=noise, datamin=0, datamax=1) ... histoplot = Viewer(vars=(histogram, betadist), ... datamin=0, datamax=1.5)
>>> from fipy.tools.numerix import arange
>>> for a in arange(0.5, 5, 0.5): ... alpha.value = a ... for b in arange(0.5, 5, 0.5): ... beta.value = b ... if __name__ == '__main__': ... import sys ... print("alpha: %g, beta: %g" % (alpha, beta), file=sys.stderr) ... viewer.plot() ... histoplot.plot()
>>> print(abs(noise.faceGrad.divergence.cellVolumeAverage) < 5e-15) 1
- Parameters:
- __abs__()¶
Following test it to fix a bug with C inline string using abs() instead of fabs()
>>> print(abs(Variable(2.3) - Variable(1.2))) 1.1
Check representation works with different versions of numpy
>>> print(repr(abs(Variable(2.3)))) numerix.fabs(Variable(value=array(2.3)))
- __add__(other)¶
- __and__(other)¶
This test case has been added due to a weird bug that was appearing.
>>> a = Variable(value=(0, 0, 1, 1)) >>> b = Variable(value=(0, 1, 0, 1)) >>> print(numerix.equal((a == 0) & (b == 1), [False, True, False, False]).all()) True >>> print(a & b) [0 0 0 1] >>> from fipy.meshes import Grid1D >>> mesh = Grid1D(nx=4) >>> from fipy.variables.cellVariable import CellVariable >>> a = CellVariable(value=(0, 0, 1, 1), mesh=mesh) >>> b = CellVariable(value=(0, 1, 0, 1), mesh=mesh) >>> print(numerix.allequal((a == 0) & (b == 1), [False, True, False, False])) True >>> print(a & b) [0 0 0 1]
- __array__(t=None)¶
Attempt to convert the Variable to a numerix array object
>>> v = Variable(value=[2, 3]) >>> print(numerix.array(v)) [2 3]
A dimensional Variable will convert to the numeric value in its base units
>>> v = Variable(value=[2, 3], unit="mm") >>> numerix.array(v) array([ 0.002, 0.003])
- __array_priority__ = 100.0¶
- __array_wrap__(arr, context=None)¶
Required to prevent numpy not calling the reverse binary operations. Both the following tests are examples ufuncs.
>>> print(type(numerix.array([1.0, 2.0]) * Variable([1.0, 2.0]))) <class 'fipy.variables.binaryOperatorVariable...binOp'>
>>> from scipy.special import gamma as Gamma >>> print(type(Gamma(Variable([1.0, 2.0])))) <class 'fipy.variables.unaryOperatorVariable...unOp'>
- __bool__()¶
>>> print(bool(Variable(value=0))) 0 >>> print(bool(Variable(value=(0, 0, 1, 1)))) Traceback (most recent call last): ... ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
- __call__(points=None, order=0, nearestCellIDs=None)¶
Interpolates the CellVariable to a set of points using a method that has a memory requirement on the order of Ncells by Npoints in general, but uses only Ncells when the CellVariable’s mesh is a UniformGrid object.
Tests
>>> from fipy import * >>> m = Grid2D(nx=3, ny=2) >>> v = CellVariable(mesh=m, value=m.cellCenters[0]) >>> print(v(((0., 1.1, 1.2), (0., 1., 1.)))) [ 0.5 1.5 1.5] >>> print(v(((0., 1.1, 1.2), (0., 1., 1.)), order=1)) [ 0.25 1.1 1.2 ] >>> m0 = Grid2D(nx=2, ny=2, dx=1., dy=1.) >>> m1 = Grid2D(nx=4, ny=4, dx=.5, dy=.5) >>> x, y = m0.cellCenters >>> v0 = CellVariable(mesh=m0, value=x * y) >>> print(v0(m1.cellCenters.globalValue)) [ 0.25 0.25 0.75 0.75 0.25 0.25 0.75 0.75 0.75 0.75 2.25 2.25 0.75 0.75 2.25 2.25] >>> print(v0(m1.cellCenters.globalValue, order=1)) [ 0.125 0.25 0.5 0.625 0.25 0.375 0.875 1. 0.5 0.875 1.875 2.25 0.625 1. 2.25 2.625]
- __div__(other)¶
- __eq__(other)¶
Test if a Variable is equal to another quantity
>>> a = Variable(value=3) >>> b = (a == 4) >>> b (Variable(value=array(3)) == 4) >>> b() 0
- __float__()¶
- __ge__(other)¶
Test if a Variable is greater than or equal to another quantity
>>> a = Variable(value=3) >>> b = (a >= 4) >>> b (Variable(value=array(3)) >= 4) >>> b() 0 >>> a.value = 4 >>> print(b()) 1 >>> a.value = 5 >>> print(b()) 1
- __getitem__(index)¶
“Evaluate” the Variable and return the specified element
>>> a = Variable(value=((3., 4.), (5., 6.)), unit="m") + "4 m" >>> print(a[1, 1]) 10.0 m
It is an error to slice a Variable whose value is not sliceable
>>> Variable(value=3)[2] Traceback (most recent call last): ... IndexError: 0-d arrays can't be indexed
- __getstate__()¶
Used internally to collect the necessary information to
pickle
the CellVariable to persistent storage.
- __gt__(other)¶
Test if a Variable is greater than another quantity
>>> a = Variable(value=3) >>> b = (a > 4) >>> b (Variable(value=array(3)) > 4) >>> print(b()) 0 >>> a.value = 5 >>> print(b()) 1
- __hash__()¶
Return hash(self).
- __int__()¶
- __invert__()¶
Returns logical “not” of the Variable
>>> a = Variable(value=True) >>> print(~a) False
- __iter__()¶
- __le__(other)¶
Test if a Variable is less than or equal to another quantity
>>> a = Variable(value=3) >>> b = (a <= 4) >>> b (Variable(value=array(3)) <= 4) >>> b() 1 >>> a.value = 4 >>> print(b()) 1 >>> a.value = 5 >>> print(b()) 0
- __len__()¶
- __lt__(other)¶
Test if a Variable is less than another quantity
>>> a = Variable(value=3) >>> b = (a < 4) >>> b (Variable(value=array(3)) < 4) >>> b() 1 >>> a.value = 4 >>> print(b()) 0 >>> print(1000000000000000000 * Variable(1) < 1.) 0 >>> print(1000 * Variable(1) < 1.) 0
Python automatically reverses the arguments when necessary
>>> 4 > Variable(value=3) (Variable(value=array(3)) < 4)
- __mod__(other)¶
- __mul__(other)¶
- __ne__(other)¶
Test if a Variable is not equal to another quantity
>>> a = Variable(value=3) >>> b = (a != 4) >>> b (Variable(value=array(3)) != 4) >>> b() 1
- __neg__()¶
- static __new__(cls, *args, **kwds)¶
- __nonzero__()¶
>>> print(bool(Variable(value=0))) 0 >>> print(bool(Variable(value=(0, 0, 1, 1)))) Traceback (most recent call last): ... ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
- __or__(other)¶
This test case has been added due to a weird bug that was appearing.
>>> a = Variable(value=(0, 0, 1, 1)) >>> b = Variable(value=(0, 1, 0, 1)) >>> print(numerix.equal((a == 0) | (b == 1), [True, True, False, True]).all()) True >>> print(a | b) [0 1 1 1] >>> from fipy.meshes import Grid1D >>> mesh = Grid1D(nx=4) >>> from fipy.variables.cellVariable import CellVariable >>> a = CellVariable(value=(0, 0, 1, 1), mesh=mesh) >>> b = CellVariable(value=(0, 1, 0, 1), mesh=mesh) >>> print(numerix.allequal((a == 0) | (b == 1), [True, True, False, True])) True >>> print(a | b) [0 1 1 1]
- __pos__()¶
- __pow__(other)¶
return self**other, or self raised to power other
>>> print(Variable(1, "mol/l")**3) 1.0 mol**3/l**3 >>> print((Variable(1, "mol/l")**3).unit) <PhysicalUnit mol**3/l**3>
- __radd__(other)¶
- __rdiv__(other)¶
- __repr__()¶
Return repr(self).
- __rmul__(other)¶
- __rpow__(other)¶
- __rsub__(other)¶
- __rtruediv__(other)¶
- __setitem__(index, value)¶
- __setstate__(dict)¶
Used internally to create a new CellVariable from
pickled
persistent storage.
- __str__()¶
Return str(self).
- __sub__(other)¶
- __truediv__(other)¶
- all(axis=None)¶
>>> print(Variable(value=(0, 0, 1, 1)).all()) 0 >>> print(Variable(value=(1, 1, 1, 1)).all()) 1
- allclose(other, rtol=1e-05, atol=1e-08)¶
>>> var = Variable((1, 1)) >>> print(var.allclose((1, 1))) 1 >>> print(var.allclose((1,))) 1
The following test is to check that the system does not run out of memory.
>>> from fipy.tools import numerix >>> var = Variable(numerix.ones(10000)) >>> print(var.allclose(numerix.zeros(10000, 'l'))) False
- allequal(other)¶
- any(axis=None)¶
>>> print(Variable(value=0).any()) 0 >>> print(Variable(value=(0, 0, 1, 1)).any()) 1
- property arithmeticFaceValue¶
Returns a FaceVariable whose value corresponds to the arithmetic interpolation of the adjacent cells:
>>> from fipy.meshes import Grid1D >>> from fipy import numerix >>> mesh = Grid1D(dx = (1., 1.)) >>> L = 1 >>> R = 2 >>> var = CellVariable(mesh = mesh, value = (L, R)) >>> faceValue = var.arithmeticFaceValue[mesh.interiorFaces.value] >>> answer = (R - L) * (0.5 / 1.) + L >>> print(numerix.allclose(faceValue, answer, atol = 1e-10, rtol = 1e-10)) True
>>> mesh = Grid1D(dx = (2., 4.)) >>> var = CellVariable(mesh = mesh, value = (L, R)) >>> faceValue = var.arithmeticFaceValue[mesh.interiorFaces.value] >>> answer = (R - L) * (1.0 / 3.0) + L >>> print(numerix.allclose(faceValue, answer, atol = 1e-10, rtol = 1e-10)) True
>>> mesh = Grid1D(dx = (10., 100.)) >>> var = CellVariable(mesh = mesh, value = (L, R)) >>> faceValue = var.arithmeticFaceValue[mesh.interiorFaces.value] >>> answer = (R - L) * (5.0 / 55.0) + L >>> print(numerix.allclose(faceValue, answer, atol = 1e-10, rtol = 1e-10)) True
- cacheMe(recursive=False)¶
- property cellVolumeAverage¶
Return the cell-volume-weighted average of the CellVariable:
>>> from fipy.meshes import Grid2D >>> from fipy.variables.cellVariable import CellVariable >>> mesh = Grid2D(nx = 3, ny = 1, dx = .5, dy = .1) >>> var = CellVariable(value = (1, 2, 6), mesh = mesh) >>> print(var.cellVolumeAverage) 3.0
- constrain(value, where=None)¶
Constrains the CellVariable to value at a location specified by where.
>>> from fipy import * >>> m = Grid1D(nx=3) >>> v = CellVariable(mesh=m, value=m.cellCenters[0]) >>> v.constrain(0., where=m.facesLeft) >>> v.faceGrad.constrain([1.], where=m.facesRight) >>> print(v.faceGrad) [[ 1. 1. 1. 1.]] >>> print(v.faceValue) [ 0. 1. 2. 2.5]
Changing the constraint changes the dependencies
>>> v.constrain(1., where=m.facesLeft) >>> print(v.faceGrad) [[-1. 1. 1. 1.]] >>> print(v.faceValue) [ 1. 1. 2. 2.5]
Constraints can be Variable
>>> c = Variable(0.) >>> v.constrain(c, where=m.facesLeft) >>> print(v.faceGrad) [[ 1. 1. 1. 1.]] >>> print(v.faceValue) [ 0. 1. 2. 2.5] >>> c.value = 1. >>> print(v.faceGrad) [[-1. 1. 1. 1.]] >>> print(v.faceValue) [ 1. 1. 2. 2.5]
Constraints can have a Variable mask.
>>> v = CellVariable(mesh=m) >>> mask = FaceVariable(mesh=m, value=m.facesLeft) >>> v.constrain(1., where=mask) >>> print(v.faceValue) [ 1. 0. 0. 0.] >>> mask[:] = mask | m.facesRight >>> print(v.faceValue) [ 1. 0. 0. 1.]
- property constraintMask¶
Test that constraintMask returns a Variable that updates itself whenever the constraints change.
>>> from fipy import *
>>> m = Grid2D(nx=2, ny=2) >>> x, y = m.cellCenters >>> v0 = CellVariable(mesh=m) >>> v0.constrain(1., where=m.facesLeft) >>> print(v0.faceValue.constraintMask) [False False False False False False True False False True False False] >>> print(v0.faceValue) [ 0. 0. 0. 0. 0. 0. 1. 0. 0. 1. 0. 0.] >>> v0.constrain(3., where=m.facesRight) >>> print(v0.faceValue.constraintMask) [False False False False False False True False True True False True] >>> print(v0.faceValue) [ 0. 0. 0. 0. 0. 0. 1. 0. 3. 1. 0. 3.] >>> v1 = CellVariable(mesh=m) >>> v1.constrain(1., where=(x < 1) & (y < 1)) >>> print(v1.constraintMask) [ True False False False] >>> print(v1) [ 1. 0. 0. 0.] >>> v1.constrain(3., where=(x > 1) & (y > 1)) >>> print(v1.constraintMask) [ True False False True] >>> print(v1) [ 1. 0. 0. 3.]
- property constraints¶
- copy()¶
Copy the value of the NoiseVariable to a static CellVariable.
- dontCacheMe(recursive=False)¶
- dot(other, opShape=None, operatorClass=None)¶
Return the mesh-element–by–mesh-element (cell-by-cell, face-by-face, etc.) scalar product
Both self and other can be of arbitrary rank, and other does not need to be a _MeshVariable.
- property faceGrad¶
Return
as a rank-1 FaceVariable using differencing for the normal direction(second-order gradient).
- property faceGradAverage¶
Deprecated since version 3.3: use
grad.arithmeticFaceValue()
insteadReturn
as a rank-1 FaceVariable using averaging for the normal direction(second-order gradient)
- property faceValue¶
Returns a FaceVariable whose value corresponds to the arithmetic interpolation of the adjacent cells:
>>> from fipy.meshes import Grid1D >>> from fipy import numerix >>> mesh = Grid1D(dx = (1., 1.)) >>> L = 1 >>> R = 2 >>> var = CellVariable(mesh = mesh, value = (L, R)) >>> faceValue = var.arithmeticFaceValue[mesh.interiorFaces.value] >>> answer = (R - L) * (0.5 / 1.) + L >>> print(numerix.allclose(faceValue, answer, atol = 1e-10, rtol = 1e-10)) True
>>> mesh = Grid1D(dx = (2., 4.)) >>> var = CellVariable(mesh = mesh, value = (L, R)) >>> faceValue = var.arithmeticFaceValue[mesh.interiorFaces.value] >>> answer = (R - L) * (1.0 / 3.0) + L >>> print(numerix.allclose(faceValue, answer, atol = 1e-10, rtol = 1e-10)) True
>>> mesh = Grid1D(dx = (10., 100.)) >>> var = CellVariable(mesh = mesh, value = (L, R)) >>> faceValue = var.arithmeticFaceValue[mesh.interiorFaces.value] >>> answer = (R - L) * (5.0 / 55.0) + L >>> print(numerix.allclose(faceValue, answer, atol = 1e-10, rtol = 1e-10)) True
- property gaussGrad¶
Return
as a rank-1 CellVariable (first-order gradient).
- getsctype(default=None)¶
Returns the Numpy sctype of the underlying array.
>>> Variable(1).getsctype() == numerix.NUMERIX.obj2sctype(numerix.array(1)) True >>> Variable(1.).getsctype() == numerix.NUMERIX.obj2sctype(numerix.array(1.)) True >>> Variable((1, 1.)).getsctype() == numerix.NUMERIX.obj2sctype(numerix.array((1., 1.))) True
- property globalValue¶
Concatenate and return values from all processors
When running on a single processor, the result is identical to
value
.
- property grad¶
Return
as a rank-1 CellVariable (first-order gradient).
- property harmonicFaceValue¶
Returns a FaceVariable whose value corresponds to the harmonic interpolation of the adjacent cells:
>>> from fipy.meshes import Grid1D >>> from fipy import numerix >>> mesh = Grid1D(dx = (1., 1.)) >>> L = 1 >>> R = 2 >>> var = CellVariable(mesh = mesh, value = (L, R)) >>> faceValue = var.harmonicFaceValue[mesh.interiorFaces.value] >>> answer = L * R / ((R - L) * (0.5 / 1.) + L) >>> print(numerix.allclose(faceValue, answer, atol = 1e-10, rtol = 1e-10)) True
>>> mesh = Grid1D(dx = (2., 4.)) >>> var = CellVariable(mesh = mesh, value = (L, R)) >>> faceValue = var.harmonicFaceValue[mesh.interiorFaces.value] >>> answer = L * R / ((R - L) * (1.0 / 3.0) + L) >>> print(numerix.allclose(faceValue, answer, atol = 1e-10, rtol = 1e-10)) True
>>> mesh = Grid1D(dx = (10., 100.)) >>> var = CellVariable(mesh = mesh, value = (L, R)) >>> faceValue = var.harmonicFaceValue[mesh.interiorFaces.value] >>> answer = L * R / ((R - L) * (5.0 / 55.0) + L) >>> print(numerix.allclose(faceValue, answer, atol = 1e-10, rtol = 1e-10)) True
- inBaseUnits()¶
Return the value of the Variable with all units reduced to their base SI elements.
>>> e = Variable(value="2.7 Hartree*Nav") >>> print(e.inBaseUnits().allclose("7088849.01085 kg*m**2/s**2/mol")) 1
- inUnitsOf(*units)¶
Returns one or more Variable objects that express the same physical quantity in different units. The units are specified by strings containing their names. The units must be compatible with the unit of the object. If one unit is specified, the return value is a single Variable.
>>> freeze = Variable('0 degC') >>> print(freeze.inUnitsOf('degF').allclose("32.0 degF")) 1
If several units are specified, the return value is a tuple of Variable instances with with one element per unit such that the sum of all quantities in the tuple equals the the original quantity and all the values except for the last one are integers. This is used to convert to irregular unit systems like hour/minute/second. The original object will not be changed.
>>> t = Variable(value=314159., unit='s') >>> from builtins import zip >>> print(numerix.allclose([e.allclose(v) for (e, v) in zip(t.inUnitsOf('d', 'h', 'min', 's'), ... ['3.0 d', '15.0 h', '15.0 min', '59.0 s'])], ... True)) 1
- itemset(value)¶
- property itemsize¶
- property leastSquaresGrad¶
Return
, which is determined by solving for
in the following matrix equation,
The matrix equation is derived by minimizing the following least squares sum,
Tests
>>> from fipy import Grid2D >>> m = Grid2D(nx=2, ny=2, dx=0.1, dy=2.0) >>> print(numerix.allclose(CellVariable(mesh=m, value=(0, 1, 3, 6)).leastSquaresGrad.globalValue, \ ... [[8.0, 8.0, 24.0, 24.0], ... [1.2, 2.0, 1.2, 2.0]])) True
>>> from fipy import Grid1D >>> print(numerix.allclose(CellVariable(mesh=Grid1D(dx=(2.0, 1.0, 0.5)), ... value=(0, 1, 2)).leastSquaresGrad.globalValue, [[0.461538461538, 0.8, 1.2]])) True
- max(axis=None)¶
- min(axis=None)¶
>>> from fipy import Grid2D, CellVariable >>> mesh = Grid2D(nx=5, ny=5) >>> x, y = mesh.cellCenters >>> v = CellVariable(mesh=mesh, value=x*y) >>> print(v.min()) 0.25
- property minmodFaceValue¶
Returns a FaceVariable with a value that is the minimum of the absolute values of the adjacent cells. If the values are of opposite sign then the result is zero:
>>> from fipy import * >>> print(CellVariable(mesh=Grid1D(nx=2), value=(1, 2)).minmodFaceValue) [1 1 2] >>> print(CellVariable(mesh=Grid1D(nx=2), value=(-1, -2)).minmodFaceValue) [-1 -1 -2] >>> print(CellVariable(mesh=Grid1D(nx=2), value=(-1, 2)).minmodFaceValue) [-1 0 2]
- property name¶
- property numericValue¶
- property old¶
Return the values of the CellVariable from the previous solution sweep.
Combinations of CellVariable’s should also return old values.
>>> from fipy.meshes import Grid1D >>> mesh = Grid1D(nx = 2) >>> from fipy.variables.cellVariable import CellVariable >>> var1 = CellVariable(mesh = mesh, value = (2, 3), hasOld = 1) >>> var2 = CellVariable(mesh = mesh, value = (3, 4)) >>> v = var1 * var2 >>> print(v) [ 6 12] >>> var1.value = ((3, 2)) >>> print(v) [9 8] >>> print(v.old) [ 6 12]
The following small test is to correct for a bug when the operator does not just use variables.
>>> v1 = var1 * 3 >>> print(v1) [9 6] >>> print(v1.old) [6 9]
- parallelRandom()¶
- put(indices, value)¶
- random()¶
- property rank¶
- ravel()¶
- rdot(other, opShape=None, operatorClass=None)¶
Return the mesh-element–by–mesh-element (cell-by-cell, face-by-face, etc.) scalar product
Both self and other can be of arbitrary rank, and other does not need to be a _MeshVariable.
- release(constraint)¶
Remove constraint from self
>>> from fipy import * >>> m = Grid1D(nx=3) >>> v = CellVariable(mesh=m, value=m.cellCenters[0]) >>> c = Constraint(0., where=m.facesLeft) >>> v.constrain(c) >>> print(v.faceValue) [ 0. 1. 2. 2.5] >>> v.release(constraint=c) >>> print(v.faceValue) [ 0.5 1. 2. 2.5]
- scramble()¶
Generate a new random distribution.
- setValue(value, unit=None, where=None)¶
Set the value of the Variable. Can take a masked array.
>>> a = Variable((1, 2, 3)) >>> a.setValue(5, where=(1, 0, 1)) >>> print(a) [5 2 5]
>>> b = Variable((4, 5, 6)) >>> a.setValue(b, where=(1, 0, 1)) >>> print(a) [4 2 6] >>> print(b) [4 5 6] >>> a.value = 3 >>> print(a) [3 3 3]
>>> b = numerix.array((3, 4, 5)) >>> a.value = b >>> a[:] = 1 >>> print(b) [3 4 5]
>>> a.setValue((4, 5, 6), where=(1, 0)) Traceback (most recent call last): .... ValueError: shape mismatch: objects cannot be broadcast to a single shape
- property shape¶
>>> from fipy.meshes import Grid2D >>> from fipy.variables.cellVariable import CellVariable >>> mesh = Grid2D(nx=2, ny=3) >>> var = CellVariable(mesh=mesh) >>> print(numerix.allequal(var.shape, (6,))) True >>> print(numerix.allequal(var.arithmeticFaceValue.shape, (17,))) True >>> print(numerix.allequal(var.grad.shape, (2, 6))) True >>> print(numerix.allequal(var.faceGrad.shape, (2, 17))) True
Have to account for zero length arrays
>>> from fipy import Grid1D >>> m = Grid1D(nx=0) >>> v = CellVariable(mesh=m, elementshape=(2,)) >>> numerix.allequal((v * 1).shape, (2, 0)) True
- std(axis=None, **kwargs)¶
Evaluate standard deviation of all the elements of a MeshVariable.
Adapted from http://mpitutorial.com/tutorials/mpi-reduce-and-allreduce/
>>> import fipy as fp >>> mesh = fp.Grid2D(nx=2, ny=2, dx=2., dy=5.) >>> var = fp.CellVariable(value=(1., 2., 3., 4.), mesh=mesh) >>> print((var.std()**2).allclose(1.25)) True
- property subscribedVariables¶
- sum(axis=None)¶
- take(ids, axis=0)¶
- tostring(max_line_width=75, precision=8, suppress_small=False, separator=' ')¶
- property unit¶
Return the unit object of self.
>>> Variable(value="1 m").unit <PhysicalUnit m>
- updateOld()¶
Set the values of the previous solution sweep to the current values.
>>> from fipy import * >>> v = CellVariable(mesh=Grid1D(), hasOld=False) >>> v.updateOld() Traceback (most recent call last): ... AssertionError: The updateOld method requires the CellVariable to have an old value. Set hasOld to True when instantiating the CellVariable.
- property value¶
“Evaluate” the Variable and return its value (longhand)
>>> a = Variable(value=3) >>> print(a.value) 3 >>> b = a + 4 >>> b (Variable(value=array(3)) + 4) >>> b.value 7
- class fipy.CellVariable(*args, **kwds)¶
Bases:
_MeshVariable
Represents the field of values of a variable on a Mesh.
A CellVariable can be
pickled
to persistent storage (disk) for later use:>>> from fipy.meshes import Grid2D >>> mesh = Grid2D(dx = 1., dy = 1., nx = 10, ny = 10)
>>> var = CellVariable(mesh = mesh, value = 1., hasOld = 1, name = 'test') >>> x, y = mesh.cellCenters >>> var.value = (x * y)
>>> from fipy.tools import dump >>> (f, filename) = dump.write(var, extension = '.gz') >>> unPickledVar = dump.read(filename, f)
>>> print(var.allclose(unPickledVar, atol = 1e-10, rtol = 1e-10)) 1
- Parameters:
mesh (Mesh) – the mesh that defines the geometry of this Variable
name (str) – the user-readable name of the Variable
value (float or array_like) – the initial value
rank (int) – the rank (number of dimensions) of each element of this Variable. Default: 0
elementshape (
tuple
ofint
) – the shape of each element of this variable Default: rank * (mesh.dim,)unit (str or PhysicalUnit) – The physical units of the variable
- __abs__()¶
Following test it to fix a bug with C inline string using abs() instead of fabs()
>>> print(abs(Variable(2.3) - Variable(1.2))) 1.1
Check representation works with different versions of numpy
>>> print(repr(abs(Variable(2.3)))) numerix.fabs(Variable(value=array(2.3)))
- __add__(other)¶
- __and__(other)¶
This test case has been added due to a weird bug that was appearing.
>>> a = Variable(value=(0, 0, 1, 1)) >>> b = Variable(value=(0, 1, 0, 1)) >>> print(numerix.equal((a == 0) & (b == 1), [False, True, False, False]).all()) True >>> print(a & b) [0 0 0 1] >>> from fipy.meshes import Grid1D >>> mesh = Grid1D(nx=4) >>> from fipy.variables.cellVariable import CellVariable >>> a = CellVariable(value=(0, 0, 1, 1), mesh=mesh) >>> b = CellVariable(value=(0, 1, 0, 1), mesh=mesh) >>> print(numerix.allequal((a == 0) & (b == 1), [False, True, False, False])) True >>> print(a & b) [0 0 0 1]
- __array__(t=None)¶
Attempt to convert the Variable to a numerix array object
>>> v = Variable(value=[2, 3]) >>> print(numerix.array(v)) [2 3]
A dimensional Variable will convert to the numeric value in its base units
>>> v = Variable(value=[2, 3], unit="mm") >>> numerix.array(v) array([ 0.002, 0.003])
- __array_priority__ = 100.0¶
- __array_wrap__(arr, context=None)¶
Required to prevent numpy not calling the reverse binary operations. Both the following tests are examples ufuncs.
>>> print(type(numerix.array([1.0, 2.0]) * Variable([1.0, 2.0]))) <class 'fipy.variables.binaryOperatorVariable...binOp'>
>>> from scipy.special import gamma as Gamma >>> print(type(Gamma(Variable([1.0, 2.0])))) <class 'fipy.variables.unaryOperatorVariable...unOp'>
- __bool__()¶
>>> print(bool(Variable(value=0))) 0 >>> print(bool(Variable(value=(0, 0, 1, 1)))) Traceback (most recent call last): ... ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
- __call__(points=None, order=0, nearestCellIDs=None)¶
Interpolates the CellVariable to a set of points using a method that has a memory requirement on the order of Ncells by Npoints in general, but uses only Ncells when the CellVariable’s mesh is a UniformGrid object.
Tests
>>> from fipy import * >>> m = Grid2D(nx=3, ny=2) >>> v = CellVariable(mesh=m, value=m.cellCenters[0]) >>> print(v(((0., 1.1, 1.2), (0., 1., 1.)))) [ 0.5 1.5 1.5] >>> print(v(((0., 1.1, 1.2), (0., 1., 1.)), order=1)) [ 0.25 1.1 1.2 ] >>> m0 = Grid2D(nx=2, ny=2, dx=1., dy=1.) >>> m1 = Grid2D(nx=4, ny=4, dx=.5, dy=.5) >>> x, y = m0.cellCenters >>> v0 = CellVariable(mesh=m0, value=x * y) >>> print(v0(m1.cellCenters.globalValue)) [ 0.25 0.25 0.75 0.75 0.25 0.25 0.75 0.75 0.75 0.75 2.25 2.25 0.75 0.75 2.25 2.25] >>> print(v0(m1.cellCenters.globalValue, order=1)) [ 0.125 0.25 0.5 0.625 0.25 0.375 0.875 1. 0.5 0.875 1.875 2.25 0.625 1. 2.25 2.625]
- __div__(other)¶
- __eq__(other)¶
Test if a Variable is equal to another quantity
>>> a = Variable(value=3) >>> b = (a == 4) >>> b (Variable(value=array(3)) == 4) >>> b() 0
- __float__()¶
- __ge__(other)¶
Test if a Variable is greater than or equal to another quantity
>>> a = Variable(value=3) >>> b = (a >= 4) >>> b (Variable(value=array(3)) >= 4) >>> b() 0 >>> a.value = 4 >>> print(b()) 1 >>> a.value = 5 >>> print(b()) 1
- __getitem__(index)¶
“Evaluate” the Variable and return the specified element
>>> a = Variable(value=((3., 4.), (5., 6.)), unit="m") + "4 m" >>> print(a[1, 1]) 10.0 m
It is an error to slice a Variable whose value is not sliceable
>>> Variable(value=3)[2] Traceback (most recent call last): ... IndexError: 0-d arrays can't be indexed
- __getstate__()¶
Used internally to collect the necessary information to
pickle
the CellVariable to persistent storage.
- __gt__(other)¶
Test if a Variable is greater than another quantity
>>> a = Variable(value=3) >>> b = (a > 4) >>> b (Variable(value=array(3)) > 4) >>> print(b()) 0 >>> a.value = 5 >>> print(b()) 1
- __hash__()¶
Return hash(self).
- __int__()¶
- __invert__()¶
Returns logical “not” of the Variable
>>> a = Variable(value=True) >>> print(~a) False
- __iter__()¶
- __le__(other)¶
Test if a Variable is less than or equal to another quantity
>>> a = Variable(value=3) >>> b = (a <= 4) >>> b (Variable(value=array(3)) <= 4) >>> b() 1 >>> a.value = 4 >>> print(b()) 1 >>> a.value = 5 >>> print(b()) 0
- __len__()¶
- __lt__(other)¶
Test if a Variable is less than another quantity
>>> a = Variable(value=3) >>> b = (a < 4) >>> b (Variable(value=array(3)) < 4) >>> b() 1 >>> a.value = 4 >>> print(b()) 0 >>> print(1000000000000000000 * Variable(1) < 1.) 0 >>> print(1000 * Variable(1) < 1.) 0
Python automatically reverses the arguments when necessary
>>> 4 > Variable(value=3) (Variable(value=array(3)) < 4)
- __mod__(other)¶
- __mul__(other)¶
- __ne__(other)¶
Test if a Variable is not equal to another quantity
>>> a = Variable(value=3) >>> b = (a != 4) >>> b (Variable(value=array(3)) != 4) >>> b() 1
- __neg__()¶
- static __new__(cls, *args, **kwds)¶
- __nonzero__()¶
>>> print(bool(Variable(value=0))) 0 >>> print(bool(Variable(value=(0, 0, 1, 1)))) Traceback (most recent call last): ... ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
- __or__(other)¶
This test case has been added due to a weird bug that was appearing.
>>> a = Variable(value=(0, 0, 1, 1)) >>> b = Variable(value=(0, 1, 0, 1)) >>> print(numerix.equal((a == 0) | (b == 1), [True, True, False, True]).all()) True >>> print(a | b) [0 1 1 1] >>> from fipy.meshes import Grid1D >>> mesh = Grid1D(nx=4) >>> from fipy.variables.cellVariable import CellVariable >>> a = CellVariable(value=(0, 0, 1, 1), mesh=mesh) >>> b = CellVariable(value=(0, 1, 0, 1), mesh=mesh) >>> print(numerix.allequal((a == 0) | (b == 1), [True, True, False, True])) True >>> print(a | b) [0 1 1 1]
- __pos__()¶
- __pow__(other)¶
return self**other, or self raised to power other
>>> print(Variable(1, "mol/l")**3) 1.0 mol**3/l**3 >>> print((Variable(1, "mol/l")**3).unit) <PhysicalUnit mol**3/l**3>
- __radd__(other)¶
- __rdiv__(other)¶
- __repr__()¶
Return repr(self).
- __rmul__(other)¶
- __rpow__(other)¶
- __rsub__(other)¶
- __rtruediv__(other)¶
- __setitem__(index, value)¶
- __setstate__(dict)¶
Used internally to create a new CellVariable from
pickled
persistent storage.
- __str__()¶
Return str(self).
- __sub__(other)¶
- __truediv__(other)¶
- all(axis=None)¶
>>> print(Variable(value=(0, 0, 1, 1)).all()) 0 >>> print(Variable(value=(1, 1, 1, 1)).all()) 1
- allclose(other, rtol=1e-05, atol=1e-08)¶
>>> var = Variable((1, 1)) >>> print(var.allclose((1, 1))) 1 >>> print(var.allclose((1,))) 1
The following test is to check that the system does not run out of memory.
>>> from fipy.tools import numerix >>> var = Variable(numerix.ones(10000)) >>> print(var.allclose(numerix.zeros(10000, 'l'))) False
- allequal(other)¶
- any(axis=None)¶
>>> print(Variable(value=0).any()) 0 >>> print(Variable(value=(0, 0, 1, 1)).any()) 1
- property arithmeticFaceValue¶
Returns a FaceVariable whose value corresponds to the arithmetic interpolation of the adjacent cells:
>>> from fipy.meshes import Grid1D >>> from fipy import numerix >>> mesh = Grid1D(dx = (1., 1.)) >>> L = 1 >>> R = 2 >>> var = CellVariable(mesh = mesh, value = (L, R)) >>> faceValue = var.arithmeticFaceValue[mesh.interiorFaces.value] >>> answer = (R - L) * (0.5 / 1.) + L >>> print(numerix.allclose(faceValue, answer, atol = 1e-10, rtol = 1e-10)) True
>>> mesh = Grid1D(dx = (2., 4.)) >>> var = CellVariable(mesh = mesh, value = (L, R)) >>> faceValue = var.arithmeticFaceValue[mesh.interiorFaces.value] >>> answer = (R - L) * (1.0 / 3.0) + L >>> print(numerix.allclose(faceValue, answer, atol = 1e-10, rtol = 1e-10)) True
>>> mesh = Grid1D(dx = (10., 100.)) >>> var = CellVariable(mesh = mesh, value = (L, R)) >>> faceValue = var.arithmeticFaceValue[mesh.interiorFaces.value] >>> answer = (R - L) * (5.0 / 55.0) + L >>> print(numerix.allclose(faceValue, answer, atol = 1e-10, rtol = 1e-10)) True
- cacheMe(recursive=False)¶
- property cellVolumeAverage¶
Return the cell-volume-weighted average of the CellVariable:
>>> from fipy.meshes import Grid2D >>> from fipy.variables.cellVariable import CellVariable >>> mesh = Grid2D(nx = 3, ny = 1, dx = .5, dy = .1) >>> var = CellVariable(value = (1, 2, 6), mesh = mesh) >>> print(var.cellVolumeAverage) 3.0
- constrain(value, where=None)¶
Constrains the CellVariable to value at a location specified by where.
>>> from fipy import * >>> m = Grid1D(nx=3) >>> v = CellVariable(mesh=m, value=m.cellCenters[0]) >>> v.constrain(0., where=m.facesLeft) >>> v.faceGrad.constrain([1.], where=m.facesRight) >>> print(v.faceGrad) [[ 1. 1. 1. 1.]] >>> print(v.faceValue) [ 0. 1. 2. 2.5]
Changing the constraint changes the dependencies
>>> v.constrain(1., where=m.facesLeft) >>> print(v.faceGrad) [[-1. 1. 1. 1.]] >>> print(v.faceValue) [ 1. 1. 2. 2.5]
Constraints can be Variable
>>> c = Variable(0.) >>> v.constrain(c, where=m.facesLeft) >>> print(v.faceGrad) [[ 1. 1. 1. 1.]] >>> print(v.faceValue) [ 0. 1. 2. 2.5] >>> c.value = 1. >>> print(v.faceGrad) [[-1. 1. 1. 1.]] >>> print(v.faceValue) [ 1. 1. 2. 2.5]
Constraints can have a Variable mask.
>>> v = CellVariable(mesh=m) >>> mask = FaceVariable(mesh=m, value=m.facesLeft) >>> v.constrain(1., where=mask) >>> print(v.faceValue) [ 1. 0. 0. 0.] >>> mask[:] = mask | m.facesRight >>> print(v.faceValue) [ 1. 0. 0. 1.]
- property constraintMask¶
Test that constraintMask returns a Variable that updates itself whenever the constraints change.
>>> from fipy import *
>>> m = Grid2D(nx=2, ny=2) >>> x, y = m.cellCenters >>> v0 = CellVariable(mesh=m) >>> v0.constrain(1., where=m.facesLeft) >>> print(v0.faceValue.constraintMask) [False False False False False False True False False True False False] >>> print(v0.faceValue) [ 0. 0. 0. 0. 0. 0. 1. 0. 0. 1. 0. 0.] >>> v0.constrain(3., where=m.facesRight) >>> print(v0.faceValue.constraintMask) [False False False False False False True False True True False True] >>> print(v0.faceValue) [ 0. 0. 0. 0. 0. 0. 1. 0. 3. 1. 0. 3.] >>> v1 = CellVariable(mesh=m) >>> v1.constrain(1., where=(x < 1) & (y < 1)) >>> print(v1.constraintMask) [ True False False False] >>> print(v1) [ 1. 0. 0. 0.] >>> v1.constrain(3., where=(x > 1) & (y > 1)) >>> print(v1.constraintMask) [ True False False True] >>> print(v1) [ 1. 0. 0. 3.]
- property constraints¶
- copy()¶
Make an duplicate of the Variable
>>> a = Variable(value=3) >>> b = a.copy() >>> b Variable(value=array(3))
The duplicate will not reflect changes made to the original
>>> a.setValue(5) >>> b Variable(value=array(3))
Check that this works for arrays.
>>> a = Variable(value=numerix.array((0, 1, 2))) >>> b = a.copy() >>> b Variable(value=array([0, 1, 2])) >>> a[1] = 3 >>> b Variable(value=array([0, 1, 2]))
- dontCacheMe(recursive=False)¶
- dot(other, opShape=None, operatorClass=None)¶
Return the mesh-element–by–mesh-element (cell-by-cell, face-by-face, etc.) scalar product
Both self and other can be of arbitrary rank, and other does not need to be a _MeshVariable.
- property faceGrad¶
Return
as a rank-1 FaceVariable using differencing for the normal direction(second-order gradient).
- property faceGradAverage¶
Deprecated since version 3.3: use
grad.arithmeticFaceValue()
insteadReturn
as a rank-1 FaceVariable using averaging for the normal direction(second-order gradient)
- property faceValue¶
Returns a FaceVariable whose value corresponds to the arithmetic interpolation of the adjacent cells:
>>> from fipy.meshes import Grid1D >>> from fipy import numerix >>> mesh = Grid1D(dx = (1., 1.)) >>> L = 1 >>> R = 2 >>> var = CellVariable(mesh = mesh, value = (L, R)) >>> faceValue = var.arithmeticFaceValue[mesh.interiorFaces.value] >>> answer = (R - L) * (0.5 / 1.) + L >>> print(numerix.allclose(faceValue, answer, atol = 1e-10, rtol = 1e-10)) True
>>> mesh = Grid1D(dx = (2., 4.)) >>> var = CellVariable(mesh = mesh, value = (L, R)) >>> faceValue = var.arithmeticFaceValue[mesh.interiorFaces.value] >>> answer = (R - L) * (1.0 / 3.0) + L >>> print(numerix.allclose(faceValue, answer, atol = 1e-10, rtol = 1e-10)) True
>>> mesh = Grid1D(dx = (10., 100.)) >>> var = CellVariable(mesh = mesh, value = (L, R)) >>> faceValue = var.arithmeticFaceValue[mesh.interiorFaces.value] >>> answer = (R - L) * (5.0 / 55.0) + L >>> print(numerix.allclose(faceValue, answer, atol = 1e-10, rtol = 1e-10)) True
- property gaussGrad¶
Return
as a rank-1 CellVariable (first-order gradient).
- getsctype(default=None)¶
Returns the Numpy sctype of the underlying array.
>>> Variable(1).getsctype() == numerix.NUMERIX.obj2sctype(numerix.array(1)) True >>> Variable(1.).getsctype() == numerix.NUMERIX.obj2sctype(numerix.array(1.)) True >>> Variable((1, 1.)).getsctype() == numerix.NUMERIX.obj2sctype(numerix.array((1., 1.))) True
- property globalValue¶
Concatenate and return values from all processors
When running on a single processor, the result is identical to
value
.
- property grad¶
Return
as a rank-1 CellVariable (first-order gradient).
- property harmonicFaceValue¶
Returns a FaceVariable whose value corresponds to the harmonic interpolation of the adjacent cells:
>>> from fipy.meshes import Grid1D >>> from fipy import numerix >>> mesh = Grid1D(dx = (1., 1.)) >>> L = 1 >>> R = 2 >>> var = CellVariable(mesh = mesh, value = (L, R)) >>> faceValue = var.harmonicFaceValue[mesh.interiorFaces.value] >>> answer = L * R / ((R - L) * (0.5 / 1.) + L) >>> print(numerix.allclose(faceValue, answer, atol = 1e-10, rtol = 1e-10)) True
>>> mesh = Grid1D(dx = (2., 4.)) >>> var = CellVariable(mesh = mesh, value = (L, R)) >>> faceValue = var.harmonicFaceValue[mesh.interiorFaces.value] >>> answer = L * R / ((R - L) * (1.0 / 3.0) + L) >>> print(numerix.allclose(faceValue, answer, atol = 1e-10, rtol = 1e-10)) True
>>> mesh = Grid1D(dx = (10., 100.)) >>> var = CellVariable(mesh = mesh, value = (L, R)) >>> faceValue = var.harmonicFaceValue[mesh.interiorFaces.value] >>> answer = L * R / ((R - L) * (5.0 / 55.0) + L) >>> print(numerix.allclose(faceValue, answer, atol = 1e-10, rtol = 1e-10)) True
- inBaseUnits()¶
Return the value of the Variable with all units reduced to their base SI elements.
>>> e = Variable(value="2.7 Hartree*Nav") >>> print(e.inBaseUnits().allclose("7088849.01085 kg*m**2/s**2/mol")) 1
- inUnitsOf(*units)¶
Returns one or more Variable objects that express the same physical quantity in different units. The units are specified by strings containing their names. The units must be compatible with the unit of the object. If one unit is specified, the return value is a single Variable.
>>> freeze = Variable('0 degC') >>> print(freeze.inUnitsOf('degF').allclose("32.0 degF")) 1
If several units are specified, the return value is a tuple of Variable instances with with one element per unit such that the sum of all quantities in the tuple equals the the original quantity and all the values except for the last one are integers. This is used to convert to irregular unit systems like hour/minute/second. The original object will not be changed.
>>> t = Variable(value=314159., unit='s') >>> from builtins import zip >>> print(numerix.allclose([e.allclose(v) for (e, v) in zip(t.inUnitsOf('d', 'h', 'min', 's'), ... ['3.0 d', '15.0 h', '15.0 min', '59.0 s'])], ... True)) 1
- itemset(value)¶
- property itemsize¶
- property leastSquaresGrad¶
Return
, which is determined by solving for
in the following matrix equation,
The matrix equation is derived by minimizing the following least squares sum,
Tests
>>> from fipy import Grid2D >>> m = Grid2D(nx=2, ny=2, dx=0.1, dy=2.0) >>> print(numerix.allclose(CellVariable(mesh=m, value=(0, 1, 3, 6)).leastSquaresGrad.globalValue, \ ... [[8.0, 8.0, 24.0, 24.0], ... [1.2, 2.0, 1.2, 2.0]])) True
>>> from fipy import Grid1D >>> print(numerix.allclose(CellVariable(mesh=Grid1D(dx=(2.0, 1.0, 0.5)), ... value=(0, 1, 2)).leastSquaresGrad.globalValue, [[0.461538461538, 0.8, 1.2]])) True
- max(axis=None)¶
- min(axis=None)¶
>>> from fipy import Grid2D, CellVariable >>> mesh = Grid2D(nx=5, ny=5) >>> x, y = mesh.cellCenters >>> v = CellVariable(mesh=mesh, value=x*y) >>> print(v.min()) 0.25
- property minmodFaceValue¶
Returns a FaceVariable with a value that is the minimum of the absolute values of the adjacent cells. If the values are of opposite sign then the result is zero:
>>> from fipy import * >>> print(CellVariable(mesh=Grid1D(nx=2), value=(1, 2)).minmodFaceValue) [1 1 2] >>> print(CellVariable(mesh=Grid1D(nx=2), value=(-1, -2)).minmodFaceValue) [-1 -1 -2] >>> print(CellVariable(mesh=Grid1D(nx=2), value=(-1, 2)).minmodFaceValue) [-1 0 2]
- property name¶
- property numericValue¶
- property old¶
Return the values of the CellVariable from the previous solution sweep.
Combinations of CellVariable’s should also return old values.
>>> from fipy.meshes import Grid1D >>> mesh = Grid1D(nx = 2) >>> from fipy.variables.cellVariable import CellVariable >>> var1 = CellVariable(mesh = mesh, value = (2, 3), hasOld = 1) >>> var2 = CellVariable(mesh = mesh, value = (3, 4)) >>> v = var1 * var2 >>> print(v) [ 6 12] >>> var1.value = ((3, 2)) >>> print(v) [9 8] >>> print(v.old) [ 6 12]
The following small test is to correct for a bug when the operator does not just use variables.
>>> v1 = var1 * 3 >>> print(v1) [9 6] >>> print(v1.old) [6 9]
- put(indices, value)¶
- property rank¶
- ravel()¶
- rdot(other, opShape=None, operatorClass=None)¶
Return the mesh-element–by–mesh-element (cell-by-cell, face-by-face, etc.) scalar product
Both self and other can be of arbitrary rank, and other does not need to be a _MeshVariable.
- release(constraint)¶
Remove constraint from self
>>> from fipy import * >>> m = Grid1D(nx=3) >>> v = CellVariable(mesh=m, value=m.cellCenters[0]) >>> c = Constraint(0., where=m.facesLeft) >>> v.constrain(c) >>> print(v.faceValue) [ 0. 1. 2. 2.5] >>> v.release(constraint=c) >>> print(v.faceValue) [ 0.5 1. 2. 2.5]
- setValue(value, unit=None, where=None)¶
Set the value of the Variable. Can take a masked array.
>>> a = Variable((1, 2, 3)) >>> a.setValue(5, where=(1, 0, 1)) >>> print(a) [5 2 5]
>>> b = Variable((4, 5, 6)) >>> a.setValue(b, where=(1, 0, 1)) >>> print(a) [4 2 6] >>> print(b) [4 5 6] >>> a.value = 3 >>> print(a) [3 3 3]
>>> b = numerix.array((3, 4, 5)) >>> a.value = b >>> a[:] = 1 >>> print(b) [3 4 5]
>>> a.setValue((4, 5, 6), where=(1, 0)) Traceback (most recent call last): .... ValueError: shape mismatch: objects cannot be broadcast to a single shape
- property shape¶
>>> from fipy.meshes import Grid2D >>> from fipy.variables.cellVariable import CellVariable >>> mesh = Grid2D(nx=2, ny=3) >>> var = CellVariable(mesh=mesh) >>> print(numerix.allequal(var.shape, (6,))) True >>> print(numerix.allequal(var.arithmeticFaceValue.shape, (17,))) True >>> print(numerix.allequal(var.grad.shape, (2, 6))) True >>> print(numerix.allequal(var.faceGrad.shape, (2, 17))) True
Have to account for zero length arrays
>>> from fipy import Grid1D >>> m = Grid1D(nx=0) >>> v = CellVariable(mesh=m, elementshape=(2,)) >>> numerix.allequal((v * 1).shape, (2, 0)) True
- std(axis=None, **kwargs)¶
Evaluate standard deviation of all the elements of a MeshVariable.
Adapted from http://mpitutorial.com/tutorials/mpi-reduce-and-allreduce/
>>> import fipy as fp >>> mesh = fp.Grid2D(nx=2, ny=2, dx=2., dy=5.) >>> var = fp.CellVariable(value=(1., 2., 3., 4.), mesh=mesh) >>> print((var.std()**2).allclose(1.25)) True
- property subscribedVariables¶
- sum(axis=None)¶
- take(ids, axis=0)¶
- tostring(max_line_width=75, precision=8, suppress_small=False, separator=' ')¶
- property unit¶
Return the unit object of self.
>>> Variable(value="1 m").unit <PhysicalUnit m>
- updateOld()¶
Set the values of the previous solution sweep to the current values.
>>> from fipy import * >>> v = CellVariable(mesh=Grid1D(), hasOld=False) >>> v.updateOld() Traceback (most recent call last): ... AssertionError: The updateOld method requires the CellVariable to have an old value. Set hasOld to True when instantiating the CellVariable.
- property value¶
“Evaluate” the Variable and return its value (longhand)
>>> a = Variable(value=3) >>> print(a.value) 3 >>> b = a + 4 >>> b (Variable(value=array(3)) + 4) >>> b.value 7
- class fipy.CentralDifferenceConvectionTerm(coeff=1.0, var=None)¶
Bases:
_AbstractConvectionTerm
This
Term
representswhere
and
is calculated using the central differencing scheme. For further details see Numerical Schemes.
Create a _AbstractConvectionTerm object.
>>> from fipy import * >>> m = Grid1D(nx = 2) >>> cv = CellVariable(mesh = m) >>> fv = FaceVariable(mesh = m) >>> vcv = CellVariable(mesh=m, rank=1) >>> vfv = FaceVariable(mesh=m, rank=1) >>> __ConvectionTerm(coeff = cv) Traceback (most recent call last): ... VectorCoeffError: The coefficient must be a vector value. >>> __ConvectionTerm(coeff = fv) Traceback (most recent call last): ... VectorCoeffError: The coefficient must be a vector value. >>> __ConvectionTerm(coeff = vcv) __ConvectionTerm(coeff=_ArithmeticCellToFaceVariable(value=array([[ 0., 0., 0.]]), mesh=UniformGrid1D(dx=1.0, nx=2))) >>> __ConvectionTerm(coeff = vfv) __ConvectionTerm(coeff=FaceVariable(value=array([[ 0., 0., 0.]]), mesh=UniformGrid1D(dx=1.0, nx=2))) >>> __ConvectionTerm(coeff = (1,)) __ConvectionTerm(coeff=(1,)) >>> ExplicitUpwindConvectionTerm(coeff = (0,)).solve(var=cv, solver=DummySolver()) Traceback (most recent call last): ... TransientTermError: The equation requires a TransientTerm with explicit convection. >>> (TransientTerm(0.) - ExplicitUpwindConvectionTerm(coeff = (0,))).solve(var=cv, solver=DummySolver(), dt=1.)
>>> (TransientTerm() - ExplicitUpwindConvectionTerm(coeff = 1)).solve(var=cv, solver=DummySolver(), dt=1.) Traceback (most recent call last): ... VectorCoeffError: The coefficient must be a vector value. >>> m2 = Grid2D(nx=2, ny=1) >>> cv2 = CellVariable(mesh=m2) >>> vcv2 = CellVariable(mesh=m2, rank=1) >>> vfv2 = FaceVariable(mesh=m2, rank=1) >>> __ConvectionTerm(coeff=vcv2) __ConvectionTerm(coeff=_ArithmeticCellToFaceVariable(value=array([[ 0., 0., 0., 0., 0., 0., 0.], [ 0., 0., 0., 0., 0., 0., 0.]]), mesh=UniformGrid2D(dx=1.0, nx=2, dy=1.0, ny=1))) >>> __ConvectionTerm(coeff=vfv2) __ConvectionTerm(coeff=FaceVariable(value=array([[ 0., 0., 0., 0., 0., 0., 0.], [ 0., 0., 0., 0., 0., 0., 0.]]), mesh=UniformGrid2D(dx=1.0, nx=2, dy=1.0, ny=1))) >>> (TransientTerm() - ExplicitUpwindConvectionTerm(coeff = ((0,), (0,)))).solve(var=cv2, solver=DummySolver(), dt=1.) >>> (TransientTerm() - ExplicitUpwindConvectionTerm(coeff = (0, 0))).solve(var=cv2, solver=DummySolver(), dt=1.)
- Parameters:
coeff (The Term’s coefficient value.) –
- property RHSvector¶
Return the RHS vector calculated in solve() or sweep(). The cacheRHSvector() method should be called before solve() or sweep() to cache the vector.
- __add__(other)¶
- __and__(other)¶
- __div__(other)¶
- __eq__(other)¶
Return self==value.
- __hash__()¶
Return hash(self).
- __mul__(other)¶
Multiply a term
>>> 2. * __NonDiffusionTerm(coeff=0.5) __NonDiffusionTerm(coeff=1.0)
Test for ticket:291.
>>> from fipy import PowerLawConvectionTerm >>> PowerLawConvectionTerm(coeff=[[1], [0]]) * 1.0 PowerLawConvectionTerm(coeff=array([[ 1.], [ 0.]]))
- __neg__()¶
Negate a Term.
>>> -__NonDiffusionTerm(coeff=1.) __NonDiffusionTerm(coeff=-1.0)
- __pos__()¶
- __radd__(other)¶
- __rand__(other)¶
- __repr__()¶
The representation of a Term object is given by,
>>> print(__UnaryTerm(123.456)) __UnaryTerm(coeff=123.456)
- __rmul__(other)¶
Multiply a term
>>> 2. * __NonDiffusionTerm(coeff=0.5) __NonDiffusionTerm(coeff=1.0)
Test for ticket:291.
>>> from fipy import PowerLawConvectionTerm >>> PowerLawConvectionTerm(coeff=[[1], [0]]) * 1.0 PowerLawConvectionTerm(coeff=array([[ 1.], [ 0.]]))
- __rsub__(other)¶
- __sub__(other)¶
- __truediv__(other)¶
- cacheMatrix()¶
Informs solve() and sweep() to cache their matrix so that matrix can return the matrix.
- cacheRHSvector()¶
Informs solve() and sweep() to cache their right hand side vector so that getRHSvector() can return it.
- copy()¶
- getDefaultSolver(var=None, solver=None, *args, **kwargs)¶
- justErrorVector(var=None, solver=None, boundaryConditions=(), dt=1.0, underRelaxation=None, residualFn=None)¶
Builds the Term’s linear system once.
This method also recalculates and returns the error as well as applying under-relaxation.
justErrorVector returns the overlapping local value in parallel (not the non-overlapping value).
>>> from fipy.solvers import DummySolver >>> from fipy import * >>> m = Grid1D(nx=10) >>> v = CellVariable(mesh=m) >>> len(DiffusionTerm().justErrorVector(v, solver=DummySolver())) == m.numberOfCells True
- Parameters:
var (CellVariable) – Variable to be solved for. Provides the initial condition, the old value and holds the solution on completion.
solver (Solver) – Iterative solver to be used to solve the linear system of equations. The default sovler depends on the solver package selected.
boundaryConditions (
tuple
ofBoundaryCondition
) –dt (float) – Timestep size.
underRelaxation (float) – Usually a value between 0 and 1 or None in the case of no under-relaxation
residualFn (function) – Takes var, matrix, and RHSvector arguments, used to customize the residual calculation.
- Returns:
error – The residual vector
- Return type:
- justResidualVector(var=None, solver=None, boundaryConditions=(), dt=None, underRelaxation=None, residualFn=None)¶
Builds the Term’s linear system once.
This method also recalculates and returns the residual as well as applying under-relaxation.
justResidualVector returns the overlapping local value in parallel (not the non-overlapping value).
>>> from fipy import * >>> m = Grid1D(nx=10) >>> v = CellVariable(mesh=m) >>> len(numerix.asarray(DiffusionTerm().justResidualVector(v))) == m.numberOfCells True
- Parameters:
var (CellVariable) – Variable to be solved for. Provides the initial condition, the old value and holds the solution on completion.
solver (Solver) – Iterative solver to be used to solve the linear system of equations. The default sovler depends on the solver package selected.
boundaryConditions (
tuple
ofBoundaryCondition
) –dt (float) – Timestep size.
underRelaxation (float) – Usually a value between 0 and 1 or None in the case of no under-relaxation
residualFn (function) – Takes var, matrix, and RHSvector arguments, used to customize the residual calculation.
- Returns:
residual – The residual vector
- Return type:
- property matrix¶
Return the matrix calculated in solve() or sweep(). The cacheMatrix() method should be called before solve() or sweep() to cache the matrix.
- residualVectorAndNorm(var=None, solver=None, boundaryConditions=(), dt=None, underRelaxation=None, residualFn=None)¶
Builds the Term’s linear system once.
This method also recalculates and returns the residual as well as applying under-relaxation.
- Parameters:
var (CellVariable) – Variable to be solved for. Provides the initial condition, the old value and holds the solution on completion.
solver (Solver) – Iterative solver to be used to solve the linear system of equations. The default sovler depends on the solver package selected.
boundaryConditions (
tuple
ofBoundaryCondition
) –dt (float) – Timestep size.
underRelaxation (float) – Usually a value between 0 and 1 or None in the case of no under-relaxation
residualFn (function) – Takes var, matrix, and RHSvector arguments, used to customize the residual calculation.
- Returns:
residual (~fipy.variables.cellVariable.CellVariable) – The residual vector
norm (float) – The L2 norm of residual,
- solve(var=None, solver=None, boundaryConditions=(), dt=None)¶
Builds and solves the Term’s linear system once. This method does not return the residual. It should be used when the residual is not required.
- Parameters:
var (CellVariable) – Variable to be solved for. Provides the initial condition, the old value and holds the solution on completion.
solver (Solver) – Iterative solver to be used to solve the linear system of equations. The default sovler depends on the solver package selected.
boundaryConditions (
tuple
ofBoundaryCondition
) –dt (float) – Timestep size.
- sweep(var=None, solver=None, boundaryConditions=(), dt=None, underRelaxation=None, residualFn=None, cacheResidual=False, cacheError=False)¶
Builds and solves the Term’s linear system once. This method also recalculates and returns the residual as well as applying under-relaxation.
- Parameters:
var (CellVariable) – Variable to be solved for. Provides the initial condition, the old value and holds the solution on completion.
solver (Solver) – Iterative solver to be used to solve the linear system of equations. The default sovler depends on the solver package selected.
boundaryConditions (
tuple
ofBoundaryCondition
) –dt (float) – Timestep size.
underRelaxation (float) – Usually a value between 0 and 1 or None in the case of no under-relaxation
residualFn (function) – Takes var, matrix, and RHSvector arguments, used to customize the residual calculation.
cacheResidual (bool) – If True, calculate and store the residual vector
in the residualVector member of Term
cacheError (bool) – If True, use the residual vector
to solve
for the error vector
and store it in the errorVector member of Term
- Returns:
residual – The residual vector
- Return type:
- class fipy.Constraint(value, where=None)¶
Bases:
object
Object to hold a Variable to value at where
see
constrain()
- __repr__()¶
Return repr(self).
- fipy.ConvectionTerm¶
alias of
PowerLawConvectionTerm
- fipy.CylindricalGrid1D(dr=None, nr=None, Lr=None, dx=1.0, nx=None, Lx=None, origin=(0,), overlap=2, communicator=SerialPETScCommWrapper())¶
Create a 2D cylindrical mesh
Factory function to select between
CylindricalUniformGrid1D
andCylindricalNonUniformGrid1D
. If Lr is specified the length of the domain is always Lr regardless of dr, unless dr is a list of spacings, in which case Lr will be the sum of dr.- Parameters:
dr (float) – Grid spacing in the radial direction. Alternative: dx.
nr (int) – Number of cells in the radial direction. Alternative: nx.
Lr (float) – Domain length in the radial direction. Alternative: Lx.
overlap (int) – the number of overlapping cells for parallel simulations. Generally 2 is adequate. Higher order equations or discretizations require more.
communicator (CommWrapper) – MPI communicator to use. Select
serialComm
to create a serial mesh when running in parallel; mostly used for test purposes. (default:parallelComm
).
- fipy.CylindricalGrid2D(dr=None, dz=None, nr=None, nz=None, Lr=None, Lz=None, dx=1.0, dy=1.0, nx=None, ny=None, Lx=None, Ly=None, origin=((0,), (0,)), overlap=2, communicator=SerialPETScCommWrapper())¶
Create a 2D cylindrical mesh
Factory function to select between
CylindricalUniformGrid2D
andCylindricalNonUniformGrid2D
. If Lr is specified the length of the domain is always Lr regardless of dr, unless dr is a list of spacings, in which case Lr will be the sum of dr.- Parameters:
dr (float) – Grid spacing in the radial direction. Alternative: dx.
dz (float) – grid spacing in the vertical direction. Alternative: dy.
nr (int) – Number of cells in the radial direction. Alternative: nx.
nz (int) – Number of cells in the vertical direction. Alternative: ny.
Lr (float) – Domain length in the radial direction. Alternative: Lx.
Lz (float) – Domain length in the vertical direction. Alternative: Ly.
overlap (int) – the number of overlapping cells for parallel simulations. Generally 2 is adequate. Higher order equations or discretizations require more.
communicator (CommWrapper) – MPI communicator to use. Select
serialComm
to create a serial mesh when running in parallel; mostly used for test purposes. (default:parallelComm
).
- fipy.DefaultAsymmetricSolver¶
alias of
LinearGMRESSolver
- fipy.DefaultSolver¶
alias of
LinearGMRESSolver
- class fipy.DiffusionTerm(coeff=(1.0,), var=None)¶
Bases:
DiffusionTermNoCorrection
This term represents a higher order diffusion term. The order of the term is determined by the number of coeffs, such that:
DiffusionTerm(D1)
represents a typical 2nd-order diffusion term of the form
and:
DiffusionTerm((D1,D2))
represents a 4th-order Cahn-Hilliard term of the form
and so on.
Create a Term.
- Parameters:
coeff (float or CellVariable or FaceVariable) – Coefficient for the term. FaceVariable objects are only acceptable for diffusion or convection terms.
- property RHSvector¶
Return the RHS vector calculated in solve() or sweep(). The cacheRHSvector() method should be called before solve() or sweep() to cache the vector.
- __add__(other)¶
- __and__(other)¶
- __div__(other)¶
- __eq__(other)¶
Return self==value.
- __hash__()¶
Return hash(self).
- __mul__(other)¶
- __neg__()¶
- __pos__()¶
- __radd__(other)¶
- __rand__(other)¶
- __repr__()¶
The representation of a Term object is given by,
>>> print(__UnaryTerm(123.456)) __UnaryTerm(coeff=123.456)
- __rmul__(other)¶
- __rsub__(other)¶
- __sub__(other)¶
- __truediv__(other)¶
- cacheMatrix()¶
Informs solve() and sweep() to cache their matrix so that matrix can return the matrix.
- cacheRHSvector()¶
Informs solve() and sweep() to cache their right hand side vector so that getRHSvector() can return it.
- copy()¶
- getDefaultSolver(var=None, solver=None, *args, **kwargs)¶
- justErrorVector(var=None, solver=None, boundaryConditions=(), dt=1.0, underRelaxation=None, residualFn=None)¶
Builds the Term’s linear system once.
This method also recalculates and returns the error as well as applying under-relaxation.
justErrorVector returns the overlapping local value in parallel (not the non-overlapping value).
>>> from fipy.solvers import DummySolver >>> from fipy import * >>> m = Grid1D(nx=10) >>> v = CellVariable(mesh=m) >>> len(DiffusionTerm().justErrorVector(v, solver=DummySolver())) == m.numberOfCells True
- Parameters:
var (CellVariable) – Variable to be solved for. Provides the initial condition, the old value and holds the solution on completion.
solver (Solver) – Iterative solver to be used to solve the linear system of equations. The default sovler depends on the solver package selected.
boundaryConditions (
tuple
ofBoundaryCondition
) –dt (float) – Timestep size.
underRelaxation (float) – Usually a value between 0 and 1 or None in the case of no under-relaxation
residualFn (function) – Takes var, matrix, and RHSvector arguments, used to customize the residual calculation.
- Returns:
error – The residual vector
- Return type:
- justResidualVector(var=None, solver=None, boundaryConditions=(), dt=None, underRelaxation=None, residualFn=None)¶
Builds the Term’s linear system once.
This method also recalculates and returns the residual as well as applying under-relaxation.
justResidualVector returns the overlapping local value in parallel (not the non-overlapping value).
>>> from fipy import * >>> m = Grid1D(nx=10) >>> v = CellVariable(mesh=m) >>> len(numerix.asarray(DiffusionTerm().justResidualVector(v))) == m.numberOfCells True
- Parameters:
var (CellVariable) – Variable to be solved for. Provides the initial condition, the old value and holds the solution on completion.
solver (Solver) – Iterative solver to be used to solve the linear system of equations. The default sovler depends on the solver package selected.
boundaryConditions (
tuple
ofBoundaryCondition
) –dt (float) – Timestep size.
underRelaxation (float) – Usually a value between 0 and 1 or None in the case of no under-relaxation
residualFn (function) – Takes var, matrix, and RHSvector arguments, used to customize the residual calculation.
- Returns:
residual – The residual vector
- Return type:
- property matrix¶
Return the matrix calculated in solve() or sweep(). The cacheMatrix() method should be called before solve() or sweep() to cache the matrix.
- residualVectorAndNorm(var=None, solver=None, boundaryConditions=(), dt=None, underRelaxation=None, residualFn=None)¶
Builds the Term’s linear system once.
This method also recalculates and returns the residual as well as applying under-relaxation.
- Parameters:
var (CellVariable) – Variable to be solved for. Provides the initial condition, the old value and holds the solution on completion.
solver (Solver) – Iterative solver to be used to solve the linear system of equations. The default sovler depends on the solver package selected.
boundaryConditions (
tuple
ofBoundaryCondition
) –dt (float) – Timestep size.
underRelaxation (float) – Usually a value between 0 and 1 or None in the case of no under-relaxation
residualFn (function) – Takes var, matrix, and RHSvector arguments, used to customize the residual calculation.
- Returns:
residual (~fipy.variables.cellVariable.CellVariable) – The residual vector
norm (float) – The L2 norm of residual,
- solve(var=None, solver=None, boundaryConditions=(), dt=None)¶
Builds and solves the Term’s linear system once. This method does not return the residual. It should be used when the residual is not required.
- Parameters:
var (CellVariable) – Variable to be solved for. Provides the initial condition, the old value and holds the solution on completion.
solver (Solver) – Iterative solver to be used to solve the linear system of equations. The default sovler depends on the solver package selected.
boundaryConditions (
tuple
ofBoundaryCondition
) –dt (float) – Timestep size.
- sweep(var=None, solver=None, boundaryConditions=(), dt=None, underRelaxation=None, residualFn=None, cacheResidual=False, cacheError=False)¶
Builds and solves the Term’s linear system once. This method also recalculates and returns the residual as well as applying under-relaxation.
- Parameters:
var (CellVariable) – Variable to be solved for. Provides the initial condition, the old value and holds the solution on completion.
solver (Solver) – Iterative solver to be used to solve the linear system of equations. The default sovler depends on the solver package selected.
boundaryConditions (
tuple
ofBoundaryCondition
) –dt (float) – Timestep size.
underRelaxation (float) – Usually a value between 0 and 1 or None in the case of no under-relaxation
residualFn (function) – Takes var, matrix, and RHSvector arguments, used to customize the residual calculation.
cacheResidual (bool) – If True, calculate and store the residual vector
in the residualVector member of Term
cacheError (bool) – If True, use the residual vector
to solve
for the error vector
and store it in the errorVector member of Term
- Returns:
residual – The residual vector
- Return type:
- class fipy.DiffusionTermCorrection(coeff=(1.0,), var=None)¶
Bases:
_AbstractDiffusionTerm
Create a Term.
- Parameters:
coeff (float or CellVariable or FaceVariable) – Coefficient for the term. FaceVariable objects are only acceptable for diffusion or convection terms.
- property RHSvector¶
Return the RHS vector calculated in solve() or sweep(). The cacheRHSvector() method should be called before solve() or sweep() to cache the vector.
- __add__(other)¶
- __and__(other)¶
- __div__(other)¶
- __eq__(other)¶
Return self==value.
- __hash__()¶
Return hash(self).
- __mul__(other)¶
- __neg__()¶
- __pos__()¶
- __radd__(other)¶
- __rand__(other)¶
- __repr__()¶
The representation of a Term object is given by,
>>> print(__UnaryTerm(123.456)) __UnaryTerm(coeff=123.456)
- __rmul__(other)¶
- __rsub__(other)¶
- __sub__(other)¶
- __truediv__(other)¶
- cacheMatrix()¶
Informs solve() and sweep() to cache their matrix so that matrix can return the matrix.
- cacheRHSvector()¶
Informs solve() and sweep() to cache their right hand side vector so that getRHSvector() can return it.
- copy()¶
- getDefaultSolver(var=None, solver=None, *args, **kwargs)¶
- justErrorVector(var=None, solver=None, boundaryConditions=(), dt=1.0, underRelaxation=None, residualFn=None)¶
Builds the Term’s linear system once.
This method also recalculates and returns the error as well as applying under-relaxation.
justErrorVector returns the overlapping local value in parallel (not the non-overlapping value).
>>> from fipy.solvers import DummySolver >>> from fipy import * >>> m = Grid1D(nx=10) >>> v = CellVariable(mesh=m) >>> len(DiffusionTerm().justErrorVector(v, solver=DummySolver())) == m.numberOfCells True
- Parameters:
var (CellVariable) – Variable to be solved for. Provides the initial condition, the old value and holds the solution on completion.
solver (Solver) – Iterative solver to be used to solve the linear system of equations. The default sovler depends on the solver package selected.
boundaryConditions (
tuple
ofBoundaryCondition
) –dt (float) – Timestep size.
underRelaxation (float) – Usually a value between 0 and 1 or None in the case of no under-relaxation
residualFn (function) – Takes var, matrix, and RHSvector arguments, used to customize the residual calculation.
- Returns:
error – The residual vector
- Return type:
- justResidualVector(var=None, solver=None, boundaryConditions=(), dt=None, underRelaxation=None, residualFn=None)¶
Builds the Term’s linear system once.
This method also recalculates and returns the residual as well as applying under-relaxation.
justResidualVector returns the overlapping local value in parallel (not the non-overlapping value).
>>> from fipy import * >>> m = Grid1D(nx=10) >>> v = CellVariable(mesh=m) >>> len(numerix.asarray(DiffusionTerm().justResidualVector(v))) == m.numberOfCells True
- Parameters:
var (CellVariable) – Variable to be solved for. Provides the initial condition, the old value and holds the solution on completion.
solver (Solver) – Iterative solver to be used to solve the linear system of equations. The default sovler depends on the solver package selected.
boundaryConditions (
tuple
ofBoundaryCondition
) –dt (float) – Timestep size.
underRelaxation (float) – Usually a value between 0 and 1 or None in the case of no under-relaxation
residualFn (function) – Takes var, matrix, and RHSvector arguments, used to customize the residual calculation.
- Returns:
residual – The residual vector
- Return type:
- property matrix¶
Return the matrix calculated in solve() or sweep(). The cacheMatrix() method should be called before solve() or sweep() to cache the matrix.
- residualVectorAndNorm(var=None, solver=None, boundaryConditions=(), dt=None, underRelaxation=None, residualFn=None)¶
Builds the Term’s linear system once.
This method also recalculates and returns the residual as well as applying under-relaxation.
- Parameters:
var (CellVariable) – Variable to be solved for. Provides the initial condition, the old value and holds the solution on completion.
solver (Solver) – Iterative solver to be used to solve the linear system of equations. The default sovler depends on the solver package selected.
boundaryConditions (
tuple
ofBoundaryCondition
) –dt (float) – Timestep size.
underRelaxation (float) – Usually a value between 0 and 1 or None in the case of no under-relaxation
residualFn (function) – Takes var, matrix, and RHSvector arguments, used to customize the residual calculation.
- Returns:
residual (~fipy.variables.cellVariable.CellVariable) – The residual vector
norm (float) – The L2 norm of residual,
- solve(var=None, solver=None, boundaryConditions=(), dt=None)¶
Builds and solves the Term’s linear system once. This method does not return the residual. It should be used when the residual is not required.
- Parameters:
var (CellVariable) – Variable to be solved for. Provides the initial condition, the old value and holds the solution on completion.
solver (Solver) – Iterative solver to be used to solve the linear system of equations. The default sovler depends on the solver package selected.
boundaryConditions (
tuple
ofBoundaryCondition
) –dt (float) – Timestep size.
- sweep(var=None, solver=None, boundaryConditions=(), dt=None, underRelaxation=None, residualFn=None, cacheResidual=False, cacheError=False)¶
Builds and solves the Term’s linear system once. This method also recalculates and returns the residual as well as applying under-relaxation.
- Parameters:
var (CellVariable) – Variable to be solved for. Provides the initial condition, the old value and holds the solution on completion.
solver (Solver) – Iterative solver to be used to solve the linear system of equations. The default sovler depends on the solver package selected.
boundaryConditions (
tuple
ofBoundaryCondition
) –dt (float) – Timestep size.
underRelaxation (float) – Usually a value between 0 and 1 or None in the case of no under-relaxation
residualFn (function) – Takes var, matrix, and RHSvector arguments, used to customize the residual calculation.
cacheResidual (bool) – If True, calculate and store the residual vector
in the residualVector member of Term
cacheError (bool) – If True, use the residual vector
to solve
for the error vector
and store it in the errorVector member of Term
- Returns:
residual – The residual vector
- Return type:
- class fipy.DiffusionTermNoCorrection(coeff=(1.0,), var=None)¶
Bases:
_AbstractDiffusionTerm
Create a Term.
- Parameters:
coeff (float or CellVariable or FaceVariable) – Coefficient for the term. FaceVariable objects are only acceptable for diffusion or convection terms.
- property RHSvector¶
Return the RHS vector calculated in solve() or sweep(). The cacheRHSvector() method should be called before solve() or sweep() to cache the vector.
- __add__(other)¶
- __and__(other)¶
- __div__(other)¶
- __eq__(other)¶
Return self==value.
- __hash__()¶
Return hash(self).
- __mul__(other)¶
- __neg__()¶
- __pos__()¶
- __radd__(other)¶
- __rand__(other)¶
- __repr__()¶
The representation of a Term object is given by,
>>> print(__UnaryTerm(123.456)) __UnaryTerm(coeff=123.456)
- __rmul__(other)¶
- __rsub__(other)¶
- __sub__(other)¶
- __truediv__(other)¶
- cacheMatrix()¶
Informs solve() and sweep() to cache their matrix so that matrix can return the matrix.
- cacheRHSvector()¶
Informs solve() and sweep() to cache their right hand side vector so that getRHSvector() can return it.
- copy()¶
- getDefaultSolver(var=None, solver=None, *args, **kwargs)¶
- justErrorVector(var=None, solver=None, boundaryConditions=(), dt=1.0, underRelaxation=None, residualFn=None)¶
Builds the Term’s linear system once.
This method also recalculates and returns the error as well as applying under-relaxation.
justErrorVector returns the overlapping local value in parallel (not the non-overlapping value).
>>> from fipy.solvers import DummySolver >>> from fipy import * >>> m = Grid1D(nx=10) >>> v = CellVariable(mesh=m) >>> len(DiffusionTerm().justErrorVector(v, solver=DummySolver())) == m.numberOfCells True
- Parameters:
var (CellVariable) – Variable to be solved for. Provides the initial condition, the old value and holds the solution on completion.
solver (Solver) – Iterative solver to be used to solve the linear system of equations. The default sovler depends on the solver package selected.
boundaryConditions (
tuple
ofBoundaryCondition
) –dt (float) – Timestep size.
underRelaxation (float) – Usually a value between 0 and 1 or None in the case of no under-relaxation
residualFn (function) – Takes var, matrix, and RHSvector arguments, used to customize the residual calculation.
- Returns:
error – The residual vector
- Return type:
- justResidualVector(var=None, solver=None, boundaryConditions=(), dt=None, underRelaxation=None, residualFn=None)¶
Builds the Term’s linear system once.
This method also recalculates and returns the residual as well as applying under-relaxation.
justResidualVector returns the overlapping local value in parallel (not the non-overlapping value).
>>> from fipy import * >>> m = Grid1D(nx=10) >>> v = CellVariable(mesh=m) >>> len(numerix.asarray(DiffusionTerm().justResidualVector(v))) == m.numberOfCells True
- Parameters:
var (CellVariable) – Variable to be solved for. Provides the initial condition, the old value and holds the solution on completion.
solver (Solver) – Iterative solver to be used to solve the linear system of equations. The default sovler depends on the solver package selected.
boundaryConditions (
tuple
ofBoundaryCondition
) –dt (float) – Timestep size.
underRelaxation (float) – Usually a value between 0 and 1 or None in the case of no under-relaxation
residualFn (function) – Takes var, matrix, and RHSvector arguments, used to customize the residual calculation.
- Returns:
residual – The residual vector
- Return type:
- property matrix¶
Return the matrix calculated in solve() or sweep(). The cacheMatrix() method should be called before solve() or sweep() to cache the matrix.
- residualVectorAndNorm(var=None, solver=None, boundaryConditions=(), dt=None, underRelaxation=None, residualFn=None)¶
Builds the Term’s linear system once.
This method also recalculates and returns the residual as well as applying under-relaxation.
- Parameters:
var (CellVariable) – Variable to be solved for. Provides the initial condition, the old value and holds the solution on completion.
solver (Solver) – Iterative solver to be used to solve the linear system of equations. The default sovler depends on the solver package selected.
boundaryConditions (
tuple
ofBoundaryCondition
) –dt (float) – Timestep size.
underRelaxation (float) – Usually a value between 0 and 1 or None in the case of no under-relaxation
residualFn (function) – Takes var, matrix, and RHSvector arguments, used to customize the residual calculation.
- Returns:
residual (~fipy.variables.cellVariable.CellVariable) – The residual vector
norm (float) – The L2 norm of residual,
- solve(var=None, solver=None, boundaryConditions=(), dt=None)¶
Builds and solves the Term’s linear system once. This method does not return the residual. It should be used when the residual is not required.
- Parameters:
var (CellVariable) – Variable to be solved for. Provides the initial condition, the old value and holds the solution on completion.
solver (Solver) – Iterative solver to be used to solve the linear system of equations. The default sovler depends on the solver package selected.
boundaryConditions (
tuple
ofBoundaryCondition
) –dt (float) – Timestep size.
- sweep(var=None, solver=None, boundaryConditions=(), dt=None, underRelaxation=None, residualFn=None, cacheResidual=False, cacheError=False)¶
Builds and solves the Term’s linear system once. This method also recalculates and returns the residual as well as applying under-relaxation.
- Parameters:
var (CellVariable) – Variable to be solved for. Provides the initial condition, the old value and holds the solution on completion.
solver (Solver) – Iterative solver to be used to solve the linear system of equations. The default sovler depends on the solver package selected.
boundaryConditions (
tuple
ofBoundaryCondition
) –dt (float) – Timestep size.
underRelaxation (float) – Usually a value between 0 and 1 or None in the case of no under-relaxation
residualFn (function) – Takes var, matrix, and RHSvector arguments, used to customize the residual calculation.
cacheResidual (bool) – If True, calculate and store the residual vector
in the residualVector member of Term
cacheError (bool) – If True, use the residual vector
to solve
for the error vector
and store it in the errorVector member of Term
- Returns:
residual – The residual vector
- Return type:
- class fipy.DistanceVariable(*args, **kwds)¶
Bases:
CellVariable
A DistanceVariable object calculates
so it satisfies,
using the fast marching method with an initial condition defined by the zero level set. The solution can either be first or second order.
Here we will define a few test cases. Firstly a 1D test case
>>> from fipy.meshes import Grid1D >>> from fipy.tools import serialComm >>> mesh = Grid1D(dx = .5, nx = 8, communicator=serialComm) >>> from .distanceVariable import DistanceVariable >>> var = DistanceVariable(mesh = mesh, value = (-1., -1., -1., -1., 1., 1., 1., 1.)) >>> var.calcDistanceFunction() >>> answer = (-1.75, -1.25, -.75, -0.25, 0.25, 0.75, 1.25, 1.75) >>> print(var.allclose(answer)) 1
A 1D test case with very small dimensions.
>>> dx = 1e-10 >>> mesh = Grid1D(dx = dx, nx = 8, communicator=serialComm) >>> var = DistanceVariable(mesh = mesh, value = (-1., -1., -1., -1., 1., 1., 1., 1.)) >>> var.calcDistanceFunction() >>> answer = numerix.arange(8) * dx - 3.5 * dx >>> print(var.allclose(answer)) 1
A 2D test case to test _calcTrialValue for a pathological case.
>>> dx = 1. >>> dy = 2. >>> from fipy.meshes import Grid2D >>> mesh = Grid2D(dx = dx, dy = dy, nx = 2, ny = 3, communicator=serialComm) >>> var = DistanceVariable(mesh = mesh, value = (-1., 1., 1., 1., -1., 1.))
>>> var.calcDistanceFunction() >>> vbl = -dx * dy / numerix.sqrt(dx**2 + dy**2) / 2. >>> vbr = dx / 2 >>> vml = dy / 2. >>> crossProd = dx * dy >>> dsq = dx**2 + dy**2 >>> top = vbr * dx**2 + vml * dy**2 >>> sqrt = crossProd**2 *(dsq - (vbr - vml)**2) >>> sqrt = numerix.sqrt(max(sqrt, 0)) >>> vmr = (top + sqrt) / dsq >>> answer = (vbl, vbr, vml, vmr, vbl, vbr) >>> print(var.allclose(answer)) 1
The extendVariable method solves the following equation for a given extensionVariable.
using the fast marching method with an initial condition defined at the zero level set.
>>> from fipy.variables.cellVariable import CellVariable >>> mesh = Grid2D(dx = 1., dy = 1., nx = 2, ny = 2, communicator=serialComm) >>> var = DistanceVariable(mesh = mesh, value = (-1., 1., 1., 1.)) >>> var.calcDistanceFunction() >>> extensionVar = CellVariable(mesh = mesh, value = (-1, .5, 2, -1)) >>> tmp = 1 / numerix.sqrt(2) >>> print(var.allclose((-tmp / 2, 0.5, 0.5, 0.5 + tmp))) 1 >>> var.extendVariable(extensionVar, order=1) >>> print(extensionVar.allclose((1.25, .5, 2, 1.25))) 1 >>> mesh = Grid2D(dx = 1., dy = 1., nx = 3, ny = 3, communicator=serialComm) >>> var = DistanceVariable(mesh = mesh, value = (-1., 1., 1., ... 1., 1., 1., ... 1., 1., 1.)) >>> var.calcDistanceFunction(order=1) >>> extensionVar = CellVariable(mesh = mesh, value = (-1., .5, -1., ... 2., -1., -1., ... -1., -1., -1.))
>>> v1 = 0.5 + tmp >>> v2 = 1.5 >>> tmp1 = (v1 + v2) / 2 + numerix.sqrt(2. - (v1 - v2)**2) / 2 >>> tmp2 = tmp1 + 1 / numerix.sqrt(2) >>> print(var.allclose((-tmp / 2, 0.5, 1.5, 0.5, 0.5 + tmp, ... tmp1, 1.5, tmp1, tmp2))) 1 >>> answer = (1.25, .5, .5, 2, 1.25, 0.9544, 2, 1.5456, 1.25) >>> var.extendVariable(extensionVar, order=1) >>> print(extensionVar.allclose(answer, rtol = 1e-4)) 1
Test case for a bug that occurs when initializing the distance variable at the interface. Currently it is assumed that adjacent cells that are opposite sign neighbors have perpendicular normal vectors. In fact the two closest cells could have opposite normals.
>>> mesh = Grid1D(dx = 1., nx = 3, communicator=serialComm) >>> var = DistanceVariable(mesh = mesh, value = (-1., 1., -1.)) >>> var.calcDistanceFunction() >>> print(var.allclose((-0.5, 0.5, -0.5))) 1
Testing second order. This example failed with Scikit-fmm.
>>> mesh = Grid2D(dx = 1., dy = 1., nx = 4, ny = 4, communicator=serialComm) >>> var = DistanceVariable(mesh = mesh, value = (-1., -1., 1., 1., ... -1., -1., 1., 1., ... 1., 1., 1., 1., ... 1, 1, 1, 1)) >>> var.calcDistanceFunction(order=2) >>> answer = [-1.30473785, -0.5, 0.5, 1.49923009, ... -0.5, -0.35355339, 0.5, 1.45118446, ... 0.5, 0.5, 0.97140452, 1.76215286, ... 1.49923009, 1.45118446, 1.76215286, 2.33721352] >>> print(numerix.allclose(var, answer, rtol=1e-9)) True
** A test for a bug in both LSMLIB and Scikit-fmm **
The following test gives different result depending on whether LSMLIB or Scikit-fmm is used. There is a deeper problem that is related to this issue. When a value becomes “known” after previously being a “trial” value it updates its neighbors’ values. In a second order scheme the neighbors one step away also need to be updated (if the in between cell is “known” and the far cell is a “trial” cell), but are not in either package. By luck (due to trial values having the same value), the values calculated in Scikit-fmm for the following example are correct although an example that didn’t work for Scikit-fmm could also be constructed.
>>> mesh = Grid2D(dx = 1., dy = 1., nx = 4, ny = 4, communicator=serialComm) >>> var = DistanceVariable(mesh = mesh, value = (-1., -1., -1., -1., ... 1., 1., -1., -1., ... 1., 1., -1., -1., ... 1., 1., -1., -1.)) >>> var.calcDistanceFunction(order=2) >>> var.calcDistanceFunction(order=2) >>> answer = [-0.5, -0.58578644, -1.08578644, -1.85136395, ... 0.5, 0.29289322, -0.58578644, -1.54389939, ... 1.30473785, 0.5, -0.5, -1.5, ... 1.49547948, 0.5, -0.5, -1.5]
The 3rd and 7th element are different for LSMLIB. This is because the 15th element is not “known” when the “trial” value for the 7th element is calculated. Scikit-fmm calculates the values in a slightly different order so gets a seemingly better answer, but this is just chance.
>>> print(numerix.allclose(var, answer, rtol=1e-9)) True
Creates a distanceVariable object.
- Parameters:
- __abs__()¶
Following test it to fix a bug with C inline string using abs() instead of fabs()
>>> print(abs(Variable(2.3) - Variable(1.2))) 1.1
Check representation works with different versions of numpy
>>> print(repr(abs(Variable(2.3)))) numerix.fabs(Variable(value=array(2.3)))
- __add__(other)¶
- __and__(other)¶
This test case has been added due to a weird bug that was appearing.
>>> a = Variable(value=(0, 0, 1, 1)) >>> b = Variable(value=(0, 1, 0, 1)) >>> print(numerix.equal((a == 0) & (b == 1), [False, True, False, False]).all()) True >>> print(a & b) [0 0 0 1] >>> from fipy.meshes import Grid1D >>> mesh = Grid1D(nx=4) >>> from fipy.variables.cellVariable import CellVariable >>> a = CellVariable(value=(0, 0, 1, 1), mesh=mesh) >>> b = CellVariable(value=(0, 1, 0, 1), mesh=mesh) >>> print(numerix.allequal((a == 0) & (b == 1), [False, True, False, False])) True >>> print(a & b) [0 0 0 1]
- __array__(t=None)¶
Attempt to convert the Variable to a numerix array object
>>> v = Variable(value=[2, 3]) >>> print(numerix.array(v)) [2 3]
A dimensional Variable will convert to the numeric value in its base units
>>> v = Variable(value=[2, 3], unit="mm") >>> numerix.array(v) array([ 0.002, 0.003])
- __array_priority__ = 100.0¶
- __array_wrap__(arr, context=None)¶
Required to prevent numpy not calling the reverse binary operations. Both the following tests are examples ufuncs.
>>> print(type(numerix.array([1.0, 2.0]) * Variable([1.0, 2.0]))) <class 'fipy.variables.binaryOperatorVariable...binOp'>
>>> from scipy.special import gamma as Gamma >>> print(type(Gamma(Variable([1.0, 2.0])))) <class 'fipy.variables.unaryOperatorVariable...unOp'>
- __bool__()¶
>>> print(bool(Variable(value=0))) 0 >>> print(bool(Variable(value=(0, 0, 1, 1)))) Traceback (most recent call last): ... ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
- __call__(points=None, order=0, nearestCellIDs=None)¶
Interpolates the CellVariable to a set of points using a method that has a memory requirement on the order of Ncells by Npoints in general, but uses only Ncells when the CellVariable’s mesh is a UniformGrid object.
Tests
>>> from fipy import * >>> m = Grid2D(nx=3, ny=2) >>> v = CellVariable(mesh=m, value=m.cellCenters[0]) >>> print(v(((0., 1.1, 1.2), (0., 1., 1.)))) [ 0.5 1.5 1.5] >>> print(v(((0., 1.1, 1.2), (0., 1., 1.)), order=1)) [ 0.25 1.1 1.2 ] >>> m0 = Grid2D(nx=2, ny=2, dx=1., dy=1.) >>> m1 = Grid2D(nx=4, ny=4, dx=.5, dy=.5) >>> x, y = m0.cellCenters >>> v0 = CellVariable(mesh=m0, value=x * y) >>> print(v0(m1.cellCenters.globalValue)) [ 0.25 0.25 0.75 0.75 0.25 0.25 0.75 0.75 0.75 0.75 2.25 2.25 0.75 0.75 2.25 2.25] >>> print(v0(m1.cellCenters.globalValue, order=1)) [ 0.125 0.25 0.5 0.625 0.25 0.375 0.875 1. 0.5 0.875 1.875 2.25 0.625 1. 2.25 2.625]
- __div__(other)¶
- __eq__(other)¶
Test if a Variable is equal to another quantity
>>> a = Variable(value=3) >>> b = (a == 4) >>> b (Variable(value=array(3)) == 4) >>> b() 0
- __float__()¶
- __ge__(other)¶
Test if a Variable is greater than or equal to another quantity
>>> a = Variable(value=3) >>> b = (a >= 4) >>> b (Variable(value=array(3)) >= 4) >>> b() 0 >>> a.value = 4 >>> print(b()) 1 >>> a.value = 5 >>> print(b()) 1
- __getitem__(index)¶
“Evaluate” the Variable and return the specified element
>>> a = Variable(value=((3., 4.), (5., 6.)), unit="m") + "4 m" >>> print(a[1, 1]) 10.0 m
It is an error to slice a Variable whose value is not sliceable
>>> Variable(value=3)[2] Traceback (most recent call last): ... IndexError: 0-d arrays can't be indexed
- __getstate__()¶
Used internally to collect the necessary information to
pickle
the CellVariable to persistent storage.
- __gt__(other)¶
Test if a Variable is greater than another quantity
>>> a = Variable(value=3) >>> b = (a > 4) >>> b (Variable(value=array(3)) > 4) >>> print(b()) 0 >>> a.value = 5 >>> print(b()) 1
- __hash__()¶
Return hash(self).
- __int__()¶
- __invert__()¶
Returns logical “not” of the Variable
>>> a = Variable(value=True) >>> print(~a) False
- __iter__()¶
- __le__(other)¶
Test if a Variable is less than or equal to another quantity
>>> a = Variable(value=3) >>> b = (a <= 4) >>> b (Variable(value=array(3)) <= 4) >>> b() 1 >>> a.value = 4 >>> print(b()) 1 >>> a.value = 5 >>> print(b()) 0
- __len__()¶
- __lt__(other)¶
Test if a Variable is less than another quantity
>>> a = Variable(value=3) >>> b = (a < 4) >>> b (Variable(value=array(3)) < 4) >>> b() 1 >>> a.value = 4 >>> print(b()) 0 >>> print(1000000000000000000 * Variable(1) < 1.) 0 >>> print(1000 * Variable(1) < 1.) 0
Python automatically reverses the arguments when necessary
>>> 4 > Variable(value=3) (Variable(value=array(3)) < 4)
- __mod__(other)¶
- __mul__(other)¶
- __ne__(other)¶
Test if a Variable is not equal to another quantity
>>> a = Variable(value=3) >>> b = (a != 4) >>> b (Variable(value=array(3)) != 4) >>> b() 1
- __neg__()¶
- static __new__(cls, *args, **kwds)¶
- __nonzero__()¶
>>> print(bool(Variable(value=0))) 0 >>> print(bool(Variable(value=(0, 0, 1, 1)))) Traceback (most recent call last): ... ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
- __or__(other)¶
This test case has been added due to a weird bug that was appearing.
>>> a = Variable(value=(0, 0, 1, 1)) >>> b = Variable(value=(0, 1, 0, 1)) >>> print(numerix.equal((a == 0) | (b == 1), [True, True, False, True]).all()) True >>> print(a | b) [0 1 1 1] >>> from fipy.meshes import Grid1D >>> mesh = Grid1D(nx=4) >>> from fipy.variables.cellVariable import CellVariable >>> a = CellVariable(value=(0, 0, 1, 1), mesh=mesh) >>> b = CellVariable(value=(0, 1, 0, 1), mesh=mesh) >>> print(numerix.allequal((a == 0) | (b == 1), [True, True, False, True])) True >>> print(a | b) [0 1 1 1]
- __pos__()¶
- __pow__(other)¶
return self**other, or self raised to power other
>>> print(Variable(1, "mol/l")**3) 1.0 mol**3/l**3 >>> print((Variable(1, "mol/l")**3).unit) <PhysicalUnit mol**3/l**3>
- __radd__(other)¶
- __rdiv__(other)¶
- __repr__()¶
Return repr(self).
- __rmul__(other)¶
- __rpow__(other)¶
- __rsub__(other)¶
- __rtruediv__(other)¶
- __setitem__(index, value)¶
- __setstate__(dict)¶
Used internally to create a new CellVariable from
pickled
persistent storage.
- __str__()¶
Return str(self).
- __sub__(other)¶
- __truediv__(other)¶
- all(axis=None)¶
>>> print(Variable(value=(0, 0, 1, 1)).all()) 0 >>> print(Variable(value=(1, 1, 1, 1)).all()) 1
- allclose(other, rtol=1e-05, atol=1e-08)¶
>>> var = Variable((1, 1)) >>> print(var.allclose((1, 1))) 1 >>> print(var.allclose((1,))) 1
The following test is to check that the system does not run out of memory.
>>> from fipy.tools import numerix >>> var = Variable(numerix.ones(10000)) >>> print(var.allclose(numerix.zeros(10000, 'l'))) False
- allequal(other)¶
- any(axis=None)¶
>>> print(Variable(value=0).any()) 0 >>> print(Variable(value=(0, 0, 1, 1)).any()) 1
- property arithmeticFaceValue¶
Returns a FaceVariable whose value corresponds to the arithmetic interpolation of the adjacent cells:
>>> from fipy.meshes import Grid1D >>> from fipy import numerix >>> mesh = Grid1D(dx = (1., 1.)) >>> L = 1 >>> R = 2 >>> var = CellVariable(mesh = mesh, value = (L, R)) >>> faceValue = var.arithmeticFaceValue[mesh.interiorFaces.value] >>> answer = (R - L) * (0.5 / 1.) + L >>> print(numerix.allclose(faceValue, answer, atol = 1e-10, rtol = 1e-10)) True
>>> mesh = Grid1D(dx = (2., 4.)) >>> var = CellVariable(mesh = mesh, value = (L, R)) >>> faceValue = var.arithmeticFaceValue[mesh.interiorFaces.value] >>> answer = (R - L) * (1.0 / 3.0) + L >>> print(numerix.allclose(faceValue, answer, atol = 1e-10, rtol = 1e-10)) True
>>> mesh = Grid1D(dx = (10., 100.)) >>> var = CellVariable(mesh = mesh, value = (L, R)) >>> faceValue = var.arithmeticFaceValue[mesh.interiorFaces.value] >>> answer = (R - L) * (5.0 / 55.0) + L >>> print(numerix.allclose(faceValue, answer, atol = 1e-10, rtol = 1e-10)) True
- cacheMe(recursive=False)¶
- calcDistanceFunction(order=2)¶
Calculates the distanceVariable as a distance function.
- Parameters:
order ({1, 2}) – The order of accuracy for the distance function calculation
- property cellInterfaceAreas¶
Returns the length of the interface that crosses the cell
A simple 1D test:
>>> from fipy.meshes import Grid1D >>> mesh = Grid1D(dx = 1., nx = 4) >>> distanceVariable = DistanceVariable(mesh = mesh, ... value = (-1.5, -0.5, 0.5, 1.5)) >>> answer = CellVariable(mesh=mesh, value=(0, 0., 1., 0)) >>> print(numerix.allclose(distanceVariable.cellInterfaceAreas, ... answer)) True
A 2D test case:
>>> from fipy.meshes import Grid2D >>> from fipy.variables.cellVariable import CellVariable >>> mesh = Grid2D(dx = 1., dy = 1., nx = 3, ny = 3) >>> distanceVariable = DistanceVariable(mesh = mesh, ... value = (1.5, 0.5, 1.5, ... 0.5, -0.5, 0.5, ... 1.5, 0.5, 1.5)) >>> answer = CellVariable(mesh=mesh, ... value=(0, 1, 0, 1, 0, 1, 0, 1, 0)) >>> print(numerix.allclose(distanceVariable.cellInterfaceAreas, answer)) True
Another 2D test case:
>>> mesh = Grid2D(dx = .5, dy = .5, nx = 2, ny = 2) >>> from fipy.variables.cellVariable import CellVariable >>> distanceVariable = DistanceVariable(mesh = mesh, ... value = (-0.5, 0.5, 0.5, 1.5)) >>> answer = CellVariable(mesh=mesh, ... value=(0, numerix.sqrt(2) / 4, numerix.sqrt(2) / 4, 0)) >>> print(numerix.allclose(distanceVariable.cellInterfaceAreas, ... answer)) True
Test to check that the circumference of a circle is, in fact,
.
>>> mesh = Grid2D(dx = 0.05, dy = 0.05, nx = 20, ny = 20) >>> r = 0.25 >>> x, y = mesh.cellCenters >>> rad = numerix.sqrt((x - .5)**2 + (y - .5)**2) - r >>> distanceVariable = DistanceVariable(mesh = mesh, value = rad) >>> print(numerix.allclose(distanceVariable.cellInterfaceAreas.sum(), 1.57984690073)) 1
- property cellVolumeAverage¶
Return the cell-volume-weighted average of the CellVariable:
>>> from fipy.meshes import Grid2D >>> from fipy.variables.cellVariable import CellVariable >>> mesh = Grid2D(nx = 3, ny = 1, dx = .5, dy = .1) >>> var = CellVariable(value = (1, 2, 6), mesh = mesh) >>> print(var.cellVolumeAverage) 3.0
- constrain(value, where=None)¶
Constrains the CellVariable to value at a location specified by where.
>>> from fipy import * >>> m = Grid1D(nx=3) >>> v = CellVariable(mesh=m, value=m.cellCenters[0]) >>> v.constrain(0., where=m.facesLeft) >>> v.faceGrad.constrain([1.], where=m.facesRight) >>> print(v.faceGrad) [[ 1. 1. 1. 1.]] >>> print(v.faceValue) [ 0. 1. 2. 2.5]
Changing the constraint changes the dependencies
>>> v.constrain(1., where=m.facesLeft) >>> print(v.faceGrad) [[-1. 1. 1. 1.]] >>> print(v.faceValue) [ 1. 1. 2. 2.5]
Constraints can be Variable
>>> c = Variable(0.) >>> v.constrain(c, where=m.facesLeft) >>> print(v.faceGrad) [[ 1. 1. 1. 1.]] >>> print(v.faceValue) [ 0. 1. 2. 2.5] >>> c.value = 1. >>> print(v.faceGrad) [[-1. 1. 1. 1.]] >>> print(v.faceValue) [ 1. 1. 2. 2.5]
Constraints can have a Variable mask.
>>> v = CellVariable(mesh=m) >>> mask = FaceVariable(mesh=m, value=m.facesLeft) >>> v.constrain(1., where=mask) >>> print(v.faceValue) [ 1. 0. 0. 0.] >>> mask[:] = mask | m.facesRight >>> print(v.faceValue) [ 1. 0. 0. 1.]
- property constraintMask¶
Test that constraintMask returns a Variable that updates itself whenever the constraints change.
>>> from fipy import *
>>> m = Grid2D(nx=2, ny=2) >>> x, y = m.cellCenters >>> v0 = CellVariable(mesh=m) >>> v0.constrain(1., where=m.facesLeft) >>> print(v0.faceValue.constraintMask) [False False False False False False True False False True False False] >>> print(v0.faceValue) [ 0. 0. 0. 0. 0. 0. 1. 0. 0. 1. 0. 0.] >>> v0.constrain(3., where=m.facesRight) >>> print(v0.faceValue.constraintMask) [False False False False False False True False True True False True] >>> print(v0.faceValue) [ 0. 0. 0. 0. 0. 0. 1. 0. 3. 1. 0. 3.] >>> v1 = CellVariable(mesh=m) >>> v1.constrain(1., where=(x < 1) & (y < 1)) >>> print(v1.constraintMask) [ True False False False] >>> print(v1) [ 1. 0. 0. 0.] >>> v1.constrain(3., where=(x > 1) & (y > 1)) >>> print(v1.constraintMask) [ True False False True] >>> print(v1) [ 1. 0. 0. 3.]
- property constraints¶
- copy()¶
Make an duplicate of the Variable
>>> a = Variable(value=3) >>> b = a.copy() >>> b Variable(value=array(3))
The duplicate will not reflect changes made to the original
>>> a.setValue(5) >>> b Variable(value=array(3))
Check that this works for arrays.
>>> a = Variable(value=numerix.array((0, 1, 2))) >>> b = a.copy() >>> b Variable(value=array([0, 1, 2])) >>> a[1] = 3 >>> b Variable(value=array([0, 1, 2]))
- dontCacheMe(recursive=False)¶
- dot(other, opShape=None, operatorClass=None)¶
Return the mesh-element–by–mesh-element (cell-by-cell, face-by-face, etc.) scalar product
Both self and other can be of arbitrary rank, and other does not need to be a _MeshVariable.
- extendVariable(extensionVariable, order=2)¶
Calculates the extension of extensionVariable from the zero level set.
- Parameters:
extensionVariable (CellVariable) – The variable to extend from the zero level set.
- property faceGrad¶
Return
as a rank-1 FaceVariable using differencing for the normal direction(second-order gradient).
- property faceGradAverage¶
Deprecated since version 3.3: use
grad.arithmeticFaceValue()
insteadReturn
as a rank-1 FaceVariable using averaging for the normal direction(second-order gradient)
- property faceValue¶
Returns a FaceVariable whose value corresponds to the arithmetic interpolation of the adjacent cells:
>>> from fipy.meshes import Grid1D >>> from fipy import numerix >>> mesh = Grid1D(dx = (1., 1.)) >>> L = 1 >>> R = 2 >>> var = CellVariable(mesh = mesh, value = (L, R)) >>> faceValue = var.arithmeticFaceValue[mesh.interiorFaces.value] >>> answer = (R - L) * (0.5 / 1.) + L >>> print(numerix.allclose(faceValue, answer, atol = 1e-10, rtol = 1e-10)) True
>>> mesh = Grid1D(dx = (2., 4.)) >>> var = CellVariable(mesh = mesh, value = (L, R)) >>> faceValue = var.arithmeticFaceValue[mesh.interiorFaces.value] >>> answer = (R - L) * (1.0 / 3.0) + L >>> print(numerix.allclose(faceValue, answer, atol = 1e-10, rtol = 1e-10)) True
>>> mesh = Grid1D(dx = (10., 100.)) >>> var = CellVariable(mesh = mesh, value = (L, R)) >>> faceValue = var.arithmeticFaceValue[mesh.interiorFaces.value] >>> answer = (R - L) * (5.0 / 55.0) + L >>> print(numerix.allclose(faceValue, answer, atol = 1e-10, rtol = 1e-10)) True
- property gaussGrad¶
Return
as a rank-1 CellVariable (first-order gradient).
- getLSMshape()¶
- getsctype(default=None)¶
Returns the Numpy sctype of the underlying array.
>>> Variable(1).getsctype() == numerix.NUMERIX.obj2sctype(numerix.array(1)) True >>> Variable(1.).getsctype() == numerix.NUMERIX.obj2sctype(numerix.array(1.)) True >>> Variable((1, 1.)).getsctype() == numerix.NUMERIX.obj2sctype(numerix.array((1., 1.))) True
- property globalValue¶
Concatenate and return values from all processors
When running on a single processor, the result is identical to
value
.
- property grad¶
Return
as a rank-1 CellVariable (first-order gradient).
- property harmonicFaceValue¶
Returns a FaceVariable whose value corresponds to the harmonic interpolation of the adjacent cells:
>>> from fipy.meshes import Grid1D >>> from fipy import numerix >>> mesh = Grid1D(dx = (1., 1.)) >>> L = 1 >>> R = 2 >>> var = CellVariable(mesh = mesh, value = (L, R)) >>> faceValue = var.harmonicFaceValue[mesh.interiorFaces.value] >>> answer = L * R / ((R - L) * (0.5 / 1.) + L) >>> print(numerix.allclose(faceValue, answer, atol = 1e-10, rtol = 1e-10)) True
>>> mesh = Grid1D(dx = (2., 4.)) >>> var = CellVariable(mesh = mesh, value = (L, R)) >>> faceValue = var.harmonicFaceValue[mesh.interiorFaces.value] >>> answer = L * R / ((R - L) * (1.0 / 3.0) + L) >>> print(numerix.allclose(faceValue, answer, atol = 1e-10, rtol = 1e-10)) True
>>> mesh = Grid1D(dx = (10., 100.)) >>> var = CellVariable(mesh = mesh, value = (L, R)) >>> faceValue = var.harmonicFaceValue[mesh.interiorFaces.value] >>> answer = L * R / ((R - L) * (5.0 / 55.0) + L) >>> print(numerix.allclose(faceValue, answer, atol = 1e-10, rtol = 1e-10)) True
- inBaseUnits()¶
Return the value of the Variable with all units reduced to their base SI elements.
>>> e = Variable(value="2.7 Hartree*Nav") >>> print(e.inBaseUnits().allclose("7088849.01085 kg*m**2/s**2/mol")) 1
- inUnitsOf(*units)¶
Returns one or more Variable objects that express the same physical quantity in different units. The units are specified by strings containing their names. The units must be compatible with the unit of the object. If one unit is specified, the return value is a single Variable.
>>> freeze = Variable('0 degC') >>> print(freeze.inUnitsOf('degF').allclose("32.0 degF")) 1
If several units are specified, the return value is a tuple of Variable instances with with one element per unit such that the sum of all quantities in the tuple equals the the original quantity and all the values except for the last one are integers. This is used to convert to irregular unit systems like hour/minute/second. The original object will not be changed.
>>> t = Variable(value=314159., unit='s') >>> from builtins import zip >>> print(numerix.allclose([e.allclose(v) for (e, v) in zip(t.inUnitsOf('d', 'h', 'min', 's'), ... ['3.0 d', '15.0 h', '15.0 min', '59.0 s'])], ... True)) 1
- itemset(value)¶
- property itemsize¶
- property leastSquaresGrad¶
Return
, which is determined by solving for
in the following matrix equation,
The matrix equation is derived by minimizing the following least squares sum,
Tests
>>> from fipy import Grid2D >>> m = Grid2D(nx=2, ny=2, dx=0.1, dy=2.0) >>> print(numerix.allclose(CellVariable(mesh=m, value=(0, 1, 3, 6)).leastSquaresGrad.globalValue, \ ... [[8.0, 8.0, 24.0, 24.0], ... [1.2, 2.0, 1.2, 2.0]])) True
>>> from fipy import Grid1D >>> print(numerix.allclose(CellVariable(mesh=Grid1D(dx=(2.0, 1.0, 0.5)), ... value=(0, 1, 2)).leastSquaresGrad.globalValue, [[0.461538461538, 0.8, 1.2]])) True
- max(axis=None)¶
- min(axis=None)¶
>>> from fipy import Grid2D, CellVariable >>> mesh = Grid2D(nx=5, ny=5) >>> x, y = mesh.cellCenters >>> v = CellVariable(mesh=mesh, value=x*y) >>> print(v.min()) 0.25
- property minmodFaceValue¶
Returns a FaceVariable with a value that is the minimum of the absolute values of the adjacent cells. If the values are of opposite sign then the result is zero:
>>> from fipy import * >>> print(CellVariable(mesh=Grid1D(nx=2), value=(1, 2)).minmodFaceValue) [1 1 2] >>> print(CellVariable(mesh=Grid1D(nx=2), value=(-1, -2)).minmodFaceValue) [-1 -1 -2] >>> print(CellVariable(mesh=Grid1D(nx=2), value=(-1, 2)).minmodFaceValue) [-1 0 2]
- property name¶
- property numericValue¶
- property old¶
Return the values of the CellVariable from the previous solution sweep.
Combinations of CellVariable’s should also return old values.
>>> from fipy.meshes import Grid1D >>> mesh = Grid1D(nx = 2) >>> from fipy.variables.cellVariable import CellVariable >>> var1 = CellVariable(mesh = mesh, value = (2, 3), hasOld = 1) >>> var2 = CellVariable(mesh = mesh, value = (3, 4)) >>> v = var1 * var2 >>> print(v) [ 6 12] >>> var1.value = ((3, 2)) >>> print(v) [9 8] >>> print(v.old) [ 6 12]
The following small test is to correct for a bug when the operator does not just use variables.
>>> v1 = var1 * 3 >>> print(v1) [9 6] >>> print(v1.old) [6 9]
- put(indices, value)¶
- property rank¶
- ravel()¶
- rdot(other, opShape=None, operatorClass=None)¶
Return the mesh-element–by–mesh-element (cell-by-cell, face-by-face, etc.) scalar product
Both self and other can be of arbitrary rank, and other does not need to be a _MeshVariable.
- release(constraint)¶
Remove constraint from self
>>> from fipy import * >>> m = Grid1D(nx=3) >>> v = CellVariable(mesh=m, value=m.cellCenters[0]) >>> c = Constraint(0., where=m.facesLeft) >>> v.constrain(c) >>> print(v.faceValue) [ 0. 1. 2. 2.5] >>> v.release(constraint=c) >>> print(v.faceValue) [ 0.5 1. 2. 2.5]
- setValue(value, unit=None, where=None)¶
Set the value of the Variable. Can take a masked array.
>>> a = Variable((1, 2, 3)) >>> a.setValue(5, where=(1, 0, 1)) >>> print(a) [5 2 5]
>>> b = Variable((4, 5, 6)) >>> a.setValue(b, where=(1, 0, 1)) >>> print(a) [4 2 6] >>> print(b) [4 5 6] >>> a.value = 3 >>> print(a) [3 3 3]
>>> b = numerix.array((3, 4, 5)) >>> a.value = b >>> a[:] = 1 >>> print(b) [3 4 5]
>>> a.setValue((4, 5, 6), where=(1, 0)) Traceback (most recent call last): .... ValueError: shape mismatch: objects cannot be broadcast to a single shape
- property shape¶
>>> from fipy.meshes import Grid2D >>> from fipy.variables.cellVariable import CellVariable >>> mesh = Grid2D(nx=2, ny=3) >>> var = CellVariable(mesh=mesh) >>> print(numerix.allequal(var.shape, (6,))) True >>> print(numerix.allequal(var.arithmeticFaceValue.shape, (17,))) True >>> print(numerix.allequal(var.grad.shape, (2, 6))) True >>> print(numerix.allequal(var.faceGrad.shape, (2, 17))) True
Have to account for zero length arrays
>>> from fipy import Grid1D >>> m = Grid1D(nx=0) >>> v = CellVariable(mesh=m, elementshape=(2,)) >>> numerix.allequal((v * 1).shape, (2, 0)) True
- std(axis=None, **kwargs)¶
Evaluate standard deviation of all the elements of a MeshVariable.
Adapted from http://mpitutorial.com/tutorials/mpi-reduce-and-allreduce/
>>> import fipy as fp >>> mesh = fp.Grid2D(nx=2, ny=2, dx=2., dy=5.) >>> var = fp.CellVariable(value=(1., 2., 3., 4.), mesh=mesh) >>> print((var.std()**2).allclose(1.25)) True
- property subscribedVariables¶
- sum(axis=None)¶
- take(ids, axis=0)¶
- tostring(max_line_width=75, precision=8, suppress_small=False, separator=' ')¶
- property unit¶
Return the unit object of self.
>>> Variable(value="1 m").unit <PhysicalUnit m>
- updateOld()¶
Set the values of the previous solution sweep to the current values.
>>> from fipy import * >>> v = CellVariable(mesh=Grid1D(), hasOld=False) >>> v.updateOld() Traceback (most recent call last): ... AssertionError: The updateOld method requires the CellVariable to have an old value. Set hasOld to True when instantiating the CellVariable.
- property value¶
“Evaluate” the Variable and return its value (longhand)
>>> a = Variable(value=3) >>> print(a.value) 3 >>> b = a + 4 >>> b (Variable(value=array(3)) + 4) >>> b.value 7
- class fipy.DummySolver(*args, **kwargs)¶
Bases:
PETScSolver
Solver that doesn’t do anything.
PETSc is intolerant of having zeros on the diagonal
Create a Solver object.
- Parameters:
- __del__()¶
- __enter__()¶
- __exit__(exc_type, exc_value, traceback)¶
- __repr__()¶
Return repr(self).
- class fipy.DummyViewer(vars, title=None, **kwlimits)¶
Bases:
AbstractViewer
Substitute viewer that doesn’t do anything
Create a AbstractViewer object.
- Parameters:
vars (CellVariable or list) – the CellVariable objects to display.
title (str, optional) – displayed at the top of the Viewer window
xmin (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.
xmax (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.
ymin (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.
ymax (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.
zmin (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.
zmax (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.
datamin (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.
datamax (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.
- property limits¶
- plot(filename=None)¶
Update the display of the viewed variables.
- Parameters:
filename (str) – If not None, the name of a file to save the image into.
- plotMesh(filename=None)¶
Display a representation of the mesh
- Parameters:
filename (str) – If not None, the name of a file to save the image into.
- setLimits(limits={}, **kwlimits)¶
Update the limits.
- Parameters:
limits (dict, optional) – a (deprecated) alternative to limit keyword arguments
xmin (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
xmax (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
ymin (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
ymax (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
zmin (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
zmax (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
datamin (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
datamax (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
- property title¶
The text appearing at the top center.
(default: if
len(self.vars) == 1
, the name ofself.vars[0]
, otherwise""
.)
- class fipy.ExplicitDiffusionTerm(coeff=(1.0,), var=None)¶
Bases:
_AbstractDiffusionTerm
The discretization for the ExplicitDiffusionTerm is given by
where
and
are the old values of the variable. The term is added to the RHS vector and makes no contribution to the solution matrix.
Create a Term.
- Parameters:
coeff (float or CellVariable or FaceVariable) – Coefficient for the term. FaceVariable objects are only acceptable for diffusion or convection terms.
- property RHSvector¶
Return the RHS vector calculated in solve() or sweep(). The cacheRHSvector() method should be called before solve() or sweep() to cache the vector.
- __add__(other)¶
- __and__(other)¶
- __div__(other)¶
- __eq__(other)¶
Return self==value.
- __hash__()¶
Return hash(self).
- __mul__(other)¶
- __neg__()¶
- __pos__()¶
- __radd__(other)¶
- __rand__(other)¶
- __repr__()¶
The representation of a Term object is given by,
>>> print(__UnaryTerm(123.456)) __UnaryTerm(coeff=123.456)
- __rmul__(other)¶
- __rsub__(other)¶
- __sub__(other)¶
- __truediv__(other)¶
- cacheMatrix()¶
Informs solve() and sweep() to cache their matrix so that matrix can return the matrix.
- cacheRHSvector()¶
Informs solve() and sweep() to cache their right hand side vector so that getRHSvector() can return it.
- copy()¶
- getDefaultSolver(var=None, solver=None, *args, **kwargs)¶
- justErrorVector(var=None, solver=None, boundaryConditions=(), dt=1.0, underRelaxation=None, residualFn=None)¶
Builds the Term’s linear system once.
This method also recalculates and returns the error as well as applying under-relaxation.
justErrorVector returns the overlapping local value in parallel (not the non-overlapping value).
>>> from fipy.solvers import DummySolver >>> from fipy import * >>> m = Grid1D(nx=10) >>> v = CellVariable(mesh=m) >>> len(DiffusionTerm().justErrorVector(v, solver=DummySolver())) == m.numberOfCells True
- Parameters:
var (CellVariable) – Variable to be solved for. Provides the initial condition, the old value and holds the solution on completion.
solver (Solver) – Iterative solver to be used to solve the linear system of equations. The default sovler depends on the solver package selected.
boundaryConditions (
tuple
ofBoundaryCondition
) –dt (float) – Timestep size.
underRelaxation (float) – Usually a value between 0 and 1 or None in the case of no under-relaxation
residualFn (function) – Takes var, matrix, and RHSvector arguments, used to customize the residual calculation.
- Returns:
error – The residual vector
- Return type:
- justResidualVector(var=None, solver=None, boundaryConditions=(), dt=None, underRelaxation=None, residualFn=None)¶
Builds the Term’s linear system once.
This method also recalculates and returns the residual as well as applying under-relaxation.
justResidualVector returns the overlapping local value in parallel (not the non-overlapping value).
>>> from fipy import * >>> m = Grid1D(nx=10) >>> v = CellVariable(mesh=m) >>> len(numerix.asarray(DiffusionTerm().justResidualVector(v))) == m.numberOfCells True
- Parameters:
var (CellVariable) – Variable to be solved for. Provides the initial condition, the old value and holds the solution on completion.
solver (Solver) – Iterative solver to be used to solve the linear system of equations. The default sovler depends on the solver package selected.
boundaryConditions (
tuple
ofBoundaryCondition
) –dt (float) – Timestep size.
underRelaxation (float) – Usually a value between 0 and 1 or None in the case of no under-relaxation
residualFn (function) – Takes var, matrix, and RHSvector arguments, used to customize the residual calculation.
- Returns:
residual – The residual vector
- Return type:
- property matrix¶
Return the matrix calculated in solve() or sweep(). The cacheMatrix() method should be called before solve() or sweep() to cache the matrix.
- residualVectorAndNorm(var=None, solver=None, boundaryConditions=(), dt=None, underRelaxation=None, residualFn=None)¶
Builds the Term’s linear system once.
This method also recalculates and returns the residual as well as applying under-relaxation.
- Parameters:
var (CellVariable) – Variable to be solved for. Provides the initial condition, the old value and holds the solution on completion.
solver (Solver) – Iterative solver to be used to solve the linear system of equations. The default sovler depends on the solver package selected.
boundaryConditions (
tuple
ofBoundaryCondition
) –dt (float) – Timestep size.
underRelaxation (float) – Usually a value between 0 and 1 or None in the case of no under-relaxation
residualFn (function) – Takes var, matrix, and RHSvector arguments, used to customize the residual calculation.
- Returns:
residual (~fipy.variables.cellVariable.CellVariable) – The residual vector
norm (float) – The L2 norm of residual,
- solve(var=None, solver=None, boundaryConditions=(), dt=None)¶
Builds and solves the Term’s linear system once. This method does not return the residual. It should be used when the residual is not required.
- Parameters:
var (CellVariable) – Variable to be solved for. Provides the initial condition, the old value and holds the solution on completion.
solver (Solver) – Iterative solver to be used to solve the linear system of equations. The default sovler depends on the solver package selected.
boundaryConditions (
tuple
ofBoundaryCondition
) –dt (float) – Timestep size.
- sweep(var=None, solver=None, boundaryConditions=(), dt=None, underRelaxation=None, residualFn=None, cacheResidual=False, cacheError=False)¶
Builds and solves the Term’s linear system once. This method also recalculates and returns the residual as well as applying under-relaxation.
- Parameters:
var (CellVariable) – Variable to be solved for. Provides the initial condition, the old value and holds the solution on completion.
solver (Solver) – Iterative solver to be used to solve the linear system of equations. The default sovler depends on the solver package selected.
boundaryConditions (
tuple
ofBoundaryCondition
) –dt (float) – Timestep size.
underRelaxation (float) – Usually a value between 0 and 1 or None in the case of no under-relaxation
residualFn (function) – Takes var, matrix, and RHSvector arguments, used to customize the residual calculation.
cacheResidual (bool) – If True, calculate and store the residual vector
in the residualVector member of Term
cacheError (bool) – If True, use the residual vector
to solve
for the error vector
and store it in the errorVector member of Term
- Returns:
residual – The residual vector
- Return type:
- class fipy.ExplicitUpwindConvectionTerm(coeff=1.0, var=None)¶
Bases:
_AbstractUpwindConvectionTerm
The discretization for this
Term
is given bywhere
and
is calculated using the upwind scheme. For further details see Numerical Schemes.
Create a _AbstractConvectionTerm object.
>>> from fipy import * >>> m = Grid1D(nx = 2) >>> cv = CellVariable(mesh = m) >>> fv = FaceVariable(mesh = m) >>> vcv = CellVariable(mesh=m, rank=1) >>> vfv = FaceVariable(mesh=m, rank=1) >>> __ConvectionTerm(coeff = cv) Traceback (most recent call last): ... VectorCoeffError: The coefficient must be a vector value. >>> __ConvectionTerm(coeff = fv) Traceback (most recent call last): ... VectorCoeffError: The coefficient must be a vector value. >>> __ConvectionTerm(coeff = vcv) __ConvectionTerm(coeff=_ArithmeticCellToFaceVariable(value=array([[ 0., 0., 0.]]), mesh=UniformGrid1D(dx=1.0, nx=2))) >>> __ConvectionTerm(coeff = vfv) __ConvectionTerm(coeff=FaceVariable(value=array([[ 0., 0., 0.]]), mesh=UniformGrid1D(dx=1.0, nx=2))) >>> __ConvectionTerm(coeff = (1,)) __ConvectionTerm(coeff=(1,)) >>> ExplicitUpwindConvectionTerm(coeff = (0,)).solve(var=cv, solver=DummySolver()) Traceback (most recent call last): ... TransientTermError: The equation requires a TransientTerm with explicit convection. >>> (TransientTerm(0.) - ExplicitUpwindConvectionTerm(coeff = (0,))).solve(var=cv, solver=DummySolver(), dt=1.)
>>> (TransientTerm() - ExplicitUpwindConvectionTerm(coeff = 1)).solve(var=cv, solver=DummySolver(), dt=1.) Traceback (most recent call last): ... VectorCoeffError: The coefficient must be a vector value. >>> m2 = Grid2D(nx=2, ny=1) >>> cv2 = CellVariable(mesh=m2) >>> vcv2 = CellVariable(mesh=m2, rank=1) >>> vfv2 = FaceVariable(mesh=m2, rank=1) >>> __ConvectionTerm(coeff=vcv2) __ConvectionTerm(coeff=_ArithmeticCellToFaceVariable(value=array([[ 0., 0., 0., 0., 0., 0., 0.], [ 0., 0., 0., 0., 0., 0., 0.]]), mesh=UniformGrid2D(dx=1.0, nx=2, dy=1.0, ny=1))) >>> __ConvectionTerm(coeff=vfv2) __ConvectionTerm(coeff=FaceVariable(value=array([[ 0., 0., 0., 0., 0., 0., 0.], [ 0., 0., 0., 0., 0., 0., 0.]]), mesh=UniformGrid2D(dx=1.0, nx=2, dy=1.0, ny=1))) >>> (TransientTerm() - ExplicitUpwindConvectionTerm(coeff = ((0,), (0,)))).solve(var=cv2, solver=DummySolver(), dt=1.) >>> (TransientTerm() - ExplicitUpwindConvectionTerm(coeff = (0, 0))).solve(var=cv2, solver=DummySolver(), dt=1.)
- Parameters:
coeff (The Term’s coefficient value.) –
- property RHSvector¶
Return the RHS vector calculated in solve() or sweep(). The cacheRHSvector() method should be called before solve() or sweep() to cache the vector.
- __add__(other)¶
- __and__(other)¶
- __div__(other)¶
- __eq__(other)¶
Return self==value.
- __hash__()¶
Return hash(self).
- __mul__(other)¶
Multiply a term
>>> 2. * __NonDiffusionTerm(coeff=0.5) __NonDiffusionTerm(coeff=1.0)
Test for ticket:291.
>>> from fipy import PowerLawConvectionTerm >>> PowerLawConvectionTerm(coeff=[[1], [0]]) * 1.0 PowerLawConvectionTerm(coeff=array([[ 1.], [ 0.]]))
- __neg__()¶
Negate a Term.
>>> -__NonDiffusionTerm(coeff=1.) __NonDiffusionTerm(coeff=-1.0)
- __pos__()¶
- __radd__(other)¶
- __rand__(other)¶
- __repr__()¶
The representation of a Term object is given by,
>>> print(__UnaryTerm(123.456)) __UnaryTerm(coeff=123.456)
- __rmul__(other)¶
Multiply a term
>>> 2. * __NonDiffusionTerm(coeff=0.5) __NonDiffusionTerm(coeff=1.0)
Test for ticket:291.
>>> from fipy import PowerLawConvectionTerm >>> PowerLawConvectionTerm(coeff=[[1], [0]]) * 1.0 PowerLawConvectionTerm(coeff=array([[ 1.], [ 0.]]))
- __rsub__(other)¶
- __sub__(other)¶
- __truediv__(other)¶
- cacheMatrix()¶
Informs solve() and sweep() to cache their matrix so that matrix can return the matrix.
- cacheRHSvector()¶
Informs solve() and sweep() to cache their right hand side vector so that getRHSvector() can return it.
- copy()¶
- getDefaultSolver(var=None, solver=None, *args, **kwargs)¶
- justErrorVector(var=None, solver=None, boundaryConditions=(), dt=1.0, underRelaxation=None, residualFn=None)¶
Builds the Term’s linear system once.
This method also recalculates and returns the error as well as applying under-relaxation.
justErrorVector returns the overlapping local value in parallel (not the non-overlapping value).
>>> from fipy.solvers import DummySolver >>> from fipy import * >>> m = Grid1D(nx=10) >>> v = CellVariable(mesh=m) >>> len(DiffusionTerm().justErrorVector(v, solver=DummySolver())) == m.numberOfCells True
- Parameters:
var (CellVariable) – Variable to be solved for. Provides the initial condition, the old value and holds the solution on completion.
solver (Solver) – Iterative solver to be used to solve the linear system of equations. The default sovler depends on the solver package selected.
boundaryConditions (
tuple
ofBoundaryCondition
) –dt (float) – Timestep size.
underRelaxation (float) – Usually a value between 0 and 1 or None in the case of no under-relaxation
residualFn (function) – Takes var, matrix, and RHSvector arguments, used to customize the residual calculation.
- Returns:
error – The residual vector
- Return type:
- justResidualVector(var=None, solver=None, boundaryConditions=(), dt=None, underRelaxation=None, residualFn=None)¶
Builds the Term’s linear system once.
This method also recalculates and returns the residual as well as applying under-relaxation.
justResidualVector returns the overlapping local value in parallel (not the non-overlapping value).
>>> from fipy import * >>> m = Grid1D(nx=10) >>> v = CellVariable(mesh=m) >>> len(numerix.asarray(DiffusionTerm().justResidualVector(v))) == m.numberOfCells True
- Parameters:
var (CellVariable) – Variable to be solved for. Provides the initial condition, the old value and holds the solution on completion.
solver (Solver) – Iterative solver to be used to solve the linear system of equations. The default sovler depends on the solver package selected.
boundaryConditions (
tuple
ofBoundaryCondition
) –dt (float) – Timestep size.
underRelaxation (float) – Usually a value between 0 and 1 or None in the case of no under-relaxation
residualFn (function) – Takes var, matrix, and RHSvector arguments, used to customize the residual calculation.
- Returns:
residual – The residual vector
- Return type:
- property matrix¶
Return the matrix calculated in solve() or sweep(). The cacheMatrix() method should be called before solve() or sweep() to cache the matrix.
- residualVectorAndNorm(var=None, solver=None, boundaryConditions=(), dt=None, underRelaxation=None, residualFn=None)¶
Builds the Term’s linear system once.
This method also recalculates and returns the residual as well as applying under-relaxation.
- Parameters:
var (CellVariable) – Variable to be solved for. Provides the initial condition, the old value and holds the solution on completion.
solver (Solver) – Iterative solver to be used to solve the linear system of equations. The default sovler depends on the solver package selected.
boundaryConditions (
tuple
ofBoundaryCondition
) –dt (float) – Timestep size.
underRelaxation (float) – Usually a value between 0 and 1 or None in the case of no under-relaxation
residualFn (function) – Takes var, matrix, and RHSvector arguments, used to customize the residual calculation.
- Returns:
residual (~fipy.variables.cellVariable.CellVariable) – The residual vector
norm (float) – The L2 norm of residual,
- solve(var=None, solver=None, boundaryConditions=(), dt=None)¶
Builds and solves the Term’s linear system once. This method does not return the residual. It should be used when the residual is not required.
- Parameters:
var (CellVariable) – Variable to be solved for. Provides the initial condition, the old value and holds the solution on completion.
solver (Solver) – Iterative solver to be used to solve the linear system of equations. The default sovler depends on the solver package selected.
boundaryConditions (
tuple
ofBoundaryCondition
) –dt (float) – Timestep size.
- sweep(var=None, solver=None, boundaryConditions=(), dt=None, underRelaxation=None, residualFn=None, cacheResidual=False, cacheError=False)¶
Builds and solves the Term’s linear system once. This method also recalculates and returns the residual as well as applying under-relaxation.
- Parameters:
var (CellVariable) – Variable to be solved for. Provides the initial condition, the old value and holds the solution on completion.
solver (Solver) – Iterative solver to be used to solve the linear system of equations. The default sovler depends on the solver package selected.
boundaryConditions (
tuple
ofBoundaryCondition
) –dt (float) – Timestep size.
underRelaxation (float) – Usually a value between 0 and 1 or None in the case of no under-relaxation
residualFn (function) – Takes var, matrix, and RHSvector arguments, used to customize the residual calculation.
cacheResidual (bool) – If True, calculate and store the residual vector
in the residualVector member of Term
cacheError (bool) – If True, use the residual vector
to solve
for the error vector
and store it in the errorVector member of Term
- Returns:
residual – The residual vector
- Return type:
- exception fipy.ExplicitVariableError(s='Terms with explicit Variables cannot mix with Terms with implicit Variables.')¶
Bases:
Exception
- __cause__¶
exception cause
- __context__¶
exception context
- __delattr__(name, /)¶
Implement delattr(self, name).
- __getattribute__(name, /)¶
Return getattr(self, name).
- __reduce__()¶
Helper for pickle.
- __repr__()¶
Return repr(self).
- __setattr__(name, value, /)¶
Implement setattr(self, name, value).
- __setstate__()¶
- __str__()¶
Return str(self).
- __suppress_context__¶
- __traceback__¶
- add_note()¶
Exception.add_note(note) – add a note to the exception
- args¶
- with_traceback()¶
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
- class fipy.ExponentialConvectionTerm(coeff=1.0, var=None)¶
Bases:
_AsymmetricConvectionTerm
The discretization for this
Term
is given bywhere
and
is calculated using the exponential scheme. For further details see Numerical Schemes.
Create a _AbstractConvectionTerm object.
>>> from fipy import * >>> m = Grid1D(nx = 2) >>> cv = CellVariable(mesh = m) >>> fv = FaceVariable(mesh = m) >>> vcv = CellVariable(mesh=m, rank=1) >>> vfv = FaceVariable(mesh=m, rank=1) >>> __ConvectionTerm(coeff = cv) Traceback (most recent call last): ... VectorCoeffError: The coefficient must be a vector value. >>> __ConvectionTerm(coeff = fv) Traceback (most recent call last): ... VectorCoeffError: The coefficient must be a vector value. >>> __ConvectionTerm(coeff = vcv) __ConvectionTerm(coeff=_ArithmeticCellToFaceVariable(value=array([[ 0., 0., 0.]]), mesh=UniformGrid1D(dx=1.0, nx=2))) >>> __ConvectionTerm(coeff = vfv) __ConvectionTerm(coeff=FaceVariable(value=array([[ 0., 0., 0.]]), mesh=UniformGrid1D(dx=1.0, nx=2))) >>> __ConvectionTerm(coeff = (1,)) __ConvectionTerm(coeff=(1,)) >>> ExplicitUpwindConvectionTerm(coeff = (0,)).solve(var=cv, solver=DummySolver()) Traceback (most recent call last): ... TransientTermError: The equation requires a TransientTerm with explicit convection. >>> (TransientTerm(0.) - ExplicitUpwindConvectionTerm(coeff = (0,))).solve(var=cv, solver=DummySolver(), dt=1.)
>>> (TransientTerm() - ExplicitUpwindConvectionTerm(coeff = 1)).solve(var=cv, solver=DummySolver(), dt=1.) Traceback (most recent call last): ... VectorCoeffError: The coefficient must be a vector value. >>> m2 = Grid2D(nx=2, ny=1) >>> cv2 = CellVariable(mesh=m2) >>> vcv2 = CellVariable(mesh=m2, rank=1) >>> vfv2 = FaceVariable(mesh=m2, rank=1) >>> __ConvectionTerm(coeff=vcv2) __ConvectionTerm(coeff=_ArithmeticCellToFaceVariable(value=array([[ 0., 0., 0., 0., 0., 0., 0.], [ 0., 0., 0., 0., 0., 0., 0.]]), mesh=UniformGrid2D(dx=1.0, nx=2, dy=1.0, ny=1))) >>> __ConvectionTerm(coeff=vfv2) __ConvectionTerm(coeff=FaceVariable(value=array([[ 0., 0., 0., 0., 0., 0., 0.], [ 0., 0., 0., 0., 0., 0., 0.]]), mesh=UniformGrid2D(dx=1.0, nx=2, dy=1.0, ny=1))) >>> (TransientTerm() - ExplicitUpwindConvectionTerm(coeff = ((0,), (0,)))).solve(var=cv2, solver=DummySolver(), dt=1.) >>> (TransientTerm() - ExplicitUpwindConvectionTerm(coeff = (0, 0))).solve(var=cv2, solver=DummySolver(), dt=1.)
- Parameters:
coeff (The Term’s coefficient value.) –
- property RHSvector¶
Return the RHS vector calculated in solve() or sweep(). The cacheRHSvector() method should be called before solve() or sweep() to cache the vector.
- __add__(other)¶
- __and__(other)¶
- __div__(other)¶
- __eq__(other)¶
Return self==value.
- __hash__()¶
Return hash(self).
- __mul__(other)¶
Multiply a term
>>> 2. * __NonDiffusionTerm(coeff=0.5) __NonDiffusionTerm(coeff=1.0)
Test for ticket:291.
>>> from fipy import PowerLawConvectionTerm >>> PowerLawConvectionTerm(coeff=[[1], [0]]) * 1.0 PowerLawConvectionTerm(coeff=array([[ 1.], [ 0.]]))
- __neg__()¶
Negate a Term.
>>> -__NonDiffusionTerm(coeff=1.) __NonDiffusionTerm(coeff=-1.0)
- __pos__()¶
- __radd__(other)¶
- __rand__(other)¶
- __repr__()¶
The representation of a Term object is given by,
>>> print(__UnaryTerm(123.456)) __UnaryTerm(coeff=123.456)
- __rmul__(other)¶
Multiply a term
>>> 2. * __NonDiffusionTerm(coeff=0.5) __NonDiffusionTerm(coeff=1.0)
Test for ticket:291.
>>> from fipy import PowerLawConvectionTerm >>> PowerLawConvectionTerm(coeff=[[1], [0]]) * 1.0 PowerLawConvectionTerm(coeff=array([[ 1.], [ 0.]]))
- __rsub__(other)¶
- __sub__(other)¶
- __truediv__(other)¶
- cacheMatrix()¶
Informs solve() and sweep() to cache their matrix so that matrix can return the matrix.
- cacheRHSvector()¶
Informs solve() and sweep() to cache their right hand side vector so that getRHSvector() can return it.
- copy()¶
- getDefaultSolver(var=None, solver=None, *args, **kwargs)¶
- justErrorVector(var=None, solver=None, boundaryConditions=(), dt=1.0, underRelaxation=None, residualFn=None)¶
Builds the Term’s linear system once.
This method also recalculates and returns the error as well as applying under-relaxation.
justErrorVector returns the overlapping local value in parallel (not the non-overlapping value).
>>> from fipy.solvers import DummySolver >>> from fipy import * >>> m = Grid1D(nx=10) >>> v = CellVariable(mesh=m) >>> len(DiffusionTerm().justErrorVector(v, solver=DummySolver())) == m.numberOfCells True
- Parameters:
var (CellVariable) – Variable to be solved for. Provides the initial condition, the old value and holds the solution on completion.
solver (Solver) – Iterative solver to be used to solve the linear system of equations. The default sovler depends on the solver package selected.
boundaryConditions (
tuple
ofBoundaryCondition
) –dt (float) – Timestep size.
underRelaxation (float) – Usually a value between 0 and 1 or None in the case of no under-relaxation
residualFn (function) – Takes var, matrix, and RHSvector arguments, used to customize the residual calculation.
- Returns:
error – The residual vector
- Return type:
- justResidualVector(var=None, solver=None, boundaryConditions=(), dt=None, underRelaxation=None, residualFn=None)¶
Builds the Term’s linear system once.
This method also recalculates and returns the residual as well as applying under-relaxation.
justResidualVector returns the overlapping local value in parallel (not the non-overlapping value).
>>> from fipy import * >>> m = Grid1D(nx=10) >>> v = CellVariable(mesh=m) >>> len(numerix.asarray(DiffusionTerm().justResidualVector(v))) == m.numberOfCells True
- Parameters:
var (CellVariable) – Variable to be solved for. Provides the initial condition, the old value and holds the solution on completion.
solver (Solver) – Iterative solver to be used to solve the linear system of equations. The default sovler depends on the solver package selected.
boundaryConditions (
tuple
ofBoundaryCondition
) –dt (float) – Timestep size.
underRelaxation (float) – Usually a value between 0 and 1 or None in the case of no under-relaxation
residualFn (function) – Takes var, matrix, and RHSvector arguments, used to customize the residual calculation.
- Returns:
residual – The residual vector
- Return type:
- property matrix¶
Return the matrix calculated in solve() or sweep(). The cacheMatrix() method should be called before solve() or sweep() to cache the matrix.
- residualVectorAndNorm(var=None, solver=None, boundaryConditions=(), dt=None, underRelaxation=None, residualFn=None)¶
Builds the Term’s linear system once.
This method also recalculates and returns the residual as well as applying under-relaxation.
- Parameters:
var (CellVariable) – Variable to be solved for. Provides the initial condition, the old value and holds the solution on completion.
solver (Solver) – Iterative solver to be used to solve the linear system of equations. The default sovler depends on the solver package selected.
boundaryConditions (
tuple
ofBoundaryCondition
) –dt (float) – Timestep size.
underRelaxation (float) – Usually a value between 0 and 1 or None in the case of no under-relaxation
residualFn (function) – Takes var, matrix, and RHSvector arguments, used to customize the residual calculation.
- Returns:
residual (~fipy.variables.cellVariable.CellVariable) – The residual vector
norm (float) – The L2 norm of residual,
- solve(var=None, solver=None, boundaryConditions=(), dt=None)¶
Builds and solves the Term’s linear system once. This method does not return the residual. It should be used when the residual is not required.
- Parameters:
var (CellVariable) – Variable to be solved for. Provides the initial condition, the old value and holds the solution on completion.
solver (Solver) – Iterative solver to be used to solve the linear system of equations. The default sovler depends on the solver package selected.
boundaryConditions (
tuple
ofBoundaryCondition
) –dt (float) – Timestep size.
- sweep(var=None, solver=None, boundaryConditions=(), dt=None, underRelaxation=None, residualFn=None, cacheResidual=False, cacheError=False)¶
Builds and solves the Term’s linear system once. This method also recalculates and returns the residual as well as applying under-relaxation.
- Parameters:
var (CellVariable) – Variable to be solved for. Provides the initial condition, the old value and holds the solution on completion.
solver (Solver) – Iterative solver to be used to solve the linear system of equations. The default sovler depends on the solver package selected.
boundaryConditions (
tuple
ofBoundaryCondition
) –dt (float) – Timestep size.
underRelaxation (float) – Usually a value between 0 and 1 or None in the case of no under-relaxation
residualFn (function) – Takes var, matrix, and RHSvector arguments, used to customize the residual calculation.
cacheResidual (bool) – If True, calculate and store the residual vector
in the residualVector member of Term
cacheError (bool) – If True, use the residual vector
to solve
for the error vector
and store it in the errorVector member of Term
- Returns:
residual – The residual vector
- Return type:
- class fipy.ExponentialNoiseVariable(*args, **kwds)¶
Bases:
NoiseVariable
Represents an exponential distribution of random numbers with the probability distribution
with a mean parameter
.
Seed the random module for the sake of deterministic test results.
>>> from fipy import numerix >>> numerix.random.seed(1)
We generate noise on a uniform Cartesian mesh
>>> from fipy.variables.variable import Variable >>> mean = Variable() >>> from fipy.meshes import Grid2D >>> noise = ExponentialNoiseVariable(mesh = Grid2D(nx = 100, ny = 100), mean = mean)
We histogram the root-volume-weighted noise distribution
>>> from fipy.variables.histogramVariable import HistogramVariable >>> histogram = HistogramVariable(distribution = noise, dx = 0.1, nx = 100)
and compare to a Gaussian distribution
>>> from fipy.variables.cellVariable import CellVariable >>> expdist = CellVariable(mesh = histogram.mesh) >>> x = histogram.mesh.cellCenters[0]
>>> if __name__ == '__main__': ... from fipy import Viewer ... viewer = Viewer(vars=noise, datamin=0, datamax=5) ... histoplot = Viewer(vars=(histogram, expdist), ... datamin=0, datamax=1.5)
>>> from fipy.tools.numerix import arange, exp
>>> for mu in arange(0.5, 3, 0.5): ... mean.value = (mu) ... expdist.value = ((1/mean)*exp(-x/mean)) ... if __name__ == '__main__': ... import sys ... print("mean: %g" % mean, file=sys.stderr) ... viewer.plot() ... histoplot.plot()
>>> print(abs(noise.faceGrad.divergence.cellVolumeAverage) < 5e-15) 1
- Parameters:
- __abs__()¶
Following test it to fix a bug with C inline string using abs() instead of fabs()
>>> print(abs(Variable(2.3) - Variable(1.2))) 1.1
Check representation works with different versions of numpy
>>> print(repr(abs(Variable(2.3)))) numerix.fabs(Variable(value=array(2.3)))
- __add__(other)¶
- __and__(other)¶
This test case has been added due to a weird bug that was appearing.
>>> a = Variable(value=(0, 0, 1, 1)) >>> b = Variable(value=(0, 1, 0, 1)) >>> print(numerix.equal((a == 0) & (b == 1), [False, True, False, False]).all()) True >>> print(a & b) [0 0 0 1] >>> from fipy.meshes import Grid1D >>> mesh = Grid1D(nx=4) >>> from fipy.variables.cellVariable import CellVariable >>> a = CellVariable(value=(0, 0, 1, 1), mesh=mesh) >>> b = CellVariable(value=(0, 1, 0, 1), mesh=mesh) >>> print(numerix.allequal((a == 0) & (b == 1), [False, True, False, False])) True >>> print(a & b) [0 0 0 1]
- __array__(t=None)¶
Attempt to convert the Variable to a numerix array object
>>> v = Variable(value=[2, 3]) >>> print(numerix.array(v)) [2 3]
A dimensional Variable will convert to the numeric value in its base units
>>> v = Variable(value=[2, 3], unit="mm") >>> numerix.array(v) array([ 0.002, 0.003])
- __array_priority__ = 100.0¶
- __array_wrap__(arr, context=None)¶
Required to prevent numpy not calling the reverse binary operations. Both the following tests are examples ufuncs.
>>> print(type(numerix.array([1.0, 2.0]) * Variable([1.0, 2.0]))) <class 'fipy.variables.binaryOperatorVariable...binOp'>
>>> from scipy.special import gamma as Gamma >>> print(type(Gamma(Variable([1.0, 2.0])))) <class 'fipy.variables.unaryOperatorVariable...unOp'>
- __bool__()¶
>>> print(bool(Variable(value=0))) 0 >>> print(bool(Variable(value=(0, 0, 1, 1)))) Traceback (most recent call last): ... ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
- __call__(points=None, order=0, nearestCellIDs=None)¶
Interpolates the CellVariable to a set of points using a method that has a memory requirement on the order of Ncells by Npoints in general, but uses only Ncells when the CellVariable’s mesh is a UniformGrid object.
Tests
>>> from fipy import * >>> m = Grid2D(nx=3, ny=2) >>> v = CellVariable(mesh=m, value=m.cellCenters[0]) >>> print(v(((0., 1.1, 1.2), (0., 1., 1.)))) [ 0.5 1.5 1.5] >>> print(v(((0., 1.1, 1.2), (0., 1., 1.)), order=1)) [ 0.25 1.1 1.2 ] >>> m0 = Grid2D(nx=2, ny=2, dx=1., dy=1.) >>> m1 = Grid2D(nx=4, ny=4, dx=.5, dy=.5) >>> x, y = m0.cellCenters >>> v0 = CellVariable(mesh=m0, value=x * y) >>> print(v0(m1.cellCenters.globalValue)) [ 0.25 0.25 0.75 0.75 0.25 0.25 0.75 0.75 0.75 0.75 2.25 2.25 0.75 0.75 2.25 2.25] >>> print(v0(m1.cellCenters.globalValue, order=1)) [ 0.125 0.25 0.5 0.625 0.25 0.375 0.875 1. 0.5 0.875 1.875 2.25 0.625 1. 2.25 2.625]
- __div__(other)¶
- __eq__(other)¶
Test if a Variable is equal to another quantity
>>> a = Variable(value=3) >>> b = (a == 4) >>> b (Variable(value=array(3)) == 4) >>> b() 0
- __float__()¶
- __ge__(other)¶
Test if a Variable is greater than or equal to another quantity
>>> a = Variable(value=3) >>> b = (a >= 4) >>> b (Variable(value=array(3)) >= 4) >>> b() 0 >>> a.value = 4 >>> print(b()) 1 >>> a.value = 5 >>> print(b()) 1
- __getitem__(index)¶
“Evaluate” the Variable and return the specified element
>>> a = Variable(value=((3., 4.), (5., 6.)), unit="m") + "4 m" >>> print(a[1, 1]) 10.0 m
It is an error to slice a Variable whose value is not sliceable
>>> Variable(value=3)[2] Traceback (most recent call last): ... IndexError: 0-d arrays can't be indexed
- __getstate__()¶
Used internally to collect the necessary information to
pickle
the CellVariable to persistent storage.
- __gt__(other)¶
Test if a Variable is greater than another quantity
>>> a = Variable(value=3) >>> b = (a > 4) >>> b (Variable(value=array(3)) > 4) >>> print(b()) 0 >>> a.value = 5 >>> print(b()) 1
- __hash__()¶
Return hash(self).
- __int__()¶
- __invert__()¶
Returns logical “not” of the Variable
>>> a = Variable(value=True) >>> print(~a) False
- __iter__()¶
- __le__(other)¶
Test if a Variable is less than or equal to another quantity
>>> a = Variable(value=3) >>> b = (a <= 4) >>> b (Variable(value=array(3)) <= 4) >>> b() 1 >>> a.value = 4 >>> print(b()) 1 >>> a.value = 5 >>> print(b()) 0
- __len__()¶
- __lt__(other)¶
Test if a Variable is less than another quantity
>>> a = Variable(value=3) >>> b = (a < 4) >>> b (Variable(value=array(3)) < 4) >>> b() 1 >>> a.value = 4 >>> print(b()) 0 >>> print(1000000000000000000 * Variable(1) < 1.) 0 >>> print(1000 * Variable(1) < 1.) 0
Python automatically reverses the arguments when necessary
>>> 4 > Variable(value=3) (Variable(value=array(3)) < 4)
- __mod__(other)¶
- __mul__(other)¶
- __ne__(other)¶
Test if a Variable is not equal to another quantity
>>> a = Variable(value=3) >>> b = (a != 4) >>> b (Variable(value=array(3)) != 4) >>> b() 1
- __neg__()¶
- static __new__(cls, *args, **kwds)¶
- __nonzero__()¶
>>> print(bool(Variable(value=0))) 0 >>> print(bool(Variable(value=(0, 0, 1, 1)))) Traceback (most recent call last): ... ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
- __or__(other)¶
This test case has been added due to a weird bug that was appearing.
>>> a = Variable(value=(0, 0, 1, 1)) >>> b = Variable(value=(0, 1, 0, 1)) >>> print(numerix.equal((a == 0) | (b == 1), [True, True, False, True]).all()) True >>> print(a | b) [0 1 1 1] >>> from fipy.meshes import Grid1D >>> mesh = Grid1D(nx=4) >>> from fipy.variables.cellVariable import CellVariable >>> a = CellVariable(value=(0, 0, 1, 1), mesh=mesh) >>> b = CellVariable(value=(0, 1, 0, 1), mesh=mesh) >>> print(numerix.allequal((a == 0) | (b == 1), [True, True, False, True])) True >>> print(a | b) [0 1 1 1]
- __pos__()¶
- __pow__(other)¶
return self**other, or self raised to power other
>>> print(Variable(1, "mol/l")**3) 1.0 mol**3/l**3 >>> print((Variable(1, "mol/l")**3).unit) <PhysicalUnit mol**3/l**3>
- __radd__(other)¶
- __rdiv__(other)¶
- __repr__()¶
Return repr(self).
- __rmul__(other)¶
- __rpow__(other)¶
- __rsub__(other)¶
- __rtruediv__(other)¶
- __setitem__(index, value)¶
- __setstate__(dict)¶
Used internally to create a new CellVariable from
pickled
persistent storage.
- __str__()¶
Return str(self).
- __sub__(other)¶
- __truediv__(other)¶
- all(axis=None)¶
>>> print(Variable(value=(0, 0, 1, 1)).all()) 0 >>> print(Variable(value=(1, 1, 1, 1)).all()) 1
- allclose(other, rtol=1e-05, atol=1e-08)¶
>>> var = Variable((1, 1)) >>> print(var.allclose((1, 1))) 1 >>> print(var.allclose((1,))) 1
The following test is to check that the system does not run out of memory.
>>> from fipy.tools import numerix >>> var = Variable(numerix.ones(10000)) >>> print(var.allclose(numerix.zeros(10000, 'l'))) False
- allequal(other)¶
- any(axis=None)¶
>>> print(Variable(value=0).any()) 0 >>> print(Variable(value=(0, 0, 1, 1)).any()) 1
- property arithmeticFaceValue¶
Returns a FaceVariable whose value corresponds to the arithmetic interpolation of the adjacent cells:
>>> from fipy.meshes import Grid1D >>> from fipy import numerix >>> mesh = Grid1D(dx = (1., 1.)) >>> L = 1 >>> R = 2 >>> var = CellVariable(mesh = mesh, value = (L, R)) >>> faceValue = var.arithmeticFaceValue[mesh.interiorFaces.value] >>> answer = (R - L) * (0.5 / 1.) + L >>> print(numerix.allclose(faceValue, answer, atol = 1e-10, rtol = 1e-10)) True
>>> mesh = Grid1D(dx = (2., 4.)) >>> var = CellVariable(mesh = mesh, value = (L, R)) >>> faceValue = var.arithmeticFaceValue[mesh.interiorFaces.value] >>> answer = (R - L) * (1.0 / 3.0) + L >>> print(numerix.allclose(faceValue, answer, atol = 1e-10, rtol = 1e-10)) True
>>> mesh = Grid1D(dx = (10., 100.)) >>> var = CellVariable(mesh = mesh, value = (L, R)) >>> faceValue = var.arithmeticFaceValue[mesh.interiorFaces.value] >>> answer = (R - L) * (5.0 / 55.0) + L >>> print(numerix.allclose(faceValue, answer, atol = 1e-10, rtol = 1e-10)) True
- cacheMe(recursive=False)¶
- property cellVolumeAverage¶
Return the cell-volume-weighted average of the CellVariable:
>>> from fipy.meshes import Grid2D >>> from fipy.variables.cellVariable import CellVariable >>> mesh = Grid2D(nx = 3, ny = 1, dx = .5, dy = .1) >>> var = CellVariable(value = (1, 2, 6), mesh = mesh) >>> print(var.cellVolumeAverage) 3.0
- constrain(value, where=None)¶
Constrains the CellVariable to value at a location specified by where.
>>> from fipy import * >>> m = Grid1D(nx=3) >>> v = CellVariable(mesh=m, value=m.cellCenters[0]) >>> v.constrain(0., where=m.facesLeft) >>> v.faceGrad.constrain([1.], where=m.facesRight) >>> print(v.faceGrad) [[ 1. 1. 1. 1.]] >>> print(v.faceValue) [ 0. 1. 2. 2.5]
Changing the constraint changes the dependencies
>>> v.constrain(1., where=m.facesLeft) >>> print(v.faceGrad) [[-1. 1. 1. 1.]] >>> print(v.faceValue) [ 1. 1. 2. 2.5]
Constraints can be Variable
>>> c = Variable(0.) >>> v.constrain(c, where=m.facesLeft) >>> print(v.faceGrad) [[ 1. 1. 1. 1.]] >>> print(v.faceValue) [ 0. 1. 2. 2.5] >>> c.value = 1. >>> print(v.faceGrad) [[-1. 1. 1. 1.]] >>> print(v.faceValue) [ 1. 1. 2. 2.5]
Constraints can have a Variable mask.
>>> v = CellVariable(mesh=m) >>> mask = FaceVariable(mesh=m, value=m.facesLeft) >>> v.constrain(1., where=mask) >>> print(v.faceValue) [ 1. 0. 0. 0.] >>> mask[:] = mask | m.facesRight >>> print(v.faceValue) [ 1. 0. 0. 1.]
- property constraintMask¶
Test that constraintMask returns a Variable that updates itself whenever the constraints change.
>>> from fipy import *
>>> m = Grid2D(nx=2, ny=2) >>> x, y = m.cellCenters >>> v0 = CellVariable(mesh=m) >>> v0.constrain(1., where=m.facesLeft) >>> print(v0.faceValue.constraintMask) [False False False False False False True False False True False False] >>> print(v0.faceValue) [ 0. 0. 0. 0. 0. 0. 1. 0. 0. 1. 0. 0.] >>> v0.constrain(3., where=m.facesRight) >>> print(v0.faceValue.constraintMask) [False False False False False False True False True True False True] >>> print(v0.faceValue) [ 0. 0. 0. 0. 0. 0. 1. 0. 3. 1. 0. 3.] >>> v1 = CellVariable(mesh=m) >>> v1.constrain(1., where=(x < 1) & (y < 1)) >>> print(v1.constraintMask) [ True False False False] >>> print(v1) [ 1. 0. 0. 0.] >>> v1.constrain(3., where=(x > 1) & (y > 1)) >>> print(v1.constraintMask) [ True False False True] >>> print(v1) [ 1. 0. 0. 3.]
- property constraints¶
- copy()¶
Copy the value of the NoiseVariable to a static CellVariable.
- dontCacheMe(recursive=False)¶
- dot(other, opShape=None, operatorClass=None)¶
Return the mesh-element–by–mesh-element (cell-by-cell, face-by-face, etc.) scalar product
Both self and other can be of arbitrary rank, and other does not need to be a _MeshVariable.
- property faceGrad¶
Return
as a rank-1 FaceVariable using differencing for the normal direction(second-order gradient).
- property faceGradAverage¶
Deprecated since version 3.3: use
grad.arithmeticFaceValue()
insteadReturn
as a rank-1 FaceVariable using averaging for the normal direction(second-order gradient)
- property faceValue¶
Returns a FaceVariable whose value corresponds to the arithmetic interpolation of the adjacent cells:
>>> from fipy.meshes import Grid1D >>> from fipy import numerix >>> mesh = Grid1D(dx = (1., 1.)) >>> L = 1 >>> R = 2 >>> var = CellVariable(mesh = mesh, value = (L, R)) >>> faceValue = var.arithmeticFaceValue[mesh.interiorFaces.value] >>> answer = (R - L) * (0.5 / 1.) + L >>> print(numerix.allclose(faceValue, answer, atol = 1e-10, rtol = 1e-10)) True
>>> mesh = Grid1D(dx = (2., 4.)) >>> var = CellVariable(mesh = mesh, value = (L, R)) >>> faceValue = var.arithmeticFaceValue[mesh.interiorFaces.value] >>> answer = (R - L) * (1.0 / 3.0) + L >>> print(numerix.allclose(faceValue, answer, atol = 1e-10, rtol = 1e-10)) True
>>> mesh = Grid1D(dx = (10., 100.)) >>> var = CellVariable(mesh = mesh, value = (L, R)) >>> faceValue = var.arithmeticFaceValue[mesh.interiorFaces.value] >>> answer = (R - L) * (5.0 / 55.0) + L >>> print(numerix.allclose(faceValue, answer, atol = 1e-10, rtol = 1e-10)) True
- property gaussGrad¶
Return
as a rank-1 CellVariable (first-order gradient).
- getsctype(default=None)¶
Returns the Numpy sctype of the underlying array.
>>> Variable(1).getsctype() == numerix.NUMERIX.obj2sctype(numerix.array(1)) True >>> Variable(1.).getsctype() == numerix.NUMERIX.obj2sctype(numerix.array(1.)) True >>> Variable((1, 1.)).getsctype() == numerix.NUMERIX.obj2sctype(numerix.array((1., 1.))) True
- property globalValue¶
Concatenate and return values from all processors
When running on a single processor, the result is identical to
value
.
- property grad¶
Return
as a rank-1 CellVariable (first-order gradient).
- property harmonicFaceValue¶
Returns a FaceVariable whose value corresponds to the harmonic interpolation of the adjacent cells:
>>> from fipy.meshes import Grid1D >>> from fipy import numerix >>> mesh = Grid1D(dx = (1., 1.)) >>> L = 1 >>> R = 2 >>> var = CellVariable(mesh = mesh, value = (L, R)) >>> faceValue = var.harmonicFaceValue[mesh.interiorFaces.value] >>> answer = L * R / ((R - L) * (0.5 / 1.) + L) >>> print(numerix.allclose(faceValue, answer, atol = 1e-10, rtol = 1e-10)) True
>>> mesh = Grid1D(dx = (2., 4.)) >>> var = CellVariable(mesh = mesh, value = (L, R)) >>> faceValue = var.harmonicFaceValue[mesh.interiorFaces.value] >>> answer = L * R / ((R - L) * (1.0 / 3.0) + L) >>> print(numerix.allclose(faceValue, answer, atol = 1e-10, rtol = 1e-10)) True
>>> mesh = Grid1D(dx = (10., 100.)) >>> var = CellVariable(mesh = mesh, value = (L, R)) >>> faceValue = var.harmonicFaceValue[mesh.interiorFaces.value] >>> answer = L * R / ((R - L) * (5.0 / 55.0) + L) >>> print(numerix.allclose(faceValue, answer, atol = 1e-10, rtol = 1e-10)) True
- inBaseUnits()¶
Return the value of the Variable with all units reduced to their base SI elements.
>>> e = Variable(value="2.7 Hartree*Nav") >>> print(e.inBaseUnits().allclose("7088849.01085 kg*m**2/s**2/mol")) 1
- inUnitsOf(*units)¶
Returns one or more Variable objects that express the same physical quantity in different units. The units are specified by strings containing their names. The units must be compatible with the unit of the object. If one unit is specified, the return value is a single Variable.
>>> freeze = Variable('0 degC') >>> print(freeze.inUnitsOf('degF').allclose("32.0 degF")) 1
If several units are specified, the return value is a tuple of Variable instances with with one element per unit such that the sum of all quantities in the tuple equals the the original quantity and all the values except for the last one are integers. This is used to convert to irregular unit systems like hour/minute/second. The original object will not be changed.
>>> t = Variable(value=314159., unit='s') >>> from builtins import zip >>> print(numerix.allclose([e.allclose(v) for (e, v) in zip(t.inUnitsOf('d', 'h', 'min', 's'), ... ['3.0 d', '15.0 h', '15.0 min', '59.0 s'])], ... True)) 1
- itemset(value)¶
- property itemsize¶
- property leastSquaresGrad¶
Return
, which is determined by solving for
in the following matrix equation,
The matrix equation is derived by minimizing the following least squares sum,
Tests
>>> from fipy import Grid2D >>> m = Grid2D(nx=2, ny=2, dx=0.1, dy=2.0) >>> print(numerix.allclose(CellVariable(mesh=m, value=(0, 1, 3, 6)).leastSquaresGrad.globalValue, \ ... [[8.0, 8.0, 24.0, 24.0], ... [1.2, 2.0, 1.2, 2.0]])) True
>>> from fipy import Grid1D >>> print(numerix.allclose(CellVariable(mesh=Grid1D(dx=(2.0, 1.0, 0.5)), ... value=(0, 1, 2)).leastSquaresGrad.globalValue, [[0.461538461538, 0.8, 1.2]])) True
- max(axis=None)¶
- min(axis=None)¶
>>> from fipy import Grid2D, CellVariable >>> mesh = Grid2D(nx=5, ny=5) >>> x, y = mesh.cellCenters >>> v = CellVariable(mesh=mesh, value=x*y) >>> print(v.min()) 0.25
- property minmodFaceValue¶
Returns a FaceVariable with a value that is the minimum of the absolute values of the adjacent cells. If the values are of opposite sign then the result is zero:
>>> from fipy import * >>> print(CellVariable(mesh=Grid1D(nx=2), value=(1, 2)).minmodFaceValue) [1 1 2] >>> print(CellVariable(mesh=Grid1D(nx=2), value=(-1, -2)).minmodFaceValue) [-1 -1 -2] >>> print(CellVariable(mesh=Grid1D(nx=2), value=(-1, 2)).minmodFaceValue) [-1 0 2]
- property name¶
- property numericValue¶
- property old¶
Return the values of the CellVariable from the previous solution sweep.
Combinations of CellVariable’s should also return old values.
>>> from fipy.meshes import Grid1D >>> mesh = Grid1D(nx = 2) >>> from fipy.variables.cellVariable import CellVariable >>> var1 = CellVariable(mesh = mesh, value = (2, 3), hasOld = 1) >>> var2 = CellVariable(mesh = mesh, value = (3, 4)) >>> v = var1 * var2 >>> print(v) [ 6 12] >>> var1.value = ((3, 2)) >>> print(v) [9 8] >>> print(v.old) [ 6 12]
The following small test is to correct for a bug when the operator does not just use variables.
>>> v1 = var1 * 3 >>> print(v1) [9 6] >>> print(v1.old) [6 9]
- parallelRandom()¶
- put(indices, value)¶
- random()¶
- property rank¶
- ravel()¶
- rdot(other, opShape=None, operatorClass=None)¶
Return the mesh-element–by–mesh-element (cell-by-cell, face-by-face, etc.) scalar product
Both self and other can be of arbitrary rank, and other does not need to be a _MeshVariable.
- release(constraint)¶
Remove constraint from self
>>> from fipy import * >>> m = Grid1D(nx=3) >>> v = CellVariable(mesh=m, value=m.cellCenters[0]) >>> c = Constraint(0., where=m.facesLeft) >>> v.constrain(c) >>> print(v.faceValue) [ 0. 1. 2. 2.5] >>> v.release(constraint=c) >>> print(v.faceValue) [ 0.5 1. 2. 2.5]
- scramble()¶
Generate a new random distribution.
- setValue(value, unit=None, where=None)¶
Set the value of the Variable. Can take a masked array.
>>> a = Variable((1, 2, 3)) >>> a.setValue(5, where=(1, 0, 1)) >>> print(a) [5 2 5]
>>> b = Variable((4, 5, 6)) >>> a.setValue(b, where=(1, 0, 1)) >>> print(a) [4 2 6] >>> print(b) [4 5 6] >>> a.value = 3 >>> print(a) [3 3 3]
>>> b = numerix.array((3, 4, 5)) >>> a.value = b >>> a[:] = 1 >>> print(b) [3 4 5]
>>> a.setValue((4, 5, 6), where=(1, 0)) Traceback (most recent call last): .... ValueError: shape mismatch: objects cannot be broadcast to a single shape
- property shape¶
>>> from fipy.meshes import Grid2D >>> from fipy.variables.cellVariable import CellVariable >>> mesh = Grid2D(nx=2, ny=3) >>> var = CellVariable(mesh=mesh) >>> print(numerix.allequal(var.shape, (6,))) True >>> print(numerix.allequal(var.arithmeticFaceValue.shape, (17,))) True >>> print(numerix.allequal(var.grad.shape, (2, 6))) True >>> print(numerix.allequal(var.faceGrad.shape, (2, 17))) True
Have to account for zero length arrays
>>> from fipy import Grid1D >>> m = Grid1D(nx=0) >>> v = CellVariable(mesh=m, elementshape=(2,)) >>> numerix.allequal((v * 1).shape, (2, 0)) True
- std(axis=None, **kwargs)¶
Evaluate standard deviation of all the elements of a MeshVariable.
Adapted from http://mpitutorial.com/tutorials/mpi-reduce-and-allreduce/
>>> import fipy as fp >>> mesh = fp.Grid2D(nx=2, ny=2, dx=2., dy=5.) >>> var = fp.CellVariable(value=(1., 2., 3., 4.), mesh=mesh) >>> print((var.std()**2).allclose(1.25)) True
- property subscribedVariables¶
- sum(axis=None)¶
- take(ids, axis=0)¶
- tostring(max_line_width=75, precision=8, suppress_small=False, separator=' ')¶
- property unit¶
Return the unit object of self.
>>> Variable(value="1 m").unit <PhysicalUnit m>
- updateOld()¶
Set the values of the previous solution sweep to the current values.
>>> from fipy import * >>> v = CellVariable(mesh=Grid1D(), hasOld=False) >>> v.updateOld() Traceback (most recent call last): ... AssertionError: The updateOld method requires the CellVariable to have an old value. Set hasOld to True when instantiating the CellVariable.
- property value¶
“Evaluate” the Variable and return its value (longhand)
>>> a = Variable(value=3) >>> print(a.value) 3 >>> b = a + 4 >>> b (Variable(value=array(3)) + 4) >>> b.value 7
- class fipy.FaceVariable(*args, **kwds)¶
Bases:
_MeshVariable
- Parameters:
mesh (Mesh) – the mesh that defines the geometry of this Variable
name (str) – the user-readable name of the Variable
value (float or array_like) – the initial value
rank (int) – the rank (number of dimensions) of each element of this Variable. Default: 0
elementshape (
tuple
ofint
) – the shape of each element of this variable Default: rank * (mesh.dim,)unit (str or PhysicalUnit) – The physical units of the variable
- __abs__()¶
Following test it to fix a bug with C inline string using abs() instead of fabs()
>>> print(abs(Variable(2.3) - Variable(1.2))) 1.1
Check representation works with different versions of numpy
>>> print(repr(abs(Variable(2.3)))) numerix.fabs(Variable(value=array(2.3)))
- __add__(other)¶
- __and__(other)¶
This test case has been added due to a weird bug that was appearing.
>>> a = Variable(value=(0, 0, 1, 1)) >>> b = Variable(value=(0, 1, 0, 1)) >>> print(numerix.equal((a == 0) & (b == 1), [False, True, False, False]).all()) True >>> print(a & b) [0 0 0 1] >>> from fipy.meshes import Grid1D >>> mesh = Grid1D(nx=4) >>> from fipy.variables.cellVariable import CellVariable >>> a = CellVariable(value=(0, 0, 1, 1), mesh=mesh) >>> b = CellVariable(value=(0, 1, 0, 1), mesh=mesh) >>> print(numerix.allequal((a == 0) & (b == 1), [False, True, False, False])) True >>> print(a & b) [0 0 0 1]
- __array__(t=None)¶
Attempt to convert the Variable to a numerix array object
>>> v = Variable(value=[2, 3]) >>> print(numerix.array(v)) [2 3]
A dimensional Variable will convert to the numeric value in its base units
>>> v = Variable(value=[2, 3], unit="mm") >>> numerix.array(v) array([ 0.002, 0.003])
- __array_priority__ = 100.0¶
- __array_wrap__(arr, context=None)¶
Required to prevent numpy not calling the reverse binary operations. Both the following tests are examples ufuncs.
>>> print(type(numerix.array([1.0, 2.0]) * Variable([1.0, 2.0]))) <class 'fipy.variables.binaryOperatorVariable...binOp'>
>>> from scipy.special import gamma as Gamma >>> print(type(Gamma(Variable([1.0, 2.0])))) <class 'fipy.variables.unaryOperatorVariable...unOp'>
- __bool__()¶
>>> print(bool(Variable(value=0))) 0 >>> print(bool(Variable(value=(0, 0, 1, 1)))) Traceback (most recent call last): ... ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
- __call__()¶
“Evaluate” the Variable and return its value
>>> a = Variable(value=3) >>> print(a()) 3 >>> b = a + 4 >>> b (Variable(value=array(3)) + 4) >>> b() 7
- __div__(other)¶
- __eq__(other)¶
Test if a Variable is equal to another quantity
>>> a = Variable(value=3) >>> b = (a == 4) >>> b (Variable(value=array(3)) == 4) >>> b() 0
- __float__()¶
- __ge__(other)¶
Test if a Variable is greater than or equal to another quantity
>>> a = Variable(value=3) >>> b = (a >= 4) >>> b (Variable(value=array(3)) >= 4) >>> b() 0 >>> a.value = 4 >>> print(b()) 1 >>> a.value = 5 >>> print(b()) 1
- __getitem__(index)¶
“Evaluate” the Variable and return the specified element
>>> a = Variable(value=((3., 4.), (5., 6.)), unit="m") + "4 m" >>> print(a[1, 1]) 10.0 m
It is an error to slice a Variable whose value is not sliceable
>>> Variable(value=3)[2] Traceback (most recent call last): ... IndexError: 0-d arrays can't be indexed
- __getstate__()¶
Used internally to collect the necessary information to
pickle
the _MeshVariable to persistent storage.
- __gt__(other)¶
Test if a Variable is greater than another quantity
>>> a = Variable(value=3) >>> b = (a > 4) >>> b (Variable(value=array(3)) > 4) >>> print(b()) 0 >>> a.value = 5 >>> print(b()) 1
- __hash__()¶
Return hash(self).
- __int__()¶
- __invert__()¶
Returns logical “not” of the Variable
>>> a = Variable(value=True) >>> print(~a) False
- __iter__()¶
- __le__(other)¶
Test if a Variable is less than or equal to another quantity
>>> a = Variable(value=3) >>> b = (a <= 4) >>> b (Variable(value=array(3)) <= 4) >>> b() 1 >>> a.value = 4 >>> print(b()) 1 >>> a.value = 5 >>> print(b()) 0
- __len__()¶
- __lt__(other)¶
Test if a Variable is less than another quantity
>>> a = Variable(value=3) >>> b = (a < 4) >>> b (Variable(value=array(3)) < 4) >>> b() 1 >>> a.value = 4 >>> print(b()) 0 >>> print(1000000000000000000 * Variable(1) < 1.) 0 >>> print(1000 * Variable(1) < 1.) 0
Python automatically reverses the arguments when necessary
>>> 4 > Variable(value=3) (Variable(value=array(3)) < 4)
- __mod__(other)¶
- __mul__(other)¶
- __ne__(other)¶
Test if a Variable is not equal to another quantity
>>> a = Variable(value=3) >>> b = (a != 4) >>> b (Variable(value=array(3)) != 4) >>> b() 1
- __neg__()¶
- static __new__(cls, *args, **kwds)¶
- __nonzero__()¶
>>> print(bool(Variable(value=0))) 0 >>> print(bool(Variable(value=(0, 0, 1, 1)))) Traceback (most recent call last): ... ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
- __or__(other)¶
This test case has been added due to a weird bug that was appearing.
>>> a = Variable(value=(0, 0, 1, 1)) >>> b = Variable(value=(0, 1, 0, 1)) >>> print(numerix.equal((a == 0) | (b == 1), [True, True, False, True]).all()) True >>> print(a | b) [0 1 1 1] >>> from fipy.meshes import Grid1D >>> mesh = Grid1D(nx=4) >>> from fipy.variables.cellVariable import CellVariable >>> a = CellVariable(value=(0, 0, 1, 1), mesh=mesh) >>> b = CellVariable(value=(0, 1, 0, 1), mesh=mesh) >>> print(numerix.allequal((a == 0) | (b == 1), [True, True, False, True])) True >>> print(a | b) [0 1 1 1]
- __pos__()¶
- __pow__(other)¶
return self**other, or self raised to power other
>>> print(Variable(1, "mol/l")**3) 1.0 mol**3/l**3 >>> print((Variable(1, "mol/l")**3).unit) <PhysicalUnit mol**3/l**3>
- __radd__(other)¶
- __rdiv__(other)¶
- __repr__()¶
Return repr(self).
- __rmul__(other)¶
- __rpow__(other)¶
- __rsub__(other)¶
- __rtruediv__(other)¶
- __setitem__(index, value)¶
- __setstate__(dict)¶
Used internally to create a new Variable from
pickled
persistent storage.
- __str__()¶
Return str(self).
- __sub__(other)¶
- __truediv__(other)¶
- all(axis=None)¶
>>> print(Variable(value=(0, 0, 1, 1)).all()) 0 >>> print(Variable(value=(1, 1, 1, 1)).all()) 1
- allclose(other, rtol=1e-05, atol=1e-08)¶
>>> var = Variable((1, 1)) >>> print(var.allclose((1, 1))) 1 >>> print(var.allclose((1,))) 1
The following test is to check that the system does not run out of memory.
>>> from fipy.tools import numerix >>> var = Variable(numerix.ones(10000)) >>> print(var.allclose(numerix.zeros(10000, 'l'))) False
- allequal(other)¶
- any(axis=None)¶
>>> print(Variable(value=0).any()) 0 >>> print(Variable(value=(0, 0, 1, 1)).any()) 1
- cacheMe(recursive=False)¶
- constrain(value, where=None)¶
Constrain the Variable to have a value at an index or mask location specified by where.
>>> v = Variable((0, 1, 2, 3)) >>> v.constrain(2, numerix.array((True, False, False, False))) >>> print(v) [2 1 2 3] >>> v[:] = 10 >>> print(v) [ 2 10 10 10] >>> v.constrain(5, numerix.array((False, False, True, False))) >>> print(v) [ 2 10 5 10] >>> v[:] = 6 >>> print(v) [2 6 5 6] >>> v.constrain(8) >>> print(v) [8 8 8 8] >>> v[:] = 10 >>> print(v) [8 8 8 8] >>> del v.constraints[2] >>> print(v) [ 2 10 5 10]
>>> from fipy.variables.cellVariable import CellVariable >>> from fipy.meshes import Grid2D >>> m = Grid2D(nx=2, ny=2) >>> x, y = m.cellCenters >>> v = CellVariable(mesh=m, rank=1, value=(x, y)) >>> v.constrain(((0.,), (-1.,)), where=m.facesLeft) >>> print(v.faceValue) [[ 0.5 1.5 0.5 1.5 0.5 1.5 0. 1. 1.5 0. 1. 1.5] [ 0.5 0.5 1. 1. 1.5 1.5 -1. 0.5 0.5 -1. 1.5 1.5]]
- Parameters:
value (float or array_like) – The value of the constraint
where (array_like of
bool
) – The constraint mask or index specifying the location of the constraint
- property constraintMask¶
Test that constraintMask returns a Variable that updates itself whenever the constraints change.
>>> from fipy import *
>>> m = Grid2D(nx=2, ny=2) >>> x, y = m.cellCenters >>> v0 = CellVariable(mesh=m) >>> v0.constrain(1., where=m.facesLeft) >>> print(v0.faceValue.constraintMask) [False False False False False False True False False True False False] >>> print(v0.faceValue) [ 0. 0. 0. 0. 0. 0. 1. 0. 0. 1. 0. 0.] >>> v0.constrain(3., where=m.facesRight) >>> print(v0.faceValue.constraintMask) [False False False False False False True False True True False True] >>> print(v0.faceValue) [ 0. 0. 0. 0. 0. 0. 1. 0. 3. 1. 0. 3.] >>> v1 = CellVariable(mesh=m) >>> v1.constrain(1., where=(x < 1) & (y < 1)) >>> print(v1.constraintMask) [ True False False False] >>> print(v1) [ 1. 0. 0. 0.] >>> v1.constrain(3., where=(x > 1) & (y > 1)) >>> print(v1.constraintMask) [ True False False True] >>> print(v1) [ 1. 0. 0. 3.]
- property constraints¶
- copy()¶
Make an duplicate of the Variable
>>> a = Variable(value=3) >>> b = a.copy() >>> b Variable(value=array(3))
The duplicate will not reflect changes made to the original
>>> a.setValue(5) >>> b Variable(value=array(3))
Check that this works for arrays.
>>> a = Variable(value=numerix.array((0, 1, 2))) >>> b = a.copy() >>> b Variable(value=array([0, 1, 2])) >>> a[1] = 3 >>> b Variable(value=array([0, 1, 2]))
- property divergence¶
the divergence of self,
,
- Returns:
divergence – one rank lower than self
- Return type:
Examples
>>> from fipy.meshes import Grid2D >>> from fipy.variables.cellVariable import CellVariable >>> mesh = Grid2D(nx=3, ny=2) >>> from builtins import range >>> var = CellVariable(mesh=mesh, value=list(range(3*2))) >>> print(var.faceGrad.divergence) [ 4. 3. 2. -2. -3. -4.]
- dontCacheMe(recursive=False)¶
- dot(other, opShape=None, operatorClass=None)¶
Return the mesh-element–by–mesh-element (cell-by-cell, face-by-face, etc.) scalar product
Both self and other can be of arbitrary rank, and other does not need to be a _MeshVariable.
- getsctype(default=None)¶
Returns the Numpy sctype of the underlying array.
>>> Variable(1).getsctype() == numerix.NUMERIX.obj2sctype(numerix.array(1)) True >>> Variable(1.).getsctype() == numerix.NUMERIX.obj2sctype(numerix.array(1.)) True >>> Variable((1, 1.)).getsctype() == numerix.NUMERIX.obj2sctype(numerix.array((1., 1.))) True
- property globalValue¶
- inBaseUnits()¶
Return the value of the Variable with all units reduced to their base SI elements.
>>> e = Variable(value="2.7 Hartree*Nav") >>> print(e.inBaseUnits().allclose("7088849.01085 kg*m**2/s**2/mol")) 1
- inUnitsOf(*units)¶
Returns one or more Variable objects that express the same physical quantity in different units. The units are specified by strings containing their names. The units must be compatible with the unit of the object. If one unit is specified, the return value is a single Variable.
>>> freeze = Variable('0 degC') >>> print(freeze.inUnitsOf('degF').allclose("32.0 degF")) 1
If several units are specified, the return value is a tuple of Variable instances with with one element per unit such that the sum of all quantities in the tuple equals the the original quantity and all the values except for the last one are integers. This is used to convert to irregular unit systems like hour/minute/second. The original object will not be changed.
>>> t = Variable(value=314159., unit='s') >>> from builtins import zip >>> print(numerix.allclose([e.allclose(v) for (e, v) in zip(t.inUnitsOf('d', 'h', 'min', 's'), ... ['3.0 d', '15.0 h', '15.0 min', '59.0 s'])], ... True)) 1
- itemset(value)¶
- property itemsize¶
- max(axis=None)¶
- min(axis=None)¶
>>> from fipy import Grid2D, CellVariable >>> mesh = Grid2D(nx=5, ny=5) >>> x, y = mesh.cellCenters >>> v = CellVariable(mesh=mesh, value=x*y) >>> print(v.min()) 0.25
- property name¶
- property numericValue¶
- put(indices, value)¶
- property rank¶
- ravel()¶
- rdot(other, opShape=None, operatorClass=None)¶
Return the mesh-element–by–mesh-element (cell-by-cell, face-by-face, etc.) scalar product
Both self and other can be of arbitrary rank, and other does not need to be a _MeshVariable.
- release(constraint)¶
Remove constraint from self
>>> v = Variable((0, 1, 2, 3)) >>> v.constrain(2, numerix.array((True, False, False, False))) >>> v[:] = 10 >>> from fipy.boundaryConditions.constraint import Constraint >>> c1 = Constraint(5, numerix.array((False, False, True, False))) >>> v.constrain(c1) >>> v[:] = 6 >>> v.constrain(8) >>> v[:] = 10 >>> del v.constraints[2] >>> v.release(constraint=c1) >>> print(v) [ 2 10 10 10]
- setValue(value, unit=None, where=None)¶
Set the value of the Variable. Can take a masked array.
>>> a = Variable((1, 2, 3)) >>> a.setValue(5, where=(1, 0, 1)) >>> print(a) [5 2 5]
>>> b = Variable((4, 5, 6)) >>> a.setValue(b, where=(1, 0, 1)) >>> print(a) [4 2 6] >>> print(b) [4 5 6] >>> a.value = 3 >>> print(a) [3 3 3]
>>> b = numerix.array((3, 4, 5)) >>> a.value = b >>> a[:] = 1 >>> print(b) [3 4 5]
>>> a.setValue((4, 5, 6), where=(1, 0)) Traceback (most recent call last): .... ValueError: shape mismatch: objects cannot be broadcast to a single shape
- property shape¶
>>> from fipy.meshes import Grid2D >>> from fipy.variables.cellVariable import CellVariable >>> mesh = Grid2D(nx=2, ny=3) >>> var = CellVariable(mesh=mesh) >>> print(numerix.allequal(var.shape, (6,))) True >>> print(numerix.allequal(var.arithmeticFaceValue.shape, (17,))) True >>> print(numerix.allequal(var.grad.shape, (2, 6))) True >>> print(numerix.allequal(var.faceGrad.shape, (2, 17))) True
Have to account for zero length arrays
>>> from fipy import Grid1D >>> m = Grid1D(nx=0) >>> v = CellVariable(mesh=m, elementshape=(2,)) >>> numerix.allequal((v * 1).shape, (2, 0)) True
- std(axis=None, **kwargs)¶
Evaluate standard deviation of all the elements of a MeshVariable.
Adapted from http://mpitutorial.com/tutorials/mpi-reduce-and-allreduce/
>>> import fipy as fp >>> mesh = fp.Grid2D(nx=2, ny=2, dx=2., dy=5.) >>> var = fp.CellVariable(value=(1., 2., 3., 4.), mesh=mesh) >>> print((var.std()**2).allclose(1.25)) True
- property subscribedVariables¶
- sum(axis=None)¶
- take(ids, axis=0)¶
- tostring(max_line_width=75, precision=8, suppress_small=False, separator=' ')¶
- property unit¶
Return the unit object of self.
>>> Variable(value="1 m").unit <PhysicalUnit m>
- property value¶
“Evaluate” the Variable and return its value (longhand)
>>> a = Variable(value=3) >>> print(a.value) 3 >>> b = a + 4 >>> b (Variable(value=array(3)) + 4) >>> b.value 7
- class fipy.FirstOrderAdvectionTerm(coeff=None)¶
Bases:
_NonDiffusionTerm
The FirstOrderAdvectionTerm object constructs the b vector contribution for the advection term given by
from the advection equation given by:
The construction of the gradient magnitude term requires upwinding. The formula used here is given by:
Here are some simple test cases for this problem:
>>> from fipy.meshes import Grid1D >>> from fipy.solvers import * >>> SparseMatrix = LinearLUSolver()._matrixClass >>> mesh = Grid1D(dx = 1., nx = 3) >>> from fipy.variables.cellVariable import CellVariable
Trivial test:
>>> var = CellVariable(value = numerix.zeros(3, 'd'), mesh = mesh) >>> v, L, b = FirstOrderAdvectionTerm(0.)._buildMatrix(var, SparseMatrix) >>> print(numerix.allclose(b, numerix.zeros(3, 'd'), atol = 1e-10)) True
Less trivial test:
>>> var = CellVariable(value = numerix.arange(3), mesh = mesh) >>> v, L, b = FirstOrderAdvectionTerm(1.)._buildMatrix(var, SparseMatrix) >>> print(numerix.allclose(b, numerix.array((0., -1., -1.)), atol = 1e-10)) True
Even less trivial
>>> var = CellVariable(value = numerix.arange(3), mesh = mesh) >>> v, L, b = FirstOrderAdvectionTerm(-1.)._buildMatrix(var, SparseMatrix) >>> print(numerix.allclose(b, numerix.array((1., 1., 0.)), atol = 1e-10)) True
Another trivial test case (more trivial than a trivial test case standing on a harpsichord singing “trivial test cases are here again”)
>>> vel = numerix.array((-1, 2, -3)) >>> var = CellVariable(value = numerix.array((4, 6, 1)), mesh = mesh) >>> v, L, b = FirstOrderAdvectionTerm(vel)._buildMatrix(var, SparseMatrix) >>> print(numerix.allclose(b, -vel * numerix.array((2, numerix.sqrt(5**2 + 2**2), 5)), atol = 1e-10)) True
Somewhat less trivial test case:
>>> from fipy.meshes import Grid2D >>> mesh = Grid2D(dx = 1., dy = 1., nx = 2, ny = 2) >>> vel = numerix.array((3, -5, -6, -3)) >>> var = CellVariable(value = numerix.array((3, 1, 6, 7)), mesh = mesh) >>> v, L, b = FirstOrderAdvectionTerm(vel)._buildMatrix(var, SparseMatrix) >>> answer = -vel * numerix.array((2, numerix.sqrt(2**2 + 6**2), 1, 0)) >>> print(numerix.allclose(b, answer, atol = 1e-10)) True
Create a Term.
- Parameters:
coeff (float or CellVariable or FaceVariable) – Coefficient for the term. FaceVariable objects are only acceptable for diffusion or convection terms.
- property RHSvector¶
Return the RHS vector calculated in solve() or sweep(). The cacheRHSvector() method should be called before solve() or sweep() to cache the vector.
- __add__(other)¶
- __and__(other)¶
- __div__(other)¶
- __eq__(other)¶
Return self==value.
- __hash__()¶
Return hash(self).
- __mul__(other)¶
Multiply a term
>>> 2. * __NonDiffusionTerm(coeff=0.5) __NonDiffusionTerm(coeff=1.0)
Test for ticket:291.
>>> from fipy import PowerLawConvectionTerm >>> PowerLawConvectionTerm(coeff=[[1], [0]]) * 1.0 PowerLawConvectionTerm(coeff=array([[ 1.], [ 0.]]))
- __neg__()¶
Negate a Term.
>>> -__NonDiffusionTerm(coeff=1.) __NonDiffusionTerm(coeff=-1.0)
- __pos__()¶
- __radd__(other)¶
- __rand__(other)¶
- __repr__()¶
The representation of a Term object is given by,
>>> print(__UnaryTerm(123.456)) __UnaryTerm(coeff=123.456)
- __rmul__(other)¶
Multiply a term
>>> 2. * __NonDiffusionTerm(coeff=0.5) __NonDiffusionTerm(coeff=1.0)
Test for ticket:291.
>>> from fipy import PowerLawConvectionTerm >>> PowerLawConvectionTerm(coeff=[[1], [0]]) * 1.0 PowerLawConvectionTerm(coeff=array([[ 1.], [ 0.]]))
- __rsub__(other)¶
- __sub__(other)¶
- __truediv__(other)¶
- cacheMatrix()¶
Informs solve() and sweep() to cache their matrix so that matrix can return the matrix.
- cacheRHSvector()¶
Informs solve() and sweep() to cache their right hand side vector so that getRHSvector() can return it.
- copy()¶
- getDefaultSolver(var=None, solver=None, *args, **kwargs)¶
- justErrorVector(var=None, solver=None, boundaryConditions=(), dt=1.0, underRelaxation=None, residualFn=None)¶
Builds the Term’s linear system once.
This method also recalculates and returns the error as well as applying under-relaxation.
justErrorVector returns the overlapping local value in parallel (not the non-overlapping value).
>>> from fipy.solvers import DummySolver >>> from fipy import * >>> m = Grid1D(nx=10) >>> v = CellVariable(mesh=m) >>> len(DiffusionTerm().justErrorVector(v, solver=DummySolver())) == m.numberOfCells True
- Parameters:
var (CellVariable) – Variable to be solved for. Provides the initial condition, the old value and holds the solution on completion.
solver (Solver) – Iterative solver to be used to solve the linear system of equations. The default sovler depends on the solver package selected.
boundaryConditions (
tuple
ofBoundaryCondition
) –dt (float) – Timestep size.
underRelaxation (float) – Usually a value between 0 and 1 or None in the case of no under-relaxation
residualFn (function) – Takes var, matrix, and RHSvector arguments, used to customize the residual calculation.
- Returns:
error – The residual vector
- Return type:
- justResidualVector(var=None, solver=None, boundaryConditions=(), dt=None, underRelaxation=None, residualFn=None)¶
Builds the Term’s linear system once.
This method also recalculates and returns the residual as well as applying under-relaxation.
justResidualVector returns the overlapping local value in parallel (not the non-overlapping value).
>>> from fipy import * >>> m = Grid1D(nx=10) >>> v = CellVariable(mesh=m) >>> len(numerix.asarray(DiffusionTerm().justResidualVector(v))) == m.numberOfCells True
- Parameters:
var (CellVariable) – Variable to be solved for. Provides the initial condition, the old value and holds the solution on completion.
solver (Solver) – Iterative solver to be used to solve the linear system of equations. The default sovler depends on the solver package selected.
boundaryConditions (
tuple
ofBoundaryCondition
) –dt (float) – Timestep size.
underRelaxation (float) – Usually a value between 0 and 1 or None in the case of no under-relaxation
residualFn (function) – Takes var, matrix, and RHSvector arguments, used to customize the residual calculation.
- Returns:
residual – The residual vector
- Return type:
- property matrix¶
Return the matrix calculated in solve() or sweep(). The cacheMatrix() method should be called before solve() or sweep() to cache the matrix.
- residualVectorAndNorm(var=None, solver=None, boundaryConditions=(), dt=None, underRelaxation=None, residualFn=None)¶
Builds the Term’s linear system once.
This method also recalculates and returns the residual as well as applying under-relaxation.
- Parameters:
var (CellVariable) – Variable to be solved for. Provides the initial condition, the old value and holds the solution on completion.
solver (Solver) – Iterative solver to be used to solve the linear system of equations. The default sovler depends on the solver package selected.
boundaryConditions (
tuple
ofBoundaryCondition
) –dt (float) – Timestep size.
underRelaxation (float) – Usually a value between 0 and 1 or None in the case of no under-relaxation
residualFn (function) – Takes var, matrix, and RHSvector arguments, used to customize the residual calculation.
- Returns:
residual (~fipy.variables.cellVariable.CellVariable) – The residual vector
norm (float) – The L2 norm of residual,
- solve(var=None, solver=None, boundaryConditions=(), dt=None)¶
Builds and solves the Term’s linear system once. This method does not return the residual. It should be used when the residual is not required.
- Parameters:
var (CellVariable) – Variable to be solved for. Provides the initial condition, the old value and holds the solution on completion.
solver (Solver) – Iterative solver to be used to solve the linear system of equations. The default sovler depends on the solver package selected.
boundaryConditions (
tuple
ofBoundaryCondition
) –dt (float) – Timestep size.
- sweep(var=None, solver=None, boundaryConditions=(), dt=None, underRelaxation=None, residualFn=None, cacheResidual=False, cacheError=False)¶
Builds and solves the Term’s linear system once. This method also recalculates and returns the residual as well as applying under-relaxation.
- Parameters:
var (CellVariable) – Variable to be solved for. Provides the initial condition, the old value and holds the solution on completion.
solver (Solver) – Iterative solver to be used to solve the linear system of equations. The default sovler depends on the solver package selected.
boundaryConditions (
tuple
ofBoundaryCondition
) –dt (float) – Timestep size.
underRelaxation (float) – Usually a value between 0 and 1 or None in the case of no under-relaxation
residualFn (function) – Takes var, matrix, and RHSvector arguments, used to customize the residual calculation.
cacheResidual (bool) – If True, calculate and store the residual vector
in the residualVector member of Term
cacheError (bool) – If True, use the residual vector
to solve
for the error vector
and store it in the errorVector member of Term
- Returns:
residual – The residual vector
- Return type:
- class fipy.FixedFlux(faces, value)¶
Bases:
BoundaryCondition
The FixedFlux boundary condition adds a contribution, equivalent to a fixed flux (Neumann condition), to the equation’s RHS vector. The contribution, given by value, is only added to entries corresponding to the specified faces, and is weighted by the face areas.
- Parameters:
faces (
FaceVariable
ofbool
) – Mask of faces where this condition applies.value (float) – Value to impose.
- __repr__()¶
Return repr(self).
- class fipy.FixedValue(faces, value)¶
Bases:
BoundaryCondition
The FixedValue boundary condition adds a contribution, equivalent to a fixed value (Dirichlet condition), to the equation’s RHS vector and coefficient matrix. The contributions are given by
for the RHS vector and
for the coefficient matrix. The parameter
represents the term’s geometric coefficient, which depends on the type of term and the mesh geometry.
Contributions are only added to entries corresponding to the specified faces.
- Parameters:
faces (
FaceVariable
ofbool
) – Mask of faces where this condition applies.value (float) – Value to impose.
- __repr__()¶
Return repr(self).
- class fipy.GammaNoiseVariable(*args, **kwds)¶
Bases:
NoiseVariable
Represents a gamma distribution of random numbers with the probability distribution
with a shape parameter
, a rate parameter
, and
.
Seed the random module for the sake of deterministic test results.
>>> from fipy import numerix >>> numerix.random.seed(1)
We generate noise on a uniform Cartesian mesh
>>> from fipy.variables.variable import Variable >>> alpha = Variable() >>> beta = Variable() >>> from fipy.meshes import Grid2D >>> noise = GammaNoiseVariable(mesh = Grid2D(nx = 100, ny = 100), shape = alpha, rate = beta)
We histogram the root-volume-weighted noise distribution
>>> from fipy.variables.histogramVariable import HistogramVariable >>> histogram = HistogramVariable(distribution = noise, dx = 0.1, nx = 300)
and compare to a Gaussian distribution
>>> from fipy.variables.cellVariable import CellVariable >>> x = CellVariable(mesh=histogram.mesh, value=histogram.mesh.cellCenters[0]) >>> from scipy.special import gamma as Gamma >>> from fipy.tools.numerix import exp >>> gammadist = (x**(alpha - 1) * (beta**alpha * exp(-beta * x)) / Gamma(alpha))
>>> if __name__ == '__main__': ... from fipy import Viewer ... viewer = Viewer(vars=noise, datamin=0, datamax=30) ... histoplot = Viewer(vars=(histogram, gammadist), ... datamin=0, datamax=1)
>>> from fipy.tools.numerix import arange
>>> for shape in arange(1, 8, 1): ... alpha.value = shape ... for rate in arange(0.5, 2.5, 0.5): ... beta.value = rate ... if __name__ == '__main__': ... import sys ... print("alpha: %g, beta: %g" % (alpha, beta), file=sys.stderr) ... viewer.plot() ... histoplot.plot()
>>> print(abs(noise.faceGrad.divergence.cellVolumeAverage) < 5e-15) 1
- Parameters:
- __abs__()¶
Following test it to fix a bug with C inline string using abs() instead of fabs()
>>> print(abs(Variable(2.3) - Variable(1.2))) 1.1
Check representation works with different versions of numpy
>>> print(repr(abs(Variable(2.3)))) numerix.fabs(Variable(value=array(2.3)))
- __add__(other)¶
- __and__(other)¶
This test case has been added due to a weird bug that was appearing.
>>> a = Variable(value=(0, 0, 1, 1)) >>> b = Variable(value=(0, 1, 0, 1)) >>> print(numerix.equal((a == 0) & (b == 1), [False, True, False, False]).all()) True >>> print(a & b) [0 0 0 1] >>> from fipy.meshes import Grid1D >>> mesh = Grid1D(nx=4) >>> from fipy.variables.cellVariable import CellVariable >>> a = CellVariable(value=(0, 0, 1, 1), mesh=mesh) >>> b = CellVariable(value=(0, 1, 0, 1), mesh=mesh) >>> print(numerix.allequal((a == 0) & (b == 1), [False, True, False, False])) True >>> print(a & b) [0 0 0 1]
- __array__(t=None)¶
Attempt to convert the Variable to a numerix array object
>>> v = Variable(value=[2, 3]) >>> print(numerix.array(v)) [2 3]
A dimensional Variable will convert to the numeric value in its base units
>>> v = Variable(value=[2, 3], unit="mm") >>> numerix.array(v) array([ 0.002, 0.003])
- __array_priority__ = 100.0¶
- __array_wrap__(arr, context=None)¶
Required to prevent numpy not calling the reverse binary operations. Both the following tests are examples ufuncs.
>>> print(type(numerix.array([1.0, 2.0]) * Variable([1.0, 2.0]))) <class 'fipy.variables.binaryOperatorVariable...binOp'>
>>> from scipy.special import gamma as Gamma >>> print(type(Gamma(Variable([1.0, 2.0])))) <class 'fipy.variables.unaryOperatorVariable...unOp'>
- __bool__()¶
>>> print(bool(Variable(value=0))) 0 >>> print(bool(Variable(value=(0, 0, 1, 1)))) Traceback (most recent call last): ... ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
- __call__(points=None, order=0, nearestCellIDs=None)¶
Interpolates the CellVariable to a set of points using a method that has a memory requirement on the order of Ncells by Npoints in general, but uses only Ncells when the CellVariable’s mesh is a UniformGrid object.
Tests
>>> from fipy import * >>> m = Grid2D(nx=3, ny=2) >>> v = CellVariable(mesh=m, value=m.cellCenters[0]) >>> print(v(((0., 1.1, 1.2), (0., 1., 1.)))) [ 0.5 1.5 1.5] >>> print(v(((0., 1.1, 1.2), (0., 1., 1.)), order=1)) [ 0.25 1.1 1.2 ] >>> m0 = Grid2D(nx=2, ny=2, dx=1., dy=1.) >>> m1 = Grid2D(nx=4, ny=4, dx=.5, dy=.5) >>> x, y = m0.cellCenters >>> v0 = CellVariable(mesh=m0, value=x * y) >>> print(v0(m1.cellCenters.globalValue)) [ 0.25 0.25 0.75 0.75 0.25 0.25 0.75 0.75 0.75 0.75 2.25 2.25 0.75 0.75 2.25 2.25] >>> print(v0(m1.cellCenters.globalValue, order=1)) [ 0.125 0.25 0.5 0.625 0.25 0.375 0.875 1. 0.5 0.875 1.875 2.25 0.625 1. 2.25 2.625]
- __div__(other)¶
- __eq__(other)¶
Test if a Variable is equal to another quantity
>>> a = Variable(value=3) >>> b = (a == 4) >>> b (Variable(value=array(3)) == 4) >>> b() 0
- __float__()¶
- __ge__(other)¶
Test if a Variable is greater than or equal to another quantity
>>> a = Variable(value=3) >>> b = (a >= 4) >>> b (Variable(value=array(3)) >= 4) >>> b() 0 >>> a.value = 4 >>> print(b()) 1 >>> a.value = 5 >>> print(b()) 1
- __getitem__(index)¶
“Evaluate” the Variable and return the specified element
>>> a = Variable(value=((3., 4.), (5., 6.)), unit="m") + "4 m" >>> print(a[1, 1]) 10.0 m
It is an error to slice a Variable whose value is not sliceable
>>> Variable(value=3)[2] Traceback (most recent call last): ... IndexError: 0-d arrays can't be indexed
- __getstate__()¶
Used internally to collect the necessary information to
pickle
the CellVariable to persistent storage.
- __gt__(other)¶
Test if a Variable is greater than another quantity
>>> a = Variable(value=3) >>> b = (a > 4) >>> b (Variable(value=array(3)) > 4) >>> print(b()) 0 >>> a.value = 5 >>> print(b()) 1
- __hash__()¶
Return hash(self).
- __int__()¶
- __invert__()¶
Returns logical “not” of the Variable
>>> a = Variable(value=True) >>> print(~a) False
- __iter__()¶
- __le__(other)¶
Test if a Variable is less than or equal to another quantity
>>> a = Variable(value=3) >>> b = (a <= 4) >>> b (Variable(value=array(3)) <= 4) >>> b() 1 >>> a.value = 4 >>> print(b()) 1 >>> a.value = 5 >>> print(b()) 0
- __len__()¶
- __lt__(other)¶
Test if a Variable is less than another quantity
>>> a = Variable(value=3) >>> b = (a < 4) >>> b (Variable(value=array(3)) < 4) >>> b() 1 >>> a.value = 4 >>> print(b()) 0 >>> print(1000000000000000000 * Variable(1) < 1.) 0 >>> print(1000 * Variable(1) < 1.) 0
Python automatically reverses the arguments when necessary
>>> 4 > Variable(value=3) (Variable(value=array(3)) < 4)
- __mod__(other)¶
- __mul__(other)¶
- __ne__(other)¶
Test if a Variable is not equal to another quantity
>>> a = Variable(value=3) >>> b = (a != 4) >>> b (Variable(value=array(3)) != 4) >>> b() 1
- __neg__()¶
- static __new__(cls, *args, **kwds)¶
- __nonzero__()¶
>>> print(bool(Variable(value=0))) 0 >>> print(bool(Variable(value=(0, 0, 1, 1)))) Traceback (most recent call last): ... ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
- __or__(other)¶
This test case has been added due to a weird bug that was appearing.
>>> a = Variable(value=(0, 0, 1, 1)) >>> b = Variable(value=(0, 1, 0, 1)) >>> print(numerix.equal((a == 0) | (b == 1), [True, True, False, True]).all()) True >>> print(a | b) [0 1 1 1] >>> from fipy.meshes import Grid1D >>> mesh = Grid1D(nx=4) >>> from fipy.variables.cellVariable import CellVariable >>> a = CellVariable(value=(0, 0, 1, 1), mesh=mesh) >>> b = CellVariable(value=(0, 1, 0, 1), mesh=mesh) >>> print(numerix.allequal((a == 0) | (b == 1), [True, True, False, True])) True >>> print(a | b) [0 1 1 1]
- __pos__()¶
- __pow__(other)¶
return self**other, or self raised to power other
>>> print(Variable(1, "mol/l")**3) 1.0 mol**3/l**3 >>> print((Variable(1, "mol/l")**3).unit) <PhysicalUnit mol**3/l**3>
- __radd__(other)¶
- __rdiv__(other)¶
- __repr__()¶
Return repr(self).
- __rmul__(other)¶
- __rpow__(other)¶
- __rsub__(other)¶
- __rtruediv__(other)¶
- __setitem__(index, value)¶
- __setstate__(dict)¶
Used internally to create a new CellVariable from
pickled
persistent storage.
- __str__()¶
Return str(self).
- __sub__(other)¶
- __truediv__(other)¶
- all(axis=None)¶
>>> print(Variable(value=(0, 0, 1, 1)).all()) 0 >>> print(Variable(value=(1, 1, 1, 1)).all()) 1
- allclose(other, rtol=1e-05, atol=1e-08)¶
>>> var = Variable((1, 1)) >>> print(var.allclose((1, 1))) 1 >>> print(var.allclose((1,))) 1
The following test is to check that the system does not run out of memory.
>>> from fipy.tools import numerix >>> var = Variable(numerix.ones(10000)) >>> print(var.allclose(numerix.zeros(10000, 'l'))) False
- allequal(other)¶
- any(axis=None)¶
>>> print(Variable(value=0).any()) 0 >>> print(Variable(value=(0, 0, 1, 1)).any()) 1
- property arithmeticFaceValue¶
Returns a FaceVariable whose value corresponds to the arithmetic interpolation of the adjacent cells:
>>> from fipy.meshes import Grid1D >>> from fipy import numerix >>> mesh = Grid1D(dx = (1., 1.)) >>> L = 1 >>> R = 2 >>> var = CellVariable(mesh = mesh, value = (L, R)) >>> faceValue = var.arithmeticFaceValue[mesh.interiorFaces.value] >>> answer = (R - L) * (0.5 / 1.) + L >>> print(numerix.allclose(faceValue, answer, atol = 1e-10, rtol = 1e-10)) True
>>> mesh = Grid1D(dx = (2., 4.)) >>> var = CellVariable(mesh = mesh, value = (L, R)) >>> faceValue = var.arithmeticFaceValue[mesh.interiorFaces.value] >>> answer = (R - L) * (1.0 / 3.0) + L >>> print(numerix.allclose(faceValue, answer, atol = 1e-10, rtol = 1e-10)) True
>>> mesh = Grid1D(dx = (10., 100.)) >>> var = CellVariable(mesh = mesh, value = (L, R)) >>> faceValue = var.arithmeticFaceValue[mesh.interiorFaces.value] >>> answer = (R - L) * (5.0 / 55.0) + L >>> print(numerix.allclose(faceValue, answer, atol = 1e-10, rtol = 1e-10)) True
- cacheMe(recursive=False)¶
- property cellVolumeAverage¶
Return the cell-volume-weighted average of the CellVariable:
>>> from fipy.meshes import Grid2D >>> from fipy.variables.cellVariable import CellVariable >>> mesh = Grid2D(nx = 3, ny = 1, dx = .5, dy = .1) >>> var = CellVariable(value = (1, 2, 6), mesh = mesh) >>> print(var.cellVolumeAverage) 3.0
- constrain(value, where=None)¶
Constrains the CellVariable to value at a location specified by where.
>>> from fipy import * >>> m = Grid1D(nx=3) >>> v = CellVariable(mesh=m, value=m.cellCenters[0]) >>> v.constrain(0., where=m.facesLeft) >>> v.faceGrad.constrain([1.], where=m.facesRight) >>> print(v.faceGrad) [[ 1. 1. 1. 1.]] >>> print(v.faceValue) [ 0. 1. 2. 2.5]
Changing the constraint changes the dependencies
>>> v.constrain(1., where=m.facesLeft) >>> print(v.faceGrad) [[-1. 1. 1. 1.]] >>> print(v.faceValue) [ 1. 1. 2. 2.5]
Constraints can be Variable
>>> c = Variable(0.) >>> v.constrain(c, where=m.facesLeft) >>> print(v.faceGrad) [[ 1. 1. 1. 1.]] >>> print(v.faceValue) [ 0. 1. 2. 2.5] >>> c.value = 1. >>> print(v.faceGrad) [[-1. 1. 1. 1.]] >>> print(v.faceValue) [ 1. 1. 2. 2.5]
Constraints can have a Variable mask.
>>> v = CellVariable(mesh=m) >>> mask = FaceVariable(mesh=m, value=m.facesLeft) >>> v.constrain(1., where=mask) >>> print(v.faceValue) [ 1. 0. 0. 0.] >>> mask[:] = mask | m.facesRight >>> print(v.faceValue) [ 1. 0. 0. 1.]
- property constraintMask¶
Test that constraintMask returns a Variable that updates itself whenever the constraints change.
>>> from fipy import *
>>> m = Grid2D(nx=2, ny=2) >>> x, y = m.cellCenters >>> v0 = CellVariable(mesh=m) >>> v0.constrain(1., where=m.facesLeft) >>> print(v0.faceValue.constraintMask) [False False False False False False True False False True False False] >>> print(v0.faceValue) [ 0. 0. 0. 0. 0. 0. 1. 0. 0. 1. 0. 0.] >>> v0.constrain(3., where=m.facesRight) >>> print(v0.faceValue.constraintMask) [False False False False False False True False True True False True] >>> print(v0.faceValue) [ 0. 0. 0. 0. 0. 0. 1. 0. 3. 1. 0. 3.] >>> v1 = CellVariable(mesh=m) >>> v1.constrain(1., where=(x < 1) & (y < 1)) >>> print(v1.constraintMask) [ True False False False] >>> print(v1) [ 1. 0. 0. 0.] >>> v1.constrain(3., where=(x > 1) & (y > 1)) >>> print(v1.constraintMask) [ True False False True] >>> print(v1) [ 1. 0. 0. 3.]
- property constraints¶
- copy()¶
Copy the value of the NoiseVariable to a static CellVariable.
- dontCacheMe(recursive=False)¶
- dot(other, opShape=None, operatorClass=None)¶
Return the mesh-element–by–mesh-element (cell-by-cell, face-by-face, etc.) scalar product
Both self and other can be of arbitrary rank, and other does not need to be a _MeshVariable.
- property faceGrad¶
Return
as a rank-1 FaceVariable using differencing for the normal direction(second-order gradient).
- property faceGradAverage¶
Deprecated since version 3.3: use
grad.arithmeticFaceValue()
insteadReturn
as a rank-1 FaceVariable using averaging for the normal direction(second-order gradient)
- property faceValue¶
Returns a FaceVariable whose value corresponds to the arithmetic interpolation of the adjacent cells:
>>> from fipy.meshes import Grid1D >>> from fipy import numerix >>> mesh = Grid1D(dx = (1., 1.)) >>> L = 1 >>> R = 2 >>> var = CellVariable(mesh = mesh, value = (L, R)) >>> faceValue = var.arithmeticFaceValue[mesh.interiorFaces.value] >>> answer = (R - L) * (0.5 / 1.) + L >>> print(numerix.allclose(faceValue, answer, atol = 1e-10, rtol = 1e-10)) True
>>> mesh = Grid1D(dx = (2., 4.)) >>> var = CellVariable(mesh = mesh, value = (L, R)) >>> faceValue = var.arithmeticFaceValue[mesh.interiorFaces.value] >>> answer = (R - L) * (1.0 / 3.0) + L >>> print(numerix.allclose(faceValue, answer, atol = 1e-10, rtol = 1e-10)) True
>>> mesh = Grid1D(dx = (10., 100.)) >>> var = CellVariable(mesh = mesh, value = (L, R)) >>> faceValue = var.arithmeticFaceValue[mesh.interiorFaces.value] >>> answer = (R - L) * (5.0 / 55.0) + L >>> print(numerix.allclose(faceValue, answer, atol = 1e-10, rtol = 1e-10)) True
- property gaussGrad¶
Return
as a rank-1 CellVariable (first-order gradient).
- getsctype(default=None)¶
Returns the Numpy sctype of the underlying array.
>>> Variable(1).getsctype() == numerix.NUMERIX.obj2sctype(numerix.array(1)) True >>> Variable(1.).getsctype() == numerix.NUMERIX.obj2sctype(numerix.array(1.)) True >>> Variable((1, 1.)).getsctype() == numerix.NUMERIX.obj2sctype(numerix.array((1., 1.))) True
- property globalValue¶
Concatenate and return values from all processors
When running on a single processor, the result is identical to
value
.
- property grad¶
Return
as a rank-1 CellVariable (first-order gradient).
- property harmonicFaceValue¶
Returns a FaceVariable whose value corresponds to the harmonic interpolation of the adjacent cells:
>>> from fipy.meshes import Grid1D >>> from fipy import numerix >>> mesh = Grid1D(dx = (1., 1.)) >>> L = 1 >>> R = 2 >>> var = CellVariable(mesh = mesh, value = (L, R)) >>> faceValue = var.harmonicFaceValue[mesh.interiorFaces.value] >>> answer = L * R / ((R - L) * (0.5 / 1.) + L) >>> print(numerix.allclose(faceValue, answer, atol = 1e-10, rtol = 1e-10)) True
>>> mesh = Grid1D(dx = (2., 4.)) >>> var = CellVariable(mesh = mesh, value = (L, R)) >>> faceValue = var.harmonicFaceValue[mesh.interiorFaces.value] >>> answer = L * R / ((R - L) * (1.0 / 3.0) + L) >>> print(numerix.allclose(faceValue, answer, atol = 1e-10, rtol = 1e-10)) True
>>> mesh = Grid1D(dx = (10., 100.)) >>> var = CellVariable(mesh = mesh, value = (L, R)) >>> faceValue = var.harmonicFaceValue[mesh.interiorFaces.value] >>> answer = L * R / ((R - L) * (5.0 / 55.0) + L) >>> print(numerix.allclose(faceValue, answer, atol = 1e-10, rtol = 1e-10)) True
- inBaseUnits()¶
Return the value of the Variable with all units reduced to their base SI elements.
>>> e = Variable(value="2.7 Hartree*Nav") >>> print(e.inBaseUnits().allclose("7088849.01085 kg*m**2/s**2/mol")) 1
- inUnitsOf(*units)¶
Returns one or more Variable objects that express the same physical quantity in different units. The units are specified by strings containing their names. The units must be compatible with the unit of the object. If one unit is specified, the return value is a single Variable.
>>> freeze = Variable('0 degC') >>> print(freeze.inUnitsOf('degF').allclose("32.0 degF")) 1
If several units are specified, the return value is a tuple of Variable instances with with one element per unit such that the sum of all quantities in the tuple equals the the original quantity and all the values except for the last one are integers. This is used to convert to irregular unit systems like hour/minute/second. The original object will not be changed.
>>> t = Variable(value=314159., unit='s') >>> from builtins import zip >>> print(numerix.allclose([e.allclose(v) for (e, v) in zip(t.inUnitsOf('d', 'h', 'min', 's'), ... ['3.0 d', '15.0 h', '15.0 min', '59.0 s'])], ... True)) 1
- itemset(value)¶
- property itemsize¶
- property leastSquaresGrad¶
Return
, which is determined by solving for
in the following matrix equation,
The matrix equation is derived by minimizing the following least squares sum,
Tests
>>> from fipy import Grid2D >>> m = Grid2D(nx=2, ny=2, dx=0.1, dy=2.0) >>> print(numerix.allclose(CellVariable(mesh=m, value=(0, 1, 3, 6)).leastSquaresGrad.globalValue, \ ... [[8.0, 8.0, 24.0, 24.0], ... [1.2, 2.0, 1.2, 2.0]])) True
>>> from fipy import Grid1D >>> print(numerix.allclose(CellVariable(mesh=Grid1D(dx=(2.0, 1.0, 0.5)), ... value=(0, 1, 2)).leastSquaresGrad.globalValue, [[0.461538461538, 0.8, 1.2]])) True
- max(axis=None)¶
- min(axis=None)¶
>>> from fipy import Grid2D, CellVariable >>> mesh = Grid2D(nx=5, ny=5) >>> x, y = mesh.cellCenters >>> v = CellVariable(mesh=mesh, value=x*y) >>> print(v.min()) 0.25
- property minmodFaceValue¶
Returns a FaceVariable with a value that is the minimum of the absolute values of the adjacent cells. If the values are of opposite sign then the result is zero:
>>> from fipy import * >>> print(CellVariable(mesh=Grid1D(nx=2), value=(1, 2)).minmodFaceValue) [1 1 2] >>> print(CellVariable(mesh=Grid1D(nx=2), value=(-1, -2)).minmodFaceValue) [-1 -1 -2] >>> print(CellVariable(mesh=Grid1D(nx=2), value=(-1, 2)).minmodFaceValue) [-1 0 2]
- property name¶
- property numericValue¶
- property old¶
Return the values of the CellVariable from the previous solution sweep.
Combinations of CellVariable’s should also return old values.
>>> from fipy.meshes import Grid1D >>> mesh = Grid1D(nx = 2) >>> from fipy.variables.cellVariable import CellVariable >>> var1 = CellVariable(mesh = mesh, value = (2, 3), hasOld = 1) >>> var2 = CellVariable(mesh = mesh, value = (3, 4)) >>> v = var1 * var2 >>> print(v) [ 6 12] >>> var1.value = ((3, 2)) >>> print(v) [9 8] >>> print(v.old) [ 6 12]
The following small test is to correct for a bug when the operator does not just use variables.
>>> v1 = var1 * 3 >>> print(v1) [9 6] >>> print(v1.old) [6 9]
- parallelRandom()¶
- put(indices, value)¶
- random()¶
- property rank¶
- ravel()¶
- rdot(other, opShape=None, operatorClass=None)¶
Return the mesh-element–by–mesh-element (cell-by-cell, face-by-face, etc.) scalar product
Both self and other can be of arbitrary rank, and other does not need to be a _MeshVariable.
- release(constraint)¶
Remove constraint from self
>>> from fipy import * >>> m = Grid1D(nx=3) >>> v = CellVariable(mesh=m, value=m.cellCenters[0]) >>> c = Constraint(0., where=m.facesLeft) >>> v.constrain(c) >>> print(v.faceValue) [ 0. 1. 2. 2.5] >>> v.release(constraint=c) >>> print(v.faceValue) [ 0.5 1. 2. 2.5]
- scramble()¶
Generate a new random distribution.
- setValue(value, unit=None, where=None)¶
Set the value of the Variable. Can take a masked array.
>>> a = Variable((1, 2, 3)) >>> a.setValue(5, where=(1, 0, 1)) >>> print(a) [5 2 5]
>>> b = Variable((4, 5, 6)) >>> a.setValue(b, where=(1, 0, 1)) >>> print(a) [4 2 6] >>> print(b) [4 5 6] >>> a.value = 3 >>> print(a) [3 3 3]
>>> b = numerix.array((3, 4, 5)) >>> a.value = b >>> a[:] = 1 >>> print(b) [3 4 5]
>>> a.setValue((4, 5, 6), where=(1, 0)) Traceback (most recent call last): .... ValueError: shape mismatch: objects cannot be broadcast to a single shape
- property shape¶
>>> from fipy.meshes import Grid2D >>> from fipy.variables.cellVariable import CellVariable >>> mesh = Grid2D(nx=2, ny=3) >>> var = CellVariable(mesh=mesh) >>> print(numerix.allequal(var.shape, (6,))) True >>> print(numerix.allequal(var.arithmeticFaceValue.shape, (17,))) True >>> print(numerix.allequal(var.grad.shape, (2, 6))) True >>> print(numerix.allequal(var.faceGrad.shape, (2, 17))) True
Have to account for zero length arrays
>>> from fipy import Grid1D >>> m = Grid1D(nx=0) >>> v = CellVariable(mesh=m, elementshape=(2,)) >>> numerix.allequal((v * 1).shape, (2, 0)) True
- std(axis=None, **kwargs)¶
Evaluate standard deviation of all the elements of a MeshVariable.
Adapted from http://mpitutorial.com/tutorials/mpi-reduce-and-allreduce/
>>> import fipy as fp >>> mesh = fp.Grid2D(nx=2, ny=2, dx=2., dy=5.) >>> var = fp.CellVariable(value=(1., 2., 3., 4.), mesh=mesh) >>> print((var.std()**2).allclose(1.25)) True
- property subscribedVariables¶
- sum(axis=None)¶
- take(ids, axis=0)¶
- tostring(max_line_width=75, precision=8, suppress_small=False, separator=' ')¶
- property unit¶
Return the unit object of self.
>>> Variable(value="1 m").unit <PhysicalUnit m>
- updateOld()¶
Set the values of the previous solution sweep to the current values.
>>> from fipy import * >>> v = CellVariable(mesh=Grid1D(), hasOld=False) >>> v.updateOld() Traceback (most recent call last): ... AssertionError: The updateOld method requires the CellVariable to have an old value. Set hasOld to True when instantiating the CellVariable.
- property value¶
“Evaluate” the Variable and return its value (longhand)
>>> a = Variable(value=3) >>> print(a.value) 3 >>> b = a + 4 >>> b (Variable(value=array(3)) + 4) >>> b.value 7
- class fipy.GaussianNoiseVariable(*args, **kwds)¶
Bases:
NoiseVariable
Represents a normal (Gaussian) distribution of random numbers with mean
and variance
, which has the probability distribution
For example, the variance of thermal noise that is uncorrelated in space and time is often expressed as
which can be obtained with:
sigmaSqrd = Mobility * kBoltzmann * Temperature / (mesh.cellVolumes * timeStep) GaussianNoiseVariable(mesh = mesh, variance = sigmaSqrd)
Note
If the time step will change as the simulation progresses, either through use of an adaptive iterator or by making manual changes at different stages, remember to declare timeStep as a Variable and to change its value with its setValue() method.
>>> import sys >>> from fipy.tools.numerix import *
>>> mean = 0. >>> variance = 4.
Seed the random module for the sake of deterministic test results.
>>> from fipy import numerix >>> numerix.random.seed(3)
We generate noise on a non-uniform Cartesian mesh with cell dimensions of
and
.
>>> from fipy.meshes import Grid2D >>> mesh = Grid2D(dx = arange(0.1, 5., 0.1)**2, dy = arange(0.1, 3., 0.1)**3) >>> from fipy.variables.cellVariable import CellVariable >>> volumes = CellVariable(mesh=mesh, value=mesh.cellVolumes) >>> noise = GaussianNoiseVariable(mesh = mesh, mean = mean, ... variance = variance / volumes)
We histogram the root-volume-weighted noise distribution
>>> from fipy.variables.histogramVariable import HistogramVariable >>> histogram = HistogramVariable(distribution = noise * sqrt(volumes), ... dx = 0.1, nx = 600, offset = -30)
and compare to a Gaussian distribution
>>> gauss = CellVariable(mesh = histogram.mesh) >>> x = histogram.mesh.cellCenters[0] >>> gauss.value = ((1/(sqrt(variance * 2 * pi))) * exp(-(x - mean)**2 / (2 * variance)))
>>> if __name__ == '__main__': ... from fipy.viewers import Viewer ... viewer = Viewer(vars=noise, ... datamin=-5, datamax=5) ... histoplot = Viewer(vars=(histogram, gauss))
>>> from builtins import range >>> for i in range(10): ... noise.scramble() ... if __name__ == '__main__': ... viewer.plot() ... histoplot.plot()
>>> print(abs(noise.faceGrad.divergence.cellVolumeAverage) < 5e-15) 1
Note that the noise exhibits larger amplitude in the small cells than in the large ones
but that the root-volume-weighted histogram is Gaussian.
- Parameters:
- __abs__()¶
Following test it to fix a bug with C inline string using abs() instead of fabs()
>>> print(abs(Variable(2.3) - Variable(1.2))) 1.1
Check representation works with different versions of numpy
>>> print(repr(abs(Variable(2.3)))) numerix.fabs(Variable(value=array(2.3)))
- __add__(other)¶
- __and__(other)¶
This test case has been added due to a weird bug that was appearing.
>>> a = Variable(value=(0, 0, 1, 1)) >>> b = Variable(value=(0, 1, 0, 1)) >>> print(numerix.equal((a == 0) & (b == 1), [False, True, False, False]).all()) True >>> print(a & b) [0 0 0 1] >>> from fipy.meshes import Grid1D >>> mesh = Grid1D(nx=4) >>> from fipy.variables.cellVariable import CellVariable >>> a = CellVariable(value=(0, 0, 1, 1), mesh=mesh) >>> b = CellVariable(value=(0, 1, 0, 1), mesh=mesh) >>> print(numerix.allequal((a == 0) & (b == 1), [False, True, False, False])) True >>> print(a & b) [0 0 0 1]
- __array__(t=None)¶
Attempt to convert the Variable to a numerix array object
>>> v = Variable(value=[2, 3]) >>> print(numerix.array(v)) [2 3]
A dimensional Variable will convert to the numeric value in its base units
>>> v = Variable(value=[2, 3], unit="mm") >>> numerix.array(v) array([ 0.002, 0.003])
- __array_priority__ = 100.0¶
- __array_wrap__(arr, context=None)¶
Required to prevent numpy not calling the reverse binary operations. Both the following tests are examples ufuncs.
>>> print(type(numerix.array([1.0, 2.0]) * Variable([1.0, 2.0]))) <class 'fipy.variables.binaryOperatorVariable...binOp'>
>>> from scipy.special import gamma as Gamma >>> print(type(Gamma(Variable([1.0, 2.0])))) <class 'fipy.variables.unaryOperatorVariable...unOp'>
- __bool__()¶
>>> print(bool(Variable(value=0))) 0 >>> print(bool(Variable(value=(0, 0, 1, 1)))) Traceback (most recent call last): ... ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
- __call__(points=None, order=0, nearestCellIDs=None)¶
Interpolates the CellVariable to a set of points using a method that has a memory requirement on the order of Ncells by Npoints in general, but uses only Ncells when the CellVariable’s mesh is a UniformGrid object.
Tests
>>> from fipy import * >>> m = Grid2D(nx=3, ny=2) >>> v = CellVariable(mesh=m, value=m.cellCenters[0]) >>> print(v(((0., 1.1, 1.2), (0., 1., 1.)))) [ 0.5 1.5 1.5] >>> print(v(((0., 1.1, 1.2), (0., 1., 1.)), order=1)) [ 0.25 1.1 1.2 ] >>> m0 = Grid2D(nx=2, ny=2, dx=1., dy=1.) >>> m1 = Grid2D(nx=4, ny=4, dx=.5, dy=.5) >>> x, y = m0.cellCenters >>> v0 = CellVariable(mesh=m0, value=x * y) >>> print(v0(m1.cellCenters.globalValue)) [ 0.25 0.25 0.75 0.75 0.25 0.25 0.75 0.75 0.75 0.75 2.25 2.25 0.75 0.75 2.25 2.25] >>> print(v0(m1.cellCenters.globalValue, order=1)) [ 0.125 0.25 0.5 0.625 0.25 0.375 0.875 1. 0.5 0.875 1.875 2.25 0.625 1. 2.25 2.625]
- __div__(other)¶
- __eq__(other)¶
Test if a Variable is equal to another quantity
>>> a = Variable(value=3) >>> b = (a == 4) >>> b (Variable(value=array(3)) == 4) >>> b() 0
- __float__()¶
- __ge__(other)¶
Test if a Variable is greater than or equal to another quantity
>>> a = Variable(value=3) >>> b = (a >= 4) >>> b (Variable(value=array(3)) >= 4) >>> b() 0 >>> a.value = 4 >>> print(b()) 1 >>> a.value = 5 >>> print(b()) 1
- __getitem__(index)¶
“Evaluate” the Variable and return the specified element
>>> a = Variable(value=((3., 4.), (5., 6.)), unit="m") + "4 m" >>> print(a[1, 1]) 10.0 m
It is an error to slice a Variable whose value is not sliceable
>>> Variable(value=3)[2] Traceback (most recent call last): ... IndexError: 0-d arrays can't be indexed
- __getstate__()¶
Used internally to collect the necessary information to
pickle
the CellVariable to persistent storage.
- __gt__(other)¶
Test if a Variable is greater than another quantity
>>> a = Variable(value=3) >>> b = (a > 4) >>> b (Variable(value=array(3)) > 4) >>> print(b()) 0 >>> a.value = 5 >>> print(b()) 1
- __hash__()¶
Return hash(self).
- __int__()¶
- __invert__()¶
Returns logical “not” of the Variable
>>> a = Variable(value=True) >>> print(~a) False
- __iter__()¶
- __le__(other)¶
Test if a Variable is less than or equal to another quantity
>>> a = Variable(value=3) >>> b = (a <= 4) >>> b (Variable(value=array(3)) <= 4) >>> b() 1 >>> a.value = 4 >>> print(b()) 1 >>> a.value = 5 >>> print(b()) 0
- __len__()¶
- __lt__(other)¶
Test if a Variable is less than another quantity
>>> a = Variable(value=3) >>> b = (a < 4) >>> b (Variable(value=array(3)) < 4) >>> b() 1 >>> a.value = 4 >>> print(b()) 0 >>> print(1000000000000000000 * Variable(1) < 1.) 0 >>> print(1000 * Variable(1) < 1.) 0
Python automatically reverses the arguments when necessary
>>> 4 > Variable(value=3) (Variable(value=array(3)) < 4)
- __mod__(other)¶
- __mul__(other)¶
- __ne__(other)¶
Test if a Variable is not equal to another quantity
>>> a = Variable(value=3) >>> b = (a != 4) >>> b (Variable(value=array(3)) != 4) >>> b() 1
- __neg__()¶
- static __new__(cls, *args, **kwds)¶
- __nonzero__()¶
>>> print(bool(Variable(value=0))) 0 >>> print(bool(Variable(value=(0, 0, 1, 1)))) Traceback (most recent call last): ... ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
- __or__(other)¶
This test case has been added due to a weird bug that was appearing.
>>> a = Variable(value=(0, 0, 1, 1)) >>> b = Variable(value=(0, 1, 0, 1)) >>> print(numerix.equal((a == 0) | (b == 1), [True, True, False, True]).all()) True >>> print(a | b) [0 1 1 1] >>> from fipy.meshes import Grid1D >>> mesh = Grid1D(nx=4) >>> from fipy.variables.cellVariable import CellVariable >>> a = CellVariable(value=(0, 0, 1, 1), mesh=mesh) >>> b = CellVariable(value=(0, 1, 0, 1), mesh=mesh) >>> print(numerix.allequal((a == 0) | (b == 1), [True, True, False, True])) True >>> print(a | b) [0 1 1 1]
- __pos__()¶
- __pow__(other)¶
return self**other, or self raised to power other
>>> print(Variable(1, "mol/l")**3) 1.0 mol**3/l**3 >>> print((Variable(1, "mol/l")**3).unit) <PhysicalUnit mol**3/l**3>
- __radd__(other)¶
- __rdiv__(other)¶
- __repr__()¶
Return repr(self).
- __rmul__(other)¶
- __rpow__(other)¶
- __rsub__(other)¶
- __rtruediv__(other)¶
- __setitem__(index, value)¶
- __setstate__(dict)¶
Used internally to create a new CellVariable from
pickled
persistent storage.
- __str__()¶
Return str(self).
- __sub__(other)¶
- __truediv__(other)¶
- all(axis=None)¶
>>> print(Variable(value=(0, 0, 1, 1)).all()) 0 >>> print(Variable(value=(1, 1, 1, 1)).all()) 1
- allclose(other, rtol=1e-05, atol=1e-08)¶
>>> var = Variable((1, 1)) >>> print(var.allclose((1, 1))) 1 >>> print(var.allclose((1,))) 1
The following test is to check that the system does not run out of memory.
>>> from fipy.tools import numerix >>> var = Variable(numerix.ones(10000)) >>> print(var.allclose(numerix.zeros(10000, 'l'))) False
- allequal(other)¶
- any(axis=None)¶
>>> print(Variable(value=0).any()) 0 >>> print(Variable(value=(0, 0, 1, 1)).any()) 1
- property arithmeticFaceValue¶
Returns a FaceVariable whose value corresponds to the arithmetic interpolation of the adjacent cells:
>>> from fipy.meshes import Grid1D >>> from fipy import numerix >>> mesh = Grid1D(dx = (1., 1.)) >>> L = 1 >>> R = 2 >>> var = CellVariable(mesh = mesh, value = (L, R)) >>> faceValue = var.arithmeticFaceValue[mesh.interiorFaces.value] >>> answer = (R - L) * (0.5 / 1.) + L >>> print(numerix.allclose(faceValue, answer, atol = 1e-10, rtol = 1e-10)) True
>>> mesh = Grid1D(dx = (2., 4.)) >>> var = CellVariable(mesh = mesh, value = (L, R)) >>> faceValue = var.arithmeticFaceValue[mesh.interiorFaces.value] >>> answer = (R - L) * (1.0 / 3.0) + L >>> print(numerix.allclose(faceValue, answer, atol = 1e-10, rtol = 1e-10)) True
>>> mesh = Grid1D(dx = (10., 100.)) >>> var = CellVariable(mesh = mesh, value = (L, R)) >>> faceValue = var.arithmeticFaceValue[mesh.interiorFaces.value] >>> answer = (R - L) * (5.0 / 55.0) + L >>> print(numerix.allclose(faceValue, answer, atol = 1e-10, rtol = 1e-10)) True
- cacheMe(recursive=False)¶
- property cellVolumeAverage¶
Return the cell-volume-weighted average of the CellVariable:
>>> from fipy.meshes import Grid2D >>> from fipy.variables.cellVariable import CellVariable >>> mesh = Grid2D(nx = 3, ny = 1, dx = .5, dy = .1) >>> var = CellVariable(value = (1, 2, 6), mesh = mesh) >>> print(var.cellVolumeAverage) 3.0
- constrain(value, where=None)¶
Constrains the CellVariable to value at a location specified by where.
>>> from fipy import * >>> m = Grid1D(nx=3) >>> v = CellVariable(mesh=m, value=m.cellCenters[0]) >>> v.constrain(0., where=m.facesLeft) >>> v.faceGrad.constrain([1.], where=m.facesRight) >>> print(v.faceGrad) [[ 1. 1. 1. 1.]] >>> print(v.faceValue) [ 0. 1. 2. 2.5]
Changing the constraint changes the dependencies
>>> v.constrain(1., where=m.facesLeft) >>> print(v.faceGrad) [[-1. 1. 1. 1.]] >>> print(v.faceValue) [ 1. 1. 2. 2.5]
Constraints can be Variable
>>> c = Variable(0.) >>> v.constrain(c, where=m.facesLeft) >>> print(v.faceGrad) [[ 1. 1. 1. 1.]] >>> print(v.faceValue) [ 0. 1. 2. 2.5] >>> c.value = 1. >>> print(v.faceGrad) [[-1. 1. 1. 1.]] >>> print(v.faceValue) [ 1. 1. 2. 2.5]
Constraints can have a Variable mask.
>>> v = CellVariable(mesh=m) >>> mask = FaceVariable(mesh=m, value=m.facesLeft) >>> v.constrain(1., where=mask) >>> print(v.faceValue) [ 1. 0. 0. 0.] >>> mask[:] = mask | m.facesRight >>> print(v.faceValue) [ 1. 0. 0. 1.]
- property constraintMask¶
Test that constraintMask returns a Variable that updates itself whenever the constraints change.
>>> from fipy import *
>>> m = Grid2D(nx=2, ny=2) >>> x, y = m.cellCenters >>> v0 = CellVariable(mesh=m) >>> v0.constrain(1., where=m.facesLeft) >>> print(v0.faceValue.constraintMask) [False False False False False False True False False True False False] >>> print(v0.faceValue) [ 0. 0. 0. 0. 0. 0. 1. 0. 0. 1. 0. 0.] >>> v0.constrain(3., where=m.facesRight) >>> print(v0.faceValue.constraintMask) [False False False False False False True False True True False True] >>> print(v0.faceValue) [ 0. 0. 0. 0. 0. 0. 1. 0. 3. 1. 0. 3.] >>> v1 = CellVariable(mesh=m) >>> v1.constrain(1., where=(x < 1) & (y < 1)) >>> print(v1.constraintMask) [ True False False False] >>> print(v1) [ 1. 0. 0. 0.] >>> v1.constrain(3., where=(x > 1) & (y > 1)) >>> print(v1.constraintMask) [ True False False True] >>> print(v1) [ 1. 0. 0. 3.]
- property constraints¶
- copy()¶
Copy the value of the NoiseVariable to a static CellVariable.
- dontCacheMe(recursive=False)¶
- dot(other, opShape=None, operatorClass=None)¶
Return the mesh-element–by–mesh-element (cell-by-cell, face-by-face, etc.) scalar product
Both self and other can be of arbitrary rank, and other does not need to be a _MeshVariable.
- property faceGrad¶
Return
as a rank-1 FaceVariable using differencing for the normal direction(second-order gradient).
- property faceGradAverage¶
Deprecated since version 3.3: use
grad.arithmeticFaceValue()
insteadReturn
as a rank-1 FaceVariable using averaging for the normal direction(second-order gradient)
- property faceValue¶
Returns a FaceVariable whose value corresponds to the arithmetic interpolation of the adjacent cells:
>>> from fipy.meshes import Grid1D >>> from fipy import numerix >>> mesh = Grid1D(dx = (1., 1.)) >>> L = 1 >>> R = 2 >>> var = CellVariable(mesh = mesh, value = (L, R)) >>> faceValue = var.arithmeticFaceValue[mesh.interiorFaces.value] >>> answer = (R - L) * (0.5 / 1.) + L >>> print(numerix.allclose(faceValue, answer, atol = 1e-10, rtol = 1e-10)) True
>>> mesh = Grid1D(dx = (2., 4.)) >>> var = CellVariable(mesh = mesh, value = (L, R)) >>> faceValue = var.arithmeticFaceValue[mesh.interiorFaces.value] >>> answer = (R - L) * (1.0 / 3.0) + L >>> print(numerix.allclose(faceValue, answer, atol = 1e-10, rtol = 1e-10)) True
>>> mesh = Grid1D(dx = (10., 100.)) >>> var = CellVariable(mesh = mesh, value = (L, R)) >>> faceValue = var.arithmeticFaceValue[mesh.interiorFaces.value] >>> answer = (R - L) * (5.0 / 55.0) + L >>> print(numerix.allclose(faceValue, answer, atol = 1e-10, rtol = 1e-10)) True
- property gaussGrad¶
Return
as a rank-1 CellVariable (first-order gradient).
- getsctype(default=None)¶
Returns the Numpy sctype of the underlying array.
>>> Variable(1).getsctype() == numerix.NUMERIX.obj2sctype(numerix.array(1)) True >>> Variable(1.).getsctype() == numerix.NUMERIX.obj2sctype(numerix.array(1.)) True >>> Variable((1, 1.)).getsctype() == numerix.NUMERIX.obj2sctype(numerix.array((1., 1.))) True
- property globalValue¶
Concatenate and return values from all processors
When running on a single processor, the result is identical to
value
.
- property grad¶
Return
as a rank-1 CellVariable (first-order gradient).
- property harmonicFaceValue¶
Returns a FaceVariable whose value corresponds to the harmonic interpolation of the adjacent cells:
>>> from fipy.meshes import Grid1D >>> from fipy import numerix >>> mesh = Grid1D(dx = (1., 1.)) >>> L = 1 >>> R = 2 >>> var = CellVariable(mesh = mesh, value = (L, R)) >>> faceValue = var.harmonicFaceValue[mesh.interiorFaces.value] >>> answer = L * R / ((R - L) * (0.5 / 1.) + L) >>> print(numerix.allclose(faceValue, answer, atol = 1e-10, rtol = 1e-10)) True
>>> mesh = Grid1D(dx = (2., 4.)) >>> var = CellVariable(mesh = mesh, value = (L, R)) >>> faceValue = var.harmonicFaceValue[mesh.interiorFaces.value] >>> answer = L * R / ((R - L) * (1.0 / 3.0) + L) >>> print(numerix.allclose(faceValue, answer, atol = 1e-10, rtol = 1e-10)) True
>>> mesh = Grid1D(dx = (10., 100.)) >>> var = CellVariable(mesh = mesh, value = (L, R)) >>> faceValue = var.harmonicFaceValue[mesh.interiorFaces.value] >>> answer = L * R / ((R - L) * (5.0 / 55.0) + L) >>> print(numerix.allclose(faceValue, answer, atol = 1e-10, rtol = 1e-10)) True
- inBaseUnits()¶
Return the value of the Variable with all units reduced to their base SI elements.
>>> e = Variable(value="2.7 Hartree*Nav") >>> print(e.inBaseUnits().allclose("7088849.01085 kg*m**2/s**2/mol")) 1
- inUnitsOf(*units)¶
Returns one or more Variable objects that express the same physical quantity in different units. The units are specified by strings containing their names. The units must be compatible with the unit of the object. If one unit is specified, the return value is a single Variable.
>>> freeze = Variable('0 degC') >>> print(freeze.inUnitsOf('degF').allclose("32.0 degF")) 1
If several units are specified, the return value is a tuple of Variable instances with with one element per unit such that the sum of all quantities in the tuple equals the the original quantity and all the values except for the last one are integers. This is used to convert to irregular unit systems like hour/minute/second. The original object will not be changed.
>>> t = Variable(value=314159., unit='s') >>> from builtins import zip >>> print(numerix.allclose([e.allclose(v) for (e, v) in zip(t.inUnitsOf('d', 'h', 'min', 's'), ... ['3.0 d', '15.0 h', '15.0 min', '59.0 s'])], ... True)) 1
- itemset(value)¶
- property itemsize¶
- property leastSquaresGrad¶
Return
, which is determined by solving for
in the following matrix equation,
The matrix equation is derived by minimizing the following least squares sum,
Tests
>>> from fipy import Grid2D >>> m = Grid2D(nx=2, ny=2, dx=0.1, dy=2.0) >>> print(numerix.allclose(CellVariable(mesh=m, value=(0, 1, 3, 6)).leastSquaresGrad.globalValue, \ ... [[8.0, 8.0, 24.0, 24.0], ... [1.2, 2.0, 1.2, 2.0]])) True
>>> from fipy import Grid1D >>> print(numerix.allclose(CellVariable(mesh=Grid1D(dx=(2.0, 1.0, 0.5)), ... value=(0, 1, 2)).leastSquaresGrad.globalValue, [[0.461538461538, 0.8, 1.2]])) True
- max(axis=None)¶
- min(axis=None)¶
>>> from fipy import Grid2D, CellVariable >>> mesh = Grid2D(nx=5, ny=5) >>> x, y = mesh.cellCenters >>> v = CellVariable(mesh=mesh, value=x*y) >>> print(v.min()) 0.25
- property minmodFaceValue¶
Returns a FaceVariable with a value that is the minimum of the absolute values of the adjacent cells. If the values are of opposite sign then the result is zero:
>>> from fipy import * >>> print(CellVariable(mesh=Grid1D(nx=2), value=(1, 2)).minmodFaceValue) [1 1 2] >>> print(CellVariable(mesh=Grid1D(nx=2), value=(-1, -2)).minmodFaceValue) [-1 -1 -2] >>> print(CellVariable(mesh=Grid1D(nx=2), value=(-1, 2)).minmodFaceValue) [-1 0 2]
- property name¶
- property numericValue¶
- property old¶
Return the values of the CellVariable from the previous solution sweep.
Combinations of CellVariable’s should also return old values.
>>> from fipy.meshes import Grid1D >>> mesh = Grid1D(nx = 2) >>> from fipy.variables.cellVariable import CellVariable >>> var1 = CellVariable(mesh = mesh, value = (2, 3), hasOld = 1) >>> var2 = CellVariable(mesh = mesh, value = (3, 4)) >>> v = var1 * var2 >>> print(v) [ 6 12] >>> var1.value = ((3, 2)) >>> print(v) [9 8] >>> print(v.old) [ 6 12]
The following small test is to correct for a bug when the operator does not just use variables.
>>> v1 = var1 * 3 >>> print(v1) [9 6] >>> print(v1.old) [6 9]
- parallelRandom()¶
- put(indices, value)¶
- random()¶
- property rank¶
- ravel()¶
- rdot(other, opShape=None, operatorClass=None)¶
Return the mesh-element–by–mesh-element (cell-by-cell, face-by-face, etc.) scalar product
Both self and other can be of arbitrary rank, and other does not need to be a _MeshVariable.
- release(constraint)¶
Remove constraint from self
>>> from fipy import * >>> m = Grid1D(nx=3) >>> v = CellVariable(mesh=m, value=m.cellCenters[0]) >>> c = Constraint(0., where=m.facesLeft) >>> v.constrain(c) >>> print(v.faceValue) [ 0. 1. 2. 2.5] >>> v.release(constraint=c) >>> print(v.faceValue) [ 0.5 1. 2. 2.5]
- scramble()¶
Generate a new random distribution.
- setValue(value, unit=None, where=None)¶
Set the value of the Variable. Can take a masked array.
>>> a = Variable((1, 2, 3)) >>> a.setValue(5, where=(1, 0, 1)) >>> print(a) [5 2 5]
>>> b = Variable((4, 5, 6)) >>> a.setValue(b, where=(1, 0, 1)) >>> print(a) [4 2 6] >>> print(b) [4 5 6] >>> a.value = 3 >>> print(a) [3 3 3]
>>> b = numerix.array((3, 4, 5)) >>> a.value = b >>> a[:] = 1 >>> print(b) [3 4 5]
>>> a.setValue((4, 5, 6), where=(1, 0)) Traceback (most recent call last): .... ValueError: shape mismatch: objects cannot be broadcast to a single shape
- property shape¶
>>> from fipy.meshes import Grid2D >>> from fipy.variables.cellVariable import CellVariable >>> mesh = Grid2D(nx=2, ny=3) >>> var = CellVariable(mesh=mesh) >>> print(numerix.allequal(var.shape, (6,))) True >>> print(numerix.allequal(var.arithmeticFaceValue.shape, (17,))) True >>> print(numerix.allequal(var.grad.shape, (2, 6))) True >>> print(numerix.allequal(var.faceGrad.shape, (2, 17))) True
Have to account for zero length arrays
>>> from fipy import Grid1D >>> m = Grid1D(nx=0) >>> v = CellVariable(mesh=m, elementshape=(2,)) >>> numerix.allequal((v * 1).shape, (2, 0)) True
- std(axis=None, **kwargs)¶
Evaluate standard deviation of all the elements of a MeshVariable.
Adapted from http://mpitutorial.com/tutorials/mpi-reduce-and-allreduce/
>>> import fipy as fp >>> mesh = fp.Grid2D(nx=2, ny=2, dx=2., dy=5.) >>> var = fp.CellVariable(value=(1., 2., 3., 4.), mesh=mesh) >>> print((var.std()**2).allclose(1.25)) True
- property subscribedVariables¶
- sum(axis=None)¶
- take(ids, axis=0)¶
- tostring(max_line_width=75, precision=8, suppress_small=False, separator=' ')¶
- property unit¶
Return the unit object of self.
>>> Variable(value="1 m").unit <PhysicalUnit m>
- updateOld()¶
Set the values of the previous solution sweep to the current values.
>>> from fipy import * >>> v = CellVariable(mesh=Grid1D(), hasOld=False) >>> v.updateOld() Traceback (most recent call last): ... AssertionError: The updateOld method requires the CellVariable to have an old value. Set hasOld to True when instantiating the CellVariable.
- property value¶
“Evaluate” the Variable and return its value (longhand)
>>> a = Variable(value=3) >>> print(a.value) 3 >>> b = a + 4 >>> b (Variable(value=array(3)) + 4) >>> b.value 7
- fipy.GeneralSolver¶
alias of
LinearGMRESSolver
- class fipy.Gmsh2D(arg, coordDimensions=2, communicator=SerialPETScCommWrapper(), overlap=1, background=None)¶
Bases:
Mesh2D
Construct a 2D Mesh using Gmsh
If called in parallel, the mesh will be partitioned based on the value of parallelComm.Nproc. If an MSH file is supplied, it must have been previously partitioned with the number of partitions matching parallelComm.Nproc.
>>> radius = 5. >>> side = 4. >>> squaredCircle = Gmsh2D(''' ... // A mesh consisting of a square inside a circle inside a circle ... ... // define the basic dimensions of the mesh ... ... cellSize = 1; ... radius = %(radius)g; ... side = %(side)g; ... ... // define the compass points of the inner circle ... ... Point(1) = {0, 0, 0, cellSize}; ... Point(2) = {-radius, 0, 0, cellSize}; ... Point(3) = {0, radius, 0, cellSize}; ... Point(4) = {radius, 0, 0, cellSize}; ... Point(5) = {0, -radius, 0, cellSize}; ... ... // define the compass points of the outer circle ... ... Point(6) = {-2*radius, 0, 0, cellSize}; ... Point(7) = {0, 2*radius, 0, cellSize}; ... Point(8) = {2*radius, 0, 0, cellSize}; ... Point(9) = {0, -2*radius, 0, cellSize}; ... ... // define the corners of the square ... ... Point(10) = {side/2, side/2, 0, cellSize/2}; ... Point(11) = {-side/2, side/2, 0, cellSize/2}; ... Point(12) = {-side/2, -side/2, 0, cellSize/2}; ... Point(13) = {side/2, -side/2, 0, cellSize/2}; ... ... // define the inner circle ... ... Circle(1) = {2, 1, 3}; ... Circle(2) = {3, 1, 4}; ... Circle(3) = {4, 1, 5}; ... Circle(4) = {5, 1, 2}; ... ... // define the outer circle ... ... Circle(5) = {6, 1, 7}; ... Circle(6) = {7, 1, 8}; ... Circle(7) = {8, 1, 9}; ... Circle(8) = {9, 1, 6}; ... ... // define the square ... ... Line(9) = {10, 13}; ... Line(10) = {13, 12}; ... Line(11) = {12, 11}; ... Line(12) = {11, 10}; ... ... // define the three boundaries ... ... Line Loop(1) = {1, 2, 3, 4}; ... Line Loop(2) = {5, 6, 7, 8}; ... Line Loop(3) = {9, 10, 11, 12}; ... ... // define the three domains ... ... Plane Surface(1) = {2, 1}; ... Plane Surface(2) = {1, 3}; ... Plane Surface(3) = {3}; ... ... // label the three domains ... ... // attention: if you use any "Physical" labels, you *must* label ... // all elements that correspond to FiPy Cells (Physical Surface in 2D ... // and Physical Volume in 3D) or Gmsh will not include them and FiPy ... // will not be able to include them in the Mesh. ... ... // note: if you do not use any labels, all Cells will be included. ... ... Physical Surface("Outer") = {1}; ... Physical Surface("Middle") = {2}; ... Physical Surface("Inner") = {3}; ... ... // label the "north-west" part of the exterior boundary ... ... // note: you only need to label the Face elements ... // (Physical Line in 2D and Physical Surface in 3D) that correspond ... // to boundaries you are interested in. FiPy does not need them to ... // construct the Mesh. ... ... Physical Line("NW") = {5}; ... ''' % locals())
It can be easier to specify certain domains and boundaries within Gmsh than it is to define the same domains and boundaries with FiPy expressions.
Here we compare obtaining the same Cells and Faces using FiPy’s parametric descriptions and Gmsh’s labels.
>>> x, y = squaredCircle.cellCenters
>>> middle = ((x**2 + y**2 <= radius**2) ... & ~((x > -side/2) & (x < side/2) ... & (y > -side/2) & (y < side/2)))
>>> print((middle == squaredCircle.physicalCells["Middle"]).all()) True
>>> X, Y = squaredCircle.faceCenters
>>> NW = ((X**2 + Y**2 > (1.99*radius)**2) ... & (X**2 + Y**2 < (2.01*radius)**2) ... & (X <= 0) & (Y >= 0))
>>> print((NW == squaredCircle.physicalFaces["NW"]).all()) True
It is possible to direct Gmsh to give the mesh different densities in different locations
>>> geo = ''' ... // A mesh consisting of a square ... ... // define the corners of the square ... ... Point(1) = {1, 1, 0, 1}; ... Point(2) = {0, 1, 0, 1}; ... Point(3) = {0, 0, 0, 1}; ... Point(4) = {1, 0, 0, 1}; ... ... // define the square ... ... Line(1) = {1, 2}; ... Line(2) = {2, 3}; ... Line(3) = {3, 4}; ... Line(4) = {4, 1}; ... ... // define the boundary ... ... Line Loop(1) = {1, 2, 3, 4}; ... ... // define the domain ... ... Plane Surface(1) = {1}; ... '''
>>> from fipy import CellVariable, numerix
>>> error = [] >>> bkg = None >>> from builtins import range >>> for refine in range(4): ... square = Gmsh2D(geo, background=bkg) ... x, y = square.cellCenters ... bkg = CellVariable(mesh=square, value=abs(x / 4) + 0.01) ... error.append(((2 * numerix.sqrt(square.cellVolumes) / bkg - 1)**2).cellVolumeAverage)
Check that the mesh is (semi)monotonically approaching the desired density (the first step may increase, depending on the number of partitions)
>>> print(numerix.greater(error[:-1], error[1:]).all()) True
and that the final density is close enough to the desired density
>>> print(error[-1] < 0.02) True
The initial mesh doesn’t have to be from Gmsh
>>> from fipy import Tri2D
>>> trisquare = Tri2D(nx=1, ny=1) >>> x, y = trisquare.cellCenters >>> bkg = CellVariable(mesh=trisquare, value=abs(x / 4) + 0.01) >>> std1 = (numerix.sqrt(2 * trisquare.cellVolumes) / bkg).std()
>>> square = Gmsh2D(geo, background=bkg) >>> x, y = square.cellCenters >>> bkg = CellVariable(mesh=square, value=abs(x / 4) + 0.01) >>> std2 = (numerix.sqrt(2 * square.cellVolumes) / bkg).std()
>>> print(std1 > std2) True
- Parameters:
arg (str) – (i) the path to an MSH file, (ii) a path to a Gmsh geometry (.geo) file, or (iii) a Gmsh geometry script
coordDimensions (int) – Dimension of shapes
overlap (int) – The number of overlapping cells for parallel simulations. Generally 1 is adequate. Higher order equations or discretizations require more. If overlap is greater than one, communication reverts to serial, as Gmsh only provides one layer of ghost cells.
background (CellVariable) – Specifies the desired characteristic lengths of the mesh cells
- property VTKCellDataSet¶
Returns a TVTK DataSet representing the cells of this mesh
- property VTKFaceDataSet¶
Returns a TVTK DataSet representing the face centers of this mesh
- __add__(other)¶
Either translate a Mesh or concatenate two Mesh objects.
>>> from fipy.meshes import Grid2D >>> baseMesh = Grid2D(dx = 1.0, dy = 1.0, nx = 2, ny = 2) >>> print(baseMesh.cellCenters) [[ 0.5 1.5 0.5 1.5] [ 0.5 0.5 1.5 1.5]]
If a vector is added to a Mesh, a translated Mesh is returned
>>> translatedMesh = baseMesh + ((5,), (10,)) >>> print(translatedMesh.cellCenters) [[ 5.5 6.5 5.5 6.5] [ 10.5 10.5 11.5 11.5]]
If a Mesh is added to a Mesh, a concatenation of the two Mesh objects is returned
>>> addedMesh = baseMesh + (baseMesh + ((2,), (0,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 2.5 3.5 2.5 3.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5]]
The two Mesh objects need not be properly aligned in order to concatenate them but the resulting mesh may not have the intended connectivity
>>> addedMesh = baseMesh + (baseMesh + ((3,), (0,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 3.5 4.5 3.5 4.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5]]
>>> addedMesh = baseMesh + (baseMesh + ((2,), (2,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 2.5 3.5 2.5 3.5] [ 0.5 0.5 1.5 1.5 2.5 2.5 3.5 3.5]]
No provision is made to avoid or consolidate overlapping Mesh objects
>>> addedMesh = baseMesh + (baseMesh + ((1,), (0,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 1.5 2.5 1.5 2.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5]]
Different Mesh classes can be concatenated
>>> from fipy.meshes import Tri2D >>> triMesh = Tri2D(dx = 1.0, dy = 1.0, nx = 2, ny = 1) >>> triMesh = triMesh + ((2,), (0,)) >>> triAddedMesh = baseMesh + triMesh >>> cellCenters = [[0.5, 1.5, 0.5, 1.5, 2.83333333, 3.83333333, ... 2.5, 3.5, 2.16666667, 3.16666667, 2.5, 3.5], ... [0.5, 0.5, 1.5, 1.5, 0.5, 0.5, 0.83333333, 0.83333333, ... 0.5, 0.5, 0.16666667, 0.16666667]] >>> print(numerix.allclose(triAddedMesh.cellCenters, ... cellCenters)) True
again, their faces need not align, but the mesh may not have the desired connectivity
>>> triMesh = Tri2D(dx = 1.0, dy = 2.0, nx = 2, ny = 1) >>> triMesh = triMesh + ((2,), (0,)) >>> triAddedMesh = baseMesh + triMesh >>> cellCenters = [[ 0.5, 1.5, 0.5, 1.5, 2.83333333, 3.83333333, ... 2.5, 3.5, 2.16666667, 3.16666667, 2.5, 3.5], ... [ 0.5, 0.5, 1.5, 1.5, 1., 1., ... 1.66666667, 1.66666667, 1., 1., 0.33333333, 0.33333333]] >>> print(numerix.allclose(triAddedMesh.cellCenters, ... cellCenters)) True
Mesh concatenation is not limited to 2D meshes
>>> from fipy.meshes import Grid3D >>> threeDBaseMesh = Grid3D(dx = 1.0, dy = 1.0, dz = 1.0, ... nx = 2, ny = 2, nz = 2) >>> threeDSecondMesh = Grid3D(dx = 1.0, dy = 1.0, dz = 1.0, ... nx = 1, ny = 1, nz = 1) >>> threeDAddedMesh = threeDBaseMesh + (threeDSecondMesh + ((2,), (0,), (0,))) >>> print(threeDAddedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 0.5 1.5 0.5 1.5 2.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5 0.5] [ 0.5 0.5 0.5 0.5 1.5 1.5 1.5 1.5 0.5]]
but the different Mesh objects must, of course, have the same dimensionality.
>>> InvalidMesh = threeDBaseMesh + baseMesh Traceback (most recent call last): ... MeshAdditionError: Dimensions do not match
- __div__(other)¶
Tests. >>> from fipy import * >>> print((Grid1D(nx=1) / 2.).cellCenters) [[ 0.25]] >>> AbstractMesh(communicator=None) / 2. Traceback (most recent call last): … NotImplementedError
- __getstate__()¶
Helper for pickle.
- __mul__(factor)¶
Dilate a Mesh by factor.
>>> from fipy.meshes import Grid2D >>> baseMesh = Grid2D(dx = 1.0, dy = 1.0, nx = 2, ny = 2) >>> print(baseMesh.cellCenters) [[ 0.5 1.5 0.5 1.5] [ 0.5 0.5 1.5 1.5]]
The factor can be a scalar
>>> dilatedMesh = baseMesh * 3 >>> print(dilatedMesh.cellCenters) [[ 1.5 4.5 1.5 4.5] [ 1.5 1.5 4.5 4.5]]
or a vector
>>> dilatedMesh = baseMesh * ((3,), (2,)) >>> print(dilatedMesh.cellCenters) [[ 1.5 4.5 1.5 4.5] [ 1. 1. 3. 3. ]]
but the vector must have the same dimensionality as the Mesh
>>> dilatedMesh = baseMesh * ((3,), (2,), (1,)) Traceback (most recent call last): ... ValueError: shape mismatch: objects cannot be broadcast to a single shape
- __radd__(other)¶
Either translate a Mesh or concatenate two Mesh objects.
>>> from fipy.meshes import Grid2D >>> baseMesh = Grid2D(dx = 1.0, dy = 1.0, nx = 2, ny = 2) >>> print(baseMesh.cellCenters) [[ 0.5 1.5 0.5 1.5] [ 0.5 0.5 1.5 1.5]]
If a vector is added to a Mesh, a translated Mesh is returned
>>> translatedMesh = baseMesh + ((5,), (10,)) >>> print(translatedMesh.cellCenters) [[ 5.5 6.5 5.5 6.5] [ 10.5 10.5 11.5 11.5]]
If a Mesh is added to a Mesh, a concatenation of the two Mesh objects is returned
>>> addedMesh = baseMesh + (baseMesh + ((2,), (0,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 2.5 3.5 2.5 3.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5]]
The two Mesh objects need not be properly aligned in order to concatenate them but the resulting mesh may not have the intended connectivity
>>> addedMesh = baseMesh + (baseMesh + ((3,), (0,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 3.5 4.5 3.5 4.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5]]
>>> addedMesh = baseMesh + (baseMesh + ((2,), (2,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 2.5 3.5 2.5 3.5] [ 0.5 0.5 1.5 1.5 2.5 2.5 3.5 3.5]]
No provision is made to avoid or consolidate overlapping Mesh objects
>>> addedMesh = baseMesh + (baseMesh + ((1,), (0,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 1.5 2.5 1.5 2.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5]]
Different Mesh classes can be concatenated
>>> from fipy.meshes import Tri2D >>> triMesh = Tri2D(dx = 1.0, dy = 1.0, nx = 2, ny = 1) >>> triMesh = triMesh + ((2,), (0,)) >>> triAddedMesh = baseMesh + triMesh >>> cellCenters = [[0.5, 1.5, 0.5, 1.5, 2.83333333, 3.83333333, ... 2.5, 3.5, 2.16666667, 3.16666667, 2.5, 3.5], ... [0.5, 0.5, 1.5, 1.5, 0.5, 0.5, 0.83333333, 0.83333333, ... 0.5, 0.5, 0.16666667, 0.16666667]] >>> print(numerix.allclose(triAddedMesh.cellCenters, ... cellCenters)) True
again, their faces need not align, but the mesh may not have the desired connectivity
>>> triMesh = Tri2D(dx = 1.0, dy = 2.0, nx = 2, ny = 1) >>> triMesh = triMesh + ((2,), (0,)) >>> triAddedMesh = baseMesh + triMesh >>> cellCenters = [[ 0.5, 1.5, 0.5, 1.5, 2.83333333, 3.83333333, ... 2.5, 3.5, 2.16666667, 3.16666667, 2.5, 3.5], ... [ 0.5, 0.5, 1.5, 1.5, 1., 1., ... 1.66666667, 1.66666667, 1., 1., 0.33333333, 0.33333333]] >>> print(numerix.allclose(triAddedMesh.cellCenters, ... cellCenters)) True
Mesh concatenation is not limited to 2D meshes
>>> from fipy.meshes import Grid3D >>> threeDBaseMesh = Grid3D(dx = 1.0, dy = 1.0, dz = 1.0, ... nx = 2, ny = 2, nz = 2) >>> threeDSecondMesh = Grid3D(dx = 1.0, dy = 1.0, dz = 1.0, ... nx = 1, ny = 1, nz = 1) >>> threeDAddedMesh = threeDBaseMesh + (threeDSecondMesh + ((2,), (0,), (0,))) >>> print(threeDAddedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 0.5 1.5 0.5 1.5 2.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5 0.5] [ 0.5 0.5 0.5 0.5 1.5 1.5 1.5 1.5 0.5]]
but the different Mesh objects must, of course, have the same dimensionality.
>>> InvalidMesh = threeDBaseMesh + baseMesh Traceback (most recent call last): ... MeshAdditionError: Dimensions do not match
- __repr__()¶
Return repr(self).
- __rmul__(factor)¶
Dilate a Mesh by factor.
>>> from fipy.meshes import Grid2D >>> baseMesh = Grid2D(dx = 1.0, dy = 1.0, nx = 2, ny = 2) >>> print(baseMesh.cellCenters) [[ 0.5 1.5 0.5 1.5] [ 0.5 0.5 1.5 1.5]]
The factor can be a scalar
>>> dilatedMesh = baseMesh * 3 >>> print(dilatedMesh.cellCenters) [[ 1.5 4.5 1.5 4.5] [ 1.5 1.5 4.5 4.5]]
or a vector
>>> dilatedMesh = baseMesh * ((3,), (2,)) >>> print(dilatedMesh.cellCenters) [[ 1.5 4.5 1.5 4.5] [ 1. 1. 3. 3. ]]
but the vector must have the same dimensionality as the Mesh
>>> dilatedMesh = baseMesh * ((3,), (2,), (1,)) Traceback (most recent call last): ... ValueError: shape mismatch: objects cannot be broadcast to a single shape
- __setstate__(state)¶
- __sub__(other)¶
Tests. >>> from fipy import * >>> m = Grid1D() >>> print((m - ((1,))).cellCenters) [[-0.5]] >>> ((1,)) - m Traceback (most recent call last): … TypeError: unsupported operand type(s) for -: ‘tuple’ and ‘UniformGrid1D’
- __truediv__(other)¶
Tests. >>> from fipy import * >>> print((Grid1D(nx=1) / 2.).cellCenters) [[ 0.25]] >>> AbstractMesh(communicator=None) / 2. Traceback (most recent call last): … NotImplementedError
- property aspect2D¶
The physical y vs x aspect ratio of a 2D mesh
- property cellCenters¶
- property cellDistanceVectors¶
- property cellFaceIDs¶
- property cellToFaceDistanceVectors¶
- property cellVolumes¶
- property extents¶
- property exteriorFaces¶
- extrude(extrudeFunc=<function Mesh2D.<lambda>>, layers=1)¶
This function returns a new 3D mesh. The 2D mesh is extruded using the extrudeFunc and the number of layers.
>>> from fipy.meshes.nonUniformGrid2D import NonUniformGrid2D >>> print(NonUniformGrid2D(nx=2, ny=2).extrude(layers=2).cellCenters) [[ 0.5 1.5 0.5 1.5 0.5 1.5 0.5 1.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5] [ 0.5 0.5 0.5 0.5 1.5 1.5 1.5 1.5]]
>>> from fipy.meshes.tri2D import Tri2D >>> print(Tri2D().extrude(layers=2).cellCenters.allclose([[ 0.83333333, 0.5, 0.16666667, 0.5, 0.83333333, 0.5, ... 0.16666667, 0.5 ], ... [ 0.5, 0.83333333, 0.5, 0.16666667, 0.5, 0.83333333, ... 0.5, 0.16666667], ... [ 0.5, 0.5, 0.5, 0.5, 1.5, 1.5, 1.5, ... 1.5 ]])) True
- Parameters:
extrudeFunc (function) – Takes the vertex coordinates and returns the displaced values
layers (int) – Number of layers in the extruded mesh (number of times extrudeFunc will be called)
- property faceCenters¶
- property facesBack¶
Return list of faces on back boundary of 3D Mesh with the z-axis running from front to back.
>>> from fipy import Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((6, 7, 8, 9, 10, 11), ... numerix.nonzero(mesh.facesBack)[0])) True >>> ignore = mesh.facesBack.value
- property facesBottom¶
Return list of faces on bottom boundary of 2D or 3D Mesh with the y-axis running from bottom to top.
>>> from fipy import Grid2D, Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((12, 13, 14), ... numerix.nonzero(mesh.facesBottom)[0])) True >>> ignore = mesh.facesBottom.value >>> x, y, z = mesh.faceCenters >>> print(numerix.allequal((12, 13), ... numerix.nonzero(mesh.facesBottom & (x < 1))[0])) True >>> ignore = mesh.facesBottom.value
- property facesDown¶
Return list of faces on bottom boundary of 2D or 3D Mesh with the y-axis running from bottom to top.
>>> from fipy import Grid2D, Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((12, 13, 14), ... numerix.nonzero(mesh.facesBottom)[0])) True >>> ignore = mesh.facesBottom.value >>> x, y, z = mesh.faceCenters >>> print(numerix.allequal((12, 13), ... numerix.nonzero(mesh.facesBottom & (x < 1))[0])) True >>> ignore = mesh.facesBottom.value
- property facesFront¶
Return list of faces on front boundary of 3D Mesh with the z-axis running from front to back.
>>> from fipy import Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((0, 1, 2, 3, 4, 5), ... numerix.nonzero(mesh.facesFront)[0])) True >>> ignore = mesh.facesFront.value
- property facesLeft¶
Return face on left boundary of Mesh as list with the x-axis running from left to right.
>>> from fipy import Grid2D, Grid3D >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((21, 25), ... numerix.nonzero(mesh.facesLeft)[0])) True >>> ignore = mesh.facesLeft.value >>> mesh = Grid2D(nx = 3, ny = 2, dx = 0.5, dy = 2.) >>> print(numerix.allequal((9, 13), ... numerix.nonzero(mesh.facesLeft)[0])) True >>> ignore = mesh.facesLeft.value
- property facesRight¶
Return list of faces on right boundary of Mesh with the x-axis running from left to right.
>>> from fipy import Grid2D, Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((24, 28), ... numerix.nonzero(mesh.facesRight)[0])) True >>> ignore = mesh.facesRight.value >>> mesh = Grid2D(nx = 3, ny = 2, dx = 0.5, dy = 2.) >>> print(numerix.allequal((12, 16), ... numerix.nonzero(mesh.facesRight)[0])) True >>> ignore = mesh.facesRight.value
- property facesTop¶
Return list of faces on top boundary of 2D or 3D Mesh with the y-axis running from bottom to top.
>>> from fipy import Grid2D, Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((18, 19, 20), ... numerix.nonzero(mesh.facesTop)[0])) True >>> ignore = mesh.facesTop.value >>> mesh = Grid2D(nx = 3, ny = 2, dx = 0.5, dy = 2.) >>> print(numerix.allequal((6, 7, 8), ... numerix.nonzero(mesh.facesTop)[0])) True >>> ignore = mesh.facesTop.value
- property facesUp¶
Return list of faces on top boundary of 2D or 3D Mesh with the y-axis running from bottom to top.
>>> from fipy import Grid2D, Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((18, 19, 20), ... numerix.nonzero(mesh.facesTop)[0])) True >>> ignore = mesh.facesTop.value >>> mesh = Grid2D(nx = 3, ny = 2, dx = 0.5, dy = 2.) >>> print(numerix.allequal((6, 7, 8), ... numerix.nonzero(mesh.facesTop)[0])) True >>> ignore = mesh.facesTop.value
- getNearestCell(point)¶
- property interiorFaceCellIDs¶
- property interiorFaceIDs¶
- property interiorFaces¶
- property scale¶
- property scaledCellDistances¶
- property scaledCellToCellDistances¶
- property scaledCellVolumes¶
- property scaledFaceAreas¶
- property scaledFaceToCellDistances¶
- property x¶
Equivalent to using
cellCenters
[0]
.>>> from fipy import * >>> print(Grid1D(nx=2).x) [ 0.5 1.5]
- property y¶
Equivalent to using
cellCenters
[1]
.>>> from fipy import * >>> print(Grid2D(nx=2, ny=2).y) [ 0.5 0.5 1.5 1.5] >>> print(Grid1D(nx=2).y) Traceback (most recent call last): ... AttributeError: 1D meshes do not have a "y" attribute.
- property z¶
Equivalent to using
cellCenters
[2]
.>>> from fipy import * >>> print(Grid3D(nx=2, ny=2, nz=2).z) [ 0.5 0.5 0.5 0.5 1.5 1.5 1.5 1.5] >>> print(Grid2D(nx=2, ny=2).z) Traceback (most recent call last): ... AttributeError: 1D and 2D meshes do not have a "z" attribute.
- class fipy.Gmsh2DIn3DSpace(arg, communicator=SerialPETScCommWrapper(), overlap=1, background=None)¶
Bases:
Gmsh2D
Create a topologically 2D Mesh in 3D coordinates using Gmsh
If called in parallel, the mesh will be partitioned based on the value of parallelComm.Nproc. If an MSH file is supplied, it must have been previously partitioned with the number of partitions matching parallelComm.Nproc.
- Parameters:
arg (str) – (i) the path to an MSH file, (ii) a path to a Gmsh geometry (.geo) file, or (iii) a Gmsh geometry script
coordDimensions (int) – Dimension of shapes
overlap (int) – The number of overlapping cells for parallel simulations. Generally 1 is adequate. Higher order equations or discretizations require more. If overlap is greater than one, communication reverts to serial, as Gmsh only provides one layer of ghost cells.
background (CellVariable) – Specifies the desired characteristic lengths of the mesh cells
- property VTKCellDataSet¶
Returns a TVTK DataSet representing the cells of this mesh
- property VTKFaceDataSet¶
Returns a TVTK DataSet representing the face centers of this mesh
- __add__(other)¶
Either translate a Mesh or concatenate two Mesh objects.
>>> from fipy.meshes import Grid2D >>> baseMesh = Grid2D(dx = 1.0, dy = 1.0, nx = 2, ny = 2) >>> print(baseMesh.cellCenters) [[ 0.5 1.5 0.5 1.5] [ 0.5 0.5 1.5 1.5]]
If a vector is added to a Mesh, a translated Mesh is returned
>>> translatedMesh = baseMesh + ((5,), (10,)) >>> print(translatedMesh.cellCenters) [[ 5.5 6.5 5.5 6.5] [ 10.5 10.5 11.5 11.5]]
If a Mesh is added to a Mesh, a concatenation of the two Mesh objects is returned
>>> addedMesh = baseMesh + (baseMesh + ((2,), (0,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 2.5 3.5 2.5 3.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5]]
The two Mesh objects need not be properly aligned in order to concatenate them but the resulting mesh may not have the intended connectivity
>>> addedMesh = baseMesh + (baseMesh + ((3,), (0,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 3.5 4.5 3.5 4.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5]]
>>> addedMesh = baseMesh + (baseMesh + ((2,), (2,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 2.5 3.5 2.5 3.5] [ 0.5 0.5 1.5 1.5 2.5 2.5 3.5 3.5]]
No provision is made to avoid or consolidate overlapping Mesh objects
>>> addedMesh = baseMesh + (baseMesh + ((1,), (0,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 1.5 2.5 1.5 2.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5]]
Different Mesh classes can be concatenated
>>> from fipy.meshes import Tri2D >>> triMesh = Tri2D(dx = 1.0, dy = 1.0, nx = 2, ny = 1) >>> triMesh = triMesh + ((2,), (0,)) >>> triAddedMesh = baseMesh + triMesh >>> cellCenters = [[0.5, 1.5, 0.5, 1.5, 2.83333333, 3.83333333, ... 2.5, 3.5, 2.16666667, 3.16666667, 2.5, 3.5], ... [0.5, 0.5, 1.5, 1.5, 0.5, 0.5, 0.83333333, 0.83333333, ... 0.5, 0.5, 0.16666667, 0.16666667]] >>> print(numerix.allclose(triAddedMesh.cellCenters, ... cellCenters)) True
again, their faces need not align, but the mesh may not have the desired connectivity
>>> triMesh = Tri2D(dx = 1.0, dy = 2.0, nx = 2, ny = 1) >>> triMesh = triMesh + ((2,), (0,)) >>> triAddedMesh = baseMesh + triMesh >>> cellCenters = [[ 0.5, 1.5, 0.5, 1.5, 2.83333333, 3.83333333, ... 2.5, 3.5, 2.16666667, 3.16666667, 2.5, 3.5], ... [ 0.5, 0.5, 1.5, 1.5, 1., 1., ... 1.66666667, 1.66666667, 1., 1., 0.33333333, 0.33333333]] >>> print(numerix.allclose(triAddedMesh.cellCenters, ... cellCenters)) True
Mesh concatenation is not limited to 2D meshes
>>> from fipy.meshes import Grid3D >>> threeDBaseMesh = Grid3D(dx = 1.0, dy = 1.0, dz = 1.0, ... nx = 2, ny = 2, nz = 2) >>> threeDSecondMesh = Grid3D(dx = 1.0, dy = 1.0, dz = 1.0, ... nx = 1, ny = 1, nz = 1) >>> threeDAddedMesh = threeDBaseMesh + (threeDSecondMesh + ((2,), (0,), (0,))) >>> print(threeDAddedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 0.5 1.5 0.5 1.5 2.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5 0.5] [ 0.5 0.5 0.5 0.5 1.5 1.5 1.5 1.5 0.5]]
but the different Mesh objects must, of course, have the same dimensionality.
>>> InvalidMesh = threeDBaseMesh + baseMesh Traceback (most recent call last): ... MeshAdditionError: Dimensions do not match
- __div__(other)¶
Tests. >>> from fipy import * >>> print((Grid1D(nx=1) / 2.).cellCenters) [[ 0.25]] >>> AbstractMesh(communicator=None) / 2. Traceback (most recent call last): … NotImplementedError
- __getstate__()¶
Helper for pickle.
- __mul__(factor)¶
Dilate a Mesh by factor.
>>> from fipy.meshes import Grid2D >>> baseMesh = Grid2D(dx = 1.0, dy = 1.0, nx = 2, ny = 2) >>> print(baseMesh.cellCenters) [[ 0.5 1.5 0.5 1.5] [ 0.5 0.5 1.5 1.5]]
The factor can be a scalar
>>> dilatedMesh = baseMesh * 3 >>> print(dilatedMesh.cellCenters) [[ 1.5 4.5 1.5 4.5] [ 1.5 1.5 4.5 4.5]]
or a vector
>>> dilatedMesh = baseMesh * ((3,), (2,)) >>> print(dilatedMesh.cellCenters) [[ 1.5 4.5 1.5 4.5] [ 1. 1. 3. 3. ]]
but the vector must have the same dimensionality as the Mesh
>>> dilatedMesh = baseMesh * ((3,), (2,), (1,)) Traceback (most recent call last): ... ValueError: shape mismatch: objects cannot be broadcast to a single shape
- __radd__(other)¶
Either translate a Mesh or concatenate two Mesh objects.
>>> from fipy.meshes import Grid2D >>> baseMesh = Grid2D(dx = 1.0, dy = 1.0, nx = 2, ny = 2) >>> print(baseMesh.cellCenters) [[ 0.5 1.5 0.5 1.5] [ 0.5 0.5 1.5 1.5]]
If a vector is added to a Mesh, a translated Mesh is returned
>>> translatedMesh = baseMesh + ((5,), (10,)) >>> print(translatedMesh.cellCenters) [[ 5.5 6.5 5.5 6.5] [ 10.5 10.5 11.5 11.5]]
If a Mesh is added to a Mesh, a concatenation of the two Mesh objects is returned
>>> addedMesh = baseMesh + (baseMesh + ((2,), (0,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 2.5 3.5 2.5 3.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5]]
The two Mesh objects need not be properly aligned in order to concatenate them but the resulting mesh may not have the intended connectivity
>>> addedMesh = baseMesh + (baseMesh + ((3,), (0,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 3.5 4.5 3.5 4.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5]]
>>> addedMesh = baseMesh + (baseMesh + ((2,), (2,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 2.5 3.5 2.5 3.5] [ 0.5 0.5 1.5 1.5 2.5 2.5 3.5 3.5]]
No provision is made to avoid or consolidate overlapping Mesh objects
>>> addedMesh = baseMesh + (baseMesh + ((1,), (0,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 1.5 2.5 1.5 2.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5]]
Different Mesh classes can be concatenated
>>> from fipy.meshes import Tri2D >>> triMesh = Tri2D(dx = 1.0, dy = 1.0, nx = 2, ny = 1) >>> triMesh = triMesh + ((2,), (0,)) >>> triAddedMesh = baseMesh + triMesh >>> cellCenters = [[0.5, 1.5, 0.5, 1.5, 2.83333333, 3.83333333, ... 2.5, 3.5, 2.16666667, 3.16666667, 2.5, 3.5], ... [0.5, 0.5, 1.5, 1.5, 0.5, 0.5, 0.83333333, 0.83333333, ... 0.5, 0.5, 0.16666667, 0.16666667]] >>> print(numerix.allclose(triAddedMesh.cellCenters, ... cellCenters)) True
again, their faces need not align, but the mesh may not have the desired connectivity
>>> triMesh = Tri2D(dx = 1.0, dy = 2.0, nx = 2, ny = 1) >>> triMesh = triMesh + ((2,), (0,)) >>> triAddedMesh = baseMesh + triMesh >>> cellCenters = [[ 0.5, 1.5, 0.5, 1.5, 2.83333333, 3.83333333, ... 2.5, 3.5, 2.16666667, 3.16666667, 2.5, 3.5], ... [ 0.5, 0.5, 1.5, 1.5, 1., 1., ... 1.66666667, 1.66666667, 1., 1., 0.33333333, 0.33333333]] >>> print(numerix.allclose(triAddedMesh.cellCenters, ... cellCenters)) True
Mesh concatenation is not limited to 2D meshes
>>> from fipy.meshes import Grid3D >>> threeDBaseMesh = Grid3D(dx = 1.0, dy = 1.0, dz = 1.0, ... nx = 2, ny = 2, nz = 2) >>> threeDSecondMesh = Grid3D(dx = 1.0, dy = 1.0, dz = 1.0, ... nx = 1, ny = 1, nz = 1) >>> threeDAddedMesh = threeDBaseMesh + (threeDSecondMesh + ((2,), (0,), (0,))) >>> print(threeDAddedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 0.5 1.5 0.5 1.5 2.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5 0.5] [ 0.5 0.5 0.5 0.5 1.5 1.5 1.5 1.5 0.5]]
but the different Mesh objects must, of course, have the same dimensionality.
>>> InvalidMesh = threeDBaseMesh + baseMesh Traceback (most recent call last): ... MeshAdditionError: Dimensions do not match
- __repr__()¶
Return repr(self).
- __rmul__(factor)¶
Dilate a Mesh by factor.
>>> from fipy.meshes import Grid2D >>> baseMesh = Grid2D(dx = 1.0, dy = 1.0, nx = 2, ny = 2) >>> print(baseMesh.cellCenters) [[ 0.5 1.5 0.5 1.5] [ 0.5 0.5 1.5 1.5]]
The factor can be a scalar
>>> dilatedMesh = baseMesh * 3 >>> print(dilatedMesh.cellCenters) [[ 1.5 4.5 1.5 4.5] [ 1.5 1.5 4.5 4.5]]
or a vector
>>> dilatedMesh = baseMesh * ((3,), (2,)) >>> print(dilatedMesh.cellCenters) [[ 1.5 4.5 1.5 4.5] [ 1. 1. 3. 3. ]]
but the vector must have the same dimensionality as the Mesh
>>> dilatedMesh = baseMesh * ((3,), (2,), (1,)) Traceback (most recent call last): ... ValueError: shape mismatch: objects cannot be broadcast to a single shape
- __setstate__(state)¶
- __sub__(other)¶
Tests. >>> from fipy import * >>> m = Grid1D() >>> print((m - ((1,))).cellCenters) [[-0.5]] >>> ((1,)) - m Traceback (most recent call last): … TypeError: unsupported operand type(s) for -: ‘tuple’ and ‘UniformGrid1D’
- __truediv__(other)¶
Tests. >>> from fipy import * >>> print((Grid1D(nx=1) / 2.).cellCenters) [[ 0.25]] >>> AbstractMesh(communicator=None) / 2. Traceback (most recent call last): … NotImplementedError
- property aspect2D¶
The physical y vs x aspect ratio of a 2D mesh
- property cellCenters¶
- property cellDistanceVectors¶
- property cellFaceIDs¶
- property cellToFaceDistanceVectors¶
- property cellVolumes¶
- property extents¶
- property exteriorFaces¶
- extrude(extrudeFunc=<function Mesh2D.<lambda>>, layers=1)¶
This function returns a new 3D mesh. The 2D mesh is extruded using the extrudeFunc and the number of layers.
>>> from fipy.meshes.nonUniformGrid2D import NonUniformGrid2D >>> print(NonUniformGrid2D(nx=2, ny=2).extrude(layers=2).cellCenters) [[ 0.5 1.5 0.5 1.5 0.5 1.5 0.5 1.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5] [ 0.5 0.5 0.5 0.5 1.5 1.5 1.5 1.5]]
>>> from fipy.meshes.tri2D import Tri2D >>> print(Tri2D().extrude(layers=2).cellCenters.allclose([[ 0.83333333, 0.5, 0.16666667, 0.5, 0.83333333, 0.5, ... 0.16666667, 0.5 ], ... [ 0.5, 0.83333333, 0.5, 0.16666667, 0.5, 0.83333333, ... 0.5, 0.16666667], ... [ 0.5, 0.5, 0.5, 0.5, 1.5, 1.5, 1.5, ... 1.5 ]])) True
- Parameters:
extrudeFunc (function) – Takes the vertex coordinates and returns the displaced values
layers (int) – Number of layers in the extruded mesh (number of times extrudeFunc will be called)
- property faceCenters¶
- property facesBack¶
Return list of faces on back boundary of 3D Mesh with the z-axis running from front to back.
>>> from fipy import Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((6, 7, 8, 9, 10, 11), ... numerix.nonzero(mesh.facesBack)[0])) True >>> ignore = mesh.facesBack.value
- property facesBottom¶
Return list of faces on bottom boundary of 2D or 3D Mesh with the y-axis running from bottom to top.
>>> from fipy import Grid2D, Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((12, 13, 14), ... numerix.nonzero(mesh.facesBottom)[0])) True >>> ignore = mesh.facesBottom.value >>> x, y, z = mesh.faceCenters >>> print(numerix.allequal((12, 13), ... numerix.nonzero(mesh.facesBottom & (x < 1))[0])) True >>> ignore = mesh.facesBottom.value
- property facesDown¶
Return list of faces on bottom boundary of 2D or 3D Mesh with the y-axis running from bottom to top.
>>> from fipy import Grid2D, Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((12, 13, 14), ... numerix.nonzero(mesh.facesBottom)[0])) True >>> ignore = mesh.facesBottom.value >>> x, y, z = mesh.faceCenters >>> print(numerix.allequal((12, 13), ... numerix.nonzero(mesh.facesBottom & (x < 1))[0])) True >>> ignore = mesh.facesBottom.value
- property facesFront¶
Return list of faces on front boundary of 3D Mesh with the z-axis running from front to back.
>>> from fipy import Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((0, 1, 2, 3, 4, 5), ... numerix.nonzero(mesh.facesFront)[0])) True >>> ignore = mesh.facesFront.value
- property facesLeft¶
Return face on left boundary of Mesh as list with the x-axis running from left to right.
>>> from fipy import Grid2D, Grid3D >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((21, 25), ... numerix.nonzero(mesh.facesLeft)[0])) True >>> ignore = mesh.facesLeft.value >>> mesh = Grid2D(nx = 3, ny = 2, dx = 0.5, dy = 2.) >>> print(numerix.allequal((9, 13), ... numerix.nonzero(mesh.facesLeft)[0])) True >>> ignore = mesh.facesLeft.value
- property facesRight¶
Return list of faces on right boundary of Mesh with the x-axis running from left to right.
>>> from fipy import Grid2D, Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((24, 28), ... numerix.nonzero(mesh.facesRight)[0])) True >>> ignore = mesh.facesRight.value >>> mesh = Grid2D(nx = 3, ny = 2, dx = 0.5, dy = 2.) >>> print(numerix.allequal((12, 16), ... numerix.nonzero(mesh.facesRight)[0])) True >>> ignore = mesh.facesRight.value
- property facesTop¶
Return list of faces on top boundary of 2D or 3D Mesh with the y-axis running from bottom to top.
>>> from fipy import Grid2D, Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((18, 19, 20), ... numerix.nonzero(mesh.facesTop)[0])) True >>> ignore = mesh.facesTop.value >>> mesh = Grid2D(nx = 3, ny = 2, dx = 0.5, dy = 2.) >>> print(numerix.allequal((6, 7, 8), ... numerix.nonzero(mesh.facesTop)[0])) True >>> ignore = mesh.facesTop.value
- property facesUp¶
Return list of faces on top boundary of 2D or 3D Mesh with the y-axis running from bottom to top.
>>> from fipy import Grid2D, Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((18, 19, 20), ... numerix.nonzero(mesh.facesTop)[0])) True >>> ignore = mesh.facesTop.value >>> mesh = Grid2D(nx = 3, ny = 2, dx = 0.5, dy = 2.) >>> print(numerix.allequal((6, 7, 8), ... numerix.nonzero(mesh.facesTop)[0])) True >>> ignore = mesh.facesTop.value
- getNearestCell(point)¶
- property interiorFaceCellIDs¶
- property interiorFaceIDs¶
- property interiorFaces¶
- property scale¶
- property scaledCellDistances¶
- property scaledCellToCellDistances¶
- property scaledCellVolumes¶
- property scaledFaceAreas¶
- property scaledFaceToCellDistances¶
- property x¶
Equivalent to using
cellCenters
[0]
.>>> from fipy import * >>> print(Grid1D(nx=2).x) [ 0.5 1.5]
- property y¶
Equivalent to using
cellCenters
[1]
.>>> from fipy import * >>> print(Grid2D(nx=2, ny=2).y) [ 0.5 0.5 1.5 1.5] >>> print(Grid1D(nx=2).y) Traceback (most recent call last): ... AttributeError: 1D meshes do not have a "y" attribute.
- property z¶
Equivalent to using
cellCenters
[2]
.>>> from fipy import * >>> print(Grid3D(nx=2, ny=2, nz=2).z) [ 0.5 0.5 0.5 0.5 1.5 1.5 1.5 1.5] >>> print(Grid2D(nx=2, ny=2).z) Traceback (most recent call last): ... AttributeError: 1D and 2D meshes do not have a "z" attribute.
- class fipy.Gmsh3D(arg, communicator=SerialPETScCommWrapper(), overlap=1, background=None)¶
Bases:
Mesh
Create a 3D Mesh using Gmsh
If called in parallel, the mesh will be partitioned based on the value of parallelComm.Nproc. If an MSH file is supplied, it must have been previously partitioned with the number of partitions matching parallelComm.Nproc.
- Parameters:
arg (str) – (i) the path to an MSH file, (ii) a path to a Gmsh geometry (.geo) file, or (iii) a Gmsh geometry script
overlap (int) – The number of overlapping cells for parallel simulations. Generally 1 is adequate. Higher order equations or discretizations require more. If overlap is greater than one, communication reverts to serial, as Gmsh only provides one layer of ghost cells.
background (CellVariable) – Specifies the desired characteristic lengths of the mesh cells
- property VTKCellDataSet¶
Returns a TVTK DataSet representing the cells of this mesh
- property VTKFaceDataSet¶
Returns a TVTK DataSet representing the face centers of this mesh
- __add__(other)¶
Either translate a Mesh or concatenate two Mesh objects.
>>> from fipy.meshes import Grid2D >>> baseMesh = Grid2D(dx = 1.0, dy = 1.0, nx = 2, ny = 2) >>> print(baseMesh.cellCenters) [[ 0.5 1.5 0.5 1.5] [ 0.5 0.5 1.5 1.5]]
If a vector is added to a Mesh, a translated Mesh is returned
>>> translatedMesh = baseMesh + ((5,), (10,)) >>> print(translatedMesh.cellCenters) [[ 5.5 6.5 5.5 6.5] [ 10.5 10.5 11.5 11.5]]
If a Mesh is added to a Mesh, a concatenation of the two Mesh objects is returned
>>> addedMesh = baseMesh + (baseMesh + ((2,), (0,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 2.5 3.5 2.5 3.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5]]
The two Mesh objects need not be properly aligned in order to concatenate them but the resulting mesh may not have the intended connectivity
>>> addedMesh = baseMesh + (baseMesh + ((3,), (0,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 3.5 4.5 3.5 4.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5]]
>>> addedMesh = baseMesh + (baseMesh + ((2,), (2,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 2.5 3.5 2.5 3.5] [ 0.5 0.5 1.5 1.5 2.5 2.5 3.5 3.5]]
No provision is made to avoid or consolidate overlapping Mesh objects
>>> addedMesh = baseMesh + (baseMesh + ((1,), (0,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 1.5 2.5 1.5 2.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5]]
Different Mesh classes can be concatenated
>>> from fipy.meshes import Tri2D >>> triMesh = Tri2D(dx = 1.0, dy = 1.0, nx = 2, ny = 1) >>> triMesh = triMesh + ((2,), (0,)) >>> triAddedMesh = baseMesh + triMesh >>> cellCenters = [[0.5, 1.5, 0.5, 1.5, 2.83333333, 3.83333333, ... 2.5, 3.5, 2.16666667, 3.16666667, 2.5, 3.5], ... [0.5, 0.5, 1.5, 1.5, 0.5, 0.5, 0.83333333, 0.83333333, ... 0.5, 0.5, 0.16666667, 0.16666667]] >>> print(numerix.allclose(triAddedMesh.cellCenters, ... cellCenters)) True
again, their faces need not align, but the mesh may not have the desired connectivity
>>> triMesh = Tri2D(dx = 1.0, dy = 2.0, nx = 2, ny = 1) >>> triMesh = triMesh + ((2,), (0,)) >>> triAddedMesh = baseMesh + triMesh >>> cellCenters = [[ 0.5, 1.5, 0.5, 1.5, 2.83333333, 3.83333333, ... 2.5, 3.5, 2.16666667, 3.16666667, 2.5, 3.5], ... [ 0.5, 0.5, 1.5, 1.5, 1., 1., ... 1.66666667, 1.66666667, 1., 1., 0.33333333, 0.33333333]] >>> print(numerix.allclose(triAddedMesh.cellCenters, ... cellCenters)) True
Mesh concatenation is not limited to 2D meshes
>>> from fipy.meshes import Grid3D >>> threeDBaseMesh = Grid3D(dx = 1.0, dy = 1.0, dz = 1.0, ... nx = 2, ny = 2, nz = 2) >>> threeDSecondMesh = Grid3D(dx = 1.0, dy = 1.0, dz = 1.0, ... nx = 1, ny = 1, nz = 1) >>> threeDAddedMesh = threeDBaseMesh + (threeDSecondMesh + ((2,), (0,), (0,))) >>> print(threeDAddedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 0.5 1.5 0.5 1.5 2.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5 0.5] [ 0.5 0.5 0.5 0.5 1.5 1.5 1.5 1.5 0.5]]
but the different Mesh objects must, of course, have the same dimensionality.
>>> InvalidMesh = threeDBaseMesh + baseMesh Traceback (most recent call last): ... MeshAdditionError: Dimensions do not match
- __div__(other)¶
Tests. >>> from fipy import * >>> print((Grid1D(nx=1) / 2.).cellCenters) [[ 0.25]] >>> AbstractMesh(communicator=None) / 2. Traceback (most recent call last): … NotImplementedError
- __getstate__()¶
Helper for pickle.
- __mul__(factor)¶
Dilate a Mesh by factor.
>>> from fipy.meshes import Grid2D >>> baseMesh = Grid2D(dx = 1.0, dy = 1.0, nx = 2, ny = 2) >>> print(baseMesh.cellCenters) [[ 0.5 1.5 0.5 1.5] [ 0.5 0.5 1.5 1.5]]
The factor can be a scalar
>>> dilatedMesh = baseMesh * 3 >>> print(dilatedMesh.cellCenters) [[ 1.5 4.5 1.5 4.5] [ 1.5 1.5 4.5 4.5]]
or a vector
>>> dilatedMesh = baseMesh * ((3,), (2,)) >>> print(dilatedMesh.cellCenters) [[ 1.5 4.5 1.5 4.5] [ 1. 1. 3. 3. ]]
but the vector must have the same dimensionality as the Mesh
>>> dilatedMesh = baseMesh * ((3,), (2,), (1,)) Traceback (most recent call last): ... ValueError: shape mismatch: objects cannot be broadcast to a single shape
- __radd__(other)¶
Either translate a Mesh or concatenate two Mesh objects.
>>> from fipy.meshes import Grid2D >>> baseMesh = Grid2D(dx = 1.0, dy = 1.0, nx = 2, ny = 2) >>> print(baseMesh.cellCenters) [[ 0.5 1.5 0.5 1.5] [ 0.5 0.5 1.5 1.5]]
If a vector is added to a Mesh, a translated Mesh is returned
>>> translatedMesh = baseMesh + ((5,), (10,)) >>> print(translatedMesh.cellCenters) [[ 5.5 6.5 5.5 6.5] [ 10.5 10.5 11.5 11.5]]
If a Mesh is added to a Mesh, a concatenation of the two Mesh objects is returned
>>> addedMesh = baseMesh + (baseMesh + ((2,), (0,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 2.5 3.5 2.5 3.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5]]
The two Mesh objects need not be properly aligned in order to concatenate them but the resulting mesh may not have the intended connectivity
>>> addedMesh = baseMesh + (baseMesh + ((3,), (0,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 3.5 4.5 3.5 4.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5]]
>>> addedMesh = baseMesh + (baseMesh + ((2,), (2,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 2.5 3.5 2.5 3.5] [ 0.5 0.5 1.5 1.5 2.5 2.5 3.5 3.5]]
No provision is made to avoid or consolidate overlapping Mesh objects
>>> addedMesh = baseMesh + (baseMesh + ((1,), (0,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 1.5 2.5 1.5 2.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5]]
Different Mesh classes can be concatenated
>>> from fipy.meshes import Tri2D >>> triMesh = Tri2D(dx = 1.0, dy = 1.0, nx = 2, ny = 1) >>> triMesh = triMesh + ((2,), (0,)) >>> triAddedMesh = baseMesh + triMesh >>> cellCenters = [[0.5, 1.5, 0.5, 1.5, 2.83333333, 3.83333333, ... 2.5, 3.5, 2.16666667, 3.16666667, 2.5, 3.5], ... [0.5, 0.5, 1.5, 1.5, 0.5, 0.5, 0.83333333, 0.83333333, ... 0.5, 0.5, 0.16666667, 0.16666667]] >>> print(numerix.allclose(triAddedMesh.cellCenters, ... cellCenters)) True
again, their faces need not align, but the mesh may not have the desired connectivity
>>> triMesh = Tri2D(dx = 1.0, dy = 2.0, nx = 2, ny = 1) >>> triMesh = triMesh + ((2,), (0,)) >>> triAddedMesh = baseMesh + triMesh >>> cellCenters = [[ 0.5, 1.5, 0.5, 1.5, 2.83333333, 3.83333333, ... 2.5, 3.5, 2.16666667, 3.16666667, 2.5, 3.5], ... [ 0.5, 0.5, 1.5, 1.5, 1., 1., ... 1.66666667, 1.66666667, 1., 1., 0.33333333, 0.33333333]] >>> print(numerix.allclose(triAddedMesh.cellCenters, ... cellCenters)) True
Mesh concatenation is not limited to 2D meshes
>>> from fipy.meshes import Grid3D >>> threeDBaseMesh = Grid3D(dx = 1.0, dy = 1.0, dz = 1.0, ... nx = 2, ny = 2, nz = 2) >>> threeDSecondMesh = Grid3D(dx = 1.0, dy = 1.0, dz = 1.0, ... nx = 1, ny = 1, nz = 1) >>> threeDAddedMesh = threeDBaseMesh + (threeDSecondMesh + ((2,), (0,), (0,))) >>> print(threeDAddedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 0.5 1.5 0.5 1.5 2.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5 0.5] [ 0.5 0.5 0.5 0.5 1.5 1.5 1.5 1.5 0.5]]
but the different Mesh objects must, of course, have the same dimensionality.
>>> InvalidMesh = threeDBaseMesh + baseMesh Traceback (most recent call last): ... MeshAdditionError: Dimensions do not match
- __repr__()¶
Return repr(self).
- __rmul__(factor)¶
Dilate a Mesh by factor.
>>> from fipy.meshes import Grid2D >>> baseMesh = Grid2D(dx = 1.0, dy = 1.0, nx = 2, ny = 2) >>> print(baseMesh.cellCenters) [[ 0.5 1.5 0.5 1.5] [ 0.5 0.5 1.5 1.5]]
The factor can be a scalar
>>> dilatedMesh = baseMesh * 3 >>> print(dilatedMesh.cellCenters) [[ 1.5 4.5 1.5 4.5] [ 1.5 1.5 4.5 4.5]]
or a vector
>>> dilatedMesh = baseMesh * ((3,), (2,)) >>> print(dilatedMesh.cellCenters) [[ 1.5 4.5 1.5 4.5] [ 1. 1. 3. 3. ]]
but the vector must have the same dimensionality as the Mesh
>>> dilatedMesh = baseMesh * ((3,), (2,), (1,)) Traceback (most recent call last): ... ValueError: shape mismatch: objects cannot be broadcast to a single shape
- __setstate__(state)¶
- __sub__(other)¶
Tests. >>> from fipy import * >>> m = Grid1D() >>> print((m - ((1,))).cellCenters) [[-0.5]] >>> ((1,)) - m Traceback (most recent call last): … TypeError: unsupported operand type(s) for -: ‘tuple’ and ‘UniformGrid1D’
- __truediv__(other)¶
Tests. >>> from fipy import * >>> print((Grid1D(nx=1) / 2.).cellCenters) [[ 0.25]] >>> AbstractMesh(communicator=None) / 2. Traceback (most recent call last): … NotImplementedError
- property aspect2D¶
The physical y vs x aspect ratio of a 2D mesh
- property cellCenters¶
- property cellDistanceVectors¶
- property cellFaceIDs¶
- property cellToFaceDistanceVectors¶
- property cellVolumes¶
- property extents¶
- property exteriorFaces¶
- property faceCenters¶
- property facesBack¶
Return list of faces on back boundary of 3D Mesh with the z-axis running from front to back.
>>> from fipy import Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((6, 7, 8, 9, 10, 11), ... numerix.nonzero(mesh.facesBack)[0])) True >>> ignore = mesh.facesBack.value
- property facesBottom¶
Return list of faces on bottom boundary of 2D or 3D Mesh with the y-axis running from bottom to top.
>>> from fipy import Grid2D, Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((12, 13, 14), ... numerix.nonzero(mesh.facesBottom)[0])) True >>> ignore = mesh.facesBottom.value >>> x, y, z = mesh.faceCenters >>> print(numerix.allequal((12, 13), ... numerix.nonzero(mesh.facesBottom & (x < 1))[0])) True >>> ignore = mesh.facesBottom.value
- property facesDown¶
Return list of faces on bottom boundary of 2D or 3D Mesh with the y-axis running from bottom to top.
>>> from fipy import Grid2D, Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((12, 13, 14), ... numerix.nonzero(mesh.facesBottom)[0])) True >>> ignore = mesh.facesBottom.value >>> x, y, z = mesh.faceCenters >>> print(numerix.allequal((12, 13), ... numerix.nonzero(mesh.facesBottom & (x < 1))[0])) True >>> ignore = mesh.facesBottom.value
- property facesFront¶
Return list of faces on front boundary of 3D Mesh with the z-axis running from front to back.
>>> from fipy import Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((0, 1, 2, 3, 4, 5), ... numerix.nonzero(mesh.facesFront)[0])) True >>> ignore = mesh.facesFront.value
- property facesLeft¶
Return face on left boundary of Mesh as list with the x-axis running from left to right.
>>> from fipy import Grid2D, Grid3D >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((21, 25), ... numerix.nonzero(mesh.facesLeft)[0])) True >>> ignore = mesh.facesLeft.value >>> mesh = Grid2D(nx = 3, ny = 2, dx = 0.5, dy = 2.) >>> print(numerix.allequal((9, 13), ... numerix.nonzero(mesh.facesLeft)[0])) True >>> ignore = mesh.facesLeft.value
- property facesRight¶
Return list of faces on right boundary of Mesh with the x-axis running from left to right.
>>> from fipy import Grid2D, Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((24, 28), ... numerix.nonzero(mesh.facesRight)[0])) True >>> ignore = mesh.facesRight.value >>> mesh = Grid2D(nx = 3, ny = 2, dx = 0.5, dy = 2.) >>> print(numerix.allequal((12, 16), ... numerix.nonzero(mesh.facesRight)[0])) True >>> ignore = mesh.facesRight.value
- property facesTop¶
Return list of faces on top boundary of 2D or 3D Mesh with the y-axis running from bottom to top.
>>> from fipy import Grid2D, Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((18, 19, 20), ... numerix.nonzero(mesh.facesTop)[0])) True >>> ignore = mesh.facesTop.value >>> mesh = Grid2D(nx = 3, ny = 2, dx = 0.5, dy = 2.) >>> print(numerix.allequal((6, 7, 8), ... numerix.nonzero(mesh.facesTop)[0])) True >>> ignore = mesh.facesTop.value
- property facesUp¶
Return list of faces on top boundary of 2D or 3D Mesh with the y-axis running from bottom to top.
>>> from fipy import Grid2D, Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((18, 19, 20), ... numerix.nonzero(mesh.facesTop)[0])) True >>> ignore = mesh.facesTop.value >>> mesh = Grid2D(nx = 3, ny = 2, dx = 0.5, dy = 2.) >>> print(numerix.allequal((6, 7, 8), ... numerix.nonzero(mesh.facesTop)[0])) True >>> ignore = mesh.facesTop.value
- getNearestCell(point)¶
- property interiorFaceCellIDs¶
- property interiorFaceIDs¶
- property interiorFaces¶
- property scale¶
- property scaledCellDistances¶
- property scaledCellToCellDistances¶
- property scaledCellVolumes¶
- property scaledFaceAreas¶
- property scaledFaceToCellDistances¶
- property x¶
Equivalent to using
cellCenters
[0]
.>>> from fipy import * >>> print(Grid1D(nx=2).x) [ 0.5 1.5]
- property y¶
Equivalent to using
cellCenters
[1]
.>>> from fipy import * >>> print(Grid2D(nx=2, ny=2).y) [ 0.5 0.5 1.5 1.5] >>> print(Grid1D(nx=2).y) Traceback (most recent call last): ... AttributeError: 1D meshes do not have a "y" attribute.
- property z¶
Equivalent to using
cellCenters
[2]
.>>> from fipy import * >>> print(Grid3D(nx=2, ny=2, nz=2).z) [ 0.5 0.5 0.5 0.5 1.5 1.5 1.5 1.5] >>> print(Grid2D(nx=2, ny=2).z) Traceback (most recent call last): ... AttributeError: 1D and 2D meshes do not have a "z" attribute.
- class fipy.GmshGrid2D(dx=1.0, dy=1.0, nx=1, ny=None, coordDimensions=2, communicator=SerialPETScCommWrapper(), overlap=1)¶
Bases:
Gmsh2D
Should serve as a drop-in replacement for Grid2D
- property VTKCellDataSet¶
Returns a TVTK DataSet representing the cells of this mesh
- property VTKFaceDataSet¶
Returns a TVTK DataSet representing the face centers of this mesh
- __add__(other)¶
Either translate a Mesh or concatenate two Mesh objects.
>>> from fipy.meshes import Grid2D >>> baseMesh = Grid2D(dx = 1.0, dy = 1.0, nx = 2, ny = 2) >>> print(baseMesh.cellCenters) [[ 0.5 1.5 0.5 1.5] [ 0.5 0.5 1.5 1.5]]
If a vector is added to a Mesh, a translated Mesh is returned
>>> translatedMesh = baseMesh + ((5,), (10,)) >>> print(translatedMesh.cellCenters) [[ 5.5 6.5 5.5 6.5] [ 10.5 10.5 11.5 11.5]]
If a Mesh is added to a Mesh, a concatenation of the two Mesh objects is returned
>>> addedMesh = baseMesh + (baseMesh + ((2,), (0,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 2.5 3.5 2.5 3.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5]]
The two Mesh objects need not be properly aligned in order to concatenate them but the resulting mesh may not have the intended connectivity
>>> addedMesh = baseMesh + (baseMesh + ((3,), (0,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 3.5 4.5 3.5 4.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5]]
>>> addedMesh = baseMesh + (baseMesh + ((2,), (2,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 2.5 3.5 2.5 3.5] [ 0.5 0.5 1.5 1.5 2.5 2.5 3.5 3.5]]
No provision is made to avoid or consolidate overlapping Mesh objects
>>> addedMesh = baseMesh + (baseMesh + ((1,), (0,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 1.5 2.5 1.5 2.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5]]
Different Mesh classes can be concatenated
>>> from fipy.meshes import Tri2D >>> triMesh = Tri2D(dx = 1.0, dy = 1.0, nx = 2, ny = 1) >>> triMesh = triMesh + ((2,), (0,)) >>> triAddedMesh = baseMesh + triMesh >>> cellCenters = [[0.5, 1.5, 0.5, 1.5, 2.83333333, 3.83333333, ... 2.5, 3.5, 2.16666667, 3.16666667, 2.5, 3.5], ... [0.5, 0.5, 1.5, 1.5, 0.5, 0.5, 0.83333333, 0.83333333, ... 0.5, 0.5, 0.16666667, 0.16666667]] >>> print(numerix.allclose(triAddedMesh.cellCenters, ... cellCenters)) True
again, their faces need not align, but the mesh may not have the desired connectivity
>>> triMesh = Tri2D(dx = 1.0, dy = 2.0, nx = 2, ny = 1) >>> triMesh = triMesh + ((2,), (0,)) >>> triAddedMesh = baseMesh + triMesh >>> cellCenters = [[ 0.5, 1.5, 0.5, 1.5, 2.83333333, 3.83333333, ... 2.5, 3.5, 2.16666667, 3.16666667, 2.5, 3.5], ... [ 0.5, 0.5, 1.5, 1.5, 1., 1., ... 1.66666667, 1.66666667, 1., 1., 0.33333333, 0.33333333]] >>> print(numerix.allclose(triAddedMesh.cellCenters, ... cellCenters)) True
Mesh concatenation is not limited to 2D meshes
>>> from fipy.meshes import Grid3D >>> threeDBaseMesh = Grid3D(dx = 1.0, dy = 1.0, dz = 1.0, ... nx = 2, ny = 2, nz = 2) >>> threeDSecondMesh = Grid3D(dx = 1.0, dy = 1.0, dz = 1.0, ... nx = 1, ny = 1, nz = 1) >>> threeDAddedMesh = threeDBaseMesh + (threeDSecondMesh + ((2,), (0,), (0,))) >>> print(threeDAddedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 0.5 1.5 0.5 1.5 2.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5 0.5] [ 0.5 0.5 0.5 0.5 1.5 1.5 1.5 1.5 0.5]]
but the different Mesh objects must, of course, have the same dimensionality.
>>> InvalidMesh = threeDBaseMesh + baseMesh Traceback (most recent call last): ... MeshAdditionError: Dimensions do not match
- __div__(other)¶
Tests. >>> from fipy import * >>> print((Grid1D(nx=1) / 2.).cellCenters) [[ 0.25]] >>> AbstractMesh(communicator=None) / 2. Traceback (most recent call last): … NotImplementedError
- __getstate__()¶
Helper for pickle.
- __mul__(factor)¶
Dilate a Mesh by factor.
>>> from fipy.meshes import Grid2D >>> baseMesh = Grid2D(dx = 1.0, dy = 1.0, nx = 2, ny = 2) >>> print(baseMesh.cellCenters) [[ 0.5 1.5 0.5 1.5] [ 0.5 0.5 1.5 1.5]]
The factor can be a scalar
>>> dilatedMesh = baseMesh * 3 >>> print(dilatedMesh.cellCenters) [[ 1.5 4.5 1.5 4.5] [ 1.5 1.5 4.5 4.5]]
or a vector
>>> dilatedMesh = baseMesh * ((3,), (2,)) >>> print(dilatedMesh.cellCenters) [[ 1.5 4.5 1.5 4.5] [ 1. 1. 3. 3. ]]
but the vector must have the same dimensionality as the Mesh
>>> dilatedMesh = baseMesh * ((3,), (2,), (1,)) Traceback (most recent call last): ... ValueError: shape mismatch: objects cannot be broadcast to a single shape
- __radd__(other)¶
Either translate a Mesh or concatenate two Mesh objects.
>>> from fipy.meshes import Grid2D >>> baseMesh = Grid2D(dx = 1.0, dy = 1.0, nx = 2, ny = 2) >>> print(baseMesh.cellCenters) [[ 0.5 1.5 0.5 1.5] [ 0.5 0.5 1.5 1.5]]
If a vector is added to a Mesh, a translated Mesh is returned
>>> translatedMesh = baseMesh + ((5,), (10,)) >>> print(translatedMesh.cellCenters) [[ 5.5 6.5 5.5 6.5] [ 10.5 10.5 11.5 11.5]]
If a Mesh is added to a Mesh, a concatenation of the two Mesh objects is returned
>>> addedMesh = baseMesh + (baseMesh + ((2,), (0,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 2.5 3.5 2.5 3.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5]]
The two Mesh objects need not be properly aligned in order to concatenate them but the resulting mesh may not have the intended connectivity
>>> addedMesh = baseMesh + (baseMesh + ((3,), (0,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 3.5 4.5 3.5 4.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5]]
>>> addedMesh = baseMesh + (baseMesh + ((2,), (2,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 2.5 3.5 2.5 3.5] [ 0.5 0.5 1.5 1.5 2.5 2.5 3.5 3.5]]
No provision is made to avoid or consolidate overlapping Mesh objects
>>> addedMesh = baseMesh + (baseMesh + ((1,), (0,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 1.5 2.5 1.5 2.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5]]
Different Mesh classes can be concatenated
>>> from fipy.meshes import Tri2D >>> triMesh = Tri2D(dx = 1.0, dy = 1.0, nx = 2, ny = 1) >>> triMesh = triMesh + ((2,), (0,)) >>> triAddedMesh = baseMesh + triMesh >>> cellCenters = [[0.5, 1.5, 0.5, 1.5, 2.83333333, 3.83333333, ... 2.5, 3.5, 2.16666667, 3.16666667, 2.5, 3.5], ... [0.5, 0.5, 1.5, 1.5, 0.5, 0.5, 0.83333333, 0.83333333, ... 0.5, 0.5, 0.16666667, 0.16666667]] >>> print(numerix.allclose(triAddedMesh.cellCenters, ... cellCenters)) True
again, their faces need not align, but the mesh may not have the desired connectivity
>>> triMesh = Tri2D(dx = 1.0, dy = 2.0, nx = 2, ny = 1) >>> triMesh = triMesh + ((2,), (0,)) >>> triAddedMesh = baseMesh + triMesh >>> cellCenters = [[ 0.5, 1.5, 0.5, 1.5, 2.83333333, 3.83333333, ... 2.5, 3.5, 2.16666667, 3.16666667, 2.5, 3.5], ... [ 0.5, 0.5, 1.5, 1.5, 1., 1., ... 1.66666667, 1.66666667, 1., 1., 0.33333333, 0.33333333]] >>> print(numerix.allclose(triAddedMesh.cellCenters, ... cellCenters)) True
Mesh concatenation is not limited to 2D meshes
>>> from fipy.meshes import Grid3D >>> threeDBaseMesh = Grid3D(dx = 1.0, dy = 1.0, dz = 1.0, ... nx = 2, ny = 2, nz = 2) >>> threeDSecondMesh = Grid3D(dx = 1.0, dy = 1.0, dz = 1.0, ... nx = 1, ny = 1, nz = 1) >>> threeDAddedMesh = threeDBaseMesh + (threeDSecondMesh + ((2,), (0,), (0,))) >>> print(threeDAddedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 0.5 1.5 0.5 1.5 2.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5 0.5] [ 0.5 0.5 0.5 0.5 1.5 1.5 1.5 1.5 0.5]]
but the different Mesh objects must, of course, have the same dimensionality.
>>> InvalidMesh = threeDBaseMesh + baseMesh Traceback (most recent call last): ... MeshAdditionError: Dimensions do not match
- __repr__()¶
Return repr(self).
- __rmul__(factor)¶
Dilate a Mesh by factor.
>>> from fipy.meshes import Grid2D >>> baseMesh = Grid2D(dx = 1.0, dy = 1.0, nx = 2, ny = 2) >>> print(baseMesh.cellCenters) [[ 0.5 1.5 0.5 1.5] [ 0.5 0.5 1.5 1.5]]
The factor can be a scalar
>>> dilatedMesh = baseMesh * 3 >>> print(dilatedMesh.cellCenters) [[ 1.5 4.5 1.5 4.5] [ 1.5 1.5 4.5 4.5]]
or a vector
>>> dilatedMesh = baseMesh * ((3,), (2,)) >>> print(dilatedMesh.cellCenters) [[ 1.5 4.5 1.5 4.5] [ 1. 1. 3. 3. ]]
but the vector must have the same dimensionality as the Mesh
>>> dilatedMesh = baseMesh * ((3,), (2,), (1,)) Traceback (most recent call last): ... ValueError: shape mismatch: objects cannot be broadcast to a single shape
- __setstate__(state)¶
- __sub__(other)¶
Tests. >>> from fipy import * >>> m = Grid1D() >>> print((m - ((1,))).cellCenters) [[-0.5]] >>> ((1,)) - m Traceback (most recent call last): … TypeError: unsupported operand type(s) for -: ‘tuple’ and ‘UniformGrid1D’
- __truediv__(other)¶
Tests. >>> from fipy import * >>> print((Grid1D(nx=1) / 2.).cellCenters) [[ 0.25]] >>> AbstractMesh(communicator=None) / 2. Traceback (most recent call last): … NotImplementedError
- property aspect2D¶
The physical y vs x aspect ratio of a 2D mesh
- property cellCenters¶
- property cellDistanceVectors¶
- property cellFaceIDs¶
- property cellToFaceDistanceVectors¶
- property cellVolumes¶
- property extents¶
- property exteriorFaces¶
- extrude(extrudeFunc=<function Mesh2D.<lambda>>, layers=1)¶
This function returns a new 3D mesh. The 2D mesh is extruded using the extrudeFunc and the number of layers.
>>> from fipy.meshes.nonUniformGrid2D import NonUniformGrid2D >>> print(NonUniformGrid2D(nx=2, ny=2).extrude(layers=2).cellCenters) [[ 0.5 1.5 0.5 1.5 0.5 1.5 0.5 1.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5] [ 0.5 0.5 0.5 0.5 1.5 1.5 1.5 1.5]]
>>> from fipy.meshes.tri2D import Tri2D >>> print(Tri2D().extrude(layers=2).cellCenters.allclose([[ 0.83333333, 0.5, 0.16666667, 0.5, 0.83333333, 0.5, ... 0.16666667, 0.5 ], ... [ 0.5, 0.83333333, 0.5, 0.16666667, 0.5, 0.83333333, ... 0.5, 0.16666667], ... [ 0.5, 0.5, 0.5, 0.5, 1.5, 1.5, 1.5, ... 1.5 ]])) True
- Parameters:
extrudeFunc (function) – Takes the vertex coordinates and returns the displaced values
layers (int) – Number of layers in the extruded mesh (number of times extrudeFunc will be called)
- property faceCenters¶
- property facesBack¶
Return list of faces on back boundary of 3D Mesh with the z-axis running from front to back.
>>> from fipy import Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((6, 7, 8, 9, 10, 11), ... numerix.nonzero(mesh.facesBack)[0])) True >>> ignore = mesh.facesBack.value
- property facesBottom¶
Return list of faces on bottom boundary of 2D or 3D Mesh with the y-axis running from bottom to top.
>>> from fipy import Grid2D, Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((12, 13, 14), ... numerix.nonzero(mesh.facesBottom)[0])) True >>> ignore = mesh.facesBottom.value >>> x, y, z = mesh.faceCenters >>> print(numerix.allequal((12, 13), ... numerix.nonzero(mesh.facesBottom & (x < 1))[0])) True >>> ignore = mesh.facesBottom.value
- property facesDown¶
Return list of faces on bottom boundary of 2D or 3D Mesh with the y-axis running from bottom to top.
>>> from fipy import Grid2D, Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((12, 13, 14), ... numerix.nonzero(mesh.facesBottom)[0])) True >>> ignore = mesh.facesBottom.value >>> x, y, z = mesh.faceCenters >>> print(numerix.allequal((12, 13), ... numerix.nonzero(mesh.facesBottom & (x < 1))[0])) True >>> ignore = mesh.facesBottom.value
- property facesFront¶
Return list of faces on front boundary of 3D Mesh with the z-axis running from front to back.
>>> from fipy import Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((0, 1, 2, 3, 4, 5), ... numerix.nonzero(mesh.facesFront)[0])) True >>> ignore = mesh.facesFront.value
- property facesLeft¶
Return face on left boundary of Mesh as list with the x-axis running from left to right.
>>> from fipy import Grid2D, Grid3D >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((21, 25), ... numerix.nonzero(mesh.facesLeft)[0])) True >>> ignore = mesh.facesLeft.value >>> mesh = Grid2D(nx = 3, ny = 2, dx = 0.5, dy = 2.) >>> print(numerix.allequal((9, 13), ... numerix.nonzero(mesh.facesLeft)[0])) True >>> ignore = mesh.facesLeft.value
- property facesRight¶
Return list of faces on right boundary of Mesh with the x-axis running from left to right.
>>> from fipy import Grid2D, Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((24, 28), ... numerix.nonzero(mesh.facesRight)[0])) True >>> ignore = mesh.facesRight.value >>> mesh = Grid2D(nx = 3, ny = 2, dx = 0.5, dy = 2.) >>> print(numerix.allequal((12, 16), ... numerix.nonzero(mesh.facesRight)[0])) True >>> ignore = mesh.facesRight.value
- property facesTop¶
Return list of faces on top boundary of 2D or 3D Mesh with the y-axis running from bottom to top.
>>> from fipy import Grid2D, Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((18, 19, 20), ... numerix.nonzero(mesh.facesTop)[0])) True >>> ignore = mesh.facesTop.value >>> mesh = Grid2D(nx = 3, ny = 2, dx = 0.5, dy = 2.) >>> print(numerix.allequal((6, 7, 8), ... numerix.nonzero(mesh.facesTop)[0])) True >>> ignore = mesh.facesTop.value
- property facesUp¶
Return list of faces on top boundary of 2D or 3D Mesh with the y-axis running from bottom to top.
>>> from fipy import Grid2D, Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((18, 19, 20), ... numerix.nonzero(mesh.facesTop)[0])) True >>> ignore = mesh.facesTop.value >>> mesh = Grid2D(nx = 3, ny = 2, dx = 0.5, dy = 2.) >>> print(numerix.allequal((6, 7, 8), ... numerix.nonzero(mesh.facesTop)[0])) True >>> ignore = mesh.facesTop.value
- getNearestCell(point)¶
- property interiorFaceCellIDs¶
- property interiorFaceIDs¶
- property interiorFaces¶
- property scale¶
- property scaledCellDistances¶
- property scaledCellToCellDistances¶
- property scaledCellVolumes¶
- property scaledFaceAreas¶
- property scaledFaceToCellDistances¶
- property x¶
Equivalent to using
cellCenters
[0]
.>>> from fipy import * >>> print(Grid1D(nx=2).x) [ 0.5 1.5]
- property y¶
Equivalent to using
cellCenters
[1]
.>>> from fipy import * >>> print(Grid2D(nx=2, ny=2).y) [ 0.5 0.5 1.5 1.5] >>> print(Grid1D(nx=2).y) Traceback (most recent call last): ... AttributeError: 1D meshes do not have a "y" attribute.
- property z¶
Equivalent to using
cellCenters
[2]
.>>> from fipy import * >>> print(Grid3D(nx=2, ny=2, nz=2).z) [ 0.5 0.5 0.5 0.5 1.5 1.5 1.5 1.5] >>> print(Grid2D(nx=2, ny=2).z) Traceback (most recent call last): ... AttributeError: 1D and 2D meshes do not have a "z" attribute.
- class fipy.GmshGrid3D(dx=1.0, dy=1.0, dz=1.0, nx=1, ny=None, nz=None, communicator=SerialPETScCommWrapper(), overlap=1)¶
Bases:
Gmsh3D
Should serve as a drop-in replacement for Grid3D
- property VTKCellDataSet¶
Returns a TVTK DataSet representing the cells of this mesh
- property VTKFaceDataSet¶
Returns a TVTK DataSet representing the face centers of this mesh
- __add__(other)¶
Either translate a Mesh or concatenate two Mesh objects.
>>> from fipy.meshes import Grid2D >>> baseMesh = Grid2D(dx = 1.0, dy = 1.0, nx = 2, ny = 2) >>> print(baseMesh.cellCenters) [[ 0.5 1.5 0.5 1.5] [ 0.5 0.5 1.5 1.5]]
If a vector is added to a Mesh, a translated Mesh is returned
>>> translatedMesh = baseMesh + ((5,), (10,)) >>> print(translatedMesh.cellCenters) [[ 5.5 6.5 5.5 6.5] [ 10.5 10.5 11.5 11.5]]
If a Mesh is added to a Mesh, a concatenation of the two Mesh objects is returned
>>> addedMesh = baseMesh + (baseMesh + ((2,), (0,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 2.5 3.5 2.5 3.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5]]
The two Mesh objects need not be properly aligned in order to concatenate them but the resulting mesh may not have the intended connectivity
>>> addedMesh = baseMesh + (baseMesh + ((3,), (0,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 3.5 4.5 3.5 4.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5]]
>>> addedMesh = baseMesh + (baseMesh + ((2,), (2,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 2.5 3.5 2.5 3.5] [ 0.5 0.5 1.5 1.5 2.5 2.5 3.5 3.5]]
No provision is made to avoid or consolidate overlapping Mesh objects
>>> addedMesh = baseMesh + (baseMesh + ((1,), (0,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 1.5 2.5 1.5 2.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5]]
Different Mesh classes can be concatenated
>>> from fipy.meshes import Tri2D >>> triMesh = Tri2D(dx = 1.0, dy = 1.0, nx = 2, ny = 1) >>> triMesh = triMesh + ((2,), (0,)) >>> triAddedMesh = baseMesh + triMesh >>> cellCenters = [[0.5, 1.5, 0.5, 1.5, 2.83333333, 3.83333333, ... 2.5, 3.5, 2.16666667, 3.16666667, 2.5, 3.5], ... [0.5, 0.5, 1.5, 1.5, 0.5, 0.5, 0.83333333, 0.83333333, ... 0.5, 0.5, 0.16666667, 0.16666667]] >>> print(numerix.allclose(triAddedMesh.cellCenters, ... cellCenters)) True
again, their faces need not align, but the mesh may not have the desired connectivity
>>> triMesh = Tri2D(dx = 1.0, dy = 2.0, nx = 2, ny = 1) >>> triMesh = triMesh + ((2,), (0,)) >>> triAddedMesh = baseMesh + triMesh >>> cellCenters = [[ 0.5, 1.5, 0.5, 1.5, 2.83333333, 3.83333333, ... 2.5, 3.5, 2.16666667, 3.16666667, 2.5, 3.5], ... [ 0.5, 0.5, 1.5, 1.5, 1., 1., ... 1.66666667, 1.66666667, 1., 1., 0.33333333, 0.33333333]] >>> print(numerix.allclose(triAddedMesh.cellCenters, ... cellCenters)) True
Mesh concatenation is not limited to 2D meshes
>>> from fipy.meshes import Grid3D >>> threeDBaseMesh = Grid3D(dx = 1.0, dy = 1.0, dz = 1.0, ... nx = 2, ny = 2, nz = 2) >>> threeDSecondMesh = Grid3D(dx = 1.0, dy = 1.0, dz = 1.0, ... nx = 1, ny = 1, nz = 1) >>> threeDAddedMesh = threeDBaseMesh + (threeDSecondMesh + ((2,), (0,), (0,))) >>> print(threeDAddedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 0.5 1.5 0.5 1.5 2.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5 0.5] [ 0.5 0.5 0.5 0.5 1.5 1.5 1.5 1.5 0.5]]
but the different Mesh objects must, of course, have the same dimensionality.
>>> InvalidMesh = threeDBaseMesh + baseMesh Traceback (most recent call last): ... MeshAdditionError: Dimensions do not match
- __div__(other)¶
Tests. >>> from fipy import * >>> print((Grid1D(nx=1) / 2.).cellCenters) [[ 0.25]] >>> AbstractMesh(communicator=None) / 2. Traceback (most recent call last): … NotImplementedError
- __getstate__()¶
Helper for pickle.
- __mul__(factor)¶
Dilate a Mesh by factor.
>>> from fipy.meshes import Grid2D >>> baseMesh = Grid2D(dx = 1.0, dy = 1.0, nx = 2, ny = 2) >>> print(baseMesh.cellCenters) [[ 0.5 1.5 0.5 1.5] [ 0.5 0.5 1.5 1.5]]
The factor can be a scalar
>>> dilatedMesh = baseMesh * 3 >>> print(dilatedMesh.cellCenters) [[ 1.5 4.5 1.5 4.5] [ 1.5 1.5 4.5 4.5]]
or a vector
>>> dilatedMesh = baseMesh * ((3,), (2,)) >>> print(dilatedMesh.cellCenters) [[ 1.5 4.5 1.5 4.5] [ 1. 1. 3. 3. ]]
but the vector must have the same dimensionality as the Mesh
>>> dilatedMesh = baseMesh * ((3,), (2,), (1,)) Traceback (most recent call last): ... ValueError: shape mismatch: objects cannot be broadcast to a single shape
- __radd__(other)¶
Either translate a Mesh or concatenate two Mesh objects.
>>> from fipy.meshes import Grid2D >>> baseMesh = Grid2D(dx = 1.0, dy = 1.0, nx = 2, ny = 2) >>> print(baseMesh.cellCenters) [[ 0.5 1.5 0.5 1.5] [ 0.5 0.5 1.5 1.5]]
If a vector is added to a Mesh, a translated Mesh is returned
>>> translatedMesh = baseMesh + ((5,), (10,)) >>> print(translatedMesh.cellCenters) [[ 5.5 6.5 5.5 6.5] [ 10.5 10.5 11.5 11.5]]
If a Mesh is added to a Mesh, a concatenation of the two Mesh objects is returned
>>> addedMesh = baseMesh + (baseMesh + ((2,), (0,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 2.5 3.5 2.5 3.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5]]
The two Mesh objects need not be properly aligned in order to concatenate them but the resulting mesh may not have the intended connectivity
>>> addedMesh = baseMesh + (baseMesh + ((3,), (0,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 3.5 4.5 3.5 4.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5]]
>>> addedMesh = baseMesh + (baseMesh + ((2,), (2,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 2.5 3.5 2.5 3.5] [ 0.5 0.5 1.5 1.5 2.5 2.5 3.5 3.5]]
No provision is made to avoid or consolidate overlapping Mesh objects
>>> addedMesh = baseMesh + (baseMesh + ((1,), (0,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 1.5 2.5 1.5 2.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5]]
Different Mesh classes can be concatenated
>>> from fipy.meshes import Tri2D >>> triMesh = Tri2D(dx = 1.0, dy = 1.0, nx = 2, ny = 1) >>> triMesh = triMesh + ((2,), (0,)) >>> triAddedMesh = baseMesh + triMesh >>> cellCenters = [[0.5, 1.5, 0.5, 1.5, 2.83333333, 3.83333333, ... 2.5, 3.5, 2.16666667, 3.16666667, 2.5, 3.5], ... [0.5, 0.5, 1.5, 1.5, 0.5, 0.5, 0.83333333, 0.83333333, ... 0.5, 0.5, 0.16666667, 0.16666667]] >>> print(numerix.allclose(triAddedMesh.cellCenters, ... cellCenters)) True
again, their faces need not align, but the mesh may not have the desired connectivity
>>> triMesh = Tri2D(dx = 1.0, dy = 2.0, nx = 2, ny = 1) >>> triMesh = triMesh + ((2,), (0,)) >>> triAddedMesh = baseMesh + triMesh >>> cellCenters = [[ 0.5, 1.5, 0.5, 1.5, 2.83333333, 3.83333333, ... 2.5, 3.5, 2.16666667, 3.16666667, 2.5, 3.5], ... [ 0.5, 0.5, 1.5, 1.5, 1., 1., ... 1.66666667, 1.66666667, 1., 1., 0.33333333, 0.33333333]] >>> print(numerix.allclose(triAddedMesh.cellCenters, ... cellCenters)) True
Mesh concatenation is not limited to 2D meshes
>>> from fipy.meshes import Grid3D >>> threeDBaseMesh = Grid3D(dx = 1.0, dy = 1.0, dz = 1.0, ... nx = 2, ny = 2, nz = 2) >>> threeDSecondMesh = Grid3D(dx = 1.0, dy = 1.0, dz = 1.0, ... nx = 1, ny = 1, nz = 1) >>> threeDAddedMesh = threeDBaseMesh + (threeDSecondMesh + ((2,), (0,), (0,))) >>> print(threeDAddedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 0.5 1.5 0.5 1.5 2.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5 0.5] [ 0.5 0.5 0.5 0.5 1.5 1.5 1.5 1.5 0.5]]
but the different Mesh objects must, of course, have the same dimensionality.
>>> InvalidMesh = threeDBaseMesh + baseMesh Traceback (most recent call last): ... MeshAdditionError: Dimensions do not match
- __repr__()¶
Return repr(self).
- __rmul__(factor)¶
Dilate a Mesh by factor.
>>> from fipy.meshes import Grid2D >>> baseMesh = Grid2D(dx = 1.0, dy = 1.0, nx = 2, ny = 2) >>> print(baseMesh.cellCenters) [[ 0.5 1.5 0.5 1.5] [ 0.5 0.5 1.5 1.5]]
The factor can be a scalar
>>> dilatedMesh = baseMesh * 3 >>> print(dilatedMesh.cellCenters) [[ 1.5 4.5 1.5 4.5] [ 1.5 1.5 4.5 4.5]]
or a vector
>>> dilatedMesh = baseMesh * ((3,), (2,)) >>> print(dilatedMesh.cellCenters) [[ 1.5 4.5 1.5 4.5] [ 1. 1. 3. 3. ]]
but the vector must have the same dimensionality as the Mesh
>>> dilatedMesh = baseMesh * ((3,), (2,), (1,)) Traceback (most recent call last): ... ValueError: shape mismatch: objects cannot be broadcast to a single shape
- __setstate__(state)¶
- __sub__(other)¶
Tests. >>> from fipy import * >>> m = Grid1D() >>> print((m - ((1,))).cellCenters) [[-0.5]] >>> ((1,)) - m Traceback (most recent call last): … TypeError: unsupported operand type(s) for -: ‘tuple’ and ‘UniformGrid1D’
- __truediv__(other)¶
Tests. >>> from fipy import * >>> print((Grid1D(nx=1) / 2.).cellCenters) [[ 0.25]] >>> AbstractMesh(communicator=None) / 2. Traceback (most recent call last): … NotImplementedError
- property aspect2D¶
The physical y vs x aspect ratio of a 2D mesh
- property cellCenters¶
- property cellDistanceVectors¶
- property cellFaceIDs¶
- property cellToFaceDistanceVectors¶
- property cellVolumes¶
- property extents¶
- property exteriorFaces¶
- property faceCenters¶
- property facesBack¶
Return list of faces on back boundary of 3D Mesh with the z-axis running from front to back.
>>> from fipy import Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((6, 7, 8, 9, 10, 11), ... numerix.nonzero(mesh.facesBack)[0])) True >>> ignore = mesh.facesBack.value
- property facesBottom¶
Return list of faces on bottom boundary of 2D or 3D Mesh with the y-axis running from bottom to top.
>>> from fipy import Grid2D, Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((12, 13, 14), ... numerix.nonzero(mesh.facesBottom)[0])) True >>> ignore = mesh.facesBottom.value >>> x, y, z = mesh.faceCenters >>> print(numerix.allequal((12, 13), ... numerix.nonzero(mesh.facesBottom & (x < 1))[0])) True >>> ignore = mesh.facesBottom.value
- property facesDown¶
Return list of faces on bottom boundary of 2D or 3D Mesh with the y-axis running from bottom to top.
>>> from fipy import Grid2D, Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((12, 13, 14), ... numerix.nonzero(mesh.facesBottom)[0])) True >>> ignore = mesh.facesBottom.value >>> x, y, z = mesh.faceCenters >>> print(numerix.allequal((12, 13), ... numerix.nonzero(mesh.facesBottom & (x < 1))[0])) True >>> ignore = mesh.facesBottom.value
- property facesFront¶
Return list of faces on front boundary of 3D Mesh with the z-axis running from front to back.
>>> from fipy import Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((0, 1, 2, 3, 4, 5), ... numerix.nonzero(mesh.facesFront)[0])) True >>> ignore = mesh.facesFront.value
- property facesLeft¶
Return face on left boundary of Mesh as list with the x-axis running from left to right.
>>> from fipy import Grid2D, Grid3D >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((21, 25), ... numerix.nonzero(mesh.facesLeft)[0])) True >>> ignore = mesh.facesLeft.value >>> mesh = Grid2D(nx = 3, ny = 2, dx = 0.5, dy = 2.) >>> print(numerix.allequal((9, 13), ... numerix.nonzero(mesh.facesLeft)[0])) True >>> ignore = mesh.facesLeft.value
- property facesRight¶
Return list of faces on right boundary of Mesh with the x-axis running from left to right.
>>> from fipy import Grid2D, Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((24, 28), ... numerix.nonzero(mesh.facesRight)[0])) True >>> ignore = mesh.facesRight.value >>> mesh = Grid2D(nx = 3, ny = 2, dx = 0.5, dy = 2.) >>> print(numerix.allequal((12, 16), ... numerix.nonzero(mesh.facesRight)[0])) True >>> ignore = mesh.facesRight.value
- property facesTop¶
Return list of faces on top boundary of 2D or 3D Mesh with the y-axis running from bottom to top.
>>> from fipy import Grid2D, Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((18, 19, 20), ... numerix.nonzero(mesh.facesTop)[0])) True >>> ignore = mesh.facesTop.value >>> mesh = Grid2D(nx = 3, ny = 2, dx = 0.5, dy = 2.) >>> print(numerix.allequal((6, 7, 8), ... numerix.nonzero(mesh.facesTop)[0])) True >>> ignore = mesh.facesTop.value
- property facesUp¶
Return list of faces on top boundary of 2D or 3D Mesh with the y-axis running from bottom to top.
>>> from fipy import Grid2D, Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((18, 19, 20), ... numerix.nonzero(mesh.facesTop)[0])) True >>> ignore = mesh.facesTop.value >>> mesh = Grid2D(nx = 3, ny = 2, dx = 0.5, dy = 2.) >>> print(numerix.allequal((6, 7, 8), ... numerix.nonzero(mesh.facesTop)[0])) True >>> ignore = mesh.facesTop.value
- getNearestCell(point)¶
- property interiorFaceCellIDs¶
- property interiorFaceIDs¶
- property interiorFaces¶
- property scale¶
- property scaledCellDistances¶
- property scaledCellToCellDistances¶
- property scaledCellVolumes¶
- property scaledFaceAreas¶
- property scaledFaceToCellDistances¶
- property x¶
Equivalent to using
cellCenters
[0]
.>>> from fipy import * >>> print(Grid1D(nx=2).x) [ 0.5 1.5]
- property y¶
Equivalent to using
cellCenters
[1]
.>>> from fipy import * >>> print(Grid2D(nx=2, ny=2).y) [ 0.5 0.5 1.5 1.5] >>> print(Grid1D(nx=2).y) Traceback (most recent call last): ... AttributeError: 1D meshes do not have a "y" attribute.
- property z¶
Equivalent to using
cellCenters
[2]
.>>> from fipy import * >>> print(Grid3D(nx=2, ny=2, nz=2).z) [ 0.5 0.5 0.5 0.5 1.5 1.5 1.5 1.5] >>> print(Grid2D(nx=2, ny=2).z) Traceback (most recent call last): ... AttributeError: 1D and 2D meshes do not have a "z" attribute.
- fipy.Grid1D(dx=1.0, nx=None, Lx=None, overlap=2, communicator=SerialPETScCommWrapper())¶
Create a 1D Cartesian mesh
Factory function to select between
UniformGrid1D
andNonUniformGrid1D
. If Lx is specified the length of the domain is always Lx regardless of dx, unless dx is a list of spacings, in which case Lx will be the sum of dx and nx will be the count of dx.- Parameters:
dx (float) – Grid spacing in the horizontal direction
nx (int) – Number of cells in the horizontal direction
Lx (float) – Domain length in the horizontal direction
overlap (int) – Number of overlapping cells for parallel simulations. Generally 2 is adequate. Higher order equations or discretizations require more.
communicator (CommWrapper) – MPI communicator to use. Select
serialComm
to create a serial mesh when running in parallel; mostly used for test purposes. (default:parallelComm
).
- fipy.Grid2D(dx=1.0, dy=1.0, nx=None, ny=None, Lx=None, Ly=None, overlap=2, communicator=SerialPETScCommWrapper())¶
Create a 2D Cartesian mesh
Factory function to select between
UniformGrid2D
andNonUniformGrid2D
. If L{x,y} is specified, the length of the domain is always L{x,y} regardless of d{x,y}, unless d{x,y} is a list of spacings, in which case L{x,y} will be the sum of d{x,y} and n{x,y} will be the count of d{x,y}.>>> print(Grid2D(Lx=3., nx=2).dx) 1.5
- Parameters:
dx (float) – Grid spacing in the horizontal direction
dy (float) – Grid spacing in the vertical direction
nx (int) – Number of cells in the horizontal direction
ny (int) – Number of cells in the vertical direction
Lx (float) – Domain length in the horizontal direction
Ly (float) – Domain length in the vertical direction
overlap (int) – Number of overlapping cells for parallel simulations. Generally 2 is adequate. Higher order equations or discretizations require more.
communicator (CommWrapper) – MPI communicator to use. Select
serialComm
to create a serial mesh when running in parallel; mostly used for test purposes. (default:parallelComm
).
- fipy.Grid3D(dx=1.0, dy=1.0, dz=1.0, nx=None, ny=None, nz=None, Lx=None, Ly=None, Lz=None, overlap=2, communicator=SerialPETScCommWrapper())¶
Create a 3D Cartesian mesh
Factory function to select between
UniformGrid3D
andNonUniformGrid3D
. If L{x,y,z} is specified, the length of the domain is always L{x,y,z} regardless of d{x,y,z}, unless d{x,y,z} is a list of spacings, in which case L{x,y,z} will be the sum of d{x,y,z} and n{x,y,z} will be the count of d{x,y,z}.- Parameters:
dx (float) – Grid spacing in the horizontal direction
dy (float) – Grid spacing in the vertical direction
dz (float) – Grid spacing in the depth direction
nx (int) – Number of cells in the horizontal direction
ny (int) – Number of cells in the vertical direction
nz (int) – Number of cells in the depth direction
Lx (float) – Domain length in the horizontal direction
Ly (float) – Domain length in the vertical direction
Lz (float) – Domain length in the depth direction
overlap (int) – Number of overlapping cells for parallel simulations. Generally 2 is adequate. Higher order equations or discretizations require more.
communicator (CommWrapper) – MPI communicator to use. Select
serialComm
to create a serial mesh when running in parallel; mostly used for test purposes. (default:parallelComm
).
- class fipy.HistogramVariable(*args, **kwds)¶
Bases:
CellVariable
Produces a histogram of the values of the supplied distribution.
- Parameters:
- __abs__()¶
Following test it to fix a bug with C inline string using abs() instead of fabs()
>>> print(abs(Variable(2.3) - Variable(1.2))) 1.1
Check representation works with different versions of numpy
>>> print(repr(abs(Variable(2.3)))) numerix.fabs(Variable(value=array(2.3)))
- __add__(other)¶
- __and__(other)¶
This test case has been added due to a weird bug that was appearing.
>>> a = Variable(value=(0, 0, 1, 1)) >>> b = Variable(value=(0, 1, 0, 1)) >>> print(numerix.equal((a == 0) & (b == 1), [False, True, False, False]).all()) True >>> print(a & b) [0 0 0 1] >>> from fipy.meshes import Grid1D >>> mesh = Grid1D(nx=4) >>> from fipy.variables.cellVariable import CellVariable >>> a = CellVariable(value=(0, 0, 1, 1), mesh=mesh) >>> b = CellVariable(value=(0, 1, 0, 1), mesh=mesh) >>> print(numerix.allequal((a == 0) & (b == 1), [False, True, False, False])) True >>> print(a & b) [0 0 0 1]
- __array__(t=None)¶
Attempt to convert the Variable to a numerix array object
>>> v = Variable(value=[2, 3]) >>> print(numerix.array(v)) [2 3]
A dimensional Variable will convert to the numeric value in its base units
>>> v = Variable(value=[2, 3], unit="mm") >>> numerix.array(v) array([ 0.002, 0.003])
- __array_priority__ = 100.0¶
- __array_wrap__(arr, context=None)¶
Required to prevent numpy not calling the reverse binary operations. Both the following tests are examples ufuncs.
>>> print(type(numerix.array([1.0, 2.0]) * Variable([1.0, 2.0]))) <class 'fipy.variables.binaryOperatorVariable...binOp'>
>>> from scipy.special import gamma as Gamma >>> print(type(Gamma(Variable([1.0, 2.0])))) <class 'fipy.variables.unaryOperatorVariable...unOp'>
- __bool__()¶
>>> print(bool(Variable(value=0))) 0 >>> print(bool(Variable(value=(0, 0, 1, 1)))) Traceback (most recent call last): ... ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
- __call__(points=None, order=0, nearestCellIDs=None)¶
Interpolates the CellVariable to a set of points using a method that has a memory requirement on the order of Ncells by Npoints in general, but uses only Ncells when the CellVariable’s mesh is a UniformGrid object.
Tests
>>> from fipy import * >>> m = Grid2D(nx=3, ny=2) >>> v = CellVariable(mesh=m, value=m.cellCenters[0]) >>> print(v(((0., 1.1, 1.2), (0., 1., 1.)))) [ 0.5 1.5 1.5] >>> print(v(((0., 1.1, 1.2), (0., 1., 1.)), order=1)) [ 0.25 1.1 1.2 ] >>> m0 = Grid2D(nx=2, ny=2, dx=1., dy=1.) >>> m1 = Grid2D(nx=4, ny=4, dx=.5, dy=.5) >>> x, y = m0.cellCenters >>> v0 = CellVariable(mesh=m0, value=x * y) >>> print(v0(m1.cellCenters.globalValue)) [ 0.25 0.25 0.75 0.75 0.25 0.25 0.75 0.75 0.75 0.75 2.25 2.25 0.75 0.75 2.25 2.25] >>> print(v0(m1.cellCenters.globalValue, order=1)) [ 0.125 0.25 0.5 0.625 0.25 0.375 0.875 1. 0.5 0.875 1.875 2.25 0.625 1. 2.25 2.625]
- __div__(other)¶
- __eq__(other)¶
Test if a Variable is equal to another quantity
>>> a = Variable(value=3) >>> b = (a == 4) >>> b (Variable(value=array(3)) == 4) >>> b() 0
- __float__()¶
- __ge__(other)¶
Test if a Variable is greater than or equal to another quantity
>>> a = Variable(value=3) >>> b = (a >= 4) >>> b (Variable(value=array(3)) >= 4) >>> b() 0 >>> a.value = 4 >>> print(b()) 1 >>> a.value = 5 >>> print(b()) 1
- __getitem__(index)¶
“Evaluate” the Variable and return the specified element
>>> a = Variable(value=((3., 4.), (5., 6.)), unit="m") + "4 m" >>> print(a[1, 1]) 10.0 m
It is an error to slice a Variable whose value is not sliceable
>>> Variable(value=3)[2] Traceback (most recent call last): ... IndexError: 0-d arrays can't be indexed
- __getstate__()¶
Used internally to collect the necessary information to
pickle
the CellVariable to persistent storage.
- __gt__(other)¶
Test if a Variable is greater than another quantity
>>> a = Variable(value=3) >>> b = (a > 4) >>> b (Variable(value=array(3)) > 4) >>> print(b()) 0 >>> a.value = 5 >>> print(b()) 1
- __hash__()¶
Return hash(self).
- __int__()¶
- __invert__()¶
Returns logical “not” of the Variable
>>> a = Variable(value=True) >>> print(~a) False
- __iter__()¶
- __le__(other)¶
Test if a Variable is less than or equal to another quantity
>>> a = Variable(value=3) >>> b = (a <= 4) >>> b (Variable(value=array(3)) <= 4) >>> b() 1 >>> a.value = 4 >>> print(b()) 1 >>> a.value = 5 >>> print(b()) 0
- __len__()¶
- __lt__(other)¶
Test if a Variable is less than another quantity
>>> a = Variable(value=3) >>> b = (a < 4) >>> b (Variable(value=array(3)) < 4) >>> b() 1 >>> a.value = 4 >>> print(b()) 0 >>> print(1000000000000000000 * Variable(1) < 1.) 0 >>> print(1000 * Variable(1) < 1.) 0
Python automatically reverses the arguments when necessary
>>> 4 > Variable(value=3) (Variable(value=array(3)) < 4)
- __mod__(other)¶
- __mul__(other)¶
- __ne__(other)¶
Test if a Variable is not equal to another quantity
>>> a = Variable(value=3) >>> b = (a != 4) >>> b (Variable(value=array(3)) != 4) >>> b() 1
- __neg__()¶
- static __new__(cls, *args, **kwds)¶
- __nonzero__()¶
>>> print(bool(Variable(value=0))) 0 >>> print(bool(Variable(value=(0, 0, 1, 1)))) Traceback (most recent call last): ... ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
- __or__(other)¶
This test case has been added due to a weird bug that was appearing.
>>> a = Variable(value=(0, 0, 1, 1)) >>> b = Variable(value=(0, 1, 0, 1)) >>> print(numerix.equal((a == 0) | (b == 1), [True, True, False, True]).all()) True >>> print(a | b) [0 1 1 1] >>> from fipy.meshes import Grid1D >>> mesh = Grid1D(nx=4) >>> from fipy.variables.cellVariable import CellVariable >>> a = CellVariable(value=(0, 0, 1, 1), mesh=mesh) >>> b = CellVariable(value=(0, 1, 0, 1), mesh=mesh) >>> print(numerix.allequal((a == 0) | (b == 1), [True, True, False, True])) True >>> print(a | b) [0 1 1 1]
- __pos__()¶
- __pow__(other)¶
return self**other, or self raised to power other
>>> print(Variable(1, "mol/l")**3) 1.0 mol**3/l**3 >>> print((Variable(1, "mol/l")**3).unit) <PhysicalUnit mol**3/l**3>
- __radd__(other)¶
- __rdiv__(other)¶
- __repr__()¶
Return repr(self).
- __rmul__(other)¶
- __rpow__(other)¶
- __rsub__(other)¶
- __rtruediv__(other)¶
- __setitem__(index, value)¶
- __setstate__(dict)¶
Used internally to create a new CellVariable from
pickled
persistent storage.
- __str__()¶
Return str(self).
- __sub__(other)¶
- __truediv__(other)¶
- all(axis=None)¶
>>> print(Variable(value=(0, 0, 1, 1)).all()) 0 >>> print(Variable(value=(1, 1, 1, 1)).all()) 1
- allclose(other, rtol=1e-05, atol=1e-08)¶
>>> var = Variable((1, 1)) >>> print(var.allclose((1, 1))) 1 >>> print(var.allclose((1,))) 1
The following test is to check that the system does not run out of memory.
>>> from fipy.tools import numerix >>> var = Variable(numerix.ones(10000)) >>> print(var.allclose(numerix.zeros(10000, 'l'))) False
- allequal(other)¶
- any(axis=None)¶
>>> print(Variable(value=0).any()) 0 >>> print(Variable(value=(0, 0, 1, 1)).any()) 1
- property arithmeticFaceValue¶
Returns a FaceVariable whose value corresponds to the arithmetic interpolation of the adjacent cells:
>>> from fipy.meshes import Grid1D >>> from fipy import numerix >>> mesh = Grid1D(dx = (1., 1.)) >>> L = 1 >>> R = 2 >>> var = CellVariable(mesh = mesh, value = (L, R)) >>> faceValue = var.arithmeticFaceValue[mesh.interiorFaces.value] >>> answer = (R - L) * (0.5 / 1.) + L >>> print(numerix.allclose(faceValue, answer, atol = 1e-10, rtol = 1e-10)) True
>>> mesh = Grid1D(dx = (2., 4.)) >>> var = CellVariable(mesh = mesh, value = (L, R)) >>> faceValue = var.arithmeticFaceValue[mesh.interiorFaces.value] >>> answer = (R - L) * (1.0 / 3.0) + L >>> print(numerix.allclose(faceValue, answer, atol = 1e-10, rtol = 1e-10)) True
>>> mesh = Grid1D(dx = (10., 100.)) >>> var = CellVariable(mesh = mesh, value = (L, R)) >>> faceValue = var.arithmeticFaceValue[mesh.interiorFaces.value] >>> answer = (R - L) * (5.0 / 55.0) + L >>> print(numerix.allclose(faceValue, answer, atol = 1e-10, rtol = 1e-10)) True
- cacheMe(recursive=False)¶
- property cellVolumeAverage¶
Return the cell-volume-weighted average of the CellVariable:
>>> from fipy.meshes import Grid2D >>> from fipy.variables.cellVariable import CellVariable >>> mesh = Grid2D(nx = 3, ny = 1, dx = .5, dy = .1) >>> var = CellVariable(value = (1, 2, 6), mesh = mesh) >>> print(var.cellVolumeAverage) 3.0
- constrain(value, where=None)¶
Constrains the CellVariable to value at a location specified by where.
>>> from fipy import * >>> m = Grid1D(nx=3) >>> v = CellVariable(mesh=m, value=m.cellCenters[0]) >>> v.constrain(0., where=m.facesLeft) >>> v.faceGrad.constrain([1.], where=m.facesRight) >>> print(v.faceGrad) [[ 1. 1. 1. 1.]] >>> print(v.faceValue) [ 0. 1. 2. 2.5]
Changing the constraint changes the dependencies
>>> v.constrain(1., where=m.facesLeft) >>> print(v.faceGrad) [[-1. 1. 1. 1.]] >>> print(v.faceValue) [ 1. 1. 2. 2.5]
Constraints can be Variable
>>> c = Variable(0.) >>> v.constrain(c, where=m.facesLeft) >>> print(v.faceGrad) [[ 1. 1. 1. 1.]] >>> print(v.faceValue) [ 0. 1. 2. 2.5] >>> c.value = 1. >>> print(v.faceGrad) [[-1. 1. 1. 1.]] >>> print(v.faceValue) [ 1. 1. 2. 2.5]
Constraints can have a Variable mask.
>>> v = CellVariable(mesh=m) >>> mask = FaceVariable(mesh=m, value=m.facesLeft) >>> v.constrain(1., where=mask) >>> print(v.faceValue) [ 1. 0. 0. 0.] >>> mask[:] = mask | m.facesRight >>> print(v.faceValue) [ 1. 0. 0. 1.]
- property constraintMask¶
Test that constraintMask returns a Variable that updates itself whenever the constraints change.
>>> from fipy import *
>>> m = Grid2D(nx=2, ny=2) >>> x, y = m.cellCenters >>> v0 = CellVariable(mesh=m) >>> v0.constrain(1., where=m.facesLeft) >>> print(v0.faceValue.constraintMask) [False False False False False False True False False True False False] >>> print(v0.faceValue) [ 0. 0. 0. 0. 0. 0. 1. 0. 0. 1. 0. 0.] >>> v0.constrain(3., where=m.facesRight) >>> print(v0.faceValue.constraintMask) [False False False False False False True False True True False True] >>> print(v0.faceValue) [ 0. 0. 0. 0. 0. 0. 1. 0. 3. 1. 0. 3.] >>> v1 = CellVariable(mesh=m) >>> v1.constrain(1., where=(x < 1) & (y < 1)) >>> print(v1.constraintMask) [ True False False False] >>> print(v1) [ 1. 0. 0. 0.] >>> v1.constrain(3., where=(x > 1) & (y > 1)) >>> print(v1.constraintMask) [ True False False True] >>> print(v1) [ 1. 0. 0. 3.]
- property constraints¶
- copy()¶
Make an duplicate of the Variable
>>> a = Variable(value=3) >>> b = a.copy() >>> b Variable(value=array(3))
The duplicate will not reflect changes made to the original
>>> a.setValue(5) >>> b Variable(value=array(3))
Check that this works for arrays.
>>> a = Variable(value=numerix.array((0, 1, 2))) >>> b = a.copy() >>> b Variable(value=array([0, 1, 2])) >>> a[1] = 3 >>> b Variable(value=array([0, 1, 2]))
- dontCacheMe(recursive=False)¶
- dot(other, opShape=None, operatorClass=None)¶
Return the mesh-element–by–mesh-element (cell-by-cell, face-by-face, etc.) scalar product
Both self and other can be of arbitrary rank, and other does not need to be a _MeshVariable.
- property faceGrad¶
Return
as a rank-1 FaceVariable using differencing for the normal direction(second-order gradient).
- property faceGradAverage¶
Deprecated since version 3.3: use
grad.arithmeticFaceValue()
insteadReturn
as a rank-1 FaceVariable using averaging for the normal direction(second-order gradient)
- property faceValue¶
Returns a FaceVariable whose value corresponds to the arithmetic interpolation of the adjacent cells:
>>> from fipy.meshes import Grid1D >>> from fipy import numerix >>> mesh = Grid1D(dx = (1., 1.)) >>> L = 1 >>> R = 2 >>> var = CellVariable(mesh = mesh, value = (L, R)) >>> faceValue = var.arithmeticFaceValue[mesh.interiorFaces.value] >>> answer = (R - L) * (0.5 / 1.) + L >>> print(numerix.allclose(faceValue, answer, atol = 1e-10, rtol = 1e-10)) True
>>> mesh = Grid1D(dx = (2., 4.)) >>> var = CellVariable(mesh = mesh, value = (L, R)) >>> faceValue = var.arithmeticFaceValue[mesh.interiorFaces.value] >>> answer = (R - L) * (1.0 / 3.0) + L >>> print(numerix.allclose(faceValue, answer, atol = 1e-10, rtol = 1e-10)) True
>>> mesh = Grid1D(dx = (10., 100.)) >>> var = CellVariable(mesh = mesh, value = (L, R)) >>> faceValue = var.arithmeticFaceValue[mesh.interiorFaces.value] >>> answer = (R - L) * (5.0 / 55.0) + L >>> print(numerix.allclose(faceValue, answer, atol = 1e-10, rtol = 1e-10)) True
- property gaussGrad¶
Return
as a rank-1 CellVariable (first-order gradient).
- getsctype(default=None)¶
Returns the Numpy sctype of the underlying array.
>>> Variable(1).getsctype() == numerix.NUMERIX.obj2sctype(numerix.array(1)) True >>> Variable(1.).getsctype() == numerix.NUMERIX.obj2sctype(numerix.array(1.)) True >>> Variable((1, 1.)).getsctype() == numerix.NUMERIX.obj2sctype(numerix.array((1., 1.))) True
- property globalValue¶
Concatenate and return values from all processors
When running on a single processor, the result is identical to
value
.
- property grad¶
Return
as a rank-1 CellVariable (first-order gradient).
- property harmonicFaceValue¶
Returns a FaceVariable whose value corresponds to the harmonic interpolation of the adjacent cells:
>>> from fipy.meshes import Grid1D >>> from fipy import numerix >>> mesh = Grid1D(dx = (1., 1.)) >>> L = 1 >>> R = 2 >>> var = CellVariable(mesh = mesh, value = (L, R)) >>> faceValue = var.harmonicFaceValue[mesh.interiorFaces.value] >>> answer = L * R / ((R - L) * (0.5 / 1.) + L) >>> print(numerix.allclose(faceValue, answer, atol = 1e-10, rtol = 1e-10)) True
>>> mesh = Grid1D(dx = (2., 4.)) >>> var = CellVariable(mesh = mesh, value = (L, R)) >>> faceValue = var.harmonicFaceValue[mesh.interiorFaces.value] >>> answer = L * R / ((R - L) * (1.0 / 3.0) + L) >>> print(numerix.allclose(faceValue, answer, atol = 1e-10, rtol = 1e-10)) True
>>> mesh = Grid1D(dx = (10., 100.)) >>> var = CellVariable(mesh = mesh, value = (L, R)) >>> faceValue = var.harmonicFaceValue[mesh.interiorFaces.value] >>> answer = L * R / ((R - L) * (5.0 / 55.0) + L) >>> print(numerix.allclose(faceValue, answer, atol = 1e-10, rtol = 1e-10)) True
- inBaseUnits()¶
Return the value of the Variable with all units reduced to their base SI elements.
>>> e = Variable(value="2.7 Hartree*Nav") >>> print(e.inBaseUnits().allclose("7088849.01085 kg*m**2/s**2/mol")) 1
- inUnitsOf(*units)¶
Returns one or more Variable objects that express the same physical quantity in different units. The units are specified by strings containing their names. The units must be compatible with the unit of the object. If one unit is specified, the return value is a single Variable.
>>> freeze = Variable('0 degC') >>> print(freeze.inUnitsOf('degF').allclose("32.0 degF")) 1
If several units are specified, the return value is a tuple of Variable instances with with one element per unit such that the sum of all quantities in the tuple equals the the original quantity and all the values except for the last one are integers. This is used to convert to irregular unit systems like hour/minute/second. The original object will not be changed.
>>> t = Variable(value=314159., unit='s') >>> from builtins import zip >>> print(numerix.allclose([e.allclose(v) for (e, v) in zip(t.inUnitsOf('d', 'h', 'min', 's'), ... ['3.0 d', '15.0 h', '15.0 min', '59.0 s'])], ... True)) 1
- itemset(value)¶
- property itemsize¶
- property leastSquaresGrad¶
Return
, which is determined by solving for
in the following matrix equation,
The matrix equation is derived by minimizing the following least squares sum,
Tests
>>> from fipy import Grid2D >>> m = Grid2D(nx=2, ny=2, dx=0.1, dy=2.0) >>> print(numerix.allclose(CellVariable(mesh=m, value=(0, 1, 3, 6)).leastSquaresGrad.globalValue, \ ... [[8.0, 8.0, 24.0, 24.0], ... [1.2, 2.0, 1.2, 2.0]])) True
>>> from fipy import Grid1D >>> print(numerix.allclose(CellVariable(mesh=Grid1D(dx=(2.0, 1.0, 0.5)), ... value=(0, 1, 2)).leastSquaresGrad.globalValue, [[0.461538461538, 0.8, 1.2]])) True
- max(axis=None)¶
- min(axis=None)¶
>>> from fipy import Grid2D, CellVariable >>> mesh = Grid2D(nx=5, ny=5) >>> x, y = mesh.cellCenters >>> v = CellVariable(mesh=mesh, value=x*y) >>> print(v.min()) 0.25
- property minmodFaceValue¶
Returns a FaceVariable with a value that is the minimum of the absolute values of the adjacent cells. If the values are of opposite sign then the result is zero:
>>> from fipy import * >>> print(CellVariable(mesh=Grid1D(nx=2), value=(1, 2)).minmodFaceValue) [1 1 2] >>> print(CellVariable(mesh=Grid1D(nx=2), value=(-1, -2)).minmodFaceValue) [-1 -1 -2] >>> print(CellVariable(mesh=Grid1D(nx=2), value=(-1, 2)).minmodFaceValue) [-1 0 2]
- property name¶
- property numericValue¶
- property old¶
Return the values of the CellVariable from the previous solution sweep.
Combinations of CellVariable’s should also return old values.
>>> from fipy.meshes import Grid1D >>> mesh = Grid1D(nx = 2) >>> from fipy.variables.cellVariable import CellVariable >>> var1 = CellVariable(mesh = mesh, value = (2, 3), hasOld = 1) >>> var2 = CellVariable(mesh = mesh, value = (3, 4)) >>> v = var1 * var2 >>> print(v) [ 6 12] >>> var1.value = ((3, 2)) >>> print(v) [9 8] >>> print(v.old) [ 6 12]
The following small test is to correct for a bug when the operator does not just use variables.
>>> v1 = var1 * 3 >>> print(v1) [9 6] >>> print(v1.old) [6 9]
- put(indices, value)¶
- property rank¶
- ravel()¶
- rdot(other, opShape=None, operatorClass=None)¶
Return the mesh-element–by–mesh-element (cell-by-cell, face-by-face, etc.) scalar product
Both self and other can be of arbitrary rank, and other does not need to be a _MeshVariable.
- release(constraint)¶
Remove constraint from self
>>> from fipy import * >>> m = Grid1D(nx=3) >>> v = CellVariable(mesh=m, value=m.cellCenters[0]) >>> c = Constraint(0., where=m.facesLeft) >>> v.constrain(c) >>> print(v.faceValue) [ 0. 1. 2. 2.5] >>> v.release(constraint=c) >>> print(v.faceValue) [ 0.5 1. 2. 2.5]
- setValue(value, unit=None, where=None)¶
Set the value of the Variable. Can take a masked array.
>>> a = Variable((1, 2, 3)) >>> a.setValue(5, where=(1, 0, 1)) >>> print(a) [5 2 5]
>>> b = Variable((4, 5, 6)) >>> a.setValue(b, where=(1, 0, 1)) >>> print(a) [4 2 6] >>> print(b) [4 5 6] >>> a.value = 3 >>> print(a) [3 3 3]
>>> b = numerix.array((3, 4, 5)) >>> a.value = b >>> a[:] = 1 >>> print(b) [3 4 5]
>>> a.setValue((4, 5, 6), where=(1, 0)) Traceback (most recent call last): .... ValueError: shape mismatch: objects cannot be broadcast to a single shape
- property shape¶
>>> from fipy.meshes import Grid2D >>> from fipy.variables.cellVariable import CellVariable >>> mesh = Grid2D(nx=2, ny=3) >>> var = CellVariable(mesh=mesh) >>> print(numerix.allequal(var.shape, (6,))) True >>> print(numerix.allequal(var.arithmeticFaceValue.shape, (17,))) True >>> print(numerix.allequal(var.grad.shape, (2, 6))) True >>> print(numerix.allequal(var.faceGrad.shape, (2, 17))) True
Have to account for zero length arrays
>>> from fipy import Grid1D >>> m = Grid1D(nx=0) >>> v = CellVariable(mesh=m, elementshape=(2,)) >>> numerix.allequal((v * 1).shape, (2, 0)) True
- std(axis=None, **kwargs)¶
Evaluate standard deviation of all the elements of a MeshVariable.
Adapted from http://mpitutorial.com/tutorials/mpi-reduce-and-allreduce/
>>> import fipy as fp >>> mesh = fp.Grid2D(nx=2, ny=2, dx=2., dy=5.) >>> var = fp.CellVariable(value=(1., 2., 3., 4.), mesh=mesh) >>> print((var.std()**2).allclose(1.25)) True
- property subscribedVariables¶
- sum(axis=None)¶
- take(ids, axis=0)¶
- tostring(max_line_width=75, precision=8, suppress_small=False, separator=' ')¶
- property unit¶
Return the unit object of self.
>>> Variable(value="1 m").unit <PhysicalUnit m>
- updateOld()¶
Set the values of the previous solution sweep to the current values.
>>> from fipy import * >>> v = CellVariable(mesh=Grid1D(), hasOld=False) >>> v.updateOld() Traceback (most recent call last): ... AssertionError: The updateOld method requires the CellVariable to have an old value. Set hasOld to True when instantiating the CellVariable.
- property value¶
“Evaluate” the Variable and return its value (longhand)
>>> a = Variable(value=3) >>> print(a.value) 3 >>> b = a + 4 >>> b (Variable(value=array(3)) + 4) >>> b.value 7
- class fipy.HybridConvectionTerm(coeff=1.0, var=None)¶
Bases:
_AsymmetricConvectionTerm
The discretization for this
Term
is given bywhere
and
is calculated using the hybrid scheme. For further details see Numerical Schemes.
Create a _AbstractConvectionTerm object.
>>> from fipy import * >>> m = Grid1D(nx = 2) >>> cv = CellVariable(mesh = m) >>> fv = FaceVariable(mesh = m) >>> vcv = CellVariable(mesh=m, rank=1) >>> vfv = FaceVariable(mesh=m, rank=1) >>> __ConvectionTerm(coeff = cv) Traceback (most recent call last): ... VectorCoeffError: The coefficient must be a vector value. >>> __ConvectionTerm(coeff = fv) Traceback (most recent call last): ... VectorCoeffError: The coefficient must be a vector value. >>> __ConvectionTerm(coeff = vcv) __ConvectionTerm(coeff=_ArithmeticCellToFaceVariable(value=array([[ 0., 0., 0.]]), mesh=UniformGrid1D(dx=1.0, nx=2))) >>> __ConvectionTerm(coeff = vfv) __ConvectionTerm(coeff=FaceVariable(value=array([[ 0., 0., 0.]]), mesh=UniformGrid1D(dx=1.0, nx=2))) >>> __ConvectionTerm(coeff = (1,)) __ConvectionTerm(coeff=(1,)) >>> ExplicitUpwindConvectionTerm(coeff = (0,)).solve(var=cv, solver=DummySolver()) Traceback (most recent call last): ... TransientTermError: The equation requires a TransientTerm with explicit convection. >>> (TransientTerm(0.) - ExplicitUpwindConvectionTerm(coeff = (0,))).solve(var=cv, solver=DummySolver(), dt=1.)
>>> (TransientTerm() - ExplicitUpwindConvectionTerm(coeff = 1)).solve(var=cv, solver=DummySolver(), dt=1.) Traceback (most recent call last): ... VectorCoeffError: The coefficient must be a vector value. >>> m2 = Grid2D(nx=2, ny=1) >>> cv2 = CellVariable(mesh=m2) >>> vcv2 = CellVariable(mesh=m2, rank=1) >>> vfv2 = FaceVariable(mesh=m2, rank=1) >>> __ConvectionTerm(coeff=vcv2) __ConvectionTerm(coeff=_ArithmeticCellToFaceVariable(value=array([[ 0., 0., 0., 0., 0., 0., 0.], [ 0., 0., 0., 0., 0., 0., 0.]]), mesh=UniformGrid2D(dx=1.0, nx=2, dy=1.0, ny=1))) >>> __ConvectionTerm(coeff=vfv2) __ConvectionTerm(coeff=FaceVariable(value=array([[ 0., 0., 0., 0., 0., 0., 0.], [ 0., 0., 0., 0., 0., 0., 0.]]), mesh=UniformGrid2D(dx=1.0, nx=2, dy=1.0, ny=1))) >>> (TransientTerm() - ExplicitUpwindConvectionTerm(coeff = ((0,), (0,)))).solve(var=cv2, solver=DummySolver(), dt=1.) >>> (TransientTerm() - ExplicitUpwindConvectionTerm(coeff = (0, 0))).solve(var=cv2, solver=DummySolver(), dt=1.)
- Parameters:
coeff (The Term’s coefficient value.) –
- property RHSvector¶
Return the RHS vector calculated in solve() or sweep(). The cacheRHSvector() method should be called before solve() or sweep() to cache the vector.
- __add__(other)¶
- __and__(other)¶
- __div__(other)¶
- __eq__(other)¶
Return self==value.
- __hash__()¶
Return hash(self).
- __mul__(other)¶
Multiply a term
>>> 2. * __NonDiffusionTerm(coeff=0.5) __NonDiffusionTerm(coeff=1.0)
Test for ticket:291.
>>> from fipy import PowerLawConvectionTerm >>> PowerLawConvectionTerm(coeff=[[1], [0]]) * 1.0 PowerLawConvectionTerm(coeff=array([[ 1.], [ 0.]]))
- __neg__()¶
Negate a Term.
>>> -__NonDiffusionTerm(coeff=1.) __NonDiffusionTerm(coeff=-1.0)
- __pos__()¶
- __radd__(other)¶
- __rand__(other)¶
- __repr__()¶
The representation of a Term object is given by,
>>> print(__UnaryTerm(123.456)) __UnaryTerm(coeff=123.456)
- __rmul__(other)¶
Multiply a term
>>> 2. * __NonDiffusionTerm(coeff=0.5) __NonDiffusionTerm(coeff=1.0)
Test for ticket:291.
>>> from fipy import PowerLawConvectionTerm >>> PowerLawConvectionTerm(coeff=[[1], [0]]) * 1.0 PowerLawConvectionTerm(coeff=array([[ 1.], [ 0.]]))
- __rsub__(other)¶
- __sub__(other)¶
- __truediv__(other)¶
- cacheMatrix()¶
Informs solve() and sweep() to cache their matrix so that matrix can return the matrix.
- cacheRHSvector()¶
Informs solve() and sweep() to cache their right hand side vector so that getRHSvector() can return it.
- copy()¶
- getDefaultSolver(var=None, solver=None, *args, **kwargs)¶
- justErrorVector(var=None, solver=None, boundaryConditions=(), dt=1.0, underRelaxation=None, residualFn=None)¶
Builds the Term’s linear system once.
This method also recalculates and returns the error as well as applying under-relaxation.
justErrorVector returns the overlapping local value in parallel (not the non-overlapping value).
>>> from fipy.solvers import DummySolver >>> from fipy import * >>> m = Grid1D(nx=10) >>> v = CellVariable(mesh=m) >>> len(DiffusionTerm().justErrorVector(v, solver=DummySolver())) == m.numberOfCells True
- Parameters:
var (CellVariable) – Variable to be solved for. Provides the initial condition, the old value and holds the solution on completion.
solver (Solver) – Iterative solver to be used to solve the linear system of equations. The default sovler depends on the solver package selected.
boundaryConditions (
tuple
ofBoundaryCondition
) –dt (float) – Timestep size.
underRelaxation (float) – Usually a value between 0 and 1 or None in the case of no under-relaxation
residualFn (function) – Takes var, matrix, and RHSvector arguments, used to customize the residual calculation.
- Returns:
error – The residual vector
- Return type:
- justResidualVector(var=None, solver=None, boundaryConditions=(), dt=None, underRelaxation=None, residualFn=None)¶
Builds the Term’s linear system once.
This method also recalculates and returns the residual as well as applying under-relaxation.
justResidualVector returns the overlapping local value in parallel (not the non-overlapping value).
>>> from fipy import * >>> m = Grid1D(nx=10) >>> v = CellVariable(mesh=m) >>> len(numerix.asarray(DiffusionTerm().justResidualVector(v))) == m.numberOfCells True
- Parameters:
var (CellVariable) – Variable to be solved for. Provides the initial condition, the old value and holds the solution on completion.
solver (Solver) – Iterative solver to be used to solve the linear system of equations. The default sovler depends on the solver package selected.
boundaryConditions (
tuple
ofBoundaryCondition
) –dt (float) – Timestep size.
underRelaxation (float) – Usually a value between 0 and 1 or None in the case of no under-relaxation
residualFn (function) – Takes var, matrix, and RHSvector arguments, used to customize the residual calculation.
- Returns:
residual – The residual vector
- Return type:
- property matrix¶
Return the matrix calculated in solve() or sweep(). The cacheMatrix() method should be called before solve() or sweep() to cache the matrix.
- residualVectorAndNorm(var=None, solver=None, boundaryConditions=(), dt=None, underRelaxation=None, residualFn=None)¶
Builds the Term’s linear system once.
This method also recalculates and returns the residual as well as applying under-relaxation.
- Parameters:
var (CellVariable) – Variable to be solved for. Provides the initial condition, the old value and holds the solution on completion.
solver (Solver) – Iterative solver to be used to solve the linear system of equations. The default sovler depends on the solver package selected.
boundaryConditions (
tuple
ofBoundaryCondition
) –dt (float) – Timestep size.
underRelaxation (float) – Usually a value between 0 and 1 or None in the case of no under-relaxation
residualFn (function) – Takes var, matrix, and RHSvector arguments, used to customize the residual calculation.
- Returns:
residual (~fipy.variables.cellVariable.CellVariable) – The residual vector
norm (float) – The L2 norm of residual,
- solve(var=None, solver=None, boundaryConditions=(), dt=None)¶
Builds and solves the Term’s linear system once. This method does not return the residual. It should be used when the residual is not required.
- Parameters:
var (CellVariable) – Variable to be solved for. Provides the initial condition, the old value and holds the solution on completion.
solver (Solver) – Iterative solver to be used to solve the linear system of equations. The default sovler depends on the solver package selected.
boundaryConditions (
tuple
ofBoundaryCondition
) –dt (float) – Timestep size.
- sweep(var=None, solver=None, boundaryConditions=(), dt=None, underRelaxation=None, residualFn=None, cacheResidual=False, cacheError=False)¶
Builds and solves the Term’s linear system once. This method also recalculates and returns the residual as well as applying under-relaxation.
- Parameters:
var (CellVariable) – Variable to be solved for. Provides the initial condition, the old value and holds the solution on completion.
solver (Solver) – Iterative solver to be used to solve the linear system of equations. The default sovler depends on the solver package selected.
boundaryConditions (
tuple
ofBoundaryCondition
) –dt (float) – Timestep size.
underRelaxation (float) – Usually a value between 0 and 1 or None in the case of no under-relaxation
residualFn (function) – Takes var, matrix, and RHSvector arguments, used to customize the residual calculation.
cacheResidual (bool) – If True, calculate and store the residual vector
in the residualVector member of Term
cacheError (bool) – If True, use the residual vector
to solve
for the error vector
and store it in the errorVector member of Term
- Returns:
residual – The residual vector
- Return type:
- exception fipy.IllConditionedPreconditionerWarning(solver, iter, relres)¶
Bases:
PreconditionerWarning
- __cause__¶
exception cause
- __context__¶
exception context
- __delattr__(name, /)¶
Implement delattr(self, name).
- __getattribute__(name, /)¶
Return getattr(self, name).
- __reduce__()¶
Helper for pickle.
- __repr__()¶
Return repr(self).
- __setattr__(name, value, /)¶
Implement setattr(self, name, value).
- __setstate__()¶
- __str__()¶
Return str(self).
- __suppress_context__¶
- __traceback__¶
- add_note()¶
Exception.add_note(note) – add a note to the exception
- args¶
- with_traceback()¶
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
- fipy.ImplicitDiffusionTerm¶
alias of
DiffusionTerm
- class fipy.ImplicitSourceTerm(coeff=0.0, var=None)¶
Bases:
SourceTerm
The ImplicitSourceTerm represents
where
is the coeff value.
Create a Term.
- Parameters:
coeff (float or CellVariable or FaceVariable) – Coefficient for the term. FaceVariable objects are only acceptable for diffusion or convection terms.
- property RHSvector¶
Return the RHS vector calculated in solve() or sweep(). The cacheRHSvector() method should be called before solve() or sweep() to cache the vector.
- __add__(other)¶
- __and__(other)¶
- __div__(other)¶
- __eq__(other)¶
Return self==value.
- __hash__()¶
Return hash(self).
- __mul__(other)¶
Multiply a term
>>> 2. * __NonDiffusionTerm(coeff=0.5) __NonDiffusionTerm(coeff=1.0)
Test for ticket:291.
>>> from fipy import PowerLawConvectionTerm >>> PowerLawConvectionTerm(coeff=[[1], [0]]) * 1.0 PowerLawConvectionTerm(coeff=array([[ 1.], [ 0.]]))
- __neg__()¶
Negate a Term.
>>> -__NonDiffusionTerm(coeff=1.) __NonDiffusionTerm(coeff=-1.0)
- __pos__()¶
- __radd__(other)¶
- __rand__(other)¶
- __repr__()¶
The representation of a Term object is given by,
>>> print(__UnaryTerm(123.456)) __UnaryTerm(coeff=123.456)
- __rmul__(other)¶
Multiply a term
>>> 2. * __NonDiffusionTerm(coeff=0.5) __NonDiffusionTerm(coeff=1.0)
Test for ticket:291.
>>> from fipy import PowerLawConvectionTerm >>> PowerLawConvectionTerm(coeff=[[1], [0]]) * 1.0 PowerLawConvectionTerm(coeff=array([[ 1.], [ 0.]]))
- __rsub__(other)¶
- __sub__(other)¶
- __truediv__(other)¶
- cacheMatrix()¶
Informs solve() and sweep() to cache their matrix so that matrix can return the matrix.
- cacheRHSvector()¶
Informs solve() and sweep() to cache their right hand side vector so that getRHSvector() can return it.
- copy()¶
- getDefaultSolver(var=None, solver=None, *args, **kwargs)¶
- justErrorVector(var=None, solver=None, boundaryConditions=(), dt=1.0, underRelaxation=None, residualFn=None)¶
Builds the Term’s linear system once.
This method also recalculates and returns the error as well as applying under-relaxation.
justErrorVector returns the overlapping local value in parallel (not the non-overlapping value).
>>> from fipy.solvers import DummySolver >>> from fipy import * >>> m = Grid1D(nx=10) >>> v = CellVariable(mesh=m) >>> len(DiffusionTerm().justErrorVector(v, solver=DummySolver())) == m.numberOfCells True
- Parameters:
var (CellVariable) – Variable to be solved for. Provides the initial condition, the old value and holds the solution on completion.
solver (Solver) – Iterative solver to be used to solve the linear system of equations. The default sovler depends on the solver package selected.
boundaryConditions (
tuple
ofBoundaryCondition
) –dt (float) – Timestep size.
underRelaxation (float) – Usually a value between 0 and 1 or None in the case of no under-relaxation
residualFn (function) – Takes var, matrix, and RHSvector arguments, used to customize the residual calculation.
- Returns:
error – The residual vector
- Return type:
- justResidualVector(var=None, solver=None, boundaryConditions=(), dt=None, underRelaxation=None, residualFn=None)¶
Builds the Term’s linear system once.
This method also recalculates and returns the residual as well as applying under-relaxation.
justResidualVector returns the overlapping local value in parallel (not the non-overlapping value).
>>> from fipy import * >>> m = Grid1D(nx=10) >>> v = CellVariable(mesh=m) >>> len(numerix.asarray(DiffusionTerm().justResidualVector(v))) == m.numberOfCells True
- Parameters:
var (CellVariable) – Variable to be solved for. Provides the initial condition, the old value and holds the solution on completion.
solver (Solver) – Iterative solver to be used to solve the linear system of equations. The default sovler depends on the solver package selected.
boundaryConditions (
tuple
ofBoundaryCondition
) –dt (float) – Timestep size.
underRelaxation (float) – Usually a value between 0 and 1 or None in the case of no under-relaxation
residualFn (function) – Takes var, matrix, and RHSvector arguments, used to customize the residual calculation.
- Returns:
residual – The residual vector
- Return type:
- property matrix¶
Return the matrix calculated in solve() or sweep(). The cacheMatrix() method should be called before solve() or sweep() to cache the matrix.
- residualVectorAndNorm(var=None, solver=None, boundaryConditions=(), dt=None, underRelaxation=None, residualFn=None)¶
Builds the Term’s linear system once.
This method also recalculates and returns the residual as well as applying under-relaxation.
- Parameters:
var (CellVariable) – Variable to be solved for. Provides the initial condition, the old value and holds the solution on completion.
solver (Solver) – Iterative solver to be used to solve the linear system of equations. The default sovler depends on the solver package selected.
boundaryConditions (
tuple
ofBoundaryCondition
) –dt (float) – Timestep size.
underRelaxation (float) – Usually a value between 0 and 1 or None in the case of no under-relaxation
residualFn (function) – Takes var, matrix, and RHSvector arguments, used to customize the residual calculation.
- Returns:
residual (~fipy.variables.cellVariable.CellVariable) – The residual vector
norm (float) – The L2 norm of residual,
- solve(var=None, solver=None, boundaryConditions=(), dt=None)¶
Builds and solves the Term’s linear system once. This method does not return the residual. It should be used when the residual is not required.
- Parameters:
var (CellVariable) – Variable to be solved for. Provides the initial condition, the old value and holds the solution on completion.
solver (Solver) – Iterative solver to be used to solve the linear system of equations. The default sovler depends on the solver package selected.
boundaryConditions (
tuple
ofBoundaryCondition
) –dt (float) – Timestep size.
- sweep(var=None, solver=None, boundaryConditions=(), dt=None, underRelaxation=None, residualFn=None, cacheResidual=False, cacheError=False)¶
Builds and solves the Term’s linear system once. This method also recalculates and returns the residual as well as applying under-relaxation.
- Parameters:
var (CellVariable) – Variable to be solved for. Provides the initial condition, the old value and holds the solution on completion.
solver (Solver) – Iterative solver to be used to solve the linear system of equations. The default sovler depends on the solver package selected.
boundaryConditions (
tuple
ofBoundaryCondition
) –dt (float) – Timestep size.
underRelaxation (float) – Usually a value between 0 and 1 or None in the case of no under-relaxation
residualFn (function) – Takes var, matrix, and RHSvector arguments, used to customize the residual calculation.
cacheResidual (bool) – If True, calculate and store the residual vector
in the residualVector member of Term
cacheError (bool) – If True, use the residual vector
to solve
for the error vector
and store it in the errorVector member of Term
- Returns:
residual – The residual vector
- Return type:
- exception fipy.IncorrectSolutionVariable(s='The solution variable is incorrect.')¶
Bases:
Exception
- __cause__¶
exception cause
- __context__¶
exception context
- __delattr__(name, /)¶
Implement delattr(self, name).
- __getattribute__(name, /)¶
Return getattr(self, name).
- __reduce__()¶
Helper for pickle.
- __repr__()¶
Return repr(self).
- __setattr__(name, value, /)¶
Implement setattr(self, name, value).
- __setstate__()¶
- __str__()¶
Return str(self).
- __suppress_context__¶
- __traceback__¶
- add_note()¶
Exception.add_note(note) – add a note to the exception
- args¶
- with_traceback()¶
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
- fipy.L1error(var, matrix, RHSvector)¶
where
is the
norm of
.
- Parameters:
var (CellVariable) – The CellVariable in question.
matrix – (ignored)
RHSvector – (ignored)
- fipy.L2error(var, matrix, RHSvector)¶
where
is the
norm of
.
- Parameters:
var (CellVariable) – The CellVariable in question.
matrix – (ignored)
RHSvector – (ignored)
- fipy.LINFerror(var, matrix, RHSvector)¶
where
is the
norm of
.
- Parameters:
var (CellVariable) – The CellVariable in question.
matrix – (ignored)
RHSvector – (ignored)
- class fipy.LinearBicgSolver(tolerance=1e-10, iterations=1000, precon=None)¶
Bases:
PETScKrylovSolver
The LinearBicgSolver is an interface to the biconjugate gradient solver in PETSc, using no preconditioner by default.
- Parameters:
tolerance: The required error tolerance.
iterations: The maximum number of iterative steps to perform.
precon: Preconditioner to use (string).
- __del__()¶
- __enter__()¶
- __exit__(exc_type, exc_value, traceback)¶
- __repr__()¶
Return repr(self).
- solver = 'bicg'¶
- class fipy.LinearCGSSolver(tolerance=1e-10, iterations=1000, precon=None)¶
Bases:
PETScKrylovSolver
The LinearCGSSolver is an interface to the conjugate gradient squared solver in PETSc, using no preconditioner by default.
- Parameters:
tolerance: The required error tolerance.
iterations: The maximum number of iterative steps to perform.
precon: Preconditioner to use (string).
- __del__()¶
- __enter__()¶
- __exit__(exc_type, exc_value, traceback)¶
- __repr__()¶
Return repr(self).
- solver = 'cgs'¶
- class fipy.LinearGMRESSolver(tolerance=1e-10, iterations=1000, precon=None)¶
Bases:
PETScKrylovSolver
The LinearGMRESSolver is an interface to the GMRES solver in PETSc, using no preconditioner by default.
- Parameters:
tolerance: The required error tolerance.
iterations: The maximum number of iterative steps to perform.
precon: Preconditioner to use (string).
- __del__()¶
- __enter__()¶
- __exit__(exc_type, exc_value, traceback)¶
- __repr__()¶
Return repr(self).
- solver = 'gmres'¶
- class fipy.LinearLUSolver(tolerance=1e-10, iterations=10, precon='lu')¶
Bases:
PETScSolver
The LinearLUSolver is an interface to the LU preconditioner in PETSc. A direct solve is performed.
- Parameters:
tolerance: The required error tolerance.
iterations: The maximum number of iterative steps to perform.
precon: Ignored.
- __del__()¶
- __enter__()¶
- __exit__(exc_type, exc_value, traceback)¶
- __repr__()¶
Return repr(self).
- class fipy.LinearPCGSolver(tolerance=1e-10, iterations=1000, precon=None)¶
Bases:
PETScKrylovSolver
The LinearPCGSolver is an interface to the cg solver in PETSc, using no preconditioner by default.
- Parameters:
tolerance: The required error tolerance.
iterations: The maximum number of iterative steps to perform.
precon: Preconditioner to use (string).
- __del__()¶
- __enter__()¶
- __exit__(exc_type, exc_value, traceback)¶
- __repr__()¶
Return repr(self).
- solver = 'cg'¶
- class fipy.Matplotlib1DViewer(vars, title=None, xlog=False, ylog=False, limits={}, legend='upper left', axes=None, **kwlimits)¶
Bases:
AbstractMatplotlibViewer
Displays a y vs. x plot of one or more 1D CellVariable objects using Matplotlib.
>>> import fipy as fp >>> mesh = fp.Grid1D(nx=100) >>> x, = mesh.cellCenters >>> xVar = fp.CellVariable(mesh=mesh, name="x", value=x) >>> k = fp.Variable(name="k", value=0.) >>> viewer = Matplotlib1DViewer(vars=(fp.numerix.sin(k * xVar) + 2, ... fp.numerix.cos(k * xVar / fp.numerix.pi) + 2), ... xmin=10, xmax=90, ... datamin=1.1, datamax=4.0, ... title="Matplotlib1DViewer test") >>> for kval in fp.numerix.arange(0, 0.3, 0.03): ... k.setValue(kval) ... viewer.plot() >>> viewer._promptForOpinion()
>>> viewer.cmap = "ocean" >>> viewer.log = True
>>> viewer.title = "Matplotlib1DViewer changed" >>> viewer.plot() >>> viewer._promptForOpinion()
- Parameters:
vars (CellVariable or list) – CellVariable objects to plot
title (str, optional) – displayed at the top of the Viewer window
xlog (bool) – log scaling of x axis if True
ylog (bool) – log scaling of y axis if True
limits (dict) – a (deprecated) alternative to limit keyword arguments
xmin (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale. (ymin and ymax are synonyms for datamin and datamax).
xmax (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale. (ymin and ymax are synonyms for datamin and datamax).
datamin (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale. (ymin and ymax are synonyms for datamin and datamax).
datamax (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale. (ymin and ymax are synonyms for datamin and datamax).
legend (str) – place a legend at the specified position, if not None
axes (Axes) – if not None, vars will be plotted into this Matplotlib
Axes
object
- property axes¶
The Matplotlib
Axes
.
- property cmap¶
The Matplotlib
Colormap
.
- property colorbar¶
The Matplotlib
Colorbar
.
- property fig¶
The Matplotlib
Figure
.
- figaspect(figaspect, colorbar)¶
- property id¶
The Matplotlib
Figure
number.
- property limits¶
- property lines¶
The collection of Matplotlib
Line2D
objects representing the plotted data.
- property log¶
Whether data has logarithmic scaling
- plot(filename=None)¶
Update the display of the viewed variables.
- Parameters:
filename (str) – If not None, the name of a file to save the image into.
- plotMesh(filename=None)¶
Display a representation of the mesh
- Parameters:
filename (str) – If not None, the name of a file to save the image into.
- setLimits(limits={}, **kwlimits)¶
Update the limits.
- Parameters:
limits (dict, optional) – a (deprecated) alternative to limit keyword arguments
xmin (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
xmax (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
ymin (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
ymax (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
zmin (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
zmax (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
datamin (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
datamax (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
- property title¶
The text appearing at the top center.
(default: if
len(self.vars) == 1
, the name ofself.vars[0]
, otherwise""
.)
- class fipy.Matplotlib2DContourViewer(vars, title=None, limits={}, cmap=None, colorbar='vertical', axes=None, number=None, levels=None, figaspect='auto', **kwlimits)¶
Bases:
AbstractMatplotlib2DViewer
Displays a contour plot of a 2D CellVariable object.
The Matplotlib2DContourViewer plots a 2D CellVariable using Matplotlib.
Creates a Matplotlib2DContourViewer.
- Parameters:
vars (CellVariable) – Variable to display
title (str, optional) – displayed at the top of the Viewer window
limits (dict, optional) – a (deprecated) alternative to limit keyword arguments
xmin (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.
xmax (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.
ymin (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.
ymax (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.
datamin (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.
datamax (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.
cmap (Colormap, optional) – the Colormap. Defaults to matplotlib.cm.jet
colorbar (bool, optional) – plot a color bar in specified orientation if not None
axes (Axes, optional) – if not None, vars will be plotted into this Matplotlib Axes object
number (int, optional) – Determines the number and positions of the contour lines / regions. (deprecated, use levels=).
levels (int or array-like, optional) – Determines the number and positions of the contour lines / regions. If an int n, tries to automatically choose no more than n+1 “nice” contour levels over the range of vars. If array-like, draw contour lines at the specified levels. The values must be in increasing order. E.g. to draw just the zero contour pass
levels=[0]
.figaspect (float) – desired aspect ratio of figure. If arg is a number, use that aspect ratio. If arg is auto, the aspect ratio will be determined from the Variable’s mesh.
- property axes¶
The Matplotlib
Axes
.
- property cmap¶
The Matplotlib
Colormap
.
- property colorbar¶
The Matplotlib
Colorbar
.
- property fig¶
The Matplotlib
Figure
.
- figaspect(figaspect, colorbar)¶
- property id¶
The Matplotlib
Figure
number.
- property levels¶
The number of automatically-chosen contours or their values.
- property limits¶
- plot(filename=None)¶
Update the display of the viewed variables.
- Parameters:
filename (str) – If not None, the name of a file to save the image into.
- plotMesh(filename=None)¶
Display a representation of the mesh
- Parameters:
filename (str) – If not None, the name of a file to save the image into.
- setLimits(limits={}, **kwlimits)¶
Update the limits.
- Parameters:
limits (dict, optional) – a (deprecated) alternative to limit keyword arguments
xmin (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
xmax (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
ymin (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
ymax (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
zmin (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
zmax (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
datamin (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
datamax (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
- property title¶
The text appearing at the top center.
(default: if
len(self.vars) == 1
, the name ofself.vars[0]
, otherwise""
.)
- class fipy.Matplotlib2DGridContourViewer(vars, title=None, limits={}, cmap=None, colorbar='vertical', axes=None, levels=None, figaspect='auto', **kwlimits)¶
Bases:
AbstractMatplotlib2DViewer
Displays a contour plot of a 2D CellVariable object.
The Matplotlib2DGridContourViewer plots a 2D CellVariable using Matplotlib.
>>> import fipy as fp >>> mesh = fp.Grid2D(nx=50, ny=100, dx=0.1, dy=0.01) >>> x, y = mesh.cellCenters >>> xyVar = fp.CellVariable(mesh=mesh, name="x y", value=x * y) >>> k = fp.Variable(name="k", value=0.) >>> viewer = Matplotlib2DGridContourViewer(vars=fp.numerix.sin(k * xyVar) * 1000 + 1002, ... ymin=0.1, ymax=0.9, ... # datamin=1.1, datamax=4.0, ... title="Matplotlib2DGridContourViewer test") >>> from builtins import range >>> for kval in range(10): ... k.setValue(kval) ... viewer.plot() >>> viewer._promptForOpinion()
>>> viewer.levels = 2
>>> viewer.cmap = "ocean" >>> viewer.log = True
>>> viewer.title = "Matplotlib2DGridContourViewer changed" >>> viewer.plot() >>> viewer._promptForOpinion()
Creates a Matplotlib2DViewer.
- Parameters:
vars (CellVariable) – the Variable to display.
title (str, optional) – displayed at the top of the Viewer window
limits (dict) – a (deprecated) alternative to limit keyword arguments
xmin (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.
xmax (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.
ymin (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.
ymax (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.
datamin (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.
datamax (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.
cmap (Colormap, optional) – the
Colormap
. Defaults to matplotlib.cm.jetcolorbar (bool, optional) – plot a color bar if not None
axes (Axes, optional) – if not None, vars will be plotted into this Matplotlib Axes object
levels (int or array-like, optional) – Determines the number and positions of the contour lines / regions. If an int n, tries to automatically choose no more than n+1 “nice” contour levels over the range of vars. If array-like, draw contour lines at the specified levels. The values must be in increasing order. E.g. to draw just the zero contour pass
levels=[0]
.figaspect (float, optional) – desired aspect ratio of figure. If a number, use that aspect ratio. If auto, the aspect ratio will be determined from the vars’s mesh.
- property axes¶
The Matplotlib
Axes
.
- property cmap¶
The Matplotlib
Colormap
.
- property colorbar¶
The Matplotlib
Colorbar
.
- property fig¶
The Matplotlib
Figure
.
- figaspect(figaspect, colorbar)¶
- property id¶
The Matplotlib
Figure
number.
- property levels¶
The number of automatically-chosen contours or their values.
- property limits¶
- plot(filename=None)¶
Update the display of the viewed variables.
- Parameters:
filename (str) – If not None, the name of a file to save the image into.
- plotMesh(filename=None)¶
Display a representation of the mesh
- Parameters:
filename (str) – If not None, the name of a file to save the image into.
- setLimits(limits={}, **kwlimits)¶
Update the limits.
- Parameters:
limits (dict, optional) – a (deprecated) alternative to limit keyword arguments
xmin (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
xmax (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
ymin (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
ymax (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
zmin (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
zmax (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
datamin (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
datamax (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
- property title¶
The text appearing at the top center.
(default: if
len(self.vars) == 1
, the name ofself.vars[0]
, otherwise""
.)
- class fipy.Matplotlib2DGridViewer(vars, title=None, limits={}, cmap=None, colorbar='vertical', axes=None, figaspect='auto', **kwlimits)¶
Bases:
AbstractMatplotlib2DViewer
Displays an image plot of a 2D CellVariable object using Matplotlib.
>>> import fipy as fp >>> mesh = fp.Grid2D(nx=50, ny=100, dx=0.1, dy=0.01) >>> x, y = mesh.cellCenters >>> xyVar = fp.CellVariable(mesh=mesh, name="x y", value=x * y) >>> k = fp.Variable(name="k", value=0.) >>> viewer = Matplotlib2DGridViewer(vars=fp.numerix.sin(k * xyVar) * 1000 + 1002, ... ymin=0.1, ymax=0.9, ... # datamin=1.1, datamax=4.0, ... title="Matplotlib2DGridViewer test") >>> from builtins import range >>> for kval in range(10): ... k.setValue(kval) ... viewer.plot() >>> viewer._promptForOpinion()
>>> viewer.cmap = "ocean" >>> viewer.log = True
>>> viewer.title = "Matplotlib2DGridViewer changed" >>> viewer.plot() >>> viewer._promptForOpinion()
Creates a Matplotlib2DGridViewer.
- Parameters:
vars (CellVariable) – the Variable to display.
title (str, optional) – displayed at the top of the Viewer window
limits (dict, optional) – a (deprecated) alternative to limit keyword arguments
cmap (Colormap, optional) – the
Colormap
. Defaults to matplotlib.cm.jetxmin (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.
xmax (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.
ymin (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.
ymax (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.
datamin (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.
datamax (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.
colorbar (bool, optional) – plot a color bar in specified orientation if not None
axes (Axes, optional) – if not None, vars will be plotted into this Matplotlib Axes object
figaspect (float, optional) – desired aspect ratio of figure. If arg is a number, use that aspect ratio. If arg is auto, the aspect ratio will be determined from the Variable’s mesh.
- property axes¶
The Matplotlib
Axes
.
- property cmap¶
The Matplotlib
Colormap
.
- property colorbar¶
The Matplotlib
Colorbar
.
- property fig¶
The Matplotlib
Figure
.
- figaspect(figaspect, colorbar)¶
- property id¶
The Matplotlib
Figure
number.
- property limits¶
- plot(filename=None)¶
Update the display of the viewed variables.
- Parameters:
filename (str) – If not None, the name of a file to save the image into.
- plotMesh(filename=None)¶
Display a representation of the mesh
- Parameters:
filename (str) – If not None, the name of a file to save the image into.
- setLimits(limits={}, **kwlimits)¶
Update the limits.
- Parameters:
limits (dict, optional) – a (deprecated) alternative to limit keyword arguments
xmin (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
xmax (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
ymin (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
ymax (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
zmin (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
zmax (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
datamin (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
datamax (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
- property title¶
The text appearing at the top center.
(default: if
len(self.vars) == 1
, the name ofself.vars[0]
, otherwise""
.)
- class fipy.Matplotlib2DViewer(vars, title=None, limits={}, cmap=None, colorbar='vertical', axes=None, figaspect='auto', **kwlimits)¶
Bases:
AbstractMatplotlib2DViewer
Displays a contour plot of a 2D CellVariable object.
The Matplotlib2DViewer plots a 2D CellVariable using Matplotlib.
>>> import fipy as fp >>> mesh = (fp.Grid2D(nx=5, ny=10, dx=0.1, dy=0.1) ... + (fp.Tri2D(nx=5, ny=5, dx=0.1, dy=0.1) ... + ((0.5,), (0.2,)))) >>> x, y = mesh.cellCenters >>> xyVar = fp.CellVariable(mesh=mesh, name="x y", value=x * y) >>> k = fp.Variable(name="k", value=0.) >>> viewer = Matplotlib2DViewer(vars=fp.numerix.sin(k * xyVar) * 1000 + 1002, ... ymin=0.1, ymax=0.9, ... # datamin=1.1, datamax=4.0, ... title="Matplotlib2DViewer test") >>> from builtins import range >>> for kval in range(10): ... k.setValue(kval) ... viewer.plot() >>> viewer._promptForOpinion()
>>> viewer.cmap = "ocean" >>> viewer.log = True
>>> viewer.title = "Matplotlib2DViewer changed" >>> viewer.plot() >>> viewer._promptForOpinion()
Creates a Matplotlib2DViewer.
- Parameters:
vars (CellVariable) – the Variable to display.
title (str, optional) – displayed at the top of the Viewer window
limits (dict, optional) – a (deprecated) alternative to limit keyword arguments
cmap (Colormap, optional) – the
Colormap
. Defaults to matplotlib.cm.jetxmin (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.
xmax (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.
ymin (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.
ymax (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.
datamin (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.
datamax (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.
colorbar (bool, optional) – plot a color bar in specified orientation if not None
axes (Axes, optional) – if not None, vars will be plotted into this Matplotlib
Axes
objectfigaspect (float, optional) – desired aspect ratio of figure. If arg is a number, use that aspect ratio. If arg is auto, the aspect ratio will be determined from the Variable’s mesh.
- property axes¶
The Matplotlib
Axes
.
- property cmap¶
The Matplotlib
Colormap
.
- property collection¶
The Matplotlib
PolyCollection
representing the cells.
- property colorbar¶
The Matplotlib
Colorbar
.
- property fig¶
The Matplotlib
Figure
.
- figaspect(figaspect, colorbar)¶
- property id¶
The Matplotlib
Figure
number.
- property limits¶
- plot(filename=None)¶
Update the display of the viewed variables.
- Parameters:
filename (str) – If not None, the name of a file to save the image into.
- plotMesh(filename=None)¶
Display a representation of the mesh
- Parameters:
filename (str) – If not None, the name of a file to save the image into.
- setLimits(limits={}, **kwlimits)¶
Update the limits.
- Parameters:
limits (dict, optional) – a (deprecated) alternative to limit keyword arguments
xmin (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
xmax (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
ymin (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
ymax (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
zmin (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
zmax (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
datamin (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
datamax (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
- property title¶
The text appearing at the top center.
(default: if
len(self.vars) == 1
, the name ofself.vars[0]
, otherwise""
.)
- class fipy.MatplotlibStreamViewer(vars, title=None, log=False, limits={}, axes=None, figaspect='auto', density=1, linewidth=None, color=None, cmap=None, norm=None, arrowsize=1, arrowstyle='-|>', minlength=0.1, **kwlimits)¶
Bases:
AbstractMatplotlib2DViewer
Displays a stream plot of a 2D rank-1 CellVariable or FaceVariable object using Matplotlib
One issue is that this Viewer relies on scipy.interpolate.griddata, which interpolates on the convex hull of the data. The results is that streams are plotted across any concavities in the mesh.
Another issue is that it does not seem possible to remove the streams without calling cla(), which means that different set of streams cannot be overlaid.
>>> import fipy as fp >>> mesh = fp.Grid2D(nx=50, ny=100, dx=0.1, dy=0.01) >>> x, y = mesh.cellCenters >>> xyVar = fp.CellVariable(mesh=mesh, name="x y", value=x * y) >>> k = fp.Variable(name="k", value=1.) >>> viewer = MatplotlibStreamViewer(vars=fp.numerix.sin(k * xyVar).grad, ... title="MatplotlibStreamViewer test") >>> for kval in fp.numerix.arange(1, 10): ... k.setValue(kval) ... viewer.plot() >>> viewer._promptForOpinion()
>>> viewer = MatplotlibStreamViewer(vars=fp.numerix.sin(k * xyVar).faceGrad, ... title="MatplotlibStreamViewer test") >>> from builtins import range >>> for kval in range(10): ... k.setValue(kval) ... viewer.plot() >>> viewer._promptForOpinion()
>>> viewer.cmap = "ocean" >>> viewer.log = True
>>> viewer.title = "MatplotlibStreamViewer changed" >>> viewer.plot() >>> viewer._promptForOpinion()
>>> import fipy as fp >>> mesh = (fp.Grid2D(nx=5, ny=10, dx=0.1, dy=0.1) ... + (fp.Tri2D(nx=5, ny=5, dx=0.1, dy=0.1) ... + ((0.5,), (0.2,)))) >>> x, y = mesh.cellCenters >>> xyVar = fp.CellVariable(mesh=mesh, name="x y", value=x * y) >>> k = fp.Variable(name="k", value=1.) >>> viewer = MatplotlibStreamViewer(vars=fp.numerix.sin(k * xyVar).grad, ... title="MatplotlibStreamViewer test") >>> for kval in fp.numerix.arange(1, 10): ... k.setValue(kval) ... viewer.plot() >>> viewer._promptForOpinion()
>>> viewer = MatplotlibStreamViewer(vars=fp.numerix.sin(k * xyVar).faceGrad, ... title="MatplotlibStreamViewer test") >>> from builtins import range >>> for kval in range(10): ... k.setValue(kval) ... viewer.plot() >>> viewer._promptForOpinion()
>>> viewer.cmap = "ocean" >>> viewer.log = True
>>> viewer.title = "MatplotlibStreamViewer changed" >>> viewer.plot() >>> viewer._promptForOpinion()
Creates a MatplotlibStreamViewer.
- Parameters:
vars (CellVariable or FaceVariable) – rank-1 Variable to display
title (str, optional) – displayed at the top of the Viewer window
log (bool, optional) – if True, arrow length goes at the base-10 logarithm of the magnitude
limits (dict, optional) – a (deprecated) alternative to limit keyword arguments
xmin (float) – displayed range of data. Any limit set to a (default) value of None will autoscale.
xmax (float) – displayed range of data. Any limit set to a (default) value of None will autoscale.
ymin (float) – displayed range of data. Any limit set to a (default) value of None will autoscale.
ymax (float) – displayed range of data. Any limit set to a (default) value of None will autoscale.
datamin (float) – displayed range of data. Any limit set to a (default) value of None will autoscale.
datamax (float) – displayed range of data. Any limit set to a (default) value of None will autoscale.
axes (Axes, optional) – if not None, vars will be plotted into this Matplotlib Axes object
figaspect (float, optional) – desired aspect ratio of figure. If arg is a number, use that aspect ratio. If arg is auto, the aspect ratio will be determined from the Variable’s mesh.
density (float or (float, float), optional) – Controls the closeness of streamlines. When
density = 1
, the domain is divided into a 30x30 grid. density linearly scales this grid. Each cell in the grid can have, at most, one traversing streamline. For different densities in each direction, use a tuple (density_x, density_y).linewidth (array_like or CellVariable or FaceVariable, optional) – The width of the stream lines. With a rank-0 CellVariable or FaceVariable the line width can be varied across the grid. The MeshVariable must have the same type and be defined on the same Mesh as vars.
color (str or CellVariable or FaceVariable, optional) – The streamline color as a matplotlib color code or a field of numbers. If given a rank-0 CellVariable or FaceVariable, its values are converted to colors using cmap and norm. The MeshVariable must have the same type and be defined on the same Mesh as vars.
cmap (Colormap, optional) – Colormap used to plot streamlines and arrows. This is only used if color is a MeshVariable.
norm (Normalize, optional) – Normalize object used to scale luminance data to 0, 1. If
None
, stretch (min, max) to (0, 1). Only necessary when color is a MeshVariable.arrowsize (float, optional) – Scaling factor for the arrow size.
arrowstyle (str, optional) – Arrow style specification. See ~matplotlib.patches.FancyArrowPatch.
minlength (float, optional) – Minimum length of streamline in axes coordinates.
- property axes¶
The Matplotlib
Axes
.
- property cmap¶
The Matplotlib
Colormap
.
- property colorbar¶
The Matplotlib
Colorbar
.
- property fig¶
The Matplotlib
Figure
.
- figaspect(figaspect, colorbar)¶
- property id¶
The Matplotlib
Figure
number.
- property kwargs¶
keyword arguments to pass to
streamplot()
.
- property limits¶
- plot(filename=None)¶
Update the display of the viewed variables.
- Parameters:
filename (str) – If not None, the name of a file to save the image into.
- plotMesh(filename=None)¶
Display a representation of the mesh
- Parameters:
filename (str) – If not None, the name of a file to save the image into.
- setLimits(limits={}, **kwlimits)¶
Update the limits.
- Parameters:
limits (dict, optional) – a (deprecated) alternative to limit keyword arguments
xmin (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
xmax (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
ymin (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
ymax (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
zmin (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
zmax (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
datamin (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
datamax (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
- property title¶
The text appearing at the top center.
(default: if
len(self.vars) == 1
, the name ofself.vars[0]
, otherwise""
.)
- class fipy.MatplotlibVectorViewer(vars, title=None, scale=None, sparsity=None, log=False, limits={}, axes=None, figaspect='auto', **kwlimits)¶
Bases:
AbstractMatplotlib2DViewer
Displays a vector plot of a 2D rank-1 CellVariable or FaceVariable object using Matplotlib
>>> import fipy as fp >>> mesh = fp.Grid2D(nx=50, ny=100, dx=0.1, dy=0.01) >>> x, y = mesh.cellCenters >>> xyVar = fp.CellVariable(mesh=mesh, name="x y", value=x * y) >>> k = fp.Variable(name="k", value=1.) >>> viewer = MatplotlibVectorViewer(vars=fp.numerix.sin(k * xyVar).grad, ... title="MatplotlibVectorViewer test") >>> for kval in fp.numerix.arange(1, 10): ... k.setValue(kval) ... viewer.plot() >>> viewer._promptForOpinion()
>>> viewer = MatplotlibVectorViewer(vars=fp.numerix.sin(k * xyVar).faceGrad, ... title="MatplotlibVectorViewer test") >>> from builtins import range >>> for kval in range(10): ... k.setValue(kval) ... viewer.plot() >>> viewer._promptForOpinion()
>>> for sparsity in numerix.arange(5000, 0, -500): ... viewer.quiver(sparsity=sparsity) ... viewer.plot() >>> viewer._promptForOpinion()
>>> viewer.cmap = "ocean" >>> viewer.log = True
>>> viewer.title = "MatplotlibVectorViewer changed" >>> viewer.plot() >>> viewer._promptForOpinion()
>>> import fipy as fp >>> mesh = (fp.Grid2D(nx=5, ny=10, dx=0.1, dy=0.1) ... + (fp.Tri2D(nx=5, ny=5, dx=0.1, dy=0.1) ... + ((0.5,), (0.2,)))) >>> x, y = mesh.cellCenters >>> xyVar = fp.CellVariable(mesh=mesh, name="x y", value=x * y) >>> k = fp.Variable(name="k", value=1.) >>> viewer = MatplotlibVectorViewer(vars=fp.numerix.sin(k * xyVar).grad, ... title="MatplotlibVectorViewer test") >>> for kval in fp.numerix.arange(1, 10): ... k.setValue(kval) ... viewer.plot() >>> viewer._promptForOpinion()
>>> viewer = MatplotlibVectorViewer(vars=fp.numerix.sin(k * xyVar).faceGrad, ... title="MatplotlibVectorViewer test") >>> from builtins import range >>> for kval in range(10): ... k.setValue(kval) ... viewer.plot() >>> viewer._promptForOpinion()
>>> for sparsity in numerix.arange(5000, 0, -500): ... viewer.quiver(sparsity=sparsity) ... viewer.plot() >>> viewer._promptForOpinion()
>>> viewer.cmap = "ocean" >>> viewer.log = True
>>> viewer.title = "MatplotlibVectorViewer changed" >>> viewer.plot() >>> viewer._promptForOpinion()
Creates a Matplotlib2DViewer.
- Parameters:
vars (CellVariable or FaceVariable) – rank-1 Variable to display
title (str, optional) – displayed at the top of the Viewer window
scale (float, optional) – if not None, scale all arrow lengths by this value
sparsity (int, optional) – if not None, then this number of arrows will be randomly chosen (weighted by the cell volume or face area)
log (bool, optional) – if True, arrow length goes at the base-10 logarithm of the magnitude
limits (dict, optional) – a (deprecated) alternative to limit keyword arguments
xmin (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.
xmax (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.
ymin (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.
ymax (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.
datamin (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.
datamax (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.
axes (Axes, optional) – if not None, vars will be plotted into this Matplotlib Axes object
figaspect (float, optional) – desired aspect ratio of figure. If arg is a number, use that aspect ratio. If arg is auto, the aspect ratio will be determined from the Variable’s mesh.
- property axes¶
The Matplotlib
Axes
.
- property cmap¶
The Matplotlib
Colormap
.
- property colorbar¶
The Matplotlib
Colorbar
.
- property fig¶
The Matplotlib
Figure
.
- figaspect(figaspect, colorbar)¶
- property id¶
The Matplotlib
Figure
number.
- property limits¶
- plot(filename=None)¶
Update the display of the viewed variables.
- Parameters:
filename (str) – If not None, the name of a file to save the image into.
- plotMesh(filename=None)¶
Display a representation of the mesh
- Parameters:
filename (str) – If not None, the name of a file to save the image into.
- quiver(sparsity=None, scale=None)¶
- setLimits(limits={}, **kwlimits)¶
Update the limits.
- Parameters:
limits (dict, optional) – a (deprecated) alternative to limit keyword arguments
xmin (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
xmax (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
ymin (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
ymax (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
zmin (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
zmax (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
datamin (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
datamax (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
- property title¶
The text appearing at the top center.
(default: if
len(self.vars) == 1
, the name ofself.vars[0]
, otherwise""
.)
- fipy.MatplotlibViewer(vars, title=None, limits={}, cmap=None, colorbar='vertical', axes=None, **kwlimits)¶
Generic function for creating a MatplotlibViewer.
The MatplotlibViewer factory will search the module tree and return an instance of the first MatplotlibViewer it finds of the correct dimension and rank.
It is possible to view different
Variable
s against different Matplotlib Axes>>> from matplotlib import pyplot as plt >>> from fipy import *
>>> plt.ion() >>> fig = plt.figure()
>>> ax1 = plt.subplot((221)) >>> ax2 = plt.subplot((223)) >>> ax3 = plt.subplot((224))
>>> k = Variable(name="k", value=0.)
>>> mesh1 = Grid1D(nx=100) >>> x, = mesh1.cellCenters >>> xVar = CellVariable(mesh=mesh1, name="x", value=x) >>> viewer1 = MatplotlibViewer(vars=(numerix.sin(0.1 * k * xVar), numerix.cos(0.1 * k * xVar / numerix.pi)), ... limits={'xmin': 10, 'xmax': 90}, ... datamin=-0.9, datamax=2.0, ... title="Grid1D test", ... axes=ax1, ... legend=None)
>>> mesh2 = Grid2D(nx=50, ny=100, dx=0.1, dy=0.01) >>> x, y = mesh2.cellCenters >>> xyVar = CellVariable(mesh=mesh2, name="x y", value=x * y) >>> viewer2 = MatplotlibViewer(vars=numerix.sin(k * xyVar), ... limits={'ymin': 0.1, 'ymax': 0.9}, ... datamin=-0.9, datamax=2.0, ... title="Grid2D test", ... axes=ax2, ... colorbar=None)
>>> mesh3 = (Grid2D(nx=5, ny=10, dx=0.1, dy=0.1) ... + (Tri2D(nx=5, ny=5, dx=0.1, dy=0.1) ... + ((0.5,), (0.2,)))) >>> x, y = mesh3.cellCenters >>> xyVar = CellVariable(mesh=mesh3, name="x y", value=x * y) >>> viewer3 = MatplotlibViewer(vars=numerix.sin(k * xyVar), ... limits={'ymin': 0.1, 'ymax': 0.9}, ... datamin=-0.9, datamax=2.0, ... title="Irregular 2D test", ... axes=ax3, ... cmap = plt.cm.OrRd)
>>> viewer = MultiViewer(viewers=(viewer1, viewer2, viewer3)) >>> from builtins import range >>> for kval in range(10): ... k.setValue(kval) ... viewer.plot()
>>> viewer._promptForOpinion()
- Parameters:
vars (CellVariable or list) – the Variable objects to display.
title (str, optional) – displayed at the top of the Viewer window
limits (dict) – a (deprecated) alternative to limit keyword arguments
xmin (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
xmax (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
ymin (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
ymax (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
datamin (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
datamax (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
cmap (Colormap, optional) – the
Colormap
. Defaults to matplotlib.cm.jetcolorbar (bool, optional) – plot a color bar in specified orientation if not None
axes (Axes, optional) – if not None, vars will be plotted into this Matplotlib Axes object
- exception fipy.MatrixIllConditionedWarning(solver, iter, relres)¶
Bases:
SolverConvergenceWarning
- __cause__¶
exception cause
- __context__¶
exception context
- __delattr__(name, /)¶
Implement delattr(self, name).
- __getattribute__(name, /)¶
Return getattr(self, name).
- __reduce__()¶
Helper for pickle.
- __repr__()¶
Return repr(self).
- __setattr__(name, value, /)¶
Implement setattr(self, name, value).
- __setstate__()¶
- __str__()¶
Return str(self).
- __suppress_context__¶
- __traceback__¶
- add_note()¶
Exception.add_note(note) – add a note to the exception
- args¶
- with_traceback()¶
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
- exception fipy.MaximumIterationWarning(solver, iter, relres)¶
Bases:
SolverConvergenceWarning
- __cause__¶
exception cause
- __context__¶
exception context
- __delattr__(name, /)¶
Implement delattr(self, name).
- __getattribute__(name, /)¶
Return getattr(self, name).
- __reduce__()¶
Helper for pickle.
- __repr__()¶
Return repr(self).
- __setattr__(name, value, /)¶
Implement setattr(self, name, value).
- __setstate__()¶
- __str__()¶
Return str(self).
- __suppress_context__¶
- __traceback__¶
- add_note()¶
Exception.add_note(note) – add a note to the exception
- args¶
- with_traceback()¶
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
- class fipy.MayaviClient(vars, title=None, daemon_file=None, fps=1.0, **kwlimits)¶
Bases:
AbstractViewer
The MayaviClient uses the Mayavi python plotting package.
>>> import fipy as fp >>> mesh = fp.Grid1D(nx=100) >>> x, = mesh.cellCenters >>> xVar = fp.CellVariable(mesh=mesh, name="x", value=x) >>> k = fp.Variable(name="k", value=0.) >>> viewer = MayaviClient(vars=(fp.numerix.sin(k * xVar) + 2, ... fp.numerix.cos(k * xVar / fp.numerix.pi) + 2), ... xmin=10, xmax=90, ... datamin=1.1, datamax=4.0, ... title="MayaviClient test") >>> for kval in fp.numerix.arange(0, 0.3, 0.03): ... k.setValue(kval) ... viewer.plot() >>> viewer._promptForOpinion()
>>> import fipy as fp >>> mesh = fp.Grid2D(nx=50, ny=100, dx=0.1, dy=0.01) >>> x, y = mesh.cellCenters >>> xyVar = fp.CellVariable(mesh=mesh, name="x y", value=x * y) >>> k = fp.Variable(name="k", value=0.) >>> viewer = MayaviClient(vars=fp.numerix.sin(k * xyVar) * 1000 + 1002, ... ymin=0.1, ymax=0.9, ... # datamin=1.1, datamax=4.0, ... title="MayaviClient test") >>> from builtins import range >>> for kval in range(10): ... k.setValue(kval) ... viewer.plot() >>> viewer._promptForOpinion()
>>> import fipy as fp >>> mesh = (fp.Grid2D(nx=5, ny=10, dx=0.1, dy=0.1) ... + (fp.Tri2D(nx=5, ny=5, dx=0.1, dy=0.1) ... + ((0.5,), (0.2,)))) >>> x, y = mesh.cellCenters >>> xyVar = fp.CellVariable(mesh=mesh, name="x y", value=x * y) >>> k = fp.Variable(name="k", value=0.) >>> viewer = MayaviClient(vars=fp.numerix.sin(k * xyVar) * 1000 + 1002, ... ymin=0.1, ymax=0.9, ... # datamin=1.1, datamax=4.0, ... title="MayaviClient test") >>> from builtins import range >>> for kval in range(10): ... k.setValue(kval) ... viewer.plot() >>> viewer._promptForOpinion()
>>> import fipy as fp >>> mesh = fp.Grid3D(nx=50, ny=100, nz=10, dx=0.1, dy=0.01, dz=0.1) >>> x, y, z = mesh.cellCenters >>> xyzVar = fp.CellVariable(mesh=mesh, name=r"x y z", value=x * y * z) >>> k = fp.Variable(name="k", value=0.) >>> viewer = MayaviClient(vars=fp.numerix.sin(k * xyzVar) + 2, ... ymin=0.1, ymax=0.9, ... datamin=1.1, datamax=4.0, ... title="MayaviClient test") >>> from builtins import range >>> for kval in range(10): ... k.setValue(kval) ... viewer.plot() >>> viewer._promptForOpinion()
Create a MayaviClient.
- Parameters:
vars (CellVariable or list) – CellVariable objects to plot
title (str, optional) – displayed at the top of the Viewer window
xmin (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
xmax (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
ymin (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
ymax (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
zmin (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
zmax (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
datamin (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
datamax (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
daemon_file (str, optional) – the path to the script to run the separate Mayavi viewer process. Defaults to fipy/viewers/mayaviViewer/mayaviDaemon.py
fps (float, optional) – frames per second to attempt to display
- __del__()¶
- property fps¶
The frames per second to attempt to display.
- property limits¶
- plot(filename=None)¶
Update the display of the viewed variables.
- Parameters:
filename (str) – If not None, the name of a file to save the image into.
- plotMesh(filename=None)¶
Display a representation of the mesh
- Parameters:
filename (str) – If not None, the name of a file to save the image into.
- setLimits(limits={}, **kwlimits)¶
Update the limits.
- Parameters:
limits (dict, optional) – a (deprecated) alternative to limit keyword arguments
xmin (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
xmax (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
ymin (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
ymax (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
zmin (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
zmax (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
datamin (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
datamax (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
- property title¶
The text appearing at the top center.
(default: if
len(self.vars) == 1
, the name ofself.vars[0]
, otherwise""
.)
- exception fipy.MeshDimensionError¶
Bases:
IndexError
- __cause__¶
exception cause
- __context__¶
exception context
- __delattr__(name, /)¶
Implement delattr(self, name).
- __getattribute__(name, /)¶
Return getattr(self, name).
- __reduce__()¶
Helper for pickle.
- __repr__()¶
Return repr(self).
- __setattr__(name, value, /)¶
Implement setattr(self, name, value).
- __setstate__()¶
- __str__()¶
Return str(self).
- __suppress_context__¶
- __traceback__¶
- add_note()¶
Exception.add_note(note) – add a note to the exception
- args¶
- with_traceback()¶
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
- class fipy.ModularVariable(*args, **kwds)¶
Bases:
CellVariable
The ModularVariable defines a variable that exists on the circle between
and
The following examples show how ModularVariable works. When subtracting the answer wraps back around the circle.
>>> from fipy.meshes import Grid1D >>> mesh = Grid1D(nx = 2) >>> from fipy.tools import numerix >>> pi = numerix.pi >>> v1 = ModularVariable(mesh = mesh, value = (2*pi/3, -2*pi/3)) >>> v2 = ModularVariable(mesh = mesh, value = -2*pi/3) >>> print(numerix.allclose(v2 - v1, (2*pi/3, 0))) 1
Obtaining the arithmetic face value.
>>> print(numerix.allclose(v1.arithmeticFaceValue, (2*pi/3, pi, -2*pi/3))) 1
Obtaining the gradient.
>>> print(numerix.allclose(v1.grad, ((pi/3, pi/3),))) 1
Obtaining the gradient at the faces.
>>> print(numerix.allclose(v1.faceGrad, ((0, 2*pi/3, 0),))) 1
Obtaining the gradient at the faces but without modular arithmetic.
>>> print(numerix.allclose(v1.faceGradNoMod, ((0, -4*pi/3, 0),))) 1
- Parameters:
mesh (Mesh) – the mesh that defines the geometry of this Variable
name (str) – the user-readable name of the Variable
value (float or array_like) – the initial value
rank (int) – the rank (number of dimensions) of each element of this Variable. Default: 0
elementshape (
tuple
ofint
) – the shape of each element of this variable Default: rank * (mesh.dim,)unit (str or PhysicalUnit) – The physical units of the variable
- __abs__()¶
Following test it to fix a bug with C inline string using abs() instead of fabs()
>>> print(abs(Variable(2.3) - Variable(1.2))) 1.1
Check representation works with different versions of numpy
>>> print(repr(abs(Variable(2.3)))) numerix.fabs(Variable(value=array(2.3)))
- __add__(other)¶
- __and__(other)¶
This test case has been added due to a weird bug that was appearing.
>>> a = Variable(value=(0, 0, 1, 1)) >>> b = Variable(value=(0, 1, 0, 1)) >>> print(numerix.equal((a == 0) & (b == 1), [False, True, False, False]).all()) True >>> print(a & b) [0 0 0 1] >>> from fipy.meshes import Grid1D >>> mesh = Grid1D(nx=4) >>> from fipy.variables.cellVariable import CellVariable >>> a = CellVariable(value=(0, 0, 1, 1), mesh=mesh) >>> b = CellVariable(value=(0, 1, 0, 1), mesh=mesh) >>> print(numerix.allequal((a == 0) & (b == 1), [False, True, False, False])) True >>> print(a & b) [0 0 0 1]
- __array__(t=None)¶
Attempt to convert the Variable to a numerix array object
>>> v = Variable(value=[2, 3]) >>> print(numerix.array(v)) [2 3]
A dimensional Variable will convert to the numeric value in its base units
>>> v = Variable(value=[2, 3], unit="mm") >>> numerix.array(v) array([ 0.002, 0.003])
- __array_priority__ = 100.0¶
- __array_wrap__(arr, context=None)¶
Required to prevent numpy not calling the reverse binary operations. Both the following tests are examples ufuncs.
>>> print(type(numerix.array([1.0, 2.0]) * Variable([1.0, 2.0]))) <class 'fipy.variables.binaryOperatorVariable...binOp'>
>>> from scipy.special import gamma as Gamma >>> print(type(Gamma(Variable([1.0, 2.0])))) <class 'fipy.variables.unaryOperatorVariable...unOp'>
- __bool__()¶
>>> print(bool(Variable(value=0))) 0 >>> print(bool(Variable(value=(0, 0, 1, 1)))) Traceback (most recent call last): ... ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
- __call__(points=None, order=0, nearestCellIDs=None)¶
Interpolates the CellVariable to a set of points using a method that has a memory requirement on the order of Ncells by Npoints in general, but uses only Ncells when the CellVariable’s mesh is a UniformGrid object.
Tests
>>> from fipy import * >>> m = Grid2D(nx=3, ny=2) >>> v = CellVariable(mesh=m, value=m.cellCenters[0]) >>> print(v(((0., 1.1, 1.2), (0., 1., 1.)))) [ 0.5 1.5 1.5] >>> print(v(((0., 1.1, 1.2), (0., 1., 1.)), order=1)) [ 0.25 1.1 1.2 ] >>> m0 = Grid2D(nx=2, ny=2, dx=1., dy=1.) >>> m1 = Grid2D(nx=4, ny=4, dx=.5, dy=.5) >>> x, y = m0.cellCenters >>> v0 = CellVariable(mesh=m0, value=x * y) >>> print(v0(m1.cellCenters.globalValue)) [ 0.25 0.25 0.75 0.75 0.25 0.25 0.75 0.75 0.75 0.75 2.25 2.25 0.75 0.75 2.25 2.25] >>> print(v0(m1.cellCenters.globalValue, order=1)) [ 0.125 0.25 0.5 0.625 0.25 0.375 0.875 1. 0.5 0.875 1.875 2.25 0.625 1. 2.25 2.625]
- __div__(other)¶
- __eq__(other)¶
Test if a Variable is equal to another quantity
>>> a = Variable(value=3) >>> b = (a == 4) >>> b (Variable(value=array(3)) == 4) >>> b() 0
- __float__()¶
- __ge__(other)¶
Test if a Variable is greater than or equal to another quantity
>>> a = Variable(value=3) >>> b = (a >= 4) >>> b (Variable(value=array(3)) >= 4) >>> b() 0 >>> a.value = 4 >>> print(b()) 1 >>> a.value = 5 >>> print(b()) 1
- __getitem__(index)¶
“Evaluate” the Variable and return the specified element
>>> a = Variable(value=((3., 4.), (5., 6.)), unit="m") + "4 m" >>> print(a[1, 1]) 10.0 m
It is an error to slice a Variable whose value is not sliceable
>>> Variable(value=3)[2] Traceback (most recent call last): ... IndexError: 0-d arrays can't be indexed
- __getstate__()¶
Used internally to collect the necessary information to
pickle
the CellVariable to persistent storage.
- __gt__(other)¶
Test if a Variable is greater than another quantity
>>> a = Variable(value=3) >>> b = (a > 4) >>> b (Variable(value=array(3)) > 4) >>> print(b()) 0 >>> a.value = 5 >>> print(b()) 1
- __hash__()¶
Return hash(self).
- __int__()¶
- __invert__()¶
Returns logical “not” of the Variable
>>> a = Variable(value=True) >>> print(~a) False
- __iter__()¶
- __le__(other)¶
Test if a Variable is less than or equal to another quantity
>>> a = Variable(value=3) >>> b = (a <= 4) >>> b (Variable(value=array(3)) <= 4) >>> b() 1 >>> a.value = 4 >>> print(b()) 1 >>> a.value = 5 >>> print(b()) 0
- __len__()¶
- __lt__(other)¶
Test if a Variable is less than another quantity
>>> a = Variable(value=3) >>> b = (a < 4) >>> b (Variable(value=array(3)) < 4) >>> b() 1 >>> a.value = 4 >>> print(b()) 0 >>> print(1000000000000000000 * Variable(1) < 1.) 0 >>> print(1000 * Variable(1) < 1.) 0
Python automatically reverses the arguments when necessary
>>> 4 > Variable(value=3) (Variable(value=array(3)) < 4)
- __mod__(other)¶
- __mul__(other)¶
- __ne__(other)¶
Test if a Variable is not equal to another quantity
>>> a = Variable(value=3) >>> b = (a != 4) >>> b (Variable(value=array(3)) != 4) >>> b() 1
- __neg__()¶
- static __new__(cls, *args, **kwds)¶
- __nonzero__()¶
>>> print(bool(Variable(value=0))) 0 >>> print(bool(Variable(value=(0, 0, 1, 1)))) Traceback (most recent call last): ... ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
- __or__(other)¶
This test case has been added due to a weird bug that was appearing.
>>> a = Variable(value=(0, 0, 1, 1)) >>> b = Variable(value=(0, 1, 0, 1)) >>> print(numerix.equal((a == 0) | (b == 1), [True, True, False, True]).all()) True >>> print(a | b) [0 1 1 1] >>> from fipy.meshes import Grid1D >>> mesh = Grid1D(nx=4) >>> from fipy.variables.cellVariable import CellVariable >>> a = CellVariable(value=(0, 0, 1, 1), mesh=mesh) >>> b = CellVariable(value=(0, 1, 0, 1), mesh=mesh) >>> print(numerix.allequal((a == 0) | (b == 1), [True, True, False, True])) True >>> print(a | b) [0 1 1 1]
- __pos__()¶
- __pow__(other)¶
return self**other, or self raised to power other
>>> print(Variable(1, "mol/l")**3) 1.0 mol**3/l**3 >>> print((Variable(1, "mol/l")**3).unit) <PhysicalUnit mol**3/l**3>
- __radd__(other)¶
- __rdiv__(other)¶
- __repr__()¶
Return repr(self).
- __rmul__(other)¶
- __rpow__(other)¶
- __rsub__(other)¶
- __rtruediv__(other)¶
- __setitem__(index, value)¶
- __setstate__(dict)¶
Used internally to create a new CellVariable from
pickled
persistent storage.
- __str__()¶
Return str(self).
- __sub__(other)¶
- __truediv__(other)¶
- all(axis=None)¶
>>> print(Variable(value=(0, 0, 1, 1)).all()) 0 >>> print(Variable(value=(1, 1, 1, 1)).all()) 1
- allclose(other, rtol=1e-05, atol=1e-08)¶
>>> var = Variable((1, 1)) >>> print(var.allclose((1, 1))) 1 >>> print(var.allclose((1,))) 1
The following test is to check that the system does not run out of memory.
>>> from fipy.tools import numerix >>> var = Variable(numerix.ones(10000)) >>> print(var.allclose(numerix.zeros(10000, 'l'))) False
- allequal(other)¶
- any(axis=None)¶
>>> print(Variable(value=0).any()) 0 >>> print(Variable(value=(0, 0, 1, 1)).any()) 1
- property arithmeticFaceValue¶
Returns a FaceVariable whose value corresponds to the arithmetic interpolation of the adjacent cells:
Adjusted for a ModularVariable
- cacheMe(recursive=False)¶
- property cellVolumeAverage¶
Return the cell-volume-weighted average of the CellVariable:
>>> from fipy.meshes import Grid2D >>> from fipy.variables.cellVariable import CellVariable >>> mesh = Grid2D(nx = 3, ny = 1, dx = .5, dy = .1) >>> var = CellVariable(value = (1, 2, 6), mesh = mesh) >>> print(var.cellVolumeAverage) 3.0
- constrain(value, where=None)¶
Constrains the CellVariable to value at a location specified by where.
>>> from fipy import * >>> m = Grid1D(nx=3) >>> v = CellVariable(mesh=m, value=m.cellCenters[0]) >>> v.constrain(0., where=m.facesLeft) >>> v.faceGrad.constrain([1.], where=m.facesRight) >>> print(v.faceGrad) [[ 1. 1. 1. 1.]] >>> print(v.faceValue) [ 0. 1. 2. 2.5]
Changing the constraint changes the dependencies
>>> v.constrain(1., where=m.facesLeft) >>> print(v.faceGrad) [[-1. 1. 1. 1.]] >>> print(v.faceValue) [ 1. 1. 2. 2.5]
Constraints can be Variable
>>> c = Variable(0.) >>> v.constrain(c, where=m.facesLeft) >>> print(v.faceGrad) [[ 1. 1. 1. 1.]] >>> print(v.faceValue) [ 0. 1. 2. 2.5] >>> c.value = 1. >>> print(v.faceGrad) [[-1. 1. 1. 1.]] >>> print(v.faceValue) [ 1. 1. 2. 2.5]
Constraints can have a Variable mask.
>>> v = CellVariable(mesh=m) >>> mask = FaceVariable(mesh=m, value=m.facesLeft) >>> v.constrain(1., where=mask) >>> print(v.faceValue) [ 1. 0. 0. 0.] >>> mask[:] = mask | m.facesRight >>> print(v.faceValue) [ 1. 0. 0. 1.]
- property constraintMask¶
Test that constraintMask returns a Variable that updates itself whenever the constraints change.
>>> from fipy import *
>>> m = Grid2D(nx=2, ny=2) >>> x, y = m.cellCenters >>> v0 = CellVariable(mesh=m) >>> v0.constrain(1., where=m.facesLeft) >>> print(v0.faceValue.constraintMask) [False False False False False False True False False True False False] >>> print(v0.faceValue) [ 0. 0. 0. 0. 0. 0. 1. 0. 0. 1. 0. 0.] >>> v0.constrain(3., where=m.facesRight) >>> print(v0.faceValue.constraintMask) [False False False False False False True False True True False True] >>> print(v0.faceValue) [ 0. 0. 0. 0. 0. 0. 1. 0. 3. 1. 0. 3.] >>> v1 = CellVariable(mesh=m) >>> v1.constrain(1., where=(x < 1) & (y < 1)) >>> print(v1.constraintMask) [ True False False False] >>> print(v1) [ 1. 0. 0. 0.] >>> v1.constrain(3., where=(x > 1) & (y > 1)) >>> print(v1.constraintMask) [ True False False True] >>> print(v1) [ 1. 0. 0. 3.]
- property constraints¶
- copy()¶
Make an duplicate of the Variable
>>> a = Variable(value=3) >>> b = a.copy() >>> b Variable(value=array(3))
The duplicate will not reflect changes made to the original
>>> a.setValue(5) >>> b Variable(value=array(3))
Check that this works for arrays.
>>> a = Variable(value=numerix.array((0, 1, 2))) >>> b = a.copy() >>> b Variable(value=array([0, 1, 2])) >>> a[1] = 3 >>> b Variable(value=array([0, 1, 2]))
- dontCacheMe(recursive=False)¶
- dot(other, opShape=None, operatorClass=None)¶
Return the mesh-element–by–mesh-element (cell-by-cell, face-by-face, etc.) scalar product
Both self and other can be of arbitrary rank, and other does not need to be a _MeshVariable.
- property faceGrad¶
Return
as a rank-1 FaceVariable (second-order gradient). Adjusted for a ModularVariable
- property faceGradAverage¶
Deprecated since version 3.3: use
grad.arithmeticFaceValue()
insteadReturn
as a rank-1 FaceVariable using averaging for the normal direction(second-order gradient)
- property faceGradNoMod¶
Return
as a rank-1 FaceVariable (second-order gradient). Not adjusted for a ModularVariable
- property faceValue¶
Returns a FaceVariable whose value corresponds to the arithmetic interpolation of the adjacent cells:
>>> from fipy.meshes import Grid1D >>> from fipy import numerix >>> mesh = Grid1D(dx = (1., 1.)) >>> L = 1 >>> R = 2 >>> var = CellVariable(mesh = mesh, value = (L, R)) >>> faceValue = var.arithmeticFaceValue[mesh.interiorFaces.value] >>> answer = (R - L) * (0.5 / 1.) + L >>> print(numerix.allclose(faceValue, answer, atol = 1e-10, rtol = 1e-10)) True
>>> mesh = Grid1D(dx = (2., 4.)) >>> var = CellVariable(mesh = mesh, value = (L, R)) >>> faceValue = var.arithmeticFaceValue[mesh.interiorFaces.value] >>> answer = (R - L) * (1.0 / 3.0) + L >>> print(numerix.allclose(faceValue, answer, atol = 1e-10, rtol = 1e-10)) True
>>> mesh = Grid1D(dx = (10., 100.)) >>> var = CellVariable(mesh = mesh, value = (L, R)) >>> faceValue = var.arithmeticFaceValue[mesh.interiorFaces.value] >>> answer = (R - L) * (5.0 / 55.0) + L >>> print(numerix.allclose(faceValue, answer, atol = 1e-10, rtol = 1e-10)) True
- property gaussGrad¶
Return
as a rank-1 CellVariable (first-order gradient).
- getsctype(default=None)¶
Returns the Numpy sctype of the underlying array.
>>> Variable(1).getsctype() == numerix.NUMERIX.obj2sctype(numerix.array(1)) True >>> Variable(1.).getsctype() == numerix.NUMERIX.obj2sctype(numerix.array(1.)) True >>> Variable((1, 1.)).getsctype() == numerix.NUMERIX.obj2sctype(numerix.array((1., 1.))) True
- property globalValue¶
Concatenate and return values from all processors
When running on a single processor, the result is identical to
value
.
- property grad¶
Return
as a rank-1 CellVariable (first-order gradient). Adjusted for a ModularVariable
- property harmonicFaceValue¶
Returns a FaceVariable whose value corresponds to the harmonic interpolation of the adjacent cells:
>>> from fipy.meshes import Grid1D >>> from fipy import numerix >>> mesh = Grid1D(dx = (1., 1.)) >>> L = 1 >>> R = 2 >>> var = CellVariable(mesh = mesh, value = (L, R)) >>> faceValue = var.harmonicFaceValue[mesh.interiorFaces.value] >>> answer = L * R / ((R - L) * (0.5 / 1.) + L) >>> print(numerix.allclose(faceValue, answer, atol = 1e-10, rtol = 1e-10)) True
>>> mesh = Grid1D(dx = (2., 4.)) >>> var = CellVariable(mesh = mesh, value = (L, R)) >>> faceValue = var.harmonicFaceValue[mesh.interiorFaces.value] >>> answer = L * R / ((R - L) * (1.0 / 3.0) + L) >>> print(numerix.allclose(faceValue, answer, atol = 1e-10, rtol = 1e-10)) True
>>> mesh = Grid1D(dx = (10., 100.)) >>> var = CellVariable(mesh = mesh, value = (L, R)) >>> faceValue = var.harmonicFaceValue[mesh.interiorFaces.value] >>> answer = L * R / ((R - L) * (5.0 / 55.0) + L) >>> print(numerix.allclose(faceValue, answer, atol = 1e-10, rtol = 1e-10)) True
- inBaseUnits()¶
Return the value of the Variable with all units reduced to their base SI elements.
>>> e = Variable(value="2.7 Hartree*Nav") >>> print(e.inBaseUnits().allclose("7088849.01085 kg*m**2/s**2/mol")) 1
- inUnitsOf(*units)¶
Returns one or more Variable objects that express the same physical quantity in different units. The units are specified by strings containing their names. The units must be compatible with the unit of the object. If one unit is specified, the return value is a single Variable.
>>> freeze = Variable('0 degC') >>> print(freeze.inUnitsOf('degF').allclose("32.0 degF")) 1
If several units are specified, the return value is a tuple of Variable instances with with one element per unit such that the sum of all quantities in the tuple equals the the original quantity and all the values except for the last one are integers. This is used to convert to irregular unit systems like hour/minute/second. The original object will not be changed.
>>> t = Variable(value=314159., unit='s') >>> from builtins import zip >>> print(numerix.allclose([e.allclose(v) for (e, v) in zip(t.inUnitsOf('d', 'h', 'min', 's'), ... ['3.0 d', '15.0 h', '15.0 min', '59.0 s'])], ... True)) 1
- itemset(value)¶
- property itemsize¶
- property leastSquaresGrad¶
Return
, which is determined by solving for
in the following matrix equation,
The matrix equation is derived by minimizing the following least squares sum,
Tests
>>> from fipy import Grid2D >>> m = Grid2D(nx=2, ny=2, dx=0.1, dy=2.0) >>> print(numerix.allclose(CellVariable(mesh=m, value=(0, 1, 3, 6)).leastSquaresGrad.globalValue, \ ... [[8.0, 8.0, 24.0, 24.0], ... [1.2, 2.0, 1.2, 2.0]])) True
>>> from fipy import Grid1D >>> print(numerix.allclose(CellVariable(mesh=Grid1D(dx=(2.0, 1.0, 0.5)), ... value=(0, 1, 2)).leastSquaresGrad.globalValue, [[0.461538461538, 0.8, 1.2]])) True
- max(axis=None)¶
- min(axis=None)¶
>>> from fipy import Grid2D, CellVariable >>> mesh = Grid2D(nx=5, ny=5) >>> x, y = mesh.cellCenters >>> v = CellVariable(mesh=mesh, value=x*y) >>> print(v.min()) 0.25
- property minmodFaceValue¶
Returns a FaceVariable with a value that is the minimum of the absolute values of the adjacent cells. If the values are of opposite sign then the result is zero:
>>> from fipy import * >>> print(CellVariable(mesh=Grid1D(nx=2), value=(1, 2)).minmodFaceValue) [1 1 2] >>> print(CellVariable(mesh=Grid1D(nx=2), value=(-1, -2)).minmodFaceValue) [-1 -1 -2] >>> print(CellVariable(mesh=Grid1D(nx=2), value=(-1, 2)).minmodFaceValue) [-1 0 2]
- property name¶
- property numericValue¶
- property old¶
Return the values of the CellVariable from the previous solution sweep.
Combinations of CellVariable’s should also return old values.
>>> from fipy.meshes import Grid1D >>> mesh = Grid1D(nx = 2) >>> from fipy.variables.cellVariable import CellVariable >>> var1 = CellVariable(mesh = mesh, value = (2, 3), hasOld = 1) >>> var2 = CellVariable(mesh = mesh, value = (3, 4)) >>> v = var1 * var2 >>> print(v) [ 6 12] >>> var1.value = ((3, 2)) >>> print(v) [9 8] >>> print(v.old) [ 6 12]
The following small test is to correct for a bug when the operator does not just use variables.
>>> v1 = var1 * 3 >>> print(v1) [9 6] >>> print(v1.old) [6 9]
- put(indices, value)¶
- property rank¶
- ravel()¶
- rdot(other, opShape=None, operatorClass=None)¶
Return the mesh-element–by–mesh-element (cell-by-cell, face-by-face, etc.) scalar product
Both self and other can be of arbitrary rank, and other does not need to be a _MeshVariable.
- release(constraint)¶
Remove constraint from self
>>> from fipy import * >>> m = Grid1D(nx=3) >>> v = CellVariable(mesh=m, value=m.cellCenters[0]) >>> c = Constraint(0., where=m.facesLeft) >>> v.constrain(c) >>> print(v.faceValue) [ 0. 1. 2. 2.5] >>> v.release(constraint=c) >>> print(v.faceValue) [ 0.5 1. 2. 2.5]
- setValue(value, unit=None, where=None)¶
Set the value of the Variable. Can take a masked array.
>>> a = Variable((1, 2, 3)) >>> a.setValue(5, where=(1, 0, 1)) >>> print(a) [5 2 5]
>>> b = Variable((4, 5, 6)) >>> a.setValue(b, where=(1, 0, 1)) >>> print(a) [4 2 6] >>> print(b) [4 5 6] >>> a.value = 3 >>> print(a) [3 3 3]
>>> b = numerix.array((3, 4, 5)) >>> a.value = b >>> a[:] = 1 >>> print(b) [3 4 5]
>>> a.setValue((4, 5, 6), where=(1, 0)) Traceback (most recent call last): .... ValueError: shape mismatch: objects cannot be broadcast to a single shape
- property shape¶
>>> from fipy.meshes import Grid2D >>> from fipy.variables.cellVariable import CellVariable >>> mesh = Grid2D(nx=2, ny=3) >>> var = CellVariable(mesh=mesh) >>> print(numerix.allequal(var.shape, (6,))) True >>> print(numerix.allequal(var.arithmeticFaceValue.shape, (17,))) True >>> print(numerix.allequal(var.grad.shape, (2, 6))) True >>> print(numerix.allequal(var.faceGrad.shape, (2, 17))) True
Have to account for zero length arrays
>>> from fipy import Grid1D >>> m = Grid1D(nx=0) >>> v = CellVariable(mesh=m, elementshape=(2,)) >>> numerix.allequal((v * 1).shape, (2, 0)) True
- std(axis=None, **kwargs)¶
Evaluate standard deviation of all the elements of a MeshVariable.
Adapted from http://mpitutorial.com/tutorials/mpi-reduce-and-allreduce/
>>> import fipy as fp >>> mesh = fp.Grid2D(nx=2, ny=2, dx=2., dy=5.) >>> var = fp.CellVariable(value=(1., 2., 3., 4.), mesh=mesh) >>> print((var.std()**2).allclose(1.25)) True
- property subscribedVariables¶
- sum(axis=None)¶
- take(ids, axis=0)¶
- tostring(max_line_width=75, precision=8, suppress_small=False, separator=' ')¶
- property unit¶
Return the unit object of self.
>>> Variable(value="1 m").unit <PhysicalUnit m>
- updateOld()¶
Set the values of the previous solution sweep to the current values. Test case due to bug.
>>> from fipy.meshes import Grid1D >>> mesh = Grid1D(nx = 1) >>> var = ModularVariable(mesh=mesh, value=1., hasOld=1) >>> var.updateOld() >>> var[:] = 2 >>> answer = CellVariable(mesh=mesh, value=1.) >>> print(var.old.allclose(answer)) True
- property value¶
“Evaluate” the Variable and return its value (longhand)
>>> a = Variable(value=3) >>> print(a.value) 3 >>> b = a + 4 >>> b (Variable(value=array(3)) + 4) >>> b.value 7
- class fipy.MultiViewer(viewers)¶
Bases:
AbstractViewer
Treat a collection of different viewers (such for different 2D plots or 1D plots with different axes) as a single viewer that will plot() all subviewers simultaneously.
- Parameters:
viewers (
list
of ~fipy.viewers.viewer.Viewer) – the viewers to bind together
- property limits¶
- plot()¶
Update the display of the viewed variables.
- Parameters:
filename (str) – If not None, the name of a file to save the image into.
- plotMesh(filename=None)¶
Display a representation of the mesh
- Parameters:
filename (str) – If not None, the name of a file to save the image into.
- setLimits(limits={}, **kwlimits)¶
Update the limits.
- Parameters:
limits (dict, optional) – a (deprecated) alternative to limit keyword arguments
xmin (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
xmax (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
ymin (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
ymax (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
zmin (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
zmax (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
datamin (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
datamax (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
- property title¶
The text appearing at the top center.
(default: if
len(self.vars) == 1
, the name ofself.vars[0]
, otherwise""
.)
- class fipy.NthOrderBoundaryCondition(faces, value, order)¶
Bases:
BoundaryCondition
This boundary condition is generally used in conjunction with a ImplicitDiffusionTerm that has multiple coefficients. It does not have any direct effect on the solution matrices, but its derivatives do.
Creates an NthOrderBoundaryCondition.
- Parameters:
faces (
FaceVariable
ofbool
) – Mask of faces where this condition applies.value (float) – Value to impose.
order (int) – Order of the boundary condition. An order of 0 corresponds to a FixedValue and an order of 1 corresponds to a FixedFlux. Even and odd orders behave like FixedValue and FixedFlux objects, respectively, but apply to higher order terms.
- __repr__()¶
Return repr(self).
- class fipy.PeriodicGrid1D(dx=1.0, nx=None, overlap=2, *args, **kwargs)¶
Bases:
NonUniformGrid1D
Creates a Periodic grid mesh.
>>> mesh = PeriodicGrid1D(dx = (1, 2, 3))
>>> print(numerix.allclose(numerix.nonzero(mesh.exteriorFaces)[0], ... [3])) True
>>> print(numerix.allclose(mesh.faceCellIDs.filled(-999), ... [[2, 0, 1, 2], ... [0, 1, 2, -999]])) True
>>> print(numerix.allclose(mesh._cellDistances, ... [ 2., 1.5, 2.5, 1.5])) True
>>> print(numerix.allclose(mesh._cellToCellDistances, ... [[ 2., 1.5, 2.5], ... [ 1.5, 2.5, 2. ]])) True
>>> print(numerix.allclose(mesh.faceNormals, ... [[ 1., 1., 1., 1.]])) True
>>> print(numerix.allclose(mesh._cellVertexIDs, ... [[1, 2, 2], ... [0, 1, 0]])) True
- property VTKCellDataSet¶
Returns a TVTK DataSet representing the cells of this mesh
- property VTKFaceDataSet¶
Returns a TVTK DataSet representing the face centers of this mesh
- __add__(other)¶
Either translate a Mesh or concatenate two Mesh objects.
>>> from fipy.meshes import Grid2D >>> baseMesh = Grid2D(dx = 1.0, dy = 1.0, nx = 2, ny = 2) >>> print(baseMesh.cellCenters) [[ 0.5 1.5 0.5 1.5] [ 0.5 0.5 1.5 1.5]]
If a vector is added to a Mesh, a translated Mesh is returned
>>> translatedMesh = baseMesh + ((5,), (10,)) >>> print(translatedMesh.cellCenters) [[ 5.5 6.5 5.5 6.5] [ 10.5 10.5 11.5 11.5]]
If a Mesh is added to a Mesh, a concatenation of the two Mesh objects is returned
>>> addedMesh = baseMesh + (baseMesh + ((2,), (0,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 2.5 3.5 2.5 3.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5]]
The two Mesh objects need not be properly aligned in order to concatenate them but the resulting mesh may not have the intended connectivity
>>> addedMesh = baseMesh + (baseMesh + ((3,), (0,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 3.5 4.5 3.5 4.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5]]
>>> addedMesh = baseMesh + (baseMesh + ((2,), (2,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 2.5 3.5 2.5 3.5] [ 0.5 0.5 1.5 1.5 2.5 2.5 3.5 3.5]]
No provision is made to avoid or consolidate overlapping Mesh objects
>>> addedMesh = baseMesh + (baseMesh + ((1,), (0,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 1.5 2.5 1.5 2.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5]]
Different Mesh classes can be concatenated
>>> from fipy.meshes import Tri2D >>> triMesh = Tri2D(dx = 1.0, dy = 1.0, nx = 2, ny = 1) >>> triMesh = triMesh + ((2,), (0,)) >>> triAddedMesh = baseMesh + triMesh >>> cellCenters = [[0.5, 1.5, 0.5, 1.5, 2.83333333, 3.83333333, ... 2.5, 3.5, 2.16666667, 3.16666667, 2.5, 3.5], ... [0.5, 0.5, 1.5, 1.5, 0.5, 0.5, 0.83333333, 0.83333333, ... 0.5, 0.5, 0.16666667, 0.16666667]] >>> print(numerix.allclose(triAddedMesh.cellCenters, ... cellCenters)) True
again, their faces need not align, but the mesh may not have the desired connectivity
>>> triMesh = Tri2D(dx = 1.0, dy = 2.0, nx = 2, ny = 1) >>> triMesh = triMesh + ((2,), (0,)) >>> triAddedMesh = baseMesh + triMesh >>> cellCenters = [[ 0.5, 1.5, 0.5, 1.5, 2.83333333, 3.83333333, ... 2.5, 3.5, 2.16666667, 3.16666667, 2.5, 3.5], ... [ 0.5, 0.5, 1.5, 1.5, 1., 1., ... 1.66666667, 1.66666667, 1., 1., 0.33333333, 0.33333333]] >>> print(numerix.allclose(triAddedMesh.cellCenters, ... cellCenters)) True
Mesh concatenation is not limited to 2D meshes
>>> from fipy.meshes import Grid3D >>> threeDBaseMesh = Grid3D(dx = 1.0, dy = 1.0, dz = 1.0, ... nx = 2, ny = 2, nz = 2) >>> threeDSecondMesh = Grid3D(dx = 1.0, dy = 1.0, dz = 1.0, ... nx = 1, ny = 1, nz = 1) >>> threeDAddedMesh = threeDBaseMesh + (threeDSecondMesh + ((2,), (0,), (0,))) >>> print(threeDAddedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 0.5 1.5 0.5 1.5 2.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5 0.5] [ 0.5 0.5 0.5 0.5 1.5 1.5 1.5 1.5 0.5]]
but the different Mesh objects must, of course, have the same dimensionality.
>>> InvalidMesh = threeDBaseMesh + baseMesh Traceback (most recent call last): ... MeshAdditionError: Dimensions do not match
- __div__(other)¶
Tests. >>> from fipy import * >>> print((Grid1D(nx=1) / 2.).cellCenters) [[ 0.25]] >>> AbstractMesh(communicator=None) / 2. Traceback (most recent call last): … NotImplementedError
- __getstate__()¶
Helper for pickle.
- __mul__(factor)¶
Dilate a Mesh by factor.
>>> from fipy.meshes import Grid2D >>> baseMesh = Grid2D(dx = 1.0, dy = 1.0, nx = 2, ny = 2) >>> print(baseMesh.cellCenters) [[ 0.5 1.5 0.5 1.5] [ 0.5 0.5 1.5 1.5]]
The factor can be a scalar
>>> dilatedMesh = baseMesh * 3 >>> print(dilatedMesh.cellCenters) [[ 1.5 4.5 1.5 4.5] [ 1.5 1.5 4.5 4.5]]
or a vector
>>> dilatedMesh = baseMesh * ((3,), (2,)) >>> print(dilatedMesh.cellCenters) [[ 1.5 4.5 1.5 4.5] [ 1. 1. 3. 3. ]]
but the vector must have the same dimensionality as the Mesh
>>> dilatedMesh = baseMesh * ((3,), (2,), (1,)) Traceback (most recent call last): ... ValueError: shape mismatch: objects cannot be broadcast to a single shape
- __radd__(other)¶
Either translate a Mesh or concatenate two Mesh objects.
>>> from fipy.meshes import Grid2D >>> baseMesh = Grid2D(dx = 1.0, dy = 1.0, nx = 2, ny = 2) >>> print(baseMesh.cellCenters) [[ 0.5 1.5 0.5 1.5] [ 0.5 0.5 1.5 1.5]]
If a vector is added to a Mesh, a translated Mesh is returned
>>> translatedMesh = baseMesh + ((5,), (10,)) >>> print(translatedMesh.cellCenters) [[ 5.5 6.5 5.5 6.5] [ 10.5 10.5 11.5 11.5]]
If a Mesh is added to a Mesh, a concatenation of the two Mesh objects is returned
>>> addedMesh = baseMesh + (baseMesh + ((2,), (0,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 2.5 3.5 2.5 3.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5]]
The two Mesh objects need not be properly aligned in order to concatenate them but the resulting mesh may not have the intended connectivity
>>> addedMesh = baseMesh + (baseMesh + ((3,), (0,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 3.5 4.5 3.5 4.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5]]
>>> addedMesh = baseMesh + (baseMesh + ((2,), (2,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 2.5 3.5 2.5 3.5] [ 0.5 0.5 1.5 1.5 2.5 2.5 3.5 3.5]]
No provision is made to avoid or consolidate overlapping Mesh objects
>>> addedMesh = baseMesh + (baseMesh + ((1,), (0,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 1.5 2.5 1.5 2.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5]]
Different Mesh classes can be concatenated
>>> from fipy.meshes import Tri2D >>> triMesh = Tri2D(dx = 1.0, dy = 1.0, nx = 2, ny = 1) >>> triMesh = triMesh + ((2,), (0,)) >>> triAddedMesh = baseMesh + triMesh >>> cellCenters = [[0.5, 1.5, 0.5, 1.5, 2.83333333, 3.83333333, ... 2.5, 3.5, 2.16666667, 3.16666667, 2.5, 3.5], ... [0.5, 0.5, 1.5, 1.5, 0.5, 0.5, 0.83333333, 0.83333333, ... 0.5, 0.5, 0.16666667, 0.16666667]] >>> print(numerix.allclose(triAddedMesh.cellCenters, ... cellCenters)) True
again, their faces need not align, but the mesh may not have the desired connectivity
>>> triMesh = Tri2D(dx = 1.0, dy = 2.0, nx = 2, ny = 1) >>> triMesh = triMesh + ((2,), (0,)) >>> triAddedMesh = baseMesh + triMesh >>> cellCenters = [[ 0.5, 1.5, 0.5, 1.5, 2.83333333, 3.83333333, ... 2.5, 3.5, 2.16666667, 3.16666667, 2.5, 3.5], ... [ 0.5, 0.5, 1.5, 1.5, 1., 1., ... 1.66666667, 1.66666667, 1., 1., 0.33333333, 0.33333333]] >>> print(numerix.allclose(triAddedMesh.cellCenters, ... cellCenters)) True
Mesh concatenation is not limited to 2D meshes
>>> from fipy.meshes import Grid3D >>> threeDBaseMesh = Grid3D(dx = 1.0, dy = 1.0, dz = 1.0, ... nx = 2, ny = 2, nz = 2) >>> threeDSecondMesh = Grid3D(dx = 1.0, dy = 1.0, dz = 1.0, ... nx = 1, ny = 1, nz = 1) >>> threeDAddedMesh = threeDBaseMesh + (threeDSecondMesh + ((2,), (0,), (0,))) >>> print(threeDAddedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 0.5 1.5 0.5 1.5 2.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5 0.5] [ 0.5 0.5 0.5 0.5 1.5 1.5 1.5 1.5 0.5]]
but the different Mesh objects must, of course, have the same dimensionality.
>>> InvalidMesh = threeDBaseMesh + baseMesh Traceback (most recent call last): ... MeshAdditionError: Dimensions do not match
- __repr__()¶
Return repr(self).
- __rmul__(factor)¶
Dilate a Mesh by factor.
>>> from fipy.meshes import Grid2D >>> baseMesh = Grid2D(dx = 1.0, dy = 1.0, nx = 2, ny = 2) >>> print(baseMesh.cellCenters) [[ 0.5 1.5 0.5 1.5] [ 0.5 0.5 1.5 1.5]]
The factor can be a scalar
>>> dilatedMesh = baseMesh * 3 >>> print(dilatedMesh.cellCenters) [[ 1.5 4.5 1.5 4.5] [ 1.5 1.5 4.5 4.5]]
or a vector
>>> dilatedMesh = baseMesh * ((3,), (2,)) >>> print(dilatedMesh.cellCenters) [[ 1.5 4.5 1.5 4.5] [ 1. 1. 3. 3. ]]
but the vector must have the same dimensionality as the Mesh
>>> dilatedMesh = baseMesh * ((3,), (2,), (1,)) Traceback (most recent call last): ... ValueError: shape mismatch: objects cannot be broadcast to a single shape
- __setstate__(state)¶
- __sub__(other)¶
Tests. >>> from fipy import * >>> m = Grid1D() >>> print((m - ((1,))).cellCenters) [[-0.5]] >>> ((1,)) - m Traceback (most recent call last): … TypeError: unsupported operand type(s) for -: ‘tuple’ and ‘UniformGrid1D’
- __truediv__(other)¶
Tests. >>> from fipy import * >>> print((Grid1D(nx=1) / 2.).cellCenters) [[ 0.25]] >>> AbstractMesh(communicator=None) / 2. Traceback (most recent call last): … NotImplementedError
- property aspect2D¶
The physical y vs x aspect ratio of a 2D mesh
- property cellCenters¶
Defined outside of a geometry class since we need the CellVariable version of cellCenters; that is, the cellCenters defined in
fipy.meshes.mesh
and not in any geometry (since a CellVariable requires a reference to a mesh).
- property cellDistanceVectors¶
- property cellFaceIDs¶
- property cellToFaceDistanceVectors¶
- property cellVolumes¶
- property extents¶
- property exteriorFaces¶
- property faceCenters¶
- property facesBack¶
Return list of faces on back boundary of 3D Mesh with the z-axis running from front to back.
>>> from fipy import Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((6, 7, 8, 9, 10, 11), ... numerix.nonzero(mesh.facesBack)[0])) True >>> ignore = mesh.facesBack.value
- property facesBottom¶
Return list of faces on bottom boundary of 2D or 3D Mesh with the y-axis running from bottom to top.
>>> from fipy import Grid2D, Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((12, 13, 14), ... numerix.nonzero(mesh.facesBottom)[0])) True >>> ignore = mesh.facesBottom.value >>> x, y, z = mesh.faceCenters >>> print(numerix.allequal((12, 13), ... numerix.nonzero(mesh.facesBottom & (x < 1))[0])) True >>> ignore = mesh.facesBottom.value
- property facesDown¶
Return list of faces on bottom boundary of 2D or 3D Mesh with the y-axis running from bottom to top.
>>> from fipy import Grid2D, Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((12, 13, 14), ... numerix.nonzero(mesh.facesBottom)[0])) True >>> ignore = mesh.facesBottom.value >>> x, y, z = mesh.faceCenters >>> print(numerix.allequal((12, 13), ... numerix.nonzero(mesh.facesBottom & (x < 1))[0])) True >>> ignore = mesh.facesBottom.value
- property facesFront¶
Return list of faces on front boundary of 3D Mesh with the z-axis running from front to back.
>>> from fipy import Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((0, 1, 2, 3, 4, 5), ... numerix.nonzero(mesh.facesFront)[0])) True >>> ignore = mesh.facesFront.value
- property facesLeft¶
Return face on left boundary of Mesh as list with the x-axis running from left to right.
>>> from fipy import Grid2D, Grid3D >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((21, 25), ... numerix.nonzero(mesh.facesLeft)[0])) True >>> ignore = mesh.facesLeft.value >>> mesh = Grid2D(nx = 3, ny = 2, dx = 0.5, dy = 2.) >>> print(numerix.allequal((9, 13), ... numerix.nonzero(mesh.facesLeft)[0])) True >>> ignore = mesh.facesLeft.value
- property facesRight¶
Return list of faces on right boundary of Mesh with the x-axis running from left to right.
>>> from fipy import Grid2D, Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((24, 28), ... numerix.nonzero(mesh.facesRight)[0])) True >>> ignore = mesh.facesRight.value >>> mesh = Grid2D(nx = 3, ny = 2, dx = 0.5, dy = 2.) >>> print(numerix.allequal((12, 16), ... numerix.nonzero(mesh.facesRight)[0])) True >>> ignore = mesh.facesRight.value
- property facesTop¶
Return list of faces on top boundary of 2D or 3D Mesh with the y-axis running from bottom to top.
>>> from fipy import Grid2D, Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((18, 19, 20), ... numerix.nonzero(mesh.facesTop)[0])) True >>> ignore = mesh.facesTop.value >>> mesh = Grid2D(nx = 3, ny = 2, dx = 0.5, dy = 2.) >>> print(numerix.allequal((6, 7, 8), ... numerix.nonzero(mesh.facesTop)[0])) True >>> ignore = mesh.facesTop.value
- property facesUp¶
Return list of faces on top boundary of 2D or 3D Mesh with the y-axis running from bottom to top.
>>> from fipy import Grid2D, Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((18, 19, 20), ... numerix.nonzero(mesh.facesTop)[0])) True >>> ignore = mesh.facesTop.value >>> mesh = Grid2D(nx = 3, ny = 2, dx = 0.5, dy = 2.) >>> print(numerix.allequal((6, 7, 8), ... numerix.nonzero(mesh.facesTop)[0])) True >>> ignore = mesh.facesTop.value
- getNearestCell(point)¶
- property interiorFaceCellIDs¶
- property interiorFaceIDs¶
- property interiorFaces¶
- property scale¶
- property scaledCellDistances¶
- property scaledCellToCellDistances¶
- property scaledCellVolumes¶
- property scaledFaceAreas¶
- property scaledFaceToCellDistances¶
- property x¶
Equivalent to using
cellCenters
[0]
.>>> from fipy import * >>> print(Grid1D(nx=2).x) [ 0.5 1.5]
- property y¶
Equivalent to using
cellCenters
[1]
.>>> from fipy import * >>> print(Grid2D(nx=2, ny=2).y) [ 0.5 0.5 1.5 1.5] >>> print(Grid1D(nx=2).y) Traceback (most recent call last): ... AttributeError: 1D meshes do not have a "y" attribute.
- property z¶
Equivalent to using
cellCenters
[2]
.>>> from fipy import * >>> print(Grid3D(nx=2, ny=2, nz=2).z) [ 0.5 0.5 0.5 0.5 1.5 1.5 1.5 1.5] >>> print(Grid2D(nx=2, ny=2).z) Traceback (most recent call last): ... AttributeError: 1D and 2D meshes do not have a "z" attribute.
- class fipy.PeriodicGrid2D(dx=1.0, dy=1.0, nx=None, ny=None, overlap=2, communicator=SerialPETScCommWrapper(), *args, **kwargs)¶
Bases:
_BasePeriodicGrid2D
Creates a periodic 2D grid mesh with horizontal faces numbered first and then vertical faces. Vertices and cells are numbered in the usual way.
>>> from fipy import numerix
>>> mesh = PeriodicGrid2D(dx = 1., dy = 0.5, nx = 2, ny = 2)
>>> print(numerix.allclose(numerix.nonzero(mesh.exteriorFaces)[0], ... [ 4, 5, 8, 11])) True
>>> print(numerix.allclose(mesh.faceCellIDs.filled(-1), ... [[2, 3, 0, 1, 2, 3, 1, 0, 1, 3, 2, 3], ... [0, 1, 2, 3, -1, -1, 0, 1, -1, 2, 3, -1]])) True
>>> print(numerix.allclose(mesh._cellDistances, ... [ 0.5, 0.5, 0.5, 0.5, 0.25, 0.25, 1., 1., 0.5, 1., 1., 0.5])) True
>>> print(numerix.allclose(mesh.cellFaceIDs, ... [[0, 1, 2, 3], ... [7, 6, 10, 9], ... [2, 3, 0, 1], ... [6, 7, 9, 10]])) True
>>> print(numerix.allclose(mesh._cellToCellDistances, ... [[ 0.5, 0.5, 0.5, 0.5], ... [ 1., 1., 1., 1. ], ... [ 0.5, 0.5, 0.5, 0.5], ... [ 1., 1., 1., 1. ]])) True
>>> normals = [[0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1], ... [1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0]]
>>> print(numerix.allclose(mesh.faceNormals, normals)) True
>>> print(numerix.allclose(mesh._cellVertexIDs, ... [[4, 5, 7, 8], ... [3, 4, 6, 7], ... [1, 2, 4, 5], ... [0, 1, 3, 4]])) True
- property VTKCellDataSet¶
Returns a TVTK DataSet representing the cells of this mesh
- property VTKFaceDataSet¶
Returns a TVTK DataSet representing the face centers of this mesh
- __add__(other)¶
Either translate a Mesh or concatenate two Mesh objects.
>>> from fipy.meshes import Grid2D >>> baseMesh = Grid2D(dx = 1.0, dy = 1.0, nx = 2, ny = 2) >>> print(baseMesh.cellCenters) [[ 0.5 1.5 0.5 1.5] [ 0.5 0.5 1.5 1.5]]
If a vector is added to a Mesh, a translated Mesh is returned
>>> translatedMesh = baseMesh + ((5,), (10,)) >>> print(translatedMesh.cellCenters) [[ 5.5 6.5 5.5 6.5] [ 10.5 10.5 11.5 11.5]]
If a Mesh is added to a Mesh, a concatenation of the two Mesh objects is returned
>>> addedMesh = baseMesh + (baseMesh + ((2,), (0,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 2.5 3.5 2.5 3.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5]]
The two Mesh objects need not be properly aligned in order to concatenate them but the resulting mesh may not have the intended connectivity
>>> addedMesh = baseMesh + (baseMesh + ((3,), (0,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 3.5 4.5 3.5 4.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5]]
>>> addedMesh = baseMesh + (baseMesh + ((2,), (2,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 2.5 3.5 2.5 3.5] [ 0.5 0.5 1.5 1.5 2.5 2.5 3.5 3.5]]
No provision is made to avoid or consolidate overlapping Mesh objects
>>> addedMesh = baseMesh + (baseMesh + ((1,), (0,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 1.5 2.5 1.5 2.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5]]
Different Mesh classes can be concatenated
>>> from fipy.meshes import Tri2D >>> triMesh = Tri2D(dx = 1.0, dy = 1.0, nx = 2, ny = 1) >>> triMesh = triMesh + ((2,), (0,)) >>> triAddedMesh = baseMesh + triMesh >>> cellCenters = [[0.5, 1.5, 0.5, 1.5, 2.83333333, 3.83333333, ... 2.5, 3.5, 2.16666667, 3.16666667, 2.5, 3.5], ... [0.5, 0.5, 1.5, 1.5, 0.5, 0.5, 0.83333333, 0.83333333, ... 0.5, 0.5, 0.16666667, 0.16666667]] >>> print(numerix.allclose(triAddedMesh.cellCenters, ... cellCenters)) True
again, their faces need not align, but the mesh may not have the desired connectivity
>>> triMesh = Tri2D(dx = 1.0, dy = 2.0, nx = 2, ny = 1) >>> triMesh = triMesh + ((2,), (0,)) >>> triAddedMesh = baseMesh + triMesh >>> cellCenters = [[ 0.5, 1.5, 0.5, 1.5, 2.83333333, 3.83333333, ... 2.5, 3.5, 2.16666667, 3.16666667, 2.5, 3.5], ... [ 0.5, 0.5, 1.5, 1.5, 1., 1., ... 1.66666667, 1.66666667, 1., 1., 0.33333333, 0.33333333]] >>> print(numerix.allclose(triAddedMesh.cellCenters, ... cellCenters)) True
Mesh concatenation is not limited to 2D meshes
>>> from fipy.meshes import Grid3D >>> threeDBaseMesh = Grid3D(dx = 1.0, dy = 1.0, dz = 1.0, ... nx = 2, ny = 2, nz = 2) >>> threeDSecondMesh = Grid3D(dx = 1.0, dy = 1.0, dz = 1.0, ... nx = 1, ny = 1, nz = 1) >>> threeDAddedMesh = threeDBaseMesh + (threeDSecondMesh + ((2,), (0,), (0,))) >>> print(threeDAddedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 0.5 1.5 0.5 1.5 2.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5 0.5] [ 0.5 0.5 0.5 0.5 1.5 1.5 1.5 1.5 0.5]]
but the different Mesh objects must, of course, have the same dimensionality.
>>> InvalidMesh = threeDBaseMesh + baseMesh Traceback (most recent call last): ... MeshAdditionError: Dimensions do not match
- __div__(other)¶
Tests. >>> from fipy import * >>> print((Grid1D(nx=1) / 2.).cellCenters) [[ 0.25]] >>> AbstractMesh(communicator=None) / 2. Traceback (most recent call last): … NotImplementedError
- __getstate__()¶
Helper for pickle.
- __mul__(factor)¶
Dilate a Mesh by factor.
>>> from fipy.meshes import Grid2D >>> baseMesh = Grid2D(dx = 1.0, dy = 1.0, nx = 2, ny = 2) >>> print(baseMesh.cellCenters) [[ 0.5 1.5 0.5 1.5] [ 0.5 0.5 1.5 1.5]]
The factor can be a scalar
>>> dilatedMesh = baseMesh * 3 >>> print(dilatedMesh.cellCenters) [[ 1.5 4.5 1.5 4.5] [ 1.5 1.5 4.5 4.5]]
or a vector
>>> dilatedMesh = baseMesh * ((3,), (2,)) >>> print(dilatedMesh.cellCenters) [[ 1.5 4.5 1.5 4.5] [ 1. 1. 3. 3. ]]
but the vector must have the same dimensionality as the Mesh
>>> dilatedMesh = baseMesh * ((3,), (2,), (1,)) Traceback (most recent call last): ... ValueError: shape mismatch: objects cannot be broadcast to a single shape
- __radd__(other)¶
Either translate a Mesh or concatenate two Mesh objects.
>>> from fipy.meshes import Grid2D >>> baseMesh = Grid2D(dx = 1.0, dy = 1.0, nx = 2, ny = 2) >>> print(baseMesh.cellCenters) [[ 0.5 1.5 0.5 1.5] [ 0.5 0.5 1.5 1.5]]
If a vector is added to a Mesh, a translated Mesh is returned
>>> translatedMesh = baseMesh + ((5,), (10,)) >>> print(translatedMesh.cellCenters) [[ 5.5 6.5 5.5 6.5] [ 10.5 10.5 11.5 11.5]]
If a Mesh is added to a Mesh, a concatenation of the two Mesh objects is returned
>>> addedMesh = baseMesh + (baseMesh + ((2,), (0,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 2.5 3.5 2.5 3.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5]]
The two Mesh objects need not be properly aligned in order to concatenate them but the resulting mesh may not have the intended connectivity
>>> addedMesh = baseMesh + (baseMesh + ((3,), (0,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 3.5 4.5 3.5 4.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5]]
>>> addedMesh = baseMesh + (baseMesh + ((2,), (2,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 2.5 3.5 2.5 3.5] [ 0.5 0.5 1.5 1.5 2.5 2.5 3.5 3.5]]
No provision is made to avoid or consolidate overlapping Mesh objects
>>> addedMesh = baseMesh + (baseMesh + ((1,), (0,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 1.5 2.5 1.5 2.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5]]
Different Mesh classes can be concatenated
>>> from fipy.meshes import Tri2D >>> triMesh = Tri2D(dx = 1.0, dy = 1.0, nx = 2, ny = 1) >>> triMesh = triMesh + ((2,), (0,)) >>> triAddedMesh = baseMesh + triMesh >>> cellCenters = [[0.5, 1.5, 0.5, 1.5, 2.83333333, 3.83333333, ... 2.5, 3.5, 2.16666667, 3.16666667, 2.5, 3.5], ... [0.5, 0.5, 1.5, 1.5, 0.5, 0.5, 0.83333333, 0.83333333, ... 0.5, 0.5, 0.16666667, 0.16666667]] >>> print(numerix.allclose(triAddedMesh.cellCenters, ... cellCenters)) True
again, their faces need not align, but the mesh may not have the desired connectivity
>>> triMesh = Tri2D(dx = 1.0, dy = 2.0, nx = 2, ny = 1) >>> triMesh = triMesh + ((2,), (0,)) >>> triAddedMesh = baseMesh + triMesh >>> cellCenters = [[ 0.5, 1.5, 0.5, 1.5, 2.83333333, 3.83333333, ... 2.5, 3.5, 2.16666667, 3.16666667, 2.5, 3.5], ... [ 0.5, 0.5, 1.5, 1.5, 1., 1., ... 1.66666667, 1.66666667, 1., 1., 0.33333333, 0.33333333]] >>> print(numerix.allclose(triAddedMesh.cellCenters, ... cellCenters)) True
Mesh concatenation is not limited to 2D meshes
>>> from fipy.meshes import Grid3D >>> threeDBaseMesh = Grid3D(dx = 1.0, dy = 1.0, dz = 1.0, ... nx = 2, ny = 2, nz = 2) >>> threeDSecondMesh = Grid3D(dx = 1.0, dy = 1.0, dz = 1.0, ... nx = 1, ny = 1, nz = 1) >>> threeDAddedMesh = threeDBaseMesh + (threeDSecondMesh + ((2,), (0,), (0,))) >>> print(threeDAddedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 0.5 1.5 0.5 1.5 2.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5 0.5] [ 0.5 0.5 0.5 0.5 1.5 1.5 1.5 1.5 0.5]]
but the different Mesh objects must, of course, have the same dimensionality.
>>> InvalidMesh = threeDBaseMesh + baseMesh Traceback (most recent call last): ... MeshAdditionError: Dimensions do not match
- __repr__()¶
Return repr(self).
- __rmul__(factor)¶
Dilate a Mesh by factor.
>>> from fipy.meshes import Grid2D >>> baseMesh = Grid2D(dx = 1.0, dy = 1.0, nx = 2, ny = 2) >>> print(baseMesh.cellCenters) [[ 0.5 1.5 0.5 1.5] [ 0.5 0.5 1.5 1.5]]
The factor can be a scalar
>>> dilatedMesh = baseMesh * 3 >>> print(dilatedMesh.cellCenters) [[ 1.5 4.5 1.5 4.5] [ 1.5 1.5 4.5 4.5]]
or a vector
>>> dilatedMesh = baseMesh * ((3,), (2,)) >>> print(dilatedMesh.cellCenters) [[ 1.5 4.5 1.5 4.5] [ 1. 1. 3. 3. ]]
but the vector must have the same dimensionality as the Mesh
>>> dilatedMesh = baseMesh * ((3,), (2,), (1,)) Traceback (most recent call last): ... ValueError: shape mismatch: objects cannot be broadcast to a single shape
- __setstate__(state)¶
- __sub__(other)¶
Tests. >>> from fipy import * >>> m = Grid1D() >>> print((m - ((1,))).cellCenters) [[-0.5]] >>> ((1,)) - m Traceback (most recent call last): … TypeError: unsupported operand type(s) for -: ‘tuple’ and ‘UniformGrid1D’
- __truediv__(other)¶
Tests. >>> from fipy import * >>> print((Grid1D(nx=1) / 2.).cellCenters) [[ 0.25]] >>> AbstractMesh(communicator=None) / 2. Traceback (most recent call last): … NotImplementedError
- property aspect2D¶
The physical y vs x aspect ratio of a 2D mesh
- property cellCenters¶
- property cellDistanceVectors¶
- property cellFaceIDs¶
- property cellToFaceDistanceVectors¶
- property cellVolumes¶
- property extents¶
- property exteriorFaces¶
- extrude(extrudeFunc=<function Mesh2D.<lambda>>, layers=1)¶
This function returns a new 3D mesh. The 2D mesh is extruded using the extrudeFunc and the number of layers.
>>> from fipy.meshes.nonUniformGrid2D import NonUniformGrid2D >>> print(NonUniformGrid2D(nx=2, ny=2).extrude(layers=2).cellCenters) [[ 0.5 1.5 0.5 1.5 0.5 1.5 0.5 1.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5] [ 0.5 0.5 0.5 0.5 1.5 1.5 1.5 1.5]]
>>> from fipy.meshes.tri2D import Tri2D >>> print(Tri2D().extrude(layers=2).cellCenters.allclose([[ 0.83333333, 0.5, 0.16666667, 0.5, 0.83333333, 0.5, ... 0.16666667, 0.5 ], ... [ 0.5, 0.83333333, 0.5, 0.16666667, 0.5, 0.83333333, ... 0.5, 0.16666667], ... [ 0.5, 0.5, 0.5, 0.5, 1.5, 1.5, 1.5, ... 1.5 ]])) True
- Parameters:
extrudeFunc (function) – Takes the vertex coordinates and returns the displaced values
layers (int) – Number of layers in the extruded mesh (number of times extrudeFunc will be called)
- property faceCenters¶
- property facesBack¶
Return list of faces on back boundary of 3D Mesh with the z-axis running from front to back.
>>> from fipy import Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((6, 7, 8, 9, 10, 11), ... numerix.nonzero(mesh.facesBack)[0])) True >>> ignore = mesh.facesBack.value
- property facesBottom¶
Return list of faces on bottom boundary of 2D or 3D Mesh with the y-axis running from bottom to top.
>>> from fipy import Grid2D, Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((12, 13, 14), ... numerix.nonzero(mesh.facesBottom)[0])) True >>> ignore = mesh.facesBottom.value >>> x, y, z = mesh.faceCenters >>> print(numerix.allequal((12, 13), ... numerix.nonzero(mesh.facesBottom & (x < 1))[0])) True >>> ignore = mesh.facesBottom.value
- property facesDown¶
Return list of faces on bottom boundary of 2D or 3D Mesh with the y-axis running from bottom to top.
>>> from fipy import Grid2D, Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((12, 13, 14), ... numerix.nonzero(mesh.facesBottom)[0])) True >>> ignore = mesh.facesBottom.value >>> x, y, z = mesh.faceCenters >>> print(numerix.allequal((12, 13), ... numerix.nonzero(mesh.facesBottom & (x < 1))[0])) True >>> ignore = mesh.facesBottom.value
- property facesFront¶
Return list of faces on front boundary of 3D Mesh with the z-axis running from front to back.
>>> from fipy import Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((0, 1, 2, 3, 4, 5), ... numerix.nonzero(mesh.facesFront)[0])) True >>> ignore = mesh.facesFront.value
- property facesLeft¶
Return face on left boundary of Mesh as list with the x-axis running from left to right.
>>> from fipy import Grid2D, Grid3D >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((21, 25), ... numerix.nonzero(mesh.facesLeft)[0])) True >>> ignore = mesh.facesLeft.value >>> mesh = Grid2D(nx = 3, ny = 2, dx = 0.5, dy = 2.) >>> print(numerix.allequal((9, 13), ... numerix.nonzero(mesh.facesLeft)[0])) True >>> ignore = mesh.facesLeft.value
- property facesRight¶
Return list of faces on right boundary of Mesh with the x-axis running from left to right.
>>> from fipy import Grid2D, Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((24, 28), ... numerix.nonzero(mesh.facesRight)[0])) True >>> ignore = mesh.facesRight.value >>> mesh = Grid2D(nx = 3, ny = 2, dx = 0.5, dy = 2.) >>> print(numerix.allequal((12, 16), ... numerix.nonzero(mesh.facesRight)[0])) True >>> ignore = mesh.facesRight.value
- property facesTop¶
Return list of faces on top boundary of 2D or 3D Mesh with the y-axis running from bottom to top.
>>> from fipy import Grid2D, Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((18, 19, 20), ... numerix.nonzero(mesh.facesTop)[0])) True >>> ignore = mesh.facesTop.value >>> mesh = Grid2D(nx = 3, ny = 2, dx = 0.5, dy = 2.) >>> print(numerix.allequal((6, 7, 8), ... numerix.nonzero(mesh.facesTop)[0])) True >>> ignore = mesh.facesTop.value
- property facesUp¶
Return list of faces on top boundary of 2D or 3D Mesh with the y-axis running from bottom to top.
>>> from fipy import Grid2D, Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((18, 19, 20), ... numerix.nonzero(mesh.facesTop)[0])) True >>> ignore = mesh.facesTop.value >>> mesh = Grid2D(nx = 3, ny = 2, dx = 0.5, dy = 2.) >>> print(numerix.allequal((6, 7, 8), ... numerix.nonzero(mesh.facesTop)[0])) True >>> ignore = mesh.facesTop.value
- getNearestCell(point)¶
- property interiorFaceCellIDs¶
- property interiorFaceIDs¶
- property interiorFaces¶
- property scale¶
- property scaledCellDistances¶
- property scaledCellToCellDistances¶
- property scaledCellVolumes¶
- property scaledFaceAreas¶
- property scaledFaceToCellDistances¶
- property x¶
Equivalent to using
cellCenters
[0]
.>>> from fipy import * >>> print(Grid1D(nx=2).x) [ 0.5 1.5]
- property y¶
Equivalent to using
cellCenters
[1]
.>>> from fipy import * >>> print(Grid2D(nx=2, ny=2).y) [ 0.5 0.5 1.5 1.5] >>> print(Grid1D(nx=2).y) Traceback (most recent call last): ... AttributeError: 1D meshes do not have a "y" attribute.
- property z¶
Equivalent to using
cellCenters
[2]
.>>> from fipy import * >>> print(Grid3D(nx=2, ny=2, nz=2).z) [ 0.5 0.5 0.5 0.5 1.5 1.5 1.5 1.5] >>> print(Grid2D(nx=2, ny=2).z) Traceback (most recent call last): ... AttributeError: 1D and 2D meshes do not have a "z" attribute.
- class fipy.PeriodicGrid2DLeftRight(dx=1.0, dy=1.0, nx=None, ny=None, overlap=2, communicator=SerialPETScCommWrapper(), *args, **kwargs)¶
Bases:
_BasePeriodicGrid2D
- property VTKCellDataSet¶
Returns a TVTK DataSet representing the cells of this mesh
- property VTKFaceDataSet¶
Returns a TVTK DataSet representing the face centers of this mesh
- __add__(other)¶
Either translate a Mesh or concatenate two Mesh objects.
>>> from fipy.meshes import Grid2D >>> baseMesh = Grid2D(dx = 1.0, dy = 1.0, nx = 2, ny = 2) >>> print(baseMesh.cellCenters) [[ 0.5 1.5 0.5 1.5] [ 0.5 0.5 1.5 1.5]]
If a vector is added to a Mesh, a translated Mesh is returned
>>> translatedMesh = baseMesh + ((5,), (10,)) >>> print(translatedMesh.cellCenters) [[ 5.5 6.5 5.5 6.5] [ 10.5 10.5 11.5 11.5]]
If a Mesh is added to a Mesh, a concatenation of the two Mesh objects is returned
>>> addedMesh = baseMesh + (baseMesh + ((2,), (0,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 2.5 3.5 2.5 3.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5]]
The two Mesh objects need not be properly aligned in order to concatenate them but the resulting mesh may not have the intended connectivity
>>> addedMesh = baseMesh + (baseMesh + ((3,), (0,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 3.5 4.5 3.5 4.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5]]
>>> addedMesh = baseMesh + (baseMesh + ((2,), (2,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 2.5 3.5 2.5 3.5] [ 0.5 0.5 1.5 1.5 2.5 2.5 3.5 3.5]]
No provision is made to avoid or consolidate overlapping Mesh objects
>>> addedMesh = baseMesh + (baseMesh + ((1,), (0,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 1.5 2.5 1.5 2.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5]]
Different Mesh classes can be concatenated
>>> from fipy.meshes import Tri2D >>> triMesh = Tri2D(dx = 1.0, dy = 1.0, nx = 2, ny = 1) >>> triMesh = triMesh + ((2,), (0,)) >>> triAddedMesh = baseMesh + triMesh >>> cellCenters = [[0.5, 1.5, 0.5, 1.5, 2.83333333, 3.83333333, ... 2.5, 3.5, 2.16666667, 3.16666667, 2.5, 3.5], ... [0.5, 0.5, 1.5, 1.5, 0.5, 0.5, 0.83333333, 0.83333333, ... 0.5, 0.5, 0.16666667, 0.16666667]] >>> print(numerix.allclose(triAddedMesh.cellCenters, ... cellCenters)) True
again, their faces need not align, but the mesh may not have the desired connectivity
>>> triMesh = Tri2D(dx = 1.0, dy = 2.0, nx = 2, ny = 1) >>> triMesh = triMesh + ((2,), (0,)) >>> triAddedMesh = baseMesh + triMesh >>> cellCenters = [[ 0.5, 1.5, 0.5, 1.5, 2.83333333, 3.83333333, ... 2.5, 3.5, 2.16666667, 3.16666667, 2.5, 3.5], ... [ 0.5, 0.5, 1.5, 1.5, 1., 1., ... 1.66666667, 1.66666667, 1., 1., 0.33333333, 0.33333333]] >>> print(numerix.allclose(triAddedMesh.cellCenters, ... cellCenters)) True
Mesh concatenation is not limited to 2D meshes
>>> from fipy.meshes import Grid3D >>> threeDBaseMesh = Grid3D(dx = 1.0, dy = 1.0, dz = 1.0, ... nx = 2, ny = 2, nz = 2) >>> threeDSecondMesh = Grid3D(dx = 1.0, dy = 1.0, dz = 1.0, ... nx = 1, ny = 1, nz = 1) >>> threeDAddedMesh = threeDBaseMesh + (threeDSecondMesh + ((2,), (0,), (0,))) >>> print(threeDAddedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 0.5 1.5 0.5 1.5 2.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5 0.5] [ 0.5 0.5 0.5 0.5 1.5 1.5 1.5 1.5 0.5]]
but the different Mesh objects must, of course, have the same dimensionality.
>>> InvalidMesh = threeDBaseMesh + baseMesh Traceback (most recent call last): ... MeshAdditionError: Dimensions do not match
- __div__(other)¶
Tests. >>> from fipy import * >>> print((Grid1D(nx=1) / 2.).cellCenters) [[ 0.25]] >>> AbstractMesh(communicator=None) / 2. Traceback (most recent call last): … NotImplementedError
- __getstate__()¶
Helper for pickle.
- __mul__(factor)¶
Dilate a Mesh by factor.
>>> from fipy.meshes import Grid2D >>> baseMesh = Grid2D(dx = 1.0, dy = 1.0, nx = 2, ny = 2) >>> print(baseMesh.cellCenters) [[ 0.5 1.5 0.5 1.5] [ 0.5 0.5 1.5 1.5]]
The factor can be a scalar
>>> dilatedMesh = baseMesh * 3 >>> print(dilatedMesh.cellCenters) [[ 1.5 4.5 1.5 4.5] [ 1.5 1.5 4.5 4.5]]
or a vector
>>> dilatedMesh = baseMesh * ((3,), (2,)) >>> print(dilatedMesh.cellCenters) [[ 1.5 4.5 1.5 4.5] [ 1. 1. 3. 3. ]]
but the vector must have the same dimensionality as the Mesh
>>> dilatedMesh = baseMesh * ((3,), (2,), (1,)) Traceback (most recent call last): ... ValueError: shape mismatch: objects cannot be broadcast to a single shape
- __radd__(other)¶
Either translate a Mesh or concatenate two Mesh objects.
>>> from fipy.meshes import Grid2D >>> baseMesh = Grid2D(dx = 1.0, dy = 1.0, nx = 2, ny = 2) >>> print(baseMesh.cellCenters) [[ 0.5 1.5 0.5 1.5] [ 0.5 0.5 1.5 1.5]]
If a vector is added to a Mesh, a translated Mesh is returned
>>> translatedMesh = baseMesh + ((5,), (10,)) >>> print(translatedMesh.cellCenters) [[ 5.5 6.5 5.5 6.5] [ 10.5 10.5 11.5 11.5]]
If a Mesh is added to a Mesh, a concatenation of the two Mesh objects is returned
>>> addedMesh = baseMesh + (baseMesh + ((2,), (0,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 2.5 3.5 2.5 3.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5]]
The two Mesh objects need not be properly aligned in order to concatenate them but the resulting mesh may not have the intended connectivity
>>> addedMesh = baseMesh + (baseMesh + ((3,), (0,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 3.5 4.5 3.5 4.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5]]
>>> addedMesh = baseMesh + (baseMesh + ((2,), (2,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 2.5 3.5 2.5 3.5] [ 0.5 0.5 1.5 1.5 2.5 2.5 3.5 3.5]]
No provision is made to avoid or consolidate overlapping Mesh objects
>>> addedMesh = baseMesh + (baseMesh + ((1,), (0,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 1.5 2.5 1.5 2.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5]]
Different Mesh classes can be concatenated
>>> from fipy.meshes import Tri2D >>> triMesh = Tri2D(dx = 1.0, dy = 1.0, nx = 2, ny = 1) >>> triMesh = triMesh + ((2,), (0,)) >>> triAddedMesh = baseMesh + triMesh >>> cellCenters = [[0.5, 1.5, 0.5, 1.5, 2.83333333, 3.83333333, ... 2.5, 3.5, 2.16666667, 3.16666667, 2.5, 3.5], ... [0.5, 0.5, 1.5, 1.5, 0.5, 0.5, 0.83333333, 0.83333333, ... 0.5, 0.5, 0.16666667, 0.16666667]] >>> print(numerix.allclose(triAddedMesh.cellCenters, ... cellCenters)) True
again, their faces need not align, but the mesh may not have the desired connectivity
>>> triMesh = Tri2D(dx = 1.0, dy = 2.0, nx = 2, ny = 1) >>> triMesh = triMesh + ((2,), (0,)) >>> triAddedMesh = baseMesh + triMesh >>> cellCenters = [[ 0.5, 1.5, 0.5, 1.5, 2.83333333, 3.83333333, ... 2.5, 3.5, 2.16666667, 3.16666667, 2.5, 3.5], ... [ 0.5, 0.5, 1.5, 1.5, 1., 1., ... 1.66666667, 1.66666667, 1., 1., 0.33333333, 0.33333333]] >>> print(numerix.allclose(triAddedMesh.cellCenters, ... cellCenters)) True
Mesh concatenation is not limited to 2D meshes
>>> from fipy.meshes import Grid3D >>> threeDBaseMesh = Grid3D(dx = 1.0, dy = 1.0, dz = 1.0, ... nx = 2, ny = 2, nz = 2) >>> threeDSecondMesh = Grid3D(dx = 1.0, dy = 1.0, dz = 1.0, ... nx = 1, ny = 1, nz = 1) >>> threeDAddedMesh = threeDBaseMesh + (threeDSecondMesh + ((2,), (0,), (0,))) >>> print(threeDAddedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 0.5 1.5 0.5 1.5 2.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5 0.5] [ 0.5 0.5 0.5 0.5 1.5 1.5 1.5 1.5 0.5]]
but the different Mesh objects must, of course, have the same dimensionality.
>>> InvalidMesh = threeDBaseMesh + baseMesh Traceback (most recent call last): ... MeshAdditionError: Dimensions do not match
- __repr__()¶
Return repr(self).
- __rmul__(factor)¶
Dilate a Mesh by factor.
>>> from fipy.meshes import Grid2D >>> baseMesh = Grid2D(dx = 1.0, dy = 1.0, nx = 2, ny = 2) >>> print(baseMesh.cellCenters) [[ 0.5 1.5 0.5 1.5] [ 0.5 0.5 1.5 1.5]]
The factor can be a scalar
>>> dilatedMesh = baseMesh * 3 >>> print(dilatedMesh.cellCenters) [[ 1.5 4.5 1.5 4.5] [ 1.5 1.5 4.5 4.5]]
or a vector
>>> dilatedMesh = baseMesh * ((3,), (2,)) >>> print(dilatedMesh.cellCenters) [[ 1.5 4.5 1.5 4.5] [ 1. 1. 3. 3. ]]
but the vector must have the same dimensionality as the Mesh
>>> dilatedMesh = baseMesh * ((3,), (2,), (1,)) Traceback (most recent call last): ... ValueError: shape mismatch: objects cannot be broadcast to a single shape
- __setstate__(state)¶
- __sub__(other)¶
Tests. >>> from fipy import * >>> m = Grid1D() >>> print((m - ((1,))).cellCenters) [[-0.5]] >>> ((1,)) - m Traceback (most recent call last): … TypeError: unsupported operand type(s) for -: ‘tuple’ and ‘UniformGrid1D’
- __truediv__(other)¶
Tests. >>> from fipy import * >>> print((Grid1D(nx=1) / 2.).cellCenters) [[ 0.25]] >>> AbstractMesh(communicator=None) / 2. Traceback (most recent call last): … NotImplementedError
- property aspect2D¶
The physical y vs x aspect ratio of a 2D mesh
- property cellCenters¶
- property cellDistanceVectors¶
- property cellFaceIDs¶
- property cellToFaceDistanceVectors¶
- property cellVolumes¶
- property extents¶
- property exteriorFaces¶
- extrude(extrudeFunc=<function Mesh2D.<lambda>>, layers=1)¶
This function returns a new 3D mesh. The 2D mesh is extruded using the extrudeFunc and the number of layers.
>>> from fipy.meshes.nonUniformGrid2D import NonUniformGrid2D >>> print(NonUniformGrid2D(nx=2, ny=2).extrude(layers=2).cellCenters) [[ 0.5 1.5 0.5 1.5 0.5 1.5 0.5 1.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5] [ 0.5 0.5 0.5 0.5 1.5 1.5 1.5 1.5]]
>>> from fipy.meshes.tri2D import Tri2D >>> print(Tri2D().extrude(layers=2).cellCenters.allclose([[ 0.83333333, 0.5, 0.16666667, 0.5, 0.83333333, 0.5, ... 0.16666667, 0.5 ], ... [ 0.5, 0.83333333, 0.5, 0.16666667, 0.5, 0.83333333, ... 0.5, 0.16666667], ... [ 0.5, 0.5, 0.5, 0.5, 1.5, 1.5, 1.5, ... 1.5 ]])) True
- Parameters:
extrudeFunc (function) – Takes the vertex coordinates and returns the displaced values
layers (int) – Number of layers in the extruded mesh (number of times extrudeFunc will be called)
- property faceCenters¶
- property facesBack¶
Return list of faces on back boundary of 3D Mesh with the z-axis running from front to back.
>>> from fipy import Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((6, 7, 8, 9, 10, 11), ... numerix.nonzero(mesh.facesBack)[0])) True >>> ignore = mesh.facesBack.value
- property facesBottom¶
Return list of faces on bottom boundary of 2D or 3D Mesh with the y-axis running from bottom to top.
>>> from fipy import Grid2D, Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((12, 13, 14), ... numerix.nonzero(mesh.facesBottom)[0])) True >>> ignore = mesh.facesBottom.value >>> x, y, z = mesh.faceCenters >>> print(numerix.allequal((12, 13), ... numerix.nonzero(mesh.facesBottom & (x < 1))[0])) True >>> ignore = mesh.facesBottom.value
- property facesDown¶
Return list of faces on bottom boundary of 2D or 3D Mesh with the y-axis running from bottom to top.
>>> from fipy import Grid2D, Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((12, 13, 14), ... numerix.nonzero(mesh.facesBottom)[0])) True >>> ignore = mesh.facesBottom.value >>> x, y, z = mesh.faceCenters >>> print(numerix.allequal((12, 13), ... numerix.nonzero(mesh.facesBottom & (x < 1))[0])) True >>> ignore = mesh.facesBottom.value
- property facesFront¶
Return list of faces on front boundary of 3D Mesh with the z-axis running from front to back.
>>> from fipy import Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((0, 1, 2, 3, 4, 5), ... numerix.nonzero(mesh.facesFront)[0])) True >>> ignore = mesh.facesFront.value
- property facesLeft¶
Return face on left boundary of Mesh as list with the x-axis running from left to right.
>>> from fipy import Grid2D, Grid3D >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((21, 25), ... numerix.nonzero(mesh.facesLeft)[0])) True >>> ignore = mesh.facesLeft.value >>> mesh = Grid2D(nx = 3, ny = 2, dx = 0.5, dy = 2.) >>> print(numerix.allequal((9, 13), ... numerix.nonzero(mesh.facesLeft)[0])) True >>> ignore = mesh.facesLeft.value
- property facesRight¶
Return list of faces on right boundary of Mesh with the x-axis running from left to right.
>>> from fipy import Grid2D, Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((24, 28), ... numerix.nonzero(mesh.facesRight)[0])) True >>> ignore = mesh.facesRight.value >>> mesh = Grid2D(nx = 3, ny = 2, dx = 0.5, dy = 2.) >>> print(numerix.allequal((12, 16), ... numerix.nonzero(mesh.facesRight)[0])) True >>> ignore = mesh.facesRight.value
- property facesTop¶
Return list of faces on top boundary of 2D or 3D Mesh with the y-axis running from bottom to top.
>>> from fipy import Grid2D, Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((18, 19, 20), ... numerix.nonzero(mesh.facesTop)[0])) True >>> ignore = mesh.facesTop.value >>> mesh = Grid2D(nx = 3, ny = 2, dx = 0.5, dy = 2.) >>> print(numerix.allequal((6, 7, 8), ... numerix.nonzero(mesh.facesTop)[0])) True >>> ignore = mesh.facesTop.value
- property facesUp¶
Return list of faces on top boundary of 2D or 3D Mesh with the y-axis running from bottom to top.
>>> from fipy import Grid2D, Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((18, 19, 20), ... numerix.nonzero(mesh.facesTop)[0])) True >>> ignore = mesh.facesTop.value >>> mesh = Grid2D(nx = 3, ny = 2, dx = 0.5, dy = 2.) >>> print(numerix.allequal((6, 7, 8), ... numerix.nonzero(mesh.facesTop)[0])) True >>> ignore = mesh.facesTop.value
- getNearestCell(point)¶
- property interiorFaceCellIDs¶
- property interiorFaceIDs¶
- property interiorFaces¶
- property scale¶
- property scaledCellDistances¶
- property scaledCellToCellDistances¶
- property scaledCellVolumes¶
- property scaledFaceAreas¶
- property scaledFaceToCellDistances¶
- property x¶
Equivalent to using
cellCenters
[0]
.>>> from fipy import * >>> print(Grid1D(nx=2).x) [ 0.5 1.5]
- property y¶
Equivalent to using
cellCenters
[1]
.>>> from fipy import * >>> print(Grid2D(nx=2, ny=2).y) [ 0.5 0.5 1.5 1.5] >>> print(Grid1D(nx=2).y) Traceback (most recent call last): ... AttributeError: 1D meshes do not have a "y" attribute.
- property z¶
Equivalent to using
cellCenters
[2]
.>>> from fipy import * >>> print(Grid3D(nx=2, ny=2, nz=2).z) [ 0.5 0.5 0.5 0.5 1.5 1.5 1.5 1.5] >>> print(Grid2D(nx=2, ny=2).z) Traceback (most recent call last): ... AttributeError: 1D and 2D meshes do not have a "z" attribute.
- class fipy.PeriodicGrid2DTopBottom(dx=1.0, dy=1.0, nx=None, ny=None, overlap=2, communicator=SerialPETScCommWrapper(), *args, **kwargs)¶
Bases:
_BasePeriodicGrid2D
- property VTKCellDataSet¶
Returns a TVTK DataSet representing the cells of this mesh
- property VTKFaceDataSet¶
Returns a TVTK DataSet representing the face centers of this mesh
- __add__(other)¶
Either translate a Mesh or concatenate two Mesh objects.
>>> from fipy.meshes import Grid2D >>> baseMesh = Grid2D(dx = 1.0, dy = 1.0, nx = 2, ny = 2) >>> print(baseMesh.cellCenters) [[ 0.5 1.5 0.5 1.5] [ 0.5 0.5 1.5 1.5]]
If a vector is added to a Mesh, a translated Mesh is returned
>>> translatedMesh = baseMesh + ((5,), (10,)) >>> print(translatedMesh.cellCenters) [[ 5.5 6.5 5.5 6.5] [ 10.5 10.5 11.5 11.5]]
If a Mesh is added to a Mesh, a concatenation of the two Mesh objects is returned
>>> addedMesh = baseMesh + (baseMesh + ((2,), (0,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 2.5 3.5 2.5 3.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5]]
The two Mesh objects need not be properly aligned in order to concatenate them but the resulting mesh may not have the intended connectivity
>>> addedMesh = baseMesh + (baseMesh + ((3,), (0,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 3.5 4.5 3.5 4.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5]]
>>> addedMesh = baseMesh + (baseMesh + ((2,), (2,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 2.5 3.5 2.5 3.5] [ 0.5 0.5 1.5 1.5 2.5 2.5 3.5 3.5]]
No provision is made to avoid or consolidate overlapping Mesh objects
>>> addedMesh = baseMesh + (baseMesh + ((1,), (0,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 1.5 2.5 1.5 2.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5]]
Different Mesh classes can be concatenated
>>> from fipy.meshes import Tri2D >>> triMesh = Tri2D(dx = 1.0, dy = 1.0, nx = 2, ny = 1) >>> triMesh = triMesh + ((2,), (0,)) >>> triAddedMesh = baseMesh + triMesh >>> cellCenters = [[0.5, 1.5, 0.5, 1.5, 2.83333333, 3.83333333, ... 2.5, 3.5, 2.16666667, 3.16666667, 2.5, 3.5], ... [0.5, 0.5, 1.5, 1.5, 0.5, 0.5, 0.83333333, 0.83333333, ... 0.5, 0.5, 0.16666667, 0.16666667]] >>> print(numerix.allclose(triAddedMesh.cellCenters, ... cellCenters)) True
again, their faces need not align, but the mesh may not have the desired connectivity
>>> triMesh = Tri2D(dx = 1.0, dy = 2.0, nx = 2, ny = 1) >>> triMesh = triMesh + ((2,), (0,)) >>> triAddedMesh = baseMesh + triMesh >>> cellCenters = [[ 0.5, 1.5, 0.5, 1.5, 2.83333333, 3.83333333, ... 2.5, 3.5, 2.16666667, 3.16666667, 2.5, 3.5], ... [ 0.5, 0.5, 1.5, 1.5, 1., 1., ... 1.66666667, 1.66666667, 1., 1., 0.33333333, 0.33333333]] >>> print(numerix.allclose(triAddedMesh.cellCenters, ... cellCenters)) True
Mesh concatenation is not limited to 2D meshes
>>> from fipy.meshes import Grid3D >>> threeDBaseMesh = Grid3D(dx = 1.0, dy = 1.0, dz = 1.0, ... nx = 2, ny = 2, nz = 2) >>> threeDSecondMesh = Grid3D(dx = 1.0, dy = 1.0, dz = 1.0, ... nx = 1, ny = 1, nz = 1) >>> threeDAddedMesh = threeDBaseMesh + (threeDSecondMesh + ((2,), (0,), (0,))) >>> print(threeDAddedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 0.5 1.5 0.5 1.5 2.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5 0.5] [ 0.5 0.5 0.5 0.5 1.5 1.5 1.5 1.5 0.5]]
but the different Mesh objects must, of course, have the same dimensionality.
>>> InvalidMesh = threeDBaseMesh + baseMesh Traceback (most recent call last): ... MeshAdditionError: Dimensions do not match
- __div__(other)¶
Tests. >>> from fipy import * >>> print((Grid1D(nx=1) / 2.).cellCenters) [[ 0.25]] >>> AbstractMesh(communicator=None) / 2. Traceback (most recent call last): … NotImplementedError
- __getstate__()¶
Helper for pickle.
- __mul__(factor)¶
Dilate a Mesh by factor.
>>> from fipy.meshes import Grid2D >>> baseMesh = Grid2D(dx = 1.0, dy = 1.0, nx = 2, ny = 2) >>> print(baseMesh.cellCenters) [[ 0.5 1.5 0.5 1.5] [ 0.5 0.5 1.5 1.5]]
The factor can be a scalar
>>> dilatedMesh = baseMesh * 3 >>> print(dilatedMesh.cellCenters) [[ 1.5 4.5 1.5 4.5] [ 1.5 1.5 4.5 4.5]]
or a vector
>>> dilatedMesh = baseMesh * ((3,), (2,)) >>> print(dilatedMesh.cellCenters) [[ 1.5 4.5 1.5 4.5] [ 1. 1. 3. 3. ]]
but the vector must have the same dimensionality as the Mesh
>>> dilatedMesh = baseMesh * ((3,), (2,), (1,)) Traceback (most recent call last): ... ValueError: shape mismatch: objects cannot be broadcast to a single shape
- __radd__(other)¶
Either translate a Mesh or concatenate two Mesh objects.
>>> from fipy.meshes import Grid2D >>> baseMesh = Grid2D(dx = 1.0, dy = 1.0, nx = 2, ny = 2) >>> print(baseMesh.cellCenters) [[ 0.5 1.5 0.5 1.5] [ 0.5 0.5 1.5 1.5]]
If a vector is added to a Mesh, a translated Mesh is returned
>>> translatedMesh = baseMesh + ((5,), (10,)) >>> print(translatedMesh.cellCenters) [[ 5.5 6.5 5.5 6.5] [ 10.5 10.5 11.5 11.5]]
If a Mesh is added to a Mesh, a concatenation of the two Mesh objects is returned
>>> addedMesh = baseMesh + (baseMesh + ((2,), (0,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 2.5 3.5 2.5 3.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5]]
The two Mesh objects need not be properly aligned in order to concatenate them but the resulting mesh may not have the intended connectivity
>>> addedMesh = baseMesh + (baseMesh + ((3,), (0,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 3.5 4.5 3.5 4.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5]]
>>> addedMesh = baseMesh + (baseMesh + ((2,), (2,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 2.5 3.5 2.5 3.5] [ 0.5 0.5 1.5 1.5 2.5 2.5 3.5 3.5]]
No provision is made to avoid or consolidate overlapping Mesh objects
>>> addedMesh = baseMesh + (baseMesh + ((1,), (0,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 1.5 2.5 1.5 2.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5]]
Different Mesh classes can be concatenated
>>> from fipy.meshes import Tri2D >>> triMesh = Tri2D(dx = 1.0, dy = 1.0, nx = 2, ny = 1) >>> triMesh = triMesh + ((2,), (0,)) >>> triAddedMesh = baseMesh + triMesh >>> cellCenters = [[0.5, 1.5, 0.5, 1.5, 2.83333333, 3.83333333, ... 2.5, 3.5, 2.16666667, 3.16666667, 2.5, 3.5], ... [0.5, 0.5, 1.5, 1.5, 0.5, 0.5, 0.83333333, 0.83333333, ... 0.5, 0.5, 0.16666667, 0.16666667]] >>> print(numerix.allclose(triAddedMesh.cellCenters, ... cellCenters)) True
again, their faces need not align, but the mesh may not have the desired connectivity
>>> triMesh = Tri2D(dx = 1.0, dy = 2.0, nx = 2, ny = 1) >>> triMesh = triMesh + ((2,), (0,)) >>> triAddedMesh = baseMesh + triMesh >>> cellCenters = [[ 0.5, 1.5, 0.5, 1.5, 2.83333333, 3.83333333, ... 2.5, 3.5, 2.16666667, 3.16666667, 2.5, 3.5], ... [ 0.5, 0.5, 1.5, 1.5, 1., 1., ... 1.66666667, 1.66666667, 1., 1., 0.33333333, 0.33333333]] >>> print(numerix.allclose(triAddedMesh.cellCenters, ... cellCenters)) True
Mesh concatenation is not limited to 2D meshes
>>> from fipy.meshes import Grid3D >>> threeDBaseMesh = Grid3D(dx = 1.0, dy = 1.0, dz = 1.0, ... nx = 2, ny = 2, nz = 2) >>> threeDSecondMesh = Grid3D(dx = 1.0, dy = 1.0, dz = 1.0, ... nx = 1, ny = 1, nz = 1) >>> threeDAddedMesh = threeDBaseMesh + (threeDSecondMesh + ((2,), (0,), (0,))) >>> print(threeDAddedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 0.5 1.5 0.5 1.5 2.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5 0.5] [ 0.5 0.5 0.5 0.5 1.5 1.5 1.5 1.5 0.5]]
but the different Mesh objects must, of course, have the same dimensionality.
>>> InvalidMesh = threeDBaseMesh + baseMesh Traceback (most recent call last): ... MeshAdditionError: Dimensions do not match
- __repr__()¶
Return repr(self).
- __rmul__(factor)¶
Dilate a Mesh by factor.
>>> from fipy.meshes import Grid2D >>> baseMesh = Grid2D(dx = 1.0, dy = 1.0, nx = 2, ny = 2) >>> print(baseMesh.cellCenters) [[ 0.5 1.5 0.5 1.5] [ 0.5 0.5 1.5 1.5]]
The factor can be a scalar
>>> dilatedMesh = baseMesh * 3 >>> print(dilatedMesh.cellCenters) [[ 1.5 4.5 1.5 4.5] [ 1.5 1.5 4.5 4.5]]
or a vector
>>> dilatedMesh = baseMesh * ((3,), (2,)) >>> print(dilatedMesh.cellCenters) [[ 1.5 4.5 1.5 4.5] [ 1. 1. 3. 3. ]]
but the vector must have the same dimensionality as the Mesh
>>> dilatedMesh = baseMesh * ((3,), (2,), (1,)) Traceback (most recent call last): ... ValueError: shape mismatch: objects cannot be broadcast to a single shape
- __setstate__(state)¶
- __sub__(other)¶
Tests. >>> from fipy import * >>> m = Grid1D() >>> print((m - ((1,))).cellCenters) [[-0.5]] >>> ((1,)) - m Traceback (most recent call last): … TypeError: unsupported operand type(s) for -: ‘tuple’ and ‘UniformGrid1D’
- __truediv__(other)¶
Tests. >>> from fipy import * >>> print((Grid1D(nx=1) / 2.).cellCenters) [[ 0.25]] >>> AbstractMesh(communicator=None) / 2. Traceback (most recent call last): … NotImplementedError
- property aspect2D¶
The physical y vs x aspect ratio of a 2D mesh
- property cellCenters¶
- property cellDistanceVectors¶
- property cellFaceIDs¶
- property cellToFaceDistanceVectors¶
- property cellVolumes¶
- property extents¶
- property exteriorFaces¶
- extrude(extrudeFunc=<function Mesh2D.<lambda>>, layers=1)¶
This function returns a new 3D mesh. The 2D mesh is extruded using the extrudeFunc and the number of layers.
>>> from fipy.meshes.nonUniformGrid2D import NonUniformGrid2D >>> print(NonUniformGrid2D(nx=2, ny=2).extrude(layers=2).cellCenters) [[ 0.5 1.5 0.5 1.5 0.5 1.5 0.5 1.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5] [ 0.5 0.5 0.5 0.5 1.5 1.5 1.5 1.5]]
>>> from fipy.meshes.tri2D import Tri2D >>> print(Tri2D().extrude(layers=2).cellCenters.allclose([[ 0.83333333, 0.5, 0.16666667, 0.5, 0.83333333, 0.5, ... 0.16666667, 0.5 ], ... [ 0.5, 0.83333333, 0.5, 0.16666667, 0.5, 0.83333333, ... 0.5, 0.16666667], ... [ 0.5, 0.5, 0.5, 0.5, 1.5, 1.5, 1.5, ... 1.5 ]])) True
- Parameters:
extrudeFunc (function) – Takes the vertex coordinates and returns the displaced values
layers (int) – Number of layers in the extruded mesh (number of times extrudeFunc will be called)
- property faceCenters¶
- property facesBack¶
Return list of faces on back boundary of 3D Mesh with the z-axis running from front to back.
>>> from fipy import Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((6, 7, 8, 9, 10, 11), ... numerix.nonzero(mesh.facesBack)[0])) True >>> ignore = mesh.facesBack.value
- property facesBottom¶
Return list of faces on bottom boundary of 2D or 3D Mesh with the y-axis running from bottom to top.
>>> from fipy import Grid2D, Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((12, 13, 14), ... numerix.nonzero(mesh.facesBottom)[0])) True >>> ignore = mesh.facesBottom.value >>> x, y, z = mesh.faceCenters >>> print(numerix.allequal((12, 13), ... numerix.nonzero(mesh.facesBottom & (x < 1))[0])) True >>> ignore = mesh.facesBottom.value
- property facesDown¶
Return list of faces on bottom boundary of 2D or 3D Mesh with the y-axis running from bottom to top.
>>> from fipy import Grid2D, Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((12, 13, 14), ... numerix.nonzero(mesh.facesBottom)[0])) True >>> ignore = mesh.facesBottom.value >>> x, y, z = mesh.faceCenters >>> print(numerix.allequal((12, 13), ... numerix.nonzero(mesh.facesBottom & (x < 1))[0])) True >>> ignore = mesh.facesBottom.value
- property facesFront¶
Return list of faces on front boundary of 3D Mesh with the z-axis running from front to back.
>>> from fipy import Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((0, 1, 2, 3, 4, 5), ... numerix.nonzero(mesh.facesFront)[0])) True >>> ignore = mesh.facesFront.value
- property facesLeft¶
Return face on left boundary of Mesh as list with the x-axis running from left to right.
>>> from fipy import Grid2D, Grid3D >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((21, 25), ... numerix.nonzero(mesh.facesLeft)[0])) True >>> ignore = mesh.facesLeft.value >>> mesh = Grid2D(nx = 3, ny = 2, dx = 0.5, dy = 2.) >>> print(numerix.allequal((9, 13), ... numerix.nonzero(mesh.facesLeft)[0])) True >>> ignore = mesh.facesLeft.value
- property facesRight¶
Return list of faces on right boundary of Mesh with the x-axis running from left to right.
>>> from fipy import Grid2D, Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((24, 28), ... numerix.nonzero(mesh.facesRight)[0])) True >>> ignore = mesh.facesRight.value >>> mesh = Grid2D(nx = 3, ny = 2, dx = 0.5, dy = 2.) >>> print(numerix.allequal((12, 16), ... numerix.nonzero(mesh.facesRight)[0])) True >>> ignore = mesh.facesRight.value
- property facesTop¶
Return list of faces on top boundary of 2D or 3D Mesh with the y-axis running from bottom to top.
>>> from fipy import Grid2D, Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((18, 19, 20), ... numerix.nonzero(mesh.facesTop)[0])) True >>> ignore = mesh.facesTop.value >>> mesh = Grid2D(nx = 3, ny = 2, dx = 0.5, dy = 2.) >>> print(numerix.allequal((6, 7, 8), ... numerix.nonzero(mesh.facesTop)[0])) True >>> ignore = mesh.facesTop.value
- property facesUp¶
Return list of faces on top boundary of 2D or 3D Mesh with the y-axis running from bottom to top.
>>> from fipy import Grid2D, Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((18, 19, 20), ... numerix.nonzero(mesh.facesTop)[0])) True >>> ignore = mesh.facesTop.value >>> mesh = Grid2D(nx = 3, ny = 2, dx = 0.5, dy = 2.) >>> print(numerix.allequal((6, 7, 8), ... numerix.nonzero(mesh.facesTop)[0])) True >>> ignore = mesh.facesTop.value
- getNearestCell(point)¶
- property interiorFaceCellIDs¶
- property interiorFaceIDs¶
- property interiorFaces¶
- property scale¶
- property scaledCellDistances¶
- property scaledCellToCellDistances¶
- property scaledCellVolumes¶
- property scaledFaceAreas¶
- property scaledFaceToCellDistances¶
- property x¶
Equivalent to using
cellCenters
[0]
.>>> from fipy import * >>> print(Grid1D(nx=2).x) [ 0.5 1.5]
- property y¶
Equivalent to using
cellCenters
[1]
.>>> from fipy import * >>> print(Grid2D(nx=2, ny=2).y) [ 0.5 0.5 1.5 1.5] >>> print(Grid1D(nx=2).y) Traceback (most recent call last): ... AttributeError: 1D meshes do not have a "y" attribute.
- property z¶
Equivalent to using
cellCenters
[2]
.>>> from fipy import * >>> print(Grid3D(nx=2, ny=2, nz=2).z) [ 0.5 0.5 0.5 0.5 1.5 1.5 1.5 1.5] >>> print(Grid2D(nx=2, ny=2).z) Traceback (most recent call last): ... AttributeError: 1D and 2D meshes do not have a "z" attribute.
- class fipy.PeriodicGrid3D(dx=1.0, dy=1.0, dz=1.0, nx=None, ny=None, nz=None, overlap=2, communicator=SerialPETScCommWrapper(), *args, **kwargs)¶
Bases:
_BasePeriodicGrid3D
Creates a periodic 3D grid mesh with horizontal faces numbered first and then vertical faces. Vertices and cells are numbered in the usual way.
>>> from fipy import numerix
>>> mesh = PeriodicGrid3D(dx=1., dy=0.5, dz=2., nx=2, ny=2, nz=1) >>> print(numerix.allclose(numerix.nonzero(mesh.exteriorFaces)[0], ... [4, 5, 6, 7, 12, 13, 16, 19])) True
>>> print(numerix.allclose(mesh.faceCellIDs.filled(-1), ... [[0, 1, 2, 3, 0, 1, 2, 3, 2, 3, ... 0, 1, 2, 3, 1, 0, 1, 3, 2, 3], ... [0, 1, 2, 3, -1, -1, -1, -1, 0, 1, ... 2, 3, -1, -1, 0, 1, -1, 2, 3, -1]])) True
>>> print(numerix.allclose(mesh._cellDistances, ... [2., 2., 2., 2., 1., 1., 1., 1., 0.5, 0.5, ... 0.5, 0.5, 0.25, 0.25, 1., 1., 0.5, 1., 1., 0.5])) True
>>> print(numerix.allclose(mesh.cellFaceIDs, ... [[14, 15, 17, 18], ... [15, 14, 18, 17], ... [8, 9, 10, 11], ... [10, 11, 8, 9], ... [0, 1, 2, 3], ... [0, 1, 2, 3]])) True
>>> print(numerix.allclose(mesh._cellToCellDistances, ... [[1., 1., 1., 1.], ... [1., 1., 1., 1.], ... [0.5, 0.5, 0.5, 0.5], ... [0.5, 0.5, 0.5, 0.5], ... [2., 2., 2., 2.], ... [2., 2., 2., 2.]])) True
>>> normals = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1], ... [0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0], ... [1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]
>>> print(numerix.allclose(mesh.faceNormals, normals)) True
>>> print(numerix.allclose(mesh._cellVertexIDs, ... [[13, 14, 16, 17], ... [12, 13, 15, 16], ... [10, 11, 13, 14], ... [9, 10, 12, 13], ... [4, 5, 7, 8], ... [3, 4, 6, 7], ... [1, 2, 4, 5], ... [0, 1, 3, 4]])) True
- property VTKCellDataSet¶
Returns a TVTK DataSet representing the cells of this mesh
- property VTKFaceDataSet¶
Returns a TVTK DataSet representing the face centers of this mesh
- __add__(other)¶
Either translate a Mesh or concatenate two Mesh objects.
>>> from fipy.meshes import Grid2D >>> baseMesh = Grid2D(dx = 1.0, dy = 1.0, nx = 2, ny = 2) >>> print(baseMesh.cellCenters) [[ 0.5 1.5 0.5 1.5] [ 0.5 0.5 1.5 1.5]]
If a vector is added to a Mesh, a translated Mesh is returned
>>> translatedMesh = baseMesh + ((5,), (10,)) >>> print(translatedMesh.cellCenters) [[ 5.5 6.5 5.5 6.5] [ 10.5 10.5 11.5 11.5]]
If a Mesh is added to a Mesh, a concatenation of the two Mesh objects is returned
>>> addedMesh = baseMesh + (baseMesh + ((2,), (0,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 2.5 3.5 2.5 3.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5]]
The two Mesh objects need not be properly aligned in order to concatenate them but the resulting mesh may not have the intended connectivity
>>> addedMesh = baseMesh + (baseMesh + ((3,), (0,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 3.5 4.5 3.5 4.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5]]
>>> addedMesh = baseMesh + (baseMesh + ((2,), (2,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 2.5 3.5 2.5 3.5] [ 0.5 0.5 1.5 1.5 2.5 2.5 3.5 3.5]]
No provision is made to avoid or consolidate overlapping Mesh objects
>>> addedMesh = baseMesh + (baseMesh + ((1,), (0,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 1.5 2.5 1.5 2.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5]]
Different Mesh classes can be concatenated
>>> from fipy.meshes import Tri2D >>> triMesh = Tri2D(dx = 1.0, dy = 1.0, nx = 2, ny = 1) >>> triMesh = triMesh + ((2,), (0,)) >>> triAddedMesh = baseMesh + triMesh >>> cellCenters = [[0.5, 1.5, 0.5, 1.5, 2.83333333, 3.83333333, ... 2.5, 3.5, 2.16666667, 3.16666667, 2.5, 3.5], ... [0.5, 0.5, 1.5, 1.5, 0.5, 0.5, 0.83333333, 0.83333333, ... 0.5, 0.5, 0.16666667, 0.16666667]] >>> print(numerix.allclose(triAddedMesh.cellCenters, ... cellCenters)) True
again, their faces need not align, but the mesh may not have the desired connectivity
>>> triMesh = Tri2D(dx = 1.0, dy = 2.0, nx = 2, ny = 1) >>> triMesh = triMesh + ((2,), (0,)) >>> triAddedMesh = baseMesh + triMesh >>> cellCenters = [[ 0.5, 1.5, 0.5, 1.5, 2.83333333, 3.83333333, ... 2.5, 3.5, 2.16666667, 3.16666667, 2.5, 3.5], ... [ 0.5, 0.5, 1.5, 1.5, 1., 1., ... 1.66666667, 1.66666667, 1., 1., 0.33333333, 0.33333333]] >>> print(numerix.allclose(triAddedMesh.cellCenters, ... cellCenters)) True
Mesh concatenation is not limited to 2D meshes
>>> from fipy.meshes import Grid3D >>> threeDBaseMesh = Grid3D(dx = 1.0, dy = 1.0, dz = 1.0, ... nx = 2, ny = 2, nz = 2) >>> threeDSecondMesh = Grid3D(dx = 1.0, dy = 1.0, dz = 1.0, ... nx = 1, ny = 1, nz = 1) >>> threeDAddedMesh = threeDBaseMesh + (threeDSecondMesh + ((2,), (0,), (0,))) >>> print(threeDAddedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 0.5 1.5 0.5 1.5 2.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5 0.5] [ 0.5 0.5 0.5 0.5 1.5 1.5 1.5 1.5 0.5]]
but the different Mesh objects must, of course, have the same dimensionality.
>>> InvalidMesh = threeDBaseMesh + baseMesh Traceback (most recent call last): ... MeshAdditionError: Dimensions do not match
- __div__(other)¶
Tests. >>> from fipy import * >>> print((Grid1D(nx=1) / 2.).cellCenters) [[ 0.25]] >>> AbstractMesh(communicator=None) / 2. Traceback (most recent call last): … NotImplementedError
- __getstate__()¶
Helper for pickle.
- __mul__(factor)¶
Dilate a Mesh by factor.
>>> from fipy.meshes import Grid2D >>> baseMesh = Grid2D(dx = 1.0, dy = 1.0, nx = 2, ny = 2) >>> print(baseMesh.cellCenters) [[ 0.5 1.5 0.5 1.5] [ 0.5 0.5 1.5 1.5]]
The factor can be a scalar
>>> dilatedMesh = baseMesh * 3 >>> print(dilatedMesh.cellCenters) [[ 1.5 4.5 1.5 4.5] [ 1.5 1.5 4.5 4.5]]
or a vector
>>> dilatedMesh = baseMesh * ((3,), (2,)) >>> print(dilatedMesh.cellCenters) [[ 1.5 4.5 1.5 4.5] [ 1. 1. 3. 3. ]]
but the vector must have the same dimensionality as the Mesh
>>> dilatedMesh = baseMesh * ((3,), (2,), (1,)) Traceback (most recent call last): ... ValueError: shape mismatch: objects cannot be broadcast to a single shape
- __radd__(other)¶
Either translate a Mesh or concatenate two Mesh objects.
>>> from fipy.meshes import Grid2D >>> baseMesh = Grid2D(dx = 1.0, dy = 1.0, nx = 2, ny = 2) >>> print(baseMesh.cellCenters) [[ 0.5 1.5 0.5 1.5] [ 0.5 0.5 1.5 1.5]]
If a vector is added to a Mesh, a translated Mesh is returned
>>> translatedMesh = baseMesh + ((5,), (10,)) >>> print(translatedMesh.cellCenters) [[ 5.5 6.5 5.5 6.5] [ 10.5 10.5 11.5 11.5]]
If a Mesh is added to a Mesh, a concatenation of the two Mesh objects is returned
>>> addedMesh = baseMesh + (baseMesh + ((2,), (0,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 2.5 3.5 2.5 3.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5]]
The two Mesh objects need not be properly aligned in order to concatenate them but the resulting mesh may not have the intended connectivity
>>> addedMesh = baseMesh + (baseMesh + ((3,), (0,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 3.5 4.5 3.5 4.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5]]
>>> addedMesh = baseMesh + (baseMesh + ((2,), (2,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 2.5 3.5 2.5 3.5] [ 0.5 0.5 1.5 1.5 2.5 2.5 3.5 3.5]]
No provision is made to avoid or consolidate overlapping Mesh objects
>>> addedMesh = baseMesh + (baseMesh + ((1,), (0,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 1.5 2.5 1.5 2.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5]]
Different Mesh classes can be concatenated
>>> from fipy.meshes import Tri2D >>> triMesh = Tri2D(dx = 1.0, dy = 1.0, nx = 2, ny = 1) >>> triMesh = triMesh + ((2,), (0,)) >>> triAddedMesh = baseMesh + triMesh >>> cellCenters = [[0.5, 1.5, 0.5, 1.5, 2.83333333, 3.83333333, ... 2.5, 3.5, 2.16666667, 3.16666667, 2.5, 3.5], ... [0.5, 0.5, 1.5, 1.5, 0.5, 0.5, 0.83333333, 0.83333333, ... 0.5, 0.5, 0.16666667, 0.16666667]] >>> print(numerix.allclose(triAddedMesh.cellCenters, ... cellCenters)) True
again, their faces need not align, but the mesh may not have the desired connectivity
>>> triMesh = Tri2D(dx = 1.0, dy = 2.0, nx = 2, ny = 1) >>> triMesh = triMesh + ((2,), (0,)) >>> triAddedMesh = baseMesh + triMesh >>> cellCenters = [[ 0.5, 1.5, 0.5, 1.5, 2.83333333, 3.83333333, ... 2.5, 3.5, 2.16666667, 3.16666667, 2.5, 3.5], ... [ 0.5, 0.5, 1.5, 1.5, 1., 1., ... 1.66666667, 1.66666667, 1., 1., 0.33333333, 0.33333333]] >>> print(numerix.allclose(triAddedMesh.cellCenters, ... cellCenters)) True
Mesh concatenation is not limited to 2D meshes
>>> from fipy.meshes import Grid3D >>> threeDBaseMesh = Grid3D(dx = 1.0, dy = 1.0, dz = 1.0, ... nx = 2, ny = 2, nz = 2) >>> threeDSecondMesh = Grid3D(dx = 1.0, dy = 1.0, dz = 1.0, ... nx = 1, ny = 1, nz = 1) >>> threeDAddedMesh = threeDBaseMesh + (threeDSecondMesh + ((2,), (0,), (0,))) >>> print(threeDAddedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 0.5 1.5 0.5 1.5 2.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5 0.5] [ 0.5 0.5 0.5 0.5 1.5 1.5 1.5 1.5 0.5]]
but the different Mesh objects must, of course, have the same dimensionality.
>>> InvalidMesh = threeDBaseMesh + baseMesh Traceback (most recent call last): ... MeshAdditionError: Dimensions do not match
- __repr__()¶
Return repr(self).
- __rmul__(factor)¶
Dilate a Mesh by factor.
>>> from fipy.meshes import Grid2D >>> baseMesh = Grid2D(dx = 1.0, dy = 1.0, nx = 2, ny = 2) >>> print(baseMesh.cellCenters) [[ 0.5 1.5 0.5 1.5] [ 0.5 0.5 1.5 1.5]]
The factor can be a scalar
>>> dilatedMesh = baseMesh * 3 >>> print(dilatedMesh.cellCenters) [[ 1.5 4.5 1.5 4.5] [ 1.5 1.5 4.5 4.5]]
or a vector
>>> dilatedMesh = baseMesh * ((3,), (2,)) >>> print(dilatedMesh.cellCenters) [[ 1.5 4.5 1.5 4.5] [ 1. 1. 3. 3. ]]
but the vector must have the same dimensionality as the Mesh
>>> dilatedMesh = baseMesh * ((3,), (2,), (1,)) Traceback (most recent call last): ... ValueError: shape mismatch: objects cannot be broadcast to a single shape
- __setstate__(state)¶
- __sub__(other)¶
Tests. >>> from fipy import * >>> m = Grid1D() >>> print((m - ((1,))).cellCenters) [[-0.5]] >>> ((1,)) - m Traceback (most recent call last): … TypeError: unsupported operand type(s) for -: ‘tuple’ and ‘UniformGrid1D’
- __truediv__(other)¶
Tests. >>> from fipy import * >>> print((Grid1D(nx=1) / 2.).cellCenters) [[ 0.25]] >>> AbstractMesh(communicator=None) / 2. Traceback (most recent call last): … NotImplementedError
- property aspect2D¶
The physical y vs x aspect ratio of a 2D mesh
- property cellCenters¶
- property cellDistanceVectors¶
- property cellFaceIDs¶
- property cellToFaceDistanceVectors¶
- property cellVolumes¶
- property extents¶
- property exteriorFaces¶
- property faceCenters¶
- property facesBack¶
Return list of faces on back boundary of 3D Mesh with the z-axis running from front to back.
>>> from fipy import Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((6, 7, 8, 9, 10, 11), ... numerix.nonzero(mesh.facesBack)[0])) True >>> ignore = mesh.facesBack.value
- property facesBottom¶
Return list of faces on bottom boundary of 2D or 3D Mesh with the y-axis running from bottom to top.
>>> from fipy import Grid2D, Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((12, 13, 14), ... numerix.nonzero(mesh.facesBottom)[0])) True >>> ignore = mesh.facesBottom.value >>> x, y, z = mesh.faceCenters >>> print(numerix.allequal((12, 13), ... numerix.nonzero(mesh.facesBottom & (x < 1))[0])) True >>> ignore = mesh.facesBottom.value
- property facesDown¶
Return list of faces on bottom boundary of 2D or 3D Mesh with the y-axis running from bottom to top.
>>> from fipy import Grid2D, Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((12, 13, 14), ... numerix.nonzero(mesh.facesBottom)[0])) True >>> ignore = mesh.facesBottom.value >>> x, y, z = mesh.faceCenters >>> print(numerix.allequal((12, 13), ... numerix.nonzero(mesh.facesBottom & (x < 1))[0])) True >>> ignore = mesh.facesBottom.value
- property facesFront¶
Return list of faces on front boundary of 3D Mesh with the z-axis running from front to back.
>>> from fipy import Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((0, 1, 2, 3, 4, 5), ... numerix.nonzero(mesh.facesFront)[0])) True >>> ignore = mesh.facesFront.value
- property facesLeft¶
Return face on left boundary of Mesh as list with the x-axis running from left to right.
>>> from fipy import Grid2D, Grid3D >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((21, 25), ... numerix.nonzero(mesh.facesLeft)[0])) True >>> ignore = mesh.facesLeft.value >>> mesh = Grid2D(nx = 3, ny = 2, dx = 0.5, dy = 2.) >>> print(numerix.allequal((9, 13), ... numerix.nonzero(mesh.facesLeft)[0])) True >>> ignore = mesh.facesLeft.value
- property facesRight¶
Return list of faces on right boundary of Mesh with the x-axis running from left to right.
>>> from fipy import Grid2D, Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((24, 28), ... numerix.nonzero(mesh.facesRight)[0])) True >>> ignore = mesh.facesRight.value >>> mesh = Grid2D(nx = 3, ny = 2, dx = 0.5, dy = 2.) >>> print(numerix.allequal((12, 16), ... numerix.nonzero(mesh.facesRight)[0])) True >>> ignore = mesh.facesRight.value
- property facesTop¶
Return list of faces on top boundary of 2D or 3D Mesh with the y-axis running from bottom to top.
>>> from fipy import Grid2D, Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((18, 19, 20), ... numerix.nonzero(mesh.facesTop)[0])) True >>> ignore = mesh.facesTop.value >>> mesh = Grid2D(nx = 3, ny = 2, dx = 0.5, dy = 2.) >>> print(numerix.allequal((6, 7, 8), ... numerix.nonzero(mesh.facesTop)[0])) True >>> ignore = mesh.facesTop.value
- property facesUp¶
Return list of faces on top boundary of 2D or 3D Mesh with the y-axis running from bottom to top.
>>> from fipy import Grid2D, Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((18, 19, 20), ... numerix.nonzero(mesh.facesTop)[0])) True >>> ignore = mesh.facesTop.value >>> mesh = Grid2D(nx = 3, ny = 2, dx = 0.5, dy = 2.) >>> print(numerix.allequal((6, 7, 8), ... numerix.nonzero(mesh.facesTop)[0])) True >>> ignore = mesh.facesTop.value
- getNearestCell(point)¶
- property interiorFaceCellIDs¶
- property interiorFaceIDs¶
- property interiorFaces¶
- property scale¶
- property scaledCellDistances¶
- property scaledCellToCellDistances¶
- property scaledCellVolumes¶
- property scaledFaceAreas¶
- property scaledFaceToCellDistances¶
- property x¶
Equivalent to using
cellCenters
[0]
.>>> from fipy import * >>> print(Grid1D(nx=2).x) [ 0.5 1.5]
- property y¶
Equivalent to using
cellCenters
[1]
.>>> from fipy import * >>> print(Grid2D(nx=2, ny=2).y) [ 0.5 0.5 1.5 1.5] >>> print(Grid1D(nx=2).y) Traceback (most recent call last): ... AttributeError: 1D meshes do not have a "y" attribute.
- property z¶
Equivalent to using
cellCenters
[2]
.>>> from fipy import * >>> print(Grid3D(nx=2, ny=2, nz=2).z) [ 0.5 0.5 0.5 0.5 1.5 1.5 1.5 1.5] >>> print(Grid2D(nx=2, ny=2).z) Traceback (most recent call last): ... AttributeError: 1D and 2D meshes do not have a "z" attribute.
- class fipy.PeriodicGrid3DFrontBack(dx=1.0, dy=1.0, dz=1.0, nx=None, ny=None, nz=None, overlap=2, communicator=SerialPETScCommWrapper(), *args, **kwargs)¶
Bases:
_BasePeriodicGrid3D
- property VTKCellDataSet¶
Returns a TVTK DataSet representing the cells of this mesh
- property VTKFaceDataSet¶
Returns a TVTK DataSet representing the face centers of this mesh
- __add__(other)¶
Either translate a Mesh or concatenate two Mesh objects.
>>> from fipy.meshes import Grid2D >>> baseMesh = Grid2D(dx = 1.0, dy = 1.0, nx = 2, ny = 2) >>> print(baseMesh.cellCenters) [[ 0.5 1.5 0.5 1.5] [ 0.5 0.5 1.5 1.5]]
If a vector is added to a Mesh, a translated Mesh is returned
>>> translatedMesh = baseMesh + ((5,), (10,)) >>> print(translatedMesh.cellCenters) [[ 5.5 6.5 5.5 6.5] [ 10.5 10.5 11.5 11.5]]
If a Mesh is added to a Mesh, a concatenation of the two Mesh objects is returned
>>> addedMesh = baseMesh + (baseMesh + ((2,), (0,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 2.5 3.5 2.5 3.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5]]
The two Mesh objects need not be properly aligned in order to concatenate them but the resulting mesh may not have the intended connectivity
>>> addedMesh = baseMesh + (baseMesh + ((3,), (0,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 3.5 4.5 3.5 4.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5]]
>>> addedMesh = baseMesh + (baseMesh + ((2,), (2,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 2.5 3.5 2.5 3.5] [ 0.5 0.5 1.5 1.5 2.5 2.5 3.5 3.5]]
No provision is made to avoid or consolidate overlapping Mesh objects
>>> addedMesh = baseMesh + (baseMesh + ((1,), (0,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 1.5 2.5 1.5 2.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5]]
Different Mesh classes can be concatenated
>>> from fipy.meshes import Tri2D >>> triMesh = Tri2D(dx = 1.0, dy = 1.0, nx = 2, ny = 1) >>> triMesh = triMesh + ((2,), (0,)) >>> triAddedMesh = baseMesh + triMesh >>> cellCenters = [[0.5, 1.5, 0.5, 1.5, 2.83333333, 3.83333333, ... 2.5, 3.5, 2.16666667, 3.16666667, 2.5, 3.5], ... [0.5, 0.5, 1.5, 1.5, 0.5, 0.5, 0.83333333, 0.83333333, ... 0.5, 0.5, 0.16666667, 0.16666667]] >>> print(numerix.allclose(triAddedMesh.cellCenters, ... cellCenters)) True
again, their faces need not align, but the mesh may not have the desired connectivity
>>> triMesh = Tri2D(dx = 1.0, dy = 2.0, nx = 2, ny = 1) >>> triMesh = triMesh + ((2,), (0,)) >>> triAddedMesh = baseMesh + triMesh >>> cellCenters = [[ 0.5, 1.5, 0.5, 1.5, 2.83333333, 3.83333333, ... 2.5, 3.5, 2.16666667, 3.16666667, 2.5, 3.5], ... [ 0.5, 0.5, 1.5, 1.5, 1., 1., ... 1.66666667, 1.66666667, 1., 1., 0.33333333, 0.33333333]] >>> print(numerix.allclose(triAddedMesh.cellCenters, ... cellCenters)) True
Mesh concatenation is not limited to 2D meshes
>>> from fipy.meshes import Grid3D >>> threeDBaseMesh = Grid3D(dx = 1.0, dy = 1.0, dz = 1.0, ... nx = 2, ny = 2, nz = 2) >>> threeDSecondMesh = Grid3D(dx = 1.0, dy = 1.0, dz = 1.0, ... nx = 1, ny = 1, nz = 1) >>> threeDAddedMesh = threeDBaseMesh + (threeDSecondMesh + ((2,), (0,), (0,))) >>> print(threeDAddedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 0.5 1.5 0.5 1.5 2.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5 0.5] [ 0.5 0.5 0.5 0.5 1.5 1.5 1.5 1.5 0.5]]
but the different Mesh objects must, of course, have the same dimensionality.
>>> InvalidMesh = threeDBaseMesh + baseMesh Traceback (most recent call last): ... MeshAdditionError: Dimensions do not match
- __div__(other)¶
Tests. >>> from fipy import * >>> print((Grid1D(nx=1) / 2.).cellCenters) [[ 0.25]] >>> AbstractMesh(communicator=None) / 2. Traceback (most recent call last): … NotImplementedError
- __getstate__()¶
Helper for pickle.
- __mul__(factor)¶
Dilate a Mesh by factor.
>>> from fipy.meshes import Grid2D >>> baseMesh = Grid2D(dx = 1.0, dy = 1.0, nx = 2, ny = 2) >>> print(baseMesh.cellCenters) [[ 0.5 1.5 0.5 1.5] [ 0.5 0.5 1.5 1.5]]
The factor can be a scalar
>>> dilatedMesh = baseMesh * 3 >>> print(dilatedMesh.cellCenters) [[ 1.5 4.5 1.5 4.5] [ 1.5 1.5 4.5 4.5]]
or a vector
>>> dilatedMesh = baseMesh * ((3,), (2,)) >>> print(dilatedMesh.cellCenters) [[ 1.5 4.5 1.5 4.5] [ 1. 1. 3. 3. ]]
but the vector must have the same dimensionality as the Mesh
>>> dilatedMesh = baseMesh * ((3,), (2,), (1,)) Traceback (most recent call last): ... ValueError: shape mismatch: objects cannot be broadcast to a single shape
- __radd__(other)¶
Either translate a Mesh or concatenate two Mesh objects.
>>> from fipy.meshes import Grid2D >>> baseMesh = Grid2D(dx = 1.0, dy = 1.0, nx = 2, ny = 2) >>> print(baseMesh.cellCenters) [[ 0.5 1.5 0.5 1.5] [ 0.5 0.5 1.5 1.5]]
If a vector is added to a Mesh, a translated Mesh is returned
>>> translatedMesh = baseMesh + ((5,), (10,)) >>> print(translatedMesh.cellCenters) [[ 5.5 6.5 5.5 6.5] [ 10.5 10.5 11.5 11.5]]
If a Mesh is added to a Mesh, a concatenation of the two Mesh objects is returned
>>> addedMesh = baseMesh + (baseMesh + ((2,), (0,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 2.5 3.5 2.5 3.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5]]
The two Mesh objects need not be properly aligned in order to concatenate them but the resulting mesh may not have the intended connectivity
>>> addedMesh = baseMesh + (baseMesh + ((3,), (0,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 3.5 4.5 3.5 4.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5]]
>>> addedMesh = baseMesh + (baseMesh + ((2,), (2,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 2.5 3.5 2.5 3.5] [ 0.5 0.5 1.5 1.5 2.5 2.5 3.5 3.5]]
No provision is made to avoid or consolidate overlapping Mesh objects
>>> addedMesh = baseMesh + (baseMesh + ((1,), (0,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 1.5 2.5 1.5 2.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5]]
Different Mesh classes can be concatenated
>>> from fipy.meshes import Tri2D >>> triMesh = Tri2D(dx = 1.0, dy = 1.0, nx = 2, ny = 1) >>> triMesh = triMesh + ((2,), (0,)) >>> triAddedMesh = baseMesh + triMesh >>> cellCenters = [[0.5, 1.5, 0.5, 1.5, 2.83333333, 3.83333333, ... 2.5, 3.5, 2.16666667, 3.16666667, 2.5, 3.5], ... [0.5, 0.5, 1.5, 1.5, 0.5, 0.5, 0.83333333, 0.83333333, ... 0.5, 0.5, 0.16666667, 0.16666667]] >>> print(numerix.allclose(triAddedMesh.cellCenters, ... cellCenters)) True
again, their faces need not align, but the mesh may not have the desired connectivity
>>> triMesh = Tri2D(dx = 1.0, dy = 2.0, nx = 2, ny = 1) >>> triMesh = triMesh + ((2,), (0,)) >>> triAddedMesh = baseMesh + triMesh >>> cellCenters = [[ 0.5, 1.5, 0.5, 1.5, 2.83333333, 3.83333333, ... 2.5, 3.5, 2.16666667, 3.16666667, 2.5, 3.5], ... [ 0.5, 0.5, 1.5, 1.5, 1., 1., ... 1.66666667, 1.66666667, 1., 1., 0.33333333, 0.33333333]] >>> print(numerix.allclose(triAddedMesh.cellCenters, ... cellCenters)) True
Mesh concatenation is not limited to 2D meshes
>>> from fipy.meshes import Grid3D >>> threeDBaseMesh = Grid3D(dx = 1.0, dy = 1.0, dz = 1.0, ... nx = 2, ny = 2, nz = 2) >>> threeDSecondMesh = Grid3D(dx = 1.0, dy = 1.0, dz = 1.0, ... nx = 1, ny = 1, nz = 1) >>> threeDAddedMesh = threeDBaseMesh + (threeDSecondMesh + ((2,), (0,), (0,))) >>> print(threeDAddedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 0.5 1.5 0.5 1.5 2.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5 0.5] [ 0.5 0.5 0.5 0.5 1.5 1.5 1.5 1.5 0.5]]
but the different Mesh objects must, of course, have the same dimensionality.
>>> InvalidMesh = threeDBaseMesh + baseMesh Traceback (most recent call last): ... MeshAdditionError: Dimensions do not match
- __repr__()¶
Return repr(self).
- __rmul__(factor)¶
Dilate a Mesh by factor.
>>> from fipy.meshes import Grid2D >>> baseMesh = Grid2D(dx = 1.0, dy = 1.0, nx = 2, ny = 2) >>> print(baseMesh.cellCenters) [[ 0.5 1.5 0.5 1.5] [ 0.5 0.5 1.5 1.5]]
The factor can be a scalar
>>> dilatedMesh = baseMesh * 3 >>> print(dilatedMesh.cellCenters) [[ 1.5 4.5 1.5 4.5] [ 1.5 1.5 4.5 4.5]]
or a vector
>>> dilatedMesh = baseMesh * ((3,), (2,)) >>> print(dilatedMesh.cellCenters) [[ 1.5 4.5 1.5 4.5] [ 1. 1. 3. 3. ]]
but the vector must have the same dimensionality as the Mesh
>>> dilatedMesh = baseMesh * ((3,), (2,), (1,)) Traceback (most recent call last): ... ValueError: shape mismatch: objects cannot be broadcast to a single shape
- __setstate__(state)¶
- __sub__(other)¶
Tests. >>> from fipy import * >>> m = Grid1D() >>> print((m - ((1,))).cellCenters) [[-0.5]] >>> ((1,)) - m Traceback (most recent call last): … TypeError: unsupported operand type(s) for -: ‘tuple’ and ‘UniformGrid1D’
- __truediv__(other)¶
Tests. >>> from fipy import * >>> print((Grid1D(nx=1) / 2.).cellCenters) [[ 0.25]] >>> AbstractMesh(communicator=None) / 2. Traceback (most recent call last): … NotImplementedError
- property aspect2D¶
The physical y vs x aspect ratio of a 2D mesh
- property cellCenters¶
- property cellDistanceVectors¶
- property cellFaceIDs¶
- property cellToFaceDistanceVectors¶
- property cellVolumes¶
- property extents¶
- property exteriorFaces¶
- property faceCenters¶
- property facesBack¶
Return list of faces on back boundary of 3D Mesh with the z-axis running from front to back.
>>> from fipy import Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((6, 7, 8, 9, 10, 11), ... numerix.nonzero(mesh.facesBack)[0])) True >>> ignore = mesh.facesBack.value
- property facesBottom¶
Return list of faces on bottom boundary of 2D or 3D Mesh with the y-axis running from bottom to top.
>>> from fipy import Grid2D, Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((12, 13, 14), ... numerix.nonzero(mesh.facesBottom)[0])) True >>> ignore = mesh.facesBottom.value >>> x, y, z = mesh.faceCenters >>> print(numerix.allequal((12, 13), ... numerix.nonzero(mesh.facesBottom & (x < 1))[0])) True >>> ignore = mesh.facesBottom.value
- property facesDown¶
Return list of faces on bottom boundary of 2D or 3D Mesh with the y-axis running from bottom to top.
>>> from fipy import Grid2D, Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((12, 13, 14), ... numerix.nonzero(mesh.facesBottom)[0])) True >>> ignore = mesh.facesBottom.value >>> x, y, z = mesh.faceCenters >>> print(numerix.allequal((12, 13), ... numerix.nonzero(mesh.facesBottom & (x < 1))[0])) True >>> ignore = mesh.facesBottom.value
- property facesFront¶
Return list of faces on front boundary of 3D Mesh with the z-axis running from front to back.
>>> from fipy import Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((0, 1, 2, 3, 4, 5), ... numerix.nonzero(mesh.facesFront)[0])) True >>> ignore = mesh.facesFront.value
- property facesLeft¶
Return face on left boundary of Mesh as list with the x-axis running from left to right.
>>> from fipy import Grid2D, Grid3D >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((21, 25), ... numerix.nonzero(mesh.facesLeft)[0])) True >>> ignore = mesh.facesLeft.value >>> mesh = Grid2D(nx = 3, ny = 2, dx = 0.5, dy = 2.) >>> print(numerix.allequal((9, 13), ... numerix.nonzero(mesh.facesLeft)[0])) True >>> ignore = mesh.facesLeft.value
- property facesRight¶
Return list of faces on right boundary of Mesh with the x-axis running from left to right.
>>> from fipy import Grid2D, Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((24, 28), ... numerix.nonzero(mesh.facesRight)[0])) True >>> ignore = mesh.facesRight.value >>> mesh = Grid2D(nx = 3, ny = 2, dx = 0.5, dy = 2.) >>> print(numerix.allequal((12, 16), ... numerix.nonzero(mesh.facesRight)[0])) True >>> ignore = mesh.facesRight.value
- property facesTop¶
Return list of faces on top boundary of 2D or 3D Mesh with the y-axis running from bottom to top.
>>> from fipy import Grid2D, Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((18, 19, 20), ... numerix.nonzero(mesh.facesTop)[0])) True >>> ignore = mesh.facesTop.value >>> mesh = Grid2D(nx = 3, ny = 2, dx = 0.5, dy = 2.) >>> print(numerix.allequal((6, 7, 8), ... numerix.nonzero(mesh.facesTop)[0])) True >>> ignore = mesh.facesTop.value
- property facesUp¶
Return list of faces on top boundary of 2D or 3D Mesh with the y-axis running from bottom to top.
>>> from fipy import Grid2D, Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((18, 19, 20), ... numerix.nonzero(mesh.facesTop)[0])) True >>> ignore = mesh.facesTop.value >>> mesh = Grid2D(nx = 3, ny = 2, dx = 0.5, dy = 2.) >>> print(numerix.allequal((6, 7, 8), ... numerix.nonzero(mesh.facesTop)[0])) True >>> ignore = mesh.facesTop.value
- getNearestCell(point)¶
- property interiorFaceCellIDs¶
- property interiorFaceIDs¶
- property interiorFaces¶
- property scale¶
- property scaledCellDistances¶
- property scaledCellToCellDistances¶
- property scaledCellVolumes¶
- property scaledFaceAreas¶
- property scaledFaceToCellDistances¶
- property x¶
Equivalent to using
cellCenters
[0]
.>>> from fipy import * >>> print(Grid1D(nx=2).x) [ 0.5 1.5]
- property y¶
Equivalent to using
cellCenters
[1]
.>>> from fipy import * >>> print(Grid2D(nx=2, ny=2).y) [ 0.5 0.5 1.5 1.5] >>> print(Grid1D(nx=2).y) Traceback (most recent call last): ... AttributeError: 1D meshes do not have a "y" attribute.
- property z¶
Equivalent to using
cellCenters
[2]
.>>> from fipy import * >>> print(Grid3D(nx=2, ny=2, nz=2).z) [ 0.5 0.5 0.5 0.5 1.5 1.5 1.5 1.5] >>> print(Grid2D(nx=2, ny=2).z) Traceback (most recent call last): ... AttributeError: 1D and 2D meshes do not have a "z" attribute.
- class fipy.PeriodicGrid3DLeftRight(dx=1.0, dy=1.0, dz=1.0, nx=None, ny=None, nz=None, overlap=2, communicator=SerialPETScCommWrapper(), *args, **kwargs)¶
Bases:
_BasePeriodicGrid3D
- property VTKCellDataSet¶
Returns a TVTK DataSet representing the cells of this mesh
- property VTKFaceDataSet¶
Returns a TVTK DataSet representing the face centers of this mesh
- __add__(other)¶
Either translate a Mesh or concatenate two Mesh objects.
>>> from fipy.meshes import Grid2D >>> baseMesh = Grid2D(dx = 1.0, dy = 1.0, nx = 2, ny = 2) >>> print(baseMesh.cellCenters) [[ 0.5 1.5 0.5 1.5] [ 0.5 0.5 1.5 1.5]]
If a vector is added to a Mesh, a translated Mesh is returned
>>> translatedMesh = baseMesh + ((5,), (10,)) >>> print(translatedMesh.cellCenters) [[ 5.5 6.5 5.5 6.5] [ 10.5 10.5 11.5 11.5]]
If a Mesh is added to a Mesh, a concatenation of the two Mesh objects is returned
>>> addedMesh = baseMesh + (baseMesh + ((2,), (0,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 2.5 3.5 2.5 3.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5]]
The two Mesh objects need not be properly aligned in order to concatenate them but the resulting mesh may not have the intended connectivity
>>> addedMesh = baseMesh + (baseMesh + ((3,), (0,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 3.5 4.5 3.5 4.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5]]
>>> addedMesh = baseMesh + (baseMesh + ((2,), (2,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 2.5 3.5 2.5 3.5] [ 0.5 0.5 1.5 1.5 2.5 2.5 3.5 3.5]]
No provision is made to avoid or consolidate overlapping Mesh objects
>>> addedMesh = baseMesh + (baseMesh + ((1,), (0,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 1.5 2.5 1.5 2.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5]]
Different Mesh classes can be concatenated
>>> from fipy.meshes import Tri2D >>> triMesh = Tri2D(dx = 1.0, dy = 1.0, nx = 2, ny = 1) >>> triMesh = triMesh + ((2,), (0,)) >>> triAddedMesh = baseMesh + triMesh >>> cellCenters = [[0.5, 1.5, 0.5, 1.5, 2.83333333, 3.83333333, ... 2.5, 3.5, 2.16666667, 3.16666667, 2.5, 3.5], ... [0.5, 0.5, 1.5, 1.5, 0.5, 0.5, 0.83333333, 0.83333333, ... 0.5, 0.5, 0.16666667, 0.16666667]] >>> print(numerix.allclose(triAddedMesh.cellCenters, ... cellCenters)) True
again, their faces need not align, but the mesh may not have the desired connectivity
>>> triMesh = Tri2D(dx = 1.0, dy = 2.0, nx = 2, ny = 1) >>> triMesh = triMesh + ((2,), (0,)) >>> triAddedMesh = baseMesh + triMesh >>> cellCenters = [[ 0.5, 1.5, 0.5, 1.5, 2.83333333, 3.83333333, ... 2.5, 3.5, 2.16666667, 3.16666667, 2.5, 3.5], ... [ 0.5, 0.5, 1.5, 1.5, 1., 1., ... 1.66666667, 1.66666667, 1., 1., 0.33333333, 0.33333333]] >>> print(numerix.allclose(triAddedMesh.cellCenters, ... cellCenters)) True
Mesh concatenation is not limited to 2D meshes
>>> from fipy.meshes import Grid3D >>> threeDBaseMesh = Grid3D(dx = 1.0, dy = 1.0, dz = 1.0, ... nx = 2, ny = 2, nz = 2) >>> threeDSecondMesh = Grid3D(dx = 1.0, dy = 1.0, dz = 1.0, ... nx = 1, ny = 1, nz = 1) >>> threeDAddedMesh = threeDBaseMesh + (threeDSecondMesh + ((2,), (0,), (0,))) >>> print(threeDAddedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 0.5 1.5 0.5 1.5 2.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5 0.5] [ 0.5 0.5 0.5 0.5 1.5 1.5 1.5 1.5 0.5]]
but the different Mesh objects must, of course, have the same dimensionality.
>>> InvalidMesh = threeDBaseMesh + baseMesh Traceback (most recent call last): ... MeshAdditionError: Dimensions do not match
- __div__(other)¶
Tests. >>> from fipy import * >>> print((Grid1D(nx=1) / 2.).cellCenters) [[ 0.25]] >>> AbstractMesh(communicator=None) / 2. Traceback (most recent call last): … NotImplementedError
- __getstate__()¶
Helper for pickle.
- __mul__(factor)¶
Dilate a Mesh by factor.
>>> from fipy.meshes import Grid2D >>> baseMesh = Grid2D(dx = 1.0, dy = 1.0, nx = 2, ny = 2) >>> print(baseMesh.cellCenters) [[ 0.5 1.5 0.5 1.5] [ 0.5 0.5 1.5 1.5]]
The factor can be a scalar
>>> dilatedMesh = baseMesh * 3 >>> print(dilatedMesh.cellCenters) [[ 1.5 4.5 1.5 4.5] [ 1.5 1.5 4.5 4.5]]
or a vector
>>> dilatedMesh = baseMesh * ((3,), (2,)) >>> print(dilatedMesh.cellCenters) [[ 1.5 4.5 1.5 4.5] [ 1. 1. 3. 3. ]]
but the vector must have the same dimensionality as the Mesh
>>> dilatedMesh = baseMesh * ((3,), (2,), (1,)) Traceback (most recent call last): ... ValueError: shape mismatch: objects cannot be broadcast to a single shape
- __radd__(other)¶
Either translate a Mesh or concatenate two Mesh objects.
>>> from fipy.meshes import Grid2D >>> baseMesh = Grid2D(dx = 1.0, dy = 1.0, nx = 2, ny = 2) >>> print(baseMesh.cellCenters) [[ 0.5 1.5 0.5 1.5] [ 0.5 0.5 1.5 1.5]]
If a vector is added to a Mesh, a translated Mesh is returned
>>> translatedMesh = baseMesh + ((5,), (10,)) >>> print(translatedMesh.cellCenters) [[ 5.5 6.5 5.5 6.5] [ 10.5 10.5 11.5 11.5]]
If a Mesh is added to a Mesh, a concatenation of the two Mesh objects is returned
>>> addedMesh = baseMesh + (baseMesh + ((2,), (0,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 2.5 3.5 2.5 3.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5]]
The two Mesh objects need not be properly aligned in order to concatenate them but the resulting mesh may not have the intended connectivity
>>> addedMesh = baseMesh + (baseMesh + ((3,), (0,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 3.5 4.5 3.5 4.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5]]
>>> addedMesh = baseMesh + (baseMesh + ((2,), (2,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 2.5 3.5 2.5 3.5] [ 0.5 0.5 1.5 1.5 2.5 2.5 3.5 3.5]]
No provision is made to avoid or consolidate overlapping Mesh objects
>>> addedMesh = baseMesh + (baseMesh + ((1,), (0,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 1.5 2.5 1.5 2.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5]]
Different Mesh classes can be concatenated
>>> from fipy.meshes import Tri2D >>> triMesh = Tri2D(dx = 1.0, dy = 1.0, nx = 2, ny = 1) >>> triMesh = triMesh + ((2,), (0,)) >>> triAddedMesh = baseMesh + triMesh >>> cellCenters = [[0.5, 1.5, 0.5, 1.5, 2.83333333, 3.83333333, ... 2.5, 3.5, 2.16666667, 3.16666667, 2.5, 3.5], ... [0.5, 0.5, 1.5, 1.5, 0.5, 0.5, 0.83333333, 0.83333333, ... 0.5, 0.5, 0.16666667, 0.16666667]] >>> print(numerix.allclose(triAddedMesh.cellCenters, ... cellCenters)) True
again, their faces need not align, but the mesh may not have the desired connectivity
>>> triMesh = Tri2D(dx = 1.0, dy = 2.0, nx = 2, ny = 1) >>> triMesh = triMesh + ((2,), (0,)) >>> triAddedMesh = baseMesh + triMesh >>> cellCenters = [[ 0.5, 1.5, 0.5, 1.5, 2.83333333, 3.83333333, ... 2.5, 3.5, 2.16666667, 3.16666667, 2.5, 3.5], ... [ 0.5, 0.5, 1.5, 1.5, 1., 1., ... 1.66666667, 1.66666667, 1., 1., 0.33333333, 0.33333333]] >>> print(numerix.allclose(triAddedMesh.cellCenters, ... cellCenters)) True
Mesh concatenation is not limited to 2D meshes
>>> from fipy.meshes import Grid3D >>> threeDBaseMesh = Grid3D(dx = 1.0, dy = 1.0, dz = 1.0, ... nx = 2, ny = 2, nz = 2) >>> threeDSecondMesh = Grid3D(dx = 1.0, dy = 1.0, dz = 1.0, ... nx = 1, ny = 1, nz = 1) >>> threeDAddedMesh = threeDBaseMesh + (threeDSecondMesh + ((2,), (0,), (0,))) >>> print(threeDAddedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 0.5 1.5 0.5 1.5 2.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5 0.5] [ 0.5 0.5 0.5 0.5 1.5 1.5 1.5 1.5 0.5]]
but the different Mesh objects must, of course, have the same dimensionality.
>>> InvalidMesh = threeDBaseMesh + baseMesh Traceback (most recent call last): ... MeshAdditionError: Dimensions do not match
- __repr__()¶
Return repr(self).
- __rmul__(factor)¶
Dilate a Mesh by factor.
>>> from fipy.meshes import Grid2D >>> baseMesh = Grid2D(dx = 1.0, dy = 1.0, nx = 2, ny = 2) >>> print(baseMesh.cellCenters) [[ 0.5 1.5 0.5 1.5] [ 0.5 0.5 1.5 1.5]]
The factor can be a scalar
>>> dilatedMesh = baseMesh * 3 >>> print(dilatedMesh.cellCenters) [[ 1.5 4.5 1.5 4.5] [ 1.5 1.5 4.5 4.5]]
or a vector
>>> dilatedMesh = baseMesh * ((3,), (2,)) >>> print(dilatedMesh.cellCenters) [[ 1.5 4.5 1.5 4.5] [ 1. 1. 3. 3. ]]
but the vector must have the same dimensionality as the Mesh
>>> dilatedMesh = baseMesh * ((3,), (2,), (1,)) Traceback (most recent call last): ... ValueError: shape mismatch: objects cannot be broadcast to a single shape
- __setstate__(state)¶
- __sub__(other)¶
Tests. >>> from fipy import * >>> m = Grid1D() >>> print((m - ((1,))).cellCenters) [[-0.5]] >>> ((1,)) - m Traceback (most recent call last): … TypeError: unsupported operand type(s) for -: ‘tuple’ and ‘UniformGrid1D’
- __truediv__(other)¶
Tests. >>> from fipy import * >>> print((Grid1D(nx=1) / 2.).cellCenters) [[ 0.25]] >>> AbstractMesh(communicator=None) / 2. Traceback (most recent call last): … NotImplementedError
- property aspect2D¶
The physical y vs x aspect ratio of a 2D mesh
- property cellCenters¶
- property cellDistanceVectors¶
- property cellFaceIDs¶
- property cellToFaceDistanceVectors¶
- property cellVolumes¶
- property extents¶
- property exteriorFaces¶
- property faceCenters¶
- property facesBack¶
Return list of faces on back boundary of 3D Mesh with the z-axis running from front to back.
>>> from fipy import Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((6, 7, 8, 9, 10, 11), ... numerix.nonzero(mesh.facesBack)[0])) True >>> ignore = mesh.facesBack.value
- property facesBottom¶
Return list of faces on bottom boundary of 2D or 3D Mesh with the y-axis running from bottom to top.
>>> from fipy import Grid2D, Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((12, 13, 14), ... numerix.nonzero(mesh.facesBottom)[0])) True >>> ignore = mesh.facesBottom.value >>> x, y, z = mesh.faceCenters >>> print(numerix.allequal((12, 13), ... numerix.nonzero(mesh.facesBottom & (x < 1))[0])) True >>> ignore = mesh.facesBottom.value
- property facesDown¶
Return list of faces on bottom boundary of 2D or 3D Mesh with the y-axis running from bottom to top.
>>> from fipy import Grid2D, Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((12, 13, 14), ... numerix.nonzero(mesh.facesBottom)[0])) True >>> ignore = mesh.facesBottom.value >>> x, y, z = mesh.faceCenters >>> print(numerix.allequal((12, 13), ... numerix.nonzero(mesh.facesBottom & (x < 1))[0])) True >>> ignore = mesh.facesBottom.value
- property facesFront¶
Return list of faces on front boundary of 3D Mesh with the z-axis running from front to back.
>>> from fipy import Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((0, 1, 2, 3, 4, 5), ... numerix.nonzero(mesh.facesFront)[0])) True >>> ignore = mesh.facesFront.value
- property facesLeft¶
Return face on left boundary of Mesh as list with the x-axis running from left to right.
>>> from fipy import Grid2D, Grid3D >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((21, 25), ... numerix.nonzero(mesh.facesLeft)[0])) True >>> ignore = mesh.facesLeft.value >>> mesh = Grid2D(nx = 3, ny = 2, dx = 0.5, dy = 2.) >>> print(numerix.allequal((9, 13), ... numerix.nonzero(mesh.facesLeft)[0])) True >>> ignore = mesh.facesLeft.value
- property facesRight¶
Return list of faces on right boundary of Mesh with the x-axis running from left to right.
>>> from fipy import Grid2D, Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((24, 28), ... numerix.nonzero(mesh.facesRight)[0])) True >>> ignore = mesh.facesRight.value >>> mesh = Grid2D(nx = 3, ny = 2, dx = 0.5, dy = 2.) >>> print(numerix.allequal((12, 16), ... numerix.nonzero(mesh.facesRight)[0])) True >>> ignore = mesh.facesRight.value
- property facesTop¶
Return list of faces on top boundary of 2D or 3D Mesh with the y-axis running from bottom to top.
>>> from fipy import Grid2D, Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((18, 19, 20), ... numerix.nonzero(mesh.facesTop)[0])) True >>> ignore = mesh.facesTop.value >>> mesh = Grid2D(nx = 3, ny = 2, dx = 0.5, dy = 2.) >>> print(numerix.allequal((6, 7, 8), ... numerix.nonzero(mesh.facesTop)[0])) True >>> ignore = mesh.facesTop.value
- property facesUp¶
Return list of faces on top boundary of 2D or 3D Mesh with the y-axis running from bottom to top.
>>> from fipy import Grid2D, Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((18, 19, 20), ... numerix.nonzero(mesh.facesTop)[0])) True >>> ignore = mesh.facesTop.value >>> mesh = Grid2D(nx = 3, ny = 2, dx = 0.5, dy = 2.) >>> print(numerix.allequal((6, 7, 8), ... numerix.nonzero(mesh.facesTop)[0])) True >>> ignore = mesh.facesTop.value
- getNearestCell(point)¶
- property interiorFaceCellIDs¶
- property interiorFaceIDs¶
- property interiorFaces¶
- property scale¶
- property scaledCellDistances¶
- property scaledCellToCellDistances¶
- property scaledCellVolumes¶
- property scaledFaceAreas¶
- property scaledFaceToCellDistances¶
- property x¶
Equivalent to using
cellCenters
[0]
.>>> from fipy import * >>> print(Grid1D(nx=2).x) [ 0.5 1.5]
- property y¶
Equivalent to using
cellCenters
[1]
.>>> from fipy import * >>> print(Grid2D(nx=2, ny=2).y) [ 0.5 0.5 1.5 1.5] >>> print(Grid1D(nx=2).y) Traceback (most recent call last): ... AttributeError: 1D meshes do not have a "y" attribute.
- property z¶
Equivalent to using
cellCenters
[2]
.>>> from fipy import * >>> print(Grid3D(nx=2, ny=2, nz=2).z) [ 0.5 0.5 0.5 0.5 1.5 1.5 1.5 1.5] >>> print(Grid2D(nx=2, ny=2).z) Traceback (most recent call last): ... AttributeError: 1D and 2D meshes do not have a "z" attribute.
- class fipy.PeriodicGrid3DLeftRightFrontBack(dx=1.0, dy=1.0, dz=1.0, nx=None, ny=None, nz=None, overlap=2, communicator=SerialPETScCommWrapper(), *args, **kwargs)¶
Bases:
_BasePeriodicGrid3D
- property VTKCellDataSet¶
Returns a TVTK DataSet representing the cells of this mesh
- property VTKFaceDataSet¶
Returns a TVTK DataSet representing the face centers of this mesh
- __add__(other)¶
Either translate a Mesh or concatenate two Mesh objects.
>>> from fipy.meshes import Grid2D >>> baseMesh = Grid2D(dx = 1.0, dy = 1.0, nx = 2, ny = 2) >>> print(baseMesh.cellCenters) [[ 0.5 1.5 0.5 1.5] [ 0.5 0.5 1.5 1.5]]
If a vector is added to a Mesh, a translated Mesh is returned
>>> translatedMesh = baseMesh + ((5,), (10,)) >>> print(translatedMesh.cellCenters) [[ 5.5 6.5 5.5 6.5] [ 10.5 10.5 11.5 11.5]]
If a Mesh is added to a Mesh, a concatenation of the two Mesh objects is returned
>>> addedMesh = baseMesh + (baseMesh + ((2,), (0,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 2.5 3.5 2.5 3.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5]]
The two Mesh objects need not be properly aligned in order to concatenate them but the resulting mesh may not have the intended connectivity
>>> addedMesh = baseMesh + (baseMesh + ((3,), (0,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 3.5 4.5 3.5 4.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5]]
>>> addedMesh = baseMesh + (baseMesh + ((2,), (2,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 2.5 3.5 2.5 3.5] [ 0.5 0.5 1.5 1.5 2.5 2.5 3.5 3.5]]
No provision is made to avoid or consolidate overlapping Mesh objects
>>> addedMesh = baseMesh + (baseMesh + ((1,), (0,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 1.5 2.5 1.5 2.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5]]
Different Mesh classes can be concatenated
>>> from fipy.meshes import Tri2D >>> triMesh = Tri2D(dx = 1.0, dy = 1.0, nx = 2, ny = 1) >>> triMesh = triMesh + ((2,), (0,)) >>> triAddedMesh = baseMesh + triMesh >>> cellCenters = [[0.5, 1.5, 0.5, 1.5, 2.83333333, 3.83333333, ... 2.5, 3.5, 2.16666667, 3.16666667, 2.5, 3.5], ... [0.5, 0.5, 1.5, 1.5, 0.5, 0.5, 0.83333333, 0.83333333, ... 0.5, 0.5, 0.16666667, 0.16666667]] >>> print(numerix.allclose(triAddedMesh.cellCenters, ... cellCenters)) True
again, their faces need not align, but the mesh may not have the desired connectivity
>>> triMesh = Tri2D(dx = 1.0, dy = 2.0, nx = 2, ny = 1) >>> triMesh = triMesh + ((2,), (0,)) >>> triAddedMesh = baseMesh + triMesh >>> cellCenters = [[ 0.5, 1.5, 0.5, 1.5, 2.83333333, 3.83333333, ... 2.5, 3.5, 2.16666667, 3.16666667, 2.5, 3.5], ... [ 0.5, 0.5, 1.5, 1.5, 1., 1., ... 1.66666667, 1.66666667, 1., 1., 0.33333333, 0.33333333]] >>> print(numerix.allclose(triAddedMesh.cellCenters, ... cellCenters)) True
Mesh concatenation is not limited to 2D meshes
>>> from fipy.meshes import Grid3D >>> threeDBaseMesh = Grid3D(dx = 1.0, dy = 1.0, dz = 1.0, ... nx = 2, ny = 2, nz = 2) >>> threeDSecondMesh = Grid3D(dx = 1.0, dy = 1.0, dz = 1.0, ... nx = 1, ny = 1, nz = 1) >>> threeDAddedMesh = threeDBaseMesh + (threeDSecondMesh + ((2,), (0,), (0,))) >>> print(threeDAddedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 0.5 1.5 0.5 1.5 2.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5 0.5] [ 0.5 0.5 0.5 0.5 1.5 1.5 1.5 1.5 0.5]]
but the different Mesh objects must, of course, have the same dimensionality.
>>> InvalidMesh = threeDBaseMesh + baseMesh Traceback (most recent call last): ... MeshAdditionError: Dimensions do not match
- __div__(other)¶
Tests. >>> from fipy import * >>> print((Grid1D(nx=1) / 2.).cellCenters) [[ 0.25]] >>> AbstractMesh(communicator=None) / 2. Traceback (most recent call last): … NotImplementedError
- __getstate__()¶
Helper for pickle.
- __mul__(factor)¶
Dilate a Mesh by factor.
>>> from fipy.meshes import Grid2D >>> baseMesh = Grid2D(dx = 1.0, dy = 1.0, nx = 2, ny = 2) >>> print(baseMesh.cellCenters) [[ 0.5 1.5 0.5 1.5] [ 0.5 0.5 1.5 1.5]]
The factor can be a scalar
>>> dilatedMesh = baseMesh * 3 >>> print(dilatedMesh.cellCenters) [[ 1.5 4.5 1.5 4.5] [ 1.5 1.5 4.5 4.5]]
or a vector
>>> dilatedMesh = baseMesh * ((3,), (2,)) >>> print(dilatedMesh.cellCenters) [[ 1.5 4.5 1.5 4.5] [ 1. 1. 3. 3. ]]
but the vector must have the same dimensionality as the Mesh
>>> dilatedMesh = baseMesh * ((3,), (2,), (1,)) Traceback (most recent call last): ... ValueError: shape mismatch: objects cannot be broadcast to a single shape
- __radd__(other)¶
Either translate a Mesh or concatenate two Mesh objects.
>>> from fipy.meshes import Grid2D >>> baseMesh = Grid2D(dx = 1.0, dy = 1.0, nx = 2, ny = 2) >>> print(baseMesh.cellCenters) [[ 0.5 1.5 0.5 1.5] [ 0.5 0.5 1.5 1.5]]
If a vector is added to a Mesh, a translated Mesh is returned
>>> translatedMesh = baseMesh + ((5,), (10,)) >>> print(translatedMesh.cellCenters) [[ 5.5 6.5 5.5 6.5] [ 10.5 10.5 11.5 11.5]]
If a Mesh is added to a Mesh, a concatenation of the two Mesh objects is returned
>>> addedMesh = baseMesh + (baseMesh + ((2,), (0,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 2.5 3.5 2.5 3.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5]]
The two Mesh objects need not be properly aligned in order to concatenate them but the resulting mesh may not have the intended connectivity
>>> addedMesh = baseMesh + (baseMesh + ((3,), (0,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 3.5 4.5 3.5 4.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5]]
>>> addedMesh = baseMesh + (baseMesh + ((2,), (2,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 2.5 3.5 2.5 3.5] [ 0.5 0.5 1.5 1.5 2.5 2.5 3.5 3.5]]
No provision is made to avoid or consolidate overlapping Mesh objects
>>> addedMesh = baseMesh + (baseMesh + ((1,), (0,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 1.5 2.5 1.5 2.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5]]
Different Mesh classes can be concatenated
>>> from fipy.meshes import Tri2D >>> triMesh = Tri2D(dx = 1.0, dy = 1.0, nx = 2, ny = 1) >>> triMesh = triMesh + ((2,), (0,)) >>> triAddedMesh = baseMesh + triMesh >>> cellCenters = [[0.5, 1.5, 0.5, 1.5, 2.83333333, 3.83333333, ... 2.5, 3.5, 2.16666667, 3.16666667, 2.5, 3.5], ... [0.5, 0.5, 1.5, 1.5, 0.5, 0.5, 0.83333333, 0.83333333, ... 0.5, 0.5, 0.16666667, 0.16666667]] >>> print(numerix.allclose(triAddedMesh.cellCenters, ... cellCenters)) True
again, their faces need not align, but the mesh may not have the desired connectivity
>>> triMesh = Tri2D(dx = 1.0, dy = 2.0, nx = 2, ny = 1) >>> triMesh = triMesh + ((2,), (0,)) >>> triAddedMesh = baseMesh + triMesh >>> cellCenters = [[ 0.5, 1.5, 0.5, 1.5, 2.83333333, 3.83333333, ... 2.5, 3.5, 2.16666667, 3.16666667, 2.5, 3.5], ... [ 0.5, 0.5, 1.5, 1.5, 1., 1., ... 1.66666667, 1.66666667, 1., 1., 0.33333333, 0.33333333]] >>> print(numerix.allclose(triAddedMesh.cellCenters, ... cellCenters)) True
Mesh concatenation is not limited to 2D meshes
>>> from fipy.meshes import Grid3D >>> threeDBaseMesh = Grid3D(dx = 1.0, dy = 1.0, dz = 1.0, ... nx = 2, ny = 2, nz = 2) >>> threeDSecondMesh = Grid3D(dx = 1.0, dy = 1.0, dz = 1.0, ... nx = 1, ny = 1, nz = 1) >>> threeDAddedMesh = threeDBaseMesh + (threeDSecondMesh + ((2,), (0,), (0,))) >>> print(threeDAddedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 0.5 1.5 0.5 1.5 2.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5 0.5] [ 0.5 0.5 0.5 0.5 1.5 1.5 1.5 1.5 0.5]]
but the different Mesh objects must, of course, have the same dimensionality.
>>> InvalidMesh = threeDBaseMesh + baseMesh Traceback (most recent call last): ... MeshAdditionError: Dimensions do not match
- __repr__()¶
Return repr(self).
- __rmul__(factor)¶
Dilate a Mesh by factor.
>>> from fipy.meshes import Grid2D >>> baseMesh = Grid2D(dx = 1.0, dy = 1.0, nx = 2, ny = 2) >>> print(baseMesh.cellCenters) [[ 0.5 1.5 0.5 1.5] [ 0.5 0.5 1.5 1.5]]
The factor can be a scalar
>>> dilatedMesh = baseMesh * 3 >>> print(dilatedMesh.cellCenters) [[ 1.5 4.5 1.5 4.5] [ 1.5 1.5 4.5 4.5]]
or a vector
>>> dilatedMesh = baseMesh * ((3,), (2,)) >>> print(dilatedMesh.cellCenters) [[ 1.5 4.5 1.5 4.5] [ 1. 1. 3. 3. ]]
but the vector must have the same dimensionality as the Mesh
>>> dilatedMesh = baseMesh * ((3,), (2,), (1,)) Traceback (most recent call last): ... ValueError: shape mismatch: objects cannot be broadcast to a single shape
- __setstate__(state)¶
- __sub__(other)¶
Tests. >>> from fipy import * >>> m = Grid1D() >>> print((m - ((1,))).cellCenters) [[-0.5]] >>> ((1,)) - m Traceback (most recent call last): … TypeError: unsupported operand type(s) for -: ‘tuple’ and ‘UniformGrid1D’
- __truediv__(other)¶
Tests. >>> from fipy import * >>> print((Grid1D(nx=1) / 2.).cellCenters) [[ 0.25]] >>> AbstractMesh(communicator=None) / 2. Traceback (most recent call last): … NotImplementedError
- property aspect2D¶
The physical y vs x aspect ratio of a 2D mesh
- property cellCenters¶
- property cellDistanceVectors¶
- property cellFaceIDs¶
- property cellToFaceDistanceVectors¶
- property cellVolumes¶
- property extents¶
- property exteriorFaces¶
- property faceCenters¶
- property facesBack¶
Return list of faces on back boundary of 3D Mesh with the z-axis running from front to back.
>>> from fipy import Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((6, 7, 8, 9, 10, 11), ... numerix.nonzero(mesh.facesBack)[0])) True >>> ignore = mesh.facesBack.value
- property facesBottom¶
Return list of faces on bottom boundary of 2D or 3D Mesh with the y-axis running from bottom to top.
>>> from fipy import Grid2D, Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((12, 13, 14), ... numerix.nonzero(mesh.facesBottom)[0])) True >>> ignore = mesh.facesBottom.value >>> x, y, z = mesh.faceCenters >>> print(numerix.allequal((12, 13), ... numerix.nonzero(mesh.facesBottom & (x < 1))[0])) True >>> ignore = mesh.facesBottom.value
- property facesDown¶
Return list of faces on bottom boundary of 2D or 3D Mesh with the y-axis running from bottom to top.
>>> from fipy import Grid2D, Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((12, 13, 14), ... numerix.nonzero(mesh.facesBottom)[0])) True >>> ignore = mesh.facesBottom.value >>> x, y, z = mesh.faceCenters >>> print(numerix.allequal((12, 13), ... numerix.nonzero(mesh.facesBottom & (x < 1))[0])) True >>> ignore = mesh.facesBottom.value
- property facesFront¶
Return list of faces on front boundary of 3D Mesh with the z-axis running from front to back.
>>> from fipy import Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((0, 1, 2, 3, 4, 5), ... numerix.nonzero(mesh.facesFront)[0])) True >>> ignore = mesh.facesFront.value
- property facesLeft¶
Return face on left boundary of Mesh as list with the x-axis running from left to right.
>>> from fipy import Grid2D, Grid3D >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((21, 25), ... numerix.nonzero(mesh.facesLeft)[0])) True >>> ignore = mesh.facesLeft.value >>> mesh = Grid2D(nx = 3, ny = 2, dx = 0.5, dy = 2.) >>> print(numerix.allequal((9, 13), ... numerix.nonzero(mesh.facesLeft)[0])) True >>> ignore = mesh.facesLeft.value
- property facesRight¶
Return list of faces on right boundary of Mesh with the x-axis running from left to right.
>>> from fipy import Grid2D, Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((24, 28), ... numerix.nonzero(mesh.facesRight)[0])) True >>> ignore = mesh.facesRight.value >>> mesh = Grid2D(nx = 3, ny = 2, dx = 0.5, dy = 2.) >>> print(numerix.allequal((12, 16), ... numerix.nonzero(mesh.facesRight)[0])) True >>> ignore = mesh.facesRight.value
- property facesTop¶
Return list of faces on top boundary of 2D or 3D Mesh with the y-axis running from bottom to top.
>>> from fipy import Grid2D, Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((18, 19, 20), ... numerix.nonzero(mesh.facesTop)[0])) True >>> ignore = mesh.facesTop.value >>> mesh = Grid2D(nx = 3, ny = 2, dx = 0.5, dy = 2.) >>> print(numerix.allequal((6, 7, 8), ... numerix.nonzero(mesh.facesTop)[0])) True >>> ignore = mesh.facesTop.value
- property facesUp¶
Return list of faces on top boundary of 2D or 3D Mesh with the y-axis running from bottom to top.
>>> from fipy import Grid2D, Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((18, 19, 20), ... numerix.nonzero(mesh.facesTop)[0])) True >>> ignore = mesh.facesTop.value >>> mesh = Grid2D(nx = 3, ny = 2, dx = 0.5, dy = 2.) >>> print(numerix.allequal((6, 7, 8), ... numerix.nonzero(mesh.facesTop)[0])) True >>> ignore = mesh.facesTop.value
- getNearestCell(point)¶
- property interiorFaceCellIDs¶
- property interiorFaceIDs¶
- property interiorFaces¶
- property scale¶
- property scaledCellDistances¶
- property scaledCellToCellDistances¶
- property scaledCellVolumes¶
- property scaledFaceAreas¶
- property scaledFaceToCellDistances¶
- property x¶
Equivalent to using
cellCenters
[0]
.>>> from fipy import * >>> print(Grid1D(nx=2).x) [ 0.5 1.5]
- property y¶
Equivalent to using
cellCenters
[1]
.>>> from fipy import * >>> print(Grid2D(nx=2, ny=2).y) [ 0.5 0.5 1.5 1.5] >>> print(Grid1D(nx=2).y) Traceback (most recent call last): ... AttributeError: 1D meshes do not have a "y" attribute.
- property z¶
Equivalent to using
cellCenters
[2]
.>>> from fipy import * >>> print(Grid3D(nx=2, ny=2, nz=2).z) [ 0.5 0.5 0.5 0.5 1.5 1.5 1.5 1.5] >>> print(Grid2D(nx=2, ny=2).z) Traceback (most recent call last): ... AttributeError: 1D and 2D meshes do not have a "z" attribute.
- class fipy.PeriodicGrid3DLeftRightTopBottom(dx=1.0, dy=1.0, dz=1.0, nx=None, ny=None, nz=None, overlap=2, communicator=SerialPETScCommWrapper(), *args, **kwargs)¶
Bases:
_BasePeriodicGrid3D
- property VTKCellDataSet¶
Returns a TVTK DataSet representing the cells of this mesh
- property VTKFaceDataSet¶
Returns a TVTK DataSet representing the face centers of this mesh
- __add__(other)¶
Either translate a Mesh or concatenate two Mesh objects.
>>> from fipy.meshes import Grid2D >>> baseMesh = Grid2D(dx = 1.0, dy = 1.0, nx = 2, ny = 2) >>> print(baseMesh.cellCenters) [[ 0.5 1.5 0.5 1.5] [ 0.5 0.5 1.5 1.5]]
If a vector is added to a Mesh, a translated Mesh is returned
>>> translatedMesh = baseMesh + ((5,), (10,)) >>> print(translatedMesh.cellCenters) [[ 5.5 6.5 5.5 6.5] [ 10.5 10.5 11.5 11.5]]
If a Mesh is added to a Mesh, a concatenation of the two Mesh objects is returned
>>> addedMesh = baseMesh + (baseMesh + ((2,), (0,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 2.5 3.5 2.5 3.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5]]
The two Mesh objects need not be properly aligned in order to concatenate them but the resulting mesh may not have the intended connectivity
>>> addedMesh = baseMesh + (baseMesh + ((3,), (0,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 3.5 4.5 3.5 4.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5]]
>>> addedMesh = baseMesh + (baseMesh + ((2,), (2,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 2.5 3.5 2.5 3.5] [ 0.5 0.5 1.5 1.5 2.5 2.5 3.5 3.5]]
No provision is made to avoid or consolidate overlapping Mesh objects
>>> addedMesh = baseMesh + (baseMesh + ((1,), (0,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 1.5 2.5 1.5 2.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5]]
Different Mesh classes can be concatenated
>>> from fipy.meshes import Tri2D >>> triMesh = Tri2D(dx = 1.0, dy = 1.0, nx = 2, ny = 1) >>> triMesh = triMesh + ((2,), (0,)) >>> triAddedMesh = baseMesh + triMesh >>> cellCenters = [[0.5, 1.5, 0.5, 1.5, 2.83333333, 3.83333333, ... 2.5, 3.5, 2.16666667, 3.16666667, 2.5, 3.5], ... [0.5, 0.5, 1.5, 1.5, 0.5, 0.5, 0.83333333, 0.83333333, ... 0.5, 0.5, 0.16666667, 0.16666667]] >>> print(numerix.allclose(triAddedMesh.cellCenters, ... cellCenters)) True
again, their faces need not align, but the mesh may not have the desired connectivity
>>> triMesh = Tri2D(dx = 1.0, dy = 2.0, nx = 2, ny = 1) >>> triMesh = triMesh + ((2,), (0,)) >>> triAddedMesh = baseMesh + triMesh >>> cellCenters = [[ 0.5, 1.5, 0.5, 1.5, 2.83333333, 3.83333333, ... 2.5, 3.5, 2.16666667, 3.16666667, 2.5, 3.5], ... [ 0.5, 0.5, 1.5, 1.5, 1., 1., ... 1.66666667, 1.66666667, 1., 1., 0.33333333, 0.33333333]] >>> print(numerix.allclose(triAddedMesh.cellCenters, ... cellCenters)) True
Mesh concatenation is not limited to 2D meshes
>>> from fipy.meshes import Grid3D >>> threeDBaseMesh = Grid3D(dx = 1.0, dy = 1.0, dz = 1.0, ... nx = 2, ny = 2, nz = 2) >>> threeDSecondMesh = Grid3D(dx = 1.0, dy = 1.0, dz = 1.0, ... nx = 1, ny = 1, nz = 1) >>> threeDAddedMesh = threeDBaseMesh + (threeDSecondMesh + ((2,), (0,), (0,))) >>> print(threeDAddedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 0.5 1.5 0.5 1.5 2.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5 0.5] [ 0.5 0.5 0.5 0.5 1.5 1.5 1.5 1.5 0.5]]
but the different Mesh objects must, of course, have the same dimensionality.
>>> InvalidMesh = threeDBaseMesh + baseMesh Traceback (most recent call last): ... MeshAdditionError: Dimensions do not match
- __div__(other)¶
Tests. >>> from fipy import * >>> print((Grid1D(nx=1) / 2.).cellCenters) [[ 0.25]] >>> AbstractMesh(communicator=None) / 2. Traceback (most recent call last): … NotImplementedError
- __getstate__()¶
Helper for pickle.
- __mul__(factor)¶
Dilate a Mesh by factor.
>>> from fipy.meshes import Grid2D >>> baseMesh = Grid2D(dx = 1.0, dy = 1.0, nx = 2, ny = 2) >>> print(baseMesh.cellCenters) [[ 0.5 1.5 0.5 1.5] [ 0.5 0.5 1.5 1.5]]
The factor can be a scalar
>>> dilatedMesh = baseMesh * 3 >>> print(dilatedMesh.cellCenters) [[ 1.5 4.5 1.5 4.5] [ 1.5 1.5 4.5 4.5]]
or a vector
>>> dilatedMesh = baseMesh * ((3,), (2,)) >>> print(dilatedMesh.cellCenters) [[ 1.5 4.5 1.5 4.5] [ 1. 1. 3. 3. ]]
but the vector must have the same dimensionality as the Mesh
>>> dilatedMesh = baseMesh * ((3,), (2,), (1,)) Traceback (most recent call last): ... ValueError: shape mismatch: objects cannot be broadcast to a single shape
- __radd__(other)¶
Either translate a Mesh or concatenate two Mesh objects.
>>> from fipy.meshes import Grid2D >>> baseMesh = Grid2D(dx = 1.0, dy = 1.0, nx = 2, ny = 2) >>> print(baseMesh.cellCenters) [[ 0.5 1.5 0.5 1.5] [ 0.5 0.5 1.5 1.5]]
If a vector is added to a Mesh, a translated Mesh is returned
>>> translatedMesh = baseMesh + ((5,), (10,)) >>> print(translatedMesh.cellCenters) [[ 5.5 6.5 5.5 6.5] [ 10.5 10.5 11.5 11.5]]
If a Mesh is added to a Mesh, a concatenation of the two Mesh objects is returned
>>> addedMesh = baseMesh + (baseMesh + ((2,), (0,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 2.5 3.5 2.5 3.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5]]
The two Mesh objects need not be properly aligned in order to concatenate them but the resulting mesh may not have the intended connectivity
>>> addedMesh = baseMesh + (baseMesh + ((3,), (0,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 3.5 4.5 3.5 4.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5]]
>>> addedMesh = baseMesh + (baseMesh + ((2,), (2,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 2.5 3.5 2.5 3.5] [ 0.5 0.5 1.5 1.5 2.5 2.5 3.5 3.5]]
No provision is made to avoid or consolidate overlapping Mesh objects
>>> addedMesh = baseMesh + (baseMesh + ((1,), (0,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 1.5 2.5 1.5 2.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5]]
Different Mesh classes can be concatenated
>>> from fipy.meshes import Tri2D >>> triMesh = Tri2D(dx = 1.0, dy = 1.0, nx = 2, ny = 1) >>> triMesh = triMesh + ((2,), (0,)) >>> triAddedMesh = baseMesh + triMesh >>> cellCenters = [[0.5, 1.5, 0.5, 1.5, 2.83333333, 3.83333333, ... 2.5, 3.5, 2.16666667, 3.16666667, 2.5, 3.5], ... [0.5, 0.5, 1.5, 1.5, 0.5, 0.5, 0.83333333, 0.83333333, ... 0.5, 0.5, 0.16666667, 0.16666667]] >>> print(numerix.allclose(triAddedMesh.cellCenters, ... cellCenters)) True
again, their faces need not align, but the mesh may not have the desired connectivity
>>> triMesh = Tri2D(dx = 1.0, dy = 2.0, nx = 2, ny = 1) >>> triMesh = triMesh + ((2,), (0,)) >>> triAddedMesh = baseMesh + triMesh >>> cellCenters = [[ 0.5, 1.5, 0.5, 1.5, 2.83333333, 3.83333333, ... 2.5, 3.5, 2.16666667, 3.16666667, 2.5, 3.5], ... [ 0.5, 0.5, 1.5, 1.5, 1., 1., ... 1.66666667, 1.66666667, 1., 1., 0.33333333, 0.33333333]] >>> print(numerix.allclose(triAddedMesh.cellCenters, ... cellCenters)) True
Mesh concatenation is not limited to 2D meshes
>>> from fipy.meshes import Grid3D >>> threeDBaseMesh = Grid3D(dx = 1.0, dy = 1.0, dz = 1.0, ... nx = 2, ny = 2, nz = 2) >>> threeDSecondMesh = Grid3D(dx = 1.0, dy = 1.0, dz = 1.0, ... nx = 1, ny = 1, nz = 1) >>> threeDAddedMesh = threeDBaseMesh + (threeDSecondMesh + ((2,), (0,), (0,))) >>> print(threeDAddedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 0.5 1.5 0.5 1.5 2.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5 0.5] [ 0.5 0.5 0.5 0.5 1.5 1.5 1.5 1.5 0.5]]
but the different Mesh objects must, of course, have the same dimensionality.
>>> InvalidMesh = threeDBaseMesh + baseMesh Traceback (most recent call last): ... MeshAdditionError: Dimensions do not match
- __repr__()¶
Return repr(self).
- __rmul__(factor)¶
Dilate a Mesh by factor.
>>> from fipy.meshes import Grid2D >>> baseMesh = Grid2D(dx = 1.0, dy = 1.0, nx = 2, ny = 2) >>> print(baseMesh.cellCenters) [[ 0.5 1.5 0.5 1.5] [ 0.5 0.5 1.5 1.5]]
The factor can be a scalar
>>> dilatedMesh = baseMesh * 3 >>> print(dilatedMesh.cellCenters) [[ 1.5 4.5 1.5 4.5] [ 1.5 1.5 4.5 4.5]]
or a vector
>>> dilatedMesh = baseMesh * ((3,), (2,)) >>> print(dilatedMesh.cellCenters) [[ 1.5 4.5 1.5 4.5] [ 1. 1. 3. 3. ]]
but the vector must have the same dimensionality as the Mesh
>>> dilatedMesh = baseMesh * ((3,), (2,), (1,)) Traceback (most recent call last): ... ValueError: shape mismatch: objects cannot be broadcast to a single shape
- __setstate__(state)¶
- __sub__(other)¶
Tests. >>> from fipy import * >>> m = Grid1D() >>> print((m - ((1,))).cellCenters) [[-0.5]] >>> ((1,)) - m Traceback (most recent call last): … TypeError: unsupported operand type(s) for -: ‘tuple’ and ‘UniformGrid1D’
- __truediv__(other)¶
Tests. >>> from fipy import * >>> print((Grid1D(nx=1) / 2.).cellCenters) [[ 0.25]] >>> AbstractMesh(communicator=None) / 2. Traceback (most recent call last): … NotImplementedError
- property aspect2D¶
The physical y vs x aspect ratio of a 2D mesh
- property cellCenters¶
- property cellDistanceVectors¶
- property cellFaceIDs¶
- property cellToFaceDistanceVectors¶
- property cellVolumes¶
- property extents¶
- property exteriorFaces¶
- property faceCenters¶
- property facesBack¶
Return list of faces on back boundary of 3D Mesh with the z-axis running from front to back.
>>> from fipy import Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((6, 7, 8, 9, 10, 11), ... numerix.nonzero(mesh.facesBack)[0])) True >>> ignore = mesh.facesBack.value
- property facesBottom¶
Return list of faces on bottom boundary of 2D or 3D Mesh with the y-axis running from bottom to top.
>>> from fipy import Grid2D, Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((12, 13, 14), ... numerix.nonzero(mesh.facesBottom)[0])) True >>> ignore = mesh.facesBottom.value >>> x, y, z = mesh.faceCenters >>> print(numerix.allequal((12, 13), ... numerix.nonzero(mesh.facesBottom & (x < 1))[0])) True >>> ignore = mesh.facesBottom.value
- property facesDown¶
Return list of faces on bottom boundary of 2D or 3D Mesh with the y-axis running from bottom to top.
>>> from fipy import Grid2D, Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((12, 13, 14), ... numerix.nonzero(mesh.facesBottom)[0])) True >>> ignore = mesh.facesBottom.value >>> x, y, z = mesh.faceCenters >>> print(numerix.allequal((12, 13), ... numerix.nonzero(mesh.facesBottom & (x < 1))[0])) True >>> ignore = mesh.facesBottom.value
- property facesFront¶
Return list of faces on front boundary of 3D Mesh with the z-axis running from front to back.
>>> from fipy import Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((0, 1, 2, 3, 4, 5), ... numerix.nonzero(mesh.facesFront)[0])) True >>> ignore = mesh.facesFront.value
- property facesLeft¶
Return face on left boundary of Mesh as list with the x-axis running from left to right.
>>> from fipy import Grid2D, Grid3D >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((21, 25), ... numerix.nonzero(mesh.facesLeft)[0])) True >>> ignore = mesh.facesLeft.value >>> mesh = Grid2D(nx = 3, ny = 2, dx = 0.5, dy = 2.) >>> print(numerix.allequal((9, 13), ... numerix.nonzero(mesh.facesLeft)[0])) True >>> ignore = mesh.facesLeft.value
- property facesRight¶
Return list of faces on right boundary of Mesh with the x-axis running from left to right.
>>> from fipy import Grid2D, Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((24, 28), ... numerix.nonzero(mesh.facesRight)[0])) True >>> ignore = mesh.facesRight.value >>> mesh = Grid2D(nx = 3, ny = 2, dx = 0.5, dy = 2.) >>> print(numerix.allequal((12, 16), ... numerix.nonzero(mesh.facesRight)[0])) True >>> ignore = mesh.facesRight.value
- property facesTop¶
Return list of faces on top boundary of 2D or 3D Mesh with the y-axis running from bottom to top.
>>> from fipy import Grid2D, Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((18, 19, 20), ... numerix.nonzero(mesh.facesTop)[0])) True >>> ignore = mesh.facesTop.value >>> mesh = Grid2D(nx = 3, ny = 2, dx = 0.5, dy = 2.) >>> print(numerix.allequal((6, 7, 8), ... numerix.nonzero(mesh.facesTop)[0])) True >>> ignore = mesh.facesTop.value
- property facesUp¶
Return list of faces on top boundary of 2D or 3D Mesh with the y-axis running from bottom to top.
>>> from fipy import Grid2D, Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((18, 19, 20), ... numerix.nonzero(mesh.facesTop)[0])) True >>> ignore = mesh.facesTop.value >>> mesh = Grid2D(nx = 3, ny = 2, dx = 0.5, dy = 2.) >>> print(numerix.allequal((6, 7, 8), ... numerix.nonzero(mesh.facesTop)[0])) True >>> ignore = mesh.facesTop.value
- getNearestCell(point)¶
- property interiorFaceCellIDs¶
- property interiorFaceIDs¶
- property interiorFaces¶
- property scale¶
- property scaledCellDistances¶
- property scaledCellToCellDistances¶
- property scaledCellVolumes¶
- property scaledFaceAreas¶
- property scaledFaceToCellDistances¶
- property x¶
Equivalent to using
cellCenters
[0]
.>>> from fipy import * >>> print(Grid1D(nx=2).x) [ 0.5 1.5]
- property y¶
Equivalent to using
cellCenters
[1]
.>>> from fipy import * >>> print(Grid2D(nx=2, ny=2).y) [ 0.5 0.5 1.5 1.5] >>> print(Grid1D(nx=2).y) Traceback (most recent call last): ... AttributeError: 1D meshes do not have a "y" attribute.
- property z¶
Equivalent to using
cellCenters
[2]
.>>> from fipy import * >>> print(Grid3D(nx=2, ny=2, nz=2).z) [ 0.5 0.5 0.5 0.5 1.5 1.5 1.5 1.5] >>> print(Grid2D(nx=2, ny=2).z) Traceback (most recent call last): ... AttributeError: 1D and 2D meshes do not have a "z" attribute.
- class fipy.PeriodicGrid3DTopBottom(dx=1.0, dy=1.0, dz=1.0, nx=None, ny=None, nz=None, overlap=2, communicator=SerialPETScCommWrapper(), *args, **kwargs)¶
Bases:
_BasePeriodicGrid3D
- property VTKCellDataSet¶
Returns a TVTK DataSet representing the cells of this mesh
- property VTKFaceDataSet¶
Returns a TVTK DataSet representing the face centers of this mesh
- __add__(other)¶
Either translate a Mesh or concatenate two Mesh objects.
>>> from fipy.meshes import Grid2D >>> baseMesh = Grid2D(dx = 1.0, dy = 1.0, nx = 2, ny = 2) >>> print(baseMesh.cellCenters) [[ 0.5 1.5 0.5 1.5] [ 0.5 0.5 1.5 1.5]]
If a vector is added to a Mesh, a translated Mesh is returned
>>> translatedMesh = baseMesh + ((5,), (10,)) >>> print(translatedMesh.cellCenters) [[ 5.5 6.5 5.5 6.5] [ 10.5 10.5 11.5 11.5]]
If a Mesh is added to a Mesh, a concatenation of the two Mesh objects is returned
>>> addedMesh = baseMesh + (baseMesh + ((2,), (0,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 2.5 3.5 2.5 3.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5]]
The two Mesh objects need not be properly aligned in order to concatenate them but the resulting mesh may not have the intended connectivity
>>> addedMesh = baseMesh + (baseMesh + ((3,), (0,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 3.5 4.5 3.5 4.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5]]
>>> addedMesh = baseMesh + (baseMesh + ((2,), (2,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 2.5 3.5 2.5 3.5] [ 0.5 0.5 1.5 1.5 2.5 2.5 3.5 3.5]]
No provision is made to avoid or consolidate overlapping Mesh objects
>>> addedMesh = baseMesh + (baseMesh + ((1,), (0,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 1.5 2.5 1.5 2.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5]]
Different Mesh classes can be concatenated
>>> from fipy.meshes import Tri2D >>> triMesh = Tri2D(dx = 1.0, dy = 1.0, nx = 2, ny = 1) >>> triMesh = triMesh + ((2,), (0,)) >>> triAddedMesh = baseMesh + triMesh >>> cellCenters = [[0.5, 1.5, 0.5, 1.5, 2.83333333, 3.83333333, ... 2.5, 3.5, 2.16666667, 3.16666667, 2.5, 3.5], ... [0.5, 0.5, 1.5, 1.5, 0.5, 0.5, 0.83333333, 0.83333333, ... 0.5, 0.5, 0.16666667, 0.16666667]] >>> print(numerix.allclose(triAddedMesh.cellCenters, ... cellCenters)) True
again, their faces need not align, but the mesh may not have the desired connectivity
>>> triMesh = Tri2D(dx = 1.0, dy = 2.0, nx = 2, ny = 1) >>> triMesh = triMesh + ((2,), (0,)) >>> triAddedMesh = baseMesh + triMesh >>> cellCenters = [[ 0.5, 1.5, 0.5, 1.5, 2.83333333, 3.83333333, ... 2.5, 3.5, 2.16666667, 3.16666667, 2.5, 3.5], ... [ 0.5, 0.5, 1.5, 1.5, 1., 1., ... 1.66666667, 1.66666667, 1., 1., 0.33333333, 0.33333333]] >>> print(numerix.allclose(triAddedMesh.cellCenters, ... cellCenters)) True
Mesh concatenation is not limited to 2D meshes
>>> from fipy.meshes import Grid3D >>> threeDBaseMesh = Grid3D(dx = 1.0, dy = 1.0, dz = 1.0, ... nx = 2, ny = 2, nz = 2) >>> threeDSecondMesh = Grid3D(dx = 1.0, dy = 1.0, dz = 1.0, ... nx = 1, ny = 1, nz = 1) >>> threeDAddedMesh = threeDBaseMesh + (threeDSecondMesh + ((2,), (0,), (0,))) >>> print(threeDAddedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 0.5 1.5 0.5 1.5 2.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5 0.5] [ 0.5 0.5 0.5 0.5 1.5 1.5 1.5 1.5 0.5]]
but the different Mesh objects must, of course, have the same dimensionality.
>>> InvalidMesh = threeDBaseMesh + baseMesh Traceback (most recent call last): ... MeshAdditionError: Dimensions do not match
- __div__(other)¶
Tests. >>> from fipy import * >>> print((Grid1D(nx=1) / 2.).cellCenters) [[ 0.25]] >>> AbstractMesh(communicator=None) / 2. Traceback (most recent call last): … NotImplementedError
- __getstate__()¶
Helper for pickle.
- __mul__(factor)¶
Dilate a Mesh by factor.
>>> from fipy.meshes import Grid2D >>> baseMesh = Grid2D(dx = 1.0, dy = 1.0, nx = 2, ny = 2) >>> print(baseMesh.cellCenters) [[ 0.5 1.5 0.5 1.5] [ 0.5 0.5 1.5 1.5]]
The factor can be a scalar
>>> dilatedMesh = baseMesh * 3 >>> print(dilatedMesh.cellCenters) [[ 1.5 4.5 1.5 4.5] [ 1.5 1.5 4.5 4.5]]
or a vector
>>> dilatedMesh = baseMesh * ((3,), (2,)) >>> print(dilatedMesh.cellCenters) [[ 1.5 4.5 1.5 4.5] [ 1. 1. 3. 3. ]]
but the vector must have the same dimensionality as the Mesh
>>> dilatedMesh = baseMesh * ((3,), (2,), (1,)) Traceback (most recent call last): ... ValueError: shape mismatch: objects cannot be broadcast to a single shape
- __radd__(other)¶
Either translate a Mesh or concatenate two Mesh objects.
>>> from fipy.meshes import Grid2D >>> baseMesh = Grid2D(dx = 1.0, dy = 1.0, nx = 2, ny = 2) >>> print(baseMesh.cellCenters) [[ 0.5 1.5 0.5 1.5] [ 0.5 0.5 1.5 1.5]]
If a vector is added to a Mesh, a translated Mesh is returned
>>> translatedMesh = baseMesh + ((5,), (10,)) >>> print(translatedMesh.cellCenters) [[ 5.5 6.5 5.5 6.5] [ 10.5 10.5 11.5 11.5]]
If a Mesh is added to a Mesh, a concatenation of the two Mesh objects is returned
>>> addedMesh = baseMesh + (baseMesh + ((2,), (0,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 2.5 3.5 2.5 3.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5]]
The two Mesh objects need not be properly aligned in order to concatenate them but the resulting mesh may not have the intended connectivity
>>> addedMesh = baseMesh + (baseMesh + ((3,), (0,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 3.5 4.5 3.5 4.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5]]
>>> addedMesh = baseMesh + (baseMesh + ((2,), (2,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 2.5 3.5 2.5 3.5] [ 0.5 0.5 1.5 1.5 2.5 2.5 3.5 3.5]]
No provision is made to avoid or consolidate overlapping Mesh objects
>>> addedMesh = baseMesh + (baseMesh + ((1,), (0,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 1.5 2.5 1.5 2.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5]]
Different Mesh classes can be concatenated
>>> from fipy.meshes import Tri2D >>> triMesh = Tri2D(dx = 1.0, dy = 1.0, nx = 2, ny = 1) >>> triMesh = triMesh + ((2,), (0,)) >>> triAddedMesh = baseMesh + triMesh >>> cellCenters = [[0.5, 1.5, 0.5, 1.5, 2.83333333, 3.83333333, ... 2.5, 3.5, 2.16666667, 3.16666667, 2.5, 3.5], ... [0.5, 0.5, 1.5, 1.5, 0.5, 0.5, 0.83333333, 0.83333333, ... 0.5, 0.5, 0.16666667, 0.16666667]] >>> print(numerix.allclose(triAddedMesh.cellCenters, ... cellCenters)) True
again, their faces need not align, but the mesh may not have the desired connectivity
>>> triMesh = Tri2D(dx = 1.0, dy = 2.0, nx = 2, ny = 1) >>> triMesh = triMesh + ((2,), (0,)) >>> triAddedMesh = baseMesh + triMesh >>> cellCenters = [[ 0.5, 1.5, 0.5, 1.5, 2.83333333, 3.83333333, ... 2.5, 3.5, 2.16666667, 3.16666667, 2.5, 3.5], ... [ 0.5, 0.5, 1.5, 1.5, 1., 1., ... 1.66666667, 1.66666667, 1., 1., 0.33333333, 0.33333333]] >>> print(numerix.allclose(triAddedMesh.cellCenters, ... cellCenters)) True
Mesh concatenation is not limited to 2D meshes
>>> from fipy.meshes import Grid3D >>> threeDBaseMesh = Grid3D(dx = 1.0, dy = 1.0, dz = 1.0, ... nx = 2, ny = 2, nz = 2) >>> threeDSecondMesh = Grid3D(dx = 1.0, dy = 1.0, dz = 1.0, ... nx = 1, ny = 1, nz = 1) >>> threeDAddedMesh = threeDBaseMesh + (threeDSecondMesh + ((2,), (0,), (0,))) >>> print(threeDAddedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 0.5 1.5 0.5 1.5 2.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5 0.5] [ 0.5 0.5 0.5 0.5 1.5 1.5 1.5 1.5 0.5]]
but the different Mesh objects must, of course, have the same dimensionality.
>>> InvalidMesh = threeDBaseMesh + baseMesh Traceback (most recent call last): ... MeshAdditionError: Dimensions do not match
- __repr__()¶
Return repr(self).
- __rmul__(factor)¶
Dilate a Mesh by factor.
>>> from fipy.meshes import Grid2D >>> baseMesh = Grid2D(dx = 1.0, dy = 1.0, nx = 2, ny = 2) >>> print(baseMesh.cellCenters) [[ 0.5 1.5 0.5 1.5] [ 0.5 0.5 1.5 1.5]]
The factor can be a scalar
>>> dilatedMesh = baseMesh * 3 >>> print(dilatedMesh.cellCenters) [[ 1.5 4.5 1.5 4.5] [ 1.5 1.5 4.5 4.5]]
or a vector
>>> dilatedMesh = baseMesh * ((3,), (2,)) >>> print(dilatedMesh.cellCenters) [[ 1.5 4.5 1.5 4.5] [ 1. 1. 3. 3. ]]
but the vector must have the same dimensionality as the Mesh
>>> dilatedMesh = baseMesh * ((3,), (2,), (1,)) Traceback (most recent call last): ... ValueError: shape mismatch: objects cannot be broadcast to a single shape
- __setstate__(state)¶
- __sub__(other)¶
Tests. >>> from fipy import * >>> m = Grid1D() >>> print((m - ((1,))).cellCenters) [[-0.5]] >>> ((1,)) - m Traceback (most recent call last): … TypeError: unsupported operand type(s) for -: ‘tuple’ and ‘UniformGrid1D’
- __truediv__(other)¶
Tests. >>> from fipy import * >>> print((Grid1D(nx=1) / 2.).cellCenters) [[ 0.25]] >>> AbstractMesh(communicator=None) / 2. Traceback (most recent call last): … NotImplementedError
- property aspect2D¶
The physical y vs x aspect ratio of a 2D mesh
- property cellCenters¶
- property cellDistanceVectors¶
- property cellFaceIDs¶
- property cellToFaceDistanceVectors¶
- property cellVolumes¶
- property extents¶
- property exteriorFaces¶
- property faceCenters¶
- property facesBack¶
Return list of faces on back boundary of 3D Mesh with the z-axis running from front to back.
>>> from fipy import Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((6, 7, 8, 9, 10, 11), ... numerix.nonzero(mesh.facesBack)[0])) True >>> ignore = mesh.facesBack.value
- property facesBottom¶
Return list of faces on bottom boundary of 2D or 3D Mesh with the y-axis running from bottom to top.
>>> from fipy import Grid2D, Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((12, 13, 14), ... numerix.nonzero(mesh.facesBottom)[0])) True >>> ignore = mesh.facesBottom.value >>> x, y, z = mesh.faceCenters >>> print(numerix.allequal((12, 13), ... numerix.nonzero(mesh.facesBottom & (x < 1))[0])) True >>> ignore = mesh.facesBottom.value
- property facesDown¶
Return list of faces on bottom boundary of 2D or 3D Mesh with the y-axis running from bottom to top.
>>> from fipy import Grid2D, Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((12, 13, 14), ... numerix.nonzero(mesh.facesBottom)[0])) True >>> ignore = mesh.facesBottom.value >>> x, y, z = mesh.faceCenters >>> print(numerix.allequal((12, 13), ... numerix.nonzero(mesh.facesBottom & (x < 1))[0])) True >>> ignore = mesh.facesBottom.value
- property facesFront¶
Return list of faces on front boundary of 3D Mesh with the z-axis running from front to back.
>>> from fipy import Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((0, 1, 2, 3, 4, 5), ... numerix.nonzero(mesh.facesFront)[0])) True >>> ignore = mesh.facesFront.value
- property facesLeft¶
Return face on left boundary of Mesh as list with the x-axis running from left to right.
>>> from fipy import Grid2D, Grid3D >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((21, 25), ... numerix.nonzero(mesh.facesLeft)[0])) True >>> ignore = mesh.facesLeft.value >>> mesh = Grid2D(nx = 3, ny = 2, dx = 0.5, dy = 2.) >>> print(numerix.allequal((9, 13), ... numerix.nonzero(mesh.facesLeft)[0])) True >>> ignore = mesh.facesLeft.value
- property facesRight¶
Return list of faces on right boundary of Mesh with the x-axis running from left to right.
>>> from fipy import Grid2D, Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((24, 28), ... numerix.nonzero(mesh.facesRight)[0])) True >>> ignore = mesh.facesRight.value >>> mesh = Grid2D(nx = 3, ny = 2, dx = 0.5, dy = 2.) >>> print(numerix.allequal((12, 16), ... numerix.nonzero(mesh.facesRight)[0])) True >>> ignore = mesh.facesRight.value
- property facesTop¶
Return list of faces on top boundary of 2D or 3D Mesh with the y-axis running from bottom to top.
>>> from fipy import Grid2D, Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((18, 19, 20), ... numerix.nonzero(mesh.facesTop)[0])) True >>> ignore = mesh.facesTop.value >>> mesh = Grid2D(nx = 3, ny = 2, dx = 0.5, dy = 2.) >>> print(numerix.allequal((6, 7, 8), ... numerix.nonzero(mesh.facesTop)[0])) True >>> ignore = mesh.facesTop.value
- property facesUp¶
Return list of faces on top boundary of 2D or 3D Mesh with the y-axis running from bottom to top.
>>> from fipy import Grid2D, Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((18, 19, 20), ... numerix.nonzero(mesh.facesTop)[0])) True >>> ignore = mesh.facesTop.value >>> mesh = Grid2D(nx = 3, ny = 2, dx = 0.5, dy = 2.) >>> print(numerix.allequal((6, 7, 8), ... numerix.nonzero(mesh.facesTop)[0])) True >>> ignore = mesh.facesTop.value
- getNearestCell(point)¶
- property interiorFaceCellIDs¶
- property interiorFaceIDs¶
- property interiorFaces¶
- property scale¶
- property scaledCellDistances¶
- property scaledCellToCellDistances¶
- property scaledCellVolumes¶
- property scaledFaceAreas¶
- property scaledFaceToCellDistances¶
- property x¶
Equivalent to using
cellCenters
[0]
.>>> from fipy import * >>> print(Grid1D(nx=2).x) [ 0.5 1.5]
- property y¶
Equivalent to using
cellCenters
[1]
.>>> from fipy import * >>> print(Grid2D(nx=2, ny=2).y) [ 0.5 0.5 1.5 1.5] >>> print(Grid1D(nx=2).y) Traceback (most recent call last): ... AttributeError: 1D meshes do not have a "y" attribute.
- property z¶
Equivalent to using
cellCenters
[2]
.>>> from fipy import * >>> print(Grid3D(nx=2, ny=2, nz=2).z) [ 0.5 0.5 0.5 0.5 1.5 1.5 1.5 1.5] >>> print(Grid2D(nx=2, ny=2).z) Traceback (most recent call last): ... AttributeError: 1D and 2D meshes do not have a "z" attribute.
- class fipy.PeriodicGrid3DTopBottomFrontBack(dx=1.0, dy=1.0, dz=1.0, nx=None, ny=None, nz=None, overlap=2, communicator=SerialPETScCommWrapper(), *args, **kwargs)¶
Bases:
_BasePeriodicGrid3D
- property VTKCellDataSet¶
Returns a TVTK DataSet representing the cells of this mesh
- property VTKFaceDataSet¶
Returns a TVTK DataSet representing the face centers of this mesh
- __add__(other)¶
Either translate a Mesh or concatenate two Mesh objects.
>>> from fipy.meshes import Grid2D >>> baseMesh = Grid2D(dx = 1.0, dy = 1.0, nx = 2, ny = 2) >>> print(baseMesh.cellCenters) [[ 0.5 1.5 0.5 1.5] [ 0.5 0.5 1.5 1.5]]
If a vector is added to a Mesh, a translated Mesh is returned
>>> translatedMesh = baseMesh + ((5,), (10,)) >>> print(translatedMesh.cellCenters) [[ 5.5 6.5 5.5 6.5] [ 10.5 10.5 11.5 11.5]]
If a Mesh is added to a Mesh, a concatenation of the two Mesh objects is returned
>>> addedMesh = baseMesh + (baseMesh + ((2,), (0,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 2.5 3.5 2.5 3.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5]]
The two Mesh objects need not be properly aligned in order to concatenate them but the resulting mesh may not have the intended connectivity
>>> addedMesh = baseMesh + (baseMesh + ((3,), (0,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 3.5 4.5 3.5 4.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5]]
>>> addedMesh = baseMesh + (baseMesh + ((2,), (2,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 2.5 3.5 2.5 3.5] [ 0.5 0.5 1.5 1.5 2.5 2.5 3.5 3.5]]
No provision is made to avoid or consolidate overlapping Mesh objects
>>> addedMesh = baseMesh + (baseMesh + ((1,), (0,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 1.5 2.5 1.5 2.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5]]
Different Mesh classes can be concatenated
>>> from fipy.meshes import Tri2D >>> triMesh = Tri2D(dx = 1.0, dy = 1.0, nx = 2, ny = 1) >>> triMesh = triMesh + ((2,), (0,)) >>> triAddedMesh = baseMesh + triMesh >>> cellCenters = [[0.5, 1.5, 0.5, 1.5, 2.83333333, 3.83333333, ... 2.5, 3.5, 2.16666667, 3.16666667, 2.5, 3.5], ... [0.5, 0.5, 1.5, 1.5, 0.5, 0.5, 0.83333333, 0.83333333, ... 0.5, 0.5, 0.16666667, 0.16666667]] >>> print(numerix.allclose(triAddedMesh.cellCenters, ... cellCenters)) True
again, their faces need not align, but the mesh may not have the desired connectivity
>>> triMesh = Tri2D(dx = 1.0, dy = 2.0, nx = 2, ny = 1) >>> triMesh = triMesh + ((2,), (0,)) >>> triAddedMesh = baseMesh + triMesh >>> cellCenters = [[ 0.5, 1.5, 0.5, 1.5, 2.83333333, 3.83333333, ... 2.5, 3.5, 2.16666667, 3.16666667, 2.5, 3.5], ... [ 0.5, 0.5, 1.5, 1.5, 1., 1., ... 1.66666667, 1.66666667, 1., 1., 0.33333333, 0.33333333]] >>> print(numerix.allclose(triAddedMesh.cellCenters, ... cellCenters)) True
Mesh concatenation is not limited to 2D meshes
>>> from fipy.meshes import Grid3D >>> threeDBaseMesh = Grid3D(dx = 1.0, dy = 1.0, dz = 1.0, ... nx = 2, ny = 2, nz = 2) >>> threeDSecondMesh = Grid3D(dx = 1.0, dy = 1.0, dz = 1.0, ... nx = 1, ny = 1, nz = 1) >>> threeDAddedMesh = threeDBaseMesh + (threeDSecondMesh + ((2,), (0,), (0,))) >>> print(threeDAddedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 0.5 1.5 0.5 1.5 2.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5 0.5] [ 0.5 0.5 0.5 0.5 1.5 1.5 1.5 1.5 0.5]]
but the different Mesh objects must, of course, have the same dimensionality.
>>> InvalidMesh = threeDBaseMesh + baseMesh Traceback (most recent call last): ... MeshAdditionError: Dimensions do not match
- __div__(other)¶
Tests. >>> from fipy import * >>> print((Grid1D(nx=1) / 2.).cellCenters) [[ 0.25]] >>> AbstractMesh(communicator=None) / 2. Traceback (most recent call last): … NotImplementedError
- __getstate__()¶
Helper for pickle.
- __mul__(factor)¶
Dilate a Mesh by factor.
>>> from fipy.meshes import Grid2D >>> baseMesh = Grid2D(dx = 1.0, dy = 1.0, nx = 2, ny = 2) >>> print(baseMesh.cellCenters) [[ 0.5 1.5 0.5 1.5] [ 0.5 0.5 1.5 1.5]]
The factor can be a scalar
>>> dilatedMesh = baseMesh * 3 >>> print(dilatedMesh.cellCenters) [[ 1.5 4.5 1.5 4.5] [ 1.5 1.5 4.5 4.5]]
or a vector
>>> dilatedMesh = baseMesh * ((3,), (2,)) >>> print(dilatedMesh.cellCenters) [[ 1.5 4.5 1.5 4.5] [ 1. 1. 3. 3. ]]
but the vector must have the same dimensionality as the Mesh
>>> dilatedMesh = baseMesh * ((3,), (2,), (1,)) Traceback (most recent call last): ... ValueError: shape mismatch: objects cannot be broadcast to a single shape
- __radd__(other)¶
Either translate a Mesh or concatenate two Mesh objects.
>>> from fipy.meshes import Grid2D >>> baseMesh = Grid2D(dx = 1.0, dy = 1.0, nx = 2, ny = 2) >>> print(baseMesh.cellCenters) [[ 0.5 1.5 0.5 1.5] [ 0.5 0.5 1.5 1.5]]
If a vector is added to a Mesh, a translated Mesh is returned
>>> translatedMesh = baseMesh + ((5,), (10,)) >>> print(translatedMesh.cellCenters) [[ 5.5 6.5 5.5 6.5] [ 10.5 10.5 11.5 11.5]]
If a Mesh is added to a Mesh, a concatenation of the two Mesh objects is returned
>>> addedMesh = baseMesh + (baseMesh + ((2,), (0,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 2.5 3.5 2.5 3.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5]]
The two Mesh objects need not be properly aligned in order to concatenate them but the resulting mesh may not have the intended connectivity
>>> addedMesh = baseMesh + (baseMesh + ((3,), (0,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 3.5 4.5 3.5 4.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5]]
>>> addedMesh = baseMesh + (baseMesh + ((2,), (2,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 2.5 3.5 2.5 3.5] [ 0.5 0.5 1.5 1.5 2.5 2.5 3.5 3.5]]
No provision is made to avoid or consolidate overlapping Mesh objects
>>> addedMesh = baseMesh + (baseMesh + ((1,), (0,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 1.5 2.5 1.5 2.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5]]
Different Mesh classes can be concatenated
>>> from fipy.meshes import Tri2D >>> triMesh = Tri2D(dx = 1.0, dy = 1.0, nx = 2, ny = 1) >>> triMesh = triMesh + ((2,), (0,)) >>> triAddedMesh = baseMesh + triMesh >>> cellCenters = [[0.5, 1.5, 0.5, 1.5, 2.83333333, 3.83333333, ... 2.5, 3.5, 2.16666667, 3.16666667, 2.5, 3.5], ... [0.5, 0.5, 1.5, 1.5, 0.5, 0.5, 0.83333333, 0.83333333, ... 0.5, 0.5, 0.16666667, 0.16666667]] >>> print(numerix.allclose(triAddedMesh.cellCenters, ... cellCenters)) True
again, their faces need not align, but the mesh may not have the desired connectivity
>>> triMesh = Tri2D(dx = 1.0, dy = 2.0, nx = 2, ny = 1) >>> triMesh = triMesh + ((2,), (0,)) >>> triAddedMesh = baseMesh + triMesh >>> cellCenters = [[ 0.5, 1.5, 0.5, 1.5, 2.83333333, 3.83333333, ... 2.5, 3.5, 2.16666667, 3.16666667, 2.5, 3.5], ... [ 0.5, 0.5, 1.5, 1.5, 1., 1., ... 1.66666667, 1.66666667, 1., 1., 0.33333333, 0.33333333]] >>> print(numerix.allclose(triAddedMesh.cellCenters, ... cellCenters)) True
Mesh concatenation is not limited to 2D meshes
>>> from fipy.meshes import Grid3D >>> threeDBaseMesh = Grid3D(dx = 1.0, dy = 1.0, dz = 1.0, ... nx = 2, ny = 2, nz = 2) >>> threeDSecondMesh = Grid3D(dx = 1.0, dy = 1.0, dz = 1.0, ... nx = 1, ny = 1, nz = 1) >>> threeDAddedMesh = threeDBaseMesh + (threeDSecondMesh + ((2,), (0,), (0,))) >>> print(threeDAddedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 0.5 1.5 0.5 1.5 2.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5 0.5] [ 0.5 0.5 0.5 0.5 1.5 1.5 1.5 1.5 0.5]]
but the different Mesh objects must, of course, have the same dimensionality.
>>> InvalidMesh = threeDBaseMesh + baseMesh Traceback (most recent call last): ... MeshAdditionError: Dimensions do not match
- __repr__()¶
Return repr(self).
- __rmul__(factor)¶
Dilate a Mesh by factor.
>>> from fipy.meshes import Grid2D >>> baseMesh = Grid2D(dx = 1.0, dy = 1.0, nx = 2, ny = 2) >>> print(baseMesh.cellCenters) [[ 0.5 1.5 0.5 1.5] [ 0.5 0.5 1.5 1.5]]
The factor can be a scalar
>>> dilatedMesh = baseMesh * 3 >>> print(dilatedMesh.cellCenters) [[ 1.5 4.5 1.5 4.5] [ 1.5 1.5 4.5 4.5]]
or a vector
>>> dilatedMesh = baseMesh * ((3,), (2,)) >>> print(dilatedMesh.cellCenters) [[ 1.5 4.5 1.5 4.5] [ 1. 1. 3. 3. ]]
but the vector must have the same dimensionality as the Mesh
>>> dilatedMesh = baseMesh * ((3,), (2,), (1,)) Traceback (most recent call last): ... ValueError: shape mismatch: objects cannot be broadcast to a single shape
- __setstate__(state)¶
- __sub__(other)¶
Tests. >>> from fipy import * >>> m = Grid1D() >>> print((m - ((1,))).cellCenters) [[-0.5]] >>> ((1,)) - m Traceback (most recent call last): … TypeError: unsupported operand type(s) for -: ‘tuple’ and ‘UniformGrid1D’
- __truediv__(other)¶
Tests. >>> from fipy import * >>> print((Grid1D(nx=1) / 2.).cellCenters) [[ 0.25]] >>> AbstractMesh(communicator=None) / 2. Traceback (most recent call last): … NotImplementedError
- property aspect2D¶
The physical y vs x aspect ratio of a 2D mesh
- property cellCenters¶
- property cellDistanceVectors¶
- property cellFaceIDs¶
- property cellToFaceDistanceVectors¶
- property cellVolumes¶
- property extents¶
- property exteriorFaces¶
- property faceCenters¶
- property facesBack¶
Return list of faces on back boundary of 3D Mesh with the z-axis running from front to back.
>>> from fipy import Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((6, 7, 8, 9, 10, 11), ... numerix.nonzero(mesh.facesBack)[0])) True >>> ignore = mesh.facesBack.value
- property facesBottom¶
Return list of faces on bottom boundary of 2D or 3D Mesh with the y-axis running from bottom to top.
>>> from fipy import Grid2D, Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((12, 13, 14), ... numerix.nonzero(mesh.facesBottom)[0])) True >>> ignore = mesh.facesBottom.value >>> x, y, z = mesh.faceCenters >>> print(numerix.allequal((12, 13), ... numerix.nonzero(mesh.facesBottom & (x < 1))[0])) True >>> ignore = mesh.facesBottom.value
- property facesDown¶
Return list of faces on bottom boundary of 2D or 3D Mesh with the y-axis running from bottom to top.
>>> from fipy import Grid2D, Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((12, 13, 14), ... numerix.nonzero(mesh.facesBottom)[0])) True >>> ignore = mesh.facesBottom.value >>> x, y, z = mesh.faceCenters >>> print(numerix.allequal((12, 13), ... numerix.nonzero(mesh.facesBottom & (x < 1))[0])) True >>> ignore = mesh.facesBottom.value
- property facesFront¶
Return list of faces on front boundary of 3D Mesh with the z-axis running from front to back.
>>> from fipy import Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((0, 1, 2, 3, 4, 5), ... numerix.nonzero(mesh.facesFront)[0])) True >>> ignore = mesh.facesFront.value
- property facesLeft¶
Return face on left boundary of Mesh as list with the x-axis running from left to right.
>>> from fipy import Grid2D, Grid3D >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((21, 25), ... numerix.nonzero(mesh.facesLeft)[0])) True >>> ignore = mesh.facesLeft.value >>> mesh = Grid2D(nx = 3, ny = 2, dx = 0.5, dy = 2.) >>> print(numerix.allequal((9, 13), ... numerix.nonzero(mesh.facesLeft)[0])) True >>> ignore = mesh.facesLeft.value
- property facesRight¶
Return list of faces on right boundary of Mesh with the x-axis running from left to right.
>>> from fipy import Grid2D, Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((24, 28), ... numerix.nonzero(mesh.facesRight)[0])) True >>> ignore = mesh.facesRight.value >>> mesh = Grid2D(nx = 3, ny = 2, dx = 0.5, dy = 2.) >>> print(numerix.allequal((12, 16), ... numerix.nonzero(mesh.facesRight)[0])) True >>> ignore = mesh.facesRight.value
- property facesTop¶
Return list of faces on top boundary of 2D or 3D Mesh with the y-axis running from bottom to top.
>>> from fipy import Grid2D, Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((18, 19, 20), ... numerix.nonzero(mesh.facesTop)[0])) True >>> ignore = mesh.facesTop.value >>> mesh = Grid2D(nx = 3, ny = 2, dx = 0.5, dy = 2.) >>> print(numerix.allequal((6, 7, 8), ... numerix.nonzero(mesh.facesTop)[0])) True >>> ignore = mesh.facesTop.value
- property facesUp¶
Return list of faces on top boundary of 2D or 3D Mesh with the y-axis running from bottom to top.
>>> from fipy import Grid2D, Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((18, 19, 20), ... numerix.nonzero(mesh.facesTop)[0])) True >>> ignore = mesh.facesTop.value >>> mesh = Grid2D(nx = 3, ny = 2, dx = 0.5, dy = 2.) >>> print(numerix.allequal((6, 7, 8), ... numerix.nonzero(mesh.facesTop)[0])) True >>> ignore = mesh.facesTop.value
- getNearestCell(point)¶
- property interiorFaceCellIDs¶
- property interiorFaceIDs¶
- property interiorFaces¶
- property scale¶
- property scaledCellDistances¶
- property scaledCellToCellDistances¶
- property scaledCellVolumes¶
- property scaledFaceAreas¶
- property scaledFaceToCellDistances¶
- property x¶
Equivalent to using
cellCenters
[0]
.>>> from fipy import * >>> print(Grid1D(nx=2).x) [ 0.5 1.5]
- property y¶
Equivalent to using
cellCenters
[1]
.>>> from fipy import * >>> print(Grid2D(nx=2, ny=2).y) [ 0.5 0.5 1.5 1.5] >>> print(Grid1D(nx=2).y) Traceback (most recent call last): ... AttributeError: 1D meshes do not have a "y" attribute.
- property z¶
Equivalent to using
cellCenters
[2]
.>>> from fipy import * >>> print(Grid3D(nx=2, ny=2, nz=2).z) [ 0.5 0.5 0.5 0.5 1.5 1.5 1.5 1.5] >>> print(Grid2D(nx=2, ny=2).z) Traceback (most recent call last): ... AttributeError: 1D and 2D meshes do not have a "z" attribute.
- class fipy.PhysicalField(value, unit=None, array=None)¶
Bases:
object
Physical field or quantity with units
Physical Fields can be constructed in one of two ways:
PhysicalField(*value*, *unit*), where *value* is a number of arbitrary type and *unit* is a string containing the unit name
>>> print(PhysicalField(value = 10., unit = 'm')) 10.0 m
PhysicalField(*string*), where *string* contains both the value and the unit. This form is provided to make interactive use more convenient
>>> print(PhysicalField(value = "10. m")) 10.0 m
Dimensionless quantities, with a unit of 1, can be specified in several ways
>>> print(PhysicalField(value = "1")) 1.0 1 >>> print(PhysicalField(value = 2., unit = " ")) 2.0 1 >>> print(PhysicalField(value = 2.)) 2.0 1
Physical arrays are also possible (and are the reason this code was adapted from Konrad Hinsen’s original PhysicalQuantity). The value can be a Numeric array:
>>> a = numerix.array(((3., 4.), (5., 6.))) >>> print(PhysicalField(value = a, unit = "m")) [[ 3. 4.] [ 5. 6.]] m
or a tuple:
>>> print(PhysicalField(value = ((3., 4.), (5., 6.)), unit = "m")) [[ 3. 4.] [ 5. 6.]] m
or as a single value to be applied to every element of a supplied array:
>>> print(PhysicalField(value = 2., unit = "m", array = a)) [[ 2. 2.] [ 2. 2.]] m
Every element in an array has the same unit, which is stored only once for the whole array.
- __abs__()¶
Return the absolute value of the quantity. The unit is unchanged.
>>> print(abs(PhysicalField(((3., -2.), (-1., 4.)), 'm'))) [[ 3. 2.] [ 1. 4.]] m
- __add__(other)¶
Add two physical quantities, so long as their units are compatible. The unit of the result is the unit of the first operand.
>>> print(PhysicalField(10., 'km') + PhysicalField(10., 'm')) 10.01 km >>> print(PhysicalField(10., 'km') + PhysicalField(10., 'J')) Traceback (most recent call last): ... TypeError: Incompatible units
- __array__(t=None)¶
Return a dimensionless PhysicalField as a Numeric
array
.>>> print(numerix.array(PhysicalField(((2., 3.), (4., 5.)), "m/m"))) [[ 2. 3.] [ 4. 5.]]
As a special case, fields with angular units are converted to base units (radians) and then assumed dimensionless.
>>> print(numerix.array(PhysicalField(((2., 3.), (4., 5.)), "deg"))) [[ 0.03490659 0.05235988] [ 0.06981317 0.08726646]]
If the array is not dimensionless, the numerical value in its base units is returned.
>>> numerix.array(PhysicalField(((2., 3.), (4., 5.)), "mm")) array([[ 0.002, 0.003], [ 0.004, 0.005]])
- __array_priority__ = 100.0¶
- __array_wrap__(arr, context=None)¶
Required to prevent numpy not calling the reverse binary operations. Both the following tests are examples ufuncs.
>>> from fipy.tools.dimensions.physicalField import PhysicalField >>> print(type(numerix.array([1.0, 2.0]) * PhysicalField([1.0, 2.0], unit="m"))) <class 'fipy.tools.dimensions.physicalField.PhysicalField'>
>>> print(type(numerix.array([1.0, 2.0]) * PhysicalField([1.0, 2.0]))) <class 'fipy.tools.dimensions.physicalField.PhysicalField'>
>>> from scipy.special import gamma as Gamma >>> print(isinstance(Gamma(PhysicalField([1.0, 2.0])), type(numerix.array(1)))) 1
- __bool__()¶
Test if the quantity is zero.
Should this only pass if the unit offset is zero?
- __div__(other)¶
Divide two physical quantities. The unit of the result is the unit of the first operand divided by the unit of the second.
>>> print(PhysicalField(10., 'm') / PhysicalField(2., 's')) 5.0 m/s
As a special case, if the result is dimensionless, the value is returned without units, rather than with a dimensionless unit of 1. This facilitates passing physical quantities to packages such as Numeric that cannot use units, while ensuring the quantities have the desired units
>>> print((PhysicalField(1., 'inch') ... / PhysicalField(1., 'mm'))) 25.4
- __eq__(other)¶
Return self==value.
- __float__()¶
Return a dimensionless PhysicalField quantity as a float.
>>> float(PhysicalField("2. m/m")) 2.0
As a special case, quantities with angular units are converted to base units (radians) and then assumed dimensionless.
>>> print(numerix.round(float(PhysicalField("2. deg")), 6)) 0.034907
If the quantity is not dimensionless, the conversion fails.
>>> float(PhysicalField("2. m")) Traceback (most recent call last): ... TypeError: Not possible to convert a PhysicalField with dimensions to float
Just as a Numeric array cannot be cast to float, neither can PhysicalField arrays
>>> float(PhysicalField(((2., 3.), (4., 5.)), "m/m")) Traceback (most recent call last): ... TypeError: only ...-1 arrays can be converted to Python scalars
- __ge__(other)¶
Return self>=value.
- __getitem__(index)¶
Return the specified element of the array. The unit of the result will be the unit of the array.
>>> a = PhysicalField(((3., 4.), (5., 6.)), "m") >>> print(a[1, 1]) 6.0 m
- __gt__(other)¶
Compare self to other, returning an array of Boolean values corresponding to the test against each element.
>>> a = PhysicalField(((3., 4.), (5., 6.)), "m") >>> print(numerix.allclose(a > PhysicalField("13 ft"), ... [[False, True], [ True, True]])) True
Appropriately formatted dimensional quantity strings can also be compared.
>>> print(numerix.allclose(a > "13 ft", ... [[False, True], [ True, True]])) True
Arrays are compared element to element
>>> print(numerix.allclose(a > PhysicalField(((3., 13.), (17., 6.)), "ft"), ... [[ True, True], [False, True]])) True
Units must be compatible
>>> print(a > PhysicalField("1 lb")) Traceback (most recent call last): ... TypeError: Incompatible units
And so must array dimensions
>>> print(a > PhysicalField(((3., 13., 4.), (17., 6., 2.)), "ft")) Traceback (most recent call last): ... ValueError: shape mismatch: objects cannot be broadcast to a single shape
- __hash__()¶
Return hash(self).
- __le__(other)¶
Return self<=value.
- __len__()¶
- __lt__(other)¶
Return self<value.
- __mod__(other)¶
Return the remainder of dividing two physical quantities. The unit of the result is the unit of the first operand divided by the unit of the second.
>>> print(PhysicalField(11., 'm') % PhysicalField(2., 's')) 1.0 m/s
- __mul__(other)¶
Multiply two physical quantities. The unit of the result is the product of the units of the operands.
>>> print(PhysicalField(10., 'N') * PhysicalField(10., 'm') == PhysicalField(100., 'N*m')) True
As a special case, if the result is dimensionless, the value is returned without units, rather than with a dimensionless unit of 1. This facilitates passing physical quantities to packages such as Numeric that cannot use units, while ensuring the quantities have the desired units.
>>> print((PhysicalField(10., 's') * PhysicalField(2., 'Hz'))) 20.0
- __ne__(other)¶
Return self!=value.
- __neg__()¶
Return the negative of the quantity. The unit is unchanged.
>>> print(-PhysicalField(((3., -2.), (-1., 4.)), 'm')) [[-3. 2.] [ 1. -4.]] m
- __nonzero__()¶
Test if the quantity is zero.
Should this only pass if the unit offset is zero?
- __pos__()¶
- __pow__(other)¶
Raise a PhysicalField to a power. The unit is raised to the same power.
>>> print(PhysicalField(10., 'm')**2) 100.0 m**2
- __radd__(other)¶
Add two physical quantities, so long as their units are compatible. The unit of the result is the unit of the first operand.
>>> print(PhysicalField(10., 'km') + PhysicalField(10., 'm')) 10.01 km >>> print(PhysicalField(10., 'km') + PhysicalField(10., 'J')) Traceback (most recent call last): ... TypeError: Incompatible units
- __rdiv__(other)¶
- __repr__()¶
Return representation of a physical quantity suitable for re-use
>>> PhysicalField(value = 3., unit = "eV") PhysicalField(3.0,'eV')
- __rmul__(other)¶
Multiply two physical quantities. The unit of the result is the product of the units of the operands.
>>> print(PhysicalField(10., 'N') * PhysicalField(10., 'm') == PhysicalField(100., 'N*m')) True
As a special case, if the result is dimensionless, the value is returned without units, rather than with a dimensionless unit of 1. This facilitates passing physical quantities to packages such as Numeric that cannot use units, while ensuring the quantities have the desired units.
>>> print((PhysicalField(10., 's') * PhysicalField(2., 'Hz'))) 20.0
- __rpow__(other)¶
- __rsub__(other)¶
- __rtruediv__(other)¶
- __setitem__(index, value)¶
Assign the specified element of the array, performing appropriate conversions.
>>> a = PhysicalField(((3., 4.), (5., 6.)), "m") >>> a[0, 1] = PhysicalField("6 ft") >>> print(a) [[ 3. 1.8288] [ 5. 6. ]] m >>> a[1, 0] = PhysicalField("2 min") Traceback (most recent call last): ... TypeError: Incompatible units
- __str__()¶
Return human-readable form of a physical quantity
>>> print(PhysicalField(value = 3., unit = "eV")) 3.0 eV
- __sub__(other)¶
Subtract two physical quantities, so long as their units are compatible. The unit of the result is the unit of the first operand.
>>> print(PhysicalField(10., 'km') - PhysicalField(10., 'm')) 9.99 km >>> print(PhysicalField(10., 'km') - PhysicalField(10., 'J')) Traceback (most recent call last): ... TypeError: Incompatible units
- __truediv__(other)¶
Divide two physical quantities. The unit of the result is the unit of the first operand divided by the unit of the second.
>>> print(PhysicalField(10., 'm') / PhysicalField(2., 's')) 5.0 m/s
As a special case, if the result is dimensionless, the value is returned without units, rather than with a dimensionless unit of 1. This facilitates passing physical quantities to packages such as Numeric that cannot use units, while ensuring the quantities have the desired units
>>> print((PhysicalField(1., 'inch') ... / PhysicalField(1., 'mm'))) 25.4
- add(other)¶
Add two physical quantities, so long as their units are compatible. The unit of the result is the unit of the first operand.
>>> print(PhysicalField(10., 'km') + PhysicalField(10., 'm')) 10.01 km >>> print(PhysicalField(10., 'km') + PhysicalField(10., 'J')) Traceback (most recent call last): ... TypeError: Incompatible units
- allclose(other, atol=None, rtol=1e-08)¶
This function tests whether or not self and other are equal subject to the given relative and absolute tolerances. The formula used is:
| self - other | < atol + rtol * | other |
This means essentially that both elements are small compared to atol or their difference divided by other’s value is small compared to rtol.
- allequal(other)¶
This function tests whether or not self and other are exactly equal.
- arccos()¶
Return the inverse cosine of the PhysicalField in radians
>>> print(PhysicalField(0).arccos().allclose("1.57079632679 rad")) 1
The input PhysicalField must be dimensionless
>>> print(numerix.round(PhysicalField("1 m").arccos(), 6)) Traceback (most recent call last): ... TypeError: Incompatible units
- arccosh()¶
Return the inverse hyperbolic cosine of the PhysicalField
>>> print(numerix.allclose(PhysicalField(2).arccosh(), ... 1.31695789692)) 1
The input PhysicalField must be dimensionless
>>> print(numerix.round(PhysicalField("1. m").arccosh(), 6)) Traceback (most recent call last): ... TypeError: Incompatible units
- arcsin()¶
Return the inverse sine of the PhysicalField in radians
>>> print(PhysicalField(1).arcsin().allclose("1.57079632679 rad")) 1
The input PhysicalField must be dimensionless
>>> print(numerix.round(PhysicalField("1 m").arcsin(), 6)) Traceback (most recent call last): ... TypeError: Incompatible units
- arctan()¶
Return the arctangent of the PhysicalField in radians
>>> print(numerix.round(PhysicalField(1).arctan(), 6)) 0.785398
The input PhysicalField must be dimensionless
>>> print(numerix.round(PhysicalField("1 m").arctan(), 6)) Traceback (most recent call last): ... TypeError: Incompatible units
- arctan2(other)¶
Return the arctangent of self divided by other in radians
>>> print(numerix.round(PhysicalField(2.).arctan2(PhysicalField(5.)), 6)) 0.380506
The input PhysicalField objects must be in the same dimensions
>>> print(numerix.round(PhysicalField(2.54, "cm").arctan2(PhysicalField(1., "inch")), 6)) 0.785398
>>> print(numerix.round(PhysicalField(2.).arctan2(PhysicalField("5. m")), 6)) Traceback (most recent call last): ... TypeError: Incompatible units
- arctanh()¶
Return the inverse hyperbolic tangent of the PhysicalField
>>> print(PhysicalField(0.5).arctanh()) 0.549306144334
The input PhysicalField must be dimensionless
>>> print(numerix.round(PhysicalField("1 m").arctanh(), 6)) Traceback (most recent call last): ... TypeError: Incompatible units
- ceil()¶
Return the smallest integer greater than or equal to the PhysicalField.
>>> print(PhysicalField(2.2, "m").ceil()) 3.0 m
- conjugate()¶
Return the complex conjugate of the PhysicalField.
>>> print(PhysicalField(2.2 - 3j, "ohm").conjugate() == PhysicalField(2.2 + 3j, "ohm")) True
- convertToUnit(unit)¶
Changes the unit to unit and adjusts the value such that the combination is equivalent. The new unit is by a string containing its name. The new unit must be compatible with the previous unit of the object.
>>> e = PhysicalField('2.7 Hartree*Nav') >>> e.convertToUnit('kcal/mol') >>> print(e) 1694.27557621 kcal/mol
- copy()¶
Make a duplicate.
>>> a = PhysicalField(1, unit = 'inch') >>> b = a.copy()
The duplicate will not reflect changes made to the original
>>> a.convertToUnit('cm') >>> print(a) 2.54 cm >>> print(b) 1 inch
Likewise for arrays
>>> a = PhysicalField(numerix.array((0, 1, 2)), unit = 'm') >>> b = a.copy() >>> a[0] = 3 >>> print(a) [3 1 2] m >>> print(b) [0 1 2] m
- cos()¶
Return the cosine of the PhysicalField
>>> print(numerix.round(PhysicalField(2*numerix.pi/6, "rad").cos(), 6)) 0.5 >>> print(numerix.round(PhysicalField(60., "deg").cos(), 6)) 0.5
The units of the PhysicalField must be an angle
>>> PhysicalField(60., "m").cos() Traceback (most recent call last): ... TypeError: Incompatible units
- cosh()¶
Return the hyperbolic cosine of the PhysicalField
>>> PhysicalField(0.).cosh() 1.0
The units of the PhysicalField must be dimensionless
>>> PhysicalField(60., "m").cosh() Traceback (most recent call last): ... TypeError: Incompatible units
- divide(other)¶
Divide two physical quantities. The unit of the result is the unit of the first operand divided by the unit of the second.
>>> print(PhysicalField(10., 'm') / PhysicalField(2., 's')) 5.0 m/s
As a special case, if the result is dimensionless, the value is returned without units, rather than with a dimensionless unit of 1. This facilitates passing physical quantities to packages such as Numeric that cannot use units, while ensuring the quantities have the desired units
>>> print((PhysicalField(1., 'inch') ... / PhysicalField(1., 'mm'))) 25.4
- dot(other)¶
Return the dot product of self with other. The resulting unit is the product of the units of self and other.
>>> v = PhysicalField(((5., 6.), (7., 8.)), "m") >>> print(PhysicalField(((1., 2.), (3., 4.)), "m").dot(v)) [ 26. 44.] m**2
- floor()¶
Return the largest integer less than or equal to the PhysicalField.
>>> print(PhysicalField(2.2, "m").floor()) 2.0 m
- getsctype(default=None)¶
Returns the NumPy sctype of the underlying array.
>>> PhysicalField(1, 'm').getsctype() == numerix.NUMERIX.obj2sctype(numerix.array(1)) True >>> PhysicalField(1., 'm').getsctype() == numerix.NUMERIX.obj2sctype(numerix.array(1.)) True >>> PhysicalField((1, 1.), 'm').getsctype() == numerix.NUMERIX.obj2sctype(numerix.array((1., 1.))) True
- inBaseUnits()¶
Return the quantity with all units reduced to their base SI elements.
>>> e = PhysicalField('2.7 Hartree*Nav') >>> print(e.inBaseUnits().allclose("7088849.01085 kg*m**2/s**2/mol")) 1
- inDimensionless()¶
Returns the numerical value of a dimensionless quantity.
>>> print(PhysicalField(((2., 3.), (4., 5.))).inDimensionless()) [[ 2. 3.] [ 4. 5.]]
It’s an error to convert a quantity with units
>>> print(PhysicalField(((2., 3.), (4., 5.)), "m").inDimensionless()) Traceback (most recent call last): ... TypeError: Incompatible units
- inRadians()¶
Converts an angular quantity to radians and returns the numerical value.
>>> print(PhysicalField(((2., 3.), (4., 5.)), "rad").inRadians()) [[ 2. 3.] [ 4. 5.]] >>> print(PhysicalField(((2., 3.), (4., 5.)), "deg").inRadians()) [[ 0.03490659 0.05235988] [ 0.06981317 0.08726646]]
As a special case, assumes a dimensionless quantity is already in radians.
>>> print(PhysicalField(((2., 3.), (4., 5.))).inRadians()) [[ 2. 3.] [ 4. 5.]]
It’s an error to convert a quantity with non-angular units
>>> print(PhysicalField(((2., 3.), (4., 5.)), "m").inRadians()) Traceback (most recent call last): ... TypeError: Incompatible units
- inSIUnits()¶
Return the quantity with all units reduced to SI-compatible elements.
>>> e = PhysicalField('2.7 Hartree*Nav') >>> print(e.inSIUnits().allclose("7088849.01085 kg*m**2/s**2/mol")) 1
- inUnitsOf(*units)¶
Returns one or more PhysicalField objects that express the same physical quantity in different units. The units are specified by strings containing their names. The units must be compatible with the unit of the object. If one unit is specified, the return value is a single PhysicalField.
>>> freeze = PhysicalField('0 degC') >>> print(freeze.inUnitsOf('degF').allclose("32.0 degF")) 1
If several units are specified, the return value is a tuple of PhysicalField instances with with one element per unit such that the sum of all quantities in the tuple equals the the original quantity and all the values except for the last one are integers. This is used to convert to irregular unit systems like hour/minute/second. The original object will not be changed.
>>> t = PhysicalField(314159., 's') >>> from builtins import zip >>> print(numerix.allclose([e.allclose(v) for (e, v) in zip(t.inUnitsOf('d', 'h', 'min', 's'), ... ['3.0 d', '15.0 h', '15.0 min', '59.0 s'])], ... True)) 1
- isCompatible(unit)¶
- itemset(value)¶
Assign the value of a scalar array, performing appropriate conversions.
>>> a = PhysicalField(4., "m") >>> a.itemset(PhysicalField("6 ft")) >>> print(a.allclose("1.8288 m")) 1 >>> a = PhysicalField(((3., 4.), (5., 6.)), "m") >>> try: ... a.itemset(PhysicalField("6 ft")) ... except IndexError: ... # NumPy 1.7 has changed the exception type ... raise ValueError("can only place a scalar for an array of size 1") Traceback (most recent call last): ... ValueError: can only convert an array of size 1 to a Python scalar >>> a.itemset(PhysicalField("2 min")) Traceback (most recent call last): ... TypeError: Incompatible units
- property itemsize¶
- log()¶
Return the natural logarithm of the PhysicalField
>>> print(numerix.round(PhysicalField(10).log(), 6)) 2.302585
The input PhysicalField must be dimensionless
>>> print(numerix.round(PhysicalField("1. m").log(), 6)) Traceback (most recent call last): ... TypeError: Incompatible units
- log10()¶
Return the base-10 logarithm of the PhysicalField
>>> print(numerix.round(PhysicalField(10.).log10(), 6)) 1.0
The input PhysicalField must be dimensionless
>>> print(numerix.round(PhysicalField("1. m").log10(), 6)) Traceback (most recent call last): ... TypeError: Incompatible units
- multiply(other)¶
Multiply two physical quantities. The unit of the result is the product of the units of the operands.
>>> print(PhysicalField(10., 'N') * PhysicalField(10., 'm') == PhysicalField(100., 'N*m')) True
As a special case, if the result is dimensionless, the value is returned without units, rather than with a dimensionless unit of 1. This facilitates passing physical quantities to packages such as Numeric that cannot use units, while ensuring the quantities have the desired units.
>>> print((PhysicalField(10., 's') * PhysicalField(2., 'Hz'))) 20.0
- property numericValue¶
Return the PhysicalField without units, after conversion to base SI units.
>>> print(numerix.round(PhysicalField("1 inch").numericValue, 6)) 0.0254
- put(indices, values)¶
put is the opposite of take. The values of self at the locations specified in indices are set to the corresponding value of values.
The indices can be any integer sequence object with values suitable for indexing into the flat form of self. The values must be any sequence of values that can be converted to the typecode of self.
>>> f = PhysicalField((1., 2., 3.), "m") >>> f.put((2, 0), PhysicalField((2., 3.), "inch")) >>> print(f) [ 0.0762 2. 0.0508] m
The units of values must be compatible with self.
>>> f.put(1, PhysicalField(3, "kg")) Traceback (most recent call last): ... TypeError: Incompatible units
- ravel()¶
- reshape(shape)¶
Changes the shape of self to that specified in shape
>>> print(PhysicalField((1., 2., 3., 4.), "m").reshape((2, 2))) [[ 1. 2.] [ 3. 4.]] m
The new shape must have the same size as the existing one.
>>> print(PhysicalField((1., 2., 3., 4.), "m").reshape((2, 3))) Traceback (most recent call last): ... ValueError: total size of new array must be unchanged
- property shape¶
Tuple of array dimensions.
- sign()¶
Return the sign of the quantity. The unit is unchanged.
>>> from fipy.tools.numerix import sign >>> print(sign(PhysicalField(((3., -2.), (-1., 4.)), 'm'))) [[ 1. -1.] [-1. 1.]]
- sin()¶
Return the sine of the PhysicalField
>>> print(PhysicalField(numerix.pi/6, "rad").sin()) 0.5 >>> print(PhysicalField(30., "deg").sin()) 0.5
The units of the PhysicalField must be an angle
>>> PhysicalField(30., "m").sin() Traceback (most recent call last): ... TypeError: Incompatible units
- sinh()¶
Return the hyperbolic sine of the PhysicalField
>>> PhysicalField(0.).sinh() 0.0
The units of the PhysicalField must be dimensionless
>>> PhysicalField(60., "m").sinh() Traceback (most recent call last): ... TypeError: Incompatible units
- sqrt()¶
Return the square root of the PhysicalField
>>> print(PhysicalField("100. m**2").sqrt()) 10.0 m
The resulting unit must be integral
>>> print(PhysicalField("100. m").sqrt()) Traceback (most recent call last): ... TypeError: Illegal exponent
- subtract(other)¶
Subtract two physical quantities, so long as their units are compatible. The unit of the result is the unit of the first operand.
>>> print(PhysicalField(10., 'km') - PhysicalField(10., 'm')) 9.99 km >>> print(PhysicalField(10., 'km') - PhysicalField(10., 'J')) Traceback (most recent call last): ... TypeError: Incompatible units
- sum(index=0)¶
Returns the sum of all of the elements in self along the specified axis (first axis by default).
>>> print(PhysicalField(((1., 2.), (3., 4.)), "m").sum()) [ 4. 6.] m >>> print(PhysicalField(((1., 2.), (3., 4.)), "m").sum(1)) [ 3. 7.] m
- take(indices, axis=0)¶
Return the elements of self specified by the elements of indices. The resulting PhysicalField array has the same units as the original.
>>> print(PhysicalField((1., 2., 3.), "m").take((2, 0))) [ 3. 1.] m
The optional third argument specifies the axis along which the selection occurs, and the default value (as in the example above) is 0, the first axis.
>>> print(PhysicalField(((1., 2., 3.), (4., 5., 6.)), "m").take((2, 0), axis = 1)) [[ 3. 1.] [ 6. 4.]] m
- tan()¶
Return the tangent of the PhysicalField
>>> numerix.round(PhysicalField(numerix.pi/4, "rad").tan(), 6) 1.0 >>> numerix.round(PhysicalField(45, "deg").tan(), 6) 1.0
The units of the PhysicalField must be an angle
>>> PhysicalField(45., "m").tan() Traceback (most recent call last): ... TypeError: Incompatible units
- tanh()¶
Return the hyperbolic tangent of the PhysicalField
>>> print(numerix.allclose(PhysicalField(1.).tanh(), 0.761594155956)) True
The units of the PhysicalField must be dimensionless
>>> PhysicalField(60., "m").tanh() Traceback (most recent call last): ... TypeError: Incompatible units
- tostring(max_line_width=75, precision=8, suppress_small=False, separator=' ')¶
Return human-readable form of a physical quantity
>>> p = PhysicalField(value = (3., 3.14159), unit = "eV") >>> print(p.tostring(precision = 3, separator = '|')) [ 3. | 3.142] eV
- property unit¶
Return the unit object of self.
>>> PhysicalField("1 m").unit <PhysicalUnit m>
- class fipy.PowerLawConvectionTerm(coeff=1.0, var=None)¶
Bases:
_AsymmetricConvectionTerm
The discretization for this
Term
is given bywhere
and
is calculated using the power law scheme. For further details see Numerical Schemes.
Create a _AbstractConvectionTerm object.
>>> from fipy import * >>> m = Grid1D(nx = 2) >>> cv = CellVariable(mesh = m) >>> fv = FaceVariable(mesh = m) >>> vcv = CellVariable(mesh=m, rank=1) >>> vfv = FaceVariable(mesh=m, rank=1) >>> __ConvectionTerm(coeff = cv) Traceback (most recent call last): ... VectorCoeffError: The coefficient must be a vector value. >>> __ConvectionTerm(coeff = fv) Traceback (most recent call last): ... VectorCoeffError: The coefficient must be a vector value. >>> __ConvectionTerm(coeff = vcv) __ConvectionTerm(coeff=_ArithmeticCellToFaceVariable(value=array([[ 0., 0., 0.]]), mesh=UniformGrid1D(dx=1.0, nx=2))) >>> __ConvectionTerm(coeff = vfv) __ConvectionTerm(coeff=FaceVariable(value=array([[ 0., 0., 0.]]), mesh=UniformGrid1D(dx=1.0, nx=2))) >>> __ConvectionTerm(coeff = (1,)) __ConvectionTerm(coeff=(1,)) >>> ExplicitUpwindConvectionTerm(coeff = (0,)).solve(var=cv, solver=DummySolver()) Traceback (most recent call last): ... TransientTermError: The equation requires a TransientTerm with explicit convection. >>> (TransientTerm(0.) - ExplicitUpwindConvectionTerm(coeff = (0,))).solve(var=cv, solver=DummySolver(), dt=1.)
>>> (TransientTerm() - ExplicitUpwindConvectionTerm(coeff = 1)).solve(var=cv, solver=DummySolver(), dt=1.) Traceback (most recent call last): ... VectorCoeffError: The coefficient must be a vector value. >>> m2 = Grid2D(nx=2, ny=1) >>> cv2 = CellVariable(mesh=m2) >>> vcv2 = CellVariable(mesh=m2, rank=1) >>> vfv2 = FaceVariable(mesh=m2, rank=1) >>> __ConvectionTerm(coeff=vcv2) __ConvectionTerm(coeff=_ArithmeticCellToFaceVariable(value=array([[ 0., 0., 0., 0., 0., 0., 0.], [ 0., 0., 0., 0., 0., 0., 0.]]), mesh=UniformGrid2D(dx=1.0, nx=2, dy=1.0, ny=1))) >>> __ConvectionTerm(coeff=vfv2) __ConvectionTerm(coeff=FaceVariable(value=array([[ 0., 0., 0., 0., 0., 0., 0.], [ 0., 0., 0., 0., 0., 0., 0.]]), mesh=UniformGrid2D(dx=1.0, nx=2, dy=1.0, ny=1))) >>> (TransientTerm() - ExplicitUpwindConvectionTerm(coeff = ((0,), (0,)))).solve(var=cv2, solver=DummySolver(), dt=1.) >>> (TransientTerm() - ExplicitUpwindConvectionTerm(coeff = (0, 0))).solve(var=cv2, solver=DummySolver(), dt=1.)
- Parameters:
coeff (The Term’s coefficient value.) –
- property RHSvector¶
Return the RHS vector calculated in solve() or sweep(). The cacheRHSvector() method should be called before solve() or sweep() to cache the vector.
- __add__(other)¶
- __and__(other)¶
- __div__(other)¶
- __eq__(other)¶
Return self==value.
- __hash__()¶
Return hash(self).
- __mul__(other)¶
Multiply a term
>>> 2. * __NonDiffusionTerm(coeff=0.5) __NonDiffusionTerm(coeff=1.0)
Test for ticket:291.
>>> from fipy import PowerLawConvectionTerm >>> PowerLawConvectionTerm(coeff=[[1], [0]]) * 1.0 PowerLawConvectionTerm(coeff=array([[ 1.], [ 0.]]))
- __neg__()¶
Negate a Term.
>>> -__NonDiffusionTerm(coeff=1.) __NonDiffusionTerm(coeff=-1.0)
- __pos__()¶
- __radd__(other)¶
- __rand__(other)¶
- __repr__()¶
The representation of a Term object is given by,
>>> print(__UnaryTerm(123.456)) __UnaryTerm(coeff=123.456)
- __rmul__(other)¶
Multiply a term
>>> 2. * __NonDiffusionTerm(coeff=0.5) __NonDiffusionTerm(coeff=1.0)
Test for ticket:291.
>>> from fipy import PowerLawConvectionTerm >>> PowerLawConvectionTerm(coeff=[[1], [0]]) * 1.0 PowerLawConvectionTerm(coeff=array([[ 1.], [ 0.]]))
- __rsub__(other)¶
- __sub__(other)¶
- __truediv__(other)¶
- cacheMatrix()¶
Informs solve() and sweep() to cache their matrix so that matrix can return the matrix.
- cacheRHSvector()¶
Informs solve() and sweep() to cache their right hand side vector so that getRHSvector() can return it.
- copy()¶
- getDefaultSolver(var=None, solver=None, *args, **kwargs)¶
- justErrorVector(var=None, solver=None, boundaryConditions=(), dt=1.0, underRelaxation=None, residualFn=None)¶
Builds the Term’s linear system once.
This method also recalculates and returns the error as well as applying under-relaxation.
justErrorVector returns the overlapping local value in parallel (not the non-overlapping value).
>>> from fipy.solvers import DummySolver >>> from fipy import * >>> m = Grid1D(nx=10) >>> v = CellVariable(mesh=m) >>> len(DiffusionTerm().justErrorVector(v, solver=DummySolver())) == m.numberOfCells True
- Parameters:
var (CellVariable) – Variable to be solved for. Provides the initial condition, the old value and holds the solution on completion.
solver (Solver) – Iterative solver to be used to solve the linear system of equations. The default sovler depends on the solver package selected.
boundaryConditions (
tuple
ofBoundaryCondition
) –dt (float) – Timestep size.
underRelaxation (float) – Usually a value between 0 and 1 or None in the case of no under-relaxation
residualFn (function) – Takes var, matrix, and RHSvector arguments, used to customize the residual calculation.
- Returns:
error – The residual vector
- Return type:
- justResidualVector(var=None, solver=None, boundaryConditions=(), dt=None, underRelaxation=None, residualFn=None)¶
Builds the Term’s linear system once.
This method also recalculates and returns the residual as well as applying under-relaxation.
justResidualVector returns the overlapping local value in parallel (not the non-overlapping value).
>>> from fipy import * >>> m = Grid1D(nx=10) >>> v = CellVariable(mesh=m) >>> len(numerix.asarray(DiffusionTerm().justResidualVector(v))) == m.numberOfCells True
- Parameters:
var (CellVariable) – Variable to be solved for. Provides the initial condition, the old value and holds the solution on completion.
solver (Solver) – Iterative solver to be used to solve the linear system of equations. The default sovler depends on the solver package selected.
boundaryConditions (
tuple
ofBoundaryCondition
) –dt (float) – Timestep size.
underRelaxation (float) – Usually a value between 0 and 1 or None in the case of no under-relaxation
residualFn (function) – Takes var, matrix, and RHSvector arguments, used to customize the residual calculation.
- Returns:
residual – The residual vector
- Return type:
- property matrix¶
Return the matrix calculated in solve() or sweep(). The cacheMatrix() method should be called before solve() or sweep() to cache the matrix.
- residualVectorAndNorm(var=None, solver=None, boundaryConditions=(), dt=None, underRelaxation=None, residualFn=None)¶
Builds the Term’s linear system once.
This method also recalculates and returns the residual as well as applying under-relaxation.
- Parameters:
var (CellVariable) – Variable to be solved for. Provides the initial condition, the old value and holds the solution on completion.
solver (Solver) – Iterative solver to be used to solve the linear system of equations. The default sovler depends on the solver package selected.
boundaryConditions (
tuple
ofBoundaryCondition
) –dt (float) – Timestep size.
underRelaxation (float) – Usually a value between 0 and 1 or None in the case of no under-relaxation
residualFn (function) – Takes var, matrix, and RHSvector arguments, used to customize the residual calculation.
- Returns:
residual (~fipy.variables.cellVariable.CellVariable) – The residual vector
norm (float) – The L2 norm of residual,
- solve(var=None, solver=None, boundaryConditions=(), dt=None)¶
Builds and solves the Term’s linear system once. This method does not return the residual. It should be used when the residual is not required.
- Parameters:
var (CellVariable) – Variable to be solved for. Provides the initial condition, the old value and holds the solution on completion.
solver (Solver) – Iterative solver to be used to solve the linear system of equations. The default sovler depends on the solver package selected.
boundaryConditions (
tuple
ofBoundaryCondition
) –dt (float) – Timestep size.
- sweep(var=None, solver=None, boundaryConditions=(), dt=None, underRelaxation=None, residualFn=None, cacheResidual=False, cacheError=False)¶
Builds and solves the Term’s linear system once. This method also recalculates and returns the residual as well as applying under-relaxation.
- Parameters:
var (CellVariable) – Variable to be solved for. Provides the initial condition, the old value and holds the solution on completion.
solver (Solver) – Iterative solver to be used to solve the linear system of equations. The default sovler depends on the solver package selected.
boundaryConditions (
tuple
ofBoundaryCondition
) –dt (float) – Timestep size.
underRelaxation (float) – Usually a value between 0 and 1 or None in the case of no under-relaxation
residualFn (function) – Takes var, matrix, and RHSvector arguments, used to customize the residual calculation.
cacheResidual (bool) – If True, calculate and store the residual vector
in the residualVector member of Term
cacheError (bool) – If True, use the residual vector
to solve
for the error vector
and store it in the errorVector member of Term
- Returns:
residual – The residual vector
- Return type:
- exception fipy.PreconditionerNotPositiveDefiniteWarning(solver, iter, relres)¶
Bases:
PreconditionerWarning
- __cause__¶
exception cause
- __context__¶
exception context
- __delattr__(name, /)¶
Implement delattr(self, name).
- __getattribute__(name, /)¶
Return getattr(self, name).
- __reduce__()¶
Helper for pickle.
- __repr__()¶
Return repr(self).
- __setattr__(name, value, /)¶
Implement setattr(self, name, value).
- __setstate__()¶
- __str__()¶
Return str(self).
- __suppress_context__¶
- __traceback__¶
- add_note()¶
Exception.add_note(note) – add a note to the exception
- args¶
- with_traceback()¶
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
- exception fipy.PreconditionerWarning(solver, iter, relres)¶
Bases:
SolverConvergenceWarning
- __cause__¶
exception cause
- __context__¶
exception context
- __delattr__(name, /)¶
Implement delattr(self, name).
- __getattribute__(name, /)¶
Return getattr(self, name).
- __reduce__()¶
Helper for pickle.
- __repr__()¶
Return repr(self).
- __setattr__(name, value, /)¶
Implement setattr(self, name, value).
- __setstate__()¶
- __str__()¶
Return str(self).
- __suppress_context__¶
- __traceback__¶
- add_note()¶
Exception.add_note(note) – add a note to the exception
- args¶
- with_traceback()¶
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
- class fipy.ResidualTerm(equation, underRelaxation=1.0)¶
Bases:
_ExplicitSourceTerm
The ResidualTerm is a special form of explicit SourceTerm that adds the residual of one equation to another equation. Useful for Newton’s method.
Create a Term.
- Parameters:
coeff (float or CellVariable or FaceVariable) – Coefficient for the term. FaceVariable objects are only acceptable for diffusion or convection terms.
- property RHSvector¶
Return the RHS vector calculated in solve() or sweep(). The cacheRHSvector() method should be called before solve() or sweep() to cache the vector.
- __add__(other)¶
- __and__(other)¶
- __div__(other)¶
- __eq__(other)¶
Return self==value.
- __hash__()¶
Return hash(self).
- __mul__(other)¶
Multiply a term
>>> 2. * __NonDiffusionTerm(coeff=0.5) __NonDiffusionTerm(coeff=1.0)
Test for ticket:291.
>>> from fipy import PowerLawConvectionTerm >>> PowerLawConvectionTerm(coeff=[[1], [0]]) * 1.0 PowerLawConvectionTerm(coeff=array([[ 1.], [ 0.]]))
- __neg__()¶
Negate a Term.
>>> -__NonDiffusionTerm(coeff=1.) __NonDiffusionTerm(coeff=-1.0)
- __pos__()¶
- __radd__(other)¶
- __rand__(other)¶
- __repr__()¶
The representation of a Term object is given by,
>>> print(__UnaryTerm(123.456)) __UnaryTerm(coeff=123.456)
- __rmul__(other)¶
Multiply a term
>>> 2. * __NonDiffusionTerm(coeff=0.5) __NonDiffusionTerm(coeff=1.0)
Test for ticket:291.
>>> from fipy import PowerLawConvectionTerm >>> PowerLawConvectionTerm(coeff=[[1], [0]]) * 1.0 PowerLawConvectionTerm(coeff=array([[ 1.], [ 0.]]))
- __rsub__(other)¶
- __sub__(other)¶
- __truediv__(other)¶
- cacheMatrix()¶
Informs solve() and sweep() to cache their matrix so that matrix can return the matrix.
- cacheRHSvector()¶
Informs solve() and sweep() to cache their right hand side vector so that getRHSvector() can return it.
- copy()¶
- getDefaultSolver(var=None, solver=None, *args, **kwargs)¶
- justErrorVector(var=None, solver=None, boundaryConditions=(), dt=1.0, underRelaxation=None, residualFn=None)¶
Builds the Term’s linear system once.
This method also recalculates and returns the error as well as applying under-relaxation.
justErrorVector returns the overlapping local value in parallel (not the non-overlapping value).
>>> from fipy.solvers import DummySolver >>> from fipy import * >>> m = Grid1D(nx=10) >>> v = CellVariable(mesh=m) >>> len(DiffusionTerm().justErrorVector(v, solver=DummySolver())) == m.numberOfCells True
- Parameters:
var (CellVariable) – Variable to be solved for. Provides the initial condition, the old value and holds the solution on completion.
solver (Solver) – Iterative solver to be used to solve the linear system of equations. The default sovler depends on the solver package selected.
boundaryConditions (
tuple
ofBoundaryCondition
) –dt (float) – Timestep size.
underRelaxation (float) – Usually a value between 0 and 1 or None in the case of no under-relaxation
residualFn (function) – Takes var, matrix, and RHSvector arguments, used to customize the residual calculation.
- Returns:
error – The residual vector
- Return type:
- justResidualVector(var=None, solver=None, boundaryConditions=(), dt=None, underRelaxation=None, residualFn=None)¶
Builds the Term’s linear system once.
This method also recalculates and returns the residual as well as applying under-relaxation.
justResidualVector returns the overlapping local value in parallel (not the non-overlapping value).
>>> from fipy import * >>> m = Grid1D(nx=10) >>> v = CellVariable(mesh=m) >>> len(numerix.asarray(DiffusionTerm().justResidualVector(v))) == m.numberOfCells True
- Parameters:
var (CellVariable) – Variable to be solved for. Provides the initial condition, the old value and holds the solution on completion.
solver (Solver) – Iterative solver to be used to solve the linear system of equations. The default sovler depends on the solver package selected.
boundaryConditions (
tuple
ofBoundaryCondition
) –dt (float) – Timestep size.
underRelaxation (float) – Usually a value between 0 and 1 or None in the case of no under-relaxation
residualFn (function) – Takes var, matrix, and RHSvector arguments, used to customize the residual calculation.
- Returns:
residual – The residual vector
- Return type:
- property matrix¶
Return the matrix calculated in solve() or sweep(). The cacheMatrix() method should be called before solve() or sweep() to cache the matrix.
- residualVectorAndNorm(var=None, solver=None, boundaryConditions=(), dt=None, underRelaxation=None, residualFn=None)¶
Builds the Term’s linear system once.
This method also recalculates and returns the residual as well as applying under-relaxation.
- Parameters:
var (CellVariable) – Variable to be solved for. Provides the initial condition, the old value and holds the solution on completion.
solver (Solver) – Iterative solver to be used to solve the linear system of equations. The default sovler depends on the solver package selected.
boundaryConditions (
tuple
ofBoundaryCondition
) –dt (float) – Timestep size.
underRelaxation (float) – Usually a value between 0 and 1 or None in the case of no under-relaxation
residualFn (function) – Takes var, matrix, and RHSvector arguments, used to customize the residual calculation.
- Returns:
residual (~fipy.variables.cellVariable.CellVariable) – The residual vector
norm (float) – The L2 norm of residual,
- solve(var=None, solver=None, boundaryConditions=(), dt=None)¶
Builds and solves the Term’s linear system once. This method does not return the residual. It should be used when the residual is not required.
- Parameters:
var (CellVariable) – Variable to be solved for. Provides the initial condition, the old value and holds the solution on completion.
solver (Solver) – Iterative solver to be used to solve the linear system of equations. The default sovler depends on the solver package selected.
boundaryConditions (
tuple
ofBoundaryCondition
) –dt (float) – Timestep size.
- sweep(var=None, solver=None, boundaryConditions=(), dt=None, underRelaxation=None, residualFn=None, cacheResidual=False, cacheError=False)¶
Builds and solves the Term’s linear system once. This method also recalculates and returns the residual as well as applying under-relaxation.
- Parameters:
var (CellVariable) – Variable to be solved for. Provides the initial condition, the old value and holds the solution on completion.
solver (Solver) – Iterative solver to be used to solve the linear system of equations. The default sovler depends on the solver package selected.
boundaryConditions (
tuple
ofBoundaryCondition
) –dt (float) – Timestep size.
underRelaxation (float) – Usually a value between 0 and 1 or None in the case of no under-relaxation
residualFn (function) – Takes var, matrix, and RHSvector arguments, used to customize the residual calculation.
cacheResidual (bool) – If True, calculate and store the residual vector
in the residualVector member of Term
cacheError (bool) – If True, use the residual vector
to solve
for the error vector
and store it in the errorVector member of Term
- Returns:
residual – The residual vector
- Return type:
- exception fipy.ScalarQuantityOutOfRangeWarning(solver, iter, relres)¶
Bases:
SolverConvergenceWarning
- __cause__¶
exception cause
- __context__¶
exception context
- __delattr__(name, /)¶
Implement delattr(self, name).
- __getattribute__(name, /)¶
Return getattr(self, name).
- __reduce__()¶
Helper for pickle.
- __repr__()¶
Return repr(self).
- __setattr__(name, value, /)¶
Implement setattr(self, name, value).
- __setstate__()¶
- __str__()¶
Return str(self).
- __suppress_context__¶
- __traceback__¶
- add_note()¶
Exception.add_note(note) – add a note to the exception
- args¶
- with_traceback()¶
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
- class fipy.ScharfetterGummelFaceVariable(*args, **kwds)¶
Bases:
_CellToFaceVariable
- Parameters:
mesh (Mesh) – the mesh that defines the geometry of this Variable
name (str) – the user-readable name of the Variable
value (float or array_like) – the initial value
rank (int) – the rank (number of dimensions) of each element of this Variable. Default: 0
elementshape (
tuple
ofint
) – the shape of each element of this variable Default: rank * (mesh.dim,)unit (str or PhysicalUnit) – The physical units of the variable
- __abs__()¶
Following test it to fix a bug with C inline string using abs() instead of fabs()
>>> print(abs(Variable(2.3) - Variable(1.2))) 1.1
Check representation works with different versions of numpy
>>> print(repr(abs(Variable(2.3)))) numerix.fabs(Variable(value=array(2.3)))
- __add__(other)¶
- __and__(other)¶
This test case has been added due to a weird bug that was appearing.
>>> a = Variable(value=(0, 0, 1, 1)) >>> b = Variable(value=(0, 1, 0, 1)) >>> print(numerix.equal((a == 0) & (b == 1), [False, True, False, False]).all()) True >>> print(a & b) [0 0 0 1] >>> from fipy.meshes import Grid1D >>> mesh = Grid1D(nx=4) >>> from fipy.variables.cellVariable import CellVariable >>> a = CellVariable(value=(0, 0, 1, 1), mesh=mesh) >>> b = CellVariable(value=(0, 1, 0, 1), mesh=mesh) >>> print(numerix.allequal((a == 0) & (b == 1), [False, True, False, False])) True >>> print(a & b) [0 0 0 1]
- __array__(t=None)¶
Attempt to convert the Variable to a numerix array object
>>> v = Variable(value=[2, 3]) >>> print(numerix.array(v)) [2 3]
A dimensional Variable will convert to the numeric value in its base units
>>> v = Variable(value=[2, 3], unit="mm") >>> numerix.array(v) array([ 0.002, 0.003])
- __array_priority__ = 100.0¶
- __array_wrap__(arr, context=None)¶
Required to prevent numpy not calling the reverse binary operations. Both the following tests are examples ufuncs.
>>> print(type(numerix.array([1.0, 2.0]) * Variable([1.0, 2.0]))) <class 'fipy.variables.binaryOperatorVariable...binOp'>
>>> from scipy.special import gamma as Gamma >>> print(type(Gamma(Variable([1.0, 2.0])))) <class 'fipy.variables.unaryOperatorVariable...unOp'>
- __bool__()¶
>>> print(bool(Variable(value=0))) 0 >>> print(bool(Variable(value=(0, 0, 1, 1)))) Traceback (most recent call last): ... ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
- __call__()¶
“Evaluate” the Variable and return its value
>>> a = Variable(value=3) >>> print(a()) 3 >>> b = a + 4 >>> b (Variable(value=array(3)) + 4) >>> b() 7
- __div__(other)¶
- __eq__(other)¶
Test if a Variable is equal to another quantity
>>> a = Variable(value=3) >>> b = (a == 4) >>> b (Variable(value=array(3)) == 4) >>> b() 0
- __float__()¶
- __ge__(other)¶
Test if a Variable is greater than or equal to another quantity
>>> a = Variable(value=3) >>> b = (a >= 4) >>> b (Variable(value=array(3)) >= 4) >>> b() 0 >>> a.value = 4 >>> print(b()) 1 >>> a.value = 5 >>> print(b()) 1
- __getitem__(index)¶
“Evaluate” the Variable and return the specified element
>>> a = Variable(value=((3., 4.), (5., 6.)), unit="m") + "4 m" >>> print(a[1, 1]) 10.0 m
It is an error to slice a Variable whose value is not sliceable
>>> Variable(value=3)[2] Traceback (most recent call last): ... IndexError: 0-d arrays can't be indexed
- __getstate__()¶
Used internally to collect the necessary information to
pickle
the _MeshVariable to persistent storage.
- __gt__(other)¶
Test if a Variable is greater than another quantity
>>> a = Variable(value=3) >>> b = (a > 4) >>> b (Variable(value=array(3)) > 4) >>> print(b()) 0 >>> a.value = 5 >>> print(b()) 1
- __hash__()¶
Return hash(self).
- __int__()¶
- __invert__()¶
Returns logical “not” of the Variable
>>> a = Variable(value=True) >>> print(~a) False
- __iter__()¶
- __le__(other)¶
Test if a Variable is less than or equal to another quantity
>>> a = Variable(value=3) >>> b = (a <= 4) >>> b (Variable(value=array(3)) <= 4) >>> b() 1 >>> a.value = 4 >>> print(b()) 1 >>> a.value = 5 >>> print(b()) 0
- __len__()¶
- __lt__(other)¶
Test if a Variable is less than another quantity
>>> a = Variable(value=3) >>> b = (a < 4) >>> b (Variable(value=array(3)) < 4) >>> b() 1 >>> a.value = 4 >>> print(b()) 0 >>> print(1000000000000000000 * Variable(1) < 1.) 0 >>> print(1000 * Variable(1) < 1.) 0
Python automatically reverses the arguments when necessary
>>> 4 > Variable(value=3) (Variable(value=array(3)) < 4)
- __mod__(other)¶
- __mul__(other)¶
- __ne__(other)¶
Test if a Variable is not equal to another quantity
>>> a = Variable(value=3) >>> b = (a != 4) >>> b (Variable(value=array(3)) != 4) >>> b() 1
- __neg__()¶
- static __new__(cls, *args, **kwds)¶
- __nonzero__()¶
>>> print(bool(Variable(value=0))) 0 >>> print(bool(Variable(value=(0, 0, 1, 1)))) Traceback (most recent call last): ... ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
- __or__(other)¶
This test case has been added due to a weird bug that was appearing.
>>> a = Variable(value=(0, 0, 1, 1)) >>> b = Variable(value=(0, 1, 0, 1)) >>> print(numerix.equal((a == 0) | (b == 1), [True, True, False, True]).all()) True >>> print(a | b) [0 1 1 1] >>> from fipy.meshes import Grid1D >>> mesh = Grid1D(nx=4) >>> from fipy.variables.cellVariable import CellVariable >>> a = CellVariable(value=(0, 0, 1, 1), mesh=mesh) >>> b = CellVariable(value=(0, 1, 0, 1), mesh=mesh) >>> print(numerix.allequal((a == 0) | (b == 1), [True, True, False, True])) True >>> print(a | b) [0 1 1 1]
- __pos__()¶
- __pow__(other)¶
return self**other, or self raised to power other
>>> print(Variable(1, "mol/l")**3) 1.0 mol**3/l**3 >>> print((Variable(1, "mol/l")**3).unit) <PhysicalUnit mol**3/l**3>
- __radd__(other)¶
- __rdiv__(other)¶
- __repr__()¶
Return repr(self).
- __rmul__(other)¶
- __rpow__(other)¶
- __rsub__(other)¶
- __rtruediv__(other)¶
- __setitem__(index, value)¶
- __setstate__(dict)¶
Used internally to create a new Variable from
pickled
persistent storage.
- __str__()¶
Return str(self).
- __sub__(other)¶
- __truediv__(other)¶
- all(axis=None)¶
>>> print(Variable(value=(0, 0, 1, 1)).all()) 0 >>> print(Variable(value=(1, 1, 1, 1)).all()) 1
- allclose(other, rtol=1e-05, atol=1e-08)¶
>>> var = Variable((1, 1)) >>> print(var.allclose((1, 1))) 1 >>> print(var.allclose((1,))) 1
The following test is to check that the system does not run out of memory.
>>> from fipy.tools import numerix >>> var = Variable(numerix.ones(10000)) >>> print(var.allclose(numerix.zeros(10000, 'l'))) False
- allequal(other)¶
- any(axis=None)¶
>>> print(Variable(value=0).any()) 0 >>> print(Variable(value=(0, 0, 1, 1)).any()) 1
- cacheMe(recursive=False)¶
- constrain(value, where=None)¶
Constrain the Variable to have a value at an index or mask location specified by where.
>>> v = Variable((0, 1, 2, 3)) >>> v.constrain(2, numerix.array((True, False, False, False))) >>> print(v) [2 1 2 3] >>> v[:] = 10 >>> print(v) [ 2 10 10 10] >>> v.constrain(5, numerix.array((False, False, True, False))) >>> print(v) [ 2 10 5 10] >>> v[:] = 6 >>> print(v) [2 6 5 6] >>> v.constrain(8) >>> print(v) [8 8 8 8] >>> v[:] = 10 >>> print(v) [8 8 8 8] >>> del v.constraints[2] >>> print(v) [ 2 10 5 10]
>>> from fipy.variables.cellVariable import CellVariable >>> from fipy.meshes import Grid2D >>> m = Grid2D(nx=2, ny=2) >>> x, y = m.cellCenters >>> v = CellVariable(mesh=m, rank=1, value=(x, y)) >>> v.constrain(((0.,), (-1.,)), where=m.facesLeft) >>> print(v.faceValue) [[ 0.5 1.5 0.5 1.5 0.5 1.5 0. 1. 1.5 0. 1. 1.5] [ 0.5 0.5 1. 1. 1.5 1.5 -1. 0.5 0.5 -1. 1.5 1.5]]
- Parameters:
value (float or array_like) – The value of the constraint
where (array_like of
bool
) – The constraint mask or index specifying the location of the constraint
- property constraintMask¶
Test that constraintMask returns a Variable that updates itself whenever the constraints change.
>>> from fipy import *
>>> m = Grid2D(nx=2, ny=2) >>> x, y = m.cellCenters >>> v0 = CellVariable(mesh=m) >>> v0.constrain(1., where=m.facesLeft) >>> print(v0.faceValue.constraintMask) [False False False False False False True False False True False False] >>> print(v0.faceValue) [ 0. 0. 0. 0. 0. 0. 1. 0. 0. 1. 0. 0.] >>> v0.constrain(3., where=m.facesRight) >>> print(v0.faceValue.constraintMask) [False False False False False False True False True True False True] >>> print(v0.faceValue) [ 0. 0. 0. 0. 0. 0. 1. 0. 3. 1. 0. 3.] >>> v1 = CellVariable(mesh=m) >>> v1.constrain(1., where=(x < 1) & (y < 1)) >>> print(v1.constraintMask) [ True False False False] >>> print(v1) [ 1. 0. 0. 0.] >>> v1.constrain(3., where=(x > 1) & (y > 1)) >>> print(v1.constraintMask) [ True False False True] >>> print(v1) [ 1. 0. 0. 3.]
- property constraints¶
- copy()¶
Make an duplicate of the Variable
>>> a = Variable(value=3) >>> b = a.copy() >>> b Variable(value=array(3))
The duplicate will not reflect changes made to the original
>>> a.setValue(5) >>> b Variable(value=array(3))
Check that this works for arrays.
>>> a = Variable(value=numerix.array((0, 1, 2))) >>> b = a.copy() >>> b Variable(value=array([0, 1, 2])) >>> a[1] = 3 >>> b Variable(value=array([0, 1, 2]))
- property divergence¶
the divergence of self,
,
- Returns:
divergence – one rank lower than self
- Return type:
Examples
>>> from fipy.meshes import Grid2D >>> from fipy.variables.cellVariable import CellVariable >>> mesh = Grid2D(nx=3, ny=2) >>> from builtins import range >>> var = CellVariable(mesh=mesh, value=list(range(3*2))) >>> print(var.faceGrad.divergence) [ 4. 3. 2. -2. -3. -4.]
- dontCacheMe(recursive=False)¶
- dot(other, opShape=None, operatorClass=None)¶
Return the mesh-element–by–mesh-element (cell-by-cell, face-by-face, etc.) scalar product
Both self and other can be of arbitrary rank, and other does not need to be a _MeshVariable.
- getsctype(default=None)¶
Returns the Numpy sctype of the underlying array.
>>> Variable(1).getsctype() == numerix.NUMERIX.obj2sctype(numerix.array(1)) True >>> Variable(1.).getsctype() == numerix.NUMERIX.obj2sctype(numerix.array(1.)) True >>> Variable((1, 1.)).getsctype() == numerix.NUMERIX.obj2sctype(numerix.array((1., 1.))) True
- property globalValue¶
- inBaseUnits()¶
Return the value of the Variable with all units reduced to their base SI elements.
>>> e = Variable(value="2.7 Hartree*Nav") >>> print(e.inBaseUnits().allclose("7088849.01085 kg*m**2/s**2/mol")) 1
- inUnitsOf(*units)¶
Returns one or more Variable objects that express the same physical quantity in different units. The units are specified by strings containing their names. The units must be compatible with the unit of the object. If one unit is specified, the return value is a single Variable.
>>> freeze = Variable('0 degC') >>> print(freeze.inUnitsOf('degF').allclose("32.0 degF")) 1
If several units are specified, the return value is a tuple of Variable instances with with one element per unit such that the sum of all quantities in the tuple equals the the original quantity and all the values except for the last one are integers. This is used to convert to irregular unit systems like hour/minute/second. The original object will not be changed.
>>> t = Variable(value=314159., unit='s') >>> from builtins import zip >>> print(numerix.allclose([e.allclose(v) for (e, v) in zip(t.inUnitsOf('d', 'h', 'min', 's'), ... ['3.0 d', '15.0 h', '15.0 min', '59.0 s'])], ... True)) 1
- itemset(value)¶
- property itemsize¶
- max(axis=None)¶
- min(axis=None)¶
>>> from fipy import Grid2D, CellVariable >>> mesh = Grid2D(nx=5, ny=5) >>> x, y = mesh.cellCenters >>> v = CellVariable(mesh=mesh, value=x*y) >>> print(v.min()) 0.25
- property name¶
- property numericValue¶
- put(indices, value)¶
- property rank¶
- ravel()¶
- rdot(other, opShape=None, operatorClass=None)¶
Return the mesh-element–by–mesh-element (cell-by-cell, face-by-face, etc.) scalar product
Both self and other can be of arbitrary rank, and other does not need to be a _MeshVariable.
- release(constraint)¶
Remove constraint from self
>>> from fipy import * >>> m = Grid1D(nx=3) >>> v = CellVariable(mesh=m, value=m.cellCenters[0]) >>> c0 = Constraint(0., where=m.facesLeft) >>> v.constrain(c0) >>> c1 = Constraint(3., where=m.facesRight) >>> v.faceValue.constrain(c1) >>> print(v.faceValue) [ 0. 1. 2. 3.] >>> v.faceValue.release(constraint=c0) >>> print(v.faceValue) [ 0.5 1. 2. 3. ] >>> v.faceValue.release(constraint=c1) >>> print(v.faceValue) [ 0.5 1. 2. 2.5]
- setValue(value, unit=None, where=None)¶
Set the value of the Variable. Can take a masked array.
>>> a = Variable((1, 2, 3)) >>> a.setValue(5, where=(1, 0, 1)) >>> print(a) [5 2 5]
>>> b = Variable((4, 5, 6)) >>> a.setValue(b, where=(1, 0, 1)) >>> print(a) [4 2 6] >>> print(b) [4 5 6] >>> a.value = 3 >>> print(a) [3 3 3]
>>> b = numerix.array((3, 4, 5)) >>> a.value = b >>> a[:] = 1 >>> print(b) [3 4 5]
>>> a.setValue((4, 5, 6), where=(1, 0)) Traceback (most recent call last): .... ValueError: shape mismatch: objects cannot be broadcast to a single shape
- property shape¶
>>> from fipy.meshes import Grid2D >>> from fipy.variables.cellVariable import CellVariable >>> mesh = Grid2D(nx=2, ny=3) >>> var = CellVariable(mesh=mesh) >>> print(numerix.allequal(var.shape, (6,))) True >>> print(numerix.allequal(var.arithmeticFaceValue.shape, (17,))) True >>> print(numerix.allequal(var.grad.shape, (2, 6))) True >>> print(numerix.allequal(var.faceGrad.shape, (2, 17))) True
Have to account for zero length arrays
>>> from fipy import Grid1D >>> m = Grid1D(nx=0) >>> v = CellVariable(mesh=m, elementshape=(2,)) >>> numerix.allequal((v * 1).shape, (2, 0)) True
- std(axis=None, **kwargs)¶
Evaluate standard deviation of all the elements of a MeshVariable.
Adapted from http://mpitutorial.com/tutorials/mpi-reduce-and-allreduce/
>>> import fipy as fp >>> mesh = fp.Grid2D(nx=2, ny=2, dx=2., dy=5.) >>> var = fp.CellVariable(value=(1., 2., 3., 4.), mesh=mesh) >>> print((var.std()**2).allclose(1.25)) True
- property subscribedVariables¶
- sum(axis=None)¶
- take(ids, axis=0)¶
- tostring(max_line_width=75, precision=8, suppress_small=False, separator=' ')¶
- property unit¶
Return the unit object of self.
>>> Variable(value="1 m").unit <PhysicalUnit m>
- property value¶
“Evaluate” the Variable and return its value (longhand)
>>> a = Variable(value=3) >>> print(a.value) 3 >>> b = a + 4 >>> b (Variable(value=array(3)) + 4) >>> b.value 7
Create a temporary file shared by all MPI ranks.
The file is created as NamedTemporaryFile would do it. The name of the returned file-like object is accessible as its
name
attribute. The file will be automatically deleted when it is closed unless the delete argument is set to False.>>> from fipy.tools import SharedTemporaryFile, parallelComm >>> with SharedTemporaryFile(mode='w+', suffix=".tmp") as tmpFile: ... # write on processor 0 ... if parallelComm.procID == 0: ... _ = tmpFile.write("shared text") ... ... parallelComm.Barrier() ... ... # read on all processors ... _ = tmpFile.seek(0) ... txt = tmpFile.read() >>> print(txt) shared text
- Parameters:
prefix (str) – As for mkstemp
suffix (str) – As for mkstemp
dir (str) – As for mkstemp
mode (str) – The mode argument to io.open (default “w+b”)
buffering (int) – The buffer size argument to io.open (default -1)
encoding (str or None) – The encoding argument to io.open (default None)
newline (str or None) – The newline argument to io.open (default None)
delete (bool) – Whether the file is deleted on close (default True)
communicator (CommWrapper) – MPI communicator describing ranks to share with. A duck-typed object with procID and Nproc attributes is sufficient.
- Return type:
file-like object
See also
- class fipy.SkewedGrid2D(dx=1.0, dy=1.0, nx=None, ny=1, rand=0, *args, **kwargs)¶
Bases:
Mesh2D
Creates a 2D grid mesh with horizontal faces numbered first and then vertical faces. The points are skewed by a random amount (between rand and -rand) in the X and Y directions.
Note
This Mesh only operates in serial
- property VTKCellDataSet¶
Returns a TVTK DataSet representing the cells of this mesh
- property VTKFaceDataSet¶
Returns a TVTK DataSet representing the face centers of this mesh
- __add__(other)¶
Either translate a Mesh or concatenate two Mesh objects.
>>> from fipy.meshes import Grid2D >>> baseMesh = Grid2D(dx = 1.0, dy = 1.0, nx = 2, ny = 2) >>> print(baseMesh.cellCenters) [[ 0.5 1.5 0.5 1.5] [ 0.5 0.5 1.5 1.5]]
If a vector is added to a Mesh, a translated Mesh is returned
>>> translatedMesh = baseMesh + ((5,), (10,)) >>> print(translatedMesh.cellCenters) [[ 5.5 6.5 5.5 6.5] [ 10.5 10.5 11.5 11.5]]
If a Mesh is added to a Mesh, a concatenation of the two Mesh objects is returned
>>> addedMesh = baseMesh + (baseMesh + ((2,), (0,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 2.5 3.5 2.5 3.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5]]
The two Mesh objects need not be properly aligned in order to concatenate them but the resulting mesh may not have the intended connectivity
>>> addedMesh = baseMesh + (baseMesh + ((3,), (0,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 3.5 4.5 3.5 4.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5]]
>>> addedMesh = baseMesh + (baseMesh + ((2,), (2,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 2.5 3.5 2.5 3.5] [ 0.5 0.5 1.5 1.5 2.5 2.5 3.5 3.5]]
No provision is made to avoid or consolidate overlapping Mesh objects
>>> addedMesh = baseMesh + (baseMesh + ((1,), (0,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 1.5 2.5 1.5 2.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5]]
Different Mesh classes can be concatenated
>>> from fipy.meshes import Tri2D >>> triMesh = Tri2D(dx = 1.0, dy = 1.0, nx = 2, ny = 1) >>> triMesh = triMesh + ((2,), (0,)) >>> triAddedMesh = baseMesh + triMesh >>> cellCenters = [[0.5, 1.5, 0.5, 1.5, 2.83333333, 3.83333333, ... 2.5, 3.5, 2.16666667, 3.16666667, 2.5, 3.5], ... [0.5, 0.5, 1.5, 1.5, 0.5, 0.5, 0.83333333, 0.83333333, ... 0.5, 0.5, 0.16666667, 0.16666667]] >>> print(numerix.allclose(triAddedMesh.cellCenters, ... cellCenters)) True
again, their faces need not align, but the mesh may not have the desired connectivity
>>> triMesh = Tri2D(dx = 1.0, dy = 2.0, nx = 2, ny = 1) >>> triMesh = triMesh + ((2,), (0,)) >>> triAddedMesh = baseMesh + triMesh >>> cellCenters = [[ 0.5, 1.5, 0.5, 1.5, 2.83333333, 3.83333333, ... 2.5, 3.5, 2.16666667, 3.16666667, 2.5, 3.5], ... [ 0.5, 0.5, 1.5, 1.5, 1., 1., ... 1.66666667, 1.66666667, 1., 1., 0.33333333, 0.33333333]] >>> print(numerix.allclose(triAddedMesh.cellCenters, ... cellCenters)) True
Mesh concatenation is not limited to 2D meshes
>>> from fipy.meshes import Grid3D >>> threeDBaseMesh = Grid3D(dx = 1.0, dy = 1.0, dz = 1.0, ... nx = 2, ny = 2, nz = 2) >>> threeDSecondMesh = Grid3D(dx = 1.0, dy = 1.0, dz = 1.0, ... nx = 1, ny = 1, nz = 1) >>> threeDAddedMesh = threeDBaseMesh + (threeDSecondMesh + ((2,), (0,), (0,))) >>> print(threeDAddedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 0.5 1.5 0.5 1.5 2.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5 0.5] [ 0.5 0.5 0.5 0.5 1.5 1.5 1.5 1.5 0.5]]
but the different Mesh objects must, of course, have the same dimensionality.
>>> InvalidMesh = threeDBaseMesh + baseMesh Traceback (most recent call last): ... MeshAdditionError: Dimensions do not match
- __div__(other)¶
Tests. >>> from fipy import * >>> print((Grid1D(nx=1) / 2.).cellCenters) [[ 0.25]] >>> AbstractMesh(communicator=None) / 2. Traceback (most recent call last): … NotImplementedError
- __getstate__()¶
Helper for pickle.
- __mul__(factor)¶
Dilate a Mesh by factor.
>>> from fipy.meshes import Grid2D >>> baseMesh = Grid2D(dx = 1.0, dy = 1.0, nx = 2, ny = 2) >>> print(baseMesh.cellCenters) [[ 0.5 1.5 0.5 1.5] [ 0.5 0.5 1.5 1.5]]
The factor can be a scalar
>>> dilatedMesh = baseMesh * 3 >>> print(dilatedMesh.cellCenters) [[ 1.5 4.5 1.5 4.5] [ 1.5 1.5 4.5 4.5]]
or a vector
>>> dilatedMesh = baseMesh * ((3,), (2,)) >>> print(dilatedMesh.cellCenters) [[ 1.5 4.5 1.5 4.5] [ 1. 1. 3. 3. ]]
but the vector must have the same dimensionality as the Mesh
>>> dilatedMesh = baseMesh * ((3,), (2,), (1,)) Traceback (most recent call last): ... ValueError: shape mismatch: objects cannot be broadcast to a single shape
- __radd__(other)¶
Either translate a Mesh or concatenate two Mesh objects.
>>> from fipy.meshes import Grid2D >>> baseMesh = Grid2D(dx = 1.0, dy = 1.0, nx = 2, ny = 2) >>> print(baseMesh.cellCenters) [[ 0.5 1.5 0.5 1.5] [ 0.5 0.5 1.5 1.5]]
If a vector is added to a Mesh, a translated Mesh is returned
>>> translatedMesh = baseMesh + ((5,), (10,)) >>> print(translatedMesh.cellCenters) [[ 5.5 6.5 5.5 6.5] [ 10.5 10.5 11.5 11.5]]
If a Mesh is added to a Mesh, a concatenation of the two Mesh objects is returned
>>> addedMesh = baseMesh + (baseMesh + ((2,), (0,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 2.5 3.5 2.5 3.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5]]
The two Mesh objects need not be properly aligned in order to concatenate them but the resulting mesh may not have the intended connectivity
>>> addedMesh = baseMesh + (baseMesh + ((3,), (0,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 3.5 4.5 3.5 4.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5]]
>>> addedMesh = baseMesh + (baseMesh + ((2,), (2,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 2.5 3.5 2.5 3.5] [ 0.5 0.5 1.5 1.5 2.5 2.5 3.5 3.5]]
No provision is made to avoid or consolidate overlapping Mesh objects
>>> addedMesh = baseMesh + (baseMesh + ((1,), (0,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 1.5 2.5 1.5 2.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5]]
Different Mesh classes can be concatenated
>>> from fipy.meshes import Tri2D >>> triMesh = Tri2D(dx = 1.0, dy = 1.0, nx = 2, ny = 1) >>> triMesh = triMesh + ((2,), (0,)) >>> triAddedMesh = baseMesh + triMesh >>> cellCenters = [[0.5, 1.5, 0.5, 1.5, 2.83333333, 3.83333333, ... 2.5, 3.5, 2.16666667, 3.16666667, 2.5, 3.5], ... [0.5, 0.5, 1.5, 1.5, 0.5, 0.5, 0.83333333, 0.83333333, ... 0.5, 0.5, 0.16666667, 0.16666667]] >>> print(numerix.allclose(triAddedMesh.cellCenters, ... cellCenters)) True
again, their faces need not align, but the mesh may not have the desired connectivity
>>> triMesh = Tri2D(dx = 1.0, dy = 2.0, nx = 2, ny = 1) >>> triMesh = triMesh + ((2,), (0,)) >>> triAddedMesh = baseMesh + triMesh >>> cellCenters = [[ 0.5, 1.5, 0.5, 1.5, 2.83333333, 3.83333333, ... 2.5, 3.5, 2.16666667, 3.16666667, 2.5, 3.5], ... [ 0.5, 0.5, 1.5, 1.5, 1., 1., ... 1.66666667, 1.66666667, 1., 1., 0.33333333, 0.33333333]] >>> print(numerix.allclose(triAddedMesh.cellCenters, ... cellCenters)) True
Mesh concatenation is not limited to 2D meshes
>>> from fipy.meshes import Grid3D >>> threeDBaseMesh = Grid3D(dx = 1.0, dy = 1.0, dz = 1.0, ... nx = 2, ny = 2, nz = 2) >>> threeDSecondMesh = Grid3D(dx = 1.0, dy = 1.0, dz = 1.0, ... nx = 1, ny = 1, nz = 1) >>> threeDAddedMesh = threeDBaseMesh + (threeDSecondMesh + ((2,), (0,), (0,))) >>> print(threeDAddedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 0.5 1.5 0.5 1.5 2.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5 0.5] [ 0.5 0.5 0.5 0.5 1.5 1.5 1.5 1.5 0.5]]
but the different Mesh objects must, of course, have the same dimensionality.
>>> InvalidMesh = threeDBaseMesh + baseMesh Traceback (most recent call last): ... MeshAdditionError: Dimensions do not match
- __repr__()¶
Return repr(self).
- __rmul__(factor)¶
Dilate a Mesh by factor.
>>> from fipy.meshes import Grid2D >>> baseMesh = Grid2D(dx = 1.0, dy = 1.0, nx = 2, ny = 2) >>> print(baseMesh.cellCenters) [[ 0.5 1.5 0.5 1.5] [ 0.5 0.5 1.5 1.5]]
The factor can be a scalar
>>> dilatedMesh = baseMesh * 3 >>> print(dilatedMesh.cellCenters) [[ 1.5 4.5 1.5 4.5] [ 1.5 1.5 4.5 4.5]]
or a vector
>>> dilatedMesh = baseMesh * ((3,), (2,)) >>> print(dilatedMesh.cellCenters) [[ 1.5 4.5 1.5 4.5] [ 1. 1. 3. 3. ]]
but the vector must have the same dimensionality as the Mesh
>>> dilatedMesh = baseMesh * ((3,), (2,), (1,)) Traceback (most recent call last): ... ValueError: shape mismatch: objects cannot be broadcast to a single shape
- __setstate__(state)¶
- __sub__(other)¶
Tests. >>> from fipy import * >>> m = Grid1D() >>> print((m - ((1,))).cellCenters) [[-0.5]] >>> ((1,)) - m Traceback (most recent call last): … TypeError: unsupported operand type(s) for -: ‘tuple’ and ‘UniformGrid1D’
- __truediv__(other)¶
Tests. >>> from fipy import * >>> print((Grid1D(nx=1) / 2.).cellCenters) [[ 0.25]] >>> AbstractMesh(communicator=None) / 2. Traceback (most recent call last): … NotImplementedError
- property aspect2D¶
The physical y vs x aspect ratio of a 2D mesh
- property cellCenters¶
- property cellDistanceVectors¶
- property cellFaceIDs¶
- property cellToFaceDistanceVectors¶
- property cellVolumes¶
- property extents¶
- property exteriorFaces¶
- extrude(extrudeFunc=<function Mesh2D.<lambda>>, layers=1)¶
This function returns a new 3D mesh. The 2D mesh is extruded using the extrudeFunc and the number of layers.
>>> from fipy.meshes.nonUniformGrid2D import NonUniformGrid2D >>> print(NonUniformGrid2D(nx=2, ny=2).extrude(layers=2).cellCenters) [[ 0.5 1.5 0.5 1.5 0.5 1.5 0.5 1.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5] [ 0.5 0.5 0.5 0.5 1.5 1.5 1.5 1.5]]
>>> from fipy.meshes.tri2D import Tri2D >>> print(Tri2D().extrude(layers=2).cellCenters.allclose([[ 0.83333333, 0.5, 0.16666667, 0.5, 0.83333333, 0.5, ... 0.16666667, 0.5 ], ... [ 0.5, 0.83333333, 0.5, 0.16666667, 0.5, 0.83333333, ... 0.5, 0.16666667], ... [ 0.5, 0.5, 0.5, 0.5, 1.5, 1.5, 1.5, ... 1.5 ]])) True
- Parameters:
extrudeFunc (function) – Takes the vertex coordinates and returns the displaced values
layers (int) – Number of layers in the extruded mesh (number of times extrudeFunc will be called)
- property faceCenters¶
- property facesBack¶
Return list of faces on back boundary of 3D Mesh with the z-axis running from front to back.
>>> from fipy import Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((6, 7, 8, 9, 10, 11), ... numerix.nonzero(mesh.facesBack)[0])) True >>> ignore = mesh.facesBack.value
- property facesBottom¶
Return list of faces on bottom boundary of 2D or 3D Mesh with the y-axis running from bottom to top.
>>> from fipy import Grid2D, Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((12, 13, 14), ... numerix.nonzero(mesh.facesBottom)[0])) True >>> ignore = mesh.facesBottom.value >>> x, y, z = mesh.faceCenters >>> print(numerix.allequal((12, 13), ... numerix.nonzero(mesh.facesBottom & (x < 1))[0])) True >>> ignore = mesh.facesBottom.value
- property facesDown¶
Return list of faces on bottom boundary of 2D or 3D Mesh with the y-axis running from bottom to top.
>>> from fipy import Grid2D, Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((12, 13, 14), ... numerix.nonzero(mesh.facesBottom)[0])) True >>> ignore = mesh.facesBottom.value >>> x, y, z = mesh.faceCenters >>> print(numerix.allequal((12, 13), ... numerix.nonzero(mesh.facesBottom & (x < 1))[0])) True >>> ignore = mesh.facesBottom.value
- property facesFront¶
Return list of faces on front boundary of 3D Mesh with the z-axis running from front to back.
>>> from fipy import Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((0, 1, 2, 3, 4, 5), ... numerix.nonzero(mesh.facesFront)[0])) True >>> ignore = mesh.facesFront.value
- property facesLeft¶
Return face on left boundary of Mesh as list with the x-axis running from left to right.
>>> from fipy import Grid2D, Grid3D >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((21, 25), ... numerix.nonzero(mesh.facesLeft)[0])) True >>> ignore = mesh.facesLeft.value >>> mesh = Grid2D(nx = 3, ny = 2, dx = 0.5, dy = 2.) >>> print(numerix.allequal((9, 13), ... numerix.nonzero(mesh.facesLeft)[0])) True >>> ignore = mesh.facesLeft.value
- property facesRight¶
Return list of faces on right boundary of Mesh with the x-axis running from left to right.
>>> from fipy import Grid2D, Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((24, 28), ... numerix.nonzero(mesh.facesRight)[0])) True >>> ignore = mesh.facesRight.value >>> mesh = Grid2D(nx = 3, ny = 2, dx = 0.5, dy = 2.) >>> print(numerix.allequal((12, 16), ... numerix.nonzero(mesh.facesRight)[0])) True >>> ignore = mesh.facesRight.value
- property facesTop¶
Return list of faces on top boundary of 2D or 3D Mesh with the y-axis running from bottom to top.
>>> from fipy import Grid2D, Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((18, 19, 20), ... numerix.nonzero(mesh.facesTop)[0])) True >>> ignore = mesh.facesTop.value >>> mesh = Grid2D(nx = 3, ny = 2, dx = 0.5, dy = 2.) >>> print(numerix.allequal((6, 7, 8), ... numerix.nonzero(mesh.facesTop)[0])) True >>> ignore = mesh.facesTop.value
- property facesUp¶
Return list of faces on top boundary of 2D or 3D Mesh with the y-axis running from bottom to top.
>>> from fipy import Grid2D, Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((18, 19, 20), ... numerix.nonzero(mesh.facesTop)[0])) True >>> ignore = mesh.facesTop.value >>> mesh = Grid2D(nx = 3, ny = 2, dx = 0.5, dy = 2.) >>> print(numerix.allequal((6, 7, 8), ... numerix.nonzero(mesh.facesTop)[0])) True >>> ignore = mesh.facesTop.value
- getNearestCell(point)¶
- property interiorFaceCellIDs¶
- property interiorFaceIDs¶
- property interiorFaces¶
- property physicalShape¶
Return physical dimensions of Grid2D.
- property scale¶
- property scaledCellDistances¶
- property scaledCellToCellDistances¶
- property scaledCellVolumes¶
- property scaledFaceAreas¶
- property scaledFaceToCellDistances¶
- property shape¶
- property x¶
Equivalent to using
cellCenters
[0]
.>>> from fipy import * >>> print(Grid1D(nx=2).x) [ 0.5 1.5]
- property y¶
Equivalent to using
cellCenters
[1]
.>>> from fipy import * >>> print(Grid2D(nx=2, ny=2).y) [ 0.5 0.5 1.5 1.5] >>> print(Grid1D(nx=2).y) Traceback (most recent call last): ... AttributeError: 1D meshes do not have a "y" attribute.
- property z¶
Equivalent to using
cellCenters
[2]
.>>> from fipy import * >>> print(Grid3D(nx=2, ny=2, nz=2).z) [ 0.5 0.5 0.5 0.5 1.5 1.5 1.5 1.5] >>> print(Grid2D(nx=2, ny=2).z) Traceback (most recent call last): ... AttributeError: 1D and 2D meshes do not have a "z" attribute.
- exception fipy.SolutionVariableNumberError(s='Different number of solution variables and equations.')¶
Bases:
Exception
- __cause__¶
exception cause
- __context__¶
exception context
- __delattr__(name, /)¶
Implement delattr(self, name).
- __getattribute__(name, /)¶
Return getattr(self, name).
- __reduce__()¶
Helper for pickle.
- __repr__()¶
Return repr(self).
- __setattr__(name, value, /)¶
Implement setattr(self, name, value).
- __setstate__()¶
- __str__()¶
Return str(self).
- __suppress_context__¶
- __traceback__¶
- add_note()¶
Exception.add_note(note) – add a note to the exception
- args¶
- with_traceback()¶
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
- exception fipy.SolutionVariableRequiredError(s='The solution variable needs to be specified.')¶
Bases:
Exception
- __cause__¶
exception cause
- __context__¶
exception context
- __delattr__(name, /)¶
Implement delattr(self, name).
- __getattribute__(name, /)¶
Return getattr(self, name).
- __reduce__()¶
Helper for pickle.
- __repr__()¶
Return repr(self).
- __setattr__(name, value, /)¶
Implement setattr(self, name, value).
- __setstate__()¶
- __str__()¶
Return str(self).
- __suppress_context__¶
- __traceback__¶
- add_note()¶
Exception.add_note(note) – add a note to the exception
- args¶
- with_traceback()¶
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
- class fipy.Solver(tolerance=1e-10, iterations=1000, precon=None)¶
Bases:
object
The base LinearXSolver class.
Attention
This class is abstract. Always create one of its subclasses.
Create a Solver object.
- Parameters:
- __del__()¶
- __enter__()¶
- __exit__(exc_type, exc_value, traceback)¶
- __repr__()¶
Return repr(self).
- exception fipy.SolverConvergenceWarning(solver, iter, relres)¶
Bases:
Warning
- __cause__¶
exception cause
- __context__¶
exception context
- __delattr__(name, /)¶
Implement delattr(self, name).
- __getattribute__(name, /)¶
Return getattr(self, name).
- __reduce__()¶
Helper for pickle.
- __repr__()¶
Return repr(self).
- __setattr__(name, value, /)¶
Implement setattr(self, name, value).
- __setstate__()¶
- __str__()¶
Return str(self).
- __suppress_context__¶
- __traceback__¶
- add_note()¶
Exception.add_note(note) – add a note to the exception
- args¶
- with_traceback()¶
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
- fipy.SphericalGrid1D(dr=None, nr=None, Lr=None, dx=1.0, nx=None, Lx=None, origin=(0,), overlap=2, communicator=SerialPETScCommWrapper())¶
Create a 1D spherical mesh
Factory function to select between
SphericalUniformGrid1D
andSphericalNonUniformGrid1D
. If Lr is specified the length of the domain is always Lr regardless of dr, unless dr is a list of spacings, in which case Lr will be the sum of dr.- Parameters:
dr (float) – Grid spacing in the radial direction. Alternative: dx.
nr (int) – Number of cells in the radial direction. Alternative: nx.
Lr (float) – Domain length in the radial direction. Alternative: Lx.
overlap (int) – the number of overlapping cells for parallel simulations. Generally 2 is adequate. Higher order equations or discretizations require more.
communicator (CommWrapper) – MPI communicator to use. Select
serialComm
to create a serial mesh when running in parallel; mostly used for test purposes. (default:parallelComm
).
- exception fipy.StagnatedSolverWarning(solver, iter, relres)¶
Bases:
SolverConvergenceWarning
- __cause__¶
exception cause
- __context__¶
exception context
- __delattr__(name, /)¶
Implement delattr(self, name).
- __getattribute__(name, /)¶
Return getattr(self, name).
- __reduce__()¶
Helper for pickle.
- __repr__()¶
Return repr(self).
- __setattr__(name, value, /)¶
Implement setattr(self, name, value).
- __setstate__()¶
- __str__()¶
Return str(self).
- __suppress_context__¶
- __traceback__¶
- add_note()¶
Exception.add_note(note) – add a note to the exception
- args¶
- with_traceback()¶
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
- class fipy.SurfactantConvectionVariable(*args, **kwds)¶
Bases:
FaceVariable
Convection coefficient for the ConservativeSurfactantEquation. The coefficient only has a value for a negative distanceVar.
Simple one dimensional test:
>>> from fipy.variables.cellVariable import CellVariable >>> from fipy.meshes import Grid2D >>> mesh = Grid2D(nx = 3, ny = 1, dx = 1., dy = 1.) >>> from fipy.variables.distanceVariable import DistanceVariable >>> distanceVar = DistanceVariable(mesh, value = (-.5, .5, 1.5)) >>> ## answer = numerix.zeros((2, mesh.numberOfFaces),'d') >>> answer = FaceVariable(mesh=mesh, rank=1, value=0.).globalValue >>> answer[0, 7] = -1 >>> print(numerix.allclose(SurfactantConvectionVariable(distanceVar).globalValue, answer)) True
Change the dimensions:
>>> mesh = Grid2D(nx = 3, ny = 1, dx = .5, dy = .25) >>> distanceVar = DistanceVariable(mesh, value = (-.25, .25, .75)) >>> answer[0, 7] = -.5 >>> print(numerix.allclose(SurfactantConvectionVariable(distanceVar).globalValue, answer)) True
Two dimensional example:
>>> mesh = Grid2D(nx = 2, ny = 2, dx = 1., dy = 1.) >>> distanceVar = DistanceVariable(mesh, value = (-1.5, -.5, -.5, .5)) >>> answer = FaceVariable(mesh=mesh, rank=1, value=0.).globalValue >>> answer[1, 2] = -.5 >>> answer[1, 3] = -1 >>> answer[0, 7] = -.5 >>> answer[0, 10] = -1 >>> print(numerix.allclose(SurfactantConvectionVariable(distanceVar).globalValue, answer)) True
Larger grid:
>>> mesh = Grid2D(nx = 3, ny = 3, dx = 1., dy = 1.) >>> distanceVar = DistanceVariable(mesh, value = (1.5, .5, 1.5, ... .5, -.5, .5, ... 1.5, .5, 1.5)) >>> answer = FaceVariable(mesh=mesh, rank=1, value=0.).globalValue >>> answer[1, 4] = .25 >>> answer[1, 7] = -.25 >>> answer[0, 17] = .25 >>> answer[0, 18] = -.25 >>> print(numerix.allclose(SurfactantConvectionVariable(distanceVar).globalValue, answer)) True
- __abs__()¶
Following test it to fix a bug with C inline string using abs() instead of fabs()
>>> print(abs(Variable(2.3) - Variable(1.2))) 1.1
Check representation works with different versions of numpy
>>> print(repr(abs(Variable(2.3)))) numerix.fabs(Variable(value=array(2.3)))
- __add__(other)¶
- __and__(other)¶
This test case has been added due to a weird bug that was appearing.
>>> a = Variable(value=(0, 0, 1, 1)) >>> b = Variable(value=(0, 1, 0, 1)) >>> print(numerix.equal((a == 0) & (b == 1), [False, True, False, False]).all()) True >>> print(a & b) [0 0 0 1] >>> from fipy.meshes import Grid1D >>> mesh = Grid1D(nx=4) >>> from fipy.variables.cellVariable import CellVariable >>> a = CellVariable(value=(0, 0, 1, 1), mesh=mesh) >>> b = CellVariable(value=(0, 1, 0, 1), mesh=mesh) >>> print(numerix.allequal((a == 0) & (b == 1), [False, True, False, False])) True >>> print(a & b) [0 0 0 1]
- __array__(t=None)¶
Attempt to convert the Variable to a numerix array object
>>> v = Variable(value=[2, 3]) >>> print(numerix.array(v)) [2 3]
A dimensional Variable will convert to the numeric value in its base units
>>> v = Variable(value=[2, 3], unit="mm") >>> numerix.array(v) array([ 0.002, 0.003])
- __array_priority__ = 100.0¶
- __array_wrap__(arr, context=None)¶
Required to prevent numpy not calling the reverse binary operations. Both the following tests are examples ufuncs.
>>> print(type(numerix.array([1.0, 2.0]) * Variable([1.0, 2.0]))) <class 'fipy.variables.binaryOperatorVariable...binOp'>
>>> from scipy.special import gamma as Gamma >>> print(type(Gamma(Variable([1.0, 2.0])))) <class 'fipy.variables.unaryOperatorVariable...unOp'>
- __bool__()¶
>>> print(bool(Variable(value=0))) 0 >>> print(bool(Variable(value=(0, 0, 1, 1)))) Traceback (most recent call last): ... ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
- __call__()¶
“Evaluate” the Variable and return its value
>>> a = Variable(value=3) >>> print(a()) 3 >>> b = a + 4 >>> b (Variable(value=array(3)) + 4) >>> b() 7
- __div__(other)¶
- __eq__(other)¶
Test if a Variable is equal to another quantity
>>> a = Variable(value=3) >>> b = (a == 4) >>> b (Variable(value=array(3)) == 4) >>> b() 0
- __float__()¶
- __ge__(other)¶
Test if a Variable is greater than or equal to another quantity
>>> a = Variable(value=3) >>> b = (a >= 4) >>> b (Variable(value=array(3)) >= 4) >>> b() 0 >>> a.value = 4 >>> print(b()) 1 >>> a.value = 5 >>> print(b()) 1
- __getitem__(index)¶
“Evaluate” the Variable and return the specified element
>>> a = Variable(value=((3., 4.), (5., 6.)), unit="m") + "4 m" >>> print(a[1, 1]) 10.0 m
It is an error to slice a Variable whose value is not sliceable
>>> Variable(value=3)[2] Traceback (most recent call last): ... IndexError: 0-d arrays can't be indexed
- __getstate__()¶
Used internally to collect the necessary information to
pickle
the _MeshVariable to persistent storage.
- __gt__(other)¶
Test if a Variable is greater than another quantity
>>> a = Variable(value=3) >>> b = (a > 4) >>> b (Variable(value=array(3)) > 4) >>> print(b()) 0 >>> a.value = 5 >>> print(b()) 1
- __hash__()¶
Return hash(self).
- __int__()¶
- __invert__()¶
Returns logical “not” of the Variable
>>> a = Variable(value=True) >>> print(~a) False
- __iter__()¶
- __le__(other)¶
Test if a Variable is less than or equal to another quantity
>>> a = Variable(value=3) >>> b = (a <= 4) >>> b (Variable(value=array(3)) <= 4) >>> b() 1 >>> a.value = 4 >>> print(b()) 1 >>> a.value = 5 >>> print(b()) 0
- __len__()¶
- __lt__(other)¶
Test if a Variable is less than another quantity
>>> a = Variable(value=3) >>> b = (a < 4) >>> b (Variable(value=array(3)) < 4) >>> b() 1 >>> a.value = 4 >>> print(b()) 0 >>> print(1000000000000000000 * Variable(1) < 1.) 0 >>> print(1000 * Variable(1) < 1.) 0
Python automatically reverses the arguments when necessary
>>> 4 > Variable(value=3) (Variable(value=array(3)) < 4)
- __mod__(other)¶
- __mul__(other)¶
- __ne__(other)¶
Test if a Variable is not equal to another quantity
>>> a = Variable(value=3) >>> b = (a != 4) >>> b (Variable(value=array(3)) != 4) >>> b() 1
- __neg__()¶
- static __new__(cls, *args, **kwds)¶
- __nonzero__()¶
>>> print(bool(Variable(value=0))) 0 >>> print(bool(Variable(value=(0, 0, 1, 1)))) Traceback (most recent call last): ... ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
- __or__(other)¶
This test case has been added due to a weird bug that was appearing.
>>> a = Variable(value=(0, 0, 1, 1)) >>> b = Variable(value=(0, 1, 0, 1)) >>> print(numerix.equal((a == 0) | (b == 1), [True, True, False, True]).all()) True >>> print(a | b) [0 1 1 1] >>> from fipy.meshes import Grid1D >>> mesh = Grid1D(nx=4) >>> from fipy.variables.cellVariable import CellVariable >>> a = CellVariable(value=(0, 0, 1, 1), mesh=mesh) >>> b = CellVariable(value=(0, 1, 0, 1), mesh=mesh) >>> print(numerix.allequal((a == 0) | (b == 1), [True, True, False, True])) True >>> print(a | b) [0 1 1 1]
- __pos__()¶
- __pow__(other)¶
return self**other, or self raised to power other
>>> print(Variable(1, "mol/l")**3) 1.0 mol**3/l**3 >>> print((Variable(1, "mol/l")**3).unit) <PhysicalUnit mol**3/l**3>
- __radd__(other)¶
- __rdiv__(other)¶
- __repr__()¶
Return repr(self).
- __rmul__(other)¶
- __rpow__(other)¶
- __rsub__(other)¶
- __rtruediv__(other)¶
- __setitem__(index, value)¶
- __setstate__(dict)¶
Used internally to create a new Variable from
pickled
persistent storage.
- __str__()¶
Return str(self).
- __sub__(other)¶
- __truediv__(other)¶
- all(axis=None)¶
>>> print(Variable(value=(0, 0, 1, 1)).all()) 0 >>> print(Variable(value=(1, 1, 1, 1)).all()) 1
- allclose(other, rtol=1e-05, atol=1e-08)¶
>>> var = Variable((1, 1)) >>> print(var.allclose((1, 1))) 1 >>> print(var.allclose((1,))) 1
The following test is to check that the system does not run out of memory.
>>> from fipy.tools import numerix >>> var = Variable(numerix.ones(10000)) >>> print(var.allclose(numerix.zeros(10000, 'l'))) False
- allequal(other)¶
- any(axis=None)¶
>>> print(Variable(value=0).any()) 0 >>> print(Variable(value=(0, 0, 1, 1)).any()) 1
- cacheMe(recursive=False)¶
- constrain(value, where=None)¶
Constrain the Variable to have a value at an index or mask location specified by where.
>>> v = Variable((0, 1, 2, 3)) >>> v.constrain(2, numerix.array((True, False, False, False))) >>> print(v) [2 1 2 3] >>> v[:] = 10 >>> print(v) [ 2 10 10 10] >>> v.constrain(5, numerix.array((False, False, True, False))) >>> print(v) [ 2 10 5 10] >>> v[:] = 6 >>> print(v) [2 6 5 6] >>> v.constrain(8) >>> print(v) [8 8 8 8] >>> v[:] = 10 >>> print(v) [8 8 8 8] >>> del v.constraints[2] >>> print(v) [ 2 10 5 10]
>>> from fipy.variables.cellVariable import CellVariable >>> from fipy.meshes import Grid2D >>> m = Grid2D(nx=2, ny=2) >>> x, y = m.cellCenters >>> v = CellVariable(mesh=m, rank=1, value=(x, y)) >>> v.constrain(((0.,), (-1.,)), where=m.facesLeft) >>> print(v.faceValue) [[ 0.5 1.5 0.5 1.5 0.5 1.5 0. 1. 1.5 0. 1. 1.5] [ 0.5 0.5 1. 1. 1.5 1.5 -1. 0.5 0.5 -1. 1.5 1.5]]
- Parameters:
value (float or array_like) – The value of the constraint
where (array_like of
bool
) – The constraint mask or index specifying the location of the constraint
- property constraintMask¶
Test that constraintMask returns a Variable that updates itself whenever the constraints change.
>>> from fipy import *
>>> m = Grid2D(nx=2, ny=2) >>> x, y = m.cellCenters >>> v0 = CellVariable(mesh=m) >>> v0.constrain(1., where=m.facesLeft) >>> print(v0.faceValue.constraintMask) [False False False False False False True False False True False False] >>> print(v0.faceValue) [ 0. 0. 0. 0. 0. 0. 1. 0. 0. 1. 0. 0.] >>> v0.constrain(3., where=m.facesRight) >>> print(v0.faceValue.constraintMask) [False False False False False False True False True True False True] >>> print(v0.faceValue) [ 0. 0. 0. 0. 0. 0. 1. 0. 3. 1. 0. 3.] >>> v1 = CellVariable(mesh=m) >>> v1.constrain(1., where=(x < 1) & (y < 1)) >>> print(v1.constraintMask) [ True False False False] >>> print(v1) [ 1. 0. 0. 0.] >>> v1.constrain(3., where=(x > 1) & (y > 1)) >>> print(v1.constraintMask) [ True False False True] >>> print(v1) [ 1. 0. 0. 3.]
- property constraints¶
- copy()¶
Make an duplicate of the Variable
>>> a = Variable(value=3) >>> b = a.copy() >>> b Variable(value=array(3))
The duplicate will not reflect changes made to the original
>>> a.setValue(5) >>> b Variable(value=array(3))
Check that this works for arrays.
>>> a = Variable(value=numerix.array((0, 1, 2))) >>> b = a.copy() >>> b Variable(value=array([0, 1, 2])) >>> a[1] = 3 >>> b Variable(value=array([0, 1, 2]))
- property divergence¶
the divergence of self,
,
- Returns:
divergence – one rank lower than self
- Return type:
Examples
>>> from fipy.meshes import Grid2D >>> from fipy.variables.cellVariable import CellVariable >>> mesh = Grid2D(nx=3, ny=2) >>> from builtins import range >>> var = CellVariable(mesh=mesh, value=list(range(3*2))) >>> print(var.faceGrad.divergence) [ 4. 3. 2. -2. -3. -4.]
- dontCacheMe(recursive=False)¶
- dot(other, opShape=None, operatorClass=None)¶
Return the mesh-element–by–mesh-element (cell-by-cell, face-by-face, etc.) scalar product
Both self and other can be of arbitrary rank, and other does not need to be a _MeshVariable.
- getsctype(default=None)¶
Returns the Numpy sctype of the underlying array.
>>> Variable(1).getsctype() == numerix.NUMERIX.obj2sctype(numerix.array(1)) True >>> Variable(1.).getsctype() == numerix.NUMERIX.obj2sctype(numerix.array(1.)) True >>> Variable((1, 1.)).getsctype() == numerix.NUMERIX.obj2sctype(numerix.array((1., 1.))) True
- property globalValue¶
- inBaseUnits()¶
Return the value of the Variable with all units reduced to their base SI elements.
>>> e = Variable(value="2.7 Hartree*Nav") >>> print(e.inBaseUnits().allclose("7088849.01085 kg*m**2/s**2/mol")) 1
- inUnitsOf(*units)¶
Returns one or more Variable objects that express the same physical quantity in different units. The units are specified by strings containing their names. The units must be compatible with the unit of the object. If one unit is specified, the return value is a single Variable.
>>> freeze = Variable('0 degC') >>> print(freeze.inUnitsOf('degF').allclose("32.0 degF")) 1
If several units are specified, the return value is a tuple of Variable instances with with one element per unit such that the sum of all quantities in the tuple equals the the original quantity and all the values except for the last one are integers. This is used to convert to irregular unit systems like hour/minute/second. The original object will not be changed.
>>> t = Variable(value=314159., unit='s') >>> from builtins import zip >>> print(numerix.allclose([e.allclose(v) for (e, v) in zip(t.inUnitsOf('d', 'h', 'min', 's'), ... ['3.0 d', '15.0 h', '15.0 min', '59.0 s'])], ... True)) 1
- itemset(value)¶
- property itemsize¶
- max(axis=None)¶
- min(axis=None)¶
>>> from fipy import Grid2D, CellVariable >>> mesh = Grid2D(nx=5, ny=5) >>> x, y = mesh.cellCenters >>> v = CellVariable(mesh=mesh, value=x*y) >>> print(v.min()) 0.25
- property name¶
- property numericValue¶
- put(indices, value)¶
- property rank¶
- ravel()¶
- rdot(other, opShape=None, operatorClass=None)¶
Return the mesh-element–by–mesh-element (cell-by-cell, face-by-face, etc.) scalar product
Both self and other can be of arbitrary rank, and other does not need to be a _MeshVariable.
- release(constraint)¶
Remove constraint from self
>>> v = Variable((0, 1, 2, 3)) >>> v.constrain(2, numerix.array((True, False, False, False))) >>> v[:] = 10 >>> from fipy.boundaryConditions.constraint import Constraint >>> c1 = Constraint(5, numerix.array((False, False, True, False))) >>> v.constrain(c1) >>> v[:] = 6 >>> v.constrain(8) >>> v[:] = 10 >>> del v.constraints[2] >>> v.release(constraint=c1) >>> print(v) [ 2 10 10 10]
- setValue(value, unit=None, where=None)¶
Set the value of the Variable. Can take a masked array.
>>> a = Variable((1, 2, 3)) >>> a.setValue(5, where=(1, 0, 1)) >>> print(a) [5 2 5]
>>> b = Variable((4, 5, 6)) >>> a.setValue(b, where=(1, 0, 1)) >>> print(a) [4 2 6] >>> print(b) [4 5 6] >>> a.value = 3 >>> print(a) [3 3 3]
>>> b = numerix.array((3, 4, 5)) >>> a.value = b >>> a[:] = 1 >>> print(b) [3 4 5]
>>> a.setValue((4, 5, 6), where=(1, 0)) Traceback (most recent call last): .... ValueError: shape mismatch: objects cannot be broadcast to a single shape
- property shape¶
>>> from fipy.meshes import Grid2D >>> from fipy.variables.cellVariable import CellVariable >>> mesh = Grid2D(nx=2, ny=3) >>> var = CellVariable(mesh=mesh) >>> print(numerix.allequal(var.shape, (6,))) True >>> print(numerix.allequal(var.arithmeticFaceValue.shape, (17,))) True >>> print(numerix.allequal(var.grad.shape, (2, 6))) True >>> print(numerix.allequal(var.faceGrad.shape, (2, 17))) True
Have to account for zero length arrays
>>> from fipy import Grid1D >>> m = Grid1D(nx=0) >>> v = CellVariable(mesh=m, elementshape=(2,)) >>> numerix.allequal((v * 1).shape, (2, 0)) True
- std(axis=None, **kwargs)¶
Evaluate standard deviation of all the elements of a MeshVariable.
Adapted from http://mpitutorial.com/tutorials/mpi-reduce-and-allreduce/
>>> import fipy as fp >>> mesh = fp.Grid2D(nx=2, ny=2, dx=2., dy=5.) >>> var = fp.CellVariable(value=(1., 2., 3., 4.), mesh=mesh) >>> print((var.std()**2).allclose(1.25)) True
- property subscribedVariables¶
- sum(axis=None)¶
- take(ids, axis=0)¶
- tostring(max_line_width=75, precision=8, suppress_small=False, separator=' ')¶
- property unit¶
Return the unit object of self.
>>> Variable(value="1 m").unit <PhysicalUnit m>
- property value¶
“Evaluate” the Variable and return its value (longhand)
>>> a = Variable(value=3) >>> print(a.value) 3 >>> b = a + 4 >>> b (Variable(value=array(3)) + 4) >>> b.value 7
- class fipy.SurfactantVariable(*args, **kwds)¶
Bases:
CellVariable
The SurfactantVariable maintains a conserved volumetric concentration on cells adjacent to, but in front of, the interface. The value argument corresponds to the initial concentration of surfactant on the interface (moles divided by area). The value held by the SurfactantVariable is actually a volume density (moles divided by volume).
A simple 1D test:
>>> from fipy.meshes import Grid1D >>> mesh = Grid1D(dx = 1., nx = 4) >>> from fipy.variables.distanceVariable import DistanceVariable >>> distanceVariable = DistanceVariable(mesh = mesh, ... value = (-1.5, -0.5, 0.5, 941.5)) >>> surfactantVariable = SurfactantVariable(value = 1, ... distanceVar = distanceVariable) >>> print(numerix.allclose(surfactantVariable, (0, 0., 1., 0))) 1
A 2D test case:
>>> from fipy.meshes import Grid2D >>> mesh = Grid2D(dx = 1., dy = 1., nx = 3, ny = 3) >>> distanceVariable = DistanceVariable(mesh = mesh, ... value = (1.5, 0.5, 1.5, ... 0.5, -0.5, 0.5, ... 1.5, 0.5, 1.5)) >>> surfactantVariable = SurfactantVariable(value = 1, ... distanceVar = distanceVariable) >>> print(numerix.allclose(surfactantVariable, (0, 1, 0, 1, 0, 1, 0, 1, 0))) 1
Another 2D test case:
>>> mesh = Grid2D(dx = .5, dy = .5, nx = 2, ny = 2) >>> distanceVariable = DistanceVariable(mesh = mesh, ... value = (-0.5, 0.5, 0.5, 1.5)) >>> surfactantVariable = SurfactantVariable(value = 1, ... distanceVar = distanceVariable) >>> print(numerix.allclose(surfactantVariable, ... (0, numerix.sqrt(2), numerix.sqrt(2), 0))) 1
- Parameters:
value (float or array_like) – The initial value.
distanceVar (DistanceVariable) –
name (str) – The name of the variable.
- __abs__()¶
Following test it to fix a bug with C inline string using abs() instead of fabs()
>>> print(abs(Variable(2.3) - Variable(1.2))) 1.1
Check representation works with different versions of numpy
>>> print(repr(abs(Variable(2.3)))) numerix.fabs(Variable(value=array(2.3)))
- __add__(other)¶
- __and__(other)¶
This test case has been added due to a weird bug that was appearing.
>>> a = Variable(value=(0, 0, 1, 1)) >>> b = Variable(value=(0, 1, 0, 1)) >>> print(numerix.equal((a == 0) & (b == 1), [False, True, False, False]).all()) True >>> print(a & b) [0 0 0 1] >>> from fipy.meshes import Grid1D >>> mesh = Grid1D(nx=4) >>> from fipy.variables.cellVariable import CellVariable >>> a = CellVariable(value=(0, 0, 1, 1), mesh=mesh) >>> b = CellVariable(value=(0, 1, 0, 1), mesh=mesh) >>> print(numerix.allequal((a == 0) & (b == 1), [False, True, False, False])) True >>> print(a & b) [0 0 0 1]
- __array__(t=None)¶
Attempt to convert the Variable to a numerix array object
>>> v = Variable(value=[2, 3]) >>> print(numerix.array(v)) [2 3]
A dimensional Variable will convert to the numeric value in its base units
>>> v = Variable(value=[2, 3], unit="mm") >>> numerix.array(v) array([ 0.002, 0.003])
- __array_priority__ = 100.0¶
- __array_wrap__(arr, context=None)¶
Required to prevent numpy not calling the reverse binary operations. Both the following tests are examples ufuncs.
>>> print(type(numerix.array([1.0, 2.0]) * Variable([1.0, 2.0]))) <class 'fipy.variables.binaryOperatorVariable...binOp'>
>>> from scipy.special import gamma as Gamma >>> print(type(Gamma(Variable([1.0, 2.0])))) <class 'fipy.variables.unaryOperatorVariable...unOp'>
- __bool__()¶
>>> print(bool(Variable(value=0))) 0 >>> print(bool(Variable(value=(0, 0, 1, 1)))) Traceback (most recent call last): ... ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
- __call__(points=None, order=0, nearestCellIDs=None)¶
Interpolates the CellVariable to a set of points using a method that has a memory requirement on the order of Ncells by Npoints in general, but uses only Ncells when the CellVariable’s mesh is a UniformGrid object.
Tests
>>> from fipy import * >>> m = Grid2D(nx=3, ny=2) >>> v = CellVariable(mesh=m, value=m.cellCenters[0]) >>> print(v(((0., 1.1, 1.2), (0., 1., 1.)))) [ 0.5 1.5 1.5] >>> print(v(((0., 1.1, 1.2), (0., 1., 1.)), order=1)) [ 0.25 1.1 1.2 ] >>> m0 = Grid2D(nx=2, ny=2, dx=1., dy=1.) >>> m1 = Grid2D(nx=4, ny=4, dx=.5, dy=.5) >>> x, y = m0.cellCenters >>> v0 = CellVariable(mesh=m0, value=x * y) >>> print(v0(m1.cellCenters.globalValue)) [ 0.25 0.25 0.75 0.75 0.25 0.25 0.75 0.75 0.75 0.75 2.25 2.25 0.75 0.75 2.25 2.25] >>> print(v0(m1.cellCenters.globalValue, order=1)) [ 0.125 0.25 0.5 0.625 0.25 0.375 0.875 1. 0.5 0.875 1.875 2.25 0.625 1. 2.25 2.625]
- __div__(other)¶
- __eq__(other)¶
Test if a Variable is equal to another quantity
>>> a = Variable(value=3) >>> b = (a == 4) >>> b (Variable(value=array(3)) == 4) >>> b() 0
- __float__()¶
- __ge__(other)¶
Test if a Variable is greater than or equal to another quantity
>>> a = Variable(value=3) >>> b = (a >= 4) >>> b (Variable(value=array(3)) >= 4) >>> b() 0 >>> a.value = 4 >>> print(b()) 1 >>> a.value = 5 >>> print(b()) 1
- __getitem__(index)¶
“Evaluate” the Variable and return the specified element
>>> a = Variable(value=((3., 4.), (5., 6.)), unit="m") + "4 m" >>> print(a[1, 1]) 10.0 m
It is an error to slice a Variable whose value is not sliceable
>>> Variable(value=3)[2] Traceback (most recent call last): ... IndexError: 0-d arrays can't be indexed
- __getstate__()¶
Used internally to collect the necessary information to
pickle
the CellVariable to persistent storage.
- __gt__(other)¶
Test if a Variable is greater than another quantity
>>> a = Variable(value=3) >>> b = (a > 4) >>> b (Variable(value=array(3)) > 4) >>> print(b()) 0 >>> a.value = 5 >>> print(b()) 1
- __hash__()¶
Return hash(self).
- __int__()¶
- __invert__()¶
Returns logical “not” of the Variable
>>> a = Variable(value=True) >>> print(~a) False
- __iter__()¶
- __le__(other)¶
Test if a Variable is less than or equal to another quantity
>>> a = Variable(value=3) >>> b = (a <= 4) >>> b (Variable(value=array(3)) <= 4) >>> b() 1 >>> a.value = 4 >>> print(b()) 1 >>> a.value = 5 >>> print(b()) 0
- __len__()¶
- __lt__(other)¶
Test if a Variable is less than another quantity
>>> a = Variable(value=3) >>> b = (a < 4) >>> b (Variable(value=array(3)) < 4) >>> b() 1 >>> a.value = 4 >>> print(b()) 0 >>> print(1000000000000000000 * Variable(1) < 1.) 0 >>> print(1000 * Variable(1) < 1.) 0
Python automatically reverses the arguments when necessary
>>> 4 > Variable(value=3) (Variable(value=array(3)) < 4)
- __mod__(other)¶
- __mul__(other)¶
- __ne__(other)¶
Test if a Variable is not equal to another quantity
>>> a = Variable(value=3) >>> b = (a != 4) >>> b (Variable(value=array(3)) != 4) >>> b() 1
- __neg__()¶
- static __new__(cls, *args, **kwds)¶
- __nonzero__()¶
>>> print(bool(Variable(value=0))) 0 >>> print(bool(Variable(value=(0, 0, 1, 1)))) Traceback (most recent call last): ... ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
- __or__(other)¶
This test case has been added due to a weird bug that was appearing.
>>> a = Variable(value=(0, 0, 1, 1)) >>> b = Variable(value=(0, 1, 0, 1)) >>> print(numerix.equal((a == 0) | (b == 1), [True, True, False, True]).all()) True >>> print(a | b) [0 1 1 1] >>> from fipy.meshes import Grid1D >>> mesh = Grid1D(nx=4) >>> from fipy.variables.cellVariable import CellVariable >>> a = CellVariable(value=(0, 0, 1, 1), mesh=mesh) >>> b = CellVariable(value=(0, 1, 0, 1), mesh=mesh) >>> print(numerix.allequal((a == 0) | (b == 1), [True, True, False, True])) True >>> print(a | b) [0 1 1 1]
- __pos__()¶
- __pow__(other)¶
return self**other, or self raised to power other
>>> print(Variable(1, "mol/l")**3) 1.0 mol**3/l**3 >>> print((Variable(1, "mol/l")**3).unit) <PhysicalUnit mol**3/l**3>
- __radd__(other)¶
- __rdiv__(other)¶
- __repr__()¶
Return repr(self).
- __rmul__(other)¶
- __rpow__(other)¶
- __rsub__(other)¶
- __rtruediv__(other)¶
- __setitem__(index, value)¶
- __setstate__(dict)¶
Used internally to create a new CellVariable from
pickled
persistent storage.
- __str__()¶
Return str(self).
- __sub__(other)¶
- __truediv__(other)¶
- all(axis=None)¶
>>> print(Variable(value=(0, 0, 1, 1)).all()) 0 >>> print(Variable(value=(1, 1, 1, 1)).all()) 1
- allclose(other, rtol=1e-05, atol=1e-08)¶
>>> var = Variable((1, 1)) >>> print(var.allclose((1, 1))) 1 >>> print(var.allclose((1,))) 1
The following test is to check that the system does not run out of memory.
>>> from fipy.tools import numerix >>> var = Variable(numerix.ones(10000)) >>> print(var.allclose(numerix.zeros(10000, 'l'))) False
- allequal(other)¶
- any(axis=None)¶
>>> print(Variable(value=0).any()) 0 >>> print(Variable(value=(0, 0, 1, 1)).any()) 1
- property arithmeticFaceValue¶
Returns a FaceVariable whose value corresponds to the arithmetic interpolation of the adjacent cells:
>>> from fipy.meshes import Grid1D >>> from fipy import numerix >>> mesh = Grid1D(dx = (1., 1.)) >>> L = 1 >>> R = 2 >>> var = CellVariable(mesh = mesh, value = (L, R)) >>> faceValue = var.arithmeticFaceValue[mesh.interiorFaces.value] >>> answer = (R - L) * (0.5 / 1.) + L >>> print(numerix.allclose(faceValue, answer, atol = 1e-10, rtol = 1e-10)) True
>>> mesh = Grid1D(dx = (2., 4.)) >>> var = CellVariable(mesh = mesh, value = (L, R)) >>> faceValue = var.arithmeticFaceValue[mesh.interiorFaces.value] >>> answer = (R - L) * (1.0 / 3.0) + L >>> print(numerix.allclose(faceValue, answer, atol = 1e-10, rtol = 1e-10)) True
>>> mesh = Grid1D(dx = (10., 100.)) >>> var = CellVariable(mesh = mesh, value = (L, R)) >>> faceValue = var.arithmeticFaceValue[mesh.interiorFaces.value] >>> answer = (R - L) * (5.0 / 55.0) + L >>> print(numerix.allclose(faceValue, answer, atol = 1e-10, rtol = 1e-10)) True
- cacheMe(recursive=False)¶
- property cellVolumeAverage¶
Return the cell-volume-weighted average of the CellVariable:
>>> from fipy.meshes import Grid2D >>> from fipy.variables.cellVariable import CellVariable >>> mesh = Grid2D(nx = 3, ny = 1, dx = .5, dy = .1) >>> var = CellVariable(value = (1, 2, 6), mesh = mesh) >>> print(var.cellVolumeAverage) 3.0
- constrain(value, where=None)¶
Constrains the CellVariable to value at a location specified by where.
>>> from fipy import * >>> m = Grid1D(nx=3) >>> v = CellVariable(mesh=m, value=m.cellCenters[0]) >>> v.constrain(0., where=m.facesLeft) >>> v.faceGrad.constrain([1.], where=m.facesRight) >>> print(v.faceGrad) [[ 1. 1. 1. 1.]] >>> print(v.faceValue) [ 0. 1. 2. 2.5]
Changing the constraint changes the dependencies
>>> v.constrain(1., where=m.facesLeft) >>> print(v.faceGrad) [[-1. 1. 1. 1.]] >>> print(v.faceValue) [ 1. 1. 2. 2.5]
Constraints can be Variable
>>> c = Variable(0.) >>> v.constrain(c, where=m.facesLeft) >>> print(v.faceGrad) [[ 1. 1. 1. 1.]] >>> print(v.faceValue) [ 0. 1. 2. 2.5] >>> c.value = 1. >>> print(v.faceGrad) [[-1. 1. 1. 1.]] >>> print(v.faceValue) [ 1. 1. 2. 2.5]
Constraints can have a Variable mask.
>>> v = CellVariable(mesh=m) >>> mask = FaceVariable(mesh=m, value=m.facesLeft) >>> v.constrain(1., where=mask) >>> print(v.faceValue) [ 1. 0. 0. 0.] >>> mask[:] = mask | m.facesRight >>> print(v.faceValue) [ 1. 0. 0. 1.]
- property constraintMask¶
Test that constraintMask returns a Variable that updates itself whenever the constraints change.
>>> from fipy import *
>>> m = Grid2D(nx=2, ny=2) >>> x, y = m.cellCenters >>> v0 = CellVariable(mesh=m) >>> v0.constrain(1., where=m.facesLeft) >>> print(v0.faceValue.constraintMask) [False False False False False False True False False True False False] >>> print(v0.faceValue) [ 0. 0. 0. 0. 0. 0. 1. 0. 0. 1. 0. 0.] >>> v0.constrain(3., where=m.facesRight) >>> print(v0.faceValue.constraintMask) [False False False False False False True False True True False True] >>> print(v0.faceValue) [ 0. 0. 0. 0. 0. 0. 1. 0. 3. 1. 0. 3.] >>> v1 = CellVariable(mesh=m) >>> v1.constrain(1., where=(x < 1) & (y < 1)) >>> print(v1.constraintMask) [ True False False False] >>> print(v1) [ 1. 0. 0. 0.] >>> v1.constrain(3., where=(x > 1) & (y > 1)) >>> print(v1.constraintMask) [ True False False True] >>> print(v1) [ 1. 0. 0. 3.]
- property constraints¶
- copy()¶
Make an duplicate of the Variable
>>> a = Variable(value=3) >>> b = a.copy() >>> b Variable(value=array(3))
The duplicate will not reflect changes made to the original
>>> a.setValue(5) >>> b Variable(value=array(3))
Check that this works for arrays.
>>> a = Variable(value=numerix.array((0, 1, 2))) >>> b = a.copy() >>> b Variable(value=array([0, 1, 2])) >>> a[1] = 3 >>> b Variable(value=array([0, 1, 2]))
- dontCacheMe(recursive=False)¶
- dot(other, opShape=None, operatorClass=None)¶
Return the mesh-element–by–mesh-element (cell-by-cell, face-by-face, etc.) scalar product
Both self and other can be of arbitrary rank, and other does not need to be a _MeshVariable.
- property faceGrad¶
Return
as a rank-1 FaceVariable using differencing for the normal direction(second-order gradient).
- property faceGradAverage¶
Deprecated since version 3.3: use
grad.arithmeticFaceValue()
insteadReturn
as a rank-1 FaceVariable using averaging for the normal direction(second-order gradient)
- property faceValue¶
Returns a FaceVariable whose value corresponds to the arithmetic interpolation of the adjacent cells:
>>> from fipy.meshes import Grid1D >>> from fipy import numerix >>> mesh = Grid1D(dx = (1., 1.)) >>> L = 1 >>> R = 2 >>> var = CellVariable(mesh = mesh, value = (L, R)) >>> faceValue = var.arithmeticFaceValue[mesh.interiorFaces.value] >>> answer = (R - L) * (0.5 / 1.) + L >>> print(numerix.allclose(faceValue, answer, atol = 1e-10, rtol = 1e-10)) True
>>> mesh = Grid1D(dx = (2., 4.)) >>> var = CellVariable(mesh = mesh, value = (L, R)) >>> faceValue = var.arithmeticFaceValue[mesh.interiorFaces.value] >>> answer = (R - L) * (1.0 / 3.0) + L >>> print(numerix.allclose(faceValue, answer, atol = 1e-10, rtol = 1e-10)) True
>>> mesh = Grid1D(dx = (10., 100.)) >>> var = CellVariable(mesh = mesh, value = (L, R)) >>> faceValue = var.arithmeticFaceValue[mesh.interiorFaces.value] >>> answer = (R - L) * (5.0 / 55.0) + L >>> print(numerix.allclose(faceValue, answer, atol = 1e-10, rtol = 1e-10)) True
- property gaussGrad¶
Return
as a rank-1 CellVariable (first-order gradient).
- getsctype(default=None)¶
Returns the Numpy sctype of the underlying array.
>>> Variable(1).getsctype() == numerix.NUMERIX.obj2sctype(numerix.array(1)) True >>> Variable(1.).getsctype() == numerix.NUMERIX.obj2sctype(numerix.array(1.)) True >>> Variable((1, 1.)).getsctype() == numerix.NUMERIX.obj2sctype(numerix.array((1., 1.))) True
- property globalValue¶
Concatenate and return values from all processors
When running on a single processor, the result is identical to
value
.
- property grad¶
Return
as a rank-1 CellVariable (first-order gradient).
- property harmonicFaceValue¶
Returns a FaceVariable whose value corresponds to the harmonic interpolation of the adjacent cells:
>>> from fipy.meshes import Grid1D >>> from fipy import numerix >>> mesh = Grid1D(dx = (1., 1.)) >>> L = 1 >>> R = 2 >>> var = CellVariable(mesh = mesh, value = (L, R)) >>> faceValue = var.harmonicFaceValue[mesh.interiorFaces.value] >>> answer = L * R / ((R - L) * (0.5 / 1.) + L) >>> print(numerix.allclose(faceValue, answer, atol = 1e-10, rtol = 1e-10)) True
>>> mesh = Grid1D(dx = (2., 4.)) >>> var = CellVariable(mesh = mesh, value = (L, R)) >>> faceValue = var.harmonicFaceValue[mesh.interiorFaces.value] >>> answer = L * R / ((R - L) * (1.0 / 3.0) + L) >>> print(numerix.allclose(faceValue, answer, atol = 1e-10, rtol = 1e-10)) True
>>> mesh = Grid1D(dx = (10., 100.)) >>> var = CellVariable(mesh = mesh, value = (L, R)) >>> faceValue = var.harmonicFaceValue[mesh.interiorFaces.value] >>> answer = L * R / ((R - L) * (5.0 / 55.0) + L) >>> print(numerix.allclose(faceValue, answer, atol = 1e-10, rtol = 1e-10)) True
- inBaseUnits()¶
Return the value of the Variable with all units reduced to their base SI elements.
>>> e = Variable(value="2.7 Hartree*Nav") >>> print(e.inBaseUnits().allclose("7088849.01085 kg*m**2/s**2/mol")) 1
- inUnitsOf(*units)¶
Returns one or more Variable objects that express the same physical quantity in different units. The units are specified by strings containing their names. The units must be compatible with the unit of the object. If one unit is specified, the return value is a single Variable.
>>> freeze = Variable('0 degC') >>> print(freeze.inUnitsOf('degF').allclose("32.0 degF")) 1
If several units are specified, the return value is a tuple of Variable instances with with one element per unit such that the sum of all quantities in the tuple equals the the original quantity and all the values except for the last one are integers. This is used to convert to irregular unit systems like hour/minute/second. The original object will not be changed.
>>> t = Variable(value=314159., unit='s') >>> from builtins import zip >>> print(numerix.allclose([e.allclose(v) for (e, v) in zip(t.inUnitsOf('d', 'h', 'min', 's'), ... ['3.0 d', '15.0 h', '15.0 min', '59.0 s'])], ... True)) 1
- property interfaceVar¶
Returns the SurfactantVariable rendered as an _InterfaceSurfactantVariable which evaluates the surfactant concentration as an area concentration the interface rather than a volumetric concentration.
- itemset(value)¶
- property itemsize¶
- property leastSquaresGrad¶
Return
, which is determined by solving for
in the following matrix equation,
The matrix equation is derived by minimizing the following least squares sum,
Tests
>>> from fipy import Grid2D >>> m = Grid2D(nx=2, ny=2, dx=0.1, dy=2.0) >>> print(numerix.allclose(CellVariable(mesh=m, value=(0, 1, 3, 6)).leastSquaresGrad.globalValue, \ ... [[8.0, 8.0, 24.0, 24.0], ... [1.2, 2.0, 1.2, 2.0]])) True
>>> from fipy import Grid1D >>> print(numerix.allclose(CellVariable(mesh=Grid1D(dx=(2.0, 1.0, 0.5)), ... value=(0, 1, 2)).leastSquaresGrad.globalValue, [[0.461538461538, 0.8, 1.2]])) True
- max(axis=None)¶
- min(axis=None)¶
>>> from fipy import Grid2D, CellVariable >>> mesh = Grid2D(nx=5, ny=5) >>> x, y = mesh.cellCenters >>> v = CellVariable(mesh=mesh, value=x*y) >>> print(v.min()) 0.25
- property minmodFaceValue¶
Returns a FaceVariable with a value that is the minimum of the absolute values of the adjacent cells. If the values are of opposite sign then the result is zero:
>>> from fipy import * >>> print(CellVariable(mesh=Grid1D(nx=2), value=(1, 2)).minmodFaceValue) [1 1 2] >>> print(CellVariable(mesh=Grid1D(nx=2), value=(-1, -2)).minmodFaceValue) [-1 -1 -2] >>> print(CellVariable(mesh=Grid1D(nx=2), value=(-1, 2)).minmodFaceValue) [-1 0 2]
- property name¶
- property numericValue¶
- property old¶
Return the values of the CellVariable from the previous solution sweep.
Combinations of CellVariable’s should also return old values.
>>> from fipy.meshes import Grid1D >>> mesh = Grid1D(nx = 2) >>> from fipy.variables.cellVariable import CellVariable >>> var1 = CellVariable(mesh = mesh, value = (2, 3), hasOld = 1) >>> var2 = CellVariable(mesh = mesh, value = (3, 4)) >>> v = var1 * var2 >>> print(v) [ 6 12] >>> var1.value = ((3, 2)) >>> print(v) [9 8] >>> print(v.old) [ 6 12]
The following small test is to correct for a bug when the operator does not just use variables.
>>> v1 = var1 * 3 >>> print(v1) [9 6] >>> print(v1.old) [6 9]
- put(indices, value)¶
- property rank¶
- ravel()¶
- rdot(other, opShape=None, operatorClass=None)¶
Return the mesh-element–by–mesh-element (cell-by-cell, face-by-face, etc.) scalar product
Both self and other can be of arbitrary rank, and other does not need to be a _MeshVariable.
- release(constraint)¶
Remove constraint from self
>>> from fipy import * >>> m = Grid1D(nx=3) >>> v = CellVariable(mesh=m, value=m.cellCenters[0]) >>> c = Constraint(0., where=m.facesLeft) >>> v.constrain(c) >>> print(v.faceValue) [ 0. 1. 2. 2.5] >>> v.release(constraint=c) >>> print(v.faceValue) [ 0.5 1. 2. 2.5]
- setValue(value, unit=None, where=None)¶
Set the value of the Variable. Can take a masked array.
>>> a = Variable((1, 2, 3)) >>> a.setValue(5, where=(1, 0, 1)) >>> print(a) [5 2 5]
>>> b = Variable((4, 5, 6)) >>> a.setValue(b, where=(1, 0, 1)) >>> print(a) [4 2 6] >>> print(b) [4 5 6] >>> a.value = 3 >>> print(a) [3 3 3]
>>> b = numerix.array((3, 4, 5)) >>> a.value = b >>> a[:] = 1 >>> print(b) [3 4 5]
>>> a.setValue((4, 5, 6), where=(1, 0)) Traceback (most recent call last): .... ValueError: shape mismatch: objects cannot be broadcast to a single shape
- property shape¶
>>> from fipy.meshes import Grid2D >>> from fipy.variables.cellVariable import CellVariable >>> mesh = Grid2D(nx=2, ny=3) >>> var = CellVariable(mesh=mesh) >>> print(numerix.allequal(var.shape, (6,))) True >>> print(numerix.allequal(var.arithmeticFaceValue.shape, (17,))) True >>> print(numerix.allequal(var.grad.shape, (2, 6))) True >>> print(numerix.allequal(var.faceGrad.shape, (2, 17))) True
Have to account for zero length arrays
>>> from fipy import Grid1D >>> m = Grid1D(nx=0) >>> v = CellVariable(mesh=m, elementshape=(2,)) >>> numerix.allequal((v * 1).shape, (2, 0)) True
- std(axis=None, **kwargs)¶
Evaluate standard deviation of all the elements of a MeshVariable.
Adapted from http://mpitutorial.com/tutorials/mpi-reduce-and-allreduce/
>>> import fipy as fp >>> mesh = fp.Grid2D(nx=2, ny=2, dx=2., dy=5.) >>> var = fp.CellVariable(value=(1., 2., 3., 4.), mesh=mesh) >>> print((var.std()**2).allclose(1.25)) True
- property subscribedVariables¶
- sum(axis=None)¶
- take(ids, axis=0)¶
- tostring(max_line_width=75, precision=8, suppress_small=False, separator=' ')¶
- property unit¶
Return the unit object of self.
>>> Variable(value="1 m").unit <PhysicalUnit m>
- updateOld()¶
Set the values of the previous solution sweep to the current values.
>>> from fipy import * >>> v = CellVariable(mesh=Grid1D(), hasOld=False) >>> v.updateOld() Traceback (most recent call last): ... AssertionError: The updateOld method requires the CellVariable to have an old value. Set hasOld to True when instantiating the CellVariable.
- property value¶
“Evaluate” the Variable and return its value (longhand)
>>> a = Variable(value=3) >>> print(a.value) 3 >>> b = a + 4 >>> b (Variable(value=array(3)) + 4) >>> b.value 7
- class fipy.TSVViewer(vars, title=None, limits={}, **kwlimits)¶
Bases:
AbstractViewer
“Views” one or more variables in tab-separated-value format.
Output is a list of coordinates and variable values at each cell center.
File contents will be, e.g.:
title x y ... var0 var2 ... 0.0 0.0 ... 3.14 1.41 ... 1.0 0.0 ... 2.72 0.866 ... : :
Creates a TSVViewer.
Any cell centers that lie outside the limits provided will not be included. Any values that lie outside the datamin or datamax will be replaced with nan.
All variables must have the same mesh.
It tries to do something reasonable with rank-1 CellVariable and FaceVariable objects.
- Parameters:
vars (CellVariable or FaceVariable or list) – the MeshVariable objects to display.
title (str, optional) – displayed at the top of the Viewer window
limits (dict, optional) – a (deprecated) alternative to limit keyword arguments
xmin (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.
xmax (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.
ymin (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.
ymax (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.
zmin (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.
zmax (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.
datamin (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.
datamax (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.
- property limits¶
- plot(filename=None)¶
“plot” the coordinates and values of the variables to filename. If filename is not provided, “plots” to stdout.
>>> from fipy.meshes import Grid1D >>> m = Grid1D(nx = 3, dx = 0.4) >>> from fipy.variables.cellVariable import CellVariable >>> v = CellVariable(mesh = m, name = "var", value = (0, 2, 5)) >>> TSVViewer(vars = (v, v.grad)).plot() x var var_gauss_grad_x 0.2 0 2.5 0.6 2 6.25 1 5 3.75
>>> from fipy.meshes import Grid2D >>> m = Grid2D(nx = 2, dx = .1, ny = 2, dy = 0.3) >>> v = CellVariable(mesh = m, name = "var", value = (0, 2, -2, 5)) >>> TSVViewer(vars = (v, v.grad)).plot() x y var var_gauss_grad_x var_gauss_grad_y 0.05 0.15 0 10 -3.33333333333333 0.15 0.15 2 10 5 0.05 0.45 -2 35 -3.33333333333333 0.15 0.45 5 35 5
- Parameters:
filename (str) – If not None, the name of a file to save the image into.
- plotMesh(filename=None)¶
Display a representation of the mesh
- Parameters:
filename (str) – If not None, the name of a file to save the image into.
- setLimits(limits={}, **kwlimits)¶
Update the limits.
- Parameters:
limits (dict, optional) – a (deprecated) alternative to limit keyword arguments
xmin (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
xmax (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
ymin (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
ymax (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
zmin (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
zmax (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
datamin (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
datamax (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
- property title¶
The text appearing at the top center.
(default: if
len(self.vars) == 1
, the name ofself.vars[0]
, otherwise""
.)
- exception fipy.TermMultiplyError(s='Must multiply terms by int or float.')¶
Bases:
Exception
- __cause__¶
exception cause
- __context__¶
exception context
- __delattr__(name, /)¶
Implement delattr(self, name).
- __getattribute__(name, /)¶
Return getattr(self, name).
- __reduce__()¶
Helper for pickle.
- __repr__()¶
Return repr(self).
- __setattr__(name, value, /)¶
Implement setattr(self, name, value).
- __setstate__()¶
- __str__()¶
Return str(self).
- __suppress_context__¶
- __traceback__¶
- add_note()¶
Exception.add_note(note) – add a note to the exception
- args¶
- with_traceback()¶
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
- class fipy.TransientTerm(coeff=1.0, var=None)¶
Bases:
CellTerm
The TransientTerm represents
where
is the coeff value.
The following test case verifies that variable coefficients and old coefficient values work correctly. We will solve the following equation
The analytic solution is given by
where
is the initial value.
>>> phi0 = 1. >>> k = 1. >>> dt = 1. >>> relaxationFactor = 1.5 >>> steps = 2 >>> sweeps = 8
>>> from fipy.meshes import Grid1D >>> mesh = Grid1D(nx = 1) >>> from fipy.variables.cellVariable import CellVariable >>> var = CellVariable(mesh = mesh, value = phi0, hasOld = 1) >>> from fipy.terms.transientTerm import TransientTerm >>> from fipy.terms.implicitSourceTerm import ImplicitSourceTerm
Relaxation, given by relaxationFactor, is required for a converged solution.
>>> eq = TransientTerm(var) == ImplicitSourceTerm(-relaxationFactor) \ ... + var * relaxationFactor + k
A number of sweeps at each time step are required to let the relaxation take effect.
>>> from builtins import range >>> for step in range(steps): ... var.updateOld() ... for sweep in range(sweeps): ... eq.solve(var, dt = dt)
Compare the final result with the analytical solution.
>>> from fipy.tools import numerix >>> print(var.allclose(numerix.sqrt(k * dt * steps + phi0**2))) 1
Create a Term.
- Parameters:
coeff (float or CellVariable or FaceVariable) – Coefficient for the term. FaceVariable objects are only acceptable for diffusion or convection terms.
- property RHSvector¶
Return the RHS vector calculated in solve() or sweep(). The cacheRHSvector() method should be called before solve() or sweep() to cache the vector.
- __add__(other)¶
- __and__(other)¶
- __div__(other)¶
- __eq__(other)¶
Return self==value.
- __hash__()¶
Return hash(self).
- __mul__(other)¶
Multiply a term
>>> 2. * __NonDiffusionTerm(coeff=0.5) __NonDiffusionTerm(coeff=1.0)
Test for ticket:291.
>>> from fipy import PowerLawConvectionTerm >>> PowerLawConvectionTerm(coeff=[[1], [0]]) * 1.0 PowerLawConvectionTerm(coeff=array([[ 1.], [ 0.]]))
- __neg__()¶
Negate a Term.
>>> -__NonDiffusionTerm(coeff=1.) __NonDiffusionTerm(coeff=-1.0)
- __pos__()¶
- __radd__(other)¶
- __rand__(other)¶
- __repr__()¶
The representation of a Term object is given by,
>>> print(__UnaryTerm(123.456)) __UnaryTerm(coeff=123.456)
- __rmul__(other)¶
Multiply a term
>>> 2. * __NonDiffusionTerm(coeff=0.5) __NonDiffusionTerm(coeff=1.0)
Test for ticket:291.
>>> from fipy import PowerLawConvectionTerm >>> PowerLawConvectionTerm(coeff=[[1], [0]]) * 1.0 PowerLawConvectionTerm(coeff=array([[ 1.], [ 0.]]))
- __rsub__(other)¶
- __sub__(other)¶
- __truediv__(other)¶
- cacheMatrix()¶
Informs solve() and sweep() to cache their matrix so that matrix can return the matrix.
- cacheRHSvector()¶
Informs solve() and sweep() to cache their right hand side vector so that getRHSvector() can return it.
- copy()¶
- getDefaultSolver(var=None, solver=None, *args, **kwargs)¶
- justErrorVector(var=None, solver=None, boundaryConditions=(), dt=1.0, underRelaxation=None, residualFn=None)¶
Builds the Term’s linear system once.
This method also recalculates and returns the error as well as applying under-relaxation.
justErrorVector returns the overlapping local value in parallel (not the non-overlapping value).
>>> from fipy.solvers import DummySolver >>> from fipy import * >>> m = Grid1D(nx=10) >>> v = CellVariable(mesh=m) >>> len(DiffusionTerm().justErrorVector(v, solver=DummySolver())) == m.numberOfCells True
- Parameters:
var (CellVariable) – Variable to be solved for. Provides the initial condition, the old value and holds the solution on completion.
solver (Solver) – Iterative solver to be used to solve the linear system of equations. The default sovler depends on the solver package selected.
boundaryConditions (
tuple
ofBoundaryCondition
) –dt (float) – Timestep size.
underRelaxation (float) – Usually a value between 0 and 1 or None in the case of no under-relaxation
residualFn (function) – Takes var, matrix, and RHSvector arguments, used to customize the residual calculation.
- Returns:
error – The residual vector
- Return type:
- justResidualVector(var=None, solver=None, boundaryConditions=(), dt=None, underRelaxation=None, residualFn=None)¶
Builds the Term’s linear system once.
This method also recalculates and returns the residual as well as applying under-relaxation.
justResidualVector returns the overlapping local value in parallel (not the non-overlapping value).
>>> from fipy import * >>> m = Grid1D(nx=10) >>> v = CellVariable(mesh=m) >>> len(numerix.asarray(DiffusionTerm().justResidualVector(v))) == m.numberOfCells True
- Parameters:
var (CellVariable) – Variable to be solved for. Provides the initial condition, the old value and holds the solution on completion.
solver (Solver) – Iterative solver to be used to solve the linear system of equations. The default sovler depends on the solver package selected.
boundaryConditions (
tuple
ofBoundaryCondition
) –dt (float) – Timestep size.
underRelaxation (float) – Usually a value between 0 and 1 or None in the case of no under-relaxation
residualFn (function) – Takes var, matrix, and RHSvector arguments, used to customize the residual calculation.
- Returns:
residual – The residual vector
- Return type:
- property matrix¶
Return the matrix calculated in solve() or sweep(). The cacheMatrix() method should be called before solve() or sweep() to cache the matrix.
- residualVectorAndNorm(var=None, solver=None, boundaryConditions=(), dt=None, underRelaxation=None, residualFn=None)¶
Builds the Term’s linear system once.
This method also recalculates and returns the residual as well as applying under-relaxation.
- Parameters:
var (CellVariable) – Variable to be solved for. Provides the initial condition, the old value and holds the solution on completion.
solver (Solver) – Iterative solver to be used to solve the linear system of equations. The default sovler depends on the solver package selected.
boundaryConditions (
tuple
ofBoundaryCondition
) –dt (float) – Timestep size.
underRelaxation (float) – Usually a value between 0 and 1 or None in the case of no under-relaxation
residualFn (function) – Takes var, matrix, and RHSvector arguments, used to customize the residual calculation.
- Returns:
residual (~fipy.variables.cellVariable.CellVariable) – The residual vector
norm (float) – The L2 norm of residual,
- solve(var=None, solver=None, boundaryConditions=(), dt=None)¶
Builds and solves the Term’s linear system once. This method does not return the residual. It should be used when the residual is not required.
- Parameters:
var (CellVariable) – Variable to be solved for. Provides the initial condition, the old value and holds the solution on completion.
solver (Solver) – Iterative solver to be used to solve the linear system of equations. The default sovler depends on the solver package selected.
boundaryConditions (
tuple
ofBoundaryCondition
) –dt (float) – Timestep size.
- sweep(var=None, solver=None, boundaryConditions=(), dt=None, underRelaxation=None, residualFn=None, cacheResidual=False, cacheError=False)¶
Builds and solves the Term’s linear system once. This method also recalculates and returns the residual as well as applying under-relaxation.
- Parameters:
var (CellVariable) – Variable to be solved for. Provides the initial condition, the old value and holds the solution on completion.
solver (Solver) – Iterative solver to be used to solve the linear system of equations. The default sovler depends on the solver package selected.
boundaryConditions (
tuple
ofBoundaryCondition
) –dt (float) – Timestep size.
underRelaxation (float) – Usually a value between 0 and 1 or None in the case of no under-relaxation
residualFn (function) – Takes var, matrix, and RHSvector arguments, used to customize the residual calculation.
cacheResidual (bool) – If True, calculate and store the residual vector
in the residualVector member of Term
cacheError (bool) – If True, use the residual vector
to solve
for the error vector
and store it in the errorVector member of Term
- Returns:
residual – The residual vector
- Return type:
- class fipy.Tri2D(dx=1.0, dy=1.0, nx=1, ny=1, _RepresentationClass=<class 'fipy.meshes.representations.gridRepresentation._Grid2DRepresentation'>, _TopologyClass=<class 'fipy.meshes.topologies.meshTopology._Mesh2DTopology'>)¶
Bases:
Mesh2D
This class creates a mesh made out of triangles. It does this by starting with a standard Cartesian mesh (Grid2D) and dividing each cell in that mesh (hereafter referred to as a “box”) into four equal parts with the dividing lines being the diagonals.
Creates a 2D triangular mesh with horizontal faces numbered first then vertical faces, then diagonal faces. Vertices are numbered starting with the vertices at the corners of boxes and then the vertices at the centers of boxes. Cells on the right of boxes are numbered first, then cells on the top of boxes, then cells on the left of boxes, then cells on the bottom of boxes. Within each of the “sub-categories” in the above, the vertices, cells and faces are numbered in the usual way.
- Parameters:
dx (float) – The X and Y dimensions of each “box”. If dx <> dy, the line segments connecting the cell centers will not be orthogonal to the faces.
dy (float) – The X and Y dimensions of each “box”. If dx <> dy, the line segments connecting the cell centers will not be orthogonal to the faces.
nx (int) – The number of boxes in the X direction and the Y direction. The total number of boxes will be equal to nx * ny, and the total number of cells will be equal to 4 * nx * ny.
ny (int) – The number of boxes in the X direction and the Y direction. The total number of boxes will be equal to nx * ny, and the total number of cells will be equal to 4 * nx * ny.
- property VTKCellDataSet¶
Returns a TVTK DataSet representing the cells of this mesh
- property VTKFaceDataSet¶
Returns a TVTK DataSet representing the face centers of this mesh
- __add__(other)¶
Either translate a Mesh or concatenate two Mesh objects.
>>> from fipy.meshes import Grid2D >>> baseMesh = Grid2D(dx = 1.0, dy = 1.0, nx = 2, ny = 2) >>> print(baseMesh.cellCenters) [[ 0.5 1.5 0.5 1.5] [ 0.5 0.5 1.5 1.5]]
If a vector is added to a Mesh, a translated Mesh is returned
>>> translatedMesh = baseMesh + ((5,), (10,)) >>> print(translatedMesh.cellCenters) [[ 5.5 6.5 5.5 6.5] [ 10.5 10.5 11.5 11.5]]
If a Mesh is added to a Mesh, a concatenation of the two Mesh objects is returned
>>> addedMesh = baseMesh + (baseMesh + ((2,), (0,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 2.5 3.5 2.5 3.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5]]
The two Mesh objects need not be properly aligned in order to concatenate them but the resulting mesh may not have the intended connectivity
>>> addedMesh = baseMesh + (baseMesh + ((3,), (0,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 3.5 4.5 3.5 4.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5]]
>>> addedMesh = baseMesh + (baseMesh + ((2,), (2,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 2.5 3.5 2.5 3.5] [ 0.5 0.5 1.5 1.5 2.5 2.5 3.5 3.5]]
No provision is made to avoid or consolidate overlapping Mesh objects
>>> addedMesh = baseMesh + (baseMesh + ((1,), (0,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 1.5 2.5 1.5 2.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5]]
Different Mesh classes can be concatenated
>>> from fipy.meshes import Tri2D >>> triMesh = Tri2D(dx = 1.0, dy = 1.0, nx = 2, ny = 1) >>> triMesh = triMesh + ((2,), (0,)) >>> triAddedMesh = baseMesh + triMesh >>> cellCenters = [[0.5, 1.5, 0.5, 1.5, 2.83333333, 3.83333333, ... 2.5, 3.5, 2.16666667, 3.16666667, 2.5, 3.5], ... [0.5, 0.5, 1.5, 1.5, 0.5, 0.5, 0.83333333, 0.83333333, ... 0.5, 0.5, 0.16666667, 0.16666667]] >>> print(numerix.allclose(triAddedMesh.cellCenters, ... cellCenters)) True
again, their faces need not align, but the mesh may not have the desired connectivity
>>> triMesh = Tri2D(dx = 1.0, dy = 2.0, nx = 2, ny = 1) >>> triMesh = triMesh + ((2,), (0,)) >>> triAddedMesh = baseMesh + triMesh >>> cellCenters = [[ 0.5, 1.5, 0.5, 1.5, 2.83333333, 3.83333333, ... 2.5, 3.5, 2.16666667, 3.16666667, 2.5, 3.5], ... [ 0.5, 0.5, 1.5, 1.5, 1., 1., ... 1.66666667, 1.66666667, 1., 1., 0.33333333, 0.33333333]] >>> print(numerix.allclose(triAddedMesh.cellCenters, ... cellCenters)) True
Mesh concatenation is not limited to 2D meshes
>>> from fipy.meshes import Grid3D >>> threeDBaseMesh = Grid3D(dx = 1.0, dy = 1.0, dz = 1.0, ... nx = 2, ny = 2, nz = 2) >>> threeDSecondMesh = Grid3D(dx = 1.0, dy = 1.0, dz = 1.0, ... nx = 1, ny = 1, nz = 1) >>> threeDAddedMesh = threeDBaseMesh + (threeDSecondMesh + ((2,), (0,), (0,))) >>> print(threeDAddedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 0.5 1.5 0.5 1.5 2.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5 0.5] [ 0.5 0.5 0.5 0.5 1.5 1.5 1.5 1.5 0.5]]
but the different Mesh objects must, of course, have the same dimensionality.
>>> InvalidMesh = threeDBaseMesh + baseMesh Traceback (most recent call last): ... MeshAdditionError: Dimensions do not match
- __div__(other)¶
Tests. >>> from fipy import * >>> print((Grid1D(nx=1) / 2.).cellCenters) [[ 0.25]] >>> AbstractMesh(communicator=None) / 2. Traceback (most recent call last): … NotImplementedError
- __getstate__()¶
Helper for pickle.
- __mul__(factor)¶
Dilate a Mesh by factor.
>>> from fipy.meshes import Grid2D >>> baseMesh = Grid2D(dx = 1.0, dy = 1.0, nx = 2, ny = 2) >>> print(baseMesh.cellCenters) [[ 0.5 1.5 0.5 1.5] [ 0.5 0.5 1.5 1.5]]
The factor can be a scalar
>>> dilatedMesh = baseMesh * 3 >>> print(dilatedMesh.cellCenters) [[ 1.5 4.5 1.5 4.5] [ 1.5 1.5 4.5 4.5]]
or a vector
>>> dilatedMesh = baseMesh * ((3,), (2,)) >>> print(dilatedMesh.cellCenters) [[ 1.5 4.5 1.5 4.5] [ 1. 1. 3. 3. ]]
but the vector must have the same dimensionality as the Mesh
>>> dilatedMesh = baseMesh * ((3,), (2,), (1,)) Traceback (most recent call last): ... ValueError: shape mismatch: objects cannot be broadcast to a single shape
- __radd__(other)¶
Either translate a Mesh or concatenate two Mesh objects.
>>> from fipy.meshes import Grid2D >>> baseMesh = Grid2D(dx = 1.0, dy = 1.0, nx = 2, ny = 2) >>> print(baseMesh.cellCenters) [[ 0.5 1.5 0.5 1.5] [ 0.5 0.5 1.5 1.5]]
If a vector is added to a Mesh, a translated Mesh is returned
>>> translatedMesh = baseMesh + ((5,), (10,)) >>> print(translatedMesh.cellCenters) [[ 5.5 6.5 5.5 6.5] [ 10.5 10.5 11.5 11.5]]
If a Mesh is added to a Mesh, a concatenation of the two Mesh objects is returned
>>> addedMesh = baseMesh + (baseMesh + ((2,), (0,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 2.5 3.5 2.5 3.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5]]
The two Mesh objects need not be properly aligned in order to concatenate them but the resulting mesh may not have the intended connectivity
>>> addedMesh = baseMesh + (baseMesh + ((3,), (0,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 3.5 4.5 3.5 4.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5]]
>>> addedMesh = baseMesh + (baseMesh + ((2,), (2,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 2.5 3.5 2.5 3.5] [ 0.5 0.5 1.5 1.5 2.5 2.5 3.5 3.5]]
No provision is made to avoid or consolidate overlapping Mesh objects
>>> addedMesh = baseMesh + (baseMesh + ((1,), (0,))) >>> print(addedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 1.5 2.5 1.5 2.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5]]
Different Mesh classes can be concatenated
>>> from fipy.meshes import Tri2D >>> triMesh = Tri2D(dx = 1.0, dy = 1.0, nx = 2, ny = 1) >>> triMesh = triMesh + ((2,), (0,)) >>> triAddedMesh = baseMesh + triMesh >>> cellCenters = [[0.5, 1.5, 0.5, 1.5, 2.83333333, 3.83333333, ... 2.5, 3.5, 2.16666667, 3.16666667, 2.5, 3.5], ... [0.5, 0.5, 1.5, 1.5, 0.5, 0.5, 0.83333333, 0.83333333, ... 0.5, 0.5, 0.16666667, 0.16666667]] >>> print(numerix.allclose(triAddedMesh.cellCenters, ... cellCenters)) True
again, their faces need not align, but the mesh may not have the desired connectivity
>>> triMesh = Tri2D(dx = 1.0, dy = 2.0, nx = 2, ny = 1) >>> triMesh = triMesh + ((2,), (0,)) >>> triAddedMesh = baseMesh + triMesh >>> cellCenters = [[ 0.5, 1.5, 0.5, 1.5, 2.83333333, 3.83333333, ... 2.5, 3.5, 2.16666667, 3.16666667, 2.5, 3.5], ... [ 0.5, 0.5, 1.5, 1.5, 1., 1., ... 1.66666667, 1.66666667, 1., 1., 0.33333333, 0.33333333]] >>> print(numerix.allclose(triAddedMesh.cellCenters, ... cellCenters)) True
Mesh concatenation is not limited to 2D meshes
>>> from fipy.meshes import Grid3D >>> threeDBaseMesh = Grid3D(dx = 1.0, dy = 1.0, dz = 1.0, ... nx = 2, ny = 2, nz = 2) >>> threeDSecondMesh = Grid3D(dx = 1.0, dy = 1.0, dz = 1.0, ... nx = 1, ny = 1, nz = 1) >>> threeDAddedMesh = threeDBaseMesh + (threeDSecondMesh + ((2,), (0,), (0,))) >>> print(threeDAddedMesh.cellCenters) [[ 0.5 1.5 0.5 1.5 0.5 1.5 0.5 1.5 2.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5 0.5] [ 0.5 0.5 0.5 0.5 1.5 1.5 1.5 1.5 0.5]]
but the different Mesh objects must, of course, have the same dimensionality.
>>> InvalidMesh = threeDBaseMesh + baseMesh Traceback (most recent call last): ... MeshAdditionError: Dimensions do not match
- __repr__()¶
Return repr(self).
- __rmul__(factor)¶
Dilate a Mesh by factor.
>>> from fipy.meshes import Grid2D >>> baseMesh = Grid2D(dx = 1.0, dy = 1.0, nx = 2, ny = 2) >>> print(baseMesh.cellCenters) [[ 0.5 1.5 0.5 1.5] [ 0.5 0.5 1.5 1.5]]
The factor can be a scalar
>>> dilatedMesh = baseMesh * 3 >>> print(dilatedMesh.cellCenters) [[ 1.5 4.5 1.5 4.5] [ 1.5 1.5 4.5 4.5]]
or a vector
>>> dilatedMesh = baseMesh * ((3,), (2,)) >>> print(dilatedMesh.cellCenters) [[ 1.5 4.5 1.5 4.5] [ 1. 1. 3. 3. ]]
but the vector must have the same dimensionality as the Mesh
>>> dilatedMesh = baseMesh * ((3,), (2,), (1,)) Traceback (most recent call last): ... ValueError: shape mismatch: objects cannot be broadcast to a single shape
- __setstate__(state)¶
- __sub__(other)¶
Tests. >>> from fipy import * >>> m = Grid1D() >>> print((m - ((1,))).cellCenters) [[-0.5]] >>> ((1,)) - m Traceback (most recent call last): … TypeError: unsupported operand type(s) for -: ‘tuple’ and ‘UniformGrid1D’
- __truediv__(other)¶
Tests. >>> from fipy import * >>> print((Grid1D(nx=1) / 2.).cellCenters) [[ 0.25]] >>> AbstractMesh(communicator=None) / 2. Traceback (most recent call last): … NotImplementedError
- property aspect2D¶
The physical y vs x aspect ratio of a 2D mesh
- property cellCenters¶
- property cellDistanceVectors¶
- property cellFaceIDs¶
- property cellToFaceDistanceVectors¶
- property cellVolumes¶
- property extents¶
- property exteriorFaces¶
- extrude(extrudeFunc=<function Mesh2D.<lambda>>, layers=1)¶
This function returns a new 3D mesh. The 2D mesh is extruded using the extrudeFunc and the number of layers.
>>> from fipy.meshes.nonUniformGrid2D import NonUniformGrid2D >>> print(NonUniformGrid2D(nx=2, ny=2).extrude(layers=2).cellCenters) [[ 0.5 1.5 0.5 1.5 0.5 1.5 0.5 1.5] [ 0.5 0.5 1.5 1.5 0.5 0.5 1.5 1.5] [ 0.5 0.5 0.5 0.5 1.5 1.5 1.5 1.5]]
>>> from fipy.meshes.tri2D import Tri2D >>> print(Tri2D().extrude(layers=2).cellCenters.allclose([[ 0.83333333, 0.5, 0.16666667, 0.5, 0.83333333, 0.5, ... 0.16666667, 0.5 ], ... [ 0.5, 0.83333333, 0.5, 0.16666667, 0.5, 0.83333333, ... 0.5, 0.16666667], ... [ 0.5, 0.5, 0.5, 0.5, 1.5, 1.5, 1.5, ... 1.5 ]])) True
- Parameters:
extrudeFunc (function) – Takes the vertex coordinates and returns the displaced values
layers (int) – Number of layers in the extruded mesh (number of times extrudeFunc will be called)
- property faceCenters¶
- property facesBack¶
Return list of faces on back boundary of 3D Mesh with the z-axis running from front to back.
>>> from fipy import Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((6, 7, 8, 9, 10, 11), ... numerix.nonzero(mesh.facesBack)[0])) True >>> ignore = mesh.facesBack.value
- property facesBottom¶
Return list of faces on bottom boundary of 2D or 3D Mesh with the y-axis running from bottom to top.
>>> from fipy import Grid2D, Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((12, 13, 14), ... numerix.nonzero(mesh.facesBottom)[0])) True >>> ignore = mesh.facesBottom.value >>> x, y, z = mesh.faceCenters >>> print(numerix.allequal((12, 13), ... numerix.nonzero(mesh.facesBottom & (x < 1))[0])) True >>> ignore = mesh.facesBottom.value
- property facesDown¶
Return list of faces on bottom boundary of 2D or 3D Mesh with the y-axis running from bottom to top.
>>> from fipy import Grid2D, Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((12, 13, 14), ... numerix.nonzero(mesh.facesBottom)[0])) True >>> ignore = mesh.facesBottom.value >>> x, y, z = mesh.faceCenters >>> print(numerix.allequal((12, 13), ... numerix.nonzero(mesh.facesBottom & (x < 1))[0])) True >>> ignore = mesh.facesBottom.value
- property facesFront¶
Return list of faces on front boundary of 3D Mesh with the z-axis running from front to back.
>>> from fipy import Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((0, 1, 2, 3, 4, 5), ... numerix.nonzero(mesh.facesFront)[0])) True >>> ignore = mesh.facesFront.value
- property facesLeft¶
Return face on left boundary of Mesh as list with the x-axis running from left to right.
>>> from fipy import Grid2D, Grid3D >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((21, 25), ... numerix.nonzero(mesh.facesLeft)[0])) True >>> ignore = mesh.facesLeft.value >>> mesh = Grid2D(nx = 3, ny = 2, dx = 0.5, dy = 2.) >>> print(numerix.allequal((9, 13), ... numerix.nonzero(mesh.facesLeft)[0])) True >>> ignore = mesh.facesLeft.value
- property facesRight¶
Return list of faces on right boundary of Mesh with the x-axis running from left to right.
>>> from fipy import Grid2D, Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((24, 28), ... numerix.nonzero(mesh.facesRight)[0])) True >>> ignore = mesh.facesRight.value >>> mesh = Grid2D(nx = 3, ny = 2, dx = 0.5, dy = 2.) >>> print(numerix.allequal((12, 16), ... numerix.nonzero(mesh.facesRight)[0])) True >>> ignore = mesh.facesRight.value
- property facesTop¶
Return list of faces on top boundary of 2D or 3D Mesh with the y-axis running from bottom to top.
>>> from fipy import Grid2D, Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((18, 19, 20), ... numerix.nonzero(mesh.facesTop)[0])) True >>> ignore = mesh.facesTop.value >>> mesh = Grid2D(nx = 3, ny = 2, dx = 0.5, dy = 2.) >>> print(numerix.allequal((6, 7, 8), ... numerix.nonzero(mesh.facesTop)[0])) True >>> ignore = mesh.facesTop.value
- property facesUp¶
Return list of faces on top boundary of 2D or 3D Mesh with the y-axis running from bottom to top.
>>> from fipy import Grid2D, Grid3D, numerix >>> mesh = Grid3D(nx = 3, ny = 2, nz = 1, dx = 0.5, dy = 2., dz = 4.) >>> print(numerix.allequal((18, 19, 20), ... numerix.nonzero(mesh.facesTop)[0])) True >>> ignore = mesh.facesTop.value >>> mesh = Grid2D(nx = 3, ny = 2, dx = 0.5, dy = 2.) >>> print(numerix.allequal((6, 7, 8), ... numerix.nonzero(mesh.facesTop)[0])) True >>> ignore = mesh.facesTop.value
- getNearestCell(point)¶
- property interiorFaceCellIDs¶
- property interiorFaceIDs¶
- property interiorFaces¶
- property physicalShape¶
Return physical dimensions of Grid2D.
- property scale¶
- property scaledCellDistances¶
- property scaledCellToCellDistances¶
- property scaledCellVolumes¶
- property scaledFaceAreas¶
- property scaledFaceToCellDistances¶
- property shape¶
- property x¶
Equivalent to using
cellCenters
[0]
.>>> from fipy import * >>> print(Grid1D(nx=2).x) [ 0.5 1.5]
- property y¶
Equivalent to using
cellCenters
[1]
.>>> from fipy import * >>> print(Grid2D(nx=2, ny=2).y) [ 0.5 0.5 1.5 1.5] >>> print(Grid1D(nx=2).y) Traceback (most recent call last): ... AttributeError: 1D meshes do not have a "y" attribute.
- property z¶
Equivalent to using
cellCenters
[2]
.>>> from fipy import * >>> print(Grid3D(nx=2, ny=2, nz=2).z) [ 0.5 0.5 0.5 0.5 1.5 1.5 1.5 1.5] >>> print(Grid2D(nx=2, ny=2).z) Traceback (most recent call last): ... AttributeError: 1D and 2D meshes do not have a "z" attribute.
- class fipy.UniformNoiseVariable(*args, **kwds)¶
Bases:
NoiseVariable
Represents a uniform distribution of random numbers.
We generate noise on a uniform Cartesian mesh
>>> from fipy.meshes import Grid2D >>> noise = UniformNoiseVariable(mesh=Grid2D(nx=100, ny=100))
and histogram the noise
>>> from fipy.variables.histogramVariable import HistogramVariable >>> histogram = HistogramVariable(distribution=noise, dx=0.01, nx=120, offset=-.1)
>>> if __name__ == '__main__': ... from fipy import Viewer ... viewer = Viewer(vars=noise, ... datamin=0, datamax=1) ... histoplot = Viewer(vars=histogram)
>>> from builtins import range >>> for i in range(10): ... noise.scramble() ... if __name__ == '__main__': ... viewer.plot() ... histoplot.plot()
- Parameters:
- __abs__()¶
Following test it to fix a bug with C inline string using abs() instead of fabs()
>>> print(abs(Variable(2.3) - Variable(1.2))) 1.1
Check representation works with different versions of numpy
>>> print(repr(abs(Variable(2.3)))) numerix.fabs(Variable(value=array(2.3)))
- __add__(other)¶
- __and__(other)¶
This test case has been added due to a weird bug that was appearing.
>>> a = Variable(value=(0, 0, 1, 1)) >>> b = Variable(value=(0, 1, 0, 1)) >>> print(numerix.equal((a == 0) & (b == 1), [False, True, False, False]).all()) True >>> print(a & b) [0 0 0 1] >>> from fipy.meshes import Grid1D >>> mesh = Grid1D(nx=4) >>> from fipy.variables.cellVariable import CellVariable >>> a = CellVariable(value=(0, 0, 1, 1), mesh=mesh) >>> b = CellVariable(value=(0, 1, 0, 1), mesh=mesh) >>> print(numerix.allequal((a == 0) & (b == 1), [False, True, False, False])) True >>> print(a & b) [0 0 0 1]
- __array__(t=None)¶
Attempt to convert the Variable to a numerix array object
>>> v = Variable(value=[2, 3]) >>> print(numerix.array(v)) [2 3]
A dimensional Variable will convert to the numeric value in its base units
>>> v = Variable(value=[2, 3], unit="mm") >>> numerix.array(v) array([ 0.002, 0.003])
- __array_priority__ = 100.0¶
- __array_wrap__(arr, context=None)¶
Required to prevent numpy not calling the reverse binary operations. Both the following tests are examples ufuncs.
>>> print(type(numerix.array([1.0, 2.0]) * Variable([1.0, 2.0]))) <class 'fipy.variables.binaryOperatorVariable...binOp'>
>>> from scipy.special import gamma as Gamma >>> print(type(Gamma(Variable([1.0, 2.0])))) <class 'fipy.variables.unaryOperatorVariable...unOp'>
- __bool__()¶
>>> print(bool(Variable(value=0))) 0 >>> print(bool(Variable(value=(0, 0, 1, 1)))) Traceback (most recent call last): ... ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
- __call__(points=None, order=0, nearestCellIDs=None)¶
Interpolates the CellVariable to a set of points using a method that has a memory requirement on the order of Ncells by Npoints in general, but uses only Ncells when the CellVariable’s mesh is a UniformGrid object.
Tests
>>> from fipy import * >>> m = Grid2D(nx=3, ny=2) >>> v = CellVariable(mesh=m, value=m.cellCenters[0]) >>> print(v(((0., 1.1, 1.2), (0., 1., 1.)))) [ 0.5 1.5 1.5] >>> print(v(((0., 1.1, 1.2), (0., 1., 1.)), order=1)) [ 0.25 1.1 1.2 ] >>> m0 = Grid2D(nx=2, ny=2, dx=1., dy=1.) >>> m1 = Grid2D(nx=4, ny=4, dx=.5, dy=.5) >>> x, y = m0.cellCenters >>> v0 = CellVariable(mesh=m0, value=x * y) >>> print(v0(m1.cellCenters.globalValue)) [ 0.25 0.25 0.75 0.75 0.25 0.25 0.75 0.75 0.75 0.75 2.25 2.25 0.75 0.75 2.25 2.25] >>> print(v0(m1.cellCenters.globalValue, order=1)) [ 0.125 0.25 0.5 0.625 0.25 0.375 0.875 1. 0.5 0.875 1.875 2.25 0.625 1. 2.25 2.625]
- __div__(other)¶
- __eq__(other)¶
Test if a Variable is equal to another quantity
>>> a = Variable(value=3) >>> b = (a == 4) >>> b (Variable(value=array(3)) == 4) >>> b() 0
- __float__()¶
- __ge__(other)¶
Test if a Variable is greater than or equal to another quantity
>>> a = Variable(value=3) >>> b = (a >= 4) >>> b (Variable(value=array(3)) >= 4) >>> b() 0 >>> a.value = 4 >>> print(b()) 1 >>> a.value = 5 >>> print(b()) 1
- __getitem__(index)¶
“Evaluate” the Variable and return the specified element
>>> a = Variable(value=((3., 4.), (5., 6.)), unit="m") + "4 m" >>> print(a[1, 1]) 10.0 m
It is an error to slice a Variable whose value is not sliceable
>>> Variable(value=3)[2] Traceback (most recent call last): ... IndexError: 0-d arrays can't be indexed
- __getstate__()¶
Used internally to collect the necessary information to
pickle
the CellVariable to persistent storage.
- __gt__(other)¶
Test if a Variable is greater than another quantity
>>> a = Variable(value=3) >>> b = (a > 4) >>> b (Variable(value=array(3)) > 4) >>> print(b()) 0 >>> a.value = 5 >>> print(b()) 1
- __hash__()¶
Return hash(self).
- __int__()¶
- __invert__()¶
Returns logical “not” of the Variable
>>> a = Variable(value=True) >>> print(~a) False
- __iter__()¶
- __le__(other)¶
Test if a Variable is less than or equal to another quantity
>>> a = Variable(value=3) >>> b = (a <= 4) >>> b (Variable(value=array(3)) <= 4) >>> b() 1 >>> a.value = 4 >>> print(b()) 1 >>> a.value = 5 >>> print(b()) 0
- __len__()¶
- __lt__(other)¶
Test if a Variable is less than another quantity
>>> a = Variable(value=3) >>> b = (a < 4) >>> b (Variable(value=array(3)) < 4) >>> b() 1 >>> a.value = 4 >>> print(b()) 0 >>> print(1000000000000000000 * Variable(1) < 1.) 0 >>> print(1000 * Variable(1) < 1.) 0
Python automatically reverses the arguments when necessary
>>> 4 > Variable(value=3) (Variable(value=array(3)) < 4)
- __mod__(other)¶
- __mul__(other)¶
- __ne__(other)¶
Test if a Variable is not equal to another quantity
>>> a = Variable(value=3) >>> b = (a != 4) >>> b (Variable(value=array(3)) != 4) >>> b() 1
- __neg__()¶
- static __new__(cls, *args, **kwds)¶
- __nonzero__()¶
>>> print(bool(Variable(value=0))) 0 >>> print(bool(Variable(value=(0, 0, 1, 1)))) Traceback (most recent call last): ... ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
- __or__(other)¶
This test case has been added due to a weird bug that was appearing.
>>> a = Variable(value=(0, 0, 1, 1)) >>> b = Variable(value=(0, 1, 0, 1)) >>> print(numerix.equal((a == 0) | (b == 1), [True, True, False, True]).all()) True >>> print(a | b) [0 1 1 1] >>> from fipy.meshes import Grid1D >>> mesh = Grid1D(nx=4) >>> from fipy.variables.cellVariable import CellVariable >>> a = CellVariable(value=(0, 0, 1, 1), mesh=mesh) >>> b = CellVariable(value=(0, 1, 0, 1), mesh=mesh) >>> print(numerix.allequal((a == 0) | (b == 1), [True, True, False, True])) True >>> print(a | b) [0 1 1 1]
- __pos__()¶
- __pow__(other)¶
return self**other, or self raised to power other
>>> print(Variable(1, "mol/l")**3) 1.0 mol**3/l**3 >>> print((Variable(1, "mol/l")**3).unit) <PhysicalUnit mol**3/l**3>
- __radd__(other)¶
- __rdiv__(other)¶
- __repr__()¶
Return repr(self).
- __rmul__(other)¶
- __rpow__(other)¶
- __rsub__(other)¶
- __rtruediv__(other)¶
- __setitem__(index, value)¶
- __setstate__(dict)¶
Used internally to create a new CellVariable from
pickled
persistent storage.
- __str__()¶
Return str(self).
- __sub__(other)¶
- __truediv__(other)¶
- all(axis=None)¶
>>> print(Variable(value=(0, 0, 1, 1)).all()) 0 >>> print(Variable(value=(1, 1, 1, 1)).all()) 1
- allclose(other, rtol=1e-05, atol=1e-08)¶
>>> var = Variable((1, 1)) >>> print(var.allclose((1, 1))) 1 >>> print(var.allclose((1,))) 1
The following test is to check that the system does not run out of memory.
>>> from fipy.tools import numerix >>> var = Variable(numerix.ones(10000)) >>> print(var.allclose(numerix.zeros(10000, 'l'))) False
- allequal(other)¶
- any(axis=None)¶
>>> print(Variable(value=0).any()) 0 >>> print(Variable(value=(0, 0, 1, 1)).any()) 1
- property arithmeticFaceValue¶
Returns a FaceVariable whose value corresponds to the arithmetic interpolation of the adjacent cells:
>>> from fipy.meshes import Grid1D >>> from fipy import numerix >>> mesh = Grid1D(dx = (1., 1.)) >>> L = 1 >>> R = 2 >>> var = CellVariable(mesh = mesh, value = (L, R)) >>> faceValue = var.arithmeticFaceValue[mesh.interiorFaces.value] >>> answer = (R - L) * (0.5 / 1.) + L >>> print(numerix.allclose(faceValue, answer, atol = 1e-10, rtol = 1e-10)) True
>>> mesh = Grid1D(dx = (2., 4.)) >>> var = CellVariable(mesh = mesh, value = (L, R)) >>> faceValue = var.arithmeticFaceValue[mesh.interiorFaces.value] >>> answer = (R - L) * (1.0 / 3.0) + L >>> print(numerix.allclose(faceValue, answer, atol = 1e-10, rtol = 1e-10)) True
>>> mesh = Grid1D(dx = (10., 100.)) >>> var = CellVariable(mesh = mesh, value = (L, R)) >>> faceValue = var.arithmeticFaceValue[mesh.interiorFaces.value] >>> answer = (R - L) * (5.0 / 55.0) + L >>> print(numerix.allclose(faceValue, answer, atol = 1e-10, rtol = 1e-10)) True
- cacheMe(recursive=False)¶
- property cellVolumeAverage¶
Return the cell-volume-weighted average of the CellVariable:
>>> from fipy.meshes import Grid2D >>> from fipy.variables.cellVariable import CellVariable >>> mesh = Grid2D(nx = 3, ny = 1, dx = .5, dy = .1) >>> var = CellVariable(value = (1, 2, 6), mesh = mesh) >>> print(var.cellVolumeAverage) 3.0
- constrain(value, where=None)¶
Constrains the CellVariable to value at a location specified by where.
>>> from fipy import * >>> m = Grid1D(nx=3) >>> v = CellVariable(mesh=m, value=m.cellCenters[0]) >>> v.constrain(0., where=m.facesLeft) >>> v.faceGrad.constrain([1.], where=m.facesRight) >>> print(v.faceGrad) [[ 1. 1. 1. 1.]] >>> print(v.faceValue) [ 0. 1. 2. 2.5]
Changing the constraint changes the dependencies
>>> v.constrain(1., where=m.facesLeft) >>> print(v.faceGrad) [[-1. 1. 1. 1.]] >>> print(v.faceValue) [ 1. 1. 2. 2.5]
Constraints can be Variable
>>> c = Variable(0.) >>> v.constrain(c, where=m.facesLeft) >>> print(v.faceGrad) [[ 1. 1. 1. 1.]] >>> print(v.faceValue) [ 0. 1. 2. 2.5] >>> c.value = 1. >>> print(v.faceGrad) [[-1. 1. 1. 1.]] >>> print(v.faceValue) [ 1. 1. 2. 2.5]
Constraints can have a Variable mask.
>>> v = CellVariable(mesh=m) >>> mask = FaceVariable(mesh=m, value=m.facesLeft) >>> v.constrain(1., where=mask) >>> print(v.faceValue) [ 1. 0. 0. 0.] >>> mask[:] = mask | m.facesRight >>> print(v.faceValue) [ 1. 0. 0. 1.]
- property constraintMask¶
Test that constraintMask returns a Variable that updates itself whenever the constraints change.
>>> from fipy import *
>>> m = Grid2D(nx=2, ny=2) >>> x, y = m.cellCenters >>> v0 = CellVariable(mesh=m) >>> v0.constrain(1., where=m.facesLeft) >>> print(v0.faceValue.constraintMask) [False False False False False False True False False True False False] >>> print(v0.faceValue) [ 0. 0. 0. 0. 0. 0. 1. 0. 0. 1. 0. 0.] >>> v0.constrain(3., where=m.facesRight) >>> print(v0.faceValue.constraintMask) [False False False False False False True False True True False True] >>> print(v0.faceValue) [ 0. 0. 0. 0. 0. 0. 1. 0. 3. 1. 0. 3.] >>> v1 = CellVariable(mesh=m) >>> v1.constrain(1., where=(x < 1) & (y < 1)) >>> print(v1.constraintMask) [ True False False False] >>> print(v1) [ 1. 0. 0. 0.] >>> v1.constrain(3., where=(x > 1) & (y > 1)) >>> print(v1.constraintMask) [ True False False True] >>> print(v1) [ 1. 0. 0. 3.]
- property constraints¶
- copy()¶
Copy the value of the NoiseVariable to a static CellVariable.
- dontCacheMe(recursive=False)¶
- dot(other, opShape=None, operatorClass=None)¶
Return the mesh-element–by–mesh-element (cell-by-cell, face-by-face, etc.) scalar product
Both self and other can be of arbitrary rank, and other does not need to be a _MeshVariable.
- property faceGrad¶
Return
as a rank-1 FaceVariable using differencing for the normal direction(second-order gradient).
- property faceGradAverage¶
Deprecated since version 3.3: use
grad.arithmeticFaceValue()
insteadReturn
as a rank-1 FaceVariable using averaging for the normal direction(second-order gradient)
- property faceValue¶
Returns a FaceVariable whose value corresponds to the arithmetic interpolation of the adjacent cells:
>>> from fipy.meshes import Grid1D >>> from fipy import numerix >>> mesh = Grid1D(dx = (1., 1.)) >>> L = 1 >>> R = 2 >>> var = CellVariable(mesh = mesh, value = (L, R)) >>> faceValue = var.arithmeticFaceValue[mesh.interiorFaces.value] >>> answer = (R - L) * (0.5 / 1.) + L >>> print(numerix.allclose(faceValue, answer, atol = 1e-10, rtol = 1e-10)) True
>>> mesh = Grid1D(dx = (2., 4.)) >>> var = CellVariable(mesh = mesh, value = (L, R)) >>> faceValue = var.arithmeticFaceValue[mesh.interiorFaces.value] >>> answer = (R - L) * (1.0 / 3.0) + L >>> print(numerix.allclose(faceValue, answer, atol = 1e-10, rtol = 1e-10)) True
>>> mesh = Grid1D(dx = (10., 100.)) >>> var = CellVariable(mesh = mesh, value = (L, R)) >>> faceValue = var.arithmeticFaceValue[mesh.interiorFaces.value] >>> answer = (R - L) * (5.0 / 55.0) + L >>> print(numerix.allclose(faceValue, answer, atol = 1e-10, rtol = 1e-10)) True
- property gaussGrad¶
Return
as a rank-1 CellVariable (first-order gradient).
- getsctype(default=None)¶
Returns the Numpy sctype of the underlying array.
>>> Variable(1).getsctype() == numerix.NUMERIX.obj2sctype(numerix.array(1)) True >>> Variable(1.).getsctype() == numerix.NUMERIX.obj2sctype(numerix.array(1.)) True >>> Variable((1, 1.)).getsctype() == numerix.NUMERIX.obj2sctype(numerix.array((1., 1.))) True
- property globalValue¶
Concatenate and return values from all processors
When running on a single processor, the result is identical to
value
.
- property grad¶
Return
as a rank-1 CellVariable (first-order gradient).
- property harmonicFaceValue¶
Returns a FaceVariable whose value corresponds to the harmonic interpolation of the adjacent cells:
>>> from fipy.meshes import Grid1D >>> from fipy import numerix >>> mesh = Grid1D(dx = (1., 1.)) >>> L = 1 >>> R = 2 >>> var = CellVariable(mesh = mesh, value = (L, R)) >>> faceValue = var.harmonicFaceValue[mesh.interiorFaces.value] >>> answer = L * R / ((R - L) * (0.5 / 1.) + L) >>> print(numerix.allclose(faceValue, answer, atol = 1e-10, rtol = 1e-10)) True
>>> mesh = Grid1D(dx = (2., 4.)) >>> var = CellVariable(mesh = mesh, value = (L, R)) >>> faceValue = var.harmonicFaceValue[mesh.interiorFaces.value] >>> answer = L * R / ((R - L) * (1.0 / 3.0) + L) >>> print(numerix.allclose(faceValue, answer, atol = 1e-10, rtol = 1e-10)) True
>>> mesh = Grid1D(dx = (10., 100.)) >>> var = CellVariable(mesh = mesh, value = (L, R)) >>> faceValue = var.harmonicFaceValue[mesh.interiorFaces.value] >>> answer = L * R / ((R - L) * (5.0 / 55.0) + L) >>> print(numerix.allclose(faceValue, answer, atol = 1e-10, rtol = 1e-10)) True
- inBaseUnits()¶
Return the value of the Variable with all units reduced to their base SI elements.
>>> e = Variable(value="2.7 Hartree*Nav") >>> print(e.inBaseUnits().allclose("7088849.01085 kg*m**2/s**2/mol")) 1
- inUnitsOf(*units)¶
Returns one or more Variable objects that express the same physical quantity in different units. The units are specified by strings containing their names. The units must be compatible with the unit of the object. If one unit is specified, the return value is a single Variable.
>>> freeze = Variable('0 degC') >>> print(freeze.inUnitsOf('degF').allclose("32.0 degF")) 1
If several units are specified, the return value is a tuple of Variable instances with with one element per unit such that the sum of all quantities in the tuple equals the the original quantity and all the values except for the last one are integers. This is used to convert to irregular unit systems like hour/minute/second. The original object will not be changed.
>>> t = Variable(value=314159., unit='s') >>> from builtins import zip >>> print(numerix.allclose([e.allclose(v) for (e, v) in zip(t.inUnitsOf('d', 'h', 'min', 's'), ... ['3.0 d', '15.0 h', '15.0 min', '59.0 s'])], ... True)) 1
- itemset(value)¶
- property itemsize¶
- property leastSquaresGrad¶
Return
, which is determined by solving for
in the following matrix equation,
The matrix equation is derived by minimizing the following least squares sum,
Tests
>>> from fipy import Grid2D >>> m = Grid2D(nx=2, ny=2, dx=0.1, dy=2.0) >>> print(numerix.allclose(CellVariable(mesh=m, value=(0, 1, 3, 6)).leastSquaresGrad.globalValue, \ ... [[8.0, 8.0, 24.0, 24.0], ... [1.2, 2.0, 1.2, 2.0]])) True
>>> from fipy import Grid1D >>> print(numerix.allclose(CellVariable(mesh=Grid1D(dx=(2.0, 1.0, 0.5)), ... value=(0, 1, 2)).leastSquaresGrad.globalValue, [[0.461538461538, 0.8, 1.2]])) True
- max(axis=None)¶
- min(axis=None)¶
>>> from fipy import Grid2D, CellVariable >>> mesh = Grid2D(nx=5, ny=5) >>> x, y = mesh.cellCenters >>> v = CellVariable(mesh=mesh, value=x*y) >>> print(v.min()) 0.25
- property minmodFaceValue¶
Returns a FaceVariable with a value that is the minimum of the absolute values of the adjacent cells. If the values are of opposite sign then the result is zero:
>>> from fipy import * >>> print(CellVariable(mesh=Grid1D(nx=2), value=(1, 2)).minmodFaceValue) [1 1 2] >>> print(CellVariable(mesh=Grid1D(nx=2), value=(-1, -2)).minmodFaceValue) [-1 -1 -2] >>> print(CellVariable(mesh=Grid1D(nx=2), value=(-1, 2)).minmodFaceValue) [-1 0 2]
- property name¶
- property numericValue¶
- property old¶
Return the values of the CellVariable from the previous solution sweep.
Combinations of CellVariable’s should also return old values.
>>> from fipy.meshes import Grid1D >>> mesh = Grid1D(nx = 2) >>> from fipy.variables.cellVariable import CellVariable >>> var1 = CellVariable(mesh = mesh, value = (2, 3), hasOld = 1) >>> var2 = CellVariable(mesh = mesh, value = (3, 4)) >>> v = var1 * var2 >>> print(v) [ 6 12] >>> var1.value = ((3, 2)) >>> print(v) [9 8] >>> print(v.old) [ 6 12]
The following small test is to correct for a bug when the operator does not just use variables.
>>> v1 = var1 * 3 >>> print(v1) [9 6] >>> print(v1.old) [6 9]
- parallelRandom()¶
- put(indices, value)¶
- random()¶
- property rank¶
- ravel()¶
- rdot(other, opShape=None, operatorClass=None)¶
Return the mesh-element–by–mesh-element (cell-by-cell, face-by-face, etc.) scalar product
Both self and other can be of arbitrary rank, and other does not need to be a _MeshVariable.
- release(constraint)¶
Remove constraint from self
>>> from fipy import * >>> m = Grid1D(nx=3) >>> v = CellVariable(mesh=m, value=m.cellCenters[0]) >>> c = Constraint(0., where=m.facesLeft) >>> v.constrain(c) >>> print(v.faceValue) [ 0. 1. 2. 2.5] >>> v.release(constraint=c) >>> print(v.faceValue) [ 0.5 1. 2. 2.5]
- scramble()¶
Generate a new random distribution.
- setValue(value, unit=None, where=None)¶
Set the value of the Variable. Can take a masked array.
>>> a = Variable((1, 2, 3)) >>> a.setValue(5, where=(1, 0, 1)) >>> print(a) [5 2 5]
>>> b = Variable((4, 5, 6)) >>> a.setValue(b, where=(1, 0, 1)) >>> print(a) [4 2 6] >>> print(b) [4 5 6] >>> a.value = 3 >>> print(a) [3 3 3]
>>> b = numerix.array((3, 4, 5)) >>> a.value = b >>> a[:] = 1 >>> print(b) [3 4 5]
>>> a.setValue((4, 5, 6), where=(1, 0)) Traceback (most recent call last): .... ValueError: shape mismatch: objects cannot be broadcast to a single shape
- property shape¶
>>> from fipy.meshes import Grid2D >>> from fipy.variables.cellVariable import CellVariable >>> mesh = Grid2D(nx=2, ny=3) >>> var = CellVariable(mesh=mesh) >>> print(numerix.allequal(var.shape, (6,))) True >>> print(numerix.allequal(var.arithmeticFaceValue.shape, (17,))) True >>> print(numerix.allequal(var.grad.shape, (2, 6))) True >>> print(numerix.allequal(var.faceGrad.shape, (2, 17))) True
Have to account for zero length arrays
>>> from fipy import Grid1D >>> m = Grid1D(nx=0) >>> v = CellVariable(mesh=m, elementshape=(2,)) >>> numerix.allequal((v * 1).shape, (2, 0)) True
- std(axis=None, **kwargs)¶
Evaluate standard deviation of all the elements of a MeshVariable.
Adapted from http://mpitutorial.com/tutorials/mpi-reduce-and-allreduce/
>>> import fipy as fp >>> mesh = fp.Grid2D(nx=2, ny=2, dx=2., dy=5.) >>> var = fp.CellVariable(value=(1., 2., 3., 4.), mesh=mesh) >>> print((var.std()**2).allclose(1.25)) True
- property subscribedVariables¶
- sum(axis=None)¶
- take(ids, axis=0)¶
- tostring(max_line_width=75, precision=8, suppress_small=False, separator=' ')¶
- property unit¶
Return the unit object of self.
>>> Variable(value="1 m").unit <PhysicalUnit m>
- updateOld()¶
Set the values of the previous solution sweep to the current values.
>>> from fipy import * >>> v = CellVariable(mesh=Grid1D(), hasOld=False) >>> v.updateOld() Traceback (most recent call last): ... AssertionError: The updateOld method requires the CellVariable to have an old value. Set hasOld to True when instantiating the CellVariable.
- property value¶
“Evaluate” the Variable and return its value (longhand)
>>> a = Variable(value=3) >>> print(a.value) 3 >>> b = a + 4 >>> b (Variable(value=array(3)) + 4) >>> b.value 7
- class fipy.UpwindConvectionTerm(coeff=1.0, var=None)¶
Bases:
_AbstractUpwindConvectionTerm
The discretization for this
Term
is given bywhere
and
is calculated using the upwind convection scheme. For further details see Numerical Schemes.
Create a _AbstractConvectionTerm object.
>>> from fipy import * >>> m = Grid1D(nx = 2) >>> cv = CellVariable(mesh = m) >>> fv = FaceVariable(mesh = m) >>> vcv = CellVariable(mesh=m, rank=1) >>> vfv = FaceVariable(mesh=m, rank=1) >>> __ConvectionTerm(coeff = cv) Traceback (most recent call last): ... VectorCoeffError: The coefficient must be a vector value. >>> __ConvectionTerm(coeff = fv) Traceback (most recent call last): ... VectorCoeffError: The coefficient must be a vector value. >>> __ConvectionTerm(coeff = vcv) __ConvectionTerm(coeff=_ArithmeticCellToFaceVariable(value=array([[ 0., 0., 0.]]), mesh=UniformGrid1D(dx=1.0, nx=2))) >>> __ConvectionTerm(coeff = vfv) __ConvectionTerm(coeff=FaceVariable(value=array([[ 0., 0., 0.]]), mesh=UniformGrid1D(dx=1.0, nx=2))) >>> __ConvectionTerm(coeff = (1,)) __ConvectionTerm(coeff=(1,)) >>> ExplicitUpwindConvectionTerm(coeff = (0,)).solve(var=cv, solver=DummySolver()) Traceback (most recent call last): ... TransientTermError: The equation requires a TransientTerm with explicit convection. >>> (TransientTerm(0.) - ExplicitUpwindConvectionTerm(coeff = (0,))).solve(var=cv, solver=DummySolver(), dt=1.)
>>> (TransientTerm() - ExplicitUpwindConvectionTerm(coeff = 1)).solve(var=cv, solver=DummySolver(), dt=1.) Traceback (most recent call last): ... VectorCoeffError: The coefficient must be a vector value. >>> m2 = Grid2D(nx=2, ny=1) >>> cv2 = CellVariable(mesh=m2) >>> vcv2 = CellVariable(mesh=m2, rank=1) >>> vfv2 = FaceVariable(mesh=m2, rank=1) >>> __ConvectionTerm(coeff=vcv2) __ConvectionTerm(coeff=_ArithmeticCellToFaceVariable(value=array([[ 0., 0., 0., 0., 0., 0., 0.], [ 0., 0., 0., 0., 0., 0., 0.]]), mesh=UniformGrid2D(dx=1.0, nx=2, dy=1.0, ny=1))) >>> __ConvectionTerm(coeff=vfv2) __ConvectionTerm(coeff=FaceVariable(value=array([[ 0., 0., 0., 0., 0., 0., 0.], [ 0., 0., 0., 0., 0., 0., 0.]]), mesh=UniformGrid2D(dx=1.0, nx=2, dy=1.0, ny=1))) >>> (TransientTerm() - ExplicitUpwindConvectionTerm(coeff = ((0,), (0,)))).solve(var=cv2, solver=DummySolver(), dt=1.) >>> (TransientTerm() - ExplicitUpwindConvectionTerm(coeff = (0, 0))).solve(var=cv2, solver=DummySolver(), dt=1.)
- Parameters:
coeff (The Term’s coefficient value.) –
- property RHSvector¶
Return the RHS vector calculated in solve() or sweep(). The cacheRHSvector() method should be called before solve() or sweep() to cache the vector.
- __add__(other)¶
- __and__(other)¶
- __div__(other)¶
- __eq__(other)¶
Return self==value.
- __hash__()¶
Return hash(self).
- __mul__(other)¶
Multiply a term
>>> 2. * __NonDiffusionTerm(coeff=0.5) __NonDiffusionTerm(coeff=1.0)
Test for ticket:291.
>>> from fipy import PowerLawConvectionTerm >>> PowerLawConvectionTerm(coeff=[[1], [0]]) * 1.0 PowerLawConvectionTerm(coeff=array([[ 1.], [ 0.]]))
- __neg__()¶
Negate a Term.
>>> -__NonDiffusionTerm(coeff=1.) __NonDiffusionTerm(coeff=-1.0)
- __pos__()¶
- __radd__(other)¶
- __rand__(other)¶
- __repr__()¶
The representation of a Term object is given by,
>>> print(__UnaryTerm(123.456)) __UnaryTerm(coeff=123.456)
- __rmul__(other)¶
Multiply a term
>>> 2. * __NonDiffusionTerm(coeff=0.5) __NonDiffusionTerm(coeff=1.0)
Test for ticket:291.
>>> from fipy import PowerLawConvectionTerm >>> PowerLawConvectionTerm(coeff=[[1], [0]]) * 1.0 PowerLawConvectionTerm(coeff=array([[ 1.], [ 0.]]))
- __rsub__(other)¶
- __sub__(other)¶
- __truediv__(other)¶
- cacheMatrix()¶
Informs solve() and sweep() to cache their matrix so that matrix can return the matrix.
- cacheRHSvector()¶
Informs solve() and sweep() to cache their right hand side vector so that getRHSvector() can return it.
- copy()¶
- getDefaultSolver(var=None, solver=None, *args, **kwargs)¶
- justErrorVector(var=None, solver=None, boundaryConditions=(), dt=1.0, underRelaxation=None, residualFn=None)¶
Builds the Term’s linear system once.
This method also recalculates and returns the error as well as applying under-relaxation.
justErrorVector returns the overlapping local value in parallel (not the non-overlapping value).
>>> from fipy.solvers import DummySolver >>> from fipy import * >>> m = Grid1D(nx=10) >>> v = CellVariable(mesh=m) >>> len(DiffusionTerm().justErrorVector(v, solver=DummySolver())) == m.numberOfCells True
- Parameters:
var (CellVariable) – Variable to be solved for. Provides the initial condition, the old value and holds the solution on completion.
solver (Solver) – Iterative solver to be used to solve the linear system of equations. The default sovler depends on the solver package selected.
boundaryConditions (
tuple
ofBoundaryCondition
) –dt (float) – Timestep size.
underRelaxation (float) – Usually a value between 0 and 1 or None in the case of no under-relaxation
residualFn (function) – Takes var, matrix, and RHSvector arguments, used to customize the residual calculation.
- Returns:
error – The residual vector
- Return type:
- justResidualVector(var=None, solver=None, boundaryConditions=(), dt=None, underRelaxation=None, residualFn=None)¶
Builds the Term’s linear system once.
This method also recalculates and returns the residual as well as applying under-relaxation.
justResidualVector returns the overlapping local value in parallel (not the non-overlapping value).
>>> from fipy import * >>> m = Grid1D(nx=10) >>> v = CellVariable(mesh=m) >>> len(numerix.asarray(DiffusionTerm().justResidualVector(v))) == m.numberOfCells True
- Parameters:
var (CellVariable) – Variable to be solved for. Provides the initial condition, the old value and holds the solution on completion.
solver (Solver) – Iterative solver to be used to solve the linear system of equations. The default sovler depends on the solver package selected.
boundaryConditions (
tuple
ofBoundaryCondition
) –dt (float) – Timestep size.
underRelaxation (float) – Usually a value between 0 and 1 or None in the case of no under-relaxation
residualFn (function) – Takes var, matrix, and RHSvector arguments, used to customize the residual calculation.
- Returns:
residual – The residual vector
- Return type:
- property matrix¶
Return the matrix calculated in solve() or sweep(). The cacheMatrix() method should be called before solve() or sweep() to cache the matrix.
- residualVectorAndNorm(var=None, solver=None, boundaryConditions=(), dt=None, underRelaxation=None, residualFn=None)¶
Builds the Term’s linear system once.
This method also recalculates and returns the residual as well as applying under-relaxation.
- Parameters:
var (CellVariable) – Variable to be solved for. Provides the initial condition, the old value and holds the solution on completion.
solver (Solver) – Iterative solver to be used to solve the linear system of equations. The default sovler depends on the solver package selected.
boundaryConditions (
tuple
ofBoundaryCondition
) –dt (float) – Timestep size.
underRelaxation (float) – Usually a value between 0 and 1 or None in the case of no under-relaxation
residualFn (function) – Takes var, matrix, and RHSvector arguments, used to customize the residual calculation.
- Returns:
residual (~fipy.variables.cellVariable.CellVariable) – The residual vector
norm (float) – The L2 norm of residual,
- solve(var=None, solver=None, boundaryConditions=(), dt=None)¶
Builds and solves the Term’s linear system once. This method does not return the residual. It should be used when the residual is not required.
- Parameters:
var (CellVariable) – Variable to be solved for. Provides the initial condition, the old value and holds the solution on completion.
solver (Solver) – Iterative solver to be used to solve the linear system of equations. The default sovler depends on the solver package selected.
boundaryConditions (
tuple
ofBoundaryCondition
) –dt (float) – Timestep size.
- sweep(var=None, solver=None, boundaryConditions=(), dt=None, underRelaxation=None, residualFn=None, cacheResidual=False, cacheError=False)¶
Builds and solves the Term’s linear system once. This method also recalculates and returns the residual as well as applying under-relaxation.
- Parameters:
var (CellVariable) – Variable to be solved for. Provides the initial condition, the old value and holds the solution on completion.
solver (Solver) – Iterative solver to be used to solve the linear system of equations. The default sovler depends on the solver package selected.
boundaryConditions (
tuple
ofBoundaryCondition
) –dt (float) – Timestep size.
underRelaxation (float) – Usually a value between 0 and 1 or None in the case of no under-relaxation
residualFn (function) – Takes var, matrix, and RHSvector arguments, used to customize the residual calculation.
cacheResidual (bool) – If True, calculate and store the residual vector
in the residualVector member of Term
cacheError (bool) – If True, use the residual vector
to solve
for the error vector
and store it in the errorVector member of Term
- Returns:
residual – The residual vector
- Return type:
- class fipy.VTKCellViewer(vars, title=None, limits={}, **kwlimits)¶
Bases:
VTKViewer
Renders CellVariable data in VTK format
Creates a VTKViewer
- Parameters:
vars (CellVariable or FaceVariable or list) – the MeshVariable objects to display.
title (str, optional) – displayed at the top of the Viewer window
limits (dict, optional) – a (deprecated) alternative to limit keyword arguments
xmin (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.
xmax (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.
ymin (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.
ymax (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.
zmin (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.
zmax (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.
datamin (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.
datamax (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.
- property limits¶
- plot(filename=None)¶
Update the display of the viewed variables.
- Parameters:
filename (str) – If not None, the name of a file to save the image into.
- plotMesh(filename=None)¶
Display a representation of the mesh
- Parameters:
filename (str) – If not None, the name of a file to save the image into.
- setLimits(limits={}, **kwlimits)¶
Update the limits.
- Parameters:
limits (dict, optional) – a (deprecated) alternative to limit keyword arguments
xmin (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
xmax (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
ymin (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
ymax (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
zmin (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
zmax (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
datamin (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
datamax (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
- property title¶
The text appearing at the top center.
(default: if
len(self.vars) == 1
, the name ofself.vars[0]
, otherwise""
.)
- class fipy.VTKFaceViewer(vars, title=None, limits={}, **kwlimits)¶
Bases:
VTKViewer
Renders _MeshVariable data in VTK format
Creates a VTKViewer
- Parameters:
vars (CellVariable or FaceVariable or list) – the MeshVariable objects to display.
title (str, optional) – displayed at the top of the Viewer window
limits (dict, optional) – a (deprecated) alternative to limit keyword arguments
xmin (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.
xmax (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.
ymin (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.
ymax (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.
zmin (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.
zmax (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.
datamin (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.
datamax (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.
- property limits¶
- plot(filename=None)¶
Update the display of the viewed variables.
- Parameters:
filename (str) – If not None, the name of a file to save the image into.
- plotMesh(filename=None)¶
Display a representation of the mesh
- Parameters:
filename (str) – If not None, the name of a file to save the image into.
- setLimits(limits={}, **kwlimits)¶
Update the limits.
- Parameters:
limits (dict, optional) – a (deprecated) alternative to limit keyword arguments
xmin (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
xmax (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
ymin (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
ymax (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
zmin (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
zmax (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
datamin (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
datamax (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
- property title¶
The text appearing at the top center.
(default: if
len(self.vars) == 1
, the name ofself.vars[0]
, otherwise""
.)
- fipy.VTKViewer(vars, title=None, limits={}, **kwlimits)¶
Generic function for creating a VTKViewer.
The VTKViewer factory will search the module tree and return an instance of the first VTKViewer it finds of the correct dimension and rank.
- Parameters:
vars (CellVariable or FaceVariable or list) – the MeshVariable objects to display.
title (str, optional) – displayed at the top of the Viewer window
limits (dict, optional) – a (deprecated) alternative to limit keyword arguments
xmin (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.
xmax (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.
ymin (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.
ymax (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.
zmin (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.
zmax (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.
datamin (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.
datamax (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.
- class fipy.VanLeerConvectionTerm(coeff=1.0, var=None)¶
Bases:
ExplicitUpwindConvectionTerm
Create a _AbstractConvectionTerm object.
>>> from fipy import * >>> m = Grid1D(nx = 2) >>> cv = CellVariable(mesh = m) >>> fv = FaceVariable(mesh = m) >>> vcv = CellVariable(mesh=m, rank=1) >>> vfv = FaceVariable(mesh=m, rank=1) >>> __ConvectionTerm(coeff = cv) Traceback (most recent call last): ... VectorCoeffError: The coefficient must be a vector value. >>> __ConvectionTerm(coeff = fv) Traceback (most recent call last): ... VectorCoeffError: The coefficient must be a vector value. >>> __ConvectionTerm(coeff = vcv) __ConvectionTerm(coeff=_ArithmeticCellToFaceVariable(value=array([[ 0., 0., 0.]]), mesh=UniformGrid1D(dx=1.0, nx=2))) >>> __ConvectionTerm(coeff = vfv) __ConvectionTerm(coeff=FaceVariable(value=array([[ 0., 0., 0.]]), mesh=UniformGrid1D(dx=1.0, nx=2))) >>> __ConvectionTerm(coeff = (1,)) __ConvectionTerm(coeff=(1,)) >>> ExplicitUpwindConvectionTerm(coeff = (0,)).solve(var=cv, solver=DummySolver()) Traceback (most recent call last): ... TransientTermError: The equation requires a TransientTerm with explicit convection. >>> (TransientTerm(0.) - ExplicitUpwindConvectionTerm(coeff = (0,))).solve(var=cv, solver=DummySolver(), dt=1.)
>>> (TransientTerm() - ExplicitUpwindConvectionTerm(coeff = 1)).solve(var=cv, solver=DummySolver(), dt=1.) Traceback (most recent call last): ... VectorCoeffError: The coefficient must be a vector value. >>> m2 = Grid2D(nx=2, ny=1) >>> cv2 = CellVariable(mesh=m2) >>> vcv2 = CellVariable(mesh=m2, rank=1) >>> vfv2 = FaceVariable(mesh=m2, rank=1) >>> __ConvectionTerm(coeff=vcv2) __ConvectionTerm(coeff=_ArithmeticCellToFaceVariable(value=array([[ 0., 0., 0., 0., 0., 0., 0.], [ 0., 0., 0., 0., 0., 0., 0.]]), mesh=UniformGrid2D(dx=1.0, nx=2, dy=1.0, ny=1))) >>> __ConvectionTerm(coeff=vfv2) __ConvectionTerm(coeff=FaceVariable(value=array([[ 0., 0., 0., 0., 0., 0., 0.], [ 0., 0., 0., 0., 0., 0., 0.]]), mesh=UniformGrid2D(dx=1.0, nx=2, dy=1.0, ny=1))) >>> (TransientTerm() - ExplicitUpwindConvectionTerm(coeff = ((0,), (0,)))).solve(var=cv2, solver=DummySolver(), dt=1.) >>> (TransientTerm() - ExplicitUpwindConvectionTerm(coeff = (0, 0))).solve(var=cv2, solver=DummySolver(), dt=1.)
- Parameters:
coeff (The Term’s coefficient value.) –
- property RHSvector¶
Return the RHS vector calculated in solve() or sweep(). The cacheRHSvector() method should be called before solve() or sweep() to cache the vector.
- __add__(other)¶
- __and__(other)¶
- __div__(other)¶
- __eq__(other)¶
Return self==value.
- __hash__()¶
Return hash(self).
- __mul__(other)¶
Multiply a term
>>> 2. * __NonDiffusionTerm(coeff=0.5) __NonDiffusionTerm(coeff=1.0)
Test for ticket:291.
>>> from fipy import PowerLawConvectionTerm >>> PowerLawConvectionTerm(coeff=[[1], [0]]) * 1.0 PowerLawConvectionTerm(coeff=array([[ 1.], [ 0.]]))
- __neg__()¶
Negate a Term.
>>> -__NonDiffusionTerm(coeff=1.) __NonDiffusionTerm(coeff=-1.0)
- __pos__()¶
- __radd__(other)¶
- __rand__(other)¶
- __repr__()¶
The representation of a Term object is given by,
>>> print(__UnaryTerm(123.456)) __UnaryTerm(coeff=123.456)
- __rmul__(other)¶
Multiply a term
>>> 2. * __NonDiffusionTerm(coeff=0.5) __NonDiffusionTerm(coeff=1.0)
Test for ticket:291.
>>> from fipy import PowerLawConvectionTerm >>> PowerLawConvectionTerm(coeff=[[1], [0]]) * 1.0 PowerLawConvectionTerm(coeff=array([[ 1.], [ 0.]]))
- __rsub__(other)¶
- __sub__(other)¶
- __truediv__(other)¶
- cacheMatrix()¶
Informs solve() and sweep() to cache their matrix so that matrix can return the matrix.
- cacheRHSvector()¶
Informs solve() and sweep() to cache their right hand side vector so that getRHSvector() can return it.
- copy()¶
- getDefaultSolver(var=None, solver=None, *args, **kwargs)¶
- justErrorVector(var=None, solver=None, boundaryConditions=(), dt=1.0, underRelaxation=None, residualFn=None)¶
Builds the Term’s linear system once.
This method also recalculates and returns the error as well as applying under-relaxation.
justErrorVector returns the overlapping local value in parallel (not the non-overlapping value).
>>> from fipy.solvers import DummySolver >>> from fipy import * >>> m = Grid1D(nx=10) >>> v = CellVariable(mesh=m) >>> len(DiffusionTerm().justErrorVector(v, solver=DummySolver())) == m.numberOfCells True
- Parameters:
var (CellVariable) – Variable to be solved for. Provides the initial condition, the old value and holds the solution on completion.
solver (Solver) – Iterative solver to be used to solve the linear system of equations. The default sovler depends on the solver package selected.
boundaryConditions (
tuple
ofBoundaryCondition
) –dt (float) – Timestep size.
underRelaxation (float) – Usually a value between 0 and 1 or None in the case of no under-relaxation
residualFn (function) – Takes var, matrix, and RHSvector arguments, used to customize the residual calculation.
- Returns:
error – The residual vector
- Return type:
- justResidualVector(var=None, solver=None, boundaryConditions=(), dt=None, underRelaxation=None, residualFn=None)¶
Builds the Term’s linear system once.
This method also recalculates and returns the residual as well as applying under-relaxation.
justResidualVector returns the overlapping local value in parallel (not the non-overlapping value).
>>> from fipy import * >>> m = Grid1D(nx=10) >>> v = CellVariable(mesh=m) >>> len(numerix.asarray(DiffusionTerm().justResidualVector(v))) == m.numberOfCells True
- Parameters:
var (CellVariable) – Variable to be solved for. Provides the initial condition, the old value and holds the solution on completion.
solver (Solver) – Iterative solver to be used to solve the linear system of equations. The default sovler depends on the solver package selected.
boundaryConditions (
tuple
ofBoundaryCondition
) –dt (float) – Timestep size.
underRelaxation (float) – Usually a value between 0 and 1 or None in the case of no under-relaxation
residualFn (function) – Takes var, matrix, and RHSvector arguments, used to customize the residual calculation.
- Returns:
residual – The residual vector
- Return type:
- property matrix¶
Return the matrix calculated in solve() or sweep(). The cacheMatrix() method should be called before solve() or sweep() to cache the matrix.
- residualVectorAndNorm(var=None, solver=None, boundaryConditions=(), dt=None, underRelaxation=None, residualFn=None)¶
Builds the Term’s linear system once.
This method also recalculates and returns the residual as well as applying under-relaxation.
- Parameters:
var (CellVariable) – Variable to be solved for. Provides the initial condition, the old value and holds the solution on completion.
solver (Solver) – Iterative solver to be used to solve the linear system of equations. The default sovler depends on the solver package selected.
boundaryConditions (
tuple
ofBoundaryCondition
) –dt (float) – Timestep size.
underRelaxation (float) – Usually a value between 0 and 1 or None in the case of no under-relaxation
residualFn (function) – Takes var, matrix, and RHSvector arguments, used to customize the residual calculation.
- Returns:
residual (~fipy.variables.cellVariable.CellVariable) – The residual vector
norm (float) – The L2 norm of residual,
- solve(var=None, solver=None, boundaryConditions=(), dt=None)¶
Builds and solves the Term’s linear system once. This method does not return the residual. It should be used when the residual is not required.
- Parameters:
var (CellVariable) – Variable to be solved for. Provides the initial condition, the old value and holds the solution on completion.
solver (Solver) – Iterative solver to be used to solve the linear system of equations. The default sovler depends on the solver package selected.
boundaryConditions (
tuple
ofBoundaryCondition
) –dt (float) – Timestep size.
- sweep(var=None, solver=None, boundaryConditions=(), dt=None, underRelaxation=None, residualFn=None, cacheResidual=False, cacheError=False)¶
Builds and solves the Term’s linear system once. This method also recalculates and returns the residual as well as applying under-relaxation.
- Parameters:
var (CellVariable) – Variable to be solved for. Provides the initial condition, the old value and holds the solution on completion.
solver (Solver) – Iterative solver to be used to solve the linear system of equations. The default sovler depends on the solver package selected.
boundaryConditions (
tuple
ofBoundaryCondition
) –dt (float) – Timestep size.
underRelaxation (float) – Usually a value between 0 and 1 or None in the case of no under-relaxation
residualFn (function) – Takes var, matrix, and RHSvector arguments, used to customize the residual calculation.
cacheResidual (bool) – If True, calculate and store the residual vector
in the residualVector member of Term
cacheError (bool) – If True, use the residual vector
to solve
for the error vector
and store it in the errorVector member of Term
- Returns:
residual – The residual vector
- Return type:
- class fipy.Variable(*args, **kwds)¶
Bases:
object
Lazily evaluated quantity with units.
Using a
Variable
in a mathematical expression will create an automatic dependencyVariable
, e.g.,>>> a = Variable(value=3) >>> b = 4 * a >>> b (Variable(value=array(3)) * 4) >>> b() 12
Changes to the value of a
Variable
will automatically trigger changes in any dependentVariable
objects>>> a.setValue(5) >>> b (Variable(value=array(5)) * 4) >>> print(b()) 20
Create a Variable.
>>> Variable(value=3) Variable(value=array(3)) >>> Variable(value=3, unit="m") Variable(value=PhysicalField(3,'m')) >>> Variable(value=3, unit="m", array=numerix.zeros((3, 2), 'l')) Variable(value=PhysicalField(array([[3, 3], [3, 3], [3, 3]]),'m'))
- Parameters:
value (int or float or array_like) –
unit (str or PhysicalUnit) – The physical units of the variable
array (ndarray, optional) – The storage array for the Variable
name (str) – The user-readable name of the Variable
cached (bool) – whether to cache or always recalculate the value
- __abs__()¶
Following test it to fix a bug with C inline string using abs() instead of fabs()
>>> print(abs(Variable(2.3) - Variable(1.2))) 1.1
Check representation works with different versions of numpy
>>> print(repr(abs(Variable(2.3)))) numerix.fabs(Variable(value=array(2.3)))
- __add__(other)¶
- __and__(other)¶
This test case has been added due to a weird bug that was appearing.
>>> a = Variable(value=(0, 0, 1, 1)) >>> b = Variable(value=(0, 1, 0, 1)) >>> print(numerix.equal((a == 0) & (b == 1), [False, True, False, False]).all()) True >>> print(a & b) [0 0 0 1] >>> from fipy.meshes import Grid1D >>> mesh = Grid1D(nx=4) >>> from fipy.variables.cellVariable import CellVariable >>> a = CellVariable(value=(0, 0, 1, 1), mesh=mesh) >>> b = CellVariable(value=(0, 1, 0, 1), mesh=mesh) >>> print(numerix.allequal((a == 0) & (b == 1), [False, True, False, False])) True >>> print(a & b) [0 0 0 1]
- __array__(t=None)¶
Attempt to convert the Variable to a numerix array object
>>> v = Variable(value=[2, 3]) >>> print(numerix.array(v)) [2 3]
A dimensional Variable will convert to the numeric value in its base units
>>> v = Variable(value=[2, 3], unit="mm") >>> numerix.array(v) array([ 0.002, 0.003])
- __array_priority__ = 100.0¶
- __array_wrap__(arr, context=None)¶
Required to prevent numpy not calling the reverse binary operations. Both the following tests are examples ufuncs.
>>> print(type(numerix.array([1.0, 2.0]) * Variable([1.0, 2.0]))) <class 'fipy.variables.binaryOperatorVariable...binOp'>
>>> from scipy.special import gamma as Gamma >>> print(type(Gamma(Variable([1.0, 2.0])))) <class 'fipy.variables.unaryOperatorVariable...unOp'>
- __bool__()¶
>>> print(bool(Variable(value=0))) 0 >>> print(bool(Variable(value=(0, 0, 1, 1)))) Traceback (most recent call last): ... ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
- __call__()¶
“Evaluate” the Variable and return its value
>>> a = Variable(value=3) >>> print(a()) 3 >>> b = a + 4 >>> b (Variable(value=array(3)) + 4) >>> b() 7
- __div__(other)¶
- __eq__(other)¶
Test if a Variable is equal to another quantity
>>> a = Variable(value=3) >>> b = (a == 4) >>> b (Variable(value=array(3)) == 4) >>> b() 0
- __float__()¶
- __ge__(other)¶
Test if a Variable is greater than or equal to another quantity
>>> a = Variable(value=3) >>> b = (a >= 4) >>> b (Variable(value=array(3)) >= 4) >>> b() 0 >>> a.value = 4 >>> print(b()) 1 >>> a.value = 5 >>> print(b()) 1
- __getitem__(index)¶
“Evaluate” the Variable and return the specified element
>>> a = Variable(value=((3., 4.), (5., 6.)), unit="m") + "4 m" >>> print(a[1, 1]) 10.0 m
It is an error to slice a Variable whose value is not sliceable
>>> Variable(value=3)[2] Traceback (most recent call last): ... IndexError: 0-d arrays can't be indexed
- __getstate__()¶
Used internally to collect the necessary information to
pickle
the Variable to persistent storage.
- __gt__(other)¶
Test if a Variable is greater than another quantity
>>> a = Variable(value=3) >>> b = (a > 4) >>> b (Variable(value=array(3)) > 4) >>> print(b()) 0 >>> a.value = 5 >>> print(b()) 1
- __hash__()¶
Return hash(self).
- __int__()¶
- __invert__()¶
Returns logical “not” of the Variable
>>> a = Variable(value=True) >>> print(~a) False
- __iter__()¶
- __le__(other)¶
Test if a Variable is less than or equal to another quantity
>>> a = Variable(value=3) >>> b = (a <= 4) >>> b (Variable(value=array(3)) <= 4) >>> b() 1 >>> a.value = 4 >>> print(b()) 1 >>> a.value = 5 >>> print(b()) 0
- __len__()¶
- __lt__(other)¶
Test if a Variable is less than another quantity
>>> a = Variable(value=3) >>> b = (a < 4) >>> b (Variable(value=array(3)) < 4) >>> b() 1 >>> a.value = 4 >>> print(b()) 0 >>> print(1000000000000000000 * Variable(1) < 1.) 0 >>> print(1000 * Variable(1) < 1.) 0
Python automatically reverses the arguments when necessary
>>> 4 > Variable(value=3) (Variable(value=array(3)) < 4)
- __mod__(other)¶
- __mul__(other)¶
- __ne__(other)¶
Test if a Variable is not equal to another quantity
>>> a = Variable(value=3) >>> b = (a != 4) >>> b (Variable(value=array(3)) != 4) >>> b() 1
- __neg__()¶
- static __new__(cls, *args, **kwds)¶
- __nonzero__()¶
>>> print(bool(Variable(value=0))) 0 >>> print(bool(Variable(value=(0, 0, 1, 1)))) Traceback (most recent call last): ... ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
- __or__(other)¶
This test case has been added due to a weird bug that was appearing.
>>> a = Variable(value=(0, 0, 1, 1)) >>> b = Variable(value=(0, 1, 0, 1)) >>> print(numerix.equal((a == 0) | (b == 1), [True, True, False, True]).all()) True >>> print(a | b) [0 1 1 1] >>> from fipy.meshes import Grid1D >>> mesh = Grid1D(nx=4) >>> from fipy.variables.cellVariable import CellVariable >>> a = CellVariable(value=(0, 0, 1, 1), mesh=mesh) >>> b = CellVariable(value=(0, 1, 0, 1), mesh=mesh) >>> print(numerix.allequal((a == 0) | (b == 1), [True, True, False, True])) True >>> print(a | b) [0 1 1 1]
- __pos__()¶
- __pow__(other)¶
return self**other, or self raised to power other
>>> print(Variable(1, "mol/l")**3) 1.0 mol**3/l**3 >>> print((Variable(1, "mol/l")**3).unit) <PhysicalUnit mol**3/l**3>
- __radd__(other)¶
- __rdiv__(other)¶
- __repr__()¶
Return repr(self).
- __rmul__(other)¶
- __rpow__(other)¶
- __rsub__(other)¶
- __rtruediv__(other)¶
- __setitem__(index, value)¶
- __setstate__(dict)¶
Used internally to create a new Variable from
pickled
persistent storage.
- __str__()¶
Return str(self).
- __sub__(other)¶
- __truediv__(other)¶
- all(axis=None)¶
>>> print(Variable(value=(0, 0, 1, 1)).all()) 0 >>> print(Variable(value=(1, 1, 1, 1)).all()) 1
- allclose(other, rtol=1e-05, atol=1e-08)¶
>>> var = Variable((1, 1)) >>> print(var.allclose((1, 1))) 1 >>> print(var.allclose((1,))) 1
The following test is to check that the system does not run out of memory.
>>> from fipy.tools import numerix >>> var = Variable(numerix.ones(10000)) >>> print(var.allclose(numerix.zeros(10000, 'l'))) False
- allequal(other)¶
- any(axis=None)¶
>>> print(Variable(value=0).any()) 0 >>> print(Variable(value=(0, 0, 1, 1)).any()) 1
- cacheMe(recursive=False)¶
- constrain(value, where=None)¶
Constrain the Variable to have a value at an index or mask location specified by where.
>>> v = Variable((0, 1, 2, 3)) >>> v.constrain(2, numerix.array((True, False, False, False))) >>> print(v) [2 1 2 3] >>> v[:] = 10 >>> print(v) [ 2 10 10 10] >>> v.constrain(5, numerix.array((False, False, True, False))) >>> print(v) [ 2 10 5 10] >>> v[:] = 6 >>> print(v) [2 6 5 6] >>> v.constrain(8) >>> print(v) [8 8 8 8] >>> v[:] = 10 >>> print(v) [8 8 8 8] >>> del v.constraints[2] >>> print(v) [ 2 10 5 10]
>>> from fipy.variables.cellVariable import CellVariable >>> from fipy.meshes import Grid2D >>> m = Grid2D(nx=2, ny=2) >>> x, y = m.cellCenters >>> v = CellVariable(mesh=m, rank=1, value=(x, y)) >>> v.constrain(((0.,), (-1.,)), where=m.facesLeft) >>> print(v.faceValue) [[ 0.5 1.5 0.5 1.5 0.5 1.5 0. 1. 1.5 0. 1. 1.5] [ 0.5 0.5 1. 1. 1.5 1.5 -1. 0.5 0.5 -1. 1.5 1.5]]
- Parameters:
value (float or array_like) – The value of the constraint
where (array_like of
bool
) – The constraint mask or index specifying the location of the constraint
- property constraints¶
- copy()¶
Make an duplicate of the Variable
>>> a = Variable(value=3) >>> b = a.copy() >>> b Variable(value=array(3))
The duplicate will not reflect changes made to the original
>>> a.setValue(5) >>> b Variable(value=array(3))
Check that this works for arrays.
>>> a = Variable(value=numerix.array((0, 1, 2))) >>> b = a.copy() >>> b Variable(value=array([0, 1, 2])) >>> a[1] = 3 >>> b Variable(value=array([0, 1, 2]))
- dontCacheMe(recursive=False)¶
- dot(other, opShape=None, operatorClass=None, axis=0)¶
- getsctype(default=None)¶
Returns the Numpy sctype of the underlying array.
>>> Variable(1).getsctype() == numerix.NUMERIX.obj2sctype(numerix.array(1)) True >>> Variable(1.).getsctype() == numerix.NUMERIX.obj2sctype(numerix.array(1.)) True >>> Variable((1, 1.)).getsctype() == numerix.NUMERIX.obj2sctype(numerix.array((1., 1.))) True
- inBaseUnits()¶
Return the value of the Variable with all units reduced to their base SI elements.
>>> e = Variable(value="2.7 Hartree*Nav") >>> print(e.inBaseUnits().allclose("7088849.01085 kg*m**2/s**2/mol")) 1
- inUnitsOf(*units)¶
Returns one or more Variable objects that express the same physical quantity in different units. The units are specified by strings containing their names. The units must be compatible with the unit of the object. If one unit is specified, the return value is a single Variable.
>>> freeze = Variable('0 degC') >>> print(freeze.inUnitsOf('degF').allclose("32.0 degF")) 1
If several units are specified, the return value is a tuple of Variable instances with with one element per unit such that the sum of all quantities in the tuple equals the the original quantity and all the values except for the last one are integers. This is used to convert to irregular unit systems like hour/minute/second. The original object will not be changed.
>>> t = Variable(value=314159., unit='s') >>> from builtins import zip >>> print(numerix.allclose([e.allclose(v) for (e, v) in zip(t.inUnitsOf('d', 'h', 'min', 's'), ... ['3.0 d', '15.0 h', '15.0 min', '59.0 s'])], ... True)) 1
- itemset(value)¶
- property itemsize¶
- max(axis=None)¶
- min(axis=None)¶
- property name¶
- property numericValue¶
- put(indices, value)¶
- ravel()¶
- release(constraint)¶
Remove constraint from self
>>> v = Variable((0, 1, 2, 3)) >>> v.constrain(2, numerix.array((True, False, False, False))) >>> v[:] = 10 >>> from fipy.boundaryConditions.constraint import Constraint >>> c1 = Constraint(5, numerix.array((False, False, True, False))) >>> v.constrain(c1) >>> v[:] = 6 >>> v.constrain(8) >>> v[:] = 10 >>> del v.constraints[2] >>> v.release(constraint=c1) >>> print(v) [ 2 10 10 10]
- setValue(value, unit=None, where=None)¶
Set the value of the Variable. Can take a masked array.
>>> a = Variable((1, 2, 3)) >>> a.setValue(5, where=(1, 0, 1)) >>> print(a) [5 2 5]
>>> b = Variable((4, 5, 6)) >>> a.setValue(b, where=(1, 0, 1)) >>> print(a) [4 2 6] >>> print(b) [4 5 6] >>> a.value = 3 >>> print(a) [3 3 3]
>>> b = numerix.array((3, 4, 5)) >>> a.value = b >>> a[:] = 1 >>> print(b) [3 4 5]
>>> a.setValue((4, 5, 6), where=(1, 0)) Traceback (most recent call last): .... ValueError: shape mismatch: objects cannot be broadcast to a single shape
- property shape¶
Tuple of array dimensions.
>>> Variable(value=3).shape () >>> numerix.allequal(Variable(value=(3,)).shape, (1,)) True >>> numerix.allequal(Variable(value=(3, 4)).shape, (2,)) True
>>> Variable(value="3 m").shape () >>> numerix.allequal(Variable(value=(3,), unit="m").shape, (1,)) True >>> numerix.allequal(Variable(value=(3, 4), unit="m").shape, (2,)) True
- std(axis=None, **kwargs)¶
- property subscribedVariables¶
- sum(axis=None)¶
- take(ids, axis=0)¶
- tostring(max_line_width=75, precision=8, suppress_small=False, separator=' ')¶
- property unit¶
Return the unit object of self.
>>> Variable(value="1 m").unit <PhysicalUnit m>
- property value¶
“Evaluate” the Variable and return its value (longhand)
>>> a = Variable(value=3) >>> print(a.value) 3 >>> b = a + 4 >>> b (Variable(value=array(3)) + 4) >>> b.value 7
- exception fipy.VectorCoeffError(s='The coefficient must be a vector value.')¶
Bases:
TypeError
- __cause__¶
exception cause
- __context__¶
exception context
- __delattr__(name, /)¶
Implement delattr(self, name).
- __getattribute__(name, /)¶
Return getattr(self, name).
- __reduce__()¶
Helper for pickle.
- __repr__()¶
Return repr(self).
- __setattr__(name, value, /)¶
Implement setattr(self, name, value).
- __setstate__()¶
- __str__()¶
Return str(self).
- __suppress_context__¶
- __traceback__¶
- add_note()¶
Exception.add_note(note) – add a note to the exception
- args¶
- with_traceback()¶
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
- fipy.Viewer(vars, title=None, limits={}, FIPY_VIEWER=None, **kwlimits)¶
Generic function for creating a Viewer.
The Viewer factory will search the module tree and return an instance of the first Viewer it finds that supports the dimensions of vars. Setting the FIPY_VIEWER environment variable to either matplotlib, mayavi, tsv, or vtk will specify the viewer.
The kwlimits or limits parameters can be used to constrain the view. For example:
Viewer(vars=some1Dvar, xmin=0.5, xmax=None, datamax=3)
or:
Viewer(vars=some1Dvar, limits={'xmin': 0.5, 'xmax': None, 'datamax': 3})
will return a viewer that displays a line plot from an x value of 0.5 up to the largest x value in the dataset. The data values will be truncated at an upper value of 3, but will have no lower limit.
- Parameters:
vars (CellVariable or list) – the Variable objects to display.
title (str, optional) – displayed at the top of the Viewer window
limits (dict) – a (deprecated) alternative to limit keyword arguments
FIPY_VIEWER – a specific viewer to attempt (possibly multiple times for multiple variables)
xmin (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
xmax (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
ymin (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
ymax (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
zmin (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
zmax (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
datamin (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
datamax (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.
- class fipy.Vitals¶
Bases:
Document
Returns XML formatted information about current FiPy environment
- ATTRIBUTE_NODE = 2¶
- CDATA_SECTION_NODE = 4¶
- COMMENT_NODE = 8¶
- DOCUMENT_FRAGMENT_NODE = 11¶
- DOCUMENT_NODE = 9¶
- DOCUMENT_TYPE_NODE = 10¶
- ELEMENT_NODE = 1¶
- ENTITY_NODE = 6¶
- ENTITY_REFERENCE_NODE = 5¶
- NOTATION_NODE = 12¶
- PROCESSING_INSTRUCTION_NODE = 7¶
- TEXT_NODE = 3¶
- __slots__ = ('_elem_info', 'doctype', '_id_search_stack', 'childNodes', '_id_cache')¶
- __str__()¶
Return str(self).
- actualEncoding = None¶
- appendChild(child)¶
- appendInfo(name, svnpath=None, **kwargs)¶
append some additional information, possibly about a project under a separate svn repository
- async_ = False¶
- attributes = None¶
- childNodes¶
- dictToXML(d, name)¶
- doctype¶
- property documentElement¶
Top-level element of this document.
- documentURI = None¶
- encoding = None¶
- errorHandler = None¶
- property firstChild¶
First child node, or None.
- implementation = <xml.dom.minidom.DOMImplementation object>¶
- property lastChild¶
Last child node, or None.
- property localName¶
Namespace-local name of this node.
- namespaceURI = None¶
- nextSibling = None¶
- nodeName = '#document'¶
- nodeType = 9¶
- nodeValue = None¶
- ownerDocument = None¶
- parentNode = None¶
- prefix = None¶
- previousSibling = None¶
- save(fname)¶
- standalone = None¶
- strictErrorChecking = False¶
- svn(*args)¶
- svncmd(cmd, *args)¶
- tupleToXML(t, name, keys=None)¶
- version = None¶
- fipy.openMSHFile(name, dimensions=None, coordDimensions=None, communicator=SerialPETScCommWrapper(), overlap=1, mode='r', background=None)¶
Open a Gmsh MSH file
- Parameters:
filename (str) – Gmsh output file
dimensions (int) – Dimension of mesh
coordDimensions (int) – Dimension of shapes
overlap (int) – The number of overlapping cells for parallel simulations. Generally 1 is adequate. Higher order equations or discretizations require more. If overlap is greater than one, communication reverts to serial, as Gmsh only provides one layer of ghost cells.
mode (str) – Beginning with r for reading and w for writing. The file will be created if it doesn’t exist when opened for writing; it will be truncated when opened for writing. Add a b to the mode for binary files.
background (CellVariable) – Specifies the desired characteristic lengths of the mesh cells
- fipy.openPOSFile(name, communicator=SerialPETScCommWrapper(), mode='w')¶
Open a Gmsh POS post-processing file