# pde

package
v1.2.9 Latest Latest

Go to latest
Published: Jun 20, 2021 License: BSD-3-Clause

### Gosl. pde. Partial Differential Equations

Package `pde` implements structures and algorithms for solving partial differential equations.

#### TODO

1. Explain how to use the FDM (Finite Difference Method) solver
2. Explain how to use the SPC (Spectral Collocation) solver
3. Implement the FEM (Finite Element Method) solver

## Documentation ¶

### Overview ¶

Package pde implements numerical methods for the solution of Partial Differential Equations. For example, this package includes the Finite Difference and the Spectral Collocation methods.

### Constants ¶

This section is empty.

### Variables ¶

This section is empty.

### Functions ¶

This section is empty.

### Types ¶

#### type BoundaryConds ¶ added in v1.1.0

```type BoundaryConds struct {
// contains filtered or unexported fields
}```

BoundaryConds holds data for prescribing a SET of boundary conditions

#### func NewBoundaryCondsGrid ¶ added in v1.1.0

`func NewBoundaryCondsGrid(grid *gm.Grid, ndof int) (o *BoundaryConds)`

NewBoundaryCondsGrid returns a new structure using Grid

#### func NewBoundaryCondsMesh ¶ added in v1.1.0

`func NewBoundaryCondsMesh(mesh *msh.Mesh, ndof int) (o *BoundaryConds)`

NewBoundaryCondsMesh returns a new structure using Mesh

`func (o *BoundaryConds) AddUsingTag(tag, dof int, cvalue float64, fvalue fun.Svs)`

AddUsingTag sets boundary condition using edge or face tag from grid or mesh

```tag    -- edge or face tag
dof    -- index of "degree-of-freedom"; e.g. 0⇒horizontal displacement, 1⇒vertical displacement
cvalue -- constant value [optional]; or
fvalue -- function value [optional]
```

#### func (*BoundaryConds) Has ¶ added in v1.1.0

`func (o *BoundaryConds) Has(node int) bool`

Has tells whether node has prescribed boundary condition or not

#### func (*BoundaryConds) Nodes ¶ added in v1.1.0

`func (o *BoundaryConds) Nodes() (list []int)`

Nodes returns (unique/sorted) list of nodes with prescribed boundary conditions

#### func (*BoundaryConds) NormalGrid ¶ added in v1.1.0

`func (o *BoundaryConds) NormalGrid(N la.Vector, node int)`

NormalGrid computes the outward normal at node (summed at corners) [when using Grid only] NOTE: returns zero normal if node doesn't have prescribed condition

#### func (*BoundaryConds) Print ¶ added in v1.1.0

`func (o *BoundaryConds) Print() (l string)`

Print prints boundary conditions

#### func (*BoundaryConds) Tags ¶ added in v1.1.0

`func (o *BoundaryConds) Tags(node int) []int`

Tags returns tags used to prescribe boundary condition at node NOTE: returns empty list of node does not have boundary condition

#### func (*BoundaryConds) Value ¶ added in v1.1.0

`func (o *BoundaryConds) Value(node, dof int, t float64) (tags []int, val float64, available bool)`

Value returns the value of prescribed boundary condition @ {node,dof,time}

#### type FdmLaplacian ¶

```type FdmLaplacian struct {
Kx       float64        // isotropic coefficient x
Ky       float64        // isotropic coefficient y
Kz       float64        // isotropic coefficient z
Grid     *gm.Grid       // grid
Source   fun.Svs        // source term function s({x},t)
EssenBcs *BoundaryConds // essential boundary conditions
Eqs      *la.Equations  // equations
// contains filtered or unexported fields
}```

FdmLaplacian implements the Finite Difference (FDM) Laplacian operator (2D or 3D)

```          ∂²u        ∂²u        ∂²u
L{u} = kx ———  +  ky ———  +  kz ———
∂x²        ∂y²        ∂z²
```

#### func NewFdmLaplacian ¶ added in v1.1.0

`func NewFdmLaplacian(params utl.Params, grid *gm.Grid, source fun.Svs) (o *FdmLaplacian)`

NewFdmLaplacian creates a new FDM Laplacian operator with given parameters

`func (o *FdmLaplacian) AddEbc(tag int, cvalue float64, fvalue fun.Svs)`

```tag    -- edge or face tag in grid
cvalue -- constant value [optional]; or
fvalue -- function value [optional]
```

#### func (*FdmLaplacian) Assemble ¶

`func (o *FdmLaplacian) Assemble(reactions bool)`

Assemble assembles operator into A matrix from [A] ⋅ {u} = {b}

```reactions -- prepare for computation of RHS
```

#### func (*FdmLaplacian) SetHbc ¶ added in v1.1.0

`func (o *FdmLaplacian) SetHbc()`

SetHbc sets homogeneous boundary conditions; i.e. all boundaries with zero EBC

`func (o *FdmLaplacian) SolveSteady(reactions bool) (u, f []float64)`

```Solves: [K]⋅{u} = {f} represented by [A]⋅{x} = {b}
```

#### type SpcLaplacian ¶

```type SpcLaplacian struct {
LagInt   fun.LagIntSet  // Lagrange interpolators [ndim]
Grid     *gm.Grid       // grid
Source   fun.Svs        // source term function s({x},t)
EssenBcs *BoundaryConds // essential boundary conditions
NaturBcs *BoundaryConds // natural boundary conditions
Eqs      *la.Equations  // equations
// contains filtered or unexported fields
}```

SpcLaplacian implements the Spectral Collocation (SPC) Laplacian operator (2D or 3D)

```             ∂²φ        ∂²φ        ∂²φ         ∂φ      ∂φ
L{φ} = ∇²φ = ——— g¹¹ +  ——— g²² +  ———— 2g¹² - —— L¹ - —— L²
∂a²        ∂b²        ∂a∂b        ∂a      ∂b

with a=u[0]=r and b=u[1]=s
```

#### func NewSpcLaplacian ¶ added in v1.1.0

`func NewSpcLaplacian(params utl.Params, lis fun.LagIntSet, grid *gm.Grid, source fun.Svs) (o *SpcLaplacian)`

NewSpcLaplacian creates a new SPC Laplacian operator with given parameters

```NOTE: params is not used at the moment
```

`func (o *SpcLaplacian) AddEbc(tag int, cvalue float64, fvalue fun.Svs)`

```tag    -- edge or face tag in grid
cvalue -- constant value [optional]; or
fvalue -- function value [optional]
```

`func (o *SpcLaplacian) AddNbc(tag int, cvalue float64, fvalue fun.Svs)`

```tag    -- edge or face tag in grid
cvalue -- constant value [optional]; or
fvalue -- function value [optional]
```

#### func (*SpcLaplacian) Assemble ¶

`func (o *SpcLaplacian) Assemble(reactions bool)`

Assemble assembles operator into A matrix from [A] ⋅ {u} = {b}

```reactions -- prepare for computation of RHS
```

#### func (*SpcLaplacian) SetHbc ¶ added in v1.1.0

`func (o *SpcLaplacian) SetHbc()`

SetHbc sets homogeneous boundary conditions; i.e. all boundaries with zero EBC

`func (o *SpcLaplacian) SolveSteady(reactions bool) (u, f []float64)`

```Solves: [K]⋅{u} = {f} represented by [A]⋅{x} = {b}