def readFromFoamFile(cls,
                         pointsFile,
                         facesFile,
                         xViewBasis,
                         yViewBasis=None,
                         viewAnchor=(0,0,0),
                         srcBasisSrc=[[1,0,0],[0,1,0],[0,0,1]]):

        '''
        Construct from a surface saved  by OpenFOAM in foamFile format.
        
        Arguments:
            *pointsFile*: python string.
             Location of the point file. It holds the points (summits) of
             the triangulate grid.
            
            *facesFile*: python string.
             Location of the faces file. It holds the triangles of the grid.
             If facesFile=None, the triangles are created with the Delauney
             method.
             
            *viewAnchor*: python of numpy array. Shape = 3.
             Location of the (0,0) point of your grid. Defined in the source
             basis (meaning: the coordinate system of the OpenFOAM simulation)
             
            *xViewBasis*: python of numpy array. Shape = 3.
            
            *yViewBasis*: python of numpy array. Shape = 3. If it's None, it 
             will be estimated. Works for surfaces normal to one coordinate
             direction
            
            *srcBasisSrc*: python of numpy array. Shape = 3,3. Keep default.
        '''
        
                
        ptsSrc = ParserFunctions.parseFoamFile_sampledSurface(pointsFile)
        ptsTgt,afftrans,lintrans=transformPoints(ptsSrc=ptsSrc,
                                                xViewBasis=xViewBasis,
                                                yViewBasis=yViewBasis,
                                                viewAnchor=viewAnchor,
                                                srcBasisSrc=srcBasisSrc)

        #get triangles
        if facesFile==None:
            triangles = None
        else:
            triangles = ParserFunctions.parseFoamFile_sampledSurface(facesFile)[:,1:4]

        # update class member variables
        return cls(x=ptsTgt[:,0],
                   y=ptsTgt[:,1],
                   z=ptsTgt[:,2],
                   triangles=triangles,
                   mask=None,
                   affTrans=afftrans,
                   linTrans=lintrans)
