diff --git a/src/main/java/by/andd3dfx/math/Area.java b/src/main/java/by/andd3dfx/math/Area.java index df73753..08beb49 100644 --- a/src/main/java/by/andd3dfx/math/Area.java +++ b/src/main/java/by/andd3dfx/math/Area.java @@ -1,19 +1,37 @@ package by.andd3dfx.math; +/** + * Space-time area + * + * @param x space interval + * @param t time interval + */ public record Area(Interval x, Interval t) { + /** + * Left border of time interval + */ public double tLeft() { return t().left(); } + /** + * Right border of time interval + */ public double tRight() { return t().right(); } + /** + * Left border of space interval + */ public double xLeft() { return x().left(); } + /** + * Right border of space interval + */ public double xRight() { return x().right(); } diff --git a/src/main/java/by/andd3dfx/math/pde/equation/Equation.java b/src/main/java/by/andd3dfx/math/pde/equation/Equation.java index a70fd3e..473f823 100644 --- a/src/main/java/by/andd3dfx/math/pde/equation/Equation.java +++ b/src/main/java/by/andd3dfx/math/pde/equation/Equation.java @@ -34,10 +34,10 @@ public Equation(double x1, double x2, double t2, } /** - * Initial condition U(x,0) at moment t=0 + * Initial condition U(x) at moment t=0 * * @param x coordinate - * @return U value in asked coordinate + * @return U(x) value */ protected double gU0(double x) { return 0; @@ -79,6 +79,12 @@ protected double gF(double x, double t, double U) { */ public abstract void solve(double h, double tau); + /** + * Initialization of equation: create space for solution, set initial value + * + * @param h space step + * @param tau time step + */ protected void prepare(double h, double tau) { assert (h > 0 && tau > 0); area.x().reborn(h); @@ -93,7 +99,7 @@ protected void prepare(double h, double tau) { } /** - * Save data U(x,t*) for asked time moment t* + * Save data U(x) for asked time moment * * @param fileName file name * @param t time @@ -103,7 +109,8 @@ public void sUt(String fileName, double t) { } /** - * Save data U(x,t_i) for asked time moments [t_i]. So in result we get some set of slices for several time moments + * Save data U(x,t_i) for asked time moments [t_i]. + * So in result we get some set of slices for several time moments * * @param fileName file name * @param t times array @@ -125,7 +132,7 @@ public void sUt(String fileName, double[] t) { } /** - * Save data U(x*,t) for asked space coordinate x* + * Save data U(t) for definite space coordinate * * @param fileName file name * @param x space coordinate @@ -135,7 +142,8 @@ public void sUx(String fileName, double x) { } /** - * Save data U(x_i,t) for asked space coordinates [x_i]. So in result we get some set of slices for several space coordinates + * Save data U(x_i, t) for asked space coordinates [x_i]. + * So in result we get some set of slices for several space coordinates * * @param fileName file name * @param x coordinates array @@ -149,13 +157,19 @@ public void sUx(String fileName, double[] x) { for (int i = 0; i <= area.t().n(); i++) { sb.append(area.t().x(i)); for (var x_i : x) { - sb.append(" ").append(arr.get(i, area.x().i(x_i))); + sb.append(" ").append(solution.get(i, area.x().i(x_i))); } sb.append("\n"); } FileUtil.serialize(fileName, sb); } + /** + * Get slice U(x) for definite time which corresponds to layer `it` in solution matrix + * + * @param it index of time layer in solution matrix + * @return U(x) slice + */ protected Matrix gUt(int it) { int N = solution.getN(); assert (0 <= it && it < N); @@ -169,12 +183,21 @@ protected Matrix gUt(int it) { } /** - * Получение среза U(x, t*) при заданном t* + * Get slice U(x) for definite time + * + * @param t time + * @return U(x) slice */ protected Matrix gUt(double t) { return gUt(area.t().i(t)); } + /** + * Get slice U(t) for definite space coordinate which corresponds to column `ix` in solution matrix + * + * @param ix index of space column in solution matrix + * @return U(t) slice + */ protected Matrix gUx(int ix) { int M = solution.getM(); assert (0 <= ix && ix < M); @@ -188,14 +211,17 @@ protected Matrix gUx(int ix) { } /** - * Получение среза U(x*, t) при заданном x* + * Get slice U(t) for definite space coordinate + * + * @param x space coordinate + * @return U(t) slice */ protected Matrix gUx(double x) { return gUx(area.x().i(x)); } /** - * Метод прогонки + * Tridiagonal matrix algorithm */ protected void progonka(double[] A, double[] B, double[] C, double[] F, double m1, double n1, double m2, double n2, double[] Y) { int N = A.length;