# Remove some cells from a mesh

**URL:** <https://simpeg.discourse.group/t/remove-some-cells-from-a-mesh/495>\
**Category:** Discretization\
**Created:** [August 23, 2023, 1:08pm UTC](https://simpeg.discourse.group/t/remove-some-cells-from-a-mesh/495 "2023-08-23T13:08:07Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![amin](https://yyz2.discourse-cdn.com/free1/user_avatar/simpeg.discourse.group/amin/32/223_2.png) [@amin](https://simpeg.discourse.group/u/amin)\
**Post date:** [August 23, 2023, 1:08pm UTC](https://simpeg.discourse.group/t/remove-some-cells-from-a-mesh/495/1 "2023-08-23T13:08:07Z")

</div>

Hi everyone!  
Is there a way to remove arbitrary number of cells from a mesh? To add some context, I need this to “mimic” a domain with some holes.

Thanks!

---

<div class="post-metadata">

**Author:** ![rana](https://avatars.discourse-cdn.com/v4/letter/r/3e96dc/32.png) [@rana](https://simpeg.discourse.group/u/rana)\
**Post date:** [August 24, 2023, 4:06pm UTC](https://simpeg.discourse.group/t/remove-some-cells-from-a-mesh/495/2 "2023-08-24T16:06:17Z")

</div>

I had a similar issue with including a void into a SimPEG model. I combined the model with the void space (concatenated the two text files ) and then re-gridded the data using nearest neighbor algorithm based on the chosen mesh. Make sure, you have smaller cells around the void spaces.

---

<div class="post-metadata">

**Author:** ![amin](https://yyz2.discourse-cdn.com/free1/user_avatar/simpeg.discourse.group/amin/32/223_2.png) [@amin](https://simpeg.discourse.group/u/amin)\
**Post date:** [August 24, 2023, 6:12pm UTC](https://simpeg.discourse.group/t/remove-some-cells-from-a-mesh/495/3 "2023-08-24T18:12:22Z")

</div>

Thanks for your response. Would you be able to share your script (if it’s not private)? Would really appreciate it.

---

<div class="post-metadata">

**Author:** ![rana](https://avatars.discourse-cdn.com/v4/letter/r/3e96dc/32.png) [@rana](https://simpeg.discourse.group/u/rana)\
**Post date:** [August 25, 2023, 3:07pm UTC](https://simpeg.discourse.group/t/remove-some-cells-from-a-mesh/495/4 "2023-08-25T15:07:55Z")

</div>

1. combine the two models by appending them together
2. Create a tensor mesh (or any other mesh)

hx = [(dx, npad\_x, -exp\_x), (dx, ncx), (dx, npad\_x, exp\_x)]  
hy = [(dy, npad\_y, -exp\_y), (dy, ncy), (dy, npad\_y, exp\_y)]  
hz = [(dpz, npad\_z1, -exp\_z1), (dz, ncz), (dpz, npad\_z2, exp\_z2)]

padding\_widths\_x = (dx\*exp\_x\*\*(np.arange(npad\_y) + 1))  
total\_padding\_width\_x = padding\_widths\_x.sum()

mesh = TensorMesh([hx, hy, hz], x0=[x0, y0, z0])  
cc = mesh.gridCC  
3. Check the cell centers to make sure to enough cell density around the voids using cc.  
4. grid the models into a new model  
gridded\_density\_new = gd( (cmb\_model[:,0], cmb\_model[:,1], cmb\_model[:,2]), cmb\_model[:,3],  
(cc[:,0], cc[:,1], cc[:,2] ), method=‘nearest’)

1. Then follow the gravity example to add the topography into the gridded model
