Documentation ¶
Overview ¶
Package gm (geometry and meshes) implements auxiliary functions for handling geometry and mesh structures
Index ¶
- Variables
- func DistPointBoxN(p *PointN, b *BoxN) (dist float64)
- func DistPointLine(p, a, b *Point, tol float64, verbose bool) float64
- func DistPointPoint(a, b *Point) float64
- func DistPointPointN(p *PointN, q *PointN) (dist float64)
- func DrawArrow2d(c, v la.Vector, normalize bool, sf float64, args *plt.A)
- func DrawArrow2dM(c la.Vector, vm *la.Matrix, col int, normalize bool, sf float64, args *plt.A)
- func DrawArrow3d(c, v la.Vector, normalize bool, sf float64, args *plt.A)
- func DrawArrow3dM(c la.Vector, vm *la.Matrix, col int, normalize bool, sf float64, args *plt.A)
- func GetVec2d(M *la.Matrix, col int, normalize bool) la.Vector
- func GetVec3d(M *la.Matrix, col int, normalize bool) la.Vector
- func IsPointIn(p *Point, cMin, cMax []float64, tol float64) bool
- func IsPointInLine(p, a, b *Point, zero, told, tolin float64) bool
- func PlotNurbs(dirout, fnkey string, b *Nurbs, ndim, npts int, withIds, withCtrl bool, ...)
- func PlotNurbsBasis2d(dirout, fnkey string, b *Nurbs, la, lb int, withElems, withCtrl bool, ...)
- func PlotNurbsDerivs2d(dirout, fnkey string, b *Nurbs, la, lb int, withElems, withCtrl bool, ...)
- func PointsLims(pp []*Point) (cmin, cmax []float64)
- func VecDot(u, v []float64) float64
- func VecNew(m float64, u []float64) []float64
- func VecNewAdd(α float64, u []float64, β float64, v []float64) []float64
- func VecNorm(u []float64) float64
- type BezierQuad
- type Bin
- type BinEntry
- type Bins
- func (o *Bins) Append(x []float64, id int, extra interface{})
- func (o Bins) CalcIndex(x []float64) int
- func (o *Bins) Clear()
- func (o *Bins) Draw(withEntry, withGrid, withEntryTxt, withGridTxt bool, ...)
- func (o Bins) FindAlongSegment(xi, xf []float64, tol float64) []int
- func (o Bins) FindBinByIndex(idx int) *Bin
- func (o Bins) FindClosest(x []float64) (idClosest int, sqDistMin float64)
- func (o *Bins) FindClosestAndAppend(nextID *int, x []float64, extra interface{}, radTol float64, ...) (id int, existent bool)
- func (o *Bins) Init(xmin, xmax []float64, ndiv []int)
- func (o *Bins) Nactive() (nactive int)
- func (o *Bins) Nentries() (nentries int)
- func (o Bins) String() string
- func (o *Bins) Summary() (l string)
- type BoxN
- type Bspline
- func (o *Bspline) CalcBasis(t float64)
- func (o *Bspline) CalcBasisAndDerivs(t float64)
- func (o *Bspline) Draw2d(npts, option int, withCtrl bool, argsCurve, argsCtrl *plt.A)
- func (o *Bspline) Draw3d(npts int)
- func (o *Bspline) Elements() (spans [][]int)
- func (o *Bspline) GetBasis(i int) float64
- func (o *Bspline) GetDeriv(i int) float64
- func (o *Bspline) NumBasis() int
- func (o *Bspline) PlotBasis(npts, option int)
- func (o *Bspline) PlotDerivs(npts int)
- func (o *Bspline) Point(t float64, option int) (C []float64)
- func (o *Bspline) RecursiveBasis(t float64, i int) float64
- func (o *Bspline) SetControl(Q [][]float64)
- func (o *Bspline) SetOrder(p int)
- type CurvGrid
- type Entity
- type Grid
- func (o *Grid) Boundary(tag int) []int
- func (o *Grid) Draw(withTxt bool, argsGrid, argsTxt *plt.A) (coordsGenerated bool)
- func (o *Grid) Edge(iEdge int) []int
- func (o *Grid) EdgeT(tag int) []int
- func (o *Grid) Face(iFace int) []int
- func (o *Grid) FaceT(tag int) []int
- func (o *Grid) GenUniform(min, max []float64, ndiv []int, genMeshCoords bool)
- func (o *Grid) GetNode(n int) (x la.Vector)
- func (o *Grid) Length(dim int) float64
- func (o *Grid) Max(dim int) float64
- func (o *Grid) Mesh2d() (X, Y [][]float64)
- func (o *Grid) Mesh3d() (X, Y, Z [][][]float64)
- func (o *Grid) Min(dim int) float64
- func (o *Grid) Ndim() int
- func (o *Grid) Node(x la.Vector, n int)
- func (o *Grid) Npts(dim int) int
- func (o *Grid) Set2d(X, Y []float64, genMeshCoords bool)
- func (o *Grid) Set3d(X, Y, Z []float64, genMeshCoords bool)
- func (o *Grid) Size() int
- type Metrics
- type Nurbs
- func (o *Nurbs) CalcBasis(u []float64)
- func (o *Nurbs) CalcBasisAndDerivs(u []float64)
- func (o *Nurbs) CloneCtrlsAlongCurve(iAlong, jAt int) (Qnew [][][][]float64)
- func (o *Nurbs) CloneCtrlsAlongSurface(iAlong, jAlong, kat int) (Qnew [][][][]float64)
- func (o *Nurbs) DrawCtrl(ndim int, withIds bool, args, argsIds *plt.A)
- func (o *Nurbs) DrawEdge(ndim int, tmin, tmax, cte float64, along, npts int, args *plt.A)
- func (o *Nurbs) DrawElem(ndim int, span []int, npts int, withIds bool, args, argsIds *plt.A)
- func (o *Nurbs) DrawElems(ndim int, npts int, withIds bool, args, argsIds *plt.A)
- func (o *Nurbs) DrawSurface(ndim int, nu, nv int, withSurf, withWire bool, argsSurf, argsWire *plt.A)
- func (o *Nurbs) DrawVectors3d(nu, nv int, sf float64, argsU, argsV *plt.A)
- func (o *Nurbs) ElemBryLocalInds() (I [][]int)
- func (o *Nurbs) Elements() (spans [][]int)
- func (o *Nurbs) ExtractSurfaces() (surfs []*Nurbs)
- func (o *Nurbs) GetBasisI(I []int) float64
- func (o *Nurbs) GetBasisL(l int) float64
- func (o *Nurbs) GetDerivI(dRdu []float64, I []int)
- func (o *Nurbs) GetDerivL(dRdu []float64, l int)
- func (o *Nurbs) GetElemNumBasis() (npts int)
- func (o *Nurbs) GetLimitsQ() (xmin, xmax []float64)
- func (o *Nurbs) GetQ(i, j, k int) (x []float64)
- func (o *Nurbs) GetQl(l int) (x []float64)
- func (o *Nurbs) GetU(dir int) []float64
- func (o *Nurbs) Gnd() int
- func (o *Nurbs) IndBasis(span []int) (L []int)
- func (o *Nurbs) IndsAlongCurve(iAlong, iSpan0, jAt int) (L []int)
- func (o *Nurbs) IndsAlongSurface(iAlong, jAlong, iSpan0, jSpan0, kat int) (L []int)
- func (o *Nurbs) Krefine(X [][]float64) (O *Nurbs)
- func (o *Nurbs) KrefineN(ndiv int, hughesEtAlPaper bool) *Nurbs
- func (o *Nurbs) NonZeroSpans(dir int) [][]int
- func (o *Nurbs) NumBasis(dir int) int
- func (o *Nurbs) Ord(dir int) int
- func (o *Nurbs) PlotBasis2d(l int, npts, option int)
- func (o *Nurbs) PlotDeriv2d(l, d int, npts int)
- func (o *Nurbs) Point(C, u []float64, ndim int)
- func (o *Nurbs) PointDeriv(dCdu *la.Matrix, C, u []float64, ndim int)
- func (o *Nurbs) RecursiveBasis(u []float64, l int) (res float64)
- func (o *Nurbs) SetControl(verts [][]float64, ctrls []int)
- func (o *Nurbs) SetQ(i, j, k int, x []float64)
- func (o *Nurbs) SetQl(l int, x []float64)
- func (o *Nurbs) U(dir, idx int) float64
- type NurbsExchangeData
- type NurbsExchangeDataSet
- type NurbsPatch
- type Octree
- type Point
- type PointExchangeData
- type PointN
- type Segment
- type Transfinite
Constants ¶
This section is empty.
Variables ¶
var FactoryNurbs = facNurbsT{}
FactoryNurbs generates NURBS'
var FactoryTfinite = facTfinite{}
FactoryTfinite generates transfinite mappings
var (
XDELZERO = 1e-10 // minimum distance between coordinates; i.e. xmax[i]-xmin[i] mininum
)
consts
Functions ¶
func DistPointBoxN ¶
DistPointBoxN returns the distance of a point to the box
NOTE: If point p lies outside box b, the distance to the nearest point on b is returned. If p is inside b or on its surface, zero is returned.
func DistPointLine ¶
DistPointLine computes the distance from p to line passing through a -> b
func DistPointPoint ¶
DistPointPoint computes the unsigned distance from a to b
func DistPointPointN ¶
DistPointPointN returns the distance between two PointN
func DrawArrow2d ¶
DrawArrow2d draws 2d arrow @ c with direction v
func DrawArrow2dM ¶
DrawArrow2dM draws 2d arrow @ c with direction v (matrix version)
func DrawArrow3d ¶
DrawArrow3d draws 3d arrow @ c with direction v
func DrawArrow3dM ¶
DrawArrow3dM draws 3d arrow @ c with direction v (matrix version)
func IsPointInLine ¶
IsPointInLine returns whether p is inside line passing through a and b
func PlotNurbs ¶
func PlotNurbs(dirout, fnkey string, b *Nurbs, ndim, npts int, withIds, withCtrl bool, argsElems, argsCtrl, argsIds *plt.A, extra func())
PlotNurbs plots a NURBS
ndim -- 2 or 3 => to plot in a 2D or 3D space
func PlotNurbsBasis2d ¶
func PlotNurbsBasis2d(dirout, fnkey string, b *Nurbs, la, lb int, withElems, withCtrl bool, argsElems, argsCtrl *plt.A, extra func(idxSubplot int))
PlotNurbsBasis2d plots basis functions la and lb
First row == CalcBasis Second row == CalcBasisAndDerivs Third row == RecursiveBasis
func PlotNurbsDerivs2d ¶
func PlotNurbsDerivs2d(dirout, fnkey string, b *Nurbs, la, lb int, withElems, withCtrl bool, argsElems, argsCtrl *plt.A, extra func(idxSubplot int))
PlotNurbsDerivs2d plots derivatives of basis functions la and lb in 2D space
Left column == Analytical Right column == Numerical
func PointsLims ¶
PointsLims returns the limits of a set of points
Types ¶
type BezierQuad ¶
type BezierQuad struct { // input Q [][]float64 // control points; can be set outside // auxiliary P []float64 // a point on curve }
BezierQuad implements a quadratic Bezier curve
C(t) = (1-t)² Q0 + 2 t (1-t) Q1 + t² Q2 = t² A + 2 t B + Q0 A = Q2 - 2 Q1 + Q0 B = Q1 - Q0
func (*BezierQuad) DistPoint ¶
func (o *BezierQuad) DistPoint(X []float64, doplot bool) float64
DistPoint returns the distance from a point to this Bezier curve It finds the closest projection which is stored in P
func (*BezierQuad) GetControlCoords ¶
func (o *BezierQuad) GetControlCoords() (X, Y, Z []float64)
GetControlCoords returns the coordinates of control points as 1D arrays (e.g. for plotting)
func (*BezierQuad) GetPoints ¶
func (o *BezierQuad) GetPoints(T []float64) (X, Y, Z []float64)
GetPoints returns points along the curve for given parameter values
func (*BezierQuad) Point ¶
func (o *BezierQuad) Point(C []float64, t float64)
Point returns the x-y-z coordinates of a point on Bezier curve
type BinEntry ¶
type BinEntry struct { ID int // object Id X []float64 // entry coordinate (read only) Extra interface{} // any entity attached to this entry }
BinEntry holds data of an entry to bin
type Bins ¶
type Bins struct { Ndim int // space dimension Xmin []float64 // [ndim] left/lower-most point Xmax []float64 // [ndim] right/upper-most point Xdel []float64 // [ndim] the lengths along each direction (whole box) Size []float64 // size of bins Npts []int // [ndim] number of points along each direction; i.e. ndiv + 1 All []*Bin // [nbins] all bins (there will be an extra "ghost" bin along each dimension) // contains filtered or unexported fields }
Bins implements a set of bins holding entries and is used to fast search entries by given coordinates.
func (Bins) CalcIndex ¶
CalcIndex calculates the bin index where the point x is returns -1 if out-of-range
func (*Bins) Draw ¶
func (o *Bins) Draw(withEntry, withGrid, withEntryTxt, withGridTxt bool, argsEntry, argsGrid, argsTxtEntry, argsTxtGrid *plt.A, selBins map[int]bool)
Draw draws bins; i.e. grid
func (Bins) FindAlongSegment ¶
FindAlongSegment gets the ids of entries that lie close to a segment
Note: the initial (xi) and final (xf) points on segment define a bounding box to filter points
func (Bins) FindBinByIndex ¶
FindBinByIndex finds or allocate new bin corresponding to index idx
func (Bins) FindClosest ¶
FindClosest returns the id of the entry whose coordinates are closest to x
idClosest -- the id of the closest entity. return -1 if out-of-range or not found sqDistMin -- the minimum distance (squared) between x and the closest entity in the same bin
func (*Bins) FindClosestAndAppend ¶
func (o *Bins) FindClosestAndAppend(nextID *int, x []float64, extra interface{}, radTol float64, diff func(idOld int, xNew []float64) bool) (id int, existent bool)
FindClosestAndAppend finds closest point and, if not found, append to bins with a new Id
Input: nextId -- is the Id of the next point. Will be incremented if x is a new point to be added. x -- is the point to be added extra -- extra information attached to point radTol -- is the tolerance for the radial distance (i.e. NOT squared) to decide whether a new point will be appended or not. diff -- [optional] a function for further check that the new and an eventual existent points are really different, even after finding that they coincide (within tol) Output: id -- the id attached to x existent -- flag telling if x was found, based on given tolerance
func (*Bins) Init ¶
Init initialise Bins structure
xmin -- [ndim] min/initial coordinates of the whole space (box/cube) xmax -- [ndim] max/final coordinates of the whole space (box/cube) ndiv -- [ndim] number of divisions for xmax-xmin
type BoxN ¶
type BoxN struct { // essential Lo *PointN // lower point Hi *PointN // higher point // auxiliary ID int // an auxiliary identification number }
BoxN implements a box int he N-dimensional space
func NewBoxN ¶
NewBoxN creates a new box with given limiting coordinates
L -- limits [4] or [6]: xmin,xmax, ymin,ymax, {zmin,zmax} optional
type Bspline ¶
type Bspline struct { // essential T []float64 // array of knots: e.g: T = [t_0, t_1, ..., t_{m-1}] // optional Q [][]float64 // control points (has to call SetControl to change this) // contains filtered or unexported fields }
Bspline holds B-spline data
Reference: [1] Piegl L and Tiller W (1995) The NURBS book, Springer, 646p
func NewBspline ¶
NewBspline returns a new B-spline
func (*Bspline) CalcBasis ¶
CalcBasis computes all non-zero basis functions N[i] @ t Note: use GetBasis to get a particular basis function value
func (*Bspline) CalcBasisAndDerivs ¶
CalcBasisAndDerivs computes all non-zero basis functions N[i] and corresponding first order derivatives of basis functions w.r.t t => dR[i]dt @ t Note: use GetBasis to get a particular basis function value
use GetDeriv to get a particular derivative
func (*Bspline) Draw2d ¶
Draw2d draws curve and control points option = 0 : use CalcBasis
1 : use RecursiveBasis
func (*Bspline) GetBasis ¶
GetBasis returns the basis function N[i] just computed by CalcBasis or CalcBasisAndDerivs
func (*Bspline) GetDeriv ¶
GetDeriv returns the derivative dN[i]dt just computed by CalcBasisAndDerivs
func (*Bspline) NumBasis ¶
NumBasis returns the number (n) of basis functions == number of control points
func (*Bspline) PlotBasis ¶
PlotBasis plots basis functions in I option = 0 : use CalcBasis
1 : use CalcBasisAndDerivs 2 : use RecursiveBasis
func (*Bspline) PlotDerivs ¶
PlotDerivs plots derivatives of basis functions in I
func (*Bspline) Point ¶
Point returns the x-y-z coordinates of a point on B-spline option = 0 : use CalcBasis
1 : use RecursiveBasis
func (*Bspline) RecursiveBasis ¶
RecursiveBasis computes one particular basis function N[i] recursively (not efficient)
func (*Bspline) SetControl ¶
SetControl sets B-spline control points
type CurvGrid ¶
type CurvGrid struct { Ndim int // space dimension N0 int // number of points along 0-direction N1 int // number of points along 1-direction N2 int // number of points along 2-direction [default = 1] M2d [][]*Metrics // [n1][n0] metrics in 2D M3d [][][]*Metrics // [n2][n1][n0] metrics in 3D }
CurvGrid holds metrics data for 2d or 3d grids represented by curvilinear coordinates
func (*CurvGrid) SetTransfinite2d ¶
func (o *CurvGrid) SetTransfinite2d(trf *Transfinite, R, S []float64)
SetTransfinite2d sets grid from 2D transfinite mapping
trf -- 2D transfinite structure R -- [n1] reference coordinates along r-direction S -- [n2] reference coordinates along s-direction
type Entity ¶
type Entity interface { }
Entity defines the geometric (or not) entity/element to be stored in the Octree
type Grid ¶
type Grid struct {
// contains filtered or unexported fields
}
Grid implements a generic (uniform or nonuniform) grid of points in 2D or 3D
NOTE: use methods GenUniform, Set2d, or Set3d to generate coordinates
func (*Grid) Boundary ¶
Boundary returns list of edge or face nodes on boundary
NOTE: will return empty list if tag is not available
func (*Grid) Draw ¶
Draw draws grid
coordsGenerate -- tells whether the meshgrid coordinates are generated or not. if the size of the current arrays are the same, no new coordinates will be generated. Thus, make sure to call the "set" commands with the genMeshCoordinates flag equal to true if when updating the grid.
func (*Grid) Edge ¶
Edge returns the ids of points on edges: [edge0, edge1, edge2, edge3]
2 +-----------+ | | | | 3| |1 | | | | +-----------+ 0
func (*Grid) EdgeT ¶
EdgeT returns a list of nodes marked with given tag
21 +-----------+ | | | | 10| |11 | | | | +-----------+ 20 NOTE: will return empty list if tag is not available
func (*Grid) Face ¶
Face returns the ids of points on faces: [face0, face1, face2, face3, face4, face5]
+----------------+ ,'| ,'| ,' | ___ ,' | ,' |,'5,' [0] ,' | ,' |~~~ ,' , | +'===============+' ,'| | | ,'| | | |3| | | |2| | | |,' | | |,' +- - - | +- - - -+ | ' ,' | ,' | ,' [1] ___| ,' | ,' ,'4,'| ,' | ,' ~~~ | ,' +----------------+'
func (*Grid) FaceT ¶
FaceT returns a list of nodes marked with given tag
+----------------+ ,'| ,'| ,' | ___ ,' | ,' |,'31' 10 ,' | ,' |~~~ ,' ,, | +'===============+' ,' | | | ,'| | | |21| | | |20| | | |,' | | | ,' +- - - | +- - - -+ | ' ,' | ,' | ,' 11 ___| ,' | ,' ,'30'| ,' | ,' ~~~ | ,' +----------------+' NOTE: will return empty list if tag is not available
func (*Grid) GenUniform ¶
GenUniform generates uniform grid
min -- min x-y-z values, len==ndim: [xmin, ymin, zmin] max -- max x-y-z values, len==ndim: [xmax, ymax, zmax] ndiv -- number of divisions along each direction len==ndim: [ndivx, ndivy, ndivz] genMeshCoords -- generate "meshgrid" coordinates. Accessed with Mesh2d or Mesh3d
func (*Grid) Length ¶
Length returns the lengths along each direction (whole box)
dim -- direction in [0, ndim-1]
func (*Grid) Npts ¶
Npts returns the number of points along each direction
dim -- direction in [0, ndim-1]
func (*Grid) Set2d ¶
Set2d sets coordinates along each direction
genMeshCoords -- generate "meshgrid" coordinates. Accessed with Mesh2d or Mesh3d
type Metrics ¶
type Metrics struct { U la.Vector // reference coordinates {r,s,t} X la.Vector // physical coordinates {x,y,z} CovG0 la.Vector // covariant basis g_0 = d{x}/dr CovG1 la.Vector // covariant basis g_1 = d{x}/ds CovG2 la.Vector // covariant basis g_2 = d{x}/dt CovGmat *la.Matrix // covariant metrics g_ij = g_i ⋅ g_j CntGmat *la.Matrix // contravariant metrics g^ij = g^i ⋅ g^j DetCovGmat float64 // determinant of covariant g matrix = det(CovGmat) GammaS [][][]float64 // [k][i][j] Christoffel coefficients of second kind L []float64 // [3] L-coefficients = sum(Γ_ij^k ⋅ g^ij) }
Metrics holds data related to a position in a space represented by curvilinear coordinates
func NewMetrics2d ¶
NewMetrics2d allocate new 2D metrics structure
type Nurbs ¶
type Nurbs struct { Q [][][][]float64 // Qw: weighted control points and weights [n[0]][n[1]][n[2]][4] (Piegl p120) // contains filtered or unexported fields }
Nurbs holds NURBS data
NOTE: (1) Control points must be set after a call to Init (2) Either SetControl must be called or the Q array must be directly specified Reference: [1] Piegl L and Tiller W (1995) The NURBS book, Springer, 646p
func (*Nurbs) CalcBasis ¶
CalcBasis computes all non-zero basis functions R[i][j][k] @ u. Note: use GetBasisI or GetBasisL to get a particular basis function value
func (*Nurbs) CalcBasisAndDerivs ¶
CalcBasisAndDerivs computes all non-zero basis functions R[i][j][k] and corresponding first order derivatives of basis functions w.r.t u => dRdu[i][j][k] @ u Note: use GetBasisI or GetBasisL to get a particular basis function value
use GetDerivI or GetDerivL to get a particular derivative
func (*Nurbs) CloneCtrlsAlongCurve ¶
CloneCtrlsAlongCurve returns a copy of control points @ 2D boundary
func (*Nurbs) CloneCtrlsAlongSurface ¶
CloneCtrlsAlongSurface returns a copy of control points @ 3D boundary
func (*Nurbs) DrawCtrl ¶
DrawCtrl draws control net in 2D or 3D space
ndim -- 2 or 3 => to plot in a 2D or 3D space
func (*Nurbs) DrawEdge ¶
DrawEdge draws edge from tmin to tmax in 2D or 3D space
ndim -- 2 or 3 => to plot in a 2D or 3D space
func (*Nurbs) DrawElem ¶
DrawElem draws element (non-zero span) in 2D or 3D space
ndim -- 2 or 3 => to plot in a 2D or 3D space
func (*Nurbs) DrawElems ¶
DrawElems draws all elements (non-zero spans) in 2D or 3D space
ndim -- 2 or 3 => to plot in a 2D or 3D space
func (*Nurbs) DrawSurface ¶
func (o *Nurbs) DrawSurface(ndim int, nu, nv int, withSurf, withWire bool, argsSurf, argsWire *plt.A)
DrawSurface draws surface
ndim -- 2 or 3 => to plot in a 2D or 3D space
func (*Nurbs) DrawVectors3d ¶
DrawVectors3d draws tangent vectors of 3D surface
func (*Nurbs) ElemBryLocalInds ¶
ElemBryLocalInds returns the local (element) indices of control points @ boundaries (if element would have all surfaces @ boundaries)
func (*Nurbs) ExtractSurfaces ¶
ExtractSurfaces returns a new NURBS representing a boundary of this NURBS
func (*Nurbs) GetBasisI ¶
GetBasisI returns the basis function R[i][j][k] just computed by CalcBasis or CalcBasisAndDerivs Note: I = [i,j,k]
func (*Nurbs) GetBasisL ¶
GetBasisL returns the basis function R[i][j][k] just computed by CalcBasis or CalcBasisAndDerivs Note: l = i + j * n0 + k * n0 * n1
func (*Nurbs) GetDerivI ¶
GetDerivI returns the derivative of basis function dR[i][j][k]du just computed by CalcBasisAndDerivs Note: I = [i,j,k]
func (*Nurbs) GetDerivL ¶
GetDerivL returns the derivative of basis function dR[i][j][k]du just computed by CalcBasisAndDerivs Note: l = i + j * n0 + k * n0 * n1
func (*Nurbs) GetElemNumBasis ¶
GetElemNumBasis returns the number of control points == basis functions needed for one element
npts := Π_i (p[i] + 1)
func (*Nurbs) GetLimitsQ ¶
GetLimitsQ computes the limits of all coordinates of control points in NURBS
func (*Nurbs) IndBasis ¶
IndBasis returns the indices of basis functions == local indices of control points
func (*Nurbs) IndsAlongCurve ¶
IndsAlongCurve returns the control points indices along curve
func (*Nurbs) IndsAlongSurface ¶
IndsAlongSurface return the control points indices along surface
func (*Nurbs) KrefineN ¶
KrefineN return a new Nurbs with each span divided into ndiv parts = [2, 3, ...]
func (*Nurbs) NonZeroSpans ¶
NonZeroSpans returns the 'elements' along direction dir
func (*Nurbs) PlotBasis2d ¶
PlotBasis2d plots basis function (2D only) option = 0 : use CalcBasis
1 : use CalcBasisAndDerivs 2 : use RecursiveBasis
func (*Nurbs) PlotDeriv2d ¶
PlotDeriv2d plots derivative dR[i][j][k]du[d] (2D only)
func (*Nurbs) Point ¶
Point returns the x-y-z coordinates of a point on curve/surface/volume
Input: u -- [gnd] knot values ndim -- the dimension of the point. E.g. allows drawing curves in 3D Output: C -- [ndim] point coordinates NOTE: Algorithm A4.1 (p124) of [1]
func (*Nurbs) PointDeriv ¶
PointDeriv returns the derivatives of the x-y-z coordinates of a point on curve/surface/volume with respect to the knot values u @ u
Input: u -- [gnd] knot values ndim -- the dimension of the point. E.g. allows drawing curves in 3D Output: dCdu -- [ndim][gnd] derivatives dC_i/du_j C -- [ndim] point coordinates
func (*Nurbs) RecursiveBasis ¶
RecursiveBasis implements basis functions by means of summing all terms in Bernstein polynomial using recursive Cox-DeBoor formula (very not efficient) Note: l = i + j * n0 + k * n0 * n1
func (*Nurbs) SetControl ¶
SetControl sets control points from list of global vertices
type NurbsExchangeData ¶
type NurbsExchangeData struct { ID int `json:"i"` // id of Nurbs Gnd int `json:"g"` // 1: curve, 2:surface, 3:volume (geometry dimension) Ords []int `json:"o"` // order along each x-y-z direction [gnd] Knots [][]float64 `json:"k"` // knots along each x-y-z direction [gnd][m] Ctrls []int `json:"c"` // global ids of control points }
NurbsExchangeData holds all data required to exchange NURBS; e.g. read/save files
type NurbsExchangeDataSet ¶
type NurbsExchangeDataSet []*NurbsExchangeData
NurbsExchangeDataSet defines a set of nurbs exchange data
type NurbsPatch ¶
type NurbsPatch struct { // input/output data ControlPoints []*PointExchangeData `json:"points"` // input/output control points ExchangeData NurbsExchangeDataSet `json:"patch"` // input/output nurbs data // Nurbs structures Entities []*Nurbs `json:"-"` // pointers to NURBS // auxiliary Bins Bins `json:"-"` // auxiliary structure to locate points }
NurbsPatch defines a patch of many NURBS'
func NewNurbsPatch ¶
func NewNurbsPatch(binsNdiv int, tolerance float64, entities ...*Nurbs) (o *NurbsPatch)
NewNurbsPatch returns new patch of NURBS
tolerance -- tolerance to assume that two control points are the same
func NewNurbsPatchFromFile ¶
func NewNurbsPatchFromFile(filename string, binsNdiv int, tolerance float64) (o *NurbsPatch)
NewNurbsPatchFromFile allocates a NurbsPatch with data from file
func (NurbsPatch) LimitsAndNdim ¶
func (o NurbsPatch) LimitsAndNdim() (xmin, xmax []float64, ndim int)
LimitsAndNdim computes the limits of the patch and max dimension by looping over all Entities
func (*NurbsPatch) ResetFromEntities ¶
func (o *NurbsPatch) ResetFromEntities(binsNdiv int, tolerance float64)
ResetFromEntities will reset all exchange data with information from Entities slice
func (*NurbsPatch) ResetFromExchangeData ¶
func (o *NurbsPatch) ResetFromExchangeData(binsNdiv int, tolerance float64)
ResetFromExchangeData will reset all Entities with information from ExchangeData (and ControlPoints)
func (NurbsPatch) Write ¶
func (o NurbsPatch) Write(dirout, fnkey string)
Write writes ExchangeData to json file
type Octree ¶
type Octree struct { // constants DIM uint32 // dimension PMAX uint32 // roughly how many levels fit in 32 bits QO uint32 // 4 for quadtree, 8 for octree QL uint32 // offset constant to leftmost daughter // contains filtered or unexported fields }
Octree implements a Quad-Tree or an Oct-Tree to assist in fast-searching elements (entities) in the 2D or 3D space
type Point ¶
type Point struct {
X, Y, Z float64
}
Point holds the Cartesian coordinates of a point in 3D space
type PointExchangeData ¶
type PointExchangeData struct { ID int `json:"i"` // id Tag int `json:"t"` // tag X []float64 `json:"x"` // coordinates (size==4) }
PointExchangeData holds data for exchanging control points
type PointN ¶
type PointN struct { // esssential X []float64 // coordinates // optional ID int // some identification number }
PointN implements a point in N-dim space
func NewPointNdim ¶
NewPointNdim creates a new PointN with given dimension (ndim)
func (PointN) AlmostTheSameX ¶
AlmostTheSameX returns true if the X slices of two points have almost the same values, for given tolerance
func (PointN) ExactlyTheSameX ¶
ExactlyTheSameX returns true if the X slices of two points have exactly the same values
type Segment ¶
type Segment struct {
A, B *Point
}
Segment represents a directed segment from A to B
func NewSegment ¶
NewSegment creates a new segment from a to b
type Transfinite ¶
type Transfinite struct {
// contains filtered or unexported fields
}
Transfinite maps a reference square [-1,+1]×[-1,+1] into a curve-bounded quadrilateral
B[3](r(x,y)) _,'\ B[3](r) _,' \ B[1](s(x,y)) ┌───────┐ _,' \ │ │ \ \ B[0](s)│ │B[1](s) ⇒ \ _,' s │ │ B[0](s(x,y)) \ _,' │ └───────┘ y \ _,' B[2](r(x,y)) └──r B[2](r) │ ' └──x +----------------+ ,'| ,'| t or z ,' | ___ ,' | B[0](s,t) ↑ ,' |,'5,' [0],' | B[1](s,t) | ,' |~~~ ,' | B[2](r,t) | +'===============+' ,'| | B[3](r,t) | | ,'| | | |3| | B[4](r,s) | s or y | |2| | | |,' | B[5](r,s) +--------> | |,' +- - - | +- - - -+ ,' | ,' | ,' ,' | ,' [1] ___| ,' r or x | ,' ,'4,'| ,' | ,' ~~~ | ,' +----------------+'
func NewTransfinite2d ¶
func NewTransfinite2d(B, Bd, Bdd []fun.Vs) (o *Transfinite)
NewTransfinite2d allocates a new structure
Input: B -- [4] boundary functions Bd -- [4] 1st derivative of boundary functions Bdd -- [4 or nil] 2nd derivative of boundary functions [may be nil]
func NewTransfinite3d ¶
NewTransfinite3d allocates a new structure
Input: B -- [6] boundary functions Bd -- [6] 1st derivative of boundary functions Bdd -- [6 or nil] 2nd derivative of boundary functions [may be nil]
func (*Transfinite) Draw ¶
func (o *Transfinite) Draw(npts []int, onlyBry bool, args, argsBry *plt.A)
Draw draws figure formed by B
func (*Transfinite) Point ¶
func (o *Transfinite) Point(x, u la.Vector)
Point computes "real" position x(r,s,t)
Input: u -- the "reference" coordinates {r,s,t} ϵ [-1,+1]×[-1,+1]×[-1,+1] Output: x -- the "real" coordinates {x,y,z}
func (*Transfinite) PointAndDerivs ¶
func (o *Transfinite) PointAndDerivs(x, dxDr, dxDs, dxDt, ddxDrr, ddxDss, ddxDtt, ddxDrs, ddxDrt, ddxDst, u la.Vector)
PointAndDerivs computes position and the first and second order derivatives
Input: u -- reference coordinates {r,s,t} Output: x -- position {x,y,z} dxDr -- ∂{x}/∂r dxDs -- ∂{x}/∂s dxDt -- ∂{x}/∂t ddxDrr -- ∂²{x}/∂r² [may be nil] ddxDss -- ∂²{x}/∂s² [may be nil] ddxDtt -- ∂²{x}/∂t² [may be nil] ddxDrs -- ∂²{x}/∂r∂s [may be nil] ddxDrt -- ∂²{x}/∂r∂t [may be nil] ddxDst -- ∂²{x}/∂s∂t [may be nil]
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package msh defines mesh data structures and implements interpolation functions for finite element analyses (FEA)
|
Package msh defines mesh data structures and implements interpolation functions for finite element analyses (FEA) |
Package rw implements reader and writers for geometry files such as the STEP file format
|
Package rw implements reader and writers for geometry files such as the STEP file format |
Package tri wraps Triangle to perform mesh generation a Delaunay triangulation
|
Package tri wraps Triangle to perform mesh generation a Delaunay triangulation |