DG2D

package
v0.0.0-...-88f8085 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 14, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Epsilon   = "Epsilon"
	Hesthaven = "Hesthaven"
)

Variables

This section is empty.

Functions

func CalculateElementLocalGeometry

func CalculateElementLocalGeometry(EToV utils.Matrix, VX, VY, R, S utils.Vector) (X, Y utils.Matrix)

func Connect2D

func Connect2D(K, NFaces, Nv int, EToV utils.Matrix) (EToE, EToF utils.Matrix)

func ExtendGeomToRT

func ExtendGeomToRT(N int, rInt, sInt utils.Vector) (r, s utils.Vector)

func GetEdgeCoordinates

func GetEdgeCoordinates(en types.EdgeKey, rev bool, VX, VY utils.Vector) (x1, x2 [2]float64)

func Nodes2D

func Nodes2D(N int) (x, y utils.Vector)

Purpose : Compute (x,y) nodes in equilateral triangle for

polynomial of order N

func NodesEpsilon

func NodesEpsilon(N int) (R, S utils.Vector)

func RStoAB

func RStoAB(R, S utils.Vector) (a, b utils.Vector)

func Warpfactor

func Warpfactor(N int, rout utils.Vector) (warpF []float64)

func XYtoRS

func XYtoRS(x, y utils.Vector) (r, s utils.Vector)

function [r,s] = xytors(x,y) Purpose : Transfer from (x,y) in equilateral triangle

to (r,s) coordinates in standard triangle

Types

type Basis2D

type Basis2D interface {
	PolynomialTerm(r, s float64, i, j int) (p float64)
	PolynomialTermDr(r, s float64, i, j int) (dr float64)
	PolynomialTermDs(r, s float64, i, j int) (ds float64)
	GetInterpMatrix(R, S utils.Vector) (Interp utils.Matrix)
}

type Cubature

type Cubature struct {
	W                       utils.Matrix
	V, Dr, Ds, VT, DrT, DsT utils.Matrix
	J                       utils.Matrix
	// contains filtered or unexported fields
}

type DFR2D

type DFR2D struct {
	N               int
	SolutionElement *LagrangeElement2D
	//FluxElement     *RTElement
	FluxElement        *RTBasis2DSimplex
	FluxInterp         utils.Matrix // Interpolates from the interior (solution) points to all of the flux points
	FluxEdgeInterp     utils.Matrix // Interpolates only from interior to the edge points in the flux element
	FluxDr, FluxDs     utils.Matrix // Derivatives from the interior (solution) points to all of the flux points
	DXMetric, DYMetric utils.Matrix // X and Y derivative metrics, multiply by scalar field values to create DOF for RT
	// Mesh Parameters
	K                    int          // Number of elements (triangles) in mesh
	VX, VY               utils.Vector // X,Y vertex points in mesh (vertices)
	BCEdges              types.BCMAP
	FluxX, FluxY         utils.Matrix    // Flux Element local coordinates
	SolutionX, SolutionY utils.Matrix    // Solution Element local coordinates
	Tris                 *Triangulation  // Triangle mesh and edge/face structures
	J, Jinv, Jdet        utils.Matrix    // Mesh Transform Jacobian, Kx[4], each K element has a 2x2 matrix, det is |J|
	FaceNorm             [2]utils.Matrix // Face normal (normalized), Kx3
	IInII                utils.Matrix    // Mag face normal divided by unit triangle face norm mag, Kx3 dimension
	EdgeNumber           []types.EdgeKey // Edge number for each edge, used to index into edge structures, Kx3 dimension
	SolutionBasis        Basis2D
}

func NewDFR2D

func NewDFR2D(N int, plotMesh bool, verbose bool, meshFileO ...string) (dfr *DFR2D)

func (*DFR2D) CalculateFaceNorms

func (dfr *DFR2D) CalculateFaceNorms()

func (*DFR2D) CalculateJacobian

func (dfr *DFR2D) CalculateJacobian()

func (*DFR2D) CalculateRTBasedDerivativeMetrics

func (dfr *DFR2D) CalculateRTBasedDerivativeMetrics()

func (*DFR2D) ConvertScalarToOutputMesh

func (dfr *DFR2D) ConvertScalarToOutputMesh(f utils.Matrix) (fI []float32)

func (*DFR2D) GetJacobian

func (dfr *DFR2D) GetJacobian(k int) (J, Jinv []float64, Jdet float64)

func (*DFR2D) OutputMesh

func (dfr *DFR2D) OutputMesh() (gm *graphics2D.TriMesh)

func (*DFR2D) ProjectFluxOntoRTSpace

func (dfr *DFR2D) ProjectFluxOntoRTSpace(Fx, Fy utils.Matrix) (Fp utils.Matrix)

type DerivativeDirection

