Skip to content

Commit

Permalink
More javadocs
Browse files Browse the repository at this point in the history
  • Loading branch information
andrei-punko committed Oct 23, 2024
1 parent 83a7fa4 commit 41f250b
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 10 deletions.
18 changes: 18 additions & 0 deletions src/main/java/by/andd3dfx/math/Area.java
Original file line number Diff line number Diff line change
@@ -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();
}
Expand Down
46 changes: 36 additions & 10 deletions src/main/java/by/andd3dfx/math/pde/equation/Equation.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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;
Expand Down

0 comments on commit 41f250b

Please sign in to comment.