Computing integrals on a slice cutting through a domain.

Hello,

If I have a BVP defined on a 2D or 3D domain (ex.: a cube) is it possible in NGSolve to compute integrals on a given slice that cuts through the domain?

For example: in the attached toy problem, I have a function u(x,y) defined on a unit cube. How do I compute the integral of u(x,y) on a plane with z-normal, say at z=0.5?

Thank you,
Anand

Attachment: toy_pb_3d.py

Attachment: toy_pb_3d_2019-10-15.py

Hi anandes,

A similar question was asked here:
integration-over-a-cross-section
Maybe this helps.

Best,
Michael

Hi Michael,

Thanks for directing me to the relevant topic. I am currently unable to get ngsxfem working with my NGSolve installation on Ubuntu. But the other method seems to work. I have a couple of follow-up questions in this regard.

1. The boolean operation within the AddSurface functionality seems to work only on solid primitives. It throws an error if I use it on solids constructed from primitives (example: cube constructed from plane primitives; please see attached file). Is this expected?

2. Is there similar functionality for a mesh which is not associated with a geometry, for example, if I just have a mesh from another source such as Gmsh?

Thank you,
Anand

Hi anandes,

can you please provide an example where the error occurs?
In your last post you did not attach one.

Best,
Michael

Hi Michael,

I thought I did, sorry about that! Please find the attachment below.

Thank you,
Anand

https://ngsolve.org/media/kunena/attachments/1281/integrate_on_slice.py

Attachment: integrate_on_slice.py

Hi Anand,

it works also for solids constructed from primitives. But you have to use it before adding it to the CSGeometry, see attached file.

To handle meshes without geometry I really would recommend xfem.
It is somehow possible to use your own integration rule, where you specify the according integration points, but the first option is easier, more robust and more flexible.

What error occurs when you try to get ngsxfem running?

Best,
Michael

https://ngsolve.org/media/kunena/attachments/889/integrate_on_slice.py

Attachment: integrate_on_slice.py

Hello Michael,

Yes, now it works well. Thank you.

I tried to install ngsxfem but it doesn’t seem to work. My laptop runs Ubuntu 18.04.3 LTS. The Netgen/NGSolve executables are in /usr/bin/. I go through the following steps (as described on this webpage).

From my home directory:

> git clone https://github.com/ngsxfem/ngsxfem.git
> cd ngsxfem
> mkdir build
> cd build
> cmake ../ -DCMAKE_INSTALL_PREFIX=/usr/bin/ -DBUILD_NGSOLVE=OFF -DCMAKE_CXX_COMPILER=ngscxx -DCMAKE_LINKER=ngsld
> make
> make install

Other than some warnings on deprecated declarations, the install goes fine. But when I try to run an examples as follows:

> cd $HOME/ngsxfem/py_tutorials/
> netgen cutfem.py

I get this error: No module named ‘xfem’
So ngsxfem does not seem to be installed. Please let me know where things could be going wrong.

Thank you,
Anand

Hi anand,
where does the installation install to? Is your PYTHONPATH environment variable set to point to that location?
Best Christopher