type DerivativeDirection uint8
const (
	None DerivativeDirection = iota
	Dr
	Ds
)

type Direction

type Direction uint8
const (
	RDir Direction = iota
	SDir
)

type Edge

type Edge struct {
	// Total Storage: 32 bytes (14 bytes, 64-bit aligned to 16, plus 2x8 bytes for ||n||)
	NumConnectedTris       uint8                    // Either 1 or 2
	ConnectedTris          [2]uint32                // Index numbers of triangles connected to this edge
	ConnectedTriDirection  [2]InternalEdgeDirection // If false(default), the edge runs from smaller to larger within the connected tri
	ConnectedTriEdgeNumber [2]InternalEdgeNumber    // For the connected triangles, what is the edge number (one of 0, 1 or 2)
	BCType                 types.BCFLAG             // If not connected to two tris, this field will be used
	IInII                  [2]float64               // ||n|| scale factor to pre-multiply normal values prior to transforming into unit tri
}

Note that we do not use a slice for any of the fields inside of an edge - why?

  • each slice ([]type) has an overhead of pointer plus length and capacity ints, total of 24 bytes for an empty slice
  • adding to a slice using append() is expensive -> by using fixed allocations with the max of 2 ([2]type), we use less memory (total of 14 bytes) and compute

func (*Edge) AddTri

func (e *Edge) AddTri(en types.EdgeKey, k, conn int, intEdgeNumber InternalEdgeNumber, direction InternalEdgeDirection, VX, VY utils.Vector)

func (*Edge) GetEdgeLength

func (e *Edge) GetEdgeLength() (len float64)

func (*Edge) GetEdgeNormal

func (e *Edge) GetEdgeNormal(conn int, en types.EdgeKey, dfr *DFR2D) (normal [2]float64)

func (*Edge) Print

func (e *Edge) Print() (p string)

type InternalEdgeDirection

type InternalEdgeDirection bool
const (
	SmallestToLargest InternalEdgeDirection = false // Edge runs smallest vertex index to largest within triangle
	Reversed          InternalEdgeDirection = true
)

type InternalEdgeNumber

type InternalEdgeNumber uint8
const (
	First InternalEdgeNumber = iota
	Second
	Third
)

func (InternalEdgeNumber) Index

func (ien InternalEdgeNumber) Index() int

func (InternalEdgeNumber) String

func (ien InternalEdgeNumber) String() string

type JacobiBasis2D

type JacobiBasis2D struct {
	P               int // Order
	Np              int // Dimension
	V, Vinv, Vr, Vs utils.Matrix
}

func NewJacobiBasis2D

func NewJacobiBasis2D(P int, R, S utils.Vector) (jb2d *JacobiBasis2D)

func (*JacobiBasis2D) GetInterpMatrix

func (jb2d *JacobiBasis2D) GetInterpMatrix(R, S utils.Vector) (Interp utils.Matrix)

func (*JacobiBasis2D) GradSimplex2DP

func (jb2d *JacobiBasis2D) GradSimplex2DP(R, S utils.Vector, id, jd int) (ddr, dds []float64)

func (*JacobiBasis2D) GradVandermonde2D

func (jb2d *JacobiBasis2D) GradVandermonde2D(N int, R, S utils.Vector) (V2Dr, V2Ds utils.Matrix)

func (*JacobiBasis2D) PolynomialTerm

func (jb2d *JacobiBasis2D) PolynomialTerm(r, s float64, i, j int) (P float64)

func (*JacobiBasis2D) PolynomialTermDr

func (jb2d *JacobiBasis2D) PolynomialTermDr(r, s float64, i, j int) (dr float64)

func (*JacobiBasis2D) PolynomialTermDs

func (jb2d *JacobiBasis2D) PolynomialTermDs(r, s float64, i, j int) (ds float64)

func (*JacobiBasis2D) Simplex2DP

func (jb2d *JacobiBasis2D) Simplex2DP(R, S utils.Vector, i, j int) (P []float64)

func (*JacobiBasis2D) Vandermonde2D

func (jb2d *JacobiBasis2D) Vandermonde2D(N int, R, S utils.Vector) (V2D utils.Matrix)

type LagrangeBasis1D

type LagrangeBasis1D struct {
	P       int       // Order
	Np      int       // Dimension of basis = N+1
	Weights []float64 // Barycentric weights, one per basis polynomial
	Nodes   []float64 // Nodes at which basis is defined
}

func NewLagrangeBasis1D

func NewLagrangeBasis1D(R []float64) (lb *LagrangeBasis1D)

func (*LagrangeBasis1D) BasisPolynomial

func (lb *LagrangeBasis1D) BasisPolynomial(R []float64, j int) (f []float64)

func (*LagrangeBasis1D) GetInterpolationMatrix