Example #2
0
    def readFromFoamFile(cls,
                         pointsFile,
                         facesFile,
                         xViewBasis,
                         yViewBasis=None,
                         viewAnchor=(0, 0, 0),
                         srcBasisSrc=[[1, 0, 0], [0, 1, 0], [0, 0, 1]]):
        '''
        Construct from a surface saved  by OpenFOAM in foamFile format.
        
        Arguments:
            *pointsFile*: python string.
             Location of the point file. It holds the points (summits) of
             the triangulate grid.
            
            *facesFile*: python string.
             Location of the faces file. It holds the triangles of the grid.
             If facesFile=None, the triangles are created with the Delauney
             method.
             
            *viewAnchor*: python of numpy array. Shape = 3.
             Location of the (0,0) point of your grid. Defined in the source
             basis (meaning: the coordinate system of the OpenFOAM simulation)
             
            *xViewBasis*: python of numpy array. Shape = 3.
            
            *yViewBasis*: python of numpy array. Shape = 3. If it's None, it 
             will be estimated. Works for surfaces normal to one coordinate
             direction
            
            *srcBasisSrc*: python of numpy array. Shape = 3,3. Keep default.
        '''

        ptsSrc = ParserFunctions.parseFoamFile_sampledSurface(pointsFile)
        ptsTgt, afftrans, lintrans = transformPoints(ptsSrc=ptsSrc,
                                                     xViewBasis=xViewBasis,
                                                     yViewBasis=yViewBasis,
                                                     viewAnchor=viewAnchor,
                                                     srcBasisSrc=srcBasisSrc)

        #get triangles
        if facesFile == None:
            triangles = None
        else:
            triangles = ParserFunctions.parseFoamFile_sampledSurface(
                facesFile)[:, 1:4]

        # update class member variables
        return cls(x=ptsTgt[:, 0],
                   y=ptsTgt[:, 1],
                   z=ptsTgt[:, 2],
                   triangles=triangles,
                   mask=None,
                   affTrans=afftrans,
                   linTrans=lintrans)
    def readFromFoamFile(cls,
                         varsFile,
                         triSurfaceMesh,
                         time,
                         projectedField=False):
        '''
        Construct from a surface saved  by OpenFOAM in foamFile format.
        
        Arguments:
            *varsFile*: python string.
             Path to the file holding the scalar field.
             
            *key*: python string
             timestep of the surface. If this information does not matter,
             use 0.
             
            *triSurfaceMesh* :  TriSurfaceMesh object.
             TriSurfaceMesh object, which holds the mesh information.
             
            *projectedField* python bool (default=False)
             Unused for the scalar field, but might be used for the fields
             added with the methods "addField", "addFieldFromFoamFile" and
             "addFieldFromVtk"
        '''

        #get scalars
        slrsTgt = ParserFunctions.parseFoamFile_sampledSurface(varsFile)

        # update class member variables
        return cls(s=slrsTgt,
                   time=time,
                   triSurfaceMesh=triSurfaceMesh,
                   projectedField=projectedField,
                   interpolation=None,
                   kind=None)
    def readFromVTK(cls, vtkFile, triSurfaceMesh, time, projectedField=False):
        '''
        Construct from a surface saved by OpenFOAM in VTK format.
        
        Arguments:
            *varsFile*: python string.
             Path to the vtk-file.
             
            *time*: python float
             timestep of the surface. If this information does not matter,
             use 0.
             
            *triSurfaceMesh* :  TriSurfaceMesh object.
             TriSurfaceMesh object, which holds the mesh information.
             
            *projectedField* python bool (default=False)
             Defines if the data fields has to be projected in the basis of the
             surface. 
        '''
        # read VTK file
        ptsSrc, triangles, slrsTgt = ParserFunctions.parseVTK_ugly_sampledSurface(
            vtkFile)

        # update class member variables
        return cls(s=slrsTgt,
                   time=time,
                   triSurfaceMesh=triSurfaceMesh,
                   projectedField=projectedField,
                   interpolation=None,
                   kind=None)
    def readFromFoamFile(cls,
                         varsFile,
                         triSurfaceMesh,
                         time,
                         projectedField=False):
        '''
        Construct from a surface saved  by OpenFOAM in foamFile format.
        
        Arguments:
            *varsFile*: python string.
             Path to the file holding the scalar field.
             
            *key*: python string
             timestep of the surface. If this information does not matter,
             use 0.
             
            *triSurfaceMesh* :  TriSurfaceMesh object.
             TriSurfaceMesh object, which holds the mesh information.
             
            *projectedField* python bool (default=False)
             Unused for the scalar field, but might be used for the fields
             added with the methods "addField", "addFieldFromFoamFile" and
             "addFieldFromVtk"
        '''

        #get scalars
        slrsTgt = ParserFunctions.parseFoamFile_sampledSurface(varsFile)

        # update class member variables
        return cls(s=slrsTgt,
                   time=time,
                   triSurfaceMesh=triSurfaceMesh,
                   projectedField=projectedField,
                   interpolation=None,
                   kind=None)
    def readFromVTK(cls,
                    vtkFile,
                    triSurfaceMesh,
                    time,
                    projectedField=False):
        '''
        Construct from a surface saved by OpenFOAM in VTK format.
        
        Arguments:
            *varsFile*: python string.
             Path to the vtk-file.
             
            *time*: python float
             timestep of the surface. If this information does not matter,
             use 0.
             
            *triSurfaceMesh* :  TriSurfaceMesh object.
             TriSurfaceMesh object, which holds the mesh information.
             
            *projectedField* python bool (default=False)
             Defines if the data fields has to be projected in the basis of the
             surface. 
        '''     
        # read VTK file
        ptsSrc, triangles, slrsTgt = ParserFunctions.parseVTK_ugly_sampledSurface(vtkFile)


        # update class member variables
        return cls(s=slrsTgt,
                   time=time,
                   triSurfaceMesh=triSurfaceMesh,
                   projectedField=projectedField,
                   interpolation=None,
                   kind=None)
    def readFromVTK(cls,
                    vtkFile,
                    viewAnchor,
                    xViewBasis,
                    yViewBasis,
                    srcBasisSrc=[[1,0,0],[0,1,0],[0,0,1]]):
        '''
        Construct from a surface saved by OpenFOAM in VTK format.
        '''
        afftrans, lintrans = TriSurface.getTransformation(viewAnchor,
                                                          xViewBasis,
                                                          yViewBasis,
                                                          srcBasisSrc)
       
        # read VTK file
        ptsSrc, triangles, vecsSrc = ParserFunctions.parseVTK_ugly_sampledSurface(vtkFile)
        
        # Transform the points
        ptsTgt = np.zeros((ptsSrc.shape[0],ptsSrc.shape[1]))
        for i in range(ptsSrc.shape[0]):
            ptsTgt[i,:] = afftrans.srcToTgt(ptsSrc[i,:])

        # update class member variables
        return cls(x=ptsTgt[:,0],
                   y=ptsTgt[:,1],
                   z=ptsTgt[:,2],
                   triangles=triangles,
                   mask=None,
                   affTrans=afftrans,
                   linTrans=lintrans)
