def test_generate_list_gausspoints3D(self): for i_test in range(2, 5): with self.subTest(i_test=i_test): # my new gausspoint list generator func gps_1D, gps_wei = gaussPoints(i_test) gps_list = generateGaussPoints3D(gps_1D, gps_wei) # this implementation was made by Alejandro legacy_list = list() for i in range(len(gps_1D)): for j in range(len(gps_1D)): for k in range(len(gps_1D)): legacy_list.append( GaussPoint3D( gps_1D[i], gps_1D[j], gps_1D[k], gps_wei[i] * gps_wei[j] * gps_wei[k])) for i in range(len(gps_1D)**3): with self.subTest(i=i): gps_test = gps_list[i] gps_exact = legacy_list[i] np_test.assert_array_almost_equal( gps_exact.r, gps_test.r) np_test.assert_array_almost_equal( gps_exact.s, gps_test.s) np_test.assert_array_almost_equal( gps_exact.t, gps_test.t) np_test.assert_array_almost_equal( gps_exact.w, gps_test.w)
def test_gausspoints_N3(self): # Seteo de valores exactos weights = np.array([5 / 9, 8 / 9, 5 / 9], dtype=float) gp1 = math.sqrt(3 / 5) gps = np.array([-gp1, 0, gp1], dtype=float) # Generacion a partir de la funcion a testear gps_result, weights_result = gaussPoints(3) np_test.assert_array_almost_equal(gps, gps_result, decimal=12) np_test.assert_array_almost_equal(weights, weights_result, decimal=12)
def test_gausspoints_N2(self): # Seteo de valores exactos weights = np.array([1, 1], dtype=float) gp1 = 1 / math.sqrt(3) gps = np.array([-gp1, gp1], dtype=float) # Generacion a partir de la funcion a testear gps_result, weights_result = gaussPoints(2) np_test.assert_array_equal(gps, gps_result) np_test.assert_array_equal(weights, weights_result)
def setUpSpectralMats3D(self, ngl): nodes1D, operWei = lobattoPoints(ngl) gps1D, fullWei = gaussPoints(ngl) if ngl <= 3 else \ lobattoPoints(ngl) gps_red1D, redWei = gaussPoints(ngl - 1) cnodes1D, _ = lobattoPoints(2) (self.H, self.Hrs, self.gps) = \ self.computeMats3D(nodes1D, gps1D, fullWei) (self.HRed, self.HrsRed, self.gpsRed) = \ self.computeMats3D(nodes1D, gps_red1D, redWei) (self.HOp, self.HrsOp, self.gpsOp) = \ self.computeMats3D(nodes1D, nodes1D, operWei) (self.HCoo, self.HrsCoo, self.gpsCoo) = \ self.computeMats3D(cnodes1D, gps1D, fullWei) (self.HCooRed, self.HrsCooRed, self.gpsCooRed) = \ self.computeMats3D(cnodes1D, gps_red1D, redWei) (self.HCooOp, self.HrsCooOp, self.gpsCooOp) = \ self.computeMats3D(cnodes1D, nodes1D, operWei) (self.HCoo1D, _) = self.interpFun1D(cnodes1D, nodes1D)