Package by.andd3dfx.math.pde.solver
Class AbstractEquationSolver<E extends Equation>
java.lang.Object
by.andd3dfx.math.pde.solver.AbstractEquationSolver<E>
- Type Parameters:
E
- the type of equation this solver handles
- All Implemented Interfaces:
EquationSolver<E>
- Direct Known Subclasses:
HyperbolicEquationSolver
,ParabolicEquationSolver
public abstract class AbstractEquationSolver<E extends Equation>
extends Object
implements EquationSolver<E>
Abstract base class for partial differential equation solvers.
Provides common functionality and utility methods used by specific equation solvers.
Implements the core numerical methods and algorithms shared across different types of PDE solvers.
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final record
Record class to store boundary condition parameters for the tridiagonal algorithm. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected Area
Builds a space-time computational domain for the equation solution.protected AbstractEquationSolver.KappaNu
calcKappaNu
(BorderCondition borderCondition, double h, double time) Calculates Kappa and Nu parameters for the tridiagonal algorithm based on boundary conditions.protected Matrix2D
Initializes the solution matrix with initial conditions.static double[]
solve3DiagonalEquationsSystem
(double[] A, double[] B, double[] C, double[] F, AbstractEquationSolver.KappaNu leftCond, AbstractEquationSolver.KappaNu rightCond) Solves a tridiagonal system of linear algebraic equations using the Thomas algorithm.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface by.andd3dfx.math.pde.solver.EquationSolver
solve
-
Constructor Details
-
AbstractEquationSolver
public AbstractEquationSolver()
-
-
Method Details
-
buildArea
Builds a space-time computational domain for the equation solution. Creates a grid with specified spatial and temporal step sizes.- Parameters:
eqn
- the equation to solveh
- spatial step size (must be positive)tau
- temporal step size (must be positive)- Returns:
- the computational domain with defined grid points
- Throws:
IllegalArgumentException
- if parameters h or tau are non-positive
-
prepare
Initializes the solution matrix with initial conditions. Creates a matrix to store the solution and sets the initial values based on the equation's initial condition.- Parameters:
eqn
- the equation to solvearea
- the computational domain where solution will be found- Returns:
- initialized matrix with initial conditions
-
solve3DiagonalEquationsSystem
public static double[] solve3DiagonalEquationsSystem(double[] A, double[] B, double[] C, double[] F, AbstractEquationSolver.KappaNu leftCond, AbstractEquationSolver.KappaNu rightCond) Solves a tridiagonal system of linear algebraic equations using the Thomas algorithm. The system has the form: A[i]*y[i-1] - C[i]*y[i] + B[i]*y[i+1] = -F[i], 0<i<NThe algorithm consists of two phases:
- Forward phase: computes coefficients Alpha[i] and Beta[i]
- Backward phase: computes the solution Y[i]
Variable notations follow "Tikhonov, Samarskii - Equations of Mathematical Physics", p.590-592
- Parameters:
A
- coefficients for y[i-1] termsB
- coefficients for y[i+1] termsC
- coefficients for y[i] termsF
- right-hand side termsleftCond
- left boundary condition parametersrightCond
- right boundary condition parameters- Returns:
- solution vector Y[i]
- Throws:
IllegalArgumentException
- if arrays have different lengths or invalid coefficients
-
calcKappaNu
protected AbstractEquationSolver.KappaNu calcKappaNu(BorderCondition borderCondition, double h, double time) Calculates Kappa and Nu parameters for the tridiagonal algorithm based on boundary conditions. These parameters are used to incorporate different types of boundary conditions into the solution.- Parameters:
borderCondition
- the boundary condition to processh
- spatial step sizetime
- current time point- Returns:
- KappaNu record containing calculated parameters
- Throws:
IllegalStateException
- if an unsupported boundary condition type is encountered
-