func (lb *LagrangeBasis1D) GetInterpolationMatrix(R []float64) (im utils.Matrix)

func (*LagrangeBasis1D) Interpolate

func (lb *LagrangeBasis1D) Interpolate(R []float64, F []float64) (f []float64)

type LagrangeBasis2D

type LagrangeBasis2D struct {
	P, Np          int       // Order
	RNodes, SNodes []float64 // Nodes at which basis is defined
	JB2D           *JacobiBasis2D
}

func NewLagrangeBasis2D

func NewLagrangeBasis2D(P int, R, S utils.Vector) (lb2d *LagrangeBasis2D)

func (*LagrangeBasis2D) BasisPolynomial

func (lb2d *LagrangeBasis2D) BasisPolynomial(R, S utils.Vector, i, j int) (P []float64)

func (*LagrangeBasis2D) GetGradInterpMatrices

func (lb2d *LagrangeBasis2D) GetGradInterpMatrices(R, S utils.Vector) (InterpDR, InterpDS utils.Matrix)

func (*LagrangeBasis2D) GetInterpMatrix

func (lb2d *LagrangeBasis2D) GetInterpMatrix(R, S utils.Vector) (Interp utils.Matrix)

func (*LagrangeBasis2D) GradBasisPolynomial

func (lb2d *LagrangeBasis2D) GradBasisPolynomial(R, S utils.Vector, i, j int) (DrTerms, DsTerms []float64)

func (*LagrangeBasis2D) PolynomialTerm

func (lb2d *LagrangeBasis2D) PolynomialTerm(r, s float64, i, j int) (p float64)

func (*LagrangeBasis2D) PolynomialTermDr

func (lb2d *LagrangeBasis2D) PolynomialTermDr(r, s float64, i, j int) (dr float64)

func (*LagrangeBasis2D) PolynomialTermDs

func (lb2d *LagrangeBasis2D) PolynomialTermDs(r, s float64, i, j int) (ds float64)

type LagrangeElement2D

type LagrangeElement2D struct {
	N, Nfp, Np, NFaces int
	R, S               utils.Vector
	Dr, Ds             utils.Matrix
	MassMatrix         utils.Matrix
	Cub                *Cubature
	JB2D               *JacobiBasis2D
}

func NewLagrangeElement2D

func NewLagrangeElement2D(N int, nodeType NodeType) (el *LagrangeElement2D)

func (*LagrangeElement2D) GetDerivativeMatrices

func (el *LagrangeElement2D) GetDerivativeMatrices(R, S utils.Vector) (Dr, Ds utils.Matrix)

func (*LagrangeElement2D) NewCube2D

func (el *LagrangeElement2D) NewCube2D(COrder int)

type MeshFileType

type MeshFileType uint8
const (
	GAMBIT_FILE MeshFileType = iota
	SU2_FILE
)

type NDG2D

type NDG2D struct {
	Element            *LagrangeElement2D
	K                  int
	NODETOL            float64
	VX, VY, VZ         utils.Vector
	FMask, Fx, Fy      utils.Matrix
	EToV, EToE, EToF   utils.Matrix
	BCType             utils.Matrix
	BCEdges            types.BCMAP
	X, Y, FScale, LIFT utils.Matrix
	Rx, Ry, Sx, Sy     utils.Matrix

	NX, NY                            utils.Matrix
	J                                 utils.Matrix
	VmapM, VmapP, VmapB, VmapI, VmapO utils.Index
	MapB, MapI, MapO                  utils.Index
	FMaskI                            utils.Index
	// contains filtered or unexported fields
}

func NewNDG2D

func NewNDG2D(N int, meshFile string) (ndg *NDG2D)

func (*NDG2D) BuildMaps2D

func (ndg *NDG2D) BuildMaps2D()

func (*NDG2D) GeometricFactors2D

func (ndg *NDG2D) GeometricFactors2D()

func (*NDG2D) GetFaces

func (ndg *NDG2D) GetFaces() (aI utils.Index, NFacePts, K int)

func (*NDG2D) Lift2D

func (ndg *NDG2D) Lift2D()

func (*NDG2D) NewCube2D

func (ndg *NDG2D) NewCube2D(COrder int)

func (*NDG2D) Normals2D

func (ndg *NDG2D) Normals2D()

func (*NDG2D) Startup2D

func (ndg *NDG2D) Startup2D()

type NodeType

type NodeType string

type RTBasis2DSimplex

type RTBasis2DSimplex struct {
	P             int          // Polynomial Order
	Np            int          // Number of terms and nodes in basis
	NpInt, NpEdge int          // Number of nodes in interior and on each edge, Np = 2*NpInt + 3*NpEdge
	R, S          utils.Vector // Node locations within [-1,1] reference triangle
	Scalar2DBasis Basis2D      // Basis used for part of the RT basis construction
	V             [2]utils.Matrix
	Div, DivInt   utils.Matrix
}

