Meshing¶
In [1]:
import numpy as np
import os
import pandas as pd
import gstlearn as gl
import gstlearn.plot as gp
import gstlearn.document as gdoc
gdoc.setNoScroll()
Standard Meshing based on an Irregular Data Set¶
We construct a Meshing Standard based on a set of Data Points
In [2]:
nech = 40
extendmin = [0,0]
extendmax = [150,100]
data = gl.Db.createFromBox(nech,extendmin, extendmax)
data
Out[2]:
Data Base Characteristics ========================= Data Base Summary ----------------- File is organized as a set of isolated points Space dimension = 2 Number of Columns = 3 Total number of samples = 40 Variables --------- Column = 0 - Name = rank - Locator = NA Column = 1 - Name = x-1 - Locator = x1 Column = 2 - Name = x-2 - Locator = x2
In [3]:
gp.setDefaultGeographic(dims=[7,7])
ax = data.plot()
ax.decoration(title="Display of Data Set")
Creating the Meshing
Turbo Meshing¶
Instead we can use Turbo Meshing to cover an area, without specifically honoring each datum
In [4]:
mesh3 = gl.MeshETurbo()
err = mesh3.initFromExtend(extendmin, extendmax, [5,5])
mesh3.display()
Turbo Meshing ============= Grid characteristics: --------------------- Origin : 0.000 0.000 Mesh : 5.000 5.000 Number : 31 21 Euclidean Geometry Space Dimension = 2 Number of Apices per Mesh = 3 Number of Meshes = 1200 Number of Apices = 651 Bounding Box Extension ---------------------- Dim #1 - Min:0 - Max:150 Dim #2 - Min:0 - Max:100
In [5]:
ax = mesh3.plot()
ax.decoration(title="Turbo Meshing on the whole area")
ax = data.plot(color="black")
We can create a regular grid covering the same area (based on the data set)
In [6]:
grid = gl.DbGrid()
err = grid.resetCoveringDb(data, [50,50])
Define a Polygon as the Convex hull of the data
In [7]:
polygon = gl.Polygons()
err = polygon.resetFromDb(data)
Use the Polygon to mask off some nodes of the regular grid, located too far from the data
In [8]:
err = gl.db_polygon(grid, polygon)
We create a Turbo Meshing from the grid (which contains a selection)
In [9]:
mesh4 = gl.MeshETurbo(grid)
mesh4.display()
Turbo Meshing ============= Grid characteristics: --------------------- Origin : 0.648 3.385 Mesh : 2.892 1.928 Number : 50 50 Euclidean Geometry Space Dimension = 2 Number of Apices per Mesh = 3 Number of Meshes = 3481 Number of Apices = 1830 Bounding Box Extension ---------------------- Dim #1 - Min:0.648392 - Max:142.336 Dim #2 - Min:3.38503 - Max:97.8622 Mask Information ................ Mesh Masking Indexing - Information (AToR) is stored as a Map - Number of absolute positions = 4802 - Number of active positions = 3481 Grid Masking Indexing - Information (AToR) is stored as a Map - Number of absolute positions = 2500 - Number of active positions = 1830
In [10]:
ax = mesh4.plot()
ax = data.plot(color="black")
ax = polygon.plot()
ax.decoration(title="Turbo Meshing restricted to the Convex Hull of Data")
Read and Write in Neutral File¶
Testing the read and write into a Neutral File (with masked meshes)
In [11]:
gl.ASerializable.setContainerName(True)
gl.ASerializable.setPrefixName("Tuto-Meshing")
err = mesh4.dumpToNF("Mesh_masked")
mesh5 = gl.MeshETurbo.createFromNF("Mesh_masked")
mesh5.display()
Turbo Meshing ============= Grid characteristics: --------------------- Origin : 0.648 3.385 Mesh : 2.892 1.928 Number : 50 50 Euclidean Geometry Space Dimension = 2 Number of Apices per Mesh = 3 Number of Meshes = 3481 Number of Apices = 1830 Bounding Box Extension ---------------------- Dim #1 - Min:0.648392 - Max:142.336 Dim #2 - Min:3.38503 - Max:97.8622 Mask Information ................ Mesh Masking Indexing - Information (AToR) is stored as a Map - Number of absolute positions = 4802 - Number of active positions = 3481 Grid Masking Indexing - Information (AToR) is stored as a Map - Number of absolute positions = 2500 - Number of active positions = 1830
In [12]:
mesh5.display()
Turbo Meshing ============= Grid characteristics: --------------------- Origin : 0.648 3.385 Mesh : 2.892 1.928 Number : 50 50 Euclidean Geometry Space Dimension = 2 Number of Apices per Mesh = 3 Number of Meshes = 3481 Number of Apices = 1830 Bounding Box Extension ---------------------- Dim #1 - Min:0.648392 - Max:142.336 Dim #2 - Min:3.38503 - Max:97.8622 Mask Information ................ Mesh Masking Indexing - Information (AToR) is stored as a Map - Number of absolute positions = 4802 - Number of active positions = 3481 Grid Masking Indexing - Information (AToR) is stored as a Map - Number of absolute positions = 2500 - Number of active positions = 1830
Turbo Meshing on Rotated Grid¶
In [13]:
grid = gl.DbGrid.create(nx=[6,4], dx=[1.,5.], x0=[10.,20.], angles=[-80.,0.])
grid.display()
ax = gp.point(grid,color="black")
Data Base Grid Characteristics ============================== Data Base Summary ----------------- File is organized as a regular grid Space dimension = 2 Number of Columns = 3 Total number of samples = 24 Grid characteristics: --------------------- Origin : 10.000 20.000 Mesh : 1.000 5.000 Number : 6 4 Rotation Angles = -80.000 0.000 Direct Rotation Matrix [, 0] [, 1] [ 0,] 0.174 0.985 [ 1,] -0.985 0.174 Inverse Rotation Matrix [, 0] [, 1] [ 0,] 0.174 -0.985 [ 1,] 0.985 0.174 Variables --------- Column = 0 - Name = rank - Locator = NA Column = 1 - Name = x1 - Locator = x1 Column = 2 - Name = x2 - Locator = x2
In [14]:
model = gl.Model.createFromParam(gl.ECov.CUBIC,ranges=[10.,5.], angles=[30.,0.])
model.display()
Model characteristics ===================== Space dimension = 2 Number of variable(s) = 1 Number of basic structure(s) = 1 Number of drift function(s) = 0 Number of drift equation(s) = 0 Covariance Part --------------- Cubic - Sill = 1.000 - Ranges = 10.000 5.000 - Angles = 30.000 0.000 - Rotation Matrix [, 0] [, 1] [ 0,] 0.866 -0.500 [ 1,] 0.500 0.866 Total Sill = 1.000 Known Mean(s) 0.000
In [15]:
mesh6 = gl.MeshETurbo()
mesh6.initFromCova(model.getCova(0),grid,ratio=10,nbExt=2,flagNoStatRot=False,useSel=True)
mesh6.display()
Turbo Meshing ============= Diamond construction is activated Grid characteristics: --------------------- Origin : 12.201 8.767 Mesh : 1.000 0.500 Number : 21 25 Rotation Angles = 30.000 0.000 Direct Rotation Matrix [, 0] [, 1] [ 0,] 0.866 -0.500 [ 1,] 0.500 0.866 Inverse Rotation Matrix [, 0] [, 1] [ 0,] 0.866 0.500 [ 1,] -0.500 0.866 Euclidean Geometry Space Dimension = 2 Number of Apices per Mesh = 3 Number of Meshes = 960 Number of Apices = 525 Bounding Box Extension ---------------------- Dim #1 - Min:12.2013 - Max:32.2013 Dim #2 - Min:8.76696 - Max:20.767
In [16]:
ax = mesh6.plot()
ax = gp.point(grid,color="black")
ax.decoration(title="Turbo Meshing for Rotated Grid")