Skip to content
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

octree mesh reshape (mesh.r) #98

Closed
craigmillernz opened this issue Jul 18, 2018 · 2 comments
Closed

octree mesh reshape (mesh.r) #98

craigmillernz opened this issue Jul 18, 2018 · 2 comments

Comments

@craigmillernz
Copy link

craigmillernz commented Jul 18, 2018

Given the recent work on octree there are a couple of tensor mesh functions that would be useful to implement in octree. One is mesh.r . From the tensor mesh

r is a quick reshape command that will do the best it can at giving you what you want.
For example, you have a face variable, and you want the x component of it reshaped to a 3D matrix.
r can fulfil your dreams:

I would suggest using a better name such as reshape?

One way to do it might be to resample back to Tensor using something like this (thanks Dom)

Can my dreams be fulfilled?
`
if isinstance(meshInput, Mesh.TensorMesh):
tree = cKDTree(mesh.gridCC)

    dd, ind = tree.query(meshInput.gridCC) # can load any Tensor mesh here.

    # Model out

    vec_xyz = Utils.matutils.atp2xyz(mrec_MVI_S.reshape((nC, 3), order='F')).reshape((nC, 3), order='F')
    vec_x = actvMap * vec_xyz[:,0]
    vec_y = actvMap * vec_xyz[:,1]
    vec_z = actvMap * vec_xyz[:,2]

    vec_xyzTensor = np.zeros((meshInput.nC,3))
    vec_xyzTensor = np.c_[vec_x[ind], vec_y[ind], vec_z[ind]]

    PF.MagneticsDriver.writeVectorUBC(meshInput, work_dir+out_dir + 'MVI_S_Tensor.fld', vec_xyzTensor)

    amp = np.sum(vec_xyzTensor**2., axis=1)**0.5
    meshInput.writeModelUBC(work_dir+out_dir + 'MVI_S_Tensor.amp', amp)
    meshInput.writeUBC(work_dir+out_dir + driver.mshfile.split('/')[2])

`

@jcapriot
Copy link
Member

Well, i don’t really think a reshape command will do much on a TreeMesh, as all of the vectors are 1D already, and there isn’t much ordering that can be expected, especially not in a 3D matrix.

If you’d like a way to generate the underlying TensorMesh from the TreeMesh, you could access its .h and .x0 properties and create a TensorMesh from those.

@lheagy
Copy link
Member

lheagy commented Jul 3, 2019

👋 @craigmillernz: I am going to close this. Feel free to re-open if you still have questions or lingering ideas here!

@lheagy lheagy closed this as completed Jul 3, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants