Skip to content

Commit

Permalink
again
Browse files Browse the repository at this point in the history
  • Loading branch information
grosilho committed Mar 20, 2024
1 parent f672095 commit 07a7830
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -104,14 +104,11 @@ def __init__(self, nelems=128, t0=0.0, family='CG', order=4, refinements=1, nu=0
# Create boundary condition
fdim = domain.topology.dim - 1
boundary_facets = dfx.mesh.locate_entities_boundary(
domain, fdim, lambda x: np.full(x.shape[1], True, dtype=bool)
)
self.bc = dfx.fem.dirichletbc(
PETSc.ScalarType(self.c), dfx.fem.locate_dofs_topological(self.V, fdim, boundary_facets), self.V
)
self.bc_hom = dfx.fem.dirichletbc(
PETSc.ScalarType(0), dfx.fem.locate_dofs_topological(self.V, fdim, boundary_facets), self.V
)
domain, fdim, lambda x: np.full(x.shape[1], True, dtype=bool))
self.bc = dfx.fem.dirichletbc(PETSc.ScalarType(self.c),
dfx.fem.locate_dofs_topological(self.V, fdim, boundary_facets), self.V)
self.bc_hom = dfx.fem.dirichletbc(PETSc.ScalarType(0),
dfx.fem.locate_dofs_topological(self.V, fdim, boundary_facets), self.V)
self.fix_bc_for_residual = True

# Stiffness term (Laplace) and mass term
Expand All @@ -130,7 +127,8 @@ def __init__(self, nelems=128, t0=0.0, family='CG', order=4, refinements=1, nu=0
# set forcing term
self.g = dfx.fem.Function(self.V)
t = self.t0
self.g.interpolate(lambda x: -np.sin(2 * np.pi * x[0]) * (np.sin(t) - 4 * self.nu * np.pi * np.pi * np.cos(t)))
self.g.interpolate(
lambda x: -np.sin(2 * np.pi * x[0]) * (np.sin(t) - 4 * self.nu * np.pi * np.pi * np.cos(t)))

self.tmp_u = dfx.fem.Function(self.V)
self.tmp_f = dfx.fem.Function(self.V)
Expand Down Expand Up @@ -206,7 +204,8 @@ def eval_f(self, u, t):
self.K.mult(self.tmp_u.vector, self.tmp_f.vector)
self.convert_from_fenicsx_vector(input=self.tmp_f, output=f.impl)

self.g.interpolate(lambda x: -np.sin(2 * np.pi * x[0]) * (np.sin(t) - self.nu * np.pi * np.pi * 4 * np.cos(t)))
self.g.interpolate(
lambda x: -np.sin(2 * np.pi * x[0]) * (np.sin(t) - self.nu * np.pi * np.pi * 4 * np.cos(t)))
self.M.mult(self.g.vector, self.tmp_f.vector)
self.convert_from_fenicsx_vector(input=self.tmp_f, output=f.expl)

Expand All @@ -233,6 +232,7 @@ def apply_mass_matrix(self, u):
self.convert_from_fenicsx_vector(input=self.tmp_f, output=uM)
return uM


def u_exact(self, t):
r"""
Routine to compute the exact solution at time :math:`t`.
Expand Down
2 changes: 0 additions & 2 deletions pySDC/playgrounds/FEniCSx/heat_equation_M.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@


from pySDC.implementations.controller_classes.controller_nonMPI import controller_nonMPI

# from pySDC.implementations.problem_classes.HeatEquation_1D_FEniCS_matrix_forced import fenics_heat_mass
from pySDC.implementations.sweeper_classes.imex_1st_order_mass import imex_1st_order_mass

# from pySDC.implementations.transfer_classes.TransferFenicsMesh import mesh_to_mesh_fenics
from pySDC.playgrounds.FEniCSx.HeatEquation_1D_FEniCSx_matrix_forced_2 import fenicsx_heat_mass
from pySDC.implementations.sweeper_classes.imex_1st_order import imex_1st_order
Expand Down

0 comments on commit 07a7830

Please sign in to comment.