def test_mass_matrix_1d(self): """ Test mass matrix in 1d for a simple geometry """ g = pp.CartGrid(3, 1) g.compute_geometry() # Mass weight is scaled by aperture 0.01 specified_parameters = {"mass_weight": 0.5 * 1e-2} data = pp.initialize_default_data(g, {}, "flow", specified_parameters) discr = pp.MixedMassMatrix() discr.discretize(g, data) lhs, rhs = discr.assemble_matrix_rhs(g, data) lhs_known = ( 1.0 / 600 * np.array( [ [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0], [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0], ] ) ) self.assertTrue(np.allclose(lhs.toarray(), lhs_known)) self.assertTrue(np.allclose(rhs, 0))
def __init__(self, gb, folder, tol): self.model = "flow" self.gb = gb self.data = None self.assembler = None # discretization operator name self.discr_name = "flux" self.discr = pp.RT0(self.model) self.mass_name = "mass" self.mass = pp.MixedMassMatrix(self.model) self.coupling_name = self.discr_name + "_coupling" self.coupling = pp.RobinCoupling(self.model, self.discr) self.source_name = "source" self.source = pp.DualScalarSource(self.model) # master variable name self.variable = "flow_variable" self.mortar = "lambda_" + self.variable # post process variables self.pressure = "pressure" self.flux = "darcy_flux" # it has to be this one self.P0_flux = "P0_darcy_flux" # tolerance self.tol = tol # exporter self.save = pp.Exporter(self.gb, "solution", folder=folder)