Example #8
0
    def readFromVTK(cls,
                    vtkFile,
                    viewAnchor,
                    xViewBasis,
                    yViewBasis,
                    srcBasisSrc=[[1, 0, 0], [0, 1, 0], [0, 0, 1]]):
        '''
        Construct from a surface saved by OpenFOAM in VTK format.
        '''
        afftrans, lintrans = TriSurface.getTransformation(
            viewAnchor, xViewBasis, yViewBasis, srcBasisSrc)

        # read VTK file
        ptsSrc, triangles, vecsSrc = ParserFunctions.parseVTK_ugly_sampledSurface(
            vtkFile)

        # Transform the points
        ptsTgt = np.zeros((ptsSrc.shape[0], ptsSrc.shape[1]))
        for i in range(ptsSrc.shape[0]):
            ptsTgt[i, :] = afftrans.srcToTgt(ptsSrc[i, :])

        # update class member variables
        return cls(x=ptsTgt[:, 0],
                   y=ptsTgt[:, 1],
                   z=ptsTgt[:, 2],
                   triangles=triangles,
                   mask=None,
                   affTrans=afftrans,
                   linTrans=lintrans)
Example #9
0
    def addFieldFromFoamFile(self, fieldFile, fieldname):
        '''
#        Add a field F (shape d) stored in a foamFile to the current
#        TriSurfaceVector object. See docstring from self.addField() for more
#        information.
        '''
        #get field
        fieldSrc = ParserFunctions.parseFoamFile_sampledSurface(fieldFile)
        self.addField(fieldSrc, fieldname)
    def addFieldFromVTK(self,fieldFile,fieldname):
        '''
#        Add a field F (shape d) stored in a VTK file to the current
#        TriSurfaceVector object. See docstring from self.addField() for more
#        information.
        '''
        #get field
        points, polygon, fieldSrc = ParserFunctions.parseVTK_ugly_sampledSurface(fieldFile)
        self.addField(fieldSrc,fieldname)
    def addFieldFromFoamFile(self,fieldFile,fieldname):
        '''
#        Add a field F (shape d) stored in a foamFile to the current
#        TriSurfaceVector object. See docstring from self.addField() for more
#        information.
        '''
        #get field
        fieldSrc = ParserFunctions.parseFoamFile_sampledSurface(fieldFile)
        self.addField(fieldSrc,fieldname)
