Skip to content

Extracting fields as 2d arrays on rectangular grid #133

Answered by HelgeGehring
lokgar asked this question in Q&A
Discussion options

You must be logged in to vote
# Trying interpolator
basis = modes[0].basis
basis_fix = basis.with_element(ElementVector(ElementDG(ElementTriP1())))

(et, et_basis), (ez, ez_basis) = basis.split(modes[0].E)
(et_x, et_x_basis), (et_y, et_y_basis) = basis_fix.split(basis_fix.project(et_basis.interpolate(et)))

node_coordinates = mesh.p
xmin, xmax = node_coordinates[0, :].min() / 2, node_coordinates[0, :].max() / 2
ymin, ymax = node_coordinates[1, :].min() / 2, node_coordinates[1, :].max() / 2

grid_x, grid_y = np.mgrid[xmin:xmax:200j, ymin:ymax:200j]

coordinates = np.array([grid_x.flatten(), grid_y.flatten()])

grid_data_1 = np.array((et_x_basis.interpolator(et_x)(coordinates), et_y_basis.interpolator(et_y)(coordinates), 

Replies: 2 comments 8 replies

Comment options

You must be logged in to vote
6 replies
@lokgar
Comment options

@HelgeGehring
Comment options

@lokgar
Comment options

@HelgeGehring
Comment options

Answer selected by lokgar
@lokgar
Comment options

@HelgeGehring
Comment options

Comment options

You must be logged in to vote
2 replies
@lokgar
Comment options

@HelgeGehring
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants