Skip to content

[BUG] - mesh.X.coords does not display the updated coordinates after mesh deforming #122

Description

@NengLu

After deforming the mesh, mesh.X.coords does not display the updated coordinates.
The coordinates in mesh.X.coords do not match those obtained from mesh.dm.

Results from the latest development branch:
Image

Results from some version of the old development branch:
Image

The bug could be tested by:

import underworld3 as uw
import numpy as np
import sympy

xmin, xmax = -0.5, 0.5
ymin, ymax = -1,0
xres, yres = 50,50
mesh = uw.meshing.StructuredQuadBox(elementRes=(int(xres), int(yres)), minCoords=(xmin, ymin), maxCoords=(xmax, ymax))

deform_fn = 0.1 * sympy.cos(2.*sympy.pi*(mesh.X[0])/1.0)
Dz = uw.discretisation.MeshVariable("Dz", mesh, 1, degree=1)
diffuser = uw.systems.Poisson(mesh, Dz)
diffuser.constitutive_model = uw.constitutive_models.DiffusionModel
diffuser.constitutive_model.Parameters.diffusivity = 1.
diffuser.add_essential_bc((deform_fn,), "Top")
diffuser.add_essential_bc((0.,),"Bottom")
diffuser.solve()
displacement = np.zeros((mesh.X.coords.shape[0],mesh.dim))
displacement[:,-1] = uw.function.evaluate(Dz.sym[0], mesh.X.coords)[:,0,0]
mesh._deform_mesh(mesh.X.coords + displacement)

import matplotlib.pyplot as plt
from underworld3.cython.petsc_discretisation import petsc_dm_find_labeled_points_local
topwall = petsc_dm_find_labeled_points_local(mesh.dm,"Top") 
coords = mesh.X.coords[topwall]
index =  np.argsort(coords[:,0])
xx = coords[index,0]
yy = coords[index,-1]
plt.plot(xx,yy,label=r'coords of topwall from mesh.X.coords')
coord_vec = mesh.dm.getCoordinatesLocal()
coords = coord_vec.array.reshape(-1, mesh.cdim)[topwall]
index =  np.argsort(coords[:,0])
xx = coords[index,0]
yy = coords[index,-1]
plt.plot(xx,yy,label=r'coords of topwall from mesh.dm.getCoordinatesLocal')
plt.legend(loc = 'upper left',prop = {'size':8})
plt.savefig('tem.png',dpi=300,bbox_inches='tight')

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions