Comments (4)
Hi Thilo
Thanks a lot for reporting. This is a bug. The form represents a scalar and it should not go into this if test. I know this used to work, so this only goes to show that we need better tests! I'll look into it right away.
from shenfun.
If you want to fix this locally, then the following added just above mentioned line should do:
if test.expr_rank() == 0:
recursive = False
from shenfun.
Hi Mikael,
Thilo and I realized that you added the lines above in commit 955a326. The code which is shown above is working properly now. Thank you for fixing this.
However, we think that there is deeper a problem somewhere. If we modify the boundary conditions in our example from homogeneous Dirichlet bcs to inhomogeneous ones, an error occurs if the linear is solved. We hope that example below show the problem. We are not sure if we should close this issue and open a new one because the problem does not seem to be related to the div-div-term. The problem also occurs if only the grad-grad is considered.
Best wishes,
Sebastian and Thilo
from sympy import symbols, cos, sin
from mpi4py import MPI
from shenfun import inner, grad, div, TestFunction, TrialFunction, Array,\
Basis, TensorProductSpace, VectorTensorProductSpace, BlockMatrix
from mpi4py_fft.pencil import Subcomm
comm = MPI.COMM_WORLD
family = 'legendre'
# Size of discretization
n = 40
N = [n, n+1]
# Bases and spaces
BX_hom = Basis(N[0], family=family, bc=(0, 0))
BX_inhom = Basis(N[0], family=family, bc=(0, 0.1))
BY_hom = Basis(N[1], family=family, bc=(0, 0))
# Function spaces
subcomms = Subcomm(MPI.COMM_WORLD, [0, 1])
T_hom = TensorProductSpace(subcomms, (BX_hom, BY_hom))
T_inhom = TensorProductSpace(subcomms, (BX_inhom, BY_hom))
V_hom = VectorTensorProductSpace([T_hom, T_hom])
V_inhom = VectorTensorProductSpace([T_inhom, T_inhom])
V_mixed = VectorTensorProductSpace([T_hom, T_inhom])
# Choose the BCs you want
# working
V = V_hom
# not working
# V = V_inhom
# V = V_mixed
# Functions
u = TrialFunction(V)
v = TestFunction(V)
# Compute matrices
# Assemble standard term
A = inner(grad(u), grad(v))
# Assemble (div(u), div(v))-term
# non-working
B = inner(div(u), div(v)) # raises an error
# Compute BlockMatrix
M = BlockMatrix(A + B)
# Compute right hand side
# Use sympy to compute a rhs
x, y = symbols("x,y")
fe = (sin(x**2)*(1-y)*(1+y), y**2*(cos(x-y**2)))
fj = Array(V, buffer=fe)
b = inner(v, fj)
# Compute solution
u_hat = M.solve(b) # This line fails because inconsistent shapes
u_sol = u_hat.backward()
from shenfun.
Hi
Non-homogeneous bcs are tricky. Please have a close look at, e.g., the driven cavity demo. There are matrices in A and B that should go on the right hand side. Please also look at the Rayleigh Bénard demo.
Best of luck😀
Mikael
from shenfun.
Related Issues (20)
- Dx not working with 1D mixed function space HOT 4
- Issue on Stokes equations with doubly periodic boundary conditions. HOT 2
- Error when evaluating derivatives for nonstandard domain HOT 7
- Installation problem: error in "cimport fastgl_wrap" HOT 2
- Old shenfun script for 2D Poisson equation dosn't work with new version HOT 2
- 1d poisson HOT 1
- Bug in FunctionSpace with bc as dictionary HOT 4
- Solve DGL with non-constant (discrete) variable? HOT 5
- AttributeError: 'tuple' object has no attribute 'copy' HOT 1
- Install problem HOT 1
- problems in solving 2D Allen Cahn equation HOT 2
- Two questions in the demo MixedPoisson.py HOT 7
- How to compute the numerical solution on the general points HOT 4
- 1. Solver for multidimensional problem 2. Product with variable coefficients HOT 4
- Two questions about the Legendre-Galerkin method for the Cahn-Hilliard equation HOT 2
- How to compute the integral about the nonlinear term in the Navier-Stokes equation? HOT 2
- How to assemble the right-hand side vector? HOT 3
- Understanding the chebyshev solver in poisson2ND.py HOT 3
- Time dependent boundary conditions in segments for Rayleigh-Benard 2D HOT 2
- Implementing the one-dimensional Kuramoto-Sivashinsky system HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from shenfun.