-
Hi all, Great project! I only recently started using I am working with 2D triangular meshes, and P1 basis functions. I would like to integrate my solution over
For 3. I could just use a probe, and integrate with numpy.trapz. Is this the most elegant solution, or are there any built-in alternatives? For 2. - is it possoble to define a 2D probe? Or what would be the best way to do this? For 1., this should not be too tricky, I would just need to build the scalar product of the solution vector with the weight of each triangle? Is it possible to access these weights; or should I calculate them from the "dx" property of the mesh? Thank you already! |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 5 replies
-
The basic idea is described here: https://scikit-fem.readthedocs.io/en/latest/howto.html#postprocessing-the-solution To integrate over subdomain, you tag the respective elements using Mesh.with_subdomains or using external mesh generator and initialize intbasis=Basis(mesh, elem, elements='yourtag') to use together with Functional wrapper. To integrate over facets you use FacetBasis. I am now on mobile phone so cannot answer in more detail. |
Beta Was this translation helpful? Give feedback.
-
Hi, sorry, my original question was answered but I haven't fully managed to do what I wanted to, it's possible that I am just confused. I would appreciate any comments. I am solving a standard diffusion equation with trivial Dirichlet boundary conditions on the left side of a quadratic mesh; with an implicit Euler algorithm in time:
As starting values, I define a region in the center of the mesh thats filled with ones (to approximate a Dirac delta function). Then I iterate over the times, and find the FEM solution for each time step:
Now in the postprocessing of the solution, I want to track two things over time: the total density within the mesh (called norm in the code below) and the flux across the Dirichlet boundary (i.e. the density lost to the environment, called flux below). I am calculating these quantities as follows:
The last part is mostly copied from the tutorial. Now the part that I don't understand is, I would expect that the time-integrated flux over the boundary should make up for the decrease of the density within the mesh. But thats not the case here, in fact the flux over the boundary is much larger than the density in the mesh (see plot below). I think I have some misconception about how the facet basis and the integral over that works? I would be very happy for suggestions what I am doing wrong. |
Beta Was this translation helpful? Give feedback.
The basic idea is described here: https://scikit-fem.readthedocs.io/en/latest/howto.html#postprocessing-the-solution
To integrate over subdomain, you tag the respective elements using Mesh.with_subdomains or using external mesh generator and initialize intbasis=Basis(mesh, elem, elements='yourtag') to use together with Functional wrapper.
To integrate over facets you use FacetBasis. I am now on mobile phone so cannot answer in more detail.