Poisson equation,Neumann BCs
Hi~all
I need to solve a pressure Poisson equation with only Neumann boundaries with F.D. method. Unfortunately, it leads to the sparse linear system equation Ax = b, where A is singular (because the Neumann BC in all boundaries).And I use matlab ....Any advise with possibility to solve singular linear systems? Thank you~ |
Quote:
pick any boundary cell treat it as fixed value of say 0. So all the boundary faces have neumann condition except for 1. if you do so, your equation will no longer be singular. Then use whatever matrix solver you want to solve the system. |
I think that you can fix any point at the boundary (as mentioned by arjun) or anywhere within the computational domain.
|
Hi
I've tried it ,but it seems that it's still hard to solve the equations. In fact my problem is ∂²p/∂x²+∂²p/∂y²= ∂u(x,y)/∂x+∂v(x,y)/∂y u(x,y) and v(x,y) are known in all points with 1 Dirichlet BC on west and 3 N BCs on the others. (uu(x,y),vv(x,y))=( u(x,y), v(x,y) )-(∂p/∂x,∂p/∂y) uu(x,y) and vv(x,y) have the same boudary with u(x,y) and v(x,y). And p(x,y) is N BCs according to the paper . But I don't know how to figure out the boundary conditions of p ...any advise?Thank you all~ |
Quote:
If you tried and it does not work then there are many possiblities: 1. You made mistake in implementing what is advised. 2. If matlab is using direct solver to solve that matrix system then point (1) is your only possiblity. 3. If matlab is using iterative method then it shall be noted that not all iterative solvers can solve all neumann problem (it also depends on size of your problem). As the size increases the difficulty in solving increases. 4. Usually though (3) only reduces rate of convergence that means you would observe some convergence but it would be converging very slowly. When the problem size increase after some point there will be virtually no convergence. PS: In the end if you are using finite difference and you mesh is cartesian mesh then have a look at fishpack and its routine called blktri . (But i think it can also not handle all neumann problem, but have a look to make sure). |
Implementing pure Neumann Boundary conditions for Poisson equations with FD method
Quote:
Thank you very much in advance Best regards, Patricio Cumsille |
Quote:
You can fix the value of the solution in anyone of the grid points. However, this is not necessary, the system admits infinite solutions and during a linear solver, your solution automatically sets a constant reference value. |
Not setting a Dirichlet BC for at least one point will not lead to a converged solution unless the implementation is noisy enough to remove the matrix singularity just enough (for convergence to take place).
On the other hand, setting a node value to a constant Dirichlet BC, as proposed in this thread, is a poor choice/strategy as well. Yes, it allows for the matrix to converge, but it yields a spike at, and in the immediate neighborhood of, the point the Dirichlet BC is applied. A few years ago, I'd developed (and published) a highly accurate and inexpensive solution, without a spike, in a boundary element methods setting. I've just begun searching for similarly accurate methods in a finite-difference/volume approach, but I haven't yet found an easy-to-implement and/or inexpensive strategy! Adrin |
Thank you very much for the responses.
Adrin: Please, could you send to me your publication? I am interested! My email is pcumsill@gmail.com Thank you again! Best regards, PC |
Quote:
|
Quote:
well, this is not an issue of CFD but a mathematical property... The Poisson equation Div Grad (phi) = q with Neumann BC.s admits a solution (apart a constant) provided that the compatibility relation is satisfied. This does not require complicate implementation of the BC.s but only the fact that: Int [S] d phi/dn dS = Int [S] q dS The CFD task consists in fulfill such relation in discrete sense. It is a common experience that fixing an arbitrary value leads to a slower convergence |
My experience agrees with that of adrin, for scale resolving simulations (e.g., LES/DNS) pressure should not be fixed, otherwise you cannot get the right statistics from it. Still, there should be no problem for the momentum equations
|
Let me say that the correct way to fix a value must accord with the correct BCs otherwise you get convergence towards some uncorrect solution
Try to fix the value not in the interior but by entering it by means of the Neumann BCs, it should work correctly without spike. However, as I said, the convergence rate is slower. |
>>>it should work correctly without spike. However, as I said, the convergence rate is slower.
Well, I happen to be working on this problem these days, and I can say that a pure neumann BC without any other modifications will _not_ work! I'm using a multigrid preconditioned krylov solver (PCG), which converges in ~10 iterations (to error of order 1.E-8) for the 3D poisson problem that I've tried. With a pure neumann BC the solution does not converge to even order 1.E-3 for up to 3000 iterations, which is the upper limit I set. In contrast, setting one of the boundary nodes to zero (dirichlet BC) leads to convergence in 7 iterations! I agree that convergence doesn't necessarily mean convergence to a correct solution (but in this case it seems it does) Adrin |
Quote:
Adrin, something in the BC implementation could be wrong... I assume you are working on the pressure problem derived from the continuity equation in which you substitute the Hodge decomposition. The same decomposition, projected along the normal direction to the boundaries provides the correct Neumann BC.s that fulfill the compatibility relation ensuring the convergence. I work usually with Neumann BC.s and it works.... Please, check if your BC.s satisfy numerically the relation Int [S] d phi/dn dS - Int [S] q.n dS=0 |
>> could you point to the paper you published
A. Gharakhani and A. F. Ghoniem,"BEM Solution of the 3D Internal Neumann Problem and A Regularized Formulation for the Potential Velocity Gradients," International Journal of Numerical Methods in Fluids, Vol. 24, No. 1, pp. 81-100, 1997. |
I remember having a possibly identical problem with a Vortex panel method applied to closed surfaces with lift (in practice the outside potential is well defined by its behavior at infinity, but the inside one is not). However, there the problem can be easily solved by assigning the circulation value for a panel as, just like the pressure, the solution is in terms of differences of circulations among adjacent panels and not their absolute values. Still, i never had the chance to apply the method to multiple closed surfaces to see if it really doesn't matter in general...
Actually, Adrin himself helped me in solving my issue here on CFD-ONLINE (http://www.cfd-online.com/Forums/mai...el-method.html). I should read your paper to check if the matter is exactly the same. Coming to the general issue, i guess that you both (Adrin and Filippo) are saying exactly the same thing, one of the equations should be switched to a global constraint instead of fixing it arbitrarily. However, there might possibly be differences in the single approaches. I guess that if pressure has infinitely many solutions, the solution should simply converge to one of them just like for the pressure checkerboard case the solution converge to a specific checkerboard pattern. My experience is that point Gauss-Seidel iterations can converge to machine accuracy (not so fast actually) if the global b.c. constraint is preserved. However, this global constraint implies a full coupling among the equations which might be difficult to solve in the context of an otherwise banded matrix. |
Quote:
The problem I see is that the convergence rate is really slow. I have carried out some numerical tests and I got a convergence rate even less than 1!!! Or even worst, for certain problems (for certain data) I did not get convergence! Thus, the technique of fixing a value at a grid point is not good in general!!! |
Quote:
Yes, this was the main problem I faced when I tried to fix a single point for neumann. Even the additive corrective AMG was not that effective specially when case sizes were large. If you could use, try smoothed aggregation AMG. I ended up taking out additive corrective and replacing it with smoothed aggregation that worked well. Arjun |
Revisiting Neumann BC
It turns out that FMDenaro is correct. So long as the Neumann BC compatibility is satisfied _explicitly_ one need not set a Dirichlet BC at one node, and one can still get a solution. In my previous experiments in the finite volume formulation I was using a simple manufactured problem for benchmarking. It turns out that although compatibility was theoretically ensured it was _not_ satisfied numerically (in discrete form). So, a simple correction led to "a" solution. That solution shifts by a constant as a function of grid resolution, but that's not an issue. I still maintain the only reason any solution may be obtained with such an approach is sufficient numerical noise to remove the linear dependence of two arbitrary equations - this approach would fail in an "infinite accuracy" solution.
So, in summary, if the _discrete_ surface integral of the fluxes is not equal to the volume integral of the Poisson source term, perform the following pre-processing before assembling the matrix and RHS. Find the difference between the aforementioned two terms, and either (a) divide that difference by the total volume and then add the volume averaged error to the source term for every node, or (b) divide the difference by the total surface area and then add the surface averaged error to the fluxes on all surface nodes. Make sure the signs are such that compatibility is now satisfied. This yields a quick, converged solution! Adrin |
Quote:
|
The compatibility may already be incorporated in the implementation, depending on the details of the formulation. I'm just curious ... suppose you have a unit cubic box with N^3 uniformly distributed grids. The volume for this will be one, irrespective of the value of N. Now, let's perturb the interior grids (keep the surface grids uniformly distributed), say (1) randomly, or (2) sinusoidally in all three directions (A*sin(2.pi.x)*sin(2.pi.y)*sin(2.pi.z)). What is the volume you get for such grid distributions?
Adrin |
Quote:
to tell the truth I don't understand that question clearly ... the key is the numerical construction of the surface integral of dp/dn that must balance the volume integral of the source term whatever the shape of the domain and its discretization is used Now, in the actual construction of the pressure equation Div Grad p = q the source term q is in the form of a divergence, therefore it is numerically constructed as the same as the divergence of the pressure gradient in the left hand side. That ensures that the compatibility constraint is ensured, provided that the correct BC for Grad p are used. |
Ah, in your case q is in divergence form. In general, though, q could be any function, and in this case it's the volume integral of q that must match the surface integral of the flux. In discrete form the volumes may be off a bit, and so the volume integral of q may not match the LHS exactly.
Adrin |
Quote:
The question for a general function q I think that depends upon the discretization of the integrals ... for example, mid-point rule for the surface integral must be associated to the use of centroid value x measure of the volume... trapezoidal rule for the surface integral must be associated to its 3D extension for the volume integral and so on |
Quote:
/Arjun ....................... |
Could You elaborate?
|
In theory, what you said is fine. In practice, these are few possible scenarios.
1. You meant div(v) = 0 on cell by cell basis. Which is only possiblibly be true in fully converged case, even then for a non - staggered system we would have div( v + v_due_to_rhie_chow) = 0 (fully converged case). So I take it that you meant globally, that is summing all equations. 2. In this case, if you have say velocity inlet and a pressure outlet, until convergence is achieved div (vel ) = 0 is not achieved. (this scenario could be discounted because then p equation is not all neumann anyway) 3. In a case if had inlet and outflow condition. In this case div(v) = 0 is only achieved if you fixed outflow such that inflow = outflow, that too when there is no reversed flow. In the end, in practice, div(v) = 0 is not taken to be granted. |
Quote:
ok, now I see what you meant. However, let me address some issues. 1) Also in practice, the Div V = 0 constraint can be reached at machine precision. It depend on your choice, if you want to adopt an Exact or Approximate Projection Method (EPM/APM). 2) R-C interpolation is not necessary, you are not forced to use it as other approaches are possible. 3) In a case with inlet and outflow condition Div V = 0 is achieved because, provide correct BC are fixed, you get inflow = outflow at machine accuracy If you are interested in, I report two of my papers about the above issues, you will find cited many other useful papers. F.M. Denaro, A 3D second-order accurate projection-based Finite Volume code on non-staggered, non-uniform structured grids with continuity preserving properties: application to buoyancy-driven flows,Int. J. Num. Meth. Fluids, 52, 4, 393-432, 2006.A. Aprovitola, F.M. Denaro, A non-diffusive, divergence-free, Finite Volume-based double projection method on non-staggered grids, Int. J. Num. Meth. Fluids,53, 1127-1172, 2007. |
Quote:
2) I agree that it is matter of practice. PS: for (1) if you meant cell by cell basis then I would not agree because div(u) = 0 would only be achieved after convergence, but the pressure equation is driving the solution to convergence div(v) = 0 cell by cell basis is not given. In fact that is source of pressure equation, without source there will be no correction. |
Quote:
Sorry, I do not understand clearly this point ... at each time step I will solve the pressure equation (double precision) even with a simple SOR method. With the pressure gradient I can drive the divergence-free contraint cell-by-cell until to machine precision, even on non-staggered grid... Any source term can be used to solve an elliptic equation and the solution provide the gradient which correct the velocity... |
Dear Adrin:
I have implemented the trick that you adviced me, but in practice the only thing I got is to project the RHS on the orthogonal of the kernel of the matrix obtained from the discretization Poisson problem with pure Neumann BC. Unfortunately, you still cannot ensure the uniqueness of the solution and therefore you do not know which solution is computed. The experiment that I have performed is with FD and the test function is u(x,y)=x^5+y^5-r^5, with r=0.5 and the RHS is obtained by computing the Laplacian of u, and so is for the Neumann BC. The issue is that even if you project the RHS on the orthogonal of the kernel of the matrix for this problem, you cannot ensure the uniqueness of the solution and therefore you cannot ensure the convergence of the numerical method. After all, the analytic solution is defined up to an additive constant and any method that converges have to handle correctly this issue. The fact of projecting the RHS is not enough to handle that! Best regards, Patricio Cumsille |
Hi Patricio,
Sorry, I hadn't checked cfd-online for a while... Yes, you are absolutely correct that the solution is/will not be unique by just discretely ensuring the consistency - the same problem at different resolution levels will give different potential distributions (but the solution is only shifted up or down; the shape is the same). But, as you suggested, that is to be expected because the original problem is itself not unique. The only way to do that properly would be to remove one of the equations (any one would do, which basically means you're setting its value to zero) and replace it with the consistency equation. That is essentially what I did in my boundary element methods based solution, where a unique solution is obtained irrespective of the resolution. Nevertheless, since we're generally interested in the gradient and not the potential itself, it really doesn't matter if the value shifts up/down - the only real concern is whether we're guaranteed to get a solution. I suspect in an infinite precision computation we won't get a converged solution. So far, I haven't experienced a problem in my finite precision tests. If you want a "pinned" solution, that means you know the potential value at a particular point (no other option available, by definition). In that case, just get the difference between the value that you have obtained and the value that you want at that node, and then adjust the value at all nodes by this difference. This will give you the unique values you want (but it's a simple post-processing and has nothing to do with your real concern of convergence guarantee) Adrin |
imposing pressure gradient at free surface of a channel flow
Dear All,
I am trying to simulate the free-surface shape, by imposing a vertical pressure gradient at uppest ghost cell of a rectangular channel. I m using a LES code, which solves the Navier -Stockes Equation, and the flow is driven by a stream- wise pressure gradient while the periodicity condition is applied in stream -wise and span- wise direction. To do that I modify the Poisson equation by changing the Boundary condition to desired pressure gradient which is do=- g*dh/dz.(dh /dz is presenting the variation of free-surface level along the span wise direction) at upper grid and a hydrostatic pressure gradient along all the vertical direction dp/dh=-g. After Running my code, The residual of poisson equation is not converging and mass-balance get apart from zero. does anyone knows anything related to this issue? Thanks in advance |
Quote:
could you better elaborate your model? I think you are not correctly setting the BC.s. You can check if the compatibility relation is numerically satisfied |
Dear Fillipo ,
The mass balance is also getting far form zero, but I can not find where it rise up from. |
Quote:
Are you using the correct normal component inserted in the Hodge decomposition? |
Quote:
Edited to add: I went back and read again what you wrote. Sorry I misunderstood you. You were saying the same thing (div (V) = 0 is used to construct pressure equation rather than it is a given condition. Discard my comment above. |
Hi there, I am working in pyAMG and have Neumann-Periodic boundary conditions. on my 2D domain.
I am aware of the compatibility condition for such a problem and have satisfied it. I have been able to solve my system with a pyamg.bicgSTAB but have had no luck with multigrid methods. I was wondering if anyone had any advice on how to solve a system with Neumann-Periodic BCs with a multigrid solver? Kind regards. |
In my experience, at least for the type of poisson solvers I'd developed when I tried it, using AMG as a preconditioner for Krylov solvers is more robust than using AMG as a solver. Recently, I've been looking into developing a high-order poisson solver and found AMG (even as a preconditioner) to be quite sensitive to the various parameters that one can tweak! The latter is not definitive, yet; I still need to make sure that I have a "nice" matrix. Make sure you do have a good matrix (for example, perhaps you should try rearranging the entries using various methods available to you).
adrin |
All times are GMT -4. The time now is 06:11. |