-
Notifications
You must be signed in to change notification settings - Fork 62
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
GridFunction, ProjectCoefficient and GetValue #209
Comments
Without reading ProjectCoefficient, I would guess as follows. If you use L2 element with order=0, you can avoid this issue. |
Hi ! Edit: H1_FECollection has default Gauss-Lobatto rules... which actually makes sense... But when I construct my GridFunctions, I don't seem to be able to evaluate at different quadrature points... fec = mfem.H1_FECollection(self._order, dim) # this has Gauss-Lobatto points
scalar_fes = mfem.FiniteElementSpace(mesh, fec) # This has default values. It should have Lobatto
scalar_fes = mfem.FiniteElementSpace(mesh, fec, mfem.BasisType.GaussLegendre) # This seems to be ignored. I get the same thing thanks for the reply. then the X (interface) should never be evaluated (GL nodes) and x_node should have a unique value (1 or 2). I think I am misunderstanding the projection... If you use L2 element with order=0, you can avoid this issue. Actually the binary values (1, 2) were for illustration. I have a density function evaluated at the integration points so constant elements won't work. I also want H1 to avoid jumps at the interface. All good. If what is happening is that the interfaces have values 1 or 2 depending on which element we are pointing from, I am OK with it. I was just worried that I couldn't reproduce the results because I was doing the wrong thing. Thanks for the ideas! |
Last question on this: I have tried without success to run the displacement problem with a H1_collection space but then when outputting the solution, evaluate at internal nodes so when I visualize the solution with paraview, each material has the appropriate density value. My problem is that when I do this: # gf is my gridfunction
fes = gf.FESpace()
mesh = fes.GetMesh()
# nodes = mesh.GetNodes()
# nodes += gf
for i in range(fes.GetNE()):
fe = fes.GetFE(i)
fdof = fe.GetDof()
logging.debug(f' TOTAL DOFS {fdof}')
T = fes.GetElementTransformation(i)
ir = fe.GetNodes()
irG = mfem.IntegrationRule(fdof)
logging.debug(f' INTEGRATION RULE {irG.GetNPoints()}')
for j in range(fdof):
ip = ir.IntPoint(j)
ipG = irG.IntPoint(j)
logging.debug(f" ORIGINAL {ip.x, ip.y, ip.z, ip.weight} NOW {ipG.x, ipG.y, ipG.z, ipG.weight}")
T.SetIntPoint(ip) the points in the integration rule irG are all set to zero
I know I can set the point ipG = Set3(args) but I am sure there is a direct way to assign it to be Legendre nodes (or whatever). Please, can you point me to the right answer? Many thanks ! |
mfem.IntegrationRule is an array of integration point, and thus, mfem.IntegrationRule(4) will return 4 integration points as array. Perhaps, what you want to do is to use mfem.IntegrationRules to construct a set of rules. Then, ask the rules for an integration rule for specific geometry and order?
Hope this helps. |
Thank you ! only that if I want to write to vtk, I need to update the mesh nodes which are still associated with the GaussLobatto rules... I need to rethink the approach. I am a bit confused on how to get both things: on one hand, I want the displacement to be C1 (like ex2) even at the interfaces where there is a change of materials, so we use a FE_H1 collection. On the other hand, the young modulus associated to the grid function should not be C1 since it is by definition, a different material. A jump at the change of material interface is expected. But the displacement solution uses the underlying Lame coefficients which are associated to the Young modulus so they have to be in the same space... I am not sure how bonded contacts work anymore. Thank you for your help. |
Hi:
I am trying to use the ElasticIntegrator for a multi-material problem where some of the materials vary the Young modulus as a function of density. So I need to change the way lame constants are computed. In example 2, they are computed using PWConstantCoefficient:
My approach was to create a LinearCoefficient class which has information about another field (in this case: density). But I have an inconsistency of values when I evaluate the coefficient class and the grid function. I have made a dumb example where this problem arises.
The first time we perform the operation gf.ProjectCoefficient(myCoeff) we are assigning a constant value of 1 or 2 according to the element Attribute. Then I store the gridFunction and call it again, this time checking that values coincide.
However, when I run it I get an error:
meaning that the grid function at (T, ip) gave different value than the element value. My first thought was that it might be using a quadrature rule including endpoints (-,1 1) but I forced it to GaussLegendre and I get the same error. What am I missing?? Shouldn-t both produce the same result ?
Many thanks
The text was updated successfully, but these errors were encountered: