-
Notifications
You must be signed in to change notification settings - Fork 267
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add smooth_data() to smooth/diffuse data attributes
- Loading branch information
Showing
5 changed files
with
105 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import numpy as np | ||
from vedo import Grid, settings, show | ||
from vedo.pyplot import histogram | ||
|
||
settings.default_font = "FiraMonoMedium" | ||
|
||
grid = Grid(res=[50,50]) | ||
grid.wireframe(False).lw(0) | ||
|
||
values = np.zeros(grid.npoints) | ||
values[int(grid.npoints/2)] = 1 | ||
values[int(grid.npoints/5)] = 1 | ||
|
||
grid.pointdata["scalars"] = values | ||
grid.cmap("Set1_r").add_scalarbar() | ||
|
||
grid2 = grid.clone() | ||
grid2.smooth_data(niter=750, relaxation_factor=0.1, strategy=1) | ||
grid2.cmap("Set1_r").add_scalarbar() | ||
|
||
his = histogram( | ||
grid2.pointdata["scalars"], | ||
c='k4', | ||
xtitle="Concentration", | ||
ytitle="Frequency", | ||
axes=dict(htitle="", axes_linewidth=2, xyframe_line=0), | ||
) | ||
his = his.clone2d() # fix it to screen coords | ||
|
||
print("integrated over domain:", grid2.integrate_arrays_over_domain()) | ||
|
||
show([ | ||
["Initial state", grid], | ||
["After diffusion", grid2, his]], | ||
N=2, axes=1, | ||
).close() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters