nodes coordinates of high order CG function space

Asked by Yi Jiang

Hi,

Does anyone know how to get a list of all nodes coordinates of high order CG function space. Say I have a 2nd order CG space like

mesh = UnitSquare(4,4)
V = FunctionSpace(mesh, 'CG', 2)

How do I get all the coordinates of the nodes (i.e., Degree of Freedom) of V? If V is linear CG space, mesh.coordinates() would give me those coordinates, is there a similar function for high order CG function space?

Thanks a lot.

Question information

Language:
English Edit question
Status:
Solved
For:
DOLFIN Edit question
Assignee:
No assignee Edit question
Solved by:
Garth Wells
Solved:
Last query:
Last reply:
Revision history for this message
Best Garth Wells (garth-wells) said :
#1

Look at

    GenericDofMap::tabulate_coordinates

Revision history for this message
Yi Jiang (yijiang) said :
#2

Thanks Garth,

Just for clarity and reference. I wrote the following script to do this task. It may be tedious, any comments are welcome.

mesh = UnitSquare(4,4)
V = FunctionSpace(mesh, 'CG', 1)

# Number of cells
NumCells = mesh.num_cells()

# Degree of freedoms
DOF = V.dofmap().global_dimension()

# Initialize nodes coordinates matrix
coor = np.zeros((DOF, 3))

# Evaluate nodes matrix by local-to-global map on each cells
for i in range(NumCells):

    # Current Cell
    C = Cell(mesh, i)

    # Coordinates of nodes in current cell
    cell_coor = V.dofmap().tabulate_coordinates(C)

    # Global indices of nodes in current cell, i.e., local-to-global maps
    nodes = V.dofmap().cell_dofs(i)

    # Evaluate global nodes coordinates matrix
    coor[nodes] = cell_coor

Finally coor is what I need.

Revision history for this message
Yi Jiang (yijiang) said :
#3

Thanks Garth Wells, that solved my question.