pde

package
v1.1.2-0...-291262d Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2019 License: BSD-3-Clause Imports: 9 Imported by: 0

README

Gosl. pde. Partial Differential Equations

GoDoc

More information is available in the documentation of this package.

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
  4. Add more tests

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.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BoundaryConds

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

BoundaryConds holds data for prescribing a SET of boundary conditions

func NewBoundaryCondsGrid

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

NewBoundaryCondsGrid returns a new structure using Grid

func NewBoundaryCondsMesh

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

NewBoundaryCondsMesh returns a new structure using Mesh

func (*BoundaryConds) AddUsingTag

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

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

Has tells whether node has prescribed boundary condition or not

func (*BoundaryConds) Nodes

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

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

func (*BoundaryConds) NormalGrid

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

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

Print prints boundary conditions

func (*BoundaryConds) Tags

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

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

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

NewFdmLaplacian creates a new FDM Laplacian operator with given parameters

func (*FdmLaplacian) AddEbc

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

AddEbc adds essential boundary condition given tag of edge or face

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

func (o *FdmLaplacian) SetHbc()

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

func (*FdmLaplacian) SolveSteady

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

SolveSteady solves steady problem

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

func NewSpcLaplacian(params dbf.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 (*SpcLaplacian) AddEbc

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

AddEbc adds essential boundary condition given tag of edge or face

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

func (*SpcLaplacian) AddNbc

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

AddNbc adds natural boundary condition given tag of edge or face

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

func (o *SpcLaplacian) SetHbc()

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

func (*SpcLaplacian) SolveSteady

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

SolveSteady solves steady problem

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

Jump to

Keyboard shortcuts

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