Replies: 2 comments 10 replies
-
|
Beta Was this translation helpful? Give feedback.
0 replies
-
I suggest you don't use Try to instead use the following snippet as a starting point: import numpy as np
from skfem import *
from skfem.models import laplace, unit_load
m = MeshTri().refined(4)
e = ElementTriP1()
basis = Basis(m, e)
left = basis.get_dofs(facets='left').nodal['u']
right = basis.get_dofs(facets='right').nodal['u']
D = basis.get_dofs({'top', 'bottom'}).all()
left = np.setdiff1d(left, D)
right = np.setdiff1d(right, D)
B = np.zeros((len(left), basis.N))
B[range(len(left)), left] = 1
B[range(len(right)), right] = -1
A = asm(laplace, basis)
f = asm(unit_load, basis)
# create a saddle point system with one additional Lagrange multiplier / periodic DOF pair
A = bmat([[A, B.T],
[B, None]], 'csr')
f = np.concatenate((f, 0 * left))
y = solve(*condense(A, f, D=basis.get_dofs({'top', 'bottom'})))
basis.plot(y[:basis.N], colorbar=True, shading='gouraud', levels=5).show() It uses Lagrange multipliers to enforce periodicity. |
Beta Was this translation helpful? Give feedback.
10 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I want to solve a problem with periodic boundary conditions on the left and right side, the top and bottom side have nonzero Dirichlet boundary conditions in some segments and Neumann boundary conditions in other segements, how should I do that? I tried some codes from expample 13 and 42, but I got errors
Transforming over 1000 vertices to C_CONTIGUOUS.
when I executem = MeshTri1DG.init_tensor( np.linspace(0, 1, 30), np.linspace(0, 1, 30), periodic=[0], ).with_boundaries({ 'ground': lambda x: x[1] == 0., 'positive': lambda x: x[1] == 1, })
Beta Was this translation helpful? Give feedback.
All reactions