How to get rid of repeated entries and how to find an entry in the dof coordinates.


115
views
1
5 months ago by
Nima  
Hi,

I have the code below:
mesh = UnitCubeMesh(4, 4 , 4)
V = VectorFunctionSpace(mesh, 'P', 1)
N = V.dim()
d = mesh.geometry().dim()

dof_coordinates = V.tabulate_dof_coordinates()
dof_coordinates.resize( ( N , d ) )​
First of all the "dof_coordinates" repeats every point 3 times. How can get rid of the repetitions?
Second of all, is it possible to have Fenics spit out the number of the row for which I have the entry (0.5  0.5  0.5)?
Community: FEniCS Project

1 Answer


3
5 months ago by
Consider this

import numpy as np

# Get dof coordinates
dof_coordinates = V.tabulate_dof_coordinates().reshape((-1, d))[::d]

# Find rows
n = dof_coordinates.shape[0]
a = [i for i in range(n) if (np.linalg.norm(dof_coordinates[i] - [0.5,0.5,0.5]) < DOLFIN_EPS)]
print(a)​
Please login to add an answer/comment or follow this question.

Similar posts:
Search »