def test_add_mesh(self):
        """Test addMesh method

        """

        pointCoordinates = foamface.getAllPointCoordinates(self.name)
        self.assertEqual(self.pointCoordinates, pointCoordinates)
        cellPoints = foamface.getAllCellPoints(self.name)
        self.assertEqual(set(self.cellPoints), set(cellPoints))
        facePoints = foamface.getAllFacePoints(self.name)
        self.assertEqual(self.facePoints, facePoints)
        patchNames = foamface.getBoundaryPatchNames(self.name)
        self.assertEqual(self.patchNames, patchNames)
        patchFaces = foamface.getBoundaryPatchFaces(self.name)
        self.assertEqual(self.patchFaces, patchFaces)
    def test_add_mesh(self):
        """Test addMesh method

        """

        pointCoordinates = foamface.getAllPointCoordinates(self.name)
        self.assertEqual(self.pointCoordinates, pointCoordinates)
        cellPoints = foamface.getAllCellPoints(self.name)
        self.assertEqual(set(self.cellPoints), set(cellPoints))
        facePoints = foamface.getAllFacePoints(self.name)
        self.assertEqual(self.facePoints, facePoints)
        patchNames = foamface.getBoundaryPatchNames(self.name)
        self.assertEqual(self.patchNames, patchNames)
        patchFaces = foamface.getBoundaryPatchFaces(self.name)
        self.assertEqual(self.patchFaces, patchFaces)
Exemplo n.º 3
0
 def _get_packed_coordinate_list(self):
     """ get packed list of points coordinate values
     """
     return foamface.getAllPointCoordinates(self.name)
Exemplo n.º 4
0
    def _iter_points(self, point_uuids=None):
        """ Returns an iterator over the selected points.

        Returns an iterator over the points with uuid in
        point_ids. If none of the ids in point_ids exists,
        an empty iterator is returned. If there is no ids
        inside point_ids, a iterator over all points of
        the mesh is returned instead.

        Parameters
        ----------
        point_uuids : list of uuids, optional
            uuids of the desired points, default empty

        Returns
        -------
        iter
            Iterator over the selected points

        """

        if point_uuids is None:
            point_coordinates = foamface.getAllPointCoordinates(self.name)
            data_map = self._get_point_data_map()

            i = 0
            label = 0
            while i < len(point_coordinates):
                point = Point(point_coordinates[i:i + 3],
                              self._foamPointLabelToUuid[label])
                for dataKey, data in data_map.iteritems():
                    if dataTypeMap[dataKey] == "scalar":
                        if dataKey == CUBA.VOLUME_FRACTION:
                            if self._foamPhaseNameToMaterial:
                                material1 = self._foamPhaseNameToMaterial[
                                    phaseNames[0]]
                                material2 = self._foamPhaseNameToMaterial[
                                    phaseNames[1]]
                                vol_frac1 = data[label]
                                phase1_vol_frac = PhaseVolumeFraction(
                                    material1, vol_frac1)
                                phase2_vol_frac = PhaseVolumeFraction(
                                    material2, 1 - vol_frac1)
                                point.data[dataKey] = [
                                    phase1_vol_frac, phase2_vol_frac
                                ]
                        else:
                            point.data[dataKey] = data[label]
                    elif dataTypeMap[dataKey] == "vector":
                        point.data[dataKey] = \
                            [data[label * 3 + k] for k in range(3)]
                    elif dataTypeMap[dataKey] == "tensor":
                        point.data[dataKey] = \
                            [data[label * 9 + k] for k in range(9)]
                yield point
                label += 1
                i += 3
            data_map.clear()
        else:
            for uid in point_uuids:
                point = self._get_point(uid)
                yield Point.from_point(point)
Exemplo n.º 5
0
 def _get_packed_coordinate_list(self):
     """ get packed list of points coordinate values
     """
     return foamface.getAllPointCoordinates(self.name)
Exemplo n.º 6
0
    def _iter_points(self, point_uuids=None):
        """ Returns an iterator over the selected points.

        Returns an iterator over the points with uuid in
        point_ids. If none of the ids in point_ids exists,
        an empty iterator is returned. If there is no ids
        inside point_ids, a iterator over all points of
        the mesh is returned instead.

        Parameters
        ----------
        point_uuids : list of uuids, optional
            uuids of the desired points, default empty

        Returns
        -------
        iter
            Iterator over the selected points

        """

        if point_uuids is None:
            point_coordinates = foamface.getAllPointCoordinates(self.name)
            data_map = self._get_point_data_map()

            i = 0
            label = 0
            while i < len(point_coordinates):
                point = Point(point_coordinates[i:i+3],
                              self._foamPointLabelToUuid[label])
                for dataKey, data in data_map.iteritems():
                    if dataTypeMap[dataKey] == "scalar":
                        if dataKey == CUBA.VOLUME_FRACTION:
                            if self._foamPhaseNameToMaterial:
                                material1 = self._foamPhaseNameToMaterial[
                                    phaseNames[0]]
                                material2 = self._foamPhaseNameToMaterial[
                                    phaseNames[1]]
                                vol_frac1 = data[label]
                                phase1_vol_frac = PhaseVolumeFraction(
                                    material1, vol_frac1)
                                phase2_vol_frac = PhaseVolumeFraction(
                                    material2, 1 - vol_frac1)
                                point.data[dataKey] = [phase1_vol_frac,
                                                       phase2_vol_frac]
                        else:
                            point.data[dataKey] = data[label]
                    elif dataTypeMap[dataKey] == "vector":
                        point.data[dataKey] = \
                            [data[label * 3 + k] for k in range(3)]
                    elif dataTypeMap[dataKey] == "tensor":
                        point.data[dataKey] = \
                            [data[label * 9 + k] for k in range(9)]
                yield point
                label += 1
                i += 3
            data_map.clear()
        else:
            for uid in point_uuids:
                point = self._get_point(uid)
                yield Point.from_point(point)