Example #12
0
    def addFieldFromVTK(self, fieldFile, fieldname):
        '''
#        Add a field F (shape d) stored in a VTK file to the current
#        TriSurfaceVector object. See docstring from self.addField() for more
#        information.
        '''
        #get field
        points, polygon, fieldSrc = ParserFunctions.parseVTK_ugly_sampledSurface(
            fieldFile)
        self.addField(fieldSrc, fieldname)
    def readFromFoamFile(cls,
                         varsFile,
                         triSurfaceMesh,
                         time,
                         projectedField=False):
        '''
        Construct from a surface saved  by OpenFOAM in foamFile format.
        
        Arguments:
            *varsFile*: python string.
             Path to the file holding the scalar field.
             
            *time*: python float
             timestep of the surface. If this information does not matter,
             use 0.
             
            *triSurfaceMesh* :  TriSurfaceMesh object.
             TriSurfaceMesh object, which holds the mesh information.
             
            *projectedField* python bool (default=False)
             Unused for the scalar field, but might be used for the fields
             added with the methods "addField", "addFieldFromFoamFile" and
             "addFieldFromVtk"
        '''

        #get scalars
        stensSrc = ParserFunctions.parseFoamFile_sampledSurface(varsFile)
        stensTgt = np.zeros((stensSrc.shape[0],stensSrc.shape[1]))
        if projectedField==True:
            for i in range(stensSrc.shape[0]):
                stenAsMat = TriSurface.mat(stensSrc[i,:])
                stensTgt[i,:] = triSurfaceMesh.linTrans.srcToTgt(stenAsMat)
        else:
            stensTgt = stensSrc

        # update class member variables
        return cls(txx=stensTgt[:,0],
                   txy=stensTgt[:,1],
                   txz=stensTgt[:,2],
                   tyy=stensTgt[:,3],
                   tyz=stensTgt[:,4],
                   tzz=stensTgt[:,5],
                   time=time,
                   triSurfaceMesh=triSurfaceMesh,
                   projectedField=projectedField,
                   interpolation=None,
                   kind=None)
    def readFromFoamFile(cls,
                         varsFile,
                         triSurfaceMesh,
                         time,
                         projectedField=False):
        '''
        Construct from a surface saved  by OpenFOAM in foamFile format.
        
        Arguments:
            *varsFile*: python string.
             Path to the file holding the scalar field.
             
            *time*: python float
             timestep of the surface. If this information does not matter,
             use 0.
             
            *triSurfaceMesh* :  TriSurfaceMesh object.
             TriSurfaceMesh object, which holds the mesh information.
             
            *projectedField* python bool (default=False)
             Unused for the scalar field, but might be used for the fields
             added with the methods "addField", "addFieldFromFoamFile" and
             "addFieldFromVtk"
        '''

        #get scalars
        stensSrc = ParserFunctions.parseFoamFile_sampledSurface(varsFile)
        stensTgt = np.zeros((stensSrc.shape[0], stensSrc.shape[1]))
        if projectedField == True:
            for i in range(stensSrc.shape[0]):
                stenAsMat = TriSurface.mat(stensSrc[i, :])
                stensTgt[i, :] = triSurfaceMesh.linTrans.srcToTgt(stenAsMat)
        else:
            stensTgt = stensSrc

        # update class member variables
        return cls(txx=stensTgt[:, 0],
                   txy=stensTgt[:, 1],
                   txz=stensTgt[:, 2],
                   tyy=stensTgt[:, 3],
                   tyz=stensTgt[:, 4],
                   tzz=stensTgt[:, 5],
                   time=time,
                   triSurfaceMesh=triSurfaceMesh,
                   projectedField=projectedField,
                   interpolation=None,
                   kind=None)
    def readFromVTK(cls,
                    vtkFile,
                    triSurfaceMesh,
                    time,
                    projectedField=False):
        '''
        Construct from a surface saved by OpenFOAM in VTK format.
        
        Arguments:
            *varsFile*: python string.
             Path to the vtk-file.
             
            *time*: python float
             timestep of the surface. If this information does not matter,
             use 0.
             
            *triSurfaceMesh* :  TriSurfaceMesh object.
             TriSurfaceMesh object, which holds the mesh information.
             
            *projectedField* python bool (default=False)
             Defines if the data fields has to be projected in the basis of the
             surface. 
        '''     
        # read VTK file
        ptsSrc, triangles, vecsSrc = ParserFunctions.parseVTK_ugly_sampledSurface(vtkFile)
            
        # transform the data
        vecsTgt = np.zeros((vecsSrc.shape[0],vecsSrc.shape[1]))
        if projectedField==True:
            for i in range(vecsSrc.shape[0]):
                vecsTgt[i,:] = triSurfaceMesh.linTrans.srcToTgt(vecsSrc[i,:])
        else:
            vecsTgt = vecsSrc

        # update class member variables
        return cls(vx=vecsTgt[:,0],
                   vy=vecsTgt[:,1],
                   vz=vecsTgt[:,2],
                   time=time,
                   triSurfaceMesh=triSurfaceMesh,
                   projectedField=projectedField,
                   interpolation=None,
                   kind=None)
Example #16
0
    def readFromFoamFile(cls,
                         varsFile,
                         triSurfaceMesh,
                         time,
                         projectedField=False):
        '''
        Construct from a surface saved  by OpenFOAM in foamFile format.
        
        Arguments:
            *varsFile*: python string.
             Path to the file holding the vector field.
             
            *time*: python float
             timestep of the surface. If this information does not matter,
             use 0.
             
            *triSurfaceMesh* :  TriSurfaceMesh object.
             TriSurfaceMesh object, which holds the mesh information.
             
            *projectedField* python bool (default=False)
             Defines if the data fields has to be projected in the basis of the
             surface. 
        '''

        #get vectors (in vecsTgt)
        vecsSrc = ParserFunctions.parseFoamFile_sampledSurface(varsFile)
        vecsTgt = np.zeros((vecsSrc.shape[0], vecsSrc.shape[1]))
        if projectedField == True:
            for i in range(vecsSrc.shape[0]):
                vecsTgt[i, :] = triSurfaceMesh.linTrans.srcToTgt(vecsSrc[i, :])
        else:
            vecsTgt = vecsSrc

        # update class member variables
        return cls(vx=vecsTgt[:, 0],
                   vy=vecsTgt[:, 1],
                   vz=vecsTgt[:, 2],
                   time=time,
                   triSurfaceMesh=triSurfaceMesh,
                   projectedField=projectedField,
                   interpolation=None,
                   kind=None)