def green( cot, BC ): ''' plots the domain Green's function with boundary condition BC on the mesh for a source. ''' u = cot.u v = cot.v normal = cot.normal kappa = cot.kappa f = Constant( 0.0 ) tmp = Function( cot.V ) loc_solver = cot.solvers( BC ) L = f*v*dx b = assemble(L) # Make the RHS have delta funcitons at the sources helper.apply_sources( cot, b ) sol = Function( cot.V ) loc_solver( tmp.vector(), b ) loc_solver( sol.vector(), assemble(tmp*v*dx) ) # Create the descrition list so we keep track of files desc = [ BC, "Greens Function" ] if "ours" in BC: desc.append( cot.quad ) helper.save_plots( sol, desc, cot )
def variance( cot, BC ): ''' plots domain pointwise variance with boundary condition BC. ''' u = cot.u v = cot.v kappa = cot.kappa f = Constant( 0.0 ) tmp = Function( cot.V ) loc_solver = cot.solvers( BC ) L = f*v*dx b = assemble(L) if "dirichlet" in BC: pass else: g = cot.gs( BC ) helper.apply_sources( cot, b, scaling = g ) sol_constant_var = Function( cot.V ) loc_solver( tmp.vector(), b ) loc_solver( sol_constant_var.vector(), assemble(tmp*v*dx) ) sol_constant_var.vector().set_local( sol_constant_var.vector().array() * g.vector().array() ) # Create the descrition list so we keep track of files greens_desc = [ BC, "Constant Variance", "Greens Function"] std_desc = [ BC, "Standard Deviation" ] if "ours" in BC: greens_desc.append( cot.quad ) std_desc.append( cot.quad ) helper.save_plots( cot.stds( BC ), std_desc, cot ) if not "dirichlet" in BC: helper.save_plots( sol_constant_var, greens_desc, cot )