Ejemplo n.º 1
0
    def eval(self, expr, solvars, phys, **kwargs):
        refine = kwargs.pop("refine", 1)
        emesh_idx = get_emesh_idx(self, expr, solvars, phys)

        if len(emesh_idx) > 1:
            assert False, "expression involves multiple mesh (emesh length != 1)"
        if len(emesh_idx) < 1:
            emesh_idx = [
                0
            ]  # use default mesh in this case. (for non mesh dependent expression)
        #    assert False, "expression is not defined on any mesh"

        if (refine != self.refine or self.emesh_idx != emesh_idx[0]):
            self.refine = refine
            self.preprocess_geometry(self.battrs, emesh_idx=emesh_idx[0])
        val = eval_on_faces(self, expr, solvars, phys)
        if val is None: return None, None, None

        edge_only = kwargs.pop('edge_only', False)
        export_type = kwargs.pop('export_type', 1)

        #print self.ptx.shape, val.shape, self.ridx.shape
        if export_type == 2:
            return self.ptx, val, None
        if not edge_only:
            return self.ptx, val, self.ridx
        else:
            assert False, "NCFace does not support edge_only"
Ejemplo n.º 2
0
    def eval(self, expr, solvars, phys, **kwargs):

        emesh_idx = get_emesh_idx(self, expr, solvars, phys)
        #print("emesh_idx", emesh_idx)
        if len(emesh_idx) > 1:
            assert False, "expression involves multiple mesh (emesh length != 1)"
        #if len(emesh_idx) < 1:
        #    assert False, "expression is not defined on any mesh"
        #(this could happen when expression is pure geometryical like "x+y")

        if len(emesh_idx) == 1:
            if self.emesh_idx != emesh_idx[0]:
                self.preprocess_geometry(self.attrs, emesh_idx=emesh_idx[0])

        val = eval_at_nodals(self, expr, solvars, phys)
        if val is None: return None, None, None

        #        return self.locs[self.iverts_inv], val[self.iverts_inv, ...]

        refine = kwargs.pop('refine', 1)

        if refine == 1:
            return self.locs, val, self.iverts_inv
        else:
            from nodal_refinement import refine_edge_data
            try:
                mesh = self.mesh()[self.emesh_idx]
                if mesh.Dimension() == 3:
                    assert False, "edge refinement is not supported for dim=3"
                ptx, data, ridx = refine_edge_data(mesh, self.ibeles, val,
                                                   self.iverts_inv, refine)
            except:
                import traceback
                traceback.print_exc()
            return ptx, data, ridx
    def eval(self, expr, solvars, phys):
        from petram.sol.bdr_nodal_evaluator import get_emesh_idx

        emesh_idx = get_emesh_idx(self, expr, solvars, phys)
        if len(emesh_idx) > 1:
            assert False, "expression involves multiple mesh (emesh length != 1)"

        if len(emesh_idx) == 1:
            if self.emesh_idx != emesh_idx[0]:
                self.preprocess_geometry(self.attrs,
                                         emesh_idx=emesh_idx[0],
                                         pc_type=self.pc_type,
                                         pc_param=self.pc_param)

        if self.counts == 0:
            return None, None, None

        val = self.eval_at_points(expr, solvars, phys)

        if val is None:
            return None, None, None

        shape = self.ans_shape[:-1]

        if self.subset is None:
            attrs = self.masked_attrs.reshape(shape)
        else:
            attrs = np.zeros(self.ans_shape[:-1], dtype=int) - 1
            attrs[self.subset] = self.masked_attrs.reshape(
                self.points.shape[:-1])

        return self.ans_points, val, attrs
Ejemplo n.º 4
0
    def eval(self, expr, solvars, phys, **kwargs):

        emesh_idx = get_emesh_idx(self, expr, solvars, phys)
        if len(emesh_idx) > 1:
            assert False, "expression involves multiple mesh (emesh length != 1)"
        #if len(emesh_idx) < 1:
        #    assert False, "expression is not defined on any mesh"
        #(this could happen when expression is pure geometryical like "x+y")

        if len(emesh_idx) == 1:
            if self.emesh_idx != emesh_idx[0]:
                self.preprocess_geometry(self.attrs, emesh_idx=emesh_idx[0])

        val = eval_at_nodals(self, expr, solvars, phys)
        if val is None: return None, None, None

        #        return self.locs[self.iverts_inv], val[self.iverts_inv, ...]
        return self.locs, val, self.iverts_inv
Ejemplo n.º 5
0
    def eval(self, expr, solvars, phys, **kwargs):
        if self.vertices is None: return None, None, None

        emesh_idx = get_emesh_idx(self, expr, solvars, phys)
        if len(emesh_idx) > 1:
            assert False, "expression involves multiple mesh (emesh length != 1)"
        #if len(emesh_idx) < 1:
        #    assert False, "expression is not defined on any mesh"
        #(this could happen when expression is pure geometryical like "x+y")

        if len(emesh_idx) == 1:
            if self.emesh_idx != emesh_idx[0]:
                self.preprocess_geometry(self.attrs,
                                         plane=self.plane,
                                         emesh_idx=emesh_idx[0])

        val = eval_at_nodals(self, expr, solvars, phys)
        if val is None: return None, None, None
        value = self.interp_mat.dot(val)
        value = value.flatten()
        verts = self.vertices.reshape(-1, self.vertices.shape[-1])
        return (verts, value,
                np.arange(len(value)).reshape(-1, self.vertices.shape[-1]))