def mbfv(x, p, poly_type): assert np.min(x) >= -1 and np.max(x) <= 1, "x should be in [-1,1]" assert p >= 1 and isinstance(p, int), "p should be positve integer" if poly_type == "LobN": # lobatto polynomials nodes, weights = lobatto_quad(p) basis = lagrange_basis(nodes, x) return basis elif poly_type == "LobE": # lobatto edges functions nodes, weights = lobatto_quad(p) basis = edge_basis(nodes, x) return basis elif poly_type == "GauN": # gauss polynomials nodes, weights = gauss_quad(p) basis = lagrange_basis(nodes, x) return basis elif poly_type == "GauE": # gauss edges functions nodes, weights = gauss_quad(p) basis = edge_basis(nodes, x) return basis elif poly_type == "etGN": # extended-gauss polynomials nodes, weights = extended_gauss_quad(p) basis = lagrange_basis(nodes, x) return basis elif poly_type == "etGE": # extended-gauss edges functions nodes, weights = extended_gauss_quad(p) basis = edge_basis(nodes, x) return basis else: raise Exception("Error, poly_type wrong......")
def evaluate_basis(self, domain=None): """Evaluate the basis.""" if domain is None: edge_basis_1d_odx = [ functionals.edge_basis(self._face_nodes[i], self._quad_nodes[i]) for i in range(2) ] edge_basis_1d_ody = [ functionals.edge_basis(self._face_nodes[-i - 1], self._quad_nodes[i]) for i in range(2) ] self.xi, self.eta = np.meshgrid(self._quad_nodes[0], self._quad_nodes[1]) else: edge_basis_1d_odx = [ functionals.edge_basis(self._face_nodes[i], domain[i]) for i in range(2) ] edge_basis_1d_ody = [ functionals.edge_basis(self._face_nodes[-i - 1], domain[i]) for i in range(2) ] self.xi, self.eta = np.meshgrid(*domain) self.basis_odx = np.kron(edge_basis_1d_odx[0], edge_basis_1d_odx[1]) self.basis_ody = np.kron(edge_basis_1d_ody[0], edge_basis_1d_ody[1]) self.basis = np.vstack((self.basis_odx, self.basis_ody))
def evaluate_basis(self, domain=None): """Evaluate the basis. The basis are evaluated in at the position of the dof or quad nodes (if supplied) or at the domain specified. """ if domain is None: # evaluate the lagrange basis in one 1d for both x and y at quad points self._xi, self._eta = np.meshgrid(self._quad_nodes[0], self._quad_nodes[1]) edge_basis_1d = [ functionals.edge_basis(self._face_nodes[i], self._quad_nodes[i]) for i in range(2) ] self._evaluate_basis_domain = (self._quad_nodes[0], self._quad_nodes[1]) else: self._xi, self._eta = np.meshgrid(*domain) edge_basis_1d = [ functionals.edge_basis(self._face_nodes[i], domain[i]) for i in range(2) ] self._evaluate_basis_domain = domain self._basis = np.kron(edge_basis_1d[0], edge_basis_1d[1]) return self._basis
def evaluate_basis(self, domain=None): """ #SUMMARY: Update self.xi, eta and basis. """ if domain is None: self._xi, self._eta = np.meshgrid(self._quad_nodes[0], self._quad_nodes[1]) nodal_basis_1d = [ functionals.lagrange_basis(self._nodal_nodes[i], self._quad_nodes[1 - i]) for i in range(2) ] edge_basis_1d = [ functionals.edge_basis(self._edge_nodes[i], self._quad_nodes[i]) for i in range(2) ] self._basis = np.zeros( (self.num_basis, np.size(self._quad_nodes[0]) * np.size(self._quad_nodes[1]))) self._evaluate_basis_domain = (self._quad_nodes[0], self._quad_nodes[1]) else: self._xi, self._eta = np.meshgrid(domain[0], domain[1]) nodal_basis_1d = [ functionals.lagrange_basis(self._nodal_nodes[i], domain[1 - i]) for i in range(2) ] edge_basis_1d = [ functionals.edge_basis(self._edge_nodes[i], domain[i]) for i in range(2) ] self._basis = np.zeros( (self.num_basis, np.size(domain[0]) * np.size(domain[1]))) self._evaluate_basis_domain = domain if self.numbering_scheme == 'symmetric1': self._basis[:self.num_basis_xi] = np.kron(nodal_basis_1d[0], edge_basis_1d[0]) self._basis[-self.num_basis_eta:] = np.kron( nodal_basis_1d[1], edge_basis_1d[1]) # self.basis_1edge = np.kron(edge_basis_1d[0], np.ones(np.shape(edge_basis_1d[0]))) # self.basis_1node = np.kron(nodal_basis_1d[0], np.ones(np.shape(nodal_basis_1d[0]))) # self.basis_1node = nodal_basis_1d[0] # sio.savemat('edgebasis', mdict={'edgebasis': self.basis_1node}) # TODO if self.numbering_scheme == 'general' or None: self._basis[:self.num_basis_xi] = np.kron(edge_basis_1d[0], nodal_basis_1d[0]) self._basis[-self.num_basis_eta:] = np.kron( nodal_basis_1d[1], edge_basis_1d[1])
def evaluate_basis(self, domain=None): """Evaluate the basis.""" pass if domain is None: edge_basis_eg = [functionals.edge_basis(self._ext_gauss_nodes, self._quad_nodes[i]) for i in range(2)] edge_basis_gl = [functionals.edge_basis(self._lobatto_nodes , self._quad_nodes[i]) for i in range(2)] node_basis_eg = [functionals.lagrange_basis(self._ext_gauss_nodes, self._quad_nodes[i]) for i in range(2)] node_basis_gl = [functionals.lagrange_basis(self._lobatto_nodes , self._quad_nodes[i]) for i in range(2)] self.xi, self.eta = np.meshgrid(self._quad_nodes, self._quad_nodes) else: edge_basis_eg = [functionals.edge_basis(self._ext_gauss_nodes, domain[i]) for i in range(2)] edge_basis_gl = [functionals.edge_basis(self._lobatto_nodes , domain[i]) for i in range(2)] node_basis_eg = [functionals.lagrange_basis(self._ext_gauss_nodes, domain[i]) for i in range(2)] node_basis_gl = [functionals.lagrange_basis(self._lobatto_nodes , domain[i]) for i in range(2)] self.xi, self.eta = np.meshgrid(*domain) self.basis_dxodx = np.kron(edge_basis_eg[0], node_basis_gl[1]) # OK self.basis_dyodx = np.kron(node_basis_eg[0], edge_basis_gl[1]) # OK self.basis_dxody = np.kron(edge_basis_gl[0], node_basis_eg[1]) # OK self.basis_dyody = np.kron(node_basis_gl[0], edge_basis_eg[1]) # OK self.basis = np.vstack( ( self.basis_dxodx, self.basis_dyodx, self.basis_dxody, self.basis_dyody ) )