People who code: we want your input. Take the Survey

New answers tagged

2

I don't know of a single book that one would like to have as a unique reference in the topic. Although, I think that the following reference is good enough: Morton, K. W., & Mayers, D. F. (2005). Numerical solution of partial differential equations: an introduction. Cambridge university press. Following there is a (non-exhaustive) list for different ...


1

Ed Bueler just wrote the perfect book for you: "PETSc for Partial Differential Equations: Numerical Solutions in C and Python" https://epubs.siam.org/isbn/978-1-61197-630-4


2

This is a (FDM) supplement to VoB's answer. You could write an extremely vectorized and optimized solver for your problem, but that is not a good first idea. Writing a for loop is easier, and once you identify the opportunities for optimization, you can implement them. Here is how I would go about it (in pseudo-code): Assume $0\leq i\leq n$ and $0\leq j\leq ...


3

Probably not what OP was waiting for, but I think it could be pretty instructive and useful. FEM codes use a much different approach to build the so-called stiffness matrix. In practice, they loop over elements and compute for each element small matrices (in your case if you use linear elements 3by3) which are distributed to the right entries of the global ...


2

User 03161 asserts that the Crank Nicolson method is not appropriate for advection problems, but boyfarrell provides a working code with results visualized in a movie. In fact they are both correct, but neither gives the full perspective. At the beginning of boyfarrell's answer the correct C-N formula for linear advection is written out. In that formula are ...


7

Your reasoning for vector type equation is correct when you wrote it down for each individual component. What occurs is that you need to write your interpolation basis function and your test function as vectors. Hence, starting from: $$\nabla^2 \mathbf{u} =0 $$ in strong integral form is: $$\int \mathbf{v} \cdot \nabla^2 \mathbf{u} \, d\Omega = 0 $$ where $\...


Top 50 recent answers are included