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.

Calculations of specific entries in a.mat/f.vec.

More
4 years 2 months ago #2243 by gekats
Hi everyone,

I have a question related to the Bilinear and Linear form integrators and corresponding assembly in NGSolve. More specifically, I would like an efficient way to access specific entries in a.mat/f.vec, avoiding the complete assembly of the related bilinear/linear forms. For instance, how could one detect the specific nodes of the mesh which correspond to a non--zero contribution for (i,j)-entry of a.mat and then calculate the related element contributions compute the (i,j)-entry? Thank you in advance for your consideration,
George
More
4 years 2 months ago #2244 by joachim
Hi George,

you can compute element-matrices (and vectors) via the Python interface, and you can query the degrees of freedom of a certain element as in the example below.

This tutorial shows how to explore the mesh topology, like finding the elements associated with a certain vertex:
ngsolve.org/docu/latest/i-tutorials/unit...gy/meshtopology.html

Best,
Joachim

Code:
from ngsolve import * from netgen.geom2d import unit_square mesh = Mesh(unit_square.GenerateMesh(maxh=0.2)) fes = H1(mesh) u,v = fes.TnT() bfi = SymbolicBFI(grad(u)*grad(v)) elid = ElementId(7) # the element provides the shape functions el = fes.GetFE(elid) # the mapping from reference element to physical element trafo = mesh.GetTrafo(elid) dofs = fes.GetDofNrs(elid) print ("dofs:", dofs) elmat = bfi.CalcElementMatrix(el, trafo) print ("element matrix:", elmat)
More
4 years 2 months ago #2268 by gekats
Hi Joachim,

thank you for your reply - this was exactly what i was looking for. However, I would appreciate an additional clarification. For my purposes, the Bilinear form includes terms with normal derivative jumps on specific facets:

bfi3 = SymbolicBFI(form = ...,VOL_or_BND = VOL, skeleton=True)

Whenever trying to compute the respective element contributions to the assembled bilinear form using

elmat3 = bfi3.CalcElementMatrix(el, trafo)

I get the error message:

netgen.libngpy._meshing.NgException: FacetBilinearFormIntegrator can not assemble volumetric element matrices!

Is there some way to bypass this complication? Thank you in advance.

All the best,
George
More
4 years 2 months ago #2271 by joachim
Hi George,

since you need jump-terms, you set the skeleton=True flag. Such integrators calculate the element matrices for both elements at the facet at once.
This requires both finite elements, and both element transformations.
These FacetBilinearFormIntegrators don't provide the usual CalcElementMatrix, thus the exception.

The two-element CalcElementMatrix is not available from Python.
I recommend to use a hybrid-DG like formulation for the (normal-derivative) jump term, then you don't need the skeleton integration.

An example for C0-interior penalty methods for the plate equation is here:
ngsolve.org/docu/latest/i-tutorials/unit...der/fourthorder.html

Best,
Joachim
More
4 years 2 months ago - 4 years 2 months ago #2285 by gekats
Dear Joachim,

thank you for your response and for pointing me to the tutorial with the dG formulation. However, I am not sure I understand how skeleton integration can be avoided through this approach and I was hoping for some additional information.

Please find attached a partial code containing the ghost penalty term I am interested in calculating element matrices for. As you will see, an additional complication in my case is that the Bilinear Form is defined on specific facets marked via an indicator coefficient function. Is it possible without skeleton integration? Now the error message reads: 'ngsolve.comp.SumOfIntegrals' object has no attribute 'CalcElementMatrix'.

Thank you in advance.

Greetings,
George
Last edit: 4 years 2 months ago by gekats.
Time to create page: 0.122 seconds