func NewRTBasis2DSimplex

func NewRTBasis2DSimplex(P int, useLagrangeBasis bool) (rtb *RTBasis2DSimplex)

This is a second Raviart-Thomas element basis implementation within this project.

This implementation is based on the paper "Computational Bases for RTk and BDMk on Triangles" by V. J. Ervin

In this approach, edges are specifically addressed with 1D Lagrange polynomials multiplied by edge specific basis functions, while the interior points are composed of a supplied 2D scalar polynomial multiplied by a barycentric basis for the triangle.

func (*RTBasis2DSimplex) CalculateBasis

func (rtb *RTBasis2DSimplex) CalculateBasis()

func (*RTBasis2DSimplex) EvaluateBasisAtLocation

func (rtb *RTBasis2DSimplex) EvaluateBasisAtLocation(r, s float64, derivO ...DerivativeDirection) (p0, p1 []float64)

func (*RTBasis2DSimplex) ExtendGeomToRT

func (rtb *RTBasis2DSimplex) ExtendGeomToRT(Rint, Sint utils.Vector) (R, S utils.Vector)

func (*RTBasis2DSimplex) GetEdgeLocations

func (rtb *RTBasis2DSimplex) GetEdgeLocations(F []float64) (Fedge []float64)

func (*RTBasis2DSimplex) GetInternalLocations

func (rtb *RTBasis2DSimplex) GetInternalLocations(F []float64) (Finternal []float64)

func (*RTBasis2DSimplex) Lagrange1DPoly

func (rtb *RTBasis2DSimplex) Lagrange1DPoly(r float64, R []float64, j int,
	dir Direction, derivO ...DerivativeDirection) (p float64)

func (*RTBasis2DSimplex) LinearPoly

func (rtb *RTBasis2DSimplex) LinearPoly(r, s float64, j int, derivO ...DerivativeDirection) (p float64)

type RTElement

type RTElement struct {
	N             int             // Order of element
	Np            int             // Number of points in element
	NpEdge, NpInt int             // Number of Edge and Interior points
	A             utils.Matrix    // Polynomial coefficient matrix, NpxNp
	V             [2]utils.Matrix // Vandermonde matrix for each direction r and s, [2]xNpxNp
	Div, DivInt   utils.Matrix    // Divergence matrix, NpxNp for all, NintxNp Interior Points
	R, S          utils.Vector    // Point locations defining element in [-1,1] Triangle, NpxNp
	RTPolyBasis   Basis2D
}

func NewRTElement

func NewRTElement(R, S utils.Vector, NFlux int, useLagrangeBasis bool) (rt *RTElement)

func (*RTElement) CalculateBasis

func (rt *RTElement) CalculateBasis()

func (*RTElement) EvaluateRTBasis

func (rt *RTElement) EvaluateRTBasis(b1 Basis2D, r, s float64, derivO ...DerivativeDirection) (p0, p1 []float64)

func (*RTElement) GetEdgeLocations

func (rt *RTElement) GetEdgeLocations(F []float64) (Fedge []float64)

func (*RTElement) GetInternalLocations

func (rt *RTElement) GetInternalLocations(F []float64) (Finternal []float64)

func (*RTElement) ProjectFunctionOntoBasis

func (rt *RTElement) ProjectFunctionOntoBasis(s1, s2 []float64) (sp []float64)

type RTPointType

type RTPointType uint8
const (
	All       RTPointType = iota
	InteriorR             // R component of vector field
	InteriorS             // S component of vector field
	Edge1                 // Edge from vertex 0-1, Normal is [0,-1]
	Edge2                 // Edge from vertex 1-2, Normal is [1./sqrt(2),1./sqrt(2)]
	Edge3                 // Edge from vertex 2-0, Normal is [-1,0]
)

type TermType

type TermType uint8

type Triangulation

type Triangulation struct {
	EToV  utils.Matrix            // K x 3 matrix mapping vertices to triangles
	Edges map[types.EdgeKey]*Edge // map of edges, key is the edge number, an int packed with the two vertices of each edge
	EtoE  [][3]int                // For each element in [k], the connected element for each of the three edges [0,1,2]
}

func NewTriangulation

func NewTriangulation(VX, VY utils.Vector, EToV utils.Matrix, BCEdges types.BCMAP) (tmesh *Triangulation)

func (*Triangulation) GetTriVerts

func (tmesh *Triangulation) GetTriVerts(k uint32) (verts [3]int)

func (*Triangulation) NewEdge

func (tmesh *Triangulation) NewEdge(VX, VY utils.Vector, verts [2]int, connectedElementNumber int, intEdgeNumber InternalEdgeNumber) (e *Edge)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL