Forum Message

 

 

We have moved the forum to https://forum.ngsolve.org . This is an archived version of the topics until 05/05/23. All the topics were moved to the new forum and conversations can be continued there. This forum is just kept as legacy to not invalidate old links. If you want to continue a conversation just look for the topic in the new forum.

Notice

The forum is in read only mode.

integrals and normals on subdomain boundaries

More
4 years 11 months ago #1577 by NilsHM
Hello everyone!

1.
I want to integrate a CoefficientFunction over the boundary of a subdomain of the mesh. The subdomain is defined as a material.
Does
Integrate(cf, mesh, BND, definedon = mesh.Materials("mat1"))
integrate over the boundary of mat1?

2.
Also I want to create a CoefficientFunction for the normal vector on the boundary of the subdomain. Is there any function that does that? specialcf.normal doesn't seem to be able to do that.

Thanks!
Nils
More
4 years 11 months ago #1578 by joachim
Hi Nils,

We have now a very new BoundaryFromVolumeCF, which does what you need. Copy from the doc-string:
Code:
Help on built-in function BoundaryFromVolumeCF in module ngsolve.comp: BoundaryFromVolumeCF(...) method of builtins.PyCapsule instance BoundaryFromVolumeCF(vol_cf: ngsolve.fem.CoefficientFunction) -> ngsolve.fem.CoefficientFunction Allows the evaluation of volumentric functions on the boundary. When evaluated on a boundary element, this function searches for the associated volume element, transforms the local coordinates, and evaluates the function in the volume. A typical use-case is to visualize L2-functions, or mechanical stresses at the boundary. It is different to the boundary Trace()-operator. The trace provides a function which is defined by boundary degrees of freedom only. E.g. the trace of an H(div) function is only the normal component, while the BoundaryFromVolumeCF gives the whole function. If called on an interface, it evaluates from one side (which one is not specified). If the function is only defined on one side, this side will be taken. One can use a domain-wise CF to define a function only locally: uloc = CoefficientFunction( [None, None, u, None] )

Attached is also a small test-file providing the domain-wise outgoing normal-vector.

In your case, you have to integrate over a boundary-region, which you have to define via boundary condition labels.

Best, Joachim
More
4 years 11 months ago #1579 by NilsHM
Hi Joachim,

Thanks for the reply.
I downloaded and installed the latest version of NGSolve but BoundaryFromVolumeCF does not exist in my build. How can I install it?

Best regards,
Nils
More
4 years 11 months ago #1580 by joachim
you need the latest nightly build
More
4 years 10 months ago #1635 by NilsHM
Hello Joachim,

I now have a Version of NGSolve with the BoundaryFromVolumeCF function and tried to get the integral over a subdomain boundary to work. It seems like the normal vector CoefficienFunction is zero everywhere. Also the doc is not very helpful. Can you better explain what that function does? Can you add the integral of gfu times the normals vetor over the inner domain boundary in the test file you provided?
That would probably help alot.

Thank you
Nils
More
4 years 10 months ago #1639 by joachim
As usual, you integrate like that
Code:
print ("Integral = ", Integrate(bfv*bfv2, mesh, definedon=mesh.Boundaries("innerbnd")))
(whole example is attached).

the result is:
Integral = -0.108
-0.108
-1.27277e-17


see also my reply in
ngsolve.org/forum/ngspy-forum/791-functi...vectors-unclear#1638

Joachim
The following user(s) said Thank You: NilsHM
Time to create page: 0.187 seconds