-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Bernard Giroux
committed
Nov 10, 2023
1 parent
fd803cd
commit 1baddef
Showing
10 changed files
with
445 additions
and
61 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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
Large diffs are not rendered by default.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,21 +1,28 @@ | ||
<?xml version="1.0"?> | ||
<VTKFile type="RectilinearGrid" version="0.1" byte_order="LittleEndian" header_type="UInt32" compressor="vtkZLibDataCompressor"> | ||
<RectilinearGrid WholeExtent="0 100 0 0 0 50"> | ||
<Piece Extent="0 100 0 0 0 50" > | ||
<PointData> | ||
</PointData> | ||
<CellData> | ||
<DataArray type="Float64" Name="Slowness" format="appended" RangeMin="0.00016184936638" RangeMax="0.000344114832" offset="0" /> | ||
<DataArray type="Float64" Name="xi" format="appended" RangeMin="1.2649110641" RangeMax="1.2649110641" offset="820" /> | ||
</CellData> | ||
<Coordinates> | ||
<DataArray type="Float32" Name="Array 0x14422f430" format="appended" RangeMin="" RangeMax="" offset="1132" /> | ||
<DataArray type="Float32" Name="Array 0x144229fc0" format="appended" RangeMin="" RangeMax="" offset="1500" /> | ||
<DataArray type="Float32" Name="Array 0x144212ba0" format="appended" RangeMin="" RangeMax="" offset="1540" /> | ||
</Coordinates> | ||
</Piece> | ||
<Piece Extent="0 100 0 0 0 50"> | ||
<PointData> | ||
</PointData> | ||
<CellData> | ||
<DataArray type="Float64" Name="Slowness" format="binary" RangeMin="0.00016184936638457496" RangeMax="0.0003441148320023047"> | ||
AgAAAACAAABAHAAAwgEAAI4AAAA=eJztxU1L0wEAx/ERNLCJFV5knUIsXTb17zZhMg0SQ71YBwtRzMQRjdT5dBBKDQyMwoiCSYdA8aHyofmY5xAWJbLUGMOyEs1LGE5PIvoC+r2Dvp/LJ9KfGCt64sqPMPM/d8X9/fzCwszqaxvexec9TmYW749OrW4lMbP6wP/4Q+6Qg5nFr8eO1+W5mVn9zfiRNhzOZmbxV+Ol2XWXmdWPSm4XvolnZvWztda1T+MGM4ud9c0Wbxkzqy2/6tavmJhZHTN3mwtGs5hZ/D3FVpxZycxqq7uzceMkM6u3Fit28uYzmVnsCrUFrfeYWe1ufhq5kcPM6oSPoYLZ3xnMLE51hm8l1DKzui975MuDTTszi0ds04F1HzOrrWf+zBzbu8jM4oc/fbGpTmZWl5u2+8OnmVltP2e6bwykM7M4+YTHN5nLzOp3g9erjZULzCzu7vV7evzMrPa8b+97e4qZ1UvbvuidCRszi0taJueCZcysTi8u7PIepDGzuOZyU7RhkJnVdkcwMHeVmdXtE9YF22EqM4t3s1pfjY8xs3r5cOiS4yYzq4vi66MDicysrmoo7dgJnWdm8XBp4GxcB/P/+RGVow7DeJxbETBDkbNB3X4FDtpAObLmpsUoPUqP0tjoh60hgiGf1UbpUXqUxkJz798lkbV+lB6lR2lsdP+e9eW8uaP0KD1KY6PZP7duM9AZpUfpURobfe/xgu/H3qiO0qP0KI2FFg/+9O7wulF6lB6lsdHLw9luSReN0qP0KI2NViifXHHYbJQepUdpbDQApqAU2Q== | ||
</DataArray> | ||
<DataArray type="Float64" Name="xi" format="binary" RangeMin="1.2649110640673515" RangeMax="1.264911064067352"> | ||
AgAAAACAAABAHAAAlAAAAD8AAAA=eJzt2rENgEAMA8ANeCTmQbSwBvuXDMAEIEHjD1x1E1iOkrRt3af5WBpJkg8cSV46kCT5wvR8R/ZsOp8kyZqm+4skSZLkf0zfJ8meTeeTJFnT9H6ZJFnTdH+RJEmSJEmSJN+Z/m8hSdY03V8kSZIkSZLknen/epJkTdP9RZKsabq/yJ5N55MkSfJrpuc7MukJNGFQBXic7dcxDQAgDABBB0CCHsIKNvA/IgAFnRuSm07BD1/2On3cWQIrSZIkSZJMN/p2knc2kqHZfZIk//QBQpzlVQ== | ||
</DataArray> | ||
</CellData> | ||
<Coordinates> | ||
<DataArray type="Float64" Name="Array 0x1306073f0" format="binary" RangeMin="0" RangeMax="6000"> | ||
AQAAAACAAAAoAwAAFwEAAA==eJxNzi1MQmEUxvEbCQYiwUAkGAgG4g0GEiMYSI7AHIndOeacwd0x5phzehVUBJUroCL4cf2EQCAaDEQD4UaDgUgwGJ5/8C2/ved9zzmPYfw/CVOuSHuVe06O1qivS3OT9y3p2/wrSLfI/22ZLtG3I8O79O/Rv4+OHB8w71B6ZeZWpHPE/GNpnbCnKpOn7KvJaJ29ZzJ4zv4LOUW/IbMud0xdkgvjTfJhrEVOjLTJi6ErcmPgmvw4Q+tGfmO6I78weSs/0OzKAUZ7soPhO1nF4L0sofEgN3CK2Ufp44JHHdvo4/yTTGEFxzj3LONYxBH+YuxF5tHDH4y8ygy6OMHQm1xGBz8x8C6X0MYhznCxL62++QcopYc0 | ||
</DataArray> | ||
<DataArray type="Float64" Name="Array 0x130607530" format="binary" RangeMin="0" RangeMax="0"> | ||
AQAAAACAAAAIAAAACwAAAA==eJxjYIAAAAAIAAE= | ||
</DataArray> | ||
<DataArray type="Float64" Name="Array 0x130608990" format="binary" RangeMin="0" RangeMax="3000"> | ||
AQAAAACAAACYAQAAqQAAAA==eJxNzikOwkAYhuFKJLISiUQiR6JIJYqgCIo0CASCNIQQQggtW9lpS1ksR+AIHKFHQCIR3ysY82Rm/uWzrP9TNbIuvSb3tnx1eO9K0+O/LzOPuoGMh9SPZGNM30QWpvTP6PcxkO858xbyuWTuSgZr5ofS3bBnK50d+/aydGDvUeZP7D/LD2aRbMXcsZaQCysX8mE5JScWr+RF+0ZuzN3Jj190H+YHwvo/dQ== | ||
</DataArray> | ||
</Coordinates> | ||
</Piece> | ||
</RectilinearGrid> | ||
<AppendedData encoding="base64"> | ||
_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D1/2On3cWQIrSZIkSZJMN/p2knc2kqHZfZIk//QBQpzlVQ==AQAAAACAAACUAQAAAgEAAA==eJwVzTEoBFAcx/F/GZTBYLgyKIYrg8FwZTC43D2DwXBlMChXBoPhymAwIOkkXZJOkpBO0iXpJN2ibMbbbGzG24x8vPr1fd++r17E/6lMR3QtV3C3urWsY13rLUZkLGs5K1jJylaxTasWY6uGdTzHBjaxhW18w3fs4Ad+4Td28Qd/i5HvSf5K8dqXYqs/RX6AZ/ggH+IjPMtH+Rgf5zk+wSf5FC/wGT7L53iJz/MFvsjLfJmv8FVe4Wt8nW/wzRRL2+47KYZ3eTXF5543+ykuD7yr6Yf6kX6s1/UT/VQ/08/1C/1Kv9Yb+o1+q9/pTf1ef9Af9Zb+pD/rL3o7/QFQUmm9AQAAAACAAAAEAAAADAAAAA==eJxjYGBgAAAABAABAQAAAACAAADMAAAAkgAAAA==eJwVzaEOglAYhuFvM7AZDAY2g8HAZjAYzmagMDn/DXgH3gF3II1GpBlpRhrFjUakGW3G04z6crZ3z/+lI82vOEuBXM5NDXU0UaDISzEl5CinC12poBtVXmWNDd6xxQd22OOAI074wjd+MOAXf17ZwvjL9FyaypUpW7Nj9oa9Ze/YCXvPPrCPbMc+sVP7A0DFLZk= | ||
</AppendedData> | ||
</VTKFile> |
Large diffs are not rendered by default.
Oops, something went wrong.
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,241 @@ | ||
#! /usr/bin/env python3 | ||
# -*- coding: utf-8 -*- | ||
|
||
import numpy as np | ||
import matplotlib.pyplot as plt | ||
import vtk | ||
|
||
|
||
# %% | ||
|
||
x = np.arange(0.0, 6000.01, 60.0) | ||
z = np.arange(0.0, 3000.01, 60.0) | ||
|
||
|
||
a = 2271.0 | ||
b = 0.88 | ||
chi = 0.3 | ||
|
||
with open('rcv2daniso.dat', 'w') as f: | ||
print('{0:d}'.format(x.size*z.size), file=f) | ||
for ix in x: | ||
for iz in z: | ||
print('{0:g} {1:g}'.format(ix, iz), file=f) | ||
|
||
|
||
# %% | ||
|
||
x[0] = 0.001 | ||
|
||
xx, zz = np.meshgrid(x, z) | ||
|
||
p = 2*xx / np.sqrt((xx*xx + (1+2*chi) * zz*zz) * | ||
((2*a + b*zz)**2 * (1+2*chi) + b*b * xx*xx)) | ||
|
||
# p[0, 0] = 0.0 | ||
|
||
t = 1/b * (np.arctanh(p * b * xx - np.sqrt(1 - (1+2*chi) * p*p * a*a)) + | ||
np.arctanh(np.sqrt(1 - (1+2*chi) * p*p * a*a))) | ||
|
||
# t[0, 0] = 0 | ||
# t[:, 0] = z / vz | ||
|
||
|
||
# %% | ||
|
||
h = plt.pcolor(xx, zz, t) | ||
plt.contour(xx, zz, t, colors='k', linewidths=0.5) | ||
plt.gca().invert_yaxis() | ||
plt.gca().axis('equal') | ||
plt.colorbar(h) | ||
plt.tight_layout() | ||
plt.show() | ||
|
||
# %% | ||
|
||
x = np.arange(30.0, 6000.0, 60.0) | ||
z = np.arange(30.0, 3000.0, 60.0) | ||
|
||
xx, zz = np.meshgrid(x, z) | ||
|
||
vz = a + b*zz | ||
vx = np.sqrt( chi * 2 * vz**2 + vz**2) | ||
|
||
|
||
sx = 1/vx | ||
sz = 1/vz | ||
|
||
xi = sz / sx | ||
|
||
plt.imshow(xi) | ||
plt.colorbar() | ||
plt.show() | ||
|
||
plt.imshow(sx) | ||
plt.colorbar() | ||
plt.show() | ||
|
||
|
||
|
||
xCoords = vtk.vtkDoubleArray() | ||
yCoords = vtk.vtkDoubleArray() | ||
zCoords = vtk.vtkDoubleArray() | ||
|
||
for i in np.arange(0.0, 6000.1, 60.0): | ||
xCoords.InsertNextValue(i) | ||
for i in np.arange(0.0, 3000.1, 60.0): | ||
zCoords.InsertNextValue(i) | ||
yCoords.InsertNextValue(0.0) | ||
|
||
rgrid = vtk.vtkRectilinearGrid() | ||
rgrid.SetDimensions(xCoords.GetNumberOfValues(), | ||
yCoords.GetNumberOfValues(), | ||
zCoords.GetNumberOfValues()) | ||
rgrid.SetXCoordinates(xCoords) | ||
rgrid.SetYCoordinates(yCoords) | ||
rgrid.SetZCoordinates(zCoords) | ||
|
||
slown = vtk.vtkDoubleArray() | ||
for i in sx.flatten(): | ||
slown.InsertNextValue(i) | ||
slown.SetName("Slowness") | ||
rgrid.GetCellData().AddArray(slown) | ||
|
||
xi_vtk = vtk.vtkDoubleArray() | ||
for i in xi.flatten(): | ||
xi_vtk.InsertNextValue(i) | ||
xi_vtk.SetName("xi") | ||
rgrid.GetCellData().AddArray(xi_vtk) | ||
|
||
writer = vtk.vtkXMLRectilinearGridWriter() | ||
writer.SetInputData(rgrid) | ||
writer.SetFileName('elliptical_fine2d.vtr') | ||
writer.SetDataModeToBinary() | ||
writer.Write() | ||
|
||
# %% | ||
rgrid = vtk.vtkRectilinearGrid() | ||
rgrid.SetDimensions(xCoords.GetNumberOfValues(), | ||
yCoords.GetNumberOfValues(), | ||
zCoords.GetNumberOfValues()) | ||
rgrid.SetXCoordinates(xCoords) | ||
rgrid.SetYCoordinates(yCoords) | ||
rgrid.SetZCoordinates(zCoords) | ||
|
||
tt = vtk.vtkDoubleArray() | ||
for i in t.flatten(): | ||
tt.InsertNextValue(i) | ||
tt.SetName("Travel Time") | ||
rgrid.GetPointData().AddArray(tt) | ||
|
||
writer = vtk.vtkXMLRectilinearGridWriter() | ||
writer.SetInputData(rgrid) | ||
writer.SetFileName('sol_analytique_elliptical_2d_tt.vtr') | ||
writer.SetDataModeToBinary() | ||
writer.Write() | ||
|
||
# %% | ||
|
||
x = np.arange(0.0, 6000.01, 60.0) | ||
z = np.arange(0.0, 3000.01, 60.0) | ||
|
||
xx, zz = np.meshgrid(x, z) | ||
|
||
xx = xx.flatten() | ||
zz = zz.flatten() | ||
t = t.flatten() | ||
|
||
npx = x.size | ||
ncx = x.size - 1 | ||
ncz = z.size - 1 | ||
|
||
tri = [] | ||
slo = [] | ||
xi = [] | ||
for nz in range(ncz): | ||
for nx in range(ncx): | ||
tri.append([nz*npx + nx, nz*npx + nx+1, (nz+1)*npx + nx]) | ||
|
||
zc = (zz[tri[-1][0]] + zz[tri[-1][1]] + zz[tri[-1][2]]) / 3. | ||
vz = a + b*zc | ||
vx = np.sqrt( chi * 2 * vz**2 + vz**2) | ||
|
||
sx = 1/vx | ||
sz = 1/vz | ||
|
||
slo.append(sx) | ||
xi.append( sz / sx ) | ||
|
||
tri.append([nz*npx + nx+1, (nz+1)*npx + nx, (nz+1)*npx + nx + 1]) | ||
|
||
zc = (zz[tri[-1][0]] + zz[tri[-1][1]] + zz[tri[-1][2]]) / 3. | ||
vz = a + b*zc | ||
vx = np.sqrt( chi * 2 * vz**2 + vz**2) | ||
|
||
sx = 1/vx | ||
sz = 1/vz | ||
|
||
slo.append(sx) | ||
xi.append( sz / sx ) | ||
|
||
# %% | ||
|
||
ugrid = vtk.vtkUnstructuredGrid() | ||
pts = vtk.vtkPoints() | ||
|
||
for n in range(len(xx)): | ||
pts.InsertNextPoint(xx[n], 0.0, zz[n]) | ||
|
||
ugrid.SetPoints(pts) | ||
|
||
triangle = vtk.vtkTriangle() | ||
d_s = vtk.vtkDoubleArray() | ||
d_x = vtk.vtkDoubleArray() | ||
d_s.SetName("Slowness") | ||
d_x.SetName("xi") | ||
for n in range(len(tri)): | ||
triangle.GetPointIds().SetId(0, tri[n][0]) | ||
triangle.GetPointIds().SetId(1, tri[n][1]) | ||
triangle.GetPointIds().SetId(2, tri[n][2]) | ||
ugrid.InsertNextCell( triangle.GetCellType(), triangle.GetPointIds() ) | ||
d_s.InsertNextValue(slo[n]) | ||
d_x.InsertNextValue(xi[n]) | ||
|
||
ugrid.GetCellData().AddArray(d_s) | ||
ugrid.GetCellData().AddArray(d_x) | ||
|
||
writer = vtk.vtkXMLUnstructuredGridWriter() | ||
writer.SetInputData(ugrid) | ||
writer.SetFileName('elliptical_fine2d.vtu') | ||
writer.SetDataModeToBinary() | ||
writer.Write() | ||
|
||
# %% | ||
|
||
ugrid = vtk.vtkUnstructuredGrid() | ||
pts = vtk.vtkPoints() | ||
|
||
for n in range(len(xx)): | ||
pts.InsertNextPoint(xx[n], 0.0, zz[n]) | ||
|
||
ugrid.SetPoints(pts) | ||
|
||
triangle = vtk.vtkTriangle() | ||
for n in range(len(tri)): | ||
triangle.GetPointIds().SetId(0, tri[n][0]) | ||
triangle.GetPointIds().SetId(1, tri[n][1]) | ||
triangle.GetPointIds().SetId(2, tri[n][2]) | ||
ugrid.InsertNextCell( triangle.GetCellType(), triangle.GetPointIds() ) | ||
|
||
d_t = vtk.vtkDoubleArray() | ||
d_t.SetName("Travel Time") | ||
for n in range(len(t)): | ||
d_t.InsertNextValue(t[n]) | ||
|
||
ugrid.GetPointData().AddArray(d_t) | ||
|
||
# writer = vtk.vtkXMLUnstructuredGridWriter() | ||
# writer.SetInputData(ugrid) | ||
# writer.SetFileName('tests/files/sol_analytique_elliptical_2d_tt.vtu') | ||
# writer.SetDataModeToBinary() | ||
# writer.Write() |
Large diffs are not rendered by default.
Oops, something went wrong.
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
Oops, something